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> --- .github/workflows/zig-fmt.yml | 2 +- Dockerfile | 2 +- .../css-stress-test/color-looper.emotion.zig | 26 +-- .../css-stress-test/color-looper.zig | 26 +-- build.zig | 9 +- docs/project/development.md | 2 +- misctools/fetch.zig | 2 +- misctools/http_bench.zig | 8 +- src/ArenaAllocator.zig | 12 +- src/__global.zig | 2 +- src/allocators.zig | 16 +- src/analytics/analytics_schema.zig | 2 +- src/analytics/analytics_thread.zig | 10 +- src/api/demo/schema.zig | 46 +++--- src/api/schema.zig | 46 +++--- src/ast/base.zig | 2 +- src/baby_list.zig | 2 +- src/bench/string-handling.zig | 2 +- src/bit_set.zig | 8 +- src/blob.zig | 4 +- src/boringssl.zig | 3 +- src/bun.js/api/JSBundler.zig | 6 +- src/bun.js/api/JSTranspiler.zig | 10 +- src/bun.js/api/bun.zig | 92 +++++------ src/bun.js/api/bun/dns_resolver.zig | 14 +- src/bun.js/api/bun/socket.zig | 18 +-- src/bun.js/api/bun/subprocess.zig | 6 +- src/bun.js/api/ffi.zig | 30 ++-- src/bun.js/api/html_rewriter.zig | 4 +- src/bun.js/api/server.zig | 34 ++-- src/bun.js/base.zig | 68 ++++---- src/bun.js/bindings/FFI.zig | 14 +- src/bun.js/bindings/bindings.zig | 118 +++++++------- src/bun.js/bindings/exports.zig | 44 ++--- src/bun.js/bindings/header-gen.zig | 6 +- src/bun.js/bindings/shimmer.zig | 2 +- src/bun.js/javascript.zig | 20 +-- src/bun.js/javascript_core_c_api.zig | 54 +++---- src/bun.js/module_loader.zig | 2 +- src/bun.js/node/buffer.zig | 2 +- src/bun.js/node/dir_iterator.zig | 54 +++---- src/bun.js/node/node_fs.zig | 34 ++-- src/bun.js/node/node_fs_constant.zig | 6 +- src/bun.js/node/node_os.zig | 6 +- src/bun.js/node/os/constants.zig | 4 +- src/bun.js/node/syscall.zig | 30 ++-- src/bun.js/node/types.zig | 62 +++---- src/bun.js/test/jest.zig | 8 +- src/bun.js/test/pretty_format.zig | 10 +- src/bun.js/webcore.zig | 2 +- src/bun.js/webcore/blob.zig | 20 +-- src/bun.js/webcore/encoding.zig | 57 +++---- src/bun.js/webcore/request.zig | 6 +- src/bun.js/webcore/response.zig | 14 +- src/bun.js/webcore/streams.zig | 43 ++--- src/bun.zig | 50 +++--- src/bun_js.zig | 2 +- src/bundler.zig | 2 +- src/bundler/bundle_v2.zig | 76 +++++---- src/bundler/entry_points.zig | 4 +- src/c.zig | 50 +++--- src/cli.zig | 6 +- src/cli/add_completions.zig | 2 +- src/cli/build_command.zig | 16 +- src/cli/bunx_command.zig | 4 +- src/cli/create_command.zig | 32 ++-- src/cli/init_command.zig | 2 +- src/cli/list-of-yarn-commands.zig | 5 +- src/cli/package_manager_command.zig | 6 +- src/cli/run_command.zig | 2 +- src/cli/upgrade_command.zig | 6 +- src/comptime_string_map.zig | 8 +- src/copy_file.zig | 2 +- src/crash_reporter.zig | 10 +- src/css_scanner.zig | 4 +- src/darwin_c.zig | 14 +- src/defines-table.zig | 4 +- src/defines.zig | 4 +- src/deps/boringssl.translated.zig | 20 +-- src/deps/c_ares.zig | 13 +- src/deps/diffz/DiffMatchPatch.zig | 16 +- src/deps/lol-html.zig | 4 +- src/deps/picohttp.zig | 4 +- src/deps/uws.zig | 44 ++--- src/deps/zig-clap/clap.zig | 2 +- src/deps/zig-datetime/src/datetime.zig | 26 +-- src/env_loader.zig | 36 ++--- src/exact_size_matcher.zig | 11 +- src/fs.zig | 20 +-- src/futex.zig | 8 +- src/hive_array.zig | 6 +- src/http.zig | 37 ++--- src/http/websocket.zig | 8 +- src/http/websocket_http_client.zig | 26 +-- src/http_client_async.zig | 41 ++--- src/import_record.zig | 2 +- src/install/bin.zig | 30 ++-- src/install/dependency.zig | 48 +++--- src/install/install.zig | 86 +++++----- src/install/integrity.zig | 4 +- src/install/lockfile.zig | 67 ++++---- src/install/npm.zig | 52 +++--- src/install/resolution.zig | 2 +- src/install/resolvers/folder_resolver.zig | 6 +- src/install/semver.zig | 24 +-- src/io/io_darwin.zig | 12 +- src/io/io_linux.zig | 60 +++---- src/js_ast.zig | 122 +++++++------- src/js_lexer.zig | 28 ++-- src/js_lexer/identifier.zig | 16 +- src/js_lexer_tables.zig | 7 +- src/js_parser.zig | 107 ++++++------ src/js_printer.zig | 24 +-- src/json_parser.zig | 4 +- src/libarchive/libarchive.zig | 30 ++-- src/linear_fifo.zig | 18 +-- src/linker.zig | 8 +- src/linux_c.zig | 12 +- src/lock.zig | 7 +- src/logger.zig | 16 +- src/main_wasm.zig | 10 +- src/multi_array_list.zig | 35 ++-- src/napi/napi.zig | 21 +-- src/network_thread.zig | 9 +- src/node_fallbacks.zig | 55 +++---- src/node_module_bundle.zig | 20 +-- src/options.zig | 4 +- src/output.zig | 18 +-- src/renamer.zig | 12 +- src/report.zig | 10 +- src/resolver/package_json.zig | 18 +-- src/resolver/resolve_path.zig | 4 +- src/resolver/resolver.zig | 13 +- src/resolver/tsconfig_json.zig | 2 +- src/router.zig | 32 ++-- src/runtime.zig | 2 +- src/sha.zig | 10 +- src/sourcemap/sourcemap.zig | 22 +-- src/standalone_bun.zig | 4 +- src/string_immutable.zig | 179 +++++++++++---------- src/string_joiner.zig | 11 +- src/string_mutable.zig | 4 +- src/string_types.zig | 12 +- src/sync.zig | 10 +- src/tagged_pointer.zig | 18 +-- src/thread_pool.zig | 12 +- src/toml/toml_lexer.zig | 8 +- src/url.zig | 30 ++-- src/util.zig | 2 +- src/walker_skippable.zig | 19 +-- src/watcher.zig | 14 +- src/wyhash.zig | 179 +++++++++++++++++++++ 152 files changed, 1772 insertions(+), 1584 deletions(-) create mode 100644 src/wyhash.zig diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml index 4d65a935c..fa904a07e 100644 --- a/.github/workflows/zig-fmt.yml +++ b/.github/workflows/zig-fmt.yml @@ -1,7 +1,7 @@ name: zig-fmt env: - ZIG_VERSION: 0.11.0-dev.2571+31738de28 + ZIG_VERSION: 0.11.0-dev.3737+9eb008717 on: pull_request: diff --git a/Dockerfile b/Dockerfile index f76cc7811..19d071e93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ARG TRIPLET=${ARCH}-linux-gnu ARG BUILDARCH=amd64 ARG WEBKIT_TAG=may20 ARG ZIG_TAG=jul1 -ARG ZIG_VERSION="0.11.0-dev.2571+31738de28" +ARG ZIG_VERSION="0.11.0-dev.3737+9eb008717" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION} diff --git a/bench/hot-module-reloading/css-stress-test/color-looper.emotion.zig b/bench/hot-module-reloading/css-stress-test/color-looper.emotion.zig index 9b7a83cf3..02ab05c54 100644 --- a/bench/hot-module-reloading/css-stress-test/color-looper.emotion.zig +++ b/bench/hot-module-reloading/css-stress-test/color-looper.emotion.zig @@ -128,27 +128,27 @@ pub fn main() anyerror!void { counters[counter].timestamp = @truncate(u64, @intCast(u128, std.time.nanoTimestamp()) / (std.time.ns_per_ms / 10)); counters[counter].rotate = rotate % 360; counters[counter].percent = std.math.mod(f64, std.math.round(((progress_bar + 1.0) / destination_count) * 1000) / 1000, 100) catch 0; - counters[counter].color_values[0] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][0] + 1) % 256)) * 0.8)); - counters[counter].color_values[1] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][1] + 1) % 256)) * 0.8)); - counters[counter].color_values[2] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][2] + 1) % 256)) * 0.8)); + counters[counter].color_values[0] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[0][0] + 1) % 256)) * 0.8)); + counters[counter].color_values[1] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[0][1] + 1) % 256)) * 0.8)); + counters[counter].color_values[2] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[0][2] + 1) % 256)) * 0.8)); counters[counter].color_values[3] = (colors[0][0] + 1) % 256; counters[counter].color_values[4] = (colors[0][1] + 1) % 256; counters[counter].color_values[5] = (colors[0][2] + 1) % 256; - counters[counter].color_values[6] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][0] + 1) % 256)) * 0.8)); - counters[counter].color_values[7] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][1] + 1) % 256)) * 0.8)); - counters[counter].color_values[8] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][2] + 1) % 256)) * 0.8)); + counters[counter].color_values[6] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[1][0] + 1) % 256)) * 0.8)); + counters[counter].color_values[7] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[1][1] + 1) % 256)) * 0.8)); + counters[counter].color_values[8] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[1][2] + 1) % 256)) * 0.8)); counters[counter].color_values[9] = (colors[1][0] + 1) % 256; counters[counter].color_values[10] = (colors[1][1] + 1) % 256; counters[counter].color_values[11] = (colors[1][2] + 1) % 256; - counters[counter].color_values[12] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][0] + 1) % 256)) * 0.8)); - counters[counter].color_values[13] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][1] + 1) % 256)) * 0.8)); - counters[counter].color_values[14] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][2] + 1) % 256)) * 0.8)); + counters[counter].color_values[12] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[2][0] + 1) % 256)) * 0.8)); + counters[counter].color_values[13] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[2][1] + 1) % 256)) * 0.8)); + counters[counter].color_values[14] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[2][2] + 1) % 256)) * 0.8)); counters[counter].color_values[15] = (colors[2][0] + 1) % 256; counters[counter].color_values[16] = (colors[2][1] + 1) % 256; counters[counter].color_values[17] = (colors[2][2] + 1) % 256; - counters[counter].color_values[18] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][0] + 1) % 256)) * 0.8)); - counters[counter].color_values[19] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][1] + 1) % 256)) * 0.8)); - counters[counter].color_values[20] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][2] + 1) % 256)) * 0.8)); + counters[counter].color_values[18] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[3][0] + 1) % 256)) * 0.8)); + counters[counter].color_values[19] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[3][1] + 1) % 256)) * 0.8)); + counters[counter].color_values[20] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[3][2] + 1) % 256)) * 0.8)); counters[counter].color_values[21] = (colors[3][0] + 1) % 256; counters[counter].color_values[22] = (colors[3][1] + 1) % 256; counters[counter].color_values[23] = (colors[3][2] + 1) % 256; @@ -203,7 +203,7 @@ pub fn main() anyerror!void { _ = try recorder.wait(); all_timestamps[0] = wrote.len; - for (counters) |count, i| { + for (counters, 0..) |count, i| { all_timestamps[i + 1] = count.timestamp; } diff --git a/bench/hot-module-reloading/css-stress-test/color-looper.zig b/bench/hot-module-reloading/css-stress-test/color-looper.zig index 87f08d32f..0509a525b 100644 --- a/bench/hot-module-reloading/css-stress-test/color-looper.zig +++ b/bench/hot-module-reloading/css-stress-test/color-looper.zig @@ -115,27 +115,27 @@ pub fn main() anyerror!void { counters[counter].timestamp = @truncate(u64, @intCast(u128, std.time.nanoTimestamp()) / (std.time.ns_per_ms / 10)); counters[counter].rotate = rotate % 360; counters[counter].percent = std.math.mod(f64, std.math.round(((progress_bar + 1.0) / destination_count) * 1000) / 1000, 100) catch 0; - counters[counter].color_values[0] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][0] + 1) % 256)) * 0.8)); - counters[counter].color_values[1] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][1] + 1) % 256)) * 0.8)); - counters[counter].color_values[2] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][2] + 1) % 256)) * 0.8)); + counters[counter].color_values[0] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[0][0] + 1) % 256)) * 0.8)); + counters[counter].color_values[1] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[0][1] + 1) % 256)) * 0.8)); + counters[counter].color_values[2] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[0][2] + 1) % 256)) * 0.8)); counters[counter].color_values[3] = (colors[0][0] + 1) % 256; counters[counter].color_values[4] = (colors[0][1] + 1) % 256; counters[counter].color_values[5] = (colors[0][2] + 1) % 256; - counters[counter].color_values[6] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][0] + 1) % 256)) * 0.8)); - counters[counter].color_values[7] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][1] + 1) % 256)) * 0.8)); - counters[counter].color_values[8] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][2] + 1) % 256)) * 0.8)); + counters[counter].color_values[6] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[1][0] + 1) % 256)) * 0.8)); + counters[counter].color_values[7] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[1][1] + 1) % 256)) * 0.8)); + counters[counter].color_values[8] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[1][2] + 1) % 256)) * 0.8)); counters[counter].color_values[9] = (colors[1][0] + 1) % 256; counters[counter].color_values[10] = (colors[1][1] + 1) % 256; counters[counter].color_values[11] = (colors[1][2] + 1) % 256; - counters[counter].color_values[12] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][0] + 1) % 256)) * 0.8)); - counters[counter].color_values[13] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][1] + 1) % 256)) * 0.8)); - counters[counter].color_values[14] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][2] + 1) % 256)) * 0.8)); + counters[counter].color_values[12] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[2][0] + 1) % 256)) * 0.8)); + counters[counter].color_values[13] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[2][1] + 1) % 256)) * 0.8)); + counters[counter].color_values[14] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[2][2] + 1) % 256)) * 0.8)); counters[counter].color_values[15] = (colors[2][0] + 1) % 256; counters[counter].color_values[16] = (colors[2][1] + 1) % 256; counters[counter].color_values[17] = (colors[2][2] + 1) % 256; - counters[counter].color_values[18] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][0] + 1) % 256)) * 0.8)); - counters[counter].color_values[19] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][1] + 1) % 256)) * 0.8)); - counters[counter].color_values[20] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][2] + 1) % 256)) * 0.8)); + counters[counter].color_values[18] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[3][0] + 1) % 256)) * 0.8)); + counters[counter].color_values[19] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[3][1] + 1) % 256)) * 0.8)); + counters[counter].color_values[20] = @intFromFloat(u32, std.math.round(@floatFromInt(f64, ((colors[3][2] + 1) % 256)) * 0.8)); counters[counter].color_values[21] = (colors[3][0] + 1) % 256; counters[counter].color_values[22] = (colors[3][1] + 1) % 256; counters[counter].color_values[23] = (colors[3][2] + 1) % 256; @@ -190,7 +190,7 @@ pub fn main() anyerror!void { _ = try recorder.wait(); all_timestamps[0] = wrote.len; - for (counters) |count, i| { + for (counters, 0..) |count, i| { all_timestamps[i + 1] = count.timestamp; } diff --git a/build.zig b/build.zig index 72588f6f4..8993070b0 100644 --- a/build.zig +++ b/build.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const Wyhash = @import("./src/wyhash.zig").Wyhash; fn moduleSource(comptime out: []const u8) FileSource { if (comptime std.fs.path.dirname(@src().file)) |base| { @@ -76,13 +77,13 @@ const BunBuildOptions = struct { pub fn updateRuntime(this: *BunBuildOptions) anyerror!void { var runtime_out_file = try std.fs.cwd().openFile("src/runtime.out.js", .{ .mode = .read_only }); - const runtime_hash = std.hash.Wyhash.hash( + const runtime_hash = Wyhash.hash( 0, try runtime_out_file.readToEndAlloc(std.heap.page_allocator, try runtime_out_file.getEndPos()), ); this.runtime_js_version = runtime_hash; var fallback_out_file = try std.fs.cwd().openFile("src/fallback.out.js", .{ .mode = .read_only }); - const fallback_hash = std.hash.Wyhash.hash( + const fallback_hash = Wyhash.hash( 0, try fallback_out_file.readToEndAlloc(std.heap.page_allocator, try fallback_out_file.getEndPos()), ); @@ -192,12 +193,12 @@ pub fn build(b: *Build) !void { else "root.zig"; - const min_version: std.builtin.Version = if (target.getOsTag() != .freestanding) + const min_version: std.SemanticVersion = if (target.getOsTag() != .freestanding) target.getOsVersionMin().semver else .{ .major = 0, .minor = 0, .patch = 0 }; - const max_version: std.builtin.Version = if (target.getOsTag() != .freestanding) + const max_version: std.SemanticVersion = if (target.getOsTag() != .freestanding) target.getOsVersionMax().semver else .{ .major = 0, .minor = 0, .patch = 0 }; diff --git a/docs/project/development.md b/docs/project/development.md index 92a414c5f..d21641aff 100644 --- a/docs/project/development.md +++ b/docs/project/development.md @@ -102,7 +102,7 @@ Zig can be installed either with our npm package [`@oven/zig`](https://www.npmjs ```bash $ bun install -g @oven/zig -$ zigup 0.11.0-dev.2777+b95cdf0ae +$ zigup 0.11.0-dev.3737+9eb008717 ``` ## Building diff --git a/misctools/fetch.zig b/misctools/fetch.zig index 38a948f52..5ac701250 100644 --- a/misctools/fetch.zig +++ b/misctools/fetch.zig @@ -91,7 +91,7 @@ pub const Arguments = struct { var raw_args: std.ArrayListUnmanaged(string) = undefined; if (positionals.len > 0) { - raw_args = .{ .capacity = positionals.len, .items = @intToPtr([*][]const u8, @ptrToInt(positionals.ptr))[0..positionals.len] }; + raw_args = .{ .capacity = positionals.len, .items = @ptrFromInt([*][]const u8, @intFromPtr(positionals.ptr))[0..positionals.len] }; } else { raw_args = .{}; } diff --git a/misctools/http_bench.zig b/misctools/http_bench.zig index 4075daf49..5847399a1 100644 --- a/misctools/http_bench.zig +++ b/misctools/http_bench.zig @@ -95,7 +95,7 @@ pub const Arguments = struct { var raw_args: std.ArrayListUnmanaged(string) = undefined; if (positionals.len > 0) { - raw_args = .{ .capacity = positionals.len, .items = @intToPtr([*][]const u8, @ptrToInt(positionals.ptr))[0..positionals.len] }; + raw_args = .{ .capacity = positionals.len, .items = @ptrFromInt([*][]const u8, @intFromPtr(positionals.ptr))[0..positionals.len] }; } else { raw_args = .{}; } @@ -244,7 +244,7 @@ pub fn main() anyerror!void { const http = channel.readItem() catch continue; read_count += 1; - Output.printElapsed(@floatCast(f64, @intToFloat(f128, http.elapsed) / std.time.ns_per_ms)); + Output.printElapsed(@floatCast(f64, @floatFromInt(f128, http.elapsed) / std.time.ns_per_ms)); if (http.response) |resp| { if (resp.status_code == 200) { success_count += 1; @@ -270,7 +270,7 @@ pub fn main() anyerror!void { http.client.url.href, http.response_buffer.list.items.len, }); - Output.printElapsed(@floatCast(f64, @intToFloat(f128, http.gzip_elapsed) / std.time.ns_per_ms)); + Output.printElapsed(@floatCast(f64, @floatFromInt(f128, http.gzip_elapsed) / std.time.ns_per_ms)); Output.prettyError(" gzip)\n", .{}); } else { Output.prettyError(" {s} - {s} ({d} bytes)\n", .{ @@ -295,7 +295,7 @@ pub fn main() anyerror!void { fail_count, }); - Output.printElapsed(@floatCast(f64, @intToFloat(f128, timer.read()) / std.time.ns_per_ms)); + Output.printElapsed(@floatCast(f64, @floatFromInt(f128, timer.read()) / std.time.ns_per_ms)); Output.prettyErrorln(" {d} requests", .{ read_count, }); diff --git a/src/ArenaAllocator.zig b/src/ArenaAllocator.zig index 31e0cf5b9..999ea4142 100644 --- a/src/ArenaAllocator.zig +++ b/src/ArenaAllocator.zig @@ -111,7 +111,7 @@ pub const ArenaAllocator = struct { // value. const requested_capacity = switch (mode) { .retain_capacity => self.queryCapacity(), - .retain_with_limit => |limit| std.math.min(limit, self.queryCapacity()), + .retain_with_limit => |limit| @min(limit, self.queryCapacity()), .free_all => 0, }; if (requested_capacity == 0) { @@ -186,8 +186,8 @@ pub const ArenaAllocator = struct { while (true) { const cur_alloc_buf = @ptrCast([*]u8, cur_node)[0..cur_node.data]; const cur_buf = cur_alloc_buf[@sizeOf(BufNode)..]; - const addr = @ptrToInt(cur_buf.ptr) + self.state.end_index; - const adjusted_addr = mem.alignForward(addr, ptr_align); + const addr = @intFromPtr(cur_buf.ptr) + self.state.end_index; + const adjusted_addr = mem.alignForward(usize, addr, ptr_align); const adjusted_index = self.state.end_index + (adjusted_addr - addr); const new_end_index = adjusted_index + n; @@ -215,7 +215,7 @@ pub const ArenaAllocator = struct { const cur_node = self.state.buffer_list.first orelse return false; const cur_buf = @ptrCast([*]u8, cur_node)[@sizeOf(BufNode)..cur_node.data]; - if (@ptrToInt(cur_buf.ptr) + self.state.end_index != @ptrToInt(buf.ptr) + buf.len) { + if (@intFromPtr(cur_buf.ptr) + self.state.end_index != @intFromPtr(buf.ptr) + buf.len) { // It's not the most recent allocation, so it cannot be expanded, // but it's fine if they want to make it smaller. return new_len <= buf.len; @@ -241,7 +241,7 @@ pub const ArenaAllocator = struct { const cur_node = self.state.buffer_list.first orelse return; const cur_buf = @ptrCast([*]u8, cur_node)[@sizeOf(BufNode)..cur_node.data]; - if (@ptrToInt(cur_buf.ptr) + self.state.end_index == @ptrToInt(buf.ptr) + buf.len) { + if (@intFromPtr(cur_buf.ptr) + self.state.end_index == @intFromPtr(buf.ptr) + buf.len) { self.state.end_index -= buf.len; } } @@ -263,7 +263,7 @@ test "ArenaAllocator (reset with preheating)" { const size = random.intRangeAtMost(usize, 16, 256); const alignment = 32; const slice = try arena_allocator.allocator().alignedAlloc(u8, alignment, size); - try std.testing.expect(std.mem.isAligned(@ptrToInt(slice.ptr), alignment)); + try std.testing.expect(std.mem.isAligned(@intFromPtr(slice.ptr), alignment)); try std.testing.expectEqual(size, slice.len); alloced_bytes += slice.len; } diff --git a/src/__global.zig b/src/__global.zig index e426cd595..ed0fa08f5 100644 --- a/src/__global.zig +++ b/src/__global.zig @@ -55,7 +55,7 @@ pub const version: @import("./install/semver.zig").Version = .{ pub fn setThreadName(name: StringTypes.stringZ) void { if (Environment.isLinux) { - _ = std.os.prctl(.SET_NAME, .{@ptrToInt(name.ptr)}) catch 0; + _ = std.os.prctl(.SET_NAME, .{@intFromPtr(name.ptr)}) catch 0; } else if (Environment.isMac) { _ = std.c.pthread_setname_np(name); } diff --git a/src/allocators.zig b/src/allocators.zig index 2827214af..1d3b30c0b 100644 --- a/src/allocators.zig +++ b/src/allocators.zig @@ -2,19 +2,18 @@ const std = @import("std"); const FeatureFlags = @import("./feature_flags.zig"); const Environment = @import("./env.zig"); -const Wyhash = std.hash.Wyhash; const FixedBufferAllocator = std.heap.FixedBufferAllocator; const constStrToU8 = @import("root").bun.constStrToU8; const bun = @import("root").bun; pub fn isSliceInBuffer(slice: anytype, buffer: anytype) bool { - return (@ptrToInt(&buffer) <= @ptrToInt(slice.ptr) and (@ptrToInt(slice.ptr) + slice.len) <= (@ptrToInt(buffer) + buffer.len)); + return (@intFromPtr(&buffer) <= @intFromPtr(slice.ptr) and (@intFromPtr(slice.ptr) + slice.len) <= (@intFromPtr(buffer) + buffer.len)); } pub fn sliceRange(slice: []const u8, buffer: []const u8) ?[2]u32 { - return if (@ptrToInt(buffer.ptr) <= @ptrToInt(slice.ptr) and - (@ptrToInt(slice.ptr) + slice.len) <= (@ptrToInt(buffer.ptr) + buffer.len)) + return if (@intFromPtr(buffer.ptr) <= @intFromPtr(slice.ptr) and + (@intFromPtr(slice.ptr) + slice.len) <= (@intFromPtr(buffer.ptr) + buffer.len)) [2]u32{ - @truncate(u32, @ptrToInt(slice.ptr) - @ptrToInt(buffer.ptr)), + @truncate(u32, @intFromPtr(slice.ptr) - @intFromPtr(buffer.ptr)), @truncate(u32, slice.len), } else @@ -53,7 +52,6 @@ pub const Result = struct { return r.index >= count; } }; -const Seed = 999; pub const NotFound = IndexType{ .index = std.math.maxInt(u31), @@ -488,7 +486,7 @@ pub fn BSSMap(comptime ValueType: type, comptime count: anytype, comptime store_ pub fn getOrPut(self: *Self, denormalized_key: []const u8) !Result { const key = if (comptime remove_trailing_slashes) std.mem.trimRight(u8, denormalized_key, "/") else denormalized_key; - const _key = Wyhash.hash(Seed, key); + const _key = bun.hash(key); self.mutex.lock(); defer self.mutex.unlock(); @@ -516,7 +514,7 @@ pub fn BSSMap(comptime ValueType: type, comptime count: anytype, comptime store_ pub fn get(self: *Self, denormalized_key: []const u8) ?*ValueType { const key = if (comptime remove_trailing_slashes) std.mem.trimRight(u8, denormalized_key, "/") else denormalized_key; - const _key = Wyhash.hash(Seed, key); + const _key = bun.hash(key); self.mutex.lock(); defer self.mutex.unlock(); const index = self.index.get(_key) orelse return null; @@ -577,7 +575,7 @@ pub fn BSSMap(comptime ValueType: type, comptime count: anytype, comptime store_ const key = if (comptime remove_trailing_slashes) std.mem.trimRight(u8, denormalized_key, "/") else denormalized_key; - const _key = Wyhash.hash(Seed, key); + const _key = bun.hash(key); _ = self.index.remove(_key); // const index = self.index.get(_key) orelse return; // switch (index) { diff --git a/src/analytics/analytics_schema.zig b/src/analytics/analytics_schema.zig index 825735331..5332a4837 100644 --- a/src/analytics/analytics_schema.zig +++ b/src/analytics/analytics_schema.zig @@ -201,7 +201,7 @@ pub fn Writer(comptime WritableStream: type) type { } pub inline fn writeEnum(this: *Self, val: anytype) !void { - try this.writeInt(@enumToInt(val)); + try this.writeInt(@intFromEnum(val)); } pub fn writeValue(this: *Self, comptime SliceType: type, slice: SliceType) !void { diff --git a/src/analytics/analytics_thread.zig b/src/analytics/analytics_thread.zig index b6039d3a7..998f5cfc2 100644 --- a/src/analytics/analytics_thread.zig +++ b/src/analytics/analytics_thread.zig @@ -261,7 +261,7 @@ pub const GenerateHeader = struct { pub const GeneratePlatform = struct { var osversion_name: [32]u8 = undefined; pub fn forMac() Analytics.Platform { - @memset(&osversion_name, 0, osversion_name.len); + @memset(&osversion_name, 0); var platform = Analytics.Platform{ .os = Analytics.OperatingSystem.macos, .version = &[_]u8{}, .arch = platform_arch }; var len = osversion_name.len - 1; @@ -340,7 +340,7 @@ pub const GenerateHeader = struct { offset = std.mem.indexOfScalar(u8, out, '"') orelse return Analytics.Uint64{}; out = out[0..offset]; - const hash = std.hash.Wyhash.hash(0, std.mem.trim(u8, out, "\n\r ")); + const hash = bun.hash(std.mem.trim(u8, out, "\n\r ")); var hash_bytes = std.mem.asBytes(&hash); return Analytics.Uint64{ .first = std.mem.readIntNative(u32, hash_bytes[0..4]), @@ -357,7 +357,7 @@ pub const GenerateHeader = struct { defer file.close(); var read_count = try file.read(&linux_machine_id); - const hash = std.hash.Wyhash.hash(0, std.mem.trim(u8, linux_machine_id[0..read_count], "\n\r ")); + const hash = bun.hash(std.mem.trim(u8, linux_machine_id[0..read_count], "\n\r ")); var hash_bytes = std.mem.asBytes(&hash); return Analytics.Uint64{ .first = std.mem.readIntNative(u32, hash_bytes[0..4]), @@ -540,8 +540,8 @@ pub const EventList = struct { } @atomicStore(bool, &is_stuck, retry_remaining == 0, .Release); - stuck_count += @intCast(u8, @boolToInt(retry_remaining == 0)); - stuck_count *= @intCast(u8, @boolToInt(retry_remaining == 0)); + stuck_count += @intCast(u8, @intFromBool(retry_remaining == 0)); + stuck_count *= @intCast(u8, @intFromBool(retry_remaining == 0)); disabled = disabled or stuck_count > 4; this.in_buffer.reset(); diff --git a/src/api/demo/schema.zig b/src/api/demo/schema.zig index 748422ed8..d57a5c725 100644 --- a/src/api/demo/schema.zig +++ b/src/api/demo/schema.zig @@ -201,7 +201,7 @@ pub fn Writer(comptime WritableStream: type) type { } pub inline fn writeEnum(this: *Self, val: anytype) !void { - try this.writeInt(@enumToInt(val)); + try this.writeInt(@intFromEnum(val)); } pub fn writeValue(this: *Self, comptime SliceType: type, slice: SliceType) !void { @@ -881,9 +881,9 @@ pub const Api = struct { try writer.writeValue(@TypeOf(this.factory), this.factory); try writer.writeEnum(this.runtime); try writer.writeValue(@TypeOf(this.fragment), this.fragment); - try writer.writeInt(@as(u8, @boolToInt(this.development))); + try writer.writeInt(@as(u8, @intFromBool(this.development))); try writer.writeValue(@TypeOf(this.import_source), this.import_source); - try writer.writeInt(@as(u8, @boolToInt(this.react_fast_refresh))); + try writer.writeInt(@as(u8, @intFromBool(this.react_fast_refresh))); } }; @@ -1151,7 +1151,7 @@ pub const Api = struct { pub fn encode(this: *const @This(), writer: anytype) anyerror!void { try writer.writeEnum(this.kind); try writer.writeValue(@TypeOf(this.path), this.path); - try writer.writeInt(@as(u8, @boolToInt(this.dynamic))); + try writer.writeInt(@as(u8, @intFromBool(this.dynamic))); } }; @@ -1390,7 +1390,7 @@ pub const Api = struct { } if (this.development) |development| { try writer.writeFieldID(5); - try writer.writeInt(@as(u8, @boolToInt(development))); + try writer.writeInt(@as(u8, @intFromBool(development))); } if (this.client_css_in_js) |client_css_in_js| { try writer.writeFieldID(6); @@ -1564,7 +1564,7 @@ pub const Api = struct { pub fn encode(this: *const @This(), writer: anytype) anyerror!void { try writer.writeValue(@TypeOf(this.package), this.package); try writer.writeValue(@TypeOf(this.display_name), this.display_name); - try writer.writeInt(@as(u8, @boolToInt(this.development))); + try writer.writeInt(@as(u8, @intFromBool(this.development))); try writer.writeValue(@TypeOf(this.entry_points), this.entry_points); try writer.writeEnum(this.client_css_in_js); try writer.writeValue(@TypeOf(this.override_modules), this.override_modules); @@ -1866,7 +1866,7 @@ pub const Api = struct { } if (this.preserve_symlinks) |preserve_symlinks| { try writer.writeFieldID(7); - try writer.writeInt(@as(u8, @boolToInt(preserve_symlinks))); + try writer.writeInt(@as(u8, @intFromBool(preserve_symlinks))); } if (this.entry_points) |entry_points| { try writer.writeFieldID(8); @@ -1874,7 +1874,7 @@ pub const Api = struct { } if (this.write) |write| { try writer.writeFieldID(9); - try writer.writeInt(@as(u8, @boolToInt(write))); + try writer.writeInt(@as(u8, @intFromBool(write))); } if (this.inject) |inject| { try writer.writeFieldID(10); @@ -1902,7 +1902,7 @@ pub const Api = struct { } if (this.serve) |serve| { try writer.writeFieldID(16); - try writer.writeInt(@as(u8, @boolToInt(serve))); + try writer.writeInt(@as(u8, @intFromBool(serve))); } if (this.extension_order) |extension_order| { try writer.writeFieldID(17); @@ -1910,7 +1910,7 @@ pub const Api = struct { } if (this.generate_node_module_bundle) |generate_node_module_bundle| { try writer.writeFieldID(18); - try writer.writeInt(@as(u8, @boolToInt(generate_node_module_bundle))); + try writer.writeInt(@as(u8, @intFromBool(generate_node_module_bundle))); } if (this.node_modules_bundle_path) |node_modules_bundle_path| { try writer.writeFieldID(19); @@ -1930,11 +1930,11 @@ pub const Api = struct { } if (this.no_summary) |no_summary| { try writer.writeFieldID(23); - try writer.writeInt(@as(u8, @boolToInt(no_summary))); + try writer.writeInt(@as(u8, @intFromBool(no_summary))); } if (this.disable_hmr) |disable_hmr| { try writer.writeFieldID(24); - try writer.writeInt(@as(u8, @boolToInt(disable_hmr))); + try writer.writeInt(@as(u8, @intFromBool(disable_hmr))); } if (this.port) |port| { try writer.writeFieldID(25); @@ -2259,7 +2259,7 @@ pub const Api = struct { } if (this.build) |build| { try writer.writeFieldID(2); - try writer.writeInt(@as(u8, @boolToInt(build))); + try writer.writeInt(@as(u8, @intFromBool(build))); } try writer.endMessage(); } @@ -2822,35 +2822,35 @@ pub const Api = struct { } if (this.dry_run) |dry_run| { try writer.writeFieldID(6); - try writer.writeInt(@as(u8, @boolToInt(dry_run))); + try writer.writeInt(@as(u8, @intFromBool(dry_run))); } if (this.force) |force| { try writer.writeFieldID(7); - try writer.writeInt(@as(u8, @boolToInt(force))); + try writer.writeInt(@as(u8, @intFromBool(force))); } if (this.save_dev) |save_dev| { try writer.writeFieldID(8); - try writer.writeInt(@as(u8, @boolToInt(save_dev))); + try writer.writeInt(@as(u8, @intFromBool(save_dev))); } if (this.save_optional) |save_optional| { try writer.writeFieldID(9); - try writer.writeInt(@as(u8, @boolToInt(save_optional))); + try writer.writeInt(@as(u8, @intFromBool(save_optional))); } if (this.save_peer) |save_peer| { try writer.writeFieldID(10); - try writer.writeInt(@as(u8, @boolToInt(save_peer))); + try writer.writeInt(@as(u8, @intFromBool(save_peer))); } if (this.save_lockfile) |save_lockfile| { try writer.writeFieldID(11); - try writer.writeInt(@as(u8, @boolToInt(save_lockfile))); + try writer.writeInt(@as(u8, @intFromBool(save_lockfile))); } if (this.production) |production| { try writer.writeFieldID(12); - try writer.writeInt(@as(u8, @boolToInt(production))); + try writer.writeInt(@as(u8, @intFromBool(production))); } if (this.save_yarn_lockfile) |save_yarn_lockfile| { try writer.writeFieldID(13); - try writer.writeInt(@as(u8, @boolToInt(save_yarn_lockfile))); + try writer.writeInt(@as(u8, @intFromBool(save_yarn_lockfile))); } if (this.native_bin_links) |native_bin_links| { try writer.writeFieldID(14); @@ -2858,11 +2858,11 @@ pub const Api = struct { } if (this.disable_cache) |disable_cache| { try writer.writeFieldID(15); - try writer.writeInt(@as(u8, @boolToInt(disable_cache))); + try writer.writeInt(@as(u8, @intFromBool(disable_cache))); } if (this.disable_manifest_cache) |disable_manifest_cache| { try writer.writeFieldID(16); - try writer.writeInt(@as(u8, @boolToInt(disable_manifest_cache))); + try writer.writeInt(@as(u8, @intFromBool(disable_manifest_cache))); } if (this.global_dir) |global_dir| { try writer.writeFieldID(17); diff --git a/src/api/schema.zig b/src/api/schema.zig index 227d1296b..1012e6051 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -201,7 +201,7 @@ pub fn Writer(comptime WritableStream: type) type { } pub inline fn writeEnum(this: *Self, val: anytype) !void { - try this.writeInt(@enumToInt(val)); + try this.writeInt(@intFromEnum(val)); } pub fn writeValue(this: *Self, comptime SliceType: type, slice: SliceType) !void { @@ -896,9 +896,9 @@ pub const Api = struct { try writer.writeValue(@TypeOf(this.factory), this.factory); try writer.writeEnum(this.runtime); try writer.writeValue(@TypeOf(this.fragment), this.fragment); - try writer.writeInt(@as(u8, @boolToInt(this.development))); + try writer.writeInt(@as(u8, @intFromBool(this.development))); try writer.writeValue(@TypeOf(this.import_source), this.import_source); - try writer.writeInt(@as(u8, @boolToInt(this.react_fast_refresh))); + try writer.writeInt(@as(u8, @intFromBool(this.react_fast_refresh))); } }; @@ -1166,7 +1166,7 @@ pub const Api = struct { pub fn encode(this: *const @This(), writer: anytype) anyerror!void { try writer.writeEnum(this.kind); try writer.writeValue(@TypeOf(this.path), this.path); - try writer.writeInt(@as(u8, @boolToInt(this.dynamic))); + try writer.writeInt(@as(u8, @intFromBool(this.dynamic))); } }; @@ -1405,7 +1405,7 @@ pub const Api = struct { } if (this.development) |development| { try writer.writeFieldID(5); - try writer.writeInt(@as(u8, @boolToInt(development))); + try writer.writeInt(@as(u8, @intFromBool(development))); } if (this.client_css_in_js) |client_css_in_js| { try writer.writeFieldID(6); @@ -1579,7 +1579,7 @@ pub const Api = struct { pub fn encode(this: *const @This(), writer: anytype) anyerror!void { try writer.writeValue(@TypeOf(this.package), this.package); try writer.writeValue(@TypeOf(this.display_name), this.display_name); - try writer.writeInt(@as(u8, @boolToInt(this.development))); + try writer.writeInt(@as(u8, @intFromBool(this.development))); try writer.writeValue(@TypeOf(this.entry_points), this.entry_points); try writer.writeEnum(this.client_css_in_js); try writer.writeValue(@TypeOf(this.override_modules), this.override_modules); @@ -1887,7 +1887,7 @@ pub const Api = struct { } if (this.preserve_symlinks) |preserve_symlinks| { try writer.writeFieldID(7); - try writer.writeInt(@as(u8, @boolToInt(preserve_symlinks))); + try writer.writeInt(@as(u8, @intFromBool(preserve_symlinks))); } if (this.entry_points) |entry_points| { try writer.writeFieldID(8); @@ -1895,7 +1895,7 @@ pub const Api = struct { } if (this.write) |write| { try writer.writeFieldID(9); - try writer.writeInt(@as(u8, @boolToInt(write))); + try writer.writeInt(@as(u8, @intFromBool(write))); } if (this.inject) |inject| { try writer.writeFieldID(10); @@ -1923,7 +1923,7 @@ pub const Api = struct { } if (this.serve) |serve| { try writer.writeFieldID(16); - try writer.writeInt(@as(u8, @boolToInt(serve))); + try writer.writeInt(@as(u8, @intFromBool(serve))); } if (this.extension_order) |extension_order| { try writer.writeFieldID(17); @@ -1931,7 +1931,7 @@ pub const Api = struct { } if (this.generate_node_module_bundle) |generate_node_module_bundle| { try writer.writeFieldID(18); - try writer.writeInt(@as(u8, @boolToInt(generate_node_module_bundle))); + try writer.writeInt(@as(u8, @intFromBool(generate_node_module_bundle))); } if (this.node_modules_bundle_path) |node_modules_bundle_path| { try writer.writeFieldID(19); @@ -1951,11 +1951,11 @@ pub const Api = struct { } if (this.no_summary) |no_summary| { try writer.writeFieldID(23); - try writer.writeInt(@as(u8, @boolToInt(no_summary))); + try writer.writeInt(@as(u8, @intFromBool(no_summary))); } if (this.disable_hmr) |disable_hmr| { try writer.writeFieldID(24); - try writer.writeInt(@as(u8, @boolToInt(disable_hmr))); + try writer.writeInt(@as(u8, @intFromBool(disable_hmr))); } if (this.port) |port| { try writer.writeFieldID(25); @@ -2427,7 +2427,7 @@ pub const Api = struct { } if (this.build) |build| { try writer.writeFieldID(2); - try writer.writeInt(@as(u8, @boolToInt(build))); + try writer.writeInt(@as(u8, @intFromBool(build))); } try writer.endMessage(); } @@ -2995,35 +2995,35 @@ pub const Api = struct { } if (this.dry_run) |dry_run| { try writer.writeFieldID(6); - try writer.writeInt(@as(u8, @boolToInt(dry_run))); + try writer.writeInt(@as(u8, @intFromBool(dry_run))); } if (this.force) |force| { try writer.writeFieldID(7); - try writer.writeInt(@as(u8, @boolToInt(force))); + try writer.writeInt(@as(u8, @intFromBool(force))); } if (this.save_dev) |save_dev| { try writer.writeFieldID(8); - try writer.writeInt(@as(u8, @boolToInt(save_dev))); + try writer.writeInt(@as(u8, @intFromBool(save_dev))); } if (this.save_optional) |save_optional| { try writer.writeFieldID(9); - try writer.writeInt(@as(u8, @boolToInt(save_optional))); + try writer.writeInt(@as(u8, @intFromBool(save_optional))); } if (this.save_peer) |save_peer| { try writer.writeFieldID(10); - try writer.writeInt(@as(u8, @boolToInt(save_peer))); + try writer.writeInt(@as(u8, @intFromBool(save_peer))); } if (this.save_lockfile) |save_lockfile| { try writer.writeFieldID(11); - try writer.writeInt(@as(u8, @boolToInt(save_lockfile))); + try writer.writeInt(@as(u8, @intFromBool(save_lockfile))); } if (this.production) |production| { try writer.writeFieldID(12); - try writer.writeInt(@as(u8, @boolToInt(production))); + try writer.writeInt(@as(u8, @intFromBool(production))); } if (this.save_yarn_lockfile) |save_yarn_lockfile| { try writer.writeFieldID(13); - try writer.writeInt(@as(u8, @boolToInt(save_yarn_lockfile))); + try writer.writeInt(@as(u8, @intFromBool(save_yarn_lockfile))); } if (this.native_bin_links) |native_bin_links| { try writer.writeFieldID(14); @@ -3031,11 +3031,11 @@ pub const Api = struct { } if (this.disable_cache) |disable_cache| { try writer.writeFieldID(15); - try writer.writeInt(@as(u8, @boolToInt(disable_cache))); + try writer.writeInt(@as(u8, @intFromBool(disable_cache))); } if (this.disable_manifest_cache) |disable_manifest_cache| { try writer.writeFieldID(16); - try writer.writeInt(@as(u8, @boolToInt(disable_manifest_cache))); + try writer.writeInt(@as(u8, @intFromBool(disable_manifest_cache))); } if (this.global_dir) |global_dir| { try writer.writeFieldID(17); diff --git a/src/ast/base.zig b/src/ast/base.zig index d3e510ae6..ae544f8be 100644 --- a/src/ast/base.zig +++ b/src/ast/base.zig @@ -275,7 +275,7 @@ pub const Ref = packed struct(u64) { } pub inline fn hash64(key: Ref) u64 { - return std.hash.Wyhash.hash(0, &@bitCast([8]u8, key.asU64())); + return bun.hash(&@bitCast([8]u8, key.asU64())); } pub fn eql(ref: Ref, b: Ref) bool { diff --git a/src/baby_list.zig b/src/baby_list.zig index 5227261e8..01ec819ec 100644 --- a/src/baby_list.zig +++ b/src/baby_list.zig @@ -30,7 +30,7 @@ pub fn BabyList(comptime Type: type) type { } pub fn contains(this: @This(), item: []const Type) bool { - return this.len > 0 and @ptrToInt(item.ptr) >= @ptrToInt(this.ptr) and @ptrToInt(item.ptr) < @ptrToInt(this.ptr) + this.len; + return this.len > 0 and @intFromPtr(item.ptr) >= @intFromPtr(this.ptr) and @intFromPtr(item.ptr) < @intFromPtr(this.ptr) + this.len; } pub inline fn initConst(items: []const Type) ListType { diff --git a/src/bench/string-handling.zig b/src/bench/string-handling.zig index f9bee87e7..23f558eb8 100644 --- a/src/bench/string-handling.zig +++ b/src/bench/string-handling.zig @@ -34,7 +34,7 @@ pub fn main() anyerror!void { var i: usize = 0; while (j < amount) : (j += 1) { i = 0; - @memcpy(duped.ptr, contents.ptr, contents.len); + @memcpy(duped[0..contents.len], contents); } if (index == std.math.maxInt(usize)) { diff --git a/src/bit_set.zig b/src/bit_set.zig index 5f18eb32b..d40794473 100644 --- a/src/bit_set.zig +++ b/src/bit_set.zig @@ -308,7 +308,7 @@ pub fn IntegerBitSet(comptime size: u16) type { } fn boolMaskBit(index: usize, value: bool) MaskInt { if (MaskInt == u0) return 0; - return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); } }; } @@ -653,7 +653,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { return index >> @bitSizeOf(ShiftInt); } inline fn boolMaskBit(index: usize, value: bool) MaskInt { - return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); } }; } @@ -751,7 +751,7 @@ pub const DynamicBitSetUnmanaged = struct { // fill in any new masks if (new_masks > old_masks) { const fill_value = std.math.boolMask(MaskInt, fill); - std.mem.set(MaskInt, self.masks[old_masks..new_masks], fill_value); + @memset(self.masks[old_masks..new_masks], fill_value); } } @@ -1088,7 +1088,7 @@ pub const DynamicBitSetUnmanaged = struct { return index >> @bitSizeOf(ShiftInt); } fn boolMaskBit(index: usize, value: bool) MaskInt { - return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index); + return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index); } fn numMasks(bit_length: usize) usize { return (bit_length + (@bitSizeOf(MaskInt) - 1)) / @bitSizeOf(MaskInt); diff --git a/src/blob.zig b/src/blob.zig index a4a187530..96a6c7783 100644 --- a/src/blob.zig +++ b/src/blob.zig @@ -42,14 +42,14 @@ pub const Map = struct { pub fn get(this: *Map, key: string) ?Blob { this.lock.lock(); defer this.lock.unlock(); - return this.map.get(std.hash.Wyhash.hash(0, key)); + return this.map.get(bun.hash(key)); } pub fn put(this: *Map, key: string, blob: Blob) !void { this.lock.lock(); defer this.lock.unlock(); - return try this.map.put(std.hash.Wyhash.hash(0, key), blob); + return try this.map.put(bun.hash(key), blob); } pub fn reset(this: *Map) !void { diff --git a/src/boringssl.zig b/src/boringssl.zig index b2ab55229..cdcd24577 100644 --- a/src/boringssl.zig +++ b/src/boringssl.zig @@ -65,7 +65,8 @@ export fn OPENSSL_memory_alloc(size: usize) ?*anyopaque { // BoringSSL always expects memory to be zero'd export fn OPENSSL_memory_free(ptr: *anyopaque) void { - @memset(@ptrCast([*]u8, ptr), 0, bun.Mimalloc.mi_usable_size(ptr)); + const len = bun.Mimalloc.mi_usable_size(ptr); + @memset(@ptrCast([*]u8, ptr)[0..len], 0); bun.Mimalloc.mi_free(ptr); } diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig index 8e85f1190..e3b540da1 100644 --- a/src/bun.js/api/JSBundler.zig +++ b/src/bun.js/api/JSBundler.zig @@ -844,7 +844,7 @@ pub const JSBundler = struct { this.value = .{ .success = .{ - .loader = @intToEnum(options.Loader, @intCast(u8, loader_as_int.to(i32))), + .loader = @enumFromInt(options.Loader, @intCast(u8, loader_as_int.to(i32))), .source_code = source_code, }, }; @@ -928,7 +928,7 @@ pub const JSBundler = struct { else ZigString.fromUTF8(namespace); const path_string = ZigString.fromUTF8(path); - JSBundlerPlugin__matchOnLoad(globalThis, this, &namespace_string, &path_string, context, @enumToInt(default_loader)); + JSBundlerPlugin__matchOnLoad(globalThis, this, &namespace_string, &path_string, context, @intFromEnum(default_loader)); } pub fn matchOnResolve( @@ -949,7 +949,7 @@ pub const JSBundler = struct { ZigString.fromUTF8(namespace); const path_string = ZigString.fromUTF8(path); const importer_string = ZigString.fromUTF8(importer); - JSBundlerPlugin__matchOnResolve(globalThis, this, &namespace_string, &path_string, &importer_string, context, @enumToInt(import_record_kind)); + JSBundlerPlugin__matchOnResolve(globalThis, this, &namespace_string, &path_string, &importer_string, context, @intFromEnum(import_record_kind)); } pub fn addPlugin( diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig index a1e1cfa36..308738abf 100644 --- a/src/bun.js/api/JSTranspiler.zig +++ b/src/bun.js/api/JSTranspiler.zig @@ -85,7 +85,7 @@ const TranspilerOptions = struct { // This is going to be hard to not leak pub const TransformTask = struct { input_code: ZigString = ZigString.init(""), - protected_input_value: JSC.JSValue = @intToEnum(JSC.JSValue, 0), + protected_input_value: JSC.JSValue = @enumFromInt(JSC.JSValue, 0), output_code: ZigString = ZigString.init(""), bundler: Bundler.Bundler = undefined, log: logger.Log, @@ -220,8 +220,8 @@ pub const TransformTask = struct { finish(this.output_code, this.global, promise); - if (@enumToInt(this.protected_input_value) != 0) { - this.protected_input_value = @intToEnum(JSC.JSValue, 0); + if (@intFromEnum(this.protected_input_value) != 0) { + this.protected_input_value = @enumFromInt(JSC.JSValue, 0); } this.deinit(); } @@ -611,7 +611,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std while (length_iter.next()) |value| { if (value.isString()) { const length = @truncate(u32, value.getLength(globalThis)); - string_count += @as(u32, @boolToInt(length > 0)); + string_count += @as(u32, @intFromBool(length > 0)); total_name_buf_len += length; } } @@ -877,7 +877,7 @@ fn getParseResult(this: *Transpiler, allocator: std.mem.Allocator, code: []const for (res.ast.import_records.slice()) |*import| { if (import.kind.isCommonJS()) { import.do_commonjs_transform_in_printer = true; - import.module_id = @truncate(u32, std.hash.Wyhash.hash(0, import.path.pretty)); + import.module_id = @truncate(u32, bun.hash(import.path.pretty)); } } } diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 5580e8840..9df125a58 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -303,7 +303,7 @@ pub fn registerMacro( return js.JSValueMakeUndefined(ctx); } // TODO: make this faster - const id = @truncate(i32, @floatToInt(i64, js.JSValueToNumber(ctx, arguments[0], exception))); + const id = @truncate(i32, @intFromFloat(i64, js.JSValueToNumber(ctx, arguments[0], exception))); if (id == -1 or id == 0) { JSError(getAllocator(ctx), "Internal error registering macros: invalid id", .{}, ctx, exception); return js.JSValueMakeUndefined(ctx); @@ -523,7 +523,7 @@ pub fn getFilePath(ctx: js.JSContextRef, arguments: []const js.JSValueRef, buf: temp_strings_list[temp_strings_list_len] = out_slice; // The dots are kind of unnecessary. They'll be normalized. - if (out.len == 0 or @ptrToInt(out.ptr) == 0 or std.mem.eql(u8, out_slice, ".") or std.mem.eql(u8, out_slice, "..") or std.mem.eql(u8, out_slice, "../")) { + if (out.len == 0 or @intFromPtr(out.ptr) == 0 or std.mem.eql(u8, out_slice, ".") or std.mem.eql(u8, out_slice, "..") or std.mem.eql(u8, out_slice, "../")) { JSError(getAllocator(ctx), "Expected a file path as a string or an array of strings to be part of a file path.", .{}, ctx, exception); return null; } @@ -600,7 +600,7 @@ pub fn readFileAsStringCallback( return js.JSValueMakeUndefined(ctx); }; - if (stat.kind != .File) { + if (stat.kind != .file) { JSError(getAllocator(ctx), "Can't read a {s} as a string (\"{s}\")", .{ @tagName(stat.kind), path }, ctx, exception); return js.JSValueMakeUndefined(ctx); } @@ -641,7 +641,7 @@ pub fn readFileAsBytesCallback( return js.JSValueMakeUndefined(ctx); }; - if (stat.kind != .File) { + if (stat.kind != .file) { JSError(allocator, "Can't read a {s} as a string (\"{s}\")", .{ @tagName(stat.kind), path }, ctx, exception); return js.JSValueMakeUndefined(ctx); } @@ -1612,7 +1612,7 @@ pub const Crypto = struct { fn createCryptoError(globalThis: *JSC.JSGlobalObject, err_code: u32) JSValue { var outbuf: [128 + 1 + "BoringSSL error: ".len]u8 = undefined; - @memset(&outbuf, 0, outbuf.len); + @memset(&outbuf, 0); outbuf[0.."BoringSSL error: ".len].* = "BoringSSL error: ".*; var message_buf = outbuf["BoringSSL error: ".len..]; @@ -3171,9 +3171,9 @@ pub fn mmapFile( return JSC.C.JSObjectMakeTypedArrayWithBytesNoCopy(ctx, JSC.C.JSTypedArrayType.kJSTypedArrayTypeUint8Array, @ptrCast(?*anyopaque, map.ptr), map.len, struct { pub fn x(ptr: ?*anyopaque, size: ?*anyopaque) callconv(.C) void { - _ = JSC.Node.Syscall.munmap(@ptrCast([*]align(std.mem.page_size) u8, @alignCast(std.mem.page_size, ptr))[0..@ptrToInt(size)]); + _ = JSC.Node.Syscall.munmap(@ptrCast([*]align(std.mem.page_size) u8, @alignCast(std.mem.page_size, ptr))[0..@intFromPtr(size)]); } - }.x, @intToPtr(?*anyopaque, map.len), exception); + }.x, @ptrFromInt(?*anyopaque, map.len), exception); } pub fn getTranspilerConstructor( @@ -3401,7 +3401,7 @@ pub const Unsafe = struct { globalThis: *JSC.JSGlobalObject, value_: ?JSValue, ) JSValue { - const ret = JSValue.jsNumber(@as(i32, @enumToInt(globalThis.bunVM().aggressive_garbage_collection))); + const ret = JSValue.jsNumber(@as(i32, @intFromEnum(globalThis.bunVM().aggressive_garbage_collection))); if (value_) |value| { switch (value.coerce(i32, globalThis)) { @@ -3912,7 +3912,7 @@ pub const Timer = struct { id, Timeout.run, this.interval, - @as(i32, @boolToInt(this.kind == .setInterval)) * this.interval, + @as(i32, @intFromBool(this.kind == .setInterval)) * this.interval, ); return this_value; } @@ -4130,7 +4130,7 @@ pub const Timer = struct { }, Timeout.run, interval, - @as(i32, @boolToInt(kind == .setInterval)) * interval, + @as(i32, @intFromBool(kind == .setInterval)) * interval, ); } @@ -4318,7 +4318,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) u8, addr).*; + const value = @ptrFromInt(*align(1) u8, addr).*; return JSValue.jsNumber(value); } pub fn @"u16"( @@ -4327,7 +4327,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) u16, addr).*; + const value = @ptrFromInt(*align(1) u16, addr).*; return JSValue.jsNumber(value); } pub fn @"u32"( @@ -4336,7 +4336,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) u32, addr).*; + const value = @ptrFromInt(*align(1) u32, addr).*; return JSValue.jsNumber(value); } pub fn ptr( @@ -4345,7 +4345,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) u64, addr).*; + const value = @ptrFromInt(*align(1) u64, addr).*; return JSValue.jsNumber(value); } pub fn @"i8"( @@ -4354,7 +4354,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) i8, addr).*; + const value = @ptrFromInt(*align(1) i8, addr).*; return JSValue.jsNumber(value); } pub fn @"i16"( @@ -4363,7 +4363,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) i16, addr).*; + const value = @ptrFromInt(*align(1) i16, addr).*; return JSValue.jsNumber(value); } pub fn @"i32"( @@ -4372,7 +4372,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) i32, addr).*; + const value = @ptrFromInt(*align(1) i32, addr).*; return JSValue.jsNumber(value); } pub fn intptr( @@ -4381,7 +4381,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) i64, addr).*; + const value = @ptrFromInt(*align(1) i64, addr).*; return JSValue.jsNumber(value); } @@ -4391,7 +4391,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) f32, addr).*; + const value = @ptrFromInt(*align(1) f32, addr).*; return JSValue.jsNumber(value); } @@ -4401,7 +4401,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) f64, addr).*; + const value = @ptrFromInt(*align(1) f64, addr).*; return JSValue.jsNumber(value); } @@ -4411,7 +4411,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) i64, addr).*; + const value = @ptrFromInt(*align(1) i64, addr).*; return JSValue.fromInt64NoTruncate(global, value); } @@ -4421,7 +4421,7 @@ pub const FFI = struct { arguments: []const JSValue, ) JSValue { const addr = arguments[0].asPtrAddress() + if (arguments.len > 1) @intCast(usize, arguments[1].to(i32)) else @as(usize, 0); - const value = @intToPtr(*align(1) u64, addr).*; + const value = @ptrFromInt(*align(1) u64, addr).*; return JSValue.fromUInt64NoTruncate(global, value); } @@ -4432,7 +4432,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) u8, addr).*; + const value = @ptrFromInt(*align(1) u8, addr).*; return JSValue.jsNumber(value); } pub fn u16WithoutTypeChecks( @@ -4442,7 +4442,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) u16, addr).*; + const value = @ptrFromInt(*align(1) u16, addr).*; return JSValue.jsNumber(value); } pub fn u32WithoutTypeChecks( @@ -4452,7 +4452,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) u32, addr).*; + const value = @ptrFromInt(*align(1) u32, addr).*; return JSValue.jsNumber(value); } pub fn ptrWithoutTypeChecks( @@ -4462,7 +4462,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) u64, addr).*; + const value = @ptrFromInt(*align(1) u64, addr).*; return JSValue.jsNumber(value); } pub fn i8WithoutTypeChecks( @@ -4472,7 +4472,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) i8, addr).*; + const value = @ptrFromInt(*align(1) i8, addr).*; return JSValue.jsNumber(value); } pub fn i16WithoutTypeChecks( @@ -4482,7 +4482,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) i16, addr).*; + const value = @ptrFromInt(*align(1) i16, addr).*; return JSValue.jsNumber(value); } pub fn i32WithoutTypeChecks( @@ -4492,7 +4492,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) i32, addr).*; + const value = @ptrFromInt(*align(1) i32, addr).*; return JSValue.jsNumber(value); } pub fn intptrWithoutTypeChecks( @@ -4502,7 +4502,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) i64, addr).*; + const value = @ptrFromInt(*align(1) i64, addr).*; return JSValue.jsNumber(value); } @@ -4513,7 +4513,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) f32, addr).*; + const value = @ptrFromInt(*align(1) f32, addr).*; return JSValue.jsNumber(value); } @@ -4524,7 +4524,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) f64, addr).*; + const value = @ptrFromInt(*align(1) f64, addr).*; return JSValue.jsNumber(value); } @@ -4535,7 +4535,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) u64, addr).*; + const value = @ptrFromInt(*align(1) u64, addr).*; return JSValue.fromUInt64NoTruncate(global, value); } @@ -4546,7 +4546,7 @@ pub const FFI = struct { offset: i32, ) callconv(.C) JSValue { const addr = @intCast(usize, raw_addr) + @intCast(usize, offset); - const value = @intToPtr(*align(1) i64, addr).*; + const value = @ptrFromInt(*align(1) i64, addr).*; return JSValue.fromInt64NoTruncate(global, value); } @@ -4590,7 +4590,7 @@ pub const FFI = struct { _: *anyopaque, array: *JSC.JSUint8Array, ) callconv(.C) JSValue { - return JSValue.fromPtrAddress(@ptrToInt(array.ptr())); + return JSValue.fromPtrAddress(@intFromPtr(array.ptr())); } fn ptr_( @@ -4610,9 +4610,9 @@ pub const FFI = struct { return JSC.toInvalidArguments("ArrayBufferView must have a length > 0. A pointer to empty memory doesn't work", .{}, globalThis); } - var addr: usize = @ptrToInt(array_buffer.ptr); + var addr: usize = @intFromPtr(array_buffer.ptr); // const Sizes = @import("../bindings/sizes.zig"); - // std.debug.assert(addr == @ptrToInt(value.asEncoded().ptr) + Sizes.Bun_FFI_PointerOffsetToTypedArrayVector); + // std.debug.assert(addr == @intFromPtr(value.asEncoded().ptr) + Sizes.Bun_FFI_PointerOffsetToTypedArrayVector); if (byteOffset) |off| { if (!off.isEmptyOrUndefinedOrNull()) { @@ -4628,7 +4628,7 @@ pub const FFI = struct { addr += @intCast(usize, bytei64); } - if (addr > @ptrToInt(array_buffer.ptr) + @as(usize, array_buffer.byte_len)) { + if (addr > @intFromPtr(array_buffer.ptr) + @as(usize, array_buffer.byte_len)) { return JSC.toInvalidArguments("byteOffset out of bounds", .{}, globalThis); } } @@ -4720,11 +4720,11 @@ pub const FFI = struct { } const length = @intCast(usize, length_i); - return .{ .slice = @intToPtr([*]u8, addr)[0..length] }; + return .{ .slice = @ptrFromInt([*]u8, addr)[0..length] }; } } - return .{ .slice = bun.span(@intToPtr([*:0]u8, addr)) }; + return .{ .slice = bun.span(@ptrFromInt([*:0]u8, addr)) }; } fn getCPtr(value: JSValue) ?usize { @@ -4759,11 +4759,11 @@ pub const FFI = struct { var ctx: ?*anyopaque = null; if (finalizationCallback) |callback_value| { if (getCPtr(callback_value)) |callback_ptr| { - callback = @intToPtr(JSC.C.JSTypedArrayBytesDeallocator, callback_ptr); + callback = @ptrFromInt(JSC.C.JSTypedArrayBytesDeallocator, callback_ptr); if (finalizationCtxOrPtr) |ctx_value| { if (getCPtr(ctx_value)) |ctx_ptr| { - ctx = @intToPtr(*anyopaque, ctx_ptr); + ctx = @ptrFromInt(*anyopaque, ctx_ptr); } else if (!ctx_value.isUndefinedOrNull()) { return JSC.toInvalidArguments("Expected user data to be a C pointer (number or BigInt)", .{}, globalThis); } @@ -4773,7 +4773,7 @@ pub const FFI = struct { } } else if (finalizationCtxOrPtr) |callback_value| { if (getCPtr(callback_value)) |callback_ptr| { - callback = @intToPtr(JSC.C.JSTypedArrayBytesDeallocator, callback_ptr); + callback = @ptrFromInt(JSC.C.JSTypedArrayBytesDeallocator, callback_ptr); } else if (!callback_value.isEmptyOrUndefinedOrNull()) { return JSC.toInvalidArguments("Expected callback to be a C pointer (number or BigInt)", .{}, globalThis); } @@ -4801,11 +4801,11 @@ pub const FFI = struct { var ctx: ?*anyopaque = null; if (finalizationCallback) |callback_value| { if (getCPtr(callback_value)) |callback_ptr| { - callback = @intToPtr(JSC.C.JSTypedArrayBytesDeallocator, callback_ptr); + callback = @ptrFromInt(JSC.C.JSTypedArrayBytesDeallocator, callback_ptr); if (finalizationCtxOrPtr) |ctx_value| { if (getCPtr(ctx_value)) |ctx_ptr| { - ctx = @intToPtr(*anyopaque, ctx_ptr); + ctx = @ptrFromInt(*anyopaque, ctx_ptr); } else if (!ctx_value.isEmptyOrUndefinedOrNull()) { return JSC.toInvalidArguments("Expected user data to be a C pointer (number or BigInt)", .{}, globalThis); } @@ -4815,7 +4815,7 @@ pub const FFI = struct { } } else if (finalizationCtxOrPtr) |callback_value| { if (getCPtr(callback_value)) |callback_ptr| { - callback = @intToPtr(JSC.C.JSTypedArrayBytesDeallocator, callback_ptr); + callback = @ptrFromInt(JSC.C.JSTypedArrayBytesDeallocator, callback_ptr); } else if (!callback_value.isEmptyOrUndefinedOrNull()) { return JSC.toInvalidArguments("Expected callback to be a C pointer (number or BigInt)", .{}, globalThis); } diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index aec295056..fee834e5e 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -123,7 +123,7 @@ const LibInfo = struct { this.vm.uws_event_loop.?, .machport, true, - @ptrToInt(request.backend.libinfo.machport), + @intFromPtr(request.backend.libinfo.machport), ) == .result, ); @@ -230,7 +230,7 @@ fn addrInfoCount(addrinfo: *std.c.addrinfo) u32 { var count: u32 = 1; var current: ?*std.c.addrinfo = addrinfo.next; while (current != null) : (current = current.?.next) { - count += @boolToInt(current.?.addr != null); + count += @intFromBool(current.?.addr != null); } return count; } @@ -285,7 +285,7 @@ pub const GetAddrInfo = struct { pub fn toCAres(this: GetAddrInfo) bun.c_ares.AddrInfo_hints { var hints: bun.c_ares.AddrInfo_hints = undefined; - @memset(std.mem.asBytes(&hints), 0, @sizeOf(bun.c_ares.AddrInfo_hints)); + @memset(std.mem.asBytes(&hints)[0..@sizeOf(bun.c_ares.AddrInfo_hints)], 0); hints.ai_family = this.options.family.toLibC(); hints.ai_socktype = this.options.socktype.toLibC(); @@ -320,7 +320,7 @@ pub const GetAddrInfo = struct { } var hints: std.c.addrinfo = undefined; - @memset(std.mem.asBytes(&hints), 0, @sizeOf(std.c.addrinfo)); + @memset(std.mem.asBytes(&hints)[0..@sizeOf(std.c.addrinfo)], 0); hints.family = this.family.toLibC(); hints.socktype = this.socktype.toLibC(); @@ -793,7 +793,7 @@ pub const GetAddrInfoRequest = struct { addr_info: ?*std.c.addrinfo, arg: ?*anyopaque, ) callconv(.C) void { - const this = @intToPtr(*GetAddrInfoRequest, @ptrToInt(arg)); + const this = @ptrFromInt(*GetAddrInfoRequest, @intFromPtr(arg)); log("getAddrInfoAsyncCallback: status={d}", .{status}); if (this.backend == .libinfo) { @@ -846,8 +846,8 @@ pub const GetAddrInfoRequest = struct { err, debug_timer, }); - if (@enumToInt(err) != 0 or addrinfo == null) { - this.* = .{ .err = @enumToInt(err) }; + if (@intFromEnum(err) != 0 or addrinfo == null) { + this.* = .{ .err = @intFromEnum(err) }; return; } diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 48bfe4218..00e34a77d 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -398,10 +398,10 @@ pub const Listener = struct { pub fn deinit(this: UnixOrHost) void { switch (this) { .unix => |u| { - bun.default_allocator.destroy(@intToPtr([*]u8, @ptrToInt(u.ptr))); + bun.default_allocator.destroy(@ptrFromInt([*]u8, @intFromPtr(u.ptr))); }, .host => |h| { - bun.default_allocator.destroy(@intToPtr([*]u8, @ptrToInt(h.host.ptr))); + bun.default_allocator.destroy(@ptrFromInt([*]u8, @intFromPtr(h.host.ptr))); }, } } @@ -472,7 +472,7 @@ pub const Listener = struct { globalObject.bunVM().eventLoop().ensureWaker(); var socket_context = uws.us_create_bun_socket_context( - @boolToInt(ssl_enabled), + @intFromBool(ssl_enabled), uws.Loop.get().?, @sizeOf(usize), ctx_opts, @@ -483,7 +483,7 @@ pub const Listener = struct { hostname_or_unix.deinit(); } - const errno = @enumToInt(std.c.getErrno(-1)); + const errno = @intFromEnum(std.c.getErrno(-1)); if (errno != 0) { err.put(globalObject, ZigString.static("errno"), JSValue.jsNumber(errno)); if (bun.C.SystemErrno.init(errno)) |str| { @@ -544,7 +544,7 @@ pub const Listener = struct { defer bun.default_allocator.free(host); const socket = uws.us_socket_context_listen( - @boolToInt(ssl_enabled), + @intFromBool(ssl_enabled), socket_context, normalizeHost(@as([:0]const u8, host)), c.port, @@ -560,13 +560,13 @@ pub const Listener = struct { .unix => |u| { var host = bun.default_allocator.dupeZ(u8, u) catch unreachable; defer bun.default_allocator.free(host); - break :brk uws.us_socket_context_listen_unix(@boolToInt(ssl_enabled), socket_context, host, socket_flags, 8); + break :brk uws.us_socket_context_listen_unix(@intFromBool(ssl_enabled), socket_context, host, socket_flags, 8); }, } } orelse { defer { hostname_or_unix.deinit(); - uws.us_socket_context_free(@boolToInt(ssl_enabled), socket_context); + uws.us_socket_context_free(@intFromBool(ssl_enabled), socket_context); } const err = globalObject.createErrorInstance( @@ -575,7 +575,7 @@ pub const Listener = struct { bun.span(hostname_or_unix.slice()), }, ); - const errno = @enumToInt(std.c.getErrno(-1)); + const errno = @intFromEnum(std.c.getErrno(-1)); if (errno != 0) { err.put(globalObject, ZigString.static("errno"), JSValue.jsNumber(errno)); if (bun.C.SystemErrno.init(errno)) |str| { @@ -789,7 +789,7 @@ pub const Listener = struct { globalObject.bunVM().eventLoop().ensureWaker(); - var socket_context = uws.us_create_bun_socket_context(@boolToInt(ssl_enabled), uws.Loop.get().?, @sizeOf(usize), ctx_opts).?; + var socket_context = uws.us_create_bun_socket_context(@intFromBool(ssl_enabled), uws.Loop.get().?, @sizeOf(usize), ctx_opts).?; var connection: Listener.UnixOrHost = if (port) |port_| .{ .host = .{ .host = (hostname_or_unix.cloneIfNeeded(bun.default_allocator) catch unreachable).slice(), .port = port_ }, } else .{ diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 832afac78..ba813c463 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -1011,7 +1011,7 @@ pub const Subprocess = struct { if (signal.name()) |name| return JSC.ZigString.init(name).toValueGC(global) else - return JSC.JSValue.jsNumber(@enumToInt(signal)); + return JSC.JSValue.jsNumber(@intFromEnum(signal)); } return JSC.JSValue.jsNull(); @@ -1535,9 +1535,9 @@ pub const Subprocess = struct { } if (std.os.W.IFSIGNALED(result.status)) { - this.signal_code = @intToEnum(SignalCode, @truncate(u8, std.os.W.TERMSIG(result.status))); + this.signal_code = @enumFromInt(SignalCode, @truncate(u8, std.os.W.TERMSIG(result.status))); } else if (std.os.W.IFSTOPPED(result.status)) { - this.signal_code = @intToEnum(SignalCode, @truncate(u8, std.os.W.STOPSIG(result.status))); + this.signal_code = @enumFromInt(SignalCode, @truncate(u8, std.os.W.STOPSIG(result.status))); } if (!this.hasExited()) { diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index fe2b50955..e46e054ec 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -137,8 +137,8 @@ pub const FFI = struct { globalThis, ZigString.static("ptr"), ZigString.static("ctx"), - JSC.JSValue.fromPtrAddress(@ptrToInt(function_.step.compiled.ptr)), - JSC.JSValue.fromPtrAddress(@ptrToInt(function_)), + JSC.JSValue.fromPtrAddress(@intFromPtr(function_.step.compiled.ptr)), + JSC.JSValue.fromPtrAddress(@intFromPtr(function_)), ); }, } @@ -523,7 +523,7 @@ pub const FFI = struct { const int = val.to(i32); switch (int) { 0...ABIType.max => { - abi_types.appendAssumeCapacity(@intToEnum(ABIType, int)); + abi_types.appendAssumeCapacity(@enumFromInt(ABIType, int)); continue; }, else => { @@ -560,7 +560,7 @@ pub const FFI = struct { const int = ret_value.toInt32(); switch (int) { 0...ABIType.max => { - return_type = @intToEnum(ABIType, int); + return_type = @enumFromInt(ABIType, int); break :brk; }, else => { @@ -594,11 +594,11 @@ pub const FFI = struct { if (ptr.isNumber()) { const num = ptr.asPtrAddress(); if (num > 0) - function.symbol_from_dynamic_library = @intToPtr(*anyopaque, num); + function.symbol_from_dynamic_library = @ptrFromInt(*anyopaque, num); } else { const num = ptr.toUInt64NoTruncate(); if (num > 0) { - function.symbol_from_dynamic_library = @intToPtr(*anyopaque, num); + function.symbol_from_dynamic_library = @ptrFromInt(*anyopaque, num); } } } @@ -866,7 +866,7 @@ pub const FFI = struct { c: u8, byte_count: usize, ) callconv(.C) void { - @memset(dest, c, byte_count); + @memset(dest[0..byte_count], c); } noinline fn memcpy( @@ -874,7 +874,7 @@ pub const FFI = struct { noalias source: [*]const u8, byte_count: usize, ) callconv(.C) void { - @memcpy(dest, source, byte_count); + @memcpy(dest[0..byte_count], source[0..byte_count]); } pub fn define(state: *TCC.TCCState) void { @@ -1205,7 +1205,7 @@ pub const FFI = struct { writer: anytype, ) !void { { - const ptr = @ptrToInt(globalObject); + const ptr = @intFromPtr(globalObject); const fmt = bun.fmt.hexIntUpper(ptr); try writer.print("#define JS_GLOBAL_OBJECT (void*)0x{any}ULL\n", .{fmt}); } @@ -1290,7 +1290,7 @@ pub const FFI = struct { var inner_buf: []u8 = &.{}; { - const ptr = @ptrToInt(context_ptr); + const ptr = @intFromPtr(context_ptr); const fmt = bun.fmt.hexIntUpper(ptr); if (this.arg_types.items.len > 0) { @@ -1355,7 +1355,7 @@ pub const FFI = struct { function = 17, - pub const max = @enumToInt(ABIType.function); + pub const max = @intFromEnum(ABIType.function); /// Types that we can directly pass through as an `int64_t` pub fn needsACastInC(this: ABIType) bool { @@ -1414,11 +1414,11 @@ pub const FFI = struct { // these are not all valid identifiers try writer.writeAll(self.name); try writer.writeAll("']:"); - try std.fmt.formatInt(@enumToInt(self.entry), 10, .lower, .{}, writer); + try std.fmt.formatInt(@intFromEnum(self.entry), 10, .lower, .{}, writer); try writer.writeAll(",'"); - try std.fmt.formatInt(@enumToInt(self.entry), 10, .lower, .{}, writer); + try std.fmt.formatInt(@intFromEnum(self.entry), 10, .lower, .{}, writer); try writer.writeAll("':"); - try std.fmt.formatInt(@enumToInt(self.entry), 10, .lower, .{}, writer); + try std.fmt.formatInt(@intFromEnum(self.entry), 10, .lower, .{}, writer); } }; pub const map_to_js_object = brk: { @@ -1426,7 +1426,7 @@ pub const FFI = struct { for (map, 0..) |item, i| { var fmt = EnumMapFormatter{ .name = item.@"0", .entry = item.@"1" }; count += std.fmt.count("{}", .{fmt}); - count += @boolToInt(i > 0); + count += @intFromBool(i > 0); } var buf: [count]u8 = undefined; diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig index bfbdb9a37..93a41b095 100644 --- a/src/bun.js/api/html_rewriter.zig +++ b/src/bun.js/api/html_rewriter.zig @@ -472,13 +472,13 @@ pub const HTMLRewriter = struct { pub fn onFinishedLoading(sink: *BufferOutputSink, bytes: JSC.WebCore.Blob.Store.ReadFile.ResultType) void { switch (bytes) { .err => |err| { - if (sink.response.body.value == .Locked and @ptrToInt(sink.response.body.value.Locked.task) == @ptrToInt(sink) and + if (sink.response.body.value == .Locked and @intFromPtr(sink.response.body.value.Locked.task) == @intFromPtr(sink) and sink.response.body.value.Locked.promise == null) { sink.response.body.value = .{ .Empty = {} }; // is there a pending promise? // we will need to reject it - } else if (sink.response.body.value == .Locked and @ptrToInt(sink.response.body.value.Locked.task) == @ptrToInt(sink) and + } else if (sink.response.body.value == .Locked and @intFromPtr(sink.response.body.value.Locked.task) == @intFromPtr(sink) and sink.response.body.value.Locked.promise != null) { sink.response.body.value.Locked.onReceiveValue = null; diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 37bc601a5..a56ff971f 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -168,7 +168,7 @@ pub const ServerConfig = struct { pub fn asUSockets(this_: ?SSLConfig) uws.us_bun_socket_context_options_t { var ctx_opts: uws.us_bun_socket_context_options_t = undefined; - @memset(@ptrCast([*]u8, &ctx_opts), 0, @sizeOf(uws.us_bun_socket_context_options_t)); + @memset(@ptrCast([*]u8, &ctx_opts)[0..@sizeOf(uws.us_bun_socket_context_options_t)], 0); if (this_) |ssl_config| { if (ssl_config.key_file_name != null) @@ -181,7 +181,7 @@ pub const ServerConfig = struct { ctx_opts.dh_params_file_name = ssl_config.dh_params_file_name; if (ssl_config.passphrase != null) ctx_opts.passphrase = ssl_config.passphrase; - ctx_opts.ssl_prefer_low_memory_usage = @boolToInt(ssl_config.low_memory_mode); + ctx_opts.ssl_prefer_low_memory_usage = @intFromBool(ssl_config.low_memory_mode); if (ssl_config.key) |key| { ctx_opts.key = key.ptr; @@ -1240,7 +1240,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp .reason = .fetch_event_handler, .cwd = VirtualMachine.get().bundler.fs.top_level_dir, .problems = Api.Problems{ - .code = @truncate(u16, @errorToInt(err)), + .code = @truncate(u16, @intFromError(err)), .name = @errorName(err), .exceptions = exceptions, .build = log.toAPI(allocator) catch unreachable, @@ -1790,7 +1790,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } var err = JSC.Node.Syscall.Error{ - .errno = @intCast(JSC.Node.Syscall.Error.Int, @enumToInt(std.os.E.INVAL)), + .errno = @intCast(JSC.Node.Syscall.Error.Int, @intFromEnum(std.os.E.INVAL)), .syscall = .sendfile, }; var sys = err.withPathLike(file.pathlike).toSystemError(); @@ -1809,7 +1809,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } var err = JSC.Node.Syscall.Error{ - .errno = @intCast(JSC.Node.Syscall.Error.Int, @enumToInt(std.os.E.INVAL)), + .errno = @intCast(JSC.Node.Syscall.Error.Int, @intFromEnum(std.os.E.INVAL)), .syscall = .sendfile, }; var sys = err.withPathLike(file.pathlike).toSystemError(); @@ -2113,7 +2113,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp const streamLog = Output.scoped(.ReadableStream, false); pub fn didUpgradeWebSocket(this: *RequestContext) bool { - return @ptrToInt(this.upgrade_context) == std.math.maxInt(usize); + return @intFromPtr(this.upgrade_context) == std.math.maxInt(usize); } pub fn onResponse( @@ -2874,7 +2874,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp const prev_len = bytes.items.len; bytes.items.len = total; var slice = bytes.items[prev_len..]; - @memcpy(slice.ptr, chunk.ptr, chunk.len); + @memcpy(slice[0..chunk.len], chunk); body.value = .{ .InternalBlob = .{ .bytes = bytes.toManaged(this.allocator), @@ -3200,7 +3200,7 @@ pub const WebSocketServer = struct { globalObject.throwInvalidArguments("websocket expects maxPayloadLength to be an integer", .{}); return null; } - server.maxPayloadLength = @intCast(u32, @truncate(i33, @max(value.toInt64(), 0))); + server.maxPayloadLength = @intCast(u32, @max(value.toInt64(), 0)); } } if (object.get(globalObject, "idleTimeout")) |value| { @@ -3220,7 +3220,7 @@ pub const WebSocketServer = struct { return null; } - server.backpressureLimit = @intCast(u32, @truncate(i33, @max(value.toInt64(), 0))); + server.backpressureLimit = @intCast(u32, @max(value.toInt64(), 0)); } } // if (object.get(globalObject, "sendPings")) |value| { @@ -3366,7 +3366,7 @@ pub const ServerWebSocket = struct { opcode: uws.Opcode, ) void { log("onMessage({d}): {s}", .{ - @enumToInt(opcode), + @intFromEnum(opcode), message, }); const onMessageHandler = this.handler.onMessage; @@ -4436,7 +4436,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { return JSValue.jsNumber( // if 0, return 0 // else return number of bytes sent - @as(i32, @boolToInt(uws.AnyWebSocket.publishWithOptions(ssl_enabled, app, topic_slice.slice(), buffer.slice(), .binary, compress))) * @intCast(i32, @truncate(u31, buffer.len)), + @as(i32, @intFromBool(uws.AnyWebSocket.publishWithOptions(ssl_enabled, app, topic_slice.slice(), buffer.slice(), .binary, compress))) * @intCast(i32, @truncate(u31, buffer.len)), ); } @@ -4451,7 +4451,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { return JSValue.jsNumber( // if 0, return 0 // else return number of bytes sent - @as(i32, @boolToInt(uws.AnyWebSocket.publishWithOptions(ssl_enabled, app, topic_slice.slice(), buffer, .text, compress))) * @intCast(i32, @truncate(u31, buffer.len)), + @as(i32, @intFromBool(uws.AnyWebSocket.publishWithOptions(ssl_enabled, app, topic_slice.slice(), buffer, .text, compress))) * @intCast(i32, @truncate(u31, buffer.len)), ); } @@ -4488,7 +4488,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { return JSC.jsBoolean(false); } - if (upgrader.upgrade_context == null or @ptrToInt(upgrader.upgrade_context) == std.math.maxInt(usize)) { + if (upgrader.upgrade_context == null or @intFromPtr(upgrader.upgrade_context) == std.math.maxInt(usize)) { return JSC.jsBoolean(false); } const resp = upgrader.resp.?; @@ -4582,7 +4582,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { // See https://github.com/oven-sh/bun/issues/1339 // obviously invalid pointer marks it as used - upgrader.upgrade_context = @intToPtr(*uws.uws_socket_context_s, std.math.maxInt(usize)); + upgrader.upgrade_context = @ptrFromInt(*uws.uws_socket_context_s, std.math.maxInt(usize)); request.upgrader = null; resp.clearAborted(); @@ -4947,7 +4947,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { if (reason.len == 0) { break; } - @memcpy(output_buf[written..].ptr, reason.ptr, reason.len); + @memcpy(output_buf[written..][0..reason.len], reason); written += reason.len; } @@ -4958,7 +4958,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { if (reason.len > 0) { output_buf[written..][0.." via ".len].* = " via ".*; written += " via ".len; - @memcpy(output_buf[written..].ptr, reason.ptr, reason.len); + @memcpy(output_buf[written..][0..reason.len], reason); written += reason.len; } } @@ -4970,7 +4970,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { if (reason.len > 0) { output_buf[written..][0] = ' '; written += 1; - @memcpy(output_buf[written..].ptr, reason.ptr, reason.len); + @memcpy(output_buf[written..][0..reason.len], reason); written += reason.len; } } diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index 038f7f38b..4a1249b5d 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -1291,23 +1291,27 @@ pub fn NewClassWithInstanceType( const static_properties: [property_names.len + 1]js.JSStaticValue = brk: { var props: [property_names.len + 1]js.JSStaticValue = undefined; - std.mem.set( - js.JSStaticValue, + @memset( &props, js.JSStaticValue{ - .name = @intToPtr([*c]const u8, 0), + .name = @ptrFromInt([*c]const u8, 0), .getProperty = null, .setProperty = null, .attributes = js.JSPropertyAttributes.kJSPropertyAttributeNone, }, ); + if (property_name_literals.len > 0 and @TypeOf(property_name_literals[0]) == [:0]const u8) { + @compileError("@typeInfo() struct field names are null-terminated"); + } for (property_name_literals, 0..) |lit, i| { props[i] = brk2: { var static_prop = JSC.C.JSStaticValue{ - .name = lit.ptr[0..lit.len :0], + // TODO: update when @typeInfo struct field names are sentinel terminated + // https://github.com/ziglang/zig/issues/16072 + .name = lit ++ .{0}, .getProperty = null, .setProperty = null, - .attributes = @intToEnum(js.JSPropertyAttributes, 0), + .attributes = @enumFromInt(js.JSPropertyAttributes, 0), }; static_prop.getProperty = StaticProperty(i).getter; @@ -1396,14 +1400,14 @@ pub fn NewClassWithInstanceType( const ctxfn = CtxField.rfn; const Func: std.builtin.Type.Fn = @typeInfo(@TypeOf(if (@typeInfo(@TypeOf(ctxfn)) == .Pointer) ctxfn.* else ctxfn)).Fn; - var attributes: c_uint = @enumToInt(js.JSPropertyAttributes.kJSPropertyAttributeNone); + var attributes: c_uint = @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeNone); if (comptime is_read_only or hasReadOnly(@TypeOf(CtxField))) { - attributes |= @enumToInt(js.JSPropertyAttributes.kJSPropertyAttributeReadOnly); + attributes |= @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeReadOnly); } if (comptime hasEnumerable(@TypeOf(CtxField)) and !CtxField.enumerable) { - attributes |= @enumToInt(js.JSPropertyAttributes.kJSPropertyAttributeDontEnum); + attributes |= @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeDontEnum); } const PointerType = comptime brk: { @@ -1419,7 +1423,7 @@ pub fn NewClassWithInstanceType( PointerType, if (@typeInfo(@TypeOf(ctxfn)) == .Pointer) ctxfn.* else ctxfn, ).rfn, - .attributes = @intToEnum(js.JSPropertyAttributes, attributes), + .attributes = @enumFromInt(js.JSPropertyAttributes, attributes), }; count += 1; @@ -1438,12 +1442,12 @@ pub fn NewClassWithInstanceType( def.hasInstance = &staticFunctions.hasInstance; } else { const attributes: js.JSPropertyAttributes = brk: { - var base = @enumToInt(js.JSPropertyAttributes.kJSPropertyAttributeNone); + var base = @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeNone); if (is_read_only) - base |= @enumToInt(js.JSPropertyAttributes.kJSPropertyAttributeReadOnly); + base |= @intFromEnum(js.JSPropertyAttributes.kJSPropertyAttributeReadOnly); - break :brk @intToEnum(js.JSPropertyAttributes, base); + break :brk @enumFromInt(js.JSPropertyAttributes, base); }; __static_functions[count] = js.JSStaticFunction{ @@ -1834,7 +1838,7 @@ pub const ArrayBuffer = extern struct { this.ptr, this.byte_len, MarkedArrayBuffer_deallocator, - @intToPtr(*anyopaque, @ptrToInt(&bun.default_allocator)), + @ptrFromInt(*anyopaque, @intFromPtr(&bun.default_allocator)), exception, )); } @@ -1845,7 +1849,7 @@ pub const ArrayBuffer = extern struct { this.ptr, this.byte_len, MarkedArrayBuffer_deallocator, - @intToPtr(*anyopaque, @ptrToInt(&bun.default_allocator)), + @ptrFromInt(*anyopaque, @intFromPtr(&bun.default_allocator)), exception, )); } @@ -2068,7 +2072,7 @@ pub const RefString = struct { pub const Callback = fn (ctx: *anyopaque, str: *RefString) void; pub fn computeHash(input: []const u8) u32 { - return std.hash.XxHash32.hash(input); + return std.hash.XxHash32.hash(0, input); } pub fn slice(this: *RefString) []const u8 { @@ -3355,7 +3359,7 @@ pub const FilePoll = struct { const DNSResolver = JSC.DNS.DNSResolver; const GetAddrInfoRequest = JSC.DNS.GetAddrInfoRequest; const Deactivated = opaque { - pub var owner: Owner = Owner.init(@intToPtr(*Deactivated, @as(usize, 0xDEADBEEF))); + pub var owner: Owner = Owner.init(@ptrFromInt(*Deactivated, @as(usize, 0xDEADBEEF))); }; pub const Owner = bun.TaggedPointerUnion(.{ @@ -3610,7 +3614,7 @@ pub const FilePoll = struct { return; this.flags.insert(.disable); - vm.uws_event_loop.?.active -= @as(u32, @boolToInt(this.flags.contains(.has_incremented_poll_count))); + vm.uws_event_loop.?.active -= @as(u32, @intFromBool(this.flags.contains(.has_incremented_poll_count))); } pub fn enableKeepingProcessAlive(this: *FilePoll, vm: *JSC.VirtualMachine) void { @@ -3618,7 +3622,7 @@ pub const FilePoll = struct { return; this.flags.remove(.disable); - vm.uws_event_loop.?.active += @as(u32, @boolToInt(this.flags.contains(.has_incremented_poll_count))); + vm.uws_event_loop.?.active += @as(u32, @intFromBool(this.flags.contains(.has_incremented_poll_count))); } pub fn canActivate(this: *const FilePoll) bool { @@ -3628,16 +3632,16 @@ pub const FilePoll = struct { /// Only intended to be used from EventLoop.Pollable pub fn deactivate(this: *FilePoll, loop: *uws.Loop) void { std.debug.assert(this.flags.contains(.has_incremented_poll_count)); - loop.num_polls -= @as(i32, @boolToInt(this.flags.contains(.has_incremented_poll_count))); - loop.active -|= @as(u32, @boolToInt(!this.flags.contains(.disable) and this.flags.contains(.has_incremented_poll_count))); + loop.num_polls -= @as(i32, @intFromBool(this.flags.contains(.has_incremented_poll_count))); + loop.active -|= @as(u32, @intFromBool(!this.flags.contains(.disable) and this.flags.contains(.has_incremented_poll_count))); this.flags.remove(.has_incremented_poll_count); } /// Only intended to be used from EventLoop.Pollable pub fn activate(this: *FilePoll, loop: *uws.Loop) void { - loop.num_polls += @as(i32, @boolToInt(!this.flags.contains(.has_incremented_poll_count))); - loop.active += @as(u32, @boolToInt(!this.flags.contains(.disable) and !this.flags.contains(.has_incremented_poll_count))); + loop.num_polls += @as(i32, @intFromBool(!this.flags.contains(.has_incremented_poll_count))); + loop.active += @as(u32, @intFromBool(!this.flags.contains(.disable) and !this.flags.contains(.has_incremented_poll_count))); this.flags.insert(.has_incremented_poll_count); } @@ -3738,7 +3742,7 @@ pub const FilePoll = struct { else => unreachable, }; - var event = linux.epoll_event{ .events = flags, .data = .{ .u64 = @ptrToInt(Pollable.init(this).ptr()) } }; + var event = linux.epoll_event{ .events = flags, .data = .{ .u64 = @intFromPtr(Pollable.init(this).ptr()) } }; const ctl = linux.epoll_ctl( watcher_fd, @@ -3759,7 +3763,7 @@ pub const FilePoll = struct { .filter = std.os.system.EVFILT_READ, .data = 0, .fflags = 0, - .udata = @ptrToInt(Pollable.init(this).ptr()), + .udata = @intFromPtr(Pollable.init(this).ptr()), .flags = std.c.EV_ADD | one_shot_flag, .ext = .{ this.generation_number, 0 }, }, @@ -3768,7 +3772,7 @@ pub const FilePoll = struct { .filter = std.os.system.EVFILT_WRITE, .data = 0, .fflags = 0, - .udata = @ptrToInt(Pollable.init(this).ptr()), + .udata = @intFromPtr(Pollable.init(this).ptr()), .flags = std.c.EV_ADD | one_shot_flag, .ext = .{ this.generation_number, 0 }, }, @@ -3777,7 +3781,7 @@ pub const FilePoll = struct { .filter = std.os.system.EVFILT_PROC, .data = 0, .fflags = std.c.NOTE_EXIT, - .udata = @ptrToInt(Pollable.init(this).ptr()), + .udata = @intFromPtr(Pollable.init(this).ptr()), .flags = std.c.EV_ADD | one_shot_flag, .ext = .{ this.generation_number, 0 }, }, @@ -3786,7 +3790,7 @@ pub const FilePoll = struct { .filter = std.os.system.EVFILT_MACHPORT, .data = 0, .fflags = 0, - .udata = @ptrToInt(Pollable.init(this).ptr()), + .udata = @intFromPtr(Pollable.init(this).ptr()), .flags = std.c.EV_ADD | one_shot_flag, .ext = .{ this.generation_number, 0 }, }, @@ -3911,7 +3915,7 @@ pub const FilePoll = struct { .filter = std.os.system.EVFILT_READ, .data = 0, .fflags = 0, - .udata = @ptrToInt(Pollable.init(this).ptr()), + .udata = @intFromPtr(Pollable.init(this).ptr()), .flags = std.c.EV_DELETE, .ext = .{ 0, 0 }, }, @@ -3920,7 +3924,7 @@ pub const FilePoll = struct { .filter = std.os.system.EVFILT_MACHPORT, .data = 0, .fflags = 0, - .udata = @ptrToInt(Pollable.init(this).ptr()), + .udata = @intFromPtr(Pollable.init(this).ptr()), .flags = std.c.EV_DELETE, .ext = .{ 0, 0 }, }, @@ -3929,7 +3933,7 @@ pub const FilePoll = struct { .filter = std.os.system.EVFILT_WRITE, .data = 0, .fflags = 0, - .udata = @ptrToInt(Pollable.init(this).ptr()), + .udata = @intFromPtr(Pollable.init(this).ptr()), .flags = std.c.EV_DELETE, .ext = .{ 0, 0 }, }, @@ -3938,7 +3942,7 @@ pub const FilePoll = struct { .filter = std.os.system.EVFILT_PROC, .data = 0, .fflags = std.c.NOTE_EXIT, - .udata = @ptrToInt(Pollable.init(this).ptr()), + .udata = @intFromPtr(Pollable.init(this).ptr()), .flags = std.c.EV_DELETE, .ext = .{ 0, 0 }, }, @@ -3973,7 +3977,7 @@ pub const FilePoll = struct { const errno = std.c.getErrno(rc); switch (rc) { - std.math.minInt(@TypeOf(rc))...-1 => return JSC.Maybe(void).errnoSys(@enumToInt(errno), .kevent).?, + std.math.minInt(@TypeOf(rc))...-1 => return JSC.Maybe(void).errnoSys(@intFromEnum(errno), .kevent).?, else => {}, } } else { diff --git a/src/bun.js/bindings/FFI.zig b/src/bun.js/bindings/FFI.zig index 087d8308c..fde4a8d30 100644 --- a/src/bun.js/bindings/FFI.zig +++ b/src/bun.js/bindings/FFI.zig @@ -42,7 +42,7 @@ pub inline fn JSVALUE_TO_UINT64(arg_value: EncodedJSValue) u64 { return @bitCast(u64, @as(c_longlong, JSVALUE_TO_INT32(value))); } if (JSVALUE_IS_NUMBER(value)) { - return @floatToInt(u64, JSVALUE_TO_DOUBLE(value)); + return @intFromFloat(u64, JSVALUE_TO_DOUBLE(value)); } return JSVALUE_TO_UINT64_SLOW(value); } @@ -52,7 +52,7 @@ pub inline fn JSVALUE_TO_INT64(arg_value: EncodedJSValue) i64 { return @bitCast(i64, @as(c_longlong, JSVALUE_TO_INT32(value))); } if (JSVALUE_IS_NUMBER(value)) { - return @floatToInt(i64, JSVALUE_TO_DOUBLE(value)); + return @intFromFloat(i64, JSVALUE_TO_DOUBLE(value)); } return JSVALUE_TO_INT64_SLOW(value); } @@ -67,7 +67,7 @@ pub inline fn UINT64_TO_JSVALUE(arg_globalObject: ?*anyopaque, arg_val: u64) Enc return INT32_TO_JSVALUE(@bitCast(i32, @truncate(c_uint, val))); } if (val < @bitCast(c_ulonglong, @as(c_longlong, @as(c_long, 9007199254740991)))) { - return DOUBLE_TO_JSVALUE(@intToFloat(f64, val)); + return DOUBLE_TO_JSVALUE(@floatFromInt(f64, val)); } return UINT64_TO_JSVALUE_SLOW(@ptrCast(*@import("./bindings.zig").JSGlobalObject, globalObject.?), val).asEncoded(); } @@ -78,7 +78,7 @@ pub inline fn INT64_TO_JSVALUE(arg_globalObject: ?*anyopaque, arg_val: i64) Enco return INT32_TO_JSVALUE(@bitCast(i32, @truncate(c_int, val))); } if ((val >= @bitCast(c_longlong, @as(c_longlong, -@as(c_long, 9007199254740991)))) and (val <= @bitCast(c_longlong, @as(c_longlong, @as(c_long, 9007199254740991))))) { - return DOUBLE_TO_JSVALUE(@intToFloat(f64, val)); + return DOUBLE_TO_JSVALUE(@floatFromInt(f64, val)); } return INT64_TO_JSVALUE_SLOW(@ptrCast(*@import("./bindings.zig").JSGlobalObject, globalObject.?), val).asEncoded(); } @@ -97,18 +97,18 @@ pub inline fn FLOAT_TO_JSVALUE(arg_val: f32) EncodedJSValue { pub inline fn BOOLEAN_TO_JSVALUE(arg_val: @"bool") EncodedJSValue { var val = arg_val; var res: EncodedJSValue = undefined; - res.asInt64 = @bitCast(i64, @as(c_longlong, if (@as(c_int, @boolToInt(val)) != 0) (@as(c_int, 2) | @as(c_int, 4)) | @as(c_int, 1) else (@as(c_int, 2) | @as(c_int, 4)) | @as(c_int, 0))); + res.asInt64 = @bitCast(i64, @as(c_longlong, if (@as(c_int, @intFromBool(val)) != 0) (@as(c_int, 2) | @as(c_int, 4)) | @as(c_int, 1) else (@as(c_int, 2) | @as(c_int, 4)) | @as(c_int, 0))); return res; } pub inline fn PTR_TO_JSVALUE(arg_ptr: ?*anyopaque) EncodedJSValue { var ptr = arg_ptr; var val: EncodedJSValue = undefined; - val.asInt64 = @intCast(i64, @ptrToInt(ptr)) + (@as(c_longlong, 1) << @intCast(@import("std").math.Log2Int(c_longlong), 49)); + val.asInt64 = @intCast(i64, @intFromPtr(ptr)) + (@as(c_longlong, 1) << @intCast(@import("std").math.Log2Int(c_longlong), 49)); return val; } pub inline fn JSVALUE_TO_PTR(arg_val: EncodedJSValue) ?*anyopaque { var val = arg_val; - return @intToPtr(?*anyopaque, val.asInt64 - (@as(c_longlong, 1) << @intCast(@import("std").math.Log2Int(c_longlong), 49))); + return @ptrFromInt(?*anyopaque, val.asInt64 - (@as(c_longlong, 1) << @intCast(@import("std").math.Log2Int(c_longlong), 49))); } pub inline fn JSVALUE_TO_INT32(arg_val: EncodedJSValue) i32 { var val = arg_val; diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 35c9d26fa..581fc6f85 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -370,11 +370,11 @@ pub const ZigString = extern struct { } pub fn markStatic(this: *ZigString) void { - this.ptr = @intToPtr([*]const u8, @ptrToInt(this.ptr) | (1 << 60)); + this.ptr = @ptrFromInt([*]const u8, @intFromPtr(this.ptr) | (1 << 60)); } pub fn isStatic(this: *const ZigString) bool { - return @ptrToInt(this.ptr) & (1 << 60) != 0; + return @intFromPtr(this.ptr) & (1 << 60) != 0; } pub const Slice = struct { @@ -483,7 +483,7 @@ pub const ZigString = extern struct { } pub fn mut(this: Slice) []u8 { - return @intToPtr([*]u8, @ptrToInt(this.ptr))[0..this.len]; + return @ptrFromInt([*]u8, @intFromPtr(this.ptr))[0..this.len]; } /// Does nothing if the slice is not allocated @@ -504,7 +504,7 @@ pub const ZigString = extern struct { pub const namespace = ""; pub inline fn is16Bit(this: *const ZigString) bool { - return (@ptrToInt(this._unsafe_ptr_do_not_use) & (1 << 63)) != 0; + return (@intFromPtr(this._unsafe_ptr_do_not_use) & (1 << 63)) != 0; } pub inline fn utf16Slice(this: *const ZigString) []align(1) const u16 { @@ -539,7 +539,7 @@ pub const ZigString = extern struct { } pub fn sortDesc(slice_: []ZigString) void { - std.sort.sort(ZigString, slice_, {}, cmpDesc); + std.sort.block(ZigString, slice_, {}, cmpDesc); } pub fn cmpDesc(_: void, a: ZigString, b: ZigString) bool { @@ -547,7 +547,7 @@ pub const ZigString = extern struct { } pub fn sortAsc(slice_: []ZigString) void { - std.sort.sort(ZigString, slice_, {}, cmpAsc); + std.sort.block(ZigString, slice_, {}, cmpAsc); } pub fn cmpAsc(_: void, a: ZigString, b: ZigString) bool { @@ -641,15 +641,15 @@ pub const ZigString = extern struct { } pub fn isUTF8(this: ZigString) bool { - return (@ptrToInt(this._unsafe_ptr_do_not_use) & (1 << 61)) != 0; + return (@intFromPtr(this._unsafe_ptr_do_not_use) & (1 << 61)) != 0; } pub fn markUTF8(this: *ZigString) void { - this._unsafe_ptr_do_not_use = @intToPtr([*]const u8, @ptrToInt(this._unsafe_ptr_do_not_use) | (1 << 61)); + this._unsafe_ptr_do_not_use = @ptrFromInt([*]const u8, @intFromPtr(this._unsafe_ptr_do_not_use) | (1 << 61)); } pub fn markUTF16(this: *ZigString) void { - this._unsafe_ptr_do_not_use = @intToPtr([*]const u8, @ptrToInt(this._unsafe_ptr_do_not_use) | (1 << 63)); + this._unsafe_ptr_do_not_use = @ptrFromInt([*]const u8, @intFromPtr(this._unsafe_ptr_do_not_use) | (1 << 63)); } pub fn setOutputEncoding(this: *ZigString) void { @@ -658,7 +658,7 @@ pub const ZigString = extern struct { } pub inline fn isGloballyAllocated(this: ZigString) bool { - return (@ptrToInt(this._unsafe_ptr_do_not_use) & (1 << 62)) != 0; + return (@intFromPtr(this._unsafe_ptr_do_not_use) & (1 << 62)) != 0; } pub inline fn deinitGlobal(this: ZigString) void { @@ -668,7 +668,7 @@ pub const ZigString = extern struct { pub const mark = markGlobal; pub inline fn markGlobal(this: *ZigString) void { - this._unsafe_ptr_do_not_use = @intToPtr([*]const u8, @ptrToInt(this._unsafe_ptr_do_not_use) | (1 << 62)); + this._unsafe_ptr_do_not_use = @ptrFromInt([*]const u8, @intFromPtr(this._unsafe_ptr_do_not_use) | (1 << 62)); } pub fn format(self: ZigString, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { @@ -694,7 +694,7 @@ pub const ZigString = extern struct { inline fn untagged(ptr: [*]const u8) [*]const u8 { // this can be null ptr, so long as it's also a 0 length string @setRuntimeSafety(false); - return @intToPtr([*]const u8, @truncate(u53, @ptrToInt(ptr))); + return @ptrFromInt([*]const u8, @truncate(u53, @intFromPtr(ptr))); } pub fn slice(this: *const ZigString) []const u8 { @@ -1303,7 +1303,7 @@ pub const FetchHeaders = opaque { this: *FetchHeaders, name_: HTTPHeaderName, ) bool { - return fastHas_(this, @enumToInt(name_)); + return fastHas_(this, @intFromEnum(name_)); } pub fn fastGet( @@ -1311,7 +1311,7 @@ pub const FetchHeaders = opaque { name_: HTTPHeaderName, ) ?ZigString { var str = ZigString.init(""); - fastGet_(this, @enumToInt(name_), &str); + fastGet_(this, @intFromEnum(name_), &str); if (str.len == 0) { return null; } @@ -1441,7 +1441,7 @@ pub const FetchHeaders = opaque { this: *FetchHeaders, header: HTTPHeaderName, ) void { - return fastRemove_(this, @enumToInt(header)); + return fastRemove_(this, @intFromEnum(header)); } pub fn fastRemove_( @@ -1611,11 +1611,11 @@ pub const Sizes = @import("../bindings/sizes.zig"); pub const JSUint8Array = opaque { pub const name = "Uint8Array_alias"; pub fn ptr(this: *JSUint8Array) [*]u8 { - return @intToPtr(*[*]u8, @ptrToInt(this) + Sizes.Bun_FFI_PointerOffsetToTypedArrayVector).*; + return @ptrFromInt(*[*]u8, @intFromPtr(this) + Sizes.Bun_FFI_PointerOffsetToTypedArrayVector).*; } pub fn len(this: *JSUint8Array) usize { - return @intToPtr(*usize, @ptrToInt(this) + Sizes.Bun_FFI_PointerOffsetToTypedArrayLength).*; + return @ptrFromInt(*usize, @intFromPtr(this) + Sizes.Bun_FFI_PointerOffsetToTypedArrayLength).*; } pub fn slice(this: *JSUint8Array) []u8 { @@ -3156,7 +3156,7 @@ pub const JSValue = enum(JSValueReprInt) { pub fn isObject(this: JSType) bool { // inline constexpr bool isObjectType(JSType type) { return type >= ObjectType; } - return @enumToInt(this) >= @enumToInt(JSType.Object); + return @intFromEnum(this) >= @intFromEnum(JSType.Object); } pub fn isFunction(this: JSType) bool { @@ -3311,7 +3311,7 @@ pub const JSValue = enum(JSValueReprInt) { }; pub inline fn cast(ptr: anytype) JSValue { - return @intToEnum(JSValue, @bitCast(i64, @ptrToInt(ptr))); + return @enumFromInt(JSValue, @bitCast(i64, @intFromPtr(ptr))); } pub fn coerceToInt32(this: JSValue, globalThis: *JSC.JSGlobalObject) i32 { @@ -3808,7 +3808,7 @@ pub const JSValue = enum(JSValueReprInt) { return jsNumberFromInt32(@intCast(i32, i)); } - return jsNumberFromDouble(@intToFloat(f64, @truncate(i52, i))); + return jsNumberFromDouble(@floatFromInt(f64, @truncate(i52, i))); } pub inline fn toJS(this: JSValue, _: *const JSGlobalObject) JSValue { @@ -3820,7 +3820,7 @@ pub const JSValue = enum(JSValueReprInt) { return jsNumberFromInt32(@intCast(i32, i)); } - return jsNumberFromDouble(@intToFloat(f64, @intCast(i52, @truncate(u51, i)))); + return jsNumberFromDouble(@floatFromInt(f64, @intCast(i52, @truncate(u51, i)))); } pub fn coerceDoubleTruncatingIntoInt64(this: JSValue) i64 { @@ -3834,7 +3834,7 @@ pub const JSValue = enum(JSValueReprInt) { return if (double_value < 0) @as(i64, std.math.minInt(i64)) else @as(i64, std.math.maxInt(i64)); } - return @floatToInt( + return @intFromFloat( i64, double_value, ); @@ -3871,26 +3871,26 @@ pub const JSValue = enum(JSValueReprInt) { } pub inline fn isUndefined(this: JSValue) bool { - return @enumToInt(this) == 0xa; + return @intFromEnum(this) == 0xa; } pub inline fn isNull(this: JSValue) bool { - return @enumToInt(this) == 0x2; + return @intFromEnum(this) == 0x2; } pub inline fn isEmptyOrUndefinedOrNull(this: JSValue) bool { - return switch (@enumToInt(this)) { + return switch (@intFromEnum(this)) { 0, 0xa, 0x2 => true, else => false, }; } pub fn isUndefinedOrNull(this: JSValue) bool { - return switch (@enumToInt(this)) { + return switch (@intFromEnum(this)) { 0xa, 0x2 => true, else => false, }; } /// Empty as in "JSValue {}" rather than an empty string pub inline fn isEmpty(this: JSValue) bool { - return switch (@enumToInt(this)) { + return switch (@intFromEnum(this)) { 0 => true, else => false, }; @@ -4016,7 +4016,7 @@ pub const JSValue = enum(JSValueReprInt) { pub inline fn isCell(this: JSValue) bool { return switch (this) { .zero, .undefined, .null, .true, .false => false, - else => (@bitCast(u64, @enumToInt(this)) & FFI.NotCellMask) == 0, + else => (@bitCast(u64, @intFromEnum(this)) & FFI.NotCellMask) == 0, }; } @@ -4179,7 +4179,7 @@ pub const JSValue = enum(JSValueReprInt) { // intended to be more lightweight than ZigString pub fn fastGet(this: JSValue, global: *JSGlobalObject, builtin_name: BuiltinName) ?JSValue { - const result = fastGet_(this, global, @enumToInt(builtin_name)); + const result = fastGet_(this, global, @intFromEnum(builtin_name)); if (result == .zero) { return null; } @@ -4188,7 +4188,7 @@ pub const JSValue = enum(JSValueReprInt) { } pub fn fastGetDirect(this: JSValue, global: *JSGlobalObject, builtin_name: BuiltinName) ?JSValue { - const result = fastGetDirect_(this, global, @enumToInt(builtin_name)); + const result = fastGetDirect_(this, global, @intFromEnum(builtin_name)); if (result == .zero) { return null; } @@ -4243,7 +4243,7 @@ pub const JSValue = enum(JSValueReprInt) { pub fn get(this: JSValue, global: *JSGlobalObject, property: []const u8) ?JSValue { const value = getIfPropertyExistsImpl(this, global, property.ptr, @intCast(u32, property.len)); - return if (@enumToInt(value) != 0) value else return null; + return if (@intFromEnum(value) != 0) value else return null; } pub fn implementsToString(this: JSValue, global: *JSGlobalObject) bool { @@ -4407,7 +4407,7 @@ pub const JSValue = enum(JSValueReprInt) { /// This algorithm differs from the IsStrictlyEqual Algorithm by treating all NaN values as equivalent and by differentiating +0𝔽 from -0𝔽. /// https://tc39.es/ecma262/#sec-samevalue pub fn isSameValue(this: JSValue, other: JSValue, global: *JSGlobalObject) bool { - return @enumToInt(this) == @enumToInt(other) or cppFn("isSameValue", .{ this, other, global }); + return @intFromEnum(this) == @intFromEnum(other) or cppFn("isSameValue", .{ this, other, global }); } pub fn deepEquals(this: JSValue, other: JSValue, global: *JSGlobalObject) bool { @@ -4460,7 +4460,7 @@ pub const JSValue = enum(JSValueReprInt) { /// Get the internal number of the `JSC::DateInstance` object /// Returns NaN if the value is not a `JSC::DateInstance` (`Date` in JS) - pub fn getUnixTimestamp(this: JSValue) f64 { + pub fn getUnixTimestamp(this: JSValue) f64 { return cppFn("getUnixTimestamp", .{ this, }); @@ -4492,7 +4492,7 @@ pub const JSValue = enum(JSValueReprInt) { pub fn asNumber(this: JSValue) f64 { if (this.isInt32()) { - return @intToFloat(f64, this.asInt32()); + return @floatFromInt(f64, this.asInt32()); } if (isNumber(this)) { @@ -4515,19 +4515,19 @@ pub const JSValue = enum(JSValueReprInt) { } pub fn asPtr(this: JSValue, comptime Pointer: type) *Pointer { - return @intToPtr(*Pointer, this.asPtrAddress()); + return @ptrFromInt(*Pointer, this.asPtrAddress()); } pub fn fromPtrAddress(addr: anytype) JSValue { - return jsNumber(@intToFloat(f64, @bitCast(usize, @as(usize, addr)))); + return jsNumber(@floatFromInt(f64, @bitCast(usize, @as(usize, addr)))); } pub fn asPtrAddress(this: JSValue) usize { - return @bitCast(usize, @floatToInt(usize, this.asDouble())); + return @bitCast(usize, @intFromFloat(usize, this.asDouble())); } pub fn fromPtr(addr: anytype) JSValue { - return fromPtrAddress(@ptrToInt(addr)); + return fromPtrAddress(@intFromPtr(addr)); } pub fn toBooleanSlow(this: JSValue, global: *JSGlobalObject) bool { @@ -4552,7 +4552,7 @@ pub const JSValue = enum(JSValueReprInt) { } if (this.isNumber()) { - return @truncate(i32, @floatToInt(i64, asDouble(this))); + return @truncate(i32, @intFromFloat(i64, asDouble(this))); } if (comptime bun.Environment.allow_assert) { @@ -4591,11 +4591,11 @@ pub const JSValue = enum(JSValueReprInt) { /// If the "length" property does not exist, this function will return 0. pub fn getLength(this: JSValue, globalThis: *JSGlobalObject) u64 { const len = this.getLengthIfPropertyExistsInternal(globalThis); - if (len == std.math.f64_max) { + if (len == std.math.floatMax(f64)) { return 0; } - return @floatToInt(u64, @max(len, 0)); + return @intFromFloat(u64, @max(len, 0)); } /// This function supports: @@ -4612,11 +4612,11 @@ pub const JSValue = enum(JSValueReprInt) { /// If the "length" property does not exist, this function will return null. pub fn tryGetLength(this: JSValue, globalThis: *JSGlobalObject) ?f64 { const len = this.getLengthIfPropertyExistsInternal(globalThis); - if (len == std.math.f64_max) { + if (len == std.math.floatMax(f64)) { return null; } - return @floatToInt(u64, @max(len, 0)); + return @intFromFloat(u64, @max(len, 0)); } /// Do not use this directly! @@ -4661,15 +4661,15 @@ pub const JSValue = enum(JSValueReprInt) { } pub inline fn asRef(this: JSValue) C_API.JSValueRef { - return @intToPtr(C_API.JSValueRef, @bitCast(usize, @enumToInt(this))); + return @ptrFromInt(C_API.JSValueRef, @bitCast(usize, @intFromEnum(this))); } pub inline fn c(this: C_API.JSValueRef) JSValue { - return @intToEnum(JSValue, @bitCast(JSValue.Type, @ptrToInt(this))); + return @enumFromInt(JSValue, @bitCast(JSValue.Type, @intFromPtr(this))); } pub inline fn fromRef(this: C_API.JSValueRef) JSValue { - return @intToEnum(JSValue, @bitCast(JSValue.Type, @ptrToInt(this))); + return @enumFromInt(JSValue, @bitCast(JSValue.Type, @intFromPtr(this))); } pub inline fn asObjectRef(this: JSValue) C_API.JSObjectRef { @@ -4685,12 +4685,12 @@ pub const JSValue = enum(JSValueReprInt) { } pub inline fn asNullableVoid(this: JSValue) ?*anyopaque { - return @intToPtr(?*anyopaque, @bitCast(usize, @enumToInt(this))); + return @ptrFromInt(?*anyopaque, @bitCast(usize, @intFromEnum(this))); } pub inline fn asVoid(this: JSValue) *anyopaque { if (comptime bun.Environment.allow_assert) { - if (@enumToInt(this) == 0) { + if (@intFromEnum(this) == 0) { @panic("JSValue is null"); } } @@ -4857,7 +4857,7 @@ pub const Exception = extern struct { pub fn create(globalObject: *JSGlobalObject, object: *JSObject, stack_capture: StackCaptureAction) *Exception { return cppFn( "create", - .{ globalObject, object, @enumToInt(stack_capture) }, + .{ globalObject, object, @intFromEnum(stack_capture) }, ); } @@ -4893,7 +4893,7 @@ pub const VM = extern struct { LargeHeap = 1, }; pub fn create(heap_type: HeapType) *VM { - return cppFn("create", .{@enumToInt(heap_type)}); + return cppFn("create", .{@intFromEnum(heap_type)}); } pub fn deinit(vm: *VM, global_object: *JSGlobalObject) void { @@ -5157,16 +5157,16 @@ pub const CallFrame = opaque { pub fn arguments(self: *const CallFrame, comptime max: usize) Arguments(max) { const len = self.argumentsCount(); var ptr = self.argumentsPtr(); - return switch (@min(len, max)) { + return switch (@as(u4, @min(len, max))) { 0 => .{ .ptr = undefined, .len = 0 }, - 1 => Arguments(max).init(1, ptr), - 2 => Arguments(max).init(@min(2, max), ptr), - 3 => Arguments(max).init(@min(3, max), ptr), - 4 => Arguments(max).init(@min(4, max), ptr), - 5 => Arguments(max).init(@min(5, max), ptr), - 6 => Arguments(max).init(@min(6, max), ptr), - 7 => Arguments(max).init(@min(7, max), ptr), - 8 => Arguments(max).init(@min(8, max), ptr), + 4 => Arguments(max).init(comptime @min(4, max), ptr), + 2 => Arguments(max).init(comptime @min(2, max), ptr), + 6 => Arguments(max).init(comptime @min(6, max), ptr), + 3 => Arguments(max).init(comptime @min(3, max), ptr), + 8 => Arguments(max).init(comptime @min(8, max), ptr), + 5 => Arguments(max).init(comptime @min(5, max), ptr), + 1 => Arguments(max).init(comptime @min(1, max), ptr), + 7 => Arguments(max).init(comptime @min(7, max), ptr), else => unreachable, }; } diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index 6ea1eba60..de3f819b7 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -112,11 +112,11 @@ pub const ErrorCode = enum(ErrorCodeInt) { _, pub inline fn from(code: anyerror) ErrorCode { - return @intToEnum(ErrorCode, @errorToInt(code)); + return @enumFromInt(ErrorCode, @intFromError(code)); } - pub const ParserError = @enumToInt(ErrorCode.from(error.ParserError)); - pub const JSErrorObject = @enumToInt(ErrorCode.from(error.JSErrorObject)); + pub const ParserError = @intFromEnum(ErrorCode.from(error.ParserError)); + pub const JSErrorObject = @intFromEnum(ErrorCode.from(error.JSErrorObject)); pub const Type = ErrorCodeInt; }; @@ -244,7 +244,7 @@ export fn ZigString__free(raw: [*]const u8, len: usize, allocator_: ?*anyopaque) } export fn ZigString__free_global(ptr: [*]const u8, len: usize) void { - var untagged = @intToPtr(*anyopaque, @ptrToInt(ZigString.init(ptr[0..len]).slice().ptr)); + var untagged = @ptrFromInt(*anyopaque, @intFromPtr(ZigString.init(ptr[0..len]).slice().ptr)); if (comptime Environment.allow_assert) { std.debug.assert(Mimalloc.mi_is_in_heap_region(ptr)); } @@ -561,7 +561,7 @@ pub const ZigStackFrame = extern struct { frame.position.source_offset = this.position.source_offset; // For remapped code, we add 1 to the line number - frame.position.line = this.position.line + @as(i32, @boolToInt(this.remapped)); + frame.position.line = this.position.line + @as(i32, @intFromBool(this.remapped)); frame.position.line_start = this.position.line_start; frame.position.line_stop = this.position.line_stop; @@ -569,7 +569,7 @@ pub const ZigStackFrame = extern struct { frame.position.column_stop = this.position.column_stop; frame.position.expression_start = this.position.expression_start; frame.position.expression_stop = this.position.expression_stop; - frame.scope = @intToEnum(Api.StackFrameScope, @enumToInt(this.code_type)); + frame.scope = @enumFromInt(Api.StackFrameScope, @intFromEnum(this.code_type)); return frame; } @@ -775,18 +775,18 @@ pub const ZigException = extern struct { pub const Zero: Holder = Holder{ .frames = brk: { var _frames: [frame_count]ZigStackFrame = undefined; - std.mem.set(ZigStackFrame, &_frames, ZigStackFrame.Zero); + @memset(&_frames, ZigStackFrame.Zero); break :brk _frames; }, .source_line_numbers = brk: { var lines: [source_lines_count]i32 = undefined; - std.mem.set(i32, &lines, -1); + @memset(&lines, -1); break :brk lines; }, .source_lines = brk: { var lines: [source_lines_count]ZigString = undefined; - std.mem.set(ZigString, &lines, ZigString.Empty); + @memset(&lines, ZigString.Empty); break :brk lines; }, .zig_exception = undefined, @@ -800,7 +800,7 @@ pub const ZigException = extern struct { pub fn zigException(this: *Holder) *ZigException { if (!this.loaded) { this.zig_exception = ZigException{ - .code = @intToEnum(JSErrorCode, 255), + .code = @enumFromInt(JSErrorCode, 255), .runtime_type = JSRuntimeType.Nothing, .name = ZigString.Empty, .message = ZigString.Empty, @@ -836,8 +836,8 @@ pub const ZigException = extern struct { var is_empty = true; var api_exception = Api.JsException{ - .runtime_type = @enumToInt(this.runtime_type), - .code = @enumToInt(this.code), + .runtime_type = @intFromEnum(this.runtime_type), + .code = @intFromEnum(this.code), }; if (_name.len > 0) { @@ -1314,7 +1314,7 @@ pub const ZigConsoleClient = struct { }; pub fn getAdvanced(value: JSValue, globalThis: *JSGlobalObject, opts: Options) Result { - switch (@enumToInt(value)) { + switch (@intFromEnum(value)) { 0, 0xa => return Result{ .tag = .Undefined, }, @@ -1878,7 +1878,7 @@ pub const ZigConsoleClient = struct { this.map = this.map_node.?.data; } - var entry = this.map.getOrPut(@enumToInt(value)) catch unreachable; + var entry = this.map.getOrPut(@intFromEnum(value)) catch unreachable; if (entry.found_existing) { writer.writeAll(comptime Output.prettyFmt("[Circular]", enable_ansi_colors)); return; @@ -1887,7 +1887,7 @@ pub const ZigConsoleClient = struct { defer { if (comptime Format.canHaveCircularReferences()) { - _ = this.map.remove(@enumToInt(value)); + _ = this.map.remove(@intFromEnum(value)); } } @@ -1959,7 +1959,7 @@ pub const ZigConsoleClient = struct { i = -i; } const digits = if (i != 0) - bun.fmt.fastDigitCount(@intCast(usize, i)) + @as(usize, @boolToInt(is_negative)) + bun.fmt.fastDigitCount(@intCast(usize, i)) + @as(usize, @intFromBool(is_negative)) else 1; this.addForNewLine(digits); @@ -2559,7 +2559,7 @@ pub const ZigConsoleClient = struct { { this.indent += 1; defer this.indent -|= 1; - const count_without_children = props_iter.len - @as(usize, @boolToInt(children_prop != null)); + const count_without_children = props_iter.len - @as(usize, @intFromBool(children_prop != null)); while (props_iter.next()) |prop| { if (prop.eqlComptime("children")) @@ -3002,7 +3002,7 @@ pub const ZigConsoleClient = struct { chars: [*]const u8, len: usize, ) callconv(.C) void { - const id = std.hash.Wyhash.hash(0, chars[0..len]); + const id = bun.hash(chars[0..len]); if (!pending_time_logs_loaded) { pending_time_logs = PendingTimers.init(default_allocator); pending_time_logs_loaded = true; @@ -3026,12 +3026,12 @@ pub const ZigConsoleClient = struct { return; } - const id = std.hash.Wyhash.hash(0, chars[0..len]); + const id = bun.hash(chars[0..len]); var result = (pending_time_logs.fetchPut(id, null) catch null) orelse return; var value: std.time.Timer = result.value orelse return; // get the duration in microseconds // then display it in milliseconds - Output.printElapsed(@intToFloat(f64, value.read() / std.time.ns_per_us) / std.time.us_per_ms); + Output.printElapsed(@floatFromInt(f64, value.read() / std.time.ns_per_us) / std.time.us_per_ms); switch (len) { 0 => Output.printErrorln("\n", .{}), else => Output.printErrorln(" {s}", .{chars[0..len]}), @@ -3056,11 +3056,11 @@ pub const ZigConsoleClient = struct { return; } - const id = std.hash.Wyhash.hash(0, chars[0..len]); + const id = bun.hash(chars[0..len]); var value: std.time.Timer = (pending_time_logs.get(id) orelse return) orelse return; // get the duration in microseconds // then display it in milliseconds - Output.printElapsed(@intToFloat(f64, value.read() / std.time.ns_per_us) / std.time.us_per_ms); + Output.printElapsed(@floatFromInt(f64, value.read() / std.time.ns_per_us) / std.time.us_per_ms); switch (len) { 0 => Output.printErrorln("\n", .{}), else => Output.printErrorln(" {s}", .{chars[0..len]}), diff --git a/src/bun.js/bindings/header-gen.zig b/src/bun.js/bindings/header-gen.zig index 089506a8f..eb0de1c09 100644 --- a/src/bun.js/bindings/header-gen.zig +++ b/src/bun.js/bindings/header-gen.zig @@ -807,7 +807,7 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp } }; var extern_list = Type.Extern; - std.sort.sort([]const u8, &extern_list, Sorder{}, Sorder.lessThan); + std.sort.block([]const u8, &extern_list, Sorder{}, Sorder.lessThan); break :brk extern_list; }; // impl_writer.print(" #include {s}\n", .{Type.include}) catch unreachable; @@ -840,7 +840,7 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp } }; var extern_list = Type.Export; - std.sort.sort(StaticExport, &extern_list, Sorder{}, Sorder.lessThan); + std.sort.block(StaticExport, &extern_list, Sorder{}, Sorder.lessThan); break :brk extern_list; }; @@ -867,7 +867,7 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp // } // }; // var extern_list = Type.lazy_static_functions; - // std.sort.sort(StaticExport, &extern_list, Sorder{}, Sorder.lessThan); + // std.sort.block(StaticExport, &extern_list, Sorder{}, Sorder.lessThan); // break :brk extern_list; // }; diff --git a/src/bun.js/bindings/shimmer.zig b/src/bun.js/bindings/shimmer.zig index a90bfab87..3a6242000 100644 --- a/src/bun.js/bindings/shimmer.zig +++ b/src/bun.js/bindings/shimmer.zig @@ -163,7 +163,7 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp if (comptime isNullableType(ExpectedReturnType) != isNullableType(ExternReturnType)) { return value.?; } else if (comptime (@typeInfo(ExpectedReturnType) == .Enum) and (@typeInfo(ExternReturnType) != .Enum)) { - return @intToEnum(ExpectedReturnType, value); + return @enumFromInt(ExpectedReturnType, value); } else { return value; } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index d458b6e7e..545f41f19 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -196,7 +196,7 @@ pub const SavedSourceMap = struct { pub const SourceMapHandler = js_printer.SourceMapHandler.For(SavedSourceMap, onSourceMapChunk); pub fn putMappings(this: *SavedSourceMap, source: logger.Source, mappings: MutableString) !void { - var entry = try this.map.getOrPut(std.hash.Wyhash.hash(0, source.path.text)); + var entry = try this.map.getOrPut(bun.hash(source.path.text)); if (entry.found_existing) { var value = Value.from(entry.value_ptr.*); if (value.get(MappingList)) |source_map_| { @@ -213,7 +213,7 @@ pub const SavedSourceMap = struct { } pub fn get(this: *SavedSourceMap, path: string) ?MappingList { - var mapping = this.map.getEntry(std.hash.Wyhash.hash(0, path)) orelse return null; + var mapping = this.map.getEntry(bun.hash(path)) orelse return null; switch (Value.from(mapping.value_ptr.*).tag()) { (@field(Value.Tag, @typeName(MappingList))) => { return Value.from(mapping.value_ptr.*).as(MappingList).*; @@ -264,7 +264,7 @@ export fn Bun__readOriginTimer(vm: *JSC.VirtualMachine) u64 { export fn Bun__readOriginTimerStart(vm: *JSC.VirtualMachine) f64 { // timespce to milliseconds - return @floatCast(f64, (@intToFloat(f64, vm.origin_timestamp) + JSC.VirtualMachine.origin_relative_epoch) / 1_000_000.0); + return @floatCast(f64, (@floatFromInt(f64, vm.origin_timestamp) + JSC.VirtualMachine.origin_relative_epoch) / 1_000_000.0); } // comptime { @@ -1382,7 +1382,7 @@ pub const VirtualMachine = struct { // // This double prints // pub fn promiseRejectionTracker(global: *JSGlobalObject, promise: *JSPromise, _: JSPromiseRejectionOperation) callconv(.C) JSValue { // const result = promise.result(global.vm()); - // if (@enumToInt(VirtualMachine.get().last_error_jsvalue) != @enumToInt(result)) { + // if (@intFromEnum(VirtualMachine.get().last_error_jsvalue) != @intFromEnum(result)) { // VirtualMachine.get().runErrorHandler(result, null); // } @@ -1823,7 +1823,7 @@ pub const VirtualMachine = struct { iterator(_vm, globalObject, nextValue, ctx.?, false); } inline fn iterator(_: [*c]VM, _: [*c]JSGlobalObject, nextValue: JSValue, ctx: ?*anyopaque, comptime color: bool) void { - var this_ = @intToPtr(*@This(), @ptrToInt(ctx)); + var this_ = @ptrFromInt(*@This(), @intFromPtr(ctx)); VirtualMachine.get().printErrorlikeObject(nextValue, null, this_.current_exception_list, Writer, this_.writer, color, allow_side_effects); } }; @@ -2066,8 +2066,8 @@ pub const VirtualMachine = struct { )) |lines| { var source_lines = exception.stack.source_lines_ptr[0..JSC.ZigException.Holder.source_lines_count]; var source_line_numbers = exception.stack.source_lines_numbers[0..JSC.ZigException.Holder.source_lines_count]; - std.mem.set(ZigString, source_lines, ZigString.Empty); - std.mem.set(i32, source_line_numbers, 0); + @memset(source_lines, ZigString.Empty); + @memset(source_line_numbers, 0); var lines_ = lines[0..@min(lines.len, source_lines.len)]; for (lines_, 0..) |line, j| { @@ -2374,7 +2374,7 @@ pub const EventListenerMixin = struct { const FetchEventRejectionHandler = struct { pub fn onRejection(_ctx: *anyopaque, err: anyerror, fetch_event: *FetchEvent, value: JSValue) void { onError( - @intToPtr(*CtxType, @ptrToInt(_ctx)), + @ptrFromInt(*CtxType, @intFromPtr(_ctx)), err, value, fetch_event.request_context.?, @@ -2763,10 +2763,10 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime break :brk path_string.slice(); } else { var file_path_without_trailing_slash = std.mem.trimRight(u8, file_path, std.fs.path.sep_str); - @memcpy(&_on_file_update_path_buf, file_path_without_trailing_slash.ptr, file_path_without_trailing_slash.len); + @memcpy(_on_file_update_path_buf[0..file_path_without_trailing_slash.len], file_path_without_trailing_slash); _on_file_update_path_buf[file_path_without_trailing_slash.len] = std.fs.path.sep; - @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len + 1 ..].ptr, changed_name.ptr, changed_name.len); + @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len..][0..changed_name.len], changed_name); const path_slice = _on_file_update_path_buf[0 .. file_path_without_trailing_slash.len + changed_name.len + 1]; file_hash = @This().Watcher.getHash(path_slice); break :brk path_slice; diff --git a/src/bun.js/javascript_core_c_api.zig b/src/bun.js/javascript_core_c_api.zig index 37f9df15d..aba143a81 100644 --- a/src/bun.js/javascript_core_c_api.zig +++ b/src/bun.js/javascript_core_c_api.zig @@ -9,7 +9,7 @@ const std = @import("std"); const cpp = @import("./bindings/bindings.zig"); const generic = opaque { pub fn value(this: *const @This()) cpp.JSValue { - return @intToEnum(cpp.JSValue, @bitCast(cpp.JSValue.Type, @ptrToInt(this))); + return @enumFromInt(cpp.JSValue, @bitCast(cpp.JSValue.Type, @intFromPtr(this))); } pub inline fn bunVM(this: *@This()) *@import("root").bun.JSC.VirtualMachine { @@ -120,13 +120,13 @@ pub const JSType = enum(c_uint) { kJSTypeObject, kJSTypeSymbol, }; -pub const kJSTypeUndefined = @enumToInt(JSType.kJSTypeUndefined); -pub const kJSTypeNull = @enumToInt(JSType.kJSTypeNull); -pub const kJSTypeBoolean = @enumToInt(JSType.kJSTypeBoolean); -pub const kJSTypeNumber = @enumToInt(JSType.kJSTypeNumber); -pub const kJSTypeString = @enumToInt(JSType.kJSTypeString); -pub const kJSTypeObject = @enumToInt(JSType.kJSTypeObject); -pub const kJSTypeSymbol = @enumToInt(JSType.kJSTypeSymbol); +pub const kJSTypeUndefined = @intFromEnum(JSType.kJSTypeUndefined); +pub const kJSTypeNull = @intFromEnum(JSType.kJSTypeNull); +pub const kJSTypeBoolean = @intFromEnum(JSType.kJSTypeBoolean); +pub const kJSTypeNumber = @intFromEnum(JSType.kJSTypeNumber); +pub const kJSTypeString = @intFromEnum(JSType.kJSTypeString); +pub const kJSTypeObject = @intFromEnum(JSType.kJSTypeObject); +pub const kJSTypeSymbol = @intFromEnum(JSType.kJSTypeSymbol); pub const JSTypedArrayType = enum(c_uint) { kJSTypedArrayTypeInt8Array, kJSTypedArrayTypeInt16Array, @@ -141,17 +141,17 @@ pub const JSTypedArrayType = enum(c_uint) { kJSTypedArrayTypeNone, _, }; -pub const kJSTypedArrayTypeInt8Array = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeInt8Array); -pub const kJSTypedArrayTypeInt16Array = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeInt16Array); -pub const kJSTypedArrayTypeInt32Array = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeInt32Array); -pub const kJSTypedArrayTypeUint8Array = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeUint8Array); -pub const kJSTypedArrayTypeUint8ClampedArray = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeUint8ClampedArray); -pub const kJSTypedArrayTypeUint16Array = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeUint16Array); -pub const kJSTypedArrayTypeUint32Array = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeUint32Array); -pub const kJSTypedArrayTypeFloat32Array = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeFloat32Array); -pub const kJSTypedArrayTypeFloat64Array = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeFloat64Array); -pub const kJSTypedArrayTypeArrayBuffer = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeArrayBuffer); -pub const kJSTypedArrayTypeNone = @enumToInt(JSTypedArrayType.kJSTypedArrayTypeNone); +pub const kJSTypedArrayTypeInt8Array = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeInt8Array); +pub const kJSTypedArrayTypeInt16Array = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeInt16Array); +pub const kJSTypedArrayTypeInt32Array = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeInt32Array); +pub const kJSTypedArrayTypeUint8Array = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeUint8Array); +pub const kJSTypedArrayTypeUint8ClampedArray = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeUint8ClampedArray); +pub const kJSTypedArrayTypeUint16Array = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeUint16Array); +pub const kJSTypedArrayTypeUint32Array = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeUint32Array); +pub const kJSTypedArrayTypeFloat32Array = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeFloat32Array); +pub const kJSTypedArrayTypeFloat64Array = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeFloat64Array); +pub const kJSTypedArrayTypeArrayBuffer = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeArrayBuffer); +pub const kJSTypedArrayTypeNone = @intFromEnum(JSTypedArrayType.kJSTypedArrayTypeNone); pub extern fn JSValueGetType(ctx: JSContextRef, value: JSValueRef) JSType; pub extern fn JSValueIsUndefined(ctx: JSContextRef, value: JSValueRef) bool; pub extern fn JSValueIsNull(ctx: JSContextRef, value: JSValueRef) bool; @@ -187,7 +187,7 @@ pub inline fn JSValueUnprotect(ctx: JSContextRef, value: JSValueRef) void { }; if (comptime log_protection) { const Output = @import("root").bun.Output; - Output.debug("[unprotect] {d}\n", .{@ptrToInt(value)}); + Output.debug("[unprotect] {d}\n", .{@intFromPtr(value)}); } // wrapper exists to make it easier to set a breakpoint Wrapped.JSValueUnprotect(ctx, value); @@ -199,7 +199,7 @@ pub inline fn JSValueProtect(ctx: JSContextRef, value: JSValueRef) void { }; if (comptime log_protection) { const Output = @import("root").bun.Output; - Output.debug("[protect] {d}\n", .{@ptrToInt(value)}); + Output.debug("[protect] {d}\n", .{@intFromPtr(value)}); } // wrapper exists to make it easier to set a breakpoint Wrapped.JSValueProtect(ctx, value); @@ -212,18 +212,18 @@ pub const JSPropertyAttributes = enum(c_uint) { kJSPropertyAttributeDontDelete = 8, _, }; -pub const kJSPropertyAttributeNone = @enumToInt(JSPropertyAttributes.kJSPropertyAttributeNone); -pub const kJSPropertyAttributeReadOnly = @enumToInt(JSPropertyAttributes.kJSPropertyAttributeReadOnly); -pub const kJSPropertyAttributeDontEnum = @enumToInt(JSPropertyAttributes.kJSPropertyAttributeDontEnum); -pub const kJSPropertyAttributeDontDelete = @enumToInt(JSPropertyAttributes.kJSPropertyAttributeDontDelete); +pub const kJSPropertyAttributeNone = @intFromEnum(JSPropertyAttributes.kJSPropertyAttributeNone); +pub const kJSPropertyAttributeReadOnly = @intFromEnum(JSPropertyAttributes.kJSPropertyAttributeReadOnly); +pub const kJSPropertyAttributeDontEnum = @intFromEnum(JSPropertyAttributes.kJSPropertyAttributeDontEnum); +pub const kJSPropertyAttributeDontDelete = @intFromEnum(JSPropertyAttributes.kJSPropertyAttributeDontDelete); pub const JSClassAttributes = enum(c_uint) { kJSClassAttributeNone = 0, kJSClassAttributeNoAutomaticPrototype = 2, _, }; -pub const kJSClassAttributeNone = @enumToInt(JSClassAttributes.kJSClassAttributeNone); -pub const kJSClassAttributeNoAutomaticPrototype = @enumToInt(JSClassAttributes.kJSClassAttributeNoAutomaticPrototype); +pub const kJSClassAttributeNone = @intFromEnum(JSClassAttributes.kJSClassAttributeNone); +pub const kJSClassAttributeNoAutomaticPrototype = @intFromEnum(JSClassAttributes.kJSClassAttributeNoAutomaticPrototype); pub const JSObjectInitializeCallback = *const fn (JSContextRef, JSObjectRef) callconv(.C) void; pub const JSObjectFinalizeCallback = *const fn (JSObjectRef) callconv(.C) void; pub const JSObjectHasPropertyCallback = *const fn (JSContextRef, JSObjectRef, JSStringRef) callconv(.C) bool; diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index d115573be..e249bba8b 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -1298,7 +1298,7 @@ pub const ModuleLoader = struct { var encoded = JSC.EncodedJSValue{ .asPtr = globalThis, }; - const globalValue = @intToEnum(JSC.JSValue, encoded.asInt64); + const globalValue = @enumFromInt(JSC.JSValue, encoded.asInt64); globalValue.put( globalThis, JSC.ZigString.static("wasmSourceBytes"), diff --git a/src/bun.js/node/buffer.zig b/src/bun.js/node/buffer.zig index f73498069..3a0750f05 100644 --- a/src/bun.js/node/buffer.zig +++ b/src/bun.js/node/buffer.zig @@ -50,7 +50,7 @@ pub const BufferVectorized = struct { switch (written) { 0 => {}, - 1 => @memset(buf.ptr, buf[0], buf.len), + 1 => @memset(buf, buf[0]), else => { var contents = buf[0..written]; buf = buf[written..]; diff --git a/src/bun.js/node/dir_iterator.zig b/src/bun.js/node/dir_iterator.zig index aa939679c..dac78e5e2 100644 --- a/src/bun.js/node/dir_iterator.zig +++ b/src/bun.js/node/dir_iterator.zig @@ -78,15 +78,15 @@ pub const Iterator = switch (builtin.os.tag) { } const entry_kind = switch (darwin_entry.d_type) { - os.DT.BLK => Entry.Kind.BlockDevice, - os.DT.CHR => Entry.Kind.CharacterDevice, - os.DT.DIR => Entry.Kind.Directory, - os.DT.FIFO => Entry.Kind.NamedPipe, - os.DT.LNK => Entry.Kind.SymLink, - os.DT.REG => Entry.Kind.File, - os.DT.SOCK => Entry.Kind.UnixDomainSocket, - os.DT.WHT => Entry.Kind.Whiteout, - else => Entry.Kind.Unknown, + os.DT.BLK => Entry.Kind.block_device, + os.DT.CHR => Entry.Kind.character_device, + os.DT.DIR => Entry.Kind.directory, + os.DT.FIFO => Entry.Kind.named_pipe, + os.DT.LNK => Entry.Kind.sym_link, + os.DT.REG => Entry.Kind.file, + os.DT.SOCK => Entry.Kind.unix_domain_socket, + os.DT.WHT => Entry.Kind.whiteout, + else => Entry.Kind.unknown, }; return .{ .result = IteratorResult{ @@ -134,14 +134,14 @@ pub const Iterator = switch (builtin.os.tag) { } const entry_kind = switch (linux_entry.d_type) { - linux.DT.BLK => Entry.Kind.BlockDevice, - linux.DT.CHR => Entry.Kind.CharacterDevice, - linux.DT.DIR => Entry.Kind.Directory, - linux.DT.FIFO => Entry.Kind.NamedPipe, - linux.DT.LNK => Entry.Kind.SymLink, - linux.DT.REG => Entry.Kind.File, - linux.DT.SOCK => Entry.Kind.UnixDomainSocket, - else => Entry.Kind.Unknown, + linux.DT.BLK => Entry.Kind.block_device, + linux.DT.CHR => Entry.Kind.character_device, + linux.DT.DIR => Entry.Kind.directory, + linux.DT.FIFO => Entry.Kind.named_pipe, + linux.DT.LNK => Entry.Kind.sym_link, + linux.DT.REG => Entry.Kind.file, + linux.DT.SOCK => Entry.Kind.unix_domain_socket, + else => Entry.Kind.unknown, }; return .{ .result = IteratorResult{ @@ -213,9 +213,9 @@ pub const Iterator = switch (builtin.os.tag) { const name_utf8 = self.name_data[0..name_utf8_len]; const kind = blk: { const attrs = dir_info.FileAttributes; - if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk Entry.Kind.Directory; - if (attrs & w.FILE_ATTRIBUTE_REPARSE_POINT != 0) break :blk Entry.Kind.SymLink; - break :blk Entry.Kind.File; + if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk Entry.Kind.directory; + if (attrs & w.FILE_ATTRIBUTE_REPARSE_POINT != 0) break :blk Entry.Kind.sym_link; + break :blk Entry.Kind.file; }; return .{ .result = IteratorResult{ @@ -275,13 +275,13 @@ pub const Iterator = switch (builtin.os.tag) { } const entry_kind = switch (entry.d_type) { - .BLOCK_DEVICE => Entry.Kind.BlockDevice, - .CHARACTER_DEVICE => Entry.Kind.CharacterDevice, - .DIRECTORY => Entry.Kind.Directory, - .SYMBOLIC_LINK => Entry.Kind.SymLink, - .REGULAR_FILE => Entry.Kind.File, - .SOCKET_STREAM, .SOCKET_DGRAM => Entry.Kind.UnixDomainSocket, - else => Entry.Kind.Unknown, + .BLOCK_DEVICE => Entry.Kind.block_device, + .CHARACTER_DEVICE => Entry.Kind.character_device, + .DIRECTORY => Entry.Kind.directory, + .SYMBOLIC_LINK => Entry.Kind.sym_link, + .REGULAR_FILE => Entry.Kind.file, + .SOCKET_STREAM, .SOCKET_DGRAM => Entry.Kind.unix_domain_socket, + else => Entry.Kind.unknown, }; return IteratorResult{ .name = name, diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 254d58455..3ea0822e6 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -2264,7 +2264,7 @@ pub const Arguments = struct { return CopyFile{ .src = src, .dest = dest, - .mode = @intToEnum(Constants.Copyfile, mode), + .mode = @enumFromInt(Constants.Copyfile, mode), }; } }; @@ -2498,7 +2498,7 @@ pub const NodeFS = struct { pub fn access(this: *NodeFS, args: Arguments.Access, comptime _: Flavor) Maybe(Return.Access) { var path = args.path.sliceZ(&this.sync_error_buf); - const rc = Syscall.system.access(path, @enumToInt(args.mode)); + const rc = Syscall.system.access(path, @intFromEnum(args.mode)); return Maybe(Return.Access).errnoSysP(rc, .access, path) orelse Maybe(Return.Access).success; } @@ -2528,7 +2528,7 @@ pub const NodeFS = struct { const path = path_.sliceZ(&this.sync_error_buf); switch (comptime flavor) { .sync => { - const fd = switch (Syscall.open(path, @enumToInt(FileSystemFlags.a), 0o000666)) { + const fd = switch (Syscall.open(path, @intFromEnum(FileSystemFlags.a), 0o000666)) { .result => |result| result, .err => |err| return .{ .err = err }, }; @@ -2594,7 +2594,7 @@ pub const NodeFS = struct { }; if (!os.S.ISREG(stat_.mode)) { - return Maybe(Return.CopyFile){ .err = .{ .errno = @enumToInt(C.SystemErrno.ENOTSUP) } }; + return Maybe(Return.CopyFile){ .err = .{ .errno = @intFromEnum(C.SystemErrno.ENOTSUP) } }; } // 64 KB is about the break-even point for clonefile() to be worth it @@ -2723,7 +2723,7 @@ pub const NodeFS = struct { }; if (!os.S.ISREG(stat_.mode)) { - return Maybe(Return.CopyFile){ .err = .{ .errno = @enumToInt(C.SystemErrno.ENOTSUP) } }; + return Maybe(Return.CopyFile){ .err = .{ .errno = @intFromEnum(C.SystemErrno.ENOTSUP) } }; } var flags: Mode = std.os.O.CREAT | std.os.O.WRONLY; @@ -3026,7 +3026,7 @@ pub const NodeFS = struct { .err => |err| { switch (err.getErrno()) { else => { - @memcpy(&this.sync_error_buf, path.ptr, len); + @memcpy(this.sync_error_buf[0..len], path[0..len]); return .{ .err = err.withPath(this.sync_error_buf[0..len]) }; }, @@ -3043,7 +3043,7 @@ pub const NodeFS = struct { } var working_mem = &this.sync_error_buf; - @memcpy(working_mem, path.ptr, len); + @memcpy(working_mem[0..len], path[0..len]); var i: u16 = len - 1; @@ -3146,7 +3146,7 @@ pub const NodeFS = struct { const prefix_slice = args.prefix.slice(); const len = @min(prefix_slice.len, prefix_buf.len -| 7); if (len > 0) { - @memcpy(prefix_buf, prefix_slice.ptr, len); + @memcpy(prefix_buf[0..len], prefix_slice[0..len]); } prefix_buf[len..][0..6].* = "XXXXXX".*; prefix_buf[len..][6] = 0; @@ -3162,15 +3162,15 @@ pub const NodeFS = struct { }; } // std.c.getErrno(rc) returns SUCCESS if rc is null so we call std.c._errno() directly - const errno = @intToEnum(std.c.E, std.c._errno().*); - return .{ .err = Syscall.Error{ .errno = @truncate(Syscall.Error.Int, @enumToInt(errno)), .syscall = .mkdtemp } }; + const errno = @enumFromInt(std.c.E, std.c._errno().*); + return .{ .err = Syscall.Error{ .errno = @truncate(Syscall.Error.Int, @intFromEnum(errno)), .syscall = .mkdtemp } }; } pub fn open(this: *NodeFS, args: Arguments.Open, comptime flavor: Flavor) Maybe(Return.Open) { switch (comptime flavor) { // The sync version does no allocation except when returning the path .sync => { const path = args.path.sliceZ(&this.sync_error_buf); - return switch (Syscall.open(path, @enumToInt(args.flags), args.mode)) { + return switch (Syscall.open(path, @intFromEnum(args.flags), args.mode)) { .err => |err| .{ .err = err.withPath(args.path.slice()), }, @@ -3605,7 +3605,7 @@ pub const NodeFS = struct { break :brk switch (Syscall.openat( args.dirfd, path, - @enumToInt(args.flag) | os.O.NOCTTY, + @intFromEnum(args.flag) | os.O.NOCTTY, args.mode, )) { .err => |err| return .{ @@ -3672,7 +3672,7 @@ pub const NodeFS = struct { } // https://github.com/oven-sh/bun/issues/2931 - if ((@enumToInt(args.flag) & std.os.O.APPEND) == 0) { + if ((@intFromEnum(args.flag) & std.os.O.APPEND) == 0) { _ = ftruncateSync(.{ .fd = fd, .len = @truncate(JSC.WebCore.Blob.SizeType, written) }); } @@ -3819,12 +3819,12 @@ pub const NodeFS = struct { while (true) { if (Maybe(Return.Rmdir).errnoSys(bun.C.darwin.removefileat(std.os.AT.FDCWD, dest, null, flags), .rmdir)) |errno| { - switch (@intToEnum(os.E, errno.err.errno)) { + switch (@enumFromInt(os.E, errno.err.errno)) { .AGAIN, .INTR => continue, .NOENT => return Maybe(Return.Rmdir).success, .MLINK => { var copy: [bun.MAX_PATH_BYTES]u8 = undefined; - @memcpy(©, dest.ptr, dest.len); + @memcpy(copy[0..dest.len], dest); copy[dest.len] = 0; var dest_copy = copy[0..dest.len :0]; switch (Syscall.unlink(dest_copy).getErrno()) { @@ -3906,7 +3906,7 @@ pub const NodeFS = struct { } if (Maybe(Return.Rm).errnoSys(bun.C.darwin.removefileat(std.os.AT.FDCWD, dest, null, flags), .unlink)) |errno| { - switch (@intToEnum(os.E, errno.err.errno)) { + switch (@enumFromInt(os.E, errno.err.errno)) { .AGAIN, .INTR => continue, .NOENT => { if (args.force) { @@ -3918,7 +3918,7 @@ pub const NodeFS = struct { .MLINK => { var copy: [bun.MAX_PATH_BYTES]u8 = undefined; - @memcpy(©, dest.ptr, dest.len); + @memcpy(copy[0..dest.len], dest); copy[dest.len] = 0; var dest_copy = copy[0..dest.len :0]; switch (Syscall.unlink(dest_copy).getErrno()) { diff --git a/src/bun.js/node/node_fs_constant.zig b/src/bun.js/node/node_fs_constant.zig index 378f332c6..8e642ebad 100644 --- a/src/bun.js/node/node_fs_constant.zig +++ b/src/bun.js/node/node_fs_constant.zig @@ -26,17 +26,17 @@ pub const Constants = struct { pub const force = 4; pub inline fn isForceClone(this: Copyfile) bool { - return (@enumToInt(this) & COPYFILE_FICLONE_FORCE) != 0; + return (@intFromEnum(this) & COPYFILE_FICLONE_FORCE) != 0; } pub inline fn shouldntOverwrite(this: Copyfile) bool { - return (@enumToInt(this) & COPYFILE_EXCL) != 0; + return (@intFromEnum(this) & COPYFILE_EXCL) != 0; } pub inline fn canUseClone(this: Copyfile) bool { _ = this; return Environment.isMac; - // return (@enumToInt(this) | COPYFILE_FICLONE) != 0; + // return (@intFromEnum(this) | COPYFILE_FICLONE) != 0; } }; diff --git a/src/bun.js/node/node_os.zig b/src/bun.js/node/node_os.zig index 4b37640cf..7f9ea2e28 100644 --- a/src/bun.js/node/node_os.zig +++ b/src/bun.js/node/node_os.zig @@ -211,7 +211,7 @@ pub const Os = struct { if (local_bindings.host_processor_info(std.c.mach_host_self(), local_bindings.PROCESSOR_CPU_LOAD_INFO, &num_cpus, @ptrCast(*local_bindings.processor_info_array_t, &info), &info_size) != .SUCCESS) { return error.no_processor_info; } - defer _ = std.c.vm_deallocate(std.c.mach_task_self(), @ptrToInt(info), info_size); + defer _ = std.c.vm_deallocate(std.c.mach_task_self(), @intFromPtr(info), info_size); // Ensure we got the amount of data we expected to guard against buffer overruns if (info_size != C.PROCESSOR_CPU_LOAD_INFO_COUNT * num_cpus) { @@ -380,7 +380,7 @@ pub const Os = struct { 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))), - .errno = @enumToInt(std.os.errno(rc)), + .errno = @intFromEnum(std.os.errno(rc)), .syscall = JSC.ZigString.init("getifaddrs"), }; @@ -461,7 +461,7 @@ pub const Os = struct { var cidr = JSC.JSValue.null; if (maybe_suffix) |suffix| { //NOTE addr_str might not start at buf[0] due to slicing in formatIp - const start = @ptrToInt(addr_str.ptr) - @ptrToInt(&buf[0]); + const start = @intFromPtr(addr_str.ptr) - @intFromPtr(&buf[0]); // Start writing the suffix immediately after the address const suffix_str = std.fmt.bufPrint(buf[start + addr_str.len ..], "/{}", .{suffix}) catch unreachable; // The full cidr value is the address + the suffix diff --git a/src/bun.js/node/os/constants.zig b/src/bun.js/node/os/constants.zig index a3508d383..9cf754e03 100644 --- a/src/bun.js/node/os/constants.zig +++ b/src/bun.js/node/os/constants.zig @@ -8,14 +8,14 @@ const ConstantType = enum { ERRNO, ERRNO_WIN, SIG, DLOPEN, OTHER }; fn getErrnoConstant(comptime name: []const u8) ?comptime_int { return if (@hasField(std.os.E, name)) - return @enumToInt(@field(std.os.E, name)) + return @intFromEnum(@field(std.os.E, name)) else return null; } fn getWindowsErrnoConstant(comptime name: []const u8) ?comptime_int { return if (@hasField(std.os.E, name)) - return @enumToInt(@field(std.os.windows.ws2_32.WinsockError, name)) + return @intFromEnum(@field(std.os.windows.ws2_32.WinsockError, name)) else return null; } diff --git a/src/bun.js/node/syscall.zig b/src/bun.js/node/syscall.zig index 7b10a3028..77bd5b13d 100644 --- a/src/bun.js/node/syscall.zig +++ b/src/bun.js/node/syscall.zig @@ -202,7 +202,7 @@ pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: JSC.Nod .SUCCESS => .{ .result = @intCast(bun.FileDescriptor, rc) }, else => |err| .{ .err = .{ - .errno = @truncate(Syscall.Error.Int, @enumToInt(err)), + .errno = @truncate(Syscall.Error.Int, @intFromEnum(err)), .syscall = .open, }, }, @@ -218,7 +218,7 @@ pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: JSC.Nod else => |err| { return Maybe(std.os.fd_t){ .err = .{ - .errno = @truncate(Syscall.Error.Int, @enumToInt(err)), + .errno = @truncate(Syscall.Error.Int, @intFromEnum(err)), .syscall = .open, }, }; @@ -253,14 +253,14 @@ pub fn closeAllowingStdoutAndStderr(fd: std.os.fd_t) ?Syscall.Error { if (comptime Environment.isMac) { // This avoids the EINTR problem. return switch (system.getErrno(system.@"close$NOCANCEL"(fd))) { - .BADF => Syscall.Error{ .errno = @enumToInt(os.E.BADF), .syscall = .close }, + .BADF => Syscall.Error{ .errno = @intFromEnum(os.E.BADF), .syscall = .close }, else => null, }; } if (comptime Environment.isLinux) { return switch (linux.getErrno(linux.close(fd))) { - .BADF => Syscall.Error{ .errno = @enumToInt(os.E.BADF), .syscall = .close }, + .BADF => Syscall.Error{ .errno = @intFromEnum(os.E.BADF), .syscall = .close }, else => null, }; } @@ -546,7 +546,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) Maybe([]u8) { .macos, .ios, .watchos, .tvos => { // On macOS, we can use F.GETPATH fcntl command to query the OS for // the path to the file descriptor. - @memset(out_buffer, 0, MAX_PATH_BYTES); + @memset(out_buffer[0..MAX_PATH_BYTES], 0); if (Maybe([]u8).errnoSys(system.fcntl(fd, os.F.GETPATH, out_buffer), .fcntl)) |err| { return err; } @@ -594,7 +594,7 @@ fn mmap( const fail = std.c.MAP.FAILED; if (rc == fail) { return Maybe([]align(mem.page_size) u8){ - .err = .{ .errno = @truncate(Syscall.Error.Int, @enumToInt(std.c.getErrno(@bitCast(i64, @ptrToInt(fail))))), .syscall = .mmap }, + .err = .{ .errno = @truncate(Syscall.Error.Int, @intFromEnum(std.c.getErrno(@bitCast(i64, @intFromPtr(fail))))), .syscall = .mmap }, }; } @@ -643,16 +643,16 @@ pub fn munmap(memory: []align(mem.page_size) const u8) Maybe(void) { pub const Error = struct { const max_errno_value = brk: { const errno_values = std.enums.values(os.E); - var err = @enumToInt(os.E.SUCCESS); + var err = @intFromEnum(os.E.SUCCESS); for (errno_values) |errn| { - err = @max(err, @enumToInt(errn)); + err = @max(err, @intFromEnum(errn)); } break :brk err; }; pub const Int: type = std.math.IntFittingRange(0, max_errno_value + 5); errno: Int, - syscall: Syscall.Tag = @intToEnum(Syscall.Tag, 0), + syscall: Syscall.Tag = @enumFromInt(Syscall.Tag, 0), path: []const u8 = "", fd: i32 = -1, @@ -661,7 +661,7 @@ pub const Error = struct { } pub fn fromCode(errno: os.E, syscall: Syscall.Tag) Error { - return .{ .errno = @truncate(Int, @enumToInt(errno)), .syscall = syscall }; + return .{ .errno = @truncate(Int, @intFromEnum(errno)), .syscall = syscall }; } pub fn format(self: Error, comptime fmt: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void { @@ -672,16 +672,16 @@ pub const Error = struct { pub const retry = Error{ .errno = if (Environment.isLinux) - @intCast(Int, @enumToInt(os.E.AGAIN)) + @intCast(Int, @intFromEnum(os.E.AGAIN)) else if (Environment.isMac) - @intCast(Int, @enumToInt(os.E.WOULDBLOCK)) + @intCast(Int, @intFromEnum(os.E.WOULDBLOCK)) else - @intCast(Int, @enumToInt(os.E.INTR)), + @intCast(Int, @intFromEnum(os.E.INTR)), .syscall = .retry, }; pub inline fn getErrno(this: Error) os.E { - return @intToEnum(os.E, this.errno); + return @enumFromInt(os.E, this.errno); } pub inline fn withPath(this: Error, path: anytype) Error { @@ -726,7 +726,7 @@ pub const Error = struct { // errno label if (this.errno > 0 and this.errno < C.SystemErrno.max) { - const system_errno = @intToEnum(C.SystemErrno, this.errno); + const system_errno = @enumFromInt(C.SystemErrno, this.errno); err.code = JSC.ZigString.init(@tagName(system_errno)); if (C.SystemErrno.labels.get(system_errno)) |label| { err.message = JSC.ZigString.init(label); diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index 1fe378a84..e2de35706 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -135,7 +135,7 @@ pub fn Maybe(comptime ResultType: type) type { pub inline fn getErrno(this: @This()) os.E { return switch (this) { .result => os.E.SUCCESS, - .err => |err| @intToEnum(os.E, err.errno), + .err => |err| @enumFromInt(os.E, err.errno), }; } @@ -144,7 +144,7 @@ pub fn Maybe(comptime ResultType: type) type { .SUCCESS => null, else => |err| @This(){ // always truncate - .err = .{ .errno = @truncate(Syscall.Error.Int, @enumToInt(err)) }, + .err = .{ .errno = @truncate(Syscall.Error.Int, @intFromEnum(err)) }, }, }; } @@ -154,7 +154,7 @@ pub fn Maybe(comptime ResultType: type) type { .SUCCESS => null, else => |err| @This(){ // always truncate - .err = .{ .errno = @truncate(Syscall.Error.Int, @enumToInt(err)), .syscall = syscall }, + .err = .{ .errno = @truncate(Syscall.Error.Int, @intFromEnum(err)), .syscall = syscall }, }, }; } @@ -165,7 +165,7 @@ pub fn Maybe(comptime ResultType: type) type { else => |err| @This(){ // always truncate .err = .{ - .errno = @truncate(Syscall.Error.Int, @enumToInt(err)), + .errno = @truncate(Syscall.Error.Int, @intFromEnum(err)), .syscall = syscall, .fd = @intCast(i32, fd), }, @@ -178,7 +178,7 @@ pub fn Maybe(comptime ResultType: type) type { .SUCCESS => null, else => |err| @This(){ // always truncate - .err = .{ .errno = @truncate(Syscall.Error.Int, @enumToInt(err)), .syscall = syscall, .path = bun.asByteSlice(path) }, + .err = .{ .errno = @truncate(Syscall.Error.Int, @intFromEnum(err)), .syscall = syscall, .path = bun.asByteSlice(path) }, }, }; } @@ -632,7 +632,7 @@ pub const PathLike = union(Tag) { } } - @memcpy(buf, sliced.ptr, sliced.len); + @memcpy(buf[0..sliced.len], sliced); buf[sliced.len] = 0; return buf[0..sliced.len :0]; } @@ -904,7 +904,7 @@ pub fn timeLikeFromJS(globalThis: *JSC.JSGlobalObject, value: JSC.JSValue, _: JS return null; } - return @truncate(TimeLike, @floatToInt(i64, milliseconds / @as(f64, std.time.ms_per_s))); + return @truncate(TimeLike, @intFromFloat(i64, milliseconds / @as(f64, std.time.ms_per_s))); } if (!value.isNumber() and !value.isString()) { @@ -916,7 +916,7 @@ pub fn timeLikeFromJS(globalThis: *JSC.JSGlobalObject, value: JSC.JSValue, _: JS return null; } - return @truncate(TimeLike, @floatToInt(i64, seconds)); + return @truncate(TimeLike, @intFromFloat(i64, seconds)); } pub fn modeFromJS(ctx: JSC.C.JSContextRef, value: JSC.JSValue, exception: JSC.C.ExceptionRef) ?Mode { @@ -968,8 +968,8 @@ pub const PathOrFileDescriptor = union(Tag) { pub fn hash(this: JSC.Node.PathOrFileDescriptor) u64 { return switch (this) { - .path => std.hash.Wyhash.hash(0, this.path.slice()), - .fd => std.hash.Wyhash.hash(0, std.mem.asBytes(&this.fd)), + .path => bun.hash(this.path.slice()), + .fd => bun.hash(std.mem.asBytes(&this.fd)), }; } @@ -1104,7 +1104,7 @@ pub const FileSystemFlags = enum(Mode) { pub fn fromJS(ctx: JSC.C.JSContextRef, val: JSC.JSValue, exception: JSC.C.ExceptionRef) ?FileSystemFlags { if (val.isNumber()) { const number = val.coerce(i32, ctx); - return @intToEnum(FileSystemFlags, @intCast(Mode, @max(number, 0))); + return @enumFromInt(FileSystemFlags, @intCast(Mode, @max(number, 0))); } const jsType = val.jsType(); @@ -1160,7 +1160,7 @@ pub const FileSystemFlags = enum(Mode) { return null; }; - return @intToEnum(FileSystemFlags, @intCast(Mode, flags)); + return @enumFromInt(FileSystemFlags, @intCast(Mode, flags)); } return null; @@ -1172,7 +1172,7 @@ pub const Date = enum(u64) { _, pub fn toJS(this: Date, ctx: JSC.C.JSContextRef, exception: JSC.C.ExceptionRef) JSC.C.JSValueRef { - const seconds = @floatCast(f64, @intToFloat(f64, @enumToInt(this)) * 1000.0); + const seconds = @floatCast(f64, @floatFromInt(f64, @intFromEnum(this)) * 1000.0); const unix_timestamp = JSC.JSValue.jsNumber(seconds); const array: [1]JSC.C.JSValueRef = .{unix_timestamp.asObjectRef()}; const obj = JSC.C.JSObjectMakeDate(ctx, 1, &array, exception); @@ -1219,12 +1219,12 @@ fn StatsDataType(comptime T: type) type { .size = @truncate(T, @intCast(i64, stat_.size)), .blksize = @truncate(T, @intCast(i64, stat_.blksize)), .blocks = @truncate(T, @intCast(i64, stat_.blocks)), - .atime_ms = (@intToFloat(f64, @max(atime.tv_sec, 0)) * std.time.ms_per_s) + (@intToFloat(f64, @intCast(usize, @max(atime.tv_nsec, 0))) / std.time.ns_per_ms), - .mtime_ms = (@intToFloat(f64, @max(mtime.tv_sec, 0)) * std.time.ms_per_s) + (@intToFloat(f64, @intCast(usize, @max(mtime.tv_nsec, 0))) / std.time.ns_per_ms), - .ctime_ms = (@intToFloat(f64, @max(ctime.tv_sec, 0)) * std.time.ms_per_s) + (@intToFloat(f64, @intCast(usize, @max(ctime.tv_nsec, 0))) / std.time.ns_per_ms), - .atime = @intToEnum(Date, @intCast(u64, @max(atime.tv_sec, 0))), - .mtime = @intToEnum(Date, @intCast(u64, @max(mtime.tv_sec, 0))), - .ctime = @intToEnum(Date, @intCast(u64, @max(ctime.tv_sec, 0))), + .atime_ms = (@floatFromInt(f64, @max(atime.tv_sec, 0)) * std.time.ms_per_s) + (@floatFromInt(f64, @intCast(usize, @max(atime.tv_nsec, 0))) / std.time.ns_per_ms), + .mtime_ms = (@floatFromInt(f64, @max(mtime.tv_sec, 0)) * std.time.ms_per_s) + (@floatFromInt(f64, @intCast(usize, @max(mtime.tv_nsec, 0))) / std.time.ns_per_ms), + .ctime_ms = (@floatFromInt(f64, @max(ctime.tv_sec, 0)) * std.time.ms_per_s) + (@floatFromInt(f64, @intCast(usize, @max(ctime.tv_nsec, 0))) / std.time.ns_per_ms), + .atime = @enumFromInt(Date, @intCast(u64, @max(atime.tv_sec, 0))), + .mtime = @enumFromInt(Date, @intCast(u64, @max(mtime.tv_sec, 0))), + .ctime = @enumFromInt(Date, @intCast(u64, @max(ctime.tv_sec, 0))), // Linux doesn't include this info in stat // maybe it does in statx, but do you really need birthtime? If you do please file an issue. @@ -1234,9 +1234,9 @@ fn StatsDataType(comptime T: type) type { @truncate(T, @intCast(i64, if (stat_.birthtime().tv_nsec > 0) (@intCast(usize, stat_.birthtime().tv_nsec) / std.time.ns_per_ms) else 0)), .birthtime = if (Environment.isLinux) - @intToEnum(Date, 0) + @enumFromInt(Date, 0) else - @intToEnum(Date, @intCast(u64, @max(stat_.birthtime().tv_sec, 0))), + @enumFromInt(Date, @intCast(u64, @max(stat_.birthtime().tv_sec, 0))), }; } }; @@ -1426,49 +1426,49 @@ pub const Dirent = struct { _: *JSC.JSGlobalObject, _: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.BlockDevice); + return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.block_device); } pub fn isCharacterDevice( this: *Dirent, _: *JSC.JSGlobalObject, _: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.CharacterDevice); + return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.character_device); } pub fn isDirectory( this: *Dirent, _: *JSC.JSGlobalObject, _: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.Directory); + return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.directory); } pub fn isFIFO( this: *Dirent, _: *JSC.JSGlobalObject, _: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.NamedPipe or this.kind == std.fs.File.Kind.EventPort); + return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.named_pipe or this.kind == std.fs.File.Kind.event_port); } pub fn isFile( this: *Dirent, _: *JSC.JSGlobalObject, _: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.File); + return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.file); } pub fn isSocket( this: *Dirent, _: *JSC.JSGlobalObject, _: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.UnixDomainSocket); + return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.unix_domain_socket); } pub fn isSymbolicLink( this: *Dirent, _: *JSC.JSGlobalObject, _: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.SymLink); + return JSC.JSValue.jsBoolean(this.kind == std.fs.File.Kind.sym_link); } pub fn finalize(this: *Dirent) callconv(.C) void { @@ -1490,14 +1490,14 @@ pub const Emitter = struct { pub fn append(this: *List, allocator: std.mem.Allocator, ctx: JSC.C.JSContextRef, listener: Listener) !void { JSC.C.JSValueProtect(ctx, listener.callback.asObjectRef()); try this.list.append(allocator, listener); - this.once_count +|= @as(u32, @boolToInt(listener.once)); + this.once_count +|= @as(u32, @intFromBool(listener.once)); } pub fn prepend(this: *List, allocator: std.mem.Allocator, ctx: JSC.C.JSContextRef, listener: Listener) !void { JSC.C.JSValueProtect(ctx, listener.callback.asObjectRef()); try this.list.ensureUnusedCapacity(allocator, 1); this.list.insertAssumeCapacity(0, listener); - this.once_count +|= @as(u32, @boolToInt(listener.once)); + this.once_count +|= @as(u32, @intFromBool(listener.once)); } // removeListener() will remove, at most, one instance of a listener from the @@ -1510,7 +1510,7 @@ pub const Emitter = struct { for (callbacks, 0..) |item, i| { if (callback.eqlValue(item)) { JSC.C.JSValueUnprotect(ctx, callback.asObjectRef()); - this.once_count -|= @as(u32, @boolToInt(this.list.items(.once)[i])); + this.once_count -|= @as(u32, @intFromBool(this.list.items(.once)[i])); this.list.orderedRemove(i); return true; } diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 00cc954ad..2dc4ae1c4 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -210,13 +210,13 @@ pub const TestRunner = struct { const start = @truncate(Test.ID, this.tests.len); this.tests.len += count; var statuses = this.tests.items(.status)[start..][0..count]; - std.mem.set(Test.Status, statuses, Test.Status.pending); + @memset(statuses, Test.Status.pending); this.callback.onUpdateCount(this.callback, count, count + start); return start; } pub fn getOrPutFile(this: *TestRunner, file_path: string) *DescribeScope { - var entry = this.index.getOrPut(this.allocator, @truncate(u32, std.hash.Wyhash.hash(0, file_path))) catch unreachable; + var entry = this.index.getOrPut(this.allocator, @truncate(u32, bun.hash(file_path))) catch unreachable; if (entry.found_existing) { return this.files.items(.module_scope)[entry.value_ptr.*]; } @@ -317,7 +317,7 @@ pub const Snapshots = struct { name_with_counter[name.len] = ' '; bun.copy(u8, name_with_counter[name.len + 1 ..], counter_string); - const name_hash = std.hash.Wyhash.hash(0, name_with_counter); + const name_hash = bun.hash(name_with_counter); if (this.values.get(name_hash)) |expected| { return expected; } @@ -416,7 +416,7 @@ pub const Snapshots = struct { } const value_clone = try this.allocator.alloc(u8, value.len); bun.copy(u8, value_clone, value); - const name_hash = std.hash.Wyhash.hash(0, key); + const name_hash = bun.hash(key); try this.values.put(name_hash, value_clone); } } diff --git a/src/bun.js/test/pretty_format.zig b/src/bun.js/test/pretty_format.zig index 15ab88799..29e330a04 100644 --- a/src/bun.js/test/pretty_format.zig +++ b/src/bun.js/test/pretty_format.zig @@ -362,7 +362,7 @@ pub const JestPrettyFormat = struct { }; pub fn get(value: JSValue, globalThis: *JSGlobalObject) Result { - switch (@enumToInt(value)) { + switch (@intFromEnum(value)) { 0, 0xa => return Result{ .tag = .Undefined, }, @@ -921,7 +921,7 @@ pub const JestPrettyFormat = struct { this.map = this.map_node.?.data; } - var entry = this.map.getOrPut(@enumToInt(value)) catch unreachable; + var entry = this.map.getOrPut(@intFromEnum(value)) catch unreachable; if (entry.found_existing) { writer.writeAll(comptime Output.prettyFmt("[Circular]", enable_ansi_colors)); return; @@ -930,7 +930,7 @@ pub const JestPrettyFormat = struct { defer { if (comptime Format.canHaveCircularReferences()) { - _ = this.map.remove(@enumToInt(value)); + _ = this.map.remove(@intFromEnum(value)); } } @@ -1049,7 +1049,7 @@ pub const JestPrettyFormat = struct { i = -i; } const digits = if (i != 0) - bun.fmt.fastDigitCount(@intCast(usize, i)) + @as(usize, @boolToInt(is_negative)) + bun.fmt.fastDigitCount(@intCast(usize, i)) + @as(usize, @intFromBool(is_negative)) else 1; this.addForNewLine(digits); @@ -1553,7 +1553,7 @@ pub const JestPrettyFormat = struct { { this.indent += 1; defer this.indent -|= 1; - const count_without_children = props_iter.len - @as(usize, @boolToInt(children_prop != null)); + const count_without_children = props_iter.len - @as(usize, @intFromBool(children_prop != null)); while (props_iter.next()) |prop| { if (prop.eqlComptime("children")) diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig index e7357e4ca..a5009e09e 100644 --- a/src/bun.js/webcore.zig +++ b/src/bun.js/webcore.zig @@ -663,7 +663,7 @@ pub const Crypto = struct { ) callconv(.C) JSC.JSValue { var slice = array.slice(); randomData(globalThis, slice.ptr, slice.len); - return @intToEnum(JSC.JSValue, @bitCast(i64, @ptrToInt(array))); + return @enumFromInt(JSC.JSValue, @bitCast(i64, @intFromPtr(array))); } fn randomData( 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; } diff --git a/src/bun.js/webcore/encoding.zig b/src/bun.js/webcore/encoding.zig index e4b8a4b95..5c8221128 100644 --- a/src/bun.js/webcore/encoding.zig +++ b/src/bun.js/webcore/encoding.zig @@ -68,7 +68,7 @@ pub const TextEncoder = struct { std.debug.assert(result.read == slice.len); const array_buffer = uint8array.asArrayBuffer(globalThis).?; std.debug.assert(result.written == array_buffer.len); - @memcpy(array_buffer.byteSlice().ptr, &buf, result.written); + @memcpy(array_buffer.byteSlice()[0..result.written], buf[0..result.written]); return uint8array; } else { const bytes = strings.allocateLatin1IntoUTF8(globalThis.bunVM().allocator, []const u8, slice) catch { @@ -103,7 +103,7 @@ pub const TextEncoder = struct { const uint8array = JSC.JSValue.createUninitializedUint8Array(globalThis, 3); const array_buffer = uint8array.asArrayBuffer(globalThis).?; const replacement_char = [_]u8{ 239, 191, 189 }; - @memcpy(array_buffer.slice().ptr, &replacement_char, replacement_char.len); + @memcpy(array_buffer.slice()[0..replacement_char.len], &replacement_char); return uint8array; } const uint8array = JSC.JSValue.createUninitializedUint8Array(globalThis, result.written); @@ -111,7 +111,7 @@ pub const TextEncoder = struct { std.debug.assert(result.read == slice.len); const array_buffer = uint8array.asArrayBuffer(globalThis).?; std.debug.assert(result.written == array_buffer.len); - @memcpy(array_buffer.slice().ptr, &buf, result.written); + @memcpy(array_buffer.slice()[0..result.written], buf[0..result.written]); return uint8array; } else { var bytes = strings.toUTF8AllocWithType( @@ -207,7 +207,7 @@ pub const TextEncoder = struct { if (array.isEmpty()) { array = JSC.JSValue.createUninitializedUint8Array(globalThis, length); array.ensureStillAlive(); - @memcpy(array.asArrayBuffer(globalThis).?.ptr, buf_to_use.ptr, length); + @memcpy(array.asArrayBuffer(globalThis).?.ptr[0..length], buf_to_use[0..length]); } return array; @@ -224,7 +224,7 @@ pub const TextEncoder = struct { var result: strings.EncodeIntoResult = strings.copyUTF16IntoUTF8(output, []const u16, input, false); if (output.len >= 3 and (result.read == 0 or result.written == 0)) { const replacement_char = [_]u8{ 239, 191, 189 }; - @memcpy(buf_ptr, &replacement_char, replacement_char.len); + @memcpy(buf_ptr[0..replacement_char.len], &replacement_char); result.read = 1; result.written = 3; } @@ -515,10 +515,10 @@ pub const TextDecoder = struct { buffer.ensureTotalCapacity(allocator, slice.len) catch unreachable; buffer.items.len = i; + var len = std.mem.sliceAsBytes(slice[0..i]).len; @memcpy( - std.mem.sliceAsBytes(buffer.items).ptr, - std.mem.sliceAsBytes(slice).ptr, - std.mem.sliceAsBytes(slice[0..i]).len, + std.mem.sliceAsBytes(buffer.items)[0..len], + std.mem.sliceAsBytes(slice)[0..len], ); const first_high_surrogate = 0xD800; @@ -537,10 +537,10 @@ pub const TextDecoder = struct { const prev = buffer.items.len; buffer.items.len += count; // Since this string is freshly allocated, we know it's not going to overlap + len = std.mem.sliceAsBytes(remainder[0..count]).len; @memcpy( - std.mem.sliceAsBytes(buffer.items[prev..]).ptr, - std.mem.sliceAsBytes(remainder).ptr, - std.mem.sliceAsBytes(remainder[0..count]).len, + std.mem.sliceAsBytes(buffer.items[prev..])[0..len], + std.mem.sliceAsBytes(remainder)[0..len], ); remainder = remainder[count..]; }, @@ -659,7 +659,7 @@ pub const TextDecoder = struct { }, EncodingLabel.@"UTF-16LE" => { - if (std.mem.isAligned(@ptrToInt(buffer_slice.ptr), @alignOf([*]const u16))) { + if (std.mem.isAligned(@intFromPtr(buffer_slice.ptr), @alignOf([*]const u16))) { return this.decodeUTF16WithAlignment([]const u16, @alignCast(2, std.mem.bytesAsSlice(u16, buffer_slice)), globalThis); } @@ -701,7 +701,7 @@ pub const TextDecoder = struct { pub const Encoder = struct { export fn Bun__encoding__writeLatin1(input: [*]const u8, len: usize, to: [*]u8, to_len: usize, encoding: u8) usize { - return switch (@intToEnum(JSC.Node.Encoding, encoding)) { + return switch (@enumFromInt(JSC.Node.Encoding, encoding)) { .utf8 => writeU8(input, len, to, to_len, .utf8), .latin1 => writeU8(input, len, to, to_len, .ascii), .ascii => writeU8(input, len, to, to_len, .ascii), @@ -714,7 +714,7 @@ pub const Encoder = struct { } catch 0; } export fn Bun__encoding__writeUTF16(input: [*]const u16, len: usize, to: [*]u8, to_len: usize, encoding: u8) usize { - return switch (@intToEnum(JSC.Node.Encoding, encoding)) { + return switch (@enumFromInt(JSC.Node.Encoding, encoding)) { .utf8 => writeU16(input, len, to, to_len, .utf8, false), .latin1 => writeU16(input, len, to, to_len, .ascii, false), .ascii => writeU16(input, len, to, to_len, .ascii, false), @@ -727,7 +727,7 @@ pub const Encoder = struct { } catch 0; } export fn Bun__encoding__byteLengthLatin1(input: [*]const u8, len: usize, encoding: u8) usize { - return switch (@intToEnum(JSC.Node.Encoding, encoding)) { + return switch (@enumFromInt(JSC.Node.Encoding, encoding)) { .utf8 => byteLengthU8(input, len, .utf8), .latin1 => byteLengthU8(input, len, .ascii), .ascii => byteLengthU8(input, len, .ascii), @@ -740,7 +740,7 @@ pub const Encoder = struct { }; } export fn Bun__encoding__byteLengthUTF16(input: [*]const u16, len: usize, encoding: u8) usize { - return switch (@intToEnum(JSC.Node.Encoding, encoding)) { + return switch (@enumFromInt(JSC.Node.Encoding, encoding)) { .utf8 => byteLengthU16(input, len, .utf8), .latin1 => byteLengthU16(input, len, .ascii), .ascii => byteLengthU16(input, len, .ascii), @@ -753,7 +753,7 @@ pub const Encoder = struct { }; } export fn Bun__encoding__constructFromLatin1(globalObject: *JSGlobalObject, input: [*]const u8, len: usize, encoding: u8) JSValue { - var slice = switch (@intToEnum(JSC.Node.Encoding, encoding)) { + var slice = switch (@enumFromInt(JSC.Node.Encoding, encoding)) { .hex => constructFromU8(input, len, .hex), .ascii => constructFromU8(input, len, .ascii), .base64url => constructFromU8(input, len, .base64url), @@ -766,7 +766,7 @@ pub const Encoder = struct { return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator); } export fn Bun__encoding__constructFromUTF16(globalObject: *JSGlobalObject, input: [*]const u16, len: usize, encoding: u8) JSValue { - var slice = switch (@intToEnum(JSC.Node.Encoding, encoding)) { + var slice = switch (@enumFromInt(JSC.Node.Encoding, encoding)) { .base64 => constructFromU16(input, len, .base64), .hex => constructFromU16(input, len, .hex), .base64url => constructFromU16(input, len, .base64url), @@ -785,7 +785,7 @@ pub const Encoder = struct { } export fn Bun__encoding__toString(input: [*]const u8, len: usize, globalObject: *JSC.JSGlobalObject, encoding: u8) JSValue { - return switch (@intToEnum(JSC.Node.Encoding, encoding)) { + return switch (@enumFromInt(JSC.Node.Encoding, encoding)) { .ucs2 => toString(input, len, globalObject, .utf16le), .utf16le => toString(input, len, globalObject, .utf16le), .utf8 => toString(input, len, globalObject, .utf8), @@ -830,7 +830,7 @@ pub const Encoder = struct { .latin1 => { var to = allocator.alloc(u8, len) catch return ZigString.init("Out of memory").toErrorInstance(global); - @memcpy(to.ptr, input_ptr, to.len); + @memcpy(to, input_ptr[0..to.len]); return ZigString.init(to).toExternalValue(global); }, @@ -852,7 +852,7 @@ pub const Encoder = struct { var output_bytes = std.mem.sliceAsBytes(output); output_bytes[output_bytes.len - 1] = 0; - @memcpy(output_bytes.ptr, input_ptr, output_bytes.len); + @memcpy(output_bytes, input_ptr[0..output_bytes.len]); return ZigString.toExternalU16(output.ptr, output.len, global); }, @@ -892,7 +892,7 @@ pub const Encoder = struct { switch (comptime encoding) { .buffer => { const written = @min(len, to_len); - @memcpy(to_ptr, input, written); + @memcpy(to_ptr[0..written], input[0..written]); return written; }, @@ -903,7 +903,7 @@ pub const Encoder = struct { var remain = input[0..written]; if (bun.simdutf.validate.ascii(remain)) { - @memcpy(to.ptr, remain.ptr, written); + @memcpy(to_ptr[0..written], remain[0..written]); } else { strings.copyLatin1IntoASCII(to, remain); } @@ -919,7 +919,7 @@ pub const Encoder = struct { if (to_len < 2) return 0; - if (std.mem.isAligned(@ptrToInt(to_ptr), @alignOf([*]u16))) { + if (std.mem.isAligned(@intFromPtr(to_ptr), @alignOf([*]u16))) { var buf = input[0..len]; var output = @ptrCast([*]u16, @alignCast(@alignOf(u16), to_ptr))[0 .. to_len / 2]; @@ -1065,14 +1065,14 @@ pub const Encoder = struct { switch (comptime encoding) { .buffer => { var to = allocator.alloc(u8, len) catch return &[_]u8{}; - @memcpy(to.ptr, input, len); + @memcpy(to[0..len], input[0..len]); return to; }, .latin1, .ascii => { var to = allocator.alloc(u8, len) catch return &[_]u8{}; - @memcpy(to.ptr, input, len); + @memcpy(to[0..len], input[0..len]); return to; }, @@ -1121,7 +1121,7 @@ pub const Encoder = struct { .latin1, .buffer, .ascii => { var to = allocator.alloc(u8, len) catch return &[_]u8{}; var input_bytes = std.mem.sliceAsBytes(input[0..len]); - @memcpy(to.ptr, input_bytes.ptr, input_bytes.len); + @memcpy(to[0..input_bytes.len], input_bytes); for (to[0..len], 0..) |c, i| { to[i] = @as(u8, @truncate(u7, c)); } @@ -1131,7 +1131,8 @@ pub const Encoder = struct { // string is already encoded, just need to copy the data .ucs2, .utf16le => { var to = std.mem.sliceAsBytes(allocator.alloc(u16, len * 2) catch return &[_]u8{}); - @memcpy(to.ptr, std.mem.sliceAsBytes(input[0..len]).ptr, std.mem.sliceAsBytes(input[0..len]).len); + const bytes = std.mem.sliceAsBytes(input[0..len]); + @memcpy(to[0..bytes.len], bytes); return to; }, diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig index a8c648212..231f0deed 100644 --- a/src/bun.js/webcore/request.zig +++ b/src/bun.js/webcore/request.zig @@ -472,8 +472,8 @@ pub const Request = struct { url_or_object, if (is_first_argument_a_url) JSValue.undefined else url_or_object, }; - const values_to_try = values_to_try_[0 .. @as(usize, @boolToInt(!is_first_argument_a_url)) + - @as(usize, @boolToInt(arguments.len > 1 and arguments[1].isObject()))]; + const values_to_try = values_to_try_[0 .. @as(usize, @intFromBool(!is_first_argument_a_url)) + + @as(usize, @intFromBool(arguments.len > 1 and arguments[1].isObject()))]; for (values_to_try) |value| { const value_type = value.jsType(); @@ -564,7 +564,7 @@ pub const Request = struct { fields.insert(.url); // first value - } else if (@enumToInt(value) == @enumToInt(values_to_try[values_to_try.len - 1]) and !is_first_argument_a_url and + } else if (@intFromEnum(value) == @intFromEnum(values_to_try[values_to_try.len - 1]) and !is_first_argument_a_url and value.implementsToString(globalThis)) { const slice = value.toSliceOrNull(globalThis) orelse { diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig index beae4d182..b4ea08579 100644 --- a/src/bun.js/webcore/response.zig +++ b/src/bun.js/webcore/response.zig @@ -386,7 +386,7 @@ pub const Response = struct { const json_value = args.nextEat() orelse JSC.JSValue.zero; - if (@enumToInt(json_value) != 0) { + if (@intFromEnum(json_value) != 0) { var zig_str = JSC.ZigString.init(""); // calling JSON.stringify on an empty string adds extra quotes // so this is correct @@ -448,7 +448,7 @@ pub const Response = struct { const url_string_value = args.nextEat() orelse JSC.JSValue.zero; var url_string = ZigString.init(""); - if (@enumToInt(url_string_value) != 0) { + if (@intFromEnum(url_string_value) != 0) { url_string = url_string_value.getZigString(globalThis.ptr()); } var url_string_slice = url_string.toSlice(getAllocator(globalThis)); @@ -1147,9 +1147,9 @@ pub const Fetch = struct { JSC.JSError(bun.default_allocator, "Out of memory", .{}, ctx, exception); return .zero; }; - @memcpy(buffer.ptr, url_slice.ptr, url_slice.len); + @memcpy(buffer[0..url_slice.len], url_slice); var proxy_url_slice = buffer[url_slice.len..]; - @memcpy(proxy_url_slice.ptr, proxy_url_zig.ptr, proxy_url_zig.len); + @memcpy(proxy_url_slice[0..proxy_url_zig.len], proxy_url_zig.ptr[0..proxy_url_zig.len]); url = ZigURL.parse(buffer[0..url_slice.len]); proxy = ZigURL.parse(proxy_url_slice); @@ -1283,9 +1283,9 @@ pub const Fetch = struct { JSC.JSError(bun.default_allocator, "Out of memory", .{}, ctx, exception); return .zero; }; - @memcpy(buffer.ptr, url_slice.ptr, url_slice.len); + @memcpy(buffer[0..url_slice.len], url_slice.ptr[0..url_slice.len]); var proxy_url_slice = buffer[url_slice.len..]; - @memcpy(proxy_url_slice.ptr, proxy_url_zig.ptr, proxy_url_zig.len); + @memcpy(proxy_url_slice[0..proxy_url_zig.len], proxy_url_zig.ptr[0..proxy_url_zig.len]); url = ZigURL.parse(buffer[0..url_slice.len]); proxy = ZigURL.parse(proxy_url_slice); @@ -1695,7 +1695,7 @@ pub const FetchEvent = struct { defer { if (!VirtualMachine.get().had_errors) { - Output.printElapsed(@intToFloat(f64, (request_context.timer.lap())) / std.time.ns_per_ms); + Output.printElapsed(@floatFromInt(f64, (request_context.timer.lap())) / std.time.ns_per_ms); Output.prettyError( " {s} - {d} transpiled, {d} imports\n", diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index dddfcbaf5..5986afac7 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -247,7 +247,7 @@ pub const ReadableStream = struct { pub fn fromNative(globalThis: *JSGlobalObject, id: Tag, ptr: *anyopaque) JSC.JSValue { JSC.markBinding(@src()); - return ZigGlobalObject__createNativeReadableStream(globalThis, JSValue.fromPtr(ptr), JSValue.jsNumber(@enumToInt(id))); + return ZigGlobalObject__createNativeReadableStream(globalThis, JSValue.fromPtr(ptr), JSValue.jsNumber(@intFromEnum(id))); } pub fn fromBlob(globalThis: *JSGlobalObject, blob: *const Blob, recommended_chunk_size: Blob.SizeType) JSC.JSValue { @@ -329,11 +329,11 @@ pub const ReadableStream = struct { const filedes_ = @bitCast([8]u8, @as(usize, @truncate(u56, @intCast(usize, filedes)))); bytes[1..8].* = filedes_[0..7].*; - return @intToEnum(StreamTag, @bitCast(u64, bytes)); + return @enumFromInt(StreamTag, @bitCast(u64, bytes)); } pub fn fd(this: StreamTag) bun.FileDescriptor { - var bytes = @bitCast([8]u8, @enumToInt(this)); + var bytes = @bitCast([8]u8, @intFromEnum(this)); if (bytes[0] != 1) { return bun.invalid_fd; } @@ -780,13 +780,15 @@ pub const StreamResult = union(Tag) { .temporary => |temp| { var array = JSC.JSValue.createUninitializedUint8Array(globalThis, temp.len); var slice_ = array.asArrayBuffer(globalThis).?.slice(); - @memcpy(slice_.ptr, temp.ptr, temp.len); + const temp_slice = temp.slice(); + @memcpy(slice_[0..temp_slice.len], temp_slice); return array; }, .temporary_and_done => |temp| { var array = JSC.JSValue.createUninitializedUint8Array(globalThis, temp.len); var slice_ = array.asArrayBuffer(globalThis).?.slice(); - @memcpy(slice_.ptr, temp.ptr, temp.len); + const temp_slice = temp.slice(); + @memcpy(slice_[0..temp_slice.len], temp_slice); return array; }, .into_array => |array| { @@ -818,7 +820,7 @@ pub const Signal = struct { ptr: *anyopaque = dead, vtable: VTable = VTable.Dead, - pub const dead = @intToPtr(*anyopaque, 0xaaaaaaaa); + pub const dead = @ptrFromInt(*anyopaque, 0xaaaaaaaa); pub fn clear(this: *Signal) void { this.ptr = dead; @@ -920,7 +922,7 @@ pub const Sink = struct { used: bool = false, pub const pending = Sink{ - .ptr = @intToPtr(*anyopaque, 0xaaaaaaaa), + .ptr = @ptrFromInt(*anyopaque, 0xaaaaaaaa), .vtable = undefined, }; @@ -961,7 +963,8 @@ pub const Sink = struct { if (stack_size >= str.len) { var buf: [stack_size]u8 = undefined; - @memcpy(&buf, str.ptr, str.len); + @memcpy(buf[0..str.len], str); + strings.replaceLatin1WithUTF8(buf[0..str.len]); if (input.isDone()) { const result = writeFn(ctx, .{ .temporary_and_done = bun.ByteList.init(buf[0..str.len]) }); @@ -974,7 +977,8 @@ pub const Sink = struct { { var slice = bun.default_allocator.alloc(u8, str.len) catch return .{ .err = Syscall.Error.oom }; - @memcpy(slice.ptr, str.ptr, str.len); + @memcpy(slice[0..str.len], str); + strings.replaceLatin1WithUTF8(slice[0..str.len]); if (input.isDone()) { return writeFn(ctx, .{ .owned_and_done = bun.ByteList.init(slice) }); @@ -1262,7 +1266,7 @@ pub const FileSink = struct { const initial_remain = remain; defer { - std.debug.assert(total - initial == @ptrToInt(remain.ptr) - @ptrToInt(initial_remain.ptr)); + std.debug.assert(total - initial == @intFromPtr(remain.ptr) - @intFromPtr(initial_remain.ptr)); if (remain.len == 0) { this.head = 0; @@ -1908,15 +1912,15 @@ pub fn NewJSSink(comptime SinkType: type, comptime name_: []const u8) type { pub fn init(cpp: JSValue) Signal { // this one can be null @setRuntimeSafety(false); - return Signal.initWithType(SinkSignal, @intToPtr(*SinkSignal, @bitCast(usize, @enumToInt(cpp)))); + return Signal.initWithType(SinkSignal, @ptrFromInt(*SinkSignal, @bitCast(usize, @intFromEnum(cpp)))); } pub fn close(this: *@This(), _: ?Syscall.Error) void { - onClose(@bitCast(SinkSignal, @ptrToInt(this)).cpp, JSValue.jsUndefined()); + onClose(@bitCast(SinkSignal, @intFromPtr(this)).cpp, JSValue.jsUndefined()); } pub fn ready(this: *@This(), _: ?Blob.SizeType, _: ?Blob.SizeType) void { - onReady(@bitCast(SinkSignal, @ptrToInt(this)).cpp, JSValue.jsUndefined(), JSValue.jsUndefined()); + onReady(@bitCast(SinkSignal, @intFromPtr(this)).cpp, JSValue.jsUndefined(), JSValue.jsUndefined()); } pub fn start(_: *@This()) void {} @@ -1992,7 +1996,7 @@ pub fn NewJSSink(comptime SinkType: type, comptime name_: []const u8) type { if (this.sink.signal.isDead()) return; this.sink.signal.clear(); - const value = @intToEnum(JSValue, @bitCast(JSC.JSValueReprInt, @ptrToInt(ptr))); + const value = @enumFromInt(JSValue, @bitCast(JSC.JSValueReprInt, @intFromPtr(ptr))); value.unprotect(); detachPtr(value); } @@ -3127,7 +3131,7 @@ pub const ByteBlobLoader = struct { this.remain -|= copied; this.offset +|= copied; std.debug.assert(buffer.ptr != temporary.ptr); - @memcpy(buffer.ptr, temporary.ptr, temporary.len); + @memcpy(buffer[0..temporary.len], temporary); if (this.remain == 0) { return .{ .into_array_and_done = .{ .value = array, .len = copied } }; } @@ -3231,7 +3235,7 @@ pub const ByteStream = struct { } if (this.has_received_last_chunk) { - return .{ .chunk_size = @truncate(Blob.SizeType, @min(1024 * 1024 * 2, this.buffer.items.len)) }; + return .{ .chunk_size = @min(1024 * 1024 * 2, this.buffer.items.len) }; } if (this.highWaterMark == 0) { @@ -3292,7 +3296,7 @@ pub const ByteStream = struct { var to_copy = this.pending_buffer[0..@min(chunk.len, this.pending_buffer.len)]; const pending_buffer_len = this.pending_buffer.len; std.debug.assert(to_copy.ptr != chunk.ptr); - @memcpy(to_copy.ptr, chunk.ptr, to_copy.len); + @memcpy(to_copy, chunk[0..to_copy.len]); this.pending_buffer = &.{}; const is_really_done = this.has_received_last_chunk and to_copy.len <= pending_buffer_len; @@ -3382,7 +3386,7 @@ pub const ByteStream = struct { ); var remaining_in_buffer = this.buffer.items[this.offset..][0..to_write]; - @memcpy(buffer.ptr, this.buffer.items.ptr + this.offset, to_write); + @memcpy(buffer[0..to_write], this.buffer.items[this.offset..][0..to_write]); if (this.offset + to_write == this.buffer.items.len) { this.offset = 0; @@ -4071,7 +4075,7 @@ pub const File = struct { this.pending.result = .{ .err = Syscall.Error{ // this is too hacky - .errno = @truncate(Syscall.Error.Int, @intCast(u16, @max(1, @errorToInt(err)))), + .errno = @truncate(Syscall.Error.Int, @intCast(u16, @max(1, @intFromError(err)))), .syscall = .read, }, }; @@ -4655,4 +4659,3 @@ pub fn NewReadyWatcher( // pub fn onError(this: *Streamer): anytype, // }; // } - diff --git a/src/bun.zig b/src/bun.zig index f2d76df53..bd50af6f6 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -149,7 +149,7 @@ pub const fmt = struct { const mags_iec = " KMGTPEZY"; const log2 = math.log2(value); - const magnitude = math.min(log2 / comptime math.log2(1000), mags_si.len - 1); + const magnitude = @min(log2 / comptime math.log2(1000), mags_si.len - 1); const new_value = math.lossyCast(f64, value) / math.pow(f64, 1000, math.lossyCast(f64, magnitude)); const suffix = switch (1000) { 1000 => mags_si[magnitude], @@ -176,7 +176,7 @@ pub const fmt = struct { pub fn size(value: anytype) SizeFormatter { return switch (@TypeOf(value)) { f64, f32, f128 => SizeFormatter{ - .value = @floatToInt(u64, value), + .value = @intFromFloat(u64, value), }, else => SizeFormatter{ .value = @intCast(u64, value) }, }; @@ -288,7 +288,7 @@ pub const MAX_PATH_BYTES: usize = if (Environment.isWasm) 1024 else std.fs.MAX_P pub inline fn cast(comptime To: type, value: anytype) To { if (comptime std.meta.trait.isIntegral(@TypeOf(value))) { - return @intToPtr(To, @bitCast(usize, value)); + return @ptrFromInt(To, @bitCast(usize, value)); } // TODO: file issue about why std.meta.Child only is necessary on Linux aarch64 @@ -471,7 +471,7 @@ pub inline fn range(comptime min: anytype, comptime max: anytype) [max - min]usi pub fn copy(comptime Type: type, dest: []Type, src: []const Type) void { if (comptime Environment.allow_assert) std.debug.assert(dest.len >= src.len); - if (@ptrToInt(src.ptr) == @ptrToInt(dest.ptr) or src.len == 0) return; + if (@intFromPtr(src.ptr) == @intFromPtr(dest.ptr) or src.len == 0) return; const input: []const u8 = std.mem.sliceAsBytes(src); const output: []u8 = std.mem.sliceAsBytes(dest); @@ -479,13 +479,13 @@ pub fn copy(comptime Type: type, dest: []Type, src: []const Type) void { std.debug.assert(input.len > 0); std.debug.assert(output.len > 0); - const does_input_or_output_overlap = (@ptrToInt(input.ptr) < @ptrToInt(output.ptr) and - @ptrToInt(input.ptr) + input.len > @ptrToInt(output.ptr)) or - (@ptrToInt(output.ptr) < @ptrToInt(input.ptr) and - @ptrToInt(output.ptr) + output.len > @ptrToInt(input.ptr)); + const does_input_or_output_overlap = (@intFromPtr(input.ptr) < @intFromPtr(output.ptr) and + @intFromPtr(input.ptr) + input.len > @intFromPtr(output.ptr)) or + (@intFromPtr(output.ptr) < @intFromPtr(input.ptr) and + @intFromPtr(output.ptr) + output.len > @intFromPtr(input.ptr)); if (!does_input_or_output_overlap) { - @memcpy(output.ptr, input.ptr, input.len); + @memcpy(output[0..input.len], input); } else { C.memmove(output.ptr, input.ptr, input.len); } @@ -541,14 +541,14 @@ pub fn assertDefined(val: anytype) void { std.debug.assert(val.len < std.math.maxInt(u32) + 1); var slice: []Type = undefined; if (val.len > 0) { - std.debug.assert(@ptrToInt(val.ptr) != @ptrToInt(slice.ptr)); + std.debug.assert(@intFromPtr(val.ptr) != @intFromPtr(slice.ptr)); } return; } if (comptime @typeInfo(Type) == .Pointer) { var slice: *Type = undefined; - std.debug.assert(@ptrToInt(val) != @ptrToInt(slice)); + std.debug.assert(@intFromPtr(val) != @intFromPtr(slice)); return; } @@ -566,6 +566,10 @@ pub fn hash(content: []const u8) u64 { return std.hash.Wyhash.hash(0, content); } +pub fn hashWithSeed(seed: u64, content: []const u8) u64 { + return std.hash.Wyhash.hash(seed, content); +} + pub fn hash32(content: []const u8) u32 { const res = hash(content); return @truncate(u32, res); @@ -592,7 +596,7 @@ pub fn ensureNonBlocking(fd: anytype) void { const global_scope_log = Output.scoped(.bun, false); pub fn isReadable(fd: std.os.fd_t) PollFlag { - var polls = &[_]std.os.pollfd{ + var polls = [_]std.os.pollfd{ .{ .fd = fd, .events = std.os.POLL.IN | std.os.POLL.ERR, @@ -600,7 +604,7 @@ pub fn isReadable(fd: std.os.fd_t) PollFlag { }, }; - const result = (std.os.poll(polls, 0) catch 0) != 0; + const result = (std.os.poll(&polls, 0) catch 0) != 0; global_scope_log("poll({d}) readable: {any} ({d})", .{ fd, result, polls[0].revents }); return if (result and polls[0].revents & std.os.POLL.HUP != 0) PollFlag.hup @@ -612,7 +616,7 @@ pub fn isReadable(fd: std.os.fd_t) PollFlag { pub const PollFlag = enum { ready, not_ready, hup }; pub fn isWritable(fd: std.os.fd_t) PollFlag { - var polls = &[_]std.os.pollfd{ + var polls = [_]std.os.pollfd{ .{ .fd = fd, .events = std.os.POLL.OUT, @@ -620,7 +624,7 @@ pub fn isWritable(fd: std.os.fd_t) PollFlag { }, }; - const result = (std.os.poll(polls, 0) catch 0) != 0; + const result = (std.os.poll(&polls, 0) catch 0) != 0; global_scope_log("poll({d}) writable: {any} ({d})", .{ fd, result, polls[0].revents }); if (result and polls[0].revents & std.os.POLL.HUP != 0) { return PollFlag.hup; @@ -678,13 +682,13 @@ pub fn isHeapMemory(memory: anytype) bool { pub const Mimalloc = @import("./allocators/mimalloc.zig"); pub inline fn isSliceInBuffer(slice: []const u8, buffer: []const u8) bool { - return slice.len > 0 and @ptrToInt(buffer.ptr) <= @ptrToInt(slice.ptr) and ((@ptrToInt(slice.ptr) + slice.len) <= (@ptrToInt(buffer.ptr) + buffer.len)); + return slice.len > 0 and @intFromPtr(buffer.ptr) <= @intFromPtr(slice.ptr) and ((@intFromPtr(slice.ptr) + slice.len) <= (@intFromPtr(buffer.ptr) + buffer.len)); } pub fn rangeOfSliceInBuffer(slice: []const u8, buffer: []const u8) ?[2]u32 { if (!isSliceInBuffer(slice, buffer)) return null; const r = [_]u32{ - @truncate(u32, @ptrToInt(slice.ptr) -| @ptrToInt(buffer.ptr)), + @truncate(u32, @intFromPtr(slice.ptr) -| @intFromPtr(buffer.ptr)), @truncate(u32, slice.len), }; if (comptime Environment.allow_assert) @@ -870,7 +874,7 @@ pub const SignalCode = enum(u8) { _, pub fn name(value: SignalCode) ?[]const u8 { - if (@enumToInt(value) <= @enumToInt(SignalCode.SIGSYS)) { + if (@intFromEnum(value) <= @intFromEnum(SignalCode.SIGSYS)) { return asByteSlice(@tagName(value)); } @@ -878,14 +882,14 @@ pub const SignalCode = enum(u8) { } pub fn from(value: anytype) SignalCode { - return @intToEnum(SignalCode, @truncate(u7, std.mem.asBytes(&value)[0])); + return @enumFromInt(SignalCode, @truncate(u7, std.mem.asBytes(&value)[0])); } pub fn format(self: SignalCode, comptime _: []const u8, _: fmt.FormatOptions, writer: anytype) !void { if (self.name()) |str| { - try std.fmt.format(writer, "code {d} ({s})", .{ @enumToInt(self), str }); + try std.fmt.format(writer, "code {d} ({s})", .{ @intFromEnum(self), str }); } else { - try std.fmt.format(writer, "code {d}", .{@enumToInt(self)}); + try std.fmt.format(writer, "code {d}", .{@intFromEnum(self)}); } } }; @@ -961,7 +965,7 @@ pub fn ComptimeEnumMap(comptime T: type) type { /// Ignores default struct values. pub fn zero(comptime Type: type) Type { var out: [@sizeOf(Type)]u8 align(@alignOf(Type)) = undefined; - @memset(@ptrCast([*]u8, &out), 0, out.len); + @memset(@ptrCast([*]u8, &out)[0..out.len], 0); return @bitCast(Type, out); } pub const c_ares = @import("./deps/c_ares.zig"); @@ -1533,3 +1537,5 @@ pub const WTF = struct { }; pub const ArenaAllocator = @import("./ArenaAllocator.zig").ArenaAllocator; + +pub const Wyhash = @import("./wyhash.zig").Wyhash; diff --git a/src/bun_js.zig b/src/bun_js.zig index fd124a8ac..63ffe0611 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -351,6 +351,6 @@ pub const Run = struct { vm.onExit(); if (!JSC.is_bindgen) JSC.napi.fixDeadCodeElimination(); - Global.exit(@boolToInt(this.any_unhandled)); + Global.exit(@intFromBool(this.any_unhandled)); } }; diff --git a/src/bundler.zig b/src/bundler.zig index fb0a11be7..ec8f6b5df 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -1601,7 +1601,7 @@ pub const Bundler = struct { // All non-absolute paths are ./paths if (path_to_use[0] != '/' and path_to_use[0] != '.') { tmp_buildfile_buf3[0..2].* = "./".*; - @memcpy(tmp_buildfile_buf3[2..], path_to_use.ptr, path_to_use.len); + @memcpy(tmp_buildfile_buf3[2..][0..path_to_use.len], path_to_use); path_to_use = tmp_buildfile_buf3[0 .. 2 + path_to_use.len]; } diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index a03847079..231a4bde8 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -103,7 +103,6 @@ const Resolver = _resolver.Resolver; const TOML = @import("../toml/toml_parser.zig").TOML; const EntryPoints = @import("./entry_points.zig"); const ThisBundler = @import("../bundler.zig").Bundler; -const wyhash = std.hash.Wyhash.hash; const Dependency = js_ast.Dependency; const JSAst = js_ast.BundledAst; const Loader = options.Loader; @@ -1364,8 +1363,8 @@ pub const BundleV2 = struct { }, .err => |err| { log.msgs.append(err) catch unreachable; - log.errors += @as(usize, @boolToInt(err.kind == .err)); - log.warnings += @as(usize, @boolToInt(err.kind == .warn)); + log.errors += @as(usize, @intFromBool(err.kind == .err)); + log.warnings += @as(usize, @intFromBool(err.kind == .warn)); // An error ocurred, prevent spinning the event loop forever _ = @atomicRmw(usize, &this.graph.parse_pending, .Sub, 1, .Monotonic); @@ -1520,8 +1519,8 @@ pub const BundleV2 = struct { }, .err => |err| { log.msgs.append(err) catch unreachable; - log.errors += @as(usize, @boolToInt(err.kind == .err)); - log.warnings += @as(usize, @boolToInt(err.kind == .warn)); + log.errors += @as(usize, @intFromBool(err.kind == .err)); + log.warnings += @as(usize, @intFromBool(err.kind == .warn)); }, .pending, .consumed => unreachable, } @@ -1819,7 +1818,7 @@ pub const BundleV2 = struct { import_record.source_index = Index.invalid; } - estimated_resolve_queue_count += @as(usize, @boolToInt(!(import_record.is_internal or import_record.is_unused or import_record.source_index.isValid()))); + estimated_resolve_queue_count += @as(usize, @intFromBool(!(import_record.is_internal or import_record.is_unused or import_record.source_index.isValid()))); } var resolve_queue = ResolveQueue.init(this.graph.allocator); resolve_queue.ensureTotalCapacity(estimated_resolve_queue_count) catch @panic("OOM"); @@ -2464,7 +2463,7 @@ pub const ParseTask = struct { defer trace.end(); if (bundler.options.framework) |framework| { if (framework.override_modules_hashes.len > 0) { - const package_relative_path_hash = wyhash(0, file_path.pretty); + const package_relative_path_hash = bun.hash(file_path.pretty); if (std.mem.indexOfScalar( u64, framework.override_modules_hashes, @@ -3264,7 +3263,7 @@ const LinkerGraph = struct { var entry_point_kinds = files.items(.entry_point_kind); { var kinds = std.mem.sliceAsBytes(entry_point_kinds); - @memset(kinds.ptr, 0, kinds.len); + @memset(kinds, 0); } // Setup entry points @@ -3276,7 +3275,7 @@ const LinkerGraph = struct { var path_strings: []bun.PathString = this.entry_points.items(.output_path); { var output_was_auto_generated = std.mem.sliceAsBytes(this.entry_points.items(.output_path_was_auto_generated)); - @memset(output_was_auto_generated.ptr, 0, output_was_auto_generated.len); + @memset(output_was_auto_generated, 0); } for (entry_points, path_strings, source_indices) |i, *path_string, *source_index| { @@ -3397,7 +3396,7 @@ const LinkerGraph = struct { var stable_source_indices = try this.allocator.alloc(Index, sources.len + 1); // set it to max value so that if we access an invalid one, it crashes - @memset(std.mem.sliceAsBytes(stable_source_indices).ptr, 255, std.mem.sliceAsBytes(stable_source_indices).len); + @memset(std.mem.sliceAsBytes(stable_source_indices), 255); for (this.reachable_files, 0..) |source_index, i| { stable_source_indices[source_index.get()] = Index.source(i); @@ -3405,8 +3404,7 @@ const LinkerGraph = struct { const file = LinkerGraph.File{}; // TODO: verify this outputs efficient code - std.mem.set( - @TypeOf(file.distance_from_entry_point), + @memset( files.items(.distance_from_entry_point), file.distance_from_entry_point, ); @@ -4449,13 +4447,13 @@ const LinkerContext = struct { var wrap_cjs_count: usize = 0; var wrap_esm_count: usize = 0; for (exports_kind) |kind| { - cjs_count += @boolToInt(kind == .cjs); - esm_count += @boolToInt(kind == .esm); + cjs_count += @intFromBool(kind == .cjs); + esm_count += @intFromBool(kind == .esm); } for (flags) |flag| { - wrap_cjs_count += @boolToInt(flag.wrap == .cjs); - wrap_esm_count += @boolToInt(flag.wrap == .esm); + wrap_cjs_count += @intFromBool(flag.wrap == .cjs); + wrap_esm_count += @intFromBool(flag.wrap == .esm); } debug("Step 1: {d} CommonJS modules (+ {d} wrapped), {d} ES modules (+ {d} wrapped)", .{ @@ -4844,7 +4842,7 @@ const LinkerContext = struct { const add_wrapper = wrap != .none; var dependencies = std.ArrayList(js_ast.Dependency).initCapacity( this.allocator, - @as(usize, @boolToInt(force_include_exports)) + @as(usize, @boolToInt(add_wrapper)), + @as(usize, @intFromBool(force_include_exports)) + @as(usize, @intFromBool(add_wrapper)), ) catch unreachable; var resolved_exports_list: *ResolvedExports = &this.graph.meta.items(.resolved_exports)[id]; for (aliases) |alias| { @@ -4875,7 +4873,7 @@ const LinkerContext = struct { } } - dependencies.ensureUnusedCapacity(@as(usize, @boolToInt(force_include_exports)) + @as(usize, @boolToInt(add_wrapper))) catch unreachable; + dependencies.ensureUnusedCapacity(@as(usize, @intFromBool(force_include_exports)) + @as(usize, @intFromBool(add_wrapper))) catch unreachable; // Ensure "exports" is included if the current output format needs it if (force_include_exports) { @@ -5171,9 +5169,9 @@ const LinkerContext = struct { // 2 statements for every export export_aliases.len * 2 + // + 1 if there are non-zero exports - @as(usize, @boolToInt(export_aliases.len > 0)) + + @as(usize, @intFromBool(export_aliases.len > 0)) + // + 1 if we need to inject the exports variable - @as(usize, @boolToInt(needs_exports_variable)); + @as(usize, @intFromBool(needs_exports_variable)); var stmts = js_ast.Stmt.Batcher.init(allocator_, stmts_count) catch unreachable; defer stmts.done(); @@ -5275,7 +5273,7 @@ const LinkerContext = struct { var declared_symbols = js_ast.DeclaredSymbol.List{}; var exports_ref = c.graph.ast.items(.exports_ref)[id]; - var all_export_stmts: []js_ast.Stmt = stmts.head[0 .. @as(usize, @boolToInt(needs_exports_variable)) + @as(usize, @boolToInt(properties.items.len > 0))]; + var all_export_stmts: []js_ast.Stmt = stmts.head[0 .. @as(usize, @intFromBool(needs_exports_variable)) + @as(usize, @intFromBool(properties.items.len > 0))]; stmts.head = stmts.head[all_export_stmts.len..]; var remaining_stmts = all_export_stmts; defer std.debug.assert(remaining_stmts.len == 0); // all must be used @@ -5862,7 +5860,7 @@ const LinkerContext = struct { // of hash calculation. if (chunk_meta.dynamic_imports.count() > 0) { var dynamic_chunk_indices = chunk_meta.dynamic_imports.keys(); - std.sort.sort(Index.Int, dynamic_chunk_indices, {}, std.sort.asc(Index.Int)); + std.sort.block(Index.Int, dynamic_chunk_indices, {}, std.sort.asc(Index.Int)); var imports = chunk.cross_chunk_imports.listManaged(c.allocator); defer chunk.cross_chunk_imports.update(imports); @@ -6121,7 +6119,7 @@ const LinkerContext = struct { } } - std.sort.sort(StableRef, list.items, {}, StableRef.isLessThan); + std.sort.block(StableRef, list.items, {}, StableRef.isLessThan); break :brk list; }; defer sorted_imports_from_other_chunks.deinit(); @@ -6193,7 +6191,7 @@ const LinkerContext = struct { } } - std.sort.sort(renamer.StableSymbolCount, top_level_symbols.items, {}, StableSymbolCount.lessThan); + std.sort.block(renamer.StableSymbolCount, top_level_symbols.items, {}, StableSymbolCount.lessThan); capacity += top_level_symbols.items.len; top_level_symbols_all.appendSlice(top_level_symbols.items) catch unreachable; } @@ -7703,7 +7701,7 @@ const LinkerContext = struct { // Prefix this module with "__reExport(exports, ns, module.exports)" const export_star_ref = c.runtimeFunction("__reExport"); - var args = try allocator.alloc(Expr, 2 + @as(usize, @boolToInt(module_exports_for_export != null))); + var args = try allocator.alloc(Expr, 2 + @as(usize, @intFromBool(module_exports_for_export != null))); args[0..2].* = .{ Expr.init( E.Identifier, @@ -7801,7 +7799,7 @@ const LinkerContext = struct { // Prefix this module with "__reExport(exports, require(path), module.exports)" const export_star_ref = c.runtimeFunction("__reExport"); - var args = try allocator.alloc(Expr, 2 + @as(usize, @boolToInt(module_exports_for_export != null))); + var args = try allocator.alloc(Expr, 2 + @as(usize, @intFromBool(module_exports_for_export != null))); args[0..2].* = .{ Expr.init( E.Identifier, @@ -8786,8 +8784,8 @@ const LinkerContext = struct { return strings.order(a, b) == .lt; } }; - std.sort.sort(u32, sorted_client_component_ids.items, Sorter{ .sources = all_sources }, Sorter.isLessThan); - std.sort.sort(u32, sorted_server_component_ids.items, Sorter{ .sources = all_sources }, Sorter.isLessThan); + std.sort.block(u32, sorted_client_component_ids.items, Sorter{ .sources = all_sources }, Sorter.isLessThan); + std.sort.block(u32, sorted_server_component_ids.items, Sorter{ .sources = all_sources }, Sorter.isLessThan); inline for (.{ sorted_client_component_ids.items, @@ -8892,7 +8890,7 @@ const LinkerContext = struct { bun.default_allocator, (if (c.options.source_maps == .external) chunks.len * 2 else chunks.len) + @as( usize, - @boolToInt(react_client_components_manifest.len > 0) + c.parse_graph.additional_output_files.items.len, + @intFromBool(react_client_components_manifest.len > 0) + c.parse_graph.additional_output_files.items.len, ), ) catch unreachable; @@ -9412,7 +9410,7 @@ const LinkerContext = struct { .ref = export_ref, }; } - std.sort.sort(StableRef, result.items, {}, StableRef.isLessThan); + std.sort.block(StableRef, result.items, {}, StableRef.isLessThan); } pub fn markFileReachableForCodeSplitting( @@ -10701,7 +10699,7 @@ pub const Chunk = struct { /// equidistant to an entry point, then break the tie by sorting on the /// stable source index derived from the DFS over all entry points. pub fn sort(a: []Order) void { - std.sort.sort(Order, a, Order{}, lessThan); + std.sort.block(Order, a, Order{}, lessThan); } }; @@ -10806,7 +10804,7 @@ pub const Chunk = struct { shift.after.add(data_offset); if (data.len > 0) - @memcpy(remain.ptr, data.ptr, data.len); + @memcpy(remain[0..data.len], data); remain = remain[data.len..]; @@ -10838,13 +10836,13 @@ pub const Chunk = struct { ); if (cheap_normalizer[0].len > 0) { - @memcpy(remain.ptr, cheap_normalizer[0].ptr, cheap_normalizer[0].len); + @memcpy(remain[0..cheap_normalizer[0].len], cheap_normalizer[0]); remain = remain[cheap_normalizer[0].len..]; shift.after.advance(cheap_normalizer[0]); } if (cheap_normalizer[1].len > 0) { - @memcpy(remain.ptr, cheap_normalizer[1].ptr, cheap_normalizer[1].len); + @memcpy(remain[0..cheap_normalizer[1].len], cheap_normalizer[1]); remain = remain[cheap_normalizer[1].len..]; shift.after.advance(cheap_normalizer[1]); } @@ -10970,7 +10968,7 @@ pub const Chunk = struct { const data = piece.data(); if (data.len > 0) - @memcpy(remain.ptr, data.ptr, data.len); + @memcpy(remain[0..data.len], data); remain = remain[data.len..]; @@ -10998,12 +10996,12 @@ pub const Chunk = struct { ); if (cheap_normalizer[0].len > 0) { - @memcpy(remain.ptr, cheap_normalizer[0].ptr, cheap_normalizer[0].len); + @memcpy(remain[0..cheap_normalizer[0].len], cheap_normalizer[0]); remain = remain[cheap_normalizer[0].len..]; } if (cheap_normalizer[1].len > 0) { - @memcpy(remain.ptr, cheap_normalizer[1].ptr, cheap_normalizer[1].len); + @memcpy(remain[0..cheap_normalizer[1].len], cheap_normalizer[1]); remain = remain[cheap_normalizer[1].len..]; } }, @@ -11144,7 +11142,7 @@ pub const CrossChunkImport = struct { item.export_alias = exports_to_other_chunks.get(item.ref).?; std.debug.assert(item.export_alias.len > 0); } - std.sort.sort(CrossChunkImport.Item, import_items.slice(), {}, CrossChunkImport.Item.lessThan); + std.sort.block(CrossChunkImport.Item, import_items.slice(), {}, CrossChunkImport.Item.lessThan); result.append(CrossChunkImport{ .chunk_index = chunk_index, @@ -11152,7 +11150,7 @@ pub const CrossChunkImport = struct { }) catch unreachable; } - std.sort.sort(CrossChunkImport, result.items, {}, CrossChunkImport.lessThan); + std.sort.block(CrossChunkImport, result.items, {}, CrossChunkImport.lessThan); } }; diff --git a/src/bundler/entry_points.zig b/src/bundler/entry_points.zig index 34afcb491..abc7eb602 100644 --- a/src/bundler/entry_points.zig +++ b/src/bundler/entry_points.zig @@ -256,7 +256,7 @@ pub const MacroEntryPoint = struct { source: logger.Source = undefined, pub fn generateID(entry_path: string, function_name: string, buf: []u8, len: *u32) i32 { - var hasher = std.hash.Wyhash.init(0); + var hasher = bun.Wyhash.init(0); hasher.update(js_ast.Macro.namespaceWithColon); hasher.update(entry_path); hasher.update(function_name); @@ -270,7 +270,7 @@ pub const MacroEntryPoint = struct { } pub fn generateIDFromSpecifier(specifier: string) i32 { - return @bitCast(i32, @truncate(u32, std.hash.Wyhash.hash(0, specifier))); + return @bitCast(i32, @truncate(u32, bun.hash(specifier))); } pub fn generate( diff --git a/src/c.zig b/src/c.zig index d43f1b887..d4d243499 100644 --- a/src/c.zig +++ b/src/c.zig @@ -72,23 +72,23 @@ pub fn lstat_absolute(path: [:0]const u8) !Stat { .mode = st.mode, .kind = switch (builtin.os.tag) { .wasi => switch (st.filetype) { - os.FILETYPE_BLOCK_DEVICE => Kind.BlockDevice, - os.FILETYPE_CHARACTER_DEVICE => Kind.CharacterDevice, - os.FILETYPE_DIRECTORY => Kind.Directory, - os.FILETYPE_SYMBOLIC_LINK => Kind.SymLink, - os.FILETYPE_REGULAR_FILE => Kind.File, - os.FILETYPE_SOCKET_STREAM, os.FILETYPE_SOCKET_DGRAM => Kind.UnixDomainSocket, - else => Kind.Unknown, + os.FILETYPE_BLOCK_DEVICE => Kind.block_device, + os.FILETYPE_CHARACTER_DEVICE => Kind.character_device, + os.FILETYPE_DIRECTORY => Kind.directory, + os.FILETYPE_SYMBOLIC_LINK => Kind.sym_link, + os.FILETYPE_REGULAR_FILE => Kind.file, + os.FILETYPE_SOCKET_STREAM, os.FILETYPE_SOCKET_DGRAM => Kind.unix_domain_socket, + else => Kind.unknown, }, else => switch (st.mode & os.S.IFMT) { - os.S.IFBLK => Kind.BlockDevice, - os.S.IFCHR => Kind.CharacterDevice, - os.S.IFDIR => Kind.Directory, - os.S.IFIFO => Kind.NamedPipe, - os.S.IFLNK => Kind.SymLink, - os.S.IFREG => Kind.File, - os.S.IFSOCK => Kind.UnixDomainSocket, - else => Kind.Unknown, + os.S.IFBLK => Kind.block_device, + os.S.IFCHR => Kind.character_device, + os.S.IFDIR => Kind.directory, + os.S.IFIFO => Kind.named_pipe, + os.S.IFLNK => Kind.sym_link, + os.S.IFREG => Kind.file, + os.S.IFSOCK => Kind.unix_domain_socket, + else => Kind.unknown, }, }, .atime = @as(i128, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec, @@ -173,14 +173,14 @@ pub fn moveFileZSlowWithHandle(in_handle: std.os.fd_t, to_dir: std.os.fd_t, dest pub fn kindFromMode(mode: os.mode_t) std.fs.File.Kind { return switch (mode & os.S.IFMT) { - os.S.IFBLK => std.fs.File.Kind.BlockDevice, - os.S.IFCHR => std.fs.File.Kind.CharacterDevice, - os.S.IFDIR => std.fs.File.Kind.Directory, - os.S.IFIFO => std.fs.File.Kind.NamedPipe, - os.S.IFLNK => std.fs.File.Kind.SymLink, - os.S.IFREG => std.fs.File.Kind.File, - os.S.IFSOCK => std.fs.File.Kind.UnixDomainSocket, - else => .Unknown, + os.S.IFBLK => std.fs.File.Kind.block_device, + os.S.IFCHR => std.fs.File.Kind.character_device, + os.S.IFDIR => std.fs.File.Kind.directory, + os.S.IFIFO => std.fs.File.Kind.named_pipe, + os.S.IFLNK => std.fs.File.Kind.sym_link, + os.S.IFREG => std.fs.File.Kind.file, + os.S.IFSOCK => std.fs.File.Kind.unix_domain_socket, + else => .unknown, }; } @@ -431,9 +431,9 @@ pub fn dlsymWithHandle(comptime Type: type, comptime name: [:0]const u8, comptim pub fn dlsym(comptime Type: type, comptime name: [:0]const u8) ?Type { const handle_getter = struct { const RTLD_DEFAULT = if (bun.Environment.isMac) - @intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -2))) + @ptrFromInt(?*anyopaque, @bitCast(usize, @as(isize, -2))) else - @intToPtr(?*anyopaque, @as(usize, 0)); + @ptrFromInt(?*anyopaque, @as(usize, 0)); pub fn getter() ?*anyopaque { return RTLD_DEFAULT; diff --git a/src/cli.zig b/src/cli.zig index 0d4c32cdf..3d0fb5b37 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -305,7 +305,7 @@ pub const Arguments = struct { defer ctx.debug.loaded_bunfig = true; var config_path: [:0]u8 = undefined; if (config_path_[0] == '/') { - @memcpy(&config_buf, config_path_.ptr, config_path_.len); + @memcpy(config_buf[0..config_path.len], config_path); config_buf[config_path_.len] = 0; config_path = config_buf[0..config_path_.len :0]; } else { @@ -1497,11 +1497,11 @@ pub const Command = struct { const file_pathZ = brk2: { if (!strings.hasPrefix(file_path, "./")) { script_name_buf[0..2].* = "./".*; - @memcpy(script_name_buf[2..], file_path.ptr, file_path.len); + @memcpy(script_name_buf[2..][0..file_path.len], file_path); script_name_buf[file_path.len + 2] = 0; break :brk2 script_name_buf[0 .. file_path.len + 2 :0]; } else { - @memcpy(&script_name_buf, file_path.ptr, file_path.len); + @memcpy(script_name_buf[0..file_path.len], file_path); script_name_buf[file_path.len] = 0; break :brk2 script_name_buf[0..file_path.len :0]; } diff --git a/src/cli/add_completions.zig b/src/cli/add_completions.zig index 95201659d..2e7d6b4ea 100644 --- a/src/cli/add_completions.zig +++ b/src/cli/add_completions.zig @@ -66,7 +66,7 @@ pub const index: Index = if (Environment.isDebug) Index.initFill(&.{"OOMWorkArou break; } } - array.set(@intToEnum(FirstLetter, i), &record); + array.set(@enumFromInt(FirstLetter, i), &record); @setEvalBranchQuota(999999); i = next_i; diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig index 14414c7de..44e512996 100644 --- a/src/cli/build_command.zig +++ b/src/cli/build_command.zig @@ -320,8 +320,8 @@ pub const BuildCommand = struct { var from_path = resolve_path.longestCommonPath(all_paths); for (output_files) |f| { - max_path_len = std.math.max( - std.math.max(from_path.len, f.dest_path.len) + 2 - from_path.len, + max_path_len = @max( + @max(from_path.len, f.dest_path.len) + 2 - from_path.len, max_path_len, ); } @@ -356,7 +356,7 @@ pub const BuildCommand = struct { Output.pretty("{s}", .{padding_buf[0..@intCast(usize, compiled_elapsed_digit_count)]}); - Output.printElapsedStdoutTrim(@intToFloat(f64, compiled_elapsed)); + Output.printElapsedStdoutTrim(@floatFromInt(f64, compiled_elapsed)); Output.prettyln(" compile {s}", .{ outfile, @@ -446,11 +446,11 @@ pub const BuildCommand = struct { // Print summary _ = try writer.write("\n"); - const padding_count = 2 + (std.math.max(rel_path.len, max_path_len) - rel_path.len); + const padding_count = 2 + (@max(rel_path.len, max_path_len) - rel_path.len); try writer.writeByteNTimes(' ', 2); try writer.writeAll(rel_path); try writer.writeByteNTimes(' ', padding_count); - const size = @intToFloat(f64, f.size) / 1000.0; + const size = @floatFromInt(f64, f.size) / 1000.0; try std.fmt.formatFloatDecimal(size, .{ .precision = 2 }, writer); try writer.writeAll(" KB\n"); } @@ -460,7 +460,7 @@ pub const BuildCommand = struct { if (write_summary and log.errors == 0) { Output.prettyln("\n", .{}); Output.printElapsedStdoutTrim( - @intToFloat(f64, (@divTrunc(@truncate(i64, std.time.nanoTimestamp() - bun.CLI.start_time), @as(i64, std.time.ns_per_ms)))), + @floatFromInt(f64, (@divTrunc(@truncate(i64, std.time.nanoTimestamp() - bun.CLI.start_time), @as(i64, std.time.ns_per_ms)))), ); if (this_bundler.options.transform_only) { Output.prettyln(" transpile", .{}); @@ -505,7 +505,7 @@ fn printSummary(bundled_end: i128, minify_duration: u64, minified: bool, input_c }; if (minified) { Output.pretty("{s}", .{padding_buf[0..@intCast(usize, minified_digit_count)]}); - Output.printElapsedStdoutTrim(@intToFloat(f64, minify_duration)); + Output.printElapsedStdoutTrim(@floatFromInt(f64, minify_duration)); const output_size = brk: { var total_size: u64 = 0; for (output_files) |f| { @@ -547,7 +547,7 @@ fn printSummary(bundled_end: i128, minify_duration: u64, minified: bool, input_c }; Output.pretty("{s}", .{padding_buf[0..@intCast(usize, bundle_elapsed_digit_count)]}); - Output.printElapsedStdoutTrim(@intToFloat(f64, bundle_elapsed)); + Output.printElapsedStdoutTrim(@floatFromInt(f64, bundle_elapsed)); Output.prettyln( " bundle {d} modules", .{ diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig index 7fb028b68..365f2c9ed 100644 --- a/src/cli/bunx_command.zig +++ b/src/cli/bunx_command.zig @@ -66,7 +66,7 @@ pub const BunxCommand = struct { .result => |result| result, } orelse break; - if (current.kind == .File) { + if (current.kind == .file) { if (current.name.len == 0) continue; return try bundler.allocator.dupe(u8, current.name.slice()); } @@ -81,7 +81,7 @@ pub const BunxCommand = struct { fn getBinNameFromProjectDirectory(bundler: *bun.Bundler, dir_fd: std.os.fd_t, package_name: []const u8) ![]const u8 { var subpath: [bun.MAX_PATH_BYTES]u8 = undefined; subpath[0.."node_modules/".len].* = "node_modules/".*; - @memcpy(subpath["node_modules/".len..], package_name.ptr, package_name.len); + @memcpy(subpath["node_modules/".len..][0..package_name.len], package_name); subpath["node_modules/".len + package_name.len] = std.fs.path.sep; subpath["node_modules/".len + package_name.len + 1 ..][0.."package.json".len].* = "package.json".*; subpath["node_modules/".len + package_name.len + 1 + "package.json".len] = 0; diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig index fcbee9dbb..d536c4750 100644 --- a/src/cli/create_command.zig +++ b/src/cli/create_command.zig @@ -104,7 +104,7 @@ fn execTask(allocator: std.mem.Allocator, task_: string, cwd: string, _: string, count += 1; } - const npm_args = 2 * @intCast(usize, @boolToInt(npm_client != null)); + const npm_args = 2 * @intCast(usize, @intFromBool(npm_client != null)); const total = count + npm_args; var argv = allocator.alloc(string, total) catch return; var proc: std.ChildProcess = undefined; @@ -491,7 +491,7 @@ pub const CreateCommand = struct { [1]Archive.Plucker{undefined}; var archive_context = Archive.Context{ - .pluckers = pluckers[0..@intCast(usize, @boolToInt(!create_options.skip_package_json))], + .pluckers = pluckers[0..@intCast(usize, @intFromBool(!create_options.skip_package_json))], .all_files = undefined, .overwrite_list = bun.StringArrayHashMap(void).init(ctx.allocator), }; @@ -523,7 +523,7 @@ pub const CreateCommand = struct { ); for (archive_context.overwrite_list.keys()) |path| { if (strings.endsWith(path, std.fs.path.sep_str)) { - Output.prettyError(" {s}", .{path[0 .. std.math.max(path.len, 1) - 1]}); + Output.prettyError(" {s}", .{path[0 .. @max(path.len, 1) - 1]}); Output.prettyErrorln(std.fs.path.sep_str, .{}); } else { Output.prettyErrorln(" {s}", .{path}); @@ -594,7 +594,7 @@ pub const CreateCommand = struct { progress_: *std.Progress, ) !void { while (try walker.next()) |entry| { - if (entry.kind != .File) continue; + if (entry.kind != .file) continue; var outfile = destination_dir_.createFile(entry.path, .{}) catch brk: { if (std.fs.path.dirname(entry.path)) |entry_dirname| { @@ -643,7 +643,7 @@ pub const CreateCommand = struct { break :read_package_json; }; - if (stat.kind != .File or stat.size == 0) { + if (stat.kind != .file or stat.size == 0) { package_json_file = null; node.end(); @@ -736,7 +736,7 @@ pub const CreateCommand = struct { if (package_json_expr.asProperty("name")) |name_expr| { if (name_expr.expr.data == .e_string) { var basename = std.fs.path.basename(destination); - name_expr.expr.data.e_string.data = @intToPtr([*]u8, @ptrToInt(basename.ptr))[0..basename.len]; + name_expr.expr.data.e_string.data = @ptrFromInt([*]u8, @intFromPtr(basename.ptr))[0..basename.len]; } } @@ -778,7 +778,7 @@ pub const CreateCommand = struct { const key = list[i].key.?.data.e_string.data; const do_prune = packages.has(key); - prune_count += @intCast(u16, @boolToInt(do_prune)); + prune_count += @intCast(u16, @intFromBool(do_prune)); if (!do_prune) { list[out_i] = list[i]; @@ -902,14 +902,14 @@ pub const CreateCommand = struct { var needs_to_inject_dev_dependency = needs.react_refresh or needs.bun_macro_relay; var needs_to_inject_dependency = needs.bun_framework_next; - const dependencies_to_inject_count = @intCast(usize, @boolToInt(needs.bun_framework_next)); + const dependencies_to_inject_count = @intCast(usize, @intFromBool(needs.bun_framework_next)); - const dev_dependencies_to_inject_count = @intCast(usize, @boolToInt(needs.react_refresh)) + - @intCast(usize, @boolToInt(needs.bun_macro_relay)); + const dev_dependencies_to_inject_count = @intCast(usize, @intFromBool(needs.react_refresh)) + + @intCast(usize, @intFromBool(needs.bun_macro_relay)); - const new_properties_count = @intCast(usize, @boolToInt(needs_to_inject_dev_dependency and dev_dependencies == null)) + - @intCast(usize, @boolToInt(needs_to_inject_dependency and dependencies == null)) + - @intCast(usize, @boolToInt(needs_bun_prop)); + const new_properties_count = @intCast(usize, @intFromBool(needs_to_inject_dev_dependency and dev_dependencies == null)) + + @intCast(usize, @intFromBool(needs_to_inject_dependency and dependencies == null)) + + @intCast(usize, @intFromBool(needs_bun_prop)); if (new_properties_count != 0) { try properties_list.ensureUnusedCapacity(new_properties_count); @@ -1463,7 +1463,7 @@ pub const CreateCommand = struct { } if (create_options.verbose) { - Output.prettyErrorln("Has dependencies? {d}", .{@boolToInt(has_dependencies)}); + Output.prettyErrorln("Has dependencies? {d}", .{@intFromBool(has_dependencies)}); } var npm_client_: ?NPMClient = null; @@ -1692,7 +1692,7 @@ pub const Example = struct { var app_name_buf: [512]u8 = undefined; pub fn print(examples: []const Example, default_app_name: ?string) void { for (examples) |example| { - var app_name = default_app_name orelse (std.fmt.bufPrint(&app_name_buf, "./{s}-app", .{example.name[0..std.math.min(example.name.len, 492)]}) catch unreachable); + var app_name = default_app_name orelse (std.fmt.bufPrint(&app_name_buf, "./{s}-app", .{example.name[0..@min(example.name.len, 492)]}) catch unreachable); if (example.description.len > 0) { Output.pretty(" # {s}\n bun create {s} {s}\n \n\n", .{ @@ -1754,7 +1754,7 @@ pub const Example = struct { const entry: std.fs.IterableDir.Entry = entry_; switch (entry.kind) { - .Directory => { + .directory => { inline for (skip_dirs) |skip_dir| { if (strings.eqlComptime(entry.name, skip_dir)) { continue :loop; diff --git a/src/cli/init_command.zig b/src/cli/init_command.zig index c7f566836..9b5ad7144 100644 --- a/src/cli/init_command.zig +++ b/src/cli/init_command.zig @@ -112,7 +112,7 @@ pub const InitCommand = struct { if (package_json_file) |pkg| { const stat = pkg.stat() catch break :read_package_json; - if (stat.kind != .File or stat.size == 0) { + if (stat.kind != .file or stat.size == 0) { break :read_package_json; } package_json_contents = try MutableString.init(alloc, stat.size); diff --git a/src/cli/list-of-yarn-commands.zig b/src/cli/list-of-yarn-commands.zig index 250541360..4109ed727 100644 --- a/src/cli/list-of-yarn-commands.zig +++ b/src/cli/list-of-yarn-commands.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const bun = @import("root").bun; // yarn v2.3 commands const yarn_v2 = [_][]const u8{ @@ -82,7 +83,7 @@ pub const all_yarn_commands = brk: { var array: [yarn_v2.len + yarn_v1.len]u64 = undefined; var array_i: usize = 0; for (yarn_v2) |yarn| { - const hash = std.hash.Wyhash.hash(0, yarn); + const hash = bun.hash(yarn); @setEvalBranchQuota(9999); if (std.mem.indexOfScalar(u64, array[0..array_i], hash) == null) { @setEvalBranchQuota(9999); @@ -94,7 +95,7 @@ pub const all_yarn_commands = brk: { for (yarn_v1) |yarn| { @setEvalBranchQuota(9999); - const hash = std.hash.Wyhash.hash(0, yarn); + const hash = bun.hash(yarn); if (std.mem.indexOfScalar(u64, array[0..array_i], hash) == null) { @setEvalBranchQuota(9999); diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig index 83d3dd023..0d92c4232 100644 --- a/src/cli/package_manager_command.zig +++ b/src/cli/package_manager_command.zig @@ -48,7 +48,7 @@ pub const PackageManagerCommand = struct { pub fn printHash(ctx: Command.Context, lockfile_: []const u8) !void { @setCold(true); var lockfile_buffer: [bun.MAX_PATH_BYTES]u8 = undefined; - @memcpy(&lockfile_buffer, lockfile_.ptr, lockfile_.len); + @memcpy(lockfile_buffer[0..lockfile_.len], lockfile_); lockfile_buffer[lockfile_.len] = 0; var lockfile = lockfile_buffer[0..lockfile_.len :0]; var pm = try PackageManager.init(ctx, null, PackageManager.Subcommand.pm); @@ -224,7 +224,7 @@ pub const PackageManagerCommand = struct { for (sorted_dependencies, 0..) |*dep, i| { dep.* = @truncate(DependencyID, root_deps.off + i); } - std.sort.sort(DependencyID, sorted_dependencies, ByName{ + std.sort.block(DependencyID, sorted_dependencies, ByName{ .dependencies = dependencies, .buf = string_bytes, }, ByName.isLessThan); @@ -336,7 +336,7 @@ fn printNodeModulesFolderStructure( const sorted_dependencies = try allocator.alloc(DependencyID, directory.dependencies.len); defer allocator.free(sorted_dependencies); bun.copy(DependencyID, sorted_dependencies, directory.dependencies); - std.sort.sort(DependencyID, sorted_dependencies, ByName{ + std.sort.block(DependencyID, sorted_dependencies, ByName{ .dependencies = dependencies, .buf = string_bytes, }, ByName.isLessThan); diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index 0c9145db1..48bbd36d2 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -135,7 +135,7 @@ pub const RunCommand = struct { } // implicit yarn commands - if (std.mem.indexOfScalar(u64, yarn_commands, std.hash.Wyhash.hash(0, yarn_cmd)) == null) { + if (std.mem.indexOfScalar(u64, yarn_commands, bun.hash(yarn_cmd)) == null) { try copy_script.appendSlice(BUN_RUN); try copy_script.append(' '); try copy_script.appendSlice(yarn_cmd); diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig index 2f06fe674..e9d16999d 100644 --- a/src/cli/upgrade_command.zig +++ b/src/cli/upgrade_command.zig @@ -344,7 +344,7 @@ pub const UpgradeCommand = struct { if (asset.asProperty("size")) |size_| { if (size_.expr.data == .e_number) { - version.size = @intCast(u32, @max(@floatToInt(i32, std.math.ceil(size_.expr.data.e_number.value)), 0)); + version.size = @intCast(u32, @max(@intFromFloat(i32, std.math.ceil(size_.expr.data.e_number.value)), 0)); } } return version; @@ -648,13 +648,13 @@ pub const UpgradeCommand = struct { if (target_stat.size == dest_stat.size and target_stat.size > 0) { var input_buf = try ctx.allocator.alloc(u8, target_stat.size); - const target_hash = std.hash.Wyhash.hash(0, target_dir.readFile(target_filename, input_buf) catch |err| { + const target_hash = bun.hash(target_dir.readFile(target_filename, input_buf) catch |err| { save_dir_.deleteTree(version_name) catch {}; Output.prettyErrorln("error: Failed to read target bun {s}", .{@errorName(err)}); Global.exit(1); }); - const source_hash = std.hash.Wyhash.hash(0, save_dir.readFile(exe, input_buf) catch |err| { + const source_hash = bun.hash(save_dir.readFile(exe, input_buf) catch |err| { save_dir_.deleteTree(version_name) catch {}; Output.prettyErrorln("error: Failed to read source bun {s}", .{@errorName(err)}); Global.exit(1); diff --git a/src/comptime_string_map.zig b/src/comptime_string_map.zig index e60fcb1cb..87881263b 100644 --- a/src/comptime_string_map.zig +++ b/src/comptime_string_map.zig @@ -41,7 +41,7 @@ pub fn ComptimeStringMapWithKeyType(comptime KeyType: type, comptime V: type, co } else { @compileError("Not implemented for this key type"); } - std.sort.sort(KV, &sorted_kvs, {}, lenAsc); + std.sort.block(KV, &sorted_kvs, {}, lenAsc); const min_len = sorted_kvs[0].key.len; const max_len = sorted_kvs[sorted_kvs.len - 1].key.len; var len_indexes: [max_len + 1]usize = undefined; @@ -443,12 +443,12 @@ pub fn compareString(input: []const u8) !void { if (TestEnum2.map.has(str) != TestEnum2.official.has(str)) { std.debug.panic("{s} - TestEnum2.map.has(str) ({d}) != TestEnum2.official.has(str) ({d})", .{ str, - @boolToInt(TestEnum2.map.has(str)), - @boolToInt(TestEnum2.official.has(str)), + @intFromBool(TestEnum2.map.has(str)), + @intFromBool(TestEnum2.official.has(str)), }); } - std.debug.print("For string: \"{s}\" (has a match? {d})\n", .{ str, @boolToInt(TestEnum2.map.has(str)) }); + std.debug.print("For string: \"{s}\" (has a match? {d})\n", .{ str, @intFromBool(TestEnum2.map.has(str)) }); var i: usize = 0; var is_eql = false; diff --git a/src/copy_file.zig b/src/copy_file.zig index 29c74c5aa..7c68791b2 100644 --- a/src/copy_file.zig +++ b/src/copy_file.zig @@ -24,7 +24,7 @@ const CopyFileError = error{SystemResources} || CopyFileRangeError || os.SendFil // No metadata is transferred over. pub fn copyFile(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void { if (comptime bun.Environment.isMac) { - const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA); + const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE.DATA); switch (os.errno(rc)) { .SUCCESS => return, .INVAL => unreachable, diff --git a/src/crash_reporter.zig b/src/crash_reporter.zig index b583db248..882ec0ba6 100644 --- a/src/crash_reporter.zig +++ b/src/crash_reporter.zig @@ -17,11 +17,11 @@ noinline fn sigaction_handler(sig: i32, info: *const std.os.siginfo_t, _: ?*cons setup_sigactions(null) catch unreachable; const addr = switch (comptime builtin.target.os.tag) { - .linux => @ptrToInt(info.fields.sigfault.addr), - .macos, .freebsd => @ptrToInt(info.addr), - .netbsd => @ptrToInt(info.info.reason.fault.addr), - .openbsd => @ptrToInt(info.data.fault.addr), - .solaris => @ptrToInt(info.reason.fault.addr), + .linux => @intFromPtr(info.fields.sigfault.addr), + .macos, .freebsd => @intFromPtr(info.addr), + .netbsd => @intFromPtr(info.info.reason.fault.addr), + .openbsd => @intFromPtr(info.data.fault.addr), + .solaris => @intFromPtr(info.reason.fault.addr), else => unreachable, }; if (on_error) |handle| handle(sig, addr); diff --git a/src/css_scanner.zig b/src/css_scanner.zig index 0a733a6c6..6edf8b310 100644 --- a/src/css_scanner.zig +++ b/src/css_scanner.zig @@ -139,7 +139,7 @@ pub const Scanner = struct { pub fn step(scanner: *Scanner) void { scanner.codepoint = scanner.nextCodepoint(); - scanner.approximate_newline_count += @boolToInt(scanner.codepoint == '\n'); + scanner.approximate_newline_count += @intFromBool(scanner.codepoint == '\n'); } pub fn raw(_: *Scanner) string {} @@ -698,7 +698,7 @@ pub const Scanner = struct { scanner.step(); } if (import_behavior == .scan or import_behavior == .keep) { - chunk.range.len = @intCast(i32, scanner.end) - std.math.max(chunk.range.loc.start, 0); + chunk.range.len = @intCast(i32, scanner.end) - @max(chunk.range.loc.start, 0); chunk.content = .{ .t_import = import }; try writeChunk(writer, chunk); } diff --git a/src/darwin_c.zig b/src/darwin_c.zig index bd6c3c9ef..2d7e98e58 100644 --- a/src/darwin_c.zig +++ b/src/darwin_c.zig @@ -294,7 +294,7 @@ pub const SystemErrno = enum(u8) { } if (code >= max) return null; - return @intToEnum(SystemErrno, code); + return @enumFromInt(SystemErrno, code); } pub fn label(this: SystemErrno) ?[]const u8 { @@ -543,11 +543,11 @@ pub fn get_system_loadavg() [3]f64 { }; const loadavg = loadavg_[0]; - const scale = @intToFloat(f64, loadavg.fscale); + const scale = @floatFromInt(f64, loadavg.fscale); return [3]f64{ - @intToFloat(f64, loadavg.ldavg[0]) / scale, - @intToFloat(f64, loadavg.ldavg[1]) / scale, - @intToFloat(f64, loadavg.ldavg[2]) / scale, + @floatFromInt(f64, loadavg.ldavg[0]) / scale, + @floatFromInt(f64, loadavg.ldavg[1]) / scale, + @floatFromInt(f64, loadavg.ldavg[2]) / scale, }; } @@ -573,7 +573,7 @@ pub extern fn get_process_priority(pid: c_uint) i32; pub extern fn set_process_priority(pid: c_uint, priority: c_int) i32; pub fn get_version(buf: []u8) []const u8 { - @memset(buf.ptr, 0, buf.len); + @memset(buf, 0); var size: usize = buf.len; @@ -589,7 +589,7 @@ pub fn get_version(buf: []u8) []const u8 { } pub fn get_release(buf: []u8) []const u8 { - @memset(buf.ptr, 0, buf.len); + @memset(buf, 0); var size: usize = buf.len; diff --git a/src/defines-table.zig b/src/defines-table.zig index 7c3d4f8d0..e7528a825 100644 --- a/src/defines-table.zig +++ b/src/defines-table.zig @@ -164,9 +164,9 @@ const pure_global_identifier_define = defines.IdentifierDefine{ const js_ast = bun.JSAst; const identifiers = struct { - const nan_val = js_ast.E.Number{ .value = std.math.nan_f64 }; + const nan_val = js_ast.E.Number{ .value = std.math.nan(f64) }; - const inf_val = js_ast.E.Number{ .value = std.math.inf_f64 }; + const inf_val = js_ast.E.Number{ .value = std.math.inf(f64) }; // Step 2. Swap in certain literal values because those can be constant folded pub const @"undefined" = defines.IdentifierDefine{ diff --git a/src/defines.zig b/src/defines.zig index 45ebffe05..ca6edf3a4 100644 --- a/src/defines.zig +++ b/src/defines.zig @@ -188,8 +188,8 @@ pub const DotDefine = struct { }; // var nan_val = try allocator.create(js_ast.E.Number); -const nan_val = js_ast.E.Number{ .value = std.math.nan_f64 }; -const inf_val = js_ast.E.Number{ .value = std.math.inf_f64 }; +const nan_val = js_ast.E.Number{ .value = std.math.nan(f64) }; +const inf_val = js_ast.E.Number{ .value = std.math.inf(f64) }; pub const Define = struct { identifiers: bun.StringHashMap(IdentifierDefine), diff --git a/src/deps/boringssl.translated.zig b/src/deps/boringssl.translated.zig index 32fdb704b..ee4f76260 100644 --- a/src/deps/boringssl.translated.zig +++ b/src/deps/boringssl.translated.zig @@ -887,8 +887,8 @@ pub fn sk_OPENSSL_STRING_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c] var cmp_func = arg_cmp_func; var a = arg_a; var b = arg_b; - const a_ptr: OPENSSL_STRING = @intToPtr(OPENSSL_STRING, @ptrToInt(a.*)); - const b_ptr: OPENSSL_STRING = @intToPtr(OPENSSL_STRING, @ptrToInt(b.*)); + const a_ptr: OPENSSL_STRING = @ptrFromInt(OPENSSL_STRING, @intFromPtr(a.*)); + const b_ptr: OPENSSL_STRING = @ptrFromInt(OPENSSL_STRING, @intFromPtr(b.*)); return @ptrCast(stack_OPENSSL_STRING_cmp_func, @alignCast(@import("std").meta.alignment(fn ([*c]const OPENSSL_STRING, [*c]const OPENSSL_STRING) callconv(.C) c_int), cmp_func)).?(&a_ptr, &b_ptr); } pub fn sk_OPENSSL_STRING_new(arg_comp: stack_OPENSSL_STRING_cmp_func) callconv(.C) ?*struct_stack_st_OPENSSL_STRING { @@ -5237,7 +5237,7 @@ pub fn sk_SSL_CIPHER_call_free_func(arg_free_func: stack_free_func, arg_ptr: ?*a pub fn sk_SSL_CIPHER_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*anyopaque) callconv(.C) ?*anyopaque { var copy_func = arg_copy_func; var ptr = arg_ptr; - return @intToPtr(?*anyopaque, @ptrToInt(@ptrCast(stack_SSL_CIPHER_copy_func, @alignCast(@import("std").meta.alignment(fn (?*const SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER), copy_func)).?(@ptrCast(?*const SSL_CIPHER, ptr)))); + return @ptrFromInt(?*anyopaque, @intFromPtr(@ptrCast(stack_SSL_CIPHER_copy_func, @alignCast(@import("std").meta.alignment(fn (?*const SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER), copy_func)).?(@ptrCast(?*const SSL_CIPHER, ptr)))); } pub fn sk_SSL_CIPHER_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const anyopaque, arg_b: [*c]?*const anyopaque) callconv(.C) c_int { var cmp_func = arg_cmp_func; @@ -5271,7 +5271,7 @@ pub fn sk_SSL_CIPHER_set(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_i: usize, arg var sk = arg_sk; var i = arg_i; var p = arg_p; - return @ptrCast(?*const SSL_CIPHER, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @intToPtr(?*anyopaque, @ptrToInt(p)))); + return @ptrCast(?*const SSL_CIPHER, sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrFromInt(?*anyopaque, @intFromPtr(p)))); } pub fn sk_SSL_CIPHER_free(arg_sk: ?*struct_stack_st_SSL_CIPHER) callconv(.C) void { var sk = arg_sk; @@ -5286,7 +5286,7 @@ pub fn sk_SSL_CIPHER_insert(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_p: ?*const var sk = arg_sk; var p = arg_p; var where = arg_where; - return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @intToPtr(?*anyopaque, @ptrToInt(p)), where); + return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrFromInt(?*anyopaque, @intFromPtr(p)), where); } pub fn sk_SSL_CIPHER_delete(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_where: usize) callconv(.C) ?*const SSL_CIPHER { var sk = arg_sk; @@ -5311,7 +5311,7 @@ pub fn sk_SSL_CIPHER_shift(arg_sk: ?*struct_stack_st_SSL_CIPHER) callconv(.C) ?* pub fn sk_SSL_CIPHER_push(arg_sk: ?*struct_stack_st_SSL_CIPHER, arg_p: ?*const SSL_CIPHER) callconv(.C) usize { var sk = arg_sk; var p = arg_p; - return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @intToPtr(?*anyopaque, @ptrToInt(p))); + return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrFromInt(?*anyopaque, @intFromPtr(p))); } pub fn sk_SSL_CIPHER_pop(arg_sk: ?*struct_stack_st_SSL_CIPHER) callconv(.C) ?*const SSL_CIPHER { var sk = arg_sk; @@ -5545,7 +5545,7 @@ pub fn sk_SRTP_PROTECTION_PROFILE_call_free_func(arg_free_func: stack_free_func, pub fn sk_SRTP_PROTECTION_PROFILE_call_copy_func(arg_copy_func: stack_copy_func, arg_ptr: ?*anyopaque) callconv(.C) ?*anyopaque { var copy_func = arg_copy_func; var ptr = arg_ptr; - return @intToPtr(?*anyopaque, @ptrToInt(@ptrCast(stack_SRTP_PROTECTION_PROFILE_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]const SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE), copy_func)).?(@ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), ptr))))); + return @ptrFromInt(?*anyopaque, @intFromPtr(@ptrCast(stack_SRTP_PROTECTION_PROFILE_copy_func, @alignCast(@import("std").meta.alignment(fn ([*c]const SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE), copy_func)).?(@ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), ptr))))); } pub fn sk_SRTP_PROTECTION_PROFILE_call_cmp_func(arg_cmp_func: stack_cmp_func, arg_a: [*c]?*const anyopaque, arg_b: [*c]?*const anyopaque) callconv(.C) c_int { var cmp_func = arg_cmp_func; @@ -5579,7 +5579,7 @@ pub fn sk_SRTP_PROTECTION_PROFILE_set(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_ var sk = arg_sk; var i = arg_i; var p = arg_p; - return @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @intToPtr(?*anyopaque, @ptrToInt(p))))); + return @ptrCast([*c]const SRTP_PROTECTION_PROFILE, @alignCast(@import("std").meta.alignment(SRTP_PROTECTION_PROFILE), sk_set(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), i, @ptrFromInt(?*anyopaque, @intFromPtr(p))))); } pub fn sk_SRTP_PROTECTION_PROFILE_free(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) void { var sk = arg_sk; @@ -5594,7 +5594,7 @@ pub fn sk_SRTP_PROTECTION_PROFILE_insert(arg_sk: ?*struct_stack_st_SRTP_PROTECTI var sk = arg_sk; var p = arg_p; var where = arg_where; - return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @intToPtr(?*anyopaque, @ptrToInt(p)), where); + return sk_insert(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrFromInt(?*anyopaque, @intFromPtr(p)), where); } pub fn sk_SRTP_PROTECTION_PROFILE_delete(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_where: usize) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE { var sk = arg_sk; @@ -5619,7 +5619,7 @@ pub fn sk_SRTP_PROTECTION_PROFILE_shift(arg_sk: ?*struct_stack_st_SRTP_PROTECTIO pub fn sk_SRTP_PROTECTION_PROFILE_push(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE, arg_p: [*c]const SRTP_PROTECTION_PROFILE) callconv(.C) usize { var sk = arg_sk; var p = arg_p; - return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @intToPtr(?*anyopaque, @ptrToInt(p))); + return sk_push(@ptrCast([*c]_STACK, @alignCast(@import("std").meta.alignment(_STACK), sk)), @ptrFromInt(?*anyopaque, @intFromPtr(p))); } pub fn sk_SRTP_PROTECTION_PROFILE_pop(arg_sk: ?*struct_stack_st_SRTP_PROTECTION_PROFILE) callconv(.C) [*c]const SRTP_PROTECTION_PROFILE { var sk = arg_sk; diff --git a/src/deps/c_ares.zig b/src/deps/c_ares.zig index 4539358d0..79591899e 100644 --- a/src/deps/c_ares.zig +++ b/src/deps/c_ares.zig @@ -488,7 +488,7 @@ pub const Channel = opaque { break :brk null; } const len = @min(host.len, host_buf.len - 1); - @memcpy(&host_buf, host.ptr, len); + @memcpy(host_buf[0..len], host[0..len]); host_buf[len] = 0; break :brk host_buf[0..len :0].ptr; }; @@ -516,7 +516,8 @@ pub const Channel = opaque { break :brk null; } const len = @min(name_buf.len, name_buf.len - 1); - @memcpy(&name_buf, name.ptr, len); + @memcpy(name_buf[0..len], name[0..len]); + name_buf[len] = 0; break :brk name_buf[0..len :0]; }; @@ -1209,8 +1210,8 @@ pub const Error = enum(i32) { ESERVICE = ARES_ESERVICE, pub fn initEAI(rc: i32) ?Error { - return switch (@intToEnum(std.os.system.EAI, rc)) { - @intToEnum(std.os.system.EAI, 0) => return null, + return switch (@enumFromInt(std.os.system.EAI, rc)) { + @enumFromInt(std.os.system.EAI, 0) => return null, .ADDRFAMILY => Error.EBADFAMILY, .BADFLAGS => Error.EBADFLAGS, // Invalid hints .FAIL => Error.EBADRESP, @@ -1283,8 +1284,8 @@ pub const Error = enum(i32) { pub fn get(rc: i32) ?Error { return switch (rc) { 0 => null, - 1...ARES_ESERVICE => @intToEnum(Error, rc), - -ARES_ESERVICE...-1 => @intToEnum(Error, -rc), + 1...ARES_ESERVICE => @enumFromInt(Error, rc), + -ARES_ESERVICE...-1 => @enumFromInt(Error, -rc), else => unreachable, }; } diff --git a/src/deps/diffz/DiffMatchPatch.zig b/src/deps/diffz/DiffMatchPatch.zig index 7e545f364..a5cc02af4 100644 --- a/src/deps/diffz/DiffMatchPatch.zig +++ b/src/deps/diffz/DiffMatchPatch.zig @@ -178,7 +178,7 @@ fn diffInternal( } fn diffCommonPrefix(before: []const u8, after: []const u8) usize { - const n = std.math.min(before.len, after.len); + const n = @min(before.len, after.len); var i: usize = 0; while (i < n) : (i += 1) { @@ -191,7 +191,7 @@ fn diffCommonPrefix(before: []const u8, after: []const u8) usize { } fn diffCommonSuffix(before: []const u8, after: []const u8) usize { - const n = std.math.min(before.len, after.len); + const n = @min(before.len, after.len); var i: usize = 1; while (i <= n) : (i += 1) { @@ -996,8 +996,8 @@ fn diffCleanupSemantic(allocator: std.mem.Allocator, diffs: *DiffList) DiffError // Eliminate an equality that is smaller or equal to the edits on both // sides of it. if (last_equality != null and - (last_equality.?.len <= std.math.max(length_insertions1, length_deletions1)) and - (last_equality.?.len <= std.math.max(length_insertions2, length_deletions2))) + (last_equality.?.len <= @max(length_insertions1, length_deletions1)) and + (last_equality.?.len <= @max(length_insertions2, length_deletions2))) { // Duplicate record. try diffs.insert( @@ -1046,8 +1046,8 @@ fn diffCleanupSemantic(allocator: std.mem.Allocator, diffs: *DiffList) DiffError var overlap_length1: usize = diffCommonOverlap(deletion, insertion); var overlap_length2: usize = diffCommonOverlap(insertion, deletion); if (overlap_length1 >= overlap_length2) { - if (@intToFloat(f32, overlap_length1) >= @intToFloat(f32, deletion.len) / 2.0 or - @intToFloat(f32, overlap_length1) >= @intToFloat(f32, insertion.len) / 2.0) + if (@floatFromInt(f32, overlap_length1) >= @floatFromInt(f32, deletion.len) / 2.0 or + @floatFromInt(f32, overlap_length1) >= @floatFromInt(f32, insertion.len) / 2.0) { // Overlap found. // Insert an equality and trim the surrounding edits. @@ -1063,8 +1063,8 @@ fn diffCleanupSemantic(allocator: std.mem.Allocator, diffs: *DiffList) DiffError pointer += 1; } } else { - if (@intToFloat(f32, overlap_length2) >= @intToFloat(f32, deletion.len) / 2.0 or - @intToFloat(f32, overlap_length2) >= @intToFloat(f32, insertion.len) / 2.0) + if (@floatFromInt(f32, overlap_length2) >= @floatFromInt(f32, deletion.len) / 2.0 or + @floatFromInt(f32, overlap_length2) >= @floatFromInt(f32, insertion.len) / 2.0) { // Reverse overlap found. // Insert an equality and swap and trim the surrounding edits. diff --git a/src/deps/lol-html.zig b/src/deps/lol-html.zig index 975aac2b3..1d71e6aa6 100644 --- a/src/deps/lol-html.zig +++ b/src/deps/lol-html.zig @@ -727,11 +727,11 @@ pub fn DirectiveHandler(comptime Container: type, comptime UserDataType: type, c return struct { pub fn callback(this: *Container, user_data: ?*anyopaque) callconv(.C) Directive { auto_disable(); - return @intToEnum( + return @enumFromInt( Directive, @as( c_uint, - @boolToInt( + @intFromBool( Callback( @ptrCast( *UserDataType, diff --git a/src/deps/picohttp.zig b/src/deps/picohttp.zig index d18cb7fa0..722475bb5 100644 --- a/src/deps/picohttp.zig +++ b/src/deps/picohttp.zig @@ -15,7 +15,7 @@ pub const Header = struct { value: []const u8, pub fn isMultiline(self: Header) bool { - return @ptrToInt(self.name.ptr) == 0; + return @intFromPtr(self.name.ptr) == 0; } pub fn format(self: Header, comptime _: []const u8, _: fmt.FormatOptions, writer: anytype) !void { @@ -101,7 +101,7 @@ pub const Request = struct { ); // Leave a sentinel value, for JavaScriptCore support. - if (rc > -1) @intToPtr([*]u8, @ptrToInt(path.ptr))[path.len] = 0; + if (rc > -1) @ptrFromInt([*]u8, @intFromPtr(path.ptr))[path.len] = 0; return switch (rc) { -1 => error.BadRequest, diff --git a/src/deps/uws.zig b/src/deps/uws.zig index 538756b71..8ebe04ac0 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -23,7 +23,7 @@ fn NativeSocketHandleType(comptime ssl: bool) type { } pub fn NewSocketHandler(comptime ssl: bool) type { return struct { - const ssl_int: i32 = @boolToInt(ssl); + const ssl_int: i32 = @intFromBool(ssl); socket: *Socket, const ThisSocket = @This(); @@ -49,7 +49,7 @@ pub fn NewSocketHandler(comptime ssl: bool) type { @compileError("SSL sockets do not have a file descriptor accessible this way"); } - return @intCast(i32, @ptrToInt(us_socket_get_native_handle(0, this.socket))); + return @intCast(i32, @intFromPtr(us_socket_get_native_handle(0, this.socket))); } pub fn markNeedsMoreForSendfile(this: ThisSocket) void { @@ -92,18 +92,18 @@ pub fn NewSocketHandler(comptime ssl: bool) type { data.ptr, // truncate to 31 bits since sign bit exists @intCast(i32, @truncate(u31, data.len)), - @as(i32, @boolToInt(msg_more)), + @as(i32, @intFromBool(msg_more)), ); } pub fn shutdown(this: ThisSocket) void { - debug("us_socket_shutdown({d})", .{@ptrToInt(this.socket)}); + debug("us_socket_shutdown({d})", .{@intFromPtr(this.socket)}); return us_socket_shutdown( comptime ssl_int, this.socket, ); } pub fn shutdownRead(this: ThisSocket) void { - debug("us_socket_shutdown_read({d})", .{@ptrToInt(this.socket)}); + debug("us_socket_shutdown_read({d})", .{@intFromPtr(this.socket)}); return us_socket_shutdown_read( comptime ssl_int, this.socket, @@ -122,7 +122,7 @@ pub fn NewSocketHandler(comptime ssl: bool) type { ) > 0; } pub fn close(this: ThisSocket, code: i32, reason: ?*anyopaque) void { - debug("us_socket_close({d})", .{@ptrToInt(this.socket)}); + debug("us_socket_close({d})", .{@intFromPtr(this.socket)}); _ = us_socket_close( comptime ssl_int, this.socket, @@ -421,7 +421,7 @@ pub const Timer = opaque { pub const SocketContext = opaque { pub fn getNativeHandle(this: *SocketContext, comptime ssl: bool) *anyopaque { - return us_socket_context_get_native_handle(comptime @as(i32, @boolToInt(ssl)), this).?; + return us_socket_context_get_native_handle(comptime @as(i32, @intFromBool(ssl)), this).?; } fn _deinit_ssl(this: *SocketContext) void { @@ -446,8 +446,8 @@ pub const SocketContext = opaque { } pub fn close(this: *SocketContext, ssl: bool) void { - debug("us_socket_context_close({d})", .{@ptrToInt(this)}); - us_socket_context_close(@as(i32, @boolToInt(ssl)), this); + debug("us_socket_context_close({d})", .{@intFromPtr(this)}); + us_socket_context_close(@as(i32, @intFromBool(ssl)), this); } pub fn ext(this: *SocketContext, ssl: bool, comptime ContextType: type) ?*ContextType { @@ -457,7 +457,7 @@ pub const SocketContext = opaque { std.meta.alignment(ContextType); var ptr = us_socket_context_ext( - @boolToInt(ssl), + @intFromBool(ssl), this, ) orelse return null; @@ -700,7 +700,7 @@ pub const Poll = opaque { fallthrough: bool, flags: Flags, ) ?*Poll { - var poll = us_create_poll(loop, @as(i32, @boolToInt(fallthrough)), @sizeOf(Data)); + var poll = us_create_poll(loop, @as(i32, @intFromBool(fallthrough)), @sizeOf(Data)); if (comptime Data != void) { poll.data(Data).* = val; } @@ -810,7 +810,7 @@ pub const AnyWebSocket = union(enum) { } pub fn close(this: AnyWebSocket) void { - const ssl_flag = @boolToInt(this == .ssl); + const ssl_flag = @intFromBool(this == .ssl); return uws_ws_close(ssl_flag, this.raw()); } @@ -874,7 +874,7 @@ pub const AnyWebSocket = union(enum) { } pub fn publishWithOptions(ssl: bool, app: *anyopaque, topic: []const u8, message: []const u8, opcode: Opcode, compress: bool) bool { return uws_publish( - @boolToInt(ssl), + @intFromBool(ssl), @ptrCast(*uws_app_t, app), topic.ptr, topic.len, @@ -1073,10 +1073,10 @@ pub const Request = opaque { pub const ListenSocket = opaque { pub fn close(this: *ListenSocket, ssl: bool) void { - us_listen_socket_close(@boolToInt(ssl), this); + us_listen_socket_close(@intFromBool(ssl), this); } pub fn getLocalPort(this: *ListenSocket, ssl: bool) i32 { - return us_socket_local_port(@boolToInt(ssl), @ptrCast(*uws.Socket, this)); + return us_socket_local_port(@intFromBool(ssl), @ptrCast(*uws.Socket, this)); } }; extern fn us_listen_socket_close(ssl: i32, ls: *ListenSocket) void; @@ -1085,7 +1085,7 @@ extern fn us_socket_context_close(ssl: i32, ctx: *anyopaque) void; pub fn NewApp(comptime ssl: bool) type { return opaque { - const ssl_flag = @as(i32, @boolToInt(ssl)); + const ssl_flag = @as(i32, @intFromBool(ssl)); const ThisApp = @This(); pub fn close(this: *ThisApp) void { @@ -1428,7 +1428,7 @@ pub fn NewApp(comptime ssl: bool) type { } pub fn getNativeHandle(res: *Response) i32 { - return @intCast(i32, @ptrToInt(uws_res_get_native_handle(ssl_flag, res.downcast()))); + return @intCast(i32, @intFromPtr(uws_res_get_native_handle(ssl_flag, res.downcast()))); } pub fn onWritable( res: *Response, @@ -1880,23 +1880,23 @@ pub const State = enum(i32) { _, pub inline fn isResponsePending(this: State) bool { - return @enumToInt(this) & @enumToInt(State.HTTP_RESPONSE_PENDING) != 0; + return @intFromEnum(this) & @intFromEnum(State.HTTP_RESPONSE_PENDING) != 0; } pub inline fn isHttpEndCalled(this: State) bool { - return @enumToInt(this) & @enumToInt(State.HTTP_END_CALLED) != 0; + return @intFromEnum(this) & @intFromEnum(State.HTTP_END_CALLED) != 0; } pub inline fn isHttpWriteCalled(this: State) bool { - return @enumToInt(this) & @enumToInt(State.HTTP_WRITE_CALLED) != 0; + return @intFromEnum(this) & @intFromEnum(State.HTTP_WRITE_CALLED) != 0; } pub inline fn isHttpStatusCalled(this: State) bool { - return @enumToInt(this) & @enumToInt(State.HTTP_STATUS_CALLED) != 0; + return @intFromEnum(this) & @intFromEnum(State.HTTP_STATUS_CALLED) != 0; } pub inline fn isHttpConnectionClose(this: State) bool { - return @enumToInt(this) & @enumToInt(State.HTTP_CONNECTION_CLOSE) != 0; + return @intFromEnum(this) & @intFromEnum(State.HTTP_CONNECTION_CLOSE) != 0; } }; diff --git a/src/deps/zig-clap/clap.zig b/src/deps/zig-clap/clap.zig index 16824e788..68cd2451c 100644 --- a/src/deps/zig-clap/clap.zig +++ b/src/deps/zig-clap/clap.zig @@ -111,7 +111,7 @@ fn parseParamRest(line: []const u8) Param(Help) { const len = mem.indexOfScalar(u8, line, '>') orelse break :blk; const takes_many = mem.startsWith(u8, line[len + 1 ..], "..."); const takes_one_optional = mem.startsWith(u8, line[len + 1 ..], "?"); - const help_start = len + 1 + @as(usize, 3) * @boolToInt(takes_many) + (@as(usize, 1) * @boolToInt(takes_one_optional)); + const help_start = len + 1 + @as(usize, 3) * @intFromBool(takes_many) + (@as(usize, 1) * @intFromBool(takes_one_optional)); return .{ .takes_value = if (takes_many) Values.many else if (takes_one_optional) Values.one_optional else Values.one, .id = .{ diff --git a/src/deps/zig-datetime/src/datetime.zig b/src/deps/zig-datetime/src/datetime.zig index 29a936630..1014863b8 100644 --- a/src/deps/zig-datetime/src/datetime.zig +++ b/src/deps/zig-datetime/src/datetime.zig @@ -47,7 +47,7 @@ pub const Month = enum(u4) { if (month.len == 3) { inline for (std.meta.fields(Month)) |f| { if (ascii.eqlIgnoreCase(f.name[0..3], month)) { - return @intToEnum(Month, f.value); + return @enumFromInt(Month, f.value); } } } @@ -57,7 +57,7 @@ pub const Month = enum(u4) { pub fn parseName(month: []const u8) !Month { inline for (std.meta.fields(Month)) |f| { if (ascii.eqlIgnoreCase(f.name, month)) { - return @intToEnum(Month, f.value); + return @enumFromInt(Month, f.value); } } return error.InvalidFormat; @@ -313,7 +313,7 @@ pub const Date = struct { // Create a date from the number of seconds since 1 Jan 1970 pub fn fromSeconds(seconds: f64) Date { const r = math.modf(seconds); - const timestamp = @floatToInt(i64, r.ipart); // Seconds + const timestamp = @intFromFloat(i64, r.ipart); // Seconds const days = @divFloor(timestamp, time.s_per_day) + @as(i64, EPOCH); assert(days >= 0 and days <= MAX_ORDINAL); return Date.fromOrdinal(@intCast(u32, days)); @@ -322,7 +322,7 @@ pub const Date = struct { // Return the number of seconds since 1 Jan 1970 pub fn toSeconds(self: Date) f64 { const days = @intCast(i64, self.toOrdinal()) - @as(i64, EPOCH); - return @intToFloat(f64, days * time.s_per_day); + return @floatFromInt(f64, days * time.s_per_day); } // Create a date from a UTC timestamp in milliseconds relative to Jan 1st 1970 @@ -445,7 +445,7 @@ pub const Date = struct { // Return day of week starting with Monday = 1 and Sunday = 7 pub fn dayOfWeek(self: Date) Weekday { const dow = @intCast(u3, self.toOrdinal() % 7); - return @intToEnum(Weekday, if (dow == 0) 7 else dow); + return @enumFromInt(Weekday, if (dow == 0) 7 else dow); } // Return the ISO calendar based week of year. With 1 being the first week. @@ -455,7 +455,7 @@ pub const Date = struct { // Return day of week starting with Monday = 0 and Sunday = 6 pub fn weekday(self: Date) u4 { - return @enumToInt(self.dayOfWeek()) - 1; + return @intFromEnum(self.dayOfWeek()) - 1; } // Return whether the date is a weekend (Saturday or Sunday) @@ -471,7 +471,7 @@ pub const Date = struct { // Return the name of the day of the month, eg "January" pub fn monthName(self: Date) []const u8 { assert(self.month >= 1 and self.month <= 12); - return @tagName(@intToEnum(Month, self.month)); + return @tagName(@enumFromInt(Month, self.month)); } // ------------------------------------------------------------------------ @@ -596,7 +596,7 @@ test "date-from-seconds" { // // Max check // var max_date = try Date.create(9999, 12, 31); - // const tmax: f64 = @intToFloat(f64, MAX_ORDINAL-1) * time.s_per_day; + // const tmax: f64 = @floatFromInt(f64, MAX_ORDINAL-1) * time.s_per_day; // date = Date.fromSeconds(tmax); // try testing.expect(date.eql(max_date)); // try testing.expectEqual(date.toSeconds(), tmax); @@ -859,7 +859,7 @@ pub const Time = struct { assert(seconds >= 0); // Convert to s and us const r = math.modf(seconds); - var s = @floatToInt(u32, @mod(r.ipart, time.s_per_day)); // s + var s = @intFromFloat(u32, @mod(r.ipart, time.s_per_day)); // s const h = @divFloor(s, time.s_per_hour); s -= h * time.s_per_hour; const m = @divFloor(s, time.s_per_min); @@ -875,15 +875,15 @@ pub const Time = struct { s -= 1; frac += time.ns_per_s; } - const ns = @floatToInt(u32, frac); + const ns = @intFromFloat(u32, frac); return Time.create(h, m, s, ns) catch unreachable; // If this fails it's a bug } // Convert to a time in seconds relative to the UTC timezones // including the nanosecond component pub fn toSeconds(self: Time) f64 { - const s = @intToFloat(f64, self.totalSeconds()); - const ns = @intToFloat(f64, self.nanosecond) / time.ns_per_s; + const s = @floatFromInt(f64, self.totalSeconds()); + const ns = @floatFromInt(f64, self.nanosecond) / time.ns_per_s; return s + ns; } @@ -1393,7 +1393,7 @@ pub const Datetime = struct { const value = std.mem.trim(u8, ims, " "); if (value.len < 29) return error.InvalidFormat; const day = std.fmt.parseInt(u8, value[5..7], 10) catch return error.InvalidFormat; - const month = @enumToInt(try Month.parseAbbr(value[8..11])); + const month = @intFromEnum(try Month.parseAbbr(value[8..11])); const year = std.fmt.parseInt(u16, value[12..16], 10) catch return error.InvalidFormat; const hour = std.fmt.parseInt(u8, value[17..19], 10) catch return error.InvalidFormat; const minute = std.fmt.parseInt(u8, value[20..22], 10) catch return error.InvalidFormat; diff --git a/src/env_loader.zig b/src/env_loader.zig index 8a3838101..14e1196b6 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -52,7 +52,7 @@ pub const Lexer = struct { pub inline fn step(this: *Lexer) void { const ended = !this.iter.next(&this.cursor); if (ended) this.cursor.c = -1; - this.current = this.cursor.i + @as(usize, @boolToInt(ended)); + this.current = this.cursor.i + @as(usize, @intFromBool(ended)); } pub fn eatNestedValue( @@ -73,7 +73,7 @@ pub const Lexer = struct { i += 1; const start = i; - const curly_braces_offset = @as(usize, @boolToInt(variable.value[i] == '{')); + const curly_braces_offset = @as(usize, @intFromBool(variable.value[i] == '{')); i += curly_braces_offset; while (i < variable.value.len) { @@ -422,7 +422,7 @@ pub const Loader = struct { pub fn getNodePath(this: *Loader, fs: *Fs.FileSystem, buf: *Fs.PathBuffer) ?[:0]const u8 { if (this.get("NODE") orelse this.get("npm_node_execpath")) |node| { - @memcpy(buf, node.ptr, node.len); + @memcpy(buf[0..node.len], node); buf[node.len] = 0; return buf[0..node.len :0]; } @@ -556,7 +556,7 @@ pub const Loader = struct { var string_map_hashes = try allocator.alloc(u64, framework_defaults.keys.len); defer allocator.free(string_map_hashes); const invalid_hash = std.math.maxInt(u64) - 1; - std.mem.set(u64, string_map_hashes, invalid_hash); + @memset(string_map_hashes, invalid_hash); var key_buf: []u8 = ""; // Frameworks determine an allowlist of values @@ -564,7 +564,7 @@ pub const Loader = struct { for (framework_defaults.keys, 0..) |key, i| { if (key.len > "process.env.".len and strings.eqlComptime(key[0.."process.env.".len], "process.env.")) { const hashable_segment = key["process.env.".len..]; - string_map_hashes[i] = std.hash.Wyhash.hash(0, hashable_segment); + string_map_hashes[i] = bun.hash(hashable_segment); } } @@ -616,7 +616,7 @@ pub const Loader = struct { e_strings[0] = js_ast.E.String{ .data = if (value.len > 0) - @intToPtr([*]u8, @ptrToInt(value.ptr))[0..value.len] + @ptrFromInt([*]u8, @intFromPtr(value.ptr))[0..value.len] else &[_]u8{}, }; @@ -632,14 +632,14 @@ pub const Loader = struct { ); e_strings = e_strings[1..]; } else { - const hash = std.hash.Wyhash.hash(0, entry.key_ptr.*); + const hash = bun.hash(entry.key_ptr.*); std.debug.assert(hash != invalid_hash); if (std.mem.indexOfScalar(u64, string_map_hashes, hash)) |key_i| { e_strings[0] = js_ast.E.String{ .data = if (value.len > 0) - @intToPtr([*]u8, @ptrToInt(value.ptr))[0..value.len] + @ptrFromInt([*]u8, @intFromPtr(value.ptr))[0..value.len] else &[_]u8{}, }; @@ -665,7 +665,7 @@ pub const Loader = struct { e_strings[0] = js_ast.E.String{ .data = if (entry.value_ptr.*.len > 0) - @intToPtr([*]u8, @ptrToInt(entry.value_ptr.*.ptr))[0..value.len] + @ptrFromInt([*]u8, @intFromPtr(entry.value_ptr.*.ptr))[0..value.len] else &[_]u8{}, }; @@ -803,17 +803,17 @@ pub const Loader = struct { pub fn printLoaded(this: *Loader, start: i128) void { const count = - @intCast(u8, @boolToInt(this.@".env.development.local" != null)) + - @intCast(u8, @boolToInt(this.@".env.production.local" != null)) + - @intCast(u8, @boolToInt(this.@".env.test.local" != null)) + - @intCast(u8, @boolToInt(this.@".env.local" != null)) + - @intCast(u8, @boolToInt(this.@".env.development" != null)) + - @intCast(u8, @boolToInt(this.@".env.production" != null)) + - @intCast(u8, @boolToInt(this.@".env.test" != null)) + - @intCast(u8, @boolToInt(this.@".env" != null)); + @intCast(u8, @intFromBool(this.@".env.development.local" != null)) + + @intCast(u8, @intFromBool(this.@".env.production.local" != null)) + + @intCast(u8, @intFromBool(this.@".env.test.local" != null)) + + @intCast(u8, @intFromBool(this.@".env.local" != null)) + + @intCast(u8, @intFromBool(this.@".env.development" != null)) + + @intCast(u8, @intFromBool(this.@".env.production" != null)) + + @intCast(u8, @intFromBool(this.@".env.test" != null)) + + @intCast(u8, @intFromBool(this.@".env" != null)); if (count == 0) return; - const elapsed = @intToFloat(f64, (std.time.nanoTimestamp() - start)) / std.time.ns_per_ms; + const elapsed = @floatFromInt(f64, (std.time.nanoTimestamp() - start)) / std.time.ns_per_ms; const all = [_]string{ ".env.development.local", diff --git a/src/exact_size_matcher.zig b/src/exact_size_matcher.zig index 5d47cee98..67d0b8fe8 100644 --- a/src/exact_size_matcher.zig +++ b/src/exact_size_matcher.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const bun = @import("root").bun; pub fn ExactSizeMatcher(comptime max_bytes: usize) type { switch (max_bytes) { @@ -19,11 +20,11 @@ pub fn ExactSizeMatcher(comptime max_bytes: usize) type { 1...max_bytes - 1 => { var tmp: [max_bytes]u8 = undefined; if (comptime std.meta.trait.isSlice(@TypeOf(str))) { - @memcpy(&tmp, str.ptr, str.len); - @memset(tmp[str.len..].ptr, 0, tmp[str.len..].len); + @memcpy(tmp[0..str.len], str); + @memset(tmp[str.len..], 0); } else { - @memcpy(&tmp, str, str.len); - @memset(tmp[str.len..], 0, tmp[str.len..].len); + @memcpy(tmp[0..str.len], str); + @memset(tmp[str.len..], 0); } return std.mem.readIntNative(T, &tmp); @@ -47,7 +48,7 @@ pub fn ExactSizeMatcher(comptime max_bytes: usize) type { for (str, 0..) |char, i| { tmp[i] = std.ascii.toLower(char); } - @memset(tmp[str.len..].ptr, 0, tmp[str.len..].len); + @memset(tmp[str.len..], 0); return std.mem.readIntNative(T, &tmp); }, max_bytes => { diff --git a/src/fs.zig b/src/fs.zig index 2dca8169c..e87d931df 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -157,10 +157,10 @@ pub const FileSystem = struct { pub fn addEntry(dir: *DirEntry, prev_map: ?*EntryMap, entry: std.fs.IterableDir.Entry, allocator: std.mem.Allocator, comptime Iterator: type, iterator: Iterator) !void { const _kind: Entry.Kind = switch (entry.kind) { - .Directory => .dir, + .directory => .dir, // This might be wrong! - .SymLink => .file, - .File => .file, + .sym_link => .file, + .file => .file, else => return, }; @@ -207,7 +207,7 @@ pub const FileSystem = struct { // Call "stat" lazily for performance. The "@material-ui/icons" package // contains a directory with over 11,000 entries in it and running "stat" // for each entry was a big performance issue for that package. - .need_stat = entry.kind == .SymLink, + .need_stat = entry.kind == .sym_link, .cache = .{ .symlink = PathString.empty, .kind = _kind, @@ -768,7 +768,7 @@ pub const FileSystem = struct { hash_bytes_remain = hash_bytes_remain[@sizeOf(@TypeOf(this.mtime))..]; std.debug.assert(hash_bytes_remain.len == 8); hash_bytes_remain[0..8].* = @bitCast([8]u8, @as(u64, 0)); - return std.hash.Wyhash.hash(0, &hash_bytes); + return bun.hash(&hash_bytes); } pub fn generate(_: *RealFS, _: string, file: std.fs.File) anyerror!ModKey { @@ -1127,7 +1127,7 @@ pub const FileSystem = struct { const absolute_path_c: [:0]const u8 = outpath[0..entry_path.len :0]; var stat = try C.lstat_absolute(absolute_path_c); - const is_symlink = stat.kind == std.fs.File.Kind.SymLink; + const is_symlink = stat.kind == std.fs.File.Kind.sym_link; var _kind = stat.kind; var cache = Entry.Cache{ .kind = Entry.Kind.file, @@ -1158,9 +1158,9 @@ pub const FileSystem = struct { _kind = _stat.kind; } - std.debug.assert(_kind != .SymLink); + std.debug.assert(_kind != .sym_link); - if (_kind == .Directory) { + if (_kind == .directory) { cache.kind = .dir; } else { cache.kind = .file; @@ -1318,8 +1318,8 @@ pub const PathName = struct { // so we extend the original slice's length by one return if (this.dir.len == 0) "./" else this.dir.ptr[0 .. this.dir.len + @intCast( usize, - @boolToInt( - this.dir[this.dir.len - 1] != std.fs.path.sep_posix and (@ptrToInt(this.dir.ptr) + this.dir.len + 1) == @ptrToInt(this.base.ptr), + @intFromBool( + this.dir[this.dir.len - 1] != std.fs.path.sep_posix and (@intFromPtr(this.dir.ptr) + this.dir.len + 1) == @intFromPtr(this.base.ptr), ), )]; } diff --git a/src/futex.zig b/src/futex.zig index 14c342321..9741032d2 100644 --- a/src/futex.zig +++ b/src/futex.zig @@ -209,7 +209,7 @@ const DarwinFutex = struct { }; if (status >= 0) return; - switch (@intToEnum(std.os.E, -status)) { + switch (@enumFromInt(std.os.E, -status)) { .INTR => {}, // Address of the futex is paged out. This is unlikely, but possible in theory, and // pthread/libdispatch on darwin bother to handle it. In this case we'll return @@ -231,7 +231,7 @@ const DarwinFutex = struct { const status = darwin.__ulock_wake(flags, addr, 0); if (status >= 0) return; - switch (@intToEnum(std.os.E, -status)) { + switch (@enumFromInt(std.os.E, -status)) { .INTR => continue, // spurious wake() .FAULT => continue, // address of the lock was paged out .NOENT => return, // nothing was woken up @@ -244,7 +244,7 @@ const DarwinFutex = struct { const PosixFutex = struct { fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut}!void { - const address = @ptrToInt(ptr); + const address = @intFromPtr(ptr); const bucket = Bucket.from(address); var waiter: List.Node = undefined; @@ -282,7 +282,7 @@ const PosixFutex = struct { } fn wake(ptr: *const Atomic(u32), num_waiters: u32) void { - const address = @ptrToInt(ptr); + const address = @intFromPtr(ptr); const bucket = Bucket.from(address); var can_notify = num_waiters; diff --git a/src/hive_array.zig b/src/hive_array.zig index a29fe6842..0213156fd 100644 --- a/src/hive_array.zig +++ b/src/hive_array.zig @@ -37,11 +37,11 @@ pub fn HiveArray(comptime T: type, comptime capacity: u16) type { pub fn indexOf(self: *const Self, value: *const T) ?u32 { const start = &self.buffer; const end = @ptrCast([*]const T, start) + capacity; - if (!(@ptrToInt(value) >= @ptrToInt(start) and @ptrToInt(value) < @ptrToInt(end))) + if (!(@intFromPtr(value) >= @intFromPtr(start) and @intFromPtr(value) < @intFromPtr(end))) return null; // aligned to the size of T - const index = (@ptrToInt(value) - @ptrToInt(start)) / @sizeOf(T); + const index = (@intFromPtr(value) - @intFromPtr(start)) / @sizeOf(T); assert(index < capacity); assert(&self.buffer[index] == value); return @intCast(u32, index); @@ -50,7 +50,7 @@ pub fn HiveArray(comptime T: type, comptime capacity: u16) type { pub fn in(self: *const Self, value: *const T) bool { const start = &self.buffer; const end = @ptrCast([*]const T, start) + capacity; - return (@ptrToInt(value) >= @ptrToInt(start) and @ptrToInt(value) < @ptrToInt(end)); + return (@intFromPtr(value) >= @intFromPtr(start) and @intFromPtr(value) < @intFromPtr(end)); } pub fn put(self: *Self, value: *T) bool { diff --git a/src/http.zig b/src/http.zig index d2924b804..827bfa6de 100644 --- a/src/http.zig +++ b/src/http.zig @@ -437,7 +437,7 @@ pub const RequestContext = struct { .reason = step, .cwd = this.bundler.fs.top_level_dir, .problems = Api.Problems{ - .code = @truncate(u16, @errorToInt(err)), + .code = @truncate(u16, @intFromError(err)), .name = @errorName(err), .exceptions = exceptions, .build = try log.toAPI(allocator), @@ -559,7 +559,7 @@ pub const RequestContext = struct { var stat = file.stat() catch return null; var absolute_path = resolve_path.joinAbs(this.bundler.options.routes.static_dir, .auto, relative_unrooted_path); - if (stat.kind == .SymLink) { + if (stat.kind == .sym_link) { file.* = std.fs.openFileAbsolute(absolute_path, .{ .mode = .read_only }) catch return null; absolute_path = bun.getFdPath( @@ -570,7 +570,7 @@ pub const RequestContext = struct { stat = file.stat() catch return null; } - if (stat.kind != .File) { + if (stat.kind != .file) { file.close(); return null; } @@ -1431,7 +1431,7 @@ pub const RequestContext = struct { JavaScript.API.Bun.flushCSSImports(); vm.flush(); - Output.printElapsed(@intToFloat(f64, (handler.start_timer.read())) / std.time.ns_per_ms); + Output.printElapsed(@floatFromInt(f64, (handler.start_timer.read())) / std.time.ns_per_ms); if (vm.bundler.options.framework.?.display_name.len > 0) { Output.prettyError( @@ -2000,11 +2000,7 @@ pub const RequestContext = struct { // sometimes the final byte has incorrect data // we never end up using all those bytes if (handler.message_buffer.list.items.len > 0) { - @memset( - handler.message_buffer.list.items.ptr, - 0, - @min(handler.message_buffer.list.items.len, 128), - ); + @memset(handler.message_buffer.list.items[0..@min(handler.message_buffer.list.items.len, 128)], 0); } const build_result = handler.builder.build(request_id, cmd.timestamp, arena.allocator()) catch |err| { if (err == error.MissingWatchID) { @@ -2087,7 +2083,7 @@ pub const RequestContext = struct { socket_buffers[2] = iovec(build_result.bytes); // we reuse the accept key buffer // so we have a pointer that is not stack memory - handler.accept_key[0..@sizeOf(usize)].* = @bitCast([@sizeOf(usize)]u8, std.hash.Wyhash.hash(0, build_result.bytes)); + handler.accept_key[0..@sizeOf(usize)].* = @bitCast([@sizeOf(usize)]u8, bun.hash(build_result.bytes)); socket_buffers[3] = iovec(handler.accept_key[0..4]); socket_buffer_count = 4; } @@ -2110,7 +2106,7 @@ pub const RequestContext = struct { else => { Output.prettyErrorln( "[Websocket]: Unknown cmd: {d}. This might be a version mismatch. Try updating your node_modules.bun", - .{@enumToInt(cmd.kind)}, + .{@intFromEnum(cmd.kind)}, ); }, } @@ -2187,7 +2183,7 @@ pub const RequestContext = struct { }; pub fn writeETag(this: *RequestContext, buffer: anytype) !bool { - const strong_etag = std.hash.Wyhash.hash(0, buffer); + const strong_etag = bun.hash(buffer); const etag_content_slice = std.fmt.bufPrintIntToSlice(strong_etag_buffer[0..49], strong_etag, 16, .upper, .{}); this.appendHeader("ETag", etag_content_slice); @@ -2404,7 +2400,7 @@ pub const RequestContext = struct { // Always cache css & json files, even big ones // css is especially important because we want to try and skip having the browser parse it whenever we can if (buf.len < 16 * 16 * 16 * 16 or chunky._loader == .css or chunky._loader == .json) { - const strong_etag = std.hash.Wyhash.hash(0, buf); + const strong_etag = bun.hash(buf); const etag_content_slice = std.fmt.bufPrintIntToSlice(strong_etag_buffer[0..49], strong_etag, 16, .upper, .{}); chunky.rctx.appendHeader("ETag", etag_content_slice); @@ -2538,7 +2534,7 @@ pub const RequestContext = struct { .css => try ctx.sendNoContent(), .toml, .js, .jsx, .ts, .tsx, .json => { const buf = "export default {};"; - const strong_etag = comptime std.hash.Wyhash.hash(0, buf); + const strong_etag = comptime bun.hash(buf); const etag_content_slice = std.fmt.bufPrintIntToSlice(strong_etag_buffer[0..49], strong_etag, 16, .upper, .{}); ctx.appendHeader("ETag", etag_content_slice); @@ -3388,10 +3384,10 @@ pub const Server = struct { break :brk path_string.slice(); } else { var file_path_without_trailing_slash = std.mem.trimRight(u8, file_path, std.fs.path.sep_str); - @memcpy(&_on_file_update_path_buf, file_path_without_trailing_slash.ptr, file_path_without_trailing_slash.len); + @memcpy(_on_file_update_path_buf[0..file_path_without_trailing_slash.len], file_path_without_trailing_slash); _on_file_update_path_buf[file_path_without_trailing_slash.len] = std.fs.path.sep; - @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len + 1 ..].ptr, changed_name.ptr, changed_name.len); + @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len + 1 .. changed_name.len], changed_name); const path_slice = _on_file_update_path_buf[0 .. file_path_without_trailing_slash.len + changed_name.len + 1]; file_hash = Watcher.getHash(path_slice); break :brk path_slice; @@ -3445,12 +3441,9 @@ pub const Server = struct { .kernel_backlog = 1280, }); defer listener.deinit(); - server.websocket_threadpool.stack_size = @truncate( - u32, - @min( - @max(128_000, Fs.FileSystem.RealFS.Limit.stack), - 4_000_000, - ), + server.websocket_threadpool.stack_size = @min( + @max(128_000, Fs.FileSystem.RealFS.Limit.stack), + 4_000_000, ); // listener.setFastOpen(true) catch {}; diff --git a/src/http/websocket.zig b/src/http/websocket.zig index 98410d57c..48a4cebf5 100644 --- a/src/http/websocket.zig +++ b/src/http/websocket.zig @@ -34,7 +34,7 @@ pub const Opcode = enum(u4) { ResF = 0xF, pub fn isControl(opcode: Opcode) bool { - return @enumToInt(opcode) & 0x8 != 0; + return @intFromEnum(opcode) & 0x8 != 0; } }; @@ -261,7 +261,7 @@ pub const Websocket = struct { } pub fn read(self: *Websocket) !WebsocketDataFrame { - @memset(&self.buf, 0, self.buf.len); + @memset(&self.buf, 0); // Read and retry if we hit the end of the stream buffer var start = try self.stream.read(&self.buf); @@ -274,7 +274,7 @@ pub const Websocket = struct { } pub fn eatAt(self: *Websocket, offset: usize, _len: usize) []u8 { - const len = std.math.min(self.read_stream.buffer.len, _len); + const len = @min(self.read_stream.buffer.len, _len); self.read_stream.pos = len; return self.read_stream.buffer[offset..len]; } @@ -292,7 +292,7 @@ pub const Websocket = struct { // header.rsv1 = header_bytes[0] & 0x40 == 0x40; // header.rsv2 = header_bytes[0] & 0x20; // header.rsv3 = header_bytes[0] & 0x10; - header.opcode = @intToEnum(Opcode, @truncate(u4, header_bytes[0])); + header.opcode = @enumFromInt(Opcode, @truncate(u4, header_bytes[0])); header.mask = header_bytes[1] & 0x80 == 0x80; header.len = @truncate(u7, header_bytes[1]); diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index e1bd42984..e79c353e3 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -77,9 +77,9 @@ fn buildRequestBody( }; if (client_protocol.len > 0) - client_protocol_hash.* = std.hash.Wyhash.hash(0, static_headers[1].value); + client_protocol_hash.* = bun.hash(static_headers[1].value); - const headers_ = static_headers[0 .. 1 + @as(usize, @boolToInt(client_protocol.len > 0))]; + const headers_ = static_headers[0 .. 1 + @as(usize, @intFromBool(client_protocol.len > 0))]; const pathname_ = pathname.slice(); const host_ = host.slice(); @@ -289,7 +289,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { this.clearData(); if (!this.tcp.isEstablished()) { - _ = uws.us_socket_close_connecting(comptime @as(c_int, @boolToInt(ssl)), this.tcp.socket); + _ = uws.us_socket_close_connecting(comptime @as(c_int, @intFromBool(ssl)), this.tcp.socket); } else { this.tcp.close(0, null); } @@ -387,7 +387,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { const to_write = remain[0..@min(remain.len, data.len)]; if (data.len > 0 and to_write.len > 0) { - @memcpy(remain.ptr, data.ptr, to_write.len); + @memcpy(remain[0..to_write.len], data[0..to_write.len]); this.body_written += to_write.len; } @@ -465,7 +465,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { }, "Sec-WebSocket-Protocol".len => { if (strings.eqlCaseInsensitiveASCII(header.name, "Sec-WebSocket-Protocol", false)) { - if (this.websocket_protocol == 0 or std.hash.Wyhash.hash(0, header.value) != this.websocket_protocol) { + if (this.websocket_protocol == 0 or bun.hash(header.value) != this.websocket_protocol) { this.terminate(ErrorCode.mismatch_client_protocol); return; } @@ -524,7 +524,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { this.terminate(ErrorCode.invalid_response); return; }; - if (remain_buf.len > 0) @memcpy(overflow.ptr, remain_buf.ptr, remain_buf.len); + if (remain_buf.len > 0) @memcpy(overflow[0..remain_buf.len], remain_buf); } this.clearData(); @@ -775,7 +775,7 @@ const Copy = union(enum) { if (this == .raw) { std.debug.assert(buf.len >= this.raw.len); std.debug.assert(buf.ptr != this.raw.ptr); - @memcpy(buf.ptr, this.raw.ptr, this.raw.len); + @memcpy(buf[0..this.raw.len], this.raw); return; } @@ -914,7 +914,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { return; if (!this.tcp.isEstablished()) { - _ = uws.us_socket_close_connecting(comptime @as(c_int, @boolToInt(ssl)), this.tcp.socket); + _ = uws.us_socket_close_connecting(comptime @as(c_int, @intFromBool(ssl)), this.tcp.socket); } else { this.tcp.close(0, null); } @@ -1027,7 +1027,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { std.debug.assert(data_.len > 0); var writable = this.receive_buffer.writableWithSize(data_.len) catch unreachable; - @memcpy(writable.ptr, data_.ptr, data_.len); + @memcpy(writable[0..data_.len], data_); this.receive_buffer.update(data_.len); if (left_in_fragment >= data_.len and left_in_fragment - data_.len - this.receive_pending_chunk_len == 0) { @@ -1177,10 +1177,10 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { .ping => { const ping_len = @min(data.len, @min(receive_body_remain, 125)); - this.ping_len = @truncate(u8, ping_len); + this.ping_len = ping_len; if (ping_len > 0) { - @memcpy(this.ping_frame_bytes[6..], data.ptr, ping_len); + @memcpy(this.ping_frame_bytes[6..][0..ping_len], data[0..ping_len]); data = data[ping_len..]; } @@ -1379,7 +1379,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { std.mem.writeIntSliceBig(u16, final_body_bytes[6..8], code); if (body) |data| { - if (body_len > 0) @memcpy(final_body_bytes[8..], data, body_len); + if (body_len > 0) @memcpy(final_body_bytes[8..][0..body_len], data[0..body_len]); } // we must mask the code @@ -1565,7 +1565,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { this.adopted.receive_buffer.ensureUnusedCapacity(this.slice.len) catch return; var writable = this.adopted.receive_buffer.writableSlice(0); - @memcpy(writable.ptr, this.slice.ptr, this.slice.len); + @memcpy(writable[0..this.slice.len], this.slice); this.adopted.handleData(this.adopted.tcp, writable); } diff --git a/src/http_client_async.zig b/src/http_client_async.zig index fe5f34f48..a1962a8b9 100644 --- a/src/http_client_async.zig +++ b/src/http_client_async.zig @@ -42,7 +42,7 @@ const HiveArray = @import("./hive_array.zig").HiveArray; const Batch = NetworkThread.Batch; const TaggedPointerUnion = @import("./tagged_pointer.zig").TaggedPointerUnion; const DeadSocket = opaque {}; -var dead_socket = @intToPtr(*DeadSocket, 1); +var dead_socket = @ptrFromInt(*DeadSocket, 1); //TODO: this needs to be freed when Worker Threads are implemented var socket_async_http_abort_tracker = std.AutoArrayHashMap(u32, *uws.Socket).init(bun.default_allocator); var async_http_id: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0); @@ -208,7 +208,7 @@ const ProxyTunnel = struct { _ = BoringSSL.BIO_push(out_bio, proxy_bio); } else { // socket output bio for non-TLS -> TLS - var fd = @intCast(c_int, @ptrToInt(socket.getNativeHandle())); + var fd = @intCast(c_int, @intFromPtr(socket.getNativeHandle())); out_bio = BoringSSL.BIO_new_fd(fd, BoringSSL.BIO_NOCLOSE); } @@ -306,7 +306,7 @@ fn NewHTTPContext(comptime ssl: bool) type { HTTPClient, PooledSocket, }); - const ssl_int = @as(c_int, @boolToInt(ssl)); + const ssl_int = @as(c_int, @intFromBool(ssl)); const MAX_KEEPALIVE_HOSTNAME = 128; @@ -320,7 +320,8 @@ fn NewHTTPContext(comptime ssl: bool) type { pub fn init(this: *@This()) !void { var opts: uws.us_socket_context_options_t = undefined; - @memset(@ptrCast([*]u8, &opts), 0, @sizeOf(uws.us_socket_context_options_t)); + const size = @sizeOf(uws.us_socket_context_options_t); + @memset(@ptrCast([*]u8, &opts)[0..size], 0); this.us_socket_context = uws.us_create_socket_context(ssl_int, http_thread.loop, @sizeOf(usize), opts).?; if (comptime ssl) { this.sslCtx().setup(); @@ -337,7 +338,7 @@ fn NewHTTPContext(comptime ssl: bool) type { /// Attempt to keep the socket alive by reusing it for another request. /// If no space is available, close the socket. pub fn releaseSocket(this: *@This(), socket: HTTPSocket, hostname: []const u8, port: u16) void { - log("releaseSocket(0x{})", .{bun.fmt.hexIntUpper(@ptrToInt(socket.socket))}); + log("releaseSocket(0x{})", .{bun.fmt.hexIntUpper(@intFromPtr(socket.socket))}); if (comptime Environment.allow_assert) { std.debug.assert(!socket.isClosed()); @@ -354,11 +355,11 @@ fn NewHTTPContext(comptime ssl: bool) type { socket.timeout(300); pending.http_socket = socket; - @memcpy(&pending.hostname_buf, hostname.ptr, hostname.len); + @memcpy(pending.hostname_buf[0..hostname.len], hostname); pending.hostname_len = @truncate(u8, hostname.len); pending.port = port; - log("Keep-Alive release {s}:{d} (0x{})", .{ hostname, port, @ptrToInt(socket.socket) }); + log("Keep-Alive release {s}:{d} (0x{})", .{ hostname, port, @intFromPtr(socket.socket) }); return; } } @@ -778,7 +779,7 @@ pub fn onOpen( var hostname_needs_free = false; if (!strings.isIPAddress(_hostname)) { if (_hostname.len < temp_hostname.len) { - @memcpy(&temp_hostname, _hostname.ptr, _hostname.len); + @memcpy(temp_hostname[0.._hostname.len], _hostname); temp_hostname[_hostname.len] = 0; hostname = temp_hostname[0.._hostname.len :0]; } else { @@ -1393,7 +1394,7 @@ pub const AsyncHTTP = struct { if (proxy.password.len > 0 and proxy.password.len < 4096) { // decode password var password_buffer: [4096]u8 = undefined; - std.mem.set(u8, &password_buffer, 0); + @memset(&password_buffer, 0); var password_stream = std.io.fixedBufferStream(&password_buffer); var password_writer = password_stream.writer(); const PassWriter = @TypeOf(password_writer); @@ -1405,7 +1406,7 @@ pub const AsyncHTTP = struct { // Decode username var username_buffer: [4096]u8 = undefined; - std.mem.set(u8, &username_buffer, 0); + @memset(&username_buffer, 0); var username_stream = std.io.fixedBufferStream(&username_buffer); var username_writer = username_stream.writer(); const UserWriter = @TypeOf(username_writer); @@ -1426,7 +1427,7 @@ pub const AsyncHTTP = struct { } else { //Decode username var username_buffer: [4096]u8 = undefined; - std.mem.set(u8, &username_buffer, 0); + @memset(&username_buffer, 0); var username_stream = std.io.fixedBufferStream(&username_buffer); var username_writer = username_stream.writer(); const UserWriter = @TypeOf(username_writer); @@ -1469,7 +1470,7 @@ pub const AsyncHTTP = struct { if (proxy.password.len > 0 and proxy.password.len < 4096) { // decode password var password_buffer: [4096]u8 = undefined; - std.mem.set(u8, &password_buffer, 0); + @memset(&password_buffer, 0); var password_stream = std.io.fixedBufferStream(&password_buffer); var password_writer = password_stream.writer(); const PassWriter = @TypeOf(password_writer); @@ -1481,7 +1482,7 @@ pub const AsyncHTTP = struct { // Decode username var username_buffer: [4096]u8 = undefined; - std.mem.set(u8, &username_buffer, 0); + @memset(&username_buffer, 0); var username_stream = std.io.fixedBufferStream(&username_buffer); var username_writer = username_stream.writer(); const UserWriter = @TypeOf(username_writer); @@ -1503,7 +1504,7 @@ pub const AsyncHTTP = struct { } else { //Decode username var username_buffer: [4096]u8 = undefined; - std.mem.set(u8, &username_buffer, 0); + @memset(&username_buffer, 0); var username_stream = std.io.fixedBufferStream(&username_buffer); var username_writer = username_stream.writer(); const UserWriter = @TypeOf(username_writer); @@ -1872,7 +1873,7 @@ pub fn onWritable(this: *HTTPClient, comptime is_first_call: bool, comptime is_s var remain = list.items.ptr[list.items.len..list.capacity]; const wrote = @min(remain.len, this.state.request_body.len); std.debug.assert(wrote > 0); - @memcpy(remain.ptr, this.state.request_body.ptr, wrote); + @memcpy(remain[0..wrote], this.state.request_body[0..wrote]); list.items.len += wrote; } @@ -2021,7 +2022,7 @@ pub fn onWritable(this: *HTTPClient, comptime is_first_call: bool, comptime is_s var remain = list.items.ptr[list.items.len..list.capacity]; const wrote = @min(remain.len, this.state.request_body.len); std.debug.assert(wrote > 0); - @memcpy(remain.ptr, this.state.request_body.ptr, wrote); + @memcpy(remain[0..wrote], this.state.request_body[0..wrote]); list.items.len += wrote; } @@ -2582,8 +2583,8 @@ fn handleResponseBodyFromSinglePacket(this: *HTTPClient, incoming_data: []const if (this.state.encoding.isCompressed()) { var body_buffer = this.state.body_out_str.?; if (body_buffer.list.capacity == 0) { - const min = @min(@ceil(@intToFloat(f64, incoming_data.len) * 1.5), @as(f64, 1024 * 1024 * 2)); - try body_buffer.growBy(@max(@floatToInt(usize, min), 32)); + const min = @min(@ceil(@floatFromInt(f64, incoming_data.len) * 1.5), @as(f64, 1024 * 1024 * 2)); + try body_buffer.growBy(@max(@intFromFloat(usize, min), 32)); } try ZlibPool.decompress(incoming_data, body_buffer, default_allocator); @@ -2737,7 +2738,7 @@ fn handleResponseBodyChunkedEncodingFromSinglePacket( buffer = bun.constStrToU8(incoming_data); } else { buffer = single_packet_small_buffer[0..incoming_data.len]; - @memcpy(buffer.ptr, incoming_data.ptr, incoming_data.len); + @memcpy(buffer[0..incoming_data.len], incoming_data); } var bytes_decoded = incoming_data.len; @@ -2871,7 +2872,7 @@ pub fn handleResponseMetadata( return error.UnsupportedRedirectProtocol; } - if ((protocol_name.len * @as(usize, @boolToInt(is_protocol_relative))) + location.len > url_buf.data.len) { + if ((protocol_name.len * @as(usize, @intFromBool(is_protocol_relative))) + location.len > url_buf.data.len) { return error.RedirectURLTooLong; } diff --git a/src/import_record.zig b/src/import_record.zig index 16e3fcde6..d0df147db 100644 --- a/src/import_record.zig +++ b/src/import_record.zig @@ -207,7 +207,7 @@ pub const ImportRecord = struct { } pub inline fn isInternal(this: Tag) bool { - return @enumToInt(this) >= @enumToInt(Tag.runtime); + return @intFromEnum(this) >= @intFromEnum(Tag.runtime); } pub fn useDirective(this: Tag) bun.JSAst.UseDirective { diff --git a/src/install/bin.zig b/src/install/bin.zig index 371ce0dde..b0e988269 100644 --- a/src/install/bin.zig +++ b/src/install/bin.zig @@ -382,7 +382,7 @@ pub const Bin = extern struct { bun.copy(u8, remain, target); remain = remain[target.len..]; remain[0] = 0; - const target_len = @ptrToInt(remain.ptr) - @ptrToInt(&dest_buf); + const target_len = @intFromPtr(remain.ptr) - @intFromPtr(&dest_buf); remain = remain[1..]; var target_path: [:0]u8 = dest_buf[0..target_len :0]; @@ -392,7 +392,7 @@ pub const Bin = extern struct { bun.copy(u8, from_remain, unscoped_name); from_remain = from_remain[unscoped_name.len..]; from_remain[0] = 0; - var dest_path: [:0]u8 = target_buf[0 .. @ptrToInt(from_remain.ptr) - @ptrToInt(&target_buf) :0]; + var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0]; this.setSimlinkAndPermissions(target_path, dest_path); }, @@ -404,7 +404,7 @@ pub const Bin = extern struct { bun.copy(u8, remain, target); remain = remain[target.len..]; remain[0] = 0; - const target_len = @ptrToInt(remain.ptr) - @ptrToInt(&dest_buf); + const target_len = @intFromPtr(remain.ptr) - @intFromPtr(&dest_buf); remain = remain[1..]; var target_path: [:0]u8 = dest_buf[0..target_len :0]; @@ -412,7 +412,7 @@ pub const Bin = extern struct { bun.copy(u8, from_remain, name_to_use); from_remain = from_remain[name_to_use.len..]; from_remain[0] = 0; - var dest_path: [:0]u8 = target_buf[0 .. @ptrToInt(from_remain.ptr) - @ptrToInt(&target_buf) :0]; + var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0]; this.setSimlinkAndPermissions(target_path, dest_path); }, @@ -434,7 +434,7 @@ pub const Bin = extern struct { bun.copy(u8, remain, target); remain = remain[target.len..]; remain[0] = 0; - const target_len = @ptrToInt(remain.ptr) - @ptrToInt(&dest_buf); + const target_len = @intFromPtr(remain.ptr) - @intFromPtr(&dest_buf); remain = remain[1..]; var target_path: [:0]u8 = dest_buf[0..target_len :0]; @@ -442,7 +442,7 @@ pub const Bin = extern struct { bun.copy(u8, from_remain, name_to_use); from_remain = from_remain[name_to_use.len..]; from_remain[0] = 0; - var dest_path: [:0]u8 = target_buf[0 .. @ptrToInt(from_remain.ptr) - @ptrToInt(&target_buf) :0]; + var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0]; this.setSimlinkAndPermissions(target_path, dest_path); } @@ -461,7 +461,7 @@ pub const Bin = extern struct { var dir = std.fs.Dir{ .fd = this.package_installed_node_modules }; var joined = Path.joinStringBuf(&target_buf, &parts, .auto); - @intToPtr([*]u8, @ptrToInt(joined.ptr))[joined.len] = 0; + @ptrFromInt([*]u8, @intFromPtr(joined.ptr))[joined.len] = 0; var joined_: [:0]const u8 = joined.ptr[0..joined.len :0]; var child_dir = bun.openDir(dir, joined_) catch |err| { this.err = err; @@ -482,12 +482,12 @@ pub const Bin = extern struct { while (iter.next() catch null) |entry_| { const entry: std.fs.IterableDir.Entry = entry_; switch (entry.kind) { - std.fs.IterableDir.Entry.Kind.SymLink, std.fs.IterableDir.Entry.Kind.File => { + std.fs.IterableDir.Entry.Kind.sym_link, std.fs.IterableDir.Entry.Kind.file => { target_buf_remain = prev_target_buf_remain; bun.copy(u8, target_buf_remain, entry.name); target_buf_remain = target_buf_remain[entry.name.len..]; target_buf_remain[0] = 0; - var from_path: [:0]u8 = target_buf[0 .. @ptrToInt(target_buf_remain.ptr) - @ptrToInt(&target_buf) :0]; + var from_path: [:0]u8 = target_buf[0 .. @intFromPtr(target_buf_remain.ptr) - @intFromPtr(&target_buf) :0]; var to_path = if (!link_global) std.fmt.bufPrintZ(&dest_buf, dot_bin ++ "{s}", .{entry.name}) catch continue else @@ -519,7 +519,7 @@ pub const Bin = extern struct { return; } - @memcpy(&target_buf, this.global_bin_path.ptr, this.global_bin_path.len); + @memcpy(target_buf[0..this.global_bin_path.len], this.global_bin_path); from_remain = target_buf[this.global_bin_path.len..]; from_remain[0] = std.fs.path.sep; from_remain = from_remain[1..]; @@ -557,7 +557,7 @@ pub const Bin = extern struct { bun.copy(u8, from_remain, unscoped_name); from_remain = from_remain[unscoped_name.len..]; from_remain[0] = 0; - var dest_path: [:0]u8 = target_buf[0 .. @ptrToInt(from_remain.ptr) - @ptrToInt(&target_buf) :0]; + var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0]; std.os.unlinkatZ(this.root_node_modules_folder, dest_path, 0) catch {}; }, @@ -566,7 +566,7 @@ pub const Bin = extern struct { bun.copy(u8, from_remain, name_to_use); from_remain = from_remain[name_to_use.len..]; from_remain[0] = 0; - var dest_path: [:0]u8 = target_buf[0 .. @ptrToInt(from_remain.ptr) - @ptrToInt(&target_buf) :0]; + var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0]; std.os.unlinkatZ(this.root_node_modules_folder, dest_path, 0) catch {}; }, @@ -594,7 +594,7 @@ pub const Bin = extern struct { bun.copy(u8, from_remain, name_to_use); from_remain = from_remain[name_to_use.len..]; from_remain[0] = 0; - var dest_path: [:0]u8 = target_buf[0 .. @ptrToInt(from_remain.ptr) - @ptrToInt(&target_buf) :0]; + var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0]; std.os.unlinkatZ(this.root_node_modules_folder, dest_path, 0) catch {}; } @@ -613,7 +613,7 @@ pub const Bin = extern struct { var dir = std.fs.Dir{ .fd = this.package_installed_node_modules }; var joined = Path.joinStringBuf(&target_buf, &parts, .auto); - @intToPtr([*]u8, @ptrToInt(joined.ptr))[joined.len] = 0; + @ptrFromInt([*]u8, @intFromPtr(joined.ptr))[joined.len] = 0; var joined_: [:0]const u8 = joined.ptr[0..joined.len :0]; var child_dir = bun.openDir(dir, joined_) catch |err| { this.err = err; @@ -634,7 +634,7 @@ pub const Bin = extern struct { while (iter.next() catch null) |entry_| { const entry: std.fs.IterableDir.Entry = entry_; switch (entry.kind) { - std.fs.IterableDir.Entry.Kind.SymLink, std.fs.IterableDir.Entry.Kind.File => { + std.fs.IterableDir.Entry.Kind.sym_link, std.fs.IterableDir.Entry.Kind.file => { target_buf_remain = prev_target_buf_remain; bun.copy(u8, target_buf_remain, entry.name); target_buf_remain = target_buf_remain[entry.name.len..]; diff --git a/src/install/dependency.zig b/src/install/dependency.zig index 0480dd9d8..6ef02bbfc 100644 --- a/src/install/dependency.zig +++ b/src/install/dependency.zig @@ -147,7 +147,7 @@ pub fn toDependency( return Dependency{ .name = name, .name_hash = @bitCast(u64, this[8..16].*), - .behavior = @intToEnum(Dependency.Behavior, this[16]), + .behavior = @enumFromInt(Dependency.Behavior, this[16]), .version = Dependency.Version.toVersion(name, this[17..this.len].*, ctx), }; } @@ -156,7 +156,7 @@ pub fn toExternal(this: Dependency) External { var bytes: External = undefined; bytes[0..this.name.bytes.len].* = this.name.bytes; bytes[8..16].* = @bitCast([8]u8, this.name_hash); - bytes[16] = @enumToInt(this.behavior); + bytes[16] = @intFromEnum(this.behavior); bytes[17..bytes.len].* = this.version.toExternal(); return bytes; } @@ -265,7 +265,7 @@ pub const Version = struct { ctx: Dependency.Context, ) Dependency.Version { const slice = String{ .bytes = bytes[1..9].* }; - const tag = @intToEnum(Dependency.Version.Tag, bytes[0]); + const tag = @enumFromInt(Dependency.Version.Tag, bytes[0]); const sliced = &slice.sliced(ctx.buffer); return Dependency.parseWithTag( ctx.allocator, @@ -279,7 +279,7 @@ pub const Version = struct { pub inline fn toExternal(this: Version) Version.External { var bytes: Version.External = undefined; - bytes[0] = @enumToInt(this.tag); + bytes[0] = @intFromEnum(this.tag); bytes[1..9].* = this.literal.bytes; return bytes; } @@ -339,7 +339,7 @@ pub const Version = struct { github = 8, pub inline fn isNPM(this: Tag) bool { - return @enumToInt(this) < 3; + return @intFromEnum(this) < 3; } pub fn infer(dependency: string) Tag { @@ -493,7 +493,7 @@ pub const Version = struct { // npm:package@1.2.3 'n' => { if (strings.hasPrefixComptime(dependency, "npm:") and dependency.len > "npm:".len) { - const remain = dependency["npm:".len + @boolToInt(dependency["npm:".len] == '@') ..]; + const remain = dependency["npm:".len + @intFromBool(dependency["npm:".len] == '@') ..]; for (remain, 0..) |c, i| { if (c == '@') { return infer(remain[i + 1 ..]); @@ -645,7 +645,7 @@ pub fn parseWithTag( var input = dependency; const name = if (strings.hasPrefixComptime(input, "npm:")) sliced.sub(brk: { var str = input["npm:".len..]; - var i: usize = @boolToInt(str.len > 0 and str[0] == '@'); + var i: usize = @intFromBool(str.len > 0 and str[0] == '@'); while (i < str.len) : (i += 1) { if (str[i] == '@') { @@ -694,7 +694,7 @@ pub fn parseWithTag( // npm:@foo/bar@latest // ^ - i += @boolToInt(dependency[i] == '@'); + i += @intFromBool(dependency[i] == '@'); while (i < dependency.len) : (i += 1) { // npm:@foo/bar@latest @@ -899,67 +899,67 @@ pub const Behavior = enum(u8) { pub const workspace: u8 = 1 << 5; pub inline fn isNormal(this: Behavior) bool { - return (@enumToInt(this) & Behavior.normal) != 0; + return (@intFromEnum(this) & Behavior.normal) != 0; } pub inline fn isOptional(this: Behavior) bool { - return (@enumToInt(this) & Behavior.optional) != 0 and !this.isPeer(); + return (@intFromEnum(this) & Behavior.optional) != 0 and !this.isPeer(); } pub inline fn isDev(this: Behavior) bool { - return (@enumToInt(this) & Behavior.dev) != 0; + return (@intFromEnum(this) & Behavior.dev) != 0; } pub inline fn isPeer(this: Behavior) bool { - return (@enumToInt(this) & Behavior.peer) != 0; + return (@intFromEnum(this) & Behavior.peer) != 0; } pub inline fn isWorkspace(this: Behavior) bool { - return (@enumToInt(this) & Behavior.workspace) != 0; + return (@intFromEnum(this) & Behavior.workspace) != 0; } pub inline fn setNormal(this: Behavior, value: bool) Behavior { if (value) { - return @intToEnum(Behavior, @enumToInt(this) | Behavior.normal); + return @enumFromInt(Behavior, @intFromEnum(this) | Behavior.normal); } else { - return @intToEnum(Behavior, @enumToInt(this) & ~Behavior.normal); + return @enumFromInt(Behavior, @intFromEnum(this) & ~Behavior.normal); } } pub inline fn setOptional(this: Behavior, value: bool) Behavior { if (value) { - return @intToEnum(Behavior, @enumToInt(this) | Behavior.optional); + return @enumFromInt(Behavior, @intFromEnum(this) | Behavior.optional); } else { - return @intToEnum(Behavior, @enumToInt(this) & ~Behavior.optional); + return @enumFromInt(Behavior, @intFromEnum(this) & ~Behavior.optional); } } pub inline fn setDev(this: Behavior, value: bool) Behavior { if (value) { - return @intToEnum(Behavior, @enumToInt(this) | Behavior.dev); + return @enumFromInt(Behavior, @intFromEnum(this) | Behavior.dev); } else { - return @intToEnum(Behavior, @enumToInt(this) & ~Behavior.dev); + return @enumFromInt(Behavior, @intFromEnum(this) & ~Behavior.dev); } } pub inline fn setPeer(this: Behavior, value: bool) Behavior { if (value) { - return @intToEnum(Behavior, @enumToInt(this) | Behavior.peer); + return @enumFromInt(Behavior, @intFromEnum(this) | Behavior.peer); } else { - return @intToEnum(Behavior, @enumToInt(this) & ~Behavior.peer); + return @enumFromInt(Behavior, @intFromEnum(this) & ~Behavior.peer); } } pub inline fn setWorkspace(this: Behavior, value: bool) Behavior { if (value) { - return @intToEnum(Behavior, @enumToInt(this) | Behavior.workspace); + return @enumFromInt(Behavior, @intFromEnum(this) | Behavior.workspace); } else { - return @intToEnum(Behavior, @enumToInt(this) & ~Behavior.workspace); + return @enumFromInt(Behavior, @intFromEnum(this) & ~Behavior.workspace); } } pub inline fn cmp(lhs: Behavior, rhs: Behavior) std.math.Order { - if (@enumToInt(lhs) == @enumToInt(rhs)) { + if (@intFromEnum(lhs) == @intFromEnum(rhs)) { return .eq; } diff --git a/src/install/install.zig b/src/install/install.zig index 88c8f653f..32c24548c 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -146,12 +146,12 @@ pub fn ExternalSliceAligned(comptime Type: type, comptime alignment_: ?u29) type pub fn init(buf: []const Type, in: []const Type) Slice { // if (comptime Environment.allow_assert) { - // std.debug.assert(@ptrToInt(buf.ptr) <= @ptrToInt(in.ptr)); - // std.debug.assert((@ptrToInt(in.ptr) + in.len) <= (@ptrToInt(buf.ptr) + buf.len)); + // std.debug.assert(@intFromPtr(buf.ptr) <= @intFromPtr(in.ptr)); + // std.debug.assert((@intFromPtr(in.ptr) + in.len) <= (@intFromPtr(buf.ptr) + buf.len)); // } return Slice{ - .off = @truncate(u32, (@ptrToInt(in.ptr) - @ptrToInt(buf.ptr)) / @sizeOf(Type)), + .off = @truncate(u32, (@intFromPtr(in.ptr) - @intFromPtr(buf.ptr)) / @sizeOf(Type)), .len = @truncate(u32, in.len), }; } @@ -183,7 +183,7 @@ pub const Aligner = struct { } pub inline fn skipAmount(comptime Type: type, pos: usize) usize { - return std.mem.alignForward(pos, @alignOf(Type)) - pos; + return std.mem.alignForward(usize, pos, @alignOf(Type)) - pos; } }; @@ -351,7 +351,7 @@ const NetworkTask = struct { }, ); header_builder.header_count = 1; - header_builder.content = GlobalStringBuilder{ .ptr = @intToPtr([*]u8, @ptrToInt(bun.span(default_headers_buf).ptr)), .len = default_headers_buf.len, .cap = default_headers_buf.len }; + header_builder.content = GlobalStringBuilder{ .ptr = @ptrFromInt([*]u8, @intFromPtr(bun.span(default_headers_buf).ptr)), .len = default_headers_buf.len, .cap = default_headers_buf.len }; } this.response_buffer = try MutableString.init(allocator, 0); @@ -474,12 +474,12 @@ pub const Features = struct { pub fn behavior(this: Features) Behavior { var out: u8 = 0; - out |= @as(u8, @boolToInt(this.dependencies)) << 1; - out |= @as(u8, @boolToInt(this.optional_dependencies)) << 2; - out |= @as(u8, @boolToInt(this.dev_dependencies)) << 3; - out |= @as(u8, @boolToInt(this.peer_dependencies)) << 4; - out |= @as(u8, @boolToInt(this.workspaces)) << 5; - return @intToEnum(Behavior, out); + out |= @as(u8, @intFromBool(this.dependencies)) << 1; + out |= @as(u8, @intFromBool(this.optional_dependencies)) << 2; + out |= @as(u8, @intFromBool(this.dev_dependencies)) << 3; + out |= @as(u8, @intFromBool(this.peer_dependencies)) << 4; + out |= @as(u8, @intFromBool(this.workspaces)) << 5; + return @enumFromInt(Behavior, out); } pub const main = Features{ @@ -541,7 +541,7 @@ const Task = struct { /// An ID that lets us register a callback without keeping the same pointer around pub const Id = struct { pub fn forNPMPackage(package_name: string, package_version: Semver.Version) u64 { - var hasher = std.hash.Wyhash.init(0); + var hasher = bun.Wyhash.init(0); hasher.update(package_name); hasher.update("@"); hasher.update(std.mem.asBytes(&package_version)); @@ -549,28 +549,28 @@ const Task = struct { } pub fn forBinLink(package_id: PackageID) u64 { - const hash = std.hash.Wyhash.hash(0, std.mem.asBytes(&package_id)); + const hash = bun.Wyhash.hash(0, std.mem.asBytes(&package_id)); return @as(u64, 1 << 61) | @as(u64, @truncate(u61, hash)); } pub fn forManifest(name: string) u64 { - return @as(u64, 2 << 61) | @as(u64, @truncate(u61, std.hash.Wyhash.hash(0, name))); + return @as(u64, 2 << 61) | @as(u64, @truncate(u61, bun.Wyhash.hash(0, name))); } pub fn forTarball(url: string) u64 { - var hasher = std.hash.Wyhash.init(0); + var hasher = bun.Wyhash.init(0); hasher.update(url); return @as(u64, 3 << 61) | @as(u64, @truncate(u61, hasher.final())); } pub fn forGitClone(url: string) u64 { - var hasher = std.hash.Wyhash.init(0); + var hasher = bun.Wyhash.init(0); hasher.update(url); return @as(u64, 4 << 61) | @as(u64, @truncate(u61, hasher.final())); } pub fn forGitCheckout(url: string, resolved: string) u64 { - var hasher = std.hash.Wyhash.init(0); + var hasher = bun.Wyhash.init(0); hasher.update(url); hasher.update("@"); hasher.update(resolved); @@ -1079,10 +1079,10 @@ const PackageInstall = struct { var stackpath: [bun.MAX_PATH_BYTES]u8 = undefined; while (try walker.next()) |entry| { switch (entry.kind) { - .Directory => { + .directory => { std.os.mkdirat(destination_dir_.dir.fd, entry.path, 0o755) catch {}; }, - .File => { + .file => { bun.copy(u8, &stackpath, entry.path); stackpath[entry.path.len] = 0; var path: [:0]u8 = stackpath[0..entry.path.len :0]; @@ -1190,7 +1190,7 @@ const PackageInstall = struct { ) !u32 { var real_file_count: u32 = 0; while (try walker.next()) |entry| { - if (entry.kind != .File) continue; + if (entry.kind != .file) continue; real_file_count += 1; var outfile = destination_dir_.createFile(entry.path, .{}) catch brk: { @@ -1268,10 +1268,10 @@ const PackageInstall = struct { var real_file_count: u32 = 0; while (try walker.next()) |entry| { switch (entry.kind) { - .Directory => { + .directory => { std.os.mkdirat(destination_dir_.dir.fd, entry.path, 0o755) catch {}; }, - .File => { + .file => { try std.os.linkat(entry.dir.dir.fd, entry.basename, destination_dir_.dir.fd, entry.path, 0); real_file_count += 1; }, @@ -1351,16 +1351,16 @@ const PackageInstall = struct { while (try walker.next()) |entry| { switch (entry.kind) { // directories are created - .Directory => { + .directory => { std.os.mkdirat(dest_dir_fd, entry.path, 0o755) catch {}; }, // but each file in the directory is a symlink - .File => { - @memcpy(remain.ptr, entry.path.ptr, entry.path.len); + .file => { + @memcpy(remain[0..entry.path.len], entry.path); remain[entry.path.len] = 0; var from_path = buf[0 .. cache_dir_offset + entry.path.len :0]; - @memcpy(dest_remaining.ptr, entry.path.ptr, entry.path.len); + @memcpy(dest_remaining[0..entry.path.len], entry.path); dest_remaining[entry.path.len] = 0; var to_path = dest_buf[0 .. dest_dir_offset + entry.path.len :0]; @@ -1830,7 +1830,7 @@ pub const PackageManager = struct { const offset = this.preinstall_state.items.len; try this.preinstall_state.ensureTotalCapacity(this.allocator, count); this.preinstall_state.expandToCapacity(); - std.mem.set(PreinstallState, this.preinstall_state.items[offset..], PreinstallState.unknown); + @memset(this.preinstall_state.items[offset..], PreinstallState.unknown); } pub fn setPreinstallState(this: *PackageManager, package_id: PackageID, lockfile: *Lockfile, value: PreinstallState) void { @@ -2263,7 +2263,7 @@ pub const PackageManager = struct { var iter = dir.iterate(); while (try iter.next()) |entry| { - if (entry.kind != .Directory and entry.kind != .SymLink) continue; + if (entry.kind != .directory and entry.kind != .sym_link) continue; const name = entry.name; const sliced = SlicedString.init(name, name); const parsed = Semver.Version.parse(sliced, allocator); @@ -2305,7 +2305,7 @@ pub const PackageManager = struct { }; // TODO: make this fewer passes - std.sort.sort( + std.sort.block( Semver.Version, installed_versions.items, @as([]const u8, tags_buf.items), @@ -3752,7 +3752,7 @@ pub const PackageManager = struct { if (comptime log_level.isVerbose()) { Output.prettyError(" ", .{}); - Output.printElapsed(@intToFloat(f64, task.http.elapsed) / std.time.ns_per_ms); + Output.printElapsed(@floatFromInt(f64, task.http.elapsed) / std.time.ns_per_ms); Output.prettyError("\n Downloaded {s} versions\n", .{name.slice()}); Output.flush(); } @@ -3886,7 +3886,7 @@ pub const PackageManager = struct { if (comptime log_level.isVerbose()) { Output.prettyError(" ", .{}); - Output.printElapsed(@floatCast(f64, @intToFloat(f64, task.http.elapsed) / std.time.ns_per_ms)); + Output.printElapsed(@floatCast(f64, @floatFromInt(f64, task.http.elapsed) / std.time.ns_per_ms)); Output.prettyError(" Downloaded {s} tarball\n", .{extract.name.slice()}); Output.flush(); } @@ -4814,7 +4814,7 @@ pub const PackageManager = struct { var new_dependencies = try allocator.alloc(G.Property, dependencies.len + remaining - replacing); bun.copy(G.Property, new_dependencies, dependencies); - std.mem.set(G.Property, new_dependencies[dependencies.len..], G.Property{}); + @memset(new_dependencies[dependencies.len..], G.Property{}); outer: for (updates) |*update| { if (update.e_string != null) continue; @@ -6372,7 +6372,7 @@ pub const PackageManager = struct { var iter: std.fs.IterableDir.Iterator = node_modules_bin.iterate(); iterator: while (iter.next() catch null) |entry| { switch (entry.kind) { - std.fs.IterableDir.Entry.Kind.SymLink => { + std.fs.IterableDir.Entry.Kind.sym_link => { // any symlinks which we are unable to open are assumed to be dangling // note that using access won't work here, because access doesn't resolve symlinks @@ -6547,7 +6547,7 @@ pub const PackageManager = struct { if (folder.len == 0 or (folder.len == 1 and folder[0] == '.')) { installer.cache_dir_subpath = "."; } else { - @memcpy(&this.folder_path_buf, folder.ptr, folder.len); + @memcpy(this.folder_path_buf[0..folder.len], folder); this.folder_path_buf[folder.len] = 0; installer.cache_dir_subpath = this.folder_path_buf[0..folder.len :0]; } @@ -6567,7 +6567,7 @@ pub const PackageManager = struct { if (folder.len == 0 or (folder.len == 1 and folder[0] == '.')) { installer.cache_dir_subpath = "."; } else { - @memcpy(&this.folder_path_buf, folder.ptr, folder.len); + @memcpy(this.folder_path_buf[0..folder.len], folder); this.folder_path_buf[folder.len] = 0; installer.cache_dir_subpath = this.folder_path_buf[0..folder.len :0]; } @@ -6608,16 +6608,16 @@ pub const PackageManager = struct { const global_link_dir = this.manager.globalLinkDirPath() catch unreachable; var ptr = &this.folder_path_buf; var remain: []u8 = this.folder_path_buf[0..]; - @memcpy(ptr, global_link_dir.ptr, global_link_dir.len); + @memcpy(ptr[0..global_link_dir.len], global_link_dir); remain = remain[global_link_dir.len..]; if (global_link_dir[global_link_dir.len - 1] != std.fs.path.sep) { remain[0] = std.fs.path.sep; remain = remain[1..]; } - @memcpy(remain.ptr, folder.ptr, folder.len); + @memcpy(remain[0..folder.len], folder); remain = remain[folder.len..]; remain[0] = 0; - const len = @ptrToInt(remain.ptr) - @ptrToInt(ptr); + const len = @intFromPtr(remain.ptr) - @intFromPtr(ptr); installer.cache_dir_subpath = this.folder_path_buf[0..len :0]; installer.cache_dir = directory; } @@ -6626,7 +6626,7 @@ pub const PackageManager = struct { } const needs_install = this.force_install or this.skip_verify_installed_version_number or !installer.verify(resolution, buf); - this.summary.skipped += @as(u32, @boolToInt(!needs_install)); + this.summary.skipped += @as(u32, @intFromBool(!needs_install)); if (needs_install) { const result: PackageInstall.Result = switch (resolution.tag) { @@ -6637,7 +6637,7 @@ pub const PackageManager = struct { switch (result) { .success => { const is_duplicate = this.successfully_installed.isSet(package_id); - this.summary.success += @as(u32, @boolToInt(!is_duplicate)); + this.summary.success += @as(u32, @intFromBool(!is_duplicate)); this.successfully_installed.set(package_id); if (comptime log_level.showProgress()) { @@ -7390,7 +7390,7 @@ pub const PackageManager = struct { ); } var mapping = try manager.lockfile.allocator.alloc(PackageID, maybe_root.dependencies.len); - std.mem.set(PackageID, mapping, invalid_package_id); + @memset(mapping, invalid_package_id); manager.summary = try Package.Diff.generate( ctx.allocator, @@ -7443,8 +7443,8 @@ pub const PackageManager = struct { var resolutions = manager.lockfile.buffers.resolutions.items.ptr[off .. off + len]; // It is too easy to accidentally undefined memory - std.mem.set(PackageID, resolutions, invalid_package_id); - std.mem.set(Dependency, dependencies, Dependency{}); + @memset(resolutions, invalid_package_id); + @memset(dependencies, Dependency{}); manager.lockfile.buffers.dependencies.items = manager.lockfile.buffers.dependencies.items.ptr[0 .. off + len]; manager.lockfile.buffers.resolutions.items = manager.lockfile.buffers.resolutions.items.ptr[0 .. off + len]; diff --git a/src/install/integrity.zig b/src/install/integrity.zig index e54d9b7e1..19e55c223 100644 --- a/src/install/integrity.zig +++ b/src/install/integrity.zig @@ -41,7 +41,7 @@ pub const Integrity = extern struct { var i: usize = 0; { - std.mem.set(u8, &integrity.value, 0); + @memset(&integrity.value, 0); } while (i < end) { @@ -111,7 +111,7 @@ pub const Integrity = extern struct { _, pub inline fn isSupported(this: Tag) bool { - return @enumToInt(this) >= @enumToInt(Tag.sha1) and @enumToInt(this) <= @enumToInt(Tag.sha512); + return @intFromEnum(this) >= @intFromEnum(Tag.sha1) and @intFromEnum(this) <= @intFromEnum(Tag.sha512); } pub fn parse(buf: []const u8) Tag { diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index 5c27c1a69..04c6ccec1 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -693,8 +693,7 @@ pub fn cleanWithLogger(old: *Lockfile, updates: []PackageManager.UpdateRequest, const root = old.rootPackage() orelse return error.NoPackage; var package_id_mapping = try old.allocator.alloc(PackageID, old.packages.len); - std.mem.set( - PackageID, + @memset( package_id_mapping, invalid_package_id, ); @@ -998,7 +997,7 @@ pub const Printer = struct { const dependencies_buffer: []const Dependency = this.lockfile.buffers.dependencies.items; const string_buf = this.lockfile.buffers.string_bytes.items; var id_map = try default_allocator.alloc(DependencyID, this.updates.len); - std.mem.set(DependencyID, id_map, invalid_package_id); + @memset(id_map, invalid_package_id); defer if (id_map.len > 0) default_allocator.free(id_map); visited.set(0); @@ -1211,12 +1210,12 @@ pub const Printer = struct { } var dependency_versions = requested_version_start[0..j]; - if (dependency_versions.len > 1) std.sort.insertionSort(Dependency.Version, dependency_versions, string_buf, Dependency.Version.isLessThan); + if (dependency_versions.len > 1) std.sort.insertion(Dependency.Version, dependency_versions, string_buf, Dependency.Version.isLessThan); try requested_versions.put(i, dependency_versions); } } - std.sort.sort( + std.sort.block( PackageID, alphabetized_names, Lockfile.Package.Alphabetizer{ @@ -1908,11 +1907,11 @@ pub const Package = extern struct { field: string, behavior: Behavior, - pub const dependencies = DependencyGroup{ .prop = "dependencies", .field = "dependencies", .behavior = @intToEnum(Behavior, Behavior.normal) }; - pub const dev = DependencyGroup{ .prop = "devDependencies", .field = "dev_dependencies", .behavior = @intToEnum(Behavior, Behavior.dev) }; - pub const optional = DependencyGroup{ .prop = "optionalDependencies", .field = "optional_dependencies", .behavior = @intToEnum(Behavior, Behavior.optional) }; - pub const peer = DependencyGroup{ .prop = "peerDependencies", .field = "peer_dependencies", .behavior = @intToEnum(Behavior, Behavior.peer) }; - pub const workspaces = DependencyGroup{ .prop = "workspaces", .field = "workspaces", .behavior = @intToEnum(Behavior, Behavior.workspace) }; + pub const dependencies = DependencyGroup{ .prop = "dependencies", .field = "dependencies", .behavior = @enumFromInt(Behavior, Behavior.normal) }; + pub const dev = DependencyGroup{ .prop = "devDependencies", .field = "dev_dependencies", .behavior = @enumFromInt(Behavior, Behavior.dev) }; + pub const optional = DependencyGroup{ .prop = "optionalDependencies", .field = "optional_dependencies", .behavior = @enumFromInt(Behavior, Behavior.optional) }; + pub const peer = DependencyGroup{ .prop = "peerDependencies", .field = "peer_dependencies", .behavior = @enumFromInt(Behavior, Behavior.peer) }; + pub const workspaces = DependencyGroup{ .prop = "workspaces", .field = "workspaces", .behavior = @enumFromInt(Behavior, Behavior.workspace) }; }; pub inline fn isDisabled(this: *const Lockfile.Package) bool { @@ -2032,7 +2031,7 @@ pub const Package = extern struct { builder.clamp(); - cloner.trees_count += @as(u32, @boolToInt(old_resolutions.len > 0)); + cloner.trees_count += @as(u32, @intFromBool(old_resolutions.len > 0)); for (old_resolutions, 0..) |old_resolution, i| { if (old_resolution >= max_package_id) continue; @@ -2108,7 +2107,7 @@ pub const Package = extern struct { if (comptime Environment.allow_assert) std.debug.assert(dependencies_list.items.len == resolutions_list.items.len); var dependencies: []Dependency = dependencies_list.items.ptr[dependencies_list.items.len..total_len]; - std.mem.set(Dependency, dependencies, Dependency{}); + @memset(dependencies, Dependency{}); const package_dependencies = package_json.dependencies.map.values(); const source_buf = package_json.dependencies.source_buf; @@ -2135,7 +2134,7 @@ pub const Package = extern struct { const new_length = package.dependencies.len + dependencies_list.items.len; - std.mem.set(PackageID, resolutions_list.items.ptr[package.dependencies.off .. package.dependencies.off + package.dependencies.len], invalid_package_id); + @memset(resolutions_list.items.ptr[package.dependencies.off .. package.dependencies.off + package.dependencies.len], invalid_package_id); dependencies_list.items = dependencies_list.items.ptr[0..new_length]; resolutions_list.items = resolutions_list.items.ptr[0..new_length]; @@ -2160,10 +2159,10 @@ pub const Package = extern struct { const dependency_groups = comptime brk: { var out_groups: [ - @as(usize, @boolToInt(features.dependencies)) + - @as(usize, @boolToInt(features.dev_dependencies)) + - @as(usize, @boolToInt(features.optional_dependencies)) + - @as(usize, @boolToInt(features.peer_dependencies)) + @as(usize, @intFromBool(features.dependencies)) + + @as(usize, @intFromBool(features.dev_dependencies)) + + @as(usize, @intFromBool(features.optional_dependencies)) + + @as(usize, @intFromBool(features.peer_dependencies)) ]DependencyGroup = undefined; var out_group_i: usize = 0; @@ -2252,7 +2251,7 @@ pub const Package = extern struct { if (comptime Environment.allow_assert) std.debug.assert(dependencies_list.items.len == resolutions_list.items.len); var dependencies = dependencies_list.items.ptr[dependencies_list.items.len..total_len]; - std.mem.set(Dependency, dependencies, .{}); + @memset(dependencies, .{}); total_dependencies_count = 0; inline for (dependency_groups) |group| { @@ -2323,7 +2322,7 @@ pub const Package = extern struct { const new_length = package.dependencies.len + dependencies_list.items.len; - std.mem.set(PackageID, resolutions_list.items.ptr[package.dependencies.off .. package.dependencies.off + package.dependencies.len], invalid_package_id); + @memset(resolutions_list.items.ptr[package.dependencies.off .. package.dependencies.off + package.dependencies.len], invalid_package_id); dependencies_list.items = dependencies_list.items.ptr[0..new_length]; resolutions_list.items = resolutions_list.items.ptr[0..new_length]; @@ -2408,7 +2407,7 @@ pub const Package = extern struct { }; pub fn hash(name: string, version: Semver.Version) u64 { - var hasher = std.hash.Wyhash.init(0); + var hasher = bun.Wyhash.init(0); hasher.update(name); hasher.update(std.mem.asBytes(&version)); return hasher.final(); @@ -2966,11 +2965,11 @@ pub const Package = extern struct { const dependency_groups = comptime brk: { var out_groups: [ - @as(usize, @boolToInt(features.dependencies)) + - @as(usize, @boolToInt(features.dev_dependencies)) + - @as(usize, @boolToInt(features.optional_dependencies)) + - @as(usize, @boolToInt(features.peer_dependencies)) + - @as(usize, @boolToInt(features.workspaces)) + @as(usize, @intFromBool(features.dependencies)) + + @as(usize, @intFromBool(features.dev_dependencies)) + + @as(usize, @intFromBool(features.optional_dependencies)) + + @as(usize, @intFromBool(features.peer_dependencies)) + + @as(usize, @intFromBool(features.workspaces)) ]DependencyGroup = undefined; var out_group_i: usize = 0; @@ -3320,7 +3319,7 @@ pub const Package = extern struct { } } - std.sort.sort( + std.sort.block( Dependency, package_dependencies[0..total_dependencies_count], lockfile.buffers.string_bytes.items, @@ -3332,7 +3331,7 @@ pub const Package = extern struct { package.resolutions = @bitCast(@TypeOf(package.resolutions), package.dependencies); - std.mem.set(PackageID, lockfile.buffers.resolutions.items.ptr[off..total_len], invalid_package_id); + @memset(lockfile.buffers.resolutions.items.ptr[off..total_len], invalid_package_id); const new_len = off + total_dependencies_count; lockfile.buffers.dependencies.items = lockfile.buffers.dependencies.items.ptr[0..new_len]; @@ -3397,7 +3396,7 @@ pub const Package = extern struct { } }; var trash: i32 = undefined; // workaround for stage1 compiler bug - std.sort.sort(Data, &data, &trash, Sort.lessThan); + std.sort.block(Data, &data, &trash, Sort.lessThan); var sizes_bytes: [fields.len]usize = undefined; var field_indexes: [fields.len]usize = undefined; var Types: [fields.len]type = undefined; @@ -3492,10 +3491,10 @@ pub const Package = extern struct { var bytes = std.mem.sliceAsBytes(sliced.items(@field(Lockfile.Package.List.Field, field.name))); const end_pos = stream.pos + bytes.len; if (end_pos <= end_at) { - @memcpy(bytes.ptr, stream.buffer[stream.pos..].ptr, bytes.len); + @memcpy(bytes, stream.buffer[stream.pos..][0..bytes.len]); stream.pos = end_pos; } else if (comptime strings.eqlComptime(field.name, "scripts")) { - @memset(bytes.ptr, 0, bytes.len); + @memset(bytes, 0); } else { return error.@"Lockfile validation failed: invalid package list range"; } @@ -3564,7 +3563,7 @@ const Buffers = struct { } }; var trash: i32 = undefined; // workaround for stage1 compiler bug - std.sort.sort(Data, &data, &trash, Sort.lessThan); + std.sort.block(Data, &data, &trash, Sort.lessThan); var sizes_bytes: [fields.len]usize = undefined; var names: [fields.len][]const u8 = undefined; var types: [fields.len]type = undefined; @@ -3808,7 +3807,7 @@ pub const Serializer = struct { var writer = stream.writer(); try writer.writeAll(header_bytes); - try writer.writeIntLittle(u32, @enumToInt(this.format)); + try writer.writeIntLittle(u32, @intFromEnum(this.format)); try writer.writeAll(&this.meta_hash); @@ -3840,7 +3839,7 @@ pub const Serializer = struct { } var format = try reader.readIntLittle(u32); - if (format != @enumToInt(Lockfile.FormatVersion.current)) { + if (format != @intFromEnum(Lockfile.FormatVersion.current)) { return error.@"Outdated lockfile version"; } @@ -3928,7 +3927,7 @@ fn generateMetaHash(this: *Lockfile, print_name_version_string: bool) !MetaHash } } - std.sort.sort( + std.sort.block( PackageID, alphabetized_names, Lockfile.Package.Alphabetizer{ diff --git a/src/install/npm.zig b/src/install/npm.zig index c01e6ee1f..074041056 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -121,9 +121,9 @@ pub const Registry = struct { if (registry.username.len > 0 and registry.password.len > 0 and auth.len == 0) { var output_buf = try allocator.alloc(u8, registry.username.len + registry.password.len + 1 + std.base64.standard.Encoder.calcSize(registry.username.len + registry.password.len + 1)); var input_buf = output_buf[0 .. registry.username.len + registry.password.len + 1]; - @memcpy(input_buf.ptr, registry.username.ptr, registry.username.len); + @memcpy(input_buf[0..registry.username.len], registry.username); input_buf[registry.username.len] = ':'; - @memcpy(input_buf[registry.username.len + 1 ..].ptr, registry.password.ptr, registry.password.len); + @memcpy(input_buf[registry.username.len + 1 ..][0..registry.password.len], registry.password); output_buf = output_buf[input_buf.len..]; auth = std.base64.standard.Encoder.encode(output_buf, input_buf); break :outer; @@ -259,9 +259,9 @@ pub const OperatingSystem = enum(u16) { pub fn isMatch(this: OperatingSystem) bool { if (comptime Environment.isLinux) { - return (@enumToInt(this) & linux) != 0; + return (@intFromEnum(this) & linux) != 0; } else if (comptime Environment.isMac) { - return (@enumToInt(this) & darwin) != 0; + return (@intFromEnum(this) & darwin) != 0; } else { return false; } @@ -282,7 +282,7 @@ pub const OperatingSystem = enum(u16) { if (str.len == 0) { return this_; } - const this = @enumToInt(this_); + const this = @intFromEnum(this_); const is_not = str[0] == '!'; const offset: usize = if (str[0] == '!') 1 else 0; @@ -290,9 +290,9 @@ pub const OperatingSystem = enum(u16) { const field: u16 = NameMap.get(str[offset..]) orelse return this_; if (is_not) { - return @intToEnum(OperatingSystem, this & ~field); + return @enumFromInt(OperatingSystem, this & ~field); } else { - return @intToEnum(OperatingSystem, this | field); + return @enumFromInt(OperatingSystem, this | field); } } }; @@ -334,9 +334,9 @@ pub const Architecture = enum(u16) { pub fn isMatch(this: Architecture) bool { if (comptime Environment.isAarch64) { - return (@enumToInt(this) & arm64) != 0; + return (@intFromEnum(this) & arm64) != 0; } else if (comptime Environment.isX64) { - return (@enumToInt(this) & x64) != 0; + return (@intFromEnum(this) & x64) != 0; } else { return false; } @@ -346,7 +346,7 @@ pub const Architecture = enum(u16) { if (str.len == 0) { return this_; } - const this = @enumToInt(this_); + const this = @intFromEnum(this_); const is_not = str[0] == '!'; const offset: usize = if (str[0] == '!') 1 else 0; @@ -355,9 +355,9 @@ pub const Architecture = enum(u16) { const field: u16 = NameMap.get(input) orelse return this_; if (is_not) { - return @intToEnum(Architecture, this & ~field); + return @enumFromInt(Architecture, this & ~field); } else { - return @intToEnum(Architecture, this | field); + return @enumFromInt(Architecture, this | field); } } }; @@ -496,7 +496,7 @@ pub const PackageManifest = struct { } }; var trash: i32 = undefined; // workaround for stage1 compiler bug - std.sort.sort(Data, &data, &trash, Sort.lessThan); + std.sort.block(Data, &data, &trash, Sort.lessThan); var sizes_bytes: [fields.len]usize = undefined; var names: [fields.len][]const u8 = undefined; for (data, 0..) |elem, i| { @@ -571,7 +571,7 @@ pub const PackageManifest = struct { } pub fn save(this: *const PackageManifest, tmpdir: std.fs.IterableDir, cache_dir: std.fs.IterableDir) !void { - const file_id = std.hash.Wyhash.hash(0, this.name()); + const file_id = bun.Wyhash.hash(0, this.name()); var dest_path_buf: [512 + 64]u8 = undefined; var out_path_buf: ["-18446744073709551615".len + ".npm".len + 1]u8 = undefined; var dest_path_stream = std.io.fixedBufferStream(&dest_path_buf); @@ -588,7 +588,7 @@ pub const PackageManifest = struct { } pub fn load(allocator: std.mem.Allocator, cache_dir: std.fs.IterableDir, package_name: string) !?PackageManifest { - const file_id = std.hash.Wyhash.hash(0, package_name); + const file_id = bun.Wyhash.hash(0, package_name); var file_path_buf: [512 + 64]u8 = undefined; const hex_fmt = bun.fmt.hexIntLower(file_id); var file_path = try std.fmt.bufPrintZ(&file_path_buf, "{any}.npm", .{hex_fmt}); @@ -630,7 +630,7 @@ pub const PackageManifest = struct { inline for (sizes.fields) |field_name| { if (comptime strings.eqlComptime(field_name, "pkg")) { - pkg_stream.pos = std.mem.alignForward(pkg_stream.pos, @alignOf(Npm.NpmPackage)); + pkg_stream.pos = std.mem.alignForward(usize, pkg_stream.pos, @alignOf(Npm.NpmPackage)); var reader = pkg_stream.reader(); package_manifest.pkg = try reader.readStruct(NpmPackage); } else { @@ -851,7 +851,7 @@ pub const PackageManifest = struct { pre_versions_len += 1; extern_string_count += 1; } else { - extern_string_count += @as(usize, @boolToInt(std.mem.indexOfScalar(u8, version_name, '+') != null)); + extern_string_count += @as(usize, @intFromBool(std.mem.indexOfScalar(u8, version_name, '+') != null)); release_versions_len += 1; } @@ -862,7 +862,7 @@ pub const PackageManifest = struct { if (tarball_prop.data == .e_string) { const tarball = tarball_prop.data.e_string.slice(allocator); string_builder.count(tarball); - tarball_urls_count += @as(usize, @boolToInt(tarball.len > 0)); + tarball_urls_count += @as(usize, @intFromBool(tarball.len > 0)); } } } @@ -961,19 +961,19 @@ pub const PackageManifest = struct { if (versioned_packages.len > 0) { var versioned_packages_bytes = std.mem.sliceAsBytes(versioned_packages); - @memset(versioned_packages_bytes.ptr, 0, versioned_packages_bytes.len); + @memset(versioned_packages_bytes, 0); } if (all_semver_versions.len > 0) { var all_semver_versions_bytes = std.mem.sliceAsBytes(all_semver_versions); - @memset(all_semver_versions_bytes.ptr, 0, all_semver_versions_bytes.len); + @memset(all_semver_versions_bytes, 0); } if (all_extern_strings.len > 0) { var all_extern_strings_bytes = std.mem.sliceAsBytes(all_extern_strings); - @memset(all_extern_strings_bytes.ptr, 0, all_extern_strings_bytes.len); + @memset(all_extern_strings_bytes, 0); } if (version_extern_strings.len > 0) { var version_extern_strings_bytes = std.mem.sliceAsBytes(version_extern_strings); - @memset(version_extern_strings_bytes.ptr, 0, version_extern_strings_bytes.len); + @memset(version_extern_strings_bytes, 0); } var versioned_package_releases = versioned_packages[0..release_versions_len]; @@ -998,7 +998,7 @@ pub const PackageManifest = struct { var string_buf: string = ""; if (string_builder.ptr) |ptr| { // 0 it out for better determinism - @memset(ptr, 0, string_builder.cap); + @memset(ptr[0..string_builder.cap], 0); string_buf = ptr[0..string_builder.cap]; } @@ -1253,8 +1253,8 @@ pub const PackageManifest = struct { var this_names = dependency_names[0..count]; var this_versions = dependency_values[0..count]; - var name_hasher = std.hash.Wyhash.init(0); - var version_hasher = std.hash.Wyhash.init(0); + var name_hasher = bun.Wyhash.init(0); + var version_hasher = bun.Wyhash.init(0); const is_peer = comptime strings.eqlComptime(pair.prop, "peerDependencies"); @@ -1495,7 +1495,7 @@ pub const PackageManifest = struct { if (src.len > 0) { var dst = std.mem.sliceAsBytes(all_extern_strings[all_extern_strings.len - extern_strings.len ..]); std.debug.assert(dst.len >= src.len); - @memcpy(dst.ptr, src.ptr, src.len); + @memcpy(dst[0..src.len], src); } all_extern_strings = all_extern_strings[0 .. all_extern_strings.len - extern_strings.len]; diff --git a/src/install/resolution.zig b/src/install/resolution.zig index 1bd88e78d..b1adb3d80 100644 --- a/src/install/resolution.zig +++ b/src/install/resolution.zig @@ -20,7 +20,7 @@ pub const Resolution = extern struct { rhs_buf: []const u8, ) std.math.Order { if (lhs.tag != rhs.tag) { - return std.math.order(@enumToInt(lhs.tag), @enumToInt(rhs.tag)); + return std.math.order(@intFromEnum(lhs.tag), @intFromEnum(rhs.tag)); } return switch (lhs.tag) { diff --git a/src/install/resolvers/folder_resolver.zig b/src/install/resolvers/folder_resolver.zig index 90a2a414c..0ece2be7f 100644 --- a/src/install/resolvers/folder_resolver.zig +++ b/src/install/resolvers/folder_resolver.zig @@ -30,7 +30,7 @@ pub const FolderResolution = union(Tag) { } pub fn hash(normalized_path: string) u64 { - return std.hash.Wyhash.hash(0, normalized_path); + return bun.hash(normalized_path); } fn NewResolver(comptime tag: Resolution.Tag) type { @@ -95,9 +95,9 @@ pub const FolderResolution = union(Tag) { .global, .cache_folder => { const path = if (global_or_relative == .global) global_or_relative.global else global_or_relative.cache_folder; if (path.len > 0) { - const offset = path.len -| @as(usize, @boolToInt(path[path.len -| 1] == std.fs.path.sep)); + const offset = path.len -| @as(usize, @intFromBool(path[path.len -| 1] == std.fs.path.sep)); if (offset > 0) - @memcpy(remain.ptr, path.ptr, offset); + @memcpy(remain[0..offset], path[0..offset]); remain = remain[offset..]; if (normalized.len > 0) { if ((path[path.len - 1] != std.fs.path.sep) and (normalized[0] != std.fs.path.sep)) { diff --git a/src/install/semver.zig b/src/install/semver.zig index 9fd6b9c8d..c2730e7c7 100644 --- a/src/install/semver.zig +++ b/src/install/semver.zig @@ -263,7 +263,7 @@ pub const String = extern struct { std.debug.assert(bun.isSliceInBuffer(in, buf)); return Pointer{ - .off = @truncate(u32, @ptrToInt(in.ptr) - @ptrToInt(buf.ptr)), + .off = @truncate(u32, @intFromPtr(in.ptr) - @intFromPtr(buf.ptr)), .len = @truncate(u32, in.len), }; } @@ -311,7 +311,7 @@ pub const String = extern struct { pub const StringPool = std.HashMap(u64, String, IdentityContext(u64), 80); pub inline fn stringHash(buf: []const u8) u64 { - return std.hash.Wyhash.hash(0, buf); + return bun.Wyhash.hash(0, buf); } pub inline fn count(this: *Builder, slice_: string) void { @@ -515,7 +515,7 @@ pub const ExternalString = extern struct { pub inline fn from(in: string) ExternalString { return ExternalString{ .value = String.init(in, in), - .hash = std.hash.Wyhash.hash(0, in), + .hash = bun.Wyhash.hash(0, in), }; } @@ -552,15 +552,15 @@ pub const BigExternalString = extern struct { return BigExternalString{ .off = 0, .len = @truncate(u32, in.len), - .hash = std.hash.Wyhash.hash(0, in), + .hash = bun.Wyhash.hash(0, in), }; } pub inline fn init(buf: string, in: string, hash: u64) BigExternalString { - std.debug.assert(@ptrToInt(buf.ptr) <= @ptrToInt(in.ptr) and ((@ptrToInt(in.ptr) + in.len) <= (@ptrToInt(buf.ptr) + buf.len))); + std.debug.assert(@intFromPtr(buf.ptr) <= @intFromPtr(in.ptr) and ((@intFromPtr(in.ptr) + in.len) <= (@intFromPtr(buf.ptr) + buf.len))); return BigExternalString{ - .off = @truncate(u32, @ptrToInt(in.ptr) - @ptrToInt(buf.ptr)), + .off = @truncate(u32, @intFromPtr(in.ptr) - @intFromPtr(buf.ptr)), .len = @truncate(u32, in.len), .hash = hash, }; @@ -580,19 +580,19 @@ pub const SlicedString = struct { } pub inline fn external(this: SlicedString) ExternalString { - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(this.buf.ptr) <= @ptrToInt(this.slice.ptr) and ((@ptrToInt(this.slice.ptr) + this.slice.len) <= (@ptrToInt(this.buf.ptr) + this.buf.len))); + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.slice.ptr) and ((@intFromPtr(this.slice.ptr) + this.slice.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len))); - return ExternalString.init(this.buf, this.slice, std.hash.Wyhash.hash(0, this.slice)); + return ExternalString.init(this.buf, this.slice, bun.Wyhash.hash(0, this.slice)); } pub inline fn value(this: SlicedString) String { - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(this.buf.ptr) <= @ptrToInt(this.slice.ptr) and ((@ptrToInt(this.slice.ptr) + this.slice.len) <= (@ptrToInt(this.buf.ptr) + this.buf.len))); + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.slice.ptr) and ((@intFromPtr(this.slice.ptr) + this.slice.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len))); return String.init(this.buf, this.slice); } pub inline fn sub(this: SlicedString, input: string) SlicedString { - std.debug.assert(@ptrToInt(this.buf.ptr) <= @ptrToInt(this.buf.ptr) and ((@ptrToInt(input.ptr) + input.len) <= (@ptrToInt(this.buf.ptr) + this.buf.len))); + std.debug.assert(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.buf.ptr) and ((@intFromPtr(input.ptr) + input.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len))); return SlicedString{ .buf = this.buf, .slice = input }; } }; @@ -678,7 +678,7 @@ pub const Version = extern struct { .build = this.tag.build.hash, }; const bytes = std.mem.asBytes(&hashable); - return std.hash.Wyhash.hash(0, bytes); + return bun.Wyhash.hash(0, bytes); } pub const Formatter = struct { @@ -1814,7 +1814,7 @@ pub const Query = struct { }; if (!hyphenate) i = rollback; - i += @as(usize, @boolToInt(!hyphenate)); + i += @as(usize, @intFromBool(!hyphenate)); if (hyphenate) { const second_parsed = Version.parse(sliced.sub(input[i..]), allocator); diff --git a/src/io/io_darwin.zig b/src/io/io_darwin.zig index 902ae2ae4..8045cbdf6 100644 --- a/src/io/io_darwin.zig +++ b/src/io/io_darwin.zig @@ -245,7 +245,7 @@ const system = darwin; pub fn asError(err: anytype) Errno { const int = if (@typeInfo(@TypeOf(err)) == .Enum) - @enumToInt(err) + @intFromEnum(err) else err; @@ -772,7 +772,7 @@ fn flush(self: *IO, comptime _: @Type(.EnumLiteral)) !void { continue; } - const completion = @intToPtr(*Completion, kevent.udata); + const completion = @ptrFromInt(*Completion, kevent.udata); completion.next = null; self.completed.push(completion); } @@ -837,7 +837,7 @@ fn flush_io(_: *IO, events: []Kevent64, io_pending_top: *?*Completion) usize { .flags = @intCast(u16, event_info[2]), .fflags = 0, .data = 0, - .udata = @ptrToInt(completion), + .udata = @intFromPtr(completion), }; } @@ -995,7 +995,7 @@ fn submitWithIncrementPending( // Complete the Completion return callback( - @intToPtr(Context, @ptrToInt(_completion.context)), + @ptrFromInt(Context, @intFromPtr(_completion.context)), _completion, result, ); @@ -1203,7 +1203,7 @@ pub fn connect( const rc = system.getsockopt(op.socket, os.SOL.SOCKET, os.SO.ERROR, @ptrCast([*]u8, &err_code), &size); assert(size == 4); break :brk switch (darwin.getErrno(rc)) { - .SUCCESS => switch (@intToEnum(os.E, err_code)) { + .SUCCESS => switch (@enumFromInt(os.E, err_code)) { .SUCCESS => {}, .ACCES => error.PermissionDenied, .PERM => error.PermissionDenied, @@ -1351,7 +1351,7 @@ pub fn read( op.buf, op.len, ); - return switch (@enumToInt(os.errno(rc))) { + return switch (@intFromEnum(os.errno(rc))) { 0 => @intCast(usize, rc), os.EINTR => continue, os.EAGAIN => error.WouldBlock, diff --git a/src/io/io_linux.zig b/src/io/io_linux.zig index 10e1ede0c..7603eabfd 100644 --- a/src/io/io_linux.zig +++ b/src/io/io_linux.zig @@ -428,7 +428,7 @@ pub const errno_map: [135]Errno = brk: { }; pub fn asError(err: anytype) Errno { const errnum = if (@typeInfo(@TypeOf(err)) == .Enum) - @enumToInt(err) + @intFromEnum(err) else err; return switch (errnum) { @@ -463,7 +463,7 @@ has_queued: usize = 0, wakeup_completion: Completion = undefined, fn queueForWakeup(this: *@This(), comptime Type: type, ctx: Type, comptime cb: anytype) void { - @memset(&this.eventfd_buf, 0, this.eventfd_buf.len); + @memset(&this.eventfd_buf, 0); const Callback = struct { pub fn callback(that: Type, completion: *Completion, _: ReadError!usize) void { var io = @fieldParentPtr(IO, "wakeup_completion", completion); @@ -640,7 +640,7 @@ fn flush(self: *IO, wait_nr: u32, timeouts: *usize, etime: *bool) !void { fn flush_completions(self: *IO, wait_nr: u32, timeouts: *usize, etime: *bool) !void { var cqes: [256]std.os.linux.io_uring_cqe = undefined; var completion_byttes = std.mem.asBytes(&cqes); - @memset(completion_byttes, 0, completion_byttes.len); + @memset(completion_byttes[0..completion_byttes.len], 0); var wait_remaining = wait_nr; while (true) { // Guard against waiting indefinitely (if there are too few requests inflight), @@ -660,7 +660,7 @@ fn flush_completions(self: *IO, wait_nr: u32, timeouts: *usize, etime: *bool) !v if (-cqe.res == os.ETIME) etime.* = true; continue; } - const completion = @intToPtr(*Completion, @intCast(usize, cqe.user_data)); + const completion = @ptrFromInt(*Completion, @intCast(usize, cqe.user_data)); completion.result = cqe.res; // We do not run the completion here (instead appending to a linked list) to avoid: // * recursion through `flush_submissions()` and `flush_completions()`, @@ -780,7 +780,7 @@ pub const Completion = struct { ); }, } - sqe.user_data = @ptrToInt(completion); + sqe.user_data = @intFromPtr(completion); } fn complete(completion: *Completion) void { @@ -1107,9 +1107,9 @@ pub fn accept( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const AcceptError!os.socket_t, @ptrToInt(res)).*, + @ptrFromInt(*const AcceptError!os.socket_t, @intFromPtr(res)).*, ); } }.wrapper, @@ -1149,9 +1149,9 @@ pub fn close( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const CloseError!void, @ptrToInt(res)).*, + @ptrFromInt(*const CloseError!void, @intFromPtr(res)).*, ); } }.wrapper, @@ -1206,9 +1206,9 @@ pub fn connect( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const ConnectError!void, @ptrToInt(res)).*, + @ptrFromInt(*const ConnectError!void, @intFromPtr(res)).*, ); } }.wrapper, @@ -1257,9 +1257,9 @@ pub fn fsync( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const FsyncError!void, @ptrToInt(res)).*, + @ptrFromInt(*const FsyncError!void, @intFromPtr(res)).*, ); } }.wrapper, @@ -1303,9 +1303,9 @@ pub fn read( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const ReadError!usize, @ptrToInt(res)).*, + @ptrFromInt(*const ReadError!usize, @intFromPtr(res)).*, ); } }.wrapper, @@ -1355,9 +1355,9 @@ pub fn recv( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const RecvError!usize, @ptrToInt(res)).*, + @ptrFromInt(*const RecvError!usize, @intFromPtr(res)).*, ); } }.wrapper, @@ -1390,9 +1390,9 @@ pub fn readev( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const RecvError!usize, @ptrToInt(res)).*, + @ptrFromInt(*const RecvError!usize, @intFromPtr(res)).*, ); } }.wrapper, @@ -1446,9 +1446,9 @@ pub fn send( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const SendError!usize, @ptrToInt(res)).*, + @ptrFromInt(*const SendError!usize, @intFromPtr(res)).*, ); } }.wrapper, @@ -1538,9 +1538,9 @@ pub fn open( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const OpenError!linux.fd_t, @ptrToInt(res)).*, + @ptrFromInt(*const OpenError!linux.fd_t, @intFromPtr(res)).*, ); } }.wrapper, @@ -1575,9 +1575,9 @@ pub fn writev( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const SendError!usize, @ptrToInt(res)).*, + @ptrFromInt(*const SendError!usize, @intFromPtr(res)).*, ); } }.wrapper, @@ -1613,9 +1613,9 @@ pub fn timeout( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const TimeoutError!void, @ptrToInt(res)).*, + @ptrFromInt(*const TimeoutError!void, @intFromPtr(res)).*, ); } }.wrapper, @@ -1662,9 +1662,9 @@ pub fn write( .callback = struct { fn wrapper(ctx: ?*anyopaque, comp: *Completion, res: *const anyopaque) void { callback( - @intToPtr(Context, @ptrToInt(ctx)), + @ptrFromInt(Context, @intFromPtr(ctx)), comp, - @intToPtr(*const WriteError!usize, @ptrToInt(res)).*, + @ptrFromInt(*const WriteError!usize, @intFromPtr(res)).*, ); } }.wrapper, @@ -1712,7 +1712,7 @@ const Syscall = struct { .NOMEM => return error.SystemResources, .PROTONOSUPPORT => return error.ProtocolNotSupported, .PROTOTYPE => return error.SocketTypeNotSupported, - else => |err| return asError(@enumToInt(err)), + else => |err| return asError(@intFromEnum(err)), }; } }; diff --git a/src/js_ast.zig b/src/js_ast.zig index 707e83fa0..bd06ca6dc 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -38,8 +38,8 @@ pub fn NewBaseStore(comptime Union: anytype, comptime count: usize) type { var max_size = 0; var max_align = 1; for (Union) |kind| { - max_size = std.math.max(@sizeOf(kind), max_size); - max_align = if (@sizeOf(kind) == 0) max_align else std.math.max(@alignOf(kind), max_align); + max_size = @max(@sizeOf(kind), max_size); + max_align = if (@sizeOf(kind) == 0) max_align else @max(@alignOf(kind), max_align); } const UnionValueType = [max_size]u8; @@ -156,7 +156,7 @@ pub fn NewBaseStore(comptime Union: anytype, comptime count: usize) type { if (comptime Environment.isDebug) { // ensure we crash if we use a freed value var bytes = std.mem.asBytes(&b.items); - @memset(bytes, undefined, bytes.len); + @memset(bytes, undefined); } b.used = 0; } @@ -666,7 +666,7 @@ pub const CharFreq = struct { break :brk _array; }; - std.sort.sort(CharAndCount, &array, {}, CharAndCount.lessThan); + std.sort.block(CharAndCount, &array, {}, CharAndCount.lessThan); var minifier = NameMinifier.init(allocator); minifier.head.ensureTotalCapacityPrecise(NameMinifier.default_head.len) catch unreachable; @@ -1158,7 +1158,7 @@ pub const Symbol = struct { } pub inline fn isPrivate(kind: Symbol.Kind) bool { - return @enumToInt(kind) >= @enumToInt(Symbol.Kind.private_field) and @enumToInt(kind) <= @enumToInt(Symbol.Kind.private_static_get_set_pair); + return @intFromEnum(kind) >= @intFromEnum(Symbol.Kind.private_field) and @intFromEnum(kind) <= @intFromEnum(Symbol.Kind.private_static_get_set_pair); } pub inline fn isHoisted(kind: Symbol.Kind) bool { @@ -1706,7 +1706,7 @@ pub const E = struct { pub fn toStringFromF64Safe(value: f64, allocator: std.mem.Allocator) ?string { if (value == @trunc(value) and (value < std.math.maxInt(i32) and value > std.math.minInt(i32))) { - const int_value = @floatToInt(i64, value); + const int_value = @intFromFloat(i64, value); const abs = @intCast(u64, std.math.absInt(int_value) catch return null); if (abs < double_digit.len) { return if (int_value < 0) @@ -1735,22 +1735,22 @@ pub const E = struct { pub inline fn toU64(self: Number) u64 { @setRuntimeSafety(false); - return @floatToInt(u64, @max(@trunc(self.value), 0)); + return @intFromFloat(u64, @max(@trunc(self.value), 0)); } pub inline fn toUsize(self: Number) usize { @setRuntimeSafety(false); - return @floatToInt(usize, @max(@trunc(self.value), 0)); + return @intFromFloat(usize, @max(@trunc(self.value), 0)); } pub inline fn toU32(self: Number) u32 { @setRuntimeSafety(false); - return @floatToInt(u32, @max(@trunc(self.value), 0)); + return @intFromFloat(u32, @max(@trunc(self.value), 0)); } pub inline fn toU16(self: Number) u16 { @setRuntimeSafety(false); - return @floatToInt(u16, @max(@trunc(self.value), 0)); + return @intFromFloat(u16, @max(@trunc(self.value), 0)); } pub fn jsonStringify(self: *const Number, opts: anytype, o: anytype) !void { @@ -2057,11 +2057,11 @@ pub const E = struct { } pub fn alphabetizeProperties(this: *Object) void { - std.sort.sort(G.Property, this.properties.slice(), {}, Sorter.isLessThan); + std.sort.block(G.Property, this.properties.slice(), {}, Sorter.isLessThan); } pub fn packageJSONSort(this: *Object) void { - std.sort.sort(G.Property, this.properties.slice(), {}, PackageJSONSort.Fields.isLessThan); + std.sort.block(G.Property, this.properties.slice(), {}, PackageJSONSort.Fields.isLessThan); } const PackageJSONSort = struct { @@ -2096,15 +2096,15 @@ pub const E = struct { }); pub fn isLessThan(ctx: void, lhs: G.Property, rhs: G.Property) bool { - var lhs_key_size: u8 = @enumToInt(Fields.__fake); - var rhs_key_size: u8 = @enumToInt(Fields.__fake); + var lhs_key_size: u8 = @intFromEnum(Fields.__fake); + var rhs_key_size: u8 = @intFromEnum(Fields.__fake); if (lhs.key != null and lhs.key.?.data == .e_string) { - lhs_key_size = @enumToInt(Map.get(lhs.key.?.data.e_string.data) orelse Fields.__fake); + lhs_key_size = @intFromEnum(Map.get(lhs.key.?.data.e_string.data) orelse Fields.__fake); } if (rhs.key != null and rhs.key.?.data == .e_string) { - rhs_key_size = @enumToInt(Map.get(rhs.key.?.data.e_string.data) orelse Fields.__fake); + rhs_key_size = @intFromEnum(Map.get(rhs.key.?.data.e_string.data) orelse Fields.__fake); } return switch (std.math.order(lhs_key_size, rhs_key_size)) { @@ -2343,10 +2343,10 @@ pub const E = struct { if (s.isUTF8()) { // hash utf-8 - return std.hash.Wyhash.hash(0, s.data); + return bun.hash(s.data); } else { // hash utf-16 - return std.hash.Wyhash.hash(0, @ptrCast([*]const u8, s.slice16().ptr)[0 .. s.slice16().len * 2]); + return bun.hash(@ptrCast([*]const u8, s.slice16().ptr)[0 .. s.slice16().len * 2]); } } @@ -3100,7 +3100,7 @@ pub const Expr = struct { pub fn hasAnyPropertyNamed(expr: *const Expr, comptime names: []const string) bool { if (std.meta.activeTag(expr.data) != .e_object) return false; const obj = expr.data.e_object; - if (@ptrToInt(obj.properties.ptr) == 0) return false; + if (@intFromPtr(obj.properties.ptr) == 0) return false; for (obj.properties.slice()) |prop| { if (prop.value == null) continue; @@ -3162,7 +3162,7 @@ pub const Expr = struct { pub fn asProperty(expr: *const Expr, name: string) ?Query { if (std.meta.activeTag(expr.data) != .e_object) return null; const obj = expr.data.e_object; - if (@ptrToInt(obj.properties.ptr) == 0) return null; + if (@intFromPtr(obj.properties.ptr) == 0) return null; return obj.asProperty(name); } @@ -3183,7 +3183,7 @@ pub const Expr = struct { pub fn asArray(expr: *const Expr) ?ArrayIterator { if (std.meta.activeTag(expr.data) != .e_array) return null; const array = expr.data.e_array; - if (array.items.len == 0 or @ptrToInt(array.items.ptr) == 0) return null; + if (array.items.len == 0 or @intFromPtr(array.items.ptr) == 0) return null; return ArrayIterator{ .array = array, .index = 0 }; } @@ -3290,7 +3290,7 @@ pub const Expr = struct { } } - pub fn joinAllWithCommaCallback(all: []Expr, comptime Context: type, ctx: Context, callback: (fn (ctx: anytype, expr: anytype) ?Expr), allocator: std.mem.Allocator) ?Expr { + pub fn joinAllWithCommaCallback(all: []Expr, comptime Context: type, ctx: Context, comptime callback: (fn (ctx: anytype, expr: Expr) ?Expr), allocator: std.mem.Allocator) ?Expr { switch (all.len) { 0 => return null, 1 => { @@ -3637,7 +3637,7 @@ pub const Expr = struct { if (comptime Environment.isDebug) { // Sanity check: assert string is not a null ptr if (st.data.len > 0 and st.isUTF8()) { - std.debug.assert(@ptrToInt(st.data.ptr) > 0); + std.debug.assert(@intFromPtr(st.data.ptr) > 0); } } return Expr{ @@ -4002,7 +4002,7 @@ pub const Expr = struct { if (comptime Environment.isDebug) { // Sanity check: assert string is not a null ptr if (st.data.len > 0 and st.isUTF8()) { - std.debug.assert(@ptrToInt(st.data.ptr) > 0); + std.debug.assert(@intFromPtr(st.data.ptr) > 0); } } return Expr{ @@ -5692,9 +5692,9 @@ pub const Op = struct { } pub fn unaryAssignTarget(code: Op.Code) AssignTarget { - if (@enumToInt(code) >= - @enumToInt(Op.Code.un_pre_dec) and @enumToInt(code) <= - @enumToInt(Op.Code.un_post_inc)) + if (@intFromEnum(code) >= + @intFromEnum(Op.Code.un_pre_dec) and @intFromEnum(code) <= + @intFromEnum(Op.Code.un_post_inc)) { return AssignTarget.update; } @@ -5702,19 +5702,19 @@ pub const Op = struct { return AssignTarget.none; } pub fn isLeftAssociative(code: Op.Code) bool { - return @enumToInt(code) >= - @enumToInt(Op.Code.bin_add) and - @enumToInt(code) < @enumToInt(Op.Code.bin_comma) and code != .bin_pow; + return @intFromEnum(code) >= + @intFromEnum(Op.Code.bin_add) and + @intFromEnum(code) < @intFromEnum(Op.Code.bin_comma) and code != .bin_pow; } pub fn isRightAssociative(code: Op.Code) bool { - return @enumToInt(code) >= @enumToInt(Op.Code.bin_assign) or code == .bin_pow; + return @intFromEnum(code) >= @intFromEnum(Op.Code.bin_assign) or code == .bin_pow; } pub fn binaryAssignTarget(code: Op.Code) AssignTarget { if (code == .bin_assign) { return AssignTarget.replace; } - if (@enumToInt(code) > @enumToInt(Op.Code.bin_assign)) { + if (@intFromEnum(code) > @intFromEnum(Op.Code.bin_assign)) { return AssignTarget.update; } @@ -5722,7 +5722,7 @@ pub const Op = struct { } pub fn isPrefix(code: Op.Code) bool { - return @enumToInt(code) < @enumToInt(Op.Code.un_post_dec); + return @intFromEnum(code) < @intFromEnum(Op.Code.un_post_dec); } }; @@ -5752,27 +5752,27 @@ pub const Op = struct { member, pub inline fn lt(self: Level, b: Level) bool { - return @enumToInt(self) < @enumToInt(b); + return @intFromEnum(self) < @intFromEnum(b); } pub inline fn gt(self: Level, b: Level) bool { - return @enumToInt(self) > @enumToInt(b); + return @intFromEnum(self) > @intFromEnum(b); } pub inline fn gte(self: Level, b: Level) bool { - return @enumToInt(self) >= @enumToInt(b); + return @intFromEnum(self) >= @intFromEnum(b); } pub inline fn lte(self: Level, b: Level) bool { - return @enumToInt(self) <= @enumToInt(b); + return @intFromEnum(self) <= @intFromEnum(b); } pub inline fn eql(self: Level, b: Level) bool { - return @enumToInt(self) == @enumToInt(b); + return @intFromEnum(self) == @intFromEnum(b); } pub inline fn sub(self: Level, i: anytype) Level { - return @intToEnum(Level, @enumToInt(self) - i); + return @enumFromInt(Level, @intFromEnum(self) - i); } pub inline fn addF(self: Level, i: anytype) Level { - return @intToEnum(Level, @enumToInt(self) + i); + return @enumFromInt(Level, @intFromEnum(self) + i); } }; @@ -6647,7 +6647,7 @@ pub const Scope = struct { } pub inline fn kindStopsHoisting(s: *const Scope) bool { - return @enumToInt(s.kind) >= @enumToInt(Kind.entry); + return @intFromEnum(s.kind) >= @intFromEnum(Kind.entry); } }; @@ -7284,7 +7284,7 @@ pub const Macro = struct { _: js.JSStringRef, _: js.ExceptionRef, ) js.JSObjectRef { - return JSC.JSValue.jsNumberFromU16(@intCast(u16, @enumToInt(std.meta.activeTag(this.data)))).asRef(); + return JSC.JSValue.jsNumberFromU16(@intCast(u16, @intFromEnum(std.meta.activeTag(this.data)))).asRef(); } pub fn getTagName( this: *JSNode, @@ -7691,7 +7691,7 @@ pub const Macro = struct { var list = std.EnumArray(Tag, Expr.Data).initFill(Expr.Data{ .e_number = E.Number{ .value = 0.0 } }); const fields: []const std.builtin.Type.EnumField = @typeInfo(Tag).Enum.fields; for (fields) |field| { - list.set(@intToEnum(Tag, field.value), Expr.Data{ .e_number = E.Number{ .value = @intToFloat(f64, field.value) } }); + list.set(@enumFromInt(Tag, field.value), Expr.Data{ .e_number = E.Number{ .value = @floatFromInt(f64, field.value) } }); } break :brk list; @@ -7868,7 +7868,7 @@ pub const Macro = struct { const Enum: std.builtin.Type.Enum = @typeInfo(Tag).Enum; var max_value: u8 = 0; for (Enum.fields) |field| { - max_value = std.math.max(@as(u8, field.value), max_value); + max_value = @max(@as(u8, field.value), max_value); } break :brk max_value; }; @@ -7877,7 +7877,7 @@ pub const Macro = struct { const Enum: std.builtin.Type.Enum = @typeInfo(Tag).Enum; var min: u8 = 255; for (Enum.fields) |field| { - min = std.math.min(@as(u8, field.value), min); + min = @min(@as(u8, field.value), min); } break :brk min; }; @@ -8007,7 +8007,7 @@ pub const Macro = struct { Expr{ .data = .{ .e_number = E.Number{ - .value = @intToFloat(f64, @boolToInt(value.data.e_boolean.value)), + .value = @floatFromInt(f64, @intFromBool(value.data.e_boolean.value)), }, }, .loc = value.loc, @@ -8084,7 +8084,7 @@ pub const Macro = struct { self.args.ensureUnusedCapacity(2 + children.len) catch unreachable; self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_array) }); const children_count = @truncate(u16, children.len); - self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = E.Number{ .value = @intToFloat(f64, children_count) } } }); + self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = E.Number{ .value = @floatFromInt(f64, children_count) } } }); var old_parent = self.parent_tag; self.parent_tag = Tag.e_array; @@ -8123,7 +8123,7 @@ pub const Macro = struct { self.args.ensureUnusedCapacity(2 + children.len) catch unreachable; self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.e_object) }); const children_count = @truncate(u16, children.len); - self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = E.Number{ .value = @intToFloat(f64, children_count) } } }); + self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = E.Number{ .value = @floatFromInt(f64, children_count) } } }); var old_parent = self.parent_tag; self.parent_tag = Tag.e_object; @@ -8328,7 +8328,7 @@ pub const Macro = struct { } self.args.ensureUnusedCapacity(2 + count) catch unreachable; self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.inline_inject) }); - self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = .{ .value = @intToFloat(f64, @intCast(u32, children.len)) } } }); + self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = .{ .e_number = .{ .value = @floatFromInt(f64, @intCast(u32, children.len)) } } }); const old_parent_tag = self.parent_tag; self.parent_tag = Tag.inline_inject; @@ -8393,7 +8393,7 @@ pub const Macro = struct { const namespace_ = propertyValueNamed(props, "namespace"); const items_count: u32 = 1 + - @intCast(u32, @boolToInt(namespace_ != null)); + @intCast(u32, @intFromBool(namespace_ != null)); self.args.ensureUnusedCapacity(items_count) catch unreachable; self.args.appendAssumeCapacity(Expr{ .loc = loc, .data = comptime Tag.ids.get(Tag.s_import) }); @@ -8504,7 +8504,7 @@ pub const Macro = struct { .loc = loc, .data = .{ .e_number = E.Number{ - .value = @intToFloat(f64, children.len), + .value = @floatFromInt(f64, children.len), }, }, }); @@ -8742,11 +8742,11 @@ pub const Macro = struct { pub fn fromJSValueRefNoValidate(ctx: js.JSContextRef, value: js.JSValueRef) TagOrJSNode { switch (js.JSValueGetType(ctx, value)) { js.JSType.kJSTypeNumber => { - const tag_int = @floatToInt(u8, JSC.JSValue.fromRef(value).asNumber()); + const tag_int = @intFromFloat(u8, JSC.JSValue.fromRef(value).asNumber()); if (tag_int < Tag.min_tag or tag_int > Tag.max_tag) { return TagOrJSNode{ .invalid = {} }; } - return TagOrJSNode{ .tag = @intToEnum(JSNode.Tag, tag_int) }; + return TagOrJSNode{ .tag = @enumFromInt(JSNode.Tag, tag_int) }; }, js.JSType.kJSTypeObject => { if (JSCBase.GetJSPrivateData(JSNode, value)) |node| { @@ -8764,13 +8764,13 @@ pub const Macro = struct { pub fn fromJSValueRef(writer: *Writer, ctx: js.JSContextRef, value: js.JSValueRef) TagOrJSNode { switch (js.JSValueGetType(ctx, value)) { js.JSType.kJSTypeNumber => { - const tag_int = @floatToInt(u8, JSC.JSValue.fromRef(value).asNumber()); + const tag_int = @intFromFloat(u8, JSC.JSValue.fromRef(value).asNumber()); if (tag_int < Tag.min_tag or tag_int > Tag.max_tag) { throwTypeError(ctx, "Node type has invalid value", writer.exception); writer.errored = true; return TagOrJSNode{ .invalid = {} }; } - return TagOrJSNode{ .tag = @intToEnum(JSNode.Tag, tag_int) }; + return TagOrJSNode{ .tag = @enumFromInt(JSNode.Tag, tag_int) }; }, js.JSType.kJSTypeObject => { if (JSCBase.GetJSPrivateData(JSNode, value)) |node| { @@ -8932,7 +8932,7 @@ pub const Macro = struct { import.import.items = writer.allocator.alloc( ClauseItem, - @intCast(u32, @boolToInt(has_default)) + array_iter.len, + @intCast(u32, @intFromBool(has_default)) + array_iter.len, ) catch return false; while (array_iter.next()) |name| { @@ -8961,7 +8961,7 @@ pub const Macro = struct { } else { import.import.items = writer.allocator.alloc( ClauseItem, - @intCast(u32, @boolToInt(has_default)), + @intCast(u32, @intFromBool(has_default)), ) catch return false; } @@ -9000,7 +9000,7 @@ pub const Macro = struct { var nextArg = writer.eatArg() orelse return false; if (js.JSValueIsArray(writer.ctx, nextArg.asRef())) { const extras = @truncate(u32, nextArg.getLength(writer.ctx.ptr())); - count += std.math.max(@truncate(@TypeOf(count), extras), 1) - 1; + count += @max(@truncate(@TypeOf(count), extras), 1) - 1; items.ensureUnusedCapacity(extras) catch unreachable; items.expandToCapacity(); var new_writer = writer.*; @@ -9919,7 +9919,7 @@ pub const Macro = struct { }, .Integer => { - return Expr.init(E.Number, E.Number{ .value = @intToFloat(f64, value.toInt32()) }, this.caller.loc); + return Expr.init(E.Number, E.Number{ .value = @floatFromInt(f64, value.toInt32()) }, this.caller.loc); }, .Double => { return Expr.init(E.Number, E.Number{ .value = value.asNumber() }, this.caller.loc); @@ -9992,7 +9992,7 @@ pub const Macro = struct { exception_holder = Zig.ZigException.Holder.init(); var js_args: []JSC.JSValue = &.{}; defer { - for (js_args[0 .. js_args.len - @as(usize, @boolToInt(!javascript_object.isEmpty()))]) |arg| { + for (js_args[0 .. js_args.len - @as(usize, @intFromBool(!javascript_object.isEmpty()))]) |arg| { arg.unprotect(); } @@ -10004,7 +10004,7 @@ pub const Macro = struct { switch (caller.data) { .e_call => |call| { const call_args: []Expr = call.args.slice(); - js_args = try allocator.alloc(JSC.JSValue, call_args.len + @as(usize, @boolToInt(!javascript_object.isEmpty()))); + js_args = try allocator.alloc(JSC.JSValue, call_args.len + @as(usize, @intFromBool(!javascript_object.isEmpty()))); for (call_args, js_args[0..call_args.len]) |in, *out| { const value = try in.toJS( diff --git a/src/js_lexer.zig b/src/js_lexer.zig index f87d28694..5d41aec4b 100644 --- a/src/js_lexer.zig +++ b/src/js_lexer.zig @@ -274,7 +274,7 @@ fn NewLexer_( } pub inline fn isIdentifierOrKeyword(lexer: LexerType) bool { - return @enumToInt(lexer.token) >= @enumToInt(T.t_identifier); + return @intFromEnum(lexer.token) >= @intFromEnum(T.t_identifier); } pub fn deinit(this: *LexerType) void { @@ -304,7 +304,7 @@ fn NewLexer_( // Convert '\r\n' into '\n' const next_i: usize = iter.i + 1; - iter.i += @as(u32, @boolToInt(next_i < text.len and text[next_i] == '\n')); + iter.i += @as(u32, @intFromBool(next_i < text.len and text[next_i] == '\n')); // Convert '\r' into '\n' buf.append('\n') catch unreachable; @@ -572,7 +572,7 @@ fn NewLexer_( // Make sure Windows CRLF counts as a single newline const next_i: usize = iter.i + 1; - iter.i += @as(u32, @boolToInt(next_i < text.len and text[next_i] == '\n')); + iter.i += @as(u32, @intFromBool(next_i < text.len and text[next_i] == '\n')); // Ignore line continuations. A line continuation is not an escaped newline. continue; @@ -819,7 +819,7 @@ fn NewLexer_( // This count is approximate because it handles "\n" and "\r\n" (the common // cases) but not "\r" or "\u2028" or "\u2029". Getting this wrong is harmless // because it's only a preallocation. The array will just grow if it's too small. - lexer.approximate_newline_count += @boolToInt(lexer.code_point == '\n'); + lexer.approximate_newline_count += @intFromBool(lexer.code_point == '\n'); } pub inline fn expect(self: *LexerType, comptime token: T) !void { @@ -1784,7 +1784,7 @@ fn NewLexer_( pub fn unexpected(lexer: *LexerType) !void { const found = finder: { - lexer.start = std.math.min(lexer.start, lexer.end); + lexer.start = @min(lexer.start, lexer.end); if (lexer.start == lexer.source.contents.len) { break :finder "end of file"; @@ -1868,7 +1868,7 @@ fn NewLexer_( const at = @bitCast(strings.AsciiVectorU1, vec == @splat(strings.ascii_vector_size, @as(u8, '@'))); if (@reduce(.Max, hashtag + at) == 1) { - rest.len = @ptrToInt(end) - @ptrToInt(rest.ptr); + rest.len = @intFromPtr(end) - @intFromPtr(rest.ptr); if (comptime Environment.allow_assert) { std.debug.assert( strings.containsChar(&@as([strings.ascii_vector_size]u8, vec), '#') or @@ -1918,7 +1918,7 @@ fn NewLexer_( rest.ptr += strings.ascii_vector_size; } - rest.len = @ptrToInt(end) - @ptrToInt(rest.ptr); + rest.len = @intFromPtr(end) - @intFromPtr(rest.ptr); } if (comptime Environment.allow_assert) @@ -1930,7 +1930,7 @@ fn NewLexer_( switch (c) { '@', '#' => { const chunk = rest; - const i = @ptrToInt(chunk.ptr) - @ptrToInt(text.ptr); + const i = @intFromPtr(chunk.ptr) - @intFromPtr(text.ptr); if (!lexer.has_pure_comment_before) { if (strings.hasPrefixWithWordBoundary(chunk, "__PURE__")) { lexer.has_pure_comment_before = true; @@ -2952,7 +2952,7 @@ fn NewLexer_( for (text) |c| { number = number * 10 + @intCast(u32, c - '0'); } - lexer.number = @intToFloat(f64, number); + lexer.number = @floatFromInt(f64, number); } else { // Parse a double-precision floating-point number if (bun.parseDouble(text)) |num| { @@ -3155,7 +3155,7 @@ pub fn rangeOfIdentifier(source: *const Source, loc: logger.Loc) logger.Range { } inline fn float64(num: anytype) f64 { - return @intToFloat(f64, num); + return @floatFromInt(f64, num); } pub fn isLatin1Identifier(comptime Buffer: type, name: Buffer) bool { @@ -3226,7 +3226,7 @@ fn latin1IdentifierContinueLength(name: []const u8) usize { } return @as(usize, first) + - @ptrToInt(wrapped.ptr) - @ptrToInt(name.ptr); + @intFromPtr(wrapped.ptr) - @intFromPtr(name.ptr); } } } @@ -3330,12 +3330,12 @@ fn skipToInterestingCharacterInMultilineComment(text_: []const u8) ?u32 { const first = @ctz(bitmask); std.debug.assert(first < strings.ascii_vector_size); std.debug.assert(text.ptr[first] == '*' or text.ptr[first] == '\r' or text.ptr[first] == '\n' or text.ptr[first] > 127); - return @truncate(u32, first + (@ptrToInt(text.ptr) - @ptrToInt(text_.ptr))); + return @truncate(u32, first + (@intFromPtr(text.ptr) - @intFromPtr(text_.ptr))); } text.ptr += strings.ascii_vector_size; } - return @truncate(u32, @ptrToInt(text.ptr) - @ptrToInt(text_.ptr)); + return @truncate(u32, @intFromPtr(text.ptr) - @intFromPtr(text_.ptr)); } fn indexOfInterestingCharacterInStringLiteral(text_: []const u8, quote: u8) ?usize { @@ -3357,7 +3357,7 @@ fn indexOfInterestingCharacterInStringLiteral(text_: []const u8, quote: u8) ?usi const bitmask = @bitCast(u16, any_significant); const first = @ctz(bitmask); std.debug.assert(first < strings.ascii_vector_size); - return first + (@ptrToInt(text.ptr) - @ptrToInt(text_.ptr)); + return first + (@intFromPtr(text.ptr) - @intFromPtr(text_.ptr)); } text = text[strings.ascii_vector_size..]; } diff --git a/src/js_lexer/identifier.zig b/src/js_lexer/identifier.zig index 4a48b5d17..8c1a59c2b 100644 --- a/src/js_lexer/identifier.zig +++ b/src/js_lexer/identifier.zig @@ -1800,7 +1800,7 @@ pub const JumpTableInline = struct { // iter = std.unicode.Utf8Iterator{ .bytes = code, .i = 0 }; // hash_table_count = 0; // while (iter.nextCodepoint()) |cp| { -// hash_table_count += @as(usize, @boolToInt(HashTable.isIdentifierStart(cp) or HashTable.isIdentifierPart(cp))); +// hash_table_count += @as(usize, @intFromBool(HashTable.isIdentifierStart(cp) or HashTable.isIdentifierPart(cp))); // } // } // hash_table_elapsed += timer.read(); @@ -1816,7 +1816,7 @@ pub const JumpTableInline = struct { // while (iter.nextCodepoint()) |cp| { // jump_table_count += @as( // usize, -// @boolToInt(JumpTable.isIdentifierStart(cp) or JumpTable.isIdentifierPart(cp)), +// @intFromBool(JumpTable.isIdentifierStart(cp) or JumpTable.isIdentifierPart(cp)), // ); // } // } @@ -1833,7 +1833,7 @@ pub const JumpTableInline = struct { // while (iter.nextCodepoint()) |cp| { // binary_search_count += @as( // usize, -// @boolToInt( +// @intFromBool( // BinarySearch.isIdentifierStart( // cp, // ) or BinarySearch.isIdentifierPart( @@ -1856,7 +1856,7 @@ pub const JumpTableInline = struct { // while (iter.nextCodepoint()) |cp| { // bitset_count += @as( // usize, -// @boolToInt( +// @intFromBool( // Bitset.isIdentifierStart( // cp, // ) or Bitset.isIdentifierPart( @@ -1930,7 +1930,7 @@ pub const JumpTableInline = struct { // iter = std.unicode.Utf8Iterator{ .bytes = code, .i = 0 }; // hash_table_count = 0; // while (iter.nextCodepoint()) |cp| { -// hash_table_count += @as(usize, @boolToInt(HashTable.isIdentifierStart(cp) or HashTable.isIdentifierPart(cp))); +// hash_table_count += @as(usize, @intFromBool(HashTable.isIdentifierStart(cp) or HashTable.isIdentifierPart(cp))); // } // } // hash_table_elapsed += timer.read(); @@ -1946,7 +1946,7 @@ pub const JumpTableInline = struct { // while (iter.nextCodepoint()) |cp| { // jump_table_count += @as( // usize, -// @boolToInt(JumpTable.isIdentifierStart(cp) or JumpTable.isIdentifierPart(cp)), +// @intFromBool(JumpTable.isIdentifierStart(cp) or JumpTable.isIdentifierPart(cp)), // ); // } // } @@ -1963,7 +1963,7 @@ pub const JumpTableInline = struct { // while (iter.nextCodepoint()) |cp| { // binary_search_count += @as( // usize, -// @boolToInt( +// @intFromBool( // BinarySearch.isIdentifierStart( // cp, // ) or BinarySearch.isIdentifierPart( @@ -1986,7 +1986,7 @@ pub const JumpTableInline = struct { // while (iter.nextCodepoint()) |cp| { // bitset_count += @as( // usize, -// @boolToInt( +// @intFromBool( // Bitset.isIdentifierStart( // cp, // ) or Bitset.isIdentifierPart( diff --git a/src/js_lexer_tables.zig b/src/js_lexer_tables.zig index dcf04573f..8256ff79d 100644 --- a/src/js_lexer_tables.zig +++ b/src/js_lexer_tables.zig @@ -136,11 +136,11 @@ pub const T = enum(u8) { t_with, pub fn isAssign(self: T) bool { - return @enumToInt(self) >= @enumToInt(T.t_ampersand_ampersand_equals) and @enumToInt(self) <= @enumToInt(T.t_slash_equals); + return @intFromEnum(self) >= @intFromEnum(T.t_ampersand_ampersand_equals) and @intFromEnum(self) <= @intFromEnum(T.t_slash_equals); } pub fn isReservedWord(self: T) bool { - return @enumToInt(self) >= @enumToInt(T.t_break) and @enumToInt(self) <= @enumToInt(T.t_with); + return @intFromEnum(self) >= @intFromEnum(T.t_break) and @intFromEnum(self) <= @intFromEnum(T.t_with); } pub fn isString(self: T) bool { @@ -155,7 +155,7 @@ pub const T = enum(u8) { } pub fn isCloseBraceOrEOF(self: T) bool { - return @enumToInt(self) <= @enumToInt(T.t_close_brace); + return @intFromEnum(self) <= @intFromEnum(T.t_close_brace); } }; @@ -842,4 +842,3 @@ test "tokenToString" { // expect(v == 0x223C); // } // } - diff --git a/src/js_parser.zig b/src/js_parser.zig index 33a8cef6d..28bd4aa0b 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -965,7 +965,7 @@ pub const ImportScanner = struct { } p.named_imports.ensureUnusedCapacity( - st.items.len + @as(usize, @boolToInt(st.default_name != null)) + @as(usize, @boolToInt(st.star_name_loc != null)), + st.items.len + @as(usize, @intFromBool(st.default_name != null)) + @as(usize, @intFromBool(st.star_name_loc != null)), ) catch unreachable; if (st.star_name_loc) |loc| { @@ -1354,7 +1354,7 @@ const StaticSymbolName = struct { pub const List = struct { fn NewStaticSymbol(comptime basename: string) StaticSymbolName { - const hash_value = std.hash.Wyhash.hash(0, basename); + const hash_value = bun.hash(basename); return comptime StaticSymbolName{ .internal = basename ++ "_" ++ std.fmt.comptimePrint("{any}", .{bun.fmt.hexIntLower(hash_value)}), .primary = basename, @@ -1363,7 +1363,7 @@ const StaticSymbolName = struct { } fn NewStaticSymbolWithBackup(comptime basename: string, comptime backup: string) StaticSymbolName { - const hash_value = std.hash.Wyhash.hash(0, basename); + const hash_value = bun.hash(basename); return comptime StaticSymbolName{ .internal = basename ++ "_" ++ std.fmt.comptimePrint("{any}", .{bun.fmt.hexIntLower(hash_value)}), .primary = basename, @@ -1555,7 +1555,7 @@ pub const SideEffects = enum(u1) { // can be removed. The annotation causes us to ignore the target. if (call.can_be_unwrapped_if_unused) { if (call.args.len > 0) { - return Expr.joinAllWithCommaCallback(call.args.slice(), @TypeOf(p), p, simpifyUnusedExpr, p.allocator); + return Expr.joinAllWithCommaCallback(call.args.slice(), @TypeOf(p), p, comptime simpifyUnusedExpr, p.allocator); } } }, @@ -1683,7 +1683,7 @@ pub const SideEffects = enum(u1) { items, @TypeOf(p), p, - simpifyUnusedExpr, + comptime simpifyUnusedExpr, p.allocator, ); }, @@ -1697,7 +1697,7 @@ pub const SideEffects = enum(u1) { call.args.slice(), @TypeOf(p), p, - simpifyUnusedExpr, + comptime simpifyUnusedExpr, p.allocator, ); } @@ -3022,7 +3022,7 @@ pub const Parser = struct { const uses_filename = p.symbols.items[p.filename_ref.innerIndex()].use_count_estimate > 0; if (uses_dirname or uses_filename) { - const count = @as(usize, @boolToInt(uses_dirname)) + @as(usize, @boolToInt(uses_filename)); + const count = @as(usize, @intFromBool(uses_dirname)) + @as(usize, @intFromBool(uses_filename)); var declared_symbols = DeclaredSymbol.List.initCapacity(p.allocator, count) catch unreachable; var decls = p.allocator.alloc(G.Decl, count) catch unreachable; if (uses_dirname) { @@ -3037,7 +3037,7 @@ pub const Parser = struct { declared_symbols.appendAssumeCapacity(.{ .ref = p.dirname_ref, .is_top_level = true }); } if (uses_filename) { - decls[@as(usize, @boolToInt(uses_dirname))] = .{ + decls[@as(usize, @intFromBool(uses_dirname))] = .{ .binding = p.b(B.Identifier{ .ref = p.filename_ref }, logger.Loc.Empty), .value = p.newExpr( E.String.init(p.source.path.text), @@ -3113,7 +3113,7 @@ pub const Parser = struct { if (p.options.module_type == .esm and p.has_es_module_syntax) { var needs_decl_count: usize = 0; for (export_refs) |*export_ref| { - needs_decl_count += @as(usize, @boolToInt(export_ref.needs_decl)); + needs_decl_count += @as(usize, @intFromBool(export_ref.needs_decl)); } if (needs_decl_count == export_names.len) { @@ -3483,7 +3483,7 @@ pub const Parser = struct { const items_count = brk: { var count: usize = 0; inline for (comptime std.meta.fieldNames(Jest)) |symbol_name| { - count += @boolToInt(p.symbols.items[@field(jest, symbol_name).innerIndex()].use_count_estimate > 0); + count += @intFromBool(p.symbols.items[@field(jest, symbol_name).innerIndex()].use_count_estimate > 0); } break :brk count; @@ -3611,21 +3611,21 @@ pub const Parser = struct { // const decls_count: u32 = // // "REACT_ELEMENT_TYPE" // // "Symbol.for('react.element')" - // @intCast(u32, @boolToInt(react_element_symbol.use_count_estimate > 0)) * 2 + + // @intCast(u32, @intFromBool(react_element_symbol.use_count_estimate > 0)) * 2 + // // "JSX" - // @intCast(u32, @boolToInt(jsx_symbol.use_count_estimate > 0)) * 2 + - // @intCast(u32, @boolToInt(FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0)) * 2 + - // @intCast(u32, @boolToInt(jsx_factory_symbol.use_count_estimate > 0)) + - // @intCast(u32, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0)); - // // @intCast(u32, @boolToInt(jsx_filename_symbol.use_count_estimate > 0)); + // @intCast(u32, @intFromBool(jsx_symbol.use_count_estimate > 0)) * 2 + + // @intCast(u32, @intFromBool(FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0)) * 2 + + // @intCast(u32, @intFromBool(jsx_factory_symbol.use_count_estimate > 0)) + + // @intCast(u32, @intFromBool(jsx_fragment_symbol.use_count_estimate > 0)); + // // @intCast(u32, @intFromBool(jsx_filename_symbol.use_count_estimate > 0)); // const imports_count = - // @intCast(u32, @boolToInt(jsx_symbol.use_count_estimate > 0)) + - // @intCast(u32, @boolToInt(jsx_classic_symbol.use_count_estimate > 0)) + - // @intCast(u32, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0)) + - // @intCast(u32, @boolToInt(p.options.features.react_fast_refresh)) + - // @intCast(u32, @boolToInt(FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0)); + // @intCast(u32, @intFromBool(jsx_symbol.use_count_estimate > 0)) + + // @intCast(u32, @intFromBool(jsx_classic_symbol.use_count_estimate > 0)) + + // @intCast(u32, @intFromBool(jsx_fragment_symbol.use_count_estimate > 0)) + + // @intCast(u32, @intFromBool(p.options.features.react_fast_refresh)) + + // @intCast(u32, @intFromBool(FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0)); // const stmts_count = imports_count + 1; // const symbols_count: u32 = imports_count + decls_count; // const loc = logger.Loc{ .start = 0 }; @@ -3989,7 +3989,7 @@ pub const Parser = struct { // // inject // // var jsxFrag = // if (jsx_fragment_symbol.use_count_estimate + jsx_factory_symbol.use_count_estimate > 0) { - // const total = @as(usize, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0)) + @as(usize, @boolToInt(jsx_factory_symbol.use_count_estimate > 0)); + // const total = @as(usize, @intFromBool(jsx_fragment_symbol.use_count_estimate > 0)) + @as(usize, @intFromBool(jsx_factory_symbol.use_count_estimate > 0)); // var declared_symbols = DeclaredSymbol.List{}; // try declared_symbols.ensureTotalCapacity(p.allocator, total); // var decls = try std.ArrayList(G.Decl).initCapacity(p.allocator, total); @@ -4206,7 +4206,7 @@ pub const Parser = struct { i += 1; } - std.sort.sort( + std.sort.block( u8, runtime_imports[0..i], {}, @@ -5214,10 +5214,7 @@ fn NewParser_( const symbol_name = p.import_records.items[import_record_index].path.name.nonUniqueNameString(p.allocator) catch unreachable; const hash_value = @truncate( u16, - std.hash.Wyhash.hash( - 0, - p.import_records.items[import_record_index].path.text, - ), + bun.hash(p.import_records.items[import_record_index].path.text), ); const cjs_import_name = std.fmt.allocPrint( @@ -6901,7 +6898,7 @@ fn NewParser_( // Output.print("\n+Loc: {d}\n", .{loc.start}); // for (p.scopes_in_order.items[p.scopes_in_order_visitor_index..p.scopes_in_order.items.len]) |scope_order, i| { // if (scope_order) |ord| { - // Output.print("Scope ({d}, {d})\n", .{ @enumToInt(ord.scope.kind), ord.loc.start }); + // Output.print("Scope ({d}, {d})\n", .{ @intFromEnum(ord.scope.kind), ord.loc.start }); // } // } const order = p.nextScopeInOrderForVisitPass(); @@ -8217,7 +8214,7 @@ fn NewParser_( var item_refs = ImportItemForNamespaceMap.init(p.allocator); const count_excluding_namespace = @intCast(u16, stmt.items.len) + - @intCast(u16, @boolToInt(stmt.default_name != null)); + @intCast(u16, @intFromBool(stmt.default_name != null)); try item_refs.ensureUnusedCapacity(count_excluding_namespace); // Even though we allocate ahead of time here @@ -8328,7 +8325,7 @@ fn NewParser_( return p.s(S.Empty{}, loc); } else if (remap_count > 0) { - item_refs.shrinkAndFree(stmt.items.len + @as(usize, @boolToInt(stmt.default_name != null))); + item_refs.shrinkAndFree(stmt.items.len + @as(usize, @intFromBool(stmt.default_name != null))); } // Track the items for this namespace @@ -11518,8 +11515,8 @@ fn NewParser_( } } - if (@ptrToInt(p.source.contents.ptr) <= @ptrToInt(name.ptr) and (@ptrToInt(name.ptr) + name.len) <= (@ptrToInt(p.source.contents.ptr) + p.source.contents.len)) { - const start = Ref.toInt(@ptrToInt(name.ptr) - @ptrToInt(p.source.contents.ptr)); + if (@intFromPtr(p.source.contents.ptr) <= @intFromPtr(name.ptr) and (@intFromPtr(name.ptr) + name.len) <= (@intFromPtr(p.source.contents.ptr) + p.source.contents.len)) { + const start = Ref.toInt(@intFromPtr(name.ptr) - @intFromPtr(p.source.contents.ptr)); const end = Ref.toInt(name.len); return Ref.initSourceEnd(.{ .source_index = start, .inner_index = end, .tag = .source_contents_slice }); } else { @@ -11805,7 +11802,7 @@ fn NewParser_( // to the expression "a().b()". if (had_pure_comment_before and level.lt(.call)) { - expr = try p.parseSuffix(expr, @intToEnum(Level, @enumToInt(Level.call) - 1), errors, flags); + expr = try p.parseSuffix(expr, @enumFromInt(Level, @intFromEnum(Level.call) - 1), errors, flags); switch (expr.data) { .e_call => |ex| { ex.can_be_unwrapped_if_unused = true; @@ -12996,7 +12993,7 @@ fn NewParser_( } try p.lexer.next(); - left = p.newExpr(E.Binary{ .op = .bin_add_assign, .left = left, .right = try p.parseExpr(@intToEnum(Op.Level, @enumToInt(Op.Level.assign) - 1)) }, left.loc); + left = p.newExpr(E.Binary{ .op = .bin_add_assign, .left = left, .right = try p.parseExpr(@enumFromInt(Op.Level, @intFromEnum(Op.Level.assign) - 1)) }, left.loc); }, .t_minus => { if (level.gte(.add)) { @@ -13474,7 +13471,7 @@ fn NewParser_( pub fn parsePrefix(p: *P, level: Level, errors: ?*DeferredErrors, flags: Expr.EFlags) anyerror!Expr { const loc = p.lexer.loc(); - const l = @enumToInt(level); + const l = @intFromEnum(level); // Output.print("Parse Prefix {s}:{s} @{s} ", .{ p.lexer.token, p.lexer.raw(), @tagName(level) }); switch (p.lexer.token) { @@ -13484,7 +13481,7 @@ fn NewParser_( switch (p.lexer.token) { .t_open_paren => { - if (l < @enumToInt(Level.call) and p.fn_or_arrow_data_parse.allow_super_call) { + if (l < @intFromEnum(Level.call) and p.fn_or_arrow_data_parse.allow_super_call) { return p.newExpr(E.Super{}, loc); } }, @@ -14239,7 +14236,7 @@ fn NewParser_( // Use NextInsideJSXElement() not Next() so we can parse a JSX-style string literal try p.lexer.nextInsideJSXElement(); if (p.lexer.token == .t_string_literal) { - previous_string_with_backslash_loc.start = std.math.max(p.lexer.loc().start, p.lexer.previous_backslash_quote_in_jsx.loc.start); + previous_string_with_backslash_loc.start = @max(p.lexer.loc().start, p.lexer.previous_backslash_quote_in_jsx.loc.start); const expr = p.newExpr(p.lexer.toEString(), previous_string_with_backslash_loc.*); try p.lexer.nextInsideJSXElement(); @@ -15155,7 +15152,7 @@ fn NewParser_( var i: usize = 2; args[0] = tag; - const num_props = e_.properties.len + @boolToInt(e_.key != null); + const num_props = e_.properties.len + @intFromBool(e_.key != null); if (num_props > 0) { var props = p.allocator.alloc(G.Property, num_props) catch unreachable; bun.copy(G.Property, props, e_.properties.slice()); @@ -15170,7 +15167,7 @@ fn NewParser_( const children_elements = e_.children.slice()[0..children_count]; for (children_elements) |child| { args[i] = p.visitExpr(child); - i += @intCast(usize, @boolToInt(args[i].data != .e_missing)); + i += @intCast(usize, @intFromBool(args[i].data != .e_missing)); } const target = p.jsxStringsToMemberExpression(expr.loc, p.options.jsx.factory) catch unreachable; @@ -15201,7 +15198,7 @@ fn NewParser_( for (children) |child| { e_.children.ptr[last_child] = p.visitExpr(child); // if tree-shaking removes the element, we must also remove it here. - last_child += @intCast(u32, @boolToInt(e_.children.ptr[last_child].data != .e_missing)); + last_child += @intCast(u32, @intFromBool(e_.children.ptr[last_child].data != .e_missing)); } e_.children.len = last_child; } @@ -15374,7 +15371,7 @@ fn NewParser_( // Either: // jsxDEV(type, arguments, key, isStaticChildren, source, self) // jsx(type, arguments, key) - const args = p.allocator.alloc(Expr, if (p.options.jsx.development) @as(usize, 6) else @as(usize, 2) + @as(usize, @boolToInt(e_.key != null))) catch unreachable; + const args = p.allocator.alloc(Expr, if (p.options.jsx.development) @as(usize, 6) else @as(usize, 2) + @as(usize, @intFromBool(e_.key != null))) catch unreachable; args[0] = tag; args[1] = p.newExpr(E.Object{ @@ -15838,7 +15835,7 @@ fn NewParser_( // TODO: // if (p.should_fold_typescript_constant_expressions) { // if (Expr.extractNumericValues(e_.left.data, e_.right.data)) |vals| { - // return p.newExpr(E.Number{ .value = ((@floatToInt(i32, vals[0]) << @floatToInt(u32, vals[1])) & 31) }, expr.loc); + // return p.newExpr(E.Number{ .value = ((@intFromFloat(i32, vals[0]) << @intFromFloat(u32, vals[1])) & 31) }, expr.loc); // } // } }, @@ -15846,7 +15843,7 @@ fn NewParser_( // TODO: // if (p.should_fold_typescript_constant_expressions) { // if (Expr.extractNumericValues(e_.left.data, e_.right.data)) |vals| { - // return p.newExpr(E.Number{ .value = ((@floatToInt(i32, vals[0]) >> @floatToInt(u32, vals[1])) & 31) }, expr.loc); + // return p.newExpr(E.Number{ .value = ((@intFromFloat(i32, vals[0]) >> @intFromFloat(u32, vals[1])) & 31) }, expr.loc); // } // } }, @@ -15854,7 +15851,7 @@ fn NewParser_( // TODO: // if (p.should_fold_typescript_constant_expressions) { // if (Expr.extractNumericValues(e_.left.data, e_.right.data)) |vals| { - // return p.newExpr(E.Number{ .value = ((@floatToInt(i32, vals[0]) >> @floatToInt(u32, vals[1])) & 31) }, expr.loc); + // return p.newExpr(E.Number{ .value = ((@intFromFloat(i32, vals[0]) >> @intFromFloat(u32, vals[1])) & 31) }, expr.loc); // } // } }, @@ -15862,7 +15859,7 @@ fn NewParser_( // TODO: // if (p.should_fold_typescript_constant_expressions) { // if (Expr.extractNumericValues(e_.left.data, e_.right.data)) |vals| { - // return p.newExpr(E.Number{ .value = ((@floatToInt(i32, vals[0]) >> @floatToInt(u32, vals[1])) & 31) }, expr.loc); + // return p.newExpr(E.Number{ .value = ((@intFromFloat(i32, vals[0]) >> @intFromFloat(u32, vals[1])) & 31) }, expr.loc); // } // } }, @@ -15870,7 +15867,7 @@ fn NewParser_( // TODO: // if (p.should_fold_typescript_constant_expressions) { // if (Expr.extractNumericValues(e_.left.data, e_.right.data)) |vals| { - // return p.newExpr(E.Number{ .value = ((@floatToInt(i32, vals[0]) >> @floatToInt(u32, vals[1])) & 31) }, expr.loc); + // return p.newExpr(E.Number{ .value = ((@intFromFloat(i32, vals[0]) >> @intFromFloat(u32, vals[1])) & 31) }, expr.loc); // } // } }, @@ -15878,7 +15875,7 @@ fn NewParser_( // TODO: // if (p.should_fold_typescript_constant_expressions) { // if (Expr.extractNumericValues(e_.left.data, e_.right.data)) |vals| { - // return p.newExpr(E.Number{ .value = ((@floatToInt(i32, vals[0]) >> @floatToInt(u32, vals[1])) & 31) }, expr.loc); + // return p.newExpr(E.Number{ .value = ((@intFromFloat(i32, vals[0]) >> @intFromFloat(u32, vals[1])) & 31) }, expr.loc); // } // } }, @@ -17757,7 +17754,7 @@ fn NewParser_( if (p.options.features.minify_syntax) { // minify "long-string".length to 11 if (strings.eqlComptime(name, "length")) { - return p.newExpr(E.Number{ .value = @intToFloat(f64, str.javascriptLength()) }, loc); + return p.newExpr(E.Number{ .value = @floatFromInt(f64, str.javascriptLength()) }, loc); } } }, @@ -19457,7 +19454,7 @@ fn NewParser_( for (arg.ts_decorators.ptr[0..arg.ts_decorators.len]) |arg_decorator| { var decorators = if (is_constructor) class.ts_decorators.listManaged(p.allocator) else prop.ts_decorators.listManaged(p.allocator); const args = p.allocator.alloc(Expr, 2) catch unreachable; - args[0] = p.newExpr(E.Number{ .value = @intToFloat(f64, i) }, arg_decorator.loc); + args[0] = p.newExpr(E.Number{ .value = @floatFromInt(f64, i) }, arg_decorator.loc); args[1] = arg_decorator; decorators.append(p.callRuntime(arg_decorator.loc, "__decorateParam", args)) catch unreachable; if (is_constructor) { @@ -20088,7 +20085,7 @@ fn NewParser_( if (constructor_function) |constructor| { var to_add: usize = 0; for (constructor.func.args) |arg| { - to_add += @boolToInt(arg.is_typescript_ctor_field and arg.binding.data == .b_identifier); + to_add += @intFromBool(arg.is_typescript_ctor_field and arg.binding.data == .b_identifier); } // if this is an expression, we can move statements after super() because there will be 0 decorators @@ -20368,7 +20365,7 @@ fn NewParser_( } before.items.len = 0; - before.ensureUnusedCapacity(@as(usize, @boolToInt(let_decls.items.len > 0)) + @as(usize, @boolToInt(var_decls.items.len > 0)) + non_fn_stmts.items.len) catch unreachable; + before.ensureUnusedCapacity(@as(usize, @intFromBool(let_decls.items.len > 0)) + @as(usize, @intFromBool(var_decls.items.len > 0)) + non_fn_stmts.items.len) catch unreachable; if (let_decls.items.len > 0) { before.appendAssumeCapacity(p.s( @@ -20994,7 +20991,7 @@ fn NewParser_( // } const bundling = p.options.bundle; - var parts_end: usize = @as(usize, @boolToInt(bundling)); + var parts_end: usize = @as(usize, @intFromBool(bundling)); // Handle import paths after the whole file has been visited because we need // symbol usage counts to be able to remove unused type-only imports in // TypeScript code. @@ -21371,7 +21368,7 @@ fn NewParser_( // We still call exportAll just with an empty object. const has_any_exports = named_exports_count > 0; - const toplevel_stmts_count = 3 + (@intCast(usize, @boolToInt(has_any_exports)) * 2); + const toplevel_stmts_count = 3 + (@intCast(usize, @intFromBool(has_any_exports)) * 2); var _stmts = allocator.alloc( Stmt, end_iife_stmts_count + toplevel_stmts_count + (named_exports_count * 2) + imports_count + exports_from_count, @@ -21384,7 +21381,7 @@ fn NewParser_( // in release: print ";" instead. // this should never happen regardless, but i'm just being cautious here. if (comptime !Environment.isDebug) { - std.mem.set(Stmt, _stmts, Stmt.empty()); + @memset(_stmts, Stmt.empty()); } // Second pass: move any imports from the part's stmts array to the new stmts @@ -21430,7 +21427,7 @@ fn NewParser_( var new_call_args = call_args[0..new_call_args_count]; var hmr_module_ident = p.newExpr(E.Identifier{ .ref = p.hmr_module.ref }, logger.Loc.Empty); - new_call_args[0] = p.newExpr(E.Number{ .value = @intToFloat(f64, p.options.filepath_hash_for_hmr) }, logger.Loc.Empty); + new_call_args[0] = p.newExpr(E.Number{ .value = @floatFromInt(f64, p.options.filepath_hash_for_hmr) }, logger.Loc.Empty); // This helps us provide better error messages new_call_args[1] = p.newExpr(E.String{ .data = p.source.path.pretty }, logger.Loc.Empty); if (p.options.features.react_fast_refresh) { diff --git a/src/js_printer.zig b/src/js_printer.zig index 1613500a1..913aaded3 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -741,7 +741,7 @@ fn NewPrinter( pub fn writeByteNTimes(self: *Printer, byte: u8, n: usize) !void { var bytes: [256]u8 = undefined; - std.mem.set(u8, bytes[0..], byte); + @memset(bytes[0..], byte); var remaining: usize = n; while (remaining > 0) { @@ -1333,7 +1333,7 @@ fn NewPrinter( // In JavaScript, numbers are represented as 64 bit floats // However, they could also be signed or unsigned int 32 (when doing bit shifts) // In this case, it's always going to unsigned since that conversion has already happened. - const val = @floatToInt(u64, float); + const val = @intFromFloat(u64, float); switch (val) { 0 => { p.print("0"); @@ -2395,7 +2395,7 @@ fn NewPrinter( // This is more efficient than creating a new Part just for the JSX auto imports when bundling if (comptime rewrite_esm_to_cjs) { - if (@ptrToInt(p.options.prepend_part_key) > 0 and @ptrToInt(e.body.stmts.ptr) == @ptrToInt(p.options.prepend_part_key)) { + if (@intFromPtr(p.options.prepend_part_key) > 0 and @intFromPtr(e.body.stmts.ptr) == @intFromPtr(p.options.prepend_part_key)) { p.printTwoBlocksInOne(e.body.loc, e.body.stmts, p.options.prepend_part_value.?.stmts); wasPrinted = true; } @@ -2527,7 +2527,7 @@ fn NewPrinter( p.print("{"); const props = expr.data.e_object.properties.slice(); if (props.len > 0) { - p.options.indent += @as(usize, @boolToInt(!e.is_single_line)); + p.options.indent += @as(usize, @intFromBool(!e.is_single_line)); if (e.is_single_line) { p.printSpace(); @@ -3465,7 +3465,7 @@ fn NewPrinter( .b_array => |b| { p.print("["); if (b.items.len > 0) { - p.options.indent += @as(usize, @boolToInt(!b.is_single_line)); + p.options.indent += @as(usize, @intFromBool(!b.is_single_line)); for (b.items, 0..) |*item, i| { if (i != 0) { @@ -3508,7 +3508,7 @@ fn NewPrinter( p.print("{"); if (b.properties.len > 0) { p.options.indent += - @as(usize, @boolToInt(!b.is_single_line)); + @as(usize, @intFromBool(!b.is_single_line)); for (b.properties, 0..) |*property, i| { if (i != 0) { @@ -5561,13 +5561,13 @@ pub const BufferWriter = struct { } pub fn writeByte(ctx: *BufferWriter, byte: u8) anyerror!usize { try ctx.buffer.appendChar(byte); - ctx.approximate_newline_count += @boolToInt(byte == '\n'); + ctx.approximate_newline_count += @intFromBool(byte == '\n'); ctx.last_bytes = .{ ctx.last_bytes[1], byte }; return 1; } pub fn writeAll(ctx: *BufferWriter, bytes: anytype) anyerror!usize { try ctx.buffer.append(bytes); - ctx.approximate_newline_count += @boolToInt(bytes.len > 0 and bytes[bytes.len - 1] == '\n'); + ctx.approximate_newline_count += @intFromBool(bytes.len > 0 and bytes[bytes.len - 1] == '\n'); if (bytes.len >= 2) { ctx.last_bytes = bytes[bytes.len - 2 ..][0..2].*; @@ -5779,7 +5779,7 @@ pub fn printAst( } } - std.sort.sort(rename.StableSymbolCount, top_level_symbols.items, {}, rename.StableSymbolCount.lessThan); + std.sort.block(rename.StableSymbolCount, top_level_symbols.items, {}, rename.StableSymbolCount.lessThan); try minify_renamer.allocateTopLevelSymbolSlots(top_level_symbols); var minifier = tree.char_freq.?.compile(allocator); @@ -5861,9 +5861,9 @@ pub fn printJSON( var stmt = Stmt{ .loc = logger.Loc.Empty, .data = .{ .s_expr = &s_expr, } }; - var stmts = &[_]js_ast.Stmt{stmt}; - var parts = &[_]js_ast.Part{.{ .stmts = stmts }}; - const ast = Ast.initTest(parts); + var stmts = [_]js_ast.Stmt{stmt}; + var parts = [_]js_ast.Part{.{ .stmts = &stmts }}; + const ast = Ast.initTest(&parts); var list = js_ast.Symbol.List.init(ast.symbols.slice()); var nested_list = js_ast.Symbol.NestedList.init(&[_]js_ast.Symbol.List{list}); var renamer = rename.NoOpRenamer.init(js_ast.Symbol.Map.initList(nested_list), source); diff --git a/src/json_parser.zig b/src/json_parser.zig index 913a16bd6..c7dd74943 100644 --- a/src/json_parser.zig +++ b/src/json_parser.zig @@ -542,7 +542,7 @@ pub fn toAST( return Expr{ .data = .{ .e_number = .{ - .value = @intToFloat(f64, value), + .value = @floatFromInt(f64, value), }, }, .loc = logger.Loc{}, @@ -626,7 +626,7 @@ pub fn toAST( } }, .Enum => { - _ = std.meta.intToEnum(Type, @enumToInt(value)) catch { + _ = std.meta.intToEnum(Type, @intFromEnum(value)) catch { return Expr{ .data = .{ .e_null = .{} }, .loc = logger.Loc{} }; }; diff --git a/src/libarchive/libarchive.zig b/src/libarchive/libarchive.zig index ebaec7dd7..c2948fd28 100644 --- a/src/libarchive/libarchive.zig +++ b/src/libarchive/libarchive.zig @@ -264,7 +264,7 @@ pub const BufferReadStream = struct { const remaining = this.bufLeft(); if (remaining.len == 0) return 0; - const diff = std.math.min(remaining.len, this.block_size); + const diff = @min(remaining.len, this.block_size); buffer.* = remaining[0..diff].ptr; this.pos += diff; return @intCast(isize, diff); @@ -281,7 +281,7 @@ pub const BufferReadStream = struct { const pos = @intCast(isize, this.pos); const proposed = pos + offset; - const new_pos = std.math.min(std.math.max(proposed, 0), buflen - 1); + const new_pos = @min(@max(proposed, 0), buflen - 1); this.pos = @intCast(usize, this.pos); return new_pos - pos; } @@ -297,19 +297,19 @@ pub const BufferReadStream = struct { const buflen = @intCast(isize, this.buf.len); const pos = @intCast(isize, this.pos); - switch (@intToEnum(Seek, whence)) { + switch (@enumFromInt(Seek, whence)) { Seek.current => { - const new_pos = std.math.max(std.math.min(pos + offset, buflen - 1), 0); + const new_pos = @max(@min(pos + offset, buflen - 1), 0); this.pos = @intCast(usize, new_pos); return new_pos; }, Seek.end => { - const new_pos = std.math.max(std.math.min(buflen - offset, buflen), 0); + const new_pos = @max(@min(buflen - offset, buflen), 0); this.pos = @intCast(usize, new_pos); return new_pos; }, Seek.set => { - const new_pos = std.math.max(std.math.min(offset, buflen - 1), 0); + const new_pos = @max(@min(offset, buflen - 1), 0); this.pos = @intCast(usize, new_pos); return new_pos; }, @@ -379,7 +379,7 @@ pub const Archive = struct { pub fn init(filepath: string, estimated_size: usize, allocator: std.mem.Allocator) !Plucker { return Plucker{ .contents = try MutableString.init(allocator, estimated_size), - .filename_hash = std.hash.Wyhash.hash(0, filepath), + .filename_hash = bun.hash(filepath), .fd = 0, .found = false, }; @@ -413,7 +413,7 @@ pub const Archive = struct { }; loop: while (true) { - const r = @intToEnum(Status, lib.archive_read_next_header(archive, &entry)); + const r = @enumFromInt(Status, lib.archive_read_next_header(archive, &entry)); switch (r) { Status.eof => break :loop, @@ -434,7 +434,7 @@ pub const Archive = struct { pathname = std.mem.sliceTo(pathname_.ptr[0..pathname_.len :0], 0); const dirname = std.mem.trim(u8, std.fs.path.dirname(bun.asByteSlice(pathname)) orelse "", std.fs.path.sep_str); - const size = @intCast(usize, std.math.max(lib.archive_entry_size(entry), 0)); + const size = @intCast(usize, @max(lib.archive_entry_size(entry), 0)); if (size > 0) { var opened = dir.dir.openFileZ(pathname, .{ .mode = .write_only }) catch continue :loop; var stat = try opened.stat(); @@ -490,7 +490,7 @@ pub const Archive = struct { const dir_fd = dir.fd; loop: while (true) { - const r = @intToEnum(Status, lib.archive_read_next_header(archive, &entry)); + const r = @enumFromInt(Status, lib.archive_read_next_header(archive, &entry)); switch (r) { Status.eof => break :loop, @@ -513,7 +513,7 @@ pub const Archive = struct { } var pathname_ = tokenizer.rest(); - pathname = @intToPtr([*]const u8, @ptrToInt(pathname_.ptr))[0..pathname_.len :0]; + pathname = @ptrFromInt([*]const u8, @intFromPtr(pathname_.ptr))[0..pathname_.len :0]; if (pathname.len == 0) continue; const kind = C.kindFromMode(lib.archive_entry_filetype(entry)); @@ -527,7 +527,7 @@ pub const Archive = struct { count += 1; switch (kind) { - Kind.Directory => { + Kind.directory => { var mode = @intCast(i32, lib.archive_entry_perm(entry)); // if dirs are readable, then they should be listable @@ -545,7 +545,7 @@ pub const Archive = struct { try std.os.mkdiratZ(dir_fd, pathname, 0o777); }; }, - Kind.SymLink => { + Kind.sym_link => { const link_target = lib.archive_entry_symlink(entry).?; std.os.symlinkatZ(link_target, dir_fd, pathname) catch |err| brk: { @@ -560,7 +560,7 @@ pub const Archive = struct { } }; }, - Kind.File => { + Kind.file => { const mode = @intCast(std.os.mode_t, lib.archive_entry_perm(entry)); const file = dir.createFileZ(pathname, .{ .truncate = true, .mode = mode }) catch |err| brk: { switch (err) { @@ -583,7 +583,7 @@ pub const Archive = struct { if (size > 0) { if (ctx) |ctx_| { const hash: u64 = if (ctx_.pluckers.len > 0) - std.hash.Wyhash.hash(0, slice) + bun.hash(slice) else @as(u64, 0); diff --git a/src/linear_fifo.zig b/src/linear_fifo.zig index 66d579fdc..b73f21ce9 100644 --- a/src/linear_fifo.zig +++ b/src/linear_fifo.zig @@ -100,7 +100,7 @@ pub fn LinearFifo( var tmp: [mem.page_size / 2 / @sizeOf(T)]T = undefined; while (self.head != 0) { - const n = math.min(self.head, tmp.len); + const n = @min(self.head, tmp.len); const m = self.buf.len - n; bun.copy(T, tmp[0..n], self.buf[0..n]); // this middle copy overlaps; the others here don't @@ -111,7 +111,7 @@ pub fn LinearFifo( } { // set unused area to undefined const unused = mem.sliceAsBytes(self.buf[self.count..]); - @memset(unused.ptr, undefined, unused.len); + @memset(unused, undefined); } } @@ -137,7 +137,7 @@ pub fn LinearFifo( if (self.count > 0) { var new_bytes = std.mem.sliceAsBytes(buf); var old_bytes = std.mem.sliceAsBytes(self.readableSlice(0)); - @memcpy(new_bytes.ptr, old_bytes.ptr, old_bytes.len); + @memcpy(new_bytes[0..old_bytes.len], old_bytes); self.allocator.free(self.buf); } self.head = 0; @@ -168,7 +168,7 @@ pub fn LinearFifo( start -= self.buf.len; return self.buf[start .. start + (self.count - offset)]; } else { - const end = math.min(self.head + self.count, self.buf.len); + const end = @min(self.head + self.count, self.buf.len); return self.buf[start..end]; } } @@ -187,12 +187,12 @@ pub fn LinearFifo( const slice = self.readableSliceMut(0); if (slice.len >= count) { const unused = mem.sliceAsBytes(slice[0..count]); - @memset(unused.ptr, undefined, unused.len); + @memset(unused, undefined); } else { const unused = mem.sliceAsBytes(slice[0..]); - @memset(unused.ptr, undefined, unused.len); + @memset(unused, undefined); const unused2 = mem.sliceAsBytes(self.readableSliceMut(slice.len)[0 .. count - slice.len]); - @memset(unused2.ptr, undefined, unused2.len); + @memset(unused2, undefined); } } @@ -224,7 +224,7 @@ pub fn LinearFifo( while (dst_left.len > 0) { const slice = self.readableSlice(0); if (slice.len == 0) break; - const n = math.min(slice.len, dst_left.len); + const n = @min(slice.len, dst_left.len); bun.copy(T, dst_left, slice[0..n]); self.discard(n); dst_left = dst_left[n..]; @@ -293,7 +293,7 @@ pub fn LinearFifo( while (src_left.len > 0) { const writable_slice = self.writableSlice(0); assert(writable_slice.len != 0); - const n = math.min(writable_slice.len, src_left.len); + const n = @min(writable_slice.len, src_left.len); bun.copy(T, writable_slice, src_left[0..n]); self.update(n); src_left = src_left[n..]; diff --git a/src/linker.zig b/src/linker.zig index 461bcf808..fa1c504d7 100644 --- a/src/linker.zig +++ b/src/linker.zig @@ -119,7 +119,7 @@ pub const Linker = struct { fd: ?FileDescriptorType, ) !string { if (Bundler.isCacheEnabled) { - var hashed = std.hash.Wyhash.hash(0, file_path.text); + var hashed = bun.hash(file_path.text); var hashed_result = try this.hashed_filenames.getOrPut(hashed); if (hashed_result.found_existing) { return hashed_result.value_ptr.*; @@ -130,7 +130,7 @@ pub const Linker = struct { const hash_name = modkey.hashName(file_path.text); if (Bundler.isCacheEnabled) { - var hashed = std.hash.Wyhash.hash(0, file_path.text); + var hashed = bun.hash(file_path.text); try this.hashed_filenames.put(hashed, try this.allocator.dupe(u8, hash_name)); } @@ -569,7 +569,7 @@ pub const Linker = struct { // But we need to at least tell the printer that this needs to happen. if (loader != .napi and resolved_import.shouldAssumeCommonJS(import_record.kind) and !is_bun) { import_record.do_commonjs_transform_in_printer = true; - import_record.module_id = @truncate(u32, std.hash.Wyhash.hash(0, path.pretty)); + import_record.module_id = @truncate(u32, bun.hash(path.pretty)); } } else |err| { switch (err) { @@ -1043,7 +1043,7 @@ pub const Linker = struct { hash_key = path.text[linker.fs.top_level_dir.len..]; } - return std.hash.Wyhash.hash(0, hash_key); + return bun.hash(hash_key); } pub fn enqueueResolveResult(linker: *ThisLinker, resolve_result: *const Resolver.Result) !bool { diff --git a/src/linux_c.zig b/src/linux_c.zig index dade43a32..12e3c9b73 100644 --- a/src/linux_c.zig +++ b/src/linux_c.zig @@ -148,7 +148,7 @@ pub const SystemErrno = enum(u8) { } if (code >= max) return null; - return @intToEnum(SystemErrno, code); + return @enumFromInt(SystemErrno, code); } pub fn label(this: SystemErrno) ?[]const u8 { @@ -385,9 +385,9 @@ pub fn splice(fd_in: std.os.fd_t, off_in: ?*i64, fd_out: std.os.fd_t, off_out: ? return std.os.linux.syscall6( .splice, @bitCast(usize, @as(isize, fd_in)), - @ptrToInt(off_in), + @intFromPtr(off_in), @bitCast(usize, @as(isize, fd_out)), - @ptrToInt(off_out), + @intFromPtr(off_out), len, flags, ); @@ -438,9 +438,9 @@ pub fn get_system_loadavg() [3]f64 { var info: struct_sysinfo = undefined; if (sysinfo(&info) == @as(c_int, 0)) { return [3]f64{ - std.math.ceil((@intToFloat(f64, info.loads[0]) / 65536.0) * 100.0) / 100.0, - std.math.ceil((@intToFloat(f64, info.loads[1]) / 65536.0) * 100.0) / 100.0, - std.math.ceil((@intToFloat(f64, info.loads[2]) / 65536.0) * 100.0) / 100.0, + std.math.ceil((@floatFromInt(f64, info.loads[0]) / 65536.0) * 100.0) / 100.0, + std.math.ceil((@floatFromInt(f64, info.loads[1]) / 65536.0) * 100.0) / 100.0, + std.math.ceil((@floatFromInt(f64, info.loads[2]) / 65536.0) * 100.0) / 100.0, }; } return [3]f64{ 0, 0, 0 }; diff --git a/src/lock.zig b/src/lock.zig index 66d64cff2..3e07945c8 100644 --- a/src/lock.zig +++ b/src/lock.zig @@ -28,11 +28,12 @@ pub const Mutex = struct { } const cas_fn = comptime switch (strong) { - true => "compareAndSwap", - else => "tryCompareAndSwap", + true => Atomic(u32).compareAndSwap, + else => Atomic(u32).tryCompareAndSwap, }; - return @field(self.state, cas_fn)( + return cas_fn( + &self.state, UNLOCKED, LOCKED, .Acquire, diff --git a/src/logger.zig b/src/logger.zig index ad7a9b333..621e643b5 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -180,7 +180,7 @@ pub const Location = struct { var data = source.initErrorPosition(r.loc); var full_line = source.contents[data.line_start..data.line_end]; if (full_line.len > 80 + data.column_count) { - full_line = full_line[std.math.max(data.column_count, 40) - 40 .. std.math.min(data.column_count + 40, full_line.len - 40) + 40]; + full_line = full_line[@max(data.column_count, 40) - 40 .. @min(data.column_count + 40, full_line.len - 40) + 40]; } bun.assertDefined(source.path.text); @@ -194,7 +194,7 @@ pub const Location = struct { .column = usize2Loc(data.column_count).start, .length = full_line.len, .line_text = full_line, - .offset = @intCast(usize, std.math.max(r.loc.start, 0)), + .offset = @intCast(usize, @max(r.loc.start, 0)), }; } else { return null; @@ -293,7 +293,7 @@ pub const Data = struct { if (location.line_text) |line_text_| { const line_text = std.mem.trimRight(u8, line_text_, "\r\n\t"); - const location_in_line_text = @intCast(u32, std.math.max(location.column, 1) - 1); + const location_in_line_text = @intCast(u32, @max(location.column, 1) - 1); const has_position = location.column > -1 and line_text.len > 0 and location_in_line_text < line_text.len; if (has_position) { @@ -650,8 +650,8 @@ pub const Log = struct { var warnings: u32 = 0; var errors: u32 = 0; for (this.msgs.items) |msg| { - errors += @intCast(u32, @boolToInt(msg.kind == .err)); - warnings += @intCast(u32, @boolToInt(msg.kind == .warn)); + errors += @intCast(u32, @intFromBool(msg.kind == .err)); + warnings += @intCast(u32, @intFromBool(msg.kind == .warn)); } return Api.Log{ @@ -669,7 +669,7 @@ pub const Log = struct { err, pub fn atLeast(this: Level, other: Level) bool { - return @enumToInt(this) <= @enumToInt(other); + return @intFromEnum(this) <= @intFromEnum(other); } pub const label: std.EnumArray(Level, string) = brk: { @@ -760,7 +760,7 @@ pub const Log = struct { const msg: Msg = msg_; if (msg.notes) |notes| { for (notes) |note| { - notes_count += @intCast(usize, @boolToInt(note.text.len > 0)); + notes_count += @intCast(usize, @intFromBool(note.text.len > 0)); } } } @@ -1372,7 +1372,7 @@ pub const Source = struct { pub fn initErrorPosition(self: *const Source, _offset: Loc) ErrorPosition { var prev_code_point: i32 = 0; - var offset: usize = std.math.min(if (_offset.start < 0) 0 else @intCast(usize, _offset.start), @max(self.contents.len, 1) - 1); + var offset: usize = @min(if (_offset.start < 0) 0 else @intCast(usize, _offset.start), @max(self.contents.len, 1) - 1); const contents = self.contents; diff --git a/src/main_wasm.zig b/src/main_wasm.zig index 8958d7cd4..c9e4666e8 100644 --- a/src/main_wasm.zig +++ b/src/main_wasm.zig @@ -31,14 +31,14 @@ pub const Uint8Array = extern struct { pub fn fromSlice(slice: []const u8) u64 { return @bitCast(u64, [2]u32{ - @ptrToInt(slice.ptr), + @intFromPtr(slice.ptr), slice.len, }); } pub fn fromJS(data: u64) []u8 { const ptrs = @bitCast([2]u32, data); - return @intToPtr([*]u8, ptrs[0])[0..ptrs[1]]; + return @ptrFromInt([*]u8, ptrs[0])[0..ptrs[1]]; } }; @@ -167,7 +167,7 @@ var writer: JSPrinter.BufferPrinter = undefined; var define: *Define.Define = undefined; export fn bun_malloc(size: usize) u64 { return @bitCast(u64, [2]u32{ - @ptrToInt((default_allocator.alloc(u8, size) catch unreachable).ptr), + @intFromPtr((default_allocator.alloc(u8, size) catch unreachable).ptr), size, }); } @@ -270,7 +270,7 @@ export fn transform(opts_array: u64) u64 { const Encoder = ApiWriter(@TypeOf(output_writer)); var encoder = Encoder.init(output_writer); transform_response.encode(&encoder) catch unreachable; - return @bitCast(u64, [2]u32{ @ptrToInt(output.items.ptr), output.items.len }); + return @bitCast(u64, [2]u32{ @intFromPtr(output.items.ptr), output.items.len }); } export fn scan(opts_array: u64) u64 { @@ -325,7 +325,7 @@ export fn scan(opts_array: u64) u64 { var encoder = Encoder.init(output_writer); scan_result.encode(&encoder) catch unreachable; - return @bitCast(u64, [2]u32{ @ptrToInt(output.items.ptr), output.items.len }); + return @bitCast(u64, [2]u32{ @intFromPtr(output.items.ptr), output.items.len }); } // pub fn main() anyerror!void {} diff --git a/src/multi_array_list.zig b/src/multi_array_list.zig index d7e3c98e6..cff601bb8 100644 --- a/src/multi_array_list.zig +++ b/src/multi_array_list.zig @@ -33,7 +33,7 @@ pub fn MultiArrayList(comptime S: type) type { /// and then get the field arrays from the slice. pub const Slice = struct { /// This array is indexed by the field index which can be obtained - /// by using @enumToInt() on the Field enum + /// by using @intFromEnum() on the Field enum ptrs: [fields.len][*]u8, len: usize, capacity: usize, @@ -43,7 +43,7 @@ pub fn MultiArrayList(comptime S: type) type { if (self.capacity == 0) { return &[_]F{}; } - const byte_ptr = self.ptrs[@enumToInt(field)]; + const byte_ptr = self.ptrs[@intFromEnum(field)]; const casted_ptr: [*]F = if (@sizeOf(F) == 0) undefined else @@ -97,7 +97,7 @@ pub fn MultiArrayList(comptime S: type) type { return lhs.alignment > rhs.alignment; } }; - std.sort.sort(Data, &data, {}, Sort.lessThan); + std.sort.block(Data, &data, {}, Sort.lessThan); var sizes_bytes: [fields.len]usize = undefined; var field_indexes: [fields.len]usize = undefined; for (data, 0..) |elem, i| { @@ -151,7 +151,7 @@ pub fn MultiArrayList(comptime S: type) type { pub fn set(self: *Self, index: usize, elem: S) void { const slices = self.slice(); inline for (fields, 0..) |field_info, i| { - slices.items(@intToEnum(Field, i))[index] = @field(elem, field_info.name); + slices.items(@enumFromInt(Field, i))[index] = @field(elem, field_info.name); } } @@ -160,7 +160,7 @@ pub fn MultiArrayList(comptime S: type) type { const slices = self.slice(); var result: S = undefined; inline for (fields, 0..) |field_info, i| { - @field(result, field_info.name) = slices.items(@intToEnum(Field, i))[index]; + @field(result, field_info.name) = slices.items(@enumFromInt(Field, i))[index]; } return result; } @@ -233,7 +233,7 @@ pub fn MultiArrayList(comptime S: type) type { self.len += 1; const slices = self.slice(); inline for (fields, 0..) |field_info, field_index| { - const field_slice = slices.items(@intToEnum(Field, field_index)); + const field_slice = slices.items(@enumFromInt(Field, field_index)); var i: usize = self.len - 1; while (i > index) : (i -= 1) { field_slice[i] = field_slice[i - 1]; @@ -248,7 +248,7 @@ pub fn MultiArrayList(comptime S: type) type { pub fn swapRemove(self: *Self, index: usize) void { const slices = self.slice(); inline for (fields, 0..) |_, i| { - const field_slice = slices.items(@intToEnum(Field, i)); + const field_slice = slices.items(@enumFromInt(Field, i)); field_slice[index] = field_slice[self.len - 1]; field_slice[self.len - 1] = undefined; } @@ -260,7 +260,7 @@ pub fn MultiArrayList(comptime S: type) type { pub fn orderedRemove(self: *Self, index: usize) void { const slices = self.slice(); inline for (fields, 0..) |_, field_index| { - const field_slice = slices.items(@intToEnum(Field, field_index)); + const field_slice = slices.items(@enumFromInt(Field, field_index)); var i = index; while (i < self.len - 1) : (i += 1) { field_slice[i] = field_slice[i + 1]; @@ -297,13 +297,12 @@ pub fn MultiArrayList(comptime S: type) type { const self_slice = self.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); const dest_slice = self_slice.items(field)[new_len..]; - const byte_count = dest_slice.len * @sizeOf(field_info.type); // We use memset here for more efficient codegen in safety-checked, // valgrind-enabled builds. Otherwise the valgrind client request // will be repeated for every element. - @memset(@ptrCast([*]u8, dest_slice.ptr), undefined, byte_count); + @memset(dest_slice, undefined); } } self.len = new_len; @@ -319,7 +318,7 @@ pub fn MultiArrayList(comptime S: type) type { const other_slice = other.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); mem.copy(field_info.type, other_slice.items(field), self_slice.items(field)); } } @@ -380,7 +379,7 @@ pub fn MultiArrayList(comptime S: type) type { const other_slice = other.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); mem.copy(field_info.type, other_slice.items(field), self_slice.items(field)); } } @@ -399,7 +398,7 @@ pub fn MultiArrayList(comptime S: type) type { const result_slice = result.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); mem.copy(field_info.type, result_slice.items(field), self_slice.items(field)); } } @@ -420,7 +419,7 @@ pub fn MultiArrayList(comptime S: type) type { pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); const ptr = sc.slice.items(field); mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]); } @@ -432,7 +431,7 @@ pub fn MultiArrayList(comptime S: type) type { } }; - std.sort.sortContext(self.len, SortContext{ + std.sort.blockContext(0, self.len, SortContext{ .sub_ctx = ctx, .slice = self.slice(), }); @@ -457,7 +456,7 @@ pub fn MultiArrayList(comptime S: type) type { const this_slice = this.slice(); inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @intToEnum(Field, i); + const field = @enumFromInt(Field, i); mem.copy(field_info.type, this_slice.items(field)[offset..], other_slice.items(field)); } } @@ -475,7 +474,7 @@ pub fn MultiArrayList(comptime S: type) type { pub fn zero(this: *Self) void { var allocated = this.allocatedBytes(); if (allocated.len > 0) { - @memset(allocated.ptr, 0, allocated.len); + @memset(allocated, 0); } } diff --git a/src/napi/napi.zig b/src/napi/napi.zig index 5f94dac90..0973ca559 100644 --- a/src/napi/napi.zig +++ b/src/napi/napi.zig @@ -386,7 +386,7 @@ pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf return .ok; } const to_copy = @min(zig_str.len, buf_.len); - @memcpy(buf, zig_str.slice().ptr, to_copy); + @memcpy(buf[0..to_copy], zig_str.slice().ptr[0..to_copy]); buf[to_copy] = 0; // if zero terminated, report the length of the string without the null result.* = to_copy; @@ -451,7 +451,7 @@ pub export fn napi_get_value_string_utf8(env: napi_env, value: napi_value, buf_p } const to_copy = @min(zig_str.len, buf_.len); - @memcpy(buf, zig_str.slice().ptr, to_copy); + @memcpy(buf[0..to_copy], zig_str.slice().ptr[0..to_copy]); buf[to_copy] = 0; if (result_ptr) |result| { result.* = @intCast(@TypeOf(result.*), to_copy); @@ -509,7 +509,7 @@ pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ } const to_copy = @min(zig_str.len, buf_.len) * 2; - @memcpy(std.mem.sliceAsBytes(buf_).ptr, std.mem.sliceAsBytes(zig_str.utf16SliceAligned()).ptr, to_copy); + @memcpy(std.mem.sliceAsBytes(buf_)[0..to_copy], std.mem.sliceAsBytes(zig_str.utf16SliceAligned())[0..to_copy]); buf[to_copy] = 0; // if zero terminated, report the length of the string without the null if (result_ptr) |result| { @@ -787,7 +787,8 @@ pub export fn napi_create_arraybuffer(env: napi_env, byte_length: usize, data: [ log("napi_create_arraybuffer", .{}); var typed_array = JSC.C.JSObjectMakeTypedArray(env.ref(), .kJSTypedArrayTypeArrayBuffer, byte_length, TODO_EXCEPTION); var array_buffer = JSValue.c(typed_array).asArrayBuffer(env) orelse return genericFailure(); - @memcpy(array_buffer.ptr, data, @min(array_buffer.len, @truncate(u32, byte_length))); + const len = @min(array_buffer.len, @truncate(u32, byte_length)); + @memcpy(array_buffer.ptr[0..len], data[0..len]); result.* = JSValue.c(typed_array); return .ok; } @@ -1035,8 +1036,8 @@ pub const napi_async_work = struct { this.run(); } pub fn run(this: *napi_async_work) void { - if (this.status.compareAndSwap(@enumToInt(Status.pending), @enumToInt(Status.started), .SeqCst, .SeqCst)) |state| { - if (state == @enumToInt(Status.cancelled)) { + if (this.status.compareAndSwap(@intFromEnum(Status.pending), @intFromEnum(Status.started), .SeqCst, .SeqCst)) |state| { + if (state == @intFromEnum(Status.cancelled)) { if (this.wait_for_deinit) { // this might cause a segfault due to Task using a linked list! bun.default_allocator.destroy(this); @@ -1045,7 +1046,7 @@ pub const napi_async_work = struct { return; } this.execute.?(this.global, this.ctx); - this.status.store(@enumToInt(Status.completed), .SeqCst); + this.status.store(@intFromEnum(Status.completed), .SeqCst); this.event_loop.enqueueTaskConcurrent(this.concurrent_task.from(this)); } @@ -1059,7 +1060,7 @@ pub const napi_async_work = struct { pub fn cancel(this: *napi_async_work) bool { this.ref.unref(this.global.bunVM()); - return this.status.compareAndSwap(@enumToInt(Status.cancelled), @enumToInt(Status.pending), .SeqCst, .SeqCst) != null; + return this.status.compareAndSwap(@intFromEnum(Status.cancelled), @intFromEnum(Status.pending), .SeqCst, .SeqCst) != null; } pub fn deinit(this: *napi_async_work) void { @@ -1075,7 +1076,7 @@ pub const napi_async_work = struct { pub fn runFromJS(this: *napi_async_work) void { this.complete.?( this.global, - if (this.status.load(.SeqCst) == @enumToInt(Status.cancelled)) + if (this.status.load(.SeqCst) == @intFromEnum(Status.cancelled)) napi_status.cancelled else napi_status.ok, @@ -1171,7 +1172,7 @@ pub export fn napi_create_buffer_copy(env: napi_env, length: usize, data: [*]u8, var buffer = JSC.JSValue.createBufferFromLength(env, length); if (buffer.asArrayBuffer(env)) |array_buf| { if (length > 0) { - @memcpy(array_buf.slice().ptr, data, length); + @memcpy(array_buf.slice()[0..length], data[0..length]); } if (result_data) |ptr| { ptr.* = if (length > 0) array_buf.ptr else null; diff --git a/src/network_thread.zig b/src/network_thread.zig index 969269c76..49711c469 100644 --- a/src/network_thread.zig +++ b/src/network_thread.zig @@ -1,15 +1,16 @@ -const ThreadPool = @import("root").bun.ThreadPool; +const bun = @import("root").bun; +const ThreadPool = bun.ThreadPool; pub const Batch = ThreadPool.Batch; pub const Task = ThreadPool.Task; const Node = ThreadPool.Node; pub const Completion = AsyncIO.Completion; const std = @import("std"); -pub const AsyncIO = @import("root").bun.AsyncIO; -const Output = @import("root").bun.Output; +pub const AsyncIO = bun.AsyncIO; +const Output = bun.Output; const IdentityContext = @import("./identity_context.zig").IdentityContext; const HTTP = @import("./http_client_async.zig"); const NetworkThread = @This(); -const Environment = @import("root").bun.Environment; +const Environment = bun.Environment; const Lock = @import("./lock.zig").Lock; /// Single-thread in this pool diff --git a/src/node_fallbacks.zig b/src/node_fallbacks.zig index fc0dc3bef..170907e58 100644 --- a/src/node_fallbacks.zig +++ b/src/node_fallbacks.zig @@ -3,6 +3,7 @@ const string = @import("./string_types.zig").string; const PackageJSON = @import("./resolver/package_json.zig").PackageJSON; const logger = @import("root").bun.logger; const Fs = @import("./fs.zig"); +const bun = @import("root").bun; const ComptimeStringMap = @import("./comptime_string_map.zig").ComptimeStringMap; const assert_code: string = @embedFile("./node-fallbacks/out/assert.js"); @@ -67,7 +68,7 @@ const assert_package_json = PackageJSON{ .name = "assert", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "assert@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("assert@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/assert/package.json", ""), @@ -76,7 +77,7 @@ const buffer_package_json = PackageJSON{ .name = "buffer", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "buffer@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("buffer@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/buffer/package.json", ""), @@ -85,7 +86,7 @@ const console_package_json = PackageJSON{ .name = "console", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "console@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("console@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/console/package.json", ""), @@ -94,7 +95,7 @@ const constants_package_json = PackageJSON{ .name = "constants", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "constants@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("constants@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/constants/package.json", ""), @@ -103,7 +104,7 @@ const crypto_package_json = PackageJSON{ .name = "crypto", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "crypto@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("crypto@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/crypto/package.json", ""), @@ -112,7 +113,7 @@ const domain_package_json = PackageJSON{ .name = "domain", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "domain@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("domain@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/domain/package.json", ""), @@ -121,7 +122,7 @@ const events_package_json = PackageJSON{ .name = "events", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "events@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("events@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/events/package.json", ""), @@ -130,7 +131,7 @@ const http_package_json = PackageJSON{ .name = "http", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "http@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("http@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/http/package.json", ""), @@ -139,7 +140,7 @@ const https_package_json = PackageJSON{ .name = "https", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "https@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("https@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/https/package.json", ""), @@ -148,7 +149,7 @@ const net_package_json = PackageJSON{ .name = "net", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "net@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("net@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/net/package.json", ""), @@ -157,7 +158,7 @@ const os_package_json = PackageJSON{ .name = "os", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "os@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("os@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/os/package.json", ""), @@ -166,7 +167,7 @@ const path_package_json = PackageJSON{ .name = "path", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "path@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("path@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/path/package.json", ""), @@ -175,7 +176,7 @@ const process_package_json = PackageJSON{ .name = "process", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "process@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("process@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/process/package.json", ""), @@ -184,7 +185,7 @@ const punycode_package_json = PackageJSON{ .name = "punycode", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "punycode@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("punycode@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/punycode/package.json", ""), @@ -193,7 +194,7 @@ const querystring_package_json = PackageJSON{ .name = "querystring", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "querystring@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("querystring@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/querystring/package.json", ""), @@ -202,7 +203,7 @@ const stream_package_json = PackageJSON{ .name = "stream", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "stream@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("stream@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/stream/package.json", ""), @@ -213,7 +214,7 @@ const string_decoder_package_json = PackageJSON{ .module_type = .cjs, .hash = brk: { @setEvalBranchQuota(9999); - break :brk @truncate(u32, std.hash.Wyhash.hash(0, "string_decoder@0.0.0-polyfill")); + break :brk @truncate(u32, bun.hash("string_decoder@0.0.0-polyfill")); }, .main_fields = undefined, @@ -225,7 +226,7 @@ const sys_package_json = PackageJSON{ .name = "sys", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "sys@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("sys@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/sys/package.json", ""), @@ -234,7 +235,7 @@ const timers_package_json = PackageJSON{ .name = "timers", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "timers@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("timers@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/timers/package.json", ""), @@ -243,7 +244,7 @@ const tty_package_json = PackageJSON{ .name = "tty", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "tty@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("tty@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/tty/package.json", ""), @@ -252,7 +253,7 @@ const url_package_json = PackageJSON{ .name = "url", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "url@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("url@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/url/package.json", ""), @@ -261,7 +262,7 @@ const util_package_json = PackageJSON{ .name = "util", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "util@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("util@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/util/package.json", ""), @@ -270,7 +271,7 @@ const zlib_package_json = PackageJSON{ .name = "zlib", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "zlib@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("zlib@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/zlib/package.json", ""), @@ -280,7 +281,7 @@ const node_fetch_package_json = PackageJSON{ .name = "node-fetch", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "node-fetch@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("node-fetch@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/node-fetch/package.json", ""), @@ -289,7 +290,7 @@ const isomorphic_fetch_package_json = PackageJSON{ .name = "isomorphic-fetch", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "isomorphic-fetch@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("isomorphic-fetch@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/isomorphic-fetch/package.json", ""), @@ -298,7 +299,7 @@ const supports_color_package_json = PackageJSON{ .name = "supports-color", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "supports-color@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("supports-color@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/supports-color/package.json", ""), @@ -308,7 +309,7 @@ const vercel_fetch_package_json = PackageJSON{ .name = "@vercel/fetch", .version = "0.0.0-polyfill", .module_type = .cjs, - .hash = @truncate(u32, std.hash.Wyhash.hash(0, "@vercel/fetch@0.0.0-polyfill")), + .hash = @truncate(u32, bun.hash("@vercel/fetch@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, .source = logger.Source.initPathString("/bun-vfs/node_modules/@vercel/fetch/package.json", ""), diff --git a/src/node_module_bundle.zig b/src/node_module_bundle.zig index c70a58419..6682e2dff 100644 --- a/src/node_module_bundle.zig +++ b/src/node_module_bundle.zig @@ -107,7 +107,7 @@ pub const NodeModuleBundle = struct { // This catches any issues with the sorting order, which would cause all sorts of weird bugs // This also allows us to simply extend the length of the previous slice to the new length // Saving us an allocation - if (@ptrToInt(prev_package_ids_for_name.ptr) != @ptrToInt(entry.value_ptr.ptr)) { + if (@intFromPtr(prev_package_ids_for_name.ptr) != @intFromPtr(entry.value_ptr.ptr)) { Output.prettyErrorln( \\Fatal: incorrect package sorting order detected in .bun file.\n \\This is a bug! Please create an issue.\n @@ -225,7 +225,7 @@ pub const NodeModuleBundle = struct { const lhs_name = context.moduleName(&lhs); const rhs_name = context.moduleName(&rhs); - const traversal_length = std.math.min(lhs_name.len, rhs_name.len); + const traversal_length = @min(lhs_name.len, rhs_name.len); for (lhs_name[0..traversal_length], 0..) |char, i| { switch (std.math.order(char, rhs_name[i])) { @@ -283,7 +283,7 @@ pub const NodeModuleBundle = struct { const lhs_name = context.moduleName(&lhs); const rhs_name = context.moduleName(&rhs); - const traversal_length = std.math.min(lhs_name.len, rhs_name.len); + const traversal_length = @min(lhs_name.len, rhs_name.len); for (lhs_name[0..traversal_length], 0..) |char, i| { switch (std.math.order(char, rhs_name[i])) { @@ -431,16 +431,16 @@ pub const NodeModuleBundle = struct { switch (size) { 0...1024 * 1024 => { switch (level) { - .bad => Output.pretty("{d: " ++ align_char ++ "6.2} KB", .{@intToFloat(f64, size) / 1024.0}), - .neutral => Output.pretty("{d: " ++ align_char ++ "6.2} KB", .{@intToFloat(f64, size) / 1024.0}), - .good => Output.pretty("{d: " ++ align_char ++ "6.2} KB", .{@intToFloat(f64, size) / 1024.0}), + .bad => Output.pretty("{d: " ++ align_char ++ "6.2} KB", .{@floatFromInt(f64, size) / 1024.0}), + .neutral => Output.pretty("{d: " ++ align_char ++ "6.2} KB", .{@floatFromInt(f64, size) / 1024.0}), + .good => Output.pretty("{d: " ++ align_char ++ "6.2} KB", .{@floatFromInt(f64, size) / 1024.0}), } }, else => { switch (level) { - .bad => Output.pretty("{d: " ++ align_char ++ "6.2} MB", .{@intToFloat(f64, size) / (1024 * 1024.0)}), - .neutral => Output.pretty("{d: " ++ align_char ++ "6.2} MB", .{@intToFloat(f64, size) / (1024 * 1024.0)}), - .good => Output.pretty("{d: " ++ align_char ++ "6.2} MB", .{@intToFloat(f64, size) / (1024 * 1024.0)}), + .bad => Output.pretty("{d: " ++ align_char ++ "6.2} MB", .{@floatFromInt(f64, size) / (1024 * 1024.0)}), + .neutral => Output.pretty("{d: " ++ align_char ++ "6.2} MB", .{@floatFromInt(f64, size) / (1024 * 1024.0)}), + .good => Output.pretty("{d: " ++ align_char ++ "6.2} MB", .{@floatFromInt(f64, size) / (1024 * 1024.0)}), } }, } @@ -459,7 +459,7 @@ pub const NodeModuleBundle = struct { var read_amount: i64 = 99999; while (remain > 0 and read_amount > 0) { read_amount = @intCast(i64, in.read(&buf) catch 0); - remain -= @intCast(i64, try out.write(buf[0..@intCast(usize, std.math.min(read_amount, remain))])); + remain -= @intCast(i64, try out.write(buf[0..@intCast(usize, @min(read_amount, remain))])); } } }; diff --git a/src/options.zig b/src/options.zig index 08eb7b4b7..3a4eaa9eb 100644 --- a/src/options.zig +++ b/src/options.zig @@ -1699,7 +1699,7 @@ pub const BundleOptions = struct { opts.node_modules_bundle_pretty_path = try allocator.dupe(u8, pretty_path); } - const elapsed = @intToFloat(f64, (std.time.nanoTimestamp() - time_start)) / std.time.ns_per_ms; + const elapsed = @floatFromInt(f64, (std.time.nanoTimestamp() - time_start)) / std.time.ns_per_ms; Output.printElapsed(elapsed); Output.prettyErrorln( " \"{s}\" - {d} modules, {d} packages", @@ -2779,7 +2779,7 @@ pub const PathTemplate = struct { }; if (count == 0) { - end_len = @ptrToInt(c) - @ptrToInt(remain.ptr); + end_len = @intFromPtr(c) - @intFromPtr(remain.ptr); std.debug.assert(end_len <= remain.len); break; } diff --git a/src/output.zig b/src/output.zig index 683e39164..cf58cbccf 100644 --- a/src/output.zig +++ b/src/output.zig @@ -270,21 +270,21 @@ pub const ElapsedFormatter = struct { 0...std.time.ns_per_ms * 10 => { const fmt_str = "[{d:>.2}ms]"; switch (self.colors) { - inline else => |colors| try writer_.print(comptime prettyFmt(fmt_str, colors), .{@intToFloat(f64, self.duration_ns) / std.time.ns_per_ms}), + inline else => |colors| try writer_.print(comptime prettyFmt(fmt_str, colors), .{@floatFromInt(f64, self.duration_ns) / std.time.ns_per_ms}), } }, std.time.ns_per_ms * 8_000...std.math.maxInt(u64) => { const fmt_str = "[{d:>.2}ms]"; switch (self.colors) { - inline else => |colors| try writer_.print(comptime prettyFmt(fmt_str, colors), .{@intToFloat(f64, self.duration_ns) / std.time.ns_per_ms}), + inline else => |colors| try writer_.print(comptime prettyFmt(fmt_str, colors), .{@floatFromInt(f64, self.duration_ns) / std.time.ns_per_ms}), } }, else => { const fmt_str = "[{d:>.2}ms]"; switch (self.colors) { - inline else => |colors| try writer_.print(comptime prettyFmt(fmt_str, colors), .{@intToFloat(f64, self.duration_ns) / std.time.ns_per_ms}), + inline else => |colors| try writer_.print(comptime prettyFmt(fmt_str, colors), .{@floatFromInt(f64, self.duration_ns) / std.time.ns_per_ms}), } }, } @@ -292,7 +292,7 @@ pub const ElapsedFormatter = struct { }; inline fn printElapsedToWithCtx(elapsed: f64, comptime printerFn: anytype, comptime has_ctx: bool, ctx: anytype) void { - switch (@floatToInt(i64, @round(elapsed))) { + switch (@intFromFloat(i64, @round(elapsed))) { 0...1500 => { const fmt = "[{d:>.2}ms]"; const args = .{elapsed}; @@ -328,7 +328,7 @@ pub fn printElapsedStdout(elapsed: f64) void { } pub fn printElapsedStdoutTrim(elapsed: f64) void { - switch (@floatToInt(i64, @round(elapsed))) { + switch (@intFromFloat(i64, @round(elapsed))) { 0...1500 => { const fmt = "[{d:>}ms]"; const args = .{elapsed}; @@ -345,18 +345,18 @@ pub fn printElapsedStdoutTrim(elapsed: f64) void { pub fn printStartEnd(start: i128, end: i128) void { const elapsed = @divTrunc(@truncate(i64, end - start), @as(i64, std.time.ns_per_ms)); - printElapsed(@intToFloat(f64, elapsed)); + printElapsed(@floatFromInt(f64, elapsed)); } pub fn printStartEndStdout(start: i128, end: i128) void { const elapsed = @divTrunc(@truncate(i64, end - start), @as(i64, std.time.ns_per_ms)); - printElapsedStdout(@intToFloat(f64, elapsed)); + printElapsedStdout(@floatFromInt(f64, elapsed)); } pub fn printTimer(timer: *SystemTimer) void { if (comptime Environment.isWasm) return; const elapsed = @divTrunc(timer.read(), @as(u64, std.time.ns_per_ms)); - printElapsed(@intToFloat(f64, elapsed)); + printElapsed(@floatFromInt(f64, elapsed)); } pub noinline fn printErrorable(comptime fmt: string, args: anytype) !void { @@ -692,7 +692,7 @@ pub const DebugTimer = struct { var _opts = opts; _opts.precision = 3; std.fmt.formatFloatDecimal( - @floatCast(f64, @intToFloat(f64, timer.read()) / std.time.ns_per_ms), + @floatCast(f64, @floatFromInt(f64, timer.read()) / std.time.ns_per_ms), _opts, writer_, ) catch unreachable; diff --git a/src/renamer.zig b/src/renamer.zig index 0177725c6..8f6af149f 100644 --- a/src/renamer.zig +++ b/src/renamer.zig @@ -156,7 +156,7 @@ pub const MinifyRenamer = struct { for (first_top_level_slots.slots.values, 0..) |count, ns| { slots.values[ns] = try std.ArrayList(SymbolSlot).initCapacity(allocator, count); slots.values[ns].items.len = count; - std.mem.set(SymbolSlot, slots.values[ns].items[0..count], SymbolSlot{}); + @memset(slots.values[ns].items[0..count], SymbolSlot{}); } renamer.* = MinifyRenamer{ @@ -297,7 +297,7 @@ pub const MinifyRenamer = struct { .count = slot.count, }; } - std.sort.sort(SlotAndCount, sorted.items, {}, SlotAndCount.lessThan); + std.sort.block(SlotAndCount, sorted.items, {}, SlotAndCount.lessThan); var next_name: isize = 0; @@ -395,7 +395,7 @@ pub fn assignNestedScopeSlotsHelper(sorted_members: *std.ArrayList(u32), scope: sorted_members_buf[i] = member.ref.innerIndex(); i += 1; } - std.sort.sort(u32, sorted_members_buf, {}, std.sort.asc(u32)); + std.sort.block(u32, sorted_members_buf, {}, std.sort.asc(u32)); // Assign slots for this scope's symbols. Only do this if the slot is // not already assigned. Nested scopes have copies of symbols from parent @@ -519,7 +519,7 @@ pub const NumberRenamer = struct { const prev_cap = inner.len; inner.ensureUnusedCapacity(r.allocator, new_len - prev_cap) catch unreachable; const to_write = inner.ptr[prev_cap..inner.cap]; - @memset(std.mem.sliceAsBytes(to_write).ptr, 0, std.mem.sliceAsBytes(to_write).len); + @memset(std.mem.sliceAsBytes(to_write), 0); } inner.len = new_len; inner.mut(ref.innerIndex()).* = name; @@ -553,7 +553,7 @@ pub const NumberRenamer = struct { symbols.dump(); } - @memset(std.mem.sliceAsBytes(renamer.names).ptr, 0, std.mem.sliceAsBytes(renamer.names).len); + @memset(std.mem.sliceAsBytes(renamer.names), 0); return renamer; } @@ -593,7 +593,7 @@ pub const NumberRenamer = struct { remaining = remaining[1..]; } std.debug.assert(remaining.len == 0); - std.sort.sort(u32, sorted.items, {}, std.sort.asc(u32)); + std.sort.block(u32, sorted.items, {}, std.sort.asc(u32)); for (sorted.items) |inner_index| { r.assignName(s, Ref.init(@intCast(Ref.Int, inner_index), source_index, false)); diff --git a/src/report.zig b/src/report.zig index 92f051427..c2f466b03 100644 --- a/src/report.zig +++ b/src/report.zig @@ -190,7 +190,7 @@ pub fn fatal(err_: ?anyerror, msg_: ?string) void { } if (msg_) |msg| { - const msg_ptr = @ptrToInt(msg.ptr); + const msg_ptr = @intFromPtr(msg.ptr); if (msg_ptr > 0) { const len = @max(@min(msg.len, 1024), 0); @@ -470,7 +470,7 @@ pub noinline fn globalError(err: anyerror, trace_: @TypeOf(@errorReturnTrace())) print_stacktrace: { var debug_info = std.debug.getSelfDebugInfo() catch break :print_stacktrace; Output.disableBuffering(); - std.debug.writeStackTrace(trace.*, Output.errorWriter(), default_allocator, debug_info, std.debug.detectTTYConfig(std.io.getStdErr())) catch break :print_stacktrace; + std.debug.writeStackTrace(trace.*, Output.errorWriter(), default_allocator, debug_info, std.io.tty.detectConfig(std.io.getStdErr())) catch break :print_stacktrace; } } @@ -539,7 +539,7 @@ pub noinline fn globalError(err: anyerror, trace_: @TypeOf(@errorReturnTrace())) print_stacktrace: { var debug_info = std.debug.getSelfDebugInfo() catch break :print_stacktrace; Output.disableBuffering(); - std.debug.writeStackTrace(trace.*, Output.errorWriter(), default_allocator, debug_info, std.debug.detectTTYConfig(std.io.getStdErr())) catch break :print_stacktrace; + std.debug.writeStackTrace(trace.*, Output.errorWriter(), default_allocator, debug_info, std.io.tty.detectConfig(std.io.getStdErr())) catch break :print_stacktrace; } } @@ -555,7 +555,7 @@ pub noinline fn globalError(err: anyerror, trace_: @TypeOf(@errorReturnTrace())) print_stacktrace: { var debug_info = std.debug.getSelfDebugInfo() catch break :print_stacktrace; Output.disableBuffering(); - std.debug.writeStackTrace(trace.*, Output.errorWriter(), default_allocator, debug_info, std.debug.detectTTYConfig(std.io.getStdErr())) catch break :print_stacktrace; + std.debug.writeStackTrace(trace.*, Output.errorWriter(), default_allocator, debug_info, std.io.tty.detectConfig(std.io.getStdErr())) catch break :print_stacktrace; } } @@ -572,7 +572,7 @@ pub noinline fn globalError(err: anyerror, trace_: @TypeOf(@errorReturnTrace())) print_stacktrace: { var debug_info = std.debug.getSelfDebugInfo() catch break :print_stacktrace; Output.disableBuffering(); - std.debug.writeStackTrace(trace.*, Output.errorWriter(), default_allocator, debug_info, std.debug.detectTTYConfig(std.io.getStdErr())) catch break :print_stacktrace; + std.debug.writeStackTrace(trace.*, Output.errorWriter(), default_allocator, debug_info, std.io.tty.detectConfig(std.io.getStdErr())) catch break :print_stacktrace; } } diff --git a/src/resolver/package_json.zig b/src/resolver/package_json.zig index 63bc5b20b..e759374e7 100644 --- a/src/resolver/package_json.zig +++ b/src/resolver/package_json.zig @@ -59,7 +59,7 @@ pub const PackageJSON = struct { pub fn generateHash(package_json: *PackageJSON) void { var hashy: [1024]u8 = undefined; - std.mem.set(u8, &hashy, 0); + @memset(&hashy, 0); var used: usize = 0; bun.copy(u8, &hashy, package_json.name); used = package_json.name.len; @@ -390,7 +390,7 @@ pub const PackageJSON = struct { var count: usize = 0; const items = array.items.slice(); for (items) |item| { - count += @boolToInt(item.data == .e_string and item.data.e_string.data.len > 0); + count += @intFromBool(item.data == .e_string and item.data.e_string.data.len > 0); } switch (count) { 0 => {}, @@ -888,10 +888,10 @@ pub const PackageJSON = struct { const dependency_groups = comptime brk: { var out_groups: [ - @as(usize, @boolToInt(features.dependencies)) + - @as(usize, @boolToInt(features.dev_dependencies)) + - @as(usize, @boolToInt(features.optional_dependencies)) + - @as(usize, @boolToInt(features.peer_dependencies)) + @as(usize, @intFromBool(features.dependencies)) + + @as(usize, @intFromBool(features.dev_dependencies)) + + @as(usize, @intFromBool(features.optional_dependencies)) + + @as(usize, @intFromBool(features.peer_dependencies)) ]DependencyGroup = undefined; var out_group_i: usize = 0; if (features.dependencies) { @@ -989,7 +989,7 @@ pub const PackageJSON = struct { const key = prop.key.?.asString(allocator) orelse continue; const value = prop.value.?.asString(allocator) orelse continue; - count += @as(usize, @boolToInt(key.len > 0 and value.len > 0)); + count += @as(usize, @intFromBool(key.len > 0 and value.len > 0)); } if (count == 0) break :read_scripts; @@ -1022,7 +1022,7 @@ pub const PackageJSON = struct { } pub fn hashModule(this: *const PackageJSON, module: string) u32 { - var hasher = std.hash.Wyhash.init(0); + var hasher = bun.Wyhash.init(0); hasher.update(std.mem.asBytes(&this.hash)); hasher.update(module); @@ -1148,7 +1148,7 @@ pub const ExportsMap = struct { // PATTERN_KEY_COMPARE which orders in descending order of specificity. const GlobLengthSorter: type = strings.NewGlobLengthSorter(Entry.Data.Map.MapEntry, "key"); var sorter = GlobLengthSorter{}; - std.sort.sort(Entry.Data.Map.MapEntry, expansion_keys, sorter, GlobLengthSorter.lessThan); + std.sort.block(Entry.Data.Map.MapEntry, expansion_keys, sorter, GlobLengthSorter.lessThan); return Entry{ .data = .{ diff --git a/src/resolver/resolve_path.zig b/src/resolver/resolve_path.zig index c5ffdc626..e63318887 100644 --- a/src/resolver/resolve_path.zig +++ b/src/resolver/resolve_path.zig @@ -376,7 +376,7 @@ pub fn relativeToCommonPath( var out_slice: []u8 = buf[0..0]; if (normalized_from.len > 0) { - var i: usize = @intCast(usize, @boolToInt(normalized_from[0] == separator)) + 1 + last_common_separator; + var i: usize = @intCast(usize, @intFromBool(normalized_from[0] == separator)) + 1 + last_common_separator; while (i <= normalized_from.len) : (i += 1) { if (i == normalized_from.len or (normalized_from[i] == separator and i + 1 < normalized_from.len)) { @@ -549,7 +549,7 @@ pub fn normalizeStringGeneric(path: []const u8, buf: []u8, comptime allow_above_ const from = r; while (r < n and !isSeparator(path[r])) : (r += 1) {} const count = r - from; - @memcpy(buf[buf_i..].ptr, path[from..].ptr, count); + @memcpy(buf[buf_i..][0..count], path[from..][0..count]); buf_i += count; } diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 8a6a2bc5e..14bc358d0 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -27,7 +27,6 @@ const CacheSet = cache.Set; const DataURL = @import("./data_url.zig").DataURL; pub const DirInfo = @import("./dir_info.zig"); const HTTPWatcher = if (Environment.isTest or Environment.isWasm) void else @import("../http.zig").Watcher; -const Wyhash = std.hash.Wyhash; const ResolvePath = @import("./resolve_path.zig"); const NodeFallbackModules = @import("../node_fallbacks.zig"); const Mutex = @import("../lock.zig").Lock; @@ -283,10 +282,10 @@ pub const Result = struct { if (strings.lastIndexOf(module, node_module_root)) |end_| { var end: usize = end_ + node_module_root.len; - return @truncate(u32, std.hash.Wyhash.hash(0, module[end..])); + return @truncate(u32, bun.hash(module[end..])); } - return @truncate(u32, std.hash.Wyhash.hash(0, this.path_pair.primary.text)); + return @truncate(u32, bun.hash(this.path_pair.primary.text)); } }; @@ -609,7 +608,7 @@ pub const Resolver = struct { if (r.debug_logs) |*debug| { if (flush_mode == DebugLogs.FlushMode.fail) { try r.log.addRangeDebugWithNotes(null, logger.Range{ .loc = logger.Loc{} }, debug.what, try debug.notes.toOwnedSlice()); - } else if (@enumToInt(r.log.level) <= @enumToInt(logger.Log.Level.verbose)) { + } else if (@intFromEnum(r.log.level) <= @intFromEnum(logger.Log.Level.verbose)) { try r.log.addVerboseWithNotes(null, logger.Loc.Empty, debug.what, try debug.notes.toOwnedSlice()); } } @@ -1265,7 +1264,7 @@ pub const Resolver = struct { if (NodeFallbackModules.Map.get(import_path_without_node_prefix)) |*fallback_module| { result.path_pair.primary = fallback_module.path; result.module_type = .cjs; - result.package_json = @intToPtr(*PackageJSON, @ptrToInt(fallback_module.package_json)); + result.package_json = @ptrFromInt(*PackageJSON, @intFromPtr(fallback_module.package_json)); result.is_from_node_modules = true; return .{ .success = result }; // "node:* @@ -1696,7 +1695,7 @@ pub const Resolver = struct { // check the global cache directory for a package.json file. var manager = r.getPackageManager(); var dependency_version: Dependency.Version = .{}; - var dependency_behavior = @intToEnum(Dependency.Behavior, Dependency.Behavior.normal); + var dependency_behavior = @enumFromInt(Dependency.Behavior, Dependency.Behavior.normal); // const initial_pending_tasks = manager.pending_tasks; var resolved_package_id: Install.PackageID = brk: { @@ -2629,7 +2628,7 @@ pub const Resolver = struct { // Directories must always end in a trailing slash or else various bugs can occur. // This covers "what happens when the trailing" - end += @intCast(usize, @boolToInt(safe_path.len > end and end > 0 and safe_path[end - 1] != std.fs.path.sep and safe_path[end] == std.fs.path.sep)); + end += @intCast(usize, @intFromBool(safe_path.len > end and end > 0 and safe_path[end - 1] != std.fs.path.sep and safe_path[end] == std.fs.path.sep)); break :brk safe_path[dir_path_i..end]; }; diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig index 4f04c39ca..2ec402fd2 100644 --- a/src/resolver/tsconfig_json.zig +++ b/src/resolver/tsconfig_json.zig @@ -344,7 +344,7 @@ pub const TSConfigJSON = struct { // foo == 1 // foo.bar.baz == 3 // foo.bar.baz.bun == 4 - const parts_count = std.mem.count(u8, text, ".") + @as(usize, @boolToInt(text[text.len - 1] != '.')); + const parts_count = std.mem.count(u8, text, ".") + @as(usize, @intFromBool(text[text.len - 1] != '.')); var parts = std.ArrayList(string).initCapacity(allocator, parts_count) catch unreachable; if (parts_count == 1) { diff --git a/src/router.zig b/src/router.zig index 3e0dc0dba..8ed16f102 100644 --- a/src/router.zig +++ b/src/router.zig @@ -28,7 +28,7 @@ const URLPath = @import("./http/url_path.zig"); const PathnameScanner = @import("./url.zig").PathnameScanner; const CodepointIterator = @import("./string_immutable.zig").CodepointIterator; -const index_route_hash = @truncate(u32, std.hash.Wyhash.hash(0, "$$/index-route$$-!(@*@#&*%-901823098123")); +const index_route_hash = @truncate(u32, bun.hash("$$/index-route$$-!(@*@#&*%-901823098123")); const arbitrary_max_route = 4096; pub const Param = struct { @@ -335,7 +335,7 @@ const RouteLoader = struct { const relative_dir = FileSystem.instance.relative(base_dir, config.dir); if (!strings.hasPrefixComptime(relative_dir, "..")) { - route_dirname_len = @truncate(u16, relative_dir.len + @as(usize, @boolToInt(config.dir[config.dir.len - 1] != std.fs.path.sep))); + route_dirname_len = @truncate(u16, relative_dir.len + @as(usize, @intFromBool(config.dir[config.dir.len - 1] != std.fs.path.sep))); } var this = RouteLoader{ @@ -356,7 +356,7 @@ const RouteLoader = struct { .allocator = allocator, }; - std.sort.sort(*Route, this.all_routes.items, Route.Sorter{}, Route.Sorter.sortByName); + std.sort.block(*Route, this.all_routes.items, Route.Sorter{}, Route.Sorter.sortByName); var route_list = RouteIndex.List{}; route_list.setCapacity(allocator, this.all_routes.items.len) catch unreachable; @@ -365,7 +365,7 @@ const RouteLoader = struct { var index_id: ?usize = null; for (this.all_routes.items, 0..) |route, i| { - if (@enumToInt(route.kind) > @enumToInt(Pattern.Tag.static) and dynamic_start == null) { + if (@intFromEnum(route.kind) > @intFromEnum(Pattern.Tag.static) and dynamic_start == null) { dynamic_start = i; } @@ -521,14 +521,14 @@ pub const TinyPtr = packed struct { pub fn from(parent: string, in: string) TinyPtr { if (in.len == 0 or parent.len == 0) return TinyPtr{}; - const right = @ptrToInt(in.ptr) + in.len; - const end = @ptrToInt(parent.ptr) + parent.len; + const right = @intFromPtr(in.ptr) + in.len; + const end = @intFromPtr(parent.ptr) + parent.len; if (comptime Environment.isDebug) { std.debug.assert(end < right); } const length = @max(end, right) - right; - const offset = @max(@ptrToInt(in.ptr), @ptrToInt(parent.ptr)) - @ptrToInt(parent.ptr); + const offset = @max(@intFromPtr(in.ptr), @intFromPtr(parent.ptr)) - @intFromPtr(parent.ptr); return TinyPtr{ .offset = @truncate(u16, offset), .len = @truncate(u16, length) }; } }; @@ -605,7 +605,7 @@ pub const Route = struct { // - static routes go first because we match those first // - dynamic, catch-all, and optional catch all routes are sorted lexicographically, except "[", "]" appear last so that deepest routes are tested first // - catch-all & optional catch-all appear at the end because we want to test those at the end. - return switch (std.math.order(@enumToInt(a.kind), @enumToInt(b.kind))) { + return switch (std.math.order(@intFromEnum(a.kind), @intFromEnum(b.kind))) { .eq => switch (a.kind) { // static + dynamic are sorted alphabetically .static, .dynamic => @call( @@ -676,7 +676,7 @@ pub const Route = struct { buf = buf[base.len..]; bun.copy(u8, buf, extname); buf = buf[extname.len..]; - break :brk route_file_buf[0 .. @ptrToInt(buf.ptr) - @ptrToInt(&route_file_buf)]; + break :brk route_file_buf[0 .. @intFromPtr(buf.ptr) - @intFromPtr(&route_file_buf)]; }; var name = public_path[0 .. public_path.len - extname.len]; @@ -711,7 +711,7 @@ pub const Route = struct { has_uppercase = public_path[name_i] >= 'A' and public_path[name_i] <= 'Z'; } - const name_offset = @ptrToInt(name.ptr) - @ptrToInt(public_path.ptr); + const name_offset = @intFromPtr(name.ptr) - @intFromPtr(public_path.ptr); if (has_uppercase) { public_path = FileSystem.DirnameStore.instance.append(@TypeOf(public_path), public_path) catch unreachable; @@ -770,7 +770,7 @@ pub const Route = struct { .full_hash = if (is_index) index_route_hash else - @truncate(u32, std.hash.Wyhash.hash(0, name)), + @truncate(u32, bun.hash(name)), .param_count = validation_result.param_count, .kind = validation_result.kind, .abs_path = entry.abs_path, @@ -1183,7 +1183,7 @@ const Pattern = struct { var count: u16 = 0; var offset: RoutePathInt = 0; std.debug.assert(input.len > 0); - var kind: u4 = @enumToInt(Tag.static); + var kind: u4 = @intFromEnum(Tag.static); const end = @truncate(u32, input.len - 1); while (offset < end) { const pattern: Pattern = Pattern.initUnhashed(input, offset) catch |err| { @@ -1247,11 +1247,11 @@ const Pattern = struct { return null; }; offset = pattern.len; - kind = @max(@enumToInt(@as(Pattern.Tag, pattern.value)), kind); - count += @intCast(u16, @boolToInt(@enumToInt(@as(Pattern.Tag, pattern.value)) > @enumToInt(Pattern.Tag.static))); + kind = @max(@intFromEnum(@as(Pattern.Tag, pattern.value)), kind); + count += @intCast(u16, @intFromBool(@intFromEnum(@as(Pattern.Tag, pattern.value)) > @intFromEnum(Pattern.Tag.static))); } - return ValidationResult{ .param_count = count, .kind = @intToEnum(Tag, kind) }; + return ValidationResult{ .param_count = count, .kind = @enumFromInt(Tag, kind) }; } pub fn eql(a: Pattern, b: Pattern) bool { @@ -1369,7 +1369,7 @@ const Pattern = struct { i += 1; } - if (@enumToInt(tag) > @enumToInt(Tag.dynamic) and i <= end) return error.CatchAllMustBeAtTheEnd; + if (@intFromEnum(tag) > @intFromEnum(Tag.dynamic) and i <= end) return error.CatchAllMustBeAtTheEnd; return Pattern{ .len = @min(i + 1, end), diff --git a/src/runtime.zig b/src/runtime.zig index 6916df6b1..072258747 100644 --- a/src/runtime.zig +++ b/src/runtime.zig @@ -406,7 +406,7 @@ pub const Runtime = struct { return std.mem.order(u8, a, b) == .lt; } }; - std.sort.sort(string, &list, {}, Sorter.compare); + std.sort.block(string, &list, {}, Sorter.compare); break :brk list; }; diff --git a/src/sha.zig b/src/sha.zig index cd9fd0f0a..8faf9fbb2 100644 --- a/src/sha.zig +++ b/src/sha.zig @@ -212,7 +212,7 @@ pub fn main() anyerror!void { { var clock1 = try std.time.Timer.start(); - std.mem.doNotOptimizeAway(std.hash.Wyhash.hash(0, bytes)); + std.mem.doNotOptimizeAway(bun.hash(bytes)); const zig_time = clock1.read(); std.debug.print( "Wyhash:\n\n zig: {any}\n\n", @@ -251,10 +251,10 @@ pub fn main() anyerror!void { var digest2: DigestType = undefined; var digest3: DigestType = undefined; var digest4: DigestType = undefined; - @memset(&digest1, 0, @sizeOf(DigestType)); - @memset(&digest2, 0, @sizeOf(DigestType)); - @memset(&digest3, 0, @sizeOf(DigestType)); - @memset(&digest4, 0, @sizeOf(DigestType)); + @memset(@ptrCast([*]u8, &digest1)[0..@sizeOf(DigestType)], 0); + @memset(@ptrCast([*]u8, &digest2)[0..@sizeOf(DigestType)], 0); + @memset(@ptrCast([*]u8, &digest3)[0..@sizeOf(DigestType)], 0); + @memset(@ptrCast([*]u8, &digest4)[0..@sizeOf(DigestType)], 0); defer { std.mem.doNotOptimizeAway(&digest1); std.mem.doNotOptimizeAway(&digest2); diff --git a/src/sourcemap/sourcemap.zig b/src/sourcemap/sourcemap.zig index f1bbcc4c1..0b245d8c7 100644 --- a/src/sourcemap/sourcemap.zig +++ b/src/sourcemap/sourcemap.zig @@ -871,14 +871,14 @@ pub const LineOffsetTable = struct { if (column == 0) { line_byte_offset = @truncate( u32, - @ptrToInt(remaining.ptr) - @ptrToInt(contents.ptr), + @intFromPtr(remaining.ptr) - @intFromPtr(contents.ptr), ); } if (c > 0x7F and columns_for_non_ascii.items.len == 0) { - std.debug.assert(@ptrToInt( + std.debug.assert(@intFromPtr( remaining.ptr, - ) >= @ptrToInt( + ) >= @intFromPtr( contents.ptr, )); // we have a non-ASCII character, so we need to keep track of the @@ -886,9 +886,9 @@ pub const LineOffsetTable = struct { columns_for_non_ascii.appendAssumeCapacity(column); column_byte_offset = @intCast( u32, - (@ptrToInt( + (@intFromPtr( remaining.ptr, - ) - @ptrToInt( + ) - @intFromPtr( contents.ptr, )) - line_byte_offset, ); @@ -899,7 +899,7 @@ pub const LineOffsetTable = struct { if (columns_for_non_ascii.items.len > 0) { const line_bytes_so_far = @intCast(u32, @truncate( u32, - @ptrToInt(remaining.ptr) - @ptrToInt(contents.ptr), + @intFromPtr(remaining.ptr) - @intFromPtr(contents.ptr), )) - line_byte_offset; columns_for_non_ascii.ensureUnusedCapacity((line_bytes_so_far - column_byte_offset) + 1) catch unreachable; while (column_byte_offset <= line_bytes_so_far) : (column_byte_offset += 1) { @@ -956,7 +956,7 @@ pub const LineOffsetTable = struct { }, else => { // Mozilla's "source-map" library counts columns using UTF-16 code units - column += @as(i32, @boolToInt(c > 0xFFFF)) + 1; + column += @as(i32, @intFromBool(c > 0xFFFF)) + 1; }, } @@ -1032,7 +1032,7 @@ pub fn appendMappingToBuffer(buffer_: MutableString, last_byte: u8, prev_state: @as(u32, vlq[1].len) + @as(u32, vlq[2].len) + @as(u32, vlq[3].len); - buffer.growIfNeeded(total_len + @as(u32, @boolToInt(needs_comma))) catch unreachable; + buffer.growIfNeeded(total_len + @as(u32, @intFromBool(needs_comma))) catch unreachable; // Put commas in between mappings if (needs_comma) { @@ -1081,12 +1081,12 @@ pub const Chunk = struct { filename = filename[FileSystem.instance.top_level_dir.len - 1 ..]; } else if (filename.len > 0 and filename[0] != '/') { filename_buf[0] = '/'; - @memcpy(filename_buf[1..], filename.ptr, filename.len); + @memcpy(filename_buf[1..][0..filename.len], filename); filename = filename_buf[0 .. filename.len + 1]; } output.growIfNeeded( - filename.len + 2 + (source.contents.len * @as(usize, @boolToInt(include_sources_contents))) + chunk.buffer.list.items.len + 32 + 39 + 29 + 22 + 20, + filename.len + 2 + (source.contents.len * @as(usize, @intFromBool(include_sources_contents))) + chunk.buffer.list.items.len + 32 + 39 + 29 + 22 + 20, ) catch unreachable; try output.append("{\n \"version\":3,\n \"sources\": ["); @@ -1288,7 +1288,7 @@ pub const Chunk = struct { else => { // Mozilla's "source-map" library counts columns using UTF-16 code units - b.generated_column += @as(i32, @boolToInt(c > 0xFFFF)) + 1; + b.generated_column += @as(i32, @intFromBool(c > 0xFFFF)) + 1; }, } } diff --git a/src/standalone_bun.zig b/src/standalone_bun.zig index 85a689ded..e7363fb58 100644 --- a/src/standalone_bun.zig +++ b/src/standalone_bun.zig @@ -468,7 +468,7 @@ pub const StandaloneModuleGraph = struct { // at the very least // if you have not a ton of code, we only do a single read() call if (Environment.allow_assert or offsets.byte_count > 1024 * 3) { - const offset_from_end = trailer_bytes.len - (@ptrToInt(end) - @ptrToInt(@as([]u8, &trailer_bytes).ptr)); + const offset_from_end = trailer_bytes.len - (@intFromPtr(end) - @intFromPtr(@as([]u8, &trailer_bytes).ptr)); std.os.lseek_END(self_exe, -@intCast(i64, offset_from_end + offsets.byte_count)) catch return null; if (comptime Environment.allow_assert) { @@ -497,7 +497,7 @@ pub const StandaloneModuleGraph = struct { if (offsets.byte_count <= 1024 * 3) { // we already have the bytes end -= offsets.byte_count; - @memcpy(to_read.ptr, end, offsets.byte_count); + @memcpy(to_read[0..offsets.byte_count], end[0..offsets.byte_count]); if (comptime Environment.allow_assert) { std.debug.assert(bun.strings.eqlLong(to_read, end[0..offsets.byte_count], true)); } diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 9e069bb99..0c90b03ff 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -143,7 +143,7 @@ pub fn repeatingAlloc(allocator: std.mem.Allocator, count: usize, char: u8) ![]u } pub fn repeatingBuf(self: []u8, char: u8) void { - @memset(self.ptr, char, self.len); + @memset(self, char); } pub fn indexOfCharNeg(self: string, char: u8) i32 { @@ -259,7 +259,7 @@ pub inline fn indexOf(self: string, str: string) ?usize { const start = bun.C.memmem(self_ptr, self_len, str_ptr, str_len) orelse return null; - const i = @ptrToInt(start) - @ptrToInt(self_ptr); + const i = @intFromPtr(start) - @intFromPtr(self_ptr); std.debug.assert(i < self_len); return @intCast(usize, i); } @@ -370,7 +370,7 @@ pub const StringOrTinyString = struct { // This is a switch expression instead of a statement to make sure it uses the faster assembly return switch (this.is_tiny_string) { 1 => this.remainder_buf[0..this.remainder_len], - 0 => @intToPtr([*]const u8, std.mem.readIntNative(usize, this.remainder_buf[0..@sizeOf(usize)]))[0..std.mem.readIntNative(usize, this.remainder_buf[@sizeOf(usize) .. @sizeOf(usize) * 2])], + 0 => @ptrFromInt([*]const u8, std.mem.readIntNative(usize, this.remainder_buf[0..@sizeOf(usize)]))[0..std.mem.readIntNative(usize, this.remainder_buf[@sizeOf(usize) .. @sizeOf(usize) * 2])], }; } @@ -408,7 +408,7 @@ pub const StringOrTinyString = struct { .is_tiny_string = 1, .remainder_len = @truncate(u7, stringy.len), }; - @memcpy(&tiny.remainder_buf, stringy.ptr, tiny.remainder_len); + @memcpy(tiny.remainder_buf[0..tiny.remainder_len], stringy[0..tiny.remainder_len]); return tiny; }, else => { @@ -416,7 +416,7 @@ pub const StringOrTinyString = struct { .is_tiny_string = 0, .remainder_len = 0, }; - std.mem.writeIntNative(usize, tiny.remainder_buf[0..@sizeOf(usize)], @ptrToInt(stringy.ptr)); + std.mem.writeIntNative(usize, tiny.remainder_buf[0..@sizeOf(usize)], @intFromPtr(stringy.ptr)); std.mem.writeIntNative(usize, tiny.remainder_buf[@sizeOf(usize) .. @sizeOf(usize) * 2], stringy.len); return tiny; }, @@ -442,7 +442,7 @@ pub const StringOrTinyString = struct { .is_tiny_string = 0, .remainder_len = 0, }; - std.mem.writeIntNative(usize, tiny.remainder_buf[0..@sizeOf(usize)], @ptrToInt(stringy.ptr)); + std.mem.writeIntNative(usize, tiny.remainder_buf[0..@sizeOf(usize)], @intFromPtr(stringy.ptr)); std.mem.writeIntNative(usize, tiny.remainder_buf[@sizeOf(usize) .. @sizeOf(usize) * 2], stringy.len); return tiny; }, @@ -545,21 +545,21 @@ test "eqlComptimeCheckLen" { const sizes = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 23, 22, 24 }; inline for (sizes) |size| { var buf: [size]u8 = undefined; - std.mem.set(u8, &buf, 'a'); + @memset(&buf, 'a'); var buf_copy: [size]u8 = undefined; - std.mem.set(u8, &buf_copy, 'a'); + @memset(&buf_copy, 'a'); var bad: [size]u8 = undefined; - std.mem.set(u8, &bad, 'b'); + @memset(&bad, 'b'); try std.testing.expectEqual(std.mem.eql(u8, &buf, &buf_copy), eqlComptime(&buf, comptime brk: { var buf_copy_: [size]u8 = undefined; - std.mem.set(u8, &buf_copy_, 'a'); + @memset(&buf_copy_, 'a'); break :brk buf_copy_; })); try std.testing.expectEqual(std.mem.eql(u8, &buf, &bad), eqlComptime(&bad, comptime brk: { var buf_copy_: [size]u8 = undefined; - std.mem.set(u8, &buf_copy_, 'a'); + @memset(&buf_copy_, 'a'); break :brk buf_copy_; })); } @@ -570,21 +570,21 @@ test "eqlComptimeUTF16" { const sizes = [_]u16{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 23, 22, 24 }; inline for (sizes) |size| { var buf: [size]u16 = undefined; - std.mem.set(u16, &buf, @as(u8, 'a')); + @memset(&buf, @as(u8, 'a')); var buf_copy: [size]u16 = undefined; - std.mem.set(u16, &buf_copy, @as(u8, 'a')); + @memset(&buf_copy, @as(u8, 'a')); var bad: [size]u16 = undefined; - std.mem.set(u16, &bad, @as(u16, 'b')); + @memset(&bad, @as(u16, 'b')); try std.testing.expectEqual(std.mem.eql(u16, &buf, &buf_copy), eqlComptimeUTF16(&buf, comptime &brk: { var buf_copy_: [size]u8 = undefined; - std.mem.set(u8, &buf_copy_, @as(u8, 'a')); + @memset(&buf_copy_, @as(u8, 'a')); break :brk buf_copy_; })); try std.testing.expectEqual(std.mem.eql(u16, &buf, &bad), eqlComptimeUTF16(&bad, comptime &brk: { var buf_copy_: [size]u8 = undefined; - std.mem.set(u8, &buf_copy_, @as(u8, 'a')); + @memset(&buf_copy_, @as(u8, 'a')); break :brk buf_copy_; })); } @@ -628,7 +628,7 @@ test "StringOrTinyString Lowercase" { pub fn copy(buf: []u8, src: []const u8) []const u8 { const len = @min(buf.len, src.len); if (len > 0) - @memcpy(buf.ptr, src.ptr, len); + @memcpy(buf[0..len], src[0..len]); return buf[0..len]; } @@ -777,7 +777,7 @@ pub const QuotedFormatter = struct { pub fn quotedAlloc(allocator: std.mem.Allocator, self: string) !string { var count: usize = 0; for (self) |char| { - count += @boolToInt(char == '"'); + count += @intFromBool(char == '"'); } if (count == 0) { @@ -822,7 +822,7 @@ pub fn countChar(self: string, char: u8) usize { } while (remaining.len > 0) { - total += @as(usize, @boolToInt(remaining[0] == char)); + total += @as(usize, @intFromBool(remaining[0] == char)); remaining = remaining[1..]; } @@ -1035,20 +1035,20 @@ pub fn eqlLong(a_str: string, b_str: string, comptime check_len: bool) bool { pub inline fn append(allocator: std.mem.Allocator, self: string, other: string) ![]u8 { var buf = try allocator.alloc(u8, self.len + other.len); if (self.len > 0) - @memcpy(buf.ptr, self.ptr, self.len); + @memcpy(buf[0..self.len], self); if (other.len > 0) - @memcpy(buf.ptr + self.len, other.ptr, other.len); + @memcpy(buf[self.len..][0..other.len], other); return buf; } pub inline fn append3(allocator: std.mem.Allocator, self: string, other: string, third: string) ![]u8 { var buf = try allocator.alloc(u8, self.len + other.len + third.len); if (self.len > 0) - @memcpy(buf.ptr, self.ptr, self.len); + @memcpy(buf[0..self.len], self); if (other.len > 0) - @memcpy(buf.ptr + self.len, other.ptr, other.len); + @memcpy(buf[self.len..][0..other.len], other); if (third.len > 0) - @memcpy(buf.ptr + self.len + other.len, third.ptr, third.len); + @memcpy(buf[self.len + other.len ..][0..third.len], third); return buf; } @@ -1123,13 +1123,13 @@ pub fn copyU8IntoU16WithAlignment(comptime alignment: u21, output_: []align(alig // un-aligned data access is slow // so we attempt to align the data - while (!std.mem.isAligned(@ptrToInt(output.ptr), @alignOf(u16)) and input.len >= word) { + while (!std.mem.isAligned(@intFromPtr(output.ptr), @alignOf(u16)) and input.len >= word) { output[0] = input[0]; output = output[1..]; input = input[1..]; } - if (std.mem.isAligned(@ptrToInt(output.ptr), @alignOf(u16)) and input.len > 0) { + if (std.mem.isAligned(@intFromPtr(output.ptr), @alignOf(u16)) and input.len > 0) { copyU8IntoU16(@alignCast(@alignOf(u16), output.ptr)[0..output.len], input); return; } @@ -1211,7 +1211,7 @@ pub fn copyLatin1IntoASCII(dest: []u8, src: []const u8) void { const non_ascii_offset = strings.firstNonASCII(remain) orelse @truncate(u32, remain.len); if (non_ascii_offset > 0) { - @memcpy(to.ptr, remain.ptr, non_ascii_offset); + @memcpy(to[0..non_ascii_offset], remain[0..non_ascii_offset]); remain = remain[non_ascii_offset..]; to = to[non_ascii_offset..]; @@ -1498,7 +1498,7 @@ pub fn toUTF8ListWithTypeBun(list_: std.ArrayList(u8), comptime Type: type, utf1 utf16_remaining = utf16_remaining[replacement.len..]; const count: usize = replacement.utf8Width(); - try list.ensureTotalCapacityPrecise(i + count + list.items.len + @floatToInt(usize, (@intToFloat(f64, @truncate(u52, utf16_remaining.len)) * 1.2))); + try list.ensureTotalCapacityPrecise(i + count + list.items.len + @intFromFloat(usize, (@floatFromInt(f64, @truncate(u52, utf16_remaining.len)) * 1.2))); list.items.len += i; copyU16IntoU8( @@ -1535,7 +1535,7 @@ pub const EncodeIntoResult = struct { pub fn allocateLatin1IntoUTF8(allocator: std.mem.Allocator, comptime Type: type, latin1_: Type) ![]u8 { if (comptime bun.FeatureFlags.latin1_is_now_ascii) { var out = try allocator.alloc(u8, latin1_.len); - @memcpy(out.ptr, latin1_.ptr, latin1_.len); + @memcpy(out[0..latin1_.len], latin1_); return out; } @@ -1644,7 +1644,7 @@ pub fn allocateLatin1IntoUTF8WithList(list_: std.ArrayList(u8), offset_into_list } while (latin1.len > 0 and latin1[0] > 127) { - i = @ptrToInt(buf.ptr) - @ptrToInt(list.items.ptr); + i = @intFromPtr(buf.ptr) - @intFromPtr(list.items.ptr); list.items.len = i; try list.ensureUnusedCapacity(2 + latin1.len); buf = list.items.ptr[i..list.capacity]; @@ -1653,7 +1653,7 @@ pub fn allocateLatin1IntoUTF8WithList(list_: std.ArrayList(u8), offset_into_list buf = buf[2..]; } - i = @ptrToInt(buf.ptr) - @ptrToInt(list.items.ptr); + i = @intFromPtr(buf.ptr) - @intFromPtr(list.items.ptr); list.items.len = i; } @@ -1778,7 +1778,8 @@ pub fn copyLatin1IntoUTF8(buf_: []u8, comptime Type: type, latin1_: Type) Encode pub fn copyLatin1IntoUTF8StopOnNonASCII(buf_: []u8, comptime Type: type, latin1_: Type, comptime stop: bool) EncodeIntoResult { if (comptime bun.FeatureFlags.latin1_is_now_ascii) { const to_copy = @truncate(u32, @min(buf_.len, latin1_.len)); - @memcpy(buf_.ptr, latin1_.ptr, to_copy); + @memcpy(buf_[0..to_copy], latin1_[0..to_copy]); + return .{ .written = to_copy, .read = to_copy }; } @@ -1874,9 +1875,9 @@ pub fn copyLatin1IntoUTF8StopOnNonASCII(buf_: []u8, comptime Type: type, latin1_ { const end = latin1.ptr + @min(buf.len, latin1.len); - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(latin1.ptr + 8) > @ptrToInt(end)); - const start_ptr = @ptrToInt(buf.ptr); - const start_ptr_latin1 = @ptrToInt(latin1.ptr); + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(latin1.ptr + 8) > @intFromPtr(end)); + const start_ptr = @intFromPtr(buf.ptr); + const start_ptr_latin1 = @intFromPtr(latin1.ptr); while (latin1.ptr != end and latin1.ptr[0] <= 127) { buf.ptr[0] = latin1.ptr[0]; @@ -1884,8 +1885,8 @@ pub fn copyLatin1IntoUTF8StopOnNonASCII(buf_: []u8, comptime Type: type, latin1_ latin1.ptr += 1; } - buf.len -= @ptrToInt(buf.ptr) - start_ptr; - latin1.len -= @ptrToInt(latin1.ptr) - start_ptr_latin1; + buf.len -= @intFromPtr(buf.ptr) - start_ptr; + latin1.len -= @intFromPtr(latin1.ptr) - start_ptr_latin1; } } @@ -1933,22 +1934,22 @@ pub fn elementLengthLatin1IntoUTF8(comptime Type: type, latin1_: Type) usize { ptr += ascii_vector_size; } } else { - while (@ptrToInt(ptr + 8) < @ptrToInt(latin1_last)) { - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(ptr) <= @ptrToInt(latin1_last) and @ptrToInt(ptr) >= @ptrToInt(latin1_.ptr)); + while (@intFromPtr(ptr + 8) < @intFromPtr(latin1_last)) { + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) <= @intFromPtr(latin1_last) and @intFromPtr(ptr) >= @intFromPtr(latin1_.ptr)); const bytes = @bitCast(u64, ptr[0..8].*) & 0x8080808080808080; total_non_ascii_count += @popCount(bytes); ptr += 8; } - if (@ptrToInt(ptr + 4) < @ptrToInt(latin1_last)) { - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(ptr) <= @ptrToInt(latin1_last) and @ptrToInt(ptr) >= @ptrToInt(latin1_.ptr)); + if (@intFromPtr(ptr + 4) < @intFromPtr(latin1_last)) { + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) <= @intFromPtr(latin1_last) and @intFromPtr(ptr) >= @intFromPtr(latin1_.ptr)); const bytes = @bitCast(u32, ptr[0..4].*) & 0x80808080; total_non_ascii_count += @popCount(bytes); ptr += 4; } - if (@ptrToInt(ptr + 2) < @ptrToInt(latin1_last)) { - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(ptr) <= @ptrToInt(latin1_last) and @ptrToInt(ptr) >= @ptrToInt(latin1_.ptr)); + if (@intFromPtr(ptr + 2) < @intFromPtr(latin1_last)) { + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) <= @intFromPtr(latin1_last) and @intFromPtr(ptr) >= @intFromPtr(latin1_.ptr)); const bytes = @bitCast(u16, ptr[0..2].*) & 0x8080; total_non_ascii_count += @popCount(bytes); ptr += 2; @@ -1956,14 +1957,14 @@ pub fn elementLengthLatin1IntoUTF8(comptime Type: type, latin1_: Type) usize { } while (ptr != latin1_last) { - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(ptr) < @ptrToInt(latin1_last)); + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) < @intFromPtr(latin1_last)); - total_non_ascii_count += @as(usize, @boolToInt(ptr[0] > 127)); + total_non_ascii_count += @as(usize, @intFromBool(ptr[0] > 127)); ptr += 1; } // assert we never go out of bounds - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(ptr) <= @ptrToInt(latin1_last) and @ptrToInt(ptr) >= @ptrToInt(latin1_.ptr)); + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) <= @intFromPtr(latin1_last) and @intFromPtr(ptr) >= @intFromPtr(latin1_.ptr)); } // each non-ascii latin1 character becomes 2 UTF8 characters @@ -2198,8 +2199,8 @@ pub fn escapeHTMLForLatin1Input(allocator: std.mem.Allocator, latin1: []const u8 if (comptime Environment.allow_assert) std.debug.assert(buf.capacity == 0); buf = try std.ArrayList(u8).initCapacity(allocator, latin1.len + 6); - const copy_len = @ptrToInt(remaining.ptr) - @ptrToInt(latin1.ptr); - @memcpy(buf.items.ptr, latin1.ptr, copy_len); + const copy_len = @intFromPtr(remaining.ptr) - @intFromPtr(latin1.ptr); + @memcpy(buf.items[0..copy_len], latin1[0..copy_len]); buf.items.len = copy_len; any_needs_escape = true; comptime var i: usize = 0; @@ -2311,8 +2312,8 @@ pub fn escapeHTMLForLatin1Input(allocator: std.mem.Allocator, latin1: []const u8 if (comptime Environment.allow_assert) std.debug.assert(buf.capacity == 0); buf = try std.ArrayList(u8).initCapacity(allocator, latin1.len + @as(usize, Scalar.lengths[c])); - const copy_len = @ptrToInt(ptr) - @ptrToInt(latin1.ptr); - @memcpy(buf.items.ptr, latin1.ptr, copy_len); + const copy_len = @intFromPtr(ptr) - @intFromPtr(latin1.ptr); + @memcpy(buf.items[0..copy_len], latin1[0..copy_len]); buf.items.len = copy_len; any_needs_escape = true; break :scan_and_allocate_lazily; @@ -2474,9 +2475,9 @@ pub fn escapeHTMLForUTF16Input(allocator: std.mem.Allocator, utf16: []const u16) } buf = try std.ArrayList(u16).initCapacity(allocator, utf16.len + 6); - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(remaining.ptr + i) >= @ptrToInt(utf16.ptr)); - const to_copy = std.mem.sliceAsBytes(utf16)[0 .. @ptrToInt(remaining.ptr + i) - @ptrToInt(utf16.ptr)]; - @memcpy(@ptrCast([*]align(2) u8, buf.items.ptr), to_copy.ptr, to_copy.len); + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(remaining.ptr + i) >= @intFromPtr(utf16.ptr)); + const to_copy = std.mem.sliceAsBytes(utf16)[0 .. @intFromPtr(remaining.ptr + i) - @intFromPtr(utf16.ptr)]; + @memcpy(@ptrCast([*]align(2) u8, buf.items[0..to_copy.len]), to_copy); buf.items.len = std.mem.bytesAsSlice(u16, to_copy).len; while (i < ascii_u16_vector_size) { @@ -2585,14 +2586,13 @@ pub fn escapeHTMLForUTF16Input(allocator: std.mem.Allocator, utf16: []const u16) switch (ptr[0]) { '"', '&', '\'', '<', '>' => |c| { buf = try std.ArrayList(u16).initCapacity(allocator, utf16.len + @as(usize, Scalar.lengths[c])); - if (comptime Environment.allow_assert) std.debug.assert(@ptrToInt(ptr) >= @ptrToInt(utf16.ptr)); + if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) >= @intFromPtr(utf16.ptr)); - const to_copy = std.mem.sliceAsBytes(utf16)[0 .. @ptrToInt(ptr) - @ptrToInt(utf16.ptr)]; + const to_copy = std.mem.sliceAsBytes(utf16)[0 .. @intFromPtr(ptr) - @intFromPtr(utf16.ptr)]; @memcpy( - @ptrCast([*]align(2) u8, buf.items.ptr), - to_copy.ptr, - to_copy.len, + @ptrCast([*]align(2) u8, buf.items[0..to_copy.len]), + to_copy, ); buf.items.len = std.mem.bytesAsSlice(u16, to_copy).len; @@ -3159,7 +3159,7 @@ pub fn firstNonASCIIWithType(comptime Type: type, slice: Type) ?u32 { if (@reduce(.Max, vec) > 127) { const Int = u64; const size = @sizeOf(Int); - remaining.len -= @ptrToInt(remaining.ptr) - @ptrToInt(remaining_start); + remaining.len -= @intFromPtr(remaining.ptr) - @intFromPtr(remaining_start); { const bytes = @bitCast(Int, remaining[0..size].*); @@ -3206,7 +3206,7 @@ pub fn firstNonASCIIWithType(comptime Type: type, slice: Type) ?u32 { // we only need to subtract the length once at the very end remaining.ptr += ascii_vector_size; } - remaining.len -= @ptrToInt(remaining.ptr) - @ptrToInt(remaining_start); + remaining.len -= @intFromPtr(remaining.ptr) - @intFromPtr(remaining_start); } } @@ -3219,7 +3219,7 @@ pub fn firstNonASCIIWithType(comptime Type: type, slice: Type) ?u32 { if (comptime Environment.enableSIMD) { // these assertions exist more so for LLVM std.debug.assert(remaining.len < ascii_vector_size); - std.debug.assert(@ptrToInt(remaining.ptr + ascii_vector_size) > @ptrToInt(remaining_end)); + std.debug.assert(@intFromPtr(remaining.ptr + ascii_vector_size) > @intFromPtr(remaining_end)); } if (remaining.len >= size) { @@ -3229,7 +3229,7 @@ pub fn firstNonASCIIWithType(comptime Type: type, slice: Type) ?u32 { const mask = bytes & 0x8080808080808080; if (mask > 0) { - remaining.len -= @ptrToInt(remaining.ptr) - @ptrToInt(remaining_start); + remaining.len -= @intFromPtr(remaining.ptr) - @intFromPtr(remaining_start); const first_set_byte = @ctz(mask) / 8; if (comptime Environment.allow_assert) { std.debug.assert(remaining[first_set_byte] > 127); @@ -3244,7 +3244,7 @@ pub fn firstNonASCIIWithType(comptime Type: type, slice: Type) ?u32 { remaining.ptr += size; } - remaining.len -= @ptrToInt(remaining.ptr) - @ptrToInt(remaining_start); + remaining.len -= @intFromPtr(remaining.ptr) - @intFromPtr(remaining_start); } } @@ -3253,7 +3253,7 @@ pub fn firstNonASCIIWithType(comptime Type: type, slice: Type) ?u32 { for (remaining) |*char| { if (char.* > 127) { // try to prevent it from reading the length of the slice - return @truncate(u32, @ptrToInt(char) - @ptrToInt(slice.ptr)); + return @truncate(u32, @intFromPtr(char) - @intFromPtr(slice.ptr)); } } @@ -3291,7 +3291,7 @@ pub fn indexOfNewlineOrNonASCIIOrANSI(slice_: []const u8, offset: u32) ?u32 { for (remaining) |*char_| { const char = char_.*; if (char > 127 or char < 0x20 or char == '\n' or char == '\r' or char == '\x1b') { - return @truncate(u32, (@ptrToInt(char_) - @ptrToInt(slice.ptr))) + offset; + return @truncate(u32, (@intFromPtr(char_) - @intFromPtr(slice.ptr))) + offset; } } @@ -3339,7 +3339,7 @@ pub fn indexOfNewlineOrNonASCIICheckStart(slice_: []const u8, offset: u32, compt for (remaining) |*char_| { const char = char_.*; if (char > 127 or char < 0x20 or char == '\n' or char == '\r') { - return @truncate(u32, (@ptrToInt(char_) - @ptrToInt(slice.ptr))) + offset; + return @truncate(u32, (@intFromPtr(char_) - @intFromPtr(slice.ptr))) + offset; } } @@ -3401,7 +3401,7 @@ pub fn indexOfNeedsEscape(slice: []const u8) ?u32 { const bitmask = @bitCast(AsciiVectorInt, cmp); const first = @ctz(bitmask); - return @as(u32, first) + @truncate(u32, @ptrToInt(remaining.ptr) - @ptrToInt(slice.ptr)); + return @as(u32, first) + @truncate(u32, @intFromPtr(remaining.ptr) - @intFromPtr(slice.ptr)); } remaining = remaining[ascii_vector_size..]; @@ -3411,7 +3411,7 @@ pub fn indexOfNeedsEscape(slice: []const u8) ?u32 { for (remaining) |*char_| { const char = char_.*; if (char > 127 or char < 0x20 or char == '\\' or char == '"') { - return @truncate(u32, @ptrToInt(char_) - @ptrToInt(slice.ptr)); + return @truncate(u32, @intFromPtr(char_) - @intFromPtr(slice.ptr)); } } @@ -3428,11 +3428,11 @@ test "indexOfNeedsEscape" { pub fn indexOfCharZ(sliceZ: [:0]const u8, char: u8) ?u63 { const ptr = bun.C.strchr(sliceZ.ptr, char) orelse return null; - const pos = @ptrToInt(ptr) - @ptrToInt(sliceZ.ptr); + const pos = @intFromPtr(ptr) - @intFromPtr(sliceZ.ptr); if (comptime Environment.allow_assert) - std.debug.assert(@ptrToInt(sliceZ.ptr) <= @ptrToInt(ptr) and - @ptrToInt(ptr) < @ptrToInt(sliceZ.ptr + sliceZ.len) and + std.debug.assert(@intFromPtr(sliceZ.ptr) <= @intFromPtr(ptr) and + @intFromPtr(ptr) < @intFromPtr(sliceZ.ptr + sliceZ.len) and pos <= sliceZ.len); return @truncate(u63, pos); @@ -3447,7 +3447,7 @@ pub fn indexOfCharUsize(slice: []const u8, char: u8) ?usize { return null; const ptr = bun.C.memchr(slice.ptr, char, slice.len) orelse return null; - const i = @ptrToInt(ptr) - @ptrToInt(slice.ptr); + const i = @intFromPtr(ptr) - @intFromPtr(slice.ptr); std.debug.assert(i < slice.len); std.debug.assert(slice[i] == char); @@ -3513,7 +3513,7 @@ pub fn indexOfNotChar(slice: []const u8, char: u8) ?u32 { for (remaining) |*current| { if (current.* != char) { - return @truncate(u32, @ptrToInt(current) - @ptrToInt(slice.ptr)); + return @truncate(u32, @intFromPtr(current) - @intFromPtr(slice.ptr)); } } @@ -3718,7 +3718,7 @@ pub fn firstNonASCII16CheckMin(comptime Slice: type, slice: Slice, comptime chec // @reduce doesn't tell us the index though const min_value = @reduce(.Min, vec); if (min_value < 0x20 or max_value > 127) { - remaining.len -= (@ptrToInt(remaining.ptr) - @ptrToInt(remaining_start)) / 2; + remaining.len -= (@intFromPtr(remaining.ptr) - @intFromPtr(remaining_start)) / 2; // this is really slow // it does it element-wise for every single u8 on the vector @@ -3734,7 +3734,7 @@ pub fn firstNonASCII16CheckMin(comptime Slice: type, slice: Slice, comptime chec } } else if (comptime !check_min) { if (max_value > 127) { - remaining.len -= (@ptrToInt(remaining.ptr) - @ptrToInt(remaining_start)) / 2; + remaining.len -= (@intFromPtr(remaining.ptr) - @intFromPtr(remaining_start)) / 2; const cmp = vec > max_u16_ascii; const bitmask: u8 = @bitCast(u8, cmp); @@ -3747,7 +3747,7 @@ pub fn firstNonASCII16CheckMin(comptime Slice: type, slice: Slice, comptime chec remaining.ptr += ascii_u16_vector_size; } - remaining.len -= (@ptrToInt(remaining.ptr) - @ptrToInt(remaining_start)) / 2; + remaining.len -= (@intFromPtr(remaining.ptr) - @intFromPtr(remaining_start)) / 2; } } @@ -3820,7 +3820,7 @@ test "indexOfNotChar" { var yes: [312]u8 = undefined; var i: usize = 0; while (i < yes.len) { - @memset(&yes, 'a', yes.len); + @memset(yes, 'a'); yes[i] = 'b'; if (comptime Environment.allow_assert) std.debug.assert(indexOfNotChar(&yes, 'a').? == i); i += 1; @@ -4077,12 +4077,12 @@ const sort_desc = std.sort.desc(u8); pub fn sortAsc(in: []string) void { // TODO: experiment with simd to see if it's faster - std.sort.sort([]const u8, in, {}, cmpStringsAsc); + std.sort.block([]const u8, in, {}, cmpStringsAsc); } pub fn sortDesc(in: []string) void { // TODO: experiment with simd to see if it's faster - std.sort.sort([]const u8, in, {}, cmpStringsDesc); + std.sort.block([]const u8, in, {}, cmpStringsDesc); } pub const StringArrayByIndexSorter = struct { @@ -4331,8 +4331,8 @@ pub fn moveAllSlices(comptime Type: type, container: *Type, from: string, to: st inline for (fields_we_care_about) |name| { const slice = @field(container, name); - if ((@ptrToInt(from.ptr) + from.len) >= @ptrToInt(slice.ptr) + slice.len and - (@ptrToInt(from.ptr) <= @ptrToInt(slice.ptr))) + if ((@intFromPtr(from.ptr) + from.len) >= @intFromPtr(slice.ptr) + slice.len and + (@intFromPtr(from.ptr) <= @intFromPtr(slice.ptr))) { @field(container, name) = moveSlice(slice, from, to); } @@ -4344,14 +4344,14 @@ pub fn moveSlice(slice: string, from: string, to: string) string { std.debug.assert(from.len <= to.len and from.len >= slice.len); // assert we are in bounds std.debug.assert( - (@ptrToInt(from.ptr) + from.len) >= - @ptrToInt(slice.ptr) + slice.len and - (@ptrToInt(from.ptr) <= @ptrToInt(slice.ptr)), + (@intFromPtr(from.ptr) + from.len) >= + @intFromPtr(slice.ptr) + slice.len and + (@intFromPtr(from.ptr) <= @intFromPtr(slice.ptr)), ); std.debug.assert(eqlLong(from, to[0..from.len], false)); // data should be identical } - const ptr_offset = @ptrToInt(slice.ptr) - @ptrToInt(from.ptr); + const ptr_offset = @intFromPtr(slice.ptr) - @intFromPtr(from.ptr); const result = to[ptr_offset..][0..slice.len]; if (comptime Environment.allow_assert) std.debug.assert(eqlLong(slice, result, false)); // data should be identical @@ -4463,7 +4463,7 @@ pub fn cloneNormalizingSeparators( if (base[0] == std.fs.path.sep) { buf[0] = std.fs.path.sep; } - var remain = buf[@as(usize, @boolToInt(base[0] == std.fs.path.sep))..]; + var remain = buf[@as(usize, @intFromBool(base[0] == std.fs.path.sep))..]; while (tokenized.next()) |token| { if (token.len == 0) continue; @@ -4477,7 +4477,7 @@ pub fn cloneNormalizingSeparators( } remain[0] = 0; - return buf[0 .. @ptrToInt(remain.ptr) - @ptrToInt(buf.ptr)]; + return buf[0 .. @intFromPtr(remain.ptr) - @intFromPtr(buf.ptr)]; } pub fn leftHasAnyInRight(to_check: []const string, against: []const string) bool { @@ -4517,7 +4517,7 @@ pub fn concatWithLength( var out = try allocator.alloc(u8, length); var remain = out; for (args) |arg| { - @memcpy(remain.ptr, arg.ptr, arg.len); + @memcpy(remain[0..arg.len], arg); remain = remain[arg.len..]; } std.debug.assert(remain.len == 0); // all bytes should be used @@ -4590,7 +4590,8 @@ pub fn concatIfNeeded( dest.* = buf; var remain = buf[0..]; for (args) |arg| { - @memcpy(remain.ptr, arg.ptr, arg.len); + @memcpy(remain[0..arg.len], arg); + remain = remain[arg.len..]; } std.debug.assert(remain.len == 0); diff --git a/src/string_joiner.zig b/src/string_joiner.zig index c1b42dee7..9abdc8a58 100644 --- a/src/string_joiner.zig +++ b/src/string_joiner.zig @@ -43,7 +43,7 @@ pub fn done(this: *Joiner, allocator: Allocator) ![]u8 { var el_ = this.head; while (el_) |join| { const to_join = join.data.slice[join.data.offset..]; - @memcpy(remaining.ptr, to_join.ptr, to_join.len); + @memcpy(remaining[0..to_join.len], to_join); remaining = remaining[@min(remaining.len, to_join.len)..]; @@ -67,7 +67,8 @@ pub fn doneWithEnd(this: *Joiner, allocator: Allocator, end: []const u8) ![]u8 { if (this.head == null) { var slice = try allocator.alloc(u8, end.len); - @memcpy(slice.ptr, end.ptr, end.len); + @memcpy(slice[0..end.len], end); + return slice; } @@ -76,7 +77,7 @@ pub fn doneWithEnd(this: *Joiner, allocator: Allocator, end: []const u8) ![]u8 { var el_ = this.head; while (el_) |join| { const to_join = join.data.slice[join.data.offset..]; - @memcpy(remaining.ptr, to_join.ptr, to_join.len); + @memcpy(remaining[0..to_join.len], to_join); remaining = remaining[@min(remaining.len, to_join.len)..]; @@ -90,7 +91,7 @@ pub fn doneWithEnd(this: *Joiner, allocator: Allocator, end: []const u8) ![]u8 { if (this.use_pool) prev.release(); } - @memcpy(remaining.ptr, end.ptr, end.len); + @memcpy(remaining[0..end.len], end); remaining = remaining[@min(remaining.len, end.len)..]; @@ -126,7 +127,7 @@ pub fn append(this: *Joiner, slice: string, offset: u32, allocator: ?Allocator) else (this.node_allocator.create(Joinable.Pool.Node) catch unreachable); - this.watcher.estimated_count += @boolToInt( + this.watcher.estimated_count += @intFromBool( this.watcher.input.len > 0 and bun.strings.contains(data, this.watcher.input), ); diff --git a/src/string_mutable.zig b/src/string_mutable.zig index cb8e1633e..103f03aa3 100644 --- a/src/string_mutable.zig +++ b/src/string_mutable.zig @@ -180,7 +180,7 @@ pub const MutableString = struct { try self.list.ensureTotalCapacityPrecise(self.allocator, self.list.items.len + slice.len); var end = self.list.items.ptr + self.list.items.len; self.list.items.len += slice.len; - @memcpy(end, slice.ptr, slice.len); + @memcpy(end[0..slice.len], slice); } pub inline fn reset( @@ -329,7 +329,7 @@ pub const MutableString = struct { if (pending.len + this.pos > max) { try this.flush(); } - @memcpy(this.remain().ptr, pending.ptr, pending.len); + @memcpy(this.remain()[0..pending.len], pending); this.pos += pending.len; } diff --git a/src/string_types.zig b/src/string_types.zig index 5063eada6..c091e2a86 100644 --- a/src/string_types.zig +++ b/src/string_types.zig @@ -40,19 +40,19 @@ pub const PathString = packed struct { pub inline fn slice(this: anytype) string { @setRuntimeSafety(false); // "cast causes pointer to be null" is fine here. if it is null, the len will be 0. - return @intToPtr([*]u8, @intCast(usize, this.ptr))[0..this.len]; + return @ptrFromInt([*]u8, @intCast(usize, this.ptr))[0..this.len]; } pub inline fn sliceAssumeZ(this: anytype) stringZ { @setRuntimeSafety(false); // "cast causes pointer to be null" is fine here. if it is null, the len will be 0. - return @intToPtr([*:0]u8, @intCast(usize, this.ptr))[0..this.len :0]; + return @ptrFromInt([*:0]u8, @intCast(usize, this.ptr))[0..this.len :0]; } pub inline fn init(str: string) @This() { @setRuntimeSafety(false); // "cast causes pointer to be null" is fine here. if it is null, the len will be 0. return @This(){ - .ptr = @truncate(PointerIntType, @ptrToInt(str.ptr)), + .ptr = @truncate(PointerIntType, @intFromPtr(str.ptr)), .len = @truncate(PathInt, str.len), }; } @@ -78,13 +78,13 @@ pub const HashedString = struct { len: u32, hash: u32, - pub const empty = HashedString{ .ptr = @intToPtr([*]const u8, 0xDEADBEEF), .len = 0, .hash = 0 }; + pub const empty = HashedString{ .ptr = @ptrFromInt([*]const u8, 0xDEADBEEF), .len = 0, .hash = 0 }; pub fn init(buf: string) HashedString { return HashedString{ .ptr = buf.ptr, .len = @truncate(u32, buf.len), - .hash = @truncate(u32, std.hash.Wyhash.hash(0, buf)), + .hash = @truncate(u32, bun.hash(buf)), }; } @@ -106,7 +106,7 @@ pub const HashedString = struct { return ((@max(this.hash, other.hash) > 0 and this.hash == other.hash) or (this.ptr == other.ptr)) and this.len == other.len; }, else => { - return @as(usize, this.len) == other.len and @truncate(u32, std.hash.Wyhash.hash(0, other[0..other.len])) == this.hash; + return @as(usize, this.len) == other.len and @truncate(u32, bun.hash(other[0..other.len])) == this.hash; }, } } diff --git a/src/sync.zig b/src/sync.zig index 23cde775a..598831099 100644 --- a/src/sync.zig +++ b/src/sync.zig @@ -28,7 +28,7 @@ pub const ThreadPool = struct { errdefer self.deinit(); - const num_workers = std.math.max(1, config.max_threads orelse std.Thread.cpuCount() catch 1); + const num_workers = @max(1, config.max_threads orelse std.Thread.cpuCount() catch 1); self.workers = try self.allocator.alloc(Worker, num_workers); for (&self.workers) |*worker| { @@ -91,8 +91,8 @@ pub const ThreadPool = struct { idle_workers: usize = 0, fn pack(self: State) usize { - return ((@as(usize, @boolToInt(self.is_shutdown)) << 0) | - (@as(usize, @boolToInt(self.is_notified)) << 1) | + return ((@as(usize, @intFromBool(self.is_shutdown)) << 0) | + (@as(usize, @intFromBool(self.is_notified)) << 1) | (self.idle_workers << 2)); } @@ -225,7 +225,7 @@ pub const ThreadPool = struct { current = self; defer current = old_current; - var tick = @ptrToInt(self); + var tick = @intFromPtr(self); var prng = std.rand.DefaultPrng.init(tick); while (true) { @@ -978,7 +978,7 @@ else if (@import("builtin").os.tag == .linux) Futex.wait( @ptrCast(*const i32, &self.state), - @enumToInt(new_state), + @intFromEnum(new_state), ); } } diff --git a/src/tagged_pointer.zig b/src/tagged_pointer.zig index 2cf3c41f5..a246ee355 100644 --- a/src/tagged_pointer.zig +++ b/src/tagged_pointer.zig @@ -23,7 +23,7 @@ pub const TaggedPointer = packed struct { @compileError(@typeName(Ptr) ++ " must be a ptr, received: " ++ @tagName(@typeInfo(Ptr))); } - const address = @ptrToInt(ptr); + const address = @intFromPtr(ptr); return TaggedPointer{ ._ptr = @truncate(AddressableSize, address), @@ -32,20 +32,20 @@ pub const TaggedPointer = packed struct { } pub inline fn get(this: TaggedPointer, comptime Type: type) *Type { - return @intToPtr(*Type, @intCast(usize, this._ptr)); + return @ptrFromInt(*Type, @intCast(usize, this._ptr)); } pub inline fn from(val: anytype) TaggedPointer { const ValueType = @TypeOf(val); return switch (ValueType) { f64, i64, u64 => @bitCast(TaggedPointer, val), - ?*anyopaque, *anyopaque => @bitCast(TaggedPointer, @ptrToInt(val)), + ?*anyopaque, *anyopaque => @bitCast(TaggedPointer, @intFromPtr(val)), else => @compileError("Unsupported type: " ++ @typeName(ValueType)), }; } pub inline fn to(this: TaggedPointer) *anyopaque { - return @intToPtr(*anyopaque, @bitCast(u64, this)); + return @ptrFromInt(*anyopaque, @bitCast(u64, this)); } }; @@ -111,7 +111,7 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { } pub inline fn tag(this: This) TagType { - return @intToEnum(TagType, this.repr.data); + return @enumFromInt(TagType, this.repr.data); } /// unsafely cast a tagged pointer to a specific type, without checking that it's really that type @@ -122,7 +122,7 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { pub inline fn is(this: This, comptime Type: type) bool { comptime assert_type(Type); - return this.repr.data == comptime @enumToInt(@field(Tag, typeBaseName(@typeName(Type)))); + return this.repr.data == comptime @intFromEnum(@field(Tag, typeBaseName(@typeName(Type)))); } pub fn set(this: *@This(), _ptr: anytype) void { @@ -135,9 +135,9 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { pub inline fn isValid(this: This) bool { return switch (this.repr.data) { - @enumToInt( + @intFromEnum( @field(Tag, typeBaseName(@typeName(Types[Types.len - 1]))), - )...@enumToInt( + )...@intFromEnum( @field(Tag, typeBaseName(@typeName(Types[0]))), ) => true, else => false, @@ -162,7 +162,7 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { const name = comptime typeBaseName(@typeName(Type)); // there will be a compiler error if the passed in type doesn't exist in the enum - return This{ .repr = TaggedPointer.init(_ptr, @enumToInt(@field(Tag, name))) }; + return This{ .repr = TaggedPointer.init(_ptr, @intFromEnum(@field(Tag, name))) }; } }; } diff --git a/src/thread_pool.zig b/src/thread_pool.zig index b6e766cf9..3359311d6 100644 --- a/src/thread_pool.zig +++ b/src/thread_pool.zig @@ -59,8 +59,8 @@ pub const Config = struct { /// Statically initialize the thread pool using the configuration. pub fn init(config: Config) ThreadPool { return .{ - .stack_size = std.math.max(1, config.stack_size), - .max_threads = std.math.max(1, config.max_threads), + .stack_size = @max(1, config.stack_size), + .max_threads = @max(1, config.max_threads), }; } @@ -945,11 +945,11 @@ pub const Node = struct { var stack = self.stack.load(.Monotonic); while (true) { // Attach the list to the stack (pt. 1) - list.tail.next = @intToPtr(?*Node, stack & PTR_MASK); + list.tail.next = @ptrFromInt(?*Node, stack & PTR_MASK); // Update the stack with the list (pt. 2). // Don't change the HAS_CACHE and IS_CONSUMING bits of the consumer. - var new_stack = @ptrToInt(list.head); + var new_stack = @intFromPtr(list.head); assert(new_stack & ~PTR_MASK == 0); new_stack |= (stack & ~PTR_MASK); @@ -985,7 +985,7 @@ pub const Node = struct { new_stack, .Acquire, .Monotonic, - ) orelse return self.cache orelse @intToPtr(*Node, stack & PTR_MASK); + ) orelse return self.cache orelse @ptrFromInt(*Node, stack & PTR_MASK); } } @@ -1022,7 +1022,7 @@ pub const Node = struct { assert(stack & IS_CONSUMING != 0); assert(stack & PTR_MASK != 0); - const node = @intToPtr(*Node, stack & PTR_MASK); + const node = @ptrFromInt(*Node, stack & PTR_MASK); consumer_ref.* = node.next; return node; } diff --git a/src/toml/toml_lexer.zig b/src/toml/toml_lexer.zig index 1e739822c..7d576af86 100644 --- a/src/toml/toml_lexer.zig +++ b/src/toml/toml_lexer.zig @@ -166,7 +166,7 @@ pub const Lexer = struct { inline fn step(lexer: *Lexer) void { lexer.code_point = lexer.nextCodepoint(); - lexer.line_number += @as(u32, @boolToInt(lexer.code_point == '\n')); + lexer.line_number += @as(u32, @intFromBool(lexer.code_point == '\n')); } pub const Error = error{ @@ -466,7 +466,7 @@ pub const Lexer = struct { for (text) |c| { number = number * 10 + @intCast(u32, c - '0'); } - lexer.number = @intToFloat(f64, number); + lexer.number = @floatFromInt(f64, number); } else { // Parse a double-precision floating-point number; if (std.fmt.parseFloat(f64, text)) |num| { @@ -1115,7 +1115,7 @@ pub const Lexer = struct { pub fn unexpected(lexer: *Lexer) !void { const found = finder: { - lexer.start = std.math.min(lexer.start, lexer.end); + lexer.start = @min(lexer.start, lexer.end); if (lexer.start == lexer.source.contents.len) { break :finder "end of file"; @@ -1215,5 +1215,5 @@ pub fn isLatin1Identifier(comptime Buffer: type, name: Buffer) bool { } inline fn float64(num: anytype) f64 { - return @intToFloat(f64, num); + return @floatFromInt(f64, num); } diff --git a/src/url.zig b/src/url.zig index d0fcdab38..66c4ff015 100644 --- a/src/url.zig +++ b/src/url.zig @@ -275,8 +275,8 @@ pub const URL = struct { if (base.len > path_offset and base[path_offset] == '/' and offset > 0) { if (url.search.len > 0) { - url.pathname = base[path_offset..std.math.min( - std.math.min(offset + url.search.len, base.len), + url.pathname = base[path_offset..@min( + @min(offset + url.search.len, base.len), hash_offset, )]; } else if (hash_offset < std.math.maxInt(u32)) { @@ -289,8 +289,8 @@ pub const URL = struct { if (url.path.len > 1) { const trimmed = std.mem.trim(u8, url.path, "/"); if (trimmed.len > 1) { - url.path = url.path[std.math.min( - std.math.max(@ptrToInt(trimmed.ptr) - @ptrToInt(url.path.ptr), 1) - 1, + url.path = url.path[@min( + @max(@intFromPtr(trimmed.ptr) - @intFromPtr(url.path.ptr), 1) - 1, hash_offset, )..]; } else { @@ -542,12 +542,12 @@ pub const QueryStringMap = struct { } pub fn getIndex(this: *const QueryStringMap, input: string) ?usize { - const hash = std.hash.Wyhash.hash(0, input); + const hash = bun.hash(input); return std.mem.indexOfScalar(u64, this.list.items(.name_hash), hash); } pub fn get(this: *const QueryStringMap, input: string) ?string { - const hash = std.hash.Wyhash.hash(0, input); + const hash = bun.hash(input); const _slice = this.list.slice(); const i = std.mem.indexOfScalar(u64, _slice.items(.name_hash), hash) orelse return null; return this.str(_slice.items(.value)[i]); @@ -558,7 +558,7 @@ pub const QueryStringMap = struct { } pub fn getAll(this: *const QueryStringMap, input: string, target: []string) usize { - const hash = std.hash.Wyhash.hash(0, input); + const hash = bun.hash(input); const _slice = this.list.slice(); return @call(.always_inline, getAllWithHashFromOffset, .{ this, target, hash, 0, _slice }); } @@ -638,7 +638,7 @@ pub const QueryStringMap = struct { try writer.writeAll(name_slice); buf_writer_pos += @truncate(u32, name_slice.len); - var name_hash: u64 = std.hash.Wyhash.hash(0, name_slice); + var name_hash: u64 = bun.hash(name_slice); value.length = PercentEncoding.decode(Writer, writer, result.rawValue(scanner.pathname.pathname)) catch continue; value.offset = buf_writer_pos; @@ -659,9 +659,9 @@ pub const QueryStringMap = struct { name.length = PercentEncoding.decode(Writer, writer, scanner.query.query_string[name.offset..][0..name.length]) catch continue; name.offset = buf_writer_pos; buf_writer_pos += name.length; - name_hash = std.hash.Wyhash.hash(0, buf.items[name.offset..][0..name.length]); + name_hash = bun.hash(buf.items[name.offset..][0..name.length]); } else { - name_hash = std.hash.Wyhash.hash(0, result.rawName(scanner.query.query_string)); + name_hash = bun.hash(result.rawName(scanner.query.query_string)); if (std.mem.indexOfScalar(u64, list_slice.items(.name_hash), name_hash)) |index| { // query string parameters should not override route parameters @@ -726,7 +726,7 @@ pub const QueryStringMap = struct { var name = result.name; var value = result.value; - const name_hash: u64 = std.hash.Wyhash.hash(0, result.rawName(query_string)); + const name_hash: u64 = bun.hash(result.rawName(query_string)); list.appendAssumeCapacity(Param{ .name = name, .value = value, .name_hash = name_hash }); } @@ -752,9 +752,9 @@ pub const QueryStringMap = struct { name.length = PercentEncoding.decode(Writer, writer, query_string[name.offset..][0..name.length]) catch continue; name.offset = buf_writer_pos; buf_writer_pos += name.length; - name_hash = std.hash.Wyhash.hash(0, buf.items[name.offset..][0..name.length]); + name_hash = bun.hash(buf.items[name.offset..][0..name.length]); } else { - name_hash = std.hash.Wyhash.hash(0, result.rawName(query_string)); + name_hash = bun.hash(result.rawName(query_string)); if (std.mem.indexOfScalar(u64, list_slice.items(.name_hash), name_hash)) |index| { name = list_slice.items(.name)[index]; } else { @@ -1126,7 +1126,7 @@ pub const FormData = struct { break; }, '\\' => { - i += @boolToInt(field_value.len > i + 1 and field_value[i + 1] == '"'); + i += @intFromBool(field_value.len > i + 1 and field_value[i + 1] == '"'); }, // the spec requires a end quote, but some browsers don't send it else => {}, @@ -1434,7 +1434,7 @@ test "Scanner.next - % encoded" { test "PercentEncoding.decode" { var buffer: [4096]u8 = undefined; - std.mem.set(u8, &buffer, 0); + @memset(&buffer, 0); var stream = std.io.fixedBufferStream(&buffer); var writer = stream.writer(); diff --git a/src/util.zig b/src/util.zig index fbc98d666..1664cadd9 100644 --- a/src/util.zig +++ b/src/util.zig @@ -237,7 +237,7 @@ pub fn fromSlice( if (comptime std.meta.trait.isIndexable(DefaultType) and (std.meta.trait.isSlice(DefaultType) or std.meta.trait.is(.Array)(DefaultType))) { var in = std.mem.sliceAsBytes(default); var out = std.mem.sliceAsBytes(slice); - @memcpy(out.ptr, in.ptr, in.len); + @memcpy(out[0..in.len], in); } else { @compileError("Needs a more specific type to copy from"); } diff --git a/src/walker_skippable.zig b/src/walker_skippable.zig index 880bed94d..4d5575405 100644 --- a/src/walker_skippable.zig +++ b/src/walker_skippable.zig @@ -1,6 +1,7 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const Walker = @This(); +const bun = @import("root").bun; const path = std.fs.path; stack: std.ArrayList(StackItem), @@ -37,30 +38,30 @@ pub fn next(self: *Walker) !?WalkerEntry { var dirname_len = top.dirname_len; if (try top.iter.next()) |base| { switch (base.kind) { - .Directory => { + .directory => { if (std.mem.indexOfScalar( u64, self.skip_dirnames, // avoid hashing if there will be 0 results - if (self.skip_dirnames.len > 0) std.hash.Wyhash.hash(self.seed, base.name) else 0, + if (self.skip_dirnames.len > 0) bun.hashWithSeed(self.seed, base.name) else 0, ) != null) continue; }, - .File => { + .file => { if (std.mem.indexOfScalar( u64, self.skip_filenames, // avoid hashing if there will be 0 results - if (self.skip_filenames.len > 0) std.hash.Wyhash.hash(self.seed, base.name) else 0, + if (self.skip_filenames.len > 0) bun.hashWithSeed(self.seed, base.name) else 0, ) != null) continue; }, // we don't know what it is for a symlink - .SymLink => { + .sym_link => { if (std.mem.indexOfScalar( u64, self.skip_all, // avoid hashing if there will be 0 results - if (self.skip_all.len > 0) std.hash.Wyhash.hash(self.seed, base.name) else 0, + if (self.skip_all.len > 0) bun.hashWithSeed(self.seed, base.name) else 0, ) != null) continue; }, @@ -77,7 +78,7 @@ pub fn next(self: *Walker) !?WalkerEntry { try self.name_buffer.append(0); self.name_buffer.shrinkRetainingCapacity(cur_len); - if (base.kind == .Directory) { + if (base.kind == .directory) { var new_dir = top.iter.dir.openIterableDir(base.name, .{}) catch |err| switch (err) { error.NameTooLong => unreachable, // no path sep in base.name else => |e| return e, @@ -143,14 +144,14 @@ pub fn walk( var skip_name_i: usize = 0; for (skip_filenames) |name| { - skip_names[skip_name_i] = std.hash.Wyhash.hash(seed, name); + skip_names[skip_name_i] = bun.hashWithSeed(seed, name); skip_name_i += 1; } var skip_filenames_ = skip_names[0..skip_name_i]; var skip_dirnames_ = skip_names[skip_name_i..]; for (skip_dirnames, 0..) |name, i| { - skip_dirnames_[i] = std.hash.Wyhash.hash(seed, name); + skip_dirnames_[i] = bun.hashWithSeed(seed, name); } try stack.append(Walker.StackItem{ diff --git a/src/watcher.zig b/src/watcher.zig index 466463805..155c0b473 100644 --- a/src/watcher.zig +++ b/src/watcher.zig @@ -73,7 +73,7 @@ pub const INotify = struct { // it includes alignment / padding // but it is a sentineled value // so we can just trim it to the first null byte - return bun.sliceTo(@intToPtr([*:0]u8, @ptrToInt(&this.name_len) + @sizeOf(u32)), 0)[0.. :0]; + return bun.sliceTo(@ptrFromInt([*:0]u8, @intFromPtr(&this.name_len) + @sizeOf(u32)), 0)[0.. :0]; } }; pub var inotify_fd: EventListIndex = 0; @@ -367,7 +367,7 @@ pub fn NewWatcher(comptime ContextType: type) type { var evict_list: [WATCHER_MAX_LIST]WatchItemIndex = undefined; pub fn getHash(filepath: string) HashType { - return @truncate(HashType, std.hash.Wyhash.hash(0, filepath)); + return @truncate(HashType, bun.hash(filepath)); } pub fn init(ctx: ContextType, fs: *Fs.FileSystem, allocator: std.mem.Allocator) !*Watcher { @@ -434,7 +434,7 @@ pub fn NewWatcher(comptime ContextType: type) type { // swapRemove messes up the order // But, it only messes up the order if any elements in the list appear after the item being removed // So if we just sort the list by the biggest index first, that should be fine - std.sort.sort( + std.sort.block( WatchItemIndex, evict_list[0..evict_list_i], {}, @@ -570,14 +570,14 @@ pub fn NewWatcher(comptime ContextType: type) type { else null; watchevents[watch_event_id].name_off = temp_name_off; - watchevents[watch_event_id].name_len = @as(u8, @boolToInt((event.name_len > 0))); - temp_name_off += @as(u8, @boolToInt((event.name_len > 0))); + watchevents[watch_event_id].name_len = @as(u8, @intFromBool((event.name_len > 0))); + temp_name_off += @as(u8, @intFromBool((event.name_len > 0))); watch_event_id += 1; } var all_events = watchevents[0..watch_event_id]; - std.sort.sort(WatchEvent, all_events, {}, WatchEvent.sortByIndex); + std.sort.block(WatchEvent, all_events, {}, WatchEvent.sortByIndex); var last_event_index: usize = 0; var last_event_id: INotify.EventListIndex = std.math.maxInt(INotify.EventListIndex); @@ -859,7 +859,7 @@ pub fn NewWatcher(comptime ContextType: type) type { } } } - try this.watchlist.ensureUnusedCapacity(this.allocator, 1 + @intCast(usize, @boolToInt(parent_watch_item == null))); + try this.watchlist.ensureUnusedCapacity(this.allocator, 1 + @intCast(usize, @intFromBool(parent_watch_item == null))); if (autowatch_parent_dir) { parent_watch_item = parent_watch_item orelse try this.appendDirectoryAssumeCapacity(dir_fd, parent_dir, parent_dir_hash, copy_file_path); diff --git a/src/wyhash.zig b/src/wyhash.zig new file mode 100644 index 000000000..bd5cbf62b --- /dev/null +++ b/src/wyhash.zig @@ -0,0 +1,179 @@ +// +// this file is a copy of Wyhash from the zig standard library, version v0.11.0-dev.2609+5e19250a1 +// + +const std = @import("std"); +const mem = std.mem; + +const primes = [_]u64{ + 0xa0761d6478bd642f, + 0xe7037ed1a0b428db, + 0x8ebc6af09c88c6e3, + 0x589965cc75374cc3, + 0x1d8e4e27c47d124f, +}; + +fn read_bytes(comptime bytes: u8, data: []const u8) u64 { + const T = std.meta.Int(.unsigned, 8 * bytes); + return mem.readIntLittle(T, data[0..bytes]); +} + +fn read_8bytes_swapped(data: []const u8) u64 { + return (read_bytes(4, data) << 32 | read_bytes(4, data[4..])); +} + +fn mum(a: u64, b: u64) u64 { + var r = std.math.mulWide(u64, a, b); + r = (r >> 64) ^ r; + return @truncate(u64, r); +} + +fn mix0(a: u64, b: u64, seed: u64) u64 { + return mum(a ^ seed ^ primes[0], b ^ seed ^ primes[1]); +} + +fn mix1(a: u64, b: u64, seed: u64) u64 { + return mum(a ^ seed ^ primes[2], b ^ seed ^ primes[3]); +} + +// Wyhash version which does not store internal state for handling partial buffers. +// This is needed so that we can maximize the speed for the short key case, which will +// use the non-iterative api which the public Wyhash exposes. +const WyhashStateless = struct { + seed: u64, + msg_len: usize, + + pub fn init(seed: u64) WyhashStateless { + return WyhashStateless{ + .seed = seed, + .msg_len = 0, + }; + } + + inline fn round(self: *WyhashStateless, b: []const u8) void { + std.debug.assert(b.len == 32); + + self.seed = mix0( + read_bytes(8, b[0..]), + read_bytes(8, b[8..]), + self.seed, + ) ^ mix1( + read_bytes(8, b[16..]), + read_bytes(8, b[24..]), + self.seed, + ); + } + + pub inline fn update(self: *WyhashStateless, b: []const u8) void { + std.debug.assert(b.len % 32 == 0); + + var off: usize = 0; + while (off < b.len) : (off += 32) { + self.round(b[off .. off + 32]); + // @call(.always_inline, self.round, .{b[off .. off + 32]}); + } + + self.msg_len += b.len; + } + + pub inline fn final(self: *WyhashStateless, b: []const u8) u64 { + std.debug.assert(b.len < 32); + + const seed = self.seed; + const rem_len = @intCast(u5, b.len); + const rem_key = b[0..rem_len]; + + self.seed = switch (rem_len) { + 0 => seed, + 1 => mix0(read_bytes(1, rem_key), primes[4], seed), + 2 => mix0(read_bytes(2, rem_key), primes[4], seed), + 3 => mix0((read_bytes(2, rem_key) << 8) | read_bytes(1, rem_key[2..]), primes[4], seed), + 4 => mix0(read_bytes(4, rem_key), primes[4], seed), + 5 => mix0((read_bytes(4, rem_key) << 8) | read_bytes(1, rem_key[4..]), primes[4], seed), + 6 => mix0((read_bytes(4, rem_key) << 16) | read_bytes(2, rem_key[4..]), primes[4], seed), + 7 => mix0((read_bytes(4, rem_key) << 24) | (read_bytes(2, rem_key[4..]) << 8) | read_bytes(1, rem_key[6..]), primes[4], seed), + 8 => mix0(read_8bytes_swapped(rem_key), primes[4], seed), + 9 => mix0(read_8bytes_swapped(rem_key), read_bytes(1, rem_key[8..]), seed), + 10 => mix0(read_8bytes_swapped(rem_key), read_bytes(2, rem_key[8..]), seed), + 11 => mix0(read_8bytes_swapped(rem_key), (read_bytes(2, rem_key[8..]) << 8) | read_bytes(1, rem_key[10..]), seed), + 12 => mix0(read_8bytes_swapped(rem_key), read_bytes(4, rem_key[8..]), seed), + 13 => mix0(read_8bytes_swapped(rem_key), (read_bytes(4, rem_key[8..]) << 8) | read_bytes(1, rem_key[12..]), seed), + 14 => mix0(read_8bytes_swapped(rem_key), (read_bytes(4, rem_key[8..]) << 16) | read_bytes(2, rem_key[12..]), seed), + 15 => mix0(read_8bytes_swapped(rem_key), (read_bytes(4, rem_key[8..]) << 24) | (read_bytes(2, rem_key[12..]) << 8) | read_bytes(1, rem_key[14..]), seed), + 16 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed), + 17 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_bytes(1, rem_key[16..]), primes[4], seed), + 18 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_bytes(2, rem_key[16..]), primes[4], seed), + 19 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1((read_bytes(2, rem_key[16..]) << 8) | read_bytes(1, rem_key[18..]), primes[4], seed), + 20 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_bytes(4, rem_key[16..]), primes[4], seed), + 21 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1((read_bytes(4, rem_key[16..]) << 8) | read_bytes(1, rem_key[20..]), primes[4], seed), + 22 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1((read_bytes(4, rem_key[16..]) << 16) | read_bytes(2, rem_key[20..]), primes[4], seed), + 23 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1((read_bytes(4, rem_key[16..]) << 24) | (read_bytes(2, rem_key[20..]) << 8) | read_bytes(1, rem_key[22..]), primes[4], seed), + 24 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), primes[4], seed), + 25 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), read_bytes(1, rem_key[24..]), seed), + 26 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), read_bytes(2, rem_key[24..]), seed), + 27 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), (read_bytes(2, rem_key[24..]) << 8) | read_bytes(1, rem_key[26..]), seed), + 28 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), read_bytes(4, rem_key[24..]), seed), + 29 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), (read_bytes(4, rem_key[24..]) << 8) | read_bytes(1, rem_key[28..]), seed), + 30 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), (read_bytes(4, rem_key[24..]) << 16) | read_bytes(2, rem_key[28..]), seed), + 31 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), (read_bytes(4, rem_key[24..]) << 24) | (read_bytes(2, rem_key[28..]) << 8) | read_bytes(1, rem_key[30..]), seed), + }; + + self.msg_len += b.len; + return mum(self.seed ^ self.msg_len, primes[4]); + } + + pub fn hash(seed: u64, input: []const u8) u64 { + const aligned_len = input.len - (input.len % 32); + + var c = WyhashStateless.init(seed); + c.update(input[0..aligned_len]); + // @call(.always_inline, c.update, .{input[0..aligned_len]}); + return c.final(input[aligned_len..]); + // return @call(.always_inline, c.final, .{input[aligned_len..]}); + } +}; + +/// Fast non-cryptographic 64bit hash function. +/// See https://github.com/wangyi-fudan/wyhash +pub const Wyhash = struct { + state: WyhashStateless, + + buf: [32]u8, + buf_len: usize, + + pub fn init(seed: u64) Wyhash { + return Wyhash{ + .state = WyhashStateless.init(seed), + .buf = undefined, + .buf_len = 0, + }; + } + + pub fn update(self: *Wyhash, b: []const u8) void { + var off: usize = 0; + + if (self.buf_len != 0 and self.buf_len + b.len >= 32) { + off += 32 - self.buf_len; + mem.copy(u8, self.buf[self.buf_len..], b[0..off]); + self.state.update(self.buf[0..]); + self.buf_len = 0; + } + + const remain_len = b.len - off; + const aligned_len = remain_len - (remain_len % 32); + self.state.update(b[off .. off + aligned_len]); + + mem.copy(u8, self.buf[self.buf_len..], b[off + aligned_len ..]); + self.buf_len += @intCast(u8, b[off + aligned_len ..].len); + } + + pub fn final(self: *Wyhash) u64 { + const rem_key = self.buf[0..self.buf_len]; + + return self.state.final(rem_key); + } + + pub fn hash(seed: u64, input: []const u8) u64 { + return WyhashStateless.hash(seed, input); + } +}; -- cgit v1.2.3 From 4a13a53058eca1c3d96847277878a19192dd2a34 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 22 Jun 2023 01:06:50 -0700 Subject: CommonJS bun build cannot use import.meta (#3378) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/js_printer.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/js_printer.zig b/src/js_printer.zig index 913aaded3..bd771d7b8 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -845,7 +845,14 @@ fn NewPrinter( fn printBunJestImportStatement(p: *Printer, import: S.Import) void { if (comptime !is_bun_platform) unreachable; - printInternalBunImport(p, import, @TypeOf("globalThis.Bun.jest(import.meta.path)"), "globalThis.Bun.jest(import.meta.path)"); + switch (p.options.module_type) { + .cjs => { + printInternalBunImport(p, import, @TypeOf("globalThis.Bun.jest(__filename)"), "globalThis.Bun.jest(__filename)"); + }, + else => { + printInternalBunImport(p, import, @TypeOf("globalThis.Bun.jest(import.meta.path)"), "globalThis.Bun.jest(import.meta.path)"); + }, + } } fn printGlobalBunImportStatement(p: *Printer, import: S.Import) void { -- cgit v1.2.3 From ca1fe3c602a19878e8cd3545494d6b5af7ed13c9 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 23 Jun 2023 03:05:54 +0300 Subject: revamp dotEnv parser (#3347) - fixes `strings.indexOfAny()` - fixes OOB array access fixes #411 fixes #2823 fixes #3042 --- src/bun.js/api/bun.zig | 8 +- src/env_loader.zig | 667 ++++++++++++++++-------------------------- src/string_immutable.zig | 38 ++- test/cli/install/bunx.test.ts | 16 +- test/cli/run/env.test.ts | 82 +++++- 5 files changed, 371 insertions(+), 440 deletions(-) diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 9df125a58..034aaa81f 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -4935,11 +4935,11 @@ pub const EnvironmentVariables = struct { pub fn getEnvNames(globalObject: *JSC.JSGlobalObject, names: []ZigString) usize { var vm = globalObject.bunVM(); const keys = vm.bundler.env.map.map.keys(); - const max = @min(names.len, keys.len); - for (keys[0..max], 0..) |key, i| { - names[i] = ZigString.initUTF8(key); + const len = @min(names.len, keys.len); + for (keys[0..len], names[0..len]) |key, *name| { + name.* = ZigString.initUTF8(key); } - return keys.len; + return len; } pub fn getEnvValue(globalObject: *JSC.JSGlobalObject, name: ZigString) ?ZigString { var vm = globalObject.bunVM(); diff --git a/src/env_loader.zig b/src/env_loader.zig index 14e1196b6..74577e3f2 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -17,384 +17,6 @@ const Fs = @import("./fs.zig"); const URL = @import("./url.zig").URL; const Api = @import("./api/schema.zig").Api; const which = @import("./which.zig").which; -const Variable = struct { - key: string, - value: string, - has_nested_value: bool = false, -}; - -// i don't expect anyone to actually use the escape line feed character -const escLineFeed = 0x0C; -// arbitrary character that is invalid in a real text file -const implicitQuoteCharacter = 8; - -// you get 4k. I hope you don't need more than that. -threadlocal var temporary_nested_value_buffer: [4096]u8 = undefined; - -pub const Lexer = struct { - source: *const logger.Source, - iter: CodepointIterator, - cursor: CodepointIterator.Cursor = CodepointIterator.Cursor{}, - _codepoint: CodePoint = 0, - current: usize = 0, - last_non_space: usize = 0, - prev_non_space: usize = 0, - start: usize = 0, - end: usize = 0, - has_nested_value: bool = false, - has_newline_before: bool = true, - was_quoted: bool = false, - - pub inline fn codepoint(this: *const Lexer) CodePoint { - return this.cursor.c; - } - - pub inline fn step(this: *Lexer) void { - const ended = !this.iter.next(&this.cursor); - if (ended) this.cursor.c = -1; - this.current = this.cursor.i + @as(usize, @intFromBool(ended)); - } - - pub fn eatNestedValue( - _: *Lexer, - comptime ContextType: type, - ctx: *ContextType, - comptime Writer: type, - writer: Writer, - variable: Variable, - comptime getter: fn (ctx: *const ContextType, key: string) ?string, - ) !void { - var i: usize = 0; - var last_flush: usize = 0; - - top: while (i < variable.value.len) { - switch (variable.value[i]) { - '$' => { - i += 1; - const start = i; - - const curly_braces_offset = @as(usize, @intFromBool(variable.value[i] == '{')); - i += curly_braces_offset; - - while (i < variable.value.len) { - switch (variable.value[i]) { - 'a'...'z', 'A'...'Z', '0'...'9', '-', '_' => { - i += 1; - }, - '}' => { - i += curly_braces_offset; - break; - }, - else => { - break; - }, - } - } - - try writer.writeAll(variable.value[last_flush .. start - 1]); - last_flush = i; - const name = variable.value[start + curly_braces_offset .. i - curly_braces_offset]; - - if (@call(.always_inline, getter, .{ ctx, name })) |new_value| { - if (new_value.len > 0) { - try writer.writeAll(new_value); - } - } - - continue :top; - }, - '\\' => { - i += 1; - switch (variable.value[i]) { - '$' => { - i += 1; - continue; - }, - else => {}, - } - }, - else => {}, - } - i += 1; - } - - try writer.writeAll(variable.value[last_flush..]); - } - - pub fn eatValue( - lexer: *Lexer, - comptime quote: CodePoint, - ) string { - var was_quoted = false; - switch (comptime quote) { - '"', '\'' => { - lexer.step(); - was_quoted = true; - }, - - else => {}, - } - - var start = lexer.current; - var last_non_space: usize = start; - var any_spaces = false; - - while (true) { - switch (lexer.codepoint()) { - '\\' => { - lexer.step(); - // Handle Windows CRLF - - switch (lexer.codepoint()) { - '\r' => { - lexer.step(); - if (lexer.codepoint() == '\n') { - lexer.step(); - } - continue; - }, - '$' => { - lexer.step(); - continue; - }, - else => { - continue; - }, - } - }, - -1 => { - lexer.end = lexer.current; - - return lexer.source.contents[start..if (any_spaces) @min(last_non_space, lexer.source.contents.len) else lexer.source.contents.len]; - }, - '$' => { - lexer.has_nested_value = true; - }, - - '#' => { - lexer.step(); - lexer.eatComment(); - - return lexer.source.contents[start .. last_non_space + 1]; - }, - - '\n', '\r', escLineFeed => { - switch (comptime quote) { - '\'' => { - lexer.end = lexer.current; - lexer.step(); - return lexer.source.contents[start..@min(lexer.end, lexer.source.contents.len)]; - }, - implicitQuoteCharacter => { - lexer.end = lexer.current; - lexer.step(); - - return lexer.source.contents[start..@min(if (any_spaces) last_non_space + 1 else lexer.end, lexer.end)]; - }, - '"' => { - // We keep going - }, - else => {}, - } - }, - quote => { - lexer.end = lexer.current; - lexer.step(); - - lexer.was_quoted = was_quoted; - return lexer.source.contents[start..@min( - lexer.end, - lexer.source.contents.len, - )]; - }, - ' ' => { - any_spaces = true; - while (lexer.codepoint() == ' ') lexer.step(); - continue; - }, - else => {}, - } - if (lexer.codepoint() != ' ') last_non_space = lexer.current; - lexer.step(); - } - unreachable; - } - - pub fn eatComment(this: *Lexer) void { - while (true) { - switch (this.codepoint()) { - '\r' => { - this.step(); - if (this.codepoint() == '\n') { - return; - } - }, - '\n' => { - this.step(); - return; - }, - -1 => { - return; - }, - else => { - this.step(); - }, - } - } - } - - // const NEWLINE = '\n' - // const RE_INI_KEY_VAL = /^\s*([\w.-]+)\s*=\s*(.*)?\s*$/ - // const RE_NEWLINES = /\\n/g - // const NEWLINES_MATCH = /\r\n|\n|\r/ - pub fn next(this: *Lexer, comptime is_process_env: bool) ?Variable { - if (this.end == 0) this.step(); - - const start = this.start; - - this.has_newline_before = this.end == 0; - - var last_non_space = start; - restart: while (true) { - last_non_space = switch (this.codepoint()) { - ' ', '\r', '\n' => last_non_space, - else => this.current, - }; - - switch (this.codepoint()) { - 0, -1 => { - return null; - }, - '#' => { - this.step(); - - this.eatComment(); - continue :restart; - }, - '\r', '\n', 0x2028, 0x2029 => { - this.step(); - this.has_newline_before = true; - continue; - }, - - // Valid keys: - 'a'...'z', 'A'...'Z', '0'...'9', '_', '-', '.' => { - this.start = this.current; - this.step(); - var key_end: usize = 0; - while (true) { - switch (this.codepoint()) { - - // to match npm's "dotenv" behavior, we ignore lines that don't have an equals - '\r', '\n', escLineFeed => { - this.end = this.current; - this.step(); - continue :restart; - }, - 0, -1 => { - this.end = this.current; - return if (last_non_space > this.start) - Variable{ .key = this.source.contents[this.start..@min(last_non_space + 1, this.source.contents.len)], .value = "" } - else - null; - }, - 'a'...'z', 'A'...'Z', '0'...'9', '_', '-', '.' => {}, - '=' => { - this.end = this.current; - if (key_end > 0) { - this.end = key_end; - } - const key = this.source.contents[this.start..this.end]; - if (key.len == 0) return null; - this.step(); - - // we don't need to do special parsing on process-level environment variable values - // if they're quoted, we should keep them quoted. - // https://github.com/oven-sh/bun/issues/40 - if (comptime is_process_env) { - const current = this.current; - // TODO: remove this loop - // it's not as simple as just setting to the end of the string - while (this.codepoint() != -1) : (this.step()) {} - return Variable{ - .key = key, - .value = this.source.contents[current..], - // nested values are unsupported in process environment variables - .has_nested_value = false, - }; - } - - this.has_nested_value = false; - inner: while (true) { - switch (this.codepoint()) { - '"' => { - const value = this.eatValue('"'); - return Variable{ - .key = key, - .value = value, - .has_nested_value = this.has_nested_value, - }; - }, - '\'' => { - const value = this.eatValue('\''); - return Variable{ - .key = key, - .value = value, - .has_nested_value = this.has_nested_value, - }; - }, - 0, -1 => { - return Variable{ .key = key, .value = "" }; - }, - '\r', '\n', escLineFeed => { - this.step(); - return Variable{ .key = key, .value = "" }; - }, - // consume unquoted leading spaces - ' ' => { - this.step(); - while (this.codepoint() == ' ') this.step(); - continue :inner; - }, - // we treat everything else the same as if it were wrapped in single quotes - // except we don't terminate on that character - else => { - const value = this.eatValue(implicitQuoteCharacter); - return Variable{ - .key = key, - .value = value, - .has_nested_value = this.has_nested_value, - }; - }, - } - } - }, - ' ' => { - // Set key end to the last non space character - key_end = this.current; - this.step(); - while (this.codepoint() == ' ') this.step(); - continue; - }, - else => {}, - } - this.step(); - } - }, - else => {}, - } - - this.step(); - } - } - - pub fn init(source: *const logger.Source) Lexer { - return Lexer{ - .source = source, - .iter = CodepointIterator.init(source.contents), - }; - } -}; pub const Loader = struct { map: *Map, @@ -912,58 +534,263 @@ pub const Loader = struct { } }; -pub const Parser = struct { - pub fn parse( - source: *const logger.Source, - allocator: std.mem.Allocator, - map: *Map, - comptime override: bool, - comptime is_process: bool, - ) void { - var lexer = Lexer.init(source); - var fbs = std.io.fixedBufferStream(&temporary_nested_value_buffer); - var writer = fbs.writer(); - const start_count = map.map.count(); - - while (lexer.next(is_process)) |variable| { - if (variable.has_nested_value) { - writer.context.reset(); - - lexer.eatNestedValue(Map, map, @TypeOf(writer), writer, variable, Map.get_) catch unreachable; - const new_value = fbs.buffer[0..fbs.pos]; - if (new_value.len > 0) { - if (comptime override) { - map.put(variable.key, allocator.dupe(u8, new_value) catch unreachable) catch unreachable; - } else { - var putter = map.map.getOrPut(variable.key) catch unreachable; - // Allow keys defined later in the same file to override keys defined earlier - // https://github.com/oven-sh/bun/issues/1262 - if (!putter.found_existing or putter.index >= start_count) { - if (putter.found_existing and putter.value_ptr.len > 0) { - allocator.free(putter.value_ptr.*); - } +const Parser = struct { + pos: usize = 0, + src: string, + + const whitespace_chars = "\t\x0B\x0C \xA0\n\r"; + // You get 4k. I hope you don't need more than that. + threadlocal var value_buffer: [4096]u8 = undefined; + + fn skipLine(this: *Parser) void { + if (strings.indexOfAny(this.src[this.pos..], "\n\r")) |i| { + this.pos += i + 1; + } else { + this.pos = this.src.len; + } + } - putter.value_ptr.* = allocator.dupe(u8, new_value) catch unreachable; + fn skipWhitespaces(this: *Parser) void { + var i = this.pos; + while (i < this.src.len) : (i += 1) { + if (strings.indexOfChar(whitespace_chars, this.src[i]) == null) break; + } + this.pos = i; + } + + fn parseKey(this: *Parser, comptime check_export: bool) ?string { + if (comptime check_export) this.skipWhitespaces(); + const start = this.pos; + var end = start; + while (end < this.src.len) : (end += 1) { + switch (this.src[end]) { + 'a'...'z', 'A'...'Z', '0'...'9', '_', '-', '.' => continue, + else => break, + } + } + if (end < this.src.len and start < end) { + this.pos = end; + this.skipWhitespaces(); + if (this.pos < this.src.len) { + if (comptime check_export) { + if (end < this.pos and strings.eqlComptime(this.src[start..end], "export")) { + if (this.parseKey(false)) |key| return key; + } + } + switch (this.src[this.pos]) { + '=' => { + this.pos += 1; + return this.src[start..end]; + }, + ':' => { + const next = this.pos + 1; + if (next < this.src.len and strings.indexOfChar(whitespace_chars, this.src[next]) != null) { + this.pos += 2; + return this.src[start..end]; } + }, + else => {}, + } + } + } + this.pos = start; + return null; + } + + fn parseQuoted(this: *Parser, comptime quote: u8) ?string { + if (comptime Environment.allow_assert) std.debug.assert(this.src[this.pos] == quote); + const start = this.pos; + var end = start + 1; + while (end < this.src.len) : (end += 1) { + switch (this.src[end]) { + '\\' => end += 1, + quote => { + end += 1; + this.pos = end; + this.skipWhitespaces(); + if (this.pos >= this.src.len or + this.src[this.pos] == '#' or + strings.indexOfChar(this.src[end..this.pos], '\n') != null or + strings.indexOfChar(this.src[end..this.pos], '\r') != null) + { + var ptr: usize = 0; + var i = start; + while (i < end) { + switch (this.src[i]) { + '\\' => if (comptime quote == '"') { + if (comptime Environment.allow_assert) std.debug.assert(i + 1 < end); + switch (this.src[i + 1]) { + 'n' => { + value_buffer[ptr] = '\n'; + ptr += 1; + i += 1; + }, + 'r' => { + value_buffer[ptr] = '\r'; + ptr += 1; + i += 1; + }, + else => { + value_buffer[ptr] = this.src[i]; + value_buffer[ptr + 1] = this.src[i + 1]; + ptr += 2; + i += 2; + }, + } + } else { + value_buffer[ptr] = '\\'; + ptr += 1; + i += 1; + }, + '\r' => { + i += 1; + if (i >= end or this.src[i] != '\n') { + value_buffer[ptr] = '\n'; + ptr += 1; + } + }, + else => |c| { + value_buffer[ptr] = c; + ptr += 1; + i += 1; + }, + } + } + return value_buffer[0..ptr]; } + this.pos = start; + }, + else => {}, + } + } + return null; + } + + fn parseValue(this: *Parser, comptime is_process: bool) string { + const start = this.pos; + this.skipWhitespaces(); + var end = this.pos; + if (end >= this.src.len) return this.src[this.src.len..]; + switch (this.src[end]) { + inline '`', '"', '\'' => |quote| { + if (this.parseQuoted(quote)) |value| { + return if (comptime is_process) value else value[1 .. value.len - 1]; } - } else { - if (comptime override) { - map.put(variable.key, variable.value) catch unreachable; + }, + else => {}, + } + end = start; + while (end < this.src.len) : (end += 1) { + switch (this.src[end]) { + '#', '\r', '\n' => break, + else => {}, + } + } + this.pos = end; + return strings.trim(this.src[start..end], whitespace_chars); + } + + inline fn writeBackwards(ptr: usize, bytes: []const u8) usize { + const end = ptr; + const start = end - bytes.len; + bun.copy(u8, value_buffer[start..end], bytes); + return start; + } + + fn expandValue(map: *Map, value: string) ?string { + if (value.len < 2) return null; + var ptr = value_buffer.len; + var pos = value.len - 2; + var last = value.len; + while (true) : (pos -= 1) { + if (value[pos] == '$') { + if (pos > 0 and value[pos - 1] == '\\') { + ptr = writeBackwards(ptr, value[pos..last]); + pos -= 1; } else { - // Allow keys defined later in the same file to override keys defined earlier - // https://github.com/oven-sh/bun/issues/1262 - var putter = map.map.getOrPut(variable.key) catch unreachable; - if (!putter.found_existing or putter.index >= start_count) { - if (putter.found_existing and putter.value_ptr.len > 0) { - allocator.free(putter.value_ptr.*); + var end = if (value[pos + 1] == '{') pos + 2 else pos + 1; + const key_start = end; + while (end < value.len) : (end += 1) { + switch (value[end]) { + 'a'...'z', 'A'...'Z', '0'...'9', '_' => continue, + else => break, } - - putter.value_ptr.* = allocator.dupe(u8, variable.value) catch unreachable; } + const lookup_value = map.get(value[key_start..end]); + const default_value = if (strings.hasPrefixComptime(value[end..], ":-")) brk: { + end += ":-".len; + const value_start = end; + while (end < value.len) : (end += 1) { + switch (value[end]) { + '}', '\\' => break, + else => continue, + } + } + break :brk value[value_start..end]; + } else ""; + if (end < value.len and value[end] == '}') end += 1; + ptr = writeBackwards(ptr, value[end..last]); + ptr = writeBackwards(ptr, lookup_value orelse default_value); + } + last = pos; + } + if (pos == 0) { + if (last == value.len) return null; + break; + } + } + if (last > 0) ptr = writeBackwards(ptr, value[0..last]); + return value_buffer[ptr..]; + } + + fn _parse( + this: *Parser, + allocator: std.mem.Allocator, + map: *Map, + comptime override: bool, + comptime is_process: bool, + ) void { + var count = map.map.count(); + while (this.pos < this.src.len) { + const key = this.parseKey(true) orelse { + this.skipLine(); + continue; + }; + const value = this.parseValue(is_process); + var entry = map.map.getOrPut(key) catch unreachable; + if (entry.found_existing) { + if (entry.index < count) { + // Allow keys defined later in the same file to override keys defined earlier + // https://github.com/oven-sh/bun/issues/1262 + if (comptime !override) continue; + } else { + allocator.free(entry.value_ptr.*); } } + entry.value_ptr.* = allocator.dupe(u8, value) catch unreachable; } + if (comptime !is_process) { + var it = map.iter(); + while (it.next()) |entry| { + if (count > 0) { + count -= 1; + } else if (expandValue(map, entry.value_ptr.*)) |value| { + allocator.free(entry.value_ptr.*); + entry.value_ptr.* = allocator.dupe(u8, value) catch unreachable; + } + } + } + } + + pub fn parse( + source: *const logger.Source, + allocator: std.mem.Allocator, + map: *Map, + comptime override: bool, + comptime is_process: bool, + ) void { + var parser = Parser{ .src = source.contents }; + parser._parse(allocator, map, override, is_process); } }; diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 0c90b03ff..0e98f3f5f 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -39,10 +39,40 @@ pub fn toUTF16Literal(comptime str: []const u8) []const u16 { } pub const OptionalUsize = std.meta.Int(.unsigned, @bitSizeOf(usize) - 1); -pub fn indexOfAny(self: string, comptime str: anytype) ?OptionalUsize { - inline for (str) |a| { - if (indexOfChar(self, a)) |i| { - return @intCast(OptionalUsize, i); +pub fn indexOfAny(slice: string, comptime str: anytype) ?OptionalUsize { + switch (comptime str.len) { + 0 => @compileError("str cannot be empty"), + 1 => return indexOfChar(slice, str[0]), + else => {}, + } + + var remaining = slice; + if (remaining.len == 0) return null; + + if (comptime Environment.enableSIMD) { + while (remaining.len >= ascii_vector_size) { + const vec: AsciiVector = remaining[0..ascii_vector_size].*; + var cmp = @bitCast(AsciiVectorU1, vec == @splat(ascii_vector_size, @as(u8, str[0]))); + inline for (str[1..]) |c| { + cmp |= @bitCast(AsciiVectorU1, vec == @splat(ascii_vector_size, @as(u8, c))); + } + + if (@reduce(.Max, cmp) > 0) { + const bitmask = @bitCast(AsciiVectorInt, cmp); + const first = @ctz(bitmask); + + return @intCast(OptionalUsize, first + slice.len - remaining.len); + } + + remaining = remaining[ascii_vector_size..]; + } + + if (comptime Environment.allow_assert) std.debug.assert(remaining.len < ascii_vector_size); + } + + for (remaining, 0..) |c, i| { + if (strings.indexOfChar(str, c) != null) { + return @intCast(OptionalUsize, i + slice.len - remaining.len); } } diff --git a/test/cli/install/bunx.test.ts b/test/cli/install/bunx.test.ts index 87ad2f8b4..3605f5b6b 100644 --- a/test/cli/install/bunx.test.ts +++ b/test/cli/install/bunx.test.ts @@ -1,7 +1,6 @@ -import { spawn } from "bun"; +import { file, spawn } from "bun"; import { afterEach, beforeEach, expect, it } from "bun:test"; import { bunExe, bunEnv as env } from "harness"; -import { realpathSync } from "fs"; import { mkdtemp, realpath, rm, writeFile } from "fs/promises"; import { tmpdir } from "os"; import { join } from "path"; @@ -10,7 +9,7 @@ import { readdirSorted } from "./dummy.registry"; let x_dir: string; beforeEach(async () => { - x_dir = realpathSync(await mkdtemp(join(tmpdir(), "bun-x.test"))); + x_dir = await realpath(await mkdtemp(join(tmpdir(), "bun-x.test"))); }); afterEach(async () => { await rm(x_dir, { force: true, recursive: true }); @@ -167,6 +166,16 @@ for (const entry of await decompress(Buffer.from(buffer))) { expect(stderr).toBeDefined(); const err = await new Response(stderr).text(); expect(err).toBe(""); + expect(await readdirSorted(x_dir)).toEqual([".cache", "test.js"]); + expect(await readdirSorted(join(x_dir, ".cache"))).toContain("decompress"); + expect(await readdirSorted(join(x_dir, ".cache", "decompress"))).toEqual(["4.2.1"]); + expect(await readdirSorted(join(x_dir, ".cache", "decompress", "4.2.1"))).toEqual([ + "index.js", + "license", + "package.json", + "readme.md", + ]); + expect(await file(join(x_dir, ".cache", "decompress", "4.2.1", "index.js")).text()).toContain("\nmodule.exports = "); expect(stdout).toBeDefined(); const out = await new Response(stdout).text(); expect(out.split(/\r?\n/)).toEqual([ @@ -176,7 +185,6 @@ for (const entry of await decompress(Buffer.from(buffer))) { "", ]); expect(await exited).toBe(0); - expect(await readdirSorted(x_dir)).toEqual([".cache", "test.js"]); }); it("should execute from current working directory", async () => { diff --git a/test/cli/run/env.test.ts b/test/cli/run/env.test.ts index ddc316f05..0cab610a5 100644 --- a/test/cli/run/env.test.ts +++ b/test/cli/run/env.test.ts @@ -194,6 +194,51 @@ describe("dotenv priority", () => { }); }); +test(".env colon assign", () => { + const dir = tempDirWithFiles("dotenv-colon", { + ".env": "FOO: foo", + "index.ts": "console.log(process.env.FOO);", + }); + const { stdout } = bunRun(`${dir}/index.ts`); + expect(stdout).toBe("foo"); +}); + +test(".env export assign", () => { + const dir = tempDirWithFiles("dotenv-export", { + ".env": "export FOO = foo\nexport = bar", + "index.ts": "console.log(process.env.FOO, process.env.export);", + }); + const { stdout } = bunRun(`${dir}/index.ts`); + expect(stdout).toBe("foo bar"); +}); + +test(".env value expansion", () => { + const dir = tempDirWithFiles("dotenv-expand", { + ".env": "FOO=foo\nBAR=$FOO bar\nMOO=${FOO} ${BAR:-fail} ${MOZ:-moo}", + "index.ts": "console.log([process.env.FOO, process.env.BAR, process.env.MOO].join('|'));", + }); + const { stdout } = bunRun(`${dir}/index.ts`); + expect(stdout).toBe("foo|foo bar|foo foo bar moo"); +}); + +test(".env comments", () => { + const dir = tempDirWithFiles("dotenv-comments", { + ".env": "#FOZ\nFOO = foo#FAIL\nBAR='bar' #BAZ", + "index.ts": "console.log(process.env.FOO, process.env.BAR);", + }); + const { stdout } = bunRun(`${dir}/index.ts`); + expect(stdout).toBe("foo bar"); +}); + +test(".env escaped dollar sign", () => { + const dir = tempDirWithFiles("dotenv-dollar", { + ".env": "FOO=foo\nBAR=\\$FOO", + "index.ts": "console.log(process.env.FOO, process.env.BAR);", + }); + const { stdout } = bunRun(`${dir}/index.ts`); + expect(stdout).toBe("foo $FOO"); +}); + test(".env doesnt crash with 159 bytes", () => { const dir = tempDirWithFiles("dotenv-159", { ".env": @@ -217,28 +262,49 @@ test(".env doesnt crash with 159 bytes", () => { ); }); -test.todo(".env space edgecase (issue #411)", () => { +test(".env with >768 entries", () => { + const dir = tempDirWithFiles("dotenv-many-entries", { + ".env": new Array(2000) + .fill(null) + .map((_, i) => `TEST_VAR${i}=TEST_VAL${i}`) + .join("\n"), + "index.ts": "console.log(process.env.TEST_VAR47);", + }); + const { stdout } = bunRun(`${dir}/index.ts`); + expect(stdout).toBe("TEST_VAL47"); +}); + +test(".env space edgecase (issue #411)", () => { const dir = tempDirWithFiles("dotenv-issue-411", { ".env": "VARNAME=A B", - "index.ts": "console.log('[' + process.env.VARNAME + ']'); ", + "index.ts": "console.log('[' + process.env.VARNAME + ']');", }); const { stdout } = bunRun(`${dir}/index.ts`); expect(stdout).toBe("[A B]"); }); -test.todo(".env special characters 1 (issue #2823)", () => { - const dir = tempDirWithFiles("dotenv-issue-411", { - ".env": 'A="a$t"\n', - "index.ts": "console.log('[' + process.env.A + ']'); ", +test(".env special characters 1 (issue #2823)", () => { + const dir = tempDirWithFiles("dotenv-issue-2823", { + ".env": 'A="a$t"\nC=`c\\$v`', + "index.ts": "console.log('[' + process.env.A + ']', '[' + process.env.C + ']');", }); const { stdout } = bunRun(`${dir}/index.ts`); - expect(stdout).toBe("[a$t]"); + expect(stdout).toBe("[a] [c$v]"); }); test.todo("env escaped quote (issue #2484)", () => { - const dir = tempDirWithFiles("dotenv-issue-411", { + const dir = tempDirWithFiles("env-issue-2484", { "index.ts": "console.log(process.env.VALUE, process.env.VALUE2);", }); const { stdout } = bunRun(`${dir}/index.ts`, { VALUE: `\\"`, VALUE2: `\\\\"` }); expect(stdout).toBe('\\" \\\\"'); }); + +test(".env Windows-style newline (issue #3042)", () => { + const dir = tempDirWithFiles("dotenv-issue-3042", { + ".env": "FOO=\rBAR='bar\r\rbaz'\r\nMOO=moo\r", + "index.ts": "console.log([process.env.FOO, process.env.BAR, process.env.MOO].join('|'));", + }); + const { stdout } = bunRun(`${dir}/index.ts`); + expect(stdout).toBe("|bar\n\nbaz|moo"); +}); -- cgit v1.2.3 From ae4b65c52e04850f45b73dc1c7d7aa8524a9a7bd Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 23 Jun 2023 06:13:26 +0300 Subject: fix tests for `expect()` (#3384) - extend test job time-out for `darwin-aarch64` --- .github/workflows/bun-mac-aarch64.yml | 2 +- test/js/bun/test/expect.test.js | 187 +++++++++++++++++++++++++--------- 2 files changed, 141 insertions(+), 48 deletions(-) diff --git a/.github/workflows/bun-mac-aarch64.yml b/.github/workflows/bun-mac-aarch64.yml index 6ac6b958e..e4d93f206 100644 --- a/.github/workflows/bun-mac-aarch64.yml +++ b/.github/workflows/bun-mac-aarch64.yml @@ -397,7 +397,7 @@ jobs: runs-on: ${{ matrix.runner }} needs: [macOS] if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh' - timeout-minutes: 10 + timeout-minutes: 30 outputs: failing_tests: ${{ steps.test.outputs.failing_tests }} failing_tests_count: ${{ steps.test.outputs.failing_tests_count }} diff --git a/test/js/bun/test/expect.test.js b/test/js/bun/test/expect.test.js index f09f7d196..d42ec2219 100644 --- a/test/js/bun/test/expect.test.js +++ b/test/js/bun/test/expect.test.js @@ -2654,28 +2654,74 @@ describe("expect()", () => { describe("toBeEmpty()", () => { const values = [ - "", - [], - {}, - new Set(), - new Map(), - new String(), - new Array(), - new Uint8Array(), - new Object(), - Buffer.from(""), - ...(isBun ? [Bun.file("/tmp/empty.txt")] : []), - new Headers(), - new URLSearchParams(), - new FormData(), - (function* () {})(), + { + label: `""`, + value: "", + }, + { + label: `[]`, + value: [], + }, + { + label: `{}`, + value: {}, + }, + { + label: `new Set()`, + value: new Set(), + }, + { + label: `new Map()`, + value: new Map(), + }, + { + label: `new String()`, + value: new String(), + }, + { + label: `new Array()`, + value: new Array(), + }, + { + label: `new Uint8Array()`, + value: new Uint8Array(), + }, + { + label: `new Object()`, + value: new Object(), + }, + { + label: `Buffer.from("")`, + value: Buffer.from(""), + }, + { + label: `new Headers()`, + value: new Headers(), + }, + { + label: `new URLSearchParams()`, + value: new URLSearchParams(), + }, + { + label: `new FormData()`, + value: new FormData(), + }, + { + label: `(function* () {})()`, + value: (function* () {})(), + }, ]; - for (const value of values) { - test(label(value), () => { - if (value && typeof value === "object" && value instanceof Blob) { + if (isBun) { + values.push({ + label: `Bun.file()`, + value: Bun.file("/tmp/empty.txt"), + }); + } + for (const { label, value } of values) { + test(label, () => { + if (value instanceof Blob) { require("fs").writeFileSync("/tmp/empty.txt", ""); } - expect(value).toBeEmpty(); }); } @@ -2683,34 +2729,81 @@ describe("expect()", () => { describe("not.toBeEmpty()", () => { const values = [ - " ", - [""], - [undefined], - { "": "" }, - new Set([""]), - new Map([["", ""]]), - new String(" "), - new Array(1), - new Uint8Array(1), - Buffer.from(" "), - ...(isBun ? [Bun.file(__filename)] : []), - new Headers({ - a: "b", - c: "d", - }), - new URL("https://example.com?d=e&f=g").searchParams, - (() => { - var a = new FormData(); - a.append("a", "b"); - a.append("c", "d"); - return a; - })(), - (function* () { - yield "123"; - })(), + { + label: `" "`, + value: " ", + }, + { + label: `[""]`, + value: [""], + }, + { + label: `[undefined]`, + value: [undefined], + }, + { + label: `{ "": "" }`, + value: { "": "" }, + }, + { + label: `new Set([""])`, + value: new Set([""]), + }, + { + label: `new Map([["", ""]])`, + value: new Map([["", ""]]), + }, + { + label: `new String(" ")`, + value: new String(" "), + }, + { + label: `new Array(1)`, + value: new Array(1), + }, + { + label: `new Uint8Array(1)`, + value: new Uint8Array(1), + }, + { + label: `Buffer.from(" ")`, + value: Buffer.from(" "), + }, + { + label: `new Headers({...})`, + value: new Headers({ + a: "b", + c: "d", + }), + }, + { + label: `URL.searchParams`, + value: new URL("https://example.com?d=e&f=g").searchParams, + }, + { + label: `FormData`, + value: (() => { + var a = new FormData(); + a.append("a", "b"); + a.append("c", "d"); + return a; + })(), + }, + { + label: `generator function`, + value: (function* () { + yield "123"; + })(), + }, ]; - for (const value of values) { - test(label(value), () => { + if (isBun) { + values.push({ + label: `Bun.file()`, + value: Bun.file(__filename), + }); + } + for (const { label, value } of values) { + test(label, () => { expect(value).not.toBeEmpty(); }); } @@ -2743,7 +2836,7 @@ describe("expect()", () => { expect([]).toBeArrayOfSize(0); expect(new Array()).toBeArrayOfSize(0); expect([1, 2, 3, "🫓"]).toBeArrayOfSize(4); - expect((new Array() < string) | (number > (1, 2, 3, "🫓"))).toBeArrayOfSize(4); + expect(new Array(1, 2, 3, "🫓")).toBeArrayOfSize(4); expect({}).not.toBeArrayOfSize(1); expect("").not.toBeArrayOfSize(1); expect(0).not.toBeArrayOfSize(1); -- cgit v1.2.3 From 217501e180eadd1999f30733e0f13580cd1f0abf Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Thu, 22 Jun 2023 22:27:00 -0700 Subject: `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> --- packages/bun-types/bun-test.d.ts | 14 + src/bun.js/bindings/bindings.cpp | 12 + src/bun.js/bindings/bindings.zig | 13 + src/bun.js/bindings/exports.zig | 14 +- src/bun.js/bindings/generated_classes_list.zig | 10 +- src/bun.js/bindings/headers.h | 2 + src/bun.js/bindings/headers.zig | 2 + src/bun.js/event_loop.zig | 24 + src/bun.js/javascript.zig | 5 + src/bun.js/test/expect.zig | 3335 ++++++++++++++++++ src/bun.js/test/jest.zig | 4264 ++---------------------- src/bun.js/test/pretty_format.zig | 15 +- src/bun.js/test/snapshot.zig | 284 ++ src/cli/test_command.zig | 2 +- src/jsc.zig | 2 + test/cli/test/bun-test.test.ts | 22 +- 16 files changed, 3970 insertions(+), 4050 deletions(-) create mode 100644 src/bun.js/test/expect.zig create mode 100644 src/bun.js/test/snapshot.zig diff --git a/packages/bun-types/bun-test.d.ts b/packages/bun-types/bun-test.d.ts index ba59966ad..156585766 100644 --- a/packages/bun-types/bun-test.d.ts +++ b/packages/bun-types/bun-test.d.ts @@ -424,6 +424,20 @@ declare module "bun:test" { * expect(null).not.toBeNull(); */ not: Expect; + /** + * Expects the value to be a promise that resolves. + * + * @example + * expect(Promise.resolve(1)).resolves.toBe(1); + */ + resolves: Expect; + /** + * Expects the value to be a promise that rejects. + * + * @example + * expect(Promise.reject("error")).rejects.toBe("error"); + */ + rejects: Expect; /** * Asserts that a value equals what is expected. * diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 4eee81f4d..2c2f5c2ea 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -2593,6 +2593,12 @@ bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1) { return arg0->isHandled(reinterpret_cast(arg1)); } +void JSC__JSPromise__setHandled(JSC__JSPromise* promise, JSC__VM* arg1) +{ + auto& vm = *arg1; + auto flags = promise->internalField(JSC::JSPromise::Field::Flags).get().asUInt32(); + promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(flags | JSC::JSPromise::isHandledFlag)); +} #pragma mark - JSC::JSInternalPromise @@ -2666,6 +2672,12 @@ bool JSC__JSInternalPromise__isHandled(const JSC__JSInternalPromise* arg0, JSC__ { return arg0->isHandled(reinterpret_cast(arg1)); } +void JSC__JSInternalPromise__setHandled(JSC__JSInternalPromise* promise, JSC__VM* arg1) +{ + auto& vm = *arg1; + auto flags = promise->internalField(JSC::JSPromise::Field::Flags).get().asUInt32(); + promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(flags | JSC::JSPromise::isHandledFlag)); +} #pragma mark - JSC::JSGlobalObject diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 581fc6f85..00833c71d 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -2045,6 +2045,9 @@ pub const JSPromise = extern struct { pub fn isHandled(this: *const JSPromise, vm: *VM) bool { return cppFn("isHandled", .{ this, vm }); } + pub fn setHandled(this: *JSPromise, vm: *VM) void { + cppFn("setHandled", .{ this, vm }); + } pub fn rejectWithCaughtException(this: *JSPromise, globalObject: *JSGlobalObject, scope: ThrowScope) void { return cppFn("rejectWithCaughtException", .{ this, globalObject, scope }); @@ -2115,6 +2118,7 @@ pub const JSPromise = extern struct { "asValue", "create", "isHandled", + "setHandled", "reject", "rejectAsHandled", "rejectAsHandledException", @@ -2149,6 +2153,9 @@ pub const JSInternalPromise = extern struct { pub fn isHandled(this: *const JSInternalPromise, vm: *VM) bool { return cppFn("isHandled", .{ this, vm }); } + pub fn setHandled(this: *JSInternalPromise, vm: *VM) void { + cppFn("setHandled", .{ this, vm }); + } pub fn rejectWithCaughtException(this: *JSInternalPromise, globalObject: *JSGlobalObject, scope: ThrowScope) void { return cppFn("rejectWithCaughtException", .{ this, globalObject, scope }); @@ -2332,6 +2339,7 @@ pub const JSInternalPromise = extern struct { "status", "result", "isHandled", + "setHandled", "resolvedPromise", "rejectedPromise", "resolve", @@ -2363,6 +2371,11 @@ pub const AnyPromise = union(enum) { inline else => |promise| promise.isHandled(vm), }; } + pub fn setHandled(this: AnyPromise, vm: *VM) void { + switch (this) { + inline else => |promise| promise.setHandled(vm), + } + } pub fn rejectWithCaughtException(this: AnyPromise, globalObject: *JSGlobalObject, scope: ThrowScope) void { switch (this) { diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index de3f819b7..f77b57216 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -2220,11 +2220,11 @@ pub const ZigConsoleClient = struct { } else if (value.as(JSC.ResolveMessage)) |resolve_log| { resolve_log.msg.writeFormat(writer_, enable_ansi_colors) catch {}; return; - } else if (value.as(JSC.Jest.ExpectAnything) != null) { + } else if (value.as(JSC.Expect.ExpectAnything) != null) { writer.writeAll("Anything"); return; - } else if (value.as(JSC.Jest.ExpectAny) != null) { - const constructor_value = JSC.Jest.ExpectAny.constructorValueGetCached(value) orelse return; + } else if (value.as(JSC.Expect.ExpectAny) != null) { + const constructor_value = JSC.Expect.ExpectAny.constructorValueGetCached(value) orelse return; this.addForNewLine("Any<".len); writer.writeAll("Any<"); @@ -2237,16 +2237,16 @@ pub const ZigConsoleClient = struct { writer.writeAll(">"); return; - } else if (value.as(JSC.Jest.ExpectStringContaining) != null) { - const substring_value = JSC.Jest.ExpectStringContaining.stringValueGetCached(value) orelse return; + } else if (value.as(JSC.Expect.ExpectStringContaining) != null) { + const substring_value = JSC.Expect.ExpectStringContaining.stringValueGetCached(value) orelse return; this.addForNewLine("StringContaining ".len); writer.writeAll("StringContaining "); this.printAs(.String, Writer, writer_, substring_value, .String, enable_ansi_colors); return; - } else if (value.as(JSC.Jest.ExpectStringMatching) != null) { - const test_value = JSC.Jest.ExpectStringMatching.testValueGetCached(value) orelse return; + } else if (value.as(JSC.Expect.ExpectStringMatching) != null) { + const test_value = JSC.Expect.ExpectStringMatching.testValueGetCached(value) orelse return; this.addForNewLine("StringMatching ".len); writer.writeAll("StringMatching "); diff --git a/src/bun.js/bindings/generated_classes_list.zig b/src/bun.js/bindings/generated_classes_list.zig index d5d987dce..c54965093 100644 --- a/src/bun.js/bindings/generated_classes_list.zig +++ b/src/bun.js/bindings/generated_classes_list.zig @@ -4,11 +4,11 @@ pub const Classes = struct { pub const Blob = JSC.WebCore.Blob; pub const CryptoHasher = JSC.API.Bun.Crypto.CryptoHasher; pub const Dirent = JSC.Node.Dirent; - pub const Expect = JSC.Jest.Expect; - pub const ExpectAny = JSC.Jest.ExpectAny; - pub const ExpectAnything = JSC.Jest.ExpectAnything; - pub const ExpectStringContaining = JSC.Jest.ExpectStringContaining; - pub const ExpectStringMatching = JSC.Jest.ExpectStringMatching; + pub const Expect = JSC.Expect.Expect; + pub const ExpectAny = JSC.Expect.ExpectAny; + pub const ExpectAnything = JSC.Expect.ExpectAnything; + pub const ExpectStringContaining = JSC.Expect.ExpectStringContaining; + pub const ExpectStringMatching = JSC.Expect.ExpectStringMatching; pub const FileSystemRouter = JSC.API.FileSystemRouter; pub const Bundler = JSC.API.JSBundler; pub const JSBundler = Bundler; diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h index cdf7e05f4..f507121f8 100644 --- a/src/bun.js/bindings/headers.h +++ b/src/bun.js/bindings/headers.h @@ -253,6 +253,7 @@ CPP_DECL JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* ar CPP_DECL JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); CPP_DECL void JSC__JSPromise__resolveOnNextTick(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); CPP_DECL JSC__JSValue JSC__JSPromise__result(JSC__JSPromise* arg0, JSC__VM* arg1); +CPP_DECL void JSC__JSPromise__setHandled(JSC__JSPromise* arg0, JSC__VM* arg1); CPP_DECL uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1); #pragma mark - JSC::JSInternalPromise @@ -267,6 +268,7 @@ CPP_DECL void JSC__JSInternalPromise__rejectWithCaughtException(JSC__JSInternalP CPP_DECL void JSC__JSInternalPromise__resolve(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); CPP_DECL JSC__JSValue JSC__JSInternalPromise__result(const JSC__JSInternalPromise* arg0, JSC__VM* arg1); +CPP_DECL void JSC__JSInternalPromise__setHandled(JSC__JSInternalPromise* arg0, JSC__VM* arg1); CPP_DECL uint32_t JSC__JSInternalPromise__status(const JSC__JSInternalPromise* arg0, JSC__VM* arg1); #pragma mark - JSC::JSFunction diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig index 4dda5f30b..666369b21 100644 --- a/src/bun.js/bindings/headers.zig +++ b/src/bun.js/bindings/headers.zig @@ -168,6 +168,7 @@ pub extern fn JSC__JSPromise__resolvedPromise(arg0: *bindings.JSGlobalObject, JS pub extern fn JSC__JSPromise__resolvedPromiseValue(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) JSC__JSValue; pub extern fn JSC__JSPromise__resolveOnNextTick(arg0: ?*bindings.JSPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void; pub extern fn JSC__JSPromise__result(arg0: ?*bindings.JSPromise, arg1: *bindings.VM) JSC__JSValue; +pub extern fn JSC__JSPromise__setHandled(arg0: ?*bindings.JSPromise, arg1: *bindings.VM) void; pub extern fn JSC__JSPromise__status(arg0: [*c]const JSC__JSPromise, arg1: *bindings.VM) u32; pub extern fn JSC__JSInternalPromise__create(arg0: *bindings.JSGlobalObject) [*c]bindings.JSInternalPromise; pub extern fn JSC__JSInternalPromise__isHandled(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) bool; @@ -179,6 +180,7 @@ pub extern fn JSC__JSInternalPromise__rejectWithCaughtException(arg0: [*c]bindin pub extern fn JSC__JSInternalPromise__resolve(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.JSGlobalObject, JSValue2: JSC__JSValue) void; pub extern fn JSC__JSInternalPromise__resolvedPromise(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) [*c]bindings.JSInternalPromise; pub extern fn JSC__JSInternalPromise__result(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) JSC__JSValue; +pub extern fn JSC__JSInternalPromise__setHandled(arg0: [*c]bindings.JSInternalPromise, arg1: *bindings.VM) void; pub extern fn JSC__JSInternalPromise__status(arg0: [*c]const JSC__JSInternalPromise, arg1: *bindings.VM) u32; pub extern fn JSC__JSFunction__optimizeSoon(JSValue0: JSC__JSValue) void; pub extern fn JSC__JSGlobalObject__bunVM(arg0: *bindings.JSGlobalObject) ?*bindings.VirtualMachine; diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index 8441bd064..0a3459d64 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -666,6 +666,30 @@ pub const EventLoop = struct { } } + pub fn waitForPromiseWithTimeout(this: *EventLoop, promise: JSC.AnyPromise, timeout: u32) bool { + return switch (promise.status(this.global.vm())) { + JSC.JSPromise.Status.Pending => { + if (timeout == 0) { + return false; + } + var start_time = std.time.milliTimestamp(); + while (promise.status(this.global.vm()) == .Pending) { + this.tick(); + + if (std.time.milliTimestamp() - start_time > timeout) { + return false; + } + + if (promise.status(this.global.vm()) == .Pending) { + this.autoTick(); + } + } + return true; + }, + else => true, + }; + } + pub fn waitForTasks(this: *EventLoop) void { this.tick(); while (this.tasks.count > 0) { diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 545f41f19..bebfbeb18 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -653,6 +653,10 @@ pub const VirtualMachine = struct { this.eventLoop().waitForPromise(promise); } + pub fn waitForPromiseWithTimeout(this: *VirtualMachine, promise: JSC.AnyPromise, timeout: u32) bool { + return this.eventLoop().waitForPromiseWithTimeout(promise, timeout); + } + pub fn waitForTasks(this: *VirtualMachine) void { this.eventLoop().waitForTasks(); } @@ -957,6 +961,7 @@ pub const VirtualMachine = struct { } pub fn refCountedStringWithWasNew(this: *VirtualMachine, new: *bool, input_: []const u8, hash_: ?u32, comptime dupe: bool) *JSC.RefString { + JSC.markBinding(@src()); const hash = hash_ orelse JSC.RefString.computeHash(input_); var entry = this.ref_strings.getOrPut(hash) catch unreachable; diff --git a/src/bun.js/test/expect.zig b/src/bun.js/test/expect.zig new file mode 100644 index 000000000..90fcb2a73 --- /dev/null +++ b/src/bun.js/test/expect.zig @@ -0,0 +1,3335 @@ +const std = @import("std"); +const bun = @import("root").bun; +const default_allocator = bun.default_allocator; +const string = bun.string; +const MutableString = bun.MutableString; +const strings = bun.strings; +const Output = bun.Output; +const jest = bun.JSC.Jest; +const Jest = jest.Jest; +const TestRunner = jest.TestRunner; +const DescribeScope = jest.DescribeScope; +const JSC = bun.JSC; +const VirtualMachine = JSC.VirtualMachine; +const JSGlobalObject = JSC.JSGlobalObject; +const JSValue = JSC.JSValue; +const JSInternalPromise = JSC.JSInternalPromise; +const JSPromise = JSC.JSPromise; +const JSType = JSValue.JSType; +const JSError = JSC.JSError; +const JSObject = JSC.JSObject; +const CallFrame = JSC.CallFrame; +const ZigString = JSC.ZigString; +const Environment = bun.Environment; +const DiffFormatter = @import("./diff_format.zig").DiffFormatter; + +pub const Counter = struct { + expected: u32 = 0, + actual: u32 = 0, +}; + +pub var active_test_expectation_counter: Counter = .{}; + +/// https://jestjs.io/docs/expect +// To support async tests, we need to track the test ID +pub const Expect = struct { + pub usingnamespace JSC.Codegen.JSExpect; + + test_id: TestRunner.Test.ID, + scope: *DescribeScope, + flags: Flags = .{}, + + pub const Flags = packed struct { + promise: enum(u2) { + resolves, + rejects, + none, + } = .none, + not: bool = false, + }; + + pub fn getSignature(comptime matcher_name: string, comptime args: string, comptime not: bool) string { + const received = "expect(received)."; + comptime if (not) { + return received ++ "not." ++ matcher_name ++ "(" ++ args ++ ")"; + }; + return received ++ matcher_name ++ "(" ++ args ++ ")"; + } + + pub fn getFullSignature(comptime matcher: string, comptime args: string, comptime flags: Flags) string { + const fmt = "expect(received)." ++ if (flags.promise != .none) + switch (flags.promise) { + .resolves => if (flags.not) "resolves.not." else "resolves.", + .rejects => if (flags.not) "rejects.not." else "rejects.", + else => unreachable, + } + else if (flags.not) "not." else ""; + return fmt ++ matcher ++ "(" ++ args ++ ")"; + } + + pub fn getNot(this: *Expect, thisValue: JSValue, _: *JSGlobalObject) callconv(.C) JSValue { + this.flags.not = !this.flags.not; + return thisValue; + } + + pub fn getResolves(this: *Expect, thisValue: JSValue, globalThis: *JSGlobalObject) callconv(.C) JSValue { + switch (this.flags.promise) { + .rejects => { + globalThis.throw("Cannot chain .resolves() after .rejects()", .{}); + return .zero; + }, + .resolves => {}, + .none => { + this.flags.promise = .resolves; + }, + } + return thisValue; + } + + pub fn getRejects(this: *Expect, thisValue: JSValue, globalThis: *JSGlobalObject) callconv(.C) JSValue { + switch (this.flags.promise) { + .rejects => { + this.flags.promise = .rejects; + }, + .resolves => { + globalThis.throw("Cannot chain .rejects() after .resolves()", .{}); + return .zero; + }, + .none => { + this.flags.promise = .resolves; + }, + } + + return thisValue; + } + + pub fn getValue(this: *Expect, globalThis: *JSGlobalObject, thisValue: JSValue, comptime matcher_name: string, comptime matcher_args: string) ?JSValue { + if (this.scope.tests.items.len <= this.test_id) { + globalThis.throw("{s}() must be called in a test", .{matcher_name}); + return null; + } + + const value = Expect.capturedValueGetCached(thisValue) orelse { + globalThis.throw("Internal error: the expect(value) was garbage collected but it should not have been!", .{}); + return null; + }; + value.ensureStillAlive(); + + switch (this.flags.promise) { + inline .resolves, .rejects => |resolution| { + if (value.asAnyPromise()) |promise| { + var vm = globalThis.vm(); + promise.setHandled(vm); + + const now = std.time.Instant.now() catch unreachable; + const pending_test = Jest.runner.?.pending_test.?; + const elapsed = @divFloor(now.since(pending_test.started_at), std.time.ns_per_ms); + const remaining = @truncate(u32, Jest.runner.?.last_test_timeout_timer_duration -| elapsed); + + if (!globalThis.bunVM().waitForPromiseWithTimeout(promise, remaining)) { + pending_test.timeout(); + return null; + } + + const newValue = promise.result(vm); + switch (promise.status(vm)) { + .Fulfilled => switch (comptime resolution) { + .resolves => {}, + .rejects => { + if (this.flags.not) { + const signature = comptime getFullSignature(matcher_name, matcher_args, .{ .not = true, .promise = .rejects }); + const fmt = signature ++ "\n\nExpected promise that rejects\nReceived promise that resolved: {any}\n"; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + globalThis.throwPretty(fmt, .{newValue.toFmt(globalThis, &formatter)}); + return null; + } + const signature = comptime getFullSignature(matcher_name, matcher_args, .{ .not = false, .promise = .rejects }); + const fmt = signature ++ "\n\nExpected promise that rejects\nReceived promise that resolved: {any}\n"; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + globalThis.throwPretty(fmt, .{newValue.toFmt(globalThis, &formatter)}); + return null; + }, + .none => unreachable, + }, + .Rejected => switch (comptime resolution) { + .rejects => {}, + .resolves => { + if (this.flags.not) { + const signature = comptime getFullSignature(matcher_name, matcher_args, .{ .not = true, .promise = .resolves }); + const fmt = signature ++ "\n\nExpected promise that resolves\nReceived promise that rejected: {any}\n"; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + globalThis.throwPretty(fmt, .{newValue.toFmt(globalThis, &formatter)}); + return null; + } + const signature = comptime getFullSignature(matcher_name, matcher_args, .{ .not = false, .promise = .resolves }); + const fmt = signature ++ "\n\nExpected promise that resolves\nReceived promise that rejected: {any}\n"; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + globalThis.throwPretty(fmt, .{newValue.toFmt(globalThis, &formatter)}); + return null; + }, + .none => unreachable, + }, + .Pending => unreachable, + } + + newValue.ensureStillAlive(); + return newValue; + } else { + switch (this.flags.promise) { + .resolves => { + if (this.flags.not) { + const signature = comptime getFullSignature(matcher_name, matcher_args, .{ .not = true, .promise = .resolves }); + const fmt = signature ++ "\n\nExpected promise\nReceived: {any}\n"; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + globalThis.throwPretty(fmt, .{value.toFmt(globalThis, &formatter)}); + return null; + } + const signature = comptime getFullSignature(matcher_name, matcher_args, .{ .not = false, .promise = .resolves }); + const fmt = signature ++ "\n\nExpected promise\nReceived: {any}\n"; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + globalThis.throwPretty(fmt, .{value.toFmt(globalThis, &formatter)}); + return null; + }, + .rejects => { + if (this.flags.not) { + const signature = comptime getFullSignature(matcher_name, matcher_args, .{ .not = true, .promise = .rejects }); + const fmt = signature ++ "\n\nExpected promise\nReceived: {any}\n"; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + globalThis.throwPretty(fmt, .{value.toFmt(globalThis, &formatter)}); + return null; + } + const signature = comptime getFullSignature(matcher_name, matcher_args, .{ .not = false, .promise = .rejects }); + const fmt = signature ++ "\n\nExpected promise\nReceived: {any}\n"; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + globalThis.throwPretty(fmt, .{value.toFmt(globalThis, &formatter)}); + return null; + }, + .none => unreachable, + } + } + }, + else => {}, + } + + return value; + } + + pub fn getSnapshotName(this: *Expect, allocator: std.mem.Allocator, hint: string) ![]const u8 { + const test_name = this.scope.tests.items[this.test_id].label; + + var length: usize = 0; + var curr_scope: ?*DescribeScope = this.scope; + while (curr_scope) |scope| { + if (scope.label.len > 0) { + length += scope.label.len + 1; + } + curr_scope = scope.parent; + } + length += test_name.len; + if (hint.len > 0) { + length += hint.len + 2; + } + + var buf = try allocator.alloc(u8, length); + + var index = buf.len; + if (hint.len > 0) { + index -= hint.len; + bun.copy(u8, buf[index..], hint); + index -= test_name.len + 2; + bun.copy(u8, buf[index..], test_name); + bun.copy(u8, buf[index + test_name.len ..], ": "); + } else { + index -= test_name.len; + bun.copy(u8, buf[index..], test_name); + } + // copy describe scopes in reverse order + curr_scope = this.scope; + while (curr_scope) |scope| { + if (scope.label.len > 0) { + index -= scope.label.len + 1; + bun.copy(u8, buf[index..], scope.label); + buf[index + scope.label.len] = ' '; + } + curr_scope = scope.parent; + } + + return buf; + } + + pub fn finalize( + this: *Expect, + ) callconv(.C) void { + VirtualMachine.get().allocator.destroy(this); + } + + pub fn call(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { + const arguments = callframe.arguments(1); + const value = if (arguments.len < 1) JSC.JSValue.jsUndefined() else arguments.ptr[0]; + + var expect = globalObject.bunVM().allocator.create(Expect) catch unreachable; + + if (Jest.runner.?.pending_test == null) { + const err = globalObject.createErrorInstance("expect() must be called in a test", .{}); + err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); + globalObject.throwValue(err); + return .zero; + } + + expect.* = .{ + .scope = Jest.runner.?.pending_test.?.describe, + .test_id = Jest.runner.?.pending_test.?.test_id, + }; + const expect_js_value = expect.toJS(globalObject); + expect_js_value.ensureStillAlive(); + Expect.capturedValueSetCached(expect_js_value, globalObject, value); + expect_js_value.ensureStillAlive(); + expect.postMatch(globalObject); + return expect_js_value; + } + + pub fn constructor( + globalObject: *JSC.JSGlobalObject, + _: *JSC.CallFrame, + ) callconv(.C) ?*Expect { + globalObject.throw("expect() cannot be called with new", .{}); + return null; + } + + /// Object.is() + pub fn toBe( + this: *Expect, + globalObject: *JSC.JSGlobalObject, + callframe: *JSC.CallFrame, + ) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + const thisValue = callframe.this(); + const arguments_ = callframe.arguments(1); + const arguments = arguments_.ptr[0..arguments_.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toBe() takes 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + const right = arguments[0]; + right.ensureStillAlive(); + const left = this.getValue(globalObject, thisValue, "toBe", "expected") orelse return .zero; + + const not = this.flags.not; + var pass = right.isSameValue(left, globalObject); + if (comptime Environment.allow_assert) { + std.debug.assert(pass == JSC.C.JSValueIsStrictEqual(globalObject, right.asObjectRef(), left.asObjectRef())); + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + if (not) { + const signature = comptime getSignature("toBe", "expected", true); + const fmt = signature ++ "\n\nExpected: not {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{right.toFmt(globalObject, &formatter)}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{right.toFmt(globalObject, &formatter)}); + return .zero; + } + + const signature = comptime getSignature("toBe", "expected", false); + if (left.deepEquals(right, globalObject) or left.strictDeepEquals(right, globalObject)) { + const fmt = signature ++ + "\n\nIf this test should pass, replace \"toBe\" with \"toEqual\" or \"toStrictEqual\"" ++ + "\n\nExpected: {any}\n" ++ + "Received: serializes to the same string\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{right.toFmt(globalObject, &formatter)}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{right.toFmt(globalObject, &formatter)}); + return .zero; + } + + if (right.isString() and left.isString()) { + const diff_format = DiffFormatter{ + .expected = right, + .received = left, + .globalObject = globalObject, + .not = not, + }; + const fmt = signature ++ "\n\n{any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{diff_format}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{diff_format}); + return .zero; + } + + const fmt = signature ++ "\n\nExpected: {any}\nReceived: {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ + right.toFmt(globalObject, &formatter), + left.toFmt(globalObject, &formatter), + }); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{ + right.toFmt(globalObject, &formatter), + left.toFmt(globalObject, &formatter), + }); + return .zero; + } + + pub fn toHaveLength( + this: *Expect, + globalObject: *JSC.JSGlobalObject, + callframe: *JSC.CallFrame, + ) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + const thisValue = callframe.this(); + const arguments_ = callframe.arguments(1); + const arguments = arguments_.ptr[0..arguments_.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toHaveLength() takes 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const expected: JSValue = arguments[0]; + const value: JSValue = this.getValue(globalObject, thisValue, "toHaveLength", "expected") orelse return .zero; + + if (!value.isObject() and !value.isString()) { + var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + globalObject.throw("Received value does not have a length property: {any}", .{value.toFmt(globalObject, &fmt)}); + return .zero; + } + + if (!expected.isNumber()) { + var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + globalObject.throw("Expected value must be a non-negative integer: {any}", .{expected.toFmt(globalObject, &fmt)}); + return .zero; + } + + const expected_length: f64 = expected.asNumber(); + if (@round(expected_length) != expected_length or std.math.isInf(expected_length) or std.math.isNan(expected_length) or expected_length < 0) { + var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + globalObject.throw("Expected value must be a non-negative integer: {any}", .{expected.toFmt(globalObject, &fmt)}); + return .zero; + } + + const not = this.flags.not; + var pass = false; + + const actual_length = value.getLengthIfPropertyExistsInternal(globalObject); + + if (actual_length == std.math.inf(f64)) { + var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + globalObject.throw("Received value does not have a length property: {any}", .{value.toFmt(globalObject, &fmt)}); + return .zero; + } else if (std.math.isNan(actual_length)) { + globalObject.throw("Received value has non-number length property: {}", .{actual_length}); + return .zero; + } + + if (actual_length == expected_length) { + pass = true; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + if (not) { + const expected_line = "Expected length: not {d}\n"; + const fmt = comptime getSignature("toHaveLength", "expected", true) ++ "\n\n" ++ expected_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{expected_length}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{expected_length}); + return .zero; + } + + const expected_line = "Expected length: {d}\n"; + const received_line = "Received length: {d}\n"; + const fmt = comptime getSignature("toHaveLength", "expected", false) ++ "\n\n" ++ + expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_length, actual_length }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_length, actual_length }); + return .zero; + } + + pub fn toContain( + this: *Expect, + globalObject: *JSC.JSGlobalObject, + callFrame: *JSC.CallFrame, + ) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + const thisValue = callFrame.this(); + const arguments_ = callFrame.arguments(1); + const arguments = arguments_.ptr[0..arguments_.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toContain() takes 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const expected = arguments[0]; + expected.ensureStillAlive(); + const value: JSValue = this.getValue(globalObject, thisValue, "toContain", "expected") orelse return .zero; + + const not = this.flags.not; + var pass = false; + + if (value.isIterable(globalObject)) { + var itr = value.arrayIterator(globalObject); + while (itr.next()) |item| { + if (item.isSameValue(expected, globalObject)) { + pass = true; + break; + } + } + } else if (value.isString() and expected.isString()) { + const value_string = value.toString(globalObject).toSlice(globalObject, default_allocator).slice(); + const expected_string = expected.toString(globalObject).toSlice(globalObject, default_allocator).slice(); + if (strings.contains(value_string, expected_string)) { + pass = true; + } else if (value_string.len == 0 and expected_string.len == 0) { // edge case two empty strings are true + pass = true; + } + } else { + globalObject.throw("Received value must be an array type, or both received and expected values must be strings.", .{}); + return .zero; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + const expected_fmt = expected.toFmt(globalObject, &formatter); + if (not) { + const expected_line = "Expected to contain: not {any}\n"; + const fmt = comptime getSignature("toContain", "expected", true) ++ "\n\n" ++ expected_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{expected_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{expected_fmt}); + return .zero; + } + + const expected_line = "Expected to contain: {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toContain", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); + return .zero; + } + + pub fn toBeTruthy(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalObject, thisValue, "toBeTruthy", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = false; + + const truthy = value.toBooleanSlow(globalObject); + if (truthy) pass = true; + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeTruthy", "", true) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeTruthy", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + pub fn toBeUndefined(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalObject, thisValue, "toBeUndefined", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = false; + if (value.isUndefined()) pass = true; + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeUndefined", "", true) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeUndefined", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + pub fn toBeNaN(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalObject, thisValue, "toBeNaN", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = false; + if (value.isNumber()) { + const number = value.asNumber(); + if (number != number) pass = true; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeNaN", "", true) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeNaN", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + pub fn toBeNull(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalObject, thisValue, "toBeNull", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = value.isNull(); + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeNull", "", true) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeNull", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + pub fn toBeDefined(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalObject, thisValue, "toBeDefined", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = !value.isUndefined(); + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeDefined", "", true) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeDefined", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + pub fn toBeFalsy(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toBeFalsy", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = false; + + const truthy = value.toBooleanSlow(globalObject); + if (!truthy) pass = true; + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeFalsy", "", true) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeFalsy", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + pub fn toEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toEqual() requires 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const expected = arguments[0]; + const value: JSValue = this.getValue(globalObject, thisValue, "toEqual", "expected") orelse return .zero; + + const not = this.flags.not; + var pass = value.jestDeepEquals(expected, globalObject); + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + const diff_formatter = DiffFormatter{ + .received = value, + .expected = expected, + .globalObject = globalObject, + .not = not, + }; + + if (not) { + const signature = comptime getSignature("toEqual", "expected", true); + const fmt = signature ++ "\n\n{any}\n"; + globalObject.throwPretty(fmt, .{diff_formatter}); + return .zero; + } + + const signature = comptime getSignature("toEqual", "expected", false); + const fmt = signature ++ "\n\n{any}\n"; + globalObject.throwPretty(fmt, .{diff_formatter}); + return .zero; + } + + pub fn toStrictEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toStrictEqual() requires 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const expected = arguments[0]; + const value: JSValue = this.getValue(globalObject, thisValue, "toStrictEqual", "expected") orelse return .zero; + + const not = this.flags.not; + var pass = value.jestStrictDeepEquals(expected, globalObject); + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + const diff_formatter = DiffFormatter{ .received = value, .expected = expected, .globalObject = globalObject, .not = not }; + + if (not) { + const signature = comptime getSignature("toStrictEqual", "expected", true); + const fmt = signature ++ "\n\n{any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{diff_formatter}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{diff_formatter}); + return .zero; + } + + const signature = comptime getSignature("toStrictEqual", "expected", false); + const fmt = signature ++ "\n\n{any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{diff_formatter}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{diff_formatter}); + return .zero; + } + + pub fn toHaveProperty(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(2); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toHaveProperty() requires at least 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const expected_property_path = arguments[0]; + expected_property_path.ensureStillAlive(); + const expected_property: ?JSValue = if (arguments.len > 1) arguments[1] else null; + if (expected_property) |ev| ev.ensureStillAlive(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toHaveProperty", "path, value") orelse return .zero; + + if (!expected_property_path.isString() and !expected_property_path.isIterable(globalObject)) { + globalObject.throw("Expected path must be a string or an array", .{}); + return .zero; + } + + const not = this.flags.not; + var path_string = ZigString.Empty; + expected_property_path.toZigString(&path_string, globalObject); + + var pass = !value.isUndefinedOrNull(); + var received_property: JSValue = .zero; + + if (pass) { + received_property = value.getIfPropertyExistsFromPath(globalObject, expected_property_path); + pass = !received_property.isEmpty(); + } + + if (pass and expected_property != null) { + pass = received_property.jestDeepEquals(expected_property.?, globalObject); + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + if (not) { + if (expected_property != null) { + const signature = comptime getSignature("toHaveProperty", "path, value", true); + if (!received_property.isEmpty()) { + const fmt = signature ++ "\n\nExpected path: {any}\n\nExpected value: not {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ + expected_property_path.toFmt(globalObject, &formatter), + expected_property.?.toFmt(globalObject, &formatter), + }); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, true), .{ + expected_property_path.toFmt(globalObject, &formatter), + expected_property.?.toFmt(globalObject, &formatter), + }); + return .zero; + } + } + + const signature = comptime getSignature("toHaveProperty", "path", true); + const fmt = signature ++ "\n\nExpected path: not {any}\n\nReceived value: {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ + expected_property_path.toFmt(globalObject, &formatter), + received_property.toFmt(globalObject, &formatter), + }); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{ + expected_property_path.toFmt(globalObject, &formatter), + received_property.toFmt(globalObject, &formatter), + }); + return .zero; + } + + if (expected_property != null) { + const signature = comptime getSignature("toHaveProperty", "path, value", false); + if (!received_property.isEmpty()) { + // deep equal case + const fmt = signature ++ "\n\n{any}\n"; + const diff_format = DiffFormatter{ + .received = received_property, + .expected = expected_property.?, + .globalObject = globalObject, + }; + + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{diff_format}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{diff_format}); + return .zero; + } + + const fmt = signature ++ "\n\nExpected path: {any}\n\nExpected value: {any}\n\n" ++ + "Unable to find property\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ + expected_property_path.toFmt(globalObject, &formatter), + expected_property.?.toFmt(globalObject, &formatter), + }); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{ + expected_property_path.toFmt(globalObject, &formatter), + expected_property.?.toFmt(globalObject, &formatter), + }); + return .zero; + } + + const signature = comptime getSignature("toHaveProperty", "path", false); + const fmt = signature ++ "\n\nExpected path: {any}\n\nUnable to find property\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{expected_property_path.toFmt(globalObject, &formatter)}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{expected_property_path.toFmt(globalObject, &formatter)}); + return .zero; + } + + pub fn toBeEven(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toBeEven", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = false; + + if (value.isAnyInt()) { + const _value = value.toInt64(); + pass = @mod(_value, 2) == 0; + if (_value == -0) { // negative zero is even + pass = true; + } + } else if (value.isBigInt() or value.isBigInt32()) { + const _value = value.toInt64(); + pass = switch (_value == -0) { // negative zero is even + true => true, + else => _value & 1 == 0, + }; + } else if (value.isNumber()) { + const _value = JSValue.asNumber(value); + if (@mod(_value, 1) == 0 and @mod(_value, 2) == 0) { // if the fraction is all zeros and even + pass = true; + } else { + pass = false; + } + } else { + pass = false; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeEven", "", true) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeEven", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + pub fn toBeGreaterThan(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toBeGreaterThan() requires 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const other_value = arguments[0]; + other_value.ensureStillAlive(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toBeGreaterThan", "expected") orelse return .zero; + + if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) { + globalObject.throw("Expected and actual values must be numbers or bigints", .{}); + return .zero; + } + + const not = this.flags.not; + var pass = false; + + if (!value.isBigInt() and !other_value.isBigInt()) { + pass = value.asNumber() > other_value.asNumber(); + } else if (value.isBigInt()) { + pass = switch (value.asBigIntCompare(globalObject, other_value)) { + .greater_than => true, + else => pass, + }; + } else { + pass = switch (other_value.asBigIntCompare(globalObject, value)) { + .less_than => true, + else => pass, + }; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + const expected_fmt = other_value.toFmt(globalObject, &formatter); + if (not) { + const expected_line = "Expected: not \\> {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeGreaterThan", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected: \\> {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeGreaterThan", "expected", false) ++ "\n\n" ++ + expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(comptime Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); + return .zero; + } + + pub fn toBeGreaterThanOrEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toBeGreaterThanOrEqual() requires 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const other_value = arguments[0]; + other_value.ensureStillAlive(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toBeGreaterThanOrEqual", "expected") orelse return .zero; + + if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) { + globalObject.throw("Expected and actual values must be numbers or bigints", .{}); + return .zero; + } + + const not = this.flags.not; + var pass = false; + + if (!value.isBigInt() and !other_value.isBigInt()) { + pass = value.asNumber() >= other_value.asNumber(); + } else if (value.isBigInt()) { + pass = switch (value.asBigIntCompare(globalObject, other_value)) { + .greater_than, .equal => true, + else => pass, + }; + } else { + pass = switch (other_value.asBigIntCompare(globalObject, value)) { + .less_than, .equal => true, + else => pass, + }; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + const expected_fmt = other_value.toFmt(globalObject, &formatter); + if (not) { + const expected_line = "Expected: not \\>= {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeGreaterThanOrEqual", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected: \\>= {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeGreaterThanOrEqual", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(comptime Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + return .zero; + } + + pub fn toBeLessThan(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toBeLessThan() requires 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const other_value = arguments[0]; + other_value.ensureStillAlive(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toBeLessThan", "expected") orelse return .zero; + + if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) { + globalObject.throw("Expected and actual values must be numbers or bigints", .{}); + return .zero; + } + + const not = this.flags.not; + var pass = false; + + if (!value.isBigInt() and !other_value.isBigInt()) { + pass = value.asNumber() < other_value.asNumber(); + } else if (value.isBigInt()) { + pass = switch (value.asBigIntCompare(globalObject, other_value)) { + .less_than => true, + else => pass, + }; + } else { + pass = switch (other_value.asBigIntCompare(globalObject, value)) { + .greater_than => true, + else => pass, + }; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + const expected_fmt = other_value.toFmt(globalObject, &formatter); + if (not) { + const expected_line = "Expected: not \\< {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeLessThan", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected: \\< {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeLessThan", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(comptime Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + return .zero; + } + + pub fn toBeLessThanOrEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toBeLessThanOrEqual() requires 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const other_value = arguments[0]; + other_value.ensureStillAlive(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toBeLessThanOrEqual", "expected") orelse return .zero; + + if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) { + globalObject.throw("Expected and actual values must be numbers or bigints", .{}); + return .zero; + } + + const not = this.flags.not; + var pass = false; + + if (!value.isBigInt() and !other_value.isBigInt()) { + pass = value.asNumber() <= other_value.asNumber(); + } else if (value.isBigInt()) { + pass = switch (value.asBigIntCompare(globalObject, other_value)) { + .less_than, .equal => true, + else => pass, + }; + } else { + pass = switch (other_value.asBigIntCompare(globalObject, value)) { + .greater_than, .equal => true, + else => pass, + }; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + const expected_fmt = other_value.toFmt(globalObject, &formatter); + if (not) { + const expected_line = "Expected: not \\<= {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeLessThanOrEqual", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected: \\<= {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeLessThanOrEqual", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(comptime Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + return .zero; + } + + pub fn toBeCloseTo(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const thisArguments = callFrame.arguments(2); + const arguments = thisArguments.ptr[0..thisArguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toBeCloseTo() requires at least 1 argument. Expected value must be a number", .{}); + return .zero; + } + + const expected_ = arguments[0]; + if (!expected_.isNumber()) { + globalObject.throwInvalidArgumentType("toBeCloseTo", "expected", "number"); + return .zero; + } + + var precision: f64 = 2.0; + if (arguments.len > 1) { + const precision_ = arguments[1]; + if (!precision_.isNumber()) { + globalObject.throwInvalidArgumentType("toBeCloseTo", "precision", "number"); + return .zero; + } + + precision = precision_.asNumber(); + } + + const received_: JSValue = this.getValue(globalObject, thisValue, "toBeCloseTo", "expected, precision") orelse return .zero; + if (!received_.isNumber()) { + globalObject.throwInvalidArgumentType("expect", "received", "number"); + return .zero; + } + + var expected = expected_.asNumber(); + var received = received_.asNumber(); + + if (std.math.isNegativeInf(expected)) { + expected = -expected; + } + + if (std.math.isNegativeInf(received)) { + received = -received; + } + + if (std.math.isPositiveInf(expected) and std.math.isPositiveInf(received)) { + return thisValue; + } + + const expected_diff = std.math.pow(f64, 10, -precision) / 2; + const actual_diff = std.math.fabs(received - expected); + var pass = actual_diff < expected_diff; + + const not = this.flags.not; + if (not) pass = !pass; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + + const expected_fmt = expected_.toFmt(globalObject, &formatter); + const received_fmt = received_.toFmt(globalObject, &formatter); + + const expected_line = "Expected: {any}\n"; + const received_line = "Received: {any}\n"; + const expected_precision = "Expected precision: {d}\n"; + const expected_difference = "Expected difference: \\< {d}\n"; + const received_difference = "Received difference: {d}\n"; + + const suffix_fmt = "\n\n" ++ expected_line ++ received_line ++ "\n" ++ expected_precision ++ expected_difference ++ received_difference; + + if (not) { + const fmt = comptime getSignature("toBeCloseTo", "expected, precision", true) ++ suffix_fmt; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, received_fmt, precision, expected_diff, actual_diff }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, received_fmt, precision, expected_diff, actual_diff }); + return .zero; + } + + const fmt = comptime getSignature("toBeCloseTo", "expected, precision", false) ++ suffix_fmt; + + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, received_fmt, precision, expected_diff, actual_diff }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, received_fmt, precision, expected_diff, actual_diff }); + return .zero; + } + + pub fn toBeOdd(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toBeOdd", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = false; + + if (value.isBigInt32()) { + pass = value.toInt32() & 1 == 1; + } else if (value.isBigInt()) { + pass = value.toInt64() & 1 == 1; + } else if (value.isInt32()) { + const _value = value.toInt32(); + pass = @mod(_value, 2) == 1; + } else if (value.isAnyInt()) { + const _value = value.toInt64(); + pass = @mod(_value, 2) == 1; + } else if (value.isNumber()) { + const _value = JSValue.asNumber(value); + if (@mod(_value, 1) == 0 and @mod(_value, 2) == 1) { // if the fraction is all zeros and odd + pass = true; + } else { + pass = false; + } + } else { + pass = false; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeOdd", "", true) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeOdd", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); + return .zero; + } + + pub fn toThrow(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + active_test_expectation_counter.actual += 1; + + const expected_value: JSValue = if (arguments.len > 0) brk: { + const value = arguments[0]; + if (value.isEmptyOrUndefinedOrNull() or !value.isObject() and !value.isString()) { + var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + globalObject.throw("Expected value must be string or Error: {any}", .{value.toFmt(globalObject, &fmt)}); + return .zero; + } + break :brk value; + } else .zero; + expected_value.ensureStillAlive(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toThrow", "expected") orelse return .zero; + + if (!value.jsType().isFunction()) { + globalObject.throw("Expected value must be a function", .{}); + return .zero; + } + + const not = this.flags.not; + + const result_: ?JSValue = brk: { + var vm = globalObject.bunVM(); + var return_value: JSValue = .zero; + var scope = vm.unhandledRejectionScope(); + var prev_unhandled_pending_rejection_to_capture = vm.unhandled_pending_rejection_to_capture; + vm.unhandled_pending_rejection_to_capture = &return_value; + vm.onUnhandledRejection = &VirtualMachine.onQuietUnhandledRejectionHandlerCaptureValue; + const return_value_from_fucntion: JSValue = value.call(globalObject, &.{}); + vm.unhandled_pending_rejection_to_capture = prev_unhandled_pending_rejection_to_capture; + + if (return_value == .zero) { + return_value = return_value_from_fucntion; + } + + if (return_value.asAnyPromise()) |promise| { + globalObject.bunVM().waitForPromise(promise); + scope.apply(vm); + const promise_result = promise.result(globalObject.vm()); + + switch (promise.status(globalObject.vm())) { + .Fulfilled => { + break :brk null; + }, + .Rejected => { + // since we know for sure it rejected, we should always return the error + break :brk promise_result.toError() orelse promise_result; + }, + .Pending => unreachable, + } + } + scope.apply(vm); + + break :brk return_value.toError(); + }; + + const did_throw = result_ != null; + + if (not) { + const signature = comptime getSignature("toThrow", "expected", true); + + if (!did_throw) return thisValue; + + const result: JSValue = result_.?; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + + if (expected_value.isEmpty()) { + const signature_no_args = comptime getSignature("toThrow", "", true); + if (result.toError()) |err| { + const name = err.get(globalObject, "name") orelse JSValue.undefined; + const message = err.get(globalObject, "message") orelse JSValue.undefined; + const fmt = signature_no_args ++ "\n\nError name: {any}\nError message: {any}\n"; + globalObject.throwPretty(fmt, .{ + name.toFmt(globalObject, &formatter), + message.toFmt(globalObject, &formatter), + }); + return .zero; + } + + // non error thrown + const fmt = signature_no_args ++ "\n\nThrown value: {any}\n"; + globalObject.throwPretty(fmt, .{result.toFmt(globalObject, &formatter)}); + return .zero; + } + + if (expected_value.isString()) { + const received_message = result.getIfPropertyExistsImpl(globalObject, "message", 7); + + // TODO: remove this allocation + // partial match + { + const expected_slice = expected_value.toSliceOrNull(globalObject) orelse return .zero; + defer expected_slice.deinit(); + const received_slice = received_message.toSliceOrNull(globalObject) orelse return .zero; + defer received_slice.deinit(); + if (!strings.contains(received_slice.slice(), expected_slice.slice())) return thisValue; + } + + const fmt = signature ++ "\n\nExpected substring: not {any}\nReceived message: {any}\n"; + globalObject.throwPretty(fmt, .{ + expected_value.toFmt(globalObject, &formatter), + received_message.toFmt(globalObject, &formatter), + }); + return .zero; + } + + if (expected_value.isRegExp()) { + const received_message = result.getIfPropertyExistsImpl(globalObject, "message", 7); + + // TODO: REMOVE THIS GETTER! Expose a binding to call .test on the RegExp object directly. + if (expected_value.get(globalObject, "test")) |test_fn| { + const matches = test_fn.callWithThis(globalObject, expected_value, &.{received_message}); + if (!matches.toBooleanSlow(globalObject)) return thisValue; + } + + const fmt = signature ++ "\n\nExpected pattern: not {any}\nReceived message: {any}\n"; + globalObject.throwPretty(fmt, .{ + expected_value.toFmt(globalObject, &formatter), + received_message.toFmt(globalObject, &formatter), + }); + return .zero; + } + + if (expected_value.get(globalObject, "message")) |expected_message| { + const received_message = result.getIfPropertyExistsImpl(globalObject, "message", 7); + // no partial match for this case + if (!expected_message.isSameValue(received_message, globalObject)) return thisValue; + + const fmt = signature ++ "\n\nExpected message: not {any}\n"; + globalObject.throwPretty(fmt, .{expected_message.toFmt(globalObject, &formatter)}); + return .zero; + } + + if (!result.isInstanceOf(globalObject, expected_value)) return thisValue; + + var expected_class = ZigString.Empty; + expected_value.getClassName(globalObject, &expected_class); + const received_message = result.getIfPropertyExistsImpl(globalObject, "message", 7); + const fmt = signature ++ "\n\nExpected constructor: not {s}\n\nReceived message: {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_class, received_message.toFmt(globalObject, &formatter) }); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_class, received_message.toFmt(globalObject, &formatter) }); + return .zero; + } + + const signature = comptime getSignature("toThrow", "expected", false); + if (did_throw) { + if (expected_value.isEmpty()) return thisValue; + + const result: JSValue = if (result_.?.toError()) |r| + r + else + result_.?; + + const _received_message: ?JSValue = if (result.isObject()) + result.get(globalObject, "message") + else if (result.toStringOrNull(globalObject)) |js_str| + JSC.JSValue.fromCell(js_str) + else + null; + + if (expected_value.isString()) { + if (_received_message) |received_message| { + // TODO: remove this allocation + // partial match + const expected_slice = expected_value.toSliceOrNull(globalObject) orelse return .zero; + defer expected_slice.deinit(); + const received_slice = received_message.toSlice(globalObject, globalObject.allocator()); + defer received_slice.deinit(); + if (strings.contains(received_slice.slice(), expected_slice.slice())) return thisValue; + } + + // error: message from received error does not match expected string + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + + if (_received_message) |received_message| { + const expected_value_fmt = expected_value.toFmt(globalObject, &formatter); + const received_message_fmt = received_message.toFmt(globalObject, &formatter); + const fmt = signature ++ "\n\n" ++ "Expected substring: {any}\nReceived message: {any}\n"; + globalObject.throwPretty(fmt, .{ expected_value_fmt, received_message_fmt }); + return .zero; + } + + const expected_fmt = expected_value.toFmt(globalObject, &formatter); + const received_fmt = result.toFmt(globalObject, &formatter); + const fmt = signature ++ "\n\n" ++ "Expected substring: {any}\nReceived value: {any}"; + globalObject.throwPretty(fmt, .{ expected_fmt, received_fmt }); + + return .zero; + } + + if (expected_value.isRegExp()) { + if (_received_message) |received_message| { + // TODO: REMOVE THIS GETTER! Expose a binding to call .test on the RegExp object directly. + if (expected_value.get(globalObject, "test")) |test_fn| { + const matches = test_fn.callWithThis(globalObject, expected_value, &.{received_message}); + if (matches.toBooleanSlow(globalObject)) return thisValue; + } + } + + // error: message from received error does not match expected pattern + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + + if (_received_message) |received_message| { + const expected_value_fmt = expected_value.toFmt(globalObject, &formatter); + const received_message_fmt = received_message.toFmt(globalObject, &formatter); + const fmt = signature ++ "\n\n" ++ "Expected pattern: {any}\nReceived message: {any}\n"; + globalObject.throwPretty(fmt, .{ expected_value_fmt, received_message_fmt }); + + return .zero; + } + + const expected_fmt = expected_value.toFmt(globalObject, &formatter); + const received_fmt = result.toFmt(globalObject, &formatter); + const fmt = signature ++ "\n\n" ++ "Expected pattern: {any}\nReceived value: {any}"; + globalObject.throwPretty(fmt, .{ expected_fmt, received_fmt }); + return .zero; + } + + // If it's not an object, we are going to crash here. + std.debug.assert(expected_value.isObject()); + + if (expected_value.get(globalObject, "message")) |expected_message| { + if (_received_message) |received_message| { + if (received_message.isSameValue(expected_message, globalObject)) return thisValue; + } + + // error: message from received error does not match expected error message. + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + + if (_received_message) |received_message| { + const expected_fmt = expected_message.toFmt(globalObject, &formatter); + const received_fmt = received_message.toFmt(globalObject, &formatter); + const fmt = signature ++ "\n\nExpected message: {any}\nReceived message: {any}\n"; + globalObject.throwPretty(fmt, .{ expected_fmt, received_fmt }); + return .zero; + } + + const expected_fmt = expected_message.toFmt(globalObject, &formatter); + const received_fmt = result.toFmt(globalObject, &formatter); + const fmt = signature ++ "\n\nExpected message: {any}\nReceived value: {any}\n"; + globalObject.throwPretty(fmt, .{ expected_fmt, received_fmt }); + return .zero; + } + + if (result.isInstanceOf(globalObject, expected_value)) return thisValue; + + // error: received error not instance of received error constructor + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + var expected_class = ZigString.Empty; + var received_class = ZigString.Empty; + expected_value.getClassName(globalObject, &expected_class); + result.getClassName(globalObject, &received_class); + const fmt = signature ++ "\n\nExpected constructor: {s}\nReceived constructor: {s}\n\n"; + + if (_received_message) |received_message| { + const message_fmt = fmt ++ "Received message: {any}\n"; + const received_message_fmt = received_message.toFmt(globalObject, &formatter); + + globalObject.throwPretty(message_fmt, .{ + expected_class, + received_class, + received_message_fmt, + }); + return .zero; + } + + const received_fmt = result.toFmt(globalObject, &formatter); + const value_fmt = fmt ++ "Received value: {any}\n"; + + globalObject.throwPretty(value_fmt, .{ + expected_class, + received_class, + received_fmt, + }); + return .zero; + } + + // did not throw + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + const received_line = "Received function did not throw\n"; + + if (expected_value.isEmpty()) { + const fmt = comptime getSignature("toThrow", "", false) ++ "\n\n" ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{}); + return .zero; + } + + if (expected_value.isString()) { + const expected_fmt = "\n\nExpected substring: {any}\n\n" ++ received_line; + const fmt = signature ++ expected_fmt; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{expected_value.toFmt(globalObject, &formatter)}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{expected_value.toFmt(globalObject, &formatter)}); + return .zero; + } + + if (expected_value.isRegExp()) { + const expected_fmt = "\n\nExpected pattern: {any}\n\n" ++ received_line; + const fmt = signature ++ expected_fmt; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{expected_value.toFmt(globalObject, &formatter)}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{expected_value.toFmt(globalObject, &formatter)}); + return .zero; + } + + if (expected_value.get(globalObject, "message")) |expected_message| { + const expected_fmt = "\n\nExpected message: {any}\n\n" ++ received_line; + const fmt = signature ++ expected_fmt; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{expected_message.toFmt(globalObject, &formatter)}); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{expected_message.toFmt(globalObject, &formatter)}); + return .zero; + } + + const expected_fmt = "\n\nExpected constructor: {s}\n\n" ++ received_line; + var expected_class = ZigString.Empty; + expected_value.getClassName(globalObject, &expected_class); + const fmt = signature ++ expected_fmt; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{expected_class}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, true), .{expected_class}); + return .zero; + } + + pub fn toMatchSnapshot(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalObject); + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(2); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + if (not) { + const signature = comptime getSignature("toMatchSnapshot", "", true); + const fmt = signature ++ "\n\nMatcher error: Snapshot matchers cannot be used with not\n"; + globalObject.throwPretty(fmt, .{}); + } + + var hint_string: ZigString = ZigString.Empty; + var property_matchers: ?JSValue = null; + switch (arguments.len) { + 0 => {}, + 1 => { + if (arguments[0].isString()) { + arguments[0].toZigString(&hint_string, globalObject); + } else if (arguments[0].isObject()) { + property_matchers = arguments[0]; + } + }, + else => { + if (!arguments[0].isObject()) { + const signature = comptime getSignature("toMatchSnapshot", "properties, hint", false); + const fmt = signature ++ "\n\nMatcher error: Expected properties must be an object\n"; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + + property_matchers = arguments[0]; + + if (arguments[1].isString()) { + arguments[1].toZigString(&hint_string, globalObject); + } + }, + } + + var hint = hint_string.toSlice(default_allocator); + defer hint.deinit(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toMatchSnapshot", "properties, hint") orelse return .zero; + + if (!value.isObject() and property_matchers != null) { + const signature = comptime getSignature("toMatchSnapshot", "properties, hint", false); + const fmt = signature ++ "\n\nMatcher error: received values must be an object when the matcher has properties\n"; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + + if (property_matchers) |_prop_matchers| { + var prop_matchers = _prop_matchers; + + if (!value.jestDeepMatch(prop_matchers, globalObject, true)) { + // TODO: print diff with properties from propertyMatchers + const signature = comptime getSignature("toMatchSnapshot", "propertyMatchers", false); + const fmt = signature ++ "\n\nExpected propertyMatchers to match properties from received object" ++ + "\n\nReceived: {any}\n"; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject }; + globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); + return .zero; + } + } + + const result = Jest.runner.?.snapshots.getOrPut(this, value, hint.slice(), globalObject) catch |err| { + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject }; + const test_file_path = Jest.runner.?.files.get(this.scope.file_id).source.path.text; + switch (err) { + error.FailedToOpenSnapshotFile => globalObject.throw("Failed to open snapshot file for test file: {s}", .{test_file_path}), + error.FailedToMakeSnapshotDirectory => globalObject.throw("Failed to make snapshot directory for test file: {s}", .{test_file_path}), + error.FailedToWriteSnapshotFile => globalObject.throw("Failed write to snapshot file: {s}", .{test_file_path}), + error.ParseError => globalObject.throw("Failed to parse snapshot file for: {s}", .{test_file_path}), + else => globalObject.throw("Failed to snapshot value: {any}", .{value.toFmt(globalObject, &formatter)}), + } + return .zero; + }; + + if (result) |saved_value| { + var pretty_value: MutableString = MutableString.init(default_allocator, 0) catch unreachable; + value.jestSnapshotPrettyFormat(&pretty_value, globalObject) catch { + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject }; + globalObject.throw("Failed to pretty format value: {s}", .{value.toFmt(globalObject, &formatter)}); + return .zero; + }; + defer pretty_value.deinit(); + + if (strings.eqlLong(pretty_value.toOwnedSliceLeaky(), saved_value, true)) { + Jest.runner.?.snapshots.passed += 1; + return thisValue; + } + + Jest.runner.?.snapshots.failed += 1; + const signature = comptime getSignature("toMatchSnapshot", "expected", false); + const fmt = signature ++ "\n\n{any}\n"; + const diff_format = DiffFormatter{ + .received_string = pretty_value.toOwnedSliceLeaky(), + .expected_string = saved_value, + .globalObject = globalObject, + }; + + globalObject.throwPretty(fmt, .{diff_format}); + return .zero; + } + + return thisValue; + } + + pub fn toBeEmpty(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalObject, thisValue, "toBeEmpty", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = false; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + + const actual_length = value.getLengthIfPropertyExistsInternal(globalObject); + + if (actual_length == std.math.inf(f64)) { + if (value.jsTypeLoose().isObject()) { + if (value.isIterable(globalObject)) { + var any_properties_in_iterator = false; + value.forEach(globalObject, &any_properties_in_iterator, struct { + pub fn anythingInIterator( + _: *JSC.VM, + _: *JSGlobalObject, + any_: ?*anyopaque, + _: JSValue, + ) callconv(.C) void { + bun.cast(*bool, any_.?).* = true; + } + }.anythingInIterator); + pass = !any_properties_in_iterator; + } else { + var props_iter = JSC.JSPropertyIterator(.{ + .skip_empty_name = false, + + .include_value = true, + }).init(globalObject, value.asObjectRef()); + defer props_iter.deinit(); + pass = props_iter.len == 0; + } + } else { + const signature = comptime getSignature("toBeEmpty", "", false); + const fmt = signature ++ "\n\nExpected value to be a string, object, or iterable" ++ + "\n\nReceived: {any}\n"; + globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); + return .zero; + } + } else if (std.math.isNan(actual_length)) { + globalObject.throw("Received value has non-number length property: {}", .{actual_length}); + return .zero; + } else { + pass = actual_length == 0; + } + + if (not and pass) { + const signature = comptime getSignature("toBeEmpty", "", true); + const fmt = signature ++ "\n\nExpected value not to be a string, object, or iterable" ++ + "\n\nReceived: {any}\n"; + globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); + return .zero; + } + + if (not) pass = !pass; + if (pass) return thisValue; + + if (not) { + const signature = comptime getSignature("toBeEmpty", "", true); + const fmt = signature ++ "\n\nExpected value not to be empty" ++ + "\n\nReceived: {any}\n"; + globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); + return .zero; + } + + const signature = comptime getSignature("toBeEmpty", "", false); + const fmt = signature ++ "\n\nExpected value to be empty" ++ + "\n\nReceived: {any}\n"; + globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); + return .zero; + } + + pub fn toBeNil(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeNil", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.isUndefinedOrNull() != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeNil", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeNil", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeArray(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeArray", "") orelse return .zero; + + if (this.scope.tests.items.len <= this.test_id) { + globalThis.throw("toBeArray() must be called in a test", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.jsType().isArray() != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeArray", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeArray", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeArrayOfSize(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalThis.throwInvalidArguments("toBeArrayOfSize() requires 1 argument", .{}); + return .zero; + } + + const value: JSValue = this.getValue(globalThis, thisValue, "toBeArrayOfSize", "") orelse return .zero; + + if (this.scope.tests.items.len <= this.test_id) { + globalThis.throw("toBeArrayOfSize() must be called in a test", .{}); + return .zero; + } + + const size = arguments[0]; + size.ensureStillAlive(); + + if (!size.isAnyInt()) { + globalThis.throw("toBeArrayOfSize() requires the first argument to be a number", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + var pass = value.jsType().isArray() and @intCast(i32, value.getLength(globalThis)) == size.toInt32(); + + if (not) pass = !pass; + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeArrayOfSize", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeArrayOfSize", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeBoolean(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeBoolean", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.isBoolean() != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeBoolean", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeBoolean", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeTypeOf(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalThis.throwInvalidArguments("toBeTypeOf() requires 1 argument", .{}); + return .zero; + } + + if (this.scope.tests.items.len <= this.test_id) { + globalThis.throw("toBeTypeOf() must be called in a test", .{}); + return .zero; + } + + const value: JSValue = this.getValue(globalThis, thisValue, "toBeTypeOf", "") orelse return .zero; + + const expected = arguments[0]; + expected.ensureStillAlive(); + + const expectedAsStr = expected.toString(globalThis).toSlice(globalThis, default_allocator).slice(); + active_test_expectation_counter.actual += 1; + + if (!expected.isString()) { + globalThis.throwInvalidArguments("toBeTypeOf() requires a string argument", .{}); + return .zero; + } + + if (!std.mem.eql(u8, expectedAsStr, "function") and + !std.mem.eql(u8, expectedAsStr, "object") and + !std.mem.eql(u8, expectedAsStr, "bigint") and + !std.mem.eql(u8, expectedAsStr, "boolean") and + !std.mem.eql(u8, expectedAsStr, "number") and + !std.mem.eql(u8, expectedAsStr, "string") and + !std.mem.eql(u8, expectedAsStr, "symbol") and + !std.mem.eql(u8, expectedAsStr, "undefined")) + { + globalThis.throwInvalidArguments("toBeTypeOf() requires a valid type string argument ('function', 'object', 'bigint', 'boolean', 'number', 'string', 'symbol', 'undefined')", .{}); + return .zero; + } + + const not = this.flags.not; + var pass = false; + var whatIsTheType: []const u8 = ""; + + // Checking for function/class should be done before everything else, or it will fail. + if (value.isCallable(globalThis.vm())) { + whatIsTheType = "function"; + } else if (value.isObject() or value.jsType().isArray() or value.isNull()) { + whatIsTheType = "object"; + } else if (value.isBigInt()) { + whatIsTheType = "bigint"; + } else if (value.isBoolean()) { + whatIsTheType = "boolean"; + } else if (value.isNumber()) { + whatIsTheType = "number"; + } else if (value.jsType().isString()) { + whatIsTheType = "string"; + } else if (value.isSymbol()) { + whatIsTheType = "symbol"; + } else if (value.isUndefined()) { + whatIsTheType = "undefined"; + } else { + globalThis.throw("Internal consistency error: unknown JSValue type", .{}); + return .zero; + } + + pass = std.mem.eql(u8, expectedAsStr, whatIsTheType); + + if (not) pass = !pass; + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + const expected_str = expected.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeTypeOf", "", true) ++ "\n\n" ++ "Expected type: not {any}\n" ++ "Received type: \"{s}\"\nReceived value: {any}\n"; + globalThis.throwPretty(fmt, .{ expected_str, whatIsTheType, received }); + return .zero; + } + + const fmt = comptime getSignature("toBeTypeOf", "", false) ++ "\n\n" ++ "Expected type: {any}\n" ++ "Received type: \"{s}\"\nReceived value: {any}\n"; + globalThis.throwPretty(fmt, .{ expected_str, whatIsTheType, received }); + return .zero; + } + + pub fn toBeTrue(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeTrue", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = (value.isBoolean() and value.toBoolean()) != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeTrue", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeTrue", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeFalse(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeFalse", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = (value.isBoolean() and !value.toBoolean()) != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeFalse", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeFalse", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeNumber(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeNumber", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.isNumber() != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeNumber", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeNumber", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeInteger(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeInteger", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.isAnyInt() != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeInteger", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeInteger", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeFinite(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeFinite", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + var pass = value.isNumber(); + if (pass) { + const num: f64 = value.asNumber(); + pass = std.math.isFinite(num) and !std.math.isNan(num); + } + + const not = this.flags.not; + if (not) pass = !pass; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeFinite", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeFinite", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBePositive(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBePositive", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + var pass = value.isNumber(); + if (pass) { + const num: f64 = value.asNumber(); + pass = @round(num) > 0 and !std.math.isInf(num) and !std.math.isNan(num); + } + + const not = this.flags.not; + if (not) pass = !pass; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBePositive", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBePositive", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeNegative(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeNegative", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + var pass = value.isNumber(); + if (pass) { + const num: f64 = value.asNumber(); + pass = @round(num) < 0 and !std.math.isInf(num) and !std.math.isNan(num); + } + + const not = this.flags.not; + if (not) pass = !pass; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeNegative", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeNegative", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeWithin(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(2); + const arguments = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalThis.throwInvalidArguments("toBeWithin() requires 2 arguments", .{}); + return .zero; + } + + const value: JSValue = this.getValue(globalThis, thisValue, "toBeWithin", "start, end") orelse return .zero; + + const startValue = arguments[0]; + startValue.ensureStillAlive(); + + if (!startValue.isNumber()) { + globalThis.throw("toBeWithin() requires the first argument to be a number", .{}); + return .zero; + } + + const endValue = arguments[1]; + endValue.ensureStillAlive(); + + if (!endValue.isNumber()) { + globalThis.throw("toBeWithin() requires the second argument to be a number", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + var pass = value.isNumber(); + if (pass) { + const num = value.asNumber(); + pass = num >= startValue.asNumber() and num < endValue.asNumber(); + } + + const not = this.flags.not; + if (not) pass = !pass; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const start_fmt = startValue.toFmt(globalThis, &formatter); + const end_fmt = endValue.toFmt(globalThis, &formatter); + const received_fmt = value.toFmt(globalThis, &formatter); + + if (not) { + const expected_line = "Expected: not between {any} (inclusive) and {any} (exclusive)\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeWithin", "start, end", true) ++ "\n\n" ++ expected_line ++ received_line; + globalThis.throwPretty(fmt, .{ start_fmt, end_fmt, received_fmt }); + return .zero; + } + + const expected_line = "Expected: between {any} (inclusive) and {any} (exclusive)\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toBeWithin", "start, end", false) ++ "\n\n" ++ expected_line ++ received_line; + globalThis.throwPretty(fmt, .{ start_fmt, end_fmt, received_fmt }); + return .zero; + } + + pub fn toBeSymbol(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeSymbol", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.isSymbol() != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeSymbol", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeSymbol", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeFunction(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeFunction", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.isCallable(globalThis.vm()) != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeFunction", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeFunction", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeDate(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeDate", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.isDate() != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeDate", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeDate", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toBeString(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const value: JSValue = this.getValue(globalThis, thisValue, "toBeString", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + const pass = value.isString() != not; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const received = value.toFmt(globalThis, &formatter); + + if (not) { + const fmt = comptime getSignature("toBeString", "", true) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + const fmt = comptime getSignature("toBeString", "", false) ++ "\n\n" ++ "Received: {any}\n"; + globalThis.throwPretty(fmt, .{received}); + return .zero; + } + + pub fn toInclude(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const arguments_ = callFrame.arguments(1); + const arguments = arguments_.ptr[0..arguments_.len]; + + if (arguments.len < 1) { + globalThis.throwInvalidArguments("toInclude() requires 1 argument", .{}); + return .zero; + } + + const expected = arguments[0]; + expected.ensureStillAlive(); + + if (!expected.isString()) { + globalThis.throw("toInclude() requires the first argument to be a string", .{}); + return .zero; + } + + const value: JSValue = this.getValue(globalThis, thisValue, "toInclude", "") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + var pass = value.isString(); + if (pass) { + const value_string = value.toString(globalThis).toSlice(globalThis, default_allocator).slice(); + const expected_string = expected.toString(globalThis).toSlice(globalThis, default_allocator).slice(); + pass = strings.contains(value_string, expected_string) or expected_string.len == 0; + } + + const not = this.flags.not; + if (not) pass = !pass; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const value_fmt = value.toFmt(globalThis, &formatter); + const expected_fmt = expected.toFmt(globalThis, &formatter); + + if (not) { + const expected_line = "Expected to not include: {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toInclude", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected to include: {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toInclude", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + pub fn toStartWith(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const arguments_ = callFrame.arguments(1); + const arguments = arguments_.ptr[0..arguments_.len]; + + if (arguments.len < 1) { + globalThis.throwInvalidArguments("toStartWith() requires 1 argument", .{}); + return .zero; + } + + const expected = arguments[0]; + expected.ensureStillAlive(); + + if (!expected.isString()) { + globalThis.throw("toStartWith() requires the first argument to be a string", .{}); + return .zero; + } + + const value: JSValue = this.getValue(globalThis, thisValue, "toStartWith", "expected") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + var pass = value.isString(); + if (pass) { + const value_string = value.toString(globalThis).toSlice(globalThis, default_allocator).slice(); + const expected_string = expected.toString(globalThis).toSlice(globalThis, default_allocator).slice(); + pass = strings.startsWith(value_string, expected_string) or expected_string.len == 0; + } + + const not = this.flags.not; + if (not) pass = !pass; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const value_fmt = value.toFmt(globalThis, &formatter); + const expected_fmt = expected.toFmt(globalThis, &formatter); + + if (not) { + const expected_line = "Expected to not start with: {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toStartWith", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected to start with: {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toStartWith", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + pub fn toEndWith(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalThis); + + const thisValue = callFrame.this(); + const arguments_ = callFrame.arguments(1); + const arguments = arguments_.ptr[0..arguments_.len]; + + if (arguments.len < 1) { + globalThis.throwInvalidArguments("toEndWith() requires 1 argument", .{}); + return .zero; + } + + const expected = arguments[0]; + expected.ensureStillAlive(); + + if (!expected.isString()) { + globalThis.throw("toEndWith() requires the first argument to be a string", .{}); + return .zero; + } + + const value: JSValue = this.getValue(globalThis, thisValue, "toEndWith", "expected") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + var pass = value.isString(); + if (pass) { + const value_string = value.toString(globalThis).toSlice(globalThis, default_allocator).slice(); + const expected_string = expected.toString(globalThis).toSlice(globalThis, default_allocator).slice(); + pass = strings.endsWith(value_string, expected_string) or expected_string.len == 0; + } + + const not = this.flags.not; + if (not) pass = !pass; + + if (pass) return thisValue; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; + const value_fmt = value.toFmt(globalThis, &formatter); + const expected_fmt = expected.toFmt(globalThis, &formatter); + + if (not) { + const expected_line = "Expected to not end with: {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toEndWith", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected to end with: {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toEndWith", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + pub fn toBeInstanceOf(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toBeInstanceOf() requires 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + + const expected_value = arguments[0]; + if (!expected_value.isConstructor()) { + globalObject.throw("Expected value must be a function: {any}", .{expected_value.toFmt(globalObject, &formatter)}); + return .zero; + } + expected_value.ensureStillAlive(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toBeInstanceOf", "expected") orelse return .zero; + + const not = this.flags.not; + var pass = value.isInstanceOf(globalObject, expected_value); + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + const expected_fmt = expected_value.toFmt(globalObject, &formatter); + const value_fmt = value.toFmt(globalObject, &formatter); + if (not) { + const expected_line = "Expected constructor: not {any}\n"; + const received_line = "Received value: {any}\n"; + const fmt = comptime getSignature("toBeInstanceOf", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); + return .zero; + } + + globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected constructor: {any}\n"; + const received_line = "Received value: {any}\n"; + const fmt = comptime getSignature("toBeInstanceOf", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + globalObject.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + pub fn toMatch(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + JSC.markBinding(@src()); + + defer this.postMatch(globalObject); + + const thisValue = callFrame.this(); + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len < 1) { + globalObject.throwInvalidArguments("toMatch() requires 1 argument", .{}); + return .zero; + } + + active_test_expectation_counter.actual += 1; + + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + + const expected_value = arguments[0]; + if (!expected_value.isString() and !expected_value.isRegExp()) { + globalObject.throw("Expected value must be a string or regular expression: {any}", .{expected_value.toFmt(globalObject, &formatter)}); + return .zero; + } + expected_value.ensureStillAlive(); + + const value: JSValue = this.getValue(globalObject, thisValue, "toMatch", "expected") orelse return .zero; + + if (!value.isString()) { + globalObject.throw("Received value must be a string: {any}", .{value.toFmt(globalObject, &formatter)}); + return .zero; + } + + const not = this.flags.not; + var pass: bool = brk: { + if (expected_value.isString()) { + break :brk value.stringIncludes(globalObject, expected_value); + } else if (expected_value.isRegExp()) { + break :brk expected_value.toMatch(globalObject, value); + } + unreachable; + }; + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + const expected_fmt = expected_value.toFmt(globalObject, &formatter); + const value_fmt = value.toFmt(globalObject, &formatter); + + if (not) { + const expected_line = "Expected substring or pattern: not {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toMatch", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; + globalObject.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + const expected_line = "Expected substring or pattern: {any}\n"; + const received_line = "Received: {any}\n"; + const fmt = comptime getSignature("toMatch", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; + globalObject.throwPretty(fmt, .{ expected_fmt, value_fmt }); + return .zero; + } + + pub fn toHaveBeenCalled(this: *Expect, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { + JSC.markBinding(@src()); + const thisValue = callframe.this(); + defer this.postMatch(globalObject); + + const value: JSValue = this.getValue(globalObject, thisValue, "toHaveBeenCalled", "") orelse return .zero; + + const calls = JSMockFunction__getCalls(value); + active_test_expectation_counter.actual += 1; + + if (calls == .zero or !calls.jsType().isArray()) { + globalObject.throw("Expected value must be a mock function: {}", .{value}); + return .zero; + } + + var pass = calls.getLength(globalObject) > 0; + + const not = this.flags.not; + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + if (not) { + const signature = comptime getSignature("toHaveBeenCalled", "", true); + const fmt = signature ++ "\n\nExpected: not {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{calls.toFmt(globalObject, &formatter)}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{calls.toFmt(globalObject, &formatter)}); + return .zero; + } else { + const signature = comptime getSignature("toHaveBeenCalled", "", true); + const fmt = signature ++ "\n\nExpected {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{calls.toFmt(globalObject, &formatter)}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{calls.toFmt(globalObject, &formatter)}); + return .zero; + } + + unreachable; + } + pub fn toHaveBeenCalledTimes(this: *Expect, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { + JSC.markBinding(@src()); + + const thisValue = callframe.this(); + const arguments_ = callframe.arguments(1); + const arguments: []const JSValue = arguments_.ptr[0..arguments_.len]; + defer this.postMatch(globalObject); + const value: JSValue = this.getValue(globalObject, thisValue, "toHaveBeenCalledTimes", "expected") orelse return .zero; + + active_test_expectation_counter.actual += 1; + + const calls = JSMockFunction__getCalls(value); + + if (calls == .zero or !calls.jsType().isArray()) { + globalObject.throw("Expected value must be a mock function: {}", .{value}); + return .zero; + } + + if (arguments.len < 1 or !arguments[0].isAnyInt()) { + globalObject.throwInvalidArguments("toHaveBeenCalledTimes() requires 1 integer argument", .{}); + return .zero; + } + + const times = arguments[0].coerce(i32, globalObject); + + var pass = @intCast(i32, calls.getLength(globalObject)) == times; + + const not = this.flags.not; + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; + if (not) { + const signature = comptime getSignature("toHaveBeenCalledTimes", "expected", true); + const fmt = signature ++ "\n\nExpected: not {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{calls.toFmt(globalObject, &formatter)}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{calls.toFmt(globalObject, &formatter)}); + return .zero; + } else { + const signature = comptime getSignature("toHaveBeenCalledTimes", "expected", true); + const fmt = signature ++ "\n\nExpected {any}\n"; + if (Output.enable_ansi_colors) { + globalObject.throw(Output.prettyFmt(fmt, true), .{calls.toFmt(globalObject, &formatter)}); + return .zero; + } + globalObject.throw(Output.prettyFmt(fmt, false), .{calls.toFmt(globalObject, &formatter)}); + return .zero; + } + + unreachable; + } + + pub fn toMatchObject(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + JSC.markBinding(@src()); + + defer this.postMatch(globalObject); + const thisValue = callFrame.this(); + const args = callFrame.arguments(1).slice(); + + active_test_expectation_counter.actual += 1; + + const not = this.flags.not; + + const received_object: JSValue = this.getValue(globalObject, thisValue, "toMatchObject", "expected") orelse return .zero; + + if (!received_object.isObject()) { + const matcher_error = "\n\nMatcher error: received value must be a non-null object\n"; + if (not) { + const fmt = comptime getSignature("toMatchObject", "expected", true) ++ matcher_error; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + + const fmt = comptime getSignature("toMatchObject", "expected", false) ++ matcher_error; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + + if (args.len < 1 or !args[0].isObject()) { + const matcher_error = "\n\nMatcher error: expected value must be a non-null object\n"; + if (not) { + const fmt = comptime getSignature("toMatchObject", "", true) ++ matcher_error; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + const fmt = comptime getSignature("toMatchObject", "", false) ++ matcher_error; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + + const property_matchers = args[0]; + + var pass = received_object.jestDeepMatch(property_matchers, globalObject, true); + + if (not) pass = !pass; + if (pass) return thisValue; + + // handle failure + const diff_formatter = DiffFormatter{ + .received = received_object, + .expected = property_matchers, + .globalObject = globalObject, + .not = not, + }; + + if (not) { + const signature = comptime getSignature("toMatchObject", "expected", true); + const fmt = signature ++ "\n\n{any}\n"; + globalObject.throwPretty(fmt, .{diff_formatter}); + return .zero; + } + + const signature = comptime getSignature("toMatchObject", "expected", false); + const fmt = signature ++ "\n\n{any}\n"; + globalObject.throwPretty(fmt, .{diff_formatter}); + return .zero; + } + + pub const toHaveBeenCalledWith = notImplementedJSCFn; + pub const toHaveBeenLastCalledWith = notImplementedJSCFn; + pub const toHaveBeenNthCalledWith = notImplementedJSCFn; + pub const toHaveReturnedTimes = notImplementedJSCFn; + pub const toHaveReturnedWith = notImplementedJSCFn; + pub const toHaveLastReturnedWith = notImplementedJSCFn; + pub const toHaveNthReturnedWith = notImplementedJSCFn; + pub const toContainEqual = notImplementedJSCFn; + pub const toMatchInlineSnapshot = notImplementedJSCFn; + pub const toThrowErrorMatchingSnapshot = notImplementedJSCFn; + pub const toThrowErrorMatchingInlineSnapshot = notImplementedJSCFn; + + pub const getStaticNot = notImplementedStaticProp; + pub const getStaticResolves = notImplementedStaticProp; + pub const getStaticRejects = notImplementedStaticProp; + + pub fn any(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + return ExpectAny.call(globalObject, callFrame); + } + + pub fn anything(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + return ExpectAnything.call(globalObject, callFrame); + } + + pub fn stringContaining(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + return ExpectStringContaining.call(globalObject, callFrame); + } + + pub fn stringMatching(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + return ExpectStringMatching.call(globalObject, callFrame); + } + + pub const extend = notImplementedStaticFn; + pub const arrayContaining = notImplementedStaticFn; + pub const assertions = notImplementedStaticFn; + pub const hasAssertions = notImplementedStaticFn; + pub const objectContaining = notImplementedStaticFn; + pub const addSnapshotSerializer = notImplementedStaticFn; + + pub fn notImplementedJSCFn(_: *Expect, globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + globalObject.throw("Not implemented", .{}); + return .zero; + } + + pub fn notImplementedStaticFn(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + globalObject.throw("Not implemented", .{}); + return .zero; + } + + pub fn notImplementedJSCProp(_: *Expect, _: JSC.JSValue, globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { + globalObject.throw("Not implemented", .{}); + return .zero; + } + + pub fn notImplementedStaticProp(globalObject: *JSC.JSGlobalObject, _: JSC.JSValue, _: JSC.JSValue) callconv(.C) JSC.JSValue { + globalObject.throw("Not implemented", .{}); + return .zero; + } + + pub fn postMatch(_: *Expect, globalObject: *JSC.JSGlobalObject) void { + var vm = globalObject.bunVM(); + vm.autoGarbageCollect(); + } +}; + +pub const ExpectAnything = struct { + pub usingnamespace JSC.Codegen.JSExpectAnything; + + pub fn finalize( + this: *ExpectAnything, + ) callconv(.C) void { + VirtualMachine.get().allocator.destroy(this); + } + + pub fn call(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSValue { + const anything = globalObject.bunVM().allocator.create(ExpectAnything) catch unreachable; + if (Jest.runner.?.pending_test == null) { + const err = globalObject.createErrorInstance("expect.anything() must be called in a test", .{}); + err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); + globalObject.throwValue(err); + return .zero; + } + + const anything_js_value = anything.toJS(globalObject); + anything_js_value.ensureStillAlive(); + + var vm = globalObject.bunVM(); + vm.autoGarbageCollect(); + + return anything_js_value; + } +}; + +pub const ExpectStringMatching = struct { + pub usingnamespace JSC.Codegen.JSExpectStringMatching; + + pub fn finalize( + this: *ExpectStringMatching, + ) callconv(.C) void { + VirtualMachine.get().allocator.destroy(this); + } + + pub fn call(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + const args = callFrame.arguments(1).slice(); + + if (args.len == 0 or (!args[0].isString() and !args[0].isRegExp())) { + const fmt = "expect.stringContaining(string)\n\nExpected a string or regular expression\n"; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + + const test_value = args[0]; + const string_matching = globalObject.bunVM().allocator.create(ExpectStringMatching) catch unreachable; + + if (Jest.runner.?.pending_test == null) { + const err = globalObject.createErrorInstance("expect.stringContaining() must be called in a test", .{}); + err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); + globalObject.throwValue(err); + return .zero; + } + + const string_matching_js_value = string_matching.toJS(globalObject); + ExpectStringMatching.testValueSetCached(string_matching_js_value, globalObject, test_value); + + var vm = globalObject.bunVM(); + vm.autoGarbageCollect(); + return string_matching_js_value; + } +}; + +pub const ExpectStringContaining = struct { + pub usingnamespace JSC.Codegen.JSExpectStringContaining; + + pub fn finalize( + this: *ExpectStringContaining, + ) callconv(.C) void { + VirtualMachine.get().allocator.destroy(this); + } + + pub fn call(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + const args = callFrame.arguments(1).slice(); + + if (args.len == 0 or !args[0].isString()) { + const fmt = "expect.stringContaining(string)\n\nExpected a string\n"; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + + const string_value = args[0]; + + const string_containing = globalObject.bunVM().allocator.create(ExpectStringContaining) catch unreachable; + + if (Jest.runner.?.pending_test == null) { + const err = globalObject.createErrorInstance("expect.stringContaining() must be called in a test", .{}); + err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); + globalObject.throwValue(err); + return .zero; + } + + const string_containing_js_value = string_containing.toJS(globalObject); + ExpectStringContaining.stringValueSetCached(string_containing_js_value, globalObject, string_value); + + var vm = globalObject.bunVM(); + vm.autoGarbageCollect(); + return string_containing_js_value; + } +}; + +pub const ExpectAny = struct { + pub usingnamespace JSC.Codegen.JSExpectAny; + + pub fn finalize( + this: *ExpectAny, + ) callconv(.C) void { + VirtualMachine.get().allocator.destroy(this); + } + + pub fn call(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + const _arguments = callFrame.arguments(1); + const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; + + if (arguments.len == 0) { + globalObject.throw("any() expects to be passed a constructor function.", .{}); + return .zero; + } + + const constructor = arguments[0]; + constructor.ensureStillAlive(); + if (!constructor.isConstructor()) { + const fmt = "expect.any(constructor)\n\nExpected a constructor\n"; + globalObject.throwPretty(fmt, .{}); + return .zero; + } + + var any = globalObject.bunVM().allocator.create(ExpectAny) catch unreachable; + + if (Jest.runner.?.pending_test == null) { + const err = globalObject.createErrorInstance("expect.any() must be called in a test", .{}); + err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); + globalObject.throwValue(err); + return .zero; + } + + any.* = .{}; + const any_js_value = any.toJS(globalObject); + any_js_value.ensureStillAlive(); + ExpectAny.constructorValueSetCached(any_js_value, globalObject, constructor); + any_js_value.ensureStillAlive(); + + var vm = globalObject.bunVM(); + vm.autoGarbageCollect(); + + return any_js_value; + } +}; + +/// JSValue.zero is used to indicate it was not a JSMockFunction +/// If there were no calls, it returns an empty JSArray* +extern fn JSMockFunction__getCalls(JSValue) JSValue; + +/// JSValue.zero is used to indicate it was not a JSMockFunction +/// If there were no calls, it returns an empty JSArray* +extern fn JSMockFunction__getReturns(JSValue) JSValue; diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 2dc4ae1c4..a1a4f2af8 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -8,7 +8,12 @@ const MimeType = @import("../../http.zig").MimeType; const ZigURL = @import("../../url.zig").URL; const HTTPClient = @import("root").bun.HTTP; const NetworkThread = HTTPClient.NetworkThread; -const Environment = @import("../../env.zig"); +const Environment = bun.Environment; + +const Snapshots = @import("./snapshot.zig").Snapshots; +const expect = @import("./expect.zig"); +const Counter = expect.Counter; +const Expect = expect.Expect; const DiffFormatter = @import("./diff_format.zig").DiffFormatter; @@ -28,8 +33,6 @@ const default_allocator = @import("root").bun.default_allocator; const FeatureFlags = @import("root").bun.FeatureFlags; const ArrayBuffer = @import("../base.zig").ArrayBuffer; const Properties = @import("../base.zig").Properties; -const d = @import("../base.zig").d; -const castObj = @import("../base.zig").castObj; const getAllocator = @import("../base.zig").getAllocator; const ZigString = JSC.ZigString; @@ -43,12 +46,10 @@ const JSObject = JSC.JSObject; const CallFrame = JSC.CallFrame; const VirtualMachine = JSC.VirtualMachine; -const Task = @import("../javascript.zig").Task; - -const Fs = @import("../../fs.zig"); +const Fs = bun.fs; const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false; -const ArrayIdentityContext = @import("../../identity_context.zig").ArrayIdentityContext; +const ArrayIdentityContext = bun.ArrayIdentityContext; pub var test_elapsed_timer: ?*std.time.Timer = null; pub const Tag = enum(u3) { @@ -252,4041 +253,256 @@ pub const TestRunner = struct { pass, fail, skip, - todo, - fail_because_todo_passed, - }; - }; -}; - -pub const Snapshots = struct { - const file_header = "// Bun Snapshot v1, https://goo.gl/fbAQLP\n"; - pub const ValuesHashMap = std.HashMap(usize, string, bun.IdentityContext(usize), std.hash_map.default_max_load_percentage); - - allocator: std.mem.Allocator, - update_snapshots: bool, - total: usize = 0, - added: usize = 0, - passed: usize = 0, - failed: usize = 0, - - file_buf: *std.ArrayList(u8), - values: *ValuesHashMap, - counts: *bun.StringHashMap(usize), - _current_file: ?File = null, - snapshot_dir_path: ?string = null, - - const File = struct { - id: TestRunner.File.ID, - file: std.fs.File, - }; - - pub fn getOrPut(this: *Snapshots, expect: *Expect, value: JSValue, hint: string, globalObject: *JSC.JSGlobalObject) !?string { - switch (try this.getSnapshotFile(expect.scope.file_id)) { - .result => {}, - .err => |err| { - return switch (err.syscall) { - .mkdir => error.FailedToMakeSnapshotDirectory, - .open => error.FailedToOpenSnapshotFile, - else => error.SnapshotFailed, - }; - }, - } - - const snapshot_name = try expect.getSnapshotName(this.allocator, hint); - this.total += 1; - - var count_entry = try this.counts.getOrPut(snapshot_name); - const counter = brk: { - if (count_entry.found_existing) { - this.allocator.free(snapshot_name); - count_entry.value_ptr.* += 1; - break :brk count_entry.value_ptr.*; - } - count_entry.value_ptr.* = 1; - break :brk count_entry.value_ptr.*; - }; - - const name = count_entry.key_ptr.*; - - var counter_string_buf = [_]u8{0} ** 32; - var counter_string = try std.fmt.bufPrint(&counter_string_buf, "{d}", .{counter}); - - var name_with_counter = try this.allocator.alloc(u8, name.len + 1 + counter_string.len); - defer this.allocator.free(name_with_counter); - bun.copy(u8, name_with_counter[0..name.len], name); - name_with_counter[name.len] = ' '; - bun.copy(u8, name_with_counter[name.len + 1 ..], counter_string); - - const name_hash = bun.hash(name_with_counter); - if (this.values.get(name_hash)) |expected| { - return expected; - } - - // doesn't exist. append to file bytes and add to hashmap. - var pretty_value = try MutableString.init(this.allocator, 0); - try value.jestSnapshotPrettyFormat(&pretty_value, globalObject); - - const serialized_length = "\nexports[`".len + name_with_counter.len + "`] = `".len + pretty_value.list.items.len + "`;\n".len; - try this.file_buf.ensureUnusedCapacity(serialized_length); - this.file_buf.appendSliceAssumeCapacity("\nexports[`"); - this.file_buf.appendSliceAssumeCapacity(name_with_counter); - this.file_buf.appendSliceAssumeCapacity("`] = `"); - this.file_buf.appendSliceAssumeCapacity(pretty_value.list.items); - this.file_buf.appendSliceAssumeCapacity("`;\n"); - - this.added += 1; - try this.values.put(name_hash, pretty_value.toOwnedSlice()); - return null; - } - - pub fn parseFile(this: *Snapshots) !void { - if (this.file_buf.items.len == 0) return; - - const vm = VirtualMachine.get(); - var opts = js_parser.Parser.Options.init(vm.bundler.options.jsx, .js); - var temp_log = logger.Log.init(this.allocator); - - const test_file = Jest.runner.?.files.get(this._current_file.?.id); - const test_filename = test_file.source.path.name.filename; - const dir_path = test_file.source.path.name.dirWithTrailingSlash(); - - var snapshot_file_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; - var remain: []u8 = snapshot_file_path_buf[0..bun.MAX_PATH_BYTES]; - bun.copy(u8, remain, dir_path); - remain = remain[dir_path.len..]; - bun.copy(u8, remain, "__snapshots__/"); - remain = remain["__snapshots__/".len..]; - bun.copy(u8, remain, test_filename); - remain = remain[test_filename.len..]; - bun.copy(u8, remain, ".snap"); - remain = remain[".snap".len..]; - remain[0] = 0; - const snapshot_file_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0]; - - const source = logger.Source.initPathString(snapshot_file_path, this.file_buf.items); - - var parser = try js_parser.Parser.init( - opts, - &temp_log, - &source, - vm.bundler.options.define, - this.allocator, - ); - - var parse_result = try parser.parse(); - var ast = if (parse_result == .ast) parse_result.ast else return error.ParseError; - defer ast.deinit(); - - if (ast.exports_ref.isNull()) return; - const exports_ref = ast.exports_ref; - - // TODO: when common js transform changes, keep this updated or add flag to support this version - - const export_default = brk: { - for (ast.parts.slice()) |part| { - for (part.stmts) |stmt| { - if (stmt.data == .s_export_default and stmt.data.s_export_default.value == .expr) { - break :brk stmt.data.s_export_default.value.expr; - } - } - } - - return; - }; - - if (export_default.data == .e_call) { - const function_call = export_default.data.e_call; - if (function_call.args.len == 2 and function_call.args.ptr[0].data == .e_function) { - const arg_function_stmts = function_call.args.ptr[0].data.e_function.func.body.stmts; - for (arg_function_stmts) |stmt| { - switch (stmt.data) { - .s_expr => |expr| { - if (expr.value.data == .e_binary and expr.value.data.e_binary.op == .bin_assign) { - const left = expr.value.data.e_binary.left; - if (left.data == .e_index and left.data.e_index.index.data == .e_string and left.data.e_index.target.data == .e_identifier) { - const target: js_ast.E.Identifier = left.data.e_index.target.data.e_identifier; - var index: *js_ast.E.String = left.data.e_index.index.data.e_string; - if (target.ref.eql(exports_ref) and expr.value.data.e_binary.right.data == .e_string) { - const key = index.slice(this.allocator); - var value_string = expr.value.data.e_binary.right.data.e_string; - const value = value_string.slice(this.allocator); - defer { - if (!index.isUTF8()) this.allocator.free(key); - if (!value_string.isUTF8()) this.allocator.free(value); - } - const value_clone = try this.allocator.alloc(u8, value.len); - bun.copy(u8, value_clone, value); - const name_hash = bun.hash(key); - try this.values.put(name_hash, value_clone); - } - } - } - }, - else => {}, - } - } - } - } - } - - pub fn writeSnapshotFile(this: *Snapshots) !void { - if (this._current_file) |_file| { - var file = _file; - file.file.writeAll(this.file_buf.items) catch { - return error.FailedToWriteSnapshotFile; - }; - file.file.close(); - this.file_buf.clearAndFree(); - - var value_itr = this.values.valueIterator(); - while (value_itr.next()) |value| { - this.allocator.free(value.*); - } - this.values.clearAndFree(); - - var count_key_itr = this.counts.keyIterator(); - while (count_key_itr.next()) |key| { - this.allocator.free(key.*); - } - this.counts.clearAndFree(); - } - } - - fn getSnapshotFile(this: *Snapshots, file_id: TestRunner.File.ID) !JSC.Maybe(void) { - if (this._current_file == null or this._current_file.?.id != file_id) { - try this.writeSnapshotFile(); - - const test_file = Jest.runner.?.files.get(file_id); - const test_filename = test_file.source.path.name.filename; - const dir_path = test_file.source.path.name.dirWithTrailingSlash(); - - var snapshot_file_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; - var remain: []u8 = snapshot_file_path_buf[0..bun.MAX_PATH_BYTES]; - bun.copy(u8, remain, dir_path); - remain = remain[dir_path.len..]; - bun.copy(u8, remain, "__snapshots__/"); - remain = remain["__snapshots__/".len..]; - - if (this.snapshot_dir_path == null or !strings.eqlLong(dir_path, this.snapshot_dir_path.?, true)) { - remain[0] = 0; - const snapshot_dir_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0]; - switch (JSC.Node.Syscall.mkdir(snapshot_dir_path, 0o777)) { - .result => this.snapshot_dir_path = dir_path, - .err => |err| { - switch (err.getErrno()) { - std.os.E.EXIST => this.snapshot_dir_path = dir_path, - else => return JSC.Maybe(void){ - .err = err, - }, - } - }, - } - } - - bun.copy(u8, remain, test_filename); - remain = remain[test_filename.len..]; - bun.copy(u8, remain, ".snap"); - remain = remain[".snap".len..]; - remain[0] = 0; - const snapshot_file_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0]; - - var flags: JSC.Node.Mode = std.os.O.CREAT | std.os.O.RDWR; - if (this.update_snapshots) flags |= std.os.O.TRUNC; - const fd = switch (JSC.Node.Syscall.open(snapshot_file_path, flags, 0o644)) { - .result => |_fd| _fd, - .err => |err| return JSC.Maybe(void){ - .err = err, - }, - }; - - var file: File = .{ - .id = file_id, - .file = .{ .handle = fd }, - }; - - if (this.update_snapshots) { - try this.file_buf.appendSlice(file_header); - } else { - const length = try file.file.getEndPos(); - if (length == 0) { - try this.file_buf.appendSlice(file_header); - } else { - const buf = try this.allocator.alloc(u8, length); - _ = try file.file.preadAll(buf, 0); - try this.file_buf.appendSlice(buf); - this.allocator.free(buf); - } - } - - this._current_file = file; - try this.parseFile(); - } - - return JSC.Maybe(void).success; - } -}; - -pub const Jest = struct { - pub var runner: ?*TestRunner = null; - - fn globalHook(comptime name: string) JSC.JSHostFunctionType { - return struct { - pub fn appendGlobalFunctionCallback( - globalThis: *JSC.JSGlobalObject, - callframe: *JSC.CallFrame, - ) callconv(.C) JSValue { - const arguments = callframe.arguments(2); - if (arguments.len < 1) { - globalThis.throwNotEnoughArguments("callback", 1, arguments.len); - return .zero; - } - - const function = arguments.ptr[0]; - if (function.isEmptyOrUndefinedOrNull() or !function.isCallable(globalThis.vm())) { - globalThis.throwInvalidArgumentType(name, "callback", "function"); - return .zero; - } - - if (function.getLength(globalThis) > 0) { - globalThis.throw("done() callback is not implemented in global hooks yet. Please make your function take no arguments", .{}); - return .zero; - } - - function.protect(); - @field(Jest.runner.?.global_callbacks, name).append( - bun.default_allocator, - function, - ) catch unreachable; - return JSC.JSValue.jsUndefined(); - } - }.appendGlobalFunctionCallback; - } - - pub fn Bun__Jest__createTestPreloadObject(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { - JSC.markBinding(@src()); - - var global_hooks_object = JSC.JSValue.createEmptyObject(globalObject, 8); - global_hooks_object.ensureStillAlive(); - - const notSupportedHereFn = struct { - pub fn notSupportedHere( - globalThis: *JSC.JSGlobalObject, - _: *JSC.CallFrame, - ) callconv(.C) JSValue { - globalThis.throw("This function can only be used in a test.", .{}); - return .zero; - } - }.notSupportedHere; - const notSupportedHere = JSC.NewFunction(globalObject, null, 0, notSupportedHereFn, false); - notSupportedHere.ensureStillAlive(); - - inline for (.{ - "expect", - "describe", - "it", - "test", - }) |name| { - global_hooks_object.put(globalObject, ZigString.static(name), notSupportedHere); - } - - inline for (.{ "beforeAll", "beforeEach", "afterAll", "afterEach" }) |name| { - const function = JSC.NewFunction(globalObject, null, 1, globalHook(name), false); - function.ensureStillAlive(); - global_hooks_object.put(globalObject, ZigString.static(name), function); - } - return global_hooks_object; - } - - pub fn Bun__Jest__createTestModuleObject(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { - JSC.markBinding(@src()); - - const module = JSC.JSValue.createEmptyObject(globalObject, 11); - - const test_fn = JSC.NewFunction(globalObject, ZigString.static("test"), 2, TestScope.call, false); - module.put( - globalObject, - ZigString.static("test"), - test_fn, - ); - test_fn.put( - globalObject, - ZigString.static("only"), - JSC.NewFunction(globalObject, ZigString.static("only"), 2, TestScope.only, false), - ); - test_fn.put( - globalObject, - ZigString.static("skip"), - JSC.NewFunction(globalObject, ZigString.static("skip"), 2, TestScope.skip, false), - ); - test_fn.put( - globalObject, - ZigString.static("todo"), - JSC.NewFunction(globalObject, ZigString.static("todo"), 2, TestScope.todo, false), - ); - test_fn.put( - globalObject, - ZigString.static("if"), - JSC.NewFunction(globalObject, ZigString.static("if"), 2, TestScope.callIf, false), - ); - test_fn.put( - globalObject, - ZigString.static("skipIf"), - JSC.NewFunction(globalObject, ZigString.static("skipIf"), 2, TestScope.skipIf, false), - ); - - module.put( - globalObject, - ZigString.static("it"), - test_fn, - ); - const describe = JSC.NewFunction(globalObject, ZigString.static("describe"), 2, DescribeScope.call, false); - describe.put( - globalObject, - ZigString.static("only"), - JSC.NewFunction(globalObject, ZigString.static("only"), 2, DescribeScope.only, false), - ); - describe.put( - globalObject, - ZigString.static("skip"), - JSC.NewFunction(globalObject, ZigString.static("skip"), 2, DescribeScope.skip, false), - ); - describe.put( - globalObject, - ZigString.static("todo"), - JSC.NewFunction(globalObject, ZigString.static("todo"), 2, DescribeScope.todo, false), - ); - describe.put( - globalObject, - ZigString.static("if"), - JSC.NewFunction(globalObject, ZigString.static("if"), 2, DescribeScope.callIf, false), - ); - describe.put( - globalObject, - ZigString.static("skipIf"), - JSC.NewFunction(globalObject, ZigString.static("skipIf"), 2, DescribeScope.skipIf, false), - ); - - module.put( - globalObject, - ZigString.static("describe"), - describe, - ); - - module.put( - globalObject, - ZigString.static("beforeAll"), - JSC.NewRuntimeFunction(globalObject, ZigString.static("beforeAll"), 1, DescribeScope.beforeAll, false), - ); - module.put( - globalObject, - ZigString.static("beforeEach"), - JSC.NewRuntimeFunction(globalObject, ZigString.static("beforeEach"), 1, DescribeScope.beforeEach, false), - ); - module.put( - globalObject, - ZigString.static("afterAll"), - JSC.NewRuntimeFunction(globalObject, ZigString.static("afterAll"), 1, DescribeScope.afterAll, false), - ); - module.put( - globalObject, - ZigString.static("afterEach"), - JSC.NewRuntimeFunction(globalObject, ZigString.static("afterEach"), 1, DescribeScope.afterEach, false), - ); - module.put( - globalObject, - ZigString.static("expect"), - Expect.getConstructor(globalObject), - ); - - const mock_fn = JSMockFunction__createObject(globalObject); - const spyOn = JSC.NewFunction(globalObject, ZigString.static("spyOn"), 2, JSMock__spyOn, false); - const restoreAllMocks = JSC.NewFunction(globalObject, ZigString.static("restoreAllMocks"), 2, jsFunctionResetSpies, false); - module.put(globalObject, ZigString.static("mock"), mock_fn); - - const jest = JSValue.createEmptyObject(globalObject, 3); - jest.put(globalObject, ZigString.static("fn"), mock_fn); - jest.put(globalObject, ZigString.static("spyOn"), spyOn); - jest.put(globalObject, ZigString.static("restoreAllMocks"), restoreAllMocks); - module.put(globalObject, ZigString.static("jest"), jest); - module.put(globalObject, ZigString.static("spyOn"), spyOn); - - const vi = JSValue.createEmptyObject(globalObject, 1); - vi.put(globalObject, ZigString.static("fn"), mock_fn); - module.put(globalObject, ZigString.static("vi"), vi); - - return module; - } - - extern fn JSMockFunction__createObject(*JSC.JSGlobalObject) JSC.JSValue; - - extern fn Bun__Jest__testPreloadObject(*JSC.JSGlobalObject) JSC.JSValue; - extern fn Bun__Jest__testModuleObject(*JSC.JSGlobalObject) JSC.JSValue; - extern fn jsFunctionResetSpies(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; - extern fn JSMock__spyOn(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; - - pub fn call( - _: void, - ctx: js.JSContextRef, - _: js.JSObjectRef, - _: js.JSObjectRef, - arguments_: []const js.JSValueRef, - exception: js.ExceptionRef, - ) js.JSValueRef { - JSC.markBinding(@src()); - var runner_ = runner orelse { - JSError(getAllocator(ctx), "Run \"bun test\" to run a test", .{}, ctx, exception); - return js.JSValueMakeUndefined(ctx); - }; - const arguments = @ptrCast([]const JSC.JSValue, arguments_); - - if (arguments.len < 1 or !arguments[0].isString()) { - JSError(getAllocator(ctx), "Bun.jest() expects a string filename", .{}, ctx, exception); - return js.JSValueMakeUndefined(ctx); - } - var str = arguments[0].toSlice(ctx, bun.default_allocator); - defer str.deinit(); - var slice = str.slice(); - - if (str.len == 0 or slice[0] != '/') { - JSError(getAllocator(ctx), "Bun.jest() expects an absolute file path", .{}, ctx, exception); - return js.JSValueMakeUndefined(ctx); - } - var vm = ctx.bunVM(); - if (vm.is_in_preload) { - return Bun__Jest__testPreloadObject(ctx).asObjectRef(); - } - - var filepath = Fs.FileSystem.instance.filename_store.append([]const u8, slice) catch unreachable; - - var scope = runner_.getOrPutFile(filepath); - DescribeScope.active = scope; - DescribeScope.module = scope; - - return Bun__Jest__testModuleObject(ctx).asObjectRef(); - } - - comptime { - if (!JSC.is_bindgen) { - @export(Bun__Jest__createTestModuleObject, .{ .name = "Bun__Jest__createTestModuleObject" }); - @export(Bun__Jest__createTestPreloadObject, .{ .name = "Bun__Jest__createTestPreloadObject" }); - } - } -}; - -pub const ExpectAnything = struct { - pub usingnamespace JSC.Codegen.JSExpectAnything; - - pub fn finalize( - this: *ExpectAnything, - ) callconv(.C) void { - VirtualMachine.get().allocator.destroy(this); - } - - pub fn call(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSValue { - const anything = globalObject.bunVM().allocator.create(ExpectAnything) catch unreachable; - if (Jest.runner.?.pending_test == null) { - const err = globalObject.createErrorInstance("expect.anything() must be called in a test", .{}); - err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); - globalObject.throwValue(err); - return .zero; - } - - const anything_js_value = anything.toJS(globalObject); - anything_js_value.ensureStillAlive(); - - var vm = globalObject.bunVM(); - vm.autoGarbageCollect(); - - return anything_js_value; - } -}; - -pub const ExpectStringMatching = struct { - pub usingnamespace JSC.Codegen.JSExpectStringMatching; - - pub fn finalize( - this: *ExpectStringMatching, - ) callconv(.C) void { - VirtualMachine.get().allocator.destroy(this); - } - - pub fn call(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - const args = callFrame.arguments(1).slice(); - - if (args.len == 0 or (!args[0].isString() and !args[0].isRegExp())) { - const fmt = "expect.stringContaining(string)\n\nExpected a string or regular expression\n"; - globalObject.throwPretty(fmt, .{}); - return .zero; - } - - const test_value = args[0]; - const string_matching = globalObject.bunVM().allocator.create(ExpectStringMatching) catch unreachable; - - if (Jest.runner.?.pending_test == null) { - const err = globalObject.createErrorInstance("expect.stringContaining() must be called in a test", .{}); - err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); - globalObject.throwValue(err); - return .zero; - } - - const string_matching_js_value = string_matching.toJS(globalObject); - ExpectStringMatching.testValueSetCached(string_matching_js_value, globalObject, test_value); - - var vm = globalObject.bunVM(); - vm.autoGarbageCollect(); - return string_matching_js_value; - } -}; - -pub const ExpectStringContaining = struct { - pub usingnamespace JSC.Codegen.JSExpectStringContaining; - - pub fn finalize( - this: *ExpectStringContaining, - ) callconv(.C) void { - VirtualMachine.get().allocator.destroy(this); - } - - pub fn call(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - const args = callFrame.arguments(1).slice(); - - if (args.len == 0 or !args[0].isString()) { - const fmt = "expect.stringContaining(string)\n\nExpected a string\n"; - globalObject.throwPretty(fmt, .{}); - return .zero; - } - - const string_value = args[0]; - - const string_containing = globalObject.bunVM().allocator.create(ExpectStringContaining) catch unreachable; - - if (Jest.runner.?.pending_test == null) { - const err = globalObject.createErrorInstance("expect.stringContaining() must be called in a test", .{}); - err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); - globalObject.throwValue(err); - return .zero; - } - - const string_containing_js_value = string_containing.toJS(globalObject); - ExpectStringContaining.stringValueSetCached(string_containing_js_value, globalObject, string_value); - - var vm = globalObject.bunVM(); - vm.autoGarbageCollect(); - return string_containing_js_value; - } -}; -pub const ExpectAny = struct { - pub usingnamespace JSC.Codegen.JSExpectAny; - - pub fn finalize( - this: *ExpectAny, - ) callconv(.C) void { - VirtualMachine.get().allocator.destroy(this); - } - - pub fn call(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len == 0) { - globalObject.throw("any() expects to be passed a constructor function.", .{}); - return .zero; - } - - const constructor = arguments[0]; - constructor.ensureStillAlive(); - if (!constructor.isConstructor()) { - const fmt = "expect.any(constructor)\n\nExpected a constructor\n"; - globalObject.throwPretty(fmt, .{}); - return .zero; - } - - var any = globalObject.bunVM().allocator.create(ExpectAny) catch unreachable; - - if (Jest.runner.?.pending_test == null) { - const err = globalObject.createErrorInstance("expect.any() must be called in a test", .{}); - err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); - globalObject.throwValue(err); - return .zero; - } - - any.* = .{}; - const any_js_value = any.toJS(globalObject); - any_js_value.ensureStillAlive(); - ExpectAny.constructorValueSetCached(any_js_value, globalObject, constructor); - any_js_value.ensureStillAlive(); - - var vm = globalObject.bunVM(); - vm.autoGarbageCollect(); - - return any_js_value; - } -}; - -/// https://jestjs.io/docs/expect -// To support async tests, we need to track the test ID -pub const Expect = struct { - test_id: TestRunner.Test.ID, - scope: *DescribeScope, - op: Op.Set = Op.Set.init(.{}), - - pub usingnamespace JSC.Codegen.JSExpect; - - pub const Op = enum(u3) { - resolves, - rejects, - not, - pub const Set = std.EnumSet(Op); - }; - - pub fn getSnapshotName(this: *Expect, allocator: std.mem.Allocator, hint: string) ![]const u8 { - const test_name = this.scope.tests.items[this.test_id].label; - - var length: usize = 0; - var curr_scope: ?*DescribeScope = this.scope; - while (curr_scope) |scope| { - if (scope.label.len > 0) { - length += scope.label.len + 1; - } - curr_scope = scope.parent; - } - length += test_name.len; - if (hint.len > 0) { - length += hint.len + 2; - } - - var buf = try allocator.alloc(u8, length); - - var index = buf.len; - if (hint.len > 0) { - index -= hint.len; - bun.copy(u8, buf[index..], hint); - index -= test_name.len + 2; - bun.copy(u8, buf[index..], test_name); - bun.copy(u8, buf[index + test_name.len ..], ": "); - } else { - index -= test_name.len; - bun.copy(u8, buf[index..], test_name); - } - // copy describe scopes in reverse order - curr_scope = this.scope; - while (curr_scope) |scope| { - if (scope.label.len > 0) { - index -= scope.label.len + 1; - bun.copy(u8, buf[index..], scope.label); - buf[index + scope.label.len] = ' '; - } - curr_scope = scope.parent; - } - - return buf; - } - - pub fn finalize( - this: *Expect, - ) callconv(.C) void { - VirtualMachine.get().allocator.destroy(this); - } - - pub fn call(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { - const arguments = callframe.arguments(1); - const value = if (arguments.len < 1) JSC.JSValue.jsUndefined() else arguments.ptr[0]; - - var expect = globalObject.bunVM().allocator.create(Expect) catch unreachable; - - if (Jest.runner.?.pending_test == null) { - const err = globalObject.createErrorInstance("expect() must be called in a test", .{}); - err.put(globalObject, ZigString.static("name"), ZigString.init("TestNotRunningError").toValueGC(globalObject)); - globalObject.throwValue(err); - return .zero; - } - - expect.* = .{ - .scope = Jest.runner.?.pending_test.?.describe, - .test_id = Jest.runner.?.pending_test.?.test_id, - }; - const expect_js_value = expect.toJS(globalObject); - expect_js_value.ensureStillAlive(); - JSC.Jest.Expect.capturedValueSetCached(expect_js_value, globalObject, value); - expect_js_value.ensureStillAlive(); - expect.postMatch(globalObject); - return expect_js_value; - } - - pub fn constructor( - globalObject: *JSC.JSGlobalObject, - callframe: *JSC.CallFrame, - ) callconv(.C) ?*Expect { - _ = callframe.arguments(1); - globalObject.throw("expect() cannot be called with new", .{}); - return null; - } - - /// Object.is() - pub fn toBe( - this: *Expect, - globalObject: *JSC.JSGlobalObject, - callframe: *JSC.CallFrame, - ) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - const thisValue = callframe.this(); - const arguments_ = callframe.arguments(1); - const arguments = arguments_.ptr[0..arguments_.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toBe() takes 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBe() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - const right = arguments[0]; - right.ensureStillAlive(); - const left = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - left.ensureStillAlive(); - - const not = this.op.contains(.not); - var pass = right.isSameValue(left, globalObject); - if (comptime Environment.allow_assert) { - std.debug.assert(pass == JSC.C.JSValueIsStrictEqual(globalObject, right.asObjectRef(), left.asObjectRef())); - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - if (not) { - const signature = comptime getSignature("toBe", "expected", true); - const fmt = signature ++ "\n\nExpected: not {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{right.toFmt(globalObject, &formatter)}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{right.toFmt(globalObject, &formatter)}); - return .zero; - } - - const signature = comptime getSignature("toBe", "expected", false); - if (left.deepEquals(right, globalObject) or left.strictDeepEquals(right, globalObject)) { - const fmt = signature ++ - "\n\nIf this test should pass, replace \"toBe\" with \"toEqual\" or \"toStrictEqual\"" ++ - "\n\nExpected: {any}\n" ++ - "Received: serializes to the same string\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{right.toFmt(globalObject, &formatter)}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{right.toFmt(globalObject, &formatter)}); - return .zero; - } - - if (right.isString() and left.isString()) { - const diff_format = DiffFormatter{ - .expected = right, - .received = left, - .globalObject = globalObject, - .not = not, - }; - const fmt = signature ++ "\n\n{any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{diff_format}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{diff_format}); - return .zero; - } - - const fmt = signature ++ "\n\nExpected: {any}\nReceived: {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ - right.toFmt(globalObject, &formatter), - left.toFmt(globalObject, &formatter), - }); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{ - right.toFmt(globalObject, &formatter), - left.toFmt(globalObject, &formatter), - }); - return .zero; - } - - pub fn getSignature(comptime matcher_name: string, comptime args: string, comptime not: bool) string { - const received = "expect(received)."; - comptime if (not) { - return received ++ "not." ++ matcher_name ++ "(" ++ args ++ ")"; - }; - return received ++ matcher_name ++ "(" ++ args ++ ")"; - } - - pub fn toHaveLength( - this: *Expect, - globalObject: *JSC.JSGlobalObject, - callframe: *JSC.CallFrame, - ) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - const thisValue = callframe.this(); - const arguments_ = callframe.arguments(1); - const arguments = arguments_.ptr[0..arguments_.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toHaveLength() takes 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toHaveLength() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const expected: JSValue = arguments[0]; - const value: JSValue = JSC.Jest.Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (!value.isObject() and !value.isString()) { - var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - globalObject.throw("Received value does not have a length property: {any}", .{value.toFmt(globalObject, &fmt)}); - return .zero; - } - - if (!expected.isNumber()) { - var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - globalObject.throw("Expected value must be a non-negative integer: {any}", .{expected.toFmt(globalObject, &fmt)}); - return .zero; - } - - const expected_length: f64 = expected.asNumber(); - if (@round(expected_length) != expected_length or std.math.isInf(expected_length) or std.math.isNan(expected_length) or expected_length < 0) { - var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - globalObject.throw("Expected value must be a non-negative integer: {any}", .{expected.toFmt(globalObject, &fmt)}); - return .zero; - } - - const not = this.op.contains(.not); - var pass = false; - - const actual_length = value.getLengthIfPropertyExistsInternal(globalObject); - - if (actual_length == std.math.inf(f64)) { - var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - globalObject.throw("Received value does not have a length property: {any}", .{value.toFmt(globalObject, &fmt)}); - return .zero; - } else if (std.math.isNan(actual_length)) { - globalObject.throw("Received value has non-number length property: {}", .{actual_length}); - return .zero; - } - - if (actual_length == expected_length) { - pass = true; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - if (not) { - const expected_line = "Expected length: not {d}\n"; - const fmt = comptime getSignature("toHaveLength", "expected", true) ++ "\n\n" ++ expected_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{expected_length}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{expected_length}); - return .zero; - } - - const expected_line = "Expected length: {d}\n"; - const received_line = "Received length: {d}\n"; - const fmt = comptime getSignature("toHaveLength", "expected", false) ++ "\n\n" ++ - expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_length, actual_length }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_length, actual_length }); - return .zero; - } - - pub fn toContain( - this: *Expect, - globalObject: *JSC.JSGlobalObject, - callFrame: *JSC.CallFrame, - ) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - const thisValue = callFrame.this(); - const arguments_ = callFrame.arguments(1); - const arguments = arguments_.ptr[0..arguments_.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toContain() takes 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toContain() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const expected = arguments[0]; - expected.ensureStillAlive(); - const value: JSValue = JSC.Jest.Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - const not = this.op.contains(.not); - var pass = false; - - if (value.isIterable(globalObject)) { - var itr = value.arrayIterator(globalObject); - while (itr.next()) |item| { - if (item.isSameValue(expected, globalObject)) { - pass = true; - break; - } - } - } else if (value.isString() and expected.isString()) { - const value_string = value.toString(globalObject).toSlice(globalObject, default_allocator).slice(); - const expected_string = expected.toString(globalObject).toSlice(globalObject, default_allocator).slice(); - if (strings.contains(value_string, expected_string)) { - pass = true; - } else if (value_string.len == 0 and expected_string.len == 0) { // edge case two empty strings are true - pass = true; - } - } else { - globalObject.throw("Received value must be an array type, or both received and expected values must be strings.", .{}); - return .zero; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - const expected_fmt = expected.toFmt(globalObject, &formatter); - if (not) { - const expected_line = "Expected to contain: not {any}\n"; - const fmt = comptime getSignature("toContain", "expected", true) ++ "\n\n" ++ expected_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{expected_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{expected_fmt}); - return .zero; - } - - const expected_line = "Expected to contain: {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toContain", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); - return .zero; - } - - pub fn toBeTruthy(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - const thisValue = callFrame.this(); - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeTruthy() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = false; - - const truthy = value.toBooleanSlow(globalObject); - if (truthy) pass = true; - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeTruthy", "", true) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeTruthy", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - pub fn toBeUndefined(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - const thisValue = callFrame.this(); - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = false; - if (value.isUndefined()) pass = true; - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeUndefined", "", true) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeUndefined", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - pub fn toBeNaN(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = false; - if (value.isNumber()) { - const number = value.asNumber(); - if (number != number) pass = true; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeNaN", "", true) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeNaN", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - pub fn toBeNull(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = value.isNull(); - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeNull", "", true) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeNull", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - pub fn toBeDefined(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = !value.isUndefined(); - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeDefined", "", true) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeDefined", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - pub fn toBeFalsy(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeFalsy() must be called in a test", .{}); - return .zero; - } - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = false; - - const truthy = value.toBooleanSlow(globalObject); - if (!truthy) pass = true; - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeFalsy", "", true) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeFalsy", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - pub fn toEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toEqual() requires 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toEqual() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const expected = arguments[0]; - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - const not = this.op.contains(.not); - var pass = value.jestDeepEquals(expected, globalObject); - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - const diff_formatter = DiffFormatter{ - .received = value, - .expected = expected, - .globalObject = globalObject, - .not = not, - }; - - if (not) { - const signature = comptime getSignature("toEqual", "expected", true); - const fmt = signature ++ "\n\n{any}\n"; - globalObject.throwPretty(fmt, .{diff_formatter}); - return .zero; - } - - const signature = comptime getSignature("toEqual", "expected", false); - const fmt = signature ++ "\n\n{any}\n"; - globalObject.throwPretty(fmt, .{diff_formatter}); - return .zero; - } - - pub fn toStrictEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toStrictEqual() requires 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toStrictEqual() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const expected = arguments[0]; - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - const not = this.op.contains(.not); - var pass = value.jestStrictDeepEquals(expected, globalObject); - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - const diff_formatter = DiffFormatter{ .received = value, .expected = expected, .globalObject = globalObject, .not = not }; - - if (not) { - const signature = comptime getSignature("toStrictEqual", "expected", true); - const fmt = signature ++ "\n\n{any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{diff_formatter}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{diff_formatter}); - return .zero; - } - - const signature = comptime getSignature("toStrictEqual", "expected", false); - const fmt = signature ++ "\n\n{any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{diff_formatter}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{diff_formatter}); - return .zero; - } - - pub fn toHaveProperty(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(2); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toHaveProperty() requires at least 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toHaveProperty must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const expected_property_path = arguments[0]; - expected_property_path.ensureStillAlive(); - const expected_property: ?JSValue = if (arguments.len > 1) arguments[1] else null; - if (expected_property) |ev| ev.ensureStillAlive(); - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (!expected_property_path.isString() and !expected_property_path.isIterable(globalObject)) { - globalObject.throw("Expected path must be a string or an array", .{}); - return .zero; - } - - const not = this.op.contains(.not); - var path_string = ZigString.Empty; - expected_property_path.toZigString(&path_string, globalObject); - - var pass = !value.isUndefinedOrNull(); - var received_property: JSValue = .zero; - - if (pass) { - received_property = value.getIfPropertyExistsFromPath(globalObject, expected_property_path); - pass = !received_property.isEmpty(); - } - - if (pass and expected_property != null) { - pass = received_property.jestDeepEquals(expected_property.?, globalObject); - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - if (not) { - if (expected_property != null) { - const signature = comptime getSignature("toHaveProperty", "path, value", true); - if (!received_property.isEmpty()) { - const fmt = signature ++ "\n\nExpected path: {any}\n\nExpected value: not {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ - expected_property_path.toFmt(globalObject, &formatter), - expected_property.?.toFmt(globalObject, &formatter), - }); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, true), .{ - expected_property_path.toFmt(globalObject, &formatter), - expected_property.?.toFmt(globalObject, &formatter), - }); - return .zero; - } - } - - const signature = comptime getSignature("toHaveProperty", "path", true); - const fmt = signature ++ "\n\nExpected path: not {any}\n\nReceived value: {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ - expected_property_path.toFmt(globalObject, &formatter), - received_property.toFmt(globalObject, &formatter), - }); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{ - expected_property_path.toFmt(globalObject, &formatter), - received_property.toFmt(globalObject, &formatter), - }); - return .zero; - } - - if (expected_property != null) { - const signature = comptime getSignature("toHaveProperty", "path, value", false); - if (!received_property.isEmpty()) { - // deep equal case - const fmt = signature ++ "\n\n{any}\n"; - const diff_format = DiffFormatter{ - .received = received_property, - .expected = expected_property.?, - .globalObject = globalObject, - }; - - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{diff_format}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{diff_format}); - return .zero; - } - - const fmt = signature ++ "\n\nExpected path: {any}\n\nExpected value: {any}\n\n" ++ - "Unable to find property\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ - expected_property_path.toFmt(globalObject, &formatter), - expected_property.?.toFmt(globalObject, &formatter), - }); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{ - expected_property_path.toFmt(globalObject, &formatter), - expected_property.?.toFmt(globalObject, &formatter), - }); - return .zero; - } - - const signature = comptime getSignature("toHaveProperty", "path", false); - const fmt = signature ++ "\n\nExpected path: {any}\n\nUnable to find property\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{expected_property_path.toFmt(globalObject, &formatter)}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{expected_property_path.toFmt(globalObject, &formatter)}); - return .zero; - } - - pub fn toBeEven(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeEven() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = false; - - if (value.isAnyInt()) { - const _value = value.toInt64(); - pass = @mod(_value, 2) == 0; - if (_value == -0) { // negative zero is even - pass = true; - } - } else if (value.isBigInt() or value.isBigInt32()) { - const _value = value.toInt64(); - pass = switch (_value == -0) { // negative zero is even - true => true, - else => _value & 1 == 0, - }; - } else if (value.isNumber()) { - const _value = JSValue.asNumber(value); - if (@mod(_value, 1) == 0 and @mod(_value, 2) == 0) { // if the fraction is all zeros and even - pass = true; - } else { - pass = false; - } - } else { - pass = false; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeEven", "", true) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeEven", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - pub fn toBeGreaterThan(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toBeGreaterThan() requires 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeGreaterThan() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const other_value = arguments[0]; - other_value.ensureStillAlive(); - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) { - globalObject.throw("Expected and actual values must be numbers or bigints", .{}); - return .zero; - } - - const not = this.op.contains(.not); - var pass = false; - - if (!value.isBigInt() and !other_value.isBigInt()) { - pass = value.asNumber() > other_value.asNumber(); - } else if (value.isBigInt()) { - pass = switch (value.asBigIntCompare(globalObject, other_value)) { - .greater_than => true, - else => pass, - }; - } else { - pass = switch (other_value.asBigIntCompare(globalObject, value)) { - .less_than => true, - else => pass, - }; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - const expected_fmt = other_value.toFmt(globalObject, &formatter); - if (not) { - const expected_line = "Expected: not \\> {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeGreaterThan", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected: \\> {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeGreaterThan", "expected", false) ++ "\n\n" ++ - expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(comptime Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); - return .zero; - } - - pub fn toBeGreaterThanOrEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toBeGreaterThanOrEqual() requires 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeGreaterThanOrEqual() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const other_value = arguments[0]; - other_value.ensureStillAlive(); - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) { - globalObject.throw("Expected and actual values must be numbers or bigints", .{}); - return .zero; - } - - const not = this.op.contains(.not); - var pass = false; - - if (!value.isBigInt() and !other_value.isBigInt()) { - pass = value.asNumber() >= other_value.asNumber(); - } else if (value.isBigInt()) { - pass = switch (value.asBigIntCompare(globalObject, other_value)) { - .greater_than, .equal => true, - else => pass, - }; - } else { - pass = switch (other_value.asBigIntCompare(globalObject, value)) { - .less_than, .equal => true, - else => pass, - }; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - const expected_fmt = other_value.toFmt(globalObject, &formatter); - if (not) { - const expected_line = "Expected: not \\>= {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeGreaterThanOrEqual", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected: \\>= {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeGreaterThanOrEqual", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(comptime Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - return .zero; - } - - pub fn toBeLessThan(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toBeLessThan() requires 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeLessThan() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const other_value = arguments[0]; - other_value.ensureStillAlive(); - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) { - globalObject.throw("Expected and actual values must be numbers or bigints", .{}); - return .zero; - } - - const not = this.op.contains(.not); - var pass = false; - - if (!value.isBigInt() and !other_value.isBigInt()) { - pass = value.asNumber() < other_value.asNumber(); - } else if (value.isBigInt()) { - pass = switch (value.asBigIntCompare(globalObject, other_value)) { - .less_than => true, - else => pass, - }; - } else { - pass = switch (other_value.asBigIntCompare(globalObject, value)) { - .greater_than => true, - else => pass, - }; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - const expected_fmt = other_value.toFmt(globalObject, &formatter); - if (not) { - const expected_line = "Expected: not \\< {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeLessThan", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected: \\< {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeLessThan", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(comptime Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - return .zero; - } - - pub fn toBeLessThanOrEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toBeLessThanOrEqual() requires 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeLessThanOrEqual() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const other_value = arguments[0]; - other_value.ensureStillAlive(); - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) { - globalObject.throw("Expected and actual values must be numbers or bigints", .{}); - return .zero; - } - - const not = this.op.contains(.not); - var pass = false; - - if (!value.isBigInt() and !other_value.isBigInt()) { - pass = value.asNumber() <= other_value.asNumber(); - } else if (value.isBigInt()) { - pass = switch (value.asBigIntCompare(globalObject, other_value)) { - .less_than, .equal => true, - else => pass, - }; - } else { - pass = switch (other_value.asBigIntCompare(globalObject, value)) { - .greater_than, .equal => true, - else => pass, - }; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - const expected_fmt = other_value.toFmt(globalObject, &formatter); - if (not) { - const expected_line = "Expected: not \\<= {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeLessThanOrEqual", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected: \\<= {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeLessThanOrEqual", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(comptime Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - return .zero; - } - - pub fn toBeCloseTo(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const thisArguments = callFrame.arguments(2); - const arguments = thisArguments.ptr[0..thisArguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toBeCloseTo() requires at least 1 argument. Expected value must be a number", .{}); - return .zero; - } - - const expected_ = arguments[0]; - if (!expected_.isNumber()) { - globalObject.throwInvalidArgumentType("toBeCloseTo", "expected", "number"); - return .zero; - } - - var precision: f64 = 2.0; - if (arguments.len > 1) { - const precision_ = arguments[1]; - if (!precision_.isNumber()) { - globalObject.throwInvalidArgumentType("toBeCloseTo", "precision", "number"); - return .zero; - } - - precision = precision_.asNumber(); - } - - const received_: JSC.JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - - if (!received_.isNumber()) { - globalObject.throwInvalidArgumentType("expect", "received", "number"); - return .zero; - } - - var expected = expected_.asNumber(); - var received = received_.asNumber(); - - if (std.math.isNegativeInf(expected)) { - expected = -expected; - } - - if (std.math.isNegativeInf(received)) { - received = -received; - } - - if (std.math.isPositiveInf(expected) and std.math.isPositiveInf(received)) { - return thisValue; - } - - const expected_diff = std.math.pow(f64, 10, -precision) / 2; - const actual_diff = std.math.fabs(received - expected); - var pass = actual_diff < expected_diff; - - const not = this.op.contains(.not); - if (not) pass = !pass; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - - const expected_fmt = expected_.toFmt(globalObject, &formatter); - const received_fmt = received_.toFmt(globalObject, &formatter); - - const expected_line = "Expected: {any}\n"; - const received_line = "Received: {any}\n"; - const expected_precision = "Expected precision: {d}\n"; - const expected_difference = "Expected difference: \\< {d}\n"; - const received_difference = "Received difference: {d}\n"; - - const suffix_fmt = "\n\n" ++ expected_line ++ received_line ++ "\n" ++ expected_precision ++ expected_difference ++ received_difference; - - if (not) { - const fmt = comptime getSignature("toBeCloseTo", "expected, precision", true) ++ suffix_fmt; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, received_fmt, precision, expected_diff, actual_diff }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, received_fmt, precision, expected_diff, actual_diff }); - return .zero; - } - - const fmt = comptime getSignature("toBeCloseTo", "expected, precision", false) ++ suffix_fmt; - - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, received_fmt, precision, expected_diff, actual_diff }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, received_fmt, precision, expected_diff, actual_diff }); - return .zero; - } - - pub fn toBeOdd(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeOdd() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = false; - - if (value.isBigInt32()) { - pass = value.toInt32() & 1 == 1; - } else if (value.isBigInt()) { - pass = value.toInt64() & 1 == 1; - } else if (value.isInt32()) { - const _value = value.toInt32(); - pass = @mod(_value, 2) == 1; - } else if (value.isAnyInt()) { - const _value = value.toInt64(); - pass = @mod(_value, 2) == 1; - } else if (value.isNumber()) { - const _value = JSValue.asNumber(value); - if (@mod(_value, 1) == 0 and @mod(_value, 2) == 1) { // if the fraction is all zeros and odd - pass = true; - } else { - pass = false; - } - } else { - pass = false; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeOdd", "", true) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeOdd", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{value_fmt}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{value_fmt}); - return .zero; - } - - pub fn toThrow(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toThrow() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const expected_value: JSValue = if (arguments.len > 0) brk: { - const value = arguments[0]; - if (value.isEmptyOrUndefinedOrNull() or !value.isObject() and !value.isString()) { - var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - globalObject.throw("Expected value must be string or Error: {any}", .{value.toFmt(globalObject, &fmt)}); - return .zero; - } - break :brk value; - } else .zero; - expected_value.ensureStillAlive(); - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (!value.jsType().isFunction()) { - globalObject.throw("Expected value must be a function", .{}); - return .zero; - } - - const not = this.op.contains(.not); - - const result_: ?JSValue = brk: { - var vm = globalObject.bunVM(); - var return_value: JSValue = .zero; - var scope = vm.unhandledRejectionScope(); - var prev_unhandled_pending_rejection_to_capture = vm.unhandled_pending_rejection_to_capture; - vm.unhandled_pending_rejection_to_capture = &return_value; - vm.onUnhandledRejection = &VirtualMachine.onQuietUnhandledRejectionHandlerCaptureValue; - const return_value_from_fucntion: JSValue = value.call(globalObject, &.{}); - vm.unhandled_pending_rejection_to_capture = prev_unhandled_pending_rejection_to_capture; - - if (return_value == .zero) { - return_value = return_value_from_fucntion; - } - - if (return_value.asAnyPromise()) |promise| { - globalObject.bunVM().waitForPromise(promise); - scope.apply(vm); - const promise_result = promise.result(globalObject.vm()); - - switch (promise.status(globalObject.vm())) { - .Fulfilled => { - break :brk null; - }, - .Rejected => { - // since we know for sure it rejected, we should always return the error - break :brk promise_result.toError() orelse promise_result; - }, - .Pending => unreachable, - } - } - scope.apply(vm); - - break :brk return_value.toError(); - }; - - const did_throw = result_ != null; - - if (not) { - const signature = comptime getSignature("toThrow", "expected", true); - - if (!did_throw) return thisValue; - - const result: JSValue = result_.?; - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - - if (expected_value.isEmpty()) { - const signature_no_args = comptime getSignature("toThrow", "", true); - if (result.toError()) |err| { - const name = err.get(globalObject, "name") orelse JSValue.undefined; - const message = err.get(globalObject, "message") orelse JSValue.undefined; - const fmt = signature_no_args ++ "\n\nError name: {any}\nError message: {any}\n"; - globalObject.throwPretty(fmt, .{ - name.toFmt(globalObject, &formatter), - message.toFmt(globalObject, &formatter), - }); - return .zero; - } - - // non error thrown - const fmt = signature_no_args ++ "\n\nThrown value: {any}\n"; - globalObject.throwPretty(fmt, .{result.toFmt(globalObject, &formatter)}); - return .zero; - } - - if (expected_value.isString()) { - const received_message = result.getIfPropertyExistsImpl(globalObject, "message", 7); - - // TODO: remove this allocation - // partial match - { - const expected_slice = expected_value.toSliceOrNull(globalObject) orelse return .zero; - defer expected_slice.deinit(); - const received_slice = received_message.toSliceOrNull(globalObject) orelse return .zero; - defer received_slice.deinit(); - if (!strings.contains(received_slice.slice(), expected_slice.slice())) return thisValue; - } - - const fmt = signature ++ "\n\nExpected substring: not {any}\nReceived message: {any}\n"; - globalObject.throwPretty(fmt, .{ - expected_value.toFmt(globalObject, &formatter), - received_message.toFmt(globalObject, &formatter), - }); - return .zero; - } - - if (expected_value.isRegExp()) { - const received_message = result.getIfPropertyExistsImpl(globalObject, "message", 7); - - // TODO: REMOVE THIS GETTER! Expose a binding to call .test on the RegExp object directly. - if (expected_value.get(globalObject, "test")) |test_fn| { - const matches = test_fn.callWithThis(globalObject, expected_value, &.{received_message}); - if (!matches.toBooleanSlow(globalObject)) return thisValue; - } - - const fmt = signature ++ "\n\nExpected pattern: not {any}\nReceived message: {any}\n"; - globalObject.throwPretty(fmt, .{ - expected_value.toFmt(globalObject, &formatter), - received_message.toFmt(globalObject, &formatter), - }); - return .zero; - } - - if (expected_value.get(globalObject, "message")) |expected_message| { - const received_message = result.getIfPropertyExistsImpl(globalObject, "message", 7); - // no partial match for this case - if (!expected_message.isSameValue(received_message, globalObject)) return thisValue; - - const fmt = signature ++ "\n\nExpected message: not {any}\n"; - globalObject.throwPretty(fmt, .{expected_message.toFmt(globalObject, &formatter)}); - return .zero; - } - - if (!result.isInstanceOf(globalObject, expected_value)) return thisValue; - - var expected_class = ZigString.Empty; - expected_value.getClassName(globalObject, &expected_class); - const received_message = result.getIfPropertyExistsImpl(globalObject, "message", 7); - const fmt = signature ++ "\n\nExpected constructor: not {s}\n\nReceived message: {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_class, received_message.toFmt(globalObject, &formatter) }); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_class, received_message.toFmt(globalObject, &formatter) }); - return .zero; - } - - const signature = comptime getSignature("toThrow", "expected", false); - if (did_throw) { - if (expected_value.isEmpty()) return thisValue; - - const result: JSValue = if (result_.?.toError()) |r| - r - else - result_.?; - - const _received_message: ?JSValue = if (result.isObject()) - result.get(globalObject, "message") - else if (result.toStringOrNull(globalObject)) |js_str| - JSC.JSValue.fromCell(js_str) - else - null; - - if (expected_value.isString()) { - if (_received_message) |received_message| { - // TODO: remove this allocation - // partial match - const expected_slice = expected_value.toSliceOrNull(globalObject) orelse return .zero; - defer expected_slice.deinit(); - const received_slice = received_message.toSlice(globalObject, globalObject.allocator()); - defer received_slice.deinit(); - if (strings.contains(received_slice.slice(), expected_slice.slice())) return thisValue; - } - - // error: message from received error does not match expected string - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - - if (_received_message) |received_message| { - const expected_value_fmt = expected_value.toFmt(globalObject, &formatter); - const received_message_fmt = received_message.toFmt(globalObject, &formatter); - const fmt = signature ++ "\n\n" ++ "Expected substring: {any}\nReceived message: {any}\n"; - globalObject.throwPretty(fmt, .{ expected_value_fmt, received_message_fmt }); - return .zero; - } - - const expected_fmt = expected_value.toFmt(globalObject, &formatter); - const received_fmt = result.toFmt(globalObject, &formatter); - const fmt = signature ++ "\n\n" ++ "Expected substring: {any}\nReceived value: {any}"; - globalObject.throwPretty(fmt, .{ expected_fmt, received_fmt }); - - return .zero; - } - - if (expected_value.isRegExp()) { - if (_received_message) |received_message| { - // TODO: REMOVE THIS GETTER! Expose a binding to call .test on the RegExp object directly. - if (expected_value.get(globalObject, "test")) |test_fn| { - const matches = test_fn.callWithThis(globalObject, expected_value, &.{received_message}); - if (matches.toBooleanSlow(globalObject)) return thisValue; - } - } - - // error: message from received error does not match expected pattern - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - - if (_received_message) |received_message| { - const expected_value_fmt = expected_value.toFmt(globalObject, &formatter); - const received_message_fmt = received_message.toFmt(globalObject, &formatter); - const fmt = signature ++ "\n\n" ++ "Expected pattern: {any}\nReceived message: {any}\n"; - globalObject.throwPretty(fmt, .{ expected_value_fmt, received_message_fmt }); - - return .zero; - } - - const expected_fmt = expected_value.toFmt(globalObject, &formatter); - const received_fmt = result.toFmt(globalObject, &formatter); - const fmt = signature ++ "\n\n" ++ "Expected pattern: {any}\nReceived value: {any}"; - globalObject.throwPretty(fmt, .{ expected_fmt, received_fmt }); - return .zero; - } - - // If it's not an object, we are going to crash here. - std.debug.assert(expected_value.isObject()); - - if (expected_value.get(globalObject, "message")) |expected_message| { - if (_received_message) |received_message| { - if (received_message.isSameValue(expected_message, globalObject)) return thisValue; - } - - // error: message from received error does not match expected error message. - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - - if (_received_message) |received_message| { - const expected_fmt = expected_message.toFmt(globalObject, &formatter); - const received_fmt = received_message.toFmt(globalObject, &formatter); - const fmt = signature ++ "\n\nExpected message: {any}\nReceived message: {any}\n"; - globalObject.throwPretty(fmt, .{ expected_fmt, received_fmt }); - return .zero; - } - - const expected_fmt = expected_message.toFmt(globalObject, &formatter); - const received_fmt = result.toFmt(globalObject, &formatter); - const fmt = signature ++ "\n\nExpected message: {any}\nReceived value: {any}\n"; - globalObject.throwPretty(fmt, .{ expected_fmt, received_fmt }); - return .zero; - } - - if (result.isInstanceOf(globalObject, expected_value)) return thisValue; - - // error: received error not instance of received error constructor - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - var expected_class = ZigString.Empty; - var received_class = ZigString.Empty; - expected_value.getClassName(globalObject, &expected_class); - result.getClassName(globalObject, &received_class); - const fmt = signature ++ "\n\nExpected constructor: {s}\nReceived constructor: {s}\n\n"; - - if (_received_message) |received_message| { - const message_fmt = fmt ++ "Received message: {any}\n"; - const received_message_fmt = received_message.toFmt(globalObject, &formatter); - - globalObject.throwPretty(message_fmt, .{ - expected_class, - received_class, - received_message_fmt, - }); - return .zero; - } - - const received_fmt = result.toFmt(globalObject, &formatter); - const value_fmt = fmt ++ "Received value: {any}\n"; - - globalObject.throwPretty(value_fmt, .{ - expected_class, - received_class, - received_fmt, - }); - return .zero; - } - - // did not throw - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - const received_line = "Received function did not throw\n"; - - if (expected_value.isEmpty()) { - const fmt = comptime getSignature("toThrow", "", false) ++ "\n\n" ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{}); - return .zero; - } - - if (expected_value.isString()) { - const expected_fmt = "\n\nExpected substring: {any}\n\n" ++ received_line; - const fmt = signature ++ expected_fmt; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{expected_value.toFmt(globalObject, &formatter)}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{expected_value.toFmt(globalObject, &formatter)}); - return .zero; - } - - if (expected_value.isRegExp()) { - const expected_fmt = "\n\nExpected pattern: {any}\n\n" ++ received_line; - const fmt = signature ++ expected_fmt; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{expected_value.toFmt(globalObject, &formatter)}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{expected_value.toFmt(globalObject, &formatter)}); - return .zero; - } - - if (expected_value.get(globalObject, "message")) |expected_message| { - const expected_fmt = "\n\nExpected message: {any}\n\n" ++ received_line; - const fmt = signature ++ expected_fmt; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{expected_message.toFmt(globalObject, &formatter)}); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{expected_message.toFmt(globalObject, &formatter)}); - return .zero; - } - - const expected_fmt = "\n\nExpected constructor: {s}\n\n" ++ received_line; - var expected_class = ZigString.Empty; - expected_value.getClassName(globalObject, &expected_class); - const fmt = signature ++ expected_fmt; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{expected_class}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, true), .{expected_class}); - return .zero; - } - - pub fn toMatchSnapshot(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalObject); - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(2); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toMatchSnapshot() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - if (not) { - const signature = comptime getSignature("toMatchSnapshot", "", true); - const fmt = signature ++ "\n\nMatcher error: Snapshot matchers cannot be used with not\n"; - globalObject.throwPretty(fmt, .{}); - } - - var hint_string: ZigString = ZigString.Empty; - var property_matchers: ?JSValue = null; - switch (arguments.len) { - 0 => {}, - 1 => { - if (arguments[0].isString()) { - arguments[0].toZigString(&hint_string, globalObject); - } else if (arguments[0].isObject()) { - property_matchers = arguments[0]; - } - }, - else => { - if (!arguments[0].isObject()) { - const signature = comptime getSignature("toMatchSnapshot", "properties, hint", false); - const fmt = signature ++ "\n\nMatcher error: Expected properties must be an object\n"; - globalObject.throwPretty(fmt, .{}); - return .zero; - } - - property_matchers = arguments[0]; - - if (arguments[1].isString()) { - arguments[1].toZigString(&hint_string, globalObject); - } - }, - } - - var hint = hint_string.toSlice(default_allocator); - defer hint.deinit(); - - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - - if (!value.isObject() and property_matchers != null) { - const signature = comptime getSignature("toMatchSnapshot", "properties, hint", false); - const fmt = signature ++ "\n\nMatcher error: received values must be an object when the matcher has properties\n"; - globalObject.throwPretty(fmt, .{}); - return .zero; - } - - if (property_matchers) |_prop_matchers| { - var prop_matchers = _prop_matchers; - - if (!value.jestDeepMatch(prop_matchers, globalObject, true)) { - // TODO: print diff with properties from propertyMatchers - const signature = comptime getSignature("toMatchSnapshot", "propertyMatchers", false); - const fmt = signature ++ "\n\nExpected propertyMatchers to match properties from received object" ++ - "\n\nReceived: {any}\n"; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject }; - globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); - return .zero; - } - } - - const result = Jest.runner.?.snapshots.getOrPut(this, value, hint.slice(), globalObject) catch |err| { - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject }; - const test_file_path = Jest.runner.?.files.get(this.scope.file_id).source.path.text; - switch (err) { - error.FailedToOpenSnapshotFile => globalObject.throw("Failed to open snapshot file for test file: {s}", .{test_file_path}), - error.FailedToMakeSnapshotDirectory => globalObject.throw("Failed to make snapshot directory for test file: {s}", .{test_file_path}), - error.FailedToWriteSnapshotFile => globalObject.throw("Failed write to snapshot file: {s}", .{test_file_path}), - error.ParseError => globalObject.throw("Failed to parse snapshot file for: {s}", .{test_file_path}), - else => globalObject.throw("Failed to snapshot value: {any}", .{value.toFmt(globalObject, &formatter)}), - } - return .zero; - }; - - if (result) |saved_value| { - var pretty_value: MutableString = MutableString.init(default_allocator, 0) catch unreachable; - value.jestSnapshotPrettyFormat(&pretty_value, globalObject) catch { - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject }; - globalObject.throw("Failed to pretty format value: {s}", .{value.toFmt(globalObject, &formatter)}); - return .zero; - }; - defer pretty_value.deinit(); - - if (strings.eqlLong(pretty_value.toOwnedSliceLeaky(), saved_value, true)) { - Jest.runner.?.snapshots.passed += 1; - return thisValue; - } - - Jest.runner.?.snapshots.failed += 1; - const signature = comptime getSignature("toMatchSnapshot", "expected", false); - const fmt = signature ++ "\n\n{any}\n"; - const diff_format = DiffFormatter{ - .received_string = pretty_value.toOwnedSliceLeaky(), - .expected_string = saved_value, - .globalObject = globalObject, - }; - - globalObject.throwPretty(fmt, .{diff_format}); - return .zero; - } - - return thisValue; - } - - pub fn toBeEmpty(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const value: JSValue = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeEmpty() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = false; - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - - const actual_length = value.getLengthIfPropertyExistsInternal(globalObject); - - if (actual_length == std.math.inf(f64)) { - if (value.jsTypeLoose().isObject()) { - if (value.isIterable(globalObject)) { - var any_properties_in_iterator = false; - value.forEach(globalObject, &any_properties_in_iterator, struct { - pub fn anythingInIterator( - _: *JSC.VM, - _: *JSGlobalObject, - any_: ?*anyopaque, - _: JSValue, - ) callconv(.C) void { - bun.cast(*bool, any_.?).* = true; - } - }.anythingInIterator); - pass = !any_properties_in_iterator; - } else { - var props_iter = JSC.JSPropertyIterator(.{ - .skip_empty_name = false, - - .include_value = true, - }).init(globalObject, value.asObjectRef()); - defer props_iter.deinit(); - pass = props_iter.len == 0; - } - } else { - const signature = comptime getSignature("toBeEmpty", "", false); - const fmt = signature ++ "\n\nExpected value to be a string, object, or iterable" ++ - "\n\nReceived: {any}\n"; - globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); - return .zero; - } - } else if (std.math.isNan(actual_length)) { - globalObject.throw("Received value has non-number length property: {}", .{actual_length}); - return .zero; - } else { - pass = actual_length == 0; - } - - if (not and pass) { - const signature = comptime getSignature("toBeEmpty", "", true); - const fmt = signature ++ "\n\nExpected value not to be a string, object, or iterable" ++ - "\n\nReceived: {any}\n"; - globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); - return .zero; - } - - if (not) pass = !pass; - if (pass) return thisValue; - - if (not) { - const signature = comptime getSignature("toBeEmpty", "", true); - const fmt = signature ++ "\n\nExpected value not to be empty" ++ - "\n\nReceived: {any}\n"; - globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); - return .zero; - } - - const signature = comptime getSignature("toBeEmpty", "", false); - const fmt = signature ++ "\n\nExpected value to be empty" ++ - "\n\nReceived: {any}\n"; - globalObject.throwPretty(fmt, .{value.toFmt(globalObject, &formatter)}); - return .zero; - } - - pub fn toBeNil(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeNil() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.isUndefinedOrNull() != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeNil", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeNil", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeArray(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeArray() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.jsType().isArray() != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeArray", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeArray", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeArrayOfSize(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalThis.throwInvalidArguments("toBeArrayOfSize() requires 1 argument", .{}); - return .zero; - } - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeArrayOfSize() must be called in a test", .{}); - return .zero; - } - - const size = arguments[0]; - size.ensureStillAlive(); - - if (!size.isAnyInt()) { - globalThis.throw("toBeArrayOfSize() requires the first argument to be a number", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - var pass = value.jsType().isArray() and @intCast(i32, value.getLength(globalThis)) == size.toInt32(); - - if (not) pass = !pass; - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeArrayOfSize", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeArrayOfSize", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeBoolean(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeBoolean() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.isBoolean() != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeBoolean", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeBoolean", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeTrue(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeTrue() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = (value.isBoolean() and value.toBoolean()) != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeTrue", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeTrue", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeFalse(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeFalse() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = (value.isBoolean() and !value.toBoolean()) != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeFalse", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeFalse", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeNumber(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeNumber() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.isNumber() != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeNumber", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeNumber", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeInteger(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeInteger() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.isAnyInt() != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeInteger", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeInteger", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeFinite(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeFinite() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - var pass = value.isNumber(); - if (pass) { - const num: f64 = value.asNumber(); - pass = std.math.isFinite(num) and !std.math.isNan(num); - } - - const not = this.op.contains(.not); - if (not) pass = !pass; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeFinite", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeFinite", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBePositive(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBePositive() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - var pass = value.isNumber(); - if (pass) { - const num: f64 = value.asNumber(); - pass = @round(num) > 0 and !std.math.isInf(num) and !std.math.isNan(num); - } - - const not = this.op.contains(.not); - if (not) pass = !pass; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBePositive", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBePositive", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeNegative(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeNegative() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - var pass = value.isNumber(); - if (pass) { - const num: f64 = value.asNumber(); - pass = @round(num) < 0 and !std.math.isInf(num) and !std.math.isNan(num); - } - - const not = this.op.contains(.not); - if (not) pass = !pass; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeNegative", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeNegative", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeTypeOf(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalThis.throwInvalidArguments("toBeTypeOf() requires 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeTypeOf() must be called in a test", .{}); - return .zero; - } - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - const expected = arguments[0]; - expected.ensureStillAlive(); - - const expectedAsStr = expected.toString(globalThis).toSlice(globalThis, default_allocator).slice(); - active_test_expectation_counter.actual += 1; - - if (!expected.isString()) { - globalThis.throwInvalidArguments("toBeTypeOf() requires a string argument", .{}); - return .zero; - } - - if (!std.mem.eql(u8, expectedAsStr, "function") and - !std.mem.eql(u8, expectedAsStr, "object") and - !std.mem.eql(u8, expectedAsStr, "bigint") and - !std.mem.eql(u8, expectedAsStr, "boolean") and - !std.mem.eql(u8, expectedAsStr, "number") and - !std.mem.eql(u8, expectedAsStr, "string") and - !std.mem.eql(u8, expectedAsStr, "symbol") and - !std.mem.eql(u8, expectedAsStr, "undefined")) - { - globalThis.throwInvalidArguments("toBeTypeOf() requires a valid type string argument ('function', 'object', 'bigint', 'boolean', 'number', 'string', 'symbol', 'undefined')", .{}); - return .zero; - } - - const not = this.op.contains(.not); - var pass = false; - var whatIsTheType: []const u8 = ""; - - // Checking for function/class should be done before everything else, or it will fail. - if (value.isCallable(globalThis.vm())) { - whatIsTheType = "function"; - } else if (value.isObject() or value.jsType().isArray() or value.isNull()) { - whatIsTheType = "object"; - } else if (value.isBigInt()) { - whatIsTheType = "bigint"; - } else if (value.isBoolean()) { - whatIsTheType = "boolean"; - } else if (value.isNumber()) { - whatIsTheType = "number"; - } else if (value.jsType().isString()) { - whatIsTheType = "string"; - } else if (value.isSymbol()) { - whatIsTheType = "symbol"; - } else if (value.isUndefined()) { - whatIsTheType = "undefined"; - } else { - globalThis.throw("Internal consistency error: unknown JSValue type", .{}); - return .zero; - } - - pass = std.mem.eql(u8, expectedAsStr, whatIsTheType); - - if (not) pass = !pass; - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - const expected_str = expected.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeTypeOf", "", true) ++ "\n\n" ++ "Expected type: not {any}\n" ++ "Received type: \"{s}\"\nReceived value: {any}\n"; - globalThis.throwPretty(fmt, .{ expected_str, whatIsTheType, received }); - return .zero; - } - - const fmt = comptime getSignature("toBeTypeOf", "", false) ++ "\n\n" ++ "Expected type: {any}\n" ++ "Received type: \"{s}\"\nReceived value: {any}\n"; - globalThis.throwPretty(fmt, .{ expected_str, whatIsTheType, received }); - return .zero; - } - - pub fn toBeWithin(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(2); - const arguments = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalThis.throwInvalidArguments("toBeWithin() requires 2 arguments", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeWithin() must be called in a test", .{}); - return .zero; - } - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - const startValue = arguments[0]; - startValue.ensureStillAlive(); - - if (!startValue.isNumber()) { - globalThis.throw("toBeWithin() requires the first argument to be a number", .{}); - return .zero; - } - - const endValue = arguments[1]; - endValue.ensureStillAlive(); - - if (!endValue.isNumber()) { - globalThis.throw("toBeWithin() requires the second argument to be a number", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - var pass = value.isNumber(); - if (pass) { - const num = value.asNumber(); - pass = num >= startValue.asNumber() and num < endValue.asNumber(); - } - - const not = this.op.contains(.not); - if (not) pass = !pass; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const start_fmt = startValue.toFmt(globalThis, &formatter); - const end_fmt = endValue.toFmt(globalThis, &formatter); - const received_fmt = value.toFmt(globalThis, &formatter); - - if (not) { - const expected_line = "Expected: not between {any} (inclusive) and {any} (exclusive)\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeWithin", "start, end", true) ++ "\n\n" ++ expected_line ++ received_line; - globalThis.throwPretty(fmt, .{ start_fmt, end_fmt, received_fmt }); - return .zero; - } - - const expected_line = "Expected: between {any} (inclusive) and {any} (exclusive)\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toBeWithin", "start, end", false) ++ "\n\n" ++ expected_line ++ received_line; - globalThis.throwPretty(fmt, .{ start_fmt, end_fmt, received_fmt }); - return .zero; - } - - pub fn toBeSymbol(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeSymbol() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.isSymbol() != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeSymbol", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeSymbol", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeFunction(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeFunction() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.isCallable(globalThis.vm()) != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeFunction", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeFunction", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeDate(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeDate() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.isDate() != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeDate", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeDate", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toBeString(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toBeString() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - const pass = value.isString() != not; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const received = value.toFmt(globalThis, &formatter); - - if (not) { - const fmt = comptime getSignature("toBeString", "", true) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - const fmt = comptime getSignature("toBeString", "", false) ++ "\n\n" ++ "Received: {any}\n"; - globalThis.throwPretty(fmt, .{received}); - return .zero; - } - - pub fn toInclude(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const arguments_ = callFrame.arguments(1); - const arguments = arguments_.ptr[0..arguments_.len]; - - if (arguments.len < 1) { - globalThis.throwInvalidArguments("toInclude() requires 1 argument", .{}); - return .zero; - } - - const expected = arguments[0]; - expected.ensureStillAlive(); - - if (!expected.isString()) { - globalThis.throw("toInclude() requires the first argument to be a string", .{}); - return .zero; - } - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toInclude() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - var pass = value.isString(); - if (pass) { - const value_string = value.toString(globalThis).toSlice(globalThis, default_allocator).slice(); - const expected_string = expected.toString(globalThis).toSlice(globalThis, default_allocator).slice(); - pass = strings.contains(value_string, expected_string) or expected_string.len == 0; - } - - const not = this.op.contains(.not); - if (not) pass = !pass; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const value_fmt = value.toFmt(globalThis, &formatter); - const expected_fmt = expected.toFmt(globalThis, &formatter); - - if (not) { - const expected_line = "Expected to not include: {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toInclude", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected to include: {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toInclude", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - pub fn toStartWith(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const arguments_ = callFrame.arguments(1); - const arguments = arguments_.ptr[0..arguments_.len]; - - if (arguments.len < 1) { - globalThis.throwInvalidArguments("toStartWith() requires 1 argument", .{}); - return .zero; - } - - const expected = arguments[0]; - expected.ensureStillAlive(); - - if (!expected.isString()) { - globalThis.throw("toStartWith() requires the first argument to be a string", .{}); - return .zero; - } - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toStartWith() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - var pass = value.isString(); - if (pass) { - const value_string = value.toString(globalThis).toSlice(globalThis, default_allocator).slice(); - const expected_string = expected.toString(globalThis).toSlice(globalThis, default_allocator).slice(); - pass = strings.startsWith(value_string, expected_string) or expected_string.len == 0; - } - - const not = this.op.contains(.not); - if (not) pass = !pass; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const value_fmt = value.toFmt(globalThis, &formatter); - const expected_fmt = expected.toFmt(globalThis, &formatter); - - if (not) { - const expected_line = "Expected to not start with: {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toStartWith", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected to start with: {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toStartWith", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - pub fn toEndWith(this: *Expect, globalThis: *JSGlobalObject, callFrame: *CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalThis); - - const thisValue = callFrame.this(); - const arguments_ = callFrame.arguments(1); - const arguments = arguments_.ptr[0..arguments_.len]; - - if (arguments.len < 1) { - globalThis.throwInvalidArguments("toEndWith() requires 1 argument", .{}); - return .zero; - } - - const expected = arguments[0]; - expected.ensureStillAlive(); - - if (!expected.isString()) { - globalThis.throw("toEndWith() requires the first argument to be a string", .{}); - return .zero; - } - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalThis.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (this.scope.tests.items.len <= this.test_id) { - globalThis.throw("toEndWith() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - var pass = value.isString(); - if (pass) { - const value_string = value.toString(globalThis).toSlice(globalThis, default_allocator).slice(); - const expected_string = expected.toString(globalThis).toSlice(globalThis, default_allocator).slice(); - pass = strings.endsWith(value_string, expected_string) or expected_string.len == 0; - } - - const not = this.op.contains(.not); - if (not) pass = !pass; - - if (pass) return thisValue; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalThis, .quote_strings = true }; - const value_fmt = value.toFmt(globalThis, &formatter); - const expected_fmt = expected.toFmt(globalThis, &formatter); - - if (not) { - const expected_line = "Expected to not end with: {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toEndWith", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected to end with: {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toEndWith", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - globalThis.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - pub fn toBeInstanceOf(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toBeInstanceOf() requires 1 argument", .{}); - return .zero; - } - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toBeInstanceOf() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - - const expected_value = arguments[0]; - if (!expected_value.isConstructor()) { - globalObject.throw("Expected value must be a function: {any}", .{expected_value.toFmt(globalObject, &formatter)}); - return .zero; - } - expected_value.ensureStillAlive(); - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - const not = this.op.contains(.not); - var pass = value.isInstanceOf(globalObject, expected_value); - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - const expected_fmt = expected_value.toFmt(globalObject, &formatter); - const value_fmt = value.toFmt(globalObject, &formatter); - if (not) { - const expected_line = "Expected constructor: not {any}\n"; - const received_line = "Received value: {any}\n"; - const fmt = comptime getSignature("toBeInstanceOf", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{ expected_fmt, value_fmt }); - return .zero; - } - - globalObject.throw(Output.prettyFmt(fmt, false), .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected constructor: {any}\n"; - const received_line = "Received value: {any}\n"; - const fmt = comptime getSignature("toBeInstanceOf", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - globalObject.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - pub fn toMatch(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - JSC.markBinding(@src()); - - defer this.postMatch(globalObject); - - const thisValue = callFrame.this(); - const _arguments = callFrame.arguments(1); - const arguments: []const JSValue = _arguments.ptr[0.._arguments.len]; - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toMatch() must be called in a test", .{}); - return .zero; - } - - if (arguments.len < 1) { - globalObject.throwInvalidArguments("toMatch() requires 1 argument", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - - const expected_value = arguments[0]; - if (!expected_value.isString() and !expected_value.isRegExp()) { - globalObject.throw("Expected value must be a string or regular expression: {any}", .{expected_value.toFmt(globalObject, &formatter)}); - return .zero; - } - expected_value.ensureStillAlive(); - - const value = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - value.ensureStillAlive(); - - if (!value.isString()) { - globalObject.throw("Received value must be a string: {any}", .{value.toFmt(globalObject, &formatter)}); - return .zero; - } - - const not = this.op.contains(.not); - var pass: bool = brk: { - if (expected_value.isString()) { - break :brk value.stringIncludes(globalObject, expected_value); - } else if (expected_value.isRegExp()) { - break :brk expected_value.toMatch(globalObject, value); - } - unreachable; - }; - - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - const expected_fmt = expected_value.toFmt(globalObject, &formatter); - const value_fmt = value.toFmt(globalObject, &formatter); - - if (not) { - const expected_line = "Expected substring or pattern: not {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toMatch", "expected", true) ++ "\n\n" ++ expected_line ++ received_line; - globalObject.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - const expected_line = "Expected substring or pattern: {any}\n"; - const received_line = "Received: {any}\n"; - const fmt = comptime getSignature("toMatch", "expected", false) ++ "\n\n" ++ expected_line ++ received_line; - globalObject.throwPretty(fmt, .{ expected_fmt, value_fmt }); - return .zero; - } - - pub fn toHaveBeenCalled(this: *Expect, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { - JSC.markBinding(@src()); - const thisValue = callframe.this(); - defer this.postMatch(globalObject); - - const value: JSValue = JSC.Jest.Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - - const calls = JSMockFunction__getCalls(value); - active_test_expectation_counter.actual += 1; - - if (calls == .zero or !calls.jsType().isArray()) { - globalObject.throw("Expected value must be a mock function: {}", .{value}); - return .zero; - } - - var pass = calls.getLength(globalObject) > 0; - - const not = this.op.contains(.not); - if (not) pass = !pass; - if (pass) return thisValue; - - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - if (not) { - const signature = comptime getSignature("toHaveBeenCalled", "expected", true); - const fmt = signature ++ "\n\nExpected: not {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{calls.toFmt(globalObject, &formatter)}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{calls.toFmt(globalObject, &formatter)}); - return .zero; - } else { - const signature = comptime getSignature("toHaveBeenCalled", "expected", true); - const fmt = signature ++ "\n\nExpected {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{calls.toFmt(globalObject, &formatter)}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{calls.toFmt(globalObject, &formatter)}); - return .zero; - } - - unreachable; - } - pub fn toHaveBeenCalledTimes(this: *Expect, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { - JSC.markBinding(@src()); - - const thisValue = callframe.this(); - const arguments_ = callframe.arguments(1); - const arguments: []const JSValue = arguments_.ptr[0..arguments_.len]; - defer this.postMatch(globalObject); - const value: JSValue = JSC.Jest.Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; - - active_test_expectation_counter.actual += 1; - - const calls = JSMockFunction__getCalls(value); - - if (calls == .zero or !calls.jsType().isArray()) { - globalObject.throw("Expected value must be a mock function: {}", .{value}); - return .zero; - } + todo, + fail_because_todo_passed, + }; + }; +}; - if (arguments.len < 1 or !arguments[0].isAnyInt()) { - globalObject.throwInvalidArguments("toHaveBeenCalledTimes() requires 1 integer argument", .{}); - return .zero; - } +pub const Jest = struct { + pub var runner: ?*TestRunner = null; - const times = arguments[0].coerce(i32, globalObject); + fn globalHook(comptime name: string) JSC.JSHostFunctionType { + return struct { + pub fn appendGlobalFunctionCallback( + globalThis: *JSC.JSGlobalObject, + callframe: *JSC.CallFrame, + ) callconv(.C) JSValue { + const arguments = callframe.arguments(2); + if (arguments.len < 1) { + globalThis.throwNotEnoughArguments("callback", 1, arguments.len); + return .zero; + } - var pass = @intCast(i32, calls.getLength(globalObject)) == times; + const function = arguments.ptr[0]; + if (function.isEmptyOrUndefinedOrNull() or !function.isCallable(globalThis.vm())) { + globalThis.throwInvalidArgumentType(name, "callback", "function"); + return .zero; + } - const not = this.op.contains(.not); - if (not) pass = !pass; - if (pass) return thisValue; + if (function.getLength(globalThis) > 0) { + globalThis.throw("done() callback is not implemented in global hooks yet. Please make your function take no arguments", .{}); + return .zero; + } - // handle failure - var formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject, .quote_strings = true }; - if (not) { - const signature = comptime getSignature("toHaveBeenCalled", "expected", true); - const fmt = signature ++ "\n\nExpected: not {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{calls.toFmt(globalObject, &formatter)}); - return .zero; - } - globalObject.throw(Output.prettyFmt(fmt, false), .{calls.toFmt(globalObject, &formatter)}); - return .zero; - } else { - const signature = comptime getSignature("toHaveBeenCalled", "expected", true); - const fmt = signature ++ "\n\nExpected {any}\n"; - if (Output.enable_ansi_colors) { - globalObject.throw(Output.prettyFmt(fmt, true), .{calls.toFmt(globalObject, &formatter)}); - return .zero; + function.protect(); + @field(Jest.runner.?.global_callbacks, name).append( + bun.default_allocator, + function, + ) catch unreachable; + return JSC.JSValue.jsUndefined(); } - globalObject.throw(Output.prettyFmt(fmt, false), .{calls.toFmt(globalObject, &formatter)}); - return .zero; - } - - unreachable; + }.appendGlobalFunctionCallback; } - pub fn toMatchObject(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { + pub fn Bun__Jest__createTestPreloadObject(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { JSC.markBinding(@src()); - defer this.postMatch(globalObject); - const thisValue = callFrame.this(); - const args = callFrame.arguments(1).slice(); - - if (this.scope.tests.items.len <= this.test_id) { - globalObject.throw("toMatchObject() must be called in a test", .{}); - return .zero; - } - - active_test_expectation_counter.actual += 1; - - const not = this.op.contains(.not); - - const received_object = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; + var global_hooks_object = JSC.JSValue.createEmptyObject(globalObject, 8); + global_hooks_object.ensureStillAlive(); - if (!received_object.isObject()) { - const matcher_error = "\n\nMatcher error: received value must be a non-null object\n"; - if (not) { - const fmt = comptime getSignature("toMatchObject", "expected", true) ++ matcher_error; - globalObject.throwPretty(fmt, .{}); + const notSupportedHereFn = struct { + pub fn notSupportedHere( + globalThis: *JSC.JSGlobalObject, + _: *JSC.CallFrame, + ) callconv(.C) JSValue { + globalThis.throw("This function can only be used in a test.", .{}); return .zero; } + }.notSupportedHere; + const notSupportedHere = JSC.NewFunction(globalObject, null, 0, notSupportedHereFn, false); + notSupportedHere.ensureStillAlive(); - const fmt = comptime getSignature("toMatchObject", "expected", false) ++ matcher_error; - globalObject.throwPretty(fmt, .{}); - return .zero; + inline for (.{ + "expect", + "describe", + "it", + "test", + }) |name| { + global_hooks_object.put(globalObject, ZigString.static(name), notSupportedHere); } - if (args.len < 1 or !args[0].isObject()) { - const matcher_error = "\n\nMatcher error: expected value must be a non-null object\n"; - if (not) { - const fmt = comptime getSignature("toMatchObject", "expected", true) ++ matcher_error; - globalObject.throwPretty(fmt, .{}); - return .zero; - } - const fmt = comptime getSignature("toMatchObject", "expected", false) ++ matcher_error; - globalObject.throwPretty(fmt, .{}); - return .zero; + inline for (.{ "beforeAll", "beforeEach", "afterAll", "afterEach" }) |name| { + const function = JSC.NewFunction(globalObject, null, 1, globalHook(name), false); + function.ensureStillAlive(); + global_hooks_object.put(globalObject, ZigString.static(name), function); } + return global_hooks_object; + } - const property_matchers = args[0]; - - var pass = received_object.jestDeepMatch(property_matchers, globalObject, true); + pub fn Bun__Jest__createTestModuleObject(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { + JSC.markBinding(@src()); - if (not) pass = !pass; - if (pass) return thisValue; + const module = JSC.JSValue.createEmptyObject(globalObject, 11); - // handle failure - const diff_formatter = DiffFormatter{ - .received = received_object, - .expected = property_matchers, - .globalObject = globalObject, - .not = not, - }; + const test_fn = JSC.NewFunction(globalObject, ZigString.static("test"), 2, TestScope.call, false); + module.put( + globalObject, + ZigString.static("test"), + test_fn, + ); + test_fn.put( + globalObject, + ZigString.static("only"), + JSC.NewFunction(globalObject, ZigString.static("only"), 2, TestScope.only, false), + ); + test_fn.put( + globalObject, + ZigString.static("skip"), + JSC.NewFunction(globalObject, ZigString.static("skip"), 2, TestScope.skip, false), + ); + test_fn.put( + globalObject, + ZigString.static("todo"), + JSC.NewFunction(globalObject, ZigString.static("todo"), 2, TestScope.todo, false), + ); + test_fn.put( + globalObject, + ZigString.static("if"), + JSC.NewFunction(globalObject, ZigString.static("if"), 2, TestScope.callIf, false), + ); + test_fn.put( + globalObject, + ZigString.static("skipIf"), + JSC.NewFunction(globalObject, ZigString.static("skipIf"), 2, TestScope.skipIf, false), + ); - if (not) { - const signature = comptime getSignature("toMatchObject", "expected", true); - const fmt = signature ++ "\n\n{any}\n"; - globalObject.throwPretty(fmt, .{diff_formatter}); - return .zero; - } + module.put( + globalObject, + ZigString.static("it"), + test_fn, + ); + const describe = JSC.NewFunction(globalObject, ZigString.static("describe"), 2, DescribeScope.call, false); + describe.put( + globalObject, + ZigString.static("only"), + JSC.NewFunction(globalObject, ZigString.static("only"), 2, DescribeScope.only, false), + ); + describe.put( + globalObject, + ZigString.static("skip"), + JSC.NewFunction(globalObject, ZigString.static("skip"), 2, DescribeScope.skip, false), + ); + describe.put( + globalObject, + ZigString.static("todo"), + JSC.NewFunction(globalObject, ZigString.static("todo"), 2, DescribeScope.todo, false), + ); + describe.put( + globalObject, + ZigString.static("if"), + JSC.NewFunction(globalObject, ZigString.static("if"), 2, DescribeScope.callIf, false), + ); + describe.put( + globalObject, + ZigString.static("skipIf"), + JSC.NewFunction(globalObject, ZigString.static("skipIf"), 2, DescribeScope.skipIf, false), + ); - const signature = comptime getSignature("toMatchObject", "expected", false); - const fmt = signature ++ "\n\n{any}\n"; - globalObject.throwPretty(fmt, .{diff_formatter}); - return .zero; - } + module.put( + globalObject, + ZigString.static("describe"), + describe, + ); - pub const toHaveBeenCalledWith = notImplementedJSCFn; - pub const toHaveBeenLastCalledWith = notImplementedJSCFn; - pub const toHaveBeenNthCalledWith = notImplementedJSCFn; - pub const toHaveReturnedTimes = notImplementedJSCFn; - pub const toHaveReturnedWith = notImplementedJSCFn; - pub const toHaveLastReturnedWith = notImplementedJSCFn; - pub const toHaveNthReturnedWith = notImplementedJSCFn; - pub const toContainEqual = notImplementedJSCFn; - pub const toMatchInlineSnapshot = notImplementedJSCFn; - pub const toThrowErrorMatchingSnapshot = notImplementedJSCFn; - pub const toThrowErrorMatchingInlineSnapshot = notImplementedJSCFn; - - pub const getStaticNot = notImplementedStaticProp; - pub const getStaticResolves = notImplementedStaticProp; - pub const getStaticRejects = notImplementedStaticProp; - - pub fn getNot(this: *Expect, thisValue: JSValue, globalObject: *JSGlobalObject) callconv(.C) JSValue { - _ = Expect.capturedValueGetCached(thisValue) orelse { - globalObject.throw("Internal consistency error: the expect(value) was garbage collected but it should not have been!", .{}); - return .zero; - }; + module.put( + globalObject, + ZigString.static("beforeAll"), + JSC.NewRuntimeFunction(globalObject, ZigString.static("beforeAll"), 1, DescribeScope.beforeAll, false), + ); + module.put( + globalObject, + ZigString.static("beforeEach"), + JSC.NewRuntimeFunction(globalObject, ZigString.static("beforeEach"), 1, DescribeScope.beforeEach, false), + ); + module.put( + globalObject, + ZigString.static("afterAll"), + JSC.NewRuntimeFunction(globalObject, ZigString.static("afterAll"), 1, DescribeScope.afterAll, false), + ); + module.put( + globalObject, + ZigString.static("afterEach"), + JSC.NewRuntimeFunction(globalObject, ZigString.static("afterEach"), 1, DescribeScope.afterEach, false), + ); + module.put( + globalObject, + ZigString.static("expect"), + Expect.getConstructor(globalObject), + ); - this.op.toggle(.not); + const mock_fn = JSMockFunction__createObject(globalObject); + const spyOn = JSC.NewFunction(globalObject, ZigString.static("spyOn"), 2, JSMock__spyOn, false); + const restoreAllMocks = JSC.NewFunction(globalObject, ZigString.static("restoreAllMocks"), 2, jsFunctionResetSpies, false); + module.put(globalObject, ZigString.static("mock"), mock_fn); - return thisValue; - } + const jest = JSValue.createEmptyObject(globalObject, 3); + jest.put(globalObject, ZigString.static("fn"), mock_fn); + jest.put(globalObject, ZigString.static("spyOn"), spyOn); + jest.put(globalObject, ZigString.static("restoreAllMocks"), restoreAllMocks); + module.put(globalObject, ZigString.static("jest"), jest); + module.put(globalObject, ZigString.static("spyOn"), spyOn); - pub const getResolves = notImplementedJSCProp; - pub const getRejects = notImplementedJSCProp; + const vi = JSValue.createEmptyObject(globalObject, 1); + vi.put(globalObject, ZigString.static("fn"), mock_fn); + module.put(globalObject, ZigString.static("vi"), vi); - pub fn any(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - return ExpectAny.call(globalObject, callFrame); + return module; } - pub fn anything(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - return ExpectAnything.call(globalObject, callFrame); - } + extern fn JSMockFunction__createObject(*JSC.JSGlobalObject) JSC.JSValue; - pub fn stringContaining(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - return ExpectStringContaining.call(globalObject, callFrame); - } + extern fn Bun__Jest__testPreloadObject(*JSC.JSGlobalObject) JSC.JSValue; + extern fn Bun__Jest__testModuleObject(*JSC.JSGlobalObject) JSC.JSValue; + extern fn jsFunctionResetSpies(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; + extern fn JSMock__spyOn(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; - pub fn stringMatching(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue { - return ExpectStringMatching.call(globalObject, callFrame); - } + pub fn call( + _: void, + ctx: js.JSContextRef, + _: js.JSObjectRef, + _: js.JSObjectRef, + arguments_: []const js.JSValueRef, + exception: js.ExceptionRef, + ) js.JSValueRef { + JSC.markBinding(@src()); + var runner_ = runner orelse { + JSError(getAllocator(ctx), "Run \"bun test\" to run a test", .{}, ctx, exception); + return js.JSValueMakeUndefined(ctx); + }; + const arguments = @ptrCast([]const JSC.JSValue, arguments_); - pub const extend = notImplementedStaticFn; - pub const arrayContaining = notImplementedStaticFn; - pub const assertions = notImplementedStaticFn; - pub const hasAssertions = notImplementedStaticFn; - pub const objectContaining = notImplementedStaticFn; - pub const addSnapshotSerializer = notImplementedStaticFn; + if (arguments.len < 1 or !arguments[0].isString()) { + JSError(getAllocator(ctx), "Bun.jest() expects a string filename", .{}, ctx, exception); + return js.JSValueMakeUndefined(ctx); + } + var str = arguments[0].toSlice(ctx, bun.default_allocator); + defer str.deinit(); + var slice = str.slice(); - pub fn notImplementedJSCFn(_: *Expect, globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { - globalObject.throw("Not implemented", .{}); - return .zero; - } + if (str.len == 0 or slice[0] != '/') { + JSError(getAllocator(ctx), "Bun.jest() expects an absolute file path", .{}, ctx, exception); + return js.JSValueMakeUndefined(ctx); + } + var vm = ctx.bunVM(); + if (vm.is_in_preload) { + return Bun__Jest__testPreloadObject(ctx).asObjectRef(); + } - pub fn notImplementedStaticFn(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { - globalObject.throw("Not implemented", .{}); - return .zero; - } + var filepath = Fs.FileSystem.instance.filename_store.append([]const u8, slice) catch unreachable; - pub fn notImplementedJSCProp(_: *Expect, _: JSC.JSValue, globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { - globalObject.throw("Not implemented", .{}); - return .zero; - } + var scope = runner_.getOrPutFile(filepath); + DescribeScope.active = scope; + DescribeScope.module = scope; - pub fn notImplementedStaticProp(globalObject: *JSC.JSGlobalObject, _: JSC.JSValue, _: JSC.JSValue) callconv(.C) JSC.JSValue { - globalObject.throw("Not implemented", .{}); - return .zero; + return Bun__Jest__testModuleObject(ctx).asObjectRef(); } - pub fn postMatch(_: *Expect, globalObject: *JSC.JSGlobalObject) void { - var vm = globalObject.bunVM(); - vm.autoGarbageCollect(); + comptime { + if (!JSC.is_bindgen) { + @export(Bun__Jest__createTestModuleObject, .{ .name = "Bun__Jest__createTestModuleObject" }); + @export(Bun__Jest__createTestPreloadObject, .{ .name = "Bun__Jest__createTestPreloadObject" }); + } } }; @@ -4338,7 +554,7 @@ pub const TestScope = struct { const err = arguments.ptr[0]; globalThis.bunVM().runErrorHandler(err, null); var task: *TestRunnerTask = arguments.ptr[1].asPromisePtr(TestRunnerTask); - task.handleResult(.{ .fail = active_test_expectation_counter.actual }, .promise); + task.handleResult(.{ .fail = expect.active_test_expectation_counter.actual }, .promise); globalThis.bunVM().autoGarbageCollect(); return JSValue.jsUndefined(); } @@ -4346,7 +562,7 @@ pub const TestScope = struct { pub fn onResolve(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue { const arguments = callframe.arguments(2); var task: *TestRunnerTask = arguments.ptr[1].asPromisePtr(TestRunnerTask); - task.handleResult(.{ .pass = active_test_expectation_counter.actual }, .promise); + task.handleResult(.{ .pass = expect.active_test_expectation_counter.actual }, .promise); globalThis.bunVM().autoGarbageCollect(); return JSValue.jsUndefined(); } @@ -4365,13 +581,13 @@ pub const TestScope = struct { if (args.len > 0) { const err = args.ptr[0]; if (err.isEmptyOrUndefinedOrNull()) { - task.handleResult(.{ .pass = active_test_expectation_counter.actual }, .callback); + task.handleResult(.{ .pass = expect.active_test_expectation_counter.actual }, .callback); } else { globalThis.bunVM().runErrorHandlerWithDedupe(err, null); - task.handleResult(.{ .fail = active_test_expectation_counter.actual }, .callback); + task.handleResult(.{ .fail = expect.active_test_expectation_counter.actual }, .callback); } } else { - task.handleResult(.{ .pass = active_test_expectation_counter.actual }, .callback); + task.handleResult(.{ .pass = expect.active_test_expectation_counter.actual }, .callback); } } @@ -4432,7 +648,7 @@ pub const TestScope = struct { return .{ .todo = {} }; } - return .{ .fail = active_test_expectation_counter.actual }; + return .{ .fail = expect.active_test_expectation_counter.actual }; } if (initial_value.asAnyPromise()) |promise| { @@ -4459,7 +675,7 @@ pub const TestScope = struct { return .{ .todo = {} }; } - return .{ .fail = active_test_expectation_counter.actual }; + return .{ .fail = expect.active_test_expectation_counter.actual }; }, .Pending => { task.promise_state = .pending; @@ -4481,15 +697,15 @@ pub const TestScope = struct { return .{ .pending = {} }; } - if (active_test_expectation_counter.expected > 0 and active_test_expectation_counter.expected < active_test_expectation_counter.actual) { + if (expect.active_test_expectation_counter.expected > 0 and expect.active_test_expectation_counter.expected < expect.active_test_expectation_counter.actual) { Output.prettyErrorln("Test fail: {d} / {d} expectations\n (make this better!)", .{ - active_test_expectation_counter.actual, - active_test_expectation_counter.expected, + expect.active_test_expectation_counter.actual, + expect.active_test_expectation_counter.expected, }); - return .{ .fail = active_test_expectation_counter.actual }; + return .{ .fail = expect.active_test_expectation_counter.actual }; } - return .{ .pass = active_test_expectation_counter.actual }; + return .{ .pass = expect.active_test_expectation_counter.actual }; } pub const name = "TestScope"; @@ -4876,8 +1092,6 @@ pub const DescribeScope = struct { }; -var active_test_expectation_counter: TestScope.Counter = undefined; - pub const TestRunnerTask = struct { test_id: TestRunner.Test.ID, describe: *DescribeScope, @@ -4920,7 +1134,7 @@ pub const TestRunnerTask = struct { if (jsc_vm.onUnhandledRejectionCtx) |ctx| { var this = bun.cast(*TestRunnerTask, ctx); jsc_vm.onUnhandledRejectionCtx = null; - this.handleResult(.{ .fail = active_test_expectation_counter.actual }, .unhandledRejection); + this.handleResult(.{ .fail = expect.active_test_expectation_counter.actual }, .unhandledRejection); } } @@ -4932,7 +1146,7 @@ pub const TestRunnerTask = struct { // reset the global state for each test // prior to the run DescribeScope.active = describe; - active_test_expectation_counter = .{}; + expect.active_test_expectation_counter = .{}; jsc_vm.last_reported_error_for_dedupe = .zero; const test_id = this.test_id; @@ -4999,7 +1213,7 @@ pub const TestRunnerTask = struct { this.ref.unref(this.globalThis.bunVM()); this.globalThis.throwTerminationException(); - this.handleResult(.{ .fail = active_test_expectation_counter.actual }, .timeout); + this.handleResult(.{ .fail = expect.active_test_expectation_counter.actual }, .timeout); } pub fn handleResult(this: *TestRunnerTask, result: Result, comptime from: @Type(.EnumLiteral)) void { @@ -5404,11 +1618,3 @@ pub fn printGithubAnnotation(exception: *JSC.ZigException) void { Output.printError("\n", .{}); Output.flush(); } - -/// JSValue.zero is used to indicate it was not a JSMockFunction -/// If there were no calls, it returns an empty JSArray* -extern fn JSMockFunction__getCalls(JSValue) JSValue; - -/// JSValue.zero is used to indicate it was not a JSMockFunction -/// If there were no calls, it returns an empty JSArray* -extern fn JSMockFunction__getReturns(JSValue) JSValue; diff --git a/src/bun.js/test/pretty_format.zig b/src/bun.js/test/pretty_format.zig index 29e330a04..4a245c3bb 100644 --- a/src/bun.js/test/pretty_format.zig +++ b/src/bun.js/test/pretty_format.zig @@ -15,6 +15,7 @@ const JSPrinter = bun.js_printer; const JSPrivateDataPtr = JSC.JSPrivateDataPtr; const JS = @import("../javascript.zig"); const JSPromise = JSC.JSPromise; +const expect = @import("./expect.zig"); pub const EventType = enum(u8) { Event, @@ -1264,12 +1265,12 @@ pub const JestPrettyFormat = struct { } else if (value.as(JSC.ResolveMessage)) |resolve_log| { resolve_log.msg.writeFormat(writer_, enable_ansi_colors) catch {}; return; - } else if (value.as(JSC.Jest.ExpectAnything) != null) { + } else if (value.as(expect.ExpectAnything) != null) { this.addForNewLine("Anything".len); writer.writeAll("Anything"); return; - } else if (value.as(JSC.Jest.ExpectAny) != null) { - const constructor_value = JSC.Jest.ExpectAny.constructorValueGetCached(value) orelse return; + } else if (value.as(expect.ExpectAny) != null) { + const constructor_value = expect.ExpectAny.constructorValueGetCached(value) orelse return; this.addForNewLine("Any<".len); writer.writeAll("Any<"); @@ -1281,16 +1282,16 @@ pub const JestPrettyFormat = struct { writer.writeAll(">"); return; - } else if (value.as(JSC.Jest.ExpectStringContaining) != null) { - const substring_value = JSC.Jest.ExpectStringContaining.stringValueGetCached(value) orelse return; + } else if (value.as(expect.ExpectStringContaining) != null) { + const substring_value = expect.ExpectStringContaining.stringValueGetCached(value) orelse return; this.addForNewLine("StringContaining ".len); writer.writeAll("StringContaining "); this.printAs(.String, Writer, writer_, substring_value, .String, enable_ansi_colors); return; - } else if (value.as(JSC.Jest.ExpectStringMatching) != null) { - const test_value = JSC.Jest.ExpectStringMatching.testValueGetCached(value) orelse return; + } else if (value.as(expect.ExpectStringMatching) != null) { + const test_value = expect.ExpectStringMatching.testValueGetCached(value) orelse return; this.addForNewLine("StringMatching ".len); writer.writeAll("StringMatching "); diff --git a/src/bun.js/test/snapshot.zig b/src/bun.js/test/snapshot.zig new file mode 100644 index 000000000..12c7b3c36 --- /dev/null +++ b/src/bun.js/test/snapshot.zig @@ -0,0 +1,284 @@ +const std = @import("std"); +const bun = @import("root").bun; +const default_allocator = bun.default_allocator; +const string = bun.string; +const MutableString = bun.MutableString; +const strings = bun.strings; +const logger = bun.logger; +const jest = @import("./jest.zig"); +const Jest = jest.Jest; +const TestRunner = jest.TestRunner; +const js_parser = bun.js_parser; +const js_ast = bun.JSAst; +const JSC = bun.JSC; +const JSValue = JSC.JSValue; +const VirtualMachine = JSC.VirtualMachine; +const Expect = @import("./expect.zig").Expect; + +pub const Snapshots = struct { + const file_header = "// Bun Snapshot v1, https://goo.gl/fbAQLP\n"; + pub const ValuesHashMap = std.HashMap(usize, string, bun.IdentityContext(usize), std.hash_map.default_max_load_percentage); + + allocator: std.mem.Allocator, + update_snapshots: bool, + total: usize = 0, + added: usize = 0, + passed: usize = 0, + failed: usize = 0, + + file_buf: *std.ArrayList(u8), + values: *ValuesHashMap, + counts: *bun.StringHashMap(usize), + _current_file: ?File = null, + snapshot_dir_path: ?string = null, + + const File = struct { + id: TestRunner.File.ID, + file: std.fs.File, + }; + + pub fn getOrPut(this: *Snapshots, expect: *Expect, value: JSValue, hint: string, globalObject: *JSC.JSGlobalObject) !?string { + switch (try this.getSnapshotFile(expect.scope.file_id)) { + .result => {}, + .err => |err| { + return switch (err.syscall) { + .mkdir => error.FailedToMakeSnapshotDirectory, + .open => error.FailedToOpenSnapshotFile, + else => error.SnapshotFailed, + }; + }, + } + + const snapshot_name = try expect.getSnapshotName(this.allocator, hint); + this.total += 1; + + var count_entry = try this.counts.getOrPut(snapshot_name); + const counter = brk: { + if (count_entry.found_existing) { + this.allocator.free(snapshot_name); + count_entry.value_ptr.* += 1; + break :brk count_entry.value_ptr.*; + } + count_entry.value_ptr.* = 1; + break :brk count_entry.value_ptr.*; + }; + + const name = count_entry.key_ptr.*; + + var counter_string_buf = [_]u8{0} ** 32; + var counter_string = try std.fmt.bufPrint(&counter_string_buf, "{d}", .{counter}); + + var name_with_counter = try this.allocator.alloc(u8, name.len + 1 + counter_string.len); + defer this.allocator.free(name_with_counter); + bun.copy(u8, name_with_counter[0..name.len], name); + name_with_counter[name.len] = ' '; + bun.copy(u8, name_with_counter[name.len + 1 ..], counter_string); + + const name_hash = bun.hash(name_with_counter); + if (this.values.get(name_hash)) |expected| { + return expected; + } + + // doesn't exist. append to file bytes and add to hashmap. + var pretty_value = try MutableString.init(this.allocator, 0); + try value.jestSnapshotPrettyFormat(&pretty_value, globalObject); + + const serialized_length = "\nexports[`".len + name_with_counter.len + "`] = `".len + pretty_value.list.items.len + "`;\n".len; + try this.file_buf.ensureUnusedCapacity(serialized_length); + this.file_buf.appendSliceAssumeCapacity("\nexports[`"); + this.file_buf.appendSliceAssumeCapacity(name_with_counter); + this.file_buf.appendSliceAssumeCapacity("`] = `"); + this.file_buf.appendSliceAssumeCapacity(pretty_value.list.items); + this.file_buf.appendSliceAssumeCapacity("`;\n"); + + this.added += 1; + try this.values.put(name_hash, pretty_value.toOwnedSlice()); + return null; + } + + pub fn parseFile(this: *Snapshots) !void { + if (this.file_buf.items.len == 0) return; + + const vm = VirtualMachine.get(); + var opts = js_parser.Parser.Options.init(vm.bundler.options.jsx, .js); + var temp_log = logger.Log.init(this.allocator); + + const test_file = Jest.runner.?.files.get(this._current_file.?.id); + const test_filename = test_file.source.path.name.filename; + const dir_path = test_file.source.path.name.dirWithTrailingSlash(); + + var snapshot_file_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + var remain: []u8 = snapshot_file_path_buf[0..bun.MAX_PATH_BYTES]; + bun.copy(u8, remain, dir_path); + remain = remain[dir_path.len..]; + bun.copy(u8, remain, "__snapshots__/"); + remain = remain["__snapshots__/".len..]; + bun.copy(u8, remain, test_filename); + remain = remain[test_filename.len..]; + bun.copy(u8, remain, ".snap"); + remain = remain[".snap".len..]; + remain[0] = 0; + const snapshot_file_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0]; + + const source = logger.Source.initPathString(snapshot_file_path, this.file_buf.items); + + var parser = try js_parser.Parser.init( + opts, + &temp_log, + &source, + vm.bundler.options.define, + this.allocator, + ); + + var parse_result = try parser.parse(); + var ast = if (parse_result == .ast) parse_result.ast else return error.ParseError; + defer ast.deinit(); + + if (ast.exports_ref.isNull()) return; + const exports_ref = ast.exports_ref; + + // TODO: when common js transform changes, keep this updated or add flag to support this version + + const export_default = brk: { + for (ast.parts.slice()) |part| { + for (part.stmts) |stmt| { + if (stmt.data == .s_export_default and stmt.data.s_export_default.value == .expr) { + break :brk stmt.data.s_export_default.value.expr; + } + } + } + + return; + }; + + if (export_default.data == .e_call) { + const function_call = export_default.data.e_call; + if (function_call.args.len == 2 and function_call.args.ptr[0].data == .e_function) { + const arg_function_stmts = function_call.args.ptr[0].data.e_function.func.body.stmts; + for (arg_function_stmts) |stmt| { + switch (stmt.data) { + .s_expr => |expr| { + if (expr.value.data == .e_binary and expr.value.data.e_binary.op == .bin_assign) { + const left = expr.value.data.e_binary.left; + if (left.data == .e_index and left.data.e_index.index.data == .e_string and left.data.e_index.target.data == .e_identifier) { + const target: js_ast.E.Identifier = left.data.e_index.target.data.e_identifier; + var index: *js_ast.E.String = left.data.e_index.index.data.e_string; + if (target.ref.eql(exports_ref) and expr.value.data.e_binary.right.data == .e_string) { + const key = index.slice(this.allocator); + var value_string = expr.value.data.e_binary.right.data.e_string; + const value = value_string.slice(this.allocator); + defer { + if (!index.isUTF8()) this.allocator.free(key); + if (!value_string.isUTF8()) this.allocator.free(value); + } + const value_clone = try this.allocator.alloc(u8, value.len); + bun.copy(u8, value_clone, value); + const name_hash = bun.hash(key); + try this.values.put(name_hash, value_clone); + } + } + } + }, + else => {}, + } + } + } + } + } + + pub fn writeSnapshotFile(this: *Snapshots) !void { + if (this._current_file) |_file| { + var file = _file; + file.file.writeAll(this.file_buf.items) catch { + return error.FailedToWriteSnapshotFile; + }; + file.file.close(); + this.file_buf.clearAndFree(); + + var value_itr = this.values.valueIterator(); + while (value_itr.next()) |value| { + this.allocator.free(value.*); + } + this.values.clearAndFree(); + + var count_key_itr = this.counts.keyIterator(); + while (count_key_itr.next()) |key| { + this.allocator.free(key.*); + } + this.counts.clearAndFree(); + } + } + + fn getSnapshotFile(this: *Snapshots, file_id: TestRunner.File.ID) !JSC.Maybe(void) { + if (this._current_file == null or this._current_file.?.id != file_id) { + try this.writeSnapshotFile(); + + const test_file = Jest.runner.?.files.get(file_id); + const test_filename = test_file.source.path.name.filename; + const dir_path = test_file.source.path.name.dirWithTrailingSlash(); + + var snapshot_file_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + var remain: []u8 = snapshot_file_path_buf[0..bun.MAX_PATH_BYTES]; + bun.copy(u8, remain, dir_path); + remain = remain[dir_path.len..]; + bun.copy(u8, remain, "__snapshots__/"); + remain = remain["__snapshots__/".len..]; + + if (this.snapshot_dir_path == null or !strings.eqlLong(dir_path, this.snapshot_dir_path.?, true)) { + remain[0] = 0; + const snapshot_dir_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0]; + switch (JSC.Node.Syscall.mkdir(snapshot_dir_path, 0o777)) { + .result => this.snapshot_dir_path = dir_path, + .err => |err| { + switch (err.getErrno()) { + std.os.E.EXIST => this.snapshot_dir_path = dir_path, + else => return JSC.Maybe(void){ + .err = err, + }, + } + }, + } + } + + bun.copy(u8, remain, test_filename); + remain = remain[test_filename.len..]; + bun.copy(u8, remain, ".snap"); + remain = remain[".snap".len..]; + remain[0] = 0; + const snapshot_file_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0]; + + var flags: JSC.Node.Mode = std.os.O.CREAT | std.os.O.RDWR; + if (this.update_snapshots) flags |= std.os.O.TRUNC; + const fd = switch (JSC.Node.Syscall.open(snapshot_file_path, flags, 0o644)) { + .result => |_fd| _fd, + .err => |err| return JSC.Maybe(void){ + .err = err, + }, + }; + + var file: File = .{ + .id = file_id, + .file = .{ .handle = fd }, + }; + + if (this.update_snapshots) { + try this.file_buf.appendSlice(file_header); + } else { + const length = try file.file.getEndPos(); + if (length == 0) { + try this.file_buf.appendSlice(file_header); + } else { + const buf = try this.allocator.alloc(u8, length); + _ = try file.file.preadAll(buf, 0); + try this.file_buf.appendSlice(buf); + this.allocator.free(buf); + } + } + + this._current_file = file; + try this.parseFile(); + } + + return JSC.Maybe(void).success; + } +}; diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index b7712c0de..445473839 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -41,7 +41,7 @@ const HTTPThread = @import("root").bun.HTTP.HTTPThread; const JSC = @import("root").bun.JSC; const jest = JSC.Jest; const TestRunner = JSC.Jest.TestRunner; -const Snapshots = JSC.Jest.Snapshots; +const Snapshots = JSC.Snapshot.Snapshots; const Test = TestRunner.Test; const NetworkThread = @import("root").bun.HTTP.NetworkThread; const uws = @import("root").bun.uws; diff --git a/src/jsc.zig b/src/jsc.zig index 26ad7cc5f..67cf3f05c 100644 --- a/src/jsc.zig +++ b/src/jsc.zig @@ -26,6 +26,8 @@ pub const Cloudflare = struct { pub const AttributeIterator = @import("./bun.js/api/html_rewriter.zig").AttributeIterator; }; pub const Jest = @import("./bun.js/test/jest.zig"); +pub const Expect = @import("./bun.js/test/expect.zig"); +pub const Snapshot = @import("./bun.js/test/snapshot.zig"); pub const API = struct { pub const JSBundler = @import("./bun.js/api/JSBundler.zig").JSBundler; pub const BuildArtifact = @import("./bun.js/api/JSBundler.zig").BuildArtifact; diff --git a/test/cli/test/bun-test.test.ts b/test/cli/test/bun-test.test.ts index 47ea17db3..534c17513 100644 --- a/test/cli/test/bun-test.test.ts +++ b/test/cli/test/bun-test.test.ts @@ -192,14 +192,34 @@ describe("bun test", () => { }); expect(stderr).toContain("Invalid timeout"); }); + test("timeout can be set to 0ms", () => { + const stderr = runTest({ + args: ["--timeout", "0"], + input: ` + import { test, expect } from "bun:test"; + import { sleep } from "bun"; + test("ok", async () => { + await expect(Promise.resolve()).resolves.toBeUndefined(); + await expect(Promise.reject()).rejects.toBeUndefined(); + }); + test("timeout", async () => { + await expect(sleep(1)).resolves.toBeUndefined(); + }); + `, + }); + expect(stderr).toContain("timed out after 0ms"); + }); test("timeout can be set to 1ms", () => { const stderr = runTest({ args: ["--timeout", "1"], input: ` import { test, expect } from "bun:test"; import { sleep } from "bun"; + test("ok", async () => { + await expect(sleep(1)).resolves.toBeUndefined(); + }); test("timeout", async () => { - await sleep(2); + await expect(sleep(2)).resolves.toBeUndefined(); }); `, }); -- cgit v1.2.3 From 4ff920c915403dd7abac18c6a80a7b9c468ee52b Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Fri, 23 Jun 2023 22:19:00 -0300 Subject: fixup min/memcopy (#3388) --- src/deps/c_ares.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deps/c_ares.zig b/src/deps/c_ares.zig index 79591899e..7813ff5e4 100644 --- a/src/deps/c_ares.zig +++ b/src/deps/c_ares.zig @@ -515,7 +515,7 @@ pub const Channel = opaque { if (name.len == 0 or name.len >= 1023) { break :brk null; } - const len = @min(name_buf.len, name_buf.len - 1); + const len = @min(name.len, name_buf.len - 1); @memcpy(name_buf[0..len], name[0..len]); name_buf[len] = 0; -- cgit v1.2.3 From 5ae8e5d773c6b57fe166681ffa9cdc153f69427b Mon Sep 17 00:00:00 2001 From: dave caruso Date: Sat, 24 Jun 2023 02:23:39 -0400 Subject: Make node-fallbacks build as esm not cjs / Fix `node-fetch` (#3377) * Make node-fallbacks build as esm not cjs. * fix stuff --- src/js/out/WebCoreJSBuiltins.cpp | 132 ++++++++++++++-------------- src/js/out/modules/node/crypto.js | 8 +- src/js/out/modules/node/http.js | 3 +- src/js/out/modules/node/net.js | 4 +- src/js/out/modules/node/path.js | 2 +- src/js/out/modules/node/path.posix.js | 2 +- src/js/out/modules/node/stream.consumers.js | 2 +- src/js/out/modules/node/stream.js | 4 +- src/js/out/modules/node/stream.web.js | 2 +- src/node-fallbacks/@vercel_fetch.js | 2 +- src/node-fallbacks/buffer.js | 1 + src/node-fallbacks/console.js | 2 +- src/node-fallbacks/crypto.js | 11 +++ src/node-fallbacks/domain.js | 4 +- src/node-fallbacks/http.js | 14 ++- src/node-fallbacks/https.js | 1 + src/node-fallbacks/node-fetch.js | 1 - src/node-fallbacks/os.js | 21 ++++- src/node-fallbacks/package.json | 4 +- src/node-fallbacks/path.js | 1 + src/node-fallbacks/process.js | 1 + src/node-fallbacks/querystring.js | 3 +- src/node-fallbacks/stream.js | 1 + src/node-fallbacks/string_decoder.js | 1 + src/node-fallbacks/sys.js | 1 + src/node-fallbacks/timers.js | 1 + src/node-fallbacks/tsconfig.json | 2 +- src/node-fallbacks/tty.js | 1 + src/node-fallbacks/util.js | 1 + src/node-fallbacks/zlib.js | 1 + src/node_fallbacks.zig | 54 ++++++------ test/js/node/fs/node-fetch.test.js | 14 ++- 32 files changed, 186 insertions(+), 116 deletions(-) diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index 1fecb34e3..455a0a3a4 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 (f,o){\"use strict\";const w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; +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"; // initializeWritableStreamSlots const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = 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 (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"; +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"; // 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 (d,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const W=@getByIdDirectPrivate(P,\"controller\");@assert(W!==@undefined);const _=@writableStreamDefaultControllerGetChunkSize(W,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const b=@getByIdDirectPrivate(P,\"state\");if(b===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(b===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(b===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(W,g,_),f})\n"; +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"; // setUpWritableStreamDefaultController const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 573; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,P,_,f,j){\"use strict\";const p=new @WritableStreamDefaultController;let q=()=>{},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()};if(\"start\"in _){const E=_[\"start\"];q=()=>@promiseInvokeOrNoopMethodNoCatch(P,E,[p])}if(\"write\"in _){const E=_[\"write\"];x=(F)=>@promiseInvokeOrNoopMethod(P,E,[F,p])}if(\"close\"in _){const E=_[\"close\"];B=()=>@promiseInvokeOrNoopMethod(P,E,[])}if(\"abort\"in _){const E=_[\"abort\"];C=(F)=>@promiseInvokeOrNoopMethod(P,E,[F])}@setUpWritableStreamDefaultController(v,p,q,x,B,C,f,j)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,q,P,_,j){\"use strict\";const p=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},f=()=>{return @Promise.@resolve()};if(\"start\"in P){const E=P[\"start\"];x=()=>@promiseInvokeOrNoopMethodNoCatch(q,E,[p])}if(\"write\"in P){const E=P[\"write\"];B=(F)=>@promiseInvokeOrNoopMethod(q,E,[F,p])}if(\"close\"in P){const E=P[\"close\"];C=()=>@promiseInvokeOrNoopMethod(q,E,[])}if(\"abort\"in P){const E=P[\"abort\"];f=(F)=>@promiseInvokeOrNoopMethod(q,E,[F])}@setUpWritableStreamDefaultController(v,p,x,B,C,f,_,j)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = 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 (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"; +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"; #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 (_,c,j,q,v,x,B){\"use strict\";if(q===@undefined)q=1;if(v===@undefined)v=()=>1;if(x===@undefined)x=0;if(B===@undefined)B=()=>1;@assert(q>=0),@assert(x>=0);const D={};@putByIdDirectPrivate(D,\"TransformStream\",!0);const E=new @TransformStream(D),F=@newPromiseCapability(@Promise);@initializeTransformStream(E,F.@promise,q,v,x,B);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(E,G,c,j),_().@then(()=>{F.@resolve.@call()},(I)=>{F.@reject.@call(@undefined,I)}),E})\n"; +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"; // 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 (f,B,T,j,q,v){\"use strict\";const x=()=>{return B},C=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,N)},D=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,N)},E=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},F=@createWritableStream(x,C,E,D,T,j),G=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},I=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(f,N),@Promise.@resolve()},J={};@putByIdDirectPrivate(J,\"start\",x),@putByIdDirectPrivate(J,\"pull\",G),@putByIdDirectPrivate(J,\"cancel\",I);const K={};@putByIdDirectPrivate(K,\"size\",v),@putByIdDirectPrivate(K,\"highWaterMark\",q);const L=new @ReadableStream(J,K);@putByIdDirectPrivate(f,\"writable\",F),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(F)),@putByIdDirectPrivate(f,\"readable\",L),@putByIdDirectPrivate(f,\"backpressure\",@undefined),@putByIdDirectPrivate(f,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(f,!0),@putByIdDirectPrivate(f,\"controller\",@undefined)})\n"; +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"; // transformStreamError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = 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){\"use strict\";const W=@getByIdDirectPrivate(_,\"stream\"),f=@getByIdDirectPrivate(W,\"readable\"),g=@getByIdDirectPrivate(f,\"readableStreamController\");if(@assert(g!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(g))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(g,S)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(W,j),@getByIdDirectPrivate(f,\"storedError\")}const i=!@readableStreamDefaultControllerShouldCallPull(g);if(i!==@getByIdDirectPrivate(W,\"backpressure\"))@assert(i),@transformStreamSetBackpressure(W,!0)})\n"; +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"; // 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){\"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"; +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"; // 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 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"; +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"; // transformStreamDefaultSourcePullAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (B,j){\"use strict\";var z={path:\"node:process\",require:j},G=(N)=>z.require(N);function H(N){var{Duplex:O,eos:Q,destroy:U}=G(\"node:stream\"),V=class X extends O{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(N)}get fd(){return N}constructor(Z){super({readable:!0,writable:!0});this.#G=`/dev/fd/${Z}`}#N(Z){const Y=this.#H;if(this.#H=null,Y)Y(Z);else if(Z)this.destroy(Z);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Z,Y){if(!Z&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Z=new P}if(this.#J=null,this.#K=null,this.#H===null)Y(Z);else{if(this.#H=Y,this.#$)U(this.#$,Z);if(this.#B)U(this.#B,Z)}}_write(Z,Y,P){if(!this.#$){var{createWriteStream:A}=G(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),Q(T,(x)=>{if(this.#z=!1,x)U(T,x);this.#N(x)})}if(T.write(Z,Y))P();else this.#J=P}_final(Z){this.#$&&this.#$.end(),this.#K=Z}#O(){var{createReadStream:Z}=G(\"node:fs\"),Y=this.#B=Z(this.#G);return Y.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),Y.on(\"end\",()=>{this.push(null)}),Q(Y,(P)=>{if(this.#j=!1,P)U(Y,P);this.#N(P)}),Y}_read(){var Z=this.#B;if(!Z)Z=this.#O();while(!0){const Y=Z.read();if(Y===null||!this.push(Y))return}}};return new V(N)}var{EventEmitter:J}=G(\"node:events\");function K(N){if(!N)return!0;var O=N.toLowerCase();return O===\"utf8\"||O===\"utf-8\"||O===\"buffer\"||O===\"binary\"}var L,M=class N extends J{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(O){if(this.#B||!K(O))return this.#J(),this.#B.setDefaultEncoding(O)}#G(){switch(this.#$){case 1:{var O=@Bun.stdout.writer({highWaterMark:0});return O.unref(),O}case 2:{var O=@Bun.stderr.writer({highWaterMark:0});return O.unref(),O}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(O){super();this.#$=O}get fd(){return this.#$}get isTTY(){return this.#z\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(O,Q,U){return(L\?\?=G(\"readline\")).cursorTo(this,O,Q,U)}moveCursor(O,Q,U){return(L\?\?=G(\"readline\")).moveCursor(this,O,Q,U)}clearLine(O,Q){return(L\?\?=G(\"readline\")).clearLine(this,O,Q)}clearScreenDown(O){return(L\?\?=G(\"readline\")).clearScreenDown(this,O)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(O,Q){if(O===\"close\"||O===\"finish\")return this.#J(),this.#B.on(O,Q);if(O===\"drain\")return super.on(\"drain\",Q);if(O===\"error\")return super.on(\"error\",Q);return super.on(O,Q)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(O){return this.#J(),this.#B.pipe(O)}unpipe(O){return this.#J(),this.#B.unpipe(O)}#J(){if(this.#B)return;this.#B=H(this.#$);const O=this.eventNames();for(let Q of O)this.#B.on(Q,(...U)=>{this.emit(Q,...U)})}#K(O){var Q=this.#H();const U=Q.write(O);this.bytesWritten+=U;const V=Q.flush(!1);return!!(U||V)}#L(O,Q){if(!K(Q))return this.#J(),this.#B.write(O,Q);return this.#K(O)}#M(O,Q){if(Q)this.emit(\"error\",Q);try{O(Q\?Q:null)}catch(U){this.emit(\"error\",U)}}#N(O,Q,U){if(!K(Q))return this.#J(),this.#B.write(O,Q,U);var V=this.#H();const X=V.write(O),Z=V.flush(!0);if(Z\?.then)return Z.then(()=>{this.#M(U),this.emit(\"drain\")},(Y)=>this.#M(U,Y)),!1;return queueMicrotask(()=>{this.#M(U)}),!!(X||Z)}write(O,Q,U){const V=this._write(O,Q,U);if(V)this.emit(\"drain\");return V}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(O,Q,U){var V=this.#B;if(V)return V.write(O,Q,U);switch(arguments.length){case 0:{var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}case 1:return this.#K(O);case 2:if(typeof Q===\"function\")return this.#N(O,\"\",Q);else if(typeof Q===\"string\")return this.#L(O,Q);default:{if(typeof Q!==\"undefined\"&&typeof Q!==\"string\"||typeof U!==\"undefined\"&&typeof U!==\"function\"){var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}if(typeof U===\"undefined\")return this.#L(O,Q);return this.#N(O,Q,U)}}}destroy(){return this}end(){return this}};return new M(B)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (j,H){\"use strict\";var J={path:\"node:process\",require:H},G=(N)=>J.require(N);function K(N){var{Duplex:O,eos:Q,destroy:U}=G(\"node:stream\"),V=class X extends O{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(N)}get fd(){return N}constructor(Z){super({readable:!0,writable:!0});this.#G=`/dev/fd/${Z}`}#N(Z){const Y=this.#H;if(this.#H=null,Y)Y(Z);else if(Z)this.destroy(Z);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Z,Y){if(!Z&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Z=new P}if(this.#J=null,this.#K=null,this.#H===null)Y(Z);else{if(this.#H=Y,this.#$)U(this.#$,Z);if(this.#B)U(this.#B,Z)}}_write(Z,Y,P){if(!this.#$){var{createWriteStream:A}=G(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),Q(T,(x)=>{if(this.#z=!1,x)U(T,x);this.#N(x)})}if(T.write(Z,Y))P();else this.#J=P}_final(Z){this.#$&&this.#$.end(),this.#K=Z}#O(){var{createReadStream:Z}=G(\"node:fs\"),Y=this.#B=Z(this.#G);return Y.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),Y.on(\"end\",()=>{this.push(null)}),Q(Y,(P)=>{if(this.#j=!1,P)U(Y,P);this.#N(P)}),Y}_read(){var Z=this.#B;if(!Z)Z=this.#O();while(!0){const Y=Z.read();if(Y===null||!this.push(Y))return}}};return new V(N)}var{EventEmitter:z}=G(\"node:events\");function L(N){if(!N)return!0;var O=N.toLowerCase();return O===\"utf8\"||O===\"utf-8\"||O===\"buffer\"||O===\"binary\"}var M,B=class N extends z{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(O){if(this.#B||!L(O))return this.#J(),this.#B.setDefaultEncoding(O)}#G(){switch(this.#$){case 1:{var O=@Bun.stdout.writer({highWaterMark:0});return O.unref(),O}case 2:{var O=@Bun.stderr.writer({highWaterMark:0});return O.unref(),O}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(O){super();this.#$=O}get fd(){return this.#$}get isTTY(){return this.#z\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(O,Q,U){return(M\?\?=G(\"readline\")).cursorTo(this,O,Q,U)}moveCursor(O,Q,U){return(M\?\?=G(\"readline\")).moveCursor(this,O,Q,U)}clearLine(O,Q){return(M\?\?=G(\"readline\")).clearLine(this,O,Q)}clearScreenDown(O){return(M\?\?=G(\"readline\")).clearScreenDown(this,O)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(O,Q){if(O===\"close\"||O===\"finish\")return this.#J(),this.#B.on(O,Q);if(O===\"drain\")return super.on(\"drain\",Q);if(O===\"error\")return super.on(\"error\",Q);return super.on(O,Q)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(O){return this.#J(),this.#B.pipe(O)}unpipe(O){return this.#J(),this.#B.unpipe(O)}#J(){if(this.#B)return;this.#B=K(this.#$);const O=this.eventNames();for(let Q of O)this.#B.on(Q,(...U)=>{this.emit(Q,...U)})}#K(O){var Q=this.#H();const U=Q.write(O);this.bytesWritten+=U;const V=Q.flush(!1);return!!(U||V)}#L(O,Q){if(!L(Q))return this.#J(),this.#B.write(O,Q);return this.#K(O)}#M(O,Q){if(Q)this.emit(\"error\",Q);try{O(Q\?Q:null)}catch(U){this.emit(\"error\",U)}}#N(O,Q,U){if(!L(Q))return this.#J(),this.#B.write(O,Q,U);var V=this.#H();const X=V.write(O),Z=V.flush(!0);if(Z\?.then)return Z.then(()=>{this.#M(U),this.emit(\"drain\")},(Y)=>this.#M(U,Y)),!1;return queueMicrotask(()=>{this.#M(U)}),!!(X||Z)}write(O,Q,U){const V=this._write(O,Q,U);if(V)this.emit(\"drain\");return V}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(O,Q,U){var V=this.#B;if(V)return V.write(O,Q,U);switch(arguments.length){case 0:{var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}case 1:return this.#K(O);case 2:if(typeof Q===\"function\")return this.#N(O,\"\",Q);else if(typeof Q===\"string\")return this.#L(O,Q);default:{if(typeof Q!==\"undefined\"&&typeof Q!==\"string\"||typeof U!==\"undefined\"&&typeof U!==\"function\"){var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}if(typeof U===\"undefined\")return this.#L(O,Q);return this.#N(O,Q,U)}}}destroy(){return this}end(){return this}};return new B(j)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = 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,j,z){\"use strict\";var G={path:\"node:process\",require:j},H=(M)=>G.require(M),{Duplex:I,eos:J,destroy:K}=H(\"node:stream\"),L=class M extends I{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return H(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(N){const P=this.#J;if(this.#J=null,P)P(N);else if(N)this.destroy(N);else if(!this.#z&&!this.#H)this.destroy()}_destroy(N,P){if(!N&&this.#J!==null){var Q=class T extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new Q}if(this.#J===null)P(N);else if(this.#J=P,this.#j)K(this.#j,N)}setRawMode(N){}on(N,P){if(N===\"readable\")this.ref(),this.#G=!0;return super.on(N,P)}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 N,P;const Q=this.#Y.readMany();if(!Q\?.then)({done:N,value:P}=Q);else({done:N,value:P}=await Q);if(!N){this.push(P[0]);const T=P.length;for(let U=1;U{if(this.#I){const Q=this.#I;this.#I=null,Q()}}),P.on(\"drain\",()=>{if(this.#K){const Q=this.#K;this.#K=null,Q()}}),J(P,(Q)=>{if(this.#H=!1,Q)K(P,Q);this.#L(Q)}),P}_write(N,P,Q){var T=this.#j;if(!T)T=this.#N();if(T.write(N,P))Q();else this.#K=Q}_final(N){this.#j.end(),this.#I=(...P)=>N(...P)}};return new L})\n"; +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"; #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 _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let u=arguments[1],j=arguments[2];if(_===@undefined)_=null;if(j===@undefined)j={};if(u===@undefined)u={};let q={};if(_!==null){if(\"start\"in _){if(q[\"start\"]=_[\"start\"],typeof q[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(q[\"transform\"]=_[\"transform\"],typeof q[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(q[\"flush\"]=_[\"flush\"],typeof q[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const v=@extractHighWaterMark(j,0),x=@extractSizeAlgorithm(j),B=@extractHighWaterMark(u,1),E=@extractSizeAlgorithm(u),F=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,F.@promise,B,E,v,x),@setUpTransformStreamDefaultControllerFromTransformer(this,_,q),(\"start\"in q)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,q[\"start\"],[G]))().@then(()=>{F.@resolve.@call()},(J)=>{F.@reject.@call(@undefined,J)})}else F.@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 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"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -900,7 +900,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(d,c),d+1})\n"; +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"; // writeInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -956,7 +956,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!0),d+4})\n"; +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"; // writeUInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -972,7 +972,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 (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"; +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"; // writeIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -980,7 +980,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 (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"; +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"; // writeUIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -988,7 +988,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,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"; +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"; // writeUIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1044,7 +1044,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!1),d+8})\n"; +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"; // writeBigUInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1204,7 +1204,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (c,p){\"use strict\";var{buffer:i,byteOffset:k,byteLength:m}=this;function q(x,z){if(x=@trunc(x),x===0||@isNaN(x))return 0;else if(x<0)return x+=z,x>0\?x:0;else return xv\?w-v:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (i,m){\"use strict\";var{buffer:q,byteOffset:v,byteLength:c}=this;function w(z,k){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=k,z>0\?z:0;else return zp\?x-p:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1304,7 +1304,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 w=async function*j(){var q=@Bun.stdin.stream().getReader(),z=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),A,B=@Bun.indexOfLine;try{while(!0){var D,F,G;const L=q.readMany();if(@isPromise(L))({done:D,value:F}=await L);else({done:D,value:F}=L);if(D){if(G)yield z.decode(G);return}var H;for(let M of F){if(H=M,G)H=@Buffer.concat([G,M]),G=null;var J=0,K=B(H,J);while(K!==-1)yield z.decode(H.subarray(J,K)),J=K+1,K=B(H,J);G=H.subarray(J)}}}catch(L){A=L}finally{if(q.releaseLock(),A)throw A}},_=globalThis.Symbol.asyncIterator;return this[_]=w,w()})\n"; +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"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,7 +1312,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (a){\"use strict\";var d=@getByIdDirectPrivate(this,\"writer\");if(!d){var _=@toLength(a\?.length\?\?0);d=@Bun.stdout.writer({highWaterMark:_>65536\?_:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var b=d.write(a);const c=@argumentCount();for(var f=1;f65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a{},(y)=>{c.error(y)});function h(){@readableStreamDefaultReaderRead(g).@then(function(y){if(y.done){c.close();return}try{c.enqueue(y.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}h()},function(y){c.error(y)})}h()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (c,g){\"use strict\";@assert(@isReadableStream(c));const h=new @ReadableStreamDefaultReader(c);@getByIdDirectPrivate(h,\"closedPromiseCapability\").@promise.@then(()=>{},(S)=>{g.error(S)});function y(){@readableStreamDefaultReaderRead(h).@then(function(S){if(S.done){g.close();return}try{g.enqueue(S.value)}catch(_){g.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(S){g.error(S)})}y()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1370,7 +1370,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 (_,f,b,j,q,v,w){\"use strict\";const x=new @ReadableStreamDefaultController(_,f,b,j,@isReadableStream),B=()=>@promiseInvokeOrNoopMethod(f,v,[x]),C=(D)=>@promiseInvokeOrNoopMethod(f,w,[D]);@putByIdDirectPrivate(x,\"pullAlgorithm\",B),@putByIdDirectPrivate(x,\"cancelAlgorithm\",C),@putByIdDirectPrivate(x,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(x,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(_,\"readableStreamController\",x),@readableStreamDefaultControllerStart(x)})\n"; +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"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1378,7 +1378,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,b)}else if(A===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (v,w,A){\"use strict\";const C=w.type,b=@toString(C);if(b===\"bytes\"){if(A.highWaterMark===@undefined)A.highWaterMark=0;if(A.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(v,\"readableStreamController\",new @ReadableByteStreamController(v,w,A.highWaterMark,@isReadableStream))}else if(b===\"direct\"){var f=A\?.highWaterMark;@initializeArrayBufferStream.@call(v,w,f)}else if(C===@undefined){if(A.highWaterMark===@undefined)A.highWaterMark=1;@setupReadableStreamDefaultController(v,w,A.size,A.highWaterMark,w.start,w.pull,w.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1394,7 +1394,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,D,E,T,k){\"use strict\";if(@assert(@isReadableStream(_)),@assert(@isWritableStream(f)),@assert(!@isReadableStreamLocked(_)),@assert(!@isWritableStreamLocked(f)),@assert(k===@undefined||@isAbortSignal(k)),@getByIdDirectPrivate(_,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let q={source:_,destination:f,preventAbort:E,preventCancel:T,preventClose:D,signal:k};if(q.reader=@acquireReadableStreamDefaultReader(_),q.writer=@acquireWritableStreamDefaultWriter(f),@putByIdDirectPrivate(_,\"disturbed\",!0),q.finalized=!1,q.shuttingDown=!1,q.promiseCapability=@newPromiseCapability(@Promise),q.pendingReadPromiseCapability=@newPromiseCapability(@Promise),q.pendingReadPromiseCapability.@resolve.@call(),q.pendingWritePromise=@Promise.@resolve(),k!==@undefined){const w=(x)=>{if(q.finalized)return;@pipeToShutdownWithAction(q,()=>{const B=!q.preventAbort&&@getByIdDirectPrivate(q.destination,\"state\")===\"writable\"\?@writableStreamAbort(q.destination,x):@Promise.@resolve(),G=!q.preventCancel&&@getByIdDirectPrivate(q.source,\"state\")===@streamReadable\?@readableStreamCancel(q.source,x):@Promise.@resolve();let H=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}H.@resolve.@call()},K=(L)=>{H.@reject.@call(@undefined,L)};return B.@then(J,K),G.@then(J,K),H.@promise},x)};if(@whenSignalAborted(k,w))return q.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(q),@pipeToErrorsMustBePropagatedBackward(q),@pipeToClosingMustBePropagatedForward(q),@pipeToClosingMustBePropagatedBackward(q),@pipeToLoop(q),q.promiseCapability.@promise})\n"; +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"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1450,7 +1450,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){\"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"; +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"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1474,7 +1474,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (i,_){\"use strict\";@assert(@isReadableStream(i)),@assert(typeof _===\"boolean\");var f=@getByIdDirectPrivate(i,\"start\");if(f)@putByIdDirectPrivate(i,\"start\",@undefined),f();const g=new @ReadableStreamDefaultReader(i),j={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};j.cancelPromiseCapability=@newPromiseCapability(@Promise);const k=@readableStreamTeePullFunction(j,g,_),q={};@putByIdDirectPrivate(q,\"pull\",k),@putByIdDirectPrivate(q,\"cancel\",@readableStreamTeeBranch1CancelFunction(j,i));const v={};@putByIdDirectPrivate(v,\"pull\",k),@putByIdDirectPrivate(v,\"cancel\",@readableStreamTeeBranch2CancelFunction(j,i));const w=new @ReadableStream(q),x=new @ReadableStream(v);return @getByIdDirectPrivate(g,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(j.closedOrErrored)return;if(@readableStreamDefaultControllerError(w.@readableStreamController,y),@readableStreamDefaultControllerError(x.@readableStreamController,y),j.closedOrErrored=!0,!j.canceled1||!j.canceled2)j.cancelPromiseCapability.@resolve.@call()}),j.branch1=w,j.branch2=x,[w,x]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (f,k){\"use strict\";@assert(@isReadableStream(f)),@assert(typeof k===\"boolean\");var i=@getByIdDirectPrivate(f,\"start\");if(i)@putByIdDirectPrivate(f,\"start\",@undefined),i();const q=new @ReadableStreamDefaultReader(f),_={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};_.cancelPromiseCapability=@newPromiseCapability(@Promise);const v=@readableStreamTeePullFunction(_,q,k),g={};@putByIdDirectPrivate(g,\"pull\",v),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch1CancelFunction(_,f));const w={};@putByIdDirectPrivate(w,\"pull\",v),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(_,f));const x=new @ReadableStream(g),j=new @ReadableStream(w);return @getByIdDirectPrivate(q,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(_.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,y),@readableStreamDefaultControllerError(j.@readableStreamController,y),_.closedOrErrored=!0,!_.canceled1||!_.canceled2)_.cancelPromiseCapability.@resolve.@call()}),_.branch1=x,_.branch2=j,[x,j]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1530,7 +1530,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 (_,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"; +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"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1546,7 +1546,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,f){\"use strict\";var I=!1,P=!1;try{var q=_.getReader(),x=q.readMany();if(x&&@isPromise(x))x=await x;if(x.done)return I=!0,c.end();var z=x.value.length;const J=@getByIdDirectPrivate(_,\"highWaterMark\");if(f)@startDirectStream.@call(c,_,@undefined,()=>!P&&@markPromiseAsHandled(_.cancel()));c.start({highWaterMark:J||0});for(var A=0,B=x.value,D=x.value.length;A!z&&@markPromiseAsHandled(c.cancel()));G.start({highWaterMark:x||0});for(var K=0,P=H.value,A=H.value.length;K{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"; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (v){\"use strict\";var C=this.@controlledReadableStream;if(!C||@getByIdDirectPrivate(C,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=v;return}if(@putByIdDirectPrivate(C,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,v)}catch(B){}var S;try{S=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(B){if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(y,B)}@readableStreamError(C,B);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var j=@getByIdDirectPrivate(C,\"reader\");if(j&&@isReadableStreamDefaultReader(j)){var c=this._pendingRead;if(c&&@isPromise(c)&&S\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(c,{value:S,done:!1}),@readableStreamClose(C);return}}if(S\?.byteLength){var b=@getByIdDirectPrivate(j,\"readRequests\");if(b\?.isNotEmpty()){@readableStreamFulfillReadRequest(C,S,!1),@readableStreamClose(C);return}@putByIdDirectPrivate(C,\"state\",@streamReadable),this.@pull=()=>{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"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1610,7 +1610,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 (_){\"use strict\";var j,q=[],v=!1,w=!1,x=\"\",z=@toLength(0),A=@newPromiseCapability(@Promise),C=!1;return j={start(){},write(E){if(typeof E===\"string\"){var F=@toLength(E.length);if(F>0)x+=E,v=!0,z+=F;return F}if(!E||!(@ArrayBuffer.@isView(E)||E instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const G=@toLength(E.byteLength);if(G>0)if(w=!0,x.length>0)@arrayPush(q,x,E),x=\"\";else @arrayPush(q,E);return z+=G,G},flush(){return 0},end(){if(C)return\"\";return j.fulfill()},fulfill(){C=!0;const E=j.finishInternal();return @fulfillPromise(A.@promise,E),E},finishInternal(){if(!v&&!w)return\"\";if(v&&!w)return x;if(w&&!v)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(q));var E=new @Bun.ArrayBufferSink;E.start({highWaterMark:z,asUint8Array:!0});for(let F of q)E.write(F);if(q.length=0,x.length>0)E.write(x),x=\"\";return new globalThis.TextDecoder().decode(E.end())},close(){try{if(!C)C=!0,j.fulfill()}catch(E){}}},[j,A]})\n"; +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"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1626,7 +1626,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){\"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"; +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"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1634,7 +1634,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 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"; +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"; // readableStreamError const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1642,7 +1642,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (_,i){\"use strict\";@assert(@isReadableStream(_)),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamErrored),@putByIdDirectPrivate(_,\"storedError\",i);const c=@getByIdDirectPrivate(_,\"reader\");if(!c)return;if(@isReadableStreamDefaultReader(c)){const h=@getByIdDirectPrivate(c,\"readRequests\");@putByIdDirectPrivate(c,\"readRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,i)}else{@assert(@isReadableStreamBYOBReader(c));const h=@getByIdDirectPrivate(c,\"readIntoRequests\");@putByIdDirectPrivate(c,\"readIntoRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,i)}@getByIdDirectPrivate(c,\"closedPromiseCapability\").@reject.@call(@undefined,i);const f=@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(f)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const h=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1690,7 +1690,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,_){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const d=@getByIdDirectPrivate(i,\"state\");if(d===@streamClosed)return @Promise.@resolve();if(d===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var h=@getByIdDirectPrivate(i,\"readableStreamController\"),p=h.@cancel;if(p)return p(h,_).@then(function(){});var u=h.close;if(u)return @Promise.@resolve(h.close(_));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (_,d){\"use strict\";@putByIdDirectPrivate(_,\"disturbed\",!0);const h=@getByIdDirectPrivate(_,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));@readableStreamClose(_);var p=@getByIdDirectPrivate(_,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,d).@then(function(){});var i=p.close;if(i)return @Promise.@resolve(p.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1770,7 +1770,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 (_){\"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"; +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"; // readableStreamDefaultControllerCanCloseOrEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1786,7 +1786,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 (b,f){\"use strict\";var j=@getByIdDirectPrivate(b,\"bunNativeType\"),m=@getByIdDirectPrivate(b,\"bunNativePtr\"),q=@lazyStreamPrototypeMap.@get(j);if(q===@undefined){let U=function(Z){var{c:_,v:p}=this;this.c=@undefined,this.v=@undefined,J(Z,_,p)},W=function(Z){try{Z.close()}catch(_){globalThis.reportError(_)}},X=function(Z,_,p,z){z[0]=!1;var A;try{A=x(Z,p,z)}catch(C){return _.error(C)}return J(A,_,p)};var Q=U,P=W,O=X,[x,B,D,E,F,G,H]=@lazyLoad(j),I=[!1],J;J=function Z(_,p,z){if(_&&@isPromise(_))return _.then(U.bind({c:p,v:z}),(A)=>p.error(A));else if(typeof _===\"number\")if(z&&z.byteLength===_&&z.buffer===p.byobRequest\?.view\?.buffer)p.byobRequest.respondWithNewView(z);else p.byobRequest.respond(_);else if(_.constructor===@Uint8Array)p.enqueue(_);if(I[0]||_===!1)@enqueueJob(W,p),I[0]=!1};const Y=F\?new FinalizationRegistry(F):null;q=class Z{constructor(_,p,z){if(this.#f=_,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=p,z!==@undefined)this.start=(A)=>{A.enqueue(z)};if(Y)Y.register(this,_,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=B;#j(_){var p=this.#f;if(!p){_.close();return}X(p,_,_.byobRequest.view,I)}#m(_){var p=this.#f;Y&&Y.unregister(this.#b),G&&G(p,!1),D(p,_)}static deinit=F;static drain=H},@lazyStreamPrototypeMap.@set(j,q)}const K=q.startSync(m,f);var L;const{drain:M,deinit:N}=q;if(M)L=M(m);if(K===0){if(F&&m&&@enqueueJob(F,m),(L\?.byteLength\?\?0)>0)return{start(U){U.enqueue(L),U.close()},type:\"bytes\"};return{start(U){U.close()},type:\"bytes\"}}return new q(m,K,L)})\n"; +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"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1794,7 +1794,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var _=f.getReader(),b=_.readMany();async function g(j){if(j.done)return[];var p=j.value||[];while(!0){var q=await _.read();if(q.done)break;p=p.concat(q.value)}return p}if(b&&@isPromise(b))return b.@then(g);return g(b)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var b=_.getReader(),g=b.readMany();async function j(p){if(p.done)return[];var f=p.value||[];while(!0){var q=await b.read();if(q.done)break;f=f.concat(q.value)}return f}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1810,7 +1810,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 (_,O){\"use strict\";var j=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(_,\"underlyingSource\",@undefined);var q=@getByIdDirectPrivate(_,\"highWaterMark\");j.start(q\?{highWaterMark:q}:{});var v=@newPromiseCapability(@Promise),w=!1,x=O.pull,z=O.close,A={start(){},close(C){if(!w){if(w=!0,z)z();@fulfillPromise(v.@promise,j.end())}},end(){if(!w){if(w=!0,z)z();@fulfillPromise(v.@promise,j.end())}},flush(){return 0},write:j.write.bind(j)},B=!1;try{const C=x(A);if(C&&@isObject(C)&&@isPromise(C))return async function(D,F,G){while(!w)await G(D);return await F}(A,promise,x);return v.@promise}catch(C){return B=!0,@readableStreamError(_,C),@Promise.@reject(C)}finally{if(!B&&_)@readableStreamClose(_);A=z=j=x=_=@undefined}})\n"; +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"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1834,7 +1834,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 k=globalThis.Symbol.asyncIterator,g=async function*q(w,x){var z=w.getReader(),B;try{while(!0){var D,F;const G=z.readMany();if(@isPromise(G))({done:D,value:F}=await G);else({done:D,value:F}=G);if(D)return;yield*F}}catch(G){B=G}finally{if(z.releaseLock(),!x)w.cancel(B);if(B)throw B}},i=function q(){return g(this,!1)},j=function q({preventCancel:w=!1}={preventCancel:!1}){return g(this,w)};return @Object.@defineProperty(h,k,{value:i}),@Object.@defineProperty(h,\"values\",{value:j}),h})\n"; +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"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeCons const JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 339; static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),u=@getByIdDirectPrivate(_,\"readable\"),i=@getByIdDirectPrivate(u,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(i)})\n"; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),i=@getByIdDirectPrivate(_,\"readable\"),u=@getByIdDirectPrivate(i,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(u)})\n"; // enqueue const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1986,7 +1986,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 _=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!_)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const d=@getByIdDirectPrivate(_,\"state\");if(@putByIdDirectPrivate(_,\"disturbed\",!0),d===@streamClosed)return{value:[],size:0,done:!0};else if(d===@streamErrored)throw @getByIdDirectPrivate(_,\"storedError\");var B=@getByIdDirectPrivate(_,\"readableStreamController\"),w=@getByIdDirectPrivate(B,\"queue\");if(!w)return B.@pull(B).@then(function({done:G,value:H}){return G\?{done:!0,value:[],size:0}:{value:[H],size:1,done:!1}});const A=w.content;var D=w.size,j=A.toArray(!1),k=j.length;if(k>0){var x=@newArrayWithSize(k);if(@isReadableByteStreamController(B)){{const G=j[0];if(!(@ArrayBuffer.@isView(G)||G instanceof @ArrayBuffer))@putByValDirect(x,0,new @Uint8Array(G.buffer,G.byteOffset,G.byteLength));else @putByValDirect(x,0,G)}for(var C=1;C{if(G.done)return{value:[],size:0,done:!0};var H=@getByIdDirectPrivate(_,\"readableStreamController\"),I=@getByIdDirectPrivate(H,\"queue\"),J=[G.value].concat(I.content.toArray(!1)),K=J.length;if(@isReadableByteStreamController(H))for(var N=0;N0){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}shift(){var{_head:x,_tail:g,_list:k,_capacityMask:w}=this;if(x===g)return @undefined;var z=k[x];if(@putByValDirect(k,x,@undefined),x=this._head=x+1&w,x<2&&g>1e4&&g<=k.length>>>2)this._shrinkArray();return z}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(x){var g=this._tail;if(@putByValDirect(this._list,g,x),this._tail=g+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(x){var g=this._list,k=@toLength(g.length);if(x||this._head>this._tail){var w=@toLength(this._head),z=@toLength(this._tail),A=@toLength(k-w+z),B=@newArrayWithSize(A),E=0;for(var F=w;F>>=1,this._capacityMask>>>=1}}return new v})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var b=@Array.prototype.slice;class z{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: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"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2140,7 +2140,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 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"; +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"; // extractHighWaterMark const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2190,7 +2190,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1337; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (_){\"use strict\";var w=@Loader,x=@createFIFO(),z=_;while(z){var B=w.registry.@get(z);if(!B||!B.state||B.state<=@ModuleFetch)@fulfillModuleSync(z),B=w.registry.@get(z);var D=@getPromiseInternalField(B.fetch,@promiseFieldReactionsOrResult),F=w.parseModule(z,D),G=B.module;if(!G&&F&&@isPromise(F)){var H=@getPromiseInternalField(F,@promiseFieldReactionsOrResult),I=@getPromiseInternalField(F,@promiseFieldFlags),J=I&@promiseStateMask;if(J===@promiseStatePending||H&&@isPromise(H))@throwTypeError(`require() async module \"${z}\" is unsupported`);else if(J===@promiseStateRejected){if(!H\?.message)@throwTypeError(`${H+\"\"\?H:\"An error occurred\"} occurred while parsing module \\\"${z}\\\"`);throw H}B.module=G=H}else if(F&&!G)B.module=G=F;@setStateToMax(B,@ModuleLink);var L=G.dependenciesMap,Q=w.requestedModules(G),T=@newArrayWithSize(Q.length);for(var U=0,V=Q.length;U=@ModuleLink)z=x.shift()}var Z=w.linkAndEvaluateModule(_,@undefined);if(Z&&@isPromise(Z))@throwTypeError(`require() async module \\\"${_}\\\" is unsupported`);return w.registry.@get(_)})\n"; +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"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2198,7 +2198,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 419; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var _=@Loader.registry.@get(a);if(!_||!_.evaluated)_=@loadCJS2ESM(a);if(!_||!_.evaluated||!_.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var f=@Loader.getModuleNamespaceObject(_.module);if(f[@commonJSSymbol]===0)return;var g=f.default,u=g\?.[@commonJSSymbol];if(u===0)return g;else if(u&&@isCallable(g))return g();return f})\n"; +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"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2206,7 +2206,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 611; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (i){\"use strict\";var n=@requireMap.@get(i);const _=i.substring(i.length-5);if(n){if(_===\".node\")return n.exports;return n}if(_===\".json\"){var q=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=JSON.parse(q.readFileSync(i,\"utf8\"));return @requireMap.@set(i,b),b}else if(_===\".node\"){var g={exports:{}};return process.dlopen(g,i),@requireMap.@set(i,g),g.exports}else if(_===\".toml\"){var q=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=@Bun.TOML.parse(q.readFileSync(i,\"utf8\"));return @requireMap.@set(i,b),b}else{var b=@requireESM(i);const k=@requireMap.@get(i);if(k)return k;return @requireMap.@set(i,b),b}})\n"; +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"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2214,7 +2214,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 891; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";class r{id;parent;filename;children=[];paths=[];constructor(P){this.id=P;const c=P.lastIndexOf(\"/\");if(c!==-1&&P.length>c+1)this.filename=P.substring(c+1);else this.filename=P}get loaded(){return!0}require(P){return @internalRequire(@resolveSync(P,this.id))}get exports(){return @requireMap.@get(this.id)\?\?{}}set exports(P){@requireMap.@set(this.id,P)}}var _=new Map;return new Proxy({},{get(P,c){if(@requireMap.@get(c)){var K=_.@get(c);if(!K)K=new r(c),_.@set(c,K);return K}},set(P,c,q){if(!_.@has(c))_.@set(c,new r(c));return @requireMap.@set(c,q\?.exports),!0},has(P,c){return @requireMap.@has(c)},deleteProperty(P,c){return _.@delete(c),@requireMap.@delete(c),@Loader.registry.@delete(c),!0},ownKeys(P){return[...@requireMap.@keys()]},getPrototypeOf(P){return null},getOwnPropertyDescriptor(P,c){if(@requireMap.@has(c))return{configurable:!0,enumerable:!0}}})})\n"; +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"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2222,7 +2222,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_importMetaObjectRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireCodeLength = 172; static const JSC::Intrinsic s_importMetaObjectRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireCode = "(function (i){var l=this\?.path\?\?arguments.callee.path;if(typeof i!==\"string\")@throwTypeError(\"require(name) must be a string\");return @internalRequire(@resolveSync(i,l))})\n"; +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"; // main const JSC::ConstructAbility s_importMetaObjectMainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2398,7 +2398,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const m=_.type===\"direct\",v=!!_.@lazy,B=m||v;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!B){const I=@getByIdDirectPrivate(f,\"size\"),b=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,I,b!==@undefined\?b:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(m)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(B){const I=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,I);if(b)@createReadableStreamController(this,b,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,I=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!I){const _=@getByIdDirectPrivate(m,\"size\"),b=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,b!==@undefined\?b:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(I){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,_);if(b)@createReadableStreamController(this,b,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2406,7 +2406,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorK const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayCodeLength = 173; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayDirect(_,b);return @readableStreamIntoArray(_)})\n"; +const char* const s_readableStreamReadableStreamToArrayCode = "(function (b){\"use strict\";var _=@getByIdDirectPrivate(b,\"underlyingSource\");if(_!==@undefined)return @readableStreamToArrayDirect(b,_);return @readableStreamIntoArray(b)})\n"; // readableStreamToText const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2446,7 +2446,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 (_,F,j){\"use strict\";const k=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var q=globalThis[k];if(!q)q=globalThis[k]=[];var w=q[F];if(w===@undefined){var[x,A,B,D,G,H]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](F);w=class J{handleError;handleClosed;processResult;constructor(K,L){this.#_=L,this.#F=K,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),K.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var K=this.#_;this.#_=0,D(K),H(K)}_handleError(K){if(this.#$)return;this.#$=!0;var L=this.#_;this.#_=0,A(L,K),H(L)}#_;#$=!1;#F;_handleReadMany({value:K,done:L,size:N}){if(L){this.handleClosed();return}if(this.#$)return;B(this.#_,K,L,N)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(K){if(K&&@isPromise(K)){if(@getPromiseInternalField(K,@promiseFieldFlags)&@promiseStateFulfilled){const N=@getPromiseInternalField(K,@promiseFieldReactionsOrResult);if(N)K=N}}if(K&&@isPromise(K))return K.then(this.processResult,this.handleError),null;if(K.done)return this.handleClosed(),0;else if(K.value)return K.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const I=F+1;if(q.length{@putByIdDirectPrivate(R,\"started\",1),@assert(!@getByIdDirectPrivate(R,\"pulling\")),@assert(!@getByIdDirectPrivate(R,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(R)},(d)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(R,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (v,b,f){\"use strict\";if(!@isReadableStream(v))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(v,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",v),@putByIdDirectPrivate(this,\"underlyingByteSource\",b),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let p=@toNumber(f);if(@isNaN(p)||p<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",p);let R=b.autoAllocateChunkSize;if(R!==@undefined){if(R=@toNumber(R),R<=0||R===@Infinity||R===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",R),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const _=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(_,\"underlyingByteSource\"),\"start\",[_]).@then(()=>{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(_)},(d)=>{if(@getByIdDirectPrivate(v,\"state\")===@streamReadable)@readableByteStreamControllerError(_,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2610,7 +2610,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadabl const JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength = 139; static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode = "(function (a,d){\"use strict\";@putByIdDirectPrivate(this,\"associatedReadableByteStreamController\",a),@putByIdDirectPrivate(this,\"view\",d)})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode = "(function (d,a){\"use strict\";@putByIdDirectPrivate(this,\"associatedReadableByteStreamController\",d),@putByIdDirectPrivate(this,\"view\",a)})\n"; // isReadableByteStreamController const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2642,7 +2642,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var _=@getByIdDirectPrivate(a,\"pendingPullIntos\"),u=_.peek();if(u)u.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2754,7 +2754,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,d,p){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:d,byteLength:p}),@getByIdDirectPrivate(_,\"queue\").size+=p})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,p,d){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:p,byteLength:d}),@getByIdDirectPrivate(_,\"queue\").size+=d})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2786,7 +2786,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,R,_){\"use strict\";if(_.bytesFilled+R>_.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"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2794,7 +2794,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,_){\"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"; +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"; // readableByteStreamControllerProcessPullDescriptors const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2810,7 +2810,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 (_,q){\"use strict\";const j=q.bytesFilled-q.bytesFilled%q.elementSize,k=@getByIdDirectPrivate(_,\"queue\").sizej)z=w-q.bytesFilled,E=!0;while(z>0){let G=@getByIdDirectPrivate(_,\"queue\").content.peek();const H=z0),@assert(q.bytesFilledq)E=w-z.bytesFilled,G=!0;while(E>0){let H=@getByIdDirectPrivate(_,\"queue\").content.peek();const k=E0),@assert(z.bytesFilled=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"; +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"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/src/js/out/modules/node/crypto.js b/src/js/out/modules/node/crypto.js index 063336164..7968a8eef 100644 --- a/src/js/out/modules/node/crypto.js +++ b/src/js/out/modules/node/crypto.js @@ -1,4 +1,4 @@ -var D$=Object.defineProperty;var C$=Object.getOwnPropertyNames;var L$=536870888,R$=($)=>import.meta.require($),F$=globalThis.crypto,P$=F$;var z$=($,Q)=>function(){return Q||(0,$[C$($)[0]])((Q={exports:{}}).exports,Q),Q.exports},M$=($,Q)=>{for(var Y in Q)D$($,Y,{get:Q[Y],enumerable:!0})};var S$=z$({"node_modules/safe-buffer/index.js"($,Q){var Y=R$("buffer"),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)}}}),v$=z$({"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=S$().Buffer,U=P$;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 J=V.allocUnsafe(K);if(K>0)if(K>Y)for(var O=0;O=this._blockSize;){for(var O=this._blockOffset;O0;++F)this._length[F]+=A,A=this._length[F]/4294967296|0,A>0&&(this._length[F]-=4294967296*A);return this},U.prototype._update=function(){throw new Error("_update is not implemented")},U.prototype.digest=function(X){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var K=this._digest();X!==void 0&&(K=K.toString(X)),this._block.fill(0),this._blockOffset=0;for(var I=0;I<4;++I)this._length[I]=0;return K},U.prototype._digest=function(){throw new Error("_digest is not implemented")},Q.exports=U}}),k$=z$({"node_modules/md5.js/index.js"($,Q){var Y=q$(),Z=j$(),G=S$().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 W=this._a,H=this._b,E=this._c,T=this._d;W=K(W,H,E,T,F[0],3614090360,7),T=K(T,W,H,E,F[1],3905402710,12),E=K(E,T,W,H,F[2],606105819,17),H=K(H,E,T,W,F[3],3250441966,22),W=K(W,H,E,T,F[4],4118548399,7),T=K(T,W,H,E,F[5],1200080426,12),E=K(E,T,W,H,F[6],2821735955,17),H=K(H,E,T,W,F[7],4249261313,22),W=K(W,H,E,T,F[8],1770035416,7),T=K(T,W,H,E,F[9],2336552879,12),E=K(E,T,W,H,F[10],4294925233,17),H=K(H,E,T,W,F[11],2304563134,22),W=K(W,H,E,T,F[12],1804603682,7),T=K(T,W,H,E,F[13],4254626195,12),E=K(E,T,W,H,F[14],2792965006,17),H=K(H,E,T,W,F[15],1236535329,22),W=I(W,H,E,T,F[1],4129170786,5),T=I(T,W,H,E,F[6],3225465664,9),E=I(E,T,W,H,F[11],643717713,14),H=I(H,E,T,W,F[0],3921069994,20),W=I(W,H,E,T,F[5],3593408605,5),T=I(T,W,H,E,F[10],38016083,9),E=I(E,T,W,H,F[15],3634488961,14),H=I(H,E,T,W,F[4],3889429448,20),W=I(W,H,E,T,F[9],568446438,5),T=I(T,W,H,E,F[14],3275163606,9),E=I(E,T,W,H,F[3],4107603335,14),H=I(H,E,T,W,F[8],1163531501,20),W=I(W,H,E,T,F[13],2850285829,5),T=I(T,W,H,E,F[2],4243563512,9),E=I(E,T,W,H,F[7],1735328473,14),H=I(H,E,T,W,F[12],2368359562,20),W=J(W,H,E,T,F[5],4294588738,4),T=J(T,W,H,E,F[8],2272392833,11),E=J(E,T,W,H,F[11],1839030562,16),H=J(H,E,T,W,F[14],4259657740,23),W=J(W,H,E,T,F[1],2763975236,4),T=J(T,W,H,E,F[4],1272893353,11),E=J(E,T,W,H,F[7],4139469664,16),H=J(H,E,T,W,F[10],3200236656,23),W=J(W,H,E,T,F[13],681279174,4),T=J(T,W,H,E,F[0],3936430074,11),E=J(E,T,W,H,F[3],3572445317,16),H=J(H,E,T,W,F[6],76029189,23),W=J(W,H,E,T,F[9],3654602809,4),T=J(T,W,H,E,F[12],3873151461,11),E=J(E,T,W,H,F[15],530742520,16),H=J(H,E,T,W,F[2],3299628645,23),W=O(W,H,E,T,F[0],4096336452,6),T=O(T,W,H,E,F[7],1126891415,10),E=O(E,T,W,H,F[14],2878612391,15),H=O(H,E,T,W,F[5],4237533241,21),W=O(W,H,E,T,F[12],1700485571,6),T=O(T,W,H,E,F[3],2399980690,10),E=O(E,T,W,H,F[10],4293915773,15),H=O(H,E,T,W,F[1],2240044497,21),W=O(W,H,E,T,F[8],1873313359,6),T=O(T,W,H,E,F[15],4264355552,10),E=O(E,T,W,H,F[6],2734768916,15),H=O(H,E,T,W,F[13],1309151649,21),W=O(W,H,E,T,F[4],4149444226,6),T=O(T,W,H,E,F[11],3174756917,10),E=O(E,T,W,H,F[2],718787259,15),H=O(H,E,T,W,F[9],3951481745,21),this._a=this._a+W|0,this._b=this._b+H|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,W,H,E,T,D){return X(F+(A&W|~A&H)+E+T|0,D)+A|0}function I(F,A,W,H,E,T,D){return X(F+(A&H|W&~H)+E+T|0,D)+A|0}function J(F,A,W,H,E,T,D){return X(F+(A^W^H)+E+T|0,D)+A|0}function O(F,A,W,H,E,T,D){return X(F+(W^(A|~H))+E+T|0,D)+A|0}Q.exports=U}}),g$=z$({"node_modules/ripemd160/index.js"($,Q){var Y=R$("buffer").Buffer,Z=q$(),G=j$(),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],J=[0,1518500249,1859775393,2400959708,2840853838],O=[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,N=0;N<80;N+=1){var x,_;N<16?(x=W(R,P,z,M,S,C[U[N]],J[0],K[N]),_=D(v,q,j,k,g,C[X[N]],O[0],I[N])):N<32?(x=H(R,P,z,M,S,C[U[N]],J[1],K[N]),_=T(v,q,j,k,g,C[X[N]],O[1],I[N])):N<48?(x=E(R,P,z,M,S,C[U[N]],J[2],K[N]),_=E(v,q,j,k,g,C[X[N]],O[2],I[N])):N<64?(x=T(R,P,z,M,S,C[U[N]],J[3],K[N]),_=H(v,q,j,k,g,C[X[N]],O[3],I[N])):(x=D(R,P,z,M,S,C[U[N]],J[4],K[N]),_=W(v,q,j,k,g,C[X[N]],O[4],I[N])),R=S,S=M,M=A(z,10),z=P,P=x,v=g,g=k,k=A(j,10),j=q,q=_}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 W(C,L,R,P,z,M,S,v){return A(C+(L^R^P)+M+S|0,v)+z|0}function H(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}}),N$=z$({"node_modules/sha.js/hash.js"($,Q){var Y=S$().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,J=0;J=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}}),x$=z$({"node_modules/sha.js/sha.js"($,Q){var Y=q$(),Z=N$(),G=S$().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(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}X.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]=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]+V[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},X.prototype._hash=function(){var O=G.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},Q.exports=X}}),_$=z$({"node_modules/sha.js/sha1.js"($,Q){var Y=q$(),Z=N$(),G=S$().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 J(F){return F<<30|F>>>2}function O(F,A,W,H){return F===0?A&W|~A&H:F===2?A&W|A&H|W&H:A^W^H}X.prototype._update=function(F){for(var A=this._w,W=this._a|0,H=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(W)+O(R,H,E,T)+D+A[L]+V[R]|0;D=T,T=E,E=J(H),H=W,W=P}this._a=W+this._a|0,this._b=H+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}}),B$=z$({"node_modules/sha.js/sha256.js"($,Q){var Y=q$(),Z=N$(),G=S$().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(W,H,E){return E^W&(H^E)}function I(W,H,E){return W&H|E&(W|H)}function J(W){return(W>>>2|W<<30)^(W>>>13|W<<19)^(W>>>22|W<<10)}function O(W){return(W>>>6|W<<26)^(W>>>11|W<<21)^(W>>>25|W<<7)}function F(W){return(W>>>7|W<<25)^(W>>>18|W<<14)^W>>>3}function A(W){return(W>>>17|W<<15)^(W>>>19|W<<13)^W>>>10}X.prototype._update=function(W){for(var H=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)H[M]=W.readInt32BE(M*4);for(;M<64;++M)H[M]=A(H[M-2])+H[M-7]+F(H[M-15])+H[M-16]|0;for(var S=0;S<64;++S){var v=z+O(L)+K(L,R,P)+V[S]+H[S]|0,q=J(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 W=G.allocUnsafe(32);return W.writeInt32BE(this._a,0),W.writeInt32BE(this._b,4),W.writeInt32BE(this._c,8),W.writeInt32BE(this._d,12),W.writeInt32BE(this._e,16),W.writeInt32BE(this._f,20),W.writeInt32BE(this._g,24),W.writeInt32BE(this._h,28),W},Q.exports=X}}),y$=z$({"node_modules/sha.js/sha224.js"($,Q){var Y=q$(),Z=B$(),G=N$(),V=S$().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}}),w$=z$({"node_modules/sha.js/sha512.js"($,Q){var Y=q$(),Z=N$(),G=S$().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 J(T,D){return(T>>>28|D<<4)^(D>>>2|T<<30)^(D>>>7|T<<25)}function O(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 W(T,D){return(T>>>19|D<<13)^(D>>>29|T<<3)^T>>>6}function H(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,N=this._el|0,x=this._fl|0,_=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],f=D[y-30+1],p=F(w,f),c=A(f,w);w=D[y-4],f=D[y-4+1];var h=W(w,f),d=H(f,w),b=D[y-14],l=D[y-14+1],o=D[y-32],u=D[y-32+1],n=c+l|0,s=p+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),r=J(C,q),e=J(q,C),i=O(z,N),$0=O(N,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=e+a|0,K0=r+m+E(X0,e)|0;v=S,B=_,S=M,_=x,M=z,x=N,N=g+V0|0,z=P+U0+E(N,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+N|0,this._fl=this._fl+x|0,this._gl=this._gl+_|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,N)|0,this._fh=this._fh+M+E(this._fl,x)|0,this._gh=this._gh+S+E(this._gl,_)|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}}),f$=z$({"node_modules/sha.js/sha384.js"($,Q){var Y=q$(),Z=w$(),G=N$(),V=S$().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(J,O,F){K.writeInt32BE(J,F),K.writeInt32BE(O,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}}),p$=z$({"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=x$(),Y.sha1=_$(),Y.sha224=y$(),Y.sha256=B$(),Y.sha384=f$(),Y.sha512=w$()}}),c$=import.meta.require("node:stream"),h$=z$({"node_modules/cipher-base/index.js"($,Q){var Y=S$().Buffer,Z=c$.Transform,G=R$("string_decoder").StringDecoder,V=q$();function U(X){Z.call(this),this.hashMode=typeof X=="string",this.hashMode?this[X]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}V(U,Z),U.prototype.update=function(X,K,I){typeof X=="string"&&(X=Y.from(X,K));var J=this._update(X);return this.hashMode?this:(I&&(J=this._toString(J,I)),J)},U.prototype.setAutoPadding=function(){},U.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},U.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},U.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},U.prototype._transform=function(X,K,I){var J;try{this.hashMode?this._update(X):this.push(this._update(X))}catch(O){J=O}finally{I(J)}},U.prototype._flush=function(X){var K;try{this.push(this.__final())}catch(I){K=I}X(K)},U.prototype._finalOrDigest=function(X){var K=this.__final()||Y.alloc(0);return X&&(K=this._toString(K,X,!0)),K},U.prototype._toString=function(X,K,I){if(this._decoder||(this._decoder=new G(K),this._encoding=K),this._encoding!==K)throw new Error("can't switch encodings");var J=this._decoder.write(X);return I&&(J+=this._decoder.end()),J},Q.exports=U}}),d$=z$({"node_modules/create-hash/browser.js"($,Q){const{Transform:Y}=c$,Z=function U(X,K){this._options=K,this._hasher=new oY(X,K),this._finalized=!1};Z.prototype=Object.create(Y.prototype),Z.prototype.update=function U(X,K){return this._checkFinalized(),this._hasher.update(X,K),this},Z.prototype.digest=function U(X,K){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(X,K)},Z.prototype._checkFinalized=function U(){if(this._finalized){var X=new Error("Digest already called");throw X.code="ERR_CRYPTO_HASH_FINALIZED",X}},Z.prototype.copy=function U(){const X=Object.create(Z.prototype);return X._options=this._options,X._hasher=this._hasher.copy(),X._finalized=this._finalized,X};const G={__proto__:Y.prototype,...Z.prototype,_transform(U,X,K){this.update(U,X),K&&K()},_flush(U){this.push(this.digest()),U()}},V=["_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 U of V)Object.defineProperty(Z.prototype,U,{get(){return Object.setPrototypeOf(this,G),Y.call(this,this._options),this[U]},enumerable:!1,configurable:!0});Q.exports=function U(X){return new Z(X)},Q.exports.createHash=Q.exports,Q.exports.Hash=Z}}),b$=z$({"node_modules/create-hmac/legacy.js"($,Q){var Y=q$(),Z=S$().Buffer,G=h$(),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 W=O==="rmd160"?new X:K(O);F=W.update(F).digest()}else F.lengthY||G!==G)throw new TypeError("Bad key length")}}}),t$=z$({"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}}),m$=z$({"node_modules/pbkdf2/lib/to-buffer.js"($,Q){var Y=S$().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")}}}),a$=z$({"node_modules/pbkdf2/lib/sync-browser.js"($,Q){var Y=l$(),Z=g$(),G=p$(),V=S$().Buffer,U=s$(),X=t$(),K=m$(),I=V.alloc(128),J={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function O(W,H,E){var T=F(W),D=W==="sha512"||W==="sha384"?128:64;H.length>D?H=T(H):H.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,J=6;J>=0;J-=2){for(var O=0;O<=24;O+=8)K<<=1,K|=V>>>O+J&1;for(var O=0;O<=24;O+=8)K<<=1,K|=G>>>O+J&1}for(var J=6;J>=0;J-=2){for(var O=1;O<=25;O+=8)I<<=1,I|=V>>>O+J&1;for(var O=1;O<=25;O+=8)I<<=1,I|=G>>>O+J&1}U[X+0]=K>>>0,U[X+1]=I>>>0},$.rip=function(G,V,U,X){for(var K=0,I=0,J=0;J<4;J++)for(var O=24;O>=0;O-=8)K<<=1,K|=V>>>O+J&1,K<<=1,K|=G>>>O+J&1;for(var J=4;J<8;J++)for(var O=24;O>=0;O-=8)I<<=1,I|=V>>>O+J&1,I<<=1,I|=G>>>O+J&1;U[X+0]=K>>>0,U[X+1]=I>>>0},$.pc1=function(G,V,U,X){for(var K=0,I=0,J=7;J>=5;J--){for(var O=0;O<=24;O+=8)K<<=1,K|=V>>O+J&1;for(var O=0;O<=24;O+=8)K<<=1,K|=G>>O+J&1}for(var O=0;O<=24;O+=8)K<<=1,K|=V>>O+J&1;for(var J=1;J<=3;J++){for(var O=0;O<=24;O+=8)I<<=1,I|=V>>O+J&1;for(var O=0;O<=24;O+=8)I<<=1,I|=G>>O+J&1}for(var O=0;O<=24;O+=8)I<<=1,I|=G>>O+J&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,J=Q.length>>>1,O=0;O>>Q[O]&1;for(var O=J;O>>Q[O]&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];O=G.r28shl(O,W),F=G.r28shl(F,W),G.pc2(O,F,I.keys,A)}},X.prototype._update=function(I,J,O,F){var A=this._desState,W=G.readUInt32BE(I,J),H=G.readUInt32BE(I,J+4);G.ip(W,H,A.tmp,0),W=A.tmp[0],H=A.tmp[1],this.type==="encrypt"?this._encrypt(A,W,H,A.tmp,0):this._decrypt(A,W,H,A.tmp,0),W=A.tmp[0],H=A.tmp[1],G.writeUInt32BE(O,W,F),G.writeUInt32BE(O,H,F+4)},X.prototype._pad=function(I,J){for(var O=I.length-J,F=J;F>>0,W=R}G.rip(H,W,F,A)},X.prototype._decrypt=function(I,J,O,F,A){for(var W=O,H=J,E=I.keys.length-2;E>=0;E-=2){var T=I.keys[E],D=I.keys[E+1];G.expand(W,I.tmp,0),T^=I.tmp[0],D^=I.tmp[1];var C=G.substitute(T,D),L=G.permute(C),R=W;W=(H^L)>>>0,H=R}G.rip(W,H,F,A)}}}),ZQ=z$({"node_modules/des.js/lib/des/cbc.js"($){var Q=$Q(),Y=q$(),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?O:F);return J}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]^H[C>>>16&255]^E[L>>>8&255]^T[R&255]^J[v++],z=W[C>>>24]^H[L>>>16&255]^E[R>>>8&255]^T[D&255]^J[v++],M=W[L>>>24]^H[R>>>16&255]^E[D>>>8&255]^T[C&255]^J[v++],S=W[R>>>24]^H[D>>>16&255]^E[C>>>8&255]^T[L&255]^J[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])^J[v++],z=(F[C>>>24]<<24|F[L>>>16&255]<<16|F[R>>>8&255]<<8|F[D&255])^J[v++],M=(F[L>>>24]<<24|F[R>>>16&255]<<16|F[D>>>8&255]<<8|F[C&255])^J[v++],S=(F[R>>>24]<<24|F[D>>>16&255]<<16|F[C>>>8&255]<<8|F[L&255])^J[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),J=0;J<256;J++)J<128?I[J]=J<<1:I[J]=J<<1^283;for(var O=[],F=[],A=[[],[],[],[]],W=[[],[],[],[]],H=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,O[H]=D,F[D]=H;var C=I[H],L=I[C],R=I[L],P=I[D]*257^D*16843008;A[0][H]=P<<24|P>>>8,A[1][H]=P<<16|P>>>16,A[2][H]=P<<8|P>>>24,A[3][H]=P,P=R*16843009^L*65537^C*257^H*16843008,W[0][D]=P<<24|P>>>8,W[1][D]=P<<16|P>>>16,W[2][D]=P<<8|P>>>24,W[3][D]=P,H===0?H=E=1:(H=C^I[I[I[R^C]]],E^=I[I[E]])}return{SBOX:O,INV_SBOX:F,SUB_MIX:A,INV_SUB_MIX:W}}();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,J=I.length,O=J+6,F=(O+1)*4,A=[],W=0;W>>24,H=X.SBOX[H>>>24]<<24|X.SBOX[H>>>16&255]<<16|X.SBOX[H>>>8&255]<<8|X.SBOX[H&255],H^=U[W/J|0]<<24):J>6&&W%J===4&&(H=X.SBOX[H>>>24]<<24|X.SBOX[H>>>16&255]<<16|X.SBOX[H>>>8&255]<<8|X.SBOX[H&255]),A[W]=A[W-J]^H}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=O,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 J=this.encryptBlockRaw(I),O=Y.allocUnsafe(16);return O.writeUInt32BE(J[0],0),O.writeUInt32BE(J[1],4),O.writeUInt32BE(J[2],8),O.writeUInt32BE(J[3],12),O},K.prototype.decryptBlock=function(I){I=Z(I);var J=I[1];I[1]=I[3],I[3]=J;var O=V(I,this._invKeySchedule,X.INV_SUB_MIX,X.INV_SBOX,this._nRounds),F=Y.allocUnsafe(16);return F.writeUInt32BE(O[0],0),F.writeUInt32BE(O[3],4),F.writeUInt32BE(O[2],8),F.writeUInt32BE(O[1],12),F},K.prototype.scrub=function(){G(this._keySchedule),G(this._invKeySchedule),G(this._key)},Q.exports.AES=K}}),DQ=z$({"node_modules/browserify-aes/ghash.js"($,Q){var Y=S$().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,O&&(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}}),CQ=z$({"node_modules/browserify-aes/authCipher.js"($,Q){var Y=TQ(),Z=S$().Buffer,G=h$(),V=q$(),U=DQ(),X=KQ(),K=WQ();function I(F,A){var W=0;F.length!==A.length&&W++;for(var H=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 W=0;if(I>0){var H=J.length-I;W=Math.min(I,F.length),F.copy(J,H,0,W),I-=W}if(W0){var E=O.length-K,T=Math.min(K,F.length-W);F.copy(O,E,W,W+T),K-=T}}return F.fill(0),{key:J,iv:O}}Q.exports=G}}),PQ=z$({"node_modules/browserify-aes/encrypter.js"($){var Q=EQ(),Y=CQ(),Z=S$().Buffer,G=LQ(),V=h$(),U=TQ(),X=RQ(),K=q$();function I(W,H,E){V.call(this),this._cache=new O,this._cipher=new U.AES(H),this._prev=Z.from(E),this._mode=W,this._autopadding=!0}K(I,V),I.prototype._update=function(W){this._cache.add(W);for(var H,E,T=[];H=this._cache.get();)E=this._mode.encrypt(this,H),T.push(E);return Z.concat(T)};var J=Z.alloc(16,16);I.prototype._final=function(){var W=this._cache.flush();if(this._autopadding)return W=this._mode.encrypt(this,W),this._cipher.scrub(),W;if(!W.equals(J))throw this._cipher.scrub(),new Error("data not multiple of block length")},I.prototype.setAutoPadding=function(W){return this._autopadding=!!W,this};function O(){this.cache=Z.allocUnsafe(0)}O.prototype.add=function(W){this.cache=Z.concat([this.cache,W])},O.prototype.get=function(){if(this.cache.length>15){var W=this.cache.slice(0,16);return this.cache=this.cache.slice(16),W}return null},O.prototype.flush=function(){for(var W=16-this.cache.length,H=Z.allocUnsafe(W),E=-1;++E16)return H=this.cache.slice(0,16),this.cache=this.cache.slice(16),H}else if(this.cache.length>=16)return H=this.cache.slice(0,16),this.cache=this.cache.slice(16),H;return null},J.prototype.flush=function(){if(this.cache.length)return this.cache};function O(W){var H=W[15];if(H<1||H>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 N=0;j[0]==="-"&&(N++,this.negative=1),N=0;N-=3)_=j[N]|j[N-1]<<8|j[N-2]<<16,this.words[x]|=_<>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);else if(g==="le")for(N=0,x=0;N>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);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 N=K(j,g);return g-1>=k&&(N|=K(j,g-1)<<4),N}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var N=0;N=k;N-=2)B=I(j,k,N)<=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8;else{var y=j.length-k;for(N=y%2===0?k+1:k;N=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8}this.strip()};function J(j,k,g,N){for(var x=0,_=Math.min(j.length,g),B=k;B<_;B++){var y=j.charCodeAt(B)-48;x*=N,y>=49?x+=y-49+10:y>=17?x+=y-17+10:x+=y}return x}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var N=0,x=1;x<=67108863;x*=k)N++;N--,x=x/k|0;for(var _=j.length-g,B=_%N,y=Math.min(_,_-B)+g,w=0,f=g;f1&&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 O=["","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 N=0,x=0,_=0;_>>24-N&16777215,x!==0||_!==this.length-1?g=O[6-y.length]+y+g:g=y+g,N+=2,N>=26&&(N-=26,_--)}for(x!==0&&(g=x.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],f=A[j];g="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(j);p=p.idivn(f),p.isZero()?g=c+g:g=O[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 N=this.byteLength(),x=g||Math.max(1,N);G(N<=x,"byte array longer than desired length"),G(x>0,"Requested array length <= 0"),this.strip();var _=k==="le",B=new j(x),y,w,f=this.clone();if(_){for(w=0;!f.isZero();w++)y=f.andln(255),f.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 W(j){for(var k=new Array(j.bitLength()),g=0;g>>x}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 N=0;Nj.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 N=0;N0&&(this.words[N]=~this.words[N]&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,N=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<j.length?(g=this,N=j):(g=j,N=this);for(var x=0,_=0;_>>26;for(;x!==0&&_>>26;if(this.length=g.length,x!==0)this.words[this.length]=x,this.length++;else if(g!==this)for(;_j.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,x;g>0?(N=this,x=j):(N=j,x=this);for(var _=0,B=0;B>26,this.words[B]=k&67108863;for(;_!==0&&B>26,this.words[B]=k&67108863;if(_===0&&B>>26,c=w&67108863,h=Math.min(f,k.length-1),d=Math.max(0,f-j.length+1);d<=h;d++){var b=f-d|0;x=j.words[b]|0,_=k.words[d]|0,B=x*_+c,p+=B/67108864|0,c=B&67108863}g.words[f]=c|0,w=p|0}return w!==0?g.words[f]=w|0:g.length--,g.strip()}var E=function(j,k,g){var N=j.words,x=k.words,_=g.words,B=0,y,w,f,p=N[0]|0,c=p&8191,h=p>>>13,d=N[1]|0,b=d&8191,l=d>>>13,o=N[2]|0,u=o&8191,n=o>>>13,s=N[3]|0,t=s&8191,m=s>>>13,a=N[4]|0,r=a&8191,e=a>>>13,i=N[5]|0,$0=i&8191,Q0=i>>>13,Y0=N[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=N[7]|0,U0=V0&8191,X0=V0>>>13,K0=N[8]|0,I0=K0&8191,J0=K0>>>13,O0=N[9]|0,F0=O0&8191,A0=O0>>>13,W0=x[0]|0,H0=W0&8191,E0=W0>>>13,T0=x[1]|0,D0=T0&8191,C0=T0>>>13,L0=x[2]|0,R0=L0&8191,P0=L0>>>13,z0=x[3]|0,M0=z0&8191,S0=z0>>>13,v0=x[4]|0,q0=v0&8191,j0=v0>>>13,k0=x[5]|0,g0=k0&8191,N0=k0>>>13,x0=x[6]|0,_0=x0&8191,B0=x0>>>13,y0=x[7]|0,w0=y0&8191,f0=y0>>>13,p0=x[8]|0,c0=p0&8191,h0=p0>>>13,d0=x[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,H0),w=Math.imul(c,E0),w=w+Math.imul(h,H0)|0,f=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,H0),w=Math.imul(b,E0),w=w+Math.imul(l,H0)|0,f=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,f=f+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,H0),w=Math.imul(u,E0),w=w+Math.imul(n,H0)|0,f=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,f=f+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,f=f+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,H0),w=Math.imul(t,E0),w=w+Math.imul(m,H0)|0,f=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,f=f+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,f=f+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,f=f+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(r,H0),w=Math.imul(r,E0),w=w+Math.imul(e,H0)|0,f=Math.imul(e,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,f=f+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,f=f+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,f=f+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,f=f+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,H0),w=Math.imul($0,E0),w=w+Math.imul(Q0,H0)|0,f=Math.imul(Q0,E0),y=y+Math.imul(r,D0)|0,w=w+Math.imul(r,C0)|0,w=w+Math.imul(e,D0)|0,f=f+Math.imul(e,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,f=f+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,f=f+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,f=f+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,N0)|0,w=w+Math.imul(h,g0)|0,f=f+Math.imul(h,N0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,H0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,H0)|0,f=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,f=f+Math.imul(Q0,C0)|0,y=y+Math.imul(r,R0)|0,w=w+Math.imul(r,P0)|0,w=w+Math.imul(e,R0)|0,f=f+Math.imul(e,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,f=f+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,f=f+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,N0)|0,w=w+Math.imul(l,g0)|0,f=f+Math.imul(l,N0)|0,y=y+Math.imul(c,_0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,_0)|0,f=f+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,H0),w=Math.imul(U0,E0),w=w+Math.imul(X0,H0)|0,f=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,f=f+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,f=f+Math.imul(Q0,P0)|0,y=y+Math.imul(r,M0)|0,w=w+Math.imul(r,S0)|0,w=w+Math.imul(e,M0)|0,f=f+Math.imul(e,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,f=f+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,N0)|0,w=w+Math.imul(n,g0)|0,f=f+Math.imul(n,N0)|0,y=y+Math.imul(b,_0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,_0)|0,f=f+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,f0)|0,w=w+Math.imul(h,w0)|0,f=f+Math.imul(h,f0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(I0,H0),w=Math.imul(I0,E0),w=w+Math.imul(J0,H0)|0,f=Math.imul(J0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,S0)|0,y=y+Math.imul(r,q0)|0,w=w+Math.imul(r,j0)|0,w=w+Math.imul(e,q0)|0,f=f+Math.imul(e,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,N0)|0,w=w+Math.imul(m,g0)|0,f=f+Math.imul(m,N0)|0,y=y+Math.imul(u,_0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,_0)|0,f=f+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,f0)|0,w=w+Math.imul(l,w0)|0,f=f+Math.imul(l,f0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,f=f+Math.imul(h,h0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(F0,H0),w=Math.imul(F0,E0),w=w+Math.imul(A0,H0)|0,f=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(J0,D0)|0,f=f+Math.imul(J0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,j0)|0,y=y+Math.imul(r,g0)|0,w=w+Math.imul(r,N0)|0,w=w+Math.imul(e,g0)|0,f=f+Math.imul(e,N0)|0,y=y+Math.imul(t,_0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,_0)|0,f=f+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,f0)|0,w=w+Math.imul(n,w0)|0,f=f+Math.imul(n,f0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,f=f+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,f=f+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(J0,R0)|0,f=f+Math.imul(J0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,f=f+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,f=f+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,N0)|0,w=w+Math.imul(Q0,g0)|0,f=f+Math.imul(Q0,N0)|0,y=y+Math.imul(r,_0)|0,w=w+Math.imul(r,B0)|0,w=w+Math.imul(e,_0)|0,f=f+Math.imul(e,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,f0)|0,w=w+Math.imul(m,w0)|0,f=f+Math.imul(m,f0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,f=f+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,f=f+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,f=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(J0,M0)|0,f=f+Math.imul(J0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,f=f+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,N0)|0,w=w+Math.imul(G0,g0)|0,f=f+Math.imul(G0,N0)|0,y=y+Math.imul($0,_0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,_0)|0,f=f+Math.imul(Q0,B0)|0,y=y+Math.imul(r,w0)|0,w=w+Math.imul(r,f0)|0,w=w+Math.imul(e,w0)|0,f=f+Math.imul(e,f0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,f=f+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,f=f+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(J0,q0)|0,f=f+Math.imul(J0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,N0)|0,w=w+Math.imul(X0,g0)|0,f=f+Math.imul(X0,N0)|0,y=y+Math.imul(Z0,_0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,_0)|0,f=f+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,f0)|0,w=w+Math.imul(Q0,w0)|0,f=f+Math.imul(Q0,f0)|0,y=y+Math.imul(r,c0)|0,w=w+Math.imul(r,h0)|0,w=w+Math.imul(e,c0)|0,f=f+Math.imul(e,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,f=f+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,N0)|0,w=w+Math.imul(J0,g0)|0,f=f+Math.imul(J0,N0)|0,y=y+Math.imul(U0,_0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,_0)|0,f=f+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,f0)|0,w=w+Math.imul(G0,w0)|0,f=f+Math.imul(G0,f0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,f=f+Math.imul(Q0,h0)|0,y=y+Math.imul(r,b0)|0,w=w+Math.imul(r,l0)|0,w=w+Math.imul(e,b0)|0,f=f+Math.imul(e,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,N0),w=w+Math.imul(A0,g0)|0,f=Math.imul(A0,N0),y=y+Math.imul(I0,_0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(J0,_0)|0,f=f+Math.imul(J0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,f0)|0,w=w+Math.imul(X0,w0)|0,f=f+Math.imul(X0,f0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,f=f+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,f=f+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,_0),w=Math.imul(F0,B0),w=w+Math.imul(A0,_0)|0,f=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,f0)|0,w=w+Math.imul(J0,w0)|0,f=f+Math.imul(J0,f0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,f=f+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,f=f+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,f0),w=w+Math.imul(A0,w0)|0,f=Math.imul(A0,f0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(J0,c0)|0,f=f+Math.imul(J0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,f=f+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(J0,b0)|0,f=f+Math.imul(J0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(f+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,_[0]=o0,_[1]=u0,_[2]=n0,_[3]=s0,_[4]=t0,_[5]=m0,_[6]=a0,_[7]=r0,_[8]=e0,_[9]=i0,_[10]=$$,_[11]=Q$,_[12]=Y$,_[13]=Z$,_[14]=G$,_[15]=V$,_[16]=U$,_[17]=X$,_[18]=K$,B!==0&&(_[19]=B,g.length++),g};Math.imul||(E=H);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var N=0,x=0,_=0;_>>26)|0,x+=B>>>26,B&=67108863}g.words[_]=y,N=B,B=x}return N!==0?g.words[_]=N:g.length--,g.strip()}function D(j,k,g){var N=new C;return N.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,N=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):N<63?g=H(this,j,k):N<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,N=0;N>=1;return N},C.prototype.permute=function(j,k,g,N,x,_){for(var B=0;B<_;B++)N[B]=k[j[B]],x[B]=g[j[B]]},C.prototype.transform=function(j,k,g,N,x,_){this.permute(_,j,k,g,N,x);for(var B=1;B>>1)x++;return 1<>>13,g[2*_+1]=x&8191,x=x>>>13;for(_=2*k;_>=26,k+=N/67108864|0,k+=x>>>26,this.words[g]=x&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=W(j);if(k.length===0)return new U(1);for(var g=this,N=0;N=0);var k=j%26,g=(j-k)/26,N=67108863>>>26-k<<26-k,x;if(k!==0){var _=0;for(x=0;x>>26-k}_&&(this.words[x]=_,this.length++)}if(g!==0){for(x=this.length-1;x>=0;x--)this.words[x+g]=this.words[x];for(x=0;x=0);var N;k?N=(k-k%26)/26:N=0;var x=j%26,_=Math.min((j-x)/26,this.length),B=67108863^67108863>>>x<_)for(this.length-=_,w=0;w=0&&(f!==0||w>=N);w--){var p=this.words[w]|0;this.words[w]=f<<26-x|p>>>x,f=p&B}return y&&f!==0&&(y.words[y.length++]=f),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,N=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 N=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[x+g]=_&67108863}for(;x>26,this.words[x+g]=_&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,x=0;x>26,this.words[x]=_&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,N=this.clone(),x=j,_=x.words[x.length-1]|0,B=this._countBits(_);g=26-B,g!==0&&(x=x.ushln(g),N.iushln(g),_=x.words[x.length-1]|0);var y=N.length-x.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var f=0;f=0;c--){var h=(N.words[x.length+c]|0)*67108864+(N.words[x.length+c-1]|0);for(h=Math.min(h/_|0,67108863),N._ishlnsubmul(x,h,c);N.negative!==0;)h--,N.negative=0,N._ishlnsubmul(x,1,c),N.isZero()||(N.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),N.strip(),k!=="div"&&g!==0&&N.iushrn(g),{div:w||null,mod:N}},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?(_=this.neg().divmod(j,k),k!=="mod"&&(N=_.div.neg()),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.iadd(j)),{div:N,mod:x}):this.negative===0&&j.negative!==0?(_=this.divmod(j.neg(),k),k!=="mod"&&(N=_.div.neg()),{div:N,mod:_.mod}):(this.negative&j.negative)!==0?(_=this.neg().divmod(j.neg(),k),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.isub(j)),{div:_.div,mod:x}):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,N=j.ushrn(1),x=j.andln(1),_=g.cmp(N);return _<0||x===1&&_===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,N=this.length-1;N>=0;N--)g=(k*g+(this.words[N]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var N=(this.words[g]|0)+k*67108864;this.words[g]=N/j|0,k=N%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 N=new U(1),x=new U(0),_=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(),f=k.clone();!k.isZero();){for(var p=0,c=1;(k.words[0]&c)===0&&p<26;++p,c<<=1);if(p>0)for(k.iushrn(p);p-- >0;)(N.isOdd()||x.isOdd())&&(N.iadd(w),x.isub(f)),N.iushrn(1),x.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;)(_.isOdd()||B.isOdd())&&(_.iadd(w),B.isub(f)),_.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(_),x.isub(B)):(g.isub(k),_.isub(N),B.isub(x))}return{a:_,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 N=new U(1),x=new U(0),_=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;)N.isOdd()&&N.iadd(_),N.iushrn(1);for(var w=0,f=1;(g.words[0]&f)===0&&w<26;++w,f<<=1);if(w>0)for(g.iushrn(w);w-- >0;)x.isOdd()&&x.iadd(_),x.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(x)):(g.isub(k),x.isub(N))}var p;return k.cmpn(1)===0?p=N:p=x,p.cmpn(0)<0&&p.iadd(j),p},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 N=0;k.isEven()&&g.isEven();N++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var x=k.cmp(g);if(x<0){var _=k;k=g,g=_}else if(x===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(N)},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,N=1<>>26,B&=67108863,this.words[_]=B}return x!==0&&(this.words[_]=x,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 N=this.words[0]|0;g=N===j?0:Nj.length)return 1;if(this.length=0;g--){var N=this.words[g]|0,x=j.words[g]|0;if(N!==x){Nx&&(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 N=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,N=Math.min(j.length,9),x=0;x>>22,_=B}_>>>=22,j.words[x-10]=_,_===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]=x,k=N}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 N=this.m.subn(1),x=0;!N.isZero()&&N.andln(1)===0;)x++,N.iushrn(1);G(!N.isZero());var _=new U(1).toRed(this),B=_.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 f=this.pow(w,N),p=this.pow(j,N.addn(1).iushrn(1)),c=this.pow(j,N),h=x;c.cmp(_)!==0;){for(var d=c,b=0;d.cmp(_)!==0;b++)d=d.redSqr();G(b=0;x--){for(var f=k.words[x],p=w-1;p>=0;p--){var c=f>>p&1;if(_!==N[0]&&(_=this.sqr(_)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(x!==0||p!==0))&&(_=this.mul(_,N[B]),y=0,B=0)}w=26}return _},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),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._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,$)}}),jQ=z$({"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;try{typeof window<"u"&&typeof window.Buffer<"u"?X=window.Buffer:X=R$("buffer").Buffer}catch{}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 N=0;j[0]==="-"&&(N++,this.negative=1),N=0;N-=3)_=j[N]|j[N-1]<<8|j[N-2]<<16,this.words[x]|=_<>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);else if(g==="le")for(N=0,x=0;N>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);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 N=K(j,g);return g-1>=k&&(N|=K(j,g-1)<<4),N}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var N=0;N=k;N-=2)B=I(j,k,N)<=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8;else{var y=j.length-k;for(N=y%2===0?k+1:k;N=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8}this.strip()};function J(j,k,g,N){for(var x=0,_=Math.min(j.length,g),B=k;B<_;B++){var y=j.charCodeAt(B)-48;x*=N,y>=49?x+=y-49+10:y>=17?x+=y-17+10:x+=y}return x}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var N=0,x=1;x<=67108863;x*=k)N++;N--,x=x/k|0;for(var _=j.length-g,B=_%N,y=Math.min(_,_-B)+g,w=0,f=g;f1&&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 O=["","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 N=0,x=0,_=0;_>>24-N&16777215,x!==0||_!==this.length-1?g=O[6-y.length]+y+g:g=y+g,N+=2,N>=26&&(N-=26,_--)}for(x!==0&&(g=x.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],f=A[j];g="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(j);p=p.idivn(f),p.isZero()?g=c+g:g=O[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 N=this.byteLength(),x=g||Math.max(1,N);G(N<=x,"byte array longer than desired length"),G(x>0,"Requested array length <= 0"),this.strip();var _=k==="le",B=new j(x),y,w,f=this.clone();if(_){for(w=0;!f.isZero();w++)y=f.andln(255),f.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 W(j){for(var k=new Array(j.bitLength()),g=0;g>>x}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 N=0;Nj.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 N=0;N0&&(this.words[N]=~this.words[N]&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,N=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<j.length?(g=this,N=j):(g=j,N=this);for(var x=0,_=0;_>>26;for(;x!==0&&_>>26;if(this.length=g.length,x!==0)this.words[this.length]=x,this.length++;else if(g!==this)for(;_j.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,x;g>0?(N=this,x=j):(N=j,x=this);for(var _=0,B=0;B>26,this.words[B]=k&67108863;for(;_!==0&&B>26,this.words[B]=k&67108863;if(_===0&&B>>26,c=w&67108863,h=Math.min(f,k.length-1),d=Math.max(0,f-j.length+1);d<=h;d++){var b=f-d|0;x=j.words[b]|0,_=k.words[d]|0,B=x*_+c,p+=B/67108864|0,c=B&67108863}g.words[f]=c|0,w=p|0}return w!==0?g.words[f]=w|0:g.length--,g.strip()}var E=function(j,k,g){var N=j.words,x=k.words,_=g.words,B=0,y,w,f,p=N[0]|0,c=p&8191,h=p>>>13,d=N[1]|0,b=d&8191,l=d>>>13,o=N[2]|0,u=o&8191,n=o>>>13,s=N[3]|0,t=s&8191,m=s>>>13,a=N[4]|0,r=a&8191,e=a>>>13,i=N[5]|0,$0=i&8191,Q0=i>>>13,Y0=N[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=N[7]|0,U0=V0&8191,X0=V0>>>13,K0=N[8]|0,I0=K0&8191,J0=K0>>>13,O0=N[9]|0,F0=O0&8191,A0=O0>>>13,W0=x[0]|0,H0=W0&8191,E0=W0>>>13,T0=x[1]|0,D0=T0&8191,C0=T0>>>13,L0=x[2]|0,R0=L0&8191,P0=L0>>>13,z0=x[3]|0,M0=z0&8191,S0=z0>>>13,v0=x[4]|0,q0=v0&8191,j0=v0>>>13,k0=x[5]|0,g0=k0&8191,N0=k0>>>13,x0=x[6]|0,_0=x0&8191,B0=x0>>>13,y0=x[7]|0,w0=y0&8191,f0=y0>>>13,p0=x[8]|0,c0=p0&8191,h0=p0>>>13,d0=x[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,H0),w=Math.imul(c,E0),w=w+Math.imul(h,H0)|0,f=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,H0),w=Math.imul(b,E0),w=w+Math.imul(l,H0)|0,f=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,f=f+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,H0),w=Math.imul(u,E0),w=w+Math.imul(n,H0)|0,f=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,f=f+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,f=f+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,H0),w=Math.imul(t,E0),w=w+Math.imul(m,H0)|0,f=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,f=f+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,f=f+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,f=f+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(r,H0),w=Math.imul(r,E0),w=w+Math.imul(e,H0)|0,f=Math.imul(e,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,f=f+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,f=f+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,f=f+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,f=f+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,H0),w=Math.imul($0,E0),w=w+Math.imul(Q0,H0)|0,f=Math.imul(Q0,E0),y=y+Math.imul(r,D0)|0,w=w+Math.imul(r,C0)|0,w=w+Math.imul(e,D0)|0,f=f+Math.imul(e,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,f=f+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,f=f+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,f=f+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,N0)|0,w=w+Math.imul(h,g0)|0,f=f+Math.imul(h,N0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,H0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,H0)|0,f=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,f=f+Math.imul(Q0,C0)|0,y=y+Math.imul(r,R0)|0,w=w+Math.imul(r,P0)|0,w=w+Math.imul(e,R0)|0,f=f+Math.imul(e,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,f=f+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,f=f+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,N0)|0,w=w+Math.imul(l,g0)|0,f=f+Math.imul(l,N0)|0,y=y+Math.imul(c,_0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,_0)|0,f=f+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,H0),w=Math.imul(U0,E0),w=w+Math.imul(X0,H0)|0,f=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,f=f+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,f=f+Math.imul(Q0,P0)|0,y=y+Math.imul(r,M0)|0,w=w+Math.imul(r,S0)|0,w=w+Math.imul(e,M0)|0,f=f+Math.imul(e,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,f=f+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,N0)|0,w=w+Math.imul(n,g0)|0,f=f+Math.imul(n,N0)|0,y=y+Math.imul(b,_0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,_0)|0,f=f+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,f0)|0,w=w+Math.imul(h,w0)|0,f=f+Math.imul(h,f0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(I0,H0),w=Math.imul(I0,E0),w=w+Math.imul(J0,H0)|0,f=Math.imul(J0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,S0)|0,y=y+Math.imul(r,q0)|0,w=w+Math.imul(r,j0)|0,w=w+Math.imul(e,q0)|0,f=f+Math.imul(e,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,N0)|0,w=w+Math.imul(m,g0)|0,f=f+Math.imul(m,N0)|0,y=y+Math.imul(u,_0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,_0)|0,f=f+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,f0)|0,w=w+Math.imul(l,w0)|0,f=f+Math.imul(l,f0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,f=f+Math.imul(h,h0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(F0,H0),w=Math.imul(F0,E0),w=w+Math.imul(A0,H0)|0,f=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(J0,D0)|0,f=f+Math.imul(J0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,j0)|0,y=y+Math.imul(r,g0)|0,w=w+Math.imul(r,N0)|0,w=w+Math.imul(e,g0)|0,f=f+Math.imul(e,N0)|0,y=y+Math.imul(t,_0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,_0)|0,f=f+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,f0)|0,w=w+Math.imul(n,w0)|0,f=f+Math.imul(n,f0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,f=f+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,f=f+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(J0,R0)|0,f=f+Math.imul(J0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,f=f+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,f=f+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,N0)|0,w=w+Math.imul(Q0,g0)|0,f=f+Math.imul(Q0,N0)|0,y=y+Math.imul(r,_0)|0,w=w+Math.imul(r,B0)|0,w=w+Math.imul(e,_0)|0,f=f+Math.imul(e,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,f0)|0,w=w+Math.imul(m,w0)|0,f=f+Math.imul(m,f0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,f=f+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,f=f+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,f=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(J0,M0)|0,f=f+Math.imul(J0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,f=f+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,N0)|0,w=w+Math.imul(G0,g0)|0,f=f+Math.imul(G0,N0)|0,y=y+Math.imul($0,_0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,_0)|0,f=f+Math.imul(Q0,B0)|0,y=y+Math.imul(r,w0)|0,w=w+Math.imul(r,f0)|0,w=w+Math.imul(e,w0)|0,f=f+Math.imul(e,f0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,f=f+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,f=f+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(J0,q0)|0,f=f+Math.imul(J0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,N0)|0,w=w+Math.imul(X0,g0)|0,f=f+Math.imul(X0,N0)|0,y=y+Math.imul(Z0,_0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,_0)|0,f=f+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,f0)|0,w=w+Math.imul(Q0,w0)|0,f=f+Math.imul(Q0,f0)|0,y=y+Math.imul(r,c0)|0,w=w+Math.imul(r,h0)|0,w=w+Math.imul(e,c0)|0,f=f+Math.imul(e,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,f=f+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,N0)|0,w=w+Math.imul(J0,g0)|0,f=f+Math.imul(J0,N0)|0,y=y+Math.imul(U0,_0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,_0)|0,f=f+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,f0)|0,w=w+Math.imul(G0,w0)|0,f=f+Math.imul(G0,f0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,f=f+Math.imul(Q0,h0)|0,y=y+Math.imul(r,b0)|0,w=w+Math.imul(r,l0)|0,w=w+Math.imul(e,b0)|0,f=f+Math.imul(e,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,N0),w=w+Math.imul(A0,g0)|0,f=Math.imul(A0,N0),y=y+Math.imul(I0,_0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(J0,_0)|0,f=f+Math.imul(J0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,f0)|0,w=w+Math.imul(X0,w0)|0,f=f+Math.imul(X0,f0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,f=f+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,f=f+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,_0),w=Math.imul(F0,B0),w=w+Math.imul(A0,_0)|0,f=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,f0)|0,w=w+Math.imul(J0,w0)|0,f=f+Math.imul(J0,f0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,f=f+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,f=f+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,f0),w=w+Math.imul(A0,w0)|0,f=Math.imul(A0,f0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(J0,c0)|0,f=f+Math.imul(J0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,f=f+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(J0,b0)|0,f=f+Math.imul(J0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(f+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,_[0]=o0,_[1]=u0,_[2]=n0,_[3]=s0,_[4]=t0,_[5]=m0,_[6]=a0,_[7]=r0,_[8]=e0,_[9]=i0,_[10]=$$,_[11]=Q$,_[12]=Y$,_[13]=Z$,_[14]=G$,_[15]=V$,_[16]=U$,_[17]=X$,_[18]=K$,B!==0&&(_[19]=B,g.length++),g};Math.imul||(E=H);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var N=0,x=0,_=0;_>>26)|0,x+=B>>>26,B&=67108863}g.words[_]=y,N=B,B=x}return N!==0?g.words[_]=N:g.length--,g.strip()}function D(j,k,g){var N=new C;return N.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,N=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):N<63?g=H(this,j,k):N<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,N=0;N>=1;return N},C.prototype.permute=function(j,k,g,N,x,_){for(var B=0;B<_;B++)N[B]=k[j[B]],x[B]=g[j[B]]},C.prototype.transform=function(j,k,g,N,x,_){this.permute(_,j,k,g,N,x);for(var B=1;B>>1)x++;return 1<>>13,g[2*_+1]=x&8191,x=x>>>13;for(_=2*k;_>=26,k+=N/67108864|0,k+=x>>>26,this.words[g]=x&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=W(j);if(k.length===0)return new U(1);for(var g=this,N=0;N=0);var k=j%26,g=(j-k)/26,N=67108863>>>26-k<<26-k,x;if(k!==0){var _=0;for(x=0;x>>26-k}_&&(this.words[x]=_,this.length++)}if(g!==0){for(x=this.length-1;x>=0;x--)this.words[x+g]=this.words[x];for(x=0;x=0);var N;k?N=(k-k%26)/26:N=0;var x=j%26,_=Math.min((j-x)/26,this.length),B=67108863^67108863>>>x<_)for(this.length-=_,w=0;w=0&&(f!==0||w>=N);w--){var p=this.words[w]|0;this.words[w]=f<<26-x|p>>>x,f=p&B}return y&&f!==0&&(y.words[y.length++]=f),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,N=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 N=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[x+g]=_&67108863}for(;x>26,this.words[x+g]=_&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,x=0;x>26,this.words[x]=_&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,N=this.clone(),x=j,_=x.words[x.length-1]|0,B=this._countBits(_);g=26-B,g!==0&&(x=x.ushln(g),N.iushln(g),_=x.words[x.length-1]|0);var y=N.length-x.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var f=0;f=0;c--){var h=(N.words[x.length+c]|0)*67108864+(N.words[x.length+c-1]|0);for(h=Math.min(h/_|0,67108863),N._ishlnsubmul(x,h,c);N.negative!==0;)h--,N.negative=0,N._ishlnsubmul(x,1,c),N.isZero()||(N.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),N.strip(),k!=="div"&&g!==0&&N.iushrn(g),{div:w||null,mod:N}},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?(_=this.neg().divmod(j,k),k!=="mod"&&(N=_.div.neg()),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.iadd(j)),{div:N,mod:x}):this.negative===0&&j.negative!==0?(_=this.divmod(j.neg(),k),k!=="mod"&&(N=_.div.neg()),{div:N,mod:_.mod}):(this.negative&j.negative)!==0?(_=this.neg().divmod(j.neg(),k),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.isub(j)),{div:_.div,mod:x}):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,N=j.ushrn(1),x=j.andln(1),_=g.cmp(N);return _<0||x===1&&_===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,N=this.length-1;N>=0;N--)g=(k*g+(this.words[N]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var N=(this.words[g]|0)+k*67108864;this.words[g]=N/j|0,k=N%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 N=new U(1),x=new U(0),_=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(),f=k.clone();!k.isZero();){for(var p=0,c=1;(k.words[0]&c)===0&&p<26;++p,c<<=1);if(p>0)for(k.iushrn(p);p-- >0;)(N.isOdd()||x.isOdd())&&(N.iadd(w),x.isub(f)),N.iushrn(1),x.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;)(_.isOdd()||B.isOdd())&&(_.iadd(w),B.isub(f)),_.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(_),x.isub(B)):(g.isub(k),_.isub(N),B.isub(x))}return{a:_,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 N=new U(1),x=new U(0),_=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;)N.isOdd()&&N.iadd(_),N.iushrn(1);for(var w=0,f=1;(g.words[0]&f)===0&&w<26;++w,f<<=1);if(w>0)for(g.iushrn(w);w-- >0;)x.isOdd()&&x.iadd(_),x.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(x)):(g.isub(k),x.isub(N))}var p;return k.cmpn(1)===0?p=N:p=x,p.cmpn(0)<0&&p.iadd(j),p},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 N=0;k.isEven()&&g.isEven();N++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var x=k.cmp(g);if(x<0){var _=k;k=g,g=_}else if(x===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(N)},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,N=1<>>26,B&=67108863,this.words[_]=B}return x!==0&&(this.words[_]=x,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 N=this.words[0]|0;g=N===j?0:Nj.length)return 1;if(this.length=0;g--){var N=this.words[g]|0,x=j.words[g]|0;if(N!==x){Nx&&(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 N=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,N=Math.min(j.length,9),x=0;x>>22,_=B}_>>>=22,j.words[x-10]=_,_===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]=x,k=N}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 N=this.m.subn(1),x=0;!N.isZero()&&N.andln(1)===0;)x++,N.iushrn(1);G(!N.isZero());var _=new U(1).toRed(this),B=_.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 f=this.pow(w,N),p=this.pow(j,N.addn(1).iushrn(1)),c=this.pow(j,N),h=x;c.cmp(_)!==0;){for(var d=c,b=0;d.cmp(_)!==0;b++)d=d.redSqr();G(b=0;x--){for(var f=k.words[x],p=w-1;p>=0;p--){var c=f>>p&1;if(_!==N[0]&&(_=this.sqr(_)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(x!==0||p!==0))&&(_=this.mul(_,N[B]),y=0,B=0)}w=26}return _},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),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._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,$)}}),kQ=z$({"(disabled):node_modules/crypto-browserify/index.js"(){}}),gQ=z$({"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 Buffer(G);return F$.getRandomValues(V),V}}}),NQ=z$({"node_modules/miller-rabin/lib/mr.js"($,Q){var Y=jQ(),Z=gQ();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),J=new Y(1).toRed(I);U||(U=Math.max(1,K/48|0));for(var O=V.subn(1),F=0;!O.testn(F);F++);for(var A=V.shrn(F),W=O.toRed(I),H=!0;U>0;U--){var E=this._randrange(new Y(2),O);X&&X(E);var T=E.toRed(I).redPow(A);if(!(T.cmp(J)===0||T.cmp(W)===0)){for(var D=1;D0;U--){var W=this._randrange(new Y(2),J),H=V.gcd(W);if(H.cmpn(1)!==0)return H;var E=W.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(H);)S.iadd(E);if(v=S.shrn(1),L(v)&&L(S)&&R(v)&&R(S)&&U.test(v)&&U.test(S))return S}}}}),_Q=z$({"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"}}}}),BQ=z$({"node_modules/diffie-hellman/lib/dh.js"($,Q){var Y=qQ(),Z=NQ(),G=new Z,V=new Y(24),U=new Y(11),X=new Y(10),K=new Y(3),I=new Y(7),J=xQ(),O=v$();Q.exports=E;function F(D,C){return C=C||"utf8",Buffer.isBuffer(D)||(D=new Buffer(D,C)),this._pub=new Y(D),this}function A(D,C){return C=C||"utf8",Buffer.isBuffer(D)||(D=new Buffer(D,C)),this._priv=new Y(D),this}var W={};function H(D,C){var L=C.toString("hex"),R=[L,D.toString(16)].join("_");if(R in W)return W[R];var P=0;if(D.isEven()||!J.simpleSieve||!J.fermatTest(D)||!G.test(D))return P+=1,L==="02"||L==="05"?P+=8:P+=4,W[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 W[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=H(this.__prime,this.__gen)),this._primeCode}}),E.prototype.generateKeys=function(){return this._priv||(this._priv=new Y(O(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 Buffer(C.toArray()),R=this.getPrime();if(L.length0?N:x},U.min=function(N,x){return N.cmp(x)<0?N:x},U.prototype._init=function(N,x,_){if(typeof N=="number")return this._initNumber(N,x,_);if(typeof N=="object")return this._initArray(N,x,_);x==="hex"&&(x=16),G(x===(x|0)&&x>=2&&x<=36),N=N.toString().replace(/\s+/g,"");var B=0;N[0]==="-"&&(B++,this.negative=1),B=0;B-=3)w=N[B]|N[B-1]<<8|N[B-2]<<16,this.words[y]|=w<>>26-f&67108863,f+=24,f>=26&&(f-=26,y++);else if(_==="le")for(B=0,y=0;B>>26-f&67108863,f+=24,f>=26&&(f-=26,y++);return this._strip()};function K(N,x){var _=N.charCodeAt(x);if(_>=48&&_<=57)return _-48;if(_>=65&&_<=70)return _-55;if(_>=97&&_<=102)return _-87;G(!1,"Invalid character in "+N)}function I(N,x,_){var B=K(N,_);return _-1>=x&&(B|=K(N,_-1)<<4),B}U.prototype._parseHex=function(N,x,_){this.length=Math.ceil((N.length-x)/6),this.words=new Array(this.length);for(var B=0;B=x;B-=2)f=I(N,x,B)<=18?(y-=18,w+=1,this.words[w]|=f>>>26):y+=8;else{var p=N.length-x;for(B=p%2===0?x+1:x;B=18?(y-=18,w+=1,this.words[w]|=f>>>26):y+=8}this._strip()};function J(N,x,_,B){for(var y=0,w=0,f=Math.min(N.length,_),p=x;p=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"],W=[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],H=[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,x){N=N||10,x=x|0||1;var _;if(N===16||N==="hex"){_="";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?_=A[6-p.length]+p+_:_=p+_}for(y!==0&&(_=y.toString(16)+_);_.length%x!==0;)_="0"+_;return this.negative!==0&&(_="-"+_),_}if(N===(N|0)&&N>=2&&N<=36){var c=W[N],h=H[N];_="";var d=this.clone();for(d.negative=0;!d.isZero();){var b=d.modrn(h).toString(N);d=d.idivn(h),d.isZero()?_=b+_:_=A[c-b.length]+b+_}for(this.isZero()&&(_="0"+_);_.length%x!==0;)_="0"+_;return this.negative!==0&&(_="-"+_),_}G(!1,"Base should be between 2 and 36")},U.prototype.toNumber=function(){var N=this.words[0];return this.length===2?N+=this.words[1]*67108864:this.length===3&&this.words[2]===1?N+=4503599627370496+this.words[1]*67108864:this.length>2&&G(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-N:N},U.prototype.toJSON=function(){return this.toString(16,2)},X&&(U.prototype.toBuffer=function(N,x){return this.toArrayLike(X,N,x)}),U.prototype.toArray=function(N,x){return this.toArrayLike(Array,N,x)};var E=function(N,x){return N.allocUnsafe?N.allocUnsafe(x):new N(x)};U.prototype.toArrayLike=function(N,x,_){this._strip();var B=this.byteLength(),y=_||Math.max(1,B);G(B<=y,"byte array longer than desired length"),G(y>0,"Requested array length <= 0");var w=E(N,y),f=x==="le"?"LE":"BE";return this["_toArrayLike"+f](w,B),w},U.prototype._toArrayLikeLE=function(N,x){for(var _=0,B=0,y=0,w=0;y>8&255),_>16&255),w===6?(_>24&255),B=0,w=0):(B=f>>>24,w+=2)}if(_=0&&(N[_--]=f>>8&255),_>=0&&(N[_--]=f>>16&255),w===6?(_>=0&&(N[_--]=f>>24&255),B=0,w=0):(B=f>>>24,w+=2)}if(_>=0)for(N[_--]=B;_>=0;)N[_--]=0},Math.clz32?U.prototype._countBits=function(N){return 32-Math.clz32(N)}:U.prototype._countBits=function(N){var x=N,_=0;return x>=4096&&(_+=13,x>>>=13),x>=64&&(_+=7,x>>>=7),x>=8&&(_+=4,x>>>=4),x>=2&&(_+=2,x>>>=2),_+x},U.prototype._zeroBits=function(N){if(N===0)return 26;var x=N,_=0;return(x&8191)===0&&(_+=13,x>>>=13),(x&127)===0&&(_+=7,x>>>=7),(x&15)===0&&(_+=4,x>>>=4),(x&3)===0&&(_+=2,x>>>=2),(x&1)===0&&_++,_},U.prototype.bitLength=function(){var N=this.words[this.length-1],x=this._countBits(N);return(this.length-1)*26+x};function T(N){for(var x=new Array(N.bitLength()),_=0;_>>y&1}return x}U.prototype.zeroBits=function(){if(this.isZero())return 0;for(var N=0,x=0;xN.length?this.clone().ior(N):N.clone().ior(this)},U.prototype.uor=function(N){return this.length>N.length?this.clone().iuor(N):N.clone().iuor(this)},U.prototype.iuand=function(N){var x;this.length>N.length?x=N:x=this;for(var _=0;_N.length?this.clone().iand(N):N.clone().iand(this)},U.prototype.uand=function(N){return this.length>N.length?this.clone().iuand(N):N.clone().iuand(this)},U.prototype.iuxor=function(N){var x,_;this.length>N.length?(x=this,_=N):(x=N,_=this);for(var B=0;B<_.length;B++)this.words[B]=x.words[B]^_.words[B];if(this!==x)for(;BN.length?this.clone().ixor(N):N.clone().ixor(this)},U.prototype.uxor=function(N){return this.length>N.length?this.clone().iuxor(N):N.clone().iuxor(this)},U.prototype.inotn=function(N){G(typeof N=="number"&&N>=0);var x=Math.ceil(N/26)|0,_=N%26;this._expand(x),_>0&&x--;for(var B=0;B0&&(this.words[B]=~this.words[B]&67108863>>26-_),this._strip()},U.prototype.notn=function(N){return this.clone().inotn(N)},U.prototype.setn=function(N,x){G(typeof N=="number"&&N>=0);var _=N/26|0,B=N%26;return this._expand(_+1),x?this.words[_]=this.words[_]|1<N.length?(_=this,B=N):(_=N,B=this);for(var y=0,w=0;w>>26;for(;y!==0&&w<_.length;w++)x=(_.words[w]|0)+y,this.words[w]=x&67108863,y=x>>>26;if(this.length=_.length,y!==0)this.words[this.length]=y,this.length++;else if(_!==this)for(;w<_.length;w++)this.words[w]=_.words[w];return this},U.prototype.add=function(N){var x;return N.negative!==0&&this.negative===0?(N.negative=0,x=this.sub(N),N.negative^=1,x):N.negative===0&&this.negative!==0?(this.negative=0,x=N.sub(this),this.negative=1,x):this.length>N.length?this.clone().iadd(N):N.clone().iadd(this)},U.prototype.isub=function(N){if(N.negative!==0){N.negative=0;var x=this.iadd(N);return N.negative=1,x._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(N),this.negative=1,this._normSign();var _=this.cmp(N);if(_===0)return this.negative=0,this.length=1,this.words[0]=0,this;var B,y;_>0?(B=this,y=N):(B=N,y=this);for(var w=0,f=0;f>26,this.words[f]=x&67108863;for(;w!==0&&f>26,this.words[f]=x&67108863;if(w===0&&f>>26,b=c&67108863,l=Math.min(h,x.length-1),o=Math.max(0,h-N.length+1);o<=l;o++){var u=h-o|0;y=N.words[u]|0,w=x.words[o]|0,f=y*w+b,d+=f/67108864|0,b=f&67108863}_.words[h]=b|0,c=d|0}return c!==0?_.words[h]=c|0:_.length--,_._strip()}var C=function(N,x,_){var B=N.words,y=x.words,w=_.words,f=0,p,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,r=a&8191,e=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,J0=K0>>>13,O0=B[8]|0,F0=O0&8191,A0=O0>>>13,W0=B[9]|0,H0=W0&8191,E0=W0>>>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,N0=k0>>>13,x0=y[5]|0,_0=x0&8191,B0=x0>>>13,y0=y[6]|0,w0=y0&8191,f0=y0>>>13,p0=y[7]|0,c0=p0&8191,h0=p0>>>13,d0=y[8]|0,b0=d0&8191,l0=d0>>>13,o0=y[9]|0,u0=o0&8191,n0=o0>>>13;_.negative=N.negative^x.negative,_.length=19,p=Math.imul(b,D0),c=Math.imul(b,C0),c=c+Math.imul(l,D0)|0,h=Math.imul(l,C0);var s0=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(s0>>>26)|0,s0&=67108863,p=Math.imul(u,D0),c=Math.imul(u,C0),c=c+Math.imul(n,D0)|0,h=Math.imul(n,C0),p=p+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=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(t0>>>26)|0,t0&=67108863,p=Math.imul(t,D0),c=Math.imul(t,C0),c=c+Math.imul(m,D0)|0,h=Math.imul(m,C0),p=p+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,p=p+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=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(m0>>>26)|0,m0&=67108863,p=Math.imul(r,D0),c=Math.imul(r,C0),c=c+Math.imul(e,D0)|0,h=Math.imul(e,C0),p=p+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,p=p+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,p=p+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=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(a0>>>26)|0,a0&=67108863,p=Math.imul($0,D0),c=Math.imul($0,C0),c=c+Math.imul(Q0,D0)|0,h=Math.imul(Q0,C0),p=p+Math.imul(r,R0)|0,c=c+Math.imul(r,P0)|0,c=c+Math.imul(e,R0)|0,h=h+Math.imul(e,P0)|0,p=p+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,p=p+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,p=p+Math.imul(b,g0)|0,c=c+Math.imul(b,N0)|0,c=c+Math.imul(l,g0)|0,h=h+Math.imul(l,N0)|0;var r0=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(r0>>>26)|0,r0&=67108863,p=Math.imul(Z0,D0),c=Math.imul(Z0,C0),c=c+Math.imul(G0,D0)|0,h=Math.imul(G0,C0),p=p+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,p=p+Math.imul(r,M0)|0,c=c+Math.imul(r,S0)|0,c=c+Math.imul(e,M0)|0,h=h+Math.imul(e,S0)|0,p=p+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,p=p+Math.imul(u,g0)|0,c=c+Math.imul(u,N0)|0,c=c+Math.imul(n,g0)|0,h=h+Math.imul(n,N0)|0,p=p+Math.imul(b,_0)|0,c=c+Math.imul(b,B0)|0,c=c+Math.imul(l,_0)|0,h=h+Math.imul(l,B0)|0;var e0=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(e0>>>26)|0,e0&=67108863,p=Math.imul(U0,D0),c=Math.imul(U0,C0),c=c+Math.imul(X0,D0)|0,h=Math.imul(X0,C0),p=p+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,p=p+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,p=p+Math.imul(r,q0)|0,c=c+Math.imul(r,j0)|0,c=c+Math.imul(e,q0)|0,h=h+Math.imul(e,j0)|0,p=p+Math.imul(t,g0)|0,c=c+Math.imul(t,N0)|0,c=c+Math.imul(m,g0)|0,h=h+Math.imul(m,N0)|0,p=p+Math.imul(u,_0)|0,c=c+Math.imul(u,B0)|0,c=c+Math.imul(n,_0)|0,h=h+Math.imul(n,B0)|0,p=p+Math.imul(b,w0)|0,c=c+Math.imul(b,f0)|0,c=c+Math.imul(l,w0)|0,h=h+Math.imul(l,f0)|0;var i0=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(i0>>>26)|0,i0&=67108863,p=Math.imul(I0,D0),c=Math.imul(I0,C0),c=c+Math.imul(J0,D0)|0,h=Math.imul(J0,C0),p=p+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,p=p+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,p=p+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,p=p+Math.imul(r,g0)|0,c=c+Math.imul(r,N0)|0,c=c+Math.imul(e,g0)|0,h=h+Math.imul(e,N0)|0,p=p+Math.imul(t,_0)|0,c=c+Math.imul(t,B0)|0,c=c+Math.imul(m,_0)|0,h=h+Math.imul(m,B0)|0,p=p+Math.imul(u,w0)|0,c=c+Math.imul(u,f0)|0,c=c+Math.imul(n,w0)|0,h=h+Math.imul(n,f0)|0,p=p+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 $$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+($$>>>26)|0,$$&=67108863,p=Math.imul(F0,D0),c=Math.imul(F0,C0),c=c+Math.imul(A0,D0)|0,h=Math.imul(A0,C0),p=p+Math.imul(I0,R0)|0,c=c+Math.imul(I0,P0)|0,c=c+Math.imul(J0,R0)|0,h=h+Math.imul(J0,P0)|0,p=p+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,p=p+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,p=p+Math.imul($0,g0)|0,c=c+Math.imul($0,N0)|0,c=c+Math.imul(Q0,g0)|0,h=h+Math.imul(Q0,N0)|0,p=p+Math.imul(r,_0)|0,c=c+Math.imul(r,B0)|0,c=c+Math.imul(e,_0)|0,h=h+Math.imul(e,B0)|0,p=p+Math.imul(t,w0)|0,c=c+Math.imul(t,f0)|0,c=c+Math.imul(m,w0)|0,h=h+Math.imul(m,f0)|0,p=p+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,p=p+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$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,p=Math.imul(H0,D0),c=Math.imul(H0,C0),c=c+Math.imul(E0,D0)|0,h=Math.imul(E0,C0),p=p+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,p=p+Math.imul(I0,M0)|0,c=c+Math.imul(I0,S0)|0,c=c+Math.imul(J0,M0)|0,h=h+Math.imul(J0,S0)|0,p=p+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,p=p+Math.imul(Z0,g0)|0,c=c+Math.imul(Z0,N0)|0,c=c+Math.imul(G0,g0)|0,h=h+Math.imul(G0,N0)|0,p=p+Math.imul($0,_0)|0,c=c+Math.imul($0,B0)|0,c=c+Math.imul(Q0,_0)|0,h=h+Math.imul(Q0,B0)|0,p=p+Math.imul(r,w0)|0,c=c+Math.imul(r,f0)|0,c=c+Math.imul(e,w0)|0,h=h+Math.imul(e,f0)|0,p=p+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,p=p+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,p=p+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$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(Y$>>>26)|0,Y$&=67108863,p=Math.imul(H0,R0),c=Math.imul(H0,P0),c=c+Math.imul(E0,R0)|0,h=Math.imul(E0,P0),p=p+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,p=p+Math.imul(I0,q0)|0,c=c+Math.imul(I0,j0)|0,c=c+Math.imul(J0,q0)|0,h=h+Math.imul(J0,j0)|0,p=p+Math.imul(U0,g0)|0,c=c+Math.imul(U0,N0)|0,c=c+Math.imul(X0,g0)|0,h=h+Math.imul(X0,N0)|0,p=p+Math.imul(Z0,_0)|0,c=c+Math.imul(Z0,B0)|0,c=c+Math.imul(G0,_0)|0,h=h+Math.imul(G0,B0)|0,p=p+Math.imul($0,w0)|0,c=c+Math.imul($0,f0)|0,c=c+Math.imul(Q0,w0)|0,h=h+Math.imul(Q0,f0)|0,p=p+Math.imul(r,c0)|0,c=c+Math.imul(r,h0)|0,c=c+Math.imul(e,c0)|0,h=h+Math.imul(e,h0)|0,p=p+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,p=p+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$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,p=Math.imul(H0,M0),c=Math.imul(H0,S0),c=c+Math.imul(E0,M0)|0,h=Math.imul(E0,S0),p=p+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,p=p+Math.imul(I0,g0)|0,c=c+Math.imul(I0,N0)|0,c=c+Math.imul(J0,g0)|0,h=h+Math.imul(J0,N0)|0,p=p+Math.imul(U0,_0)|0,c=c+Math.imul(U0,B0)|0,c=c+Math.imul(X0,_0)|0,h=h+Math.imul(X0,B0)|0,p=p+Math.imul(Z0,w0)|0,c=c+Math.imul(Z0,f0)|0,c=c+Math.imul(G0,w0)|0,h=h+Math.imul(G0,f0)|0,p=p+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,p=p+Math.imul(r,b0)|0,c=c+Math.imul(r,l0)|0,c=c+Math.imul(e,b0)|0,h=h+Math.imul(e,l0)|0,p=p+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$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(G$>>>26)|0,G$&=67108863,p=Math.imul(H0,q0),c=Math.imul(H0,j0),c=c+Math.imul(E0,q0)|0,h=Math.imul(E0,j0),p=p+Math.imul(F0,g0)|0,c=c+Math.imul(F0,N0)|0,c=c+Math.imul(A0,g0)|0,h=h+Math.imul(A0,N0)|0,p=p+Math.imul(I0,_0)|0,c=c+Math.imul(I0,B0)|0,c=c+Math.imul(J0,_0)|0,h=h+Math.imul(J0,B0)|0,p=p+Math.imul(U0,w0)|0,c=c+Math.imul(U0,f0)|0,c=c+Math.imul(X0,w0)|0,h=h+Math.imul(X0,f0)|0,p=p+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,p=p+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,p=p+Math.imul(r,u0)|0,c=c+Math.imul(r,n0)|0,c=c+Math.imul(e,u0)|0,h=h+Math.imul(e,n0)|0;var V$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(V$>>>26)|0,V$&=67108863,p=Math.imul(H0,g0),c=Math.imul(H0,N0),c=c+Math.imul(E0,g0)|0,h=Math.imul(E0,N0),p=p+Math.imul(F0,_0)|0,c=c+Math.imul(F0,B0)|0,c=c+Math.imul(A0,_0)|0,h=h+Math.imul(A0,B0)|0,p=p+Math.imul(I0,w0)|0,c=c+Math.imul(I0,f0)|0,c=c+Math.imul(J0,w0)|0,h=h+Math.imul(J0,f0)|0,p=p+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,p=p+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,p=p+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$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(U$>>>26)|0,U$&=67108863,p=Math.imul(H0,_0),c=Math.imul(H0,B0),c=c+Math.imul(E0,_0)|0,h=Math.imul(E0,B0),p=p+Math.imul(F0,w0)|0,c=c+Math.imul(F0,f0)|0,c=c+Math.imul(A0,w0)|0,h=h+Math.imul(A0,f0)|0,p=p+Math.imul(I0,c0)|0,c=c+Math.imul(I0,h0)|0,c=c+Math.imul(J0,c0)|0,h=h+Math.imul(J0,h0)|0,p=p+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,p=p+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$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(X$>>>26)|0,X$&=67108863,p=Math.imul(H0,w0),c=Math.imul(H0,f0),c=c+Math.imul(E0,w0)|0,h=Math.imul(E0,f0),p=p+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,p=p+Math.imul(I0,b0)|0,c=c+Math.imul(I0,l0)|0,c=c+Math.imul(J0,b0)|0,h=h+Math.imul(J0,l0)|0,p=p+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$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(K$>>>26)|0,K$&=67108863,p=Math.imul(H0,c0),c=Math.imul(H0,h0),c=c+Math.imul(E0,c0)|0,h=Math.imul(E0,h0),p=p+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,p=p+Math.imul(I0,u0)|0,c=c+Math.imul(I0,n0)|0,c=c+Math.imul(J0,u0)|0,h=h+Math.imul(J0,n0)|0;var I$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(I$>>>26)|0,I$&=67108863,p=Math.imul(H0,b0),c=Math.imul(H0,l0),c=c+Math.imul(E0,b0)|0,h=Math.imul(E0,l0),p=p+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 J$=(f+p|0)+((c&8191)<<13)|0;f=(h+(c>>>13)|0)+(J$>>>26)|0,J$&=67108863,p=Math.imul(H0,u0),c=Math.imul(H0,n0),c=c+Math.imul(E0,u0)|0,h=Math.imul(E0,n0);var O$=(f+p|0)+((c&8191)<<13)|0;return f=(h+(c>>>13)|0)+(O$>>>26)|0,O$&=67108863,w[0]=s0,w[1]=t0,w[2]=m0,w[3]=a0,w[4]=r0,w[5]=e0,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]=J$,w[18]=O$,f!==0&&(w[19]=f,_.length++),_};Math.imul||(C=D);function L(N,x,_){_.negative=x.negative^N.negative,_.length=N.length+x.length;for(var B=0,y=0,w=0;w<_.length-1;w++){var f=y;y=0;for(var p=B&67108863,c=Math.min(w,x.length-1),h=Math.max(0,w-N.length+1);h<=c;h++){var d=w-h,b=N.words[d]|0,l=x.words[h]|0,o=b*l,u=o&67108863;f=f+(o/67108864|0)|0,u=u+p|0,p=u&67108863,f=f+(u>>>26)|0,y+=f>>>26,f&=67108863}_.words[w]=p,B=f,f=y}return B!==0?_.words[w]=B:_.length--,_._strip()}function R(N,x,_){return L(N,x,_)}U.prototype.mulTo=function(N,x){var _,B=this.length+N.length;return this.length===10&&N.length===10?_=C(this,N,x):B<63?_=D(this,N,x):B<1024?_=L(this,N,x):_=R(this,N,x),_};function P(N,x){this.x=N,this.y=x}P.prototype.makeRBT=function(N){for(var x=new Array(N),_=U.prototype._countBits(N)-1,B=0;B>=1;return B},P.prototype.permute=function(N,x,_,B,y,w){for(var f=0;f>>1)y++;return 1<>>13,_[2*w+1]=y&8191,y=y>>>13;for(w=2*x;w>=26,_+=y/67108864|0,_+=w>>>26,this.words[B]=w&67108863}return _!==0&&(this.words[B]=_,this.length++),x?this.ineg():this},U.prototype.muln=function(N){return this.clone().imuln(N)},U.prototype.sqr=function(){return this.mul(this)},U.prototype.isqr=function(){return this.imul(this.clone())},U.prototype.pow=function(N){var x=T(N);if(x.length===0)return new U(1);for(var _=this,B=0;B=0);var x=N%26,_=(N-x)/26,B=67108863>>>26-x<<26-x,y;if(x!==0){var w=0;for(y=0;y>>26-x}w&&(this.words[y]=w,this.length++)}if(_!==0){for(y=this.length-1;y>=0;y--)this.words[y+_]=this.words[y];for(y=0;y<_;y++)this.words[y]=0;this.length+=_}return this._strip()},U.prototype.ishln=function(N){return G(this.negative===0),this.iushln(N)},U.prototype.iushrn=function(N,x,_){G(typeof N=="number"&&N>=0);var B;x?B=(x-x%26)/26:B=0;var y=N%26,w=Math.min((N-y)/26,this.length),f=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&f}return p&&h!==0&&(p.words[p.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(N){return this.clone().ishln(N)},U.prototype.ushln=function(N){return this.clone().iushln(N)},U.prototype.shrn=function(N){return this.clone().ishrn(N)},U.prototype.ushrn=function(N){return this.clone().iushrn(N)},U.prototype.testn=function(N){G(typeof N=="number"&&N>=0);var x=N%26,_=(N-x)/26,B=1<=0);var x=N%26,_=(N-x)/26;if(G(this.negative===0,"imaskn works only with positive numbers"),this.length<=_)return this;if(x!==0&&_++,this.length=Math.min(_,this.length),x!==0){var B=67108863^67108863>>>x<=67108864;x++)this.words[x]-=67108864,x===this.length-1?this.words[x+1]=1:this.words[x+1]++;return this.length=Math.max(this.length,x+1),this},U.prototype.isubn=function(N){if(G(typeof N=="number"),G(N<67108864),N<0)return this.iaddn(-N);if(this.negative!==0)return this.negative=0,this.iaddn(N),this.negative=1,this;if(this.words[0]-=N,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var x=0;x>26)-(p/67108864|0),this.words[y+_]=w&67108863}for(;y>26,this.words[y+_]=w&67108863;if(f===0)return this._strip();for(G(f===-1),f=0,y=0;y>26,this.words[y]=w&67108863;return this.negative=1,this._strip()},U.prototype._wordDiv=function(N,x){var _=this.length-N.length,B=this.clone(),y=N,w=y.words[y.length-1]|0,f=this._countBits(w);_=26-f,_!==0&&(y=y.ushln(_),B.iushln(_),w=y.words[y.length-1]|0);var p=B.length-y.length,c;if(x!=="mod"){c=new U(null),c.length=p+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(),x!=="div"&&_!==0&&B.iushrn(_),{div:c||null,mod:B}},U.prototype.divmod=function(N,x,_){if(G(!N.isZero()),this.isZero())return{div:new U(0),mod:new U(0)};var B,y,w;return this.negative!==0&&N.negative===0?(w=this.neg().divmod(N,x),x!=="mod"&&(B=w.div.neg()),x!=="div"&&(y=w.mod.neg(),_&&y.negative!==0&&y.iadd(N)),{div:B,mod:y}):this.negative===0&&N.negative!==0?(w=this.divmod(N.neg(),x),x!=="mod"&&(B=w.div.neg()),{div:B,mod:w.mod}):(this.negative&N.negative)!==0?(w=this.neg().divmod(N.neg(),x),x!=="div"&&(y=w.mod.neg(),_&&y.negative!==0&&y.isub(N)),{div:w.div,mod:y}):N.length>this.length||this.cmp(N)<0?{div:new U(0),mod:this}:N.length===1?x==="div"?{div:this.divn(N.words[0]),mod:null}:x==="mod"?{div:null,mod:new U(this.modrn(N.words[0]))}:{div:this.divn(N.words[0]),mod:new U(this.modrn(N.words[0]))}:this._wordDiv(N,x)},U.prototype.div=function(N){return this.divmod(N,"div",!1).div},U.prototype.mod=function(N){return this.divmod(N,"mod",!1).mod},U.prototype.umod=function(N){return this.divmod(N,"mod",!0).mod},U.prototype.divRound=function(N){var x=this.divmod(N);if(x.mod.isZero())return x.div;var _=x.div.negative!==0?x.mod.isub(N):x.mod,B=N.ushrn(1),y=N.andln(1),w=_.cmp(B);return w<0||y===1&&w===0?x.div:x.div.negative!==0?x.div.isubn(1):x.div.iaddn(1)},U.prototype.modrn=function(N){var x=N<0;x&&(N=-N),G(N<=67108863);for(var _=(1<<26)%N,B=0,y=this.length-1;y>=0;y--)B=(_*B+(this.words[y]|0))%N;return x?-B:B},U.prototype.modn=function(N){return this.modrn(N)},U.prototype.idivn=function(N){var x=N<0;x&&(N=-N),G(N<=67108863);for(var _=0,B=this.length-1;B>=0;B--){var y=(this.words[B]|0)+_*67108864;this.words[B]=y/N|0,_=y%N}return this._strip(),x?this.ineg():this},U.prototype.divn=function(N){return this.clone().idivn(N)},U.prototype.egcd=function(N){G(N.negative===0),G(!N.isZero());var x=this,_=N.clone();x.negative!==0?x=x.umod(N):x=x.clone();for(var B=new U(1),y=new U(0),w=new U(0),f=new U(1),p=0;x.isEven()&&_.isEven();)x.iushrn(1),_.iushrn(1),++p;for(var c=_.clone(),h=x.clone();!x.isZero();){for(var d=0,b=1;(x.words[0]&b)===0&&d<26;++d,b<<=1);if(d>0)for(x.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;(_.words[0]&o)===0&&l<26;++l,o<<=1);if(l>0)for(_.iushrn(l);l-- >0;)(w.isOdd()||f.isOdd())&&(w.iadd(c),f.isub(h)),w.iushrn(1),f.iushrn(1);x.cmp(_)>=0?(x.isub(_),B.isub(w),y.isub(f)):(_.isub(x),w.isub(B),f.isub(y))}return{a:w,b:f,gcd:_.iushln(p)}},U.prototype._invmp=function(N){G(N.negative===0),G(!N.isZero());var x=this,_=N.clone();x.negative!==0?x=x.umod(N):x=x.clone();for(var B=new U(1),y=new U(0),w=_.clone();x.cmpn(1)>0&&_.cmpn(1)>0;){for(var f=0,p=1;(x.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(x.iushrn(f);f-- >0;)B.isOdd()&&B.iadd(w),B.iushrn(1);for(var c=0,h=1;(_.words[0]&h)===0&&c<26;++c,h<<=1);if(c>0)for(_.iushrn(c);c-- >0;)y.isOdd()&&y.iadd(w),y.iushrn(1);x.cmp(_)>=0?(x.isub(_),B.isub(y)):(_.isub(x),y.isub(B))}var d;return x.cmpn(1)===0?d=B:d=y,d.cmpn(0)<0&&d.iadd(N),d},U.prototype.gcd=function(N){if(this.isZero())return N.abs();if(N.isZero())return this.abs();var x=this.clone(),_=N.clone();x.negative=0,_.negative=0;for(var B=0;x.isEven()&&_.isEven();B++)x.iushrn(1),_.iushrn(1);do{for(;x.isEven();)x.iushrn(1);for(;_.isEven();)_.iushrn(1);var y=x.cmp(_);if(y<0){var w=x;x=_,_=w}else if(y===0||_.cmpn(1)===0)break;x.isub(_)}while(!0);return _.iushln(B)},U.prototype.invm=function(N){return this.egcd(N).a.umod(N)},U.prototype.isEven=function(){return(this.words[0]&1)===0},U.prototype.isOdd=function(){return(this.words[0]&1)===1},U.prototype.andln=function(N){return this.words[0]&N},U.prototype.bincn=function(N){G(typeof N=="number");var x=N%26,_=(N-x)/26,B=1<>>26,f&=67108863,this.words[w]=f}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(N){var x=N<0;if(this.negative!==0&&!x)return-1;if(this.negative===0&&x)return 1;this._strip();var _;if(this.length>1)_=1;else{x&&(N=-N),G(N<=67108863,"Number is too big");var B=this.words[0]|0;_=B===N?0:BN.length)return 1;if(this.length=0;_--){var B=this.words[_]|0,y=N.words[_]|0;if(B!==y){By&&(x=1);break}}return x},U.prototype.gtn=function(N){return this.cmpn(N)===1},U.prototype.gt=function(N){return this.cmp(N)===1},U.prototype.gten=function(N){return this.cmpn(N)>=0},U.prototype.gte=function(N){return this.cmp(N)>=0},U.prototype.ltn=function(N){return this.cmpn(N)===-1},U.prototype.lt=function(N){return this.cmp(N)===-1},U.prototype.lten=function(N){return this.cmpn(N)<=0},U.prototype.lte=function(N){return this.cmp(N)<=0},U.prototype.eqn=function(N){return this.cmpn(N)===0},U.prototype.eq=function(N){return this.cmp(N)===0},U.red=function(N){return new k(N)},U.prototype.toRed=function(N){return G(!this.red,"Already a number in reduction context"),G(this.negative===0,"red works only with positives"),N.convertTo(this)._forceRed(N)},U.prototype.fromRed=function(){return G(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},U.prototype._forceRed=function(N){return this.red=N,this},U.prototype.forceRed=function(N){return G(!this.red,"Already a number in reduction context"),this._forceRed(N)},U.prototype.redAdd=function(N){return G(this.red,"redAdd works only with red numbers"),this.red.add(this,N)},U.prototype.redIAdd=function(N){return G(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,N)},U.prototype.redSub=function(N){return G(this.red,"redSub works only with red numbers"),this.red.sub(this,N)},U.prototype.redISub=function(N){return G(this.red,"redISub works only with red numbers"),this.red.isub(this,N)},U.prototype.redShl=function(N){return G(this.red,"redShl works only with red numbers"),this.red.shl(this,N)},U.prototype.redMul=function(N){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,N),this.red.mul(this,N)},U.prototype.redIMul=function(N){return G(this.red,"redMul works only with red numbers"),this.red._verify2(this,N),this.red.imul(this,N)},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(N){return G(this.red&&!N.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,N)};var z={k256:null,p224:null,p192:null,p25519:null};function M(N,x){this.name=N,this.p=new U(x,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 N=new U(null);return N.words=new Array(Math.ceil(this.n/13)),N},M.prototype.ireduce=function(N){var x=N,_;do this.split(x,this.tmp),x=this.imulK(x),x=x.iadd(this.tmp),_=x.bitLength();while(_>this.n);var B=_0?x.isub(this.p):x.strip!==void 0?x.strip():x._strip(),x},M.prototype.split=function(N,x){N.iushrn(this.n,0,x)},M.prototype.imulK=function(N){return N.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,x){for(var _=4194303,B=Math.min(N.length,9),y=0;y>>22,w=f}w>>>=22,N.words[y-10]=w,w===0&&N.length>10?N.length-=10:N.length-=9},S.prototype.imulK=function(N){N.words[N.length]=0,N.words[N.length+1]=0,N.length+=2;for(var x=0,_=0;_>>=26,N.words[_]=y,x=B}return x!==0&&(N.words[N.length++]=x),N},U._prime=function(N){if(z[N])return z[N];var x;if(N==="k256")x=new S;else if(N==="p224")x=new v;else if(N==="p192")x=new q;else if(N==="p25519")x=new j;else throw new Error("Unknown prime "+N);return z[N]=x,x};function k(N){if(typeof N=="string"){var x=U._prime(N);this.m=x.p,this.prime=x}else G(N.gtn(1),"modulus must be greater than 1"),this.m=N,this.prime=null}k.prototype._verify1=function(N){G(N.negative===0,"red works only with positives"),G(N.red,"red works only with red numbers")},k.prototype._verify2=function(N,x){G((N.negative|x.negative)===0,"red works only with positives"),G(N.red&&N.red===x.red,"red works only with red numbers")},k.prototype.imod=function(N){return this.prime?this.prime.ireduce(N)._forceRed(this):(O(N,N.umod(this.m)._forceRed(this)),N)},k.prototype.neg=function(N){return N.isZero()?N.clone():this.m.sub(N)._forceRed(this)},k.prototype.add=function(N,x){this._verify2(N,x);var _=N.add(x);return _.cmp(this.m)>=0&&_.isub(this.m),_._forceRed(this)},k.prototype.iadd=function(N,x){this._verify2(N,x);var _=N.iadd(x);return _.cmp(this.m)>=0&&_.isub(this.m),_},k.prototype.sub=function(N,x){this._verify2(N,x);var _=N.sub(x);return _.cmpn(0)<0&&_.iadd(this.m),_._forceRed(this)},k.prototype.isub=function(N,x){this._verify2(N,x);var _=N.isub(x);return _.cmpn(0)<0&&_.iadd(this.m),_},k.prototype.shl=function(N,x){return this._verify1(N),this.imod(N.ushln(x))},k.prototype.imul=function(N,x){return this._verify2(N,x),this.imod(N.imul(x))},k.prototype.mul=function(N,x){return this._verify2(N,x),this.imod(N.mul(x))},k.prototype.isqr=function(N){return this.imul(N,N.clone())},k.prototype.sqr=function(N){return this.mul(N,N)},k.prototype.sqrt=function(N){if(N.isZero())return N.clone();var x=this.m.andln(3);if(G(x%2===1),x===3){var _=this.m.add(new U(1)).iushrn(2);return this.pow(N,_)}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),f=w.redNeg(),p=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new U(2*c*c).toRed(this);this.pow(c,p).cmp(f)!==0;)c.redIAdd(f);for(var h=this.pow(c,B),d=this.pow(N,B.addn(1).iushrn(1)),b=this.pow(N,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=x.words[y],d=c-1;d>=0;d--){var b=h>>d&1;if(w!==B[0]&&(w=this.sqr(w)),b===0&&f===0){p=0;continue}f<<=1,f|=b,p++,!(p!==_&&(y!==0||d!==0))&&(w=this.mul(w,B[f]),p=0,f=0)}c=26}return w},k.prototype.convertTo=function(N){var x=N.umod(this.m);return x===N?x.clone():x},k.prototype.convertFrom=function(N){var x=N.clone();return x.red=null,x},U.mont=function(N){return new g(N)};function g(N){k.call(this,N),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(N){return this.imod(N.ushln(this.shift))},g.prototype.convertFrom=function(N){var x=this.imod(N.mul(this.rinv));return x.red=null,x},g.prototype.imul=function(N,x){if(N.isZero()||x.isZero())return N.words[0]=0,N.length=1,N;var _=N.imul(x),B=_.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=_.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,x){if(N.isZero()||x.isZero())return new U(0)._forceRed(this);var _=N.mul(x),B=_.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=_.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(N){var x=this.imod(N._invmp(this.m).mul(this.r2));return x._forceRed(this)}})(typeof Q>"u"||Q,$)}}),fQ=z$({"node_modules/browserify-rsa/index.js"($,Q){var Y=wQ(),Z=v$();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),J=K.modulus.byteLength(),O=new Y(X).mul(I.blinder).umod(K.modulus),F=O.toRed(Y.mont(K.prime1)),A=O.toRed(Y.mont(K.prime2)),W=K.coefficient,H=K.prime1,E=K.prime2,T=F.redPow(K.exponent1).fromRed(),D=A.redPow(K.exponent2).fromRed(),C=T.isub(D).imul(W).umod(H).imul(E);return D.iadd(C).imul(I.unblinder).umod(K.modulus).toArrayLike(Buffer,"be",J)}U.getr=V,Q.exports=U}}),pQ=z$({"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"}}}}),cQ=z$({"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;try{typeof window<"u"&&typeof window.Buffer<"u"?X=window.Buffer:X=R$("buffer").Buffer}catch{}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 N=0;j[0]==="-"&&(N++,this.negative=1),N=0;N-=3)_=j[N]|j[N-1]<<8|j[N-2]<<16,this.words[x]|=_<>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);else if(g==="le")for(N=0,x=0;N>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);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 N=K(j,g);return g-1>=k&&(N|=K(j,g-1)<<4),N}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var N=0;N=k;N-=2)B=I(j,k,N)<=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8;else{var y=j.length-k;for(N=y%2===0?k+1:k;N=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8}this.strip()};function J(j,k,g,N){for(var x=0,_=Math.min(j.length,g),B=k;B<_;B++){var y=j.charCodeAt(B)-48;x*=N,y>=49?x+=y-49+10:y>=17?x+=y-17+10:x+=y}return x}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var N=0,x=1;x<=67108863;x*=k)N++;N--,x=x/k|0;for(var _=j.length-g,B=_%N,y=Math.min(_,_-B)+g,w=0,f=g;f1&&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 O=["","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 N=0,x=0,_=0;_>>24-N&16777215,x!==0||_!==this.length-1?g=O[6-y.length]+y+g:g=y+g,N+=2,N>=26&&(N-=26,_--)}for(x!==0&&(g=x.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],f=A[j];g="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(j);p=p.idivn(f),p.isZero()?g=c+g:g=O[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 N=this.byteLength(),x=g||Math.max(1,N);G(N<=x,"byte array longer than desired length"),G(x>0,"Requested array length <= 0"),this.strip();var _=k==="le",B=new j(x),y,w,f=this.clone();if(_){for(w=0;!f.isZero();w++)y=f.andln(255),f.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 W(j){for(var k=new Array(j.bitLength()),g=0;g>>x}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 N=0;Nj.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 N=0;N0&&(this.words[N]=~this.words[N]&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,N=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<j.length?(g=this,N=j):(g=j,N=this);for(var x=0,_=0;_>>26;for(;x!==0&&_>>26;if(this.length=g.length,x!==0)this.words[this.length]=x,this.length++;else if(g!==this)for(;_j.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,x;g>0?(N=this,x=j):(N=j,x=this);for(var _=0,B=0;B>26,this.words[B]=k&67108863;for(;_!==0&&B>26,this.words[B]=k&67108863;if(_===0&&B>>26,c=w&67108863,h=Math.min(f,k.length-1),d=Math.max(0,f-j.length+1);d<=h;d++){var b=f-d|0;x=j.words[b]|0,_=k.words[d]|0,B=x*_+c,p+=B/67108864|0,c=B&67108863}g.words[f]=c|0,w=p|0}return w!==0?g.words[f]=w|0:g.length--,g.strip()}var E=function(j,k,g){var N=j.words,x=k.words,_=g.words,B=0,y,w,f,p=N[0]|0,c=p&8191,h=p>>>13,d=N[1]|0,b=d&8191,l=d>>>13,o=N[2]|0,u=o&8191,n=o>>>13,s=N[3]|0,t=s&8191,m=s>>>13,a=N[4]|0,r=a&8191,e=a>>>13,i=N[5]|0,$0=i&8191,Q0=i>>>13,Y0=N[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=N[7]|0,U0=V0&8191,X0=V0>>>13,K0=N[8]|0,I0=K0&8191,J0=K0>>>13,O0=N[9]|0,F0=O0&8191,A0=O0>>>13,W0=x[0]|0,H0=W0&8191,E0=W0>>>13,T0=x[1]|0,D0=T0&8191,C0=T0>>>13,L0=x[2]|0,R0=L0&8191,P0=L0>>>13,z0=x[3]|0,M0=z0&8191,S0=z0>>>13,v0=x[4]|0,q0=v0&8191,j0=v0>>>13,k0=x[5]|0,g0=k0&8191,N0=k0>>>13,x0=x[6]|0,_0=x0&8191,B0=x0>>>13,y0=x[7]|0,w0=y0&8191,f0=y0>>>13,p0=x[8]|0,c0=p0&8191,h0=p0>>>13,d0=x[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,H0),w=Math.imul(c,E0),w=w+Math.imul(h,H0)|0,f=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,H0),w=Math.imul(b,E0),w=w+Math.imul(l,H0)|0,f=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,f=f+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,H0),w=Math.imul(u,E0),w=w+Math.imul(n,H0)|0,f=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,f=f+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,f=f+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,H0),w=Math.imul(t,E0),w=w+Math.imul(m,H0)|0,f=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,f=f+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,f=f+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,f=f+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(r,H0),w=Math.imul(r,E0),w=w+Math.imul(e,H0)|0,f=Math.imul(e,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,f=f+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,f=f+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,f=f+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,f=f+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,H0),w=Math.imul($0,E0),w=w+Math.imul(Q0,H0)|0,f=Math.imul(Q0,E0),y=y+Math.imul(r,D0)|0,w=w+Math.imul(r,C0)|0,w=w+Math.imul(e,D0)|0,f=f+Math.imul(e,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,f=f+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,f=f+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,f=f+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,N0)|0,w=w+Math.imul(h,g0)|0,f=f+Math.imul(h,N0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,H0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,H0)|0,f=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,f=f+Math.imul(Q0,C0)|0,y=y+Math.imul(r,R0)|0,w=w+Math.imul(r,P0)|0,w=w+Math.imul(e,R0)|0,f=f+Math.imul(e,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,f=f+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,f=f+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,N0)|0,w=w+Math.imul(l,g0)|0,f=f+Math.imul(l,N0)|0,y=y+Math.imul(c,_0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,_0)|0,f=f+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,H0),w=Math.imul(U0,E0),w=w+Math.imul(X0,H0)|0,f=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,f=f+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,f=f+Math.imul(Q0,P0)|0,y=y+Math.imul(r,M0)|0,w=w+Math.imul(r,S0)|0,w=w+Math.imul(e,M0)|0,f=f+Math.imul(e,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,f=f+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,N0)|0,w=w+Math.imul(n,g0)|0,f=f+Math.imul(n,N0)|0,y=y+Math.imul(b,_0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,_0)|0,f=f+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,f0)|0,w=w+Math.imul(h,w0)|0,f=f+Math.imul(h,f0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(I0,H0),w=Math.imul(I0,E0),w=w+Math.imul(J0,H0)|0,f=Math.imul(J0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,S0)|0,y=y+Math.imul(r,q0)|0,w=w+Math.imul(r,j0)|0,w=w+Math.imul(e,q0)|0,f=f+Math.imul(e,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,N0)|0,w=w+Math.imul(m,g0)|0,f=f+Math.imul(m,N0)|0,y=y+Math.imul(u,_0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,_0)|0,f=f+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,f0)|0,w=w+Math.imul(l,w0)|0,f=f+Math.imul(l,f0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,f=f+Math.imul(h,h0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(F0,H0),w=Math.imul(F0,E0),w=w+Math.imul(A0,H0)|0,f=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(J0,D0)|0,f=f+Math.imul(J0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,j0)|0,y=y+Math.imul(r,g0)|0,w=w+Math.imul(r,N0)|0,w=w+Math.imul(e,g0)|0,f=f+Math.imul(e,N0)|0,y=y+Math.imul(t,_0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,_0)|0,f=f+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,f0)|0,w=w+Math.imul(n,w0)|0,f=f+Math.imul(n,f0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,f=f+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,f=f+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(J0,R0)|0,f=f+Math.imul(J0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,f=f+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,f=f+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,N0)|0,w=w+Math.imul(Q0,g0)|0,f=f+Math.imul(Q0,N0)|0,y=y+Math.imul(r,_0)|0,w=w+Math.imul(r,B0)|0,w=w+Math.imul(e,_0)|0,f=f+Math.imul(e,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,f0)|0,w=w+Math.imul(m,w0)|0,f=f+Math.imul(m,f0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,f=f+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,f=f+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,f=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(J0,M0)|0,f=f+Math.imul(J0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,f=f+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,N0)|0,w=w+Math.imul(G0,g0)|0,f=f+Math.imul(G0,N0)|0,y=y+Math.imul($0,_0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,_0)|0,f=f+Math.imul(Q0,B0)|0,y=y+Math.imul(r,w0)|0,w=w+Math.imul(r,f0)|0,w=w+Math.imul(e,w0)|0,f=f+Math.imul(e,f0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,f=f+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,f=f+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(J0,q0)|0,f=f+Math.imul(J0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,N0)|0,w=w+Math.imul(X0,g0)|0,f=f+Math.imul(X0,N0)|0,y=y+Math.imul(Z0,_0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,_0)|0,f=f+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,f0)|0,w=w+Math.imul(Q0,w0)|0,f=f+Math.imul(Q0,f0)|0,y=y+Math.imul(r,c0)|0,w=w+Math.imul(r,h0)|0,w=w+Math.imul(e,c0)|0,f=f+Math.imul(e,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,f=f+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,N0)|0,w=w+Math.imul(J0,g0)|0,f=f+Math.imul(J0,N0)|0,y=y+Math.imul(U0,_0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,_0)|0,f=f+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,f0)|0,w=w+Math.imul(G0,w0)|0,f=f+Math.imul(G0,f0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,f=f+Math.imul(Q0,h0)|0,y=y+Math.imul(r,b0)|0,w=w+Math.imul(r,l0)|0,w=w+Math.imul(e,b0)|0,f=f+Math.imul(e,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,N0),w=w+Math.imul(A0,g0)|0,f=Math.imul(A0,N0),y=y+Math.imul(I0,_0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(J0,_0)|0,f=f+Math.imul(J0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,f0)|0,w=w+Math.imul(X0,w0)|0,f=f+Math.imul(X0,f0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,f=f+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,f=f+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,_0),w=Math.imul(F0,B0),w=w+Math.imul(A0,_0)|0,f=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,f0)|0,w=w+Math.imul(J0,w0)|0,f=f+Math.imul(J0,f0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,f=f+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,f=f+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,f0),w=w+Math.imul(A0,w0)|0,f=Math.imul(A0,f0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(J0,c0)|0,f=f+Math.imul(J0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,f=f+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(J0,b0)|0,f=f+Math.imul(J0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(f+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,_[0]=o0,_[1]=u0,_[2]=n0,_[3]=s0,_[4]=t0,_[5]=m0,_[6]=a0,_[7]=r0,_[8]=e0,_[9]=i0,_[10]=$$,_[11]=Q$,_[12]=Y$,_[13]=Z$,_[14]=G$,_[15]=V$,_[16]=U$,_[17]=X$,_[18]=K$,B!==0&&(_[19]=B,g.length++),g};Math.imul||(E=H);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var N=0,x=0,_=0;_>>26)|0,x+=B>>>26,B&=67108863}g.words[_]=y,N=B,B=x}return N!==0?g.words[_]=N:g.length--,g.strip()}function D(j,k,g){var N=new C;return N.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,N=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):N<63?g=H(this,j,k):N<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,N=0;N>=1;return N},C.prototype.permute=function(j,k,g,N,x,_){for(var B=0;B<_;B++)N[B]=k[j[B]],x[B]=g[j[B]]},C.prototype.transform=function(j,k,g,N,x,_){this.permute(_,j,k,g,N,x);for(var B=1;B>>1)x++;return 1<>>13,g[2*_+1]=x&8191,x=x>>>13;for(_=2*k;_>=26,k+=N/67108864|0,k+=x>>>26,this.words[g]=x&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=W(j);if(k.length===0)return new U(1);for(var g=this,N=0;N=0);var k=j%26,g=(j-k)/26,N=67108863>>>26-k<<26-k,x;if(k!==0){var _=0;for(x=0;x>>26-k}_&&(this.words[x]=_,this.length++)}if(g!==0){for(x=this.length-1;x>=0;x--)this.words[x+g]=this.words[x];for(x=0;x=0);var N;k?N=(k-k%26)/26:N=0;var x=j%26,_=Math.min((j-x)/26,this.length),B=67108863^67108863>>>x<_)for(this.length-=_,w=0;w=0&&(f!==0||w>=N);w--){var p=this.words[w]|0;this.words[w]=f<<26-x|p>>>x,f=p&B}return y&&f!==0&&(y.words[y.length++]=f),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,N=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 N=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[x+g]=_&67108863}for(;x>26,this.words[x+g]=_&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,x=0;x>26,this.words[x]=_&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,N=this.clone(),x=j,_=x.words[x.length-1]|0,B=this._countBits(_);g=26-B,g!==0&&(x=x.ushln(g),N.iushln(g),_=x.words[x.length-1]|0);var y=N.length-x.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var f=0;f=0;c--){var h=(N.words[x.length+c]|0)*67108864+(N.words[x.length+c-1]|0);for(h=Math.min(h/_|0,67108863),N._ishlnsubmul(x,h,c);N.negative!==0;)h--,N.negative=0,N._ishlnsubmul(x,1,c),N.isZero()||(N.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),N.strip(),k!=="div"&&g!==0&&N.iushrn(g),{div:w||null,mod:N}},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?(_=this.neg().divmod(j,k),k!=="mod"&&(N=_.div.neg()),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.iadd(j)),{div:N,mod:x}):this.negative===0&&j.negative!==0?(_=this.divmod(j.neg(),k),k!=="mod"&&(N=_.div.neg()),{div:N,mod:_.mod}):(this.negative&j.negative)!==0?(_=this.neg().divmod(j.neg(),k),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.isub(j)),{div:_.div,mod:x}):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,N=j.ushrn(1),x=j.andln(1),_=g.cmp(N);return _<0||x===1&&_===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,N=this.length-1;N>=0;N--)g=(k*g+(this.words[N]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var N=(this.words[g]|0)+k*67108864;this.words[g]=N/j|0,k=N%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 N=new U(1),x=new U(0),_=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(),f=k.clone();!k.isZero();){for(var p=0,c=1;(k.words[0]&c)===0&&p<26;++p,c<<=1);if(p>0)for(k.iushrn(p);p-- >0;)(N.isOdd()||x.isOdd())&&(N.iadd(w),x.isub(f)),N.iushrn(1),x.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;)(_.isOdd()||B.isOdd())&&(_.iadd(w),B.isub(f)),_.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(_),x.isub(B)):(g.isub(k),_.isub(N),B.isub(x))}return{a:_,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 N=new U(1),x=new U(0),_=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;)N.isOdd()&&N.iadd(_),N.iushrn(1);for(var w=0,f=1;(g.words[0]&f)===0&&w<26;++w,f<<=1);if(w>0)for(g.iushrn(w);w-- >0;)x.isOdd()&&x.iadd(_),x.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(x)):(g.isub(k),x.isub(N))}var p;return k.cmpn(1)===0?p=N:p=x,p.cmpn(0)<0&&p.iadd(j),p},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 N=0;k.isEven()&&g.isEven();N++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var x=k.cmp(g);if(x<0){var _=k;k=g,g=_}else if(x===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(N)},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,N=1<>>26,B&=67108863,this.words[_]=B}return x!==0&&(this.words[_]=x,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 N=this.words[0]|0;g=N===j?0:Nj.length)return 1;if(this.length=0;g--){var N=this.words[g]|0,x=j.words[g]|0;if(N!==x){Nx&&(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 N=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,N=Math.min(j.length,9),x=0;x>>22,_=B}_>>>=22,j.words[x-10]=_,_===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]=x,k=N}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 N=this.m.subn(1),x=0;!N.isZero()&&N.andln(1)===0;)x++,N.iushrn(1);G(!N.isZero());var _=new U(1).toRed(this),B=_.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 f=this.pow(w,N),p=this.pow(j,N.addn(1).iushrn(1)),c=this.pow(j,N),h=x;c.cmp(_)!==0;){for(var d=c,b=0;d.cmp(_)!==0;b++)d=d.redSqr();G(b=0;x--){for(var f=k.words[x],p=w-1;p>=0;p--){var c=f>>p&1;if(_!==N[0]&&(_=this.sqr(_)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(x!==0||p!==0))&&(_=this.mul(_,N[B]),y=0,B=0)}w=26}return _},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),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._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,$)}}),hQ=z$({"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,O=I&255;J?X.push(J,O):X.push(O)}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(W>>1)-1?T=(W>>1)-D:T=D,H.isubn(T)):T=0,A[E]=T,H.iushrn(1)}return A}Q.getNAF=V;function U(J,O){var F=[[],[]];J=J.clone(),O=O.clone();for(var A=0,W=0,H;J.cmpn(-A)>0||O.cmpn(-W)>0;){var E=J.andln(3)+A&3,T=O.andln(3)+W&3;E===3&&(E=-1),T===3&&(T=-1);var D;(E&1)===0?D=0:(H=J.andln(7)+A&7,(H===3||H===5)&&T===2?D=-E:D=E),F[0].push(D);var C;(T&1)===0?C=0:(H=O.andln(7)+W&7,(H===3||H===5)&&E===2?C=-T:C=T),F[1].push(C),2*A===D+1&&(A=1-A),2*W===C+1&&(W=1-W),J.iushrn(1),O.iushrn(1)}return F}Q.getJSF=U;function X(J,O,F){var A="_"+O;J.prototype[O]=function(){return this[A]!==void 0?this[A]:this[A]=F.call(this)}}Q.cachedProperty=X;function K(J){return typeof J=="string"?Q.toArray(J,"hex"):J}Q.parseBytes=K;function I(J){return new Y(J,"hex","le")}Q.intFromLE=I}}),bQ=z$({"node_modules/elliptic/lib/elliptic/curve/base.js"($,Q){var Y=cQ(),Z=dQ(),G=Z.getNAF,V=Z.getJSF,U=Z.assert;function X(I,J){this.type=I,this.p=new Y(J.p,16),this.red=J.prime?Y.red(J.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=J.n&&new Y(J.n,16),this.g=J.g&&this.pointFromJSON(J.g,J.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 O=this.n&&this.p.div(this.n);!O||O.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,J){U(I.precomputed);var O=I._getDoubles(),F=G(J,1,this._bitLength),A=(1<=H;T--)E=(E<<1)+F[T];W.push(E)}for(var D=this.jpoint(null,null,null),C=this.jpoint(null,null,null),L=A;L>0;L--){for(H=0;H=0;E--){for(var T=0;E>=0&&W[E]===0;E--)T++;if(E>=0&&T++,H=H.dblp(T),E<0)break;var D=W[E];U(D!==0),I.type==="affine"?D>0?H=H.mixedAdd(A[D-1>>1]):H=H.mixedAdd(A[-D-1>>1].neg()):D>0?H=H.add(A[D-1>>1]):H=H.add(A[-D-1>>1].neg())}return I.type==="affine"?H.toP():H},X.prototype._wnafMulAdd=function(I,J,O,F,A){var W=this._wnafT1,H=this._wnafT2,E=this._wnafT3,T=0,D,C,L;for(D=0;D=1;D-=2){var P=D-1,z=D;if(W[P]!==1||W[z]!==1){E[P]=G(O[P],W[P],this._bitLength),E[z]=G(O[z],W[z],this._bitLength),T=Math.max(E[P].length,T),T=Math.max(E[z].length,T);continue}var M=[J[P],null,null,J[z]];J[P].y.cmp(J[z].y)===0?(M[1]=J[P].add(J[z]),M[2]=J[P].toJ().mixedAdd(J[z].neg())):J[P].y.cmp(J[z].y.redNeg())===0?(M[1]=J[P].toJ().mixedAdd(J[z]),M[2]=J[P].add(J[z].neg())):(M[1]=J[P].toJ().mixedAdd(J[z]),M[2]=J[P].toJ().mixedAdd(J[z].neg()));var S=[-3,-1,-5,-7,0,7,5,1,3],v=V(O[P],O[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 N=0;D>=0;){var x=!0;for(C=0;C=0&&N++,k=k.dblp(N),D<0)break;for(C=0;C0?L=H[C][_-1>>1]:_<0&&(L=H[C][-_-1>>1].neg()),L.type==="affine"?k=k.mixedAdd(L):k=k.add(L))}}for(D=0;D=Math.ceil((I.bitLength()+1)/J.step):!1},K.prototype._getDoubles=function(I,J){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var O=[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(J){var O=this.endo.basis,F=O[0],A=O[1],W=A.b.mul(J).divRound(this.n),H=F.b.neg().mul(J).divRound(this.n),E=W.mul(F.a),T=H.mul(A.a),D=W.mul(F.b),C=H.mul(A.b),L=J.sub(E).sub(T),R=D.add(C).neg();return{k1:L,k2:R}},X.prototype.pointFromX=function(J,O){J=new Z(J,16),J.red||(J=J.toRed(this.red));var F=J.redSqr().redMul(J).redIAdd(J.redMul(this.a)).redIAdd(this.b),A=F.redSqrt();if(A.redSqr().redSub(F).cmp(this.zero)!==0)throw new Error("invalid point");var W=A.fromRed().isOdd();return(O&&!W||!O&&W)&&(A=A.redNeg()),this.point(J,A)},X.prototype.validate=function(J){if(J.inf)return!0;var{x:O,y:F}=J,A=this.a.redMul(O),W=O.redSqr().redMul(O).redIAdd(A).redIAdd(this.b);return F.redSqr().redISub(W).cmpn(0)===0},X.prototype._endoWnafMulAdd=function(J,O,F){for(var A=this._endoWnafT1,W=this._endoWnafT2,H=0;H":""},K.prototype.isInfinity=function(){return this.inf},K.prototype.add=function(J){if(this.inf)return J;if(J.inf)return this;if(this.eq(J))return this.dbl();if(this.neg().eq(J))return this.curve.point(null,null);if(this.x.cmp(J.x)===0)return this.curve.point(null,null);var O=this.y.redSub(J.y);O.cmpn(0)!==0&&(O=O.redMul(this.x.redSub(J.x).redInvm()));var F=O.redSqr().redISub(this.x).redISub(J.x),A=O.redMul(this.x.redSub(F)).redISub(this.y);return this.curve.point(F,A)},K.prototype.dbl=function(){if(this.inf)return this;var J=this.y.redAdd(this.y);if(J.cmpn(0)===0)return this.curve.point(null,null);var O=this.curve.a,F=this.x.redSqr(),A=J.redInvm(),W=F.redAdd(F).redIAdd(F).redIAdd(O).redMul(A),H=W.redSqr().redISub(this.x.redAdd(this.x)),E=W.redMul(this.x.redSub(H)).redISub(this.y);return this.curve.point(H,E)},K.prototype.getX=function(){return this.x.fromRed()},K.prototype.getY=function(){return this.y.fromRed()},K.prototype.mul=function(J){return J=new Z(J,16),this.isInfinity()?this:this._hasDoubles(J)?this.curve._fixedNafMul(this,J):this.curve.endo?this.curve._endoWnafMulAdd([this],[J]):this.curve._wnafMul(this,J)},K.prototype.mulAdd=function(J,O,F){var A=[this,O],W=[J,F];return this.curve.endo?this.curve._endoWnafMulAdd(A,W):this.curve._wnafMulAdd(1,A,W,2)},K.prototype.jmulAdd=function(J,O,F){var A=[this,O],W=[J,F];return this.curve.endo?this.curve._endoWnafMulAdd(A,W,!0):this.curve._wnafMulAdd(1,A,W,2,!0)},K.prototype.eq=function(J){return this===J||this.inf===J.inf&&(this.inf||this.x.cmp(J.x)===0&&this.y.cmp(J.y)===0)},K.prototype.neg=function(J){if(this.inf)return this;var O=this.curve.point(this.x,this.y.redNeg());if(J&&this.precomputed){var F=this.precomputed,A=function(W){return W.neg()};O.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 O},K.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var J=this.curve.jpoint(this.x,this.y,this.curve.one);return J};function I(J,O,F,A){V.BasePoint.call(this,J,"jacobian"),O===null&&F===null&&A===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Z(0)):(this.x=new Z(O,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(J,O,F){return new I(this,J,O,F)},I.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var J=this.z.redInvm(),O=J.redSqr(),F=this.x.redMul(O),A=this.y.redMul(O).redMul(J);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(J){if(this.isInfinity())return J;if(J.isInfinity())return this;var O=J.z.redSqr(),F=this.z.redSqr(),A=this.x.redMul(O),W=J.x.redMul(F),H=this.y.redMul(O.redMul(J.z)),E=J.y.redMul(F.redMul(this.z)),T=A.redSub(W),D=H.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(H.redMul(L)),M=this.z.redMul(J.z).redMul(T);return this.curve.jpoint(P,z,M)},I.prototype.mixedAdd=function(J){if(this.isInfinity())return J.toJ();if(J.isInfinity())return this;var O=this.z.redSqr(),F=this.x,A=J.x.redMul(O),W=this.y,H=J.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(E);return this.curve.jpoint(R,P,z)},I.prototype.dblp=function(J){if(J===0)return this;if(this.isInfinity())return this;if(!J)return this.dbl();var O;if(this.curve.zeroA||this.curve.threeA){var F=this;for(O=0;O=0)return!1;if(F.redIAdd(W),this.x.cmp(F)===0)return!0}},I.prototype.inspect=function(){return this.isInfinity()?"":""},I.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),oQ=z$({"node_modules/elliptic/lib/elliptic/curve/mont.js"($,Q){var Y=cQ(),Z=q$(),G=bQ(),V=dQ();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,J=I.redSqr(),O=J.redMul(I).redAdd(J.redMul(this.a)).redAdd(I),F=O.redSqrt();return F.redSqr().cmp(O)===0};function X(K,I,J){G.BasePoint.call(this,K,"projective"),I===null&&J===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Y(I,16),this.z=new Y(J,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(),J=this.x.redSub(this.z),O=J.redSqr(),F=I.redSub(O),A=I.redMul(O),W=F.redMul(O.redAdd(this.curve.a24.redMul(F)));return this.curve.point(A,W)},X.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},X.prototype.diffAdd=function(K,I){var J=this.x.redAdd(this.z),O=this.x.redSub(this.z),F=K.x.redAdd(K.z),A=K.x.redSub(K.z),W=A.redMul(J),H=F.redMul(O),E=I.z.redMul(W.redAdd(H).redSqr()),T=I.x.redMul(W.redISub(H).redSqr());return this.curve.point(E,T)},X.prototype.mul=function(K){for(var I=K.clone(),J=this,O=this.curve.point(null,null),F=this,A=[];I.cmpn(0)!==0;I.iushrn(1))A.push(I.andln(1));for(var W=A.length-1;W>=0;W--)A[W]===0?(J=J.diffAdd(O,F),O=O.dbl()):(O=J.diffAdd(O,F),J=J.dbl());return O},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()}}}),uQ=z$({"node_modules/elliptic/lib/elliptic/curve/edwards.js"($,Q){var Y=dQ(),Z=cQ(),G=q$(),V=bQ(),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,J,O,F){return this.point(I,J,O,F)},X.prototype.pointFromX=function(I,J){I=new Z(I,16),I.red||(I=I.toRed(this.red));var O=I.redSqr(),F=this.c2.redSub(this.a.redMul(O)),A=this.one.redSub(this.c2.redMul(this.d).redMul(O)),W=F.redMul(A.redInvm()),H=W.redSqrt();if(H.redSqr().redSub(W).cmp(this.zero)!==0)throw new Error("invalid point");var E=H.fromRed().isOdd();return(J&&!E||!J&&E)&&(H=H.redNeg()),this.point(I,H)},X.prototype.pointFromY=function(I,J){I=new Z(I,16),I.red||(I=I.toRed(this.red));var O=I.redSqr(),F=O.redSub(this.c2),A=O.redMul(this.d).redMul(this.c2).redSub(this.a),W=F.redMul(A.redInvm());if(W.cmp(this.zero)===0){if(J)throw new Error("invalid point");return this.point(this.zero,I)}var H=W.redSqrt();if(H.redSqr().redSub(W).cmp(this.zero)!==0)throw new Error("invalid point");return H.fromRed().isOdd()!==J&&(H=H.redNeg()),this.point(H,I)},X.prototype.validate=function(I){if(I.isInfinity())return!0;I.normalize();var J=I.x.redSqr(),O=I.y.redSqr(),F=J.redMul(this.a).redAdd(O),A=this.c2.redMul(this.one.redAdd(this.d.redMul(J).redMul(O)));return F.cmp(A)===0};function K(I,J,O,F,A){V.BasePoint.call(this,I,"projective"),J===null&&O===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(J,16),this.y=new Z(O,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,J,O,F){return new K(this,I,J,O,F)},K.fromJSON=function(I,J){return new K(I,J[0],J[1],J[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(),J=this.y.redSqr(),O=this.z.redSqr();O=O.redIAdd(O);var F=this.curve._mulA(I),A=this.x.redAdd(this.y).redSqr().redISub(I).redISub(J),W=F.redAdd(J),H=W.redSub(O),E=F.redSub(J),T=A.redMul(H),D=W.redMul(E),C=A.redMul(E),L=H.redMul(W);return this.curve.point(T,D,L,C)},K.prototype._projDbl=function(){var I=this.x.redAdd(this.y).redSqr(),J=this.x.redSqr(),O=this.y.redSqr(),F,A,W,H,E,T;if(this.curve.twisted){H=this.curve._mulA(J);var D=H.redAdd(O);this.zOne?(F=I.redSub(J).redSub(O).redMul(D.redSub(this.curve.two)),A=D.redMul(H.redSub(O)),W=D.redSqr().redSub(D).redSub(D)):(E=this.z.redSqr(),T=D.redSub(E).redISub(E),F=I.redSub(J).redISub(O).redMul(T),A=D.redMul(H.redSub(O)),W=D.redMul(T))}else H=J.redAdd(O),E=this.curve._mulC(this.z).redSqr(),T=H.redSub(E).redSub(E),F=this.curve._mulC(I.redISub(H)).redMul(T),A=this.curve._mulC(H).redMul(J.redISub(O)),W=H.redMul(T);return this.curve.point(F,A,W)},K.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},K.prototype._extAdd=function(I){var J=this.y.redSub(this.x).redMul(I.y.redSub(I.x)),O=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)),W=O.redSub(J),H=A.redSub(F),E=A.redAdd(F),T=O.redAdd(J),D=W.redMul(H),C=E.redMul(T),L=W.redMul(T),R=H.redMul(E);return this.curve.point(D,C,R,L)},K.prototype._projAdd=function(I){var J=this.z.redMul(I.z),O=J.redSqr(),F=this.x.redMul(I.x),A=this.y.redMul(I.y),W=this.curve.d.redMul(F).redMul(A),H=O.redSub(W),E=O.redAdd(W),T=this.x.redAdd(this.y).redMul(I.x.redAdd(I.y)).redISub(F).redISub(A),D=J.redMul(H).redMul(T),C,L;return this.curve.twisted?(C=J.redMul(E).redMul(A.redSub(this.curve._mulA(F))),L=H.redMul(E)):(C=J.redMul(E).redMul(A.redSub(F)),L=this.curve._mulC(H).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,J,O){return this.curve._wnafMulAdd(1,[this,J],[I,O],2,!1)},K.prototype.jmulAdd=function(I,J,O){return this.curve._wnafMulAdd(1,[this,J],[I,O],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 J=I.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(J)===0)return!0;for(var O=I.clone(),F=this.curve.redN.redMul(this.z);;){if(O.iadd(this.curve.n),O.cmp(this.curve.p)>=0)return!1;if(J.redIAdd(F),this.x.cmp(J)===0)return!0}},K.prototype.toP=K.prototype.normalize,K.prototype.mixedAdd=K.prototype.add}}),nQ=z$({"node_modules/elliptic/lib/elliptic/curve/index.js"($){var Q=$;Q.base=bQ(),Q.short=lQ(),Q.mont=oQ(),Q.edwards=uQ()}}),sQ=z$({"node_modules/hash.js/lib/hash/utils.js"($){var Q=$Q(),Y=q$();$.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 N=[];if(typeof k=="string")if(g){if(g==="hex")for(k=k.replace(/[^a-z0-9]+/gi,""),k.length%2!==0&&(k="0"+k),_=0;_>6|192,N[x++]=B&63|128):Z(k,_)?(B=65536+((B&1023)<<10)+(k.charCodeAt(++_)&1023),N[x++]=B>>18|240,N[x++]=B>>12&63|128,N[x++]=B>>6&63|128,N[x++]=B&63|128):(N[x++]=B>>12|224,N[x++]=B>>6&63|128,N[x++]=B&63|128)}else for(_=0;_>>24|k>>>8&65280|k<<8&16711680|(k&255)<<24;return g>>>0}$.htonl=U;function X(k,g){for(var N="",x=0;x>>0}return B}$.join32=J;function O(k,g){for(var N=new Array(k.length*4),x=0,_=0;x>>24,N[_+1]=B>>>16&255,N[_+2]=B>>>8&255,N[_+3]=B&255):(N[_+3]=B>>>24,N[_+2]=B>>>16&255,N[_+1]=B>>>8&255,N[_]=B&255)}return N}$.split32=O;function F(k,g){return k>>>g|k<<32-g}$.rotr32=F;function A(k,g){return k<>>32-g}$.rotl32=A;function W(k,g){return k+g>>>0}$.sum32=W;function H(k,g,N){return k+g+N>>>0}$.sum32_3=H;function E(k,g,N,x){return k+g+N+x>>>0}$.sum32_4=E;function T(k,g,N,x,_){return k+g+N+x+_>>>0}$.sum32_5=T;function D(k,g,N,x){var _=k[g],B=k[g+1],y=x+B>>>0,w=(y>>0,k[g+1]=y}$.sum64=D;function C(k,g,N,x){var _=g+x>>>0,B=(_>>0}$.sum64_hi=C;function L(k,g,N,x){var _=g+x;return _>>>0}$.sum64_lo=L;function R(k,g,N,x,_,B,y,w){var f=0,p=g;p=p+x>>>0,f+=p>>0,f+=p>>0,f+=p>>0}$.sum64_4_hi=R;function P(k,g,N,x,_,B,y,w){var f=g+x+B+w;return f>>>0}$.sum64_4_lo=P;function z(k,g,N,x,_,B,y,w,f,p){var c=0,h=g;h=h+x>>>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,f,p){var c=g+x+B+w+p;return c>>>0}$.sum64_5_lo=M;function S(k,g,N){var x=g<<32-N|k>>>N;return x>>>0}$.rotr64_hi=S;function v(k,g,N){var x=k<<32-N|g>>>N;return x>>>0}$.rotr64_lo=v;function q(k,g,N){return k>>>N}$.shr64_hi=q;function j(k,g,N){var x=k<<32-N|g>>>N;return x>>>0}$.shr64_lo=j}}),tQ=z$({"node_modules/hash.js/lib/hash/common.js"($){var Q=sQ(),Y=$Q();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 J(O){return Y(O,17)^Y(O,19)^O>>>10}$.g1_256=J}}),aQ=z$({"node_modules/hash.js/lib/hash/sha/1.js"($,Q){var Y=sQ(),Z=tQ(),G=mQ(),V=Y.rotl32,U=Y.sum32,X=Y.sum32_5,K=G.ft_1,I=Z.BlockHash,J=[1518500249,1859775393,2400959708,3395469782];function O(){if(!(this instanceof O))return new O;I.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Y.inherits(O,I),Q.exports=O,O.blockSize=512,O.outSize=160,O.hmacStrength=80,O.padLength=64,O.prototype._update=function(F,A){for(var W=this.W,H=0;H<16;H++)W[H]=F[A+H];for(;Hthis.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 J=0;J=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 J=[];J.length"}}}),IY=z$({"node_modules/elliptic/lib/elliptic/ec/signature.js"($,Q){var Y=cQ(),Z=dQ(),G=Z.assert;function V(J,O){if(J instanceof V)return J;this._importDER(J,O)||(G(J.r&&J.s,"Signature without r or s"),this.r=new Y(J.r,16),this.s=new Y(J.s,16),J.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=J.recoveryParam)}Q.exports=V;function U(){this.place=0}function X(J,O){var F=J[O.place++];if(!(F&128))return F;var A=F&15;if(A===0||A>4)return!1;for(var W=0,H=0,E=O.place;H>>=0;return W<=127?!1:(O.place=E,W)}function K(J){for(var O=0,F=J.length-1;!J[O]&&!(J[O+1]&128)&&O>>3);for(J.push(F|128);--F;)J.push(O>>>(F<<3)&255);J.push(O)}V.prototype.toDER=function(J){var O=this.r.toArray(),F=this.s.toArray();for(O[0]&128&&(O=[0].concat(O)),F[0]&128&&(F=[0].concat(F)),O=K(O),F=K(F);!F[0]&&!(F[1]&128);)F=F.slice(1);var A=[2];I(A,O.length),A=A.concat(O),A.push(2),I(A,F.length);var W=A.concat(F),H=[48];return I(H,W.length),H=H.concat(W),Z.encode(H,J)}}}),JY=z$({"node_modules/elliptic/lib/elliptic/ec/index.js"($,Q){var Y=cQ(),Z=XY(),G=dQ(),V=UY(),U=gQ(),X=G.assert,K=KY(),I=IY();function J(O){if(!(this instanceof J))return new J(O);typeof O=="string"&&(X(Object.prototype.hasOwnProperty.call(V,O),"Unknown curve "+O),O=V[O]),O instanceof V.PresetCurve&&(O={curve:O}),this.curve=O.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=O.curve.g,this.g.precompute(O.curve.n.bitLength()+1),this.hash=O.hash||O.curve.hash}Q.exports=J,J.prototype.keyPair=function(O){return new K(this,O)},J.prototype.keyFromPrivate=function(O,F){return K.fromPrivate(this,O,F)},J.prototype.keyFromPublic=function(O,F){return K.fromPublic(this,O,F)},J.prototype.genKeyPair=function(O){O||(O={});for(var F=new Z({hash:this.hash,pers:O.pers,persEnc:O.persEnc||"utf8",entropy:O.entropy||U(this.hash.hmacStrength),entropyEnc:O.entropy&&O.entropyEnc||"utf8",nonce:this.n.toArray()}),A=this.n.byteLength(),W=this.n.sub(new Y(2));;){var H=new Y(F.generate(A));if(!(H.cmp(W)>0))return H.iaddn(1),this.keyFromPrivate(H)}},J.prototype._truncateToN=function(O,F){var A=O.byteLength()*8-this.n.bitLength();return A>0&&(O=O.ushrn(A)),!F&&O.cmp(this.n)>=0?O.sub(this.n):O},J.prototype.sign=function(O,F,A,W){typeof A=="object"&&(W=A,A=null),W||(W={}),F=this.keyFromPrivate(F,A),O=this._truncateToN(new Y(O,16));for(var H=this.n.byteLength(),E=F.getPrivate().toArray("be",H),T=O.toArray("be",H),D=new Z({hash:this.hash,entropy:E,nonce:T,pers:W.pers,persEnc:W.persEnc||"utf8"}),C=this.n.sub(new Y(1)),L=0;;L++){var R=W.k?W.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(O));if(S=S.umod(this.n),S.cmpn(0)!==0){var v=(P.getY().isOdd()?1:0)|(z.cmp(M)!==0?2:0);return W.canonical&&S.cmp(this.nh)>0&&(S=this.n.sub(S),v^=1),new I({r:M,s:S,recoveryParam:v})}}}}}},J.prototype.verify=function(O,F,A,W){O=this._truncateToN(new Y(O,16)),A=this.keyFromPublic(A,W),F=new I(F,"hex");var{r:H,s:E}=F;if(H.cmpn(1)<0||H.cmp(this.n)>=0||E.cmpn(1)<0||E.cmp(this.n)>=0)return!1;var T=E.invm(this.n),D=T.mul(O).umod(this.n),C=T.mul(H).umod(this.n),L;return this.curve._maxwellTrick?(L=this.g.jmulAdd(D,A.getPublic(),C),L.isInfinity()?!1:L.eqXToP(H)):(L=this.g.mulAdd(D,A.getPublic(),C),L.isInfinity()?!1:L.getX().umod(this.n).cmp(H)===0)},J.prototype.recoverPubKey=function(O,F,A,W){X((3&A)===A,"The recovery param is more than two bits"),F=new I(F,W);var H=this.n,E=new Y(O),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(H),P=H.sub(E).mul(R).umod(H),z=D.mul(R).umod(H);return this.g.mulAdd(P,T,z)},J.prototype.getKeyRecoveryParam=function(O,F,A,W){if(F=new I(F,W),F.recoveryParam!==null)return F.recoveryParam;for(var H=0;H<4;H++){var E;try{E=this.recoverPubKey(O,F,H)}catch{continue}if(E.eq(A))return H}throw new Error("Unable to find valid recovery factor")}}}),OY=z$({"node_modules/elliptic/lib/elliptic/eddsa/key.js"($,Q){var Y=dQ(),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,J=K.slice(0,X.encodingLength);return J[0]&=248,J[I]&=127,J[I]|=64,J}),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}}),FY=z$({"node_modules/elliptic/lib/elliptic/eddsa/signature.js"($,Q){var Y=cQ(),Z=dQ(),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}}),AY=z$({"node_modules/elliptic/lib/elliptic/eddsa/index.js"($,Q){var Y=GY(),Z=UY(),G=dQ(),V=G.assert,U=G.parseBytes,X=OY(),K=FY();function I(J){if(V(J==="ed25519","only tested with ed25519 so far"),!(this instanceof I))return new I(J);J=Z[J].curve,this.curve=J,this.g=J.g,this.g.precompute(J.n.bitLength()+1),this.pointClass=J.point().constructor,this.encodingLength=Math.ceil(J.n.bitLength()/8),this.hash=Y.sha512}Q.exports=I,I.prototype.sign=function(J,O){J=U(J);var F=this.keyFromSecret(O),A=this.hashInt(F.messagePrefix(),J),W=this.g.mul(A),H=this.encodePoint(W),E=this.hashInt(H,F.pubBytes(),J).mul(F.priv()),T=A.add(E).umod(this.curve.n);return this.makeSignature({R:W,S:T,Rencoded:H})},I.prototype.verify=function(J,O,F){J=U(J),O=this.makeSignature(O);var A=this.keyFromPublic(F),W=this.hashInt(O.Rencoded(),A.pubBytes(),J),H=this.g.mul(O.S()),E=O.R().add(A.pub().mul(W));return E.eq(H)},I.prototype.hashInt=function(){for(var J=this.hash(),O=0;O0?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 N=0;j[0]==="-"&&(N++,this.negative=1),N=0;N-=3)_=j[N]|j[N-1]<<8|j[N-2]<<16,this.words[x]|=_<>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);else if(g==="le")for(N=0,x=0;N>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);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 N=K(j,g);return g-1>=k&&(N|=K(j,g-1)<<4),N}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var N=0;N=k;N-=2)B=I(j,k,N)<=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8;else{var y=j.length-k;for(N=y%2===0?k+1:k;N=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8}this.strip()};function J(j,k,g,N){for(var x=0,_=Math.min(j.length,g),B=k;B<_;B++){var y=j.charCodeAt(B)-48;x*=N,y>=49?x+=y-49+10:y>=17?x+=y-17+10:x+=y}return x}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var N=0,x=1;x<=67108863;x*=k)N++;N--,x=x/k|0;for(var _=j.length-g,B=_%N,y=Math.min(_,_-B)+g,w=0,f=g;f1&&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 O=["","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 N=0,x=0,_=0;_>>24-N&16777215,x!==0||_!==this.length-1?g=O[6-y.length]+y+g:g=y+g,N+=2,N>=26&&(N-=26,_--)}for(x!==0&&(g=x.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],f=A[j];g="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(j);p=p.idivn(f),p.isZero()?g=c+g:g=O[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 N=this.byteLength(),x=g||Math.max(1,N);G(N<=x,"byte array longer than desired length"),G(x>0,"Requested array length <= 0"),this.strip();var _=k==="le",B=new j(x),y,w,f=this.clone();if(_){for(w=0;!f.isZero();w++)y=f.andln(255),f.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 W(j){for(var k=new Array(j.bitLength()),g=0;g>>x}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 N=0;Nj.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 N=0;N0&&(this.words[N]=~this.words[N]&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,N=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<j.length?(g=this,N=j):(g=j,N=this);for(var x=0,_=0;_>>26;for(;x!==0&&_>>26;if(this.length=g.length,x!==0)this.words[this.length]=x,this.length++;else if(g!==this)for(;_j.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,x;g>0?(N=this,x=j):(N=j,x=this);for(var _=0,B=0;B>26,this.words[B]=k&67108863;for(;_!==0&&B>26,this.words[B]=k&67108863;if(_===0&&B>>26,c=w&67108863,h=Math.min(f,k.length-1),d=Math.max(0,f-j.length+1);d<=h;d++){var b=f-d|0;x=j.words[b]|0,_=k.words[d]|0,B=x*_+c,p+=B/67108864|0,c=B&67108863}g.words[f]=c|0,w=p|0}return w!==0?g.words[f]=w|0:g.length--,g.strip()}var E=function(j,k,g){var N=j.words,x=k.words,_=g.words,B=0,y,w,f,p=N[0]|0,c=p&8191,h=p>>>13,d=N[1]|0,b=d&8191,l=d>>>13,o=N[2]|0,u=o&8191,n=o>>>13,s=N[3]|0,t=s&8191,m=s>>>13,a=N[4]|0,r=a&8191,e=a>>>13,i=N[5]|0,$0=i&8191,Q0=i>>>13,Y0=N[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=N[7]|0,U0=V0&8191,X0=V0>>>13,K0=N[8]|0,I0=K0&8191,J0=K0>>>13,O0=N[9]|0,F0=O0&8191,A0=O0>>>13,W0=x[0]|0,H0=W0&8191,E0=W0>>>13,T0=x[1]|0,D0=T0&8191,C0=T0>>>13,L0=x[2]|0,R0=L0&8191,P0=L0>>>13,z0=x[3]|0,M0=z0&8191,S0=z0>>>13,v0=x[4]|0,q0=v0&8191,j0=v0>>>13,k0=x[5]|0,g0=k0&8191,N0=k0>>>13,x0=x[6]|0,_0=x0&8191,B0=x0>>>13,y0=x[7]|0,w0=y0&8191,f0=y0>>>13,p0=x[8]|0,c0=p0&8191,h0=p0>>>13,d0=x[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,H0),w=Math.imul(c,E0),w=w+Math.imul(h,H0)|0,f=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,H0),w=Math.imul(b,E0),w=w+Math.imul(l,H0)|0,f=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,f=f+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,H0),w=Math.imul(u,E0),w=w+Math.imul(n,H0)|0,f=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,f=f+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,f=f+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,H0),w=Math.imul(t,E0),w=w+Math.imul(m,H0)|0,f=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,f=f+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,f=f+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,f=f+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(r,H0),w=Math.imul(r,E0),w=w+Math.imul(e,H0)|0,f=Math.imul(e,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,f=f+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,f=f+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,f=f+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,f=f+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,H0),w=Math.imul($0,E0),w=w+Math.imul(Q0,H0)|0,f=Math.imul(Q0,E0),y=y+Math.imul(r,D0)|0,w=w+Math.imul(r,C0)|0,w=w+Math.imul(e,D0)|0,f=f+Math.imul(e,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,f=f+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,f=f+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,f=f+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,N0)|0,w=w+Math.imul(h,g0)|0,f=f+Math.imul(h,N0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,H0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,H0)|0,f=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,f=f+Math.imul(Q0,C0)|0,y=y+Math.imul(r,R0)|0,w=w+Math.imul(r,P0)|0,w=w+Math.imul(e,R0)|0,f=f+Math.imul(e,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,f=f+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,f=f+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,N0)|0,w=w+Math.imul(l,g0)|0,f=f+Math.imul(l,N0)|0,y=y+Math.imul(c,_0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,_0)|0,f=f+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,H0),w=Math.imul(U0,E0),w=w+Math.imul(X0,H0)|0,f=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,f=f+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,f=f+Math.imul(Q0,P0)|0,y=y+Math.imul(r,M0)|0,w=w+Math.imul(r,S0)|0,w=w+Math.imul(e,M0)|0,f=f+Math.imul(e,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,f=f+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,N0)|0,w=w+Math.imul(n,g0)|0,f=f+Math.imul(n,N0)|0,y=y+Math.imul(b,_0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,_0)|0,f=f+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,f0)|0,w=w+Math.imul(h,w0)|0,f=f+Math.imul(h,f0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(I0,H0),w=Math.imul(I0,E0),w=w+Math.imul(J0,H0)|0,f=Math.imul(J0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,S0)|0,y=y+Math.imul(r,q0)|0,w=w+Math.imul(r,j0)|0,w=w+Math.imul(e,q0)|0,f=f+Math.imul(e,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,N0)|0,w=w+Math.imul(m,g0)|0,f=f+Math.imul(m,N0)|0,y=y+Math.imul(u,_0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,_0)|0,f=f+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,f0)|0,w=w+Math.imul(l,w0)|0,f=f+Math.imul(l,f0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,f=f+Math.imul(h,h0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(F0,H0),w=Math.imul(F0,E0),w=w+Math.imul(A0,H0)|0,f=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(J0,D0)|0,f=f+Math.imul(J0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,j0)|0,y=y+Math.imul(r,g0)|0,w=w+Math.imul(r,N0)|0,w=w+Math.imul(e,g0)|0,f=f+Math.imul(e,N0)|0,y=y+Math.imul(t,_0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,_0)|0,f=f+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,f0)|0,w=w+Math.imul(n,w0)|0,f=f+Math.imul(n,f0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,f=f+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,f=f+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(J0,R0)|0,f=f+Math.imul(J0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,f=f+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,f=f+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,N0)|0,w=w+Math.imul(Q0,g0)|0,f=f+Math.imul(Q0,N0)|0,y=y+Math.imul(r,_0)|0,w=w+Math.imul(r,B0)|0,w=w+Math.imul(e,_0)|0,f=f+Math.imul(e,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,f0)|0,w=w+Math.imul(m,w0)|0,f=f+Math.imul(m,f0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,f=f+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,f=f+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,f=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(J0,M0)|0,f=f+Math.imul(J0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,f=f+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,N0)|0,w=w+Math.imul(G0,g0)|0,f=f+Math.imul(G0,N0)|0,y=y+Math.imul($0,_0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,_0)|0,f=f+Math.imul(Q0,B0)|0,y=y+Math.imul(r,w0)|0,w=w+Math.imul(r,f0)|0,w=w+Math.imul(e,w0)|0,f=f+Math.imul(e,f0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,f=f+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,f=f+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(J0,q0)|0,f=f+Math.imul(J0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,N0)|0,w=w+Math.imul(X0,g0)|0,f=f+Math.imul(X0,N0)|0,y=y+Math.imul(Z0,_0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,_0)|0,f=f+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,f0)|0,w=w+Math.imul(Q0,w0)|0,f=f+Math.imul(Q0,f0)|0,y=y+Math.imul(r,c0)|0,w=w+Math.imul(r,h0)|0,w=w+Math.imul(e,c0)|0,f=f+Math.imul(e,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,f=f+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,N0)|0,w=w+Math.imul(J0,g0)|0,f=f+Math.imul(J0,N0)|0,y=y+Math.imul(U0,_0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,_0)|0,f=f+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,f0)|0,w=w+Math.imul(G0,w0)|0,f=f+Math.imul(G0,f0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,f=f+Math.imul(Q0,h0)|0,y=y+Math.imul(r,b0)|0,w=w+Math.imul(r,l0)|0,w=w+Math.imul(e,b0)|0,f=f+Math.imul(e,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,N0),w=w+Math.imul(A0,g0)|0,f=Math.imul(A0,N0),y=y+Math.imul(I0,_0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(J0,_0)|0,f=f+Math.imul(J0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,f0)|0,w=w+Math.imul(X0,w0)|0,f=f+Math.imul(X0,f0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,f=f+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,f=f+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,_0),w=Math.imul(F0,B0),w=w+Math.imul(A0,_0)|0,f=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,f0)|0,w=w+Math.imul(J0,w0)|0,f=f+Math.imul(J0,f0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,f=f+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,f=f+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,f0),w=w+Math.imul(A0,w0)|0,f=Math.imul(A0,f0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(J0,c0)|0,f=f+Math.imul(J0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,f=f+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(J0,b0)|0,f=f+Math.imul(J0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(f+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,_[0]=o0,_[1]=u0,_[2]=n0,_[3]=s0,_[4]=t0,_[5]=m0,_[6]=a0,_[7]=r0,_[8]=e0,_[9]=i0,_[10]=$$,_[11]=Q$,_[12]=Y$,_[13]=Z$,_[14]=G$,_[15]=V$,_[16]=U$,_[17]=X$,_[18]=K$,B!==0&&(_[19]=B,g.length++),g};Math.imul||(E=H);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var N=0,x=0,_=0;_>>26)|0,x+=B>>>26,B&=67108863}g.words[_]=y,N=B,B=x}return N!==0?g.words[_]=N:g.length--,g.strip()}function D(j,k,g){var N=new C;return N.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,N=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):N<63?g=H(this,j,k):N<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,N=0;N>=1;return N},C.prototype.permute=function(j,k,g,N,x,_){for(var B=0;B<_;B++)N[B]=k[j[B]],x[B]=g[j[B]]},C.prototype.transform=function(j,k,g,N,x,_){this.permute(_,j,k,g,N,x);for(var B=1;B>>1)x++;return 1<>>13,g[2*_+1]=x&8191,x=x>>>13;for(_=2*k;_>=26,k+=N/67108864|0,k+=x>>>26,this.words[g]=x&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=W(j);if(k.length===0)return new U(1);for(var g=this,N=0;N=0);var k=j%26,g=(j-k)/26,N=67108863>>>26-k<<26-k,x;if(k!==0){var _=0;for(x=0;x>>26-k}_&&(this.words[x]=_,this.length++)}if(g!==0){for(x=this.length-1;x>=0;x--)this.words[x+g]=this.words[x];for(x=0;x=0);var N;k?N=(k-k%26)/26:N=0;var x=j%26,_=Math.min((j-x)/26,this.length),B=67108863^67108863>>>x<_)for(this.length-=_,w=0;w=0&&(f!==0||w>=N);w--){var p=this.words[w]|0;this.words[w]=f<<26-x|p>>>x,f=p&B}return y&&f!==0&&(y.words[y.length++]=f),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,N=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 N=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[x+g]=_&67108863}for(;x>26,this.words[x+g]=_&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,x=0;x>26,this.words[x]=_&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,N=this.clone(),x=j,_=x.words[x.length-1]|0,B=this._countBits(_);g=26-B,g!==0&&(x=x.ushln(g),N.iushln(g),_=x.words[x.length-1]|0);var y=N.length-x.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var f=0;f=0;c--){var h=(N.words[x.length+c]|0)*67108864+(N.words[x.length+c-1]|0);for(h=Math.min(h/_|0,67108863),N._ishlnsubmul(x,h,c);N.negative!==0;)h--,N.negative=0,N._ishlnsubmul(x,1,c),N.isZero()||(N.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),N.strip(),k!=="div"&&g!==0&&N.iushrn(g),{div:w||null,mod:N}},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?(_=this.neg().divmod(j,k),k!=="mod"&&(N=_.div.neg()),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.iadd(j)),{div:N,mod:x}):this.negative===0&&j.negative!==0?(_=this.divmod(j.neg(),k),k!=="mod"&&(N=_.div.neg()),{div:N,mod:_.mod}):(this.negative&j.negative)!==0?(_=this.neg().divmod(j.neg(),k),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.isub(j)),{div:_.div,mod:x}):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,N=j.ushrn(1),x=j.andln(1),_=g.cmp(N);return _<0||x===1&&_===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,N=this.length-1;N>=0;N--)g=(k*g+(this.words[N]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var N=(this.words[g]|0)+k*67108864;this.words[g]=N/j|0,k=N%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 N=new U(1),x=new U(0),_=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(),f=k.clone();!k.isZero();){for(var p=0,c=1;(k.words[0]&c)===0&&p<26;++p,c<<=1);if(p>0)for(k.iushrn(p);p-- >0;)(N.isOdd()||x.isOdd())&&(N.iadd(w),x.isub(f)),N.iushrn(1),x.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;)(_.isOdd()||B.isOdd())&&(_.iadd(w),B.isub(f)),_.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(_),x.isub(B)):(g.isub(k),_.isub(N),B.isub(x))}return{a:_,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 N=new U(1),x=new U(0),_=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;)N.isOdd()&&N.iadd(_),N.iushrn(1);for(var w=0,f=1;(g.words[0]&f)===0&&w<26;++w,f<<=1);if(w>0)for(g.iushrn(w);w-- >0;)x.isOdd()&&x.iadd(_),x.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(x)):(g.isub(k),x.isub(N))}var p;return k.cmpn(1)===0?p=N:p=x,p.cmpn(0)<0&&p.iadd(j),p},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 N=0;k.isEven()&&g.isEven();N++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var x=k.cmp(g);if(x<0){var _=k;k=g,g=_}else if(x===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(N)},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,N=1<>>26,B&=67108863,this.words[_]=B}return x!==0&&(this.words[_]=x,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 N=this.words[0]|0;g=N===j?0:Nj.length)return 1;if(this.length=0;g--){var N=this.words[g]|0,x=j.words[g]|0;if(N!==x){Nx&&(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 N=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,N=Math.min(j.length,9),x=0;x>>22,_=B}_>>>=22,j.words[x-10]=_,_===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]=x,k=N}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 N=this.m.subn(1),x=0;!N.isZero()&&N.andln(1)===0;)x++,N.iushrn(1);G(!N.isZero());var _=new U(1).toRed(this),B=_.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 f=this.pow(w,N),p=this.pow(j,N.addn(1).iushrn(1)),c=this.pow(j,N),h=x;c.cmp(_)!==0;){for(var d=c,b=0;d.cmp(_)!==0;b++)d=d.redSqr();G(b=0;x--){for(var f=k.words[x],p=w-1;p>=0;p--){var c=f>>p&1;if(_!==N[0]&&(_=this.sqr(_)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(x!==0||p!==0))&&(_=this.mul(_,N[B]),y=0,B=0)}w=26}return _},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),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._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,$)}}),EY=z$({"node_modules/safer-buffer/safer.js"($,Q){var Y=R$("buffer"),Z=Y.Buffer,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 J=Z(X);return!K||K.length===0?J.fill(0):typeof I=="string"?J.fill(K,I):J.fill(K),J}),!G.kStringMaxLength)try{G.kStringMaxLength=L$}catch{}G.constants||(G.constants={MAX_LENGTH:G.kMaxLength},G.kStringMaxLength&&(G.constants.MAX_STRING_LENGTH=G.kStringMaxLength)),Q.exports=G}}),TY=z$({"node_modules/asn1.js/lib/asn1/base/reporter.js"($){var Q=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}}}),W$=z$({"node_modules/asn1.js/lib/asn1/base/buffer.js"($){var Q=q$(),Y=TY().Reporter,Z=EY().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}}}),DY=z$({"node_modules/asn1.js/lib/asn1/base/node.js"($,Q){var Y=TY().Reporter,Z=W$().EncoderBuffer,G=W$().DecoderBuffer,V=$Q(),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(O,F,A){let W={};this._baseState=W,W.name=A,W.enc=O,W.parent=F||null,W.children=null,W.tag=null,W.args=null,W.reverseArgs=null,W.choice=null,W.optional=!1,W.any=!1,W.obj=!1,W.use=null,W.useDecoder=null,W.key=null,W.default=null,W.explicit=null,W.implicit=null,W.contains=null,W.parent||(W.children=[],this._wrap())}Q.exports=I;var J=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];I.prototype.clone=function(){let O=this._baseState,F={};J.forEach(function(W){F[W]=O[W]});let A=new this.constructor(F.parent);return A._baseState=F,A},I.prototype._wrap=function(){let O=this._baseState;X.forEach(function(F){this[F]=function(){let A=new this.constructor(this);return O.children.push(A),A[F].apply(A,arguments)}},this)},I.prototype._init=function(O){let F=this._baseState;V(F.parent===null),O.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(O){let F=this._baseState,A=O.filter(function(W){return W instanceof this.constructor},this);O=O.filter(function(W){return!(W instanceof this.constructor)},this),A.length!==0&&(V(F.children===null),F.children=A,A.forEach(function(W){W._baseState.parent=this},this)),O.length!==0&&(V(F.args===null),F.args=O,F.reverseArgs=O.map(function(W){if(typeof W!="object"||W.constructor!==Object)return W;let H={};return Object.keys(W).forEach(function(E){E==(E|0)&&(E|=0);let T=W[E];H[T]=E}),H}))},K.forEach(function(O){I.prototype[O]=function(){let F=this._baseState;throw new Error(O+" not implemented for encoding: "+F.enc)}}),U.forEach(function(O){I.prototype[O]=function(){let F=this._baseState,A=Array.prototype.slice.call(arguments);return V(F.tag===null),F.tag=O,this._useArgs(A),this}}),I.prototype.use=function(O){V(O);let F=this._baseState;return V(F.use===null),F.use=O,this},I.prototype.optional=function(){let O=this._baseState;return O.optional=!0,this},I.prototype.def=function(O){let F=this._baseState;return V(F.default===null),F.default=O,F.optional=!0,this},I.prototype.explicit=function(O){let F=this._baseState;return V(F.explicit===null&&F.implicit===null),F.explicit=O,this},I.prototype.implicit=function(O){let F=this._baseState;return V(F.explicit===null&&F.implicit===null),F.implicit=O,this},I.prototype.obj=function(){let O=this._baseState,F=Array.prototype.slice.call(arguments);return O.obj=!0,F.length!==0&&this._useArgs(F),this},I.prototype.key=function(O){let F=this._baseState;return V(F.key===null),F.key=O,this},I.prototype.any=function(){let O=this._baseState;return O.any=!0,this},I.prototype.choice=function(O){let F=this._baseState;return V(F.choice===null),F.choice=O,this._useArgs(Object.keys(O).map(function(A){return O[A]})),this},I.prototype.contains=function(O){let F=this._baseState;return V(F.use===null),F.contains=O,this},I.prototype._decode=function(O,F){let A=this._baseState;if(A.parent===null)return O.wrapResult(A.children[0]._decode(O,F));let W=A.default,H=!0,E=null;if(A.key!==null&&(E=O.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=O.save();try{A.choice===null?this._decodeGeneric(A.tag,O,F):this._decodeChoice(O,F),H=!0}catch{H=!1}O.restore(C)}else if(H=this._peekTag(O,D,A.any),O.isError(H))return H}let T;if(A.obj&&H&&(T=O.enterObject()),H){if(A.explicit!==null){let C=this._decodeTag(O,A.explicit);if(O.isError(C))return C;O=C}let D=O.offset;if(A.use===null&&A.choice===null){let C;A.any&&(C=O.save());let L=this._decodeTag(O,A.implicit!==null?A.implicit:A.tag,A.any);if(O.isError(L))return L;A.any?W=O.raw(C):O=L}if(F&&F.track&&A.tag!==null&&F.track(O.path(),D,O.length,"tagged"),F&&F.track&&A.tag!==null&&F.track(O.path(),O.offset,O.length,"content"),A.any||(A.choice===null?W=this._decodeGeneric(A.tag,O,F):W=this._decodeChoice(O,F)),O.isError(W))return W;if(!A.any&&A.choice===null&&A.children!==null&&A.children.forEach(function(C){C._decode(O,F)}),A.contains&&(A.tag==="octstr"||A.tag==="bitstr")){let C=new G(W);W=this._getUse(A.contains,O._reporterState.obj)._decode(C,F)}}return A.obj&&H&&(W=O.leaveObject(T)),A.key!==null&&(W!==null||H===!0)?O.leaveKey(E,A.key,W):E!==null&&O.exitKey(E),W},I.prototype._decodeGeneric=function(O,F,A){let W=this._baseState;return O==="seq"||O==="set"?null:O==="seqof"||O==="setof"?this._decodeList(F,O,W.args[0],A):/str$/.test(O)?this._decodeStr(F,O,A):O==="objid"&&W.args?this._decodeObjid(F,W.args[0],W.args[1],A):O==="objid"?this._decodeObjid(F,null,null,A):O==="gentime"||O==="utctime"?this._decodeTime(F,O,A):O==="null_"?this._decodeNull(F,A):O==="bool"?this._decodeBool(F,A):O==="objDesc"?this._decodeStr(F,O,A):O==="int"||O==="enum"?this._decodeInt(F,W.args&&W.args[0],A):W.use!==null?this._getUse(W.use,F._reporterState.obj)._decode(F,A):F.error("unknown tag: "+O)},I.prototype._getUse=function(O,F){let A=this._baseState;return A.useDecoder=this._use(O,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(O,F){let A=this._baseState,W=null,H=!1;return Object.keys(A.choice).some(function(E){let T=O.save(),D=A.choice[E];try{let C=D._decode(O,F);if(O.isError(C))return!1;W={type:E,value:C},H=!0}catch{return O.restore(T),!1}return!0},this),H?W:O.error("Choice not matched")},I.prototype._createEncoderBuffer=function(O){return new Z(O,this.reporter)},I.prototype._encode=function(O,F,A){let W=this._baseState;if(W.default!==null&&W.default===O)return;let H=this._encodeValue(O,F,A);if(H!==void 0&&!this._skipDefault(H,F,A))return H},I.prototype._encodeValue=function(O,F,A){let W=this._baseState;if(W.parent===null)return W.children[0]._encode(O,F||new Y);let H=null;if(this.reporter=F,W.optional&&O===void 0)if(W.default!==null)O=W.default;else return;let E=null,T=!1;if(W.any)H=this._createEncoderBuffer(O);else if(W.choice)H=this._encodeChoice(O,F);else if(W.contains)E=this._getUse(W.contains,A)._encode(O,F),T=!0;else if(W.children)E=W.children.map(function(D){if(D._baseState.tag==="null_")return D._encode(null,F,O);if(D._baseState.key===null)return F.error("Child should have a key");let C=F.enterKey(D._baseState.key);if(typeof O!="object")return F.error("Child expected, but input is not object");let L=D._encode(O[D._baseState.key],F,O);return F.leaveKey(C),L},this).filter(function(D){return D}),E=this._createEncoderBuffer(E);else if(W.tag==="seqof"||W.tag==="setof"){if(!(W.args&&W.args.length===1))return F.error("Too many args for : "+W.tag);if(!Array.isArray(O))return F.error("seqof/setof, but data is not Array");let D=this.clone();D._baseState.implicit=null,E=this._createEncoderBuffer(O.map(function(C){let L=this._baseState;return this._getUse(L.args[0],O)._encode(C,F)},D))}else W.use!==null?H=this._getUse(W.use,A)._encode(O,F):(E=this._encodePrimitive(W.tag,O),T=!0);if(!W.any&&W.choice===null){let D=W.implicit!==null?W.implicit:W.tag,C=W.implicit===null?"universal":"context";D===null?W.use===null&&F.error("Tag could be omitted only for .use()"):W.use===null&&(H=this._encodeComposite(D,T,C,E))}return W.explicit!==null&&(H=this._encodeComposite(W.explicit,!1,"context",H)),H},I.prototype._encodeChoice=function(O,F){let A=this._baseState,W=A.choice[O.type];return W||V(!1,O.type+" not found in "+JSON.stringify(Object.keys(A.choice))),W._encode(O.value,F)},I.prototype._encodePrimitive=function(O,F){let A=this._baseState;if(/str$/.test(O))return this._encodeStr(F,O);if(O==="objid"&&A.args)return this._encodeObjid(F,A.reverseArgs[0],A.args[1]);if(O==="objid")return this._encodeObjid(F,null,null);if(O==="gentime"||O==="utctime")return this._encodeTime(F,O);if(O==="null_")return this._encodeNull();if(O==="int"||O==="enum")return this._encodeInt(F,A.args&&A.reverseArgs[0]);if(O==="bool")return this._encodeBool(F);if(O==="objDesc")return this._encodeStr(F,O);throw new Error("Unsupported tag: "+O)},I.prototype._isNumstr=function(O){return/^[0-9 ]*$/.test(O)},I.prototype._isPrintstr=function(O){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(O)}}}),CY=z$({"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)}}),LY=z$({"node_modules/asn1.js/lib/asn1/encoders/der.js"($,Q){var Y=q$(),Z=EY().Buffer,G=DY(),V=CY();function U(J){this.enc="der",this.name=J.name,this.entity=J,this.tree=new X,this.tree._init(J.body)}Q.exports=U,U.prototype.encode=function(J,O){return this.tree._encode(J,O).join()};function X(J){G.call(this,"der",J)}Y(X,G),X.prototype._encodeComposite=function(J,O,F,A){let W=I(J,O,F,this.reporter);if(A.length<128){let T=Z.alloc(2);return T[0]=W,T[1]=A.length,this._createEncoderBuffer([T,A])}let H=1;for(let T=A.length;T>=256;T>>=8)H++;let E=Z.alloc(2+H);E[0]=W,E[1]=128|H;for(let T=1+H,D=A.length;D>0;T--,D>>=8)E[T]=D&255;return this._createEncoderBuffer([E,A])},X.prototype._encodeStr=function(J,O){if(O==="bitstr")return this._createEncoderBuffer([J.unused|0,J.data]);if(O==="bmpstr"){let F=Z.alloc(J.length*2);for(let A=0;A=40)return this.reporter.error("Second objid identifier OOB");J.splice(0,2,J[0]*40+J[1])}let A=0;for(let E=0;E=128;T>>=7)A++}let W=Z.alloc(A),H=W.length-1;for(let E=J.length-1;E>=0;E--){let T=J[E];for(W[H--]=T&127;(T>>=7)>0;)W[H--]=128|T&127}return this._createEncoderBuffer(W)};function K(J){return J<10?"0"+J:J}X.prototype._encodeTime=function(J,O){let F,A=new Date(J);return O==="gentime"?F=[K(A.getUTCFullYear()),K(A.getUTCMonth()+1),K(A.getUTCDate()),K(A.getUTCHours()),K(A.getUTCMinutes()),K(A.getUTCSeconds()),"Z"].join(""):O==="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 "+O+" time is not supported yet"),this._encodeStr(F,"octstr")},X.prototype._encodeNull=function(){return this._createEncoderBuffer("")},X.prototype._encodeInt=function(J,O){if(typeof J=="string"){if(!O)return this.reporter.error("String int or enum given, but no values map");if(!O.hasOwnProperty(J))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(J));J=O[J]}if(typeof J!="number"&&!Z.isBuffer(J)){let W=J.toArray();!J.sign&&W[0]&128&&W.unshift(0),J=Z.from(W)}if(Z.isBuffer(J)){let W=J.length;J.length===0&&W++;let H=Z.alloc(W);return J.copy(H),J.length===0&&(H[0]=0),this._createEncoderBuffer(H)}if(J<128)return this._createEncoderBuffer(J);if(J<256)return this._createEncoderBuffer([0,J]);let F=1;for(let W=J;W>=256;W>>=8)F++;let A=new Array(F);for(let W=A.length-1;W>=0;W--)A[W]=J&255,J>>=8;return A[0]&128&&A.unshift(0),this._createEncoderBuffer(Z.from(A))},X.prototype._encodeBool=function(J){return this._createEncoderBuffer(J?255:0)},X.prototype._use=function(J,O){return typeof J=="function"&&(J=J(O)),J._getEncoder("der").tree},X.prototype._skipDefault=function(J,O,F){let A=this._baseState,W;if(A.default===null)return!1;let H=J.join();if(A.defaultBuffer===void 0&&(A.defaultBuffer=this._encodeValue(A.default,O,F).join()),H.length!==A.defaultBuffer.length)return!1;for(W=0;W=31?A.error("Multi-octet tag encoding unsupported"):(O||(W|=32),W|=V.tagClassByName[F||"universal"]<<6,W)}}}),RY=z$({"node_modules/asn1.js/lib/asn1/encoders/pem.js"($,Q){var Y=q$(),Z=LY();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],H=(A&32)===0;if((A&31)===31){let T=A;for(A=0;(T&128)===128;){if(T=O.readUInt8(F),O.isError(T))return T;A<<=7,A|=T&127}}else A&=31;let E=U.tag[A];return{cls:W,primitive:H,tag:A,tagStr:E}}function J(O,F,A){let W=O.readUInt8(A);if(O.isError(W))return W;if(!F&&W===128)return null;if((W&128)===0)return W;let H=W&127;if(H>4)return O.error("length octect is too long");W=0;for(let E=0;E0&&L.ishrn(R),L}function H(D,C){D=W(D,C),D=D.mod(C);var L=Y.from(D.toArray());if(L.length=F)throw new Error("invalid sig")}Q.exports=X}}),pY=z$({"node_modules/browserify-sign/browser/index.js"($,Q){var Y=S$().Buffer,Z=d$(),G=R$("readable-stream"),V=q$(),U=wY(),X=fY(),K=u$();Object.keys(K).forEach(function(A){K[A].id=Y.from(K[A].id,"hex"),K[A.toLowerCase()]=K[A]});function I(A){G.Writable.call(this);var W=K[A];if(!W)throw new Error("Unknown message digest");this._hashType=W.hash,this._hash=Z(W.hash),this._tag=W.id,this._signType=W.sign}V(I,G.Writable),I.prototype._write=function(A,W,H){this._hash.update(A),H()},I.prototype.update=function(A,W){return typeof A=="string"&&(A=Y.from(A,W)),this._hash.update(A),this},I.prototype.sign=function(A,W){this.end();var H=this._hash.digest(),E=U(H,A,this._hashType,this._signType,this._tag);return W?E.toString(W):E};function J(A){G.Writable.call(this);var W=K[A];if(!W)throw new Error("Unknown message digest");this._hash=Z(W.hash),this._tag=W.id,this._signType=W.sign}V(J,G.Writable),J.prototype._write=function(A,W,H){this._hash.update(A),H()},J.prototype.update=function(A,W){return typeof A=="string"&&(A=Y.from(A,W)),this._hash.update(A),this},J.prototype.verify=function(A,W,H){typeof W=="string"&&(W=Y.from(W,H)),this.end();var E=this._hash.digest();return X(W,E,A,this._signType,this._tag)};function O(A){return new I(A)}function F(A){return new J(A)}Q.exports={Sign:O,Verify:F,createSign:O,createVerify:F}}}),cY=z$({"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;try{typeof window<"u"&&typeof window.Buffer<"u"?X=window.Buffer:X=R$("buffer").Buffer}catch{}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 N=0;j[0]==="-"&&(N++,this.negative=1),N=0;N-=3)_=j[N]|j[N-1]<<8|j[N-2]<<16,this.words[x]|=_<>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);else if(g==="le")for(N=0,x=0;N>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);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 N=K(j,g);return g-1>=k&&(N|=K(j,g-1)<<4),N}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var N=0;N=k;N-=2)B=I(j,k,N)<=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8;else{var y=j.length-k;for(N=y%2===0?k+1:k;N=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8}this.strip()};function J(j,k,g,N){for(var x=0,_=Math.min(j.length,g),B=k;B<_;B++){var y=j.charCodeAt(B)-48;x*=N,y>=49?x+=y-49+10:y>=17?x+=y-17+10:x+=y}return x}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var N=0,x=1;x<=67108863;x*=k)N++;N--,x=x/k|0;for(var _=j.length-g,B=_%N,y=Math.min(_,_-B)+g,w=0,f=g;f1&&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 O=["","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 N=0,x=0,_=0;_>>24-N&16777215,x!==0||_!==this.length-1?g=O[6-y.length]+y+g:g=y+g,N+=2,N>=26&&(N-=26,_--)}for(x!==0&&(g=x.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],f=A[j];g="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(j);p=p.idivn(f),p.isZero()?g=c+g:g=O[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 N=this.byteLength(),x=g||Math.max(1,N);G(N<=x,"byte array longer than desired length"),G(x>0,"Requested array length <= 0"),this.strip();var _=k==="le",B=new j(x),y,w,f=this.clone();if(_){for(w=0;!f.isZero();w++)y=f.andln(255),f.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 W(j){for(var k=new Array(j.bitLength()),g=0;g>>x}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 N=0;Nj.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 N=0;N0&&(this.words[N]=~this.words[N]&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,N=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<j.length?(g=this,N=j):(g=j,N=this);for(var x=0,_=0;_>>26;for(;x!==0&&_>>26;if(this.length=g.length,x!==0)this.words[this.length]=x,this.length++;else if(g!==this)for(;_j.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,x;g>0?(N=this,x=j):(N=j,x=this);for(var _=0,B=0;B>26,this.words[B]=k&67108863;for(;_!==0&&B>26,this.words[B]=k&67108863;if(_===0&&B>>26,c=w&67108863,h=Math.min(f,k.length-1),d=Math.max(0,f-j.length+1);d<=h;d++){var b=f-d|0;x=j.words[b]|0,_=k.words[d]|0,B=x*_+c,p+=B/67108864|0,c=B&67108863}g.words[f]=c|0,w=p|0}return w!==0?g.words[f]=w|0:g.length--,g.strip()}var E=function(j,k,g){var N=j.words,x=k.words,_=g.words,B=0,y,w,f,p=N[0]|0,c=p&8191,h=p>>>13,d=N[1]|0,b=d&8191,l=d>>>13,o=N[2]|0,u=o&8191,n=o>>>13,s=N[3]|0,t=s&8191,m=s>>>13,a=N[4]|0,r=a&8191,e=a>>>13,i=N[5]|0,$0=i&8191,Q0=i>>>13,Y0=N[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=N[7]|0,U0=V0&8191,X0=V0>>>13,K0=N[8]|0,I0=K0&8191,J0=K0>>>13,O0=N[9]|0,F0=O0&8191,A0=O0>>>13,W0=x[0]|0,H0=W0&8191,E0=W0>>>13,T0=x[1]|0,D0=T0&8191,C0=T0>>>13,L0=x[2]|0,R0=L0&8191,P0=L0>>>13,z0=x[3]|0,M0=z0&8191,S0=z0>>>13,v0=x[4]|0,q0=v0&8191,j0=v0>>>13,k0=x[5]|0,g0=k0&8191,N0=k0>>>13,x0=x[6]|0,_0=x0&8191,B0=x0>>>13,y0=x[7]|0,w0=y0&8191,f0=y0>>>13,p0=x[8]|0,c0=p0&8191,h0=p0>>>13,d0=x[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,H0),w=Math.imul(c,E0),w=w+Math.imul(h,H0)|0,f=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,H0),w=Math.imul(b,E0),w=w+Math.imul(l,H0)|0,f=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,f=f+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,H0),w=Math.imul(u,E0),w=w+Math.imul(n,H0)|0,f=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,f=f+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,f=f+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,H0),w=Math.imul(t,E0),w=w+Math.imul(m,H0)|0,f=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,f=f+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,f=f+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,f=f+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(r,H0),w=Math.imul(r,E0),w=w+Math.imul(e,H0)|0,f=Math.imul(e,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,f=f+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,f=f+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,f=f+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,f=f+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,H0),w=Math.imul($0,E0),w=w+Math.imul(Q0,H0)|0,f=Math.imul(Q0,E0),y=y+Math.imul(r,D0)|0,w=w+Math.imul(r,C0)|0,w=w+Math.imul(e,D0)|0,f=f+Math.imul(e,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,f=f+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,f=f+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,f=f+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,N0)|0,w=w+Math.imul(h,g0)|0,f=f+Math.imul(h,N0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,H0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,H0)|0,f=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,f=f+Math.imul(Q0,C0)|0,y=y+Math.imul(r,R0)|0,w=w+Math.imul(r,P0)|0,w=w+Math.imul(e,R0)|0,f=f+Math.imul(e,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,f=f+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,f=f+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,N0)|0,w=w+Math.imul(l,g0)|0,f=f+Math.imul(l,N0)|0,y=y+Math.imul(c,_0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,_0)|0,f=f+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,H0),w=Math.imul(U0,E0),w=w+Math.imul(X0,H0)|0,f=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,f=f+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,f=f+Math.imul(Q0,P0)|0,y=y+Math.imul(r,M0)|0,w=w+Math.imul(r,S0)|0,w=w+Math.imul(e,M0)|0,f=f+Math.imul(e,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,f=f+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,N0)|0,w=w+Math.imul(n,g0)|0,f=f+Math.imul(n,N0)|0,y=y+Math.imul(b,_0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,_0)|0,f=f+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,f0)|0,w=w+Math.imul(h,w0)|0,f=f+Math.imul(h,f0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(I0,H0),w=Math.imul(I0,E0),w=w+Math.imul(J0,H0)|0,f=Math.imul(J0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,S0)|0,y=y+Math.imul(r,q0)|0,w=w+Math.imul(r,j0)|0,w=w+Math.imul(e,q0)|0,f=f+Math.imul(e,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,N0)|0,w=w+Math.imul(m,g0)|0,f=f+Math.imul(m,N0)|0,y=y+Math.imul(u,_0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,_0)|0,f=f+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,f0)|0,w=w+Math.imul(l,w0)|0,f=f+Math.imul(l,f0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,f=f+Math.imul(h,h0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(F0,H0),w=Math.imul(F0,E0),w=w+Math.imul(A0,H0)|0,f=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(J0,D0)|0,f=f+Math.imul(J0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,j0)|0,y=y+Math.imul(r,g0)|0,w=w+Math.imul(r,N0)|0,w=w+Math.imul(e,g0)|0,f=f+Math.imul(e,N0)|0,y=y+Math.imul(t,_0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,_0)|0,f=f+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,f0)|0,w=w+Math.imul(n,w0)|0,f=f+Math.imul(n,f0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,f=f+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,f=f+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(J0,R0)|0,f=f+Math.imul(J0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,f=f+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,f=f+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,N0)|0,w=w+Math.imul(Q0,g0)|0,f=f+Math.imul(Q0,N0)|0,y=y+Math.imul(r,_0)|0,w=w+Math.imul(r,B0)|0,w=w+Math.imul(e,_0)|0,f=f+Math.imul(e,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,f0)|0,w=w+Math.imul(m,w0)|0,f=f+Math.imul(m,f0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,f=f+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,f=f+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,f=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(J0,M0)|0,f=f+Math.imul(J0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,f=f+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,N0)|0,w=w+Math.imul(G0,g0)|0,f=f+Math.imul(G0,N0)|0,y=y+Math.imul($0,_0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,_0)|0,f=f+Math.imul(Q0,B0)|0,y=y+Math.imul(r,w0)|0,w=w+Math.imul(r,f0)|0,w=w+Math.imul(e,w0)|0,f=f+Math.imul(e,f0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,f=f+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,f=f+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(J0,q0)|0,f=f+Math.imul(J0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,N0)|0,w=w+Math.imul(X0,g0)|0,f=f+Math.imul(X0,N0)|0,y=y+Math.imul(Z0,_0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,_0)|0,f=f+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,f0)|0,w=w+Math.imul(Q0,w0)|0,f=f+Math.imul(Q0,f0)|0,y=y+Math.imul(r,c0)|0,w=w+Math.imul(r,h0)|0,w=w+Math.imul(e,c0)|0,f=f+Math.imul(e,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,f=f+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,N0)|0,w=w+Math.imul(J0,g0)|0,f=f+Math.imul(J0,N0)|0,y=y+Math.imul(U0,_0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,_0)|0,f=f+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,f0)|0,w=w+Math.imul(G0,w0)|0,f=f+Math.imul(G0,f0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,f=f+Math.imul(Q0,h0)|0,y=y+Math.imul(r,b0)|0,w=w+Math.imul(r,l0)|0,w=w+Math.imul(e,b0)|0,f=f+Math.imul(e,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,N0),w=w+Math.imul(A0,g0)|0,f=Math.imul(A0,N0),y=y+Math.imul(I0,_0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(J0,_0)|0,f=f+Math.imul(J0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,f0)|0,w=w+Math.imul(X0,w0)|0,f=f+Math.imul(X0,f0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,f=f+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,f=f+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,_0),w=Math.imul(F0,B0),w=w+Math.imul(A0,_0)|0,f=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,f0)|0,w=w+Math.imul(J0,w0)|0,f=f+Math.imul(J0,f0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,f=f+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,f=f+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,f0),w=w+Math.imul(A0,w0)|0,f=Math.imul(A0,f0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(J0,c0)|0,f=f+Math.imul(J0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,f=f+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(J0,b0)|0,f=f+Math.imul(J0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(f+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,_[0]=o0,_[1]=u0,_[2]=n0,_[3]=s0,_[4]=t0,_[5]=m0,_[6]=a0,_[7]=r0,_[8]=e0,_[9]=i0,_[10]=$$,_[11]=Q$,_[12]=Y$,_[13]=Z$,_[14]=G$,_[15]=V$,_[16]=U$,_[17]=X$,_[18]=K$,B!==0&&(_[19]=B,g.length++),g};Math.imul||(E=H);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var N=0,x=0,_=0;_>>26)|0,x+=B>>>26,B&=67108863}g.words[_]=y,N=B,B=x}return N!==0?g.words[_]=N:g.length--,g.strip()}function D(j,k,g){var N=new C;return N.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,N=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):N<63?g=H(this,j,k):N<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,N=0;N>=1;return N},C.prototype.permute=function(j,k,g,N,x,_){for(var B=0;B<_;B++)N[B]=k[j[B]],x[B]=g[j[B]]},C.prototype.transform=function(j,k,g,N,x,_){this.permute(_,j,k,g,N,x);for(var B=1;B>>1)x++;return 1<>>13,g[2*_+1]=x&8191,x=x>>>13;for(_=2*k;_>=26,k+=N/67108864|0,k+=x>>>26,this.words[g]=x&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=W(j);if(k.length===0)return new U(1);for(var g=this,N=0;N=0);var k=j%26,g=(j-k)/26,N=67108863>>>26-k<<26-k,x;if(k!==0){var _=0;for(x=0;x>>26-k}_&&(this.words[x]=_,this.length++)}if(g!==0){for(x=this.length-1;x>=0;x--)this.words[x+g]=this.words[x];for(x=0;x=0);var N;k?N=(k-k%26)/26:N=0;var x=j%26,_=Math.min((j-x)/26,this.length),B=67108863^67108863>>>x<_)for(this.length-=_,w=0;w=0&&(f!==0||w>=N);w--){var p=this.words[w]|0;this.words[w]=f<<26-x|p>>>x,f=p&B}return y&&f!==0&&(y.words[y.length++]=f),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,N=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 N=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[x+g]=_&67108863}for(;x>26,this.words[x+g]=_&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,x=0;x>26,this.words[x]=_&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,N=this.clone(),x=j,_=x.words[x.length-1]|0,B=this._countBits(_);g=26-B,g!==0&&(x=x.ushln(g),N.iushln(g),_=x.words[x.length-1]|0);var y=N.length-x.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var f=0;f=0;c--){var h=(N.words[x.length+c]|0)*67108864+(N.words[x.length+c-1]|0);for(h=Math.min(h/_|0,67108863),N._ishlnsubmul(x,h,c);N.negative!==0;)h--,N.negative=0,N._ishlnsubmul(x,1,c),N.isZero()||(N.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),N.strip(),k!=="div"&&g!==0&&N.iushrn(g),{div:w||null,mod:N}},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?(_=this.neg().divmod(j,k),k!=="mod"&&(N=_.div.neg()),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.iadd(j)),{div:N,mod:x}):this.negative===0&&j.negative!==0?(_=this.divmod(j.neg(),k),k!=="mod"&&(N=_.div.neg()),{div:N,mod:_.mod}):(this.negative&j.negative)!==0?(_=this.neg().divmod(j.neg(),k),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.isub(j)),{div:_.div,mod:x}):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,N=j.ushrn(1),x=j.andln(1),_=g.cmp(N);return _<0||x===1&&_===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,N=this.length-1;N>=0;N--)g=(k*g+(this.words[N]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var N=(this.words[g]|0)+k*67108864;this.words[g]=N/j|0,k=N%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 N=new U(1),x=new U(0),_=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(),f=k.clone();!k.isZero();){for(var p=0,c=1;(k.words[0]&c)===0&&p<26;++p,c<<=1);if(p>0)for(k.iushrn(p);p-- >0;)(N.isOdd()||x.isOdd())&&(N.iadd(w),x.isub(f)),N.iushrn(1),x.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;)(_.isOdd()||B.isOdd())&&(_.iadd(w),B.isub(f)),_.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(_),x.isub(B)):(g.isub(k),_.isub(N),B.isub(x))}return{a:_,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 N=new U(1),x=new U(0),_=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;)N.isOdd()&&N.iadd(_),N.iushrn(1);for(var w=0,f=1;(g.words[0]&f)===0&&w<26;++w,f<<=1);if(w>0)for(g.iushrn(w);w-- >0;)x.isOdd()&&x.iadd(_),x.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(x)):(g.isub(k),x.isub(N))}var p;return k.cmpn(1)===0?p=N:p=x,p.cmpn(0)<0&&p.iadd(j),p},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 N=0;k.isEven()&&g.isEven();N++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var x=k.cmp(g);if(x<0){var _=k;k=g,g=_}else if(x===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(N)},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,N=1<>>26,B&=67108863,this.words[_]=B}return x!==0&&(this.words[_]=x,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 N=this.words[0]|0;g=N===j?0:Nj.length)return 1;if(this.length=0;g--){var N=this.words[g]|0,x=j.words[g]|0;if(N!==x){Nx&&(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 N=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,N=Math.min(j.length,9),x=0;x>>22,_=B}_>>>=22,j.words[x-10]=_,_===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]=x,k=N}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 N=this.m.subn(1),x=0;!N.isZero()&&N.andln(1)===0;)x++,N.iushrn(1);G(!N.isZero());var _=new U(1).toRed(this),B=_.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 f=this.pow(w,N),p=this.pow(j,N.addn(1).iushrn(1)),c=this.pow(j,N),h=x;c.cmp(_)!==0;){for(var d=c,b=0;d.cmp(_)!==0;b++)d=d.redSqr();G(b=0;x--){for(var f=k.words[x],p=w-1;p>=0;p--){var c=f>>p&1;if(_!==N[0]&&(_=this.sqr(_)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(x!==0||p!==0))&&(_=this.mul(_,N[B]),y=0,B=0)}w=26}return _},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),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._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,$)}}),hY=z$({"node_modules/create-ecdh/browser.js"($,Q){var Y=WY(),Z=cY();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",Buffer.isBuffer(X)||(X=new Buffer(X,K));var J=this.curve.keyFromPublic(X).getPublic(),O=J.mul(this.keys.getPrivate()).getX();return U(O,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",Buffer.isBuffer(X)||(X=new Buffer(X,K)),this.keys._importPublic(X),this},V.prototype.setPrivateKey=function(X,K){K=K||"utf8",Buffer.isBuffer(X)||(X=new Buffer(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 J=new Buffer(X);if(I&&J.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 N=0;j[0]==="-"&&(N++,this.negative=1),N=0;N-=3)_=j[N]|j[N-1]<<8|j[N-2]<<16,this.words[x]|=_<>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);else if(g==="le")for(N=0,x=0;N>>26-B&67108863,B+=24,B>=26&&(B-=26,x++);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 N=K(j,g);return g-1>=k&&(N|=K(j,g-1)<<4),N}U.prototype._parseHex=function(j,k,g){this.length=Math.ceil((j.length-k)/6),this.words=new Array(this.length);for(var N=0;N=k;N-=2)B=I(j,k,N)<=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8;else{var y=j.length-k;for(N=y%2===0?k+1:k;N=18?(x-=18,_+=1,this.words[_]|=B>>>26):x+=8}this.strip()};function J(j,k,g,N){for(var x=0,_=Math.min(j.length,g),B=k;B<_;B++){var y=j.charCodeAt(B)-48;x*=N,y>=49?x+=y-49+10:y>=17?x+=y-17+10:x+=y}return x}U.prototype._parseBase=function(j,k,g){this.words=[0],this.length=1;for(var N=0,x=1;x<=67108863;x*=k)N++;N--,x=x/k|0;for(var _=j.length-g,B=_%N,y=Math.min(_,_-B)+g,w=0,f=g;f1&&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 O=["","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 N=0,x=0,_=0;_>>24-N&16777215,x!==0||_!==this.length-1?g=O[6-y.length]+y+g:g=y+g,N+=2,N>=26&&(N-=26,_--)}for(x!==0&&(g=x.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],f=A[j];g="";var p=this.clone();for(p.negative=0;!p.isZero();){var c=p.modn(f).toString(j);p=p.idivn(f),p.isZero()?g=c+g:g=O[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 N=this.byteLength(),x=g||Math.max(1,N);G(N<=x,"byte array longer than desired length"),G(x>0,"Requested array length <= 0"),this.strip();var _=k==="le",B=new j(x),y,w,f=this.clone();if(_){for(w=0;!f.isZero();w++)y=f.andln(255),f.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 W(j){for(var k=new Array(j.bitLength()),g=0;g>>x}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 N=0;Nj.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 N=0;N0&&(this.words[N]=~this.words[N]&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,N=j%26;return this._expand(g+1),k?this.words[g]=this.words[g]|1<j.length?(g=this,N=j):(g=j,N=this);for(var x=0,_=0;_>>26;for(;x!==0&&_>>26;if(this.length=g.length,x!==0)this.words[this.length]=x,this.length++;else if(g!==this)for(;_j.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,x;g>0?(N=this,x=j):(N=j,x=this);for(var _=0,B=0;B>26,this.words[B]=k&67108863;for(;_!==0&&B>26,this.words[B]=k&67108863;if(_===0&&B>>26,c=w&67108863,h=Math.min(f,k.length-1),d=Math.max(0,f-j.length+1);d<=h;d++){var b=f-d|0;x=j.words[b]|0,_=k.words[d]|0,B=x*_+c,p+=B/67108864|0,c=B&67108863}g.words[f]=c|0,w=p|0}return w!==0?g.words[f]=w|0:g.length--,g.strip()}var E=function(j,k,g){var N=j.words,x=k.words,_=g.words,B=0,y,w,f,p=N[0]|0,c=p&8191,h=p>>>13,d=N[1]|0,b=d&8191,l=d>>>13,o=N[2]|0,u=o&8191,n=o>>>13,s=N[3]|0,t=s&8191,m=s>>>13,a=N[4]|0,r=a&8191,e=a>>>13,i=N[5]|0,$0=i&8191,Q0=i>>>13,Y0=N[6]|0,Z0=Y0&8191,G0=Y0>>>13,V0=N[7]|0,U0=V0&8191,X0=V0>>>13,K0=N[8]|0,I0=K0&8191,J0=K0>>>13,O0=N[9]|0,F0=O0&8191,A0=O0>>>13,W0=x[0]|0,H0=W0&8191,E0=W0>>>13,T0=x[1]|0,D0=T0&8191,C0=T0>>>13,L0=x[2]|0,R0=L0&8191,P0=L0>>>13,z0=x[3]|0,M0=z0&8191,S0=z0>>>13,v0=x[4]|0,q0=v0&8191,j0=v0>>>13,k0=x[5]|0,g0=k0&8191,N0=k0>>>13,x0=x[6]|0,_0=x0&8191,B0=x0>>>13,y0=x[7]|0,w0=y0&8191,f0=y0>>>13,p0=x[8]|0,c0=p0&8191,h0=p0>>>13,d0=x[9]|0,b0=d0&8191,l0=d0>>>13;g.negative=j.negative^k.negative,g.length=19,y=Math.imul(c,H0),w=Math.imul(c,E0),w=w+Math.imul(h,H0)|0,f=Math.imul(h,E0);var o0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(o0>>>26)|0,o0&=67108863,y=Math.imul(b,H0),w=Math.imul(b,E0),w=w+Math.imul(l,H0)|0,f=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,f=f+Math.imul(h,C0)|0;var u0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(u0>>>26)|0,u0&=67108863,y=Math.imul(u,H0),w=Math.imul(u,E0),w=w+Math.imul(n,H0)|0,f=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,f=f+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,f=f+Math.imul(h,P0)|0;var n0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(n0>>>26)|0,n0&=67108863,y=Math.imul(t,H0),w=Math.imul(t,E0),w=w+Math.imul(m,H0)|0,f=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,f=f+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,f=f+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,f=f+Math.imul(h,S0)|0;var s0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(s0>>>26)|0,s0&=67108863,y=Math.imul(r,H0),w=Math.imul(r,E0),w=w+Math.imul(e,H0)|0,f=Math.imul(e,E0),y=y+Math.imul(t,D0)|0,w=w+Math.imul(t,C0)|0,w=w+Math.imul(m,D0)|0,f=f+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,f=f+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,f=f+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,f=f+Math.imul(h,j0)|0;var t0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(t0>>>26)|0,t0&=67108863,y=Math.imul($0,H0),w=Math.imul($0,E0),w=w+Math.imul(Q0,H0)|0,f=Math.imul(Q0,E0),y=y+Math.imul(r,D0)|0,w=w+Math.imul(r,C0)|0,w=w+Math.imul(e,D0)|0,f=f+Math.imul(e,C0)|0,y=y+Math.imul(t,R0)|0,w=w+Math.imul(t,P0)|0,w=w+Math.imul(m,R0)|0,f=f+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,f=f+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,f=f+Math.imul(l,j0)|0,y=y+Math.imul(c,g0)|0,w=w+Math.imul(c,N0)|0,w=w+Math.imul(h,g0)|0,f=f+Math.imul(h,N0)|0;var m0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(m0>>>26)|0,m0&=67108863,y=Math.imul(Z0,H0),w=Math.imul(Z0,E0),w=w+Math.imul(G0,H0)|0,f=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,f=f+Math.imul(Q0,C0)|0,y=y+Math.imul(r,R0)|0,w=w+Math.imul(r,P0)|0,w=w+Math.imul(e,R0)|0,f=f+Math.imul(e,P0)|0,y=y+Math.imul(t,M0)|0,w=w+Math.imul(t,S0)|0,w=w+Math.imul(m,M0)|0,f=f+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,f=f+Math.imul(n,j0)|0,y=y+Math.imul(b,g0)|0,w=w+Math.imul(b,N0)|0,w=w+Math.imul(l,g0)|0,f=f+Math.imul(l,N0)|0,y=y+Math.imul(c,_0)|0,w=w+Math.imul(c,B0)|0,w=w+Math.imul(h,_0)|0,f=f+Math.imul(h,B0)|0;var a0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(a0>>>26)|0,a0&=67108863,y=Math.imul(U0,H0),w=Math.imul(U0,E0),w=w+Math.imul(X0,H0)|0,f=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,f=f+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,f=f+Math.imul(Q0,P0)|0,y=y+Math.imul(r,M0)|0,w=w+Math.imul(r,S0)|0,w=w+Math.imul(e,M0)|0,f=f+Math.imul(e,S0)|0,y=y+Math.imul(t,q0)|0,w=w+Math.imul(t,j0)|0,w=w+Math.imul(m,q0)|0,f=f+Math.imul(m,j0)|0,y=y+Math.imul(u,g0)|0,w=w+Math.imul(u,N0)|0,w=w+Math.imul(n,g0)|0,f=f+Math.imul(n,N0)|0,y=y+Math.imul(b,_0)|0,w=w+Math.imul(b,B0)|0,w=w+Math.imul(l,_0)|0,f=f+Math.imul(l,B0)|0,y=y+Math.imul(c,w0)|0,w=w+Math.imul(c,f0)|0,w=w+Math.imul(h,w0)|0,f=f+Math.imul(h,f0)|0;var r0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(r0>>>26)|0,r0&=67108863,y=Math.imul(I0,H0),w=Math.imul(I0,E0),w=w+Math.imul(J0,H0)|0,f=Math.imul(J0,E0),y=y+Math.imul(U0,D0)|0,w=w+Math.imul(U0,C0)|0,w=w+Math.imul(X0,D0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,S0)|0,y=y+Math.imul(r,q0)|0,w=w+Math.imul(r,j0)|0,w=w+Math.imul(e,q0)|0,f=f+Math.imul(e,j0)|0,y=y+Math.imul(t,g0)|0,w=w+Math.imul(t,N0)|0,w=w+Math.imul(m,g0)|0,f=f+Math.imul(m,N0)|0,y=y+Math.imul(u,_0)|0,w=w+Math.imul(u,B0)|0,w=w+Math.imul(n,_0)|0,f=f+Math.imul(n,B0)|0,y=y+Math.imul(b,w0)|0,w=w+Math.imul(b,f0)|0,w=w+Math.imul(l,w0)|0,f=f+Math.imul(l,f0)|0,y=y+Math.imul(c,c0)|0,w=w+Math.imul(c,h0)|0,w=w+Math.imul(h,c0)|0,f=f+Math.imul(h,h0)|0;var e0=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(e0>>>26)|0,e0&=67108863,y=Math.imul(F0,H0),w=Math.imul(F0,E0),w=w+Math.imul(A0,H0)|0,f=Math.imul(A0,E0),y=y+Math.imul(I0,D0)|0,w=w+Math.imul(I0,C0)|0,w=w+Math.imul(J0,D0)|0,f=f+Math.imul(J0,C0)|0,y=y+Math.imul(U0,R0)|0,w=w+Math.imul(U0,P0)|0,w=w+Math.imul(X0,R0)|0,f=f+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,f=f+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,f=f+Math.imul(Q0,j0)|0,y=y+Math.imul(r,g0)|0,w=w+Math.imul(r,N0)|0,w=w+Math.imul(e,g0)|0,f=f+Math.imul(e,N0)|0,y=y+Math.imul(t,_0)|0,w=w+Math.imul(t,B0)|0,w=w+Math.imul(m,_0)|0,f=f+Math.imul(m,B0)|0,y=y+Math.imul(u,w0)|0,w=w+Math.imul(u,f0)|0,w=w+Math.imul(n,w0)|0,f=f+Math.imul(n,f0)|0,y=y+Math.imul(b,c0)|0,w=w+Math.imul(b,h0)|0,w=w+Math.imul(l,c0)|0,f=f+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,f=f+Math.imul(h,l0)|0;var i0=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,C0),y=y+Math.imul(I0,R0)|0,w=w+Math.imul(I0,P0)|0,w=w+Math.imul(J0,R0)|0,f=f+Math.imul(J0,P0)|0,y=y+Math.imul(U0,M0)|0,w=w+Math.imul(U0,S0)|0,w=w+Math.imul(X0,M0)|0,f=f+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,f=f+Math.imul(G0,j0)|0,y=y+Math.imul($0,g0)|0,w=w+Math.imul($0,N0)|0,w=w+Math.imul(Q0,g0)|0,f=f+Math.imul(Q0,N0)|0,y=y+Math.imul(r,_0)|0,w=w+Math.imul(r,B0)|0,w=w+Math.imul(e,_0)|0,f=f+Math.imul(e,B0)|0,y=y+Math.imul(t,w0)|0,w=w+Math.imul(t,f0)|0,w=w+Math.imul(m,w0)|0,f=f+Math.imul(m,f0)|0,y=y+Math.imul(u,c0)|0,w=w+Math.imul(u,h0)|0,w=w+Math.imul(n,c0)|0,f=f+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,f=f+Math.imul(l,l0)|0;var $$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+($$>>>26)|0,$$&=67108863,y=Math.imul(F0,R0),w=Math.imul(F0,P0),w=w+Math.imul(A0,R0)|0,f=Math.imul(A0,P0),y=y+Math.imul(I0,M0)|0,w=w+Math.imul(I0,S0)|0,w=w+Math.imul(J0,M0)|0,f=f+Math.imul(J0,S0)|0,y=y+Math.imul(U0,q0)|0,w=w+Math.imul(U0,j0)|0,w=w+Math.imul(X0,q0)|0,f=f+Math.imul(X0,j0)|0,y=y+Math.imul(Z0,g0)|0,w=w+Math.imul(Z0,N0)|0,w=w+Math.imul(G0,g0)|0,f=f+Math.imul(G0,N0)|0,y=y+Math.imul($0,_0)|0,w=w+Math.imul($0,B0)|0,w=w+Math.imul(Q0,_0)|0,f=f+Math.imul(Q0,B0)|0,y=y+Math.imul(r,w0)|0,w=w+Math.imul(r,f0)|0,w=w+Math.imul(e,w0)|0,f=f+Math.imul(e,f0)|0,y=y+Math.imul(t,c0)|0,w=w+Math.imul(t,h0)|0,w=w+Math.imul(m,c0)|0,f=f+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,f=f+Math.imul(n,l0)|0;var Q$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,S0),y=y+Math.imul(I0,q0)|0,w=w+Math.imul(I0,j0)|0,w=w+Math.imul(J0,q0)|0,f=f+Math.imul(J0,j0)|0,y=y+Math.imul(U0,g0)|0,w=w+Math.imul(U0,N0)|0,w=w+Math.imul(X0,g0)|0,f=f+Math.imul(X0,N0)|0,y=y+Math.imul(Z0,_0)|0,w=w+Math.imul(Z0,B0)|0,w=w+Math.imul(G0,_0)|0,f=f+Math.imul(G0,B0)|0,y=y+Math.imul($0,w0)|0,w=w+Math.imul($0,f0)|0,w=w+Math.imul(Q0,w0)|0,f=f+Math.imul(Q0,f0)|0,y=y+Math.imul(r,c0)|0,w=w+Math.imul(r,h0)|0,w=w+Math.imul(e,c0)|0,f=f+Math.imul(e,h0)|0,y=y+Math.imul(t,b0)|0,w=w+Math.imul(t,l0)|0,w=w+Math.imul(m,b0)|0,f=f+Math.imul(m,l0)|0;var Y$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,j0),y=y+Math.imul(I0,g0)|0,w=w+Math.imul(I0,N0)|0,w=w+Math.imul(J0,g0)|0,f=f+Math.imul(J0,N0)|0,y=y+Math.imul(U0,_0)|0,w=w+Math.imul(U0,B0)|0,w=w+Math.imul(X0,_0)|0,f=f+Math.imul(X0,B0)|0,y=y+Math.imul(Z0,w0)|0,w=w+Math.imul(Z0,f0)|0,w=w+Math.imul(G0,w0)|0,f=f+Math.imul(G0,f0)|0,y=y+Math.imul($0,c0)|0,w=w+Math.imul($0,h0)|0,w=w+Math.imul(Q0,c0)|0,f=f+Math.imul(Q0,h0)|0,y=y+Math.imul(r,b0)|0,w=w+Math.imul(r,l0)|0,w=w+Math.imul(e,b0)|0,f=f+Math.imul(e,l0)|0;var Z$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(Z$>>>26)|0,Z$&=67108863,y=Math.imul(F0,g0),w=Math.imul(F0,N0),w=w+Math.imul(A0,g0)|0,f=Math.imul(A0,N0),y=y+Math.imul(I0,_0)|0,w=w+Math.imul(I0,B0)|0,w=w+Math.imul(J0,_0)|0,f=f+Math.imul(J0,B0)|0,y=y+Math.imul(U0,w0)|0,w=w+Math.imul(U0,f0)|0,w=w+Math.imul(X0,w0)|0,f=f+Math.imul(X0,f0)|0,y=y+Math.imul(Z0,c0)|0,w=w+Math.imul(Z0,h0)|0,w=w+Math.imul(G0,c0)|0,f=f+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,f=f+Math.imul(Q0,l0)|0;var G$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(G$>>>26)|0,G$&=67108863,y=Math.imul(F0,_0),w=Math.imul(F0,B0),w=w+Math.imul(A0,_0)|0,f=Math.imul(A0,B0),y=y+Math.imul(I0,w0)|0,w=w+Math.imul(I0,f0)|0,w=w+Math.imul(J0,w0)|0,f=f+Math.imul(J0,f0)|0,y=y+Math.imul(U0,c0)|0,w=w+Math.imul(U0,h0)|0,w=w+Math.imul(X0,c0)|0,f=f+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,f=f+Math.imul(G0,l0)|0;var V$=(B+y|0)+((w&8191)<<13)|0;B=(f+(w>>>13)|0)+(V$>>>26)|0,V$&=67108863,y=Math.imul(F0,w0),w=Math.imul(F0,f0),w=w+Math.imul(A0,w0)|0,f=Math.imul(A0,f0),y=y+Math.imul(I0,c0)|0,w=w+Math.imul(I0,h0)|0,w=w+Math.imul(J0,c0)|0,f=f+Math.imul(J0,h0)|0,y=y+Math.imul(U0,b0)|0,w=w+Math.imul(U0,l0)|0,w=w+Math.imul(X0,b0)|0,f=f+Math.imul(X0,l0)|0;var U$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,h0),y=y+Math.imul(I0,b0)|0,w=w+Math.imul(I0,l0)|0,w=w+Math.imul(J0,b0)|0,f=f+Math.imul(J0,l0)|0;var X$=(B+y|0)+((w&8191)<<13)|0;B=(f+(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,f=Math.imul(A0,l0);var K$=(B+y|0)+((w&8191)<<13)|0;return B=(f+(w>>>13)|0)+(K$>>>26)|0,K$&=67108863,_[0]=o0,_[1]=u0,_[2]=n0,_[3]=s0,_[4]=t0,_[5]=m0,_[6]=a0,_[7]=r0,_[8]=e0,_[9]=i0,_[10]=$$,_[11]=Q$,_[12]=Y$,_[13]=Z$,_[14]=G$,_[15]=V$,_[16]=U$,_[17]=X$,_[18]=K$,B!==0&&(_[19]=B,g.length++),g};Math.imul||(E=H);function T(j,k,g){g.negative=k.negative^j.negative,g.length=j.length+k.length;for(var N=0,x=0,_=0;_>>26)|0,x+=B>>>26,B&=67108863}g.words[_]=y,N=B,B=x}return N!==0?g.words[_]=N:g.length--,g.strip()}function D(j,k,g){var N=new C;return N.mulp(j,k,g)}U.prototype.mulTo=function(j,k){var g,N=this.length+j.length;return this.length===10&&j.length===10?g=E(this,j,k):N<63?g=H(this,j,k):N<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,N=0;N>=1;return N},C.prototype.permute=function(j,k,g,N,x,_){for(var B=0;B<_;B++)N[B]=k[j[B]],x[B]=g[j[B]]},C.prototype.transform=function(j,k,g,N,x,_){this.permute(_,j,k,g,N,x);for(var B=1;B>>1)x++;return 1<>>13,g[2*_+1]=x&8191,x=x>>>13;for(_=2*k;_>=26,k+=N/67108864|0,k+=x>>>26,this.words[g]=x&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=W(j);if(k.length===0)return new U(1);for(var g=this,N=0;N=0);var k=j%26,g=(j-k)/26,N=67108863>>>26-k<<26-k,x;if(k!==0){var _=0;for(x=0;x>>26-k}_&&(this.words[x]=_,this.length++)}if(g!==0){for(x=this.length-1;x>=0;x--)this.words[x+g]=this.words[x];for(x=0;x=0);var N;k?N=(k-k%26)/26:N=0;var x=j%26,_=Math.min((j-x)/26,this.length),B=67108863^67108863>>>x<_)for(this.length-=_,w=0;w=0&&(f!==0||w>=N);w--){var p=this.words[w]|0;this.words[w]=f<<26-x|p>>>x,f=p&B}return y&&f!==0&&(y.words[y.length++]=f),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,N=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 N=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[x+g]=_&67108863}for(;x>26,this.words[x+g]=_&67108863;if(B===0)return this.strip();for(G(B===-1),B=0,x=0;x>26,this.words[x]=_&67108863;return this.negative=1,this.strip()},U.prototype._wordDiv=function(j,k){var g=this.length-j.length,N=this.clone(),x=j,_=x.words[x.length-1]|0,B=this._countBits(_);g=26-B,g!==0&&(x=x.ushln(g),N.iushln(g),_=x.words[x.length-1]|0);var y=N.length-x.length,w;if(k!=="mod"){w=new U(null),w.length=y+1,w.words=new Array(w.length);for(var f=0;f=0;c--){var h=(N.words[x.length+c]|0)*67108864+(N.words[x.length+c-1]|0);for(h=Math.min(h/_|0,67108863),N._ishlnsubmul(x,h,c);N.negative!==0;)h--,N.negative=0,N._ishlnsubmul(x,1,c),N.isZero()||(N.negative^=1);w&&(w.words[c]=h)}return w&&w.strip(),N.strip(),k!=="div"&&g!==0&&N.iushrn(g),{div:w||null,mod:N}},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?(_=this.neg().divmod(j,k),k!=="mod"&&(N=_.div.neg()),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.iadd(j)),{div:N,mod:x}):this.negative===0&&j.negative!==0?(_=this.divmod(j.neg(),k),k!=="mod"&&(N=_.div.neg()),{div:N,mod:_.mod}):(this.negative&j.negative)!==0?(_=this.neg().divmod(j.neg(),k),k!=="div"&&(x=_.mod.neg(),g&&x.negative!==0&&x.isub(j)),{div:_.div,mod:x}):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,N=j.ushrn(1),x=j.andln(1),_=g.cmp(N);return _<0||x===1&&_===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,N=this.length-1;N>=0;N--)g=(k*g+(this.words[N]|0))%j;return g},U.prototype.idivn=function(j){G(j<=67108863);for(var k=0,g=this.length-1;g>=0;g--){var N=(this.words[g]|0)+k*67108864;this.words[g]=N/j|0,k=N%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 N=new U(1),x=new U(0),_=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(),f=k.clone();!k.isZero();){for(var p=0,c=1;(k.words[0]&c)===0&&p<26;++p,c<<=1);if(p>0)for(k.iushrn(p);p-- >0;)(N.isOdd()||x.isOdd())&&(N.iadd(w),x.isub(f)),N.iushrn(1),x.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;)(_.isOdd()||B.isOdd())&&(_.iadd(w),B.isub(f)),_.iushrn(1),B.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(_),x.isub(B)):(g.isub(k),_.isub(N),B.isub(x))}return{a:_,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 N=new U(1),x=new U(0),_=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;)N.isOdd()&&N.iadd(_),N.iushrn(1);for(var w=0,f=1;(g.words[0]&f)===0&&w<26;++w,f<<=1);if(w>0)for(g.iushrn(w);w-- >0;)x.isOdd()&&x.iadd(_),x.iushrn(1);k.cmp(g)>=0?(k.isub(g),N.isub(x)):(g.isub(k),x.isub(N))}var p;return k.cmpn(1)===0?p=N:p=x,p.cmpn(0)<0&&p.iadd(j),p},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 N=0;k.isEven()&&g.isEven();N++)k.iushrn(1),g.iushrn(1);do{for(;k.isEven();)k.iushrn(1);for(;g.isEven();)g.iushrn(1);var x=k.cmp(g);if(x<0){var _=k;k=g,g=_}else if(x===0||g.cmpn(1)===0)break;k.isub(g)}while(!0);return g.iushln(N)},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,N=1<>>26,B&=67108863,this.words[_]=B}return x!==0&&(this.words[_]=x,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 N=this.words[0]|0;g=N===j?0:Nj.length)return 1;if(this.length=0;g--){var N=this.words[g]|0,x=j.words[g]|0;if(N!==x){Nx&&(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 N=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,N=Math.min(j.length,9),x=0;x>>22,_=B}_>>>=22,j.words[x-10]=_,_===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]=x,k=N}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 N=this.m.subn(1),x=0;!N.isZero()&&N.andln(1)===0;)x++,N.iushrn(1);G(!N.isZero());var _=new U(1).toRed(this),B=_.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 f=this.pow(w,N),p=this.pow(j,N.addn(1).iushrn(1)),c=this.pow(j,N),h=x;c.cmp(_)!==0;){for(var d=c,b=0;d.cmp(_)!==0;b++)d=d.redSqr();G(b=0;x--){for(var f=k.words[x],p=w-1;p>=0;p--){var c=f>>p&1;if(_!==N[0]&&(_=this.sqr(_)),c===0&&B===0){y=0;continue}B<<=1,B|=c,y++,!(y!==g&&(x!==0||p!==0))&&(_=this.mul(_,N[B]),y=0,B=0)}w=26}return _},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),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._forceRed(this)},q.prototype.mul=function(j,k){if(j.isZero()||k.isZero())return new U(0)._forceRed(this);var g=j.mul(k),N=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=g.isub(N).iushrn(this.shift),_=x;return x.cmp(this.m)>=0?_=x.isub(this.m):x.cmpn(0)<0&&(_=x.iadd(this.m)),_._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:oY}=globalThis.Bun,uY=z$({"node_modules/public-encrypt/withPublic.js"($,Q){var Y=lY(),Z=S$().Buffer;function G(V,U){return Z.from(V.toRed(Y.mont(U.modulus)).redPow(new Y(U.publicExponent)).fromRed().toArray())}Q.exports=G}}),nY=z$({"node_modules/public-encrypt/publicEncrypt.js"($,Q){var Y=BY(),Z=v$(),G=d$(),V=dY(),U=bY(),X=lY(),K=uY(),I=fQ(),J=S$().Buffer;Q.exports=function(W,H,E){var T;W.padding?T=W.padding:E?T=1:T=4;var D=Y(W),C;if(T===4)C=O(D,H);else if(T===1)C=F(D,H,E);else if(T===3){if(C=new X(H),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 O(W,H){var E=W.modulus.byteLength(),T=H.length,D=G("sha1").update(J.alloc(0)).digest(),C=D.length,L=2*C;if(T>E-L-2)throw new Error("message too long");var R=J.alloc(E-T-L-2),P=E-C-1,z=Z(C),M=U(J.concat([D,R,J.alloc(1,1),H],P),V(z,P)),S=U(z,V(M,C));return new X(J.concat([J.alloc(1),S,M],E))}function F(W,H,E){var T=H.length,D=W.modulus.byteLength();if(T>D-11)throw new Error("message too long");var C;return E?C=J.alloc(D-T-3,255):C=A(D-T-3),new X(J.concat([J.from([0,E?1:2]),C,J.alloc(1),H],D))}function A(W){for(var H=J.allocUnsafe(W),E=0,T=Z(W*2),D=0,C;ED||new V(W).cmp(T.modulus)>=0)throw new Error("decryption error");var C;H?C=K(new V(W),T):C=U(W,T);var L=I.alloc(D-C.length);if(C=I.concat([L,C],D),E===4)return J(T,C);if(E===1)return O(T,C,H);if(E===3)return C;throw new Error("unknown padding")};function J(A,W){var H=A.modulus.byteLength(),E=X("sha1").update(I.alloc(0)).digest(),T=E.length;if(W[0]!==0)throw new Error("decryption error");var D=W.slice(1,T+1),C=W.slice(T+1),L=G(D,Z(C,T)),R=G(C,Z(L,H-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 O(A,W,H){for(var E=W.slice(0,2),T=2,D=0;W[T++]!==0;)if(T>=W.length){D++;break}var C=W.slice(2,T-1);if((E.toString("hex")!=="0002"&&!H||E.toString("hex")!=="0001"&&H)&&D++,C.length<8&&D++,D)throw new Error("decryption error");return W.slice(T)}function F(A,W){A=I.from(A),W=I.from(W);var H=0,E=A.length;A.length!==W.length&&(H++,E=Math.min(A.length,W.length));for(var T=-1;++TV||O<0)throw new TypeError("offset must be a uint32");if(O>G||O>F)throw new RangeError("offset out of range")}function X(O,F,A){if(typeof O!="number"||O!==O)throw new TypeError("size must be a number");if(O>V||O<0)throw new TypeError("size must be a uint32");if(O+F>A||O>G)throw new RangeError("buffer too small")}$.randomFill=K,$.randomFillSync=J;function K(O,F,A,W){if(!Z.isBuffer(O)&&!(O instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof F=="function")W=F,F=0,A=O.length;else if(typeof A=="function")W=A,A=O.length-F;else if(typeof W!="function")throw new TypeError('"cb" argument must be a function');return U(F,O.length),X(A,F,O.length),I(O,F,A,W)}function I(O,F,A,W){if(W){Y(A,function(E,T){if(E)return W(E);T.copy(O,F),W(null,O)});return}var H=Y(A);return H.copy(O,F),O}function J(O,F,A){if(typeof F>"u"&&(F=0),!Z.isBuffer(O)&&!(O instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return U(F,O.length),A===void 0&&(A=O.length-F),X(A,F,O.length),I(O,F,A)}}}),aY=z$({"node_modules/crypto-browserify/index.js"($){$.randomBytes=$.rng=$.pseudoRandomBytes=$.prng=v$(),$.createHash=d$(),$.Hash=$.createHash.Hash,$.createHmac=$.Hmac=o$();var Q=n$(),Y=Object.keys(Q),Z=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Y);$.getHashes=function(){return Z};var G=e$();$.pbkdf2=G.pbkdf2,$.pbkdf2Sync=G.pbkdf2Sync;var V=vQ();$.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=yQ();$.DiffieHellmanGroup=U.DiffieHellmanGroup,$.createDiffieHellmanGroup=U.createDiffieHellmanGroup,$.getDiffieHellman=U.getDiffieHellman,$.createDiffieHellman=U.createDiffieHellman,$.DiffieHellman=U.DiffieHellman;var X=pY();$.createSign=X.createSign,$.Sign=X.Sign,$.createVerify=X.createVerify,$.Verify=X.Verify,$.createECDH=hY();var K=tY();$.publicEncrypt=K.publicEncrypt,$.privateEncrypt=K.privateEncrypt,$.publicDecrypt=K.publicDecrypt,$.privateDecrypt=K.privateDecrypt,$.getRandomValues=(J)=>F$.getRandomValues(J);var I=mY();$.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}}}),rY={...aY(),[Symbol.for("CommonJS")]:0},H$="buffer",eY=($)=>F$.getRandomValues($),iY=()=>F$.randomUUID(),E$="timingSafeEqual"in F$?($,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 F$.timingSafeEqual($,Q)}:void 0,$Z="scryptSync"in F$?($,Q,Y,Z)=>{let G=F$.scryptSync($,Q,Y,Z);return H$!=="buffer"?new Buffer(G).toString(H$):new Buffer(G)}:void 0,QZ="scryptSync"in F$?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=F$.scryptSync($,Q,Y,Z);process.nextTick(G,null,H$!=="buffer"?new Buffer(U).toString(H$):new Buffer(U))}catch(U){throw U}}:void 0;E$&&(Object.defineProperty(E$,"name",{value:"::bunternal::"}),Object.defineProperty(QZ,"name",{value:"::bunternal::"}),Object.defineProperty($Z,"name",{value:"::bunternal::"}));var T$=F$;M$(rY,{DEFAULT_ENCODING:()=>H$,getRandomValues:()=>eY,randomUUID:()=>iY,scrypt:()=>QZ,scryptSync:()=>$Z,timingSafeEqual:()=>E$,webcrypto:()=>T$,subtle:()=>T$.subtle});var{randomBytes:YZ,rng:ZZ,pseudoRandomBytes:GZ,prng:VZ,Hash:UZ,createHash:XZ,createHmac:KZ,Hmac:IZ,getHashes:JZ,pbkdf2:OZ,pbkdf2Sync:FZ,Cipher:AZ,createCipher:WZ,Cipheriv:HZ,createCipheriv:EZ,Decipher:TZ,createDecipher:DZ,Decipheriv:CZ,createDecipheriv:LZ,getCiphers:RZ,listCiphers:PZ,DiffieHellmanGroup:zZ,createDiffieHellmanGroup:MZ,getDiffieHellman:SZ,createDiffieHellman:vZ,DiffieHellman:qZ,createSign:jZ,Sign:kZ,createVerify:gZ,Verify:NZ,createECDH:xZ,publicEncrypt:_Z,privateEncrypt:BZ,publicDecrypt:yZ,privateDecrypt:wZ,randomFill:fZ,randomFillSync:pZ,createCredentials:cZ,constants:hZ}=rY;var bZ=rY;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{T$ as webcrypto,E$ as timingSafeEqual,$Z as scryptSync,QZ as scrypt,ZZ as rng,iY as randomUUID,pZ as randomFillSync,fZ as randomFill,YZ as randomBytes,_Z as publicEncrypt,yZ as publicDecrypt,GZ as pseudoRandomBytes,VZ as prng,BZ as privateEncrypt,wZ as privateDecrypt,FZ as pbkdf2Sync,OZ as pbkdf2,PZ as listCiphers,eY as getRandomValues,JZ as getHashes,SZ as getDiffieHellman,RZ as getCiphers,bZ as default,gZ as createVerify,jZ as createSign,KZ as createHmac,XZ as createHash,xZ as createECDH,MZ as createDiffieHellmanGroup,vZ as createDiffieHellman,LZ as createDecipheriv,DZ as createDecipher,cZ as createCredentials,EZ as createCipheriv,WZ as createCipher,hZ as constants,NZ as Verify,kZ as Sign,IZ as Hmac,UZ as Hash,zZ as DiffieHellmanGroup,qZ as DiffieHellman,CZ as Decipheriv,TZ as Decipher,H$ as DEFAULT_ENCODING,HZ as Cipheriv,AZ as Cipher}; +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}; diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index dd007e740..02e000138 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -93,7 +93,8 @@ function get(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]/, 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 { +}, __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 { bytesRead = 0; bytesWritten = 0; connecting = !1; diff --git a/src/js/out/modules/node/net.js b/src/js/out/modules/node/net.js index ddd799cf2..162da7754 100644 --- a/src/js/out/modules/node/net.js +++ b/src/js/out/modules/node/net.js @@ -24,7 +24,9 @@ var isIPv4 = function(s) { self.emit("listening"); }, createServer = function(options, connectionListener) { return new Server(options, connectionListener); -}, v4Seg = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])", v4Str = "((?:[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])", 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])$"), v6Seg = "(?:[0-9a-fA-F]{1,4})", 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) { +}; +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) { 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 c089dd8d5..ad6a231a9 100644 --- a/src/js/out/modules/node/path.js +++ b/src/js/out/modules/node/path.js @@ -1 +1 @@ -var k=function(f){var m=g({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 m.default=m,m},g=(f)=>Object.assign(Object.create(null),f),q=k(Bun._Path()),v=k(Bun._Path(!1)),y=k(Bun._Path(!0));q.win32=y;q.posix=v;var{basename:z,dirname:A,extname:B,format:C,isAbsolute:D,join:E,normalize:F,parse:G,relative:H,resolve:I,toNamespacedPath:J,sep:K,delimiter:L,__esModule:N}=q;q[Symbol.for("CommonJS")]=0;q.__esModule=!0;var P=q;export{y as win32,J as toNamespacedPath,K as sep,I as resolve,H as relative,v as posix,G as parse,F as normalize,E as join,D as isAbsolute,C as format,B as extname,A as dirname,L as delimiter,P as default,g as createModule,z as basename,N as __esModule}; +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}; diff --git a/src/js/out/modules/node/path.posix.js b/src/js/out/modules/node/path.posix.js index 64e8a62f5..8071342a9 100644 --- a/src/js/out/modules/node/path.posix.js +++ b/src/js/out/modules/node/path.posix.js @@ -1 +1 @@ -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}; +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}; diff --git a/src/js/out/modules/node/stream.consumers.js b/src/js/out/modules/node/stream.consumers.js index 1c66aab55..e2cfb9cc1 100644 --- a/src/js/out/modules/node/stream.consumers.js +++ b/src/js/out/modules/node/stream.consumers.js @@ -1 +1 @@ -var{Bun:T}=import.meta.primordials,c=T.readableStreamToArrayBuffer,g=T.readableStreamToText,h=(o)=>T.readableStreamToText(o).then(JSON.parse),i=async(o)=>{return new Buffer(await c(o))},k=T.readableStreamToBlob,p={[Symbol.for("CommonJS")]:0,arrayBuffer:c,text:g,json:h,buffer:i,blob:k};export{g as text,h as json,p as default,i as buffer,k as blob,c as arrayBuffer}; +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}; diff --git a/src/js/out/modules/node/stream.js b/src/js/out/modules/node/stream.js index 533cf8a04..100ca09fa 100644 --- a/src/js/out/modules/node/stream.js +++ b/src/js/out/modules/node/stream.js @@ -1,2 +1,2 @@ -var wq=function(q){if(!(this instanceof wq))return new wq(q);bq.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}`)},jQ=function(q,Q){var[X,J,H,Z,K,B,Y]=globalThis[Symbol.for("Bun.lazy")](q),$=[!1],z=function(j,L,N,W){if(L>0){const P=N.subarray(0,L),I=N.subarray(L);if(P.byteLength>0)j.push(P);if(W)j.push(null);return I.byteLength>0?I:void 0}if(W)j.push(null);return N},V=function(j,L,N,W){if(L.byteLength>0)j.push(L);if(W)j.push(null);return N},G=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const U=new FinalizationRegistry((j)=>j&&K(j)),F=512;var M=class j extends Q{#q;#Q=1;#X=!1;#J=void 0;#H;#Z=!1;#K=!G;#B;constructor(L,N={}){super(N);if(typeof N.highWaterMark==="number")this.#H=N.highWaterMark;else this.#H=262144;this.#q=L,this.#X=!1,this.#J=void 0,this.#Z=!1,this.#B={},U.register(this,this.#q,this.#B)}_read(L){if(xq&&Iq("NativeReadable._read",this.__id),this.#Z){xq&&Iq("pendingRead is true",this.__id);return}var N=this.#q;if(xq&&Iq("ptr @ NativeReadable._read",N,this.__id),N===0){this.push(null);return}if(!this.#X)xq&&Iq("NativeReadable not constructed yet",this.__id),this.#Y(N);return this.#V(this.#$(L),N)}#Y(L){this.#X=!0;const N=J(L,this.#H);if(xq&&Iq("NativeReadable internal `start` result",N,this.__id),typeof N==="number"&&N>1)this.#K=!0,xq&&Iq("NativeReadable resized",this.__id),this.#H=Math.min(this.#H,N);if(Y){const W=Y(L);if(xq&&Iq("NativeReadable drain result",W,this.__id),(W?.byteLength??0)>0)this.push(W)}}#$(L=this.#H){var N=this.#J;if(xq&&Iq("chunk @ #getRemainingChunk",N,this.__id),N?.byteLength??0F?L:F;this.#J=N=new Buffer(W)}return N}push(L,N){return xq&&Iq("NativeReadable push -- result, encoding",L,N,this.__id),super.push(...arguments)}#z(L,N,W){if(xq&&Iq("result, isClosed @ #handleResult",L,W,this.__id),typeof L==="number"){if(L>=this.#H&&!this.#K&&!W)this.#H*=2,this.#K=!0;return z(this,L,N,W)}else if(typeof L==="boolean")return this.push(null),N?.byteLength??0>0?N:void 0;else if(ArrayBuffer.isView(L)){if(L.byteLength>=this.#H&&!this.#K&&!W)this.#H*=2,this.#K=!0,xq&&Iq("Resized",this.__id);return V(this,L,N,W)}else throw xq&&Iq("Unknown result type",L,this.__id),new Error("Invalid result from pull")}#V(L,N){xq&&Iq("#internalRead()",this.__id),$[0]=!1;var W=X(N,L,$);if(Cq(W))return this.#Z=!0,W.then((P)=>{this.#Z=!1,xq&&Iq("pending no longerrrrrrrr (result returned from pull)",this.__id),this.#J=this.#z(P,L,$[0])},(P)=>{xq&&Iq("error from pull",P,this.__id),errorOrDestroy(this,P)});else this.#J=this.#z(W,L,$[0])}_destroy(L,N){var W=this.#q;if(W===0){N(L);return}if(U.unregister(this.#B),this.#q=0,B)B(W,!1);xq&&Iq("NativeReadable destroyed",this.__id),H(W,L),N(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},NQ=function(q,Q){return LQ[q]||=jQ(q,Q)},WQ=function(q,Q,X){if(!(Q&&typeof Q==="object"&&Q instanceof ReadableStream))return;const J=gq(Q);if(!J){Iq("no native readable stream");return}const{stream:H,data:Z}=J;return new(NQ(Z,q))(H,X)},{isPromise:Cq,isCallable:Rq,direct:gq,Object:Oq}=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 Sq=!!process.env.DEBUG_TRACK_EE,xq=!!(process.env.DEBUG||process.env.DEBUG_STREAMS||Sq),Iq=xq?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=Oq.create,fq=Oq.defineProperty,yq=Oq.getOwnPropertyDescriptor,hq=Oq.getOwnPropertyNames,pq=Oq.getPrototypeOf,uq=Oq.prototype.hasOwnProperty,mq=Oq.setPrototypeOf,Eq=(q)=>import.meta.require(q),bq=Eq("bun:events_native");mq(wq.prototype,bq.prototype);mq(wq,bq);wq.prototype.emit=function(q,...Q){var X=this.__id;if(X)Iq("emit",q,...Q,X);else Iq("emit",q,...Q);return bq.prototype.emit.call(this,q,...Q)};wq.prototype.on=function(q,Q){var X=this.__id;if(X)Iq("on",q,"added",X);else Iq("on",q,"added");return bq.prototype.on.call(this,q,Q)};wq.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 Oq.defineProperties(X,J)},ObjectDefineProperty(X,J,H){return Oq.defineProperty(X,J,H)},ObjectGetOwnPropertyDescriptor(X,J){return Oq.getOwnPropertyDescriptor(X,J)},ObjectKeys(X){return Oq.keys(X)},ObjectSetPrototypeOf(X,J){return Oq.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=cq({"node_modules/readable-stream/lib/ours/util.js"(q,Q){var X=Eq("buffer"),J=Oq.getPrototypeOf(async function(){}).constructor,H=globalThis.Blob||X.Blob,Z=typeof H!=="undefined"?function B(Y){return Y instanceof H}:function B(Y){return!1},K=class extends Error{constructor(B){if(!Array.isArray(B))throw new TypeError(`Expected input to be an Array, got ${typeof B}`);let Y="";for(let $=0;${B=z,Y=V}),resolve:B,reject:Y}},promisify(B){return new Promise((Y,$)=>{B((z,...V)=>{if(z)return $(z);return Y(...V)})})},debuglog(){return function(){}},format(B,...Y){return B.replace(/%([sdifj])/g,function(...[$,z]){const V=Y.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!==Oq?V.constructor.name:""} {}`.trim();else return V.toString()})},inspect(B){switch(typeof B){case"string":if(B.includes("'")){if(!B.includes('"'))return`"${B}"`;else if(!B.includes("`")&&!B.includes("${"))return`\`${B}\``}return`'${B}'`;case"number":if(isNaN(B))return"NaN";else if(Oq.is(B,-0))return String(B);return B;case"bigint":return`${String(B)}n`;case"boolean":case"undefined":return String(B);case"object":return"{}"}},types:{isAsyncFunction(B){return B instanceof J},isArrayBufferView(B){return ArrayBuffer.isView(B)}},isBlob:Z},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}=_q(),Z=globalThis.AggregateError||H,K=Symbol("kIsNodeError"),B=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Y=/^([A-Z][a-z0-9]*)+$/,$="__node_internal_",z={};function V(N,W){if(!N)throw new z.ERR_INTERNAL_ASSERTION(W)}function G(N){let W="",P=N.length;const I=N[0]==="-"?1:0;for(;P>=I+4;P-=3)W=`_${N.slice(P-3,P)}${W}`;return`${N.slice(0,P)}${W}`}function U(N,W,P){if(typeof W==="function")return V(W.length<=P.length,`Code: ${N}; The provided arguments length (${P.length}) does not match the required ones (${W.length}).`),W(...P);const I=(W.match(/%[dfijoOs]/g)||[]).length;if(V(I===P.length,`Code: ${N}; The provided arguments length (${P.length}) does not match the required ones (${I}).`),P.length===0)return W;return X(W,...P)}function F(N,W,P){if(!P)P=Error;class I extends P{constructor(...x){super(U(N,W,x))}toString(){return`${this.name} [${N}]: ${this.message}`}}Oq.defineProperties(I.prototype,{name:{value:P.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${N}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),I.prototype.code=N,I.prototype[K]=!0,z[N]=I}function M(N){const W=$+N.name;return Oq.defineProperty(N,"name",{value:W}),N}function j(N,W){if(N&&W&&N!==W){if(Array.isArray(W.errors))return W.errors.push(N),W;const P=new Z([W,N],W.message);return P.code=W.code,P}return N||W}var L=class extends Error{constructor(N="The operation was aborted",W=void 0){if(W!==void 0&&typeof W!=="object")throw new z.ERR_INVALID_ARG_TYPE("options","Object",W);super(N,W);this.code="ABORT_ERR",this.name="AbortError"}};F("ERR_ASSERTION","%s",Error),F("ERR_INVALID_ARG_TYPE",(N,W,P)=>{if(V(typeof N==="string","'name' must be a string"),!Array.isArray(W))W=[W];let I="The ";if(N.endsWith(" argument"))I+=`${N} `;else I+=`"${N}" ${N.includes(".")?"property":"argument"} `;I+="must be ";const x=[],T=[],A=[];for(let C of W)if(V(typeof C==="string","All expected entries have to be of type string"),B.includes(C))x.push(C.toLowerCase());else if(Y.test(C))T.push(C);else V(C!=="object",'The value "object" should be written as "Object"'),A.push(C);if(T.length>0){const C=x.indexOf("object");if(C!==-1)x.splice(x,C,1),T.push("Object")}if(x.length>0){switch(x.length){case 1:I+=`of type ${x[0]}`;break;case 2:I+=`one of type ${x[0]} or ${x[1]}`;break;default:{const C=x.pop();I+=`one of type ${x.join(", ")}, or ${C}`}}if(T.length>0||A.length>0)I+=" or "}if(T.length>0){switch(T.length){case 1:I+=`an instance of ${T[0]}`;break;case 2:I+=`an instance of ${T[0]} or ${T[1]}`;break;default:{const C=T.pop();I+=`an instance of ${T.join(", ")}, or ${C}`}}if(A.length>0)I+=" or "}switch(A.length){case 0:break;case 1:if(A[0].toLowerCase()!==A[0])I+="an ";I+=`${A[0]}`;break;case 2:I+=`one of ${A[0]} or ${A[1]}`;break;default:{const C=A.pop();I+=`one of ${A.join(", ")}, or ${C}`}}if(P==null)I+=`. Received ${P}`;else if(typeof P==="function"&&P.name)I+=`. Received function ${P.name}`;else if(typeof P==="object"){var O;if((O=P.constructor)!==null&&O!==void 0&&O.name)I+=`. Received an instance of ${P.constructor.name}`;else{const C=J(P,{depth:-1});I+=`. Received ${C}`}}else{let C=J(P,{colors:!1});if(C.length>25)C=`${C.slice(0,25)}...`;I+=`. Received type ${typeof P} (${C})`}return I},TypeError),F("ERR_INVALID_ARG_VALUE",(N,W,P="is invalid")=>{let I=J(W);if(I.length>128)I=I.slice(0,128)+"...";return`The ${N.includes(".")?"property":"argument"} '${N}' ${P}. Received ${I}`},TypeError),F("ERR_INVALID_RETURN_VALUE",(N,W,P)=>{var I;const x=P!==null&&P!==void 0&&(I=P.constructor)!==null&&I!==void 0&&I.name?`instance of ${P.constructor.name}`:`type ${typeof P}`;return`Expected ${N} to be returned from the "${W}" function but got ${x}.`},TypeError),F("ERR_MISSING_ARGS",(...N)=>{V(N.length>0,"At least one arg needs to be specified");let W;const P=N.length;switch(N=(Array.isArray(N)?N:[N]).map((I)=>`"${I}"`).join(" or "),P){case 1:W+=`The ${N[0]} argument`;break;case 2:W+=`The ${N[0]} and ${N[1]} arguments`;break;default:{const I=N.pop();W+=`The ${N.join(", ")}, and ${I} arguments`}break}return`${W} must be specified`},TypeError),F("ERR_OUT_OF_RANGE",(N,W,P)=>{V(W,'Missing "range" argument');let I;if(Number.isInteger(P)&&Math.abs(P)>4294967296)I=G(String(P));else if(typeof P==="bigint"){if(I=String(P),P>2n**32n||P<-(2n**32n))I=G(I);I+="n"}else I=J(P);return`The value of "${N}" is out of range. It must be ${W}. Received ${I}`},RangeError),F("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),F("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),F("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),F("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),F("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),F("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),F("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),F("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),F("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),F("ERR_STREAM_WRITE_AFTER_END","write after end",Error),F("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),Q.exports={AbortError:L,aggregateTwoErrors:M(j),hideStackFrames:M,codes:z}}}),aq=cq({"node_modules/readable-stream/lib/internal/validators.js"(q,Q){var{ArrayIsArray:X,ArrayPrototypeIncludes:J,ArrayPrototypeJoin:H,ArrayPrototypeMap:Z,NumberIsInteger:K,NumberMAX_SAFE_INTEGER:B,NumberMIN_SAFE_INTEGER:Y,NumberParseInt:$,RegExpPrototypeTest:z,String:V,StringPrototypeToUpperCase:G,StringPrototypeTrim:U}=Dq(),{hideStackFrames:F,codes:{ERR_SOCKET_BAD_PORT:M,ERR_INVALID_ARG_TYPE:j,ERR_INVALID_ARG_VALUE:L,ERR_OUT_OF_RANGE:N,ERR_UNKNOWN_SIGNAL:W}}=sq(),{normalizeEncoding:P}=_q(),{isAsyncFunction:I,isArrayBufferView:x}=_q().types,T={};function A(i){return i===(i|0)}function O(i){return i===i>>>0}var C=/^[0-7]+$/,E="must be a 32-bit unsigned integer or an octal string";function w(i,n,o){if(typeof i==="undefined")i=o;if(typeof i==="string"){if(!z(C,i))throw new L(n,i,E);i=$(i,8)}return _(i,n,0,4294967295),i}var D=F((i,n,o=Y,s=B)=>{if(typeof i!=="number")throw new j(n,"number",i);if(!K(i))throw new N(n,"an integer",i);if(is)throw new N(n,`>= ${o} && <= ${s}`,i)}),_=F((i,n,o=-2147483648,s=2147483647)=>{if(typeof i!=="number")throw new j(n,"number",i);if(!A(i)){if(!K(i))throw new N(n,"an integer",i);throw new N(n,`>= ${o} && <= ${s}`,i)}if(is)throw new N(n,`>= ${o} && <= ${s}`,i)}),v=F((i,n,o)=>{if(typeof i!=="number")throw new j(n,"number",i);if(!O(i)){if(!K(i))throw new N(n,"an integer",i);throw new N(n,`>= ${o?1:0} && < 4294967296`,i)}if(o&&i===0)throw new N(n,">= 1 && < 4294967296",i)});function R(i,n){if(typeof i!=="string")throw new j(n,"string",i)}function g(i,n){if(typeof i!=="number")throw new j(n,"number",i)}var S=F((i,n,o)=>{if(!J(o,i)){const a="must be one of: "+H(Z(o,(r)=>typeof r==="string"?`'${r}'`:V(r)),", ");throw new L(n,i,a)}});function k(i,n){if(typeof i!=="boolean")throw new j(n,"boolean",i)}var f=F((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 j(n,"Object",i)}),y=F((i,n,o=0)=>{if(!X(i))throw new j(n,"Array",i);if(i.length{if(!x(i))throw new j(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 m(i,n="Port",o=!0){if(typeof i!=="number"&&typeof i!=="string"||typeof i==="string"&&U(i).length===0||+i!==+i>>>0||i>65535||i===0&&!o)throw new M(n,i,o);return i|0}var b=F((i,n)=>{if(i!==void 0&&(i===null||typeof i!=="object"||!("aborted"in i)))throw new j(n,"AbortSignal",i)}),c=F((i,n)=>{if(typeof i!=="function")throw new j(n,"Function",i)}),d=F((i,n)=>{if(typeof i!=="function"||I(i))throw new j(n,"Function",i)}),l=F((i,n)=>{if(i!==void 0)throw new j(n,"undefined",i)});Q.exports={isInt32:A,isUint32:O,parseFileMode:w,validateArray:y,validateBoolean:k,validateBuffer:p,validateEncoding:u,validateFunction:c,validateInt32:_,validateInteger:D,validateNumber:g,validateObject:f,validateOneOf:S,validatePlainFunction:d,validatePort:m,validateSignalName:h,validateString:R,validateUint32:v,validateUndefined:l,validateAbortSignal:b}}}),rq=cq({"node_modules/readable-stream/lib/internal/streams/utils.js"(q,Q){var{Symbol:X,SymbolAsyncIterator:J,SymbolIterator:H}=Dq(),Z=X("kDestroyed"),K=X("kIsErrored"),B=X("kIsReadable"),Y=X("kIsDisturbed");function $(v,R=!1){var g;return!!(v&&typeof v.pipe==="function"&&typeof v.on==="function"&&(!R||typeof v.pause==="function"&&typeof v.resume==="function")&&(!v._writableState||((g=v._readableState)===null||g===void 0?void 0:g.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 G(v){return v&&(v._readableState||v._writableState||typeof v.write==="function"&&typeof v.on==="function"||typeof v.pipe==="function"&&typeof v.on==="function")}function U(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 F(v){if(!G(v))return null;const{_writableState:R,_readableState:g}=v,S=R||g;return!!(v.destroyed||v[Z]||S!==null&&S!==void 0&&S.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 j(v,R){if(!z(v))return null;if(v.writableFinished===!0)return!0;const g=v._writableState;if(g!==null&&g!==void 0&&g.errored)return!1;if(typeof(g===null||g===void 0?void 0:g.finished)!=="boolean")return null;return!!(g.finished||R===!1&&g.ended===!0&&g.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 N(v,R){if(!$(v))return null;const g=v._readableState;if(g!==null&&g!==void 0&&g.errored)return!1;if(typeof(g===null||g===void 0?void 0:g.endEmitted)!=="boolean")return null;return!!(g.endEmitted||R===!1&&g.ended===!0&&g.length===0)}function W(v){if(v&&v[B]!=null)return v[B];if(typeof(v===null||v===void 0?void 0:v.readable)!=="boolean")return null;if(F(v))return!1;return $(v)&&v.readable&&!N(v)}function P(v){if(typeof(v===null||v===void 0?void 0:v.writable)!=="boolean")return null;if(F(v))return!1;return z(v)&&v.writable&&!M(v)}function I(v,R){if(!G(v))return null;if(F(v))return!0;if((R===null||R===void 0?void 0:R.readable)!==!1&&W(v))return!1;if((R===null||R===void 0?void 0:R.writable)!==!1&&P(v))return!1;return!0}function x(v){var R,g;if(!G(v))return null;if(v.writableErrored)return v.writableErrored;return(R=(g=v._writableState)===null||g===void 0?void 0:g.errored)!==null&&R!==void 0?R:null}function T(v){var R,g;if(!G(v))return null;if(v.readableErrored)return v.readableErrored;return(R=(g=v._readableState)===null||g===void 0?void 0:g.errored)!==null&&R!==void 0?R:null}function A(v){if(!G(v))return null;if(typeof v.closed==="boolean")return v.closed;const{_writableState:R,_readableState:g}=v;if(typeof(R===null||R===void 0?void 0:R.closed)==="boolean"||typeof(g===null||g===void 0?void 0:g.closed)==="boolean")return(R===null||R===void 0?void 0:R.closed)||(g===null||g===void 0?void 0:g.closed);if(typeof v._closed==="boolean"&&O(v))return v._closed;return null}function O(v){return typeof v._closed==="boolean"&&typeof v._defaultKeepAlive==="boolean"&&typeof v._removedConnection==="boolean"&&typeof v._removedContLen==="boolean"}function C(v){return typeof v._sent100==="boolean"&&O(v)}function E(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 w(v){if(!G(v))return null;const{_writableState:R,_readableState:g}=v,S=R||g;return!S&&C(v)||!!(S&&S.autoDestroy&&S.emitClose&&S.closed===!1)}function D(v){var R;return!!(v&&((R=v[Y])!==null&&R!==void 0?R:v.readableDidRead||v.readableAborted))}function _(v){var R,g,S,k,f,y,h,p,u,m;return!!(v&&((R=(g=(S=(k=(f=(y=v[K])!==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&&S!==void 0?S:(p=v._writableState)===null||p===void 0?void 0:p.errorEmitted)!==null&&g!==void 0?g:(u=v._readableState)===null||u===void 0?void 0:u.errored)!==null&&R!==void 0?R:(m=v._writableState)===null||m===void 0?void 0:m.errored))}Q.exports={kDestroyed:Z,isDisturbed:D,kIsDisturbed:Y,isErrored:_,kIsErrored:K,isReadable:W,kIsReadable:B,isClosed:A,isDestroyed:F,isDuplexNodeStream:V,isFinished:I,isIterable:U,isReadableNodeStream:$,isReadableEnded:L,isReadableFinished:N,isReadableErrored:T,isNodeStream:G,isWritable:P,isWritableNodeStream:z,isWritableEnded:M,isWritableFinished:j,isWritableErrored:x,isServerRequest:E,isServerResponse:C,willEmitClose:w}}}),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:Z}=J,{once:K}=_q(),{validateAbortSignal:B,validateFunction:Y,validateObject:$}=aq(),{Promise:z}=Dq(),{isClosed:V,isReadable:G,isReadableNodeStream:U,isReadableFinished:F,isReadableErrored:M,isWritable:j,isWritableNodeStream:L,isWritableFinished:N,isWritableErrored:W,isNodeStream:P,willEmitClose:I}=rq();function x(C){return C.setHeader&&typeof C.abort==="function"}var T=()=>{};function A(C,E,w){var D,_;if(arguments.length===2)w=E,E={};else if(E==null)E={};else $(E,"options");Y(w,"callback"),B(E.signal,"options.signal"),w=K(w);const v=(D=E.readable)!==null&&D!==void 0?D:U(C),R=(_=E.writable)!==null&&_!==void 0?_:L(C);if(!P(C))throw new H("stream","Stream",C);const{_writableState:g,_readableState:S}=C,k=()=>{if(!C.writable)h()};let f=I(C)&&U(C)===v&&L(C)===R,y=N(C,!1);const h=()=>{if(y=!0,C.destroyed)f=!1;if(f&&(!C.readable||v))return;if(!v||p)w.call(C)};let p=F(C,!1);const u=()=>{if(p=!0,C.destroyed)f=!1;if(f&&(!C.writable||R))return;if(!R||y)w.call(C)},m=(i)=>{w.call(C,i)};let b=V(C);const c=()=>{b=!0;const i=W(C)||M(C);if(i&&typeof i!=="boolean")return w.call(C,i);if(v&&!p&&U(C,!0)){if(!F(C,!1))return w.call(C,new Z)}if(R&&!y){if(!N(C,!1))return w.call(C,new Z)}w.call(C)},d=()=>{C.req.on("finish",h)};if(x(C)){if(C.on("complete",h),!f)C.on("abort",c);if(C.req)d();else C.on("request",d)}else if(R&&!g)C.on("end",k),C.on("close",k);if(!f&&typeof C.aborted==="boolean")C.on("aborted",c);if(C.on("end",u),C.on("finish",h),E.error!==!1)C.on("error",m);if(C.on("close",c),b)Aq(c);else if(g!==null&&g!==void 0&&g.errorEmitted||S!==null&&S!==void 0&&S.errorEmitted){if(!f)Aq(c)}else if(!v&&(!f||G(C))&&(y||j(C)===!1))Aq(c);else if(!R&&(!f||j(C))&&(p||G(C)===!1))Aq(c);else if(S&&C.req&&C.aborted)Aq(c);const l=()=>{if(w=T,C.removeListener("aborted",c),C.removeListener("complete",h),C.removeListener("abort",c),C.removeListener("request",d),C.req)C.req.removeListener("finish",h);C.removeListener("end",k),C.removeListener("close",k),C.removeListener("finish",h),C.removeListener("end",u),C.removeListener("error",m),C.removeListener("close",c)};if(E.signal&&!b){const i=()=>{const n=w;l(),n.call(C,new X(void 0,{cause:E.signal.reason}))};if(E.signal.aborted)Aq(i);else{const n=w;w=K((...o)=>{E.signal.removeEventListener("abort",i),n.apply(C,o)}),E.signal.addEventListener("abort",i)}}return l}function O(C,E){return new z((w,D)=>{A(C,E,(_)=>{if(_)D(_);else w()})})}Q.exports=A,Q.exports.finished=O}}),eq=cq({"node_modules/readable-stream/lib/internal/streams/operators.js"(q,Q){var X=globalThis.AbortController||Eq("abort-controller").AbortController,{codes:{ERR_INVALID_ARG_TYPE:J,ERR_MISSING_ARGS:H,ERR_OUT_OF_RANGE:Z},AbortError:K}=sq(),{validateAbortSignal:B,validateInteger:Y,validateObject:$}=aq(),z=Dq().Symbol("kWeak"),{finished:V}=tq(),{ArrayPrototypePush:G,MathFloor:U,Number:F,NumberIsNaN:M,Promise:j,PromiseReject:L,PromisePrototypeCatch:N,Symbol:W}=Dq(),P=W("kEmpty"),I=W("kEof");function x(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)B(y.signal,"options.signal");let h=1;if((y===null||y===void 0?void 0:y.concurrency)!=null)h=U(y.concurrency);return Y(h,"concurrency",1),async function*p(){var u,m;const b=new X,c=this,d=[],l=b.signal,i={signal:l},n=()=>b.abort();if(y!==null&&y!==void 0&&(u=y.signal)!==null&&u!==void 0&&u.aborted)n();y===null||y===void 0||(m=y.signal)===null||m===void 0||m.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 K;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 j((Xq)=>{s=Xq})}d.push(I)}catch(Qq){const Xq=L(Qq);N(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===I)return;if(l.aborted)throw new K;if(e!==P)yield e;if(d.shift(),s)s(),s=null}await new j((e)=>{o=e})}}finally{if(b.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)B(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 K({cause:f.signal.reason});yield[h++,u]}}.call(this)}async function A(f,y=void 0){for await(let h of w.call(this,f,y))return!0;return!1}async function O(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 C(f,y){for await(let h of w.call(this,f,y))return h;return}async function E(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 x.call(this,h,y));}function w(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 x.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 _(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)B(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 K(void 0,{cause:h.signal.reason});throw this.once("error",()=>{}),await V(this.destroy(l)),l}const m=new X,b=m.signal;if(h!==null&&h!==void 0&&h.signal){const l={once:!0,[z]:this};h.signal.addEventListener("abort",()=>m.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 K;if(!u)y=l,u=!0;else y=await f(y,l,{signal:b})}if(!c&&!u)throw new D}finally{m.abort()}return y}async function v(f){if(f!=null)$(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)B(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 K(void 0,{cause:f.signal.reason});G(y,p)}return y}function R(f,y){const h=x.call(this,f,y);return async function*p(){for await(let u of h)yield*u}.call(this)}function g(f){if(f=F(f),M(f))return 0;if(f<0)throw new Z("number",">= 0",f);return f}function S(f,y=void 0){if(y!=null)$(y,"options");if((y===null||y===void 0?void 0:y.signal)!=null)B(y.signal,"options.signal");return f=g(f),async function*h(){var p;if(y!==null&&y!==void 0&&(p=y.signal)!==null&&p!==void 0&&p.aborted)throw new K;for await(let m of this){var u;if(y!==null&&y!==void 0&&(u=y.signal)!==null&&u!==void 0&&u.aborted)throw new K;if(f--<=0)yield m}}.call(this)}function k(f,y=void 0){if(y!=null)$(y,"options");if((y===null||y===void 0?void 0:y.signal)!=null)B(y.signal,"options.signal");return f=g(f),async function*h(){var p;if(y!==null&&y!==void 0&&(p=y.signal)!==null&&p!==void 0&&p.aborted)throw new K;for await(let m of this){var u;if(y!==null&&y!==void 0&&(u=y.signal)!==null&&u!==void 0&&u.aborted)throw new K;if(f-- >0)yield m;else return}}.call(this)}Q.exports.streamReturningOperators={asIndexedPairs:T,drop:S,filter:w,flatMap:R,map:x,take:k},Q.exports.promiseReturningOperators={every:O,forEach:E,reduce:_,toArray:v,some:A,find:C}}}),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:Z}=Dq(),{kDestroyed:K,isDestroyed:B,isFinished:Y,isServerRequest:$}=rq(),z="#kDestroy",V="#kConstruct";function G(E,w,D){if(E){if(E.stack,w&&!w.errored)w.errored=E;if(D&&!D.errored)D.errored=E}}function U(E,w){const D=this._readableState,_=this._writableState,v=_||D;if(_&&_.destroyed||D&&D.destroyed){if(typeof w==="function")w();return this}if(G(E,_,D),_)_.destroyed=!0;if(D)D.destroyed=!0;if(!v.constructed)this.once(z,(R)=>{F(this,X(R,E),w)});else F(this,E,w);return this}function F(E,w,D){let _=!1;function v(R){if(_)return;_=!0;const{_readableState:g,_writableState:S}=E;if(G(R,S,g),S)S.closed=!0;if(g)g.closed=!0;if(typeof D==="function")D(R);if(R)Aq(M,E,R);else Aq(j,E)}try{E._destroy(w||null,v)}catch(R){v(R)}}function M(E,w){L(E,w),j(E)}function j(E){const{_readableState:w,_writableState:D}=E;if(D)D.closeEmitted=!0;if(w)w.closeEmitted=!0;if(D&&D.emitClose||w&&w.emitClose)E.emit("close")}function L(E,w){const D=E?._readableState,_=E?._writableState;if(_?.errorEmitted||D?.errorEmitted)return;if(_)_.errorEmitted=!0;if(D)D.errorEmitted=!0;E?.emit?.("error",w)}function N(){const E=this._readableState,w=this._writableState;if(E)E.constructed=!0,E.closed=!1,E.closeEmitted=!1,E.destroyed=!1,E.errored=null,E.errorEmitted=!1,E.reading=!1,E.ended=E.readable===!1,E.endEmitted=E.readable===!1;if(w)w.constructed=!0,w.destroyed=!1,w.closed=!1,w.closeEmitted=!1,w.errored=null,w.errorEmitted=!1,w.finalCalled=!1,w.prefinished=!1,w.ended=w.writable===!1,w.ending=w.writable===!1,w.finished=w.writable===!1}function W(E,w,D){const _=E?._readableState,v=E?._writableState;if(v&&v.destroyed||_&&_.destroyed)return this;if(_&&_.autoDestroy||v&&v.autoDestroy)E.destroy(w);else if(w){if(Error.captureStackTrace(w),v&&!v.errored)v.errored=w;if(_&&!_.errored)_.errored=w;if(D)Aq(L,E,w);else L(E,w)}}function P(E,w){if(typeof E._construct!=="function")return;const{_readableState:D,_writableState:_}=E;if(D)D.constructed=!1;if(_)_.constructed=!1;if(E.once(V,w),E.listenerCount(V)>1)return;Aq(I,E)}function I(E){let w=!1;function D(_){if(w){W(E,_!==null&&_!==void 0?_:new J);return}w=!0;const{_readableState:v,_writableState:R}=E,g=R||v;if(v)v.constructed=!0;if(R)R.constructed=!0;if(g.destroyed)E.emit(z,_);else if(_)W(E,_,!0);else Aq(x,E)}try{E._construct(D)}catch(_){D(_)}}function x(E){E.emit(V)}function T(E){return E&&E.setHeader&&typeof E.abort==="function"}function A(E){E.emit("close")}function O(E,w){E.emit("error",w),Aq(A,E)}function C(E,w){if(!E||B(E))return;if(!w&&!Y(E))w=new H;if($(E))E.socket=null,E.destroy(w);else if(T(E))E.abort();else if(T(E.req))E.req.abort();else if(typeof E.destroy==="function")E.destroy(w);else if(typeof E.close==="function")E.close();else if(w)Aq(O,E);else Aq(A,E);if(!E.destroyed)E[K]=!0}Q.exports={construct:P,destroyer:C,destroy:U,undestroy:N,errorOrDestroy:W}}}),QQ=cq({"node_modules/readable-stream/lib/internal/streams/legacy.js"(q,Q){var{ArrayIsArray:X,ObjectSetPrototypeOf:J}=Dq(),{EventEmitter:H}=Eq("bun:events_native"),Z;if(Sq)Z=wq;else Z=H;function K(Y){if(!(this instanceof K))return new K(Y);Z.call(this,Y)}J(K.prototype,Z.prototype),J(K,Z),K.prototype.pipe=function(Y,$){const z=this;function V(N){if(Y.writable&&Y.write(N)===!1&&z.pause)z.pause()}z.on("data",V);function G(){if(z.readable&&z.resume)z.resume()}if(Y.on("drain",G),!Y._isStdio&&(!$||$.end!==!1))z.on("end",F),z.on("close",M);let U=!1;function F(){if(U)return;U=!0,Y.end()}function M(){if(U)return;if(U=!0,typeof Y.destroy==="function")Y.destroy()}function j(N){if(L(),Z.listenerCount(this,"error")===0)this.emit("error",N)}B(z,"error",j),B(Y,"error",j);function L(){z.removeListener("data",V),Y.removeListener("drain",G),z.removeListener("end",F),z.removeListener("close",M),z.removeListener("error",j),Y.removeListener("error",j),z.removeListener("end",L),z.removeListener("close",L),Y.removeListener("close",L)}return z.on("end",L),z.on("close",L),Y.on("close",L),Y.emit("pipe",z),Y};function B(Y,$,z){if(typeof Y.prependListener==="function")return Y.prependListener($,z);if(!Y._events||!Y._events[$])Y.on($,z);else if(X(Y._events[$]))Y._events[$].unshift(z);else Y._events[$]=[z,Y._events[$]]}Q.exports={Stream:K,prependListener:B}}}),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:Z}=J,K=(Y,$)=>{if(typeof Y!=="object"||!("aborted"in Y))throw new Z($,"AbortSignal",Y)};function B(Y){return!!(Y&&typeof Y.pipe==="function")}Q.exports.addAbortSignal=function Y($,z){if(K($,"signal"),!B(z))throw new Z("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 $}}}),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 Z(Y,$,z){return Y.highWaterMark!=null?Y.highWaterMark:$?Y[z]:null}function K(Y){return Y?16:16384}function B(Y,$,z,V){const G=Z($,V,z);if(G!=null){if(!J(G)||G<0){const U=V?`options.${z}`:"options.highWaterMark";throw new H(U,G)}return X(G)}return K(Y.objectMode)}Q.exports={getHighWaterMark:B,getDefaultHighWaterMark:K}}}),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:Z,ERR_STREAM_NULL_VALUES:K}=sq().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 G;if($&&$[J])G=!0,V=$[J]();else if($&&$[H])G=!1,V=$[H]();else throw new Z("iterable",["Iterable"],$);const U=new Y({objectMode:!0,highWaterMark:1,...z});let F=!1;U._read=function(){if(!F)F=!0,j()},U._destroy=function(L,N){X(M(L),()=>Aq(N,L),(W)=>Aq(N,W||L))};async function M(L){const N=L!==void 0&&L!==null,W=typeof V.throw==="function";if(N&&W){const{value:P,done:I}=await V.throw(L);if(await P,I)return}if(typeof V.return==="function"){const{value:P}=await V.return();await P}}async function j(){for(;;){try{const{value:L,done:N}=G?await V.next():V.next();if(N)U.push(null);else{const W=L&&typeof L.then==="function"?await L:L;if(W===null)throw F=!1,new K;else if(U.push(W))continue;else F=!1}}catch(L){U.destroy(L)}break}}return U}Q.exports=B}}),ZQ,KQ=cq({"node_modules/readable-stream/lib/internal/streams/readable.js"(q,Q){var{ArrayPrototypeIndexOf:X,NumberIsInteger:J,NumberIsNaN:H,NumberParseInt:Z,ObjectDefineProperties:K,ObjectKeys:B,ObjectSetPrototypeOf:Y,Promise:$,SafeSet:z,SymbolAsyncIterator:V,Symbol:G}=Dq(),U=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{EventEmitter:F}=Eq("bun:events_native"),{Stream:M,prependListener:j}=QQ();function L(Xq){if(!(this instanceof L))return new L(Xq);const Jq=this instanceof vq();if(this._readableState=new U(Xq,this,Jq),Xq){const{read:Hq,destroy:Zq,construct:Kq,signal:Bq}=Xq;if(typeof Hq==="function")this._read=Hq;if(typeof Zq==="function")this._destroy=Zq;if(typeof Kq==="function")this._construct=Kq;if(Bq&&!Jq)P(Bq,this)}M.call(this,Xq),w.construct(this,()=>{if(this._readableState.needReadable)C(this,this._readableState)})}Y(L.prototype,M.prototype),Y(L,M),L.prototype.on=function(Xq,Jq){const Hq=M.prototype.on.call(this,Xq,Jq),Zq=this._readableState;if(Xq==="data")if(Zq.readableListening=this.listenerCount("readable")>0,Zq.flowing!==!1)xq&&Iq("in flowing mode!",this.__id),this.resume();else xq&&Iq("in readable mode!",this.__id);else if(Xq==="readable"){if(xq&&Iq("readable listener added!",this.__id),!Zq.endEmitted&&!Zq.readableListening){if(Zq.readableListening=Zq.needReadable=!0,Zq.flowing=!1,Zq.emittedReadable=!1,xq&&Iq("on readable - state.length, reading, emittedReadable",Zq.length,Zq.reading,Zq.emittedReadable,this.__id),Zq.length)E(this,Zq);else if(!Zq.reading)Aq(n,this)}else if(Zq.endEmitted)xq&&Iq("end already emitted...",this.__id)}return Hq};class N extends L{#q;#Q;#X;#J;constructor(Xq,Jq){const{objectMode:Hq,highWaterMark:Zq,encoding:Kq,signal:Bq}=Xq;super({objectMode:Hq,highWaterMark:Zq,encoding:Kq,signal:Bq});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}#Z(Xq){Xq.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){xq&&Iq("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 Zq=!1,Kq;const Bq=Jq.readMany();if(Cq(Bq)){if({done:Zq,value:Kq}=await Bq,this.#Q){this.#X.push(...Kq);return}}else({done:Zq,value:Kq}=Bq);if(Zq){this.#Z(Jq);return}if(!this.push(Kq[0])){this.#X=Kq.slice(1);return}for(let Yq=1,$q=Kq.length;Yq<$q;Yq++)if(!this.push(Kq[Yq])){this.#X=Kq.slice(Yq+1);return}}while(!this.#Q)}catch(Bq){Hq=Bq}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(Zq){globalThis.reportError(Zq)}}}function W(Xq,Jq={}){if(!dq(Xq))throw new _("readableStream","ReadableStream",Xq);k(Jq,"options");const{highWaterMark:Hq,encoding:Zq,objectMode:Kq=!1,signal:Bq}=Jq;if(Zq!==void 0&&!Buffer.isEncoding(Zq))throw new oq(Zq,"options.encoding");return lq(Kq,"options.objectMode"),WQ(L,Xq,Jq)||new N({highWaterMark:Hq,encoding:Zq,objectMode:Kq,signal:Bq},Xq)}Q.exports=L,ZQ=N;var{addAbortSignal:P}=XQ(),I=tq();const{maybeReadMore:x,resume:T,emitReadable:A,onEofChunk:O}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function C(Xq,Jq){process.nextTick(x,Xq,Jq)}function E(Xq,Jq){xq&&Iq("NativeReadable - emitReadable",Xq.__id),A(Xq,Jq)}var w=qQ(),{aggregateTwoErrors:D,codes:{ERR_INVALID_ARG_TYPE:_,ERR_METHOD_NOT_IMPLEMENTED:v,ERR_OUT_OF_RANGE:R,ERR_STREAM_PUSH_AFTER_EOF:g,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:S}}=sq(),{validateObject:k}=aq(),{StringDecoder:f}=Eq("string_decoder"),y=HQ(),h=()=>{},{errorOrDestroy:p}=w;L.prototype.destroy=w.destroy,L.prototype._undestroy=w.undestroy,L.prototype._destroy=function(Xq,Jq){Jq(Xq)},L.prototype[F.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,Zq){xq&&Iq("readableAddChunk",Jq,Xq.__id);const Kq=Xq._readableState;let Bq;if(!Kq.objectMode){if(typeof Jq==="string"){if(Hq=Hq||Kq.defaultEncoding,Kq.encoding!==Hq)if(Zq&&Kq.encoding)Jq=Buffer.from(Jq,Hq).toString(Kq.encoding);else Jq=Buffer.from(Jq,Hq),Hq=""}else if(Jq instanceof Buffer)Hq="";else if(M._isUint8Array(Jq)){if(Zq||!Kq.decoder)Jq=M._uint8ArrayToBuffer(Jq);Hq=""}else if(Jq!=null)Bq=new _("chunk",["string","Buffer","Uint8Array"],Jq)}if(Bq)p(Xq,Bq);else if(Jq===null)Kq.reading=!1,O(Xq,Kq);else if(Kq.objectMode||Jq&&Jq.length>0)if(Zq)if(Kq.endEmitted)p(Xq,new S);else if(Kq.destroyed||Kq.errored)return!1;else m(Xq,Kq,Jq,!0);else if(Kq.ended)p(Xq,new g);else if(Kq.destroyed||Kq.errored)return!1;else if(Kq.reading=!1,Kq.decoder&&!Hq)if(Jq=Kq.decoder.write(Jq),Kq.objectMode||Jq.length!==0)m(Xq,Kq,Jq,!1);else C(Xq,Kq);else m(Xq,Kq,Jq,!1);else if(!Zq)Kq.reading=!1,C(Xq,Kq);return!Kq.ended&&(Kq.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,Zq)Jq.buffer.unshift(Hq);else Jq.buffer.push(Hq);if(xq&&Iq("needReadable @ addChunk",Jq.needReadable,Xq.__id),Jq.needReadable)E(Xq,Jq)}C(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 Zq="";for(let Kq=Hq.length;Kq>0;Kq--)Zq+=Jq.write(Hq.shift());if(Zq!=="")Hq.push(Zq);return this._readableState.length=Zq.length,this};var b=1073741824;function c(Xq){if(Xq>b)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(xq&&Iq("read - n =",Xq,this.__id),!J(Xq))Xq=Z(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(xq&&Iq("read: emitReadable or endReadable",Jq.length,Jq.ended,this.__id),Jq.length===0&&Jq.ended)r(this);else E(this,Jq);return null}if(Xq=d(Xq,Jq),Xq===0&&Jq.ended){if(xq&&Iq("read: calling endReadable if length 0 -- length, state.ended",Jq.length,Jq.ended,this.__id),Jq.length===0)r(this);return null}let Zq=Jq.needReadable;if(xq&&Iq("need readable",Zq,this.__id),Jq.length===0||Jq.length-Xq0)Bq=a(Xq,Jq);else Bq=null;if(xq&&Iq("ret @ read",Bq,this.__id),Bq===null)Jq.needReadable=Jq.length<=Jq.highWaterMark,xq&&Iq("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(Bq!==null&&!Jq.errorEmitted&&!Jq.closeEmitted)Jq.dataEmitted=!0,this.emit("data",Bq);return Bq},L.prototype._read=function(Xq){throw new v("_read()")},L.prototype.pipe=function(Xq,Jq){const Hq=this,Zq=this._readableState;if(Zq.pipes.length===1){if(!Zq.multiAwaitDrain)Zq.multiAwaitDrain=!0,Zq.awaitDrainWriters=new z(Zq.awaitDrainWriters?[Zq.awaitDrainWriters]:[])}Zq.pipes.push(Xq),xq&&Iq("pipe count=%d opts=%j",Zq.pipes.length,Jq,Hq.__id);const Bq=(!Jq||Jq.end!==!1)&&Xq!==process.stdout&&Xq!==process.stderr?$q:Nq;if(Zq.endEmitted)Aq(Bq);else Hq.once("end",Bq);Xq.on("unpipe",Yq);function Yq(Wq,Pq){if(xq&&Iq("onunpipe",Hq.__id),Wq===Hq){if(Pq&&Pq.hasUnpiped===!1)Pq.hasUnpiped=!0,Gq()}}function $q(){xq&&Iq("onend",Hq.__id),Xq.end()}let zq,Vq=!1;function Gq(){if(xq&&Iq("cleanup",Hq.__id),Xq.removeListener("close",jq),Xq.removeListener("finish",Lq),zq)Xq.removeListener("drain",zq);if(Xq.removeListener("error",Mq),Xq.removeListener("unpipe",Yq),Hq.removeListener("end",$q),Hq.removeListener("end",Nq),Hq.removeListener("data",Fq),Vq=!0,zq&&Zq.awaitDrainWriters&&(!Xq._writableState||Xq._writableState.needDrain))zq()}function Uq(){if(!Vq){if(Zq.pipes.length===1&&Zq.pipes[0]===Xq)xq&&Iq("false write response, pause",0,Hq.__id),Zq.awaitDrainWriters=Xq,Zq.multiAwaitDrain=!1;else if(Zq.pipes.length>1&&Zq.pipes.includes(Xq))xq&&Iq("false write response, pause",Zq.awaitDrainWriters.size,Hq.__id),Zq.awaitDrainWriters.add(Xq);Hq.pause()}if(!zq)zq=l(Hq,Xq),Xq.on("drain",zq)}Hq.on("data",Fq);function Fq(Wq){xq&&Iq("ondata",Hq.__id);const Pq=Xq.write(Wq);if(xq&&Iq("dest.write",Pq,Hq.__id),Pq===!1)Uq()}function Mq(Wq){if(Iq("onerror",Wq),Nq(),Xq.removeListener("error",Mq),Xq.listenerCount("error")===0){const Pq=Xq._writableState||Xq._readableState;if(Pq&&!Pq.errorEmitted)p(Xq,Wq);else Xq.emit("error",Wq)}}j(Xq,"error",Mq);function jq(){Xq.removeListener("finish",Lq),Nq()}Xq.once("close",jq);function Lq(){Iq("onfinish"),Xq.removeListener("close",jq),Nq()}Xq.once("finish",Lq);function Nq(){Iq("unpipe"),Hq.unpipe(Xq)}if(Xq.emit("pipe",Hq),Xq.writableNeedDrain===!0){if(Zq.flowing)Uq()}else if(!Zq.flowing)Iq("pipe resume"),Hq.resume();return Xq};function l(Xq,Jq){return function Hq(){const Zq=Xq._readableState;if(Zq.awaitDrainWriters===Jq)Iq("pipeOnDrain",1),Zq.awaitDrainWriters=null;else if(Zq.multiAwaitDrain)Iq("pipeOnDrain",Zq.awaitDrainWriters.size),Zq.awaitDrainWriters.delete(Jq);if((!Zq.awaitDrainWriters||Zq.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 Kq=Jq.pipes;Jq.pipes=[],this.pause();for(let Bq=0;Bq0,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){xq&&Iq("on readable nextTick, calling read(0)",Xq.__id),Xq.read(0)}L.prototype.resume=function(){const Xq=this._readableState;if(!Xq.flowing)xq&&Iq("resume",this.__id),Xq.flowing=!Xq.readableListening,T(this,Xq);return Xq.paused=!1,this},L.prototype.pause=function(){if(xq&&Iq("call pause flowing=%j",this._readableState.flowing,this.__id),this._readableState.flowing!==!1)xq&&Iq("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",(Zq)=>{if(!this.push(Zq)&&Xq.pause)Jq=!0,Xq.pause()}),Xq.on("end",()=>{this.push(null)}),Xq.on("error",(Zq)=>{p(this,Zq)}),Xq.on("close",()=>{this.destroy()}),Xq.on("destroy",()=>{this.destroy()}),this._read=()=>{if(Jq&&Xq.resume)Jq=!1,Xq.resume()};const Hq=B(Xq);for(let Zq=1;Zq{Kq=Yq?D(Kq,Yq):null,Hq(),Hq=h});try{while(!0){const Yq=Xq.destroyed?null:Xq.read();if(Yq!==null)yield Yq;else if(Kq)throw Kq;else if(Kq===null)return;else await new $(Zq)}}catch(Yq){throw Kq=D(Kq,Yq),Kq}finally{if((Kq||(Jq===null||Jq===void 0?void 0:Jq.destroyOnReturn)!==!1)&&(Kq===void 0||Xq._readableState.autoDestroy))w.destroyer(Xq,null);else Xq.off("readable",Zq),Bq()}}K(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(xq&&Iq("endEmitted @ endReadable",Jq.endEmitted,Xq.__id),!Jq.endEmitted)Jq.ended=!0,Aq(t,Jq,Xq)}function t(Xq,Jq){if(xq&&Iq("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"),xq&&Iq("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:W};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,Zq;return new L({objectMode:(Hq=(Zq=Xq.readableObjectMode)!==null&&Zq!==void 0?Zq:Xq.objectMode)!==null&&Hq!==void 0?Hq:!0,...Jq,destroy(Kq,Bq){w.destroyer(Xq,Kq),Bq(Kq)}}).wrap(Xq)}}}),BQ=cq({"node_modules/readable-stream/lib/internal/streams/writable.js"(q,Q){var{ArrayPrototypeSlice:X,Error:J,FunctionPrototypeSymbolHasInstance:H,ObjectDefineProperty:Z,ObjectDefineProperties:K,ObjectSetPrototypeOf:B,StringPrototypeToLowerCase:Y,Symbol:$,SymbolHasInstance:z}=Dq(),{EventEmitter:V}=Eq("bun:events_native"),G=QQ().Stream,U=qQ(),{addAbortSignal:F}=XQ(),{getHighWaterMark:M,getDefaultHighWaterMark:j}=JQ(),{ERR_INVALID_ARG_TYPE:L,ERR_METHOD_NOT_IMPLEMENTED:N,ERR_MULTIPLE_CALLBACK:W,ERR_STREAM_CANNOT_PIPE:P,ERR_STREAM_DESTROYED:I,ERR_STREAM_ALREADY_FINISHED:x,ERR_STREAM_NULL_VALUES:T,ERR_STREAM_WRITE_AFTER_END:A,ERR_UNKNOWN_ENCODING:O}=sq().codes,{errorOrDestroy:C}=U;function E(s={}){const a=this instanceof vq();if(!a&&!H(E,this))return new E(s);if(this._writableState=new _(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)F(s.signal,this)}G.call(this,s),U.construct(this,()=>{const r=this._writableState;if(!r.writing)u(this,r);d(this,r)})}B(E.prototype,G.prototype),B(E,G),Q.exports=E;function w(){}var D=$("kOnFinished");function _(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):j(!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}_.prototype.getBuffer=function s(){return X(this.buffered,this.bufferedIndex)},Z(_.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),Z(E,z,{value:function(s){if(H(this,s))return!0;if(this!==E)return!1;return s&&s._writableState instanceof _}}),E.prototype.pipe=function(){C(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 O(r);if(typeof t!=="function")t=w}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(G._isUint8Array(a))a=G._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 I("write");if(qq)return Aq(t,qq),C(s,qq,!0),qq;return e.pendingcb++,g(s,e,a,r,t)}E.prototype.write=function(s,a,r){return R(this,s,a,r)===!0},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){const s=this._writableState;if(s.corked){if(s.corked--,!s.writing)u(this,s)}},E.prototype.setDefaultEncoding=function s(a){if(typeof a==="string")a=Y(a);if(!Buffer.isEncoding(a))throw new O(a);return this._writableState.defaultEncoding=a,this};function g(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?w:(Hq)=>{for(let Zq=Qq;Zq256)r.splice(0,Qq),a.bufferedIndex=0;else a.bufferedIndex=Qq}a.bufferProcessing=!1}E.prototype._write=function(s,a,r){if(this._writev)this._writev([{chunk:s,encoding:a}],r);else throw new N("_write()")},E.prototype._writev=null,E.prototype.end=function(s,a,r,t=!1){const e=this._writableState;if(xq&&Iq("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 x("end");else if(e.destroyed)qq=new I("end");if(typeof r==="function")if(qq||e.finished)Aq(r,qq);else e[D].push(r);return this};function m(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 Iq("needFinish",r,a),r}function b(s,a){let r=!1;function t(e){if(r){C(s,e!==null&&e!==void 0?e:W());return}if(r=!0,a.pendingcb--,e){const qq=a[D].splice(0);for(let Qq=0;Qq{if(m(e))l(t,e);else e.pendingcb--},s,a);else if(m(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 U("nully","body",y)},(y)=>{F(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:g})}throw new U("Iterable, AsyncIterable or AsyncFunction",w,_)}if(P(E))return C(E.arrayBuffer());if(Z(E))return N(T,E,{objectMode:!0,writable:!1});if(typeof(E===null||E===void 0?void 0:E.writable)==="object"||typeof(E===null||E===void 0?void 0:E.readable)==="object"){const _=E!==null&&E!==void 0&&E.readable?B(E===null||E===void 0?void 0:E.readable)?E===null||E===void 0?void 0:E.readable:C(E.readable):void 0,v=E!==null&&E!==void 0&&E.writable?Y(E===null||E===void 0?void 0:E.writable)?E===null||E===void 0?void 0:E.writable:C(E.writable):void 0;return O({readable:_,writable:v})}const D=E===null||E===void 0?void 0:E.then;if(typeof D==="function"){let _;return x(D,E,(v)=>{if(v!=null)_.push(v);_.push(null)},(v)=>{F(_,v)}),_=new T({objectMode:!0,writable:!1,read(){}})}throw new G(w,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],E)};function A(C){let{promise:E,resolve:w}=L();const D=new I,_=D.signal;return{value:C(async function*(){while(!0){const R=E;E=null;const{chunk:g,done:S,cb:k}=await R;if(Aq(k),S)return;if(_.aborted)throw new V(void 0,{cause:_.reason});({promise:E,resolve:w}=L()),yield g}}(),{signal:_}),write(R,g,S){const k=w;w=null,k({chunk:R,done:!1,cb:S})},final(R){const g=w;w=null,g({done:!0,cb:R})},destroy(R,g){D.abort(),g(R)}}}function O(C){const E=C.readable&&typeof C.readable.read!=="function"?j.wrap(C.readable):C.readable,w=C.writable;let D=!!J(E),_=!!H(w),v,R,g,S,k;function f(y){const h=S;if(S=null,h)h(y);else if(y)k.destroy(y);else if(!D&&!_)k.destroy()}if(k=new T({readableObjectMode:!!(E!==null&&E!==void 0&&E.readableObjectMode),writableObjectMode:!!(w!==null&&w!==void 0&&w.writableObjectMode),readable:D,writable:_}),_)z(w,(y)=>{if(_=!1,y)F(E,y);f(y)}),k._write=function(y,h,p){if(w.write(y,h))p();else v=p},k._final=function(y){w.end(),R=y},w.on("drain",function(){if(v){const y=v;v=null,y()}}),w.on("finish",function(){if(R){const y=R;R=null,y()}});if(D)z(E,(y)=>{if(D=!1,y)F(E,y);f(y)}),E.on("readable",function(){if(g){const y=g;g=null,y()}}),E.on("end",function(){k.push(null)}),k._read=function(){while(!0){const y=E.read();if(y===null){g=k._read;return}if(!k.push(y))return}};return k._destroy=function(y,h){if(!y&&S!==null)y=new V;if(g=null,v=null,R=null,S===null)h(y);else S=h,F(w,y),F(E,y)},k}}}),vq=cq({"node_modules/readable-stream/lib/internal/streams/duplex.js"(q,Q){var{ObjectDefineProperties:X,ObjectGetOwnPropertyDescriptor:J,ObjectKeys:H,ObjectSetPrototypeOf:Z}=Dq(),K=KQ();function B(G){if(!(this instanceof B))return new B(G);if(K.call(this,G),Tq.call(this,G),G){if(this.allowHalfOpen=G.allowHalfOpen!==!1,G.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(G.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,Z(B.prototype,K.prototype),Z(B,K);for(var Y in Tq.prototype)if(!B.prototype[Y])B.prototype[Y]=Tq.prototype[Y];X(B.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(G){if(this._readableState&&this._writableState)this._readableState.destroyed=G,this._writableState.destroyed=G}}});var $;function z(){if($===void 0)$={};return $}B.fromWeb=function(G,U){return z().newStreamDuplexFromReadableWritablePair(G,U)},B.toWeb=function(G){return z().newReadableWritablePairFromDuplex(G)};var V;B.from=function(G){if(!V)V=YQ();return V(G,"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,Z=vq();function K(z){if(!(this instanceof K))return new K(z);if(Z.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(K.prototype,Z.prototype),X(K,Z),Q.exports=K;var B=J("kCallback");function Y(z){if(typeof this._flush==="function"&&!this.destroyed)this._flush((V,G)=>{if(V){if(z)z(V);else this.destroy(V);return}if(G!=null)this.push(G);if(this.push(null),z)z()});else if(this.push(null),z)z()}function $(){if(this._final!==Y)Y.call(this)}K.prototype._final=Y,K.prototype._transform=function(z,V,G){throw new H("_transform()")},K.prototype._write=function(z,V,G){const U=this._readableState,F=this._writableState,M=U.length;this._transform(z,V,(j,L)=>{if(j){G(j);return}if(L!=null)this.push(L);if(F.ended||M===U.length||U.length{k=!0});const f=Z(R,{readable:g,writable:S},(y)=>{k=!y});return{destroy:(y)=>{if(k)return;k=!0,B.destroyer(R,y||new U("pipe"))},cleanup:f}}function O(R){return M(R[R.length-1],"streams[stream.length - 1]"),R.pop()}function C(R){if(L(R))return R;else if(W(R))return E(R);throw new z("val",["Readable","Iterable","AsyncIterable"],R)}async function*E(R){if(!T)T=KQ();yield*T.prototype[H].call(R)}async function w(R,g,S,{end:k}){let f,y=null;const h=(m)=>{if(m)f=m;if(y){const b=y;y=null,b()}},p=()=>new J((m,b)=>{if(f)b(f);else y=()=>{if(f)b(f);else m()}});g.on("drain",h);const u=Z(g,{readable:!1},h);try{if(g.writableNeedDrain)await p();for await(let m of R)if(!g.write(m))await p();if(k)g.end();await p(),S()}catch(m){S(f!==m?$(f,m):m)}finally{u(),g.off("drain",h)}}function D(...R){return _(R,K(O(R)))}function _(R,g,S){if(R.length===1&&X(R[0]))R=R[0];if(R.length<2)throw new G("streams");const k=new I,f=k.signal,y=S===null||S===void 0?void 0:S.signal,h=[];j(y,"options.signal");function p(){l(new F)}y===null||y===void 0||y.addEventListener("abort",p);let u,m;const b=[];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(b.length)b.shift()(u);if(y===null||y===void 0||y.removeEventListener("abort",p),k.abort(),s){if(!u)h.forEach((a)=>a());Aq(g,u,m)}}let i;for(let o=0;o0,t=a||(S===null||S===void 0?void 0:S.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(b.push(Qq),N(s)&&e)h.push(Xq)}if(s.on("error",qq),N(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)||W(s))i=s;else i=Y.from(s);else if(typeof s==="function")if(i=C(i),i=s(i,{signal:f}),a){if(!L(i,!0))throw new V("AsyncIterable",`transform[${o-1}]`,i)}else{var n;if(!x)x=zQ();const qq=new x({objectMode:!0}),Qq=(n=i)===null||n===void 0?void 0:n.then;if(typeof Qq==="function")c++,Qq.call(i,(Hq)=>{if(m=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++,w(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(b.push(Xq),e)h.push(Jq)}else if(P(s)){if(W(i)){c+=2;const qq=v(i,s,d,{end:t});if(N(s)&&e)h.push(qq)}else if(L(i))c++,w(i,s,d,{end:t});else throw new z("val",["Readable","Iterable","AsyncIterable"],i);i=s}else i=Y.from(s)}if(f!==null&&f!==void 0&&f.aborted||y!==null&&y!==void 0&&y.aborted)Aq(p);return i}function v(R,g,S,{end:k}){if(R.pipe(g,{end:k}),k)R.once("end",()=>g.end());else S();return Z(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",S).once("error",S);else S(f)}),Z(g,{readable:!1,writable:!0},S)}Q.exports={pipelineImpl:_,pipeline:D}}}),GQ=cq({"node_modules/readable-stream/lib/internal/streams/compose.js"(q,Q){var{pipeline:X}=VQ(),J=vq(),{destroyer:H}=qQ(),{isNodeStream:Z,isReadable:K,isWritable:B}=rq(),{AbortError:Y,codes:{ERR_INVALID_ARG_VALUE:$,ERR_MISSING_ARGS:z}}=sq();Q.exports=function V(...G){if(G.length===0)throw new z("streams");if(G.length===1)return J.from(G[0]);const U=[...G];if(typeof G[0]==="function")G[0]=J.from(G[0]);if(typeof G[G.length-1]==="function"){const A=G.length-1;G[A]=J.from(G[A])}for(let A=0;A0&&!B(G[A]))throw new $(`streams[${A}]`,U[A],"must be writable")}let F,M,j,L,N;function W(A){const O=L;if(L=null,O)O(A);else if(A)N.destroy(A);else if(!T&&!x)N.destroy()}const P=G[0],I=X(G,W),x=!!B(P),T=!!K(I);if(N=new J({writableObjectMode:!!(P!==null&&P!==void 0&&P.writableObjectMode),readableObjectMode:!!(I!==null&&I!==void 0&&I.writableObjectMode),writable:x,readable:T}),x)N._write=function(A,O,C){if(P.write(A,O))C();else F=C},N._final=function(A){P.end(),M=A},P.on("drain",function(){if(F){const A=F;F=null,A()}}),I.on("finish",function(){if(M){const A=M;M=null,A()}});if(T)I.on("readable",function(){if(j){const A=j;j=null,A()}}),I.on("end",function(){N.push(null)}),N._read=function(){while(!0){const A=I.read();if(A===null){j=N._read;return}if(!N.push(A))return}};return N._destroy=function(A,O){if(!A&&L!==null)A=new Y;if(j=null,F=null,M=null,L===null)O(A);else L=O,H(I,A)},N}}}),UQ=cq({"node_modules/readable-stream/lib/stream/promises.js"(q,Q){var{ArrayPrototypePop:X,Promise:J}=Dq(),{isIterable:H,isNodeStream:Z}=rq(),{pipelineImpl:K}=VQ(),{finished:B}=tq();function Y(...$){return new J((z,V)=>{let G,U;const F=$[$.length-1];if(F&&typeof F==="object"&&!Z(F)&&!H(F)){const M=X($);G=M.signal,U=M.end}K($,(M,j)=>{if(M)V(M);else z(j)},{signal:G,end:U})})}Q.exports={finished:B,pipeline:Y}}}),FQ=cq({"node_modules/readable-stream/lib/stream.js"(q,Q){var{ObjectDefineProperty:X,ObjectKeys:J,ReflectApply:H}=Dq(),{promisify:{custom:Z}}=_q(),{streamReturningOperators:K,promiseReturningOperators:B}=eq(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:Y}}=sq(),$=GQ(),{pipeline:z}=VQ(),{destroyer:V}=qQ(),G=tq(),U=UQ(),F=rq(),M=Q.exports=QQ().Stream;M.isDisturbed=F.isDisturbed,M.isErrored=F.isErrored,M.isWritable=F.isWritable,M.isReadable=F.isReadable,M.Readable=KQ();for(let L of J(K)){let N=function(...P){if(new.target)throw Y();return M.Readable.from(H(W,this,P))};const W=K[L];X(N,"name",{value:W.name}),X(N,"length",{value:W.length}),X(M.Readable.prototype,L,{value:N,enumerable:!1,configurable:!0,writable:!0})}for(let L of J(B)){let N=function(...P){if(new.target)throw Y();return H(W,this,P)};const W=B[L];X(N,"name",{value:W.name}),X(N,"length",{value:W.length}),X(M.Readable.prototype,L,{value:N,enumerable:!1,configurable:!0,writable:!0})}M.Writable=BQ(),M.Duplex=vq(),M.Transform=$Q(),M.PassThrough=zQ(),M.pipeline=z;var{addAbortSignal:j}=XQ();M.addAbortSignal=j,M.finished=G,M.destroy=V,M.compose=$,X(M,"promises",{configurable:!0,enumerable:!0,get(){return U}}),X(z,Z,{enumerable:!0,get(){return U.pipeline}}),X(G,Z,{enumerable:!0,get(){return U.finished}}),M.Stream=M,M._isUint8Array=function L(N){return N instanceof Uint8Array},M._uint8ArrayToBuffer=function L(N){return new Buffer(N.buffer,N.byteOffset,N.byteLength)}}}),MQ=cq({"node_modules/readable-stream/lib/ours/index.js"(q,Q){const X=FQ(),J=UQ(),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=NQ,Q.exports.NativeWritable=pQ,Oq.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=BQ(),pQ=class q extends Tq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(Q,X={}){super(X);this._construct=this.#J,this._destroy=this.#Z,this._final=this.#K,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 Z=this.#Q,K=Z.write(Q);if(Cq(K))return K.then(()=>{this.emit("drain"),Z.flush(!0)}),!1;if(Z.flush(!0),J)J(null,Q.byteLength);return!0}end(Q,X,J,H=this.#X){return super.end(Q,X,J,H)}#Z(Q,X){if(this._writableState.destroyed=!0,X)X(Q)}#K(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:ZQ};var lQ=PQ,IQ=PQ._uint8ArrayToBuffer,xQ=PQ._isUint8Array,TQ=PQ.isDisturbed,AQ=PQ.isErrored,OQ=PQ.isWritable,CQ=PQ.isReadable,EQ=PQ.Readable,Tq=PQ.Writable,wQ=PQ.Duplex,DQ=PQ.Transform,_Q=PQ.PassThrough,vQ=PQ.addAbortSignal,RQ=PQ.finished,gQ=PQ.destroy,SQ=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,SQ as pipeline,OQ as isWritable,CQ as isReadable,AQ as isErrored,TQ as isDisturbed,RQ as finished,yQ as eos,gQ as destroy,lQ as default,kQ as compose,vQ as addAbortSignal,IQ as _uint8ArrayToBuffer,xQ as _isUint8Array,hQ as _getNativeReadableStreamPrototype,Tq as Writable,DQ as Transform,fQ as Stream,EQ as Readable,_Q as PassThrough,pQ as NativeWritable,wQ as Duplex}; +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}; diff --git a/src/js/out/modules/node/stream.web.js b/src/js/out/modules/node/stream.web.js index 7eca1802a..bb906418c 100644 --- a/src/js/out/modules/node/stream.web.js +++ b/src/js/out/modules/node/stream.web.js @@ -1 +1 @@ -var{ReadableStream:b,ReadableStreamDefaultController:c,WritableStream:d,WritableStreamDefaultController:f,WritableStreamDefaultWriter:h,TransformStream:j,TransformStreamDefaultController:k,ByteLengthQueuingStrategy:l,CountQueuingStrategy:m,ReadableStreamBYOBReader:p,ReadableStreamBYOBRequest:q,ReadableStreamDefaultReader:s}=globalThis,v={ReadableStream:b,ReadableStreamDefaultController:c,WritableStream:d,WritableStreamDefaultController:f,WritableStreamDefaultWriter:h,TransformStream:j,TransformStreamDefaultController:k,ByteLengthQueuingStrategy:l,CountQueuingStrategy:m,ReadableStreamBYOBReader:p,ReadableStreamBYOBRequest:q,ReadableStreamDefaultReader:s,[Symbol.for("CommonJS")]:0};export{v as default,h as WritableStreamDefaultWriter,f as WritableStreamDefaultController,d as WritableStream,k as TransformStreamDefaultController,j as TransformStream,s as ReadableStreamDefaultReader,c as ReadableStreamDefaultController,q as ReadableStreamBYOBRequest,p as ReadableStreamBYOBReader,b as ReadableStream,m as CountQueuingStrategy,l as ByteLengthQueuingStrategy}; +var{ReadableStream:c,ReadableStreamDefaultController:j,WritableStream:k,WritableStreamDefaultController:p,WritableStreamDefaultWriter:v,TransformStream:w,TransformStreamDefaultController:x,ByteLengthQueuingStrategy:z,CountQueuingStrategy:A,ReadableStreamBYOBReader:E,ReadableStreamBYOBRequest:F,ReadableStreamDefaultReader:G}=globalThis,H={ReadableStream:c,ReadableStreamDefaultController:j,WritableStream:k,WritableStreamDefaultController:p,WritableStreamDefaultWriter:v,TransformStream:w,TransformStreamDefaultController:x,ByteLengthQueuingStrategy:z,CountQueuingStrategy:A,ReadableStreamBYOBReader:E,ReadableStreamBYOBRequest:F,ReadableStreamDefaultReader:G,[Symbol.for("CommonJS")]:0};export{H as default,v as WritableStreamDefaultWriter,p as WritableStreamDefaultController,k as WritableStream,x as TransformStreamDefaultController,w as TransformStream,G as ReadableStreamDefaultReader,j as ReadableStreamDefaultController,F as ReadableStreamBYOBRequest,E as ReadableStreamBYOBReader,c as ReadableStream,A as CountQueuingStrategy,z as ByteLengthQueuingStrategy}; diff --git a/src/node-fallbacks/@vercel_fetch.js b/src/node-fallbacks/@vercel_fetch.js index a8de45222..276b4bc9f 100644 --- a/src/node-fallbacks/@vercel_fetch.js +++ b/src/node-fallbacks/@vercel_fetch.js @@ -1,5 +1,5 @@ // This is just a no-op. Intent is to prevent importing a bunch of stuff that isn't relevant. -module.exports = (wrapper = "Bun" in globalThis ? Bun.fetch : globalThis.fetch) => { +export default (wrapper = "Bun" in globalThis ? Bun.fetch : globalThis.fetch) => { async function vercelFetch(url, opts = {}) { // Convert Object bodies to JSON if they are JS objects if ( diff --git a/src/node-fallbacks/buffer.js b/src/node-fallbacks/buffer.js index 9984aef87..aa0065398 100644 --- a/src/node-fallbacks/buffer.js +++ b/src/node-fallbacks/buffer.js @@ -1 +1,2 @@ export * from "buffer"; +export { Buffer as default } from "buffer"; diff --git a/src/node-fallbacks/console.js b/src/node-fallbacks/console.js index 5cb1dfa10..34cc54b56 100644 --- a/src/node-fallbacks/console.js +++ b/src/node-fallbacks/console.js @@ -1 +1 @@ -module.exports = console; +export default console; diff --git a/src/node-fallbacks/crypto.js b/src/node-fallbacks/crypto.js index 8c83b6c87..7745530da 100644 --- a/src/node-fallbacks/crypto.js +++ b/src/node-fallbacks/crypto.js @@ -1,4 +1,5 @@ export * from "crypto-browserify"; +import * as cryptoBrowserify from "crypto-browserify"; export var DEFAULT_ENCODING = "buffer"; @@ -79,3 +80,13 @@ if (timingSafeEqual) { } export const webcrypto = crypto; + +export default { + ...cryptoBrowserify, + getRandomValues, + randomUUID, + timingSafeEqual, + scryptSync, + scrypt, + webcrypto, +}; diff --git a/src/node-fallbacks/domain.js b/src/node-fallbacks/domain.js index 9fe768097..af37e7059 100644 --- a/src/node-fallbacks/domain.js +++ b/src/node-fallbacks/domain.js @@ -1 +1,3 @@ -export * from "domain-browser"; +import domain from "domain-browser"; +export default domain; +export var { create, createDomain } = domain; diff --git a/src/node-fallbacks/http.js b/src/node-fallbacks/http.js index 3f025710f..4bb5b4a0d 100644 --- a/src/node-fallbacks/http.js +++ b/src/node-fallbacks/http.js @@ -1 +1,13 @@ -export * from "stream-http"; +import http from "stream-http"; +export default http; +export var { + // + request, + get, + ClientRequest, + IncomingMessage, + Agent, + globalAgent, + STATUS_CODES, + METHIDS, +} = http; diff --git a/src/node-fallbacks/https.js b/src/node-fallbacks/https.js index a5f405a5a..d1de96beb 100644 --- a/src/node-fallbacks/https.js +++ b/src/node-fallbacks/https.js @@ -1 +1,2 @@ export * from "https-browserify"; +export * as default from "https-browserify"; diff --git a/src/node-fallbacks/node-fetch.js b/src/node-fallbacks/node-fetch.js index f124e6461..a66d8fc7f 100644 --- a/src/node-fallbacks/node-fetch.js +++ b/src/node-fallbacks/node-fetch.js @@ -70,7 +70,6 @@ export default Object.assign(fetch, { fileFrom, fileFromSync, isRedirect, - [Symbol.for("CommonJS")]: 0, }); export { diff --git a/src/node-fallbacks/os.js b/src/node-fallbacks/os.js index c5bef4cf0..df0a41fd2 100644 --- a/src/node-fallbacks/os.js +++ b/src/node-fallbacks/os.js @@ -1 +1,20 @@ -export * from "os-browserify/browser"; +import os from "os-browserify/browser"; +export default os; +export var { + endianness, + hostname, + loadavg, + uptime, + freemem, + totalmem, + cpus, + type, + release, + arch, + platform, + tmpdir, + EOL, + homedir, + networkInterfaces, + getNetworkInterfaces, +} = os; diff --git a/src/node-fallbacks/package.json b/src/node-fallbacks/package.json index 144f553c0..3d48960c5 100644 --- a/src/node-fallbacks/package.json +++ b/src/node-fallbacks/package.json @@ -5,8 +5,8 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build-gen": "esbuild --bundle *.js --outdir=bun --format=cjs --platform=browser --external:buffer --external:stream --external:util --external:util/ --external:assert", - "build": "esbuild --bundle *.js --outdir=out --format=cjs --minify --platform=browser" + "build-gen": "esbuild --bundle *.js --outdir=bun --format=esm --platform=browser --external:buffer --external:stream --external:util --external:util/ --external:assert", + "build": "esbuild --bundle *.js --outdir=out --format=esm --minify --platform=browser" }, "author": "", "license": "ISC", diff --git a/src/node-fallbacks/path.js b/src/node-fallbacks/path.js index 558f820cc..a582c6d0f 100644 --- a/src/node-fallbacks/path.js +++ b/src/node-fallbacks/path.js @@ -1 +1,2 @@ export * from "path-browserify"; +export * as default from "path-browserify"; diff --git a/src/node-fallbacks/process.js b/src/node-fallbacks/process.js index 74190ab67..fec4e652f 100644 --- a/src/node-fallbacks/process.js +++ b/src/node-fallbacks/process.js @@ -1 +1,2 @@ export * from "process/browser"; +export * as default from "process/browser"; diff --git a/src/node-fallbacks/querystring.js b/src/node-fallbacks/querystring.js index ad7fd038d..00404cc1b 100644 --- a/src/node-fallbacks/querystring.js +++ b/src/node-fallbacks/querystring.js @@ -1 +1,2 @@ -export * from "querystring-es3"; +export { unescapeBuffer, unescape, escape, stringify, encode, parse, decode } from "querystring-es3"; +export { default } from "querystring-es3"; diff --git a/src/node-fallbacks/stream.js b/src/node-fallbacks/stream.js index 381cbc761..bee941be1 100644 --- a/src/node-fallbacks/stream.js +++ b/src/node-fallbacks/stream.js @@ -1 +1,2 @@ export * from "readable-stream"; +export * as default from "readable-stream"; diff --git a/src/node-fallbacks/string_decoder.js b/src/node-fallbacks/string_decoder.js index 90487c47e..c6fd8a2fd 100644 --- a/src/node-fallbacks/string_decoder.js +++ b/src/node-fallbacks/string_decoder.js @@ -1 +1,2 @@ export * from "string_decoder"; +export * as default from "string_decoder"; diff --git a/src/node-fallbacks/sys.js b/src/node-fallbacks/sys.js index 4b20b6354..99f15c638 100644 --- a/src/node-fallbacks/sys.js +++ b/src/node-fallbacks/sys.js @@ -1 +1,2 @@ export * from "util"; +export * as default from "util"; diff --git a/src/node-fallbacks/timers.js b/src/node-fallbacks/timers.js index a02f00701..c69274eef 100644 --- a/src/node-fallbacks/timers.js +++ b/src/node-fallbacks/timers.js @@ -1 +1,2 @@ export * from "timers-browserify"; +export * as default from "timers-browserify"; diff --git a/src/node-fallbacks/tsconfig.json b/src/node-fallbacks/tsconfig.json index d1c7e7a71..1228b6423 100644 --- a/src/node-fallbacks/tsconfig.json +++ b/src/node-fallbacks/tsconfig.json @@ -12,7 +12,7 @@ "https": ["node_modules/https-browserify"], "os": ["node_modules/os-browserify/browser"], "path": ["node_modules/path-browserify"], - "punycode": ["node_modules/punycode"], + "punycode": ["node_modules/punycode/punycode.es6.js"], "process": ["node_modules/process/browser"], "querystring": ["node_modules/querystring-es3"], "stream": ["node_modules/stream-browserify"], diff --git a/src/node-fallbacks/tty.js b/src/node-fallbacks/tty.js index 49efb472e..727bdc5c6 100644 --- a/src/node-fallbacks/tty.js +++ b/src/node-fallbacks/tty.js @@ -1 +1,2 @@ export * from "tty-browserify"; +export * as default from "tty-browserify"; diff --git a/src/node-fallbacks/util.js b/src/node-fallbacks/util.js index 3bd55da0a..1ad352a2a 100644 --- a/src/node-fallbacks/util.js +++ b/src/node-fallbacks/util.js @@ -4,3 +4,4 @@ const TextEncoder = globalThis.TextEncoder; const TextDecoder = globalThis.TextDecoder; export { TextEncoder, TextDecoder }; +export default { TextEncoder, TextDecoder }; diff --git a/src/node-fallbacks/zlib.js b/src/node-fallbacks/zlib.js index 4af7ab847..093367e29 100644 --- a/src/node-fallbacks/zlib.js +++ b/src/node-fallbacks/zlib.js @@ -1 +1,2 @@ export * from "browserify-zlib"; +export * as default from "browserify-zlib"; diff --git a/src/node_fallbacks.zig b/src/node_fallbacks.zig index 170907e58..51da04be0 100644 --- a/src/node_fallbacks.zig +++ b/src/node_fallbacks.zig @@ -67,7 +67,7 @@ const vercel_fetch_import_path = "/bun-vfs/node_modules/@vercel/fetch/index.js"; const assert_package_json = PackageJSON{ .name = "assert", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("assert@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -76,7 +76,7 @@ const assert_package_json = PackageJSON{ const buffer_package_json = PackageJSON{ .name = "buffer", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("buffer@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -85,7 +85,7 @@ const buffer_package_json = PackageJSON{ const console_package_json = PackageJSON{ .name = "console", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("console@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -94,7 +94,7 @@ const console_package_json = PackageJSON{ const constants_package_json = PackageJSON{ .name = "constants", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("constants@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -103,7 +103,7 @@ const constants_package_json = PackageJSON{ const crypto_package_json = PackageJSON{ .name = "crypto", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("crypto@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -112,7 +112,7 @@ const crypto_package_json = PackageJSON{ const domain_package_json = PackageJSON{ .name = "domain", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("domain@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -121,7 +121,7 @@ const domain_package_json = PackageJSON{ const events_package_json = PackageJSON{ .name = "events", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("events@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -130,7 +130,7 @@ const events_package_json = PackageJSON{ const http_package_json = PackageJSON{ .name = "http", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("http@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -139,7 +139,7 @@ const http_package_json = PackageJSON{ const https_package_json = PackageJSON{ .name = "https", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("https@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -148,7 +148,7 @@ const https_package_json = PackageJSON{ const net_package_json = PackageJSON{ .name = "net", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("net@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -157,7 +157,7 @@ const net_package_json = PackageJSON{ const os_package_json = PackageJSON{ .name = "os", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("os@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -166,7 +166,7 @@ const os_package_json = PackageJSON{ const path_package_json = PackageJSON{ .name = "path", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("path@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -175,7 +175,7 @@ const path_package_json = PackageJSON{ const process_package_json = PackageJSON{ .name = "process", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("process@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -184,7 +184,7 @@ const process_package_json = PackageJSON{ const punycode_package_json = PackageJSON{ .name = "punycode", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("punycode@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -193,7 +193,7 @@ const punycode_package_json = PackageJSON{ const querystring_package_json = PackageJSON{ .name = "querystring", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("querystring@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -202,7 +202,7 @@ const querystring_package_json = PackageJSON{ const stream_package_json = PackageJSON{ .name = "stream", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("stream@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -211,7 +211,7 @@ const stream_package_json = PackageJSON{ const string_decoder_package_json = PackageJSON{ .name = "string_decoder", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = brk: { @setEvalBranchQuota(9999); break :brk @truncate(u32, bun.hash("string_decoder@0.0.0-polyfill")); @@ -225,7 +225,7 @@ const string_decoder_package_json = PackageJSON{ const sys_package_json = PackageJSON{ .name = "sys", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("sys@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -234,7 +234,7 @@ const sys_package_json = PackageJSON{ const timers_package_json = PackageJSON{ .name = "timers", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("timers@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -243,7 +243,7 @@ const timers_package_json = PackageJSON{ const tty_package_json = PackageJSON{ .name = "tty", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("tty@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -252,7 +252,7 @@ const tty_package_json = PackageJSON{ const url_package_json = PackageJSON{ .name = "url", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("url@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -261,7 +261,7 @@ const url_package_json = PackageJSON{ const util_package_json = PackageJSON{ .name = "util", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("util@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -270,7 +270,7 @@ const util_package_json = PackageJSON{ const zlib_package_json = PackageJSON{ .name = "zlib", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("zlib@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -280,7 +280,7 @@ const zlib_package_json = PackageJSON{ const node_fetch_package_json = PackageJSON{ .name = "node-fetch", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("node-fetch@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -289,7 +289,7 @@ const node_fetch_package_json = PackageJSON{ const isomorphic_fetch_package_json = PackageJSON{ .name = "isomorphic-fetch", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("isomorphic-fetch@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -298,7 +298,7 @@ const isomorphic_fetch_package_json = PackageJSON{ const supports_color_package_json = PackageJSON{ .name = "supports-color", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("supports-color@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, @@ -308,7 +308,7 @@ const supports_color_package_json = PackageJSON{ const vercel_fetch_package_json = PackageJSON{ .name = "@vercel/fetch", .version = "0.0.0-polyfill", - .module_type = .cjs, + .module_type = .esm, .hash = @truncate(u32, bun.hash("@vercel/fetch@0.0.0-polyfill")), .main_fields = undefined, .browser_map = undefined, diff --git a/test/js/node/fs/node-fetch.test.js b/test/js/node/fs/node-fetch.test.js index 11c5e0ed3..33af3252d 100644 --- a/test/js/node/fs/node-fetch.test.js +++ b/test/js/node/fs/node-fetch.test.js @@ -1,4 +1,4 @@ -import { fetch, Response, Request, Headers } from "node-fetch"; +import fetch2, { fetch, Response, Request, Headers } from "node-fetch"; import { test, expect } from "bun:test"; @@ -19,3 +19,15 @@ test("node-fetch fetches", async () => { expect(await fetch("http://" + server.hostname + ":" + server.port)).toBeInstanceOf(Response); server.stop(true); }); + +test("node-fetch.default fetches", async () => { + const server = Bun.serve({ + port: 0, + fetch(req, server) { + server.stop(); + return new Response(); + }, + }); + expect(await fetch2("http://" + server.hostname + ":" + server.port)).toBeInstanceOf(Response); + server.stop(true); +}); -- cgit v1.2.3 From ceec1afec2bb187fecef0f5006dfe27ee3e1a9a6 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Sat, 24 Jun 2023 02:24:05 -0400 Subject: Add vi.spyOn and clean up some mock function binding calls (#3376) * Add vi.spyOn and clean up some binding calls * add vi.restoreAllMocks * remove junk file --------- Co-authored-by: Jarred Sumner --- src/bun.js/bindings/JSMockFunction.cpp | 12 ++++-------- src/bun.js/test/jest.zig | 25 +++++++++++++------------ test/bun.lockb | Bin 56172 -> 86272 bytes test/js/bun/test/mock-fn.test.js | 12 ++++++++++-- test/js/bun/test/test-interop.js | 19 +++++++++++++++++++ test/package.json | 3 ++- 6 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/bun.js/bindings/JSMockFunction.cpp b/src/bun.js/bindings/JSMockFunction.cpp index b7c2659b4..fbfcf0c9e 100644 --- a/src/bun.js/bindings/JSMockFunction.cpp +++ b/src/bun.js/bindings/JSMockFunction.cpp @@ -391,6 +391,7 @@ void JSMockFunction::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(fn->instances); visitor.append(fn->returnValues); visitor.append(fn->invocationCallOrder); + visitor.append(fn->spyOriginal); fn->mock.visit(visitor); } DEFINE_VISIT_CHILDREN(JSMockFunction); @@ -526,13 +527,13 @@ extern "C" void JSMock__resetSpies(Zig::GlobalObject* globalObject) globalObject->mockModule.activeSpies.clear(); } -extern "C" EncodedJSValue jsFunctionResetSpies(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe) +extern "C" EncodedJSValue JSMock__jsRestoreAllMocks(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe) { JSMock__resetSpies(jsCast(globalObject)); return JSValue::encode(jsUndefined()); } -extern "C" EncodedJSValue JSMock__spyOn(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callframe) +extern "C" EncodedJSValue JSMock__jsSpyOn(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callframe) { auto& vm = lexicalGlobalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -963,7 +964,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsMockFunctionGetter_protoImpl, (JSC::JSGlobalObject * return JSValue::encode(jsUndefined()); } -JSC_DEFINE_HOST_FUNCTION(jsMockFunctionConstructor, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callframe)) +extern "C" EncodedJSValue JSMock__jsMockFn(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callframe) { auto& vm = lexicalGlobalObject->vm(); auto* globalObject = jsCast(lexicalGlobalObject); @@ -997,11 +998,6 @@ JSC_DEFINE_HOST_FUNCTION(jsMockFunctionConstructor, (JSC::JSGlobalObject * lexic return JSValue::encode(thisObject); } -extern "C" EncodedJSValue JSMockFunction__createObject(Zig::GlobalObject* globalObject) -{ - auto& vm = globalObject->vm(); - return JSValue::encode(JSC::JSFunction::create(vm, globalObject, 0, "mock"_s, jsMockFunctionConstructor, ImplementationVisibility::Public)); -} extern "C" EncodedJSValue JSMockFunction__getCalls(EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index a1a4f2af8..f43afb1a2 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -333,7 +333,7 @@ pub const Jest = struct { pub fn Bun__Jest__createTestModuleObject(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { JSC.markBinding(@src()); - const module = JSC.JSValue.createEmptyObject(globalObject, 11); + const module = JSC.JSValue.createEmptyObject(globalObject, 12); const test_fn = JSC.NewFunction(globalObject, ZigString.static("test"), 2, TestScope.call, false); module.put( @@ -431,31 +431,32 @@ pub const Jest = struct { Expect.getConstructor(globalObject), ); - const mock_fn = JSMockFunction__createObject(globalObject); - const spyOn = JSC.NewFunction(globalObject, ZigString.static("spyOn"), 2, JSMock__spyOn, false); - const restoreAllMocks = JSC.NewFunction(globalObject, ZigString.static("restoreAllMocks"), 2, jsFunctionResetSpies, false); - module.put(globalObject, ZigString.static("mock"), mock_fn); + const mockFn = JSC.NewFunction(globalObject, ZigString.static("fn"), 1, JSMock__jsMockFn, false); + const spyOn = JSC.NewFunction(globalObject, ZigString.static("spyOn"), 2, JSMock__jsSpyOn, false); + const restoreAllMocks = JSC.NewFunction(globalObject, ZigString.static("restoreAllMocks"), 2, JSMock__jsRestoreAllMocks, false); + module.put(globalObject, ZigString.static("mock"), mockFn); const jest = JSValue.createEmptyObject(globalObject, 3); - jest.put(globalObject, ZigString.static("fn"), mock_fn); + jest.put(globalObject, ZigString.static("fn"), mockFn); jest.put(globalObject, ZigString.static("spyOn"), spyOn); jest.put(globalObject, ZigString.static("restoreAllMocks"), restoreAllMocks); module.put(globalObject, ZigString.static("jest"), jest); module.put(globalObject, ZigString.static("spyOn"), spyOn); - const vi = JSValue.createEmptyObject(globalObject, 1); - vi.put(globalObject, ZigString.static("fn"), mock_fn); + const vi = JSValue.createEmptyObject(globalObject, 3); + vi.put(globalObject, ZigString.static("fn"), mockFn); + vi.put(globalObject, ZigString.static("spyOn"), spyOn); + vi.put(globalObject, ZigString.static("restoreAllMocks"), restoreAllMocks); module.put(globalObject, ZigString.static("vi"), vi); return module; } - extern fn JSMockFunction__createObject(*JSC.JSGlobalObject) JSC.JSValue; - extern fn Bun__Jest__testPreloadObject(*JSC.JSGlobalObject) JSC.JSValue; extern fn Bun__Jest__testModuleObject(*JSC.JSGlobalObject) JSC.JSValue; - extern fn jsFunctionResetSpies(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; - extern fn JSMock__spyOn(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; + extern fn JSMock__jsMockFn(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; + extern fn JSMock__jsRestoreAllMocks(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; + extern fn JSMock__jsSpyOn(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; pub fn call( _: void, diff --git a/test/bun.lockb b/test/bun.lockb index fc86845e1..a26f2fdfe 100755 Binary files a/test/bun.lockb and b/test/bun.lockb differ diff --git a/test/js/bun/test/mock-fn.test.js b/test/js/bun/test/mock-fn.test.js index eac981fd1..8504e3d70 100644 --- a/test/js/bun/test/mock-fn.test.js +++ b/test/js/bun/test/mock-fn.test.js @@ -2,7 +2,16 @@ * This file is meant to be runnable in both Jest and Bun. * `bunx jest mock-fn.test.js` */ -var { isBun, test, describe, expect, jest, vi, mock, bunTest, spyOn } = require("./test-interop.js")(); +var { isBun, expect, jest, vi, mock, spyOn } = require("./test-interop.js")(); + +// if you want to test vitest, comment the above and uncomment the below + +// import { expect, describe, test, vi } from "vitest"; +// const isBun = false; +// const jest = { fn: vi.fn, restoreAllMocks: vi.restoreAllMocks }; +// const spyOn = vi.spyOn; +// import * as extended from "jest-extended"; +// expect.extend(extended); async function expectResolves(promise) { expect(promise).toBeInstanceOf(Promise); @@ -434,7 +443,6 @@ describe("mock()", () => { return "3"; }, ); - expect(result).toBe(undefined); expect(fn()).toBe("1"); }); test("withImplementation (async)", async () => { diff --git a/test/js/bun/test/test-interop.js b/test/js/bun/test/test-interop.js index 5c41082d6..4b2199ae9 100644 --- a/test/js/bun/test/test-interop.js +++ b/test/js/bun/test/test-interop.js @@ -20,6 +20,25 @@ module.exports = () => { vi: bunTest.vi, spyOn: bunTest.spyOn, }; + } else if (process.env.VITEST) { + const vi = require("vitest"); + + return { + isBun: false, + bunTest: null, + test: vi.test, + describe: vi.describe, + it: vi.it, + expect: vi.expect, + beforeEach: vi.beforeEach, + afterEach: vi.afterEach, + beforeAll: vi.beforeAll, + afterAll: vi.afterAll, + jest: { fn: vi.fn }, + mock: null, + vi, + spyOn: vi.spyOn, + }; } else { const globals = require("@jest/globals"); const extended = require("jest-extended"); diff --git a/test/package.json b/test/package.json index a9b8db913..480305013 100644 --- a/test/package.json +++ b/test/package.json @@ -22,7 +22,8 @@ "supertest": "^6.1.6", "svelte": "^3.55.1", "typescript": "^5.0.2", - "undici": "^5.20.0" + "undici": "^5.20.0", + "vitest": "^0.32.2" }, "private": true, "scripts": { -- cgit v1.2.3 From 069b42a7cc1275969859dc60e7c303528ca2dccb Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Sat, 24 Jun 2023 03:24:34 -0300 Subject: [feat] fs.watch (#3249) * initial support * add types * fix comment * fix types * bigfix up * more fixes * fix some encoding support for watch * fix rename event * fixup * fix latin1 * add fs_events, still failing some tests * fixuup * remove unecesary check * readd tests ops * this is necessary? just testing CI/CD weird errors * just use dupe here * cleanup and fix deinit * fix zig upgrade --- packages/bun-types/fs.d.ts | 97 +++ packages/bun-types/fs/promises.d.ts | 58 ++ src/bun.js/bindings/JSSink.cpp | 2 +- src/bun.js/bindings/JSSink.h | 2 +- src/bun.js/bindings/JSSinkLookupTable.h | 2 +- .../ZigGeneratedClasses+DOMClientIsoSubspaces.h | 1 + .../bindings/ZigGeneratedClasses+DOMIsoSubspaces.h | 1 + .../ZigGeneratedClasses+lazyStructureHeader.h | 6 + .../ZigGeneratedClasses+lazyStructureImpl.h | 7 + src/bun.js/bindings/ZigGeneratedClasses.cpp | 322 ++++++++ src/bun.js/bindings/ZigGeneratedClasses.h | 56 ++ src/bun.js/bindings/generated_classes.zig | 94 +++ src/bun.js/bindings/generated_classes_list.zig | 1 + src/bun.js/event_loop.zig | 7 + src/bun.js/javascript.zig | 7 + src/bun.js/node/fs_events.zig | 609 ++++++++++++++ src/bun.js/node/node.classes.ts | 30 +- src/bun.js/node/node_fs.zig | 13 +- src/bun.js/node/node_fs_binding.zig | 2 + src/bun.js/node/node_fs_watcher.zig | 913 +++++++++++++++++++++ src/bun.js/node/types.zig | 4 + src/bun.js/webcore/encoding.zig | 15 +- src/fs.zig | 54 ++ src/http.zig | 7 +- src/js/node/fs.js | 65 +- src/js/node/fs.promises.ts | 51 ++ src/js/out/modules/node/fs.js | 50 +- src/js/out/modules/node/fs.promises.js | 2 +- src/js/private.d.ts | 86 +- src/jsc.zig | 1 + src/watcher.zig | 68 +- test/js/node/watch/fixtures/close.js | 7 + test/js/node/watch/fixtures/persistent.js | 5 + test/js/node/watch/fixtures/relative.js | 23 + test/js/node/watch/fixtures/unref.js | 7 + test/js/node/watch/fs.watch.test.js | 424 ++++++++++ 36 files changed, 3072 insertions(+), 27 deletions(-) create mode 100644 src/bun.js/node/fs_events.zig create mode 100644 src/bun.js/node/node_fs_watcher.zig create mode 100644 test/js/node/watch/fixtures/close.js create mode 100644 test/js/node/watch/fixtures/persistent.js create mode 100644 test/js/node/watch/fixtures/relative.js create mode 100644 test/js/node/watch/fixtures/unref.js create mode 100644 test/js/node/watch/fs.watch.test.js diff --git a/packages/bun-types/fs.d.ts b/packages/bun-types/fs.d.ts index 14c5c1d1d..5dfb2c7f2 100644 --- a/packages/bun-types/fs.d.ts +++ b/packages/bun-types/fs.d.ts @@ -19,6 +19,7 @@ */ declare module "fs" { import * as stream from "stream"; + import type EventEmitter from "events"; import type { SystemError, ArrayBufferView } from "bun"; interface ObjectEncodingOptions { encoding?: BufferEncoding | null | undefined; @@ -3929,6 +3930,102 @@ declare module "fs" { */ recursive?: boolean; } + + export interface FSWatcher extends EventEmitter { + /** + * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable. + * @since v0.6.8 + */ + close(): void; + + /** + * When called, requests that the Node.js event loop not exit so long as the is active. Calling watcher.ref() multiple times will have no effect. + */ + ref(): void; + + /** + * When called, the active object will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before the object's callback is invoked. Calling watcher.unref() multiple times will have no effect. + */ + unref(): void; + + /** + * events.EventEmitter + * 1. change + * 2. error + */ + addListener(event: string, listener: (...args: any[]) => void): this; + addListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; + addListener(event: 'error', listener: (error: Error) => void): this; + addListener(event: 'close', listener: () => void): this; + on(event: string, listener: (...args: any[]) => void): this; + on(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; + on(event: 'error', listener: (error: Error) => void): this; + on(event: 'close', listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; + once(event: 'error', listener: (error: Error) => void): this; + once(event: 'close', listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; + prependListener(event: 'error', listener: (error: Error) => void): this; + prependListener(event: 'close', listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; + prependOnceListener(event: 'error', listener: (error: Error) => void): this; + prependOnceListener(event: 'close', listener: () => void): this; + } + /** + * Watch for changes on `filename`, where `filename` is either a file or a + * directory. + * + * The second argument is optional. If `options` is provided as a string, it + * specifies the `encoding`. Otherwise `options` should be passed as an object. + * + * The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'` or `'change'`, and `filename` is the name of the file + * which triggered the event. + * + * On most platforms, `'rename'` is emitted whenever a filename appears or + * disappears in the directory. + * + * The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`. + * + * If a `signal` is passed, aborting the corresponding AbortController will close + * the returned `fs.FSWatcher`. + * @since v0.6.8 + * @param listener + */ + export function watch( + filename: PathLike, + options: + | (WatchOptions & { + encoding: 'buffer'; + }) + | 'buffer', + listener?: WatchListener + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + export function watch(filename: PathLike, options?: WatchOptions | BufferEncoding | null, listener?: WatchListener): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + export function watch(filename: PathLike, options: WatchOptions | string, listener?: WatchListener): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + export function watch(filename: PathLike, listener?: WatchListener): FSWatcher; } declare module "node:fs" { diff --git a/packages/bun-types/fs/promises.d.ts b/packages/bun-types/fs/promises.d.ts index 0d71464b9..2b908fceb 100644 --- a/packages/bun-types/fs/promises.d.ts +++ b/packages/bun-types/fs/promises.d.ts @@ -26,6 +26,7 @@ declare module "fs/promises" { Abortable, RmOptions, RmDirOptions, + WatchOptions, } from "node:fs"; const constants: typeof import("node:fs")["constants"]; @@ -709,6 +710,63 @@ declare module "fs/promises" { * To remove a directory recursively, use `fs.promises.rm()` instead, with the `recursive` option set to `true`. */ function rmdir(path: PathLike, options?: RmDirOptions): Promise; + + /** + * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory. + * + * ```js + * const { watch } = require('node:fs/promises'); + * + * const ac = new AbortController(); + * const { signal } = ac; + * setTimeout(() => ac.abort(), 10000); + * + * (async () => { + * try { + * const watcher = watch(__filename, { signal }); + * for await (const event of watcher) + * console.log(event); + * } catch (err) { + * if (err.name === 'AbortError') + * return; + * throw err; + * } + * })(); + * ``` + * + * On most platforms, `'rename'` is emitted whenever a filename appears or + * disappears in the directory. + * + * All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`. + * @since v0.6.8 + * @return of objects with the properties: + */ + function watch( + filename: PathLike, + options: + | (WatchOptions & { + encoding: 'buffer'; + }) + | 'buffer' + ): AsyncIterable>; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable>; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + function watch(filename: PathLike, options: WatchOptions | string): AsyncIterable> | AsyncIterable>; } declare module "node:fs/promises" { diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index 36be334dd..4acf01ff7 100644 --- a/src/bun.js/bindings/JSSink.cpp +++ b/src/bun.js/bindings/JSSink.cpp @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-05-18T01:04:00.447Z +// Generated by 'make generate-sink' at 2023-06-14T21:38:04.394Z // To regenerate this file, run: // // make generate-sink diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h index 5bbfab777..37c458e9b 100644 --- a/src/bun.js/bindings/JSSink.h +++ b/src/bun.js/bindings/JSSink.h @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-05-18T01:04:00.446Z +// Generated by 'make generate-sink' at 2023-06-14T21:38:04.394Z // #pragma once diff --git a/src/bun.js/bindings/JSSinkLookupTable.h b/src/bun.js/bindings/JSSinkLookupTable.h index a4ace6dc3..e4ed81629 100644 --- a/src/bun.js/bindings/JSSinkLookupTable.h +++ b/src/bun.js/bindings/JSSinkLookupTable.h @@ -1,4 +1,4 @@ -// Automatically generated from src/bun.js/bindings/JSSink.cpp using /Users/jarred/Code/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! +// Automatically generated from src/bun.js/bindings/JSSink.cpp using /home/cirospaciari/Repos/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h index b16febcdb..f0d491c0b 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h @@ -8,6 +8,7 @@ std::unique_ptr m_clientSubspaceForExpectConstructor;std: std::unique_ptr m_clientSubspaceForExpectAnything; std::unique_ptr m_clientSubspaceForExpectStringContaining; std::unique_ptr m_clientSubspaceForExpectStringMatching; +std::unique_ptr m_clientSubspaceForFSWatcher; std::unique_ptr m_clientSubspaceForFileSystemRouter; std::unique_ptr m_clientSubspaceForFileSystemRouterConstructor;std::unique_ptr m_clientSubspaceForListener; std::unique_ptr m_clientSubspaceForMD4; diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h index 59263e62c..02a9adbca 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h @@ -8,6 +8,7 @@ std::unique_ptr m_subspaceForExpectConstructor;std::unique_ptr m_subspaceForExpectAnything; std::unique_ptr m_subspaceForExpectStringContaining; std::unique_ptr m_subspaceForExpectStringMatching; +std::unique_ptr m_subspaceForFSWatcher; std::unique_ptr m_subspaceForFileSystemRouter; std::unique_ptr m_subspaceForFileSystemRouterConstructor;std::unique_ptr m_subspaceForListener; std::unique_ptr m_subspaceForMD4; diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h index 4471fbab3..ac03032e6 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h @@ -58,6 +58,12 @@ JSC::Structure* JSExpectStringMatchingStructure() { return m_JSExpectStringMatch JSC::LazyClassStructure m_JSExpectStringMatching; bool hasJSExpectStringMatchingSetterValue { false }; mutable JSC::WriteBarrier m_JSExpectStringMatchingSetterValue; +JSC::Structure* JSFSWatcherStructure() { return m_JSFSWatcher.getInitializedOnMainThread(this); } + JSC::JSObject* JSFSWatcherConstructor() { return m_JSFSWatcher.constructorInitializedOnMainThread(this); } + JSC::JSValue JSFSWatcherPrototype() { return m_JSFSWatcher.prototypeInitializedOnMainThread(this); } + JSC::LazyClassStructure m_JSFSWatcher; + bool hasJSFSWatcherSetterValue { false }; + mutable JSC::WriteBarrier m_JSFSWatcherSetterValue; JSC::Structure* JSFileSystemRouterStructure() { return m_JSFileSystemRouter.getInitializedOnMainThread(this); } JSC::JSObject* JSFileSystemRouterConstructor() { return m_JSFileSystemRouter.constructorInitializedOnMainThread(this); } JSC::JSValue JSFileSystemRouterPrototype() { return m_JSFileSystemRouter.prototypeInitializedOnMainThread(this); } diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h index 4e5a2c1fa..b3b5327a4 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h @@ -58,6 +58,12 @@ void GlobalObject::initGeneratedLazyClasses() { init.setPrototype(WebCore::JSExpectStringMatching::createPrototype(init.vm, reinterpret_cast(init.global))); init.setStructure(WebCore::JSExpectStringMatching::createStructure(init.vm, init.global, init.prototype)); + }); + m_JSFSWatcher.initLater( + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSFSWatcher::createPrototype(init.vm, reinterpret_cast(init.global))); + init.setStructure(WebCore::JSFSWatcher::createStructure(init.vm, init.global, init.prototype)); + }); m_JSFileSystemRouter.initLater( [](LazyClassStructure::Initializer& init) { @@ -211,6 +217,7 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor& thisObject->m_JSExpectAnything.visit(visitor); visitor.append(thisObject->m_JSExpectAnythingSetterValue); thisObject->m_JSExpectStringContaining.visit(visitor); visitor.append(thisObject->m_JSExpectStringContainingSetterValue); thisObject->m_JSExpectStringMatching.visit(visitor); visitor.append(thisObject->m_JSExpectStringMatchingSetterValue); + thisObject->m_JSFSWatcher.visit(visitor); visitor.append(thisObject->m_JSFSWatcherSetterValue); thisObject->m_JSFileSystemRouter.visit(visitor); visitor.append(thisObject->m_JSFileSystemRouterSetterValue); thisObject->m_JSListener.visit(visitor); visitor.append(thisObject->m_JSListenerSetterValue); thisObject->m_JSMD4.visit(visitor); visitor.append(thisObject->m_JSMD4SetterValue); diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp index d51a1959a..e0a3f33d6 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.cpp +++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp @@ -5381,6 +5381,297 @@ void JSExpectStringMatching::visitOutputConstraintsImpl(JSCell* cell, Visitor& v } DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSExpectStringMatching); +class JSFSWatcherPrototype final : public JSC::JSNonFinalObject { +public: + using Base = JSC::JSNonFinalObject; + + static JSFSWatcherPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSFSWatcherPrototype* ptr = new (NotNull, JSC::allocateCell(vm)) JSFSWatcherPrototype(vm, globalObject, structure); + ptr->finishCreation(vm, globalObject); + return ptr; + } + + 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) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + } + +private: + JSFSWatcherPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + : Base(vm, structure) + { + } + + void finishCreation(JSC::VM&, JSC::JSGlobalObject*); +}; + +extern "C" void FSWatcherClass__finalize(void*); + +extern "C" EncodedJSValue FSWatcherPrototype__doClose(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(FSWatcherPrototype__closeCallback); + +extern "C" EncodedJSValue FSWatcherPrototype__hasRef(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(FSWatcherPrototype__hasRefCallback); + +extern "C" EncodedJSValue FSWatcherPrototype__doRef(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(FSWatcherPrototype__refCallback); + +extern "C" EncodedJSValue FSWatcherPrototype__doUnref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(FSWatcherPrototype__unrefCallback); + +STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFSWatcherPrototype, JSFSWatcherPrototype::Base); + +static const HashTableValue JSFSWatcherPrototypeTableValues[] = { + { "close"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FSWatcherPrototype__closeCallback, 0 } }, + { "hasRef"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FSWatcherPrototype__hasRefCallback, 0 } }, + { "ref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FSWatcherPrototype__refCallback, 0 } }, + { "unref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FSWatcherPrototype__unrefCallback, 0 } } +}; + +const ClassInfo JSFSWatcherPrototype::s_info = { "FSWatcher"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFSWatcherPrototype) }; + +JSC_DEFINE_HOST_FUNCTION(FSWatcherPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSFSWatcher* 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 FSWatcherPrototype__doClose(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + +JSC_DEFINE_HOST_FUNCTION(FSWatcherPrototype__hasRefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSFSWatcher* 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 FSWatcherPrototype__hasRef(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + +JSC_DEFINE_HOST_FUNCTION(FSWatcherPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSFSWatcher* 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 FSWatcherPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + +JSC_DEFINE_HOST_FUNCTION(FSWatcherPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSFSWatcher* 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 FSWatcherPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + +extern "C" void FSWatcherPrototype__listenerSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + auto& vm = globalObject->vm(); + auto* thisObject = jsCast(JSValue::decode(thisValue)); + thisObject->m_listener.set(vm, thisObject, JSValue::decode(value)); +} + +extern "C" EncodedJSValue FSWatcherPrototype__listenerGetCachedValue(JSC::EncodedJSValue thisValue) +{ + auto* thisObject = jsCast(JSValue::decode(thisValue)); + return JSValue::encode(thisObject->m_listener.get()); +} + +void JSFSWatcherPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject) +{ + Base::finishCreation(vm); + reifyStaticProperties(vm, JSFSWatcher::info(), JSFSWatcherPrototypeTableValues, *this); + JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); +} + +JSFSWatcher::~JSFSWatcher() +{ + if (m_ctx) { + FSWatcherClass__finalize(m_ctx); + } +} +void JSFSWatcher::destroy(JSCell* cell) +{ + static_cast(cell)->JSFSWatcher::~JSFSWatcher(); +} + +const ClassInfo JSFSWatcher::s_info = { "FSWatcher"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFSWatcher) }; + +void JSFSWatcher::finishCreation(VM& vm) +{ + Base::finishCreation(vm); + ASSERT(inherits(info())); +} + +JSFSWatcher* JSFSWatcher::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) +{ + JSFSWatcher* ptr = new (NotNull, JSC::allocateCell(vm)) JSFSWatcher(vm, structure, ctx); + ptr->finishCreation(vm); + return ptr; +} + +extern "C" void* FSWatcher__fromJS(JSC::EncodedJSValue value) +{ + JSC::JSValue decodedValue = JSC::JSValue::decode(value); + if (decodedValue.isEmpty() || !decodedValue.isCell()) + return nullptr; + + JSC::JSCell* cell = decodedValue.asCell(); + JSFSWatcher* object = JSC::jsDynamicCast(cell); + + if (!object) + return nullptr; + + return object->wrapped(); +} + +extern "C" bool FSWatcher__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) +{ + JSFSWatcher* object = JSC::jsDynamicCast(JSValue::decode(value)); + if (!object) + return false; + + object->m_ctx = ptr; + return true; +} + +extern "C" const size_t FSWatcher__ptrOffset = JSFSWatcher::offsetOfWrapped(); + +void JSFSWatcher::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) +{ + auto* thisObject = jsCast(cell); + if (void* wrapped = thisObject->wrapped()) { + // if (thisObject->scriptExecutionContext()) + // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); + } + Base::analyzeHeap(cell, analyzer); +} + +JSObject* JSFSWatcher::createPrototype(VM& vm, JSDOMGlobalObject* globalObject) +{ + return JSFSWatcherPrototype::create(vm, globalObject, JSFSWatcherPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); +} + +extern "C" EncodedJSValue FSWatcher__create(Zig::GlobalObject* globalObject, void* ptr) +{ + auto& vm = globalObject->vm(); + JSC::Structure* structure = globalObject->JSFSWatcherStructure(); + JSFSWatcher* instance = JSFSWatcher::create(vm, globalObject, structure, ptr); + + return JSValue::encode(instance); +} + +template +void JSFSWatcher::visitChildrenImpl(JSCell* cell, Visitor& visitor) +{ + JSFSWatcher* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + Base::visitChildren(thisObject, visitor); + visitor.append(thisObject->m_listener); +} + +DEFINE_VISIT_CHILDREN(JSFSWatcher); + +template +void JSFSWatcher::visitAdditionalChildren(Visitor& visitor) +{ + JSFSWatcher* thisObject = this; + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + visitor.append(thisObject->m_listener); +} + +DEFINE_VISIT_ADDITIONAL_CHILDREN(JSFSWatcher); + +template +void JSFSWatcher::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor) +{ + JSFSWatcher* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + thisObject->visitAdditionalChildren(visitor); +} + +DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSFSWatcher); class JSFileSystemRouterPrototype final : public JSC::JSNonFinalObject { public: using Base = JSC::JSNonFinalObject; @@ -7654,6 +7945,9 @@ JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__utimesCallback); extern "C" EncodedJSValue NodeJSFSPrototype__utimesSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__utimesSyncCallback); +extern "C" EncodedJSValue NodeJSFSPrototype__watch(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__watchCallback); + extern "C" EncodedJSValue NodeJSFSPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__writeCallback); @@ -7751,6 +8045,7 @@ static const HashTableValue JSNodeJSFSPrototypeTableValues[] = { { "unlinkSync"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__unlinkSyncCallback, 1 } }, { "utimes"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__utimesCallback, 4 } }, { "utimesSync"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__utimesSyncCallback, 3 } }, + { "watch"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__watchCallback, 3 } }, { "write"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeCallback, 6 } }, { "writeFile"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeFileCallback, 4 } }, { "writeFileSync"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeFileSyncCallback, 3 } }, @@ -9795,6 +10090,33 @@ JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__utimesSyncCallback, (JSGlobalObject return NodeJSFSPrototype__utimesSync(thisObject->wrapped(), lexicalGlobalObject, callFrame); } +JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__watchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSNodeJSFS* 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 NodeJSFSPrototype__watch(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { auto& vm = lexicalGlobalObject->vm(); diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h index 668cd3f6b..3fa0e26d2 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.h +++ b/src/bun.js/bindings/ZigGeneratedClasses.h @@ -578,6 +578,62 @@ public: mutable JSC::WriteBarrier m_testValue; }; +class JSFSWatcher final : public JSC::JSDestructibleObject { +public: + using Base = JSC::JSDestructibleObject; + static JSFSWatcher* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx); + + DECLARE_EXPORT_INFO; + 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_clientSubspaceForFSWatcher.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForFSWatcher = std::forward(space); }, + [](auto& spaces) { return spaces.m_subspaceForFSWatcher.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForFSWatcher = std::forward(space); }); + } + + static void destroy(JSC::JSCell*); + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast(0b11101110), StructureFlags), info()); + } + + static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject); + ; + + ~JSFSWatcher(); + + void* wrapped() const { return m_ctx; } + + void detach() + { + m_ctx = nullptr; + } + + static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSFSWatcher, m_ctx); } + + void* m_ctx { nullptr }; + + JSFSWatcher(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) + : Base(vm, structure) + { + m_ctx = sinkPtr; + } + + void finishCreation(JSC::VM&); + + DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; + + mutable JSC::WriteBarrier m_listener; +}; + class JSFileSystemRouter final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig index 0ec65a469..74e30cd83 100644 --- a/src/bun.js/bindings/generated_classes.zig +++ b/src/bun.js/bindings/generated_classes.zig @@ -1406,6 +1406,96 @@ pub const JSExpectStringMatching = struct { } } }; +pub const JSFSWatcher = struct { + const FSWatcher = Classes.FSWatcher; + const GetterType = fn (*FSWatcher, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue; + const GetterTypeWithThisValue = fn (*FSWatcher, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue; + const SetterType = fn (*FSWatcher, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool; + const SetterTypeWithThisValue = fn (*FSWatcher, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool; + const CallbackType = fn (*FSWatcher, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue; + + /// Return the pointer to the wrapped object. + /// If the object does not match the type, return null. + pub fn fromJS(value: JSC.JSValue) ?*FSWatcher { + JSC.markBinding(@src()); + return FSWatcher__fromJS(value); + } + + extern fn FSWatcherPrototype__listenerSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void; + + extern fn FSWatcherPrototype__listenerGetCachedValue(JSC.JSValue) JSC.JSValue; + + /// `FSWatcher.listener` setter + /// This value will be visited by the garbage collector. + pub fn listenerSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void { + JSC.markBinding(@src()); + FSWatcherPrototype__listenerSetCachedValue(thisValue, globalObject, value); + } + + /// `FSWatcher.listener` getter + /// This value will be visited by the garbage collector. + pub fn listenerGetCached(thisValue: JSC.JSValue) ?JSC.JSValue { + JSC.markBinding(@src()); + const result = FSWatcherPrototype__listenerGetCachedValue(thisValue); + if (result == .zero) + return null; + + return result; + } + + /// Create a new instance of FSWatcher + pub fn toJS(this: *FSWatcher, globalObject: *JSC.JSGlobalObject) JSC.JSValue { + JSC.markBinding(@src()); + if (comptime Environment.allow_assert) { + const value__ = FSWatcher__create(globalObject, this); + std.debug.assert(value__.as(FSWatcher).? == this); // If this fails, likely a C ABI issue. + return value__; + } else { + return FSWatcher__create(globalObject, this); + } + } + + /// Modify the internal ptr to point to a new instance of FSWatcher. + pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*FSWatcher) bool { + JSC.markBinding(@src()); + return FSWatcher__dangerouslySetPtr(value, ptr); + } + + /// Detach the ptr from the thisValue + pub fn detachPtr(_: *FSWatcher, value: JSC.JSValue) void { + JSC.markBinding(@src()); + std.debug.assert(FSWatcher__dangerouslySetPtr(value, null)); + } + + extern fn FSWatcher__fromJS(JSC.JSValue) ?*FSWatcher; + extern fn FSWatcher__getConstructor(*JSC.JSGlobalObject) JSC.JSValue; + + extern fn FSWatcher__create(globalObject: *JSC.JSGlobalObject, ptr: ?*FSWatcher) JSC.JSValue; + + extern fn FSWatcher__dangerouslySetPtr(JSC.JSValue, ?*FSWatcher) bool; + + comptime { + if (@TypeOf(FSWatcher.finalize) != (fn (*FSWatcher) callconv(.C) void)) { + @compileLog("FSWatcher.finalize is not a finalizer"); + } + + if (@TypeOf(FSWatcher.doClose) != CallbackType) + @compileLog("Expected FSWatcher.doClose to be a callback but received " ++ @typeName(@TypeOf(FSWatcher.doClose))); + if (@TypeOf(FSWatcher.hasRef) != CallbackType) + @compileLog("Expected FSWatcher.hasRef to be a callback but received " ++ @typeName(@TypeOf(FSWatcher.hasRef))); + if (@TypeOf(FSWatcher.doRef) != CallbackType) + @compileLog("Expected FSWatcher.doRef to be a callback but received " ++ @typeName(@TypeOf(FSWatcher.doRef))); + if (@TypeOf(FSWatcher.doUnref) != CallbackType) + @compileLog("Expected FSWatcher.doUnref to be a callback but received " ++ @typeName(@TypeOf(FSWatcher.doUnref))); + if (!JSC.is_bindgen) { + @export(FSWatcher.doClose, .{ .name = "FSWatcherPrototype__doClose" }); + @export(FSWatcher.doRef, .{ .name = "FSWatcherPrototype__doRef" }); + @export(FSWatcher.doUnref, .{ .name = "FSWatcherPrototype__doUnref" }); + @export(FSWatcher.finalize, .{ .name = "FSWatcherClass__finalize" }); + @export(FSWatcher.hasRef, .{ .name = "FSWatcherPrototype__hasRef" }); + } + } +}; pub const JSFileSystemRouter = struct { const FileSystemRouter = Classes.FileSystemRouter; const GetterType = fn (*FileSystemRouter, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue; @@ -2312,6 +2402,8 @@ pub const JSNodeJSFS = struct { @compileLog("Expected NodeJSFS.utimes to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.utimes))); if (@TypeOf(NodeJSFS.utimesSync) != CallbackType) @compileLog("Expected NodeJSFS.utimesSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.utimesSync))); + if (@TypeOf(NodeJSFS.watch) != CallbackType) + @compileLog("Expected NodeJSFS.watch to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.watch))); if (@TypeOf(NodeJSFS.write) != CallbackType) @compileLog("Expected NodeJSFS.write to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.write))); if (@TypeOf(NodeJSFS.writeFile) != CallbackType) @@ -2402,6 +2494,7 @@ pub const JSNodeJSFS = struct { @export(NodeJSFS.unlinkSync, .{ .name = "NodeJSFSPrototype__unlinkSync" }); @export(NodeJSFS.utimes, .{ .name = "NodeJSFSPrototype__utimes" }); @export(NodeJSFS.utimesSync, .{ .name = "NodeJSFSPrototype__utimesSync" }); + @export(NodeJSFS.watch, .{ .name = "NodeJSFSPrototype__watch" }); @export(NodeJSFS.write, .{ .name = "NodeJSFSPrototype__write" }); @export(NodeJSFS.writeFile, .{ .name = "NodeJSFSPrototype__writeFile" }); @export(NodeJSFS.writeFileSync, .{ .name = "NodeJSFSPrototype__writeFileSync" }); @@ -4855,6 +4948,7 @@ comptime { _ = JSExpectAnything; _ = JSExpectStringContaining; _ = JSExpectStringMatching; + _ = JSFSWatcher; _ = JSFileSystemRouter; _ = JSListener; _ = JSMD4; diff --git a/src/bun.js/bindings/generated_classes_list.zig b/src/bun.js/bindings/generated_classes_list.zig index c54965093..d90267337 100644 --- a/src/bun.js/bindings/generated_classes_list.zig +++ b/src/bun.js/bindings/generated_classes_list.zig @@ -37,4 +37,5 @@ pub const Classes = struct { pub const BuildArtifact = JSC.API.BuildArtifact; pub const BuildMessage = JSC.BuildMessage; pub const ResolveMessage = JSC.ResolveMessage; + pub const FSWatcher = JSC.Node.FSWatcher.JSObject; }; diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index 0a3459d64..a3ccd16ad 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -224,6 +224,7 @@ pub const CppTask = opaque { const ThreadSafeFunction = JSC.napi.ThreadSafeFunction; const MicrotaskForDefaultGlobalObject = JSC.MicrotaskForDefaultGlobalObject; const HotReloadTask = JSC.HotReloader.HotReloadTask; +const FSWatchTask = JSC.Node.FSWatcher.FSWatchTask; const PollPendingModulesTask = JSC.ModuleLoader.AsyncModule.Queue; // const PromiseTask = JSInternalPromise.Completion.PromiseTask; const GetAddrInfoRequestTask = JSC.DNS.GetAddrInfoRequest.Task; @@ -242,6 +243,7 @@ pub const Task = TaggedPointerUnion(.{ HotReloadTask, PollPendingModulesTask, GetAddrInfoRequestTask, + FSWatchTask, // PromiseTask, // TimeoutTasklet, }); @@ -467,6 +469,11 @@ pub const EventLoop = struct { // special case: we return return 0; }, + .FSWatchTask => { + var transform_task: *FSWatchTask = task.get(FSWatchTask).?; + transform_task.*.run(); + transform_task.deinit(); + }, @field(Task.Tag, typeBaseName(@typeName(AnyTask))) => { var any: *AnyTask = task.get(AnyTask).?; any.run(); diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index bebfbeb18..3baa25e22 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -2609,6 +2609,13 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime return this.tombstones.get(key); } + pub fn onError( + _: *@This(), + err: anyerror, + ) void { + Output.prettyErrorln("Watcher crashed: {s}", .{@errorName(err)}); + } + pub fn onFileUpdate( this: *@This(), events: []watcher.WatchEvent, diff --git a/src/bun.js/node/fs_events.zig b/src/bun.js/node/fs_events.zig new file mode 100644 index 000000000..a3fba5441 --- /dev/null +++ b/src/bun.js/node/fs_events.zig @@ -0,0 +1,609 @@ +const std = @import("std"); +const bun = @import("root").bun; +const Environment = bun.Environment; +const Mutex = @import("../../lock.zig").Lock; +const sync = @import("../../sync.zig"); +const Semaphore = sync.Semaphore; +const UnboundedQueue = @import("../unbounded_queue.zig").UnboundedQueue; +const TaggedPointerUnion = @import("../../tagged_pointer.zig").TaggedPointerUnion; +const string = bun.string; + +pub const CFAbsoluteTime = f64; +pub const CFTimeInterval = f64; +pub const CFArrayCallBacks = anyopaque; + +pub const FSEventStreamEventFlags = c_int; +pub const OSStatus = c_int; +pub const CFIndex = c_long; + +pub const FSEventStreamCreateFlags = u32; +pub const FSEventStreamEventId = u64; + +pub const CFStringEncoding = c_uint; + +pub const CFArrayRef = ?*anyopaque; +pub const CFAllocatorRef = ?*anyopaque; +pub const CFBundleRef = ?*anyopaque; +pub const CFDictionaryRef = ?*anyopaque; +pub const CFRunLoopRef = ?*anyopaque; +pub const CFRunLoopSourceRef = ?*anyopaque; +pub const CFStringRef = ?*anyopaque; +pub const CFTypeRef = ?*anyopaque; +pub const FSEventStreamRef = ?*anyopaque; +pub const FSEventStreamCallback = *const fn (FSEventStreamRef, ?*anyopaque, usize, ?*anyopaque, *FSEventStreamEventFlags, *FSEventStreamEventId) callconv(.C) void; + +// we only care about info and perform +pub const CFRunLoopSourceContext = extern struct { + version: CFIndex = 0, + info: *anyopaque, + retain: ?*anyopaque = null, + release: ?*anyopaque = null, + copyDescription: ?*anyopaque = null, + equal: ?*anyopaque = null, + hash: ?*anyopaque = null, + schedule: ?*anyopaque = null, + cancel: ?*anyopaque = null, + perform: *const fn (?*anyopaque) callconv(.C) void, +}; + +pub const FSEventStreamContext = extern struct { + version: CFIndex = 0, + info: ?*anyopaque = null, + pad: [3]?*anyopaque = .{ null, null, null }, +}; + +pub const kCFStringEncodingUTF8: CFStringEncoding = 0x8000100; +pub const noErr: OSStatus = 0; + +pub const kFSEventStreamCreateFlagNoDefer: c_int = 2; +pub const kFSEventStreamCreateFlagFileEvents: c_int = 16; + +pub const kFSEventStreamEventFlagEventIdsWrapped: c_int = 8; +pub const kFSEventStreamEventFlagHistoryDone: c_int = 16; +pub const kFSEventStreamEventFlagItemChangeOwner: c_int = 0x4000; +pub const kFSEventStreamEventFlagItemCreated: c_int = 0x100; +pub const kFSEventStreamEventFlagItemFinderInfoMod: c_int = 0x2000; +pub const kFSEventStreamEventFlagItemInodeMetaMod: c_int = 0x400; +pub const kFSEventStreamEventFlagItemIsDir: c_int = 0x20000; +pub const kFSEventStreamEventFlagItemModified: c_int = 0x1000; +pub const kFSEventStreamEventFlagItemRemoved: c_int = 0x200; +pub const kFSEventStreamEventFlagItemRenamed: c_int = 0x800; +pub const kFSEventStreamEventFlagItemXattrMod: c_int = 0x8000; +pub const kFSEventStreamEventFlagKernelDropped: c_int = 4; +pub const kFSEventStreamEventFlagMount: c_int = 64; +pub const kFSEventStreamEventFlagRootChanged: c_int = 32; +pub const kFSEventStreamEventFlagUnmount: c_int = 128; +pub const kFSEventStreamEventFlagUserDropped: c_int = 2; + +// Lazy function call binding. +const RTLD_LAZY = 0x1; +// Symbols exported from this image (dynamic library or bundle) +// are generally hidden and only availble to dlsym() when +// directly using the handle returned by this call to dlopen(). +const RTLD_LOCAL = 0x4; + +pub const kFSEventsModified: c_int = + kFSEventStreamEventFlagItemChangeOwner | + kFSEventStreamEventFlagItemFinderInfoMod | + kFSEventStreamEventFlagItemInodeMetaMod | + kFSEventStreamEventFlagItemModified | + kFSEventStreamEventFlagItemXattrMod; + +pub const kFSEventsRenamed: c_int = + kFSEventStreamEventFlagItemCreated | + kFSEventStreamEventFlagItemRemoved | + kFSEventStreamEventFlagItemRenamed; + +pub const kFSEventsSystem: c_int = + kFSEventStreamEventFlagUserDropped | + kFSEventStreamEventFlagKernelDropped | + kFSEventStreamEventFlagEventIdsWrapped | + kFSEventStreamEventFlagHistoryDone | + kFSEventStreamEventFlagMount | + kFSEventStreamEventFlagUnmount | + kFSEventStreamEventFlagRootChanged; + +var fsevents_mutex: Mutex = Mutex.init(); +var fsevents_default_loop_mutex: Mutex = Mutex.init(); +var fsevents_default_loop: ?*FSEventsLoop = null; + +fn dlsym(handle: ?*anyopaque, comptime Type: type, comptime symbol: [:0]const u8) ?Type { + if (std.c.dlsym(handle, symbol)) |ptr| { + return bun.cast(Type, ptr); + } + return null; +} + +pub const CoreFoundation = struct { + handle: ?*anyopaque, + ArrayCreate: *fn (CFAllocatorRef, [*]?*anyopaque, CFIndex, ?*CFArrayCallBacks) callconv(.C) CFArrayRef, + Release: *fn (CFTypeRef) callconv(.C) void, + + RunLoopAddSource: *fn (CFRunLoopRef, CFRunLoopSourceRef, CFStringRef) callconv(.C) void, + RunLoopGetCurrent: *fn () callconv(.C) CFRunLoopRef, + RunLoopRemoveSource: *fn (CFRunLoopRef, CFRunLoopSourceRef, CFStringRef) callconv(.C) void, + RunLoopRun: *fn () callconv(.C) void, + RunLoopSourceCreate: *fn (CFAllocatorRef, CFIndex, *CFRunLoopSourceContext) callconv(.C) CFRunLoopSourceRef, + RunLoopSourceSignal: *fn (CFRunLoopSourceRef) callconv(.C) void, + RunLoopStop: *fn (CFRunLoopRef) callconv(.C) void, + RunLoopWakeUp: *fn (CFRunLoopRef) callconv(.C) void, + StringCreateWithFileSystemRepresentation: *fn (CFAllocatorRef, [*]const u8) callconv(.C) CFStringRef, + RunLoopDefaultMode: *CFStringRef, + + pub fn get() CoreFoundation { + if (fsevents_cf) |cf| return cf; + fsevents_mutex.lock(); + defer fsevents_mutex.unlock(); + if (fsevents_cf) |cf| return cf; + + InitLibrary(); + + return fsevents_cf.?; + } + + // We Actually never deinit it + // pub fn deinit(this: *CoreFoundation) void { + // if(this.handle) | ptr| { + // this.handle = null; + // _ = std.c.dlclose(this.handle); + // } + // } + +}; + +pub const CoreServices = struct { + handle: ?*anyopaque, + FSEventStreamCreate: *fn (CFAllocatorRef, FSEventStreamCallback, *FSEventStreamContext, CFArrayRef, FSEventStreamEventId, CFTimeInterval, FSEventStreamCreateFlags) callconv(.C) FSEventStreamRef, + FSEventStreamInvalidate: *fn (FSEventStreamRef) callconv(.C) void, + FSEventStreamRelease: *fn (FSEventStreamRef) callconv(.C) void, + FSEventStreamScheduleWithRunLoop: *fn (FSEventStreamRef, CFRunLoopRef, CFStringRef) callconv(.C) void, + FSEventStreamStart: *fn (FSEventStreamRef) callconv(.C) c_int, + FSEventStreamStop: *fn (FSEventStreamRef) callconv(.C) void, + // libuv set it to -1 so the actual value is this + kFSEventStreamEventIdSinceNow: FSEventStreamEventId = 18446744073709551615, + + pub fn get() CoreServices { + if (fsevents_cs) |cs| return cs; + fsevents_mutex.lock(); + defer fsevents_mutex.unlock(); + if (fsevents_cs) |cs| return cs; + + InitLibrary(); + + return fsevents_cs.?; + } + + // We Actually never deinit it + // pub fn deinit(this: *CoreServices) void { + // if(this.handle) | ptr| { + // this.handle = null; + // _ = std.c.dlclose(this.handle); + // } + // } + +}; + +var fsevents_cf: ?CoreFoundation = null; +var fsevents_cs: ?CoreServices = null; + +fn InitLibrary() void { + const fsevents_cf_handle = std.c.dlopen("/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation", RTLD_LAZY | RTLD_LOCAL); + if (fsevents_cf_handle == null) @panic("Cannot Load CoreFoundation"); + + fsevents_cf = CoreFoundation{ + .handle = fsevents_cf_handle, + .ArrayCreate = dlsym(fsevents_cf_handle, *fn (CFAllocatorRef, [*]?*anyopaque, CFIndex, ?*CFArrayCallBacks) callconv(.C) CFArrayRef, "CFArrayCreate") orelse @panic("Cannot Load CoreFoundation"), + .Release = dlsym(fsevents_cf_handle, *fn (CFTypeRef) callconv(.C) void, "CFRelease") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopAddSource = dlsym(fsevents_cf_handle, *fn (CFRunLoopRef, CFRunLoopSourceRef, CFStringRef) callconv(.C) void, "CFRunLoopAddSource") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopGetCurrent = dlsym(fsevents_cf_handle, *fn () callconv(.C) CFRunLoopRef, "CFRunLoopGetCurrent") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopRemoveSource = dlsym(fsevents_cf_handle, *fn (CFRunLoopRef, CFRunLoopSourceRef, CFStringRef) callconv(.C) void, "CFRunLoopRemoveSource") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopRun = dlsym(fsevents_cf_handle, *fn () callconv(.C) void, "CFRunLoopRun") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopSourceCreate = dlsym(fsevents_cf_handle, *fn (CFAllocatorRef, CFIndex, *CFRunLoopSourceContext) callconv(.C) CFRunLoopSourceRef, "CFRunLoopSourceCreate") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopSourceSignal = dlsym(fsevents_cf_handle, *fn (CFRunLoopSourceRef) callconv(.C) void, "CFRunLoopSourceSignal") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopStop = dlsym(fsevents_cf_handle, *fn (CFRunLoopRef) callconv(.C) void, "CFRunLoopStop") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopWakeUp = dlsym(fsevents_cf_handle, *fn (CFRunLoopRef) callconv(.C) void, "CFRunLoopWakeUp") orelse @panic("Cannot Load CoreFoundation"), + .StringCreateWithFileSystemRepresentation = dlsym(fsevents_cf_handle, *fn (CFAllocatorRef, [*]const u8) callconv(.C) CFStringRef, "CFStringCreateWithFileSystemRepresentation") orelse @panic("Cannot Load CoreFoundation"), + .RunLoopDefaultMode = dlsym(fsevents_cf_handle, *CFStringRef, "kCFRunLoopDefaultMode") orelse @panic("Cannot Load CoreFoundation"), + }; + + const fsevents_cs_handle = std.c.dlopen("/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices", RTLD_LAZY | RTLD_LOCAL); + if (fsevents_cs_handle == null) @panic("Cannot Load CoreServices"); + + fsevents_cs = CoreServices{ + .handle = fsevents_cs_handle, + .FSEventStreamCreate = dlsym(fsevents_cs_handle, *fn (CFAllocatorRef, FSEventStreamCallback, *FSEventStreamContext, CFArrayRef, FSEventStreamEventId, CFTimeInterval, FSEventStreamCreateFlags) callconv(.C) FSEventStreamRef, "FSEventStreamCreate") orelse @panic("Cannot Load CoreServices"), + .FSEventStreamInvalidate = dlsym(fsevents_cs_handle, *fn (FSEventStreamRef) callconv(.C) void, "FSEventStreamInvalidate") orelse @panic("Cannot Load CoreServices"), + .FSEventStreamRelease = dlsym(fsevents_cs_handle, *fn (FSEventStreamRef) callconv(.C) void, "FSEventStreamRelease") orelse @panic("Cannot Load CoreServices"), + .FSEventStreamScheduleWithRunLoop = dlsym(fsevents_cs_handle, *fn (FSEventStreamRef, CFRunLoopRef, CFStringRef) callconv(.C) void, "FSEventStreamScheduleWithRunLoop") orelse @panic("Cannot Load CoreServices"), + .FSEventStreamStart = dlsym(fsevents_cs_handle, *fn (FSEventStreamRef) callconv(.C) c_int, "FSEventStreamStart") orelse @panic("Cannot Load CoreServices"), + .FSEventStreamStop = dlsym(fsevents_cs_handle, *fn (FSEventStreamRef) callconv(.C) void, "FSEventStreamStop") orelse @panic("Cannot Load CoreServices"), + }; +} + +pub const FSEventsLoop = struct { + signal_source: CFRunLoopSourceRef, + mutex: Mutex, + loop: CFRunLoopRef = null, + sem: Semaphore, + thread: std.Thread = undefined, + tasks: ConcurrentTask.Queue = ConcurrentTask.Queue{}, + watchers: bun.BabyList(?*FSEventsWatcher) = .{}, + watcher_count: u32 = 0, + fsevent_stream: FSEventStreamRef = null, + paths: ?[]?*anyopaque = null, + cf_paths: CFArrayRef = null, + has_scheduled_watchers: bool = false, + + pub const Task = struct { + ctx: ?*anyopaque, + callback: *const (fn (*anyopaque) void), + + pub fn run(this: *Task) void { + var callback = this.callback; + var ctx = this.ctx; + callback(ctx.?); + } + + pub fn New(comptime Type: type, comptime Callback: anytype) type { + return struct { + pub fn init(ctx: *Type) Task { + return Task{ + .callback = wrap, + .ctx = ctx, + }; + } + + pub fn wrap(this: ?*anyopaque) void { + @call(.always_inline, Callback, .{@ptrCast(*Type, @alignCast(@alignOf(Type), this.?))}); + } + }; + } + }; + + pub const ConcurrentTask = struct { + task: Task = undefined, + next: ?*ConcurrentTask = null, + auto_delete: bool = false, + + pub const Queue = UnboundedQueue(ConcurrentTask, .next); + + pub fn from(this: *ConcurrentTask, task: Task) *ConcurrentTask { + this.* = .{ + .task = task, + .next = null, + }; + return this; + } + }; + + pub fn CFThreadLoop(this: *FSEventsLoop) void { + bun.Output.Source.configureNamedThread("CFThreadLoop"); + + const CF = CoreFoundation.get(); + + this.loop = CF.RunLoopGetCurrent(); + + CF.RunLoopAddSource(this.loop, this.signal_source, CF.RunLoopDefaultMode.*); + + this.sem.post(); + + CF.RunLoopRun(); + CF.RunLoopRemoveSource(this.loop, this.signal_source, CF.RunLoopDefaultMode.*); + + this.loop = null; + } + + // Runs in CF thread, executed after `enqueueTaskConcurrent()` + fn CFLoopCallback(arg: ?*anyopaque) callconv(.C) void { + if (arg) |self| { + const this = bun.cast(*FSEventsLoop, self); + + var concurrent = this.tasks.popBatch(); + const count = concurrent.count; + if (count == 0) + return; + + var iter = concurrent.iterator(); + while (iter.next()) |task| { + task.task.run(); + if (task.auto_delete) bun.default_allocator.destroy(task); + } + } + } + + pub fn init() !*FSEventsLoop { + const this = bun.default_allocator.create(FSEventsLoop) catch unreachable; + + const CF = CoreFoundation.get(); + + var ctx = CFRunLoopSourceContext{ + .info = this, + .perform = CFLoopCallback, + }; + + const signal_source = CF.RunLoopSourceCreate(null, 0, &ctx); + if (signal_source == null) { + return error.FailedToCreateCoreFoudationSourceLoop; + } + + var fs_loop = FSEventsLoop{ .sem = Semaphore.init(0), .mutex = Mutex.init(), .signal_source = signal_source }; + + this.* = fs_loop; + this.thread = try std.Thread.spawn(.{}, FSEventsLoop.CFThreadLoop, .{this}); + + // sync threads + this.sem.wait(); + return this; + } + + fn enqueueTaskConcurrent(this: *FSEventsLoop, task: Task) void { + const CF = CoreFoundation.get(); + var concurrent = bun.default_allocator.create(ConcurrentTask) catch unreachable; + concurrent.auto_delete = true; + this.tasks.push(concurrent.from(task)); + CF.RunLoopSourceSignal(this.signal_source); + CF.RunLoopWakeUp(this.loop); + } + + // Runs in CF thread, when there're events in FSEventStream + fn _events_cb(_: FSEventStreamRef, info: ?*anyopaque, numEvents: usize, eventPaths: ?*anyopaque, eventFlags: *FSEventStreamEventFlags, _: *FSEventStreamEventId) callconv(.C) void { + const paths_ptr = bun.cast([*][*:0]const u8, eventPaths); + const paths = paths_ptr[0..numEvents]; + var loop = bun.cast(*FSEventsLoop, info); + const event_flags = bun.cast([*]FSEventStreamEventFlags, eventFlags); + + for (loop.watchers.slice()) |watcher| { + if (watcher) |handle| { + for (paths, 0..) |path_ptr, i| { + var flags = event_flags[i]; + var path = path_ptr[0..bun.len(path_ptr)]; + // Filter out paths that are outside handle's request + if (path.len < handle.path.len or !bun.strings.startsWith(path, handle.path)) { + continue; + } + const is_file = (flags & kFSEventStreamEventFlagItemIsDir) == 0; + + // Remove common prefix, unless the watched folder is "/" + if (!(handle.path.len == 1 and handle.path[0] == '/')) { + path = path[handle.path.len..]; + + // Ignore events with path equal to directory itself + if (path.len <= 1 and is_file) { + continue; + } + if (path.len == 0) { + // Since we're using fsevents to watch the file itself, path == handle.path, and we now need to get the basename of the file back + while (path.len > 0) { + if (bun.strings.startsWithChar(path, '/')) { + path = path[1..]; + break; + } else { + path = path[1..]; + } + } + + // Created and Removed seem to be always set, but don't make sense + flags &= ~kFSEventsRenamed; + } else { + // Skip forward slash + path = path[1..]; + } + } + + // Do not emit events from subdirectories (without option set) + if (path.len == 0 or (bun.strings.containsChar(path, '/') and !handle.recursive)) { + continue; + } + + var is_rename = true; + + if ((flags & kFSEventsRenamed) == 0) { + if ((flags & kFSEventsModified) != 0 or is_file) { + is_rename = false; + } + } + + handle.callback(handle.ctx, path, is_file, is_rename); + } + } + } + } + + // Runs on CF Thread + pub fn _schedule(this: *FSEventsLoop) void { + this.mutex.lock(); + defer this.mutex.unlock(); + this.has_scheduled_watchers = false; + + var watchers = this.watchers.slice(); + + const CF = CoreFoundation.get(); + const CS = CoreServices.get(); + + if (this.fsevent_stream) |stream| { + // Stop emitting events + CS.FSEventStreamStop(stream); + + // Release stream + CS.FSEventStreamInvalidate(stream); + CS.FSEventStreamRelease(stream); + this.fsevent_stream = null; + } + // clean old paths + if (this.paths) |p| { + this.paths = null; + bun.default_allocator.destroy(p); + } + if (this.cf_paths) |cf| { + this.cf_paths = null; + CF.Release(cf); + } + + const paths = bun.default_allocator.alloc(?*anyopaque, this.watcher_count) catch unreachable; + var count: u32 = 0; + for (watchers) |w| { + if (w) |watcher| { + const path = CF.StringCreateWithFileSystemRepresentation(null, watcher.path.ptr); + paths[count] = path; + count += 1; + } + } + + const cf_paths = CF.ArrayCreate(null, paths.ptr, count, null); + var ctx: FSEventStreamContext = .{ + .info = this, + }; + + const latency: CFAbsoluteTime = 0.05; + // Explanation of selected flags: + // 1. NoDefer - without this flag, events that are happening continuously + // (i.e. each event is happening after time interval less than `latency`, + // counted from previous event), will be deferred and passed to callback + // once they'll either fill whole OS buffer, or when this continuous stream + // will stop (i.e. there'll be delay between events, bigger than + // `latency`). + // Specifying this flag will invoke callback after `latency` time passed + // since event. + // 2. FileEvents - fire callback for file changes too (by default it is firing + // it only for directory changes). + // + const flags: FSEventStreamCreateFlags = kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagFileEvents; + + // + // NOTE: It might sound like a good idea to remember last seen StreamEventId, + // but in reality one dir might have last StreamEventId less than, the other, + // that is being watched now. Which will cause FSEventStream API to report + // changes to files from the past. + // + const ref = CS.FSEventStreamCreate(null, _events_cb, &ctx, cf_paths, CS.kFSEventStreamEventIdSinceNow, latency, flags); + + CS.FSEventStreamScheduleWithRunLoop(ref, this.loop, CF.RunLoopDefaultMode.*); + if (CS.FSEventStreamStart(ref) == 0) { + //clean in case of failure + bun.default_allocator.destroy(paths); + CF.Release(cf_paths); + CS.FSEventStreamInvalidate(ref); + CS.FSEventStreamRelease(ref); + return; + } + this.fsevent_stream = ref; + this.paths = paths; + this.cf_paths = cf_paths; + } + + fn registerWatcher(this: *FSEventsLoop, watcher: *FSEventsWatcher) void { + this.mutex.lock(); + defer this.mutex.unlock(); + if (this.watcher_count == this.watchers.len) { + this.watcher_count += 1; + this.watchers.push(bun.default_allocator, watcher) catch unreachable; + } else { + var watchers = this.watchers.slice(); + for (watchers, 0..) |w, i| { + if (w == null) { + watchers[i] = watcher; + this.watcher_count += 1; + break; + } + } + } + + if (this.has_scheduled_watchers == false) { + this.has_scheduled_watchers = true; + this.enqueueTaskConcurrent(Task.New(FSEventsLoop, _schedule).init(this)); + } + } + + fn unregisterWatcher(this: *FSEventsLoop, watcher: *FSEventsWatcher) void { + this.mutex.lock(); + defer this.mutex.unlock(); + var watchers = this.watchers.slice(); + for (watchers, 0..) |w, i| { + if (w) |item| { + if (item == watcher) { + watchers[i] = null; + // if is the last one just pop + if (i == watchers.len - 1) { + this.watchers.len -= 1; + } + this.watcher_count -= 1; + break; + } + } + } + } + + // Runs on CF loop to close the loop + fn _stop(this: *FSEventsLoop) void { + const CF = CoreFoundation.get(); + CF.RunLoopStop(this.loop); + } + fn deinit(this: *FSEventsLoop) void { + // signal close and wait + this.enqueueTaskConcurrent(Task.New(FSEventsLoop, FSEventsLoop._stop).init(this)); + this.thread.join(); + const CF = CoreFoundation.get(); + + CF.Release(this.signal_source); + this.signal_source = null; + + this.sem.deinit(); + this.mutex.deinit(); + if (this.watcher_count > 0) { + while (this.watchers.popOrNull()) |watcher| { + if (watcher) |w| { + // unlink watcher + w.loop = null; + } + } + } + + this.watchers.deinitWithAllocator(bun.default_allocator); + + bun.default_allocator.destroy(this); + } +}; + +pub const FSEventsWatcher = struct { + path: string, + callback: Callback, + loop: ?*FSEventsLoop, + recursive: bool, + ctx: ?*anyopaque, + + const Callback = *const fn (ctx: ?*anyopaque, path: string, is_file: bool, is_rename: bool) void; + + pub fn init(loop: *FSEventsLoop, path: string, recursive: bool, callback: Callback, ctx: ?*anyopaque) *FSEventsWatcher { + var this = bun.default_allocator.create(FSEventsWatcher) catch unreachable; + this.* = FSEventsWatcher{ + .path = path, + .callback = callback, + .loop = loop, + .recursive = recursive, + .ctx = ctx, + }; + + loop.registerWatcher(this); + return this; + } + + pub fn deinit(this: *FSEventsWatcher) void { + if (this.loop) |loop| { + loop.unregisterWatcher(this); + } + bun.default_allocator.destroy(this); + } +}; + +pub fn watch(path: string, recursive: bool, callback: FSEventsWatcher.Callback, ctx: ?*anyopaque) !*FSEventsWatcher { + if (fsevents_default_loop) |loop| { + return FSEventsWatcher.init(loop, path, recursive, callback, ctx); + } else { + fsevents_default_loop_mutex.lock(); + defer fsevents_default_loop_mutex.unlock(); + if (fsevents_default_loop == null) { + fsevents_default_loop = try FSEventsLoop.init(); + } + return FSEventsWatcher.init(fsevents_default_loop.?, path, recursive, callback, ctx); + } +} diff --git a/src/bun.js/node/node.classes.ts b/src/bun.js/node/node.classes.ts index f984077e4..ce35c940a 100644 --- a/src/bun.js/node/node.classes.ts +++ b/src/bun.js/node/node.classes.ts @@ -1,6 +1,34 @@ import { define } from "../scripts/class-definitions"; export default [ + define({ + name: "FSWatcher", + construct: false, + noConstructor: true, + finalize: true, + configurable: false, + klass: {}, + JSType: "0b11101110", + proto: { + ref: { + fn: "doRef", + length: 0, + }, + unref: { + fn: "doUnref", + length: 0, + }, + hasRef: { + fn: "hasRef", + length: 0, + }, + close: { + fn: "doClose", + length: 0, + }, + }, + values: ["listener"], + }), define({ name: "Timeout", construct: false, @@ -300,7 +328,7 @@ export default [ utimes: { fn: "utimes", length: 4 }, utimesSync: { fn: "utimesSync", length: 3 }, // TODO: - // watch: { fn: "watch", length: 3 }, + watch: { fn: "watch", length: 3 }, // watchFile: { fn: "watchFile", length: 3 }, writeFile: { fn: "writeFile", length: 4 }, writeFileSync: { fn: "writeFileSync", length: 3 }, diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 3ea0822e6..21a65251a 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -34,7 +34,6 @@ const Mode = JSC.Node.Mode; const uid_t = std.os.uid_t; const gid_t = std.os.gid_t; - /// u63 to allow one null bit const ReadPosition = u63; @@ -2313,7 +2312,7 @@ pub const Arguments = struct { }; pub const UnwatchFile = void; - pub const Watch = void; + pub const Watch = JSC.Node.FSWatcher.Arguments; pub const WatchFile = void; pub const Fsync = struct { fd: FileDescriptor, @@ -2475,7 +2474,7 @@ const Return = struct { pub const Truncate = void; pub const Unlink = void; pub const UnwatchFile = void; - pub const Watch = void; + pub const Watch = JSC.JSValue; pub const WatchFile = void; pub const Utimes = void; @@ -4181,8 +4180,12 @@ pub const NodeFS = struct { return Maybe(Return.Lutimes).todo; } - pub fn watch(_: *NodeFS, _: Arguments.Watch, comptime _: Flavor) Maybe(Return.Watch) { - return Maybe(Return.Watch).todo; + pub fn watch(_: *NodeFS, args: Arguments.Watch, comptime _: Flavor) Maybe(Return.Watch) { + const watcher = args.createFSWatcher() catch |err| { + args.global_this.throwError(err, "Failed to watch filename"); + return Maybe(Return.Watch){ .result = JSC.JSValue.jsUndefined() }; + }; + return Maybe(Return.Watch){ .result = watcher }; } pub fn createReadStream(_: *NodeFS, _: Arguments.CreateReadStream, comptime _: Flavor) Maybe(Return.CreateReadStream) { return Maybe(Return.CreateReadStream).todo; diff --git a/src/bun.js/node/node_fs_binding.zig b/src/bun.js/node/node_fs_binding.zig index 74b769bf6..f178f0355 100644 --- a/src/bun.js/node/node_fs_binding.zig +++ b/src/bun.js/node/node_fs_binding.zig @@ -241,6 +241,8 @@ pub const NodeJSFS = struct { return JSC.Node.Stats.getConstructor(globalThis); } + pub const watch = callSync(.watch); + // Not implemented yet: const notimpl = fdatasync; pub const opendir = notimpl; diff --git a/src/bun.js/node/node_fs_watcher.zig b/src/bun.js/node/node_fs_watcher.zig new file mode 100644 index 000000000..397d51916 --- /dev/null +++ b/src/bun.js/node/node_fs_watcher.zig @@ -0,0 +1,913 @@ +const std = @import("std"); +const JSC = @import("root").bun.JSC; +const bun = @import("root").bun; +const Fs = @import("../../fs.zig"); +const Path = @import("../../resolver/resolve_path.zig"); +const Encoder = JSC.WebCore.Encoder; + +const FSEvents = @import("./fs_events.zig"); + +const VirtualMachine = JSC.VirtualMachine; +const EventLoop = JSC.EventLoop; +const PathLike = JSC.Node.PathLike; +const ArgumentsSlice = JSC.Node.ArgumentsSlice; +const Output = bun.Output; +const string = bun.string; +const StoredFileDescriptorType = bun.StoredFileDescriptorType; +const Environment = bun.Environment; + +pub const FSWatcher = struct { + const watcher = @import("../../watcher.zig"); + const options = @import("../../options.zig"); + pub const Watcher = watcher.NewWatcher(*FSWatcher); + const log = Output.scoped(.FSWatcher, false); + + pub const ChangeEvent = struct { + hash: Watcher.HashType = 0, + event_type: FSWatchTask.EventType = .change, + time_stamp: i64 = 0, + }; + + onAccept: std.ArrayHashMapUnmanaged(FSWatcher.Watcher.HashType, bun.BabyList(OnAcceptCallback), bun.ArrayIdentityContext, false) = .{}, + ctx: *VirtualMachine, + js_watcher: ?*JSObject = null, + watcher_instance: ?*FSWatcher.Watcher = null, + verbose: bool = false, + file_paths: bun.BabyList(string) = .{}, + entry_path: ?string = null, + entry_dir: string = "", + last_change_event: ChangeEvent = .{}, + + pub fn toJS(this: *FSWatcher) JSC.JSValue { + return if (this.js_watcher) |js| js.js_this else JSC.JSValue.jsUndefined(); + } + + pub fn eventLoop(this: FSWatcher) *EventLoop { + return this.ctx.eventLoop(); + } + + pub fn enqueueTaskConcurrent(this: FSWatcher, task: *JSC.ConcurrentTask) void { + this.eventLoop().enqueueTaskConcurrent(task); + } + + pub fn deinit(this: *FSWatcher) void { + while (this.file_paths.popOrNull()) |file_path| { + bun.default_allocator.destroy(file_path); + } + this.file_paths.deinitWithAllocator(bun.default_allocator); + if (this.entry_path) |path| { + this.entry_path = null; + bun.default_allocator.destroy(path); + } + bun.default_allocator.destroy(this); + } + + pub const FSWatchTask = struct { + ctx: *FSWatcher, + count: u8 = 0, + + entries: [8]Entry = undefined, + concurrent_task: JSC.ConcurrentTask = undefined, + + pub const EventType = enum { + rename, + change, + @"error", + abort, + }; + + pub const EventFreeType = enum { + destroy, + free, + none, + }; + + pub const Entry = struct { + file_path: string, + event_type: EventType, + free_type: EventFreeType, + }; + + pub fn append(this: *FSWatchTask, file_path: string, event_type: EventType, free_type: EventFreeType) void { + if (this.count == 8) { + this.enqueue(); + var ctx = this.ctx; + this.* = .{ + .ctx = ctx, + .count = 0, + }; + } + + this.entries[this.count] = .{ + .file_path = file_path, + .event_type = event_type, + .free_type = free_type, + }; + this.count += 1; + } + + pub fn run(this: *FSWatchTask) void { + // this runs on JS Context + if (this.ctx.js_watcher) |js_watcher| { + for (this.entries[0..this.count]) |entry| { + switch (entry.event_type) { + .rename => { + js_watcher.emit(entry.file_path, "rename"); + }, + .change => { + js_watcher.emit(entry.file_path, "change"); + }, + .@"error" => { + // file_path is the error message in this case + js_watcher.emitError(entry.file_path); + }, + .abort => { + js_watcher.emitIfAborted(); + }, + } + } + } + } + + pub fn enqueue(this: *FSWatchTask) void { + if (this.count == 0) + return; + + var that = bun.default_allocator.create(FSWatchTask) catch unreachable; + + that.* = this.*; + this.count = 0; + that.concurrent_task.task = JSC.Task.init(that); + this.ctx.enqueueTaskConcurrent(&that.concurrent_task); + } + + pub fn deinit(this: *FSWatchTask) void { + while (this.count > 0) { + this.count -= 1; + switch (this.entries[this.count].free_type) { + .destroy => bun.default_allocator.destroy(this.entries[this.count].file_path), + .free => bun.default_allocator.free(this.entries[this.count].file_path), + else => {}, + } + } + bun.default_allocator.destroy(this); + } + }; + + fn NewCallback(comptime FunctionSignature: type) type { + return union(enum) { + javascript_callback: JSC.Strong, + zig_callback: struct { + ptr: *anyopaque, + function: *const FunctionSignature, + }, + }; + } + + pub const OnAcceptCallback = NewCallback(fn ( + vm: *JSC.VirtualMachine, + specifier: []const u8, + ) void); + + fn addDirectory(ctx: *FSWatcher, fs_watcher: *FSWatcher.Watcher, fd: StoredFileDescriptorType, file_path: string, recursive: bool, buf: *[bun.MAX_PATH_BYTES + 1]u8, is_entry_path: bool) !void { + var dir_path_clone = bun.default_allocator.dupeZ(u8, file_path) catch unreachable; + + if (is_entry_path) { + ctx.entry_path = dir_path_clone; + ctx.entry_dir = dir_path_clone; + } else { + ctx.file_paths.push(bun.default_allocator, dir_path_clone) catch unreachable; + } + fs_watcher.addDirectory(fd, dir_path_clone, FSWatcher.Watcher.getHash(file_path), false) catch |err| { + ctx.deinit(); + fs_watcher.deinit(true); + return err; + }; + + var iter = (std.fs.IterableDir{ .dir = std.fs.Dir{ + .fd = fd, + } }).iterate(); + + while (iter.next() catch |err| { + ctx.deinit(); + fs_watcher.deinit(true); + return err; + }) |entry| { + var parts = [2]string{ dir_path_clone, entry.name }; + var entry_path = Path.joinAbsStringBuf( + Fs.FileSystem.instance.topLevelDirWithoutTrailingSlash(), + buf, + &parts, + .auto, + ); + + buf[entry_path.len] = 0; + var entry_path_z = buf[0..entry_path.len :0]; + + var fs_info = fdFromAbsolutePathZ(entry_path_z) catch |err| { + ctx.deinit(); + fs_watcher.deinit(true); + return err; + }; + + if (fs_info.is_file) { + const file_path_clone = bun.default_allocator.dupeZ(u8, entry_path) catch unreachable; + + ctx.file_paths.push(bun.default_allocator, file_path_clone) catch unreachable; + + fs_watcher.addFile(fs_info.fd, file_path_clone, FSWatcher.Watcher.getHash(entry_path), options.Loader.file, 0, null, false) catch |err| { + ctx.deinit(); + fs_watcher.deinit(true); + return err; + }; + } else { + if (recursive) { + addDirectory(ctx, fs_watcher, fs_info.fd, entry_path, recursive, buf, false) catch |err| { + ctx.deinit(); + fs_watcher.deinit(true); + return err; + }; + } + } + } + } + + pub fn onError( + this: *FSWatcher, + err: anyerror, + ) void { + var current_task: FSWatchTask = .{ + .ctx = this, + }; + current_task.append(@errorName(err), .@"error", .none); + current_task.enqueue(); + } + + pub fn onFSEventUpdate( + ctx: ?*anyopaque, + path: string, + _: bool, + is_rename: bool, + ) void { + const this = bun.cast(*FSWatcher, ctx.?); + + var current_task: FSWatchTask = .{ + .ctx = this, + }; + defer current_task.enqueue(); + + const relative_path = bun.default_allocator.dupe(u8, path) catch unreachable; + const event_type: FSWatchTask.EventType = if (is_rename) .rename else .change; + + current_task.append(relative_path, event_type, .destroy); + } + + pub fn onFileUpdate( + this: *FSWatcher, + events: []watcher.WatchEvent, + changed_files: []?[:0]u8, + watchlist: watcher.Watchlist, + ) void { + var slice = watchlist.slice(); + const file_paths = slice.items(.file_path); + + var counts = slice.items(.count); + const kinds = slice.items(.kind); + var _on_file_update_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + + var ctx = this.watcher_instance.?; + defer ctx.flushEvictions(); + defer Output.flush(); + + var bundler = if (@TypeOf(this.ctx.bundler) == *bun.Bundler) + this.ctx.bundler + else + &this.ctx.bundler; + + var fs: *Fs.FileSystem = bundler.fs; + + var current_task: FSWatchTask = .{ + .ctx = this, + }; + defer current_task.enqueue(); + + const time_stamp = std.time.milliTimestamp(); + const time_diff = time_stamp - this.last_change_event.time_stamp; + + for (events) |event| { + const file_path = file_paths[event.index]; + const update_count = counts[event.index] + 1; + counts[event.index] = update_count; + const kind = kinds[event.index]; + + if (comptime Environment.isDebug) { + if (this.verbose) { + Output.prettyErrorln("[watch] {s} ({s}, {})", .{ file_path, @tagName(kind), event.op }); + } + } + + switch (kind) { + .file => { + if (event.op.delete) { + ctx.removeAtIndex( + event.index, + 0, + &.{}, + .file, + ); + } + + var file_hash: FSWatcher.Watcher.HashType = FSWatcher.Watcher.getHash(file_path); + + if (event.op.write or event.op.delete or event.op.rename) { + const event_type: FSWatchTask.EventType = if (event.op.delete or event.op.rename or event.op.move_to) .rename else .change; + // skip consecutive duplicates + if ((this.last_change_event.time_stamp == 0 or time_diff > 1) or this.last_change_event.event_type != event_type and this.last_change_event.hash != file_hash) { + this.last_change_event.time_stamp = time_stamp; + this.last_change_event.event_type = event_type; + this.last_change_event.hash = file_hash; + + const relative_slice = fs.relative(this.entry_dir, file_path); + + if (this.verbose) + Output.prettyErrorln("File changed: {s}", .{relative_slice}); + + const relative_path = bun.default_allocator.dupe(u8, relative_slice) catch unreachable; + + current_task.append(relative_path, event_type, .destroy); + } + } + }, + .directory => { + // macOS should use FSEvents for directories + if (comptime Environment.isMac) { + @panic("Unexpected directory watch"); + } + + const affected = event.names(changed_files); + + for (affected) |changed_name_| { + const changed_name: []const u8 = bun.asByteSlice(changed_name_.?); + if (changed_name.len == 0 or changed_name[0] == '~' or changed_name[0] == '.') continue; + + var file_hash: FSWatcher.Watcher.HashType = 0; + const relative_slice: string = brk: { + var file_path_without_trailing_slash = std.mem.trimRight(u8, file_path, std.fs.path.sep_str); + + @memcpy(_on_file_update_path_buf[0..file_path_without_trailing_slash.len], file_path_without_trailing_slash); + + _on_file_update_path_buf[file_path_without_trailing_slash.len] = std.fs.path.sep; + + @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len + 1 ..][0..changed_name.len], changed_name); + const path_slice = _on_file_update_path_buf[0 .. file_path_without_trailing_slash.len + changed_name.len + 1]; + file_hash = FSWatcher.Watcher.getHash(path_slice); + + const relative = fs.relative(this.entry_dir, path_slice); + + break :brk relative; + }; + + // skip consecutive duplicates + const event_type: FSWatchTask.EventType = .rename; // renaming folders, creating folder or files will be always be rename + if ((this.last_change_event.time_stamp == 0 or time_diff > 1) or this.last_change_event.event_type != event_type and this.last_change_event.hash != file_hash) { + const relative_path = bun.default_allocator.dupe(u8, relative_slice) catch unreachable; + + this.last_change_event.time_stamp = time_stamp; + this.last_change_event.event_type = event_type; + this.last_change_event.hash = file_hash; + + current_task.append(relative_path, event_type, .destroy); + + if (this.verbose) + Output.prettyErrorln(" Dir change: {s}", .{relative_path}); + } + } + + if (this.verbose and affected.len == 0) { + Output.prettyErrorln(" Dir change: {s}", .{fs.relative(this.entry_dir, file_path)}); + } + }, + } + } + } + + pub const Arguments = struct { + path: PathLike, + listener: JSC.JSValue, + global_this: JSC.C.JSContextRef, + signal: ?*JSC.AbortSignal, + persistent: bool, + recursive: bool, + encoding: JSC.Node.Encoding, + verbose: bool, + pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Arguments { + const vm = ctx.vm(); + const path = PathLike.fromJS(ctx, arguments, exception) orelse { + if (exception.* == null) { + JSC.throwInvalidArguments( + "filename must be a string or TypedArray", + .{}, + ctx, + exception, + ); + } + return null; + }; + + if (exception.* != null) return null; + var listener: JSC.JSValue = .zero; + var signal: ?*JSC.AbortSignal = null; + var persistent: bool = true; + var recursive: bool = false; + var encoding: JSC.Node.Encoding = .utf8; + var verbose = false; + if (arguments.nextEat()) |options_or_callable| { + + // options + if (options_or_callable.isObject()) { + if (options_or_callable.get(ctx, "persistent")) |persistent_| { + if (!persistent_.isBoolean()) { + JSC.throwInvalidArguments( + "persistent must be a boolean.", + .{}, + ctx, + exception, + ); + return null; + } + persistent = persistent_.toBoolean(); + } + + if (options_or_callable.get(ctx, "verbose")) |verbose_| { + if (!verbose_.isBoolean()) { + JSC.throwInvalidArguments( + "verbose must be a boolean.", + .{}, + ctx, + exception, + ); + return null; + } + verbose = verbose_.toBoolean(); + } + + if (options_or_callable.get(ctx, "encoding")) |encoding_| { + if (!encoding_.isString()) { + JSC.throwInvalidArguments( + "encoding must be a string.", + .{}, + ctx, + exception, + ); + return null; + } + if (JSC.Node.Encoding.fromJS(encoding_, ctx.ptr())) |node_encoding| { + encoding = node_encoding; + } else { + JSC.throwInvalidArguments( + "invalid encoding.", + .{}, + ctx, + exception, + ); + return null; + } + } + + if (options_or_callable.get(ctx, "recursive")) |recursive_| { + if (!recursive_.isBoolean()) { + JSC.throwInvalidArguments( + "recursive must be a boolean.", + .{}, + ctx, + exception, + ); + return null; + } + recursive = recursive_.toBoolean(); + } + + // abort signal + if (options_or_callable.get(ctx, "signal")) |signal_| { + if (JSC.AbortSignal.fromJS(signal_)) |signal_obj| { + //Keep it alive + signal_.ensureStillAlive(); + signal = signal_obj; + } else { + JSC.throwInvalidArguments( + "signal is not of type AbortSignal.", + .{}, + ctx, + exception, + ); + + return null; + } + } + + // listener + if (arguments.nextEat()) |callable| { + if (!callable.isCell() or !callable.isCallable(vm)) { + exception.* = JSC.toInvalidArguments("Expected \"listener\" callback to be a function", .{}, ctx).asObjectRef(); + return null; + } + listener = callable; + } + } else { + if (!options_or_callable.isCell() or !options_or_callable.isCallable(vm)) { + exception.* = JSC.toInvalidArguments("Expected \"listener\" callback to be a function", .{}, ctx).asObjectRef(); + return null; + } + listener = options_or_callable; + } + } + if (listener == .zero) { + exception.* = JSC.toInvalidArguments("Expected \"listener\" callback", .{}, ctx).asObjectRef(); + return null; + } + + return Arguments{ + .path = path, + .listener = listener, + .global_this = ctx, + .signal = signal, + .persistent = persistent, + .recursive = recursive, + .encoding = encoding, + .verbose = verbose, + }; + } + + pub fn createFSWatcher(this: Arguments) !JSC.JSValue { + const obj = try FSWatcher.init(this); + return obj.toJS(); + } + }; + + pub const JSObject = struct { + signal: ?*JSC.AbortSignal, + persistent: bool, + manager: ?*FSWatcher.Watcher, + fsevents_watcher: ?*FSEvents.FSEventsWatcher, + poll_ref: JSC.PollRef = .{}, + globalThis: ?*JSC.JSGlobalObject, + js_this: JSC.JSValue, + encoding: JSC.Node.Encoding, + closed: bool, + + pub usingnamespace JSC.Codegen.JSFSWatcher; + + pub fn getFSWatcher(this: *JSObject) *FSWatcher { + if (this.manager) |manager| return manager.ctx; + if (this.fsevents_watcher) |manager| return bun.cast(*FSWatcher, manager.ctx.?); + + @panic("No context attached to JSFSWatcher"); + } + + pub fn init(globalThis: *JSC.JSGlobalObject, manager: ?*FSWatcher.Watcher, fsevents_watcher: ?*FSEvents.FSEventsWatcher, signal: ?*JSC.AbortSignal, listener: JSC.JSValue, persistent: bool, encoding: JSC.Node.Encoding) !*JSObject { + var obj = try globalThis.allocator().create(JSObject); + obj.* = .{ + .signal = null, + .persistent = persistent, + .manager = manager, + .fsevents_watcher = fsevents_watcher, + .globalThis = globalThis, + .js_this = .zero, + .encoding = encoding, + .closed = false, + }; + const instance = obj.getFSWatcher(); + + if (persistent) { + obj.poll_ref.ref(instance.ctx); + } + + var js_this = JSObject.toJS(obj, globalThis); + JSObject.listenerSetCached(js_this, globalThis, listener); + obj.js_this = js_this; + obj.js_this.protect(); + + if (signal) |s| { + + // already aborted? + if (s.aborted()) { + obj.signal = s.ref(); + // abort next tick + var current_task: FSWatchTask = .{ + .ctx = instance, + }; + current_task.append("", .abort, .none); + current_task.enqueue(); + } else { + // watch for abortion + obj.signal = s.ref().listen(JSObject, obj, JSObject.emitAbort); + } + } + return obj; + } + + pub fn emitIfAborted(this: *JSObject) void { + if (this.signal) |s| { + if (s.aborted()) { + const err = s.abortReason(); + this.emitAbort(err); + } + } + } + + pub fn emitAbort(this: *JSObject, err: JSC.JSValue) void { + if (this.closed) return; + defer this.close(true); + + err.ensureStillAlive(); + + if (this.globalThis) |globalThis| { + if (this.js_this != .zero) { + if (JSObject.listenerGetCached(this.js_this)) |listener| { + var args = [_]JSC.JSValue{ + JSC.ZigString.static("error").toValue(globalThis), + if (err.isEmptyOrUndefinedOrNull()) JSC.WebCore.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, globalThis) else err, + }; + _ = listener.callWithGlobalThis( + globalThis, + &args, + ); + } + } + } + } + pub fn emitError(this: *JSObject, err: string) void { + if (this.closed) return; + defer this.close(true); + + if (this.globalThis) |globalThis| { + if (this.js_this != .zero) { + if (JSObject.listenerGetCached(this.js_this)) |listener| { + var args = [_]JSC.JSValue{ + JSC.ZigString.static("error").toValue(globalThis), + JSC.ZigString.fromUTF8(err).toErrorInstance(globalThis), + }; + _ = listener.callWithGlobalThis( + globalThis, + &args, + ); + } + } + } + } + + pub fn emit(this: *JSObject, file_name: string, comptime eventType: string) void { + if (this.globalThis) |globalThis| { + if (this.js_this != .zero) { + if (JSObject.listenerGetCached(this.js_this)) |listener| { + var filename: JSC.JSValue = JSC.JSValue.jsUndefined(); + if (file_name.len > 0) { + if (this.encoding == .buffer) + filename = JSC.ArrayBuffer.createBuffer(globalThis, file_name) + else if (this.encoding == .utf8) { + filename = JSC.ZigString.fromUTF8(file_name).toValueGC(globalThis); + } else { + // convert to desired encoding + filename = Encoder.toStringAtRuntime(file_name.ptr, file_name.len, globalThis, this.encoding); + } + } + var args = [_]JSC.JSValue{ + JSC.ZigString.static(eventType).toValue(globalThis), + filename, + }; + _ = listener.callWithGlobalThis( + globalThis, + &args, + ); + } + } + } + } + + pub fn ref(this: *JSObject) void { + if (this.closed) return; + + if (!this.persistent) { + this.persistent = true; + this.poll_ref.ref(this.getFSWatcher().ctx); + } + } + + pub fn doRef(this: *JSObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + this.ref(); + return JSC.JSValue.jsUndefined(); + } + + pub fn unref(this: *JSObject) void { + if (this.persistent) { + this.persistent = false; + this.poll_ref.unref(this.getFSWatcher().ctx); + } + } + + pub fn doUnref(this: *JSObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + this.unref(); + return JSC.JSValue.jsUndefined(); + } + + pub fn hasRef(this: *JSObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + return JSC.JSValue.jsBoolean(this.persistent); + } + + pub fn close( + this: *JSObject, + emitEvent: bool, + ) void { + if (!this.closed) { + if (this.signal) |signal| { + this.signal = null; + signal.detach(this); + } + this.closed = true; + if (emitEvent) { + this.emit("", "close"); + } + + this.detach(); + } + } + + pub fn detach(this: *JSObject) void { + this.unref(); + + if (this.js_this != .zero) { + this.js_this.unprotect(); + this.js_this = .zero; + } + + this.globalThis = null; + + if (this.signal) |signal| { + this.signal = null; + signal.detach(this); + } + if (this.manager) |manager| { + var ctx = manager.ctx; + this.manager = null; + ctx.js_watcher = null; + ctx.deinit(); + manager.deinit(true); + } + + if (this.fsevents_watcher) |manager| { + var ctx = bun.cast(*FSWatcher, manager.ctx.?); + ctx.js_watcher = null; + ctx.deinit(); + manager.deinit(); + } + } + + pub fn doClose(this: *JSObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + this.close(true); + return JSC.JSValue.jsUndefined(); + } + + pub fn finalize(this: *JSObject) callconv(.C) void { + if (!this.closed) { + this.detach(); + } + + bun.default_allocator.destroy(this); + } + }; + + const PathResult = struct { + fd: StoredFileDescriptorType = 0, + is_file: bool = true, + }; + + fn fdFromAbsolutePathZ( + absolute_path_z: [:0]const u8, + ) !PathResult { + var stat = try bun.C.lstat_absolute(absolute_path_z); + var result = PathResult{}; + + switch (stat.kind) { + .sym_link => { + var file = try std.fs.openFileAbsoluteZ(absolute_path_z, .{ .mode = .read_only }); + result.fd = file.handle; + const _stat = try file.stat(); + + result.is_file = _stat.kind == .directory; + }, + .directory => { + const dir = (try std.fs.openIterableDirAbsoluteZ(absolute_path_z, .{ + .access_sub_paths = true, + })).dir; + result.fd = dir.fd; + result.is_file = false; + }, + else => { + const file = try std.fs.openFileAbsoluteZ(absolute_path_z, .{ .mode = .read_only }); + result.fd = file.handle; + result.is_file = true; + }, + } + return result; + } + + pub fn init(args: Arguments) !*FSWatcher { + var buf: [bun.MAX_PATH_BYTES + 1]u8 = undefined; + var slice = args.path.slice(); + if (bun.strings.startsWith(slice, "file://")) { + slice = slice[6..]; + } + var parts = [_]string{ + slice, + }; + + var file_path = Path.joinAbsStringBuf( + Fs.FileSystem.instance.top_level_dir, + &buf, + &parts, + .auto, + ); + + buf[file_path.len] = 0; + var file_path_z = buf[0..file_path.len :0]; + + var fs_type = try fdFromAbsolutePathZ(file_path_z); + + var ctx = try bun.default_allocator.create(FSWatcher); + const vm = args.global_this.bunVM(); + ctx.* = .{ + .ctx = vm, + .verbose = args.verbose, + .file_paths = bun.BabyList(string).initCapacity(bun.default_allocator, 1) catch |err| { + ctx.deinit(); + return err; + }, + }; + + if (comptime Environment.isMac) { + if (!fs_type.is_file) { + var dir_path_clone = bun.default_allocator.dupeZ(u8, file_path) catch unreachable; + ctx.entry_path = dir_path_clone; + ctx.entry_dir = dir_path_clone; + + var fsevents_watcher = FSEvents.watch(dir_path_clone, args.recursive, onFSEventUpdate, bun.cast(*anyopaque, ctx)) catch |err| { + ctx.deinit(); + return err; + }; + + ctx.js_watcher = JSObject.init(args.global_this, null, fsevents_watcher, args.signal, args.listener, args.persistent, args.encoding) catch |err| { + ctx.deinit(); + fsevents_watcher.deinit(); + return err; + }; + + return ctx; + } + } + + var fs_watcher = FSWatcher.Watcher.init( + ctx, + vm.bundler.fs, + bun.default_allocator, + ) catch |err| { + ctx.deinit(); + return err; + }; + + ctx.watcher_instance = fs_watcher; + + if (fs_type.is_file) { + var file_path_clone = bun.default_allocator.dupeZ(u8, file_path) catch unreachable; + + ctx.entry_path = file_path_clone; + ctx.entry_dir = std.fs.path.dirname(file_path_clone) orelse file_path_clone; + + fs_watcher.addFile(fs_type.fd, file_path_clone, FSWatcher.Watcher.getHash(file_path), options.Loader.file, 0, null, false) catch |err| { + ctx.deinit(); + fs_watcher.deinit(true); + return err; + }; + } else { + addDirectory(ctx, fs_watcher, fs_type.fd, file_path, args.recursive, &buf, true) catch |err| { + ctx.deinit(); + fs_watcher.deinit(true); + return err; + }; + } + + fs_watcher.start() catch |err| { + ctx.deinit(); + + fs_watcher.deinit(true); + return err; + }; + + ctx.js_watcher = JSObject.init(args.global_this, fs_watcher, null, args.signal, args.listener, args.persistent, args.encoding) catch |err| { + ctx.deinit(); + fs_watcher.deinit(true); + return err; + }; + + return ctx; + } +}; diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index e2de35706..659ac31bb 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -93,6 +93,10 @@ pub fn Maybe(comptime ResultType: type) type { return JSC.JSValue.jsUndefined(); } + if (comptime ReturnType == JSC.JSValue) { + return r; + } + if (comptime ReturnType == JSC.ArrayBuffer) { return r.toJS(globalThis, null); } diff --git a/src/bun.js/webcore/encoding.zig b/src/bun.js/webcore/encoding.zig index 5c8221128..061a25eed 100644 --- a/src/bun.js/webcore/encoding.zig +++ b/src/bun.js/webcore/encoding.zig @@ -802,7 +802,20 @@ pub const Encoder = struct { // pub fn writeUTF16AsUTF8(utf16: [*]const u16, len: usize, to: [*]u8, to_len: usize) callconv(.C) i32 { // return @intCast(i32, strings.copyUTF16IntoUTF8(to[0..to_len], []const u16, utf16[0..len], true).written); // } - + pub fn toStringAtRuntime(input: [*]const u8, len: usize, globalObject: *JSGlobalObject, encoding: JSC.Node.Encoding) JSValue { + return switch (encoding) { + .ucs2 => toString(input, len, globalObject, .utf16le), + .utf16le => toString(input, len, globalObject, .utf16le), + .utf8 => toString(input, len, globalObject, .utf8), + .ascii => toString(input, len, globalObject, .ascii), + .hex => toString(input, len, globalObject, .hex), + .base64 => toString(input, len, globalObject, .base64), + .base64url => toString(input, len, globalObject, .base64url), + .latin1 => toString(input, len, globalObject, .latin1), + // treat everything else as utf8 + else => toString(input, len, globalObject, .utf8), + }; + } pub fn toString(input_ptr: [*]const u8, len: usize, global: *JSGlobalObject, comptime encoding: JSC.Node.Encoding) JSValue { if (len == 0) return ZigString.Empty.toValue(global); diff --git a/src/fs.zig b/src/fs.zig index e87d931df..98174fac3 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1109,6 +1109,60 @@ pub const FileSystem = struct { return File{ .path = Path.init(path), .contents = file_contents }; } + pub fn kindFromAbsolute( + fs: *RealFS, + absolute_path: [:0]const u8, + existing_fd: StoredFileDescriptorType, + store_fd: bool, + ) !Entry.Cache { + var outpath: [bun.MAX_PATH_BYTES]u8 = undefined; + + var stat = try C.lstat_absolute(absolute_path); + const is_symlink = stat.kind == std.fs.File.Kind.SymLink; + var _kind = stat.kind; + var cache = Entry.Cache{ + .kind = Entry.Kind.file, + .symlink = PathString.empty, + }; + var symlink: []const u8 = ""; + + if (is_symlink) { + var file = try if (existing_fd != 0) + std.fs.File{ .handle = existing_fd } + else if (store_fd) + std.fs.openFileAbsoluteZ(absolute_path, .{ .mode = .read_only }) + else + bun.openFileForPath(absolute_path); + setMaxFd(file.handle); + + defer { + if ((!store_fd or fs.needToCloseFiles()) and existing_fd == 0) { + file.close(); + } else if (comptime FeatureFlags.store_file_descriptors) { + cache.fd = file.handle; + } + } + const _stat = try file.stat(); + + symlink = try bun.getFdPath(file.handle, &outpath); + + _kind = _stat.kind; + } + + std.debug.assert(_kind != .SymLink); + + if (_kind == .Directory) { + cache.kind = .dir; + } else { + cache.kind = .file; + } + if (symlink.len > 0) { + cache.symlink = PathString.init(try FilenameStore.instance.append([]const u8, symlink)); + } + + return cache; + } + pub fn kind( fs: *RealFS, _dir: string, diff --git a/src/http.zig b/src/http.zig index 827bfa6de..80718db2f 100644 --- a/src/http.zig +++ b/src/http.zig @@ -3238,7 +3238,12 @@ pub const Server = struct { threadlocal var filechange_buf: [32]u8 = undefined; threadlocal var filechange_buf_hinted: [32]u8 = undefined; - + pub fn onError( + _: *@This(), + err: anyerror, + ) void { + Output.prettyErrorln("Watcher crashed: {s}", .{@errorName(err)}); + } pub fn onFileUpdate( ctx: *Server, events: []watcher.WatchEvent, diff --git a/src/js/node/fs.js b/src/js/node/fs.js index f117020dd..6b0e3954e 100644 --- a/src/js/node/fs.js +++ b/src/js/node/fs.js @@ -1,3 +1,5 @@ +import { EventEmitter } from "stream"; + // Hardcoded module "node:fs" var { direct, isPromise, isCallable } = import.meta.primordials; var promises = import.meta.require("node:fs/promises"); @@ -7,6 +9,63 @@ var NativeReadable = _getNativeReadableStreamPrototype(2, Readable); // 2 means var fs = Bun.fs(); var debug = process.env.DEBUG ? console.log : () => {}; + +class FSWatcher extends EventEmitter { + #watcher; + #listener; + constructor(path, options, listener) { + super(); + + if (typeof options === "function") { + listener = options; + options = {}; + } else if (typeof options === "string") { + options = { encoding: options }; + } + + if (typeof listener !== "function") { + listener = () => {}; + } + + this.#listener = listener; + try { + this.#watcher = fs.watch(path, options || {}, this.#onEvent.bind(this)); + } catch (e) { + if (!e.message?.startsWith("FileNotFound")) { + throw e; + } + const notFound = new Error(`ENOENT: no such file or directory, watch '${path}'`); + notFound.code = "ENOENT"; + notFound.errno = -2; + notFound.path = path; + notFound.syscall = "watch"; + notFound.filename = path; + throw notFound; + } + } + + #onEvent(eventType, filenameOrError) { + if (eventType === "error" || eventType === "close") { + this.emit(eventType, filenameOrError); + } else { + this.emit("change", eventType, filenameOrError); + this.#listener(eventType, filenameOrError); + } + } + + close() { + this.#watcher?.close(); + this.#watcher = null; + } + + ref() { + this.#watcher?.ref(); + } + + unref() { + this.#watcher?.unref(); + } +} export var access = function access(...args) { callbackify(fs.accessSync, args); }, @@ -153,6 +212,9 @@ export var access = function access(...args) { rmdirSync = fs.rmdirSync.bind(fs), Dirent = fs.Dirent, 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) { @@ -1002,7 +1064,8 @@ export default { writeSync, WriteStream, ReadStream, - + watch, + FSWatcher, [Symbol.for("::bunternal::")]: { ReadStreamClass, WriteStreamClass, diff --git a/src/js/node/fs.promises.ts b/src/js/node/fs.promises.ts index de802928b..7df446ccb 100644 --- a/src/js/node/fs.promises.ts +++ b/src/js/node/fs.promises.ts @@ -1,4 +1,5 @@ // Hardcoded module "node:fs/promises" + // Note: `constants` is injected into the top of this file declare var constants: typeof import("node:fs/promises").constants; @@ -38,6 +39,55 @@ var promisify = { }, }[notrace]; +export function watch( + filename: string | Buffer | URL, + options: { encoding?: BufferEncoding; persistent?: boolean; recursive?: boolean; signal?: AbortSignal } = {}, +) { + type Event = { + eventType: string; + filename: string | Buffer | undefined; + }; + const events: Array = []; + if (filename instanceof URL) { + throw new TypeError("Watch URLs are not supported yet"); + } else if (Buffer.isBuffer(filename)) { + filename = filename.toString(); + } else if (typeof filename !== "string") { + throw new TypeError("Expected path to be a string or Buffer"); + } + let nextEventResolve: Function | null = null; + if (typeof options === "string") { + options = { encoding: options }; + } + fs.watch(filename, options || {}, (eventType: string, filename: string | Buffer | undefined) => { + events.push({ eventType, filename }); + if (nextEventResolve) { + const resolve = nextEventResolve; + nextEventResolve = null; + resolve(); + } + }); + return { + async *[Symbol.asyncIterator]() { + let closed = false; + while (!closed) { + while (events.length) { + let event = events.shift() as Event; + if (event.eventType === "close") { + closed = true; + break; + } + if (event.eventType === "error") { + closed = true; + throw event.filename; + } + yield event; + } + await new Promise((resolve: Function) => (nextEventResolve = resolve)); + } + }, + }; +} export var access = promisify(fs.accessSync), appendFile = promisify(fs.appendFileSync), close = promisify(fs.closeSync), @@ -112,6 +162,7 @@ export default { lutimes, rm, rmdir, + watch, constants, [Symbol.for("CommonJS")]: 0, }; diff --git a/src/js/out/modules/node/fs.js b/src/js/out/modules/node/fs.js index cc1e14d2b..cc3763cfc 100644 --- a/src/js/out/modules/node/fs.js +++ b/src/js/out/modules/node/fs.js @@ -1,3 +1,4 @@ +var {EventEmitter } = import.meta.require("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 +17,47 @@ 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 : () => { -}, access = function access2(...args) { +}; + +class FSWatcher extends EventEmitter { + #watcher; + #listener; + constructor(path, options, listener) { + super(); + if (typeof options === "function") + listener = options, options = {}; + else if (typeof options === "string") + options = { encoding: options }; + if (typeof listener !== "function") + listener = () => { + }; + this.#listener = listener; + try { + this.#watcher = fs.watch(path, options || {}, this.#onEvent.bind(this)); + } catch (e) { + if (!e.message?.startsWith("FileNotFound")) + throw e; + const notFound = new Error(`ENOENT: no such file or directory, watch '${path}'`); + throw notFound.code = "ENOENT", notFound.errno = -2, notFound.path = path, notFound.syscall = "watch", notFound.filename = path, notFound; + } + } + #onEvent(eventType, filenameOrError) { + if (eventType === "error" || eventType === "close") + this.emit(eventType, filenameOrError); + else + this.emit("change", eventType, filenameOrError), this.#listener(eventType, filenameOrError); + } + close() { + this.#watcher?.close(), this.#watcher = null; + } + ref() { + this.#watcher?.ref(); + } + unref() { + this.#watcher?.unref(); + } +} +var access = function access2(...args) { callbackify(fs.accessSync, args); }, appendFile = function appendFile2(...args) { callbackify(fs.appendFileSync, args); @@ -88,7 +129,9 @@ var { direct, isPromise, isCallable } = import.meta.primordials, promises = impo callbackify(fs.utimesSync, args); }, lutimes = function lutimes2(...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, 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 = { +}, 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 = { file: void 0, fd: void 0, flags: "r", @@ -590,6 +633,8 @@ var fs_default = { writeSync, WriteStream, ReadStream, + watch, + FSWatcher, [Symbol.for("::bunternal::")]: { ReadStreamClass, WriteStreamClass @@ -600,6 +645,7 @@ export { writeFileSync, writeFile, write, + watch, utimesSync, utimes, unlinkSync, diff --git a/src/js/out/modules/node/fs.promises.js b/src/js/out/modules/node/fs.promises.js index 2780ff166..ef3330771 100644 --- a/src/js/out/modules/node/fs.promises.js +++ b/src/js/out/modules/node/fs.promises.js @@ -1 +1 @@ -var D=Bun.fs(),B="::bunternal::",E={[B]:(S)=>{var b={[B]:function(C,J,q){var z;try{z=S.apply(D,q),q=void 0}catch(A){q=void 0,J(A);return}C(z)}}[B];return async function(...C){return await new Promise((J,q)=>{process.nextTick(b,J,q,C)})}}}[B],G=E(D.accessSync),H=E(D.appendFileSync),I=E(D.closeSync),K=E(D.copyFileSync),L=E(D.existsSync),M=E(D.chownSync),N=E(D.chmodSync),O=E(D.fchmodSync),P=E(D.fchownSync),Q=E(D.fstatSync),R=E(D.fsyncSync),T=E(D.ftruncateSync),U=E(D.futimesSync),V=E(D.lchmodSync),W=E(D.lchownSync),X=E(D.linkSync),Y=E(D.lstatSync),Z=E(D.mkdirSync),_=E(D.mkdtempSync),$=E(D.openSync),x=E(D.readSync),j=E(D.writeSync),v=E(D.readdirSync),w=E(D.readFileSync),k=E(D.writeFileSync),F=E(D.readlinkSync),h=E(D.realpathSync),g=E(D.renameSync),u=E(D.statSync),d=E(D.symlinkSync),n=E(D.truncateSync),l=E(D.unlinkSync),a=E(D.utimesSync),c=E(D.lutimesSync),t=E(D.rmSync),y=E(D.rmdirSync),p={access:G,appendFile:H,close:I,copyFile:K,exists:L,chown:M,chmod:N,fchmod:O,fchown:P,fstat:Q,fsync:R,ftruncate:T,futimes:U,lchmod:V,lchown:W,link:X,lstat:Y,mkdir:Z,mkdtemp:_,open:$,read:x,write:j,readdir:v,readFile:w,writeFile:k,readlink:F,realpath:h,rename:g,stat:u,symlink:d,truncate:n,unlink:l,utimes:a,lutimes:c,rm:t,rmdir:y,constants,[Symbol.for("CommonJS")]:0};export{k as writeFile,j as write,a as utimes,l as unlink,n as truncate,d as symlink,u as stat,y as rmdir,t as rm,g as rename,h as realpath,F as readlink,v as readdir,w as readFile,x as read,$ as open,_ as mkdtemp,Z as mkdir,c as lutimes,Y as lstat,X as link,W as lchown,V as lchmod,U as futimes,T as ftruncate,R as fsync,Q as fstat,P as fchown,O as fchmod,L as exists,p as default,K as copyFile,I as close,M as chown,N as chmod,H as appendFile,G as access}; +function H(S,C={}){const J=[];if(S instanceof URL)throw new TypeError("Watch URLs are not supported yet");else if(Buffer.isBuffer(S))S=S.toString();else if(typeof S!=="string")throw new TypeError("Expected path to be a string or Buffer");let b=null;if(typeof C==="string")C={encoding:C};return D.watch(S,C||{},(q,z)=>{if(J.push({eventType:q,filename:z}),b){const A=b;b=null,A()}}),{async*[Symbol.asyncIterator](){let q=!1;while(!q){while(J.length){let z=J.shift();if(z.eventType==="close"){q=!0;break}if(z.eventType==="error")throw q=!0,z.filename;yield z}await new Promise((z)=>b=z)}}}}var D=Bun.fs(),B="::bunternal::",G={[B]:(S)=>{var C={[B]:function(J,b,q){var z;try{z=S.apply(D,q),q=void 0}catch(A){q=void 0,b(A);return}J(z)}}[B];return async function(...J){return await new Promise((b,q)=>{process.nextTick(C,b,q,J)})}}}[B],I=G(D.accessSync),K=G(D.appendFileSync),L=G(D.closeSync),M=G(D.copyFileSync),N=G(D.existsSync),O=G(D.chownSync),P=G(D.chmodSync),Q=G(D.fchmodSync),U=G(D.fchownSync),V=G(D.fstatSync),W=G(D.fsyncSync),X=G(D.ftruncateSync),Y=G(D.futimesSync),Z=G(D.lchmodSync),_=G(D.lchownSync),$=G(D.linkSync),T=G(D.lstatSync),E=G(D.mkdirSync),j=G(D.mkdtempSync),R=G(D.openSync),k=G(D.readSync),x=G(D.writeSync),F=G(D.readdirSync),u=G(D.readFileSync),w=G(D.writeFileSync),g=G(D.readlinkSync),h=G(D.realpathSync),d=G(D.renameSync),c=G(D.statSync),v=G(D.symlinkSync),a=G(D.truncateSync),y=G(D.unlinkSync),l=G(D.utimesSync),t=G(D.lutimesSync),p=G(D.rmSync),n=G(D.rmdirSync),m={access:I,appendFile:K,close:L,copyFile:M,exists:N,chown:O,chmod:P,fchmod:Q,fchown:U,fstat:V,fsync:W,ftruncate:X,futimes:Y,lchmod:Z,lchown:_,link:$,lstat:T,mkdir:E,mkdtemp:j,open:R,read:k,write:x,readdir:F,readFile:u,writeFile:w,readlink:g,realpath:h,rename:d,stat:c,symlink:v,truncate:a,unlink:y,utimes:l,lutimes:t,rm:p,rmdir:n,watch:H,constants,[Symbol.for("CommonJS")]:0};export{w as writeFile,x as write,H as watch,l as utimes,y as unlink,a as truncate,v as symlink,c as stat,n as rmdir,p as rm,d as rename,h as realpath,g as readlink,F as readdir,u as readFile,k as read,R as open,j as mkdtemp,E as mkdir,t as lutimes,T as lstat,$ as link,_ as lchown,Z as lchmod,Y as futimes,X as ftruncate,W as fsync,V as fstat,U as fchown,Q as fchmod,N as exists,m as default,M as copyFile,L as close,O as chown,P as chmod,K as appendFile,I as access}; diff --git a/src/js/private.d.ts b/src/js/private.d.ts index b6ed64801..b689c208e 100644 --- a/src/js/private.d.ts +++ b/src/js/private.d.ts @@ -6,11 +6,95 @@ */ declare function $bundleError(error: string); +type BunFSWatchOptions = { encoding?: BufferEncoding; persistent?: boolean; recursive?: boolean; signal?: AbortSignal }; + +type BunWatchEventType = "rename" | "change" | "error" | "close"; +type BunWatchListener = (event: WatchEventType, filename: T | Error | undefined) => void; + +interface BunFSWatcher { + /** + * Stop watching for changes on the given `BunFSWatcher`. Once stopped, the `BunFSWatcher` object is no longer usable. + * @since v0.6.8 + */ + close(): void; + + /** + * When called, requests that the Node.js event loop not exit so long as the is active. Calling watcher.ref() multiple times will have no effect. + */ + ref(): void; + + /** + * When called, the active object will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before the object's callback is invoked. Calling watcher.unref() multiple times will have no effect. + */ + unref(): void; +} +type BunFS = Omit & { + /** + * Watch for changes on `filename`, where `filename` is either a file or a + * directory. + * + * The second argument is optional. If `options` is provided as a string, it + * specifies the `encoding`. Otherwise `options` should be passed as an object. + * + * The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'`, `'change', 'error' or 'close'`, and `filename` is the name of the file + * which triggered the event, the error when `eventType` is 'error' or undefined when eventType is 'close'. + * + * On most platforms, `'rename'` is emitted whenever a filename appears or + * disappears in the directory. + * + * + * If a `signal` is passed, aborting the corresponding AbortController will close + * the returned `BunFSWatcher`. + * @since v0.6.8 + * @param listener + */ + watch( + filename: string, + options: + | (WatchOptions & { + encoding: "buffer"; + }) + | "buffer", + listener?: BunWatchListener, + ): BunFSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `BunFSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + watch( + filename: string, + options?: WatchOptions | BufferEncoding | null, + listener?: BunWatchListener, + ): BunFSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `BunFSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + watch( + filename: string, + options: BunWatchListener | string, + listener?: BunWatchListener, + ): BunFSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `BunFSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + watch(filename: string, listener?: BunWatchListener): BunFSWatcher; +}; + declare module "bun" { var TOML: { parse(contents: string): any; }; - function fs(): typeof import("node:fs"); + function fs(): BunFS; function _Os(): typeof import("node:os"); function jest(): typeof import("bun:test"); var main: string; diff --git a/src/jsc.zig b/src/jsc.zig index 67cf3f05c..ca31d5f1a 100644 --- a/src/jsc.zig +++ b/src/jsc.zig @@ -50,6 +50,7 @@ pub const FFI = @import("./bun.js/api/ffi.zig").FFI; pub const Node = struct { pub usingnamespace @import("./bun.js/node/types.zig"); pub usingnamespace @import("./bun.js/node/node_fs.zig"); + pub usingnamespace @import("./bun.js/node/node_fs_watcher.zig"); pub usingnamespace @import("./bun.js/node/node_fs_binding.zig"); pub usingnamespace @import("./bun.js/node/node_os.zig"); pub const Syscall = @import("./bun.js/node/syscall.zig"); diff --git a/src/watcher.zig b/src/watcher.zig index 155c0b473..044770dc4 100644 --- a/src/watcher.zig +++ b/src/watcher.zig @@ -108,6 +108,10 @@ pub const INotify = struct { std.os.inotify_rm_watch(inotify_fd, wd); } + pub fn isRunning() bool { + return loaded_inotify; + } + var coalesce_interval: isize = 100_000; pub fn init() !void { std.debug.assert(!loaded_inotify); @@ -229,6 +233,10 @@ const DarwinWatcher = struct { if (fd == 0) return error.KQueueError; } + pub fn isRunning() bool { + return fd != 0; + } + pub fn stop() void { if (fd != 0) { std.os.close(fd); @@ -361,6 +369,8 @@ pub fn NewWatcher(comptime ContextType: type) type { watchloop_handle: ?std.Thread.Id = null, cwd: string, thread: std.Thread = undefined, + running: bool = true, + close_descriptors: bool = false, pub const HashType = u32; @@ -372,7 +382,9 @@ pub fn NewWatcher(comptime ContextType: type) type { pub fn init(ctx: ContextType, fs: *Fs.FileSystem, allocator: std.mem.Allocator) !*Watcher { var watcher = try allocator.create(Watcher); - try PlatformWatcher.init(); + if (!PlatformWatcher.isRunning()) { + try PlatformWatcher.init(); + } watcher.* = Watcher{ .fs = fs, @@ -393,6 +405,26 @@ pub fn NewWatcher(comptime ContextType: type) type { this.thread = try std.Thread.spawn(.{}, Watcher.watchLoop, .{this}); } + pub fn deinit(this: *Watcher, close_descriptors: bool) void { + this.mutex.lock(); + defer this.mutex.unlock(); + + this.close_descriptors = close_descriptors; + if (this.watchloop_handle != null) { + this.running = false; + } else { + if (this.close_descriptors and this.running) { + const fds = this.watchlist.items(.fd); + for (fds) |fd| { + std.os.close(fd); + } + } + this.watchlist.deinit(this.allocator); + const allocator = this.allocator; + allocator.destroy(this); + } + } + // This must only be called from the watcher thread pub fn watchLoop(this: *Watcher) !void { this.watchloop_handle = std.Thread.getCurrentId(); @@ -402,12 +434,24 @@ pub fn NewWatcher(comptime ContextType: type) type { if (FeatureFlags.verbose_watcher) Output.prettyln("Watcher started", .{}); this._watchLoop() catch |err| { - Output.prettyErrorln("Watcher crashed: {s}", .{@errorName(err)}); - this.watchloop_handle = null; PlatformWatcher.stop(); - return; + if (this.running) { + this.ctx.onError(err); + } }; + + // deinit and close descriptors if needed + if (this.close_descriptors) { + const fds = this.watchlist.items(.fd); + for (fds) |fd| { + std.os.close(fd); + } + } + this.watchlist.deinit(this.allocator); + + const allocator = this.allocator; + allocator.destroy(this); } var evict_list_i: WatchItemIndex = 0; @@ -475,7 +519,7 @@ pub fn NewWatcher(comptime ContextType: type) type { var changelist_array: [128]KEvent = std.mem.zeroes([128]KEvent); var changelist = &changelist_array; - while (true) { + while (this.running) { defer Output.flush(); var count_ = std.os.system.kevent( @@ -530,11 +574,12 @@ pub fn NewWatcher(comptime ContextType: type) type { this.mutex.lock(); defer this.mutex.unlock(); - - this.ctx.onFileUpdate(watchevents, this.changed_filepaths[0..watchevents.len], this.watchlist); + if (this.running) { + this.ctx.onFileUpdate(watchevents, this.changed_filepaths[0..watchevents.len], this.watchlist); + } } } else if (Environment.isLinux) { - restart: while (true) { + restart: while (this.running) { defer Output.flush(); var events = try INotify.read(); @@ -600,9 +645,10 @@ pub fn NewWatcher(comptime ContextType: type) type { this.mutex.lock(); defer this.mutex.unlock(); - - this.ctx.onFileUpdate(all_events[0 .. last_event_index + 1], this.changed_filepaths[0 .. name_off + 1], this.watchlist); - remaining_events -= slice.len; + if (this.running) { + this.ctx.onFileUpdate(all_events[0 .. last_event_index + 1], this.changed_filepaths[0 .. name_off + 1], this.watchlist); + remaining_events -= slice.len; + } } } } diff --git a/test/js/node/watch/fixtures/close.js b/test/js/node/watch/fixtures/close.js new file mode 100644 index 000000000..8eeeb79a3 --- /dev/null +++ b/test/js/node/watch/fixtures/close.js @@ -0,0 +1,7 @@ +import fs from "fs"; +fs.watch(import.meta.path, { signal: AbortSignal.timeout(4000) }) + .on("error", err => { + console.error(err.message); + process.exit(1); + }) + .close(); diff --git a/test/js/node/watch/fixtures/persistent.js b/test/js/node/watch/fixtures/persistent.js new file mode 100644 index 000000000..72a2b6564 --- /dev/null +++ b/test/js/node/watch/fixtures/persistent.js @@ -0,0 +1,5 @@ +import fs from "fs"; +fs.watch(import.meta.path, { persistent: false, signal: AbortSignal.timeout(4000) }).on("error", err => { + console.error(err.message); + process.exit(1); +}); diff --git a/test/js/node/watch/fixtures/relative.js b/test/js/node/watch/fixtures/relative.js new file mode 100644 index 000000000..26e09da1a --- /dev/null +++ b/test/js/node/watch/fixtures/relative.js @@ -0,0 +1,23 @@ +import fs from "fs"; +const watcher = fs.watch("relative.txt", { signal: AbortSignal.timeout(2000) }); + +watcher.on("change", function (event, filename) { + if (filename !== "relative.txt" && event !== "change") { + console.error("fail"); + clearInterval(interval); + watcher.close(); + process.exit(1); + } else { + clearInterval(interval); + watcher.close(); + } +}); +watcher.on("error", err => { + clearInterval(interval); + console.error(err.message); + process.exit(1); +}); + +const interval = setInterval(() => { + fs.writeFileSync("relative.txt", "world"); +}, 10); diff --git a/test/js/node/watch/fixtures/unref.js b/test/js/node/watch/fixtures/unref.js new file mode 100644 index 000000000..a0c506a04 --- /dev/null +++ b/test/js/node/watch/fixtures/unref.js @@ -0,0 +1,7 @@ +import fs from "fs"; +fs.watch(import.meta.path, { signal: AbortSignal.timeout(4000) }) + .on("error", err => { + console.error(err.message); + process.exit(1); + }) + .unref(); diff --git a/test/js/node/watch/fs.watch.test.js b/test/js/node/watch/fs.watch.test.js new file mode 100644 index 000000000..56e1798f1 --- /dev/null +++ b/test/js/node/watch/fs.watch.test.js @@ -0,0 +1,424 @@ +import fs from "fs"; +import path from "path"; +import { tempDirWithFiles, bunRun, bunRunAsScript } from "harness"; +import { pathToFileURL } from "bun"; + +import { describe, expect, test } from "bun:test"; +// Because macOS (and possibly other operating systems) can return a watcher +// before it is actually watching, we need to repeat the operation to avoid +// a race condition. +function repeat(fn) { + const interval = setInterval(fn, 20); + return interval; +} +const encodingFileName = `新建文夹件.txt`; +const testDir = tempDirWithFiles("watch", { + "watch.txt": "hello", + "relative.txt": "hello", + "abort.txt": "hello", + "url.txt": "hello", + [encodingFileName]: "hello", +}); + +describe("fs.watch", () => { + test("non-persistent watcher should not block the event loop", done => { + try { + // https://github.com/joyent/node/issues/2293 - non-persistent watcher should not block the event loop + bunRun(path.join(import.meta.dir, "fixtures", "persistent.js")); + done(); + } catch (e) { + done(e); + } + }); + + test("watcher should close and not block the event loop", done => { + try { + bunRun(path.join(import.meta.dir, "fixtures", "close.js")); + done(); + } catch (e) { + done(e); + } + }); + + test("unref watcher should not block the event loop", done => { + try { + bunRun(path.join(import.meta.dir, "fixtures", "unref.js")); + done(); + } catch (e) { + done(e); + } + }); + + test("should work with relative files", done => { + try { + bunRunAsScript(testDir, path.join(import.meta.dir, "fixtures", "relative.js")); + done(); + } catch (e) { + done(e); + } + }); + + test("add file/folder to folder", done => { + let count = 0; + const root = path.join(testDir, "add-directory"); + try { + fs.mkdirSync(root); + } catch {} + let err = undefined; + const watcher = fs.watch(root, { signal: AbortSignal.timeout(3000) }); + watcher.on("change", (event, filename) => { + count++; + try { + expect(event).toBe("rename"); + expect(["new-file.txt", "new-folder.txt"]).toContain(filename); + if (count >= 2) { + watcher.close(); + } + } catch (e) { + err = e; + watcher.close(); + } + }); + + watcher.on("error", e => (err = e)); + watcher.on("close", () => { + clearInterval(interval); + done(err); + }); + + const interval = repeat(() => { + fs.writeFileSync(path.join(root, "new-file.txt"), "hello"); + fs.mkdirSync(path.join(root, "new-folder.txt")); + fs.rmdirSync(path.join(root, "new-folder.txt")); + }); + }); + + test("add file/folder to subfolder", done => { + let count = 0; + const root = path.join(testDir, "add-subdirectory"); + try { + fs.mkdirSync(root); + } catch {} + const subfolder = path.join(root, "subfolder"); + fs.mkdirSync(subfolder); + const watcher = fs.watch(root, { recursive: true, signal: AbortSignal.timeout(3000) }); + let err = undefined; + watcher.on("change", (event, filename) => { + const basename = path.basename(filename); + if (basename === "subfolder") return; + count++; + try { + expect(event).toBe("rename"); + expect(["new-file.txt", "new-folder.txt"]).toContain(basename); + if (count >= 2) { + watcher.close(); + } + } catch (e) { + err = e; + watcher.close(); + } + }); + watcher.on("error", e => (err = e)); + watcher.on("close", () => { + clearInterval(interval); + done(err); + }); + + const interval = repeat(() => { + fs.writeFileSync(path.join(subfolder, "new-file.txt"), "hello"); + fs.mkdirSync(path.join(subfolder, "new-folder.txt")); + fs.rmdirSync(path.join(subfolder, "new-folder.txt")); + }); + }); + + test("should emit event when file is deleted", done => { + const testsubdir = tempDirWithFiles("subdir", { + "deleted.txt": "hello", + }); + const filepath = path.join(testsubdir, "deleted.txt"); + let err = undefined; + const watcher = fs.watch(testsubdir, function (event, filename) { + try { + expect(event).toBe("rename"); + expect(filename).toBe("deleted.txt"); + } catch (e) { + err = e; + } finally { + clearInterval(interval); + watcher.close(); + } + }); + + watcher.once("close", () => { + done(err); + }); + + const interval = repeat(() => { + fs.rmSync(filepath, { force: true }); + const fd = fs.openSync(filepath, "w"); + fs.closeSync(fd); + }); + }); + + test("should emit 'change' event when file is modified", done => { + const filepath = path.join(testDir, "watch.txt"); + + const watcher = fs.watch(filepath); + let err = undefined; + watcher.on("change", function (event, filename) { + try { + expect(event).toBe("change"); + expect(filename).toBe("watch.txt"); + } catch (e) { + err = e; + } finally { + clearInterval(interval); + watcher.close(); + } + }); + + watcher.once("close", () => { + done(err); + }); + + const interval = repeat(() => { + fs.writeFileSync(filepath, "world"); + }); + }); + + test("should error on invalid path", done => { + try { + fs.watch(path.join(testDir, "404.txt")); + done(new Error("should not reach here")); + } catch (err) { + expect(err).toBeInstanceOf(Error); + expect(err.code).toBe("ENOENT"); + expect(err.syscall).toBe("watch"); + done(); + } + }); + + const encodings = ["utf8", "buffer", "hex", "ascii", "base64", "utf16le", "ucs2", "latin1", "binary"]; + + test(`should work with encodings ${encodings.join(", ")}`, async () => { + const watchers = []; + const filepath = path.join(testDir, encodingFileName); + + const promises = []; + encodings.forEach(name => { + const encoded_filename = + name !== "buffer" ? Buffer.from(encodingFileName, "utf8").toString(name) : Buffer.from(encodingFileName); + + promises.push( + new Promise((resolve, reject) => { + watchers.push( + fs.watch(filepath, { encoding: name }, (event, filename) => { + try { + expect(event).toBe("change"); + + if (name !== "buffer") { + expect(filename).toBe(encoded_filename); + } else { + expect(filename).toBeInstanceOf(Buffer); + expect(filename.toString("utf8")).toBe(encodingFileName); + } + + resolve(); + } catch (e) { + reject(e); + } + }), + ); + }), + ); + }); + + const interval = repeat(() => { + fs.writeFileSync(filepath, "world"); + }); + + try { + await Promise.all(promises); + } finally { + clearInterval(interval); + watchers.forEach(watcher => watcher.close()); + } + }); + + test("should work with url", done => { + const filepath = path.join(testDir, "url.txt"); + try { + const watcher = fs.watch(pathToFileURL(filepath)); + let err = undefined; + watcher.on("change", function (event, filename) { + try { + expect(event).toBe("change"); + expect(filename).toBe("url.txt"); + } catch (e) { + err = e; + } finally { + clearInterval(interval); + watcher.close(); + } + }); + + watcher.once("close", () => { + done(err); + }); + + const interval = repeat(() => { + fs.writeFileSync(filepath, "world"); + }); + } catch (e) { + done(e); + } + }); + + test("Signal aborted after creating the watcher", async () => { + const filepath = path.join(testDir, "abort.txt"); + + const ac = new AbortController(); + const promise = new Promise((resolve, reject) => { + const watcher = fs.watch(filepath, { signal: ac.signal }); + watcher.once("error", err => (err.message === "The operation was aborted." ? resolve() : reject(err))); + watcher.once("close", () => reject()); + }); + await Bun.sleep(10); + ac.abort(); + await promise; + }); + + test("Signal aborted before creating the watcher", async () => { + const filepath = path.join(testDir, "abort.txt"); + + const signal = AbortSignal.abort(); + await new Promise((resolve, reject) => { + const watcher = fs.watch(filepath, { signal }); + watcher.once("error", err => (err.message === "The operation was aborted." ? resolve() : reject(err))); + watcher.once("close", () => reject()); + }); + }); +}); + +describe("fs.promises.watchFile", () => { + test("add file/folder to folder", async () => { + let count = 0; + const root = path.join(testDir, "add-promise-directory"); + try { + fs.mkdirSync(root); + } catch {} + let success = false; + let err = undefined; + try { + const ac = new AbortController(); + const watcher = fs.promises.watch(root, { signal: ac.signal }); + + const interval = repeat(() => { + fs.writeFileSync(path.join(root, "new-file.txt"), "hello"); + fs.mkdirSync(path.join(root, "new-folder.txt")); + fs.rmdirSync(path.join(root, "new-folder.txt")); + }); + + for await (const event of watcher) { + count++; + try { + expect(event.eventType).toBe("rename"); + expect(["new-file.txt", "new-folder.txt"]).toContain(event.filename); + + if (count >= 2) { + success = true; + clearInterval(interval); + ac.abort(); + } + } catch (e) { + err = e; + clearInterval(interval); + ac.abort(); + } + } + } catch (e) { + if (!success) { + throw err || e; + } + } + }); + + test("add file/folder to subfolder", async () => { + let count = 0; + const root = path.join(testDir, "add-promise-subdirectory"); + try { + fs.mkdirSync(root); + } catch {} + const subfolder = path.join(root, "subfolder"); + fs.mkdirSync(subfolder); + let success = false; + let err = undefined; + + try { + const ac = new AbortController(); + const watcher = fs.promises.watch(root, { recursive: true, signal: ac.signal }); + + const interval = repeat(() => { + fs.writeFileSync(path.join(subfolder, "new-file.txt"), "hello"); + fs.mkdirSync(path.join(subfolder, "new-folder.txt")); + fs.rmdirSync(path.join(subfolder, "new-folder.txt")); + }); + for await (const event of watcher) { + const basename = path.basename(event.filename); + if (basename === "subfolder") continue; + + count++; + try { + expect(event.eventType).toBe("rename"); + expect(["new-file.txt", "new-folder.txt"]).toContain(basename); + + if (count >= 2) { + success = true; + clearInterval(interval); + ac.abort(); + } + } catch (e) { + err = e; + clearInterval(interval); + ac.abort(); + } + } + } catch (e) { + if (!success) { + throw err || e; + } + } + }); + + test("Signal aborted after creating the watcher", async () => { + const filepath = path.join(testDir, "abort.txt"); + + const ac = new AbortController(); + const watcher = fs.promises.watch(filepath, { signal: ac.signal }); + + const promise = (async () => { + try { + for await (const _ of watcher); + } catch (e) { + expect(e.message).toBe("The operation was aborted."); + } + })(); + await Bun.sleep(10); + ac.abort(); + await promise; + }); + + test("Signal aborted before creating the watcher", async () => { + const filepath = path.join(testDir, "abort.txt"); + + const signal = AbortSignal.abort(); + const watcher = fs.promises.watch(filepath, { signal }); + await (async () => { + try { + for await (const _ of watcher); + } catch (e) { + expect(e.message).toBe("The operation was aborted."); + } + })(); + }); +}); -- 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 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 bc7719fc2800e339fa9a75a124023e92bae2ec56 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 25 Jun 2023 02:58:49 -0700 Subject: Reliability bugfix for `WebSocket` (#3394) * Rewrite elementLengthLatin1IntoUTF8 * Update SIMDUTF * Make `elementLengthLatin1IntoUTF8` faster --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/simdutf.cpp | 46310 +++++++++++++++++++---------------- src/bun.js/bindings/simdutf.h | 659 +- src/http/websocket_http_client.zig | 10 +- src/string_immutable.zig | 71 +- 4 files changed, 25668 insertions(+), 21382 deletions(-) diff --git a/src/bun.js/bindings/simdutf.cpp b/src/bun.js/bindings/simdutf.cpp index ea0d95f42..6d20bcf5e 100644 --- a/src/bun.js/bindings/simdutf.cpp +++ b/src/bun.js/bindings/simdutf.cpp @@ -1,8 +1,8 @@ -/* auto-generated on 2023-02-10 14:42:58 -0500. Do not edit! */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf.cpp +/* auto-generated on 2023-06-21 08:09:45 -0400. Do not edit! */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf.cpp /* begin file src/simdutf.cpp */ #include "simdutf.h" -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=implementation.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=implementation.cpp /* begin file src/implementation.cpp */ #include #include @@ -11,22 +11,23 @@ namespace simdutf { namespace { -template -std::string toBinaryString(T b) { - std::string binary = ""; - T mask = T(1) << (sizeof(T) * CHAR_BIT - 1); - while (mask > 0) { - binary += ((b & mask) == 0) ? '0' : '1'; - mask >>= 1; - } - return binary; +template +std::string toBinaryString(T b) +{ + std::string binary = ""; + T mask = T(1) << (sizeof(T) * CHAR_BIT - 1); + while (mask > 0) { + binary += ((b & mask) == 0) ? '0' : '1'; + mask >>= 1; + } + return binary; } } } // Implementations // The best choice should always come first! -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64.h /* begin file src/simdutf/arm64.h */ #ifndef SIMDUTF_ARM64_H #define SIMDUTF_ARM64_H @@ -35,13 +36,10 @@ std::string toBinaryString(T b) { #error "arm64.h must be included before fallback.h" #endif - #ifndef SIMDUTF_IMPLEMENTATION_ARM64 #define SIMDUTF_IMPLEMENTATION_ARM64 (SIMDUTF_IS_ARM64) #endif -#define SIMDUTF_CAN_ALWAYS_RUN_ARM64 SIMDUTF_IMPLEMENTATION_ARM64 && SIMDUTF_IS_ARM64 - - +#define SIMDUTF_CAN_ALWAYS_RUN_ARM64 SIMDUTF_IMPLEMENTATION_ARM64&& SIMDUTF_IS_ARM64 #if SIMDUTF_IMPLEMENTATION_ARM64 @@ -53,12 +51,11 @@ namespace arm64 { } // namespace arm64 } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/implementation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/implementation.h /* begin file src/simdutf/arm64/implementation.h */ #ifndef SIMDUTF_ARM64_IMPLEMENTATION_H #define SIMDUTF_ARM64_IMPLEMENTATION_H - namespace simdutf { namespace arm64 { @@ -68,60 +65,85 @@ using namespace simdutf; class implementation final : public simdutf::implementation { public: - simdutf_really_inline implementation() : simdutf::implementation("arm64", "ARM NEON", internal::instruction_set::NEON) {} - simdutf_warn_unused int detect_encodings(const char * input, size_t length) const noexcept final; - simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16le(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16be(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - void change_endianness_utf16(const char16_t * buf, size_t length, char16_t * output) const noexcept final; - simdutf_warn_unused size_t count_utf16le(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf16be(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf8(const char * buf, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t length) const noexcept; + simdutf_really_inline implementation() + : simdutf::implementation("arm64", "ARM NEON", internal::instruction_set::NEON) + { + } + simdutf_warn_unused int detect_encodings(const char* input, size_t length) const noexcept final; + simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + void change_endianness_utf16(const char16_t* buf, size_t length, char16_t* output) const noexcept final; + simdutf_warn_unused size_t count_utf16le(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf16be(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf8(const char* buf, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf16(size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf32(size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_latin1(const char* input, size_t length) const noexcept; }; } // namespace arm64 @@ -130,26 +152,25 @@ public: #endif // SIMDUTF_ARM64_IMPLEMENTATION_H /* end file src/simdutf/arm64/implementation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/begin.h /* begin file src/simdutf/arm64/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "arm64" // #define SIMDUTF_IMPLEMENTATION arm64 /* end file src/simdutf/arm64/begin.h */ // Declarations -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/intrinsics.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/intrinsics.h /* begin file src/simdutf/arm64/intrinsics.h */ #ifndef SIMDUTF_ARM64_INTRINSICS_H #define SIMDUTF_ARM64_INTRINSICS_H - // This should be the correct header whether // you use visual studio or other compilers. #include #endif // SIMDUTF_ARM64_INTRINSICS_H /* end file src/simdutf/arm64/intrinsics.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/bitmanipulation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/bitmanipulation.h /* begin file src/simdutf/arm64/bitmanipulation.h */ #ifndef SIMDUTF_ARM64_BITMANIPULATION_H #define SIMDUTF_ARM64_BITMANIPULATION_H @@ -159,8 +180,9 @@ namespace arm64 { namespace { /* result might be undefined when input_num is zero */ -simdutf_really_inline int count_ones(uint64_t input_num) { - return vaddv_u8(vcnt_u8(vcreate_u8(input_num))); +simdutf_really_inline int count_ones(uint64_t input_num) +{ + return vaddv_u8(vcnt_u8(vcreate_u8(input_num))); } } // unnamed namespace @@ -169,14 +191,13 @@ simdutf_really_inline int count_ones(uint64_t input_num) { #endif // SIMDUTF_ARM64_BITMANIPULATION_H /* end file src/simdutf/arm64/bitmanipulation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/simd.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/simd.h /* begin file src/simdutf/arm64/simd.h */ #ifndef SIMDUTF_ARM64_SIMD_H #define SIMDUTF_ARM64_SIMD_H #include - namespace simdutf { namespace arm64 { namespace { @@ -186,7 +207,6 @@ namespace simd { namespace { // Start of private section with Visual Studio workaround - /** * make_uint8x16_t initializes a SIMD register (uint8x16_t). * This is needed because, incredibly, the syntax uint8x16_t x = {1,2,3...} @@ -198,130 +218,138 @@ namespace { * You should not use this function except for compile-time constants: * it is not efficient. */ -simdutf_really_inline uint8x16_t make_uint8x16_t(uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, - uint8_t x5, uint8_t x6, uint8_t x7, uint8_t x8, - uint8_t x9, uint8_t x10, uint8_t x11, uint8_t x12, - uint8_t x13, uint8_t x14, uint8_t x15, uint8_t x16) { - // Doing a load like so end ups generating worse code. - // uint8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, - // x9, x10,x11,x12,x13,x14,x15,x16}; - // return vld1q_u8(array); - uint8x16_t x{}; - // incredibly, Visual Studio does not allow x[0] = x1 - x = vsetq_lane_u8(x1, x, 0); - x = vsetq_lane_u8(x2, x, 1); - x = vsetq_lane_u8(x3, x, 2); - x = vsetq_lane_u8(x4, x, 3); - x = vsetq_lane_u8(x5, x, 4); - x = vsetq_lane_u8(x6, x, 5); - x = vsetq_lane_u8(x7, x, 6); - x = vsetq_lane_u8(x8, x, 7); - x = vsetq_lane_u8(x9, x, 8); - x = vsetq_lane_u8(x10, x, 9); - x = vsetq_lane_u8(x11, x, 10); - x = vsetq_lane_u8(x12, x, 11); - x = vsetq_lane_u8(x13, x, 12); - x = vsetq_lane_u8(x14, x, 13); - x = vsetq_lane_u8(x15, x, 14); - x = vsetq_lane_u8(x16, x, 15); - return x; +simdutf_really_inline uint8x16_t make_uint8x16_t(uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, + uint8_t x5, uint8_t x6, uint8_t x7, uint8_t x8, + uint8_t x9, uint8_t x10, uint8_t x11, uint8_t x12, + uint8_t x13, uint8_t x14, uint8_t x15, uint8_t x16) +{ + // Doing a load like so end ups generating worse code. + // uint8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, + // x9, x10,x11,x12,x13,x14,x15,x16}; + // return vld1q_u8(array); + uint8x16_t x {}; + // incredibly, Visual Studio does not allow x[0] = x1 + x = vsetq_lane_u8(x1, x, 0); + x = vsetq_lane_u8(x2, x, 1); + x = vsetq_lane_u8(x3, x, 2); + x = vsetq_lane_u8(x4, x, 3); + x = vsetq_lane_u8(x5, x, 4); + x = vsetq_lane_u8(x6, x, 5); + x = vsetq_lane_u8(x7, x, 6); + x = vsetq_lane_u8(x8, x, 7); + x = vsetq_lane_u8(x9, x, 8); + x = vsetq_lane_u8(x10, x, 9); + x = vsetq_lane_u8(x11, x, 10); + x = vsetq_lane_u8(x12, x, 11); + x = vsetq_lane_u8(x13, x, 12); + x = vsetq_lane_u8(x14, x, 13); + x = vsetq_lane_u8(x15, x, 14); + x = vsetq_lane_u8(x16, x, 15); + return x; } // We have to do the same work for make_int8x16_t -simdutf_really_inline int8x16_t make_int8x16_t(int8_t x1, int8_t x2, int8_t x3, int8_t x4, - int8_t x5, int8_t x6, int8_t x7, int8_t x8, - int8_t x9, int8_t x10, int8_t x11, int8_t x12, - int8_t x13, int8_t x14, int8_t x15, int8_t x16) { - // Doing a load like so end ups generating worse code. - // int8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, - // x9, x10,x11,x12,x13,x14,x15,x16}; - // return vld1q_s8(array); - int8x16_t x{}; - // incredibly, Visual Studio does not allow x[0] = x1 - x = vsetq_lane_s8(x1, x, 0); - x = vsetq_lane_s8(x2, x, 1); - x = vsetq_lane_s8(x3, x, 2); - x = vsetq_lane_s8(x4, x, 3); - x = vsetq_lane_s8(x5, x, 4); - x = vsetq_lane_s8(x6, x, 5); - x = vsetq_lane_s8(x7, x, 6); - x = vsetq_lane_s8(x8, x, 7); - x = vsetq_lane_s8(x9, x, 8); - x = vsetq_lane_s8(x10, x, 9); - x = vsetq_lane_s8(x11, x, 10); - x = vsetq_lane_s8(x12, x, 11); - x = vsetq_lane_s8(x13, x, 12); - x = vsetq_lane_s8(x14, x, 13); - x = vsetq_lane_s8(x15, x, 14); - x = vsetq_lane_s8(x16, x, 15); - return x; -} - -simdutf_really_inline uint8x8_t make_uint8x8_t(uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, - uint8_t x5, uint8_t x6, uint8_t x7, uint8_t x8) { - uint8x8_t x{}; - x = vset_lane_u8(x1, x, 0); - x = vset_lane_u8(x2, x, 1); - x = vset_lane_u8(x3, x, 2); - x = vset_lane_u8(x4, x, 3); - x = vset_lane_u8(x5, x, 4); - x = vset_lane_u8(x6, x, 5); - x = vset_lane_u8(x7, x, 6); - x = vset_lane_u8(x8, x, 7); - return x; -} - -simdutf_really_inline uint16x8_t make_uint16x8_t(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t x4, - uint16_t x5, uint16_t x6, uint16_t x7, uint16_t x8) { - uint16x8_t x{}; - x = vsetq_lane_u16(x1, x, 0); - x = vsetq_lane_u16(x2, x, 1); - x = vsetq_lane_u16(x3, x, 2); - x = vsetq_lane_u16(x4, x, 3); - x = vsetq_lane_u16(x5, x, 4); - x = vsetq_lane_u16(x6, x, 5); - x = vsetq_lane_u16(x7, x, 6); - x = vsetq_lane_u16(x8, x, 7);; - return x; -} - -simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t x3, int16_t x4, - int16_t x5, int16_t x6, int16_t x7, int16_t x8) { - uint16x8_t x{}; - x = vsetq_lane_s16(x1, x, 0); - x = vsetq_lane_s16(x2, x, 1); - x = vsetq_lane_s16(x3, x, 2); - x = vsetq_lane_s16(x4, x, 3); - x = vsetq_lane_s16(x5, x, 4); - x = vsetq_lane_s16(x6, x, 5); - x = vsetq_lane_s16(x7, x, 6); - x = vsetq_lane_s16(x8, x, 7);; - return x; +simdutf_really_inline int8x16_t make_int8x16_t(int8_t x1, int8_t x2, int8_t x3, int8_t x4, + int8_t x5, int8_t x6, int8_t x7, int8_t x8, + int8_t x9, int8_t x10, int8_t x11, int8_t x12, + int8_t x13, int8_t x14, int8_t x15, int8_t x16) +{ + // Doing a load like so end ups generating worse code. + // int8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, + // x9, x10,x11,x12,x13,x14,x15,x16}; + // return vld1q_s8(array); + int8x16_t x {}; + // incredibly, Visual Studio does not allow x[0] = x1 + x = vsetq_lane_s8(x1, x, 0); + x = vsetq_lane_s8(x2, x, 1); + x = vsetq_lane_s8(x3, x, 2); + x = vsetq_lane_s8(x4, x, 3); + x = vsetq_lane_s8(x5, x, 4); + x = vsetq_lane_s8(x6, x, 5); + x = vsetq_lane_s8(x7, x, 6); + x = vsetq_lane_s8(x8, x, 7); + x = vsetq_lane_s8(x9, x, 8); + x = vsetq_lane_s8(x10, x, 9); + x = vsetq_lane_s8(x11, x, 10); + x = vsetq_lane_s8(x12, x, 11); + x = vsetq_lane_s8(x13, x, 12); + x = vsetq_lane_s8(x14, x, 13); + x = vsetq_lane_s8(x15, x, 14); + x = vsetq_lane_s8(x16, x, 15); + return x; +} + +simdutf_really_inline uint8x8_t make_uint8x8_t(uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, + uint8_t x5, uint8_t x6, uint8_t x7, uint8_t x8) +{ + uint8x8_t x {}; + x = vset_lane_u8(x1, x, 0); + x = vset_lane_u8(x2, x, 1); + x = vset_lane_u8(x3, x, 2); + x = vset_lane_u8(x4, x, 3); + x = vset_lane_u8(x5, x, 4); + x = vset_lane_u8(x6, x, 5); + x = vset_lane_u8(x7, x, 6); + x = vset_lane_u8(x8, x, 7); + return x; +} + +simdutf_really_inline uint16x8_t make_uint16x8_t(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t x4, + uint16_t x5, uint16_t x6, uint16_t x7, uint16_t x8) +{ + uint16x8_t x {}; + x = vsetq_lane_u16(x1, x, 0); + x = vsetq_lane_u16(x2, x, 1); + x = vsetq_lane_u16(x3, x, 2); + x = vsetq_lane_u16(x4, x, 3); + x = vsetq_lane_u16(x5, x, 4); + x = vsetq_lane_u16(x6, x, 5); + x = vsetq_lane_u16(x7, x, 6); + x = vsetq_lane_u16(x8, x, 7); + ; + return x; +} + +simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t x3, int16_t x4, + int16_t x5, int16_t x6, int16_t x7, int16_t x8) +{ + uint16x8_t x {}; + x = vsetq_lane_s16(x1, x, 0); + x = vsetq_lane_s16(x2, x, 1); + x = vsetq_lane_s16(x3, x, 2); + x = vsetq_lane_s16(x4, x, 3); + x = vsetq_lane_s16(x5, x, 4); + x = vsetq_lane_s16(x6, x, 5); + x = vsetq_lane_s16(x7, x, 6); + x = vsetq_lane_s16(x8, x, 7); + ; + return x; } - // End of private section with Visual Studio workaround } // namespace #endif // SIMDUTF_REGULAR_VISUAL_STUDIO +template +struct simd8; - template - struct simd8; - - // - // Base class of simd8 and simd8, both of which use uint8x16_t internally. - // - template> - struct base_u8 { +// +// Base class of simd8 and simd8, both of which use uint8x16_t internally. +// +template> +struct base_u8 { uint8x16_t value; static const int SIZE = sizeof(value); // Conversion from/to SIMD register - simdutf_really_inline base_u8(const uint8x16_t _value) : value(_value) {} + simdutf_really_inline base_u8(const uint8x16_t _value) + : value(_value) + { + } simdutf_really_inline operator const uint8x16_t&() const { return this->value; } simdutf_really_inline operator uint8x16_t&() { return this->value; } - simdutf_really_inline T first() const { return vgetq_lane_u8(*this,0); } - simdutf_really_inline T last() const { return vgetq_lane_u8(*this,15); } + simdutf_really_inline T first() const { return vgetq_lane_u8(*this, 0); } + simdutf_really_inline T last() const { return vgetq_lane_u8(*this, 15); } // Bit operations simdutf_really_inline simd8 operator|(const simd8 other) const { return vorrq_u8(*this, other); } @@ -329,48 +357,74 @@ simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t simdutf_really_inline simd8 operator^(const simd8 other) const { return veorq_u8(*this, other); } simdutf_really_inline simd8 bit_andnot(const simd8 other) const { return vbicq_u8(*this, other); } simdutf_really_inline simd8 operator~() const { return *this ^ 0xFFu; } - simdutf_really_inline simd8& operator|=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast | other; return *this_cast; } - simdutf_really_inline simd8& operator&=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast & other; return *this_cast; } - simdutf_really_inline simd8& operator^=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast ^ other; return *this_cast; } + simdutf_really_inline simd8& operator|=(const simd8 other) + { + auto this_cast = static_cast*>(this); + *this_cast = *this_cast | other; + return *this_cast; + } + simdutf_really_inline simd8& operator&=(const simd8 other) + { + auto this_cast = static_cast*>(this); + *this_cast = *this_cast & other; + return *this_cast; + } + simdutf_really_inline simd8& operator^=(const simd8 other) + { + auto this_cast = static_cast*>(this); + *this_cast = *this_cast ^ other; + return *this_cast; + } - simdutf_really_inline Mask operator==(const simd8 other) const { return vceqq_u8(*this, other); } + friend simdutf_really_inline Mask operator==(const simd8 lhs, const simd8 rhs) { return vceqq_u8(lhs, rhs); } - template - simdutf_really_inline simd8 prev(const simd8 prev_chunk) const { - return vextq_u8(prev_chunk, *this, 16 - N); + template + simdutf_really_inline simd8 prev(const simd8 prev_chunk) const + { + return vextq_u8(prev_chunk, *this, 16 - N); } - }; +}; - // SIMD byte mask type (returned by things like eq and gt) - template<> - struct simd8: base_u8 { +// SIMD byte mask type (returned by things like eq and gt) +template<> +struct simd8 : base_u8 { typedef uint16_t bitmask_t; typedef uint32_t bitmask2_t; static simdutf_really_inline simd8 splat(bool _value) { return vmovq_n_u8(uint8_t(-(!!_value))); } - simdutf_really_inline simd8(const uint8x16_t _value) : base_u8(_value) {} + simdutf_really_inline simd8(const uint8x16_t _value) + : base_u8(_value) + { + } // False constructor - simdutf_really_inline simd8() : simd8(vdupq_n_u8(0)) {} + simdutf_really_inline simd8() + : simd8(vdupq_n_u8(0)) + { + } // Splat constructor - simdutf_really_inline simd8(bool _value) : simd8(splat(_value)) {} + simdutf_really_inline simd8(bool _value) + : simd8(splat(_value)) + { + } simdutf_really_inline void store(uint8_t dst[16]) const { return vst1q_u8(dst, *this); } // We return uint32_t instead of uint16_t because that seems to be more efficient for most // purposes (cutting it down to uint16_t costs performance in some compilers). - simdutf_really_inline uint32_t to_bitmask() const { + simdutf_really_inline uint32_t to_bitmask() const + { #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t bit_mask = make_uint8x16_t(0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80); + const uint8x16_t bit_mask = make_uint8x16_t(0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80); #else - const uint8x16_t bit_mask = {0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80}; + const uint8x16_t bit_mask = { 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 }; #endif - auto minput = *this & bit_mask; - uint8x16_t tmp = vpaddq_u8(minput, minput); - tmp = vpaddq_u8(tmp, tmp); - tmp = vpaddq_u8(tmp, tmp); - return vgetq_lane_u16(vreinterpretq_u16_u8(tmp), 0); + auto minput = *this & bit_mask; + uint8x16_t tmp = vpaddq_u8(minput, minput); + tmp = vpaddq_u8(tmp, tmp); + tmp = vpaddq_u8(tmp, tmp); + return vgetq_lane_u16(vreinterpretq_u16_u8(tmp), 0); } // Returns 4-bit out of each byte, alternating between the high 4 bits and low bits @@ -378,58 +432,70 @@ simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t // This method is expected to be faster than none() and is equivalent // when the vector register is the result of a comparison, with byte // values 0xff and 0x00. - simdutf_really_inline uint64_t to_bitmask64() const { - return vget_lane_u64(vreinterpret_u64_u8(vshrn_n_u16(vreinterpretq_u16_u8(*this), 4)), 0); + simdutf_really_inline uint64_t to_bitmask64() const + { + return vget_lane_u64(vreinterpret_u64_u8(vshrn_n_u16(vreinterpretq_u16_u8(*this), 4)), 0); } simdutf_really_inline bool any() const { return vmaxvq_u8(*this) != 0; } simdutf_really_inline bool none() const { return vmaxvq_u8(*this) == 0; } simdutf_really_inline bool all() const { return vminvq_u8(*this) == 0xFF; } +}; - - }; - - // Unsigned bytes - template<> - struct simd8: base_u8 { +// Unsigned bytes +template<> +struct simd8 : base_u8 { static simdutf_really_inline simd8 splat(uint8_t _value) { return vmovq_n_u8(_value); } static simdutf_really_inline simd8 zero() { return vdupq_n_u8(0); } static simdutf_really_inline simd8 load(const uint8_t* values) { return vld1q_u8(values); } - simdutf_really_inline simd8(const uint8x16_t _value) : base_u8(_value) {} + simdutf_really_inline simd8(const uint8x16_t _value) + : base_u8(_value) + { + } // Zero constructor - simdutf_really_inline simd8() : simd8(zero()) {} + simdutf_really_inline simd8() + : simd8(zero()) + { + } // Array constructor - simdutf_really_inline simd8(const uint8_t values[16]) : simd8(load(values)) {} + simdutf_really_inline simd8(const uint8_t values[16]) + : simd8(load(values)) + { + } // Splat constructor - simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {} + simdutf_really_inline simd8(uint8_t _value) + : simd8(splat(_value)) + { + } // Member-by-member initialization #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO simdutf_really_inline simd8( - uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, - uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15 - ) : simd8(make_uint8x16_t( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - )) {} + uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, + uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15) + : simd8(make_uint8x16_t( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15)) + { + } #else simdutf_really_inline simd8( - uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, - uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15 - ) : simd8(uint8x16_t{ - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - }) {} + uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, + uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15) + : simd8(uint8x16_t { + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15 }) + { + } #endif // Repeat 16 values as many times as necessary (usually for lookup tables) simdutf_really_inline static simd8 repeat_16( - uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, - uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15 - ) { - return simd8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - ); + uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, + uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15) + { + return simd8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); } // Store to array @@ -442,8 +508,16 @@ simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t // Addition/subtraction are the same for signed and unsigned simdutf_really_inline simd8 operator+(const simd8 other) const { return vaddq_u8(*this, other); } simdutf_really_inline simd8 operator-(const simd8 other) const { return vsubq_u8(*this, other); } - simdutf_really_inline simd8& operator+=(const simd8 other) { *this = *this + other; return *this; } - simdutf_really_inline simd8& operator-=(const simd8 other) { *this = *this - other; return *this; } + simdutf_really_inline simd8& operator+=(const simd8 other) + { + *this = *this + other; + return *this; + } + simdutf_really_inline simd8& operator-=(const simd8 other) + { + *this = *this - other; + return *this; + } // Order-specific operations simdutf_really_inline uint8_t max_val() const { return vmaxvq_u8(*this); } @@ -472,100 +546,116 @@ simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t // Perform a lookup assuming the value is between 0 and 16 (undefined behavior for out of range values) template - simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const { - return lookup_table.apply_lookup_16_to(*this); + simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const + { + return lookup_table.apply_lookup_16_to(*this); } - template simdutf_really_inline simd8 lookup_16( - L replace0, L replace1, L replace2, L replace3, - L replace4, L replace5, L replace6, L replace7, - L replace8, L replace9, L replace10, L replace11, - L replace12, L replace13, L replace14, L replace15) const { - return lookup_16(simd8::repeat_16( - replace0, replace1, replace2, replace3, - replace4, replace5, replace6, replace7, - replace8, replace9, replace10, replace11, - replace12, replace13, replace14, replace15 - )); + L replace0, L replace1, L replace2, L replace3, + L replace4, L replace5, L replace6, L replace7, + L replace8, L replace9, L replace10, L replace11, + L replace12, L replace13, L replace14, L replace15) const + { + return lookup_16(simd8::repeat_16( + replace0, replace1, replace2, replace3, + replace4, replace5, replace6, replace7, + replace8, replace9, replace10, replace11, + replace12, replace13, replace14, replace15)); } template - simdutf_really_inline simd8 apply_lookup_16_to(const simd8 original) const { - return vqtbl1q_u8(*this, simd8(original)); + simdutf_really_inline simd8 apply_lookup_16_to(const simd8 original) const + { + return vqtbl1q_u8(*this, simd8(original)); } - }; +}; - // Signed bytes - template<> - struct simd8 { +// Signed bytes +template<> +struct simd8 { int8x16_t value; static simdutf_really_inline simd8 splat(int8_t _value) { return vmovq_n_s8(_value); } static simdutf_really_inline simd8 zero() { return vdupq_n_s8(0); } static simdutf_really_inline simd8 load(const int8_t values[16]) { return vld1q_s8(values); } - template - simdutf_really_inline void store_ascii_as_utf16(char16_t * p) const { - uint16x8_t first = vmovl_u8(vget_low_u8 (vreinterpretq_u8_s8(this->value))); - uint16x8_t second = vmovl_high_u8(vreinterpretq_u8_s8(this->value)); - if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - first = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(first), swap)); - second = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(second), swap)); - } - vst1q_u16(reinterpret_cast(p), first); - vst1q_u16(reinterpret_cast(p + 8), second); - } - simdutf_really_inline void store_ascii_as_utf32(char32_t * p) const { - vst1q_u32(reinterpret_cast(p), vmovl_u16(vget_low_u16(vmovl_u8(vget_low_u8 (vreinterpretq_u8_s8(this->value)))))); - vst1q_u32(reinterpret_cast(p + 4), vmovl_high_u16(vmovl_u8(vget_low_u8 (vreinterpretq_u8_s8(this->value))))); - vst1q_u32(reinterpret_cast(p + 8), vmovl_u16(vget_low_u16(vmovl_high_u8(vreinterpretq_u8_s8(this->value))))); - vst1q_u32(reinterpret_cast(p + 12), vmovl_high_u16(vmovl_high_u8(vreinterpretq_u8_s8(this->value)))); + template + simdutf_really_inline void store_ascii_as_utf16(char16_t* p) const + { + uint16x8_t first = vmovl_u8(vget_low_u8(vreinterpretq_u8_s8(this->value))); + uint16x8_t second = vmovl_high_u8(vreinterpretq_u8_s8(this->value)); + if (!match_system(big_endian)) { +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + first = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(first), swap)); + second = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(second), swap)); + } + vst1q_u16(reinterpret_cast(p), first); + vst1q_u16(reinterpret_cast(p + 8), second); + } + simdutf_really_inline void store_ascii_as_utf32(char32_t* p) const + { + vst1q_u32(reinterpret_cast(p), vmovl_u16(vget_low_u16(vmovl_u8(vget_low_u8(vreinterpretq_u8_s8(this->value)))))); + vst1q_u32(reinterpret_cast(p + 4), vmovl_high_u16(vmovl_u8(vget_low_u8(vreinterpretq_u8_s8(this->value))))); + vst1q_u32(reinterpret_cast(p + 8), vmovl_u16(vget_low_u16(vmovl_high_u8(vreinterpretq_u8_s8(this->value))))); + vst1q_u32(reinterpret_cast(p + 12), vmovl_high_u16(vmovl_high_u8(vreinterpretq_u8_s8(this->value)))); } // Conversion from/to SIMD register - simdutf_really_inline simd8(const int8x16_t _value) : value{_value} {} + simdutf_really_inline simd8(const int8x16_t _value) + : value { _value } + { + } simdutf_really_inline operator const int8x16_t&() const { return this->value; } simdutf_really_inline operator const uint8x16_t() const { return vreinterpretq_u8_s8(this->value); } simdutf_really_inline operator int8x16_t&() { return this->value; } // Zero constructor - simdutf_really_inline simd8() : simd8(zero()) {} + simdutf_really_inline simd8() + : simd8(zero()) + { + } // Splat constructor - simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {} + simdutf_really_inline simd8(int8_t _value) + : simd8(splat(_value)) + { + } // Array constructor - simdutf_really_inline simd8(const int8_t* values) : simd8(load(values)) {} + simdutf_really_inline simd8(const int8_t* values) + : simd8(load(values)) + { + } // Member-by-member initialization #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO simdutf_really_inline simd8( - int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, - int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15 - ) : simd8(make_int8x16_t( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - )) {} + int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, + int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15) + : simd8(make_int8x16_t( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15)) + { + } #else simdutf_really_inline simd8( - int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, - int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15 - ) : simd8(int8x16_t{ - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - }) {} + int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, + int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15) + : simd8(int8x16_t { + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15 }) + { + } #endif // Repeat 16 values as many times as necessary (usually for lookup tables) simdutf_really_inline static simd8 repeat_16( - int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, - int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15 - ) { - return simd8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - ); + int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, + int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15) + { + return simd8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); } // Store to array @@ -576,9 +666,15 @@ simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t // In theory, we could check this occurrence with std::same_as and std::enabled_if but it is C++14 // and relatively ugly and hard to read. #ifndef SIMDUTF_REGULAR_VISUAL_STUDIO - simdutf_really_inline explicit simd8(const uint8x16_t other): simd8(vreinterpretq_s8_u8(other)) {} + simdutf_really_inline explicit simd8(const uint8x16_t other) + : simd8(vreinterpretq_s8_u8(other)) + { + } #endif - simdutf_really_inline operator simd8() const { return vreinterpretq_u8_s8(this->value); } + simdutf_really_inline operator simd8() const + { + return vreinterpretq_u8_s8(this->value); + } simdutf_really_inline simd8 operator|(const simd8 other) const { return vorrq_s8(value, other.value); } simdutf_really_inline simd8 operator&(const simd8 other) const { return vandq_s8(value, other.value); } @@ -588,8 +684,16 @@ simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t // Math simdutf_really_inline simd8 operator+(const simd8 other) const { return vaddq_s8(value, other.value); } simdutf_really_inline simd8 operator-(const simd8 other) const { return vsubq_s8(value, other.value); } - simdutf_really_inline simd8& operator+=(const simd8 other) { *this = *this + other; return *this; } - simdutf_really_inline simd8& operator-=(const simd8 other) { *this = *this - other; return *this; } + simdutf_really_inline simd8& operator+=(const simd8 other) + { + *this = *this + other; + return *this; + } + simdutf_really_inline simd8& operator-=(const simd8 other) + { + *this = *this - other; + return *this; + } simdutf_really_inline int8_t max_val() const { return vmaxvq_s8(value); } simdutf_really_inline int8_t min_val() const { return vminvq_s8(value); } @@ -602,38 +706,41 @@ simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t simdutf_really_inline simd8 operator<(const simd8 other) const { return vcltq_s8(value, other.value); } simdutf_really_inline simd8 operator==(const simd8 other) const { return vceqq_s8(value, other.value); } - template - simdutf_really_inline simd8 prev(const simd8 prev_chunk) const { - return vextq_s8(prev_chunk, *this, 16 - N); + template + simdutf_really_inline simd8 prev(const simd8 prev_chunk) const + { + return vextq_s8(prev_chunk, *this, 16 - N); } // Perform a lookup assuming no value is larger than 16 template - simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const { - return lookup_table.apply_lookup_16_to(*this); + simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const + { + return lookup_table.apply_lookup_16_to(*this); } template simdutf_really_inline simd8 lookup_16( - L replace0, L replace1, L replace2, L replace3, - L replace4, L replace5, L replace6, L replace7, - L replace8, L replace9, L replace10, L replace11, - L replace12, L replace13, L replace14, L replace15) const { - return lookup_16(simd8::repeat_16( - replace0, replace1, replace2, replace3, - replace4, replace5, replace6, replace7, - replace8, replace9, replace10, replace11, - replace12, replace13, replace14, replace15 - )); + L replace0, L replace1, L replace2, L replace3, + L replace4, L replace5, L replace6, L replace7, + L replace8, L replace9, L replace10, L replace11, + L replace12, L replace13, L replace14, L replace15) const + { + return lookup_16(simd8::repeat_16( + replace0, replace1, replace2, replace3, + replace4, replace5, replace6, replace7, + replace8, replace9, replace10, replace11, + replace12, replace13, replace14, replace15)); } template - simdutf_really_inline simd8 apply_lookup_16_to(const simd8 original) { - return vqtbl1q_s8(*this, simd8(original)); + simdutf_really_inline simd8 apply_lookup_16_to(const simd8 original) + { + return vqtbl1q_s8(*this, simd8(original)); } - }; +}; - template - struct simd8x64 { +template +struct simd8x64 { static constexpr int NUM_CHUNKS = 64 / sizeof(simd8); static_assert(NUM_CHUNKS == 4, "ARM kernel should use four registers per 64-byte block."); simd8 chunks[NUM_CHUNKS]; @@ -642,159 +749,181 @@ simdutf_really_inline int16x8_t make_int16x8_t(int16_t x1, int16_t x2, int16_t simd8x64& operator=(const simd8 other) = delete; // no assignment allowed simd8x64() = delete; // no default constructor allowed - simdutf_really_inline simd8x64(const simd8 chunk0, const simd8 chunk1, const simd8 chunk2, const simd8 chunk3) : chunks{chunk0, chunk1, chunk2, chunk3} {} - simdutf_really_inline simd8x64(const T* ptr) : chunks{simd8::load(ptr), simd8::load(ptr+sizeof(simd8)/sizeof(T)), simd8::load(ptr+2*sizeof(simd8)/sizeof(T)), simd8::load(ptr+3*sizeof(simd8)/sizeof(T))} {} - - simdutf_really_inline void store(T* ptr) const { - this->chunks[0].store(ptr+sizeof(simd8)*0/sizeof(T)); - this->chunks[1].store(ptr+sizeof(simd8)*1/sizeof(T)); - this->chunks[2].store(ptr+sizeof(simd8)*2/sizeof(T)); - this->chunks[3].store(ptr+sizeof(simd8)*3/sizeof(T)); + simdutf_really_inline simd8x64(const simd8 chunk0, const simd8 chunk1, const simd8 chunk2, const simd8 chunk3) + : chunks { chunk0, chunk1, chunk2, chunk3 } + { + } + simdutf_really_inline simd8x64(const T* ptr) + : chunks { simd8::load(ptr), simd8::load(ptr + sizeof(simd8) / sizeof(T)), simd8::load(ptr + 2 * sizeof(simd8) / sizeof(T)), simd8::load(ptr + 3 * sizeof(simd8) / sizeof(T)) } + { } + simdutf_really_inline void store(T* ptr) const + { + this->chunks[0].store(ptr + sizeof(simd8) * 0 / sizeof(T)); + this->chunks[1].store(ptr + sizeof(simd8) * 1 / sizeof(T)); + this->chunks[2].store(ptr + sizeof(simd8) * 2 / sizeof(T)); + this->chunks[3].store(ptr + sizeof(simd8) * 3 / sizeof(T)); + } - simdutf_really_inline simd8x64& operator |=(const simd8x64 &other) { - this->chunks[0] |= other.chunks[0]; - this->chunks[1] |= other.chunks[1]; - this->chunks[2] |= other.chunks[2]; - this->chunks[3] |= other.chunks[3]; - return *this; + simdutf_really_inline simd8x64& operator|=(const simd8x64& other) + { + this->chunks[0] |= other.chunks[0]; + this->chunks[1] |= other.chunks[1]; + this->chunks[2] |= other.chunks[2]; + this->chunks[3] |= other.chunks[3]; + return *this; } - simdutf_really_inline simd8 reduce_or() const { - return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); + simdutf_really_inline simd8 reduce_or() const + { + return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); } - simdutf_really_inline bool is_ascii() const { - return reduce_or().is_ascii(); + simdutf_really_inline bool is_ascii() const + { + return reduce_or().is_ascii(); } - template - simdutf_really_inline void store_ascii_as_utf16(char16_t * ptr) const { - this->chunks[0].template store_ascii_as_utf16(ptr+sizeof(simd8)*0); - this->chunks[1].template store_ascii_as_utf16(ptr+sizeof(simd8)*1); - this->chunks[2].template store_ascii_as_utf16(ptr+sizeof(simd8)*2); - this->chunks[3].template store_ascii_as_utf16(ptr+sizeof(simd8)*3); + template + simdutf_really_inline void store_ascii_as_utf16(char16_t* ptr) const + { + this->chunks[0].template store_ascii_as_utf16(ptr + sizeof(simd8) * 0); + this->chunks[1].template store_ascii_as_utf16(ptr + sizeof(simd8) * 1); + this->chunks[2].template store_ascii_as_utf16(ptr + sizeof(simd8) * 2); + this->chunks[3].template store_ascii_as_utf16(ptr + sizeof(simd8) * 3); } - simdutf_really_inline void store_ascii_as_utf32(char32_t * ptr) const { - this->chunks[0].store_ascii_as_utf32(ptr+sizeof(simd8)*0); - this->chunks[1].store_ascii_as_utf32(ptr+sizeof(simd8)*1); - this->chunks[2].store_ascii_as_utf32(ptr+sizeof(simd8)*2); - this->chunks[3].store_ascii_as_utf32(ptr+sizeof(simd8)*3); + simdutf_really_inline void store_ascii_as_utf32(char32_t* ptr) const + { + this->chunks[0].store_ascii_as_utf32(ptr + sizeof(simd8) * 0); + this->chunks[1].store_ascii_as_utf32(ptr + sizeof(simd8) * 1); + this->chunks[2].store_ascii_as_utf32(ptr + sizeof(simd8) * 2); + this->chunks[3].store_ascii_as_utf32(ptr + sizeof(simd8) * 3); } - simdutf_really_inline uint64_t to_bitmask() const { + simdutf_really_inline uint64_t to_bitmask() const + { #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t bit_mask = make_uint8x16_t( - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 - ); + const uint8x16_t bit_mask = make_uint8x16_t( + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80); #else - const uint8x16_t bit_mask = { - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 - }; + const uint8x16_t bit_mask = { + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 + }; #endif - // Add each of the elements next to each other, successively, to stuff each 8 byte mask into one. - uint8x16_t sum0 = vpaddq_u8(vandq_u8(uint8x16_t(this->chunks[0]), bit_mask), vandq_u8(uint8x16_t(this->chunks[1]), bit_mask)); - uint8x16_t sum1 = vpaddq_u8(vandq_u8(uint8x16_t(this->chunks[2]), bit_mask), vandq_u8(uint8x16_t(this->chunks[3]), bit_mask)); - sum0 = vpaddq_u8(sum0, sum1); - sum0 = vpaddq_u8(sum0, sum0); - return vgetq_lane_u64(vreinterpretq_u64_u8(sum0), 0); - } - - simdutf_really_inline uint64_t eq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] == mask, - this->chunks[1] == mask, - this->chunks[2] == mask, - this->chunks[3] == mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t lteq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] <= mask, - this->chunks[1] <= mask, - this->chunks[2] <= mask, - this->chunks[3] <= mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t in_range(const T low, const T high) const { - const simd8 mask_low = simd8::splat(low); - const simd8 mask_high = simd8::splat(high); - - return simd8x64( - (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), - (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), - (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), - (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t not_in_range(const T low, const T high) const { - const simd8 mask_low = simd8::splat(low); - const simd8 mask_high = simd8::splat(high); - return simd8x64( - (this->chunks[0] > mask_high) | (this->chunks[0] < mask_low), - (this->chunks[1] > mask_high) | (this->chunks[1] < mask_low), - (this->chunks[2] > mask_high) | (this->chunks[2] < mask_low), - (this->chunks[3] > mask_high) | (this->chunks[3] < mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t lt(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] < mask, - this->chunks[1] < mask, - this->chunks[2] < mask, - this->chunks[3] < mask - ).to_bitmask(); - } - simdutf_really_inline uint64_t gt(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] > mask, - this->chunks[1] > mask, - this->chunks[2] > mask, - this->chunks[3] > mask - ).to_bitmask(); - } - simdutf_really_inline uint64_t gteq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] >= mask, - this->chunks[1] >= mask, - this->chunks[2] >= mask, - this->chunks[3] >= mask - ).to_bitmask(); - } - simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - simd8(uint8x16_t(this->chunks[0])) >= mask, - simd8(uint8x16_t(this->chunks[1])) >= mask, - simd8(uint8x16_t(this->chunks[2])) >= mask, - simd8(uint8x16_t(this->chunks[3])) >= mask - ).to_bitmask(); - } - }; // struct simd8x64 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/simd16-inl.h + // Add each of the elements next to each other, successively, to stuff each 8 byte mask into one. + uint8x16_t sum0 = vpaddq_u8(vandq_u8(uint8x16_t(this->chunks[0]), bit_mask), vandq_u8(uint8x16_t(this->chunks[1]), bit_mask)); + uint8x16_t sum1 = vpaddq_u8(vandq_u8(uint8x16_t(this->chunks[2]), bit_mask), vandq_u8(uint8x16_t(this->chunks[3]), bit_mask)); + sum0 = vpaddq_u8(sum0, sum1); + sum0 = vpaddq_u8(sum0, sum0); + return vgetq_lane_u64(vreinterpretq_u64_u8(sum0), 0); + } + + simdutf_really_inline uint64_t eq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] == mask, + this->chunks[1] == mask, + this->chunks[2] == mask, + this->chunks[3] == mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t lteq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] <= mask, + this->chunks[1] <= mask, + this->chunks[2] <= mask, + this->chunks[3] <= mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t in_range(const T low, const T high) const + { + const simd8 mask_low = simd8::splat(low); + const simd8 mask_high = simd8::splat(high); + + return simd8x64( + (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), + (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), + (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), + (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t not_in_range(const T low, const T high) const + { + const simd8 mask_low = simd8::splat(low); + const simd8 mask_high = simd8::splat(high); + return simd8x64( + (this->chunks[0] > mask_high) | (this->chunks[0] < mask_low), + (this->chunks[1] > mask_high) | (this->chunks[1] < mask_low), + (this->chunks[2] > mask_high) | (this->chunks[2] < mask_low), + (this->chunks[3] > mask_high) | (this->chunks[3] < mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t lt(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] < mask, + this->chunks[1] < mask, + this->chunks[2] < mask, + this->chunks[3] < mask) + .to_bitmask(); + } + simdutf_really_inline uint64_t gt(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] > mask, + this->chunks[1] > mask, + this->chunks[2] > mask, + this->chunks[3] > mask) + .to_bitmask(); + } + simdutf_really_inline uint64_t gteq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] >= mask, + this->chunks[1] >= mask, + this->chunks[2] >= mask, + this->chunks[3] >= mask) + .to_bitmask(); + } + simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + simd8(uint8x16_t(this->chunks[0])) >= mask, + simd8(uint8x16_t(this->chunks[1])) >= mask, + simd8(uint8x16_t(this->chunks[2])) >= mask, + simd8(uint8x16_t(this->chunks[3])) >= mask) + .to_bitmask(); + } +}; // struct simd8x64 +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/simd16-inl.h /* begin file src/simdutf/arm64/simd16-inl.h */ template struct simd16; - template> - struct base_u16 { +template> +struct base_u16 { uint16x8_t value; static const int SIZE = sizeof(value); // Conversion from/to SIMD register simdutf_really_inline base_u16() = default; - simdutf_really_inline base_u16(const uint16x8_t _value) : value(_value) {} + simdutf_really_inline base_u16(const uint16x8_t _value) + : value(_value) + { + } simdutf_really_inline operator const uint16x8_t&() const { return this->value; } simdutf_really_inline operator uint16x8_t&() { return this->value; } // Bit operations @@ -803,167 +932,244 @@ struct simd16; simdutf_really_inline simd16 operator^(const simd16 other) const { return veorq_u16(*this, other); } simdutf_really_inline simd16 bit_andnot(const simd16 other) const { return vbicq_u16(*this, other); } simdutf_really_inline simd16 operator~() const { return *this ^ 0xFFu; } - simdutf_really_inline simd16& operator|=(const simd16 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast | other; return *this_cast; } - simdutf_really_inline simd16& operator&=(const simd16 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast & other; return *this_cast; } - simdutf_really_inline simd16& operator^=(const simd16 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast ^ other; return *this_cast; } + simdutf_really_inline simd16& operator|=(const simd16 other) + { + auto this_cast = static_cast*>(this); + *this_cast = *this_cast | other; + return *this_cast; + } + simdutf_really_inline simd16& operator&=(const simd16 other) + { + auto this_cast = static_cast*>(this); + *this_cast = *this_cast & other; + return *this_cast; + } + simdutf_really_inline simd16& operator^=(const simd16 other) + { + auto this_cast = static_cast*>(this); + *this_cast = *this_cast ^ other; + return *this_cast; + } - simdutf_really_inline Mask operator==(const simd16 other) const { return vceqq_u16(*this, other); } + friend simdutf_really_inline Mask operator==(const simd16 lhs, const simd16 rhs) { return vceqq_u16(lhs, rhs); } - template - simdutf_really_inline simd16 prev(const simd16 prev_chunk) const { - return vextq_u18(prev_chunk, *this, 8 - N); + template + simdutf_really_inline simd16 prev(const simd16 prev_chunk) const + { + return vextq_u18(prev_chunk, *this, 8 - N); } - }; - -template> -struct base16: base_u16 { - typedef uint16_t bitmask_t; - typedef uint32_t bitmask2_t; +}; - simdutf_really_inline base16() : base_u16() {} - simdutf_really_inline base16(const uint16x8_t _value) : base_u16(_value) {} - template - simdutf_really_inline base16(const Pointer* ptr) : base16(vld1q_u16(ptr)) {} +template> +struct base16 : base_u16 { + typedef uint16_t bitmask_t; + typedef uint32_t bitmask2_t; - simdutf_really_inline Mask operator==(const simd16 other) const { return vceqq_u16(*this, other); } + simdutf_really_inline base16() + : base_u16() + { + } + simdutf_really_inline base16(const uint16x8_t _value) + : base_u16(_value) + { + } + template + simdutf_really_inline base16(const Pointer* ptr) + : base16(vld1q_u16(ptr)) + { + } - static const int SIZE = sizeof(base_u16::value); + static const int SIZE = sizeof(base_u16::value); - template - simdutf_really_inline simd16 prev(const simd16 prev_chunk) const { - return vextq_u18(prev_chunk, *this, 8 - N); - } + template + simdutf_really_inline simd16 prev(const simd16 prev_chunk) const + { + return vextq_u18(prev_chunk, *this, 8 - N); + } }; // SIMD byte mask type (returned by things like eq and gt) template<> -struct simd16: base16 { - static simdutf_really_inline simd16 splat(bool _value) { return vmovq_n_u16(uint16_t(-(!!_value))); } - - simdutf_really_inline simd16() : base16() {} - simdutf_really_inline simd16(const uint16x8_t _value) : base16(_value) {} - // Splat constructor - simdutf_really_inline simd16(bool _value) : base16(splat(_value)) {} +struct simd16 : base16 { + static simdutf_really_inline simd16 splat(bool _value) { return vmovq_n_u16(uint16_t(-(!!_value))); } + simdutf_really_inline simd16() + : base16() + { + } + simdutf_really_inline simd16(const uint16x8_t _value) + : base16(_value) + { + } + // Splat constructor + simdutf_really_inline simd16(bool _value) + : base16(splat(_value)) + { + } }; template -struct base16_numeric: base16 { - static simdutf_really_inline simd16 splat(T _value) { return vmovq_n_u16(_value); } - static simdutf_really_inline simd16 zero() { return vdupq_n_u16(0); } - static simdutf_really_inline simd16 load(const T values[8]) { - return vld1q_u16(reinterpret_cast(values)); - } - - simdutf_really_inline base16_numeric() : base16() {} - simdutf_really_inline base16_numeric(const uint16x8_t _value) : base16(_value) {} - - // Store to array - simdutf_really_inline void store(T dst[8]) const { return vst1q_u16(dst, *this); } - - // Override to distinguish from bool version - simdutf_really_inline simd16 operator~() const { return *this ^ 0xFFu; } - - // Addition/subtraction are the same for signed and unsigned - simdutf_really_inline simd16 operator+(const simd16 other) const { return vaddq_u8(*this, other); } - simdutf_really_inline simd16 operator-(const simd16 other) const { return vsubq_u8(*this, other); } - simdutf_really_inline simd16& operator+=(const simd16 other) { *this = *this + other; return *static_cast*>(this); } - simdutf_really_inline simd16& operator-=(const simd16 other) { *this = *this - other; return *static_cast*>(this); } +struct base16_numeric : base16 { + static simdutf_really_inline simd16 splat(T _value) { return vmovq_n_u16(_value); } + static simdutf_really_inline simd16 zero() { return vdupq_n_u16(0); } + static simdutf_really_inline simd16 load(const T values[8]) + { + return vld1q_u16(reinterpret_cast(values)); + } + + simdutf_really_inline base16_numeric() + : base16() + { + } + simdutf_really_inline base16_numeric(const uint16x8_t _value) + : base16(_value) + { + } + + // Store to array + simdutf_really_inline void store(T dst[8]) const { return vst1q_u16(dst, *this); } + + // Override to distinguish from bool version + simdutf_really_inline simd16 operator~() const { return *this ^ 0xFFu; } + + // Addition/subtraction are the same for signed and unsigned + simdutf_really_inline simd16 operator+(const simd16 other) const { return vaddq_u8(*this, other); } + simdutf_really_inline simd16 operator-(const simd16 other) const { return vsubq_u8(*this, other); } + simdutf_really_inline simd16& operator+=(const simd16 other) + { + *this = *this + other; + return *static_cast*>(this); + } + simdutf_really_inline simd16& operator-=(const simd16 other) + { + *this = *this - other; + return *static_cast*>(this); + } }; // Signed words template<> struct simd16 : base16_numeric { - simdutf_really_inline simd16() : base16_numeric() {} + simdutf_really_inline simd16() + : base16_numeric() + { + } #ifndef SIMDUTF_REGULAR_VISUAL_STUDIO - simdutf_really_inline simd16(const uint16x8_t _value) : base16_numeric(_value) {} + simdutf_really_inline simd16(const uint16x8_t _value) + : base16_numeric(_value) + { + } #endif - simdutf_really_inline simd16(const int16x8_t _value) : base16_numeric(vreinterpretq_u16_s16(_value)) {} - - // Splat constructor - simdutf_really_inline simd16(int16_t _value) : simd16(splat(_value)) {} - // Array constructor - simdutf_really_inline simd16(const int16_t* values) : simd16(load(values)) {} - simdutf_really_inline simd16(const char16_t* values) : simd16(load(reinterpret_cast(values))) {} - simdutf_really_inline operator simd16() const; - simdutf_really_inline operator const uint16x8_t&() const { return this->value; } - simdutf_really_inline operator const int16x8_t() const { return vreinterpretq_s16_u16(this->value); } - - simdutf_really_inline int16_t max_val() const { return vmaxvq_s16(vreinterpretq_s16_u16(this->value)); } - simdutf_really_inline int16_t min_val() const { return vminvq_s16(vreinterpretq_s16_u16(this->value)); } - // Order-sensitive comparisons - simdutf_really_inline simd16 max_val(const simd16 other) const { return vmaxq_s16(vreinterpretq_s16_u16(this->value), vreinterpretq_s16_u16(other.value)); } - simdutf_really_inline simd16 min_val(const simd16 other) const { return vmaxq_s16(vreinterpretq_s16_u16(this->value), vreinterpretq_s16_u16(other.value)); } - simdutf_really_inline simd16 operator>(const simd16 other) const { return vcgtq_s16(vreinterpretq_s16_u16(this->value), vreinterpretq_s16_u16(other.value)); } - simdutf_really_inline simd16 operator<(const simd16 other) const { return vcltq_s16(vreinterpretq_s16_u16(this->value), vreinterpretq_s16_u16(other.value)); } -}; - + simdutf_really_inline simd16(const int16x8_t _value) + : base16_numeric(vreinterpretq_u16_s16(_value)) + { + } + // Splat constructor + simdutf_really_inline simd16(int16_t _value) + : simd16(splat(_value)) + { + } + // Array constructor + simdutf_really_inline simd16(const int16_t* values) + : simd16(load(values)) + { + } + simdutf_really_inline simd16(const char16_t* values) + : simd16(load(reinterpret_cast(values))) + { + } + simdutf_really_inline operator simd16() const; + simdutf_really_inline operator const uint16x8_t&() const { return this->value; } + simdutf_really_inline operator const int16x8_t() const { return vreinterpretq_s16_u16(this->value); } + simdutf_really_inline int16_t max_val() const { return vmaxvq_s16(vreinterpretq_s16_u16(this->value)); } + simdutf_really_inline int16_t min_val() const { return vminvq_s16(vreinterpretq_s16_u16(this->value)); } + // Order-sensitive comparisons + simdutf_really_inline simd16 max_val(const simd16 other) const { return vmaxq_s16(vreinterpretq_s16_u16(this->value), vreinterpretq_s16_u16(other.value)); } + simdutf_really_inline simd16 min_val(const simd16 other) const { return vmaxq_s16(vreinterpretq_s16_u16(this->value), vreinterpretq_s16_u16(other.value)); } + simdutf_really_inline simd16 operator>(const simd16 other) const { return vcgtq_s16(vreinterpretq_s16_u16(this->value), vreinterpretq_s16_u16(other.value)); } + simdutf_really_inline simd16 operator<(const simd16 other) const { return vcltq_s16(vreinterpretq_s16_u16(this->value), vreinterpretq_s16_u16(other.value)); } +}; // Unsigned words template<> -struct simd16: base16_numeric { - simdutf_really_inline simd16() : base16_numeric() {} - simdutf_really_inline simd16(const uint16x8_t _value) : base16_numeric(_value) {} - - // Splat constructor - simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {} - // Array constructor - simdutf_really_inline simd16(const uint16_t* values) : simd16(load(values)) {} - simdutf_really_inline simd16(const char16_t* values) : simd16(load(reinterpret_cast(values))) {} - - - simdutf_really_inline int16_t max_val() const { return vmaxvq_u16(*this); } - simdutf_really_inline int16_t min_val() const { return vminvq_u16(*this); } - // Saturated math - simdutf_really_inline simd16 saturating_add(const simd16 other) const { return vqaddq_u16(*this, other); } - simdutf_really_inline simd16 saturating_sub(const simd16 other) const { return vqsubq_u16(*this, other); } - - // Order-specific operations - simdutf_really_inline simd16 max_val(const simd16 other) const { return vmaxq_u16(*this, other); } - simdutf_really_inline simd16 min_val(const simd16 other) const { return vminq_u16(*this, other); } - // Same as >, but only guarantees true is nonzero (< guarantees true = -1) - simdutf_really_inline simd16 gt_bits(const simd16 other) const { return this->saturating_sub(other); } - // Same as <, but only guarantees true is nonzero (< guarantees true = -1) - simdutf_really_inline simd16 lt_bits(const simd16 other) const { return other.saturating_sub(*this); } - simdutf_really_inline simd16 operator<=(const simd16 other) const { return vcleq_u16(*this, other); } - simdutf_really_inline simd16 operator>=(const simd16 other) const { return vcgeq_u16(*this, other); } - simdutf_really_inline simd16 operator>(const simd16 other) const { return vcgtq_u16(*this, other); } - simdutf_really_inline simd16 operator<(const simd16 other) const { return vcltq_u16(*this, other); } - - // Bit-specific operations - simdutf_really_inline simd16 bits_not_set() const { return *this == uint16_t(0); } - template - simdutf_really_inline simd16 shr() const { return simd16(vshrq_n_u16(*this, N)); } - template - simdutf_really_inline simd16 shl() const { return simd16(vshlq_n_u16(*this, N)); } - - // logical operations - simdutf_really_inline simd16 operator|(const simd16 other) const { return vorrq_u16(*this, other); } - simdutf_really_inline simd16 operator&(const simd16 other) const { return vandq_u16(*this, other); } - simdutf_really_inline simd16 operator^(const simd16 other) const { return veorq_u16(*this, other); } - - // Pack with the unsigned saturation two uint16_t words into single uint8_t vector - static simdutf_really_inline simd8 pack(const simd16& v0, const simd16& v1) { - return vqmovn_high_u16(vqmovn_u16(v0), v1); - } - - // Change the endianness - simdutf_really_inline simd16 swap_bytes() const { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - return vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(*this), swap)); - } +struct simd16 : base16_numeric { + simdutf_really_inline simd16() + : base16_numeric() + { + } + simdutf_really_inline simd16(const uint16x8_t _value) + : base16_numeric(_value) + { + } + + // Splat constructor + simdutf_really_inline simd16(uint16_t _value) + : simd16(splat(_value)) + { + } + // Array constructor + simdutf_really_inline simd16(const uint16_t* values) + : simd16(load(values)) + { + } + simdutf_really_inline simd16(const char16_t* values) + : simd16(load(reinterpret_cast(values))) + { + } + + simdutf_really_inline int16_t max_val() const { return vmaxvq_u16(*this); } + simdutf_really_inline int16_t min_val() const { return vminvq_u16(*this); } + // Saturated math + simdutf_really_inline simd16 saturating_add(const simd16 other) const { return vqaddq_u16(*this, other); } + simdutf_really_inline simd16 saturating_sub(const simd16 other) const { return vqsubq_u16(*this, other); } + + // Order-specific operations + simdutf_really_inline simd16 max_val(const simd16 other) const { return vmaxq_u16(*this, other); } + simdutf_really_inline simd16 min_val(const simd16 other) const { return vminq_u16(*this, other); } + // Same as >, but only guarantees true is nonzero (< guarantees true = -1) + simdutf_really_inline simd16 gt_bits(const simd16 other) const { return this->saturating_sub(other); } + // Same as <, but only guarantees true is nonzero (< guarantees true = -1) + simdutf_really_inline simd16 lt_bits(const simd16 other) const { return other.saturating_sub(*this); } + simdutf_really_inline simd16 operator<=(const simd16 other) const { return vcleq_u16(*this, other); } + simdutf_really_inline simd16 operator>=(const simd16 other) const { return vcgeq_u16(*this, other); } + simdutf_really_inline simd16 operator>(const simd16 other) const { return vcgtq_u16(*this, other); } + simdutf_really_inline simd16 operator<(const simd16 other) const { return vcltq_u16(*this, other); } + + // Bit-specific operations + simdutf_really_inline simd16 bits_not_set() const { return *this == uint16_t(0); } + template + simdutf_really_inline simd16 shr() const { return simd16(vshrq_n_u16(*this, N)); } + template + simdutf_really_inline simd16 shl() const { return simd16(vshlq_n_u16(*this, N)); } + + // logical operations + simdutf_really_inline simd16 operator|(const simd16 other) const { return vorrq_u16(*this, other); } + simdutf_really_inline simd16 operator&(const simd16 other) const { return vandq_u16(*this, other); } + simdutf_really_inline simd16 operator^(const simd16 other) const { return veorq_u16(*this, other); } + + // Pack with the unsigned saturation two uint16_t words into single uint8_t vector + static simdutf_really_inline simd8 pack(const simd16& v0, const simd16& v1) + { + return vqmovn_high_u16(vqmovn_u16(v0), v1); + } + + // Change the endianness + simdutf_really_inline simd16 swap_bytes() const + { +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + return vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(*this), swap)); + } }; simdutf_really_inline simd16::operator simd16() const { return this->value; } - - template - struct simd16x32 { +template +struct simd16x32 { static constexpr int NUM_CHUNKS = 64 / sizeof(simd16); static_assert(NUM_CHUNKS == 4, "ARM kernel should use four registers per 64-byte block."); simd16 chunks[NUM_CHUNKS]; @@ -972,132 +1178,148 @@ simdutf_really_inline simd16::operator simd16() const { retur simd16x32& operator=(const simd16 other) = delete; // no assignment allowed simd16x32() = delete; // no default constructor allowed - simdutf_really_inline simd16x32(const simd16 chunk0, const simd16 chunk1, const simd16 chunk2, const simd16 chunk3) : chunks{chunk0, chunk1, chunk2, chunk3} {} - simdutf_really_inline simd16x32(const T* ptr) : chunks{simd16::load(ptr), simd16::load(ptr+sizeof(simd16)/sizeof(T)), simd16::load(ptr+2*sizeof(simd16)/sizeof(T)), simd16::load(ptr+3*sizeof(simd16)/sizeof(T))} {} + simdutf_really_inline simd16x32(const simd16 chunk0, const simd16 chunk1, const simd16 chunk2, const simd16 chunk3) + : chunks { chunk0, chunk1, chunk2, chunk3 } + { + } + simdutf_really_inline simd16x32(const T* ptr) + : chunks { simd16::load(ptr), simd16::load(ptr + sizeof(simd16) / sizeof(T)), simd16::load(ptr + 2 * sizeof(simd16) / sizeof(T)), simd16::load(ptr + 3 * sizeof(simd16) / sizeof(T)) } + { + } - simdutf_really_inline void store(T* ptr) const { - this->chunks[0].store(ptr+sizeof(simd16)*0/sizeof(T)); - this->chunks[1].store(ptr+sizeof(simd16)*1/sizeof(T)); - this->chunks[2].store(ptr+sizeof(simd16)*2/sizeof(T)); - this->chunks[3].store(ptr+sizeof(simd16)*3/sizeof(T)); + simdutf_really_inline void store(T* ptr) const + { + this->chunks[0].store(ptr + sizeof(simd16) * 0 / sizeof(T)); + this->chunks[1].store(ptr + sizeof(simd16) * 1 / sizeof(T)); + this->chunks[2].store(ptr + sizeof(simd16) * 2 / sizeof(T)); + this->chunks[3].store(ptr + sizeof(simd16) * 3 / sizeof(T)); } - simdutf_really_inline simd16 reduce_or() const { - return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); + simdutf_really_inline simd16 reduce_or() const + { + return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); } - simdutf_really_inline bool is_ascii() const { - return reduce_or().is_ascii(); + simdutf_really_inline bool is_ascii() const + { + return reduce_or().is_ascii(); } - simdutf_really_inline void store_ascii_as_utf16(char16_t * ptr) const { - this->chunks[0].store_ascii_as_utf16(ptr+sizeof(simd16)*0); - this->chunks[1].store_ascii_as_utf16(ptr+sizeof(simd16)*1); - this->chunks[2].store_ascii_as_utf16(ptr+sizeof(simd16)*2); - this->chunks[3].store_ascii_as_utf16(ptr+sizeof(simd16)*3); + simdutf_really_inline void store_ascii_as_utf16(char16_t* ptr) const + { + this->chunks[0].store_ascii_as_utf16(ptr + sizeof(simd16) * 0); + this->chunks[1].store_ascii_as_utf16(ptr + sizeof(simd16) * 1); + this->chunks[2].store_ascii_as_utf16(ptr + sizeof(simd16) * 2); + this->chunks[3].store_ascii_as_utf16(ptr + sizeof(simd16) * 3); } - simdutf_really_inline uint64_t to_bitmask() const { + simdutf_really_inline uint64_t to_bitmask() const + { #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t bit_mask = make_uint8x16_t( - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 - ); + const uint8x16_t bit_mask = make_uint8x16_t( + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80); #else - const uint8x16_t bit_mask = { - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, - 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 - }; + const uint8x16_t bit_mask = { + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, + 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 + }; #endif - // Add each of the elements next to each other, successively, to stuff each 8 byte mask into one. - uint8x16_t sum0 = vpaddq_u8(vreinterpretq_u8_u16(this->chunks[0] & vreinterpretq_u16_u8(bit_mask)), vreinterpretq_u8_u16(this->chunks[1] & vreinterpretq_u16_u8(bit_mask))); - uint8x16_t sum1 = vpaddq_u8(vreinterpretq_u8_u16(this->chunks[2] & vreinterpretq_u16_u8(bit_mask)), vreinterpretq_u8_u16(this->chunks[3] & vreinterpretq_u16_u8(bit_mask))); - sum0 = vpaddq_u8(sum0, sum1); - sum0 = vpaddq_u8(sum0, sum0); - return vgetq_lane_u64(vreinterpretq_u64_u8(sum0), 0); - } - - simdutf_really_inline void swap_bytes() { - this->chunks[0] = this->chunks[0].swap_bytes(); - this->chunks[1] = this->chunks[1].swap_bytes(); - this->chunks[2] = this->chunks[2].swap_bytes(); - this->chunks[3] = this->chunks[3].swap_bytes(); - } - - simdutf_really_inline uint64_t eq(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] == mask, - this->chunks[1] == mask, - this->chunks[2] == mask, - this->chunks[3] == mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t lteq(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] <= mask, - this->chunks[1] <= mask, - this->chunks[2] <= mask, - this->chunks[3] <= mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t in_range(const T low, const T high) const { - const simd16 mask_low = simd16::splat(low); - const simd16 mask_high = simd16::splat(high); - - return simd16x32( - (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), - (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), - (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), - (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t not_in_range(const T low, const T high) const { - const simd16 mask_low = simd16::splat(low); - const simd16 mask_high = simd16::splat(high); - return simd16x32( - (this->chunks[0] > mask_high) | (this->chunks[0] < mask_low), - (this->chunks[1] > mask_high) | (this->chunks[1] < mask_low), - (this->chunks[2] > mask_high) | (this->chunks[2] < mask_low), - (this->chunks[3] > mask_high) | (this->chunks[3] < mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t lt(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] < mask, - this->chunks[1] < mask, - this->chunks[2] < mask, - this->chunks[3] < mask - ).to_bitmask(); - } - - }; // struct simd16x32 - template<> - simdutf_really_inline uint64_t simd16x32::not_in_range(const uint16_t low, const uint16_t high) const { - const simd16 mask_low = simd16::splat(low); - const simd16 mask_high = simd16::splat(high); - simd16x32 x( - simd16((this->chunks[0] > mask_high) | (this->chunks[0] < mask_low)), - simd16((this->chunks[1] > mask_high) | (this->chunks[1] < mask_low)), - simd16((this->chunks[2] > mask_high) | (this->chunks[2] < mask_low)), - simd16((this->chunks[3] > mask_high) | (this->chunks[3] < mask_low)) - ); - return x.to_bitmask(); + // Add each of the elements next to each other, successively, to stuff each 8 byte mask into one. + uint8x16_t sum0 = vpaddq_u8(vreinterpretq_u8_u16(this->chunks[0] & vreinterpretq_u16_u8(bit_mask)), vreinterpretq_u8_u16(this->chunks[1] & vreinterpretq_u16_u8(bit_mask))); + uint8x16_t sum1 = vpaddq_u8(vreinterpretq_u8_u16(this->chunks[2] & vreinterpretq_u16_u8(bit_mask)), vreinterpretq_u8_u16(this->chunks[3] & vreinterpretq_u16_u8(bit_mask))); + sum0 = vpaddq_u8(sum0, sum1); + sum0 = vpaddq_u8(sum0, sum0); + return vgetq_lane_u64(vreinterpretq_u64_u8(sum0), 0); } -/* end file src/simdutf/arm64/simd16-inl.h */ -} // namespace simd -} // unnamed namespace -} // namespace arm64 -} // namespace simdutf -#endif // SIMDUTF_ARM64_SIMD_H -/* end file src/simdutf/arm64/simd.h */ + simdutf_really_inline void swap_bytes() + { + this->chunks[0] = this->chunks[0].swap_bytes(); + this->chunks[1] = this->chunks[1].swap_bytes(); + this->chunks[2] = this->chunks[2].swap_bytes(); + this->chunks[3] = this->chunks[3].swap_bytes(); + } -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/end.h + simdutf_really_inline uint64_t eq(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] == mask, + this->chunks[1] == mask, + this->chunks[2] == mask, + this->chunks[3] == mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t lteq(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] <= mask, + this->chunks[1] <= mask, + this->chunks[2] <= mask, + this->chunks[3] <= mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t in_range(const T low, const T high) const + { + const simd16 mask_low = simd16::splat(low); + const simd16 mask_high = simd16::splat(high); + + return simd16x32( + (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), + (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), + (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), + (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t not_in_range(const T low, const T high) const + { + const simd16 mask_low = simd16::splat(low); + const simd16 mask_high = simd16::splat(high); + return simd16x32( + (this->chunks[0] > mask_high) | (this->chunks[0] < mask_low), + (this->chunks[1] > mask_high) | (this->chunks[1] < mask_low), + (this->chunks[2] > mask_high) | (this->chunks[2] < mask_low), + (this->chunks[3] > mask_high) | (this->chunks[3] < mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t lt(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] < mask, + this->chunks[1] < mask, + this->chunks[2] < mask, + this->chunks[3] < mask) + .to_bitmask(); + } + +}; // struct simd16x32 +template<> +simdutf_really_inline uint64_t simd16x32::not_in_range(const uint16_t low, const uint16_t high) const +{ + const simd16 mask_low = simd16::splat(low); + const simd16 mask_high = simd16::splat(high); + simd16x32 x( + simd16((this->chunks[0] > mask_high) | (this->chunks[0] < mask_low)), + simd16((this->chunks[1] > mask_high) | (this->chunks[1] < mask_low)), + simd16((this->chunks[2] > mask_high) | (this->chunks[2] < mask_low)), + simd16((this->chunks[3] > mask_high) | (this->chunks[3] < mask_low))); + return x.to_bitmask(); +} +/* end file src/simdutf/arm64/simd16-inl.h */ +} // namespace simd +} // unnamed namespace +} // namespace arm64 +} // namespace simdutf + +#endif // SIMDUTF_ARM64_SIMD_H +/* end file src/simdutf/arm64/simd.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/end.h /* begin file src/simdutf/arm64/end.h */ /* end file src/simdutf/arm64/end.h */ @@ -1105,13 +1327,11 @@ simdutf_really_inline simd16::operator simd16() const { retur #endif // SIMDUTF_ARM64_H /* end file src/simdutf/arm64.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/icelake.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/icelake.h /* begin file src/simdutf/icelake.h */ #ifndef SIMDUTF_ICELAKE_H #define SIMDUTF_ICELAKE_H - - #ifdef __has_include // How do we detect that a compiler supports vbmi2? // For sure if the following header is found, we are ok? @@ -1133,18 +1353,15 @@ simdutf_really_inline simd16::operator simd16() const { retur #define SIMDUTF_IMPLEMENTATION_ICELAKE ((SIMDUTF_IS_X86_64) && (SIMDUTF_COMPILER_SUPPORTS_VBMI2)) #endif -// To see why (__BMI__) && (__PCLMUL__) && (__LZCNT__) are not part of this next line, see +// To see why (__BMI__) && (__LZCNT__) are not part of this next line, see // https://github.com/simdutf/simdutf/issues/1247 -#define SIMDUTF_CAN_ALWAYS_RUN_ICELAKE ((SIMDUTF_IMPLEMENTATION_ICELAKE) && (SIMDUTF_IS_X86_64) && (__AVX2__) && (SIMDUTF_HAS_AVX512F && \ - SIMDUTF_HAS_AVX512DQ && \ - SIMDUTF_HAS_AVX512VL && \ - SIMDUTF_HAS_AVX512VBMI2) && (!SIMDUTF_IS_32BITS)) +#define SIMDUTF_CAN_ALWAYS_RUN_ICELAKE ((SIMDUTF_IMPLEMENTATION_ICELAKE) && (SIMDUTF_IS_X86_64) && (__AVX2__) && (SIMDUTF_HAS_AVX512F && SIMDUTF_HAS_AVX512DQ && SIMDUTF_HAS_AVX512VL && SIMDUTF_HAS_AVX512VBMI2) && (!SIMDUTF_IS_32BITS)) #if SIMDUTF_IMPLEMENTATION_ICELAKE #if SIMDUTF_CAN_ALWAYS_RUN_ICELAKE #define SIMDUTF_TARGET_ICELAKE #else -#define SIMDUTF_TARGET_ICELAKE SIMDUTF_TARGET_REGION("avx512f,avx512dq,avx512cd,avx512bw,avx512vbmi,avx512vbmi2,avx512vl,avx2,bmi,bmi2,pclmul,lzcnt") +#define SIMDUTF_TARGET_ICELAKE SIMDUTF_TARGET_REGION("avx512f,avx512dq,avx512cd,avx512bw,avx512vbmi,avx512vbmi2,avx512vl,avx2,bmi,bmi2,pclmul,lzcnt,popcnt") #endif namespace simdutf { @@ -1152,20 +1369,17 @@ namespace icelake { } // namespace icelake } // namespace simdutf - - // // These two need to be included outside SIMDUTF_TARGET_REGION // -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/icelake/intrinsics.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/icelake/intrinsics.h /* begin file src/simdutf/icelake/intrinsics.h */ #ifndef SIMDUTF_ICELAKE_INTRINSICS_H #define SIMDUTF_ICELAKE_INTRINSICS_H - #ifdef SIMDUTF_VISUAL_STUDIO // under clang within visual studio, this will include -#include // visual studio or clang +#include // visual studio or clang #include #else @@ -1179,7 +1393,6 @@ SIMDUTF_DISABLE_GCC_WARNING(-Wuninitialized) #include // elsewhere - #if SIMDUTF_GCC11ORMORE // cancels the suppression of the -Wuninitialized SIMDUTF_POP_DISABLE_WARNINGS @@ -1209,15 +1422,14 @@ SIMDUTF_POP_DISABLE_WARNINGS * (or ) before, so the headers * are fooled. */ -#include // for _blsr_u64 -#include // for _pext_u64, _pdep_u64 +#include // for _blsr_u64 +#include // for _pext_u64, _pdep_u64 #include // for __lzcnt64 -#include // for most things (AVX2, AVX512, _popcnt64) +#include // for most things (AVX2, AVX512, _popcnt64) #include #include #include #include -#include // for _mm_clmulepi64_si128 // Important: we need the AVX-512 headers: #include #include @@ -1235,8 +1447,6 @@ SIMDUTF_POP_DISABLE_WARNINGS #endif // _blsr_u64 #endif // SIMDUTF_CLANG_VISUAL_STUDIO - - #if defined(__GNUC__) && !defined(__clang__) #if __GNUC__ == 8 @@ -1253,27 +1463,27 @@ SIMDUTF_POP_DISABLE_WARNINGS /** * GCC 8 fails to provide _mm512_set_epi8. We roll our own. */ -inline __m512i _mm512_set_epi8(uint8_t a0, uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6, uint8_t a7, uint8_t a8, uint8_t a9, uint8_t a10, uint8_t a11, uint8_t a12, uint8_t a13, uint8_t a14, uint8_t a15, uint8_t a16, uint8_t a17, uint8_t a18, uint8_t a19, uint8_t a20, uint8_t a21, uint8_t a22, uint8_t a23, uint8_t a24, uint8_t a25, uint8_t a26, uint8_t a27, uint8_t a28, uint8_t a29, uint8_t a30, uint8_t a31, uint8_t a32, uint8_t a33, uint8_t a34, uint8_t a35, uint8_t a36, uint8_t a37, uint8_t a38, uint8_t a39, uint8_t a40, uint8_t a41, uint8_t a42, uint8_t a43, uint8_t a44, uint8_t a45, uint8_t a46, uint8_t a47, uint8_t a48, uint8_t a49, uint8_t a50, uint8_t a51, uint8_t a52, uint8_t a53, uint8_t a54, uint8_t a55, uint8_t a56, uint8_t a57, uint8_t a58, uint8_t a59, uint8_t a60, uint8_t a61, uint8_t a62, uint8_t a63) { - return _mm512_set_epi64(uint64_t(a7) + (uint64_t(a6) << 8) + (uint64_t(a5) << 16) + (uint64_t(a4) << 24) + (uint64_t(a3) << 32) + (uint64_t(a2) << 40) + (uint64_t(a1) << 48) + (uint64_t(a0) << 56), - uint64_t(a15) + (uint64_t(a14) << 8) + (uint64_t(a13) << 16) + (uint64_t(a12) << 24) + (uint64_t(a11) << 32) + (uint64_t(a10) << 40) + (uint64_t(a9) << 48) + (uint64_t(a8) << 56), - uint64_t(a23) + (uint64_t(a22) << 8) + (uint64_t(a21) << 16) + (uint64_t(a20) << 24) + (uint64_t(a19) << 32) + (uint64_t(a18) << 40) + (uint64_t(a17) << 48) + (uint64_t(a16) << 56), - uint64_t(a31) + (uint64_t(a30) << 8) + (uint64_t(a29) << 16) + (uint64_t(a28) << 24) + (uint64_t(a27) << 32) + (uint64_t(a26) << 40) + (uint64_t(a25) << 48) + (uint64_t(a24) << 56), - uint64_t(a39) + (uint64_t(a38) << 8) + (uint64_t(a37) << 16) + (uint64_t(a36) << 24) + (uint64_t(a35) << 32) + (uint64_t(a34) << 40) + (uint64_t(a33) << 48) + (uint64_t(a32) << 56), - uint64_t(a47) + (uint64_t(a46) << 8) + (uint64_t(a45) << 16) + (uint64_t(a44) << 24) + (uint64_t(a43) << 32) + (uint64_t(a42) << 40) + (uint64_t(a41) << 48) + (uint64_t(a40) << 56), - uint64_t(a55) + (uint64_t(a54) << 8) + (uint64_t(a53) << 16) + (uint64_t(a52) << 24) + (uint64_t(a51) << 32) + (uint64_t(a50) << 40) + (uint64_t(a49) << 48) + (uint64_t(a48) << 56), - uint64_t(a63) + (uint64_t(a62) << 8) + (uint64_t(a61) << 16) + (uint64_t(a60) << 24) + (uint64_t(a59) << 32) + (uint64_t(a58) << 40) + (uint64_t(a57) << 48) + (uint64_t(a56) << 56)); +inline __m512i _mm512_set_epi8(uint8_t a0, uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6, uint8_t a7, uint8_t a8, uint8_t a9, uint8_t a10, uint8_t a11, uint8_t a12, uint8_t a13, uint8_t a14, uint8_t a15, uint8_t a16, uint8_t a17, uint8_t a18, uint8_t a19, uint8_t a20, uint8_t a21, uint8_t a22, uint8_t a23, uint8_t a24, uint8_t a25, uint8_t a26, uint8_t a27, uint8_t a28, uint8_t a29, uint8_t a30, uint8_t a31, uint8_t a32, uint8_t a33, uint8_t a34, uint8_t a35, uint8_t a36, uint8_t a37, uint8_t a38, uint8_t a39, uint8_t a40, uint8_t a41, uint8_t a42, uint8_t a43, uint8_t a44, uint8_t a45, uint8_t a46, uint8_t a47, uint8_t a48, uint8_t a49, uint8_t a50, uint8_t a51, uint8_t a52, uint8_t a53, uint8_t a54, uint8_t a55, uint8_t a56, uint8_t a57, uint8_t a58, uint8_t a59, uint8_t a60, uint8_t a61, uint8_t a62, uint8_t a63) +{ + return _mm512_set_epi64(uint64_t(a7) + (uint64_t(a6) << 8) + (uint64_t(a5) << 16) + (uint64_t(a4) << 24) + (uint64_t(a3) << 32) + (uint64_t(a2) << 40) + (uint64_t(a1) << 48) + (uint64_t(a0) << 56), + uint64_t(a15) + (uint64_t(a14) << 8) + (uint64_t(a13) << 16) + (uint64_t(a12) << 24) + (uint64_t(a11) << 32) + (uint64_t(a10) << 40) + (uint64_t(a9) << 48) + (uint64_t(a8) << 56), + uint64_t(a23) + (uint64_t(a22) << 8) + (uint64_t(a21) << 16) + (uint64_t(a20) << 24) + (uint64_t(a19) << 32) + (uint64_t(a18) << 40) + (uint64_t(a17) << 48) + (uint64_t(a16) << 56), + uint64_t(a31) + (uint64_t(a30) << 8) + (uint64_t(a29) << 16) + (uint64_t(a28) << 24) + (uint64_t(a27) << 32) + (uint64_t(a26) << 40) + (uint64_t(a25) << 48) + (uint64_t(a24) << 56), + uint64_t(a39) + (uint64_t(a38) << 8) + (uint64_t(a37) << 16) + (uint64_t(a36) << 24) + (uint64_t(a35) << 32) + (uint64_t(a34) << 40) + (uint64_t(a33) << 48) + (uint64_t(a32) << 56), + uint64_t(a47) + (uint64_t(a46) << 8) + (uint64_t(a45) << 16) + (uint64_t(a44) << 24) + (uint64_t(a43) << 32) + (uint64_t(a42) << 40) + (uint64_t(a41) << 48) + (uint64_t(a40) << 56), + uint64_t(a55) + (uint64_t(a54) << 8) + (uint64_t(a53) << 16) + (uint64_t(a52) << 24) + (uint64_t(a51) << 32) + (uint64_t(a50) << 40) + (uint64_t(a49) << 48) + (uint64_t(a48) << 56), + uint64_t(a63) + (uint64_t(a62) << 8) + (uint64_t(a61) << 16) + (uint64_t(a60) << 24) + (uint64_t(a59) << 32) + (uint64_t(a58) << 40) + (uint64_t(a57) << 48) + (uint64_t(a56) << 56)); } #pragma GCC pop_options #endif // SIMDUTF_GCC8 #endif // SIMDUTF_HASWELL_INTRINSICS_H /* end file src/simdutf/icelake/intrinsics.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/icelake/implementation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/icelake/implementation.h /* begin file src/simdutf/icelake/implementation.h */ #ifndef SIMDUTF_ICELAKE_IMPLEMENTATION_H #define SIMDUTF_ICELAKE_IMPLEMENTATION_H - namespace simdutf { namespace icelake { @@ -1283,63 +1493,88 @@ using namespace simdutf; class implementation final : public simdutf::implementation { public: - simdutf_really_inline implementation() : simdutf::implementation( - "icelake", - "Intel AVX512 (AVX-512BW, AVX-512CD, AVX-512VL, AVX-512VBMI2 extensions)", - internal::instruction_set::AVX2 | internal::instruction_set::PCLMULQDQ | internal::instruction_set::BMI1 | internal::instruction_set::BMI2 | internal::instruction_set::AVX512BW | internal::instruction_set::AVX512CD | internal::instruction_set::AVX512VL | internal::instruction_set::AVX512VBMI2 ) {} - simdutf_warn_unused int detect_encodings(const char * input, size_t length) const noexcept final; - simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16le(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16be(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - void change_endianness_utf16(const char16_t * buf, size_t length, char16_t * output) const noexcept final; - simdutf_warn_unused size_t count_utf16le(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf16be(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf8(const char * buf, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t length) const noexcept; + simdutf_really_inline implementation() + : simdutf::implementation( + "icelake", + "Intel AVX512 (AVX-512BW, AVX-512CD, AVX-512VL, AVX-512VBMI2 extensions)", + internal::instruction_set::AVX2 | internal::instruction_set::BMI1 | internal::instruction_set::BMI2 | internal::instruction_set::AVX512BW | internal::instruction_set::AVX512CD | internal::instruction_set::AVX512VL | internal::instruction_set::AVX512VBMI2) + { + } + simdutf_warn_unused int detect_encodings(const char* input, size_t length) const noexcept final; + simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + void change_endianness_utf16(const char16_t* buf, size_t length, char16_t* output) const noexcept final; + simdutf_warn_unused size_t count_utf16le(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf16be(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf8(const char* buf, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf16(size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf32(size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_latin1(const char* input, size_t length) const noexcept; }; } // namespace icelake @@ -1351,7 +1586,7 @@ public: // // The rest need to be inside the region // -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/icelake/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/icelake/begin.h /* begin file src/simdutf/icelake/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "icelake" // #define SIMDUTF_IMPLEMENTATION icelake @@ -1363,11 +1598,11 @@ SIMDUTF_TARGET_ICELAKE #endif #if SIMDUTF_GCC11ORMORE // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593 -SIMDUTF_DISABLE_GCC_WARNING(-Wmaybe-uninitialized) +SIMDUTF_DISABLE_GCC_WARNING(-Wmaybe - uninitialized) #endif // end of workaround /* end file src/simdutf/icelake/begin.h */ // Declarations -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/icelake/bitmanipulation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/icelake/bitmanipulation.h /* begin file src/simdutf/icelake/bitmanipulation.h */ #ifndef SIMDUTF_ICELAKE_BITMANIPULATION_H #define SIMDUTF_ICELAKE_BITMANIPULATION_H @@ -1377,13 +1612,15 @@ namespace icelake { namespace { #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO -simdutf_really_inline unsigned __int64 count_ones(uint64_t input_num) { - // note: we do not support legacy 32-bit Windows - return __popcnt64(input_num);// Visual Studio wants two underscores +simdutf_really_inline unsigned __int64 count_ones(uint64_t input_num) +{ + // note: we do not support legacy 32-bit Windows + return __popcnt64(input_num); // Visual Studio wants two underscores } #else -simdutf_really_inline long long int count_ones(uint64_t input_num) { - return _popcnt64(input_num); +simdutf_really_inline long long int count_ones(uint64_t input_num) +{ + return _popcnt64(input_num); } #endif @@ -1393,7 +1630,7 @@ simdutf_really_inline long long int count_ones(uint64_t input_num) { #endif // SIMDUTF_ICELAKE_BITMANIPULATION_H /* end file src/simdutf/icelake/bitmanipulation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/icelake/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/icelake/end.h /* begin file src/simdutf/icelake/end.h */ #if SIMDUTF_CAN_ALWAYS_RUN_ICELAKE // nothing needed. @@ -1401,18 +1638,15 @@ simdutf_really_inline long long int count_ones(uint64_t input_num) { SIMDUTF_UNTARGET_REGION #endif - #if SIMDUTF_GCC11ORMORE // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593 SIMDUTF_POP_DISABLE_WARNINGS #endif // end of workaround /* end file src/simdutf/icelake/end.h */ - - #endif // SIMDUTF_IMPLEMENTATION_ICELAKE #endif // SIMDUTF_ICELAKE_H /* end file src/simdutf/icelake.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell.h /* begin file src/simdutf/haswell.h */ #ifndef SIMDUTF_HASWELL_H #define SIMDUTF_HASWELL_H @@ -1424,7 +1658,6 @@ SIMDUTF_POP_DISABLE_WARNINGS #error "haswell.h must be included before fallback.h" #endif - // Default Haswell to on if this is x86-64. Even if we're not compiled for it, it could be selected // at runtime. #ifndef SIMDUTF_IMPLEMENTATION_HASWELL @@ -1439,13 +1672,13 @@ SIMDUTF_POP_DISABLE_WARNINGS #endif #endif -// To see why (__BMI__) && (__PCLMUL__) && (__LZCNT__) are not part of this next line, see +// To see why (__BMI__) && (__LZCNT__) are not part of this next line, see // https://github.com/simdutf/simdutf/issues/1247 #define SIMDUTF_CAN_ALWAYS_RUN_HASWELL ((SIMDUTF_IMPLEMENTATION_HASWELL) && (SIMDUTF_IS_X86_64) && (__AVX2__)) #if SIMDUTF_IMPLEMENTATION_HASWELL -#define SIMDUTF_TARGET_HASWELL SIMDUTF_TARGET_REGION("avx2,bmi,pclmul,lzcnt") +#define SIMDUTF_TARGET_HASWELL SIMDUTF_TARGET_REGION("avx2,bmi,lzcnt,popcnt") namespace simdutf { /** @@ -1458,12 +1691,11 @@ namespace haswell { // // These two need to be included outside SIMDUTF_TARGET_REGION // -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/implementation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/implementation.h /* begin file src/simdutf/haswell/implementation.h */ #ifndef SIMDUTF_HASWELL_IMPLEMENTATION_H #define SIMDUTF_HASWELL_IMPLEMENTATION_H - // The constructor may be executed on any host, so we take care not to use SIMDUTF_TARGET_REGION namespace simdutf { namespace haswell { @@ -1472,64 +1704,88 @@ using namespace simdutf; class implementation final : public simdutf::implementation { public: - simdutf_really_inline implementation() : simdutf::implementation( - "haswell", - "Intel/AMD AVX2", - internal::instruction_set::AVX2 | internal::instruction_set::PCLMULQDQ | internal::instruction_set::BMI1 | internal::instruction_set::BMI2 - ) {} - simdutf_warn_unused int detect_encodings(const char * input, size_t length) const noexcept final; - simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16le(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16be(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - void change_endianness_utf16(const char16_t * buf, size_t length, char16_t * output) const noexcept final; - simdutf_warn_unused size_t count_utf16le(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf16be(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf8(const char * buf, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t length) const noexcept; + simdutf_really_inline implementation() + : simdutf::implementation( + "haswell", + "Intel/AMD AVX2", + internal::instruction_set::AVX2 | internal::instruction_set::BMI1 | internal::instruction_set::BMI2) + { + } + simdutf_warn_unused int detect_encodings(const char* input, size_t length) const noexcept final; + simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + void change_endianness_utf16(const char16_t* buf, size_t length, char16_t* output) const noexcept final; + simdutf_warn_unused size_t count_utf16le(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf16be(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf8(const char* buf, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf16(size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf32(size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_latin1(const char* input, size_t length) const noexcept; }; } // namespace haswell @@ -1537,15 +1793,14 @@ public: #endif // SIMDUTF_HASWELL_IMPLEMENTATION_H /* end file src/simdutf/haswell/implementation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/intrinsics.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/intrinsics.h /* begin file src/simdutf/haswell/intrinsics.h */ #ifndef SIMDUTF_HASWELL_INTRINSICS_H #define SIMDUTF_HASWELL_INTRINSICS_H - #ifdef SIMDUTF_VISUAL_STUDIO // under clang within visual studio, this will include -#include // visual studio or clang +#include // visual studio or clang #else #if SIMDUTF_GCC11ORMORE @@ -1558,7 +1813,6 @@ SIMDUTF_DISABLE_GCC_WARNING(-Wuninitialized) #include // elsewhere - #if SIMDUTF_GCC11ORMORE // cancels the suppression of the -Wuninitialized SIMDUTF_POP_DISABLE_WARNINGS @@ -1585,14 +1839,13 @@ SIMDUTF_POP_DISABLE_WARNINGS * (or ) before, so the headers * are fooled. */ -#include // for _blsr_u64 +#include // for _blsr_u64 #include // for __lzcnt64 -#include // for most things (AVX2, AVX512, _popcnt64) +#include // for most things (AVX2, AVX512, _popcnt64) #include #include #include #include -#include // for _mm_clmulepi64_si128 // unfortunately, we may not get _blsr_u64, but, thankfully, clang // has it as a macro. #ifndef _blsr_u64 @@ -1607,7 +1860,7 @@ SIMDUTF_POP_DISABLE_WARNINGS // // The rest need to be inside the region // -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/begin.h /* begin file src/simdutf/haswell/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "haswell" // #define SIMDUTF_IMPLEMENTATION haswell @@ -1619,11 +1872,11 @@ SIMDUTF_TARGET_HASWELL #endif #if SIMDUTF_GCC11ORMORE // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593 -SIMDUTF_DISABLE_GCC_WARNING(-Wmaybe-uninitialized) +SIMDUTF_DISABLE_GCC_WARNING(-Wmaybe - uninitialized) #endif // end of workaround /* end file src/simdutf/haswell/begin.h */ // Declarations -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/bitmanipulation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/bitmanipulation.h /* begin file src/simdutf/haswell/bitmanipulation.h */ #ifndef SIMDUTF_HASWELL_BITMANIPULATION_H #define SIMDUTF_HASWELL_BITMANIPULATION_H @@ -1633,13 +1886,15 @@ namespace haswell { namespace { #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO -simdutf_really_inline unsigned __int64 count_ones(uint64_t input_num) { - // note: we do not support legacy 32-bit Windows - return __popcnt64(input_num);// Visual Studio wants two underscores +simdutf_really_inline unsigned __int64 count_ones(uint64_t input_num) +{ + // note: we do not support legacy 32-bit Windows + return __popcnt64(input_num); // Visual Studio wants two underscores } #else -simdutf_really_inline long long int count_ones(uint64_t input_num) { - return _popcnt64(input_num); +simdutf_really_inline long long int count_ones(uint64_t input_num) +{ + return _popcnt64(input_num); } #endif @@ -1649,190 +1904,254 @@ simdutf_really_inline long long int count_ones(uint64_t input_num) { #endif // SIMDUTF_HASWELL_BITMANIPULATION_H /* end file src/simdutf/haswell/bitmanipulation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/simd.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/simd.h /* begin file src/simdutf/haswell/simd.h */ #ifndef SIMDUTF_HASWELL_SIMD_H #define SIMDUTF_HASWELL_SIMD_H - namespace simdutf { namespace haswell { namespace { namespace simd { - // Forward-declared so they can be used by splat and friends. - template - struct base { +// Forward-declared so they can be used by splat and friends. +template +struct base { __m256i value; // Zero constructor - simdutf_really_inline base() : value{__m256i()} {} + simdutf_really_inline base() + : value { __m256i() } + { + } // Conversion from SIMD register - simdutf_really_inline base(const __m256i _value) : value(_value) {} + simdutf_really_inline base(const __m256i _value) + : value(_value) + { + } // Conversion to SIMD register simdutf_really_inline operator const __m256i&() const { return this->value; } simdutf_really_inline operator __m256i&() { return this->value; } - template - simdutf_really_inline void store_ascii_as_utf16(char16_t * ptr) const { - __m256i first = _mm256_cvtepu8_epi16(_mm256_castsi256_si128(*this)); - __m256i second = _mm256_cvtepu8_epi16(_mm256_extractf128_si256(*this,1)); - if (big_endian) { - const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, - 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); - first = _mm256_shuffle_epi8(first, swap); - second = _mm256_shuffle_epi8(second, swap); - } - _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr), first); - _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 16), second); - } - simdutf_really_inline void store_ascii_as_utf32(char32_t * ptr) const { - _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr), _mm256_cvtepu8_epi32(_mm256_castsi256_si128(*this))); - _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr+8), _mm256_cvtepu8_epi32(_mm256_castsi256_si128(_mm256_srli_si256(*this,8)))); - _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 16), _mm256_cvtepu8_epi32(_mm256_extractf128_si256(*this,1))); - _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 24), _mm256_cvtepu8_epi32(_mm_srli_si128(_mm256_extractf128_si256(*this,1),8))); + template + simdutf_really_inline void store_ascii_as_utf16(char16_t* ptr) const + { + __m256i first = _mm256_cvtepu8_epi16(_mm256_castsi256_si128(*this)); + __m256i second = _mm256_cvtepu8_epi16(_mm256_extractf128_si256(*this, 1)); + if (big_endian) { + const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, + 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); + first = _mm256_shuffle_epi8(first, swap); + second = _mm256_shuffle_epi8(second, swap); + } + _mm256_storeu_si256(reinterpret_cast<__m256i*>(ptr), first); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(ptr + 16), second); + } + simdutf_really_inline void store_ascii_as_utf32(char32_t* ptr) const + { + _mm256_storeu_si256(reinterpret_cast<__m256i*>(ptr), _mm256_cvtepu8_epi32(_mm256_castsi256_si128(*this))); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(ptr + 8), _mm256_cvtepu8_epi32(_mm256_castsi256_si128(_mm256_srli_si256(*this, 8)))); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(ptr + 16), _mm256_cvtepu8_epi32(_mm256_extractf128_si256(*this, 1))); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(ptr + 24), _mm256_cvtepu8_epi32(_mm_srli_si128(_mm256_extractf128_si256(*this, 1), 8))); } // Bit operations simdutf_really_inline Child operator|(const Child other) const { return _mm256_or_si256(*this, other); } simdutf_really_inline Child operator&(const Child other) const { return _mm256_and_si256(*this, other); } simdutf_really_inline Child operator^(const Child other) const { return _mm256_xor_si256(*this, other); } simdutf_really_inline Child bit_andnot(const Child other) const { return _mm256_andnot_si256(other, *this); } - simdutf_really_inline Child& operator|=(const Child other) { auto this_cast = static_cast(this); *this_cast = *this_cast | other; return *this_cast; } - simdutf_really_inline Child& operator&=(const Child other) { auto this_cast = static_cast(this); *this_cast = *this_cast & other; return *this_cast; } - simdutf_really_inline Child& operator^=(const Child other) { auto this_cast = static_cast(this); *this_cast = *this_cast ^ other; return *this_cast; } - }; + simdutf_really_inline Child& operator|=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast | other; + return *this_cast; + } + simdutf_really_inline Child& operator&=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast & other; + return *this_cast; + } + simdutf_really_inline Child& operator^=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast ^ other; + return *this_cast; + } +}; - // Forward-declared so they can be used by splat and friends. - template - struct simd8; +// Forward-declared so they can be used by splat and friends. +template +struct simd8; - template> - struct base8: base> { +template> +struct base8 : base> { typedef uint32_t bitmask_t; typedef uint64_t bitmask2_t; - simdutf_really_inline base8() : base>() {} - simdutf_really_inline base8(const __m256i _value) : base>(_value) {} - simdutf_really_inline T first() const { return _mm256_extract_epi8(*this,0); } - simdutf_really_inline T last() const { return _mm256_extract_epi8(*this,31); } - simdutf_really_inline Mask operator==(const simd8 other) const { return _mm256_cmpeq_epi8(*this, other); } + simdutf_really_inline base8() + : base>() + { + } + simdutf_really_inline base8(const __m256i _value) + : base>(_value) + { + } + simdutf_really_inline T first() const { return _mm256_extract_epi8(*this, 0); } + simdutf_really_inline T last() const { return _mm256_extract_epi8(*this, 31); } + friend simdutf_really_inline Mask operator==(const simd8 lhs, const simd8 rhs) { return _mm256_cmpeq_epi8(lhs, rhs); } static const int SIZE = sizeof(base::value); - template - simdutf_really_inline simd8 prev(const simd8 prev_chunk) const { - return _mm256_alignr_epi8(*this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N); + template + simdutf_really_inline simd8 prev(const simd8 prev_chunk) const + { + return _mm256_alignr_epi8(*this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N); } - }; +}; - // SIMD byte mask type (returned by things like eq and gt) - template<> - struct simd8: base8 { +// SIMD byte mask type (returned by things like eq and gt) +template<> +struct simd8 : base8 { static simdutf_really_inline simd8 splat(bool _value) { return _mm256_set1_epi8(uint8_t(-(!!_value))); } - simdutf_really_inline simd8() : base8() {} - simdutf_really_inline simd8(const __m256i _value) : base8(_value) {} + simdutf_really_inline simd8() + : base8() + { + } + simdutf_really_inline simd8(const __m256i _value) + : base8(_value) + { + } // Splat constructor - simdutf_really_inline simd8(bool _value) : base8(splat(_value)) {} + simdutf_really_inline simd8(bool _value) + : base8(splat(_value)) + { + } simdutf_really_inline uint32_t to_bitmask() const { return uint32_t(_mm256_movemask_epi8(*this)); } simdutf_really_inline bool any() const { return !_mm256_testz_si256(*this, *this); } simdutf_really_inline bool none() const { return _mm256_testz_si256(*this, *this); } simdutf_really_inline bool all() const { return static_cast(_mm256_movemask_epi8(*this)) == 0xFFFFFFFF; } simdutf_really_inline simd8 operator~() const { return *this ^ true; } - }; +}; - template - struct base8_numeric: base8 { +template +struct base8_numeric : base8 { static simdutf_really_inline simd8 splat(T _value) { return _mm256_set1_epi8(_value); } static simdutf_really_inline simd8 zero() { return _mm256_setzero_si256(); } - static simdutf_really_inline simd8 load(const T values[32]) { - return _mm256_loadu_si256(reinterpret_cast(values)); + static simdutf_really_inline simd8 load(const T values[32]) + { + return _mm256_loadu_si256(reinterpret_cast(values)); } // Repeat 16 values as many times as necessary (usually for lookup tables) static simdutf_really_inline simd8 repeat_16( - T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, - T v8, T v9, T v10, T v11, T v12, T v13, T v14, T v15 - ) { - return simd8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15, - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - ); + T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, + T v8, T v9, T v10, T v11, T v12, T v13, T v14, T v15) + { + return simd8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15, + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); } - simdutf_really_inline base8_numeric() : base8() {} - simdutf_really_inline base8_numeric(const __m256i _value) : base8(_value) {} + simdutf_really_inline base8_numeric() + : base8() + { + } + simdutf_really_inline base8_numeric(const __m256i _value) + : base8(_value) + { + } // Store to array - simdutf_really_inline void store(T dst[32]) const { return _mm256_storeu_si256(reinterpret_cast<__m256i *>(dst), *this); } + simdutf_really_inline void store(T dst[32]) const { return _mm256_storeu_si256(reinterpret_cast<__m256i*>(dst), *this); } // Addition/subtraction are the same for signed and unsigned simdutf_really_inline simd8 operator+(const simd8 other) const { return _mm256_add_epi8(*this, other); } simdutf_really_inline simd8 operator-(const simd8 other) const { return _mm256_sub_epi8(*this, other); } - simdutf_really_inline simd8& operator+=(const simd8 other) { *this = *this + other; return *static_cast*>(this); } - simdutf_really_inline simd8& operator-=(const simd8 other) { *this = *this - other; return *static_cast*>(this); } + simdutf_really_inline simd8& operator+=(const simd8 other) + { + *this = *this + other; + return *static_cast*>(this); + } + simdutf_really_inline simd8& operator-=(const simd8 other) + { + *this = *this - other; + return *static_cast*>(this); + } // Override to distinguish from bool version simdutf_really_inline simd8 operator~() const { return *this ^ 0xFFu; } // Perform a lookup assuming the value is between 0 and 16 (undefined behavior for out of range values) template - simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const { - return _mm256_shuffle_epi8(lookup_table, *this); + simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const + { + return _mm256_shuffle_epi8(lookup_table, *this); } template simdutf_really_inline simd8 lookup_16( - L replace0, L replace1, L replace2, L replace3, - L replace4, L replace5, L replace6, L replace7, - L replace8, L replace9, L replace10, L replace11, - L replace12, L replace13, L replace14, L replace15) const { - return lookup_16(simd8::repeat_16( - replace0, replace1, replace2, replace3, - replace4, replace5, replace6, replace7, - replace8, replace9, replace10, replace11, - replace12, replace13, replace14, replace15 - )); - } - }; - - - // Signed bytes - template<> - struct simd8 : base8_numeric { - simdutf_really_inline simd8() : base8_numeric() {} - simdutf_really_inline simd8(const __m256i _value) : base8_numeric(_value) {} + L replace0, L replace1, L replace2, L replace3, + L replace4, L replace5, L replace6, L replace7, + L replace8, L replace9, L replace10, L replace11, + L replace12, L replace13, L replace14, L replace15) const + { + return lookup_16(simd8::repeat_16( + replace0, replace1, replace2, replace3, + replace4, replace5, replace6, replace7, + replace8, replace9, replace10, replace11, + replace12, replace13, replace14, replace15)); + } +}; + +// Signed bytes +template<> +struct simd8 : base8_numeric { + simdutf_really_inline simd8() + : base8_numeric() + { + } + simdutf_really_inline simd8(const __m256i _value) + : base8_numeric(_value) + { + } // Splat constructor - simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {} + simdutf_really_inline simd8(int8_t _value) + : simd8(splat(_value)) + { + } // Array constructor - simdutf_really_inline simd8(const int8_t values[32]) : simd8(load(values)) {} + simdutf_really_inline simd8(const int8_t values[32]) + : simd8(load(values)) + { + } simdutf_really_inline operator simd8() const; // Member-by-member initialization simdutf_really_inline simd8( - int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, - int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15, - int8_t v16, int8_t v17, int8_t v18, int8_t v19, int8_t v20, int8_t v21, int8_t v22, int8_t v23, - int8_t v24, int8_t v25, int8_t v26, int8_t v27, int8_t v28, int8_t v29, int8_t v30, int8_t v31 - ) : simd8(_mm256_setr_epi8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15, - v16,v17,v18,v19,v20,v21,v22,v23, - v24,v25,v26,v27,v28,v29,v30,v31 - )) {} + int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, + int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15, + int8_t v16, int8_t v17, int8_t v18, int8_t v19, int8_t v20, int8_t v21, int8_t v22, int8_t v23, + int8_t v24, int8_t v25, int8_t v26, int8_t v27, int8_t v28, int8_t v29, int8_t v30, int8_t v31) + : simd8(_mm256_setr_epi8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15, + v16, v17, v18, v19, v20, v21, v22, v23, + v24, v25, v26, v27, v28, v29, v30, v31)) + { + } // Repeat 16 values as many times as necessary (usually for lookup tables) simdutf_really_inline static simd8 repeat_16( - int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, - int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15 - ) { - return simd8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15, - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - ); + int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, + int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15) + { + return simd8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15, + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); } simdutf_really_inline bool is_ascii() const { return _mm256_movemask_epi8(*this) == 0; } // Order-sensitive comparisons @@ -1840,43 +2159,54 @@ namespace simd { simdutf_really_inline simd8 min_val(const simd8 other) const { return _mm256_min_epi8(*this, other); } simdutf_really_inline simd8 operator>(const simd8 other) const { return _mm256_cmpgt_epi8(*this, other); } simdutf_really_inline simd8 operator<(const simd8 other) const { return _mm256_cmpgt_epi8(other, *this); } - }; +}; - // Unsigned bytes - template<> - struct simd8: base8_numeric { - simdutf_really_inline simd8() : base8_numeric() {} - simdutf_really_inline simd8(const __m256i _value) : base8_numeric(_value) {} +// Unsigned bytes +template<> +struct simd8 : base8_numeric { + simdutf_really_inline simd8() + : base8_numeric() + { + } + simdutf_really_inline simd8(const __m256i _value) + : base8_numeric(_value) + { + } // Splat constructor - simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {} + simdutf_really_inline simd8(uint8_t _value) + : simd8(splat(_value)) + { + } // Array constructor - simdutf_really_inline simd8(const uint8_t values[32]) : simd8(load(values)) {} + simdutf_really_inline simd8(const uint8_t values[32]) + : simd8(load(values)) + { + } // Member-by-member initialization simdutf_really_inline simd8( - uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, - uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15, - uint8_t v16, uint8_t v17, uint8_t v18, uint8_t v19, uint8_t v20, uint8_t v21, uint8_t v22, uint8_t v23, - uint8_t v24, uint8_t v25, uint8_t v26, uint8_t v27, uint8_t v28, uint8_t v29, uint8_t v30, uint8_t v31 - ) : simd8(_mm256_setr_epi8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15, - v16,v17,v18,v19,v20,v21,v22,v23, - v24,v25,v26,v27,v28,v29,v30,v31 - )) {} + uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, + uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15, + uint8_t v16, uint8_t v17, uint8_t v18, uint8_t v19, uint8_t v20, uint8_t v21, uint8_t v22, uint8_t v23, + uint8_t v24, uint8_t v25, uint8_t v26, uint8_t v27, uint8_t v28, uint8_t v29, uint8_t v30, uint8_t v31) + : simd8(_mm256_setr_epi8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15, + v16, v17, v18, v19, v20, v21, v22, v23, + v24, v25, v26, v27, v28, v29, v30, v31)) + { + } // Repeat 16 values as many times as necessary (usually for lookup tables) simdutf_really_inline static simd8 repeat_16( - uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, - uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15 - ) { - return simd8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15, - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - ); + uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, + uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15) + { + return simd8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15, + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); } - // Saturated math simdutf_really_inline simd8 saturating_add(const simd8 other) const { return _mm256_adds_epu8(*this, other); } simdutf_really_inline simd8 saturating_sub(const simd8 other) const { return _mm256_subs_epu8(*this, other); } @@ -1910,13 +2240,12 @@ namespace simd { // Get one of the bits and make a bitmask out of it. // e.g. value.get_bit<7>() gets the high bit template - simdutf_really_inline int get_bit() const { return _mm256_movemask_epi8(_mm256_slli_epi16(*this, 7-N)); } - }; - simdutf_really_inline simd8::operator simd8() const { return this->value; } - + simdutf_really_inline int get_bit() const { return _mm256_movemask_epi8(_mm256_slli_epi16(*this, 7 - N)); } +}; +simdutf_really_inline simd8::operator simd8() const { return this->value; } - template - struct simd8x64 { +template +struct simd8x64 { static constexpr int NUM_CHUNKS = 64 / sizeof(simd8); static_assert(NUM_CHUNKS == 2, "Haswell kernel should use two registers per 64-byte block."); simd8 chunks[NUM_CHUNKS]; @@ -1925,297 +2254,383 @@ namespace simd { simd8x64& operator=(const simd8 other) = delete; // no assignment allowed simd8x64() = delete; // no default constructor allowed - simdutf_really_inline simd8x64(const simd8 chunk0, const simd8 chunk1) : chunks{chunk0, chunk1} {} - simdutf_really_inline simd8x64(const T* ptr) : chunks{simd8::load(ptr), simd8::load(ptr+sizeof(simd8)/sizeof(T))} {} + simdutf_really_inline simd8x64(const simd8 chunk0, const simd8 chunk1) + : chunks { chunk0, chunk1 } + { + } + simdutf_really_inline simd8x64(const T* ptr) + : chunks { simd8::load(ptr), simd8::load(ptr + sizeof(simd8) / sizeof(T)) } + { + } - simdutf_really_inline void store(T* ptr) const { - this->chunks[0].store(ptr+sizeof(simd8)*0/sizeof(T)); - this->chunks[1].store(ptr+sizeof(simd8)*1/sizeof(T)); + simdutf_really_inline void store(T* ptr) const + { + this->chunks[0].store(ptr + sizeof(simd8) * 0 / sizeof(T)); + this->chunks[1].store(ptr + sizeof(simd8) * 1 / sizeof(T)); } - simdutf_really_inline uint64_t to_bitmask() const { - uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask()); - uint64_t r_hi = this->chunks[1].to_bitmask(); - return r_lo | (r_hi << 32); + simdutf_really_inline uint64_t to_bitmask() const + { + uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask()); + uint64_t r_hi = this->chunks[1].to_bitmask(); + return r_lo | (r_hi << 32); } - simdutf_really_inline simd8x64& operator|=(const simd8x64 &other) { - this->chunks[0] |= other.chunks[0]; - this->chunks[1] |= other.chunks[1]; - return *this; + simdutf_really_inline simd8x64& operator|=(const simd8x64& other) + { + this->chunks[0] |= other.chunks[0]; + this->chunks[1] |= other.chunks[1]; + return *this; } - simdutf_really_inline simd8 reduce_or() const { - return this->chunks[0] | this->chunks[1]; + simdutf_really_inline simd8 reduce_or() const + { + return this->chunks[0] | this->chunks[1]; } - simdutf_really_inline bool is_ascii() const { - return this->reduce_or().is_ascii(); + simdutf_really_inline bool is_ascii() const + { + return this->reduce_or().is_ascii(); } - template - simdutf_really_inline void store_ascii_as_utf16(char16_t * ptr) const { - this->chunks[0].template store_ascii_as_utf16(ptr+sizeof(simd8)*0); - this->chunks[1].template store_ascii_as_utf16(ptr+sizeof(simd8)*1); + template + simdutf_really_inline void store_ascii_as_utf16(char16_t* ptr) const + { + this->chunks[0].template store_ascii_as_utf16(ptr + sizeof(simd8) * 0); + this->chunks[1].template store_ascii_as_utf16(ptr + sizeof(simd8) * 1); } - simdutf_really_inline void store_ascii_as_utf32(char32_t * ptr) const { - this->chunks[0].store_ascii_as_utf32(ptr+sizeof(simd8)*0); - this->chunks[1].store_ascii_as_utf32(ptr+sizeof(simd8)*1); + simdutf_really_inline void store_ascii_as_utf32(char32_t* ptr) const + { + this->chunks[0].store_ascii_as_utf32(ptr + sizeof(simd8) * 0); + this->chunks[1].store_ascii_as_utf32(ptr + sizeof(simd8) * 1); } - simdutf_really_inline simd8x64 bit_or(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] | mask, - this->chunks[1] | mask - ); + simdutf_really_inline simd8x64 bit_or(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] | mask, + this->chunks[1] | mask); } - simdutf_really_inline uint64_t eq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] == mask, - this->chunks[1] == mask - ).to_bitmask(); + simdutf_really_inline uint64_t eq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] == mask, + this->chunks[1] == mask) + .to_bitmask(); } - simdutf_really_inline uint64_t eq(const simd8x64 &other) const { - return simd8x64( - this->chunks[0] == other.chunks[0], - this->chunks[1] == other.chunks[1] - ).to_bitmask(); + simdutf_really_inline uint64_t eq(const simd8x64& other) const + { + return simd8x64( + this->chunks[0] == other.chunks[0], + this->chunks[1] == other.chunks[1]) + .to_bitmask(); } - simdutf_really_inline uint64_t lteq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] <= mask, - this->chunks[1] <= mask - ).to_bitmask(); + simdutf_really_inline uint64_t lteq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] <= mask, + this->chunks[1] <= mask) + .to_bitmask(); } - simdutf_really_inline uint64_t in_range(const T low, const T high) const { - const simd8 mask_low = simd8::splat(low); - const simd8 mask_high = simd8::splat(high); + simdutf_really_inline uint64_t in_range(const T low, const T high) const + { + const simd8 mask_low = simd8::splat(low); + const simd8 mask_high = simd8::splat(high); - return simd8x64( - (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), - (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), - (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), - (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t not_in_range(const T low, const T high) const { - const simd8 mask_low = simd8::splat(low); - const simd8 mask_high = simd8::splat(high); - return simd8x64( - (this->chunks[0] > mask_high) | (this->chunks[0] < mask_low), - (this->chunks[1] > mask_high) | (this->chunks[1] < mask_low) - ).to_bitmask(); + return simd8x64( + (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), + (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), + (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), + (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low)) + .to_bitmask(); } - simdutf_really_inline uint64_t lt(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] < mask, - this->chunks[1] < mask - ).to_bitmask(); + simdutf_really_inline uint64_t not_in_range(const T low, const T high) const + { + const simd8 mask_low = simd8::splat(low); + const simd8 mask_high = simd8::splat(high); + return simd8x64( + (this->chunks[0] > mask_high) | (this->chunks[0] < mask_low), + (this->chunks[1] > mask_high) | (this->chunks[1] < mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t lt(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] < mask, + this->chunks[1] < mask) + .to_bitmask(); } - simdutf_really_inline uint64_t gt(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] > mask, - this->chunks[1] > mask - ).to_bitmask(); + simdutf_really_inline uint64_t gt(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] > mask, + this->chunks[1] > mask) + .to_bitmask(); } - simdutf_really_inline uint64_t gteq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] >= mask, - this->chunks[1] >= mask - ).to_bitmask(); + simdutf_really_inline uint64_t gteq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] >= mask, + this->chunks[1] >= mask) + .to_bitmask(); } - simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - (simd8(__m256i(this->chunks[0])) >= mask), - (simd8(__m256i(this->chunks[1])) >= mask) - ).to_bitmask(); + simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + (simd8(__m256i(this->chunks[0])) >= mask), + (simd8(__m256i(this->chunks[1])) >= mask)) + .to_bitmask(); } - }; // struct simd8x64 +}; // struct simd8x64 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/simd16-inl.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/simd16-inl.h /* begin file src/simdutf/haswell/simd16-inl.h */ #ifdef __GNUC__ #if __GNUC__ < 8 #define _mm256_set_m128i(xmm1, xmm2) _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1), _mm256_castsi128_si256(xmm2), 2) -#define _mm256_setr_m128i(xmm2, xmm1) _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1), _mm256_castsi128_si256(xmm2), 2) +#define _mm256_setr_m128i(xmm2, xmm1) _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1), _mm256_castsi128_si256(xmm2), 2) #endif #endif template struct simd16; -template> -struct base16: base> { - using bitmask_type = uint32_t; +template> +struct base16 : base> { + using bitmask_type = uint32_t; - simdutf_really_inline base16() : base>() {} - simdutf_really_inline base16(const __m256i _value) : base>(_value) {} - template - simdutf_really_inline base16(const Pointer* ptr) : base16(_mm256_loadu_si256(reinterpret_cast(ptr))) {} - - simdutf_really_inline Mask operator==(const simd16 other) const { return _mm256_cmpeq_epi16(*this, other); } + simdutf_really_inline base16() + : base>() + { + } + simdutf_really_inline base16(const __m256i _value) + : base>(_value) + { + } + template + simdutf_really_inline base16(const Pointer* ptr) + : base16(_mm256_loadu_si256(reinterpret_cast(ptr))) + { + } + friend simdutf_really_inline Mask operator==(const simd16 lhs, const simd16 rhs) { return _mm256_cmpeq_epi16(lhs, rhs); } - /// the size of vector in bytes - static const int SIZE = sizeof(base>::value); + /// the size of vector in bytes + static const int SIZE = sizeof(base>::value); - /// the number of elements of type T a vector can hold - static const int ELEMENTS = SIZE / sizeof(T); + /// the number of elements of type T a vector can hold + static const int ELEMENTS = SIZE / sizeof(T); - template - simdutf_really_inline simd16 prev(const simd16 prev_chunk) const { - return _mm256_alignr_epi8(*this, prev_chunk, 16 - N); - } + template + simdutf_really_inline simd16 prev(const simd16 prev_chunk) const + { + return _mm256_alignr_epi8(*this, prev_chunk, 16 - N); + } }; // SIMD byte mask type (returned by things like eq and gt) template<> -struct simd16: base16 { - static simdutf_really_inline simd16 splat(bool _value) { return _mm256_set1_epi16(uint16_t(-(!!_value))); } +struct simd16 : base16 { + static simdutf_really_inline simd16 splat(bool _value) { return _mm256_set1_epi16(uint16_t(-(!!_value))); } - simdutf_really_inline simd16() : base16() {} - simdutf_really_inline simd16(const __m256i _value) : base16(_value) {} - // Splat constructor - simdutf_really_inline simd16(bool _value) : base16(splat(_value)) {} + simdutf_really_inline simd16() + : base16() + { + } + simdutf_really_inline simd16(const __m256i _value) + : base16(_value) + { + } + // Splat constructor + simdutf_really_inline simd16(bool _value) + : base16(splat(_value)) + { + } - simdutf_really_inline bitmask_type to_bitmask() const { return _mm256_movemask_epi8(*this); } - simdutf_really_inline bool any() const { return !_mm256_testz_si256(*this, *this); } - simdutf_really_inline simd16 operator~() const { return *this ^ true; } + simdutf_really_inline bitmask_type to_bitmask() const { return _mm256_movemask_epi8(*this); } + simdutf_really_inline bool any() const { return !_mm256_testz_si256(*this, *this); } + simdutf_really_inline simd16 operator~() const { return *this ^ true; } }; template -struct base16_numeric: base16 { - static simdutf_really_inline simd16 splat(T _value) { return _mm256_set1_epi16(_value); } - static simdutf_really_inline simd16 zero() { return _mm256_setzero_si256(); } - static simdutf_really_inline simd16 load(const T values[8]) { - return _mm256_loadu_si256(reinterpret_cast(values)); - } - - simdutf_really_inline base16_numeric() : base16() {} - simdutf_really_inline base16_numeric(const __m256i _value) : base16(_value) {} - - // Store to array - simdutf_really_inline void store(T dst[8]) const { return _mm256_storeu_si256(reinterpret_cast<__m256i *>(dst), *this); } - - // Override to distinguish from bool version - simdutf_really_inline simd16 operator~() const { return *this ^ 0xFFFFu; } - - // Addition/subtraction are the same for signed and unsigned - simdutf_really_inline simd16 operator+(const simd16 other) const { return _mm256_add_epi16(*this, other); } - simdutf_really_inline simd16 operator-(const simd16 other) const { return _mm256_sub_epi16(*this, other); } - simdutf_really_inline simd16& operator+=(const simd16 other) { *this = *this + other; return *static_cast*>(this); } - simdutf_really_inline simd16& operator-=(const simd16 other) { *this = *this - other; return *static_cast*>(this); } +struct base16_numeric : base16 { + static simdutf_really_inline simd16 splat(T _value) { return _mm256_set1_epi16(_value); } + static simdutf_really_inline simd16 zero() { return _mm256_setzero_si256(); } + static simdutf_really_inline simd16 load(const T values[8]) + { + return _mm256_loadu_si256(reinterpret_cast(values)); + } + + simdutf_really_inline base16_numeric() + : base16() + { + } + simdutf_really_inline base16_numeric(const __m256i _value) + : base16(_value) + { + } + + // Store to array + simdutf_really_inline void store(T dst[8]) const { return _mm256_storeu_si256(reinterpret_cast<__m256i*>(dst), *this); } + + // Override to distinguish from bool version + simdutf_really_inline simd16 operator~() const { return *this ^ 0xFFFFu; } + + // Addition/subtraction are the same for signed and unsigned + simdutf_really_inline simd16 operator+(const simd16 other) const { return _mm256_add_epi16(*this, other); } + simdutf_really_inline simd16 operator-(const simd16 other) const { return _mm256_sub_epi16(*this, other); } + simdutf_really_inline simd16& operator+=(const simd16 other) + { + *this = *this + other; + return *static_cast*>(this); + } + simdutf_really_inline simd16& operator-=(const simd16 other) + { + *this = *this - other; + return *static_cast*>(this); + } }; // Signed words template<> struct simd16 : base16_numeric { - simdutf_really_inline simd16() : base16_numeric() {} - simdutf_really_inline simd16(const __m256i _value) : base16_numeric(_value) {} - // Splat constructor - simdutf_really_inline simd16(int16_t _value) : simd16(splat(_value)) {} - // Array constructor - simdutf_really_inline simd16(const int16_t* values) : simd16(load(values)) {} - simdutf_really_inline simd16(const char16_t* values) : simd16(load(reinterpret_cast(values))) {} - // Order-sensitive comparisons - simdutf_really_inline simd16 max_val(const simd16 other) const { return _mm256_max_epi16(*this, other); } - simdutf_really_inline simd16 min_val(const simd16 other) const { return _mm256_min_epi16(*this, other); } - simdutf_really_inline simd16 operator>(const simd16 other) const { return _mm256_cmpgt_epi16(*this, other); } - simdutf_really_inline simd16 operator<(const simd16 other) const { return _mm256_cmpgt_epi16(other, *this); } + simdutf_really_inline simd16() + : base16_numeric() + { + } + simdutf_really_inline simd16(const __m256i _value) + : base16_numeric(_value) + { + } + // Splat constructor + simdutf_really_inline simd16(int16_t _value) + : simd16(splat(_value)) + { + } + // Array constructor + simdutf_really_inline simd16(const int16_t* values) + : simd16(load(values)) + { + } + simdutf_really_inline simd16(const char16_t* values) + : simd16(load(reinterpret_cast(values))) + { + } + // Order-sensitive comparisons + simdutf_really_inline simd16 max_val(const simd16 other) const { return _mm256_max_epi16(*this, other); } + simdutf_really_inline simd16 min_val(const simd16 other) const { return _mm256_min_epi16(*this, other); } + simdutf_really_inline simd16 operator>(const simd16 other) const { return _mm256_cmpgt_epi16(*this, other); } + simdutf_really_inline simd16 operator<(const simd16 other) const { return _mm256_cmpgt_epi16(other, *this); } }; // Unsigned words template<> -struct simd16: base16_numeric { - simdutf_really_inline simd16() : base16_numeric() {} - simdutf_really_inline simd16(const __m256i _value) : base16_numeric(_value) {} - - // Splat constructor - simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {} - // Array constructor - simdutf_really_inline simd16(const uint16_t* values) : simd16(load(values)) {} - simdutf_really_inline simd16(const char16_t* values) : simd16(load(reinterpret_cast(values))) {} - - // Saturated math - simdutf_really_inline simd16 saturating_add(const simd16 other) const { return _mm256_adds_epu16(*this, other); } - simdutf_really_inline simd16 saturating_sub(const simd16 other) const { return _mm256_subs_epu16(*this, other); } - - // Order-specific operations - simdutf_really_inline simd16 max_val(const simd16 other) const { return _mm256_max_epu16(*this, other); } - simdutf_really_inline simd16 min_val(const simd16 other) const { return _mm256_min_epu16(*this, other); } - // Same as >, but only guarantees true is nonzero (< guarantees true = -1) - simdutf_really_inline simd16 gt_bits(const simd16 other) const { return this->saturating_sub(other); } - // Same as <, but only guarantees true is nonzero (< guarantees true = -1) - simdutf_really_inline simd16 lt_bits(const simd16 other) const { return other.saturating_sub(*this); } - simdutf_really_inline simd16 operator<=(const simd16 other) const { return other.max_val(*this) == other; } - simdutf_really_inline simd16 operator>=(const simd16 other) const { return other.min_val(*this) == other; } - simdutf_really_inline simd16 operator>(const simd16 other) const { return this->gt_bits(other).any_bits_set(); } - simdutf_really_inline simd16 operator<(const simd16 other) const { return this->gt_bits(other).any_bits_set(); } - - // Bit-specific operations - simdutf_really_inline simd16 bits_not_set() const { return *this == uint16_t(0); } - simdutf_really_inline simd16 bits_not_set(simd16 bits) const { return (*this & bits).bits_not_set(); } - simdutf_really_inline simd16 any_bits_set() const { return ~this->bits_not_set(); } - simdutf_really_inline simd16 any_bits_set(simd16 bits) const { return ~this->bits_not_set(bits); } - - simdutf_really_inline bool bits_not_set_anywhere() const { return _mm256_testz_si256(*this, *this); } - simdutf_really_inline bool any_bits_set_anywhere() const { return !bits_not_set_anywhere(); } - simdutf_really_inline bool bits_not_set_anywhere(simd16 bits) const { return _mm256_testz_si256(*this, bits); } - simdutf_really_inline bool any_bits_set_anywhere(simd16 bits) const { return !bits_not_set_anywhere(bits); } - template - simdutf_really_inline simd16 shr() const { return simd16(_mm256_srli_epi16(*this, N)); } - template - simdutf_really_inline simd16 shl() const { return simd16(_mm256_slli_epi16(*this, N)); } - // Get one of the bits and make a bitmask out of it. - // e.g. value.get_bit<7>() gets the high bit - template - simdutf_really_inline int get_bit() const { return _mm256_movemask_epi8(_mm256_slli_epi16(*this, 15-N)); } - - // Change the endianness - simdutf_really_inline simd16 swap_bytes() const { - const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, - 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); - return _mm256_shuffle_epi8(*this, swap); - } - - // Pack with the unsigned saturation two uint16_t words into single uint8_t vector - static simdutf_really_inline simd8 pack(const simd16& v0, const simd16& v1) { - // Note: the AVX2 variant of pack operates on 128-bit lanes, thus - // we have to shuffle lanes in order to produce bytes in the - // correct order. - - // get the 0th lanes - const __m128i lo_0 = _mm256_extracti128_si256(v0, 0); - const __m128i lo_1 = _mm256_extracti128_si256(v1, 0); - - // get the 1st lanes - const __m128i hi_0 = _mm256_extracti128_si256(v0, 1); - const __m128i hi_1 = _mm256_extracti128_si256(v1, 1); - - // build new vectors (shuffle lanes) - const __m256i t0 = _mm256_set_m128i(lo_1, lo_0); - const __m256i t1 = _mm256_set_m128i(hi_1, hi_0); - - // pack words in linear order from v0 and v1 - return _mm256_packus_epi16(t0, t1); - } -}; +struct simd16 : base16_numeric { + simdutf_really_inline simd16() + : base16_numeric() + { + } + simdutf_really_inline simd16(const __m256i _value) + : base16_numeric(_value) + { + } + + // Splat constructor + simdutf_really_inline simd16(uint16_t _value) + : simd16(splat(_value)) + { + } + // Array constructor + simdutf_really_inline simd16(const uint16_t* values) + : simd16(load(values)) + { + } + simdutf_really_inline simd16(const char16_t* values) + : simd16(load(reinterpret_cast(values))) + { + } + + // Saturated math + simdutf_really_inline simd16 saturating_add(const simd16 other) const { return _mm256_adds_epu16(*this, other); } + simdutf_really_inline simd16 saturating_sub(const simd16 other) const { return _mm256_subs_epu16(*this, other); } + + // Order-specific operations + simdutf_really_inline simd16 max_val(const simd16 other) const { return _mm256_max_epu16(*this, other); } + simdutf_really_inline simd16 min_val(const simd16 other) const { return _mm256_min_epu16(*this, other); } + // Same as >, but only guarantees true is nonzero (< guarantees true = -1) + simdutf_really_inline simd16 gt_bits(const simd16 other) const { return this->saturating_sub(other); } + // Same as <, but only guarantees true is nonzero (< guarantees true = -1) + simdutf_really_inline simd16 lt_bits(const simd16 other) const { return other.saturating_sub(*this); } + simdutf_really_inline simd16 operator<=(const simd16 other) const { return other.max_val(*this) == other; } + simdutf_really_inline simd16 operator>=(const simd16 other) const { return other.min_val(*this) == other; } + simdutf_really_inline simd16 operator>(const simd16 other) const { return this->gt_bits(other).any_bits_set(); } + simdutf_really_inline simd16 operator<(const simd16 other) const { return this->gt_bits(other).any_bits_set(); } + + // Bit-specific operations + simdutf_really_inline simd16 bits_not_set() const { return *this == uint16_t(0); } + simdutf_really_inline simd16 bits_not_set(simd16 bits) const { return (*this & bits).bits_not_set(); } + simdutf_really_inline simd16 any_bits_set() const { return ~this->bits_not_set(); } + simdutf_really_inline simd16 any_bits_set(simd16 bits) const { return ~this->bits_not_set(bits); } + + simdutf_really_inline bool bits_not_set_anywhere() const { return _mm256_testz_si256(*this, *this); } + simdutf_really_inline bool any_bits_set_anywhere() const { return !bits_not_set_anywhere(); } + simdutf_really_inline bool bits_not_set_anywhere(simd16 bits) const { return _mm256_testz_si256(*this, bits); } + simdutf_really_inline bool any_bits_set_anywhere(simd16 bits) const { return !bits_not_set_anywhere(bits); } + template + simdutf_really_inline simd16 shr() const { return simd16(_mm256_srli_epi16(*this, N)); } + template + simdutf_really_inline simd16 shl() const { return simd16(_mm256_slli_epi16(*this, N)); } + // Get one of the bits and make a bitmask out of it. + // e.g. value.get_bit<7>() gets the high bit + template + simdutf_really_inline int get_bit() const { return _mm256_movemask_epi8(_mm256_slli_epi16(*this, 15 - N)); } + + // Change the endianness + simdutf_really_inline simd16 swap_bytes() const + { + const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, + 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); + return _mm256_shuffle_epi8(*this, swap); + } + + // Pack with the unsigned saturation two uint16_t words into single uint8_t vector + static simdutf_really_inline simd8 pack(const simd16& v0, const simd16& v1) + { + // Note: the AVX2 variant of pack operates on 128-bit lanes, thus + // we have to shuffle lanes in order to produce bytes in the + // correct order. + + // get the 0th lanes + const __m128i lo_0 = _mm256_extracti128_si256(v0, 0); + const __m128i lo_1 = _mm256_extracti128_si256(v1, 0); + // get the 1st lanes + const __m128i hi_0 = _mm256_extracti128_si256(v0, 1); + const __m128i hi_1 = _mm256_extracti128_si256(v1, 1); - template - struct simd16x32 { + // build new vectors (shuffle lanes) + const __m256i t0 = _mm256_set_m128i(lo_1, lo_0); + const __m256i t1 = _mm256_set_m128i(hi_1, hi_0); + + // pack words in linear order from v0 and v1 + return _mm256_packus_epi16(t0, t1); + } +}; + +template +struct simd16x32 { static constexpr int NUM_CHUNKS = 64 / sizeof(simd16); static_assert(NUM_CHUNKS == 2, "Haswell kernel should use two registers per 64-byte block."); simd16 chunks[NUM_CHUNKS]; @@ -2224,96 +2639,114 @@ struct simd16: base16_numeric { simd16x32& operator=(const simd16 other) = delete; // no assignment allowed simd16x32() = delete; // no default constructor allowed - simdutf_really_inline simd16x32(const simd16 chunk0, const simd16 chunk1) : chunks{chunk0, chunk1} {} - simdutf_really_inline simd16x32(const T* ptr) : chunks{simd16::load(ptr), simd16::load(ptr+sizeof(simd16)/sizeof(T))} {} - - simdutf_really_inline void store(T* ptr) const { - this->chunks[0].store(ptr+sizeof(simd16)*0/sizeof(T)); - this->chunks[1].store(ptr+sizeof(simd16)*1/sizeof(T)); + simdutf_really_inline simd16x32(const simd16 chunk0, const simd16 chunk1) + : chunks { chunk0, chunk1 } + { } - - simdutf_really_inline uint64_t to_bitmask() const { - uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask()); - uint64_t r_hi = this->chunks[1].to_bitmask(); - return r_lo | (r_hi << 32); + simdutf_really_inline simd16x32(const T* ptr) + : chunks { simd16::load(ptr), simd16::load(ptr + sizeof(simd16) / sizeof(T)) } + { } - simdutf_really_inline simd16 reduce_or() const { - return this->chunks[0] | this->chunks[1]; + simdutf_really_inline void store(T* ptr) const + { + this->chunks[0].store(ptr + sizeof(simd16) * 0 / sizeof(T)); + this->chunks[1].store(ptr + sizeof(simd16) * 1 / sizeof(T)); } - simdutf_really_inline bool is_ascii() const { - return this->reduce_or().is_ascii(); + simdutf_really_inline uint64_t to_bitmask() const + { + uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask()); + uint64_t r_hi = this->chunks[1].to_bitmask(); + return r_lo | (r_hi << 32); } - simdutf_really_inline void store_ascii_as_utf16(char16_t * ptr) const { - this->chunks[0].store_ascii_as_utf16(ptr+sizeof(simd16)*0); - this->chunks[1].store_ascii_as_utf16(ptr+sizeof(simd16)); + simdutf_really_inline simd16 reduce_or() const + { + return this->chunks[0] | this->chunks[1]; } - simdutf_really_inline simd16x32 bit_or(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] | mask, - this->chunks[1] | mask - ); + simdutf_really_inline bool is_ascii() const + { + return this->reduce_or().is_ascii(); } - simdutf_really_inline void swap_bytes() { - this->chunks[0] = this->chunks[0].swap_bytes(); - this->chunks[1] = this->chunks[1].swap_bytes(); + simdutf_really_inline void store_ascii_as_utf16(char16_t* ptr) const + { + this->chunks[0].store_ascii_as_utf16(ptr + sizeof(simd16) * 0); + this->chunks[1].store_ascii_as_utf16(ptr + sizeof(simd16)); } - simdutf_really_inline uint64_t eq(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] == mask, - this->chunks[1] == mask - ).to_bitmask(); + simdutf_really_inline simd16x32 bit_or(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] | mask, + this->chunks[1] | mask); } - simdutf_really_inline uint64_t eq(const simd16x32 &other) const { - return simd16x32( - this->chunks[0] == other.chunks[0], - this->chunks[1] == other.chunks[1] - ).to_bitmask(); + simdutf_really_inline void swap_bytes() + { + this->chunks[0] = this->chunks[0].swap_bytes(); + this->chunks[1] = this->chunks[1].swap_bytes(); } - simdutf_really_inline uint64_t lteq(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] <= mask, - this->chunks[1] <= mask - ).to_bitmask(); + simdutf_really_inline uint64_t eq(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] == mask, + this->chunks[1] == mask) + .to_bitmask(); } - simdutf_really_inline uint64_t in_range(const T low, const T high) const { - const simd16 mask_low = simd16::splat(low); - const simd16 mask_high = simd16::splat(high); + simdutf_really_inline uint64_t eq(const simd16x32& other) const + { + return simd16x32( + this->chunks[0] == other.chunks[0], + this->chunks[1] == other.chunks[1]) + .to_bitmask(); + } - return simd16x32( - (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), - (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), - (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), - (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low) - ).to_bitmask(); + simdutf_really_inline uint64_t lteq(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] <= mask, + this->chunks[1] <= mask) + .to_bitmask(); } - simdutf_really_inline uint64_t not_in_range(const T low, const T high) const { - const simd16 mask_low = simd16::splat(static_cast(low-1)); - const simd16 mask_high = simd16::splat(static_cast(high+1)); - return simd16x32( - (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low), - (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low) - ).to_bitmask(); + + simdutf_really_inline uint64_t in_range(const T low, const T high) const + { + const simd16 mask_low = simd16::splat(low); + const simd16 mask_high = simd16::splat(high); + + return simd16x32( + (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), + (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), + (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), + (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low)) + .to_bitmask(); } - simdutf_really_inline uint64_t lt(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] < mask, - this->chunks[1] < mask - ).to_bitmask(); + simdutf_really_inline uint64_t not_in_range(const T low, const T high) const + { + const simd16 mask_low = simd16::splat(static_cast(low - 1)); + const simd16 mask_high = simd16::splat(static_cast(high + 1)); + return simd16x32( + (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low), + (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t lt(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] < mask, + this->chunks[1] < mask) + .to_bitmask(); } - }; // struct simd16x32 +}; // struct simd16x32 /* end file src/simdutf/haswell/simd16-inl.h */ } // namespace simd @@ -2325,7 +2758,7 @@ struct simd16: base16_numeric { #endif // SIMDUTF_HASWELL_SIMD_H /* end file src/simdutf/haswell/simd.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/end.h /* begin file src/simdutf/haswell/end.h */ #if SIMDUTF_CAN_ALWAYS_RUN_HASWELL // nothing needed. @@ -2333,7 +2766,6 @@ struct simd16: base16_numeric { SIMDUTF_UNTARGET_REGION #endif - #if SIMDUTF_GCC11ORMORE // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593 SIMDUTF_POP_DISABLE_WARNINGS #endif // end of workaround @@ -2342,7 +2774,7 @@ SIMDUTF_POP_DISABLE_WARNINGS #endif // SIMDUTF_IMPLEMENTATION_HASWELL #endif // SIMDUTF_HASWELL_COMMON_H /* end file src/simdutf/haswell.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere.h /* begin file src/simdutf/westmere.h */ #ifndef SIMDUTF_WESTMERE_H #define SIMDUTF_WESTMERE_H @@ -2351,7 +2783,6 @@ SIMDUTF_POP_DISABLE_WARNINGS #error "westmere.h must be included before fallback.h" #endif - // Default Westmere to on if this is x86-64, unless we'll always select Haswell. #ifndef SIMDUTF_IMPLEMENTATION_WESTMERE // @@ -2366,11 +2797,11 @@ SIMDUTF_POP_DISABLE_WARNINGS #endif -#define SIMDUTF_CAN_ALWAYS_RUN_WESTMERE (SIMDUTF_IMPLEMENTATION_WESTMERE && SIMDUTF_IS_X86_64 && __SSE4_2__ && __PCLMUL__) +#define SIMDUTF_CAN_ALWAYS_RUN_WESTMERE (SIMDUTF_IMPLEMENTATION_WESTMERE && SIMDUTF_IS_X86_64 && __SSE4_2__) #if SIMDUTF_IMPLEMENTATION_WESTMERE -#define SIMDUTF_TARGET_WESTMERE SIMDUTF_TARGET_REGION("sse4.2,pclmul") +#define SIMDUTF_TARGET_WESTMERE SIMDUTF_TARGET_REGION("sse4.2,popcnt") namespace simdutf { /** @@ -2383,12 +2814,11 @@ namespace westmere { // // These two need to be included outside SIMDUTF_TARGET_REGION // -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/implementation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/implementation.h /* begin file src/simdutf/westmere/implementation.h */ #ifndef SIMDUTF_WESTMERE_IMPLEMENTATION_H #define SIMDUTF_WESTMERE_IMPLEMENTATION_H - // The constructor may be executed on any host, so we take care not to use SIMDUTF_TARGET_REGION namespace simdutf { namespace westmere { @@ -2399,60 +2829,85 @@ using namespace simdutf; class implementation final : public simdutf::implementation { public: - simdutf_really_inline implementation() : simdutf::implementation("westmere", "Intel/AMD SSE4.2", internal::instruction_set::SSE42 | internal::instruction_set::PCLMULQDQ) {} - simdutf_warn_unused int detect_encodings(const char * input, size_t length) const noexcept final; - simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16le(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16be(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - void change_endianness_utf16(const char16_t * buf, size_t length, char16_t * output) const noexcept final; - simdutf_warn_unused size_t count_utf16le(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf16be(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf8(const char * buf, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t length) const noexcept; + simdutf_really_inline implementation() + : simdutf::implementation("westmere", "Intel/AMD SSE4.2", internal::instruction_set::SSE42) + { + } + simdutf_warn_unused int detect_encodings(const char* input, size_t length) const noexcept final; + simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + void change_endianness_utf16(const char16_t* buf, size_t length, char16_t* output) const noexcept final; + simdutf_warn_unused size_t count_utf16le(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf16be(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf8(const char* buf, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf16(size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf32(size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_latin1(const char* input, size_t length) const noexcept; }; } // namespace westmere @@ -2460,7 +2915,7 @@ public: #endif // SIMDUTF_WESTMERE_IMPLEMENTATION_H /* end file src/simdutf/westmere/implementation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/intrinsics.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/intrinsics.h /* begin file src/simdutf/westmere/intrinsics.h */ #ifndef SIMDUTF_WESTMERE_INTRINSICS_H #define SIMDUTF_WESTMERE_INTRINSICS_H @@ -2480,7 +2935,6 @@ SIMDUTF_DISABLE_GCC_WARNING(-Wuninitialized) #include // elsewhere - #if SIMDUTF_GCC11ORMORE // cancels the suppression of the -Wuninitialized SIMDUTF_POP_DISABLE_WARNINGS @@ -2488,7 +2942,6 @@ SIMDUTF_POP_DISABLE_WARNINGS #endif // SIMDUTF_VISUAL_STUDIO - #ifdef SIMDUTF_CLANG_VISUAL_STUDIO /** * You are not supposed, normally, to include these @@ -2498,19 +2951,16 @@ SIMDUTF_POP_DISABLE_WARNINGS * only get included *if* the corresponding features are detected * from macros: */ -#include // for _mm_alignr_epi8 -#include // for _mm_clmulepi64_si128 +#include // for _mm_alignr_epi8 #endif - - #endif // SIMDUTF_WESTMERE_INTRINSICS_H /* end file src/simdutf/westmere/intrinsics.h */ // // The rest need to be inside the region // -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/begin.h /* begin file src/simdutf/westmere/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "westmere" // #define SIMDUTF_IMPLEMENTATION westmere @@ -2523,7 +2973,7 @@ SIMDUTF_TARGET_WESTMERE /* end file src/simdutf/westmere/begin.h */ // Declarations -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/bitmanipulation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/bitmanipulation.h /* begin file src/simdutf/westmere/bitmanipulation.h */ #ifndef SIMDUTF_WESTMERE_BITMANIPULATION_H #define SIMDUTF_WESTMERE_BITMANIPULATION_H @@ -2533,13 +2983,15 @@ namespace westmere { namespace { #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO -simdutf_really_inline unsigned __int64 count_ones(uint64_t input_num) { - // note: we do not support legacy 32-bit Windows - return __popcnt64(input_num);// Visual Studio wants two underscores +simdutf_really_inline unsigned __int64 count_ones(uint64_t input_num) +{ + // note: we do not support legacy 32-bit Windows + return __popcnt64(input_num); // Visual Studio wants two underscores } #else -simdutf_really_inline long long int count_ones(uint64_t input_num) { - return _popcnt64(input_num); +simdutf_really_inline long long int count_ones(uint64_t input_num) +{ + return _popcnt64(input_num); } #endif @@ -2549,7 +3001,7 @@ simdutf_really_inline long long int count_ones(uint64_t input_num) { #endif // SIMDUTF_WESTMERE_BITMANIPULATION_H /* end file src/simdutf/westmere/bitmanipulation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/simd.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/simd.h /* begin file src/simdutf/westmere/simd.h */ #ifndef SIMDUTF_WESTMERE_SIMD_H #define SIMDUTF_WESTMERE_SIMD_H @@ -2559,110 +3011,155 @@ namespace westmere { namespace { namespace simd { - template - struct base { +template +struct base { __m128i value; // Zero constructor - simdutf_really_inline base() : value{__m128i()} {} + simdutf_really_inline base() + : value { __m128i() } + { + } // Conversion from SIMD register - simdutf_really_inline base(const __m128i _value) : value(_value) {} + simdutf_really_inline base(const __m128i _value) + : value(_value) + { + } // Conversion to SIMD register simdutf_really_inline operator const __m128i&() const { return this->value; } simdutf_really_inline operator __m128i&() { return this->value; } - template - simdutf_really_inline void store_ascii_as_utf16(char16_t * p) const { - __m128i first = _mm_cvtepu8_epi16(*this); - __m128i second = _mm_cvtepu8_epi16(_mm_srli_si128(*this,8)); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - first = _mm_shuffle_epi8(first, swap); - second = _mm_shuffle_epi8(second, swap); - } - _mm_storeu_si128(reinterpret_cast<__m128i *>(p), first); - _mm_storeu_si128(reinterpret_cast<__m128i *>(p+8), second); - } - simdutf_really_inline void store_ascii_as_utf32(char32_t * p) const { - _mm_storeu_si128(reinterpret_cast<__m128i *>(p), _mm_cvtepu8_epi32(*this)); - _mm_storeu_si128(reinterpret_cast<__m128i *>(p+4), _mm_cvtepu8_epi32(_mm_srli_si128(*this,4))); - _mm_storeu_si128(reinterpret_cast<__m128i *>(p+8), _mm_cvtepu8_epi32(_mm_srli_si128(*this,8))); - _mm_storeu_si128(reinterpret_cast<__m128i *>(p+12), _mm_cvtepu8_epi32(_mm_srli_si128(*this,12))); + template + simdutf_really_inline void store_ascii_as_utf16(char16_t* p) const + { + __m128i first = _mm_cvtepu8_epi16(*this); + __m128i second = _mm_cvtepu8_epi16(_mm_srli_si128(*this, 8)); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + first = _mm_shuffle_epi8(first, swap); + second = _mm_shuffle_epi8(second, swap); + } + _mm_storeu_si128(reinterpret_cast<__m128i*>(p), first); + _mm_storeu_si128(reinterpret_cast<__m128i*>(p + 8), second); + } + simdutf_really_inline void store_ascii_as_utf32(char32_t* p) const + { + _mm_storeu_si128(reinterpret_cast<__m128i*>(p), _mm_cvtepu8_epi32(*this)); + _mm_storeu_si128(reinterpret_cast<__m128i*>(p + 4), _mm_cvtepu8_epi32(_mm_srli_si128(*this, 4))); + _mm_storeu_si128(reinterpret_cast<__m128i*>(p + 8), _mm_cvtepu8_epi32(_mm_srli_si128(*this, 8))); + _mm_storeu_si128(reinterpret_cast<__m128i*>(p + 12), _mm_cvtepu8_epi32(_mm_srli_si128(*this, 12))); } // Bit operations simdutf_really_inline Child operator|(const Child other) const { return _mm_or_si128(*this, other); } simdutf_really_inline Child operator&(const Child other) const { return _mm_and_si128(*this, other); } simdutf_really_inline Child operator^(const Child other) const { return _mm_xor_si128(*this, other); } simdutf_really_inline Child bit_andnot(const Child other) const { return _mm_andnot_si128(other, *this); } - simdutf_really_inline Child& operator|=(const Child other) { auto this_cast = static_cast(this); *this_cast = *this_cast | other; return *this_cast; } - simdutf_really_inline Child& operator&=(const Child other) { auto this_cast = static_cast(this); *this_cast = *this_cast & other; return *this_cast; } - simdutf_really_inline Child& operator^=(const Child other) { auto this_cast = static_cast(this); *this_cast = *this_cast ^ other; return *this_cast; } - }; + simdutf_really_inline Child& operator|=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast | other; + return *this_cast; + } + simdutf_really_inline Child& operator&=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast & other; + return *this_cast; + } + simdutf_really_inline Child& operator^=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast ^ other; + return *this_cast; + } +}; - // Forward-declared so they can be used by splat and friends. - template - struct simd8; +// Forward-declared so they can be used by splat and friends. +template +struct simd8; - template> - struct base8: base> { +template> +struct base8 : base> { typedef uint16_t bitmask_t; typedef uint32_t bitmask2_t; - simdutf_really_inline T first() const { return _mm_extract_epi8(*this,0); } - simdutf_really_inline T last() const { return _mm_extract_epi8(*this,15); } - simdutf_really_inline base8() : base>() {} - simdutf_really_inline base8(const __m128i _value) : base>(_value) {} + simdutf_really_inline T first() const { return _mm_extract_epi8(*this, 0); } + simdutf_really_inline T last() const { return _mm_extract_epi8(*this, 15); } + simdutf_really_inline base8() + : base>() + { + } + simdutf_really_inline base8(const __m128i _value) + : base>(_value) + { + } - simdutf_really_inline Mask operator==(const simd8 other) const { return _mm_cmpeq_epi8(*this, other); } + friend simdutf_really_inline Mask operator==(const simd8 lhs, const simd8 rhs) { return _mm_cmpeq_epi8(lhs, rhs); } static const int SIZE = sizeof(base>::value); - template - simdutf_really_inline simd8 prev(const simd8 prev_chunk) const { - return _mm_alignr_epi8(*this, prev_chunk, 16 - N); + template + simdutf_really_inline simd8 prev(const simd8 prev_chunk) const + { + return _mm_alignr_epi8(*this, prev_chunk, 16 - N); } - }; +}; - // SIMD byte mask type (returned by things like eq and gt) - template<> - struct simd8: base8 { +// SIMD byte mask type (returned by things like eq and gt) +template<> +struct simd8 : base8 { static simdutf_really_inline simd8 splat(bool _value) { return _mm_set1_epi8(uint8_t(-(!!_value))); } - simdutf_really_inline simd8() : base8() {} - simdutf_really_inline simd8(const __m128i _value) : base8(_value) {} + simdutf_really_inline simd8() + : base8() + { + } + simdutf_really_inline simd8(const __m128i _value) + : base8(_value) + { + } // Splat constructor - simdutf_really_inline simd8(bool _value) : base8(splat(_value)) {} + simdutf_really_inline simd8(bool _value) + : base8(splat(_value)) + { + } simdutf_really_inline int to_bitmask() const { return _mm_movemask_epi8(*this); } simdutf_really_inline bool any() const { return !_mm_testz_si128(*this, *this); } simdutf_really_inline bool none() const { return _mm_testz_si128(*this, *this); } simdutf_really_inline bool all() const { return _mm_movemask_epi8(*this) == 0xFFFF; } simdutf_really_inline simd8 operator~() const { return *this ^ true; } - }; +}; - template - struct base8_numeric: base8 { +template +struct base8_numeric : base8 { static simdutf_really_inline simd8 splat(T _value) { return _mm_set1_epi8(_value); } static simdutf_really_inline simd8 zero() { return _mm_setzero_si128(); } - static simdutf_really_inline simd8 load(const T values[16]) { - return _mm_loadu_si128(reinterpret_cast(values)); + static simdutf_really_inline simd8 load(const T values[16]) + { + return _mm_loadu_si128(reinterpret_cast(values)); } // Repeat 16 values as many times as necessary (usually for lookup tables) static simdutf_really_inline simd8 repeat_16( - T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, - T v8, T v9, T v10, T v11, T v12, T v13, T v14, T v15 - ) { - return simd8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - ); + T v0, T v1, T v2, T v3, T v4, T v5, T v6, T v7, + T v8, T v9, T v10, T v11, T v12, T v13, T v14, T v15) + { + return simd8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); } - simdutf_really_inline base8_numeric() : base8() {} - simdutf_really_inline base8_numeric(const __m128i _value) : base8(_value) {} + simdutf_really_inline base8_numeric() + : base8() + { + } + simdutf_really_inline base8_numeric(const __m128i _value) + : base8(_value) + { + } // Store to array - simdutf_really_inline void store(T dst[16]) const { return _mm_storeu_si128(reinterpret_cast<__m128i *>(dst), *this); } + simdutf_really_inline void store(T dst[16]) const { return _mm_storeu_si128(reinterpret_cast<__m128i*>(dst), *this); } // Override to distinguish from bool version simdutf_really_inline simd8 operator~() const { return *this ^ 0xFFu; } @@ -2670,56 +3167,77 @@ namespace simd { // Addition/subtraction are the same for signed and unsigned simdutf_really_inline simd8 operator+(const simd8 other) const { return _mm_add_epi8(*this, other); } simdutf_really_inline simd8 operator-(const simd8 other) const { return _mm_sub_epi8(*this, other); } - simdutf_really_inline simd8& operator+=(const simd8 other) { *this = *this + other; return *static_cast*>(this); } - simdutf_really_inline simd8& operator-=(const simd8 other) { *this = *this - other; return *static_cast*>(this); } + simdutf_really_inline simd8& operator+=(const simd8 other) + { + *this = *this + other; + return *static_cast*>(this); + } + simdutf_really_inline simd8& operator-=(const simd8 other) + { + *this = *this - other; + return *static_cast*>(this); + } // Perform a lookup assuming the value is between 0 and 16 (undefined behavior for out of range values) template - simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const { - return _mm_shuffle_epi8(lookup_table, *this); + simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const + { + return _mm_shuffle_epi8(lookup_table, *this); } template simdutf_really_inline simd8 lookup_16( - L replace0, L replace1, L replace2, L replace3, - L replace4, L replace5, L replace6, L replace7, - L replace8, L replace9, L replace10, L replace11, - L replace12, L replace13, L replace14, L replace15) const { - return lookup_16(simd8::repeat_16( - replace0, replace1, replace2, replace3, - replace4, replace5, replace6, replace7, - replace8, replace9, replace10, replace11, - replace12, replace13, replace14, replace15 - )); - } - }; - - // Signed bytes - template<> - struct simd8 : base8_numeric { - simdutf_really_inline simd8() : base8_numeric() {} - simdutf_really_inline simd8(const __m128i _value) : base8_numeric(_value) {} + L replace0, L replace1, L replace2, L replace3, + L replace4, L replace5, L replace6, L replace7, + L replace8, L replace9, L replace10, L replace11, + L replace12, L replace13, L replace14, L replace15) const + { + return lookup_16(simd8::repeat_16( + replace0, replace1, replace2, replace3, + replace4, replace5, replace6, replace7, + replace8, replace9, replace10, replace11, + replace12, replace13, replace14, replace15)); + } +}; + +// Signed bytes +template<> +struct simd8 : base8_numeric { + simdutf_really_inline simd8() + : base8_numeric() + { + } + simdutf_really_inline simd8(const __m128i _value) + : base8_numeric(_value) + { + } // Splat constructor - simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {} + simdutf_really_inline simd8(int8_t _value) + : simd8(splat(_value)) + { + } // Array constructor - simdutf_really_inline simd8(const int8_t* values) : simd8(load(values)) {} + simdutf_really_inline simd8(const int8_t* values) + : simd8(load(values)) + { + } // Member-by-member initialization simdutf_really_inline simd8( - int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, - int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15 - ) : simd8(_mm_setr_epi8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - )) {} + int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, + int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15) + : simd8(_mm_setr_epi8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15)) + { + } // Repeat 16 values as many times as necessary (usually for lookup tables) simdutf_really_inline static simd8 repeat_16( - int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, - int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15 - ) { - return simd8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - ); + int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7, + int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15) + { + return simd8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); } simdutf_really_inline operator simd8() const; simdutf_really_inline bool is_ascii() const { return _mm_movemask_epi8(*this) == 0; } @@ -2729,35 +3247,47 @@ namespace simd { simdutf_really_inline simd8 min_val(const simd8 other) const { return _mm_min_epi8(*this, other); } simdutf_really_inline simd8 operator>(const simd8 other) const { return _mm_cmpgt_epi8(*this, other); } simdutf_really_inline simd8 operator<(const simd8 other) const { return _mm_cmpgt_epi8(other, *this); } - }; +}; - // Unsigned bytes - template<> - struct simd8: base8_numeric { - simdutf_really_inline simd8() : base8_numeric() {} - simdutf_really_inline simd8(const __m128i _value) : base8_numeric(_value) {} +// Unsigned bytes +template<> +struct simd8 : base8_numeric { + simdutf_really_inline simd8() + : base8_numeric() + { + } + simdutf_really_inline simd8(const __m128i _value) + : base8_numeric(_value) + { + } // Splat constructor - simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {} + simdutf_really_inline simd8(uint8_t _value) + : simd8(splat(_value)) + { + } // Array constructor - simdutf_really_inline simd8(const uint8_t* values) : simd8(load(values)) {} + simdutf_really_inline simd8(const uint8_t* values) + : simd8(load(values)) + { + } // Member-by-member initialization simdutf_really_inline simd8( - uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, - uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15 - ) : simd8(_mm_setr_epi8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - )) {} + uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, + uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15) + : simd8(_mm_setr_epi8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15)) + { + } // Repeat 16 values as many times as necessary (usually for lookup tables) simdutf_really_inline static simd8 repeat_16( - uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, - uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15 - ) { - return simd8( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10,v11,v12,v13,v14,v15 - ); + uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, + uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15) + { + return simd8( + v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); } // Saturated math @@ -2794,30 +3324,44 @@ namespace simd { // Get one of the bits and make a bitmask out of it. // e.g. value.get_bit<7>() gets the high bit template - simdutf_really_inline int get_bit() const { return _mm_movemask_epi8(_mm_slli_epi16(*this, 7-N)); } - }; - simdutf_really_inline simd8::operator simd8() const { return this->value; } + simdutf_really_inline int get_bit() const { return _mm_movemask_epi8(_mm_slli_epi16(*this, 7 - N)); } +}; +simdutf_really_inline simd8::operator simd8() const { return this->value; } - // Unsigned bytes - template<> - struct simd8: base { +// Unsigned bytes +template<> +struct simd8 : base { static simdutf_really_inline simd8 splat(uint16_t _value) { return _mm_set1_epi16(_value); } - static simdutf_really_inline simd8 load(const uint16_t values[8]) { - return _mm_loadu_si128(reinterpret_cast(values)); + static simdutf_really_inline simd8 load(const uint16_t values[8]) + { + return _mm_loadu_si128(reinterpret_cast(values)); } - simdutf_really_inline simd8() : base() {} - simdutf_really_inline simd8(const __m128i _value) : base(_value) {} + simdutf_really_inline simd8() + : base() + { + } + simdutf_really_inline simd8(const __m128i _value) + : base(_value) + { + } // Splat constructor - simdutf_really_inline simd8(uint16_t _value) : simd8(splat(_value)) {} + simdutf_really_inline simd8(uint16_t _value) + : simd8(splat(_value)) + { + } // Array constructor - simdutf_really_inline simd8(const uint16_t* values) : simd8(load(values)) {} + simdutf_really_inline simd8(const uint16_t* values) + : simd8(load(values)) + { + } // Member-by-member initialization simdutf_really_inline simd8( - uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3, uint16_t v4, uint16_t v5, uint16_t v6, uint16_t v7 - ) : simd8(_mm_setr_epi16( - v0, v1, v2, v3, v4, v5, v6, v7 - )) {} + uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3, uint16_t v4, uint16_t v5, uint16_t v6, uint16_t v7) + : simd8(_mm_setr_epi16( + v0, v1, v2, v3, v4, v5, v6, v7)) + { + } // Saturated math simdutf_really_inline simd8 saturating_add(const simd8 other) const { return _mm_adds_epu16(*this, other); } @@ -2844,9 +3388,9 @@ namespace simd { simdutf_really_inline bool any_bits_set_anywhere() const { return !bits_not_set_anywhere(); } simdutf_really_inline bool bits_not_set_anywhere(simd8 bits) const { return _mm_testz_si128(*this, bits); } simdutf_really_inline bool any_bits_set_anywhere(simd8 bits) const { return !bits_not_set_anywhere(bits); } - }; - template - struct simd8x64 { +}; +template +struct simd8x64 { static constexpr int NUM_CHUNKS = 64 / sizeof(simd8); static_assert(NUM_CHUNKS == 4, "Westmere kernel should use four registers per 64-byte block."); simd8 chunks[NUM_CHUNKS]; @@ -2855,303 +3399,395 @@ namespace simd { simd8x64& operator=(const simd8 other) = delete; // no assignment allowed simd8x64() = delete; // no default constructor allowed - simdutf_really_inline simd8x64(const simd8 chunk0, const simd8 chunk1, const simd8 chunk2, const simd8 chunk3) : chunks{chunk0, chunk1, chunk2, chunk3} {} - simdutf_really_inline simd8x64(const T* ptr) : chunks{simd8::load(ptr), simd8::load(ptr+sizeof(simd8)/sizeof(T)), simd8::load(ptr+2*sizeof(simd8)/sizeof(T)), simd8::load(ptr+3*sizeof(simd8)/sizeof(T))} {} - - simdutf_really_inline void store(T* ptr) const { - this->chunks[0].store(ptr+sizeof(simd8)*0/sizeof(T)); - this->chunks[1].store(ptr+sizeof(simd8)*1/sizeof(T)); - this->chunks[2].store(ptr+sizeof(simd8)*2/sizeof(T)); - this->chunks[3].store(ptr+sizeof(simd8)*3/sizeof(T)); + simdutf_really_inline simd8x64(const simd8 chunk0, const simd8 chunk1, const simd8 chunk2, const simd8 chunk3) + : chunks { chunk0, chunk1, chunk2, chunk3 } + { + } + simdutf_really_inline simd8x64(const T* ptr) + : chunks { simd8::load(ptr), simd8::load(ptr + sizeof(simd8) / sizeof(T)), simd8::load(ptr + 2 * sizeof(simd8) / sizeof(T)), simd8::load(ptr + 3 * sizeof(simd8) / sizeof(T)) } + { + } + + simdutf_really_inline void store(T* ptr) const + { + this->chunks[0].store(ptr + sizeof(simd8) * 0 / sizeof(T)); + this->chunks[1].store(ptr + sizeof(simd8) * 1 / sizeof(T)); + this->chunks[2].store(ptr + sizeof(simd8) * 2 / sizeof(T)); + this->chunks[3].store(ptr + sizeof(simd8) * 3 / sizeof(T)); + } + + simdutf_really_inline simd8x64& operator|=(const simd8x64& other) + { + this->chunks[0] |= other.chunks[0]; + this->chunks[1] |= other.chunks[1]; + this->chunks[2] |= other.chunks[2]; + this->chunks[3] |= other.chunks[3]; + return *this; + } + + simdutf_really_inline simd8 reduce_or() const + { + return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); + } + + simdutf_really_inline bool is_ascii() const + { + return this->reduce_or().is_ascii(); + } + + template + simdutf_really_inline void store_ascii_as_utf16(char16_t* ptr) const + { + this->chunks[0].template store_ascii_as_utf16(ptr + sizeof(simd8) * 0); + this->chunks[1].template store_ascii_as_utf16(ptr + sizeof(simd8) * 1); + this->chunks[2].template store_ascii_as_utf16(ptr + sizeof(simd8) * 2); + this->chunks[3].template store_ascii_as_utf16(ptr + sizeof(simd8) * 3); + } + + simdutf_really_inline void store_ascii_as_utf32(char32_t* ptr) const + { + this->chunks[0].store_ascii_as_utf32(ptr + sizeof(simd8) * 0); + this->chunks[1].store_ascii_as_utf32(ptr + sizeof(simd8) * 1); + this->chunks[2].store_ascii_as_utf32(ptr + sizeof(simd8) * 2); + this->chunks[3].store_ascii_as_utf32(ptr + sizeof(simd8) * 3); + } + + simdutf_really_inline uint64_t to_bitmask() const + { + uint64_t r0 = uint32_t(this->chunks[0].to_bitmask()); + uint64_t r1 = this->chunks[1].to_bitmask(); + uint64_t r2 = this->chunks[2].to_bitmask(); + uint64_t r3 = this->chunks[3].to_bitmask(); + return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48); + } + + simdutf_really_inline uint64_t eq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] == mask, + this->chunks[1] == mask, + this->chunks[2] == mask, + this->chunks[3] == mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t eq(const simd8x64& other) const + { + return simd8x64( + this->chunks[0] == other.chunks[0], + this->chunks[1] == other.chunks[1], + this->chunks[2] == other.chunks[2], + this->chunks[3] == other.chunks[3]) + .to_bitmask(); + } + + simdutf_really_inline uint64_t lteq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] <= mask, + this->chunks[1] <= mask, + this->chunks[2] <= mask, + this->chunks[3] <= mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t in_range(const T low, const T high) const + { + const simd8 mask_low = simd8::splat(low); + const simd8 mask_high = simd8::splat(high); + + return simd8x64( + (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), + (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), + (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), + (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t not_in_range(const T low, const T high) const + { + const simd8 mask_low = simd8::splat(low - 1); + const simd8 mask_high = simd8::splat(high + 1); + return simd8x64( + (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low), + (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low), + (this->chunks[2] >= mask_high) | (this->chunks[2] <= mask_low), + (this->chunks[3] >= mask_high) | (this->chunks[3] <= mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t lt(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] < mask, + this->chunks[1] < mask, + this->chunks[2] < mask, + this->chunks[3] < mask) + .to_bitmask(); } - simdutf_really_inline simd8x64& operator |=(const simd8x64 &other) { - this->chunks[0] |= other.chunks[0]; - this->chunks[1] |= other.chunks[1]; - this->chunks[2] |= other.chunks[2]; - this->chunks[3] |= other.chunks[3]; - return *this; - } - - simdutf_really_inline simd8 reduce_or() const { - return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); - } - - simdutf_really_inline bool is_ascii() const { - return this->reduce_or().is_ascii(); - } - - template - simdutf_really_inline void store_ascii_as_utf16(char16_t * ptr) const { - this->chunks[0].template store_ascii_as_utf16(ptr+sizeof(simd8)*0); - this->chunks[1].template store_ascii_as_utf16(ptr+sizeof(simd8)*1); - this->chunks[2].template store_ascii_as_utf16(ptr+sizeof(simd8)*2); - this->chunks[3].template store_ascii_as_utf16(ptr+sizeof(simd8)*3); - } - - simdutf_really_inline void store_ascii_as_utf32(char32_t * ptr) const { - this->chunks[0].store_ascii_as_utf32(ptr+sizeof(simd8)*0); - this->chunks[1].store_ascii_as_utf32(ptr+sizeof(simd8)*1); - this->chunks[2].store_ascii_as_utf32(ptr+sizeof(simd8)*2); - this->chunks[3].store_ascii_as_utf32(ptr+sizeof(simd8)*3); - } - - simdutf_really_inline uint64_t to_bitmask() const { - uint64_t r0 = uint32_t(this->chunks[0].to_bitmask() ); - uint64_t r1 = this->chunks[1].to_bitmask() ; - uint64_t r2 = this->chunks[2].to_bitmask() ; - uint64_t r3 = this->chunks[3].to_bitmask() ; - return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48); - } - - simdutf_really_inline uint64_t eq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] == mask, - this->chunks[1] == mask, - this->chunks[2] == mask, - this->chunks[3] == mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t eq(const simd8x64 &other) const { - return simd8x64( - this->chunks[0] == other.chunks[0], - this->chunks[1] == other.chunks[1], - this->chunks[2] == other.chunks[2], - this->chunks[3] == other.chunks[3] - ).to_bitmask(); - } - - simdutf_really_inline uint64_t lteq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] <= mask, - this->chunks[1] <= mask, - this->chunks[2] <= mask, - this->chunks[3] <= mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t in_range(const T low, const T high) const { - const simd8 mask_low = simd8::splat(low); - const simd8 mask_high = simd8::splat(high); - - return simd8x64( - (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), - (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), - (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), - (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t not_in_range(const T low, const T high) const { - const simd8 mask_low = simd8::splat(low-1); - const simd8 mask_high = simd8::splat(high+1); - return simd8x64( - (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low), - (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low), - (this->chunks[2] >= mask_high) | (this->chunks[2] <= mask_low), - (this->chunks[3] >= mask_high) | (this->chunks[3] <= mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t lt(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] < mask, - this->chunks[1] < mask, - this->chunks[2] < mask, - this->chunks[3] < mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t gt(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] > mask, - this->chunks[1] > mask, - this->chunks[2] > mask, - this->chunks[3] > mask - ).to_bitmask(); - } - simdutf_really_inline uint64_t gteq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] >= mask, - this->chunks[1] >= mask, - this->chunks[2] >= mask, - this->chunks[3] >= mask - ).to_bitmask(); - } - simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - simd8(__m128i(this->chunks[0])) >= mask, - simd8(__m128i(this->chunks[1])) >= mask, - simd8(__m128i(this->chunks[2])) >= mask, - simd8(__m128i(this->chunks[3])) >= mask - ).to_bitmask(); - } - }; // struct simd8x64 - -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/simd16-inl.h + simdutf_really_inline uint64_t gt(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] > mask, + this->chunks[1] > mask, + this->chunks[2] > mask, + this->chunks[3] > mask) + .to_bitmask(); + } + simdutf_really_inline uint64_t gteq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] >= mask, + this->chunks[1] >= mask, + this->chunks[2] >= mask, + this->chunks[3] >= mask) + .to_bitmask(); + } + simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + simd8(__m128i(this->chunks[0])) >= mask, + simd8(__m128i(this->chunks[1])) >= mask, + simd8(__m128i(this->chunks[2])) >= mask, + simd8(__m128i(this->chunks[3])) >= mask) + .to_bitmask(); + } +}; // struct simd8x64 + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/simd16-inl.h /* begin file src/simdutf/westmere/simd16-inl.h */ template struct simd16; -template> -struct base16: base> { - typedef uint16_t bitmask_t; - typedef uint32_t bitmask2_t; +template> +struct base16 : base> { + typedef uint16_t bitmask_t; + typedef uint32_t bitmask2_t; - simdutf_really_inline base16() : base>() {} - simdutf_really_inline base16(const __m128i _value) : base>(_value) {} - template - simdutf_really_inline base16(const Pointer* ptr) : base16(_mm_loadu_si128(reinterpret_cast(ptr))) {} + simdutf_really_inline base16() + : base>() + { + } + simdutf_really_inline base16(const __m128i _value) + : base>(_value) + { + } + template + simdutf_really_inline base16(const Pointer* ptr) + : base16(_mm_loadu_si128(reinterpret_cast(ptr))) + { + } - simdutf_really_inline Mask operator==(const simd16 other) const { return _mm_cmpeq_epi16(*this, other); } + friend simdutf_really_inline Mask operator==(const simd16 lhs, const simd16 rhs) { return _mm_cmpeq_epi16(lhs, rhs); } - static const int SIZE = sizeof(base>::value); + static const int SIZE = sizeof(base>::value); - template - simdutf_really_inline simd16 prev(const simd16 prev_chunk) const { - return _mm_alignr_epi8(*this, prev_chunk, 16 - N); - } + template + simdutf_really_inline simd16 prev(const simd16 prev_chunk) const + { + return _mm_alignr_epi8(*this, prev_chunk, 16 - N); + } }; // SIMD byte mask type (returned by things like eq and gt) template<> -struct simd16: base16 { - static simdutf_really_inline simd16 splat(bool _value) { return _mm_set1_epi16(uint16_t(-(!!_value))); } +struct simd16 : base16 { + static simdutf_really_inline simd16 splat(bool _value) { return _mm_set1_epi16(uint16_t(-(!!_value))); } - simdutf_really_inline simd16() : base16() {} - simdutf_really_inline simd16(const __m128i _value) : base16(_value) {} - // Splat constructor - simdutf_really_inline simd16(bool _value) : base16(splat(_value)) {} + simdutf_really_inline simd16() + : base16() + { + } + simdutf_really_inline simd16(const __m128i _value) + : base16(_value) + { + } + // Splat constructor + simdutf_really_inline simd16(bool _value) + : base16(splat(_value)) + { + } - simdutf_really_inline int to_bitmask() const { return _mm_movemask_epi8(*this); } - simdutf_really_inline bool any() const { return !_mm_testz_si128(*this, *this); } - simdutf_really_inline simd16 operator~() const { return *this ^ true; } + simdutf_really_inline int to_bitmask() const { return _mm_movemask_epi8(*this); } + simdutf_really_inline bool any() const { return !_mm_testz_si128(*this, *this); } + simdutf_really_inline simd16 operator~() const { return *this ^ true; } }; template -struct base16_numeric: base16 { - static simdutf_really_inline simd16 splat(T _value) { return _mm_set1_epi16(_value); } - static simdutf_really_inline simd16 zero() { return _mm_setzero_si128(); } - static simdutf_really_inline simd16 load(const T values[8]) { - return _mm_loadu_si128(reinterpret_cast(values)); - } - - simdutf_really_inline base16_numeric() : base16() {} - simdutf_really_inline base16_numeric(const __m128i _value) : base16(_value) {} - - // Store to array - simdutf_really_inline void store(T dst[8]) const { return _mm_storeu_si128(reinterpret_cast<__m128i *>(dst), *this); } - - // Override to distinguish from bool version - simdutf_really_inline simd16 operator~() const { return *this ^ 0xFFu; } - - // Addition/subtraction are the same for signed and unsigned - simdutf_really_inline simd16 operator+(const simd16 other) const { return _mm_add_epi16(*this, other); } - simdutf_really_inline simd16 operator-(const simd16 other) const { return _mm_sub_epi16(*this, other); } - simdutf_really_inline simd16& operator+=(const simd16 other) { *this = *this + other; return *static_cast*>(this); } - simdutf_really_inline simd16& operator-=(const simd16 other) { *this = *this - other; return *static_cast*>(this); } +struct base16_numeric : base16 { + static simdutf_really_inline simd16 splat(T _value) { return _mm_set1_epi16(_value); } + static simdutf_really_inline simd16 zero() { return _mm_setzero_si128(); } + static simdutf_really_inline simd16 load(const T values[8]) + { + return _mm_loadu_si128(reinterpret_cast(values)); + } + + simdutf_really_inline base16_numeric() + : base16() + { + } + simdutf_really_inline base16_numeric(const __m128i _value) + : base16(_value) + { + } + + // Store to array + simdutf_really_inline void store(T dst[8]) const { return _mm_storeu_si128(reinterpret_cast<__m128i*>(dst), *this); } + + // Override to distinguish from bool version + simdutf_really_inline simd16 operator~() const { return *this ^ 0xFFu; } + + // Addition/subtraction are the same for signed and unsigned + simdutf_really_inline simd16 operator+(const simd16 other) const { return _mm_add_epi16(*this, other); } + simdutf_really_inline simd16 operator-(const simd16 other) const { return _mm_sub_epi16(*this, other); } + simdutf_really_inline simd16& operator+=(const simd16 other) + { + *this = *this + other; + return *static_cast*>(this); + } + simdutf_really_inline simd16& operator-=(const simd16 other) + { + *this = *this - other; + return *static_cast*>(this); + } }; // Signed words template<> struct simd16 : base16_numeric { - simdutf_really_inline simd16() : base16_numeric() {} - simdutf_really_inline simd16(const __m128i _value) : base16_numeric(_value) {} - // Splat constructor - simdutf_really_inline simd16(int16_t _value) : simd16(splat(_value)) {} - // Array constructor - simdutf_really_inline simd16(const int16_t* values) : simd16(load(values)) {} - simdutf_really_inline simd16(const char16_t* values) : simd16(load(reinterpret_cast(values))) {} - // Member-by-member initialization - simdutf_really_inline simd16( - int16_t v0, int16_t v1, int16_t v2, int16_t v3, int16_t v4, int16_t v5, int16_t v6, int16_t v7) - : simd16(_mm_setr_epi16(v0, v1, v2, v3, v4, v5, v6, v7)) {} - simdutf_really_inline operator simd16() const; - - // Order-sensitive comparisons - simdutf_really_inline simd16 max_val(const simd16 other) const { return _mm_max_epi16(*this, other); } - simdutf_really_inline simd16 min_val(const simd16 other) const { return _mm_min_epi16(*this, other); } - simdutf_really_inline simd16 operator>(const simd16 other) const { return _mm_cmpgt_epi16(*this, other); } - simdutf_really_inline simd16 operator<(const simd16 other) const { return _mm_cmpgt_epi16(other, *this); } + simdutf_really_inline simd16() + : base16_numeric() + { + } + simdutf_really_inline simd16(const __m128i _value) + : base16_numeric(_value) + { + } + // Splat constructor + simdutf_really_inline simd16(int16_t _value) + : simd16(splat(_value)) + { + } + // Array constructor + simdutf_really_inline simd16(const int16_t* values) + : simd16(load(values)) + { + } + simdutf_really_inline simd16(const char16_t* values) + : simd16(load(reinterpret_cast(values))) + { + } + // Member-by-member initialization + simdutf_really_inline simd16( + int16_t v0, int16_t v1, int16_t v2, int16_t v3, int16_t v4, int16_t v5, int16_t v6, int16_t v7) + : simd16(_mm_setr_epi16(v0, v1, v2, v3, v4, v5, v6, v7)) + { + } + simdutf_really_inline operator simd16() const; + + // Order-sensitive comparisons + simdutf_really_inline simd16 max_val(const simd16 other) const { return _mm_max_epi16(*this, other); } + simdutf_really_inline simd16 min_val(const simd16 other) const { return _mm_min_epi16(*this, other); } + simdutf_really_inline simd16 operator>(const simd16 other) const { return _mm_cmpgt_epi16(*this, other); } + simdutf_really_inline simd16 operator<(const simd16 other) const { return _mm_cmpgt_epi16(other, *this); } }; // Unsigned words template<> -struct simd16: base16_numeric { - simdutf_really_inline simd16() : base16_numeric() {} - simdutf_really_inline simd16(const __m128i _value) : base16_numeric(_value) {} - - // Splat constructor - simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {} - // Array constructor - simdutf_really_inline simd16(const uint16_t* values) : simd16(load(values)) {} - simdutf_really_inline simd16(const char16_t* values) : simd16(load(reinterpret_cast(values))) {} - // Member-by-member initialization - simdutf_really_inline simd16( - uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3, uint16_t v4, uint16_t v5, uint16_t v6, uint16_t v7) - : simd16(_mm_setr_epi16(v0, v1, v2, v3, v4, v5, v6, v7)) {} - // Repeat 16 values as many times as necessary (usually for lookup tables) - simdutf_really_inline static simd16 repeat_16( - uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3, uint16_t v4, uint16_t v5, uint16_t v6, uint16_t v7 - ) { - return simd16(v0, v1, v2, v3, v4, v5, v6, v7); - } - - // Saturated math - simdutf_really_inline simd16 saturating_add(const simd16 other) const { return _mm_adds_epu16(*this, other); } - simdutf_really_inline simd16 saturating_sub(const simd16 other) const { return _mm_subs_epu16(*this, other); } - - // Order-specific operations - simdutf_really_inline simd16 max_val(const simd16 other) const { return _mm_max_epu16(*this, other); } - simdutf_really_inline simd16 min_val(const simd16 other) const { return _mm_min_epu16(*this, other); } - // Same as >, but only guarantees true is nonzero (< guarantees true = -1) - simdutf_really_inline simd16 gt_bits(const simd16 other) const { return this->saturating_sub(other); } - // Same as <, but only guarantees true is nonzero (< guarantees true = -1) - simdutf_really_inline simd16 lt_bits(const simd16 other) const { return other.saturating_sub(*this); } - simdutf_really_inline simd16 operator<=(const simd16 other) const { return other.max_val(*this) == other; } - simdutf_really_inline simd16 operator>=(const simd16 other) const { return other.min_val(*this) == other; } - simdutf_really_inline simd16 operator>(const simd16 other) const { return this->gt_bits(other).any_bits_set(); } - simdutf_really_inline simd16 operator<(const simd16 other) const { return this->gt_bits(other).any_bits_set(); } - - // Bit-specific operations - simdutf_really_inline simd16 bits_not_set() const { return *this == uint16_t(0); } - simdutf_really_inline simd16 bits_not_set(simd16 bits) const { return (*this & bits).bits_not_set(); } - simdutf_really_inline simd16 any_bits_set() const { return ~this->bits_not_set(); } - simdutf_really_inline simd16 any_bits_set(simd16 bits) const { return ~this->bits_not_set(bits); } - - simdutf_really_inline bool bits_not_set_anywhere() const { return _mm_testz_si128(*this, *this); } - simdutf_really_inline bool any_bits_set_anywhere() const { return !bits_not_set_anywhere(); } - simdutf_really_inline bool bits_not_set_anywhere(simd16 bits) const { return _mm_testz_si128(*this, bits); } - simdutf_really_inline bool any_bits_set_anywhere(simd16 bits) const { return !bits_not_set_anywhere(bits); } - template - simdutf_really_inline simd16 shr() const { return simd16(_mm_srli_epi16(*this, N)); } - template - simdutf_really_inline simd16 shl() const { return simd16(_mm_slli_epi16(*this, N)); } - // Get one of the bits and make a bitmask out of it. - // e.g. value.get_bit<7>() gets the high bit - template - simdutf_really_inline int get_bit() const { return _mm_movemask_epi8(_mm_slli_epi16(*this, 7-N)); } - - // Change the endianness - simdutf_really_inline simd16 swap_bytes() const { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - return _mm_shuffle_epi8(*this, swap); - } +struct simd16 : base16_numeric { + simdutf_really_inline simd16() + : base16_numeric() + { + } + simdutf_really_inline simd16(const __m128i _value) + : base16_numeric(_value) + { + } + + // Splat constructor + simdutf_really_inline simd16(uint16_t _value) + : simd16(splat(_value)) + { + } + // Array constructor + simdutf_really_inline simd16(const uint16_t* values) + : simd16(load(values)) + { + } + simdutf_really_inline simd16(const char16_t* values) + : simd16(load(reinterpret_cast(values))) + { + } + // Member-by-member initialization + simdutf_really_inline simd16( + uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3, uint16_t v4, uint16_t v5, uint16_t v6, uint16_t v7) + : simd16(_mm_setr_epi16(v0, v1, v2, v3, v4, v5, v6, v7)) + { + } + // Repeat 16 values as many times as necessary (usually for lookup tables) + simdutf_really_inline static simd16 repeat_16( + uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3, uint16_t v4, uint16_t v5, uint16_t v6, uint16_t v7) + { + return simd16(v0, v1, v2, v3, v4, v5, v6, v7); + } + + // Saturated math + simdutf_really_inline simd16 saturating_add(const simd16 other) const { return _mm_adds_epu16(*this, other); } + simdutf_really_inline simd16 saturating_sub(const simd16 other) const { return _mm_subs_epu16(*this, other); } + + // Order-specific operations + simdutf_really_inline simd16 max_val(const simd16 other) const { return _mm_max_epu16(*this, other); } + simdutf_really_inline simd16 min_val(const simd16 other) const { return _mm_min_epu16(*this, other); } + // Same as >, but only guarantees true is nonzero (< guarantees true = -1) + simdutf_really_inline simd16 gt_bits(const simd16 other) const { return this->saturating_sub(other); } + // Same as <, but only guarantees true is nonzero (< guarantees true = -1) + simdutf_really_inline simd16 lt_bits(const simd16 other) const { return other.saturating_sub(*this); } + simdutf_really_inline simd16 operator<=(const simd16 other) const { return other.max_val(*this) == other; } + simdutf_really_inline simd16 operator>=(const simd16 other) const { return other.min_val(*this) == other; } + simdutf_really_inline simd16 operator>(const simd16 other) const { return this->gt_bits(other).any_bits_set(); } + simdutf_really_inline simd16 operator<(const simd16 other) const { return this->gt_bits(other).any_bits_set(); } + + // Bit-specific operations + simdutf_really_inline simd16 bits_not_set() const { return *this == uint16_t(0); } + simdutf_really_inline simd16 bits_not_set(simd16 bits) const { return (*this & bits).bits_not_set(); } + simdutf_really_inline simd16 any_bits_set() const { return ~this->bits_not_set(); } + simdutf_really_inline simd16 any_bits_set(simd16 bits) const { return ~this->bits_not_set(bits); } - // Pack with the unsigned saturation two uint16_t words into single uint8_t vector - static simdutf_really_inline simd8 pack(const simd16& v0, const simd16& v1) { - return _mm_packus_epi16(v0, v1); - } + simdutf_really_inline bool bits_not_set_anywhere() const { return _mm_testz_si128(*this, *this); } + simdutf_really_inline bool any_bits_set_anywhere() const { return !bits_not_set_anywhere(); } + simdutf_really_inline bool bits_not_set_anywhere(simd16 bits) const { return _mm_testz_si128(*this, bits); } + simdutf_really_inline bool any_bits_set_anywhere(simd16 bits) const { return !bits_not_set_anywhere(bits); } + template + simdutf_really_inline simd16 shr() const { return simd16(_mm_srli_epi16(*this, N)); } + template + simdutf_really_inline simd16 shl() const { return simd16(_mm_slli_epi16(*this, N)); } + // Get one of the bits and make a bitmask out of it. + // e.g. value.get_bit<7>() gets the high bit + template + simdutf_really_inline int get_bit() const { return _mm_movemask_epi8(_mm_slli_epi16(*this, 7 - N)); } + + // Change the endianness + simdutf_really_inline simd16 swap_bytes() const + { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + return _mm_shuffle_epi8(*this, swap); + } + + // Pack with the unsigned saturation two uint16_t words into single uint8_t vector + static simdutf_really_inline simd8 pack(const simd16& v0, const simd16& v1) + { + return _mm_packus_epi16(v0, v1); + } }; simdutf_really_inline simd16::operator simd16() const { return this->value; } template - struct simd16x32 { +struct simd16x32 { static constexpr int NUM_CHUNKS = 64 / sizeof(simd16); static_assert(NUM_CHUNKS == 4, "Westmere kernel should use four registers per 64-byte block."); simd16 chunks[NUM_CHUNKS]; @@ -3160,108 +3796,126 @@ template simd16x32& operator=(const simd16 other) = delete; // no assignment allowed simd16x32() = delete; // no default constructor allowed - simdutf_really_inline simd16x32(const simd16 chunk0, const simd16 chunk1, const simd16 chunk2, const simd16 chunk3) : chunks{chunk0, chunk1, chunk2, chunk3} {} - simdutf_really_inline simd16x32(const T* ptr) : chunks{simd16::load(ptr), simd16::load(ptr+sizeof(simd16)/sizeof(T)), simd16::load(ptr+2*sizeof(simd16)/sizeof(T)), simd16::load(ptr+3*sizeof(simd16)/sizeof(T))} {} - - simdutf_really_inline void store(T* ptr) const { - this->chunks[0].store(ptr+sizeof(simd16)*0/sizeof(T)); - this->chunks[1].store(ptr+sizeof(simd16)*1/sizeof(T)); - this->chunks[2].store(ptr+sizeof(simd16)*2/sizeof(T)); - this->chunks[3].store(ptr+sizeof(simd16)*3/sizeof(T)); - } - - simdutf_really_inline simd16 reduce_or() const { - return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); - } - - simdutf_really_inline bool is_ascii() const { - return this->reduce_or().is_ascii(); - } - - simdutf_really_inline void store_ascii_as_utf16(char16_t * ptr) const { - this->chunks[0].store_ascii_as_utf16(ptr+sizeof(simd16)*0); - this->chunks[1].store_ascii_as_utf16(ptr+sizeof(simd16)*1); - this->chunks[2].store_ascii_as_utf16(ptr+sizeof(simd16)*2); - this->chunks[3].store_ascii_as_utf16(ptr+sizeof(simd16)*3); - } - - simdutf_really_inline uint64_t to_bitmask() const { - uint64_t r0 = uint32_t(this->chunks[0].to_bitmask() ); - uint64_t r1 = this->chunks[1].to_bitmask() ; - uint64_t r2 = this->chunks[2].to_bitmask() ; - uint64_t r3 = this->chunks[3].to_bitmask() ; - return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48); - } - - simdutf_really_inline void swap_bytes() { - this->chunks[0] = this->chunks[0].swap_bytes(); - this->chunks[1] = this->chunks[1].swap_bytes(); - this->chunks[2] = this->chunks[2].swap_bytes(); - this->chunks[3] = this->chunks[3].swap_bytes(); - } - - simdutf_really_inline uint64_t eq(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] == mask, - this->chunks[1] == mask, - this->chunks[2] == mask, - this->chunks[3] == mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t eq(const simd16x32 &other) const { - return simd16x32( - this->chunks[0] == other.chunks[0], - this->chunks[1] == other.chunks[1], - this->chunks[2] == other.chunks[2], - this->chunks[3] == other.chunks[3] - ).to_bitmask(); - } - - simdutf_really_inline uint64_t lteq(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] <= mask, - this->chunks[1] <= mask, - this->chunks[2] <= mask, - this->chunks[3] <= mask - ).to_bitmask(); - } - - simdutf_really_inline uint64_t in_range(const T low, const T high) const { - const simd16 mask_low = simd16::splat(low); - const simd16 mask_high = simd16::splat(high); - - return simd16x32( - (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), - (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), - (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), - (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t not_in_range(const T low, const T high) const { - const simd16 mask_low = simd16::splat(static_cast(low-1)); - const simd16 mask_high = simd16::splat(static_cast(high+1)); - return simd16x32( - (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low), - (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low), - (this->chunks[2] >= mask_high) | (this->chunks[2] <= mask_low), - (this->chunks[3] >= mask_high) | (this->chunks[3] <= mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t lt(const T m) const { - const simd16 mask = simd16::splat(m); - return simd16x32( - this->chunks[0] < mask, - this->chunks[1] < mask, - this->chunks[2] < mask, - this->chunks[3] < mask - ).to_bitmask(); - } - }; // struct simd16x32 -/* end file src/simdutf/westmere/simd16-inl.h */ - + simdutf_really_inline simd16x32(const simd16 chunk0, const simd16 chunk1, const simd16 chunk2, const simd16 chunk3) + : chunks { chunk0, chunk1, chunk2, chunk3 } + { + } + simdutf_really_inline simd16x32(const T* ptr) + : chunks { simd16::load(ptr), simd16::load(ptr + sizeof(simd16) / sizeof(T)), simd16::load(ptr + 2 * sizeof(simd16) / sizeof(T)), simd16::load(ptr + 3 * sizeof(simd16) / sizeof(T)) } + { + } + + simdutf_really_inline void store(T* ptr) const + { + this->chunks[0].store(ptr + sizeof(simd16) * 0 / sizeof(T)); + this->chunks[1].store(ptr + sizeof(simd16) * 1 / sizeof(T)); + this->chunks[2].store(ptr + sizeof(simd16) * 2 / sizeof(T)); + this->chunks[3].store(ptr + sizeof(simd16) * 3 / sizeof(T)); + } + + simdutf_really_inline simd16 reduce_or() const + { + return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); + } + + simdutf_really_inline bool is_ascii() const + { + return this->reduce_or().is_ascii(); + } + + simdutf_really_inline void store_ascii_as_utf16(char16_t* ptr) const + { + this->chunks[0].store_ascii_as_utf16(ptr + sizeof(simd16) * 0); + this->chunks[1].store_ascii_as_utf16(ptr + sizeof(simd16) * 1); + this->chunks[2].store_ascii_as_utf16(ptr + sizeof(simd16) * 2); + this->chunks[3].store_ascii_as_utf16(ptr + sizeof(simd16) * 3); + } + + simdutf_really_inline uint64_t to_bitmask() const + { + uint64_t r0 = uint32_t(this->chunks[0].to_bitmask()); + uint64_t r1 = this->chunks[1].to_bitmask(); + uint64_t r2 = this->chunks[2].to_bitmask(); + uint64_t r3 = this->chunks[3].to_bitmask(); + return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48); + } + + simdutf_really_inline void swap_bytes() + { + this->chunks[0] = this->chunks[0].swap_bytes(); + this->chunks[1] = this->chunks[1].swap_bytes(); + this->chunks[2] = this->chunks[2].swap_bytes(); + this->chunks[3] = this->chunks[3].swap_bytes(); + } + + simdutf_really_inline uint64_t eq(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] == mask, + this->chunks[1] == mask, + this->chunks[2] == mask, + this->chunks[3] == mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t eq(const simd16x32& other) const + { + return simd16x32( + this->chunks[0] == other.chunks[0], + this->chunks[1] == other.chunks[1], + this->chunks[2] == other.chunks[2], + this->chunks[3] == other.chunks[3]) + .to_bitmask(); + } + + simdutf_really_inline uint64_t lteq(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] <= mask, + this->chunks[1] <= mask, + this->chunks[2] <= mask, + this->chunks[3] <= mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t in_range(const T low, const T high) const + { + const simd16 mask_low = simd16::splat(low); + const simd16 mask_high = simd16::splat(high); + + return simd16x32( + (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), + (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), + (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), + (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t not_in_range(const T low, const T high) const + { + const simd16 mask_low = simd16::splat(static_cast(low - 1)); + const simd16 mask_high = simd16::splat(static_cast(high + 1)); + return simd16x32( + (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low), + (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low), + (this->chunks[2] >= mask_high) | (this->chunks[2] <= mask_low), + (this->chunks[3] >= mask_high) | (this->chunks[3] <= mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t lt(const T m) const + { + const simd16 mask = simd16::splat(m); + return simd16x32( + this->chunks[0] < mask, + this->chunks[1] < mask, + this->chunks[2] < mask, + this->chunks[3] < mask) + .to_bitmask(); + } +}; // struct simd16x32 +/* end file src/simdutf/westmere/simd16-inl.h */ + } // namespace simd } // unnamed namespace } // namespace westmere @@ -3270,7 +3924,7 @@ template #endif // SIMDUTF_WESTMERE_SIMD_INPUT_H /* end file src/simdutf/westmere/simd.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/end.h /* begin file src/simdutf/westmere/end.h */ #if SIMDUTF_CAN_ALWAYS_RUN_WESTMERE // nothing needed. @@ -3283,7 +3937,7 @@ SIMDUTF_UNTARGET_REGION #endif // SIMDUTF_IMPLEMENTATION_WESTMERE #endif // SIMDUTF_WESTMERE_COMMON_H /* end file src/simdutf/westmere.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64.h /* begin file src/simdutf/ppc64.h */ #ifndef SIMDUTF_PPC64_H #define SIMDUTF_PPC64_H @@ -3292,13 +3946,10 @@ SIMDUTF_UNTARGET_REGION #error "ppc64.h must be included before fallback.h" #endif - #ifndef SIMDUTF_IMPLEMENTATION_PPC64 #define SIMDUTF_IMPLEMENTATION_PPC64 (SIMDUTF_IS_PPC64) #endif -#define SIMDUTF_CAN_ALWAYS_RUN_PPC64 SIMDUTF_IMPLEMENTATION_PPC64 && SIMDUTF_IS_PPC64 - - +#define SIMDUTF_CAN_ALWAYS_RUN_PPC64 SIMDUTF_IMPLEMENTATION_PPC64&& SIMDUTF_IS_PPC64 #if SIMDUTF_IMPLEMENTATION_PPC64 @@ -3310,12 +3961,11 @@ namespace ppc64 { } // namespace ppc64 } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64/implementation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64/implementation.h /* begin file src/simdutf/ppc64/implementation.h */ #ifndef SIMDUTF_PPC64_IMPLEMENTATION_H #define SIMDUTF_PPC64_IMPLEMENTATION_H - namespace simdutf { namespace ppc64 { @@ -3325,62 +3975,64 @@ using namespace simdutf; class implementation final : public simdutf::implementation { public: - simdutf_really_inline implementation() - : simdutf::implementation("ppc64", "PPC64 ALTIVEC", - internal::instruction_set::ALTIVEC) {} - simdutf_warn_unused int detect_encodings(const char * input, size_t length) const noexcept final; - simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16le(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16be(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - void change_endianness_utf16(const char16_t * buf, size_t length, char16_t * output) const noexcept final; - simdutf_warn_unused size_t count_utf16le(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf16be(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf8(const char * buf, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t length) const noexcept; + simdutf_really_inline implementation() + : simdutf::implementation("ppc64", "PPC64 ALTIVEC", + internal::instruction_set::ALTIVEC) + { + } + simdutf_warn_unused int detect_encodings(const char* input, size_t length) const noexcept final; + simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + void change_endianness_utf16(const char16_t* buf, size_t length, char16_t* output) const noexcept final; + simdutf_warn_unused size_t count_utf16le(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf16be(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf8(const char* buf, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf8(const char* input, size_t length) const noexcept; }; } // namespace ppc64 @@ -3389,19 +4041,18 @@ public: #endif // SIMDUTF_PPC64_IMPLEMENTATION_H /* end file src/simdutf/ppc64/implementation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64/begin.h /* begin file src/simdutf/ppc64/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "ppc64" // #define SIMDUTF_IMPLEMENTATION ppc64 /* end file src/simdutf/ppc64/begin.h */ // Declarations -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64/intrinsics.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64/intrinsics.h /* begin file src/simdutf/ppc64/intrinsics.h */ #ifndef SIMDUTF_PPC64_INTRINSICS_H #define SIMDUTF_PPC64_INTRINSICS_H - // This should be the correct header whether // you use visual studio or other compilers. #include @@ -3417,7 +4068,7 @@ public: #endif // SIMDUTF_PPC64_INTRINSICS_H /* end file src/simdutf/ppc64/intrinsics.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64/bitmanipulation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64/bitmanipulation.h /* begin file src/simdutf/ppc64/bitmanipulation.h */ #ifndef SIMDUTF_PPC64_BITMANIPULATION_H #define SIMDUTF_PPC64_BITMANIPULATION_H @@ -3427,13 +4078,15 @@ namespace ppc64 { namespace { #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO -simdutf_really_inline int count_ones(uint64_t input_num) { - // note: we do not support legacy 32-bit Windows - return __popcnt64(input_num); // Visual Studio wants two underscores +simdutf_really_inline int count_ones(uint64_t input_num) +{ + // note: we do not support legacy 32-bit Windows + return __popcnt64(input_num); // Visual Studio wants two underscores } #else -simdutf_really_inline int count_ones(uint64_t input_num) { - return __builtin_popcountll(input_num); +simdutf_really_inline int count_ones(uint64_t input_num) +{ + return __builtin_popcountll(input_num); } #endif @@ -3443,7 +4096,7 @@ simdutf_really_inline int count_ones(uint64_t input_num) { #endif // SIMDUTF_PPC64_BITMANIPULATION_H /* end file src/simdutf/ppc64/bitmanipulation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64/simd.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64/simd.h /* begin file src/simdutf/ppc64/simd.h */ #ifndef SIMDUTF_PPC64_SIMD_H #define SIMDUTF_PPC64_SIMD_H @@ -3457,485 +4110,603 @@ namespace simd { using __m128i = __vector unsigned char; -template struct base { - __m128i value; - - // Zero constructor - simdutf_really_inline base() : value{__m128i()} {} - - // Conversion from SIMD register - simdutf_really_inline base(const __m128i _value) : value(_value) {} - - // Conversion to SIMD register - simdutf_really_inline operator const __m128i &() const { - return this->value; - } - simdutf_really_inline operator __m128i &() { return this->value; } - - // Bit operations - simdutf_really_inline Child operator|(const Child other) const { - return vec_or(this->value, (__m128i)other); - } - simdutf_really_inline Child operator&(const Child other) const { - return vec_and(this->value, (__m128i)other); - } - simdutf_really_inline Child operator^(const Child other) const { - return vec_xor(this->value, (__m128i)other); - } - simdutf_really_inline Child bit_andnot(const Child other) const { - return vec_andc(this->value, (__m128i)other); - } - simdutf_really_inline Child &operator|=(const Child other) { - auto this_cast = static_cast(this); - *this_cast = *this_cast | other; - return *this_cast; - } - simdutf_really_inline Child &operator&=(const Child other) { - auto this_cast = static_cast(this); - *this_cast = *this_cast & other; - return *this_cast; - } - simdutf_really_inline Child &operator^=(const Child other) { - auto this_cast = static_cast(this); - *this_cast = *this_cast ^ other; - return *this_cast; - } +template struct base { + __m128i value; + + // Zero constructor + simdutf_really_inline base() + : value { __m128i() } + { + } + + // Conversion from SIMD register + simdutf_really_inline base(const __m128i _value) + : value(_value) + { + } + + // Conversion to SIMD register + simdutf_really_inline operator const __m128i&() const + { + return this->value; + } + simdutf_really_inline operator __m128i&() { return this->value; } + + // Bit operations + simdutf_really_inline Child operator|(const Child other) const + { + return vec_or(this->value, (__m128i)other); + } + simdutf_really_inline Child operator&(const Child other) const + { + return vec_and(this->value, (__m128i)other); + } + simdutf_really_inline Child operator^(const Child other) const + { + return vec_xor(this->value, (__m128i)other); + } + simdutf_really_inline Child bit_andnot(const Child other) const + { + return vec_andc(this->value, (__m128i)other); + } + simdutf_really_inline Child& operator|=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast | other; + return *this_cast; + } + simdutf_really_inline Child& operator&=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast & other; + return *this_cast; + } + simdutf_really_inline Child& operator^=(const Child other) + { + auto this_cast = static_cast(this); + *this_cast = *this_cast ^ other; + return *this_cast; + } }; // Forward-declared so they can be used by splat and friends. -template struct simd8; +template struct simd8; -template > +template> struct base8 : base> { - typedef uint16_t bitmask_t; - typedef uint32_t bitmask2_t; + typedef uint16_t bitmask_t; + typedef uint32_t bitmask2_t; - simdutf_really_inline base8() : base>() {} - simdutf_really_inline base8(const __m128i _value) : base>(_value) {} + simdutf_really_inline base8() + : base>() + { + } + simdutf_really_inline base8(const __m128i _value) + : base>(_value) + { + } - simdutf_really_inline Mask operator==(const simd8 other) const { - return (__m128i)vec_cmpeq(this->value, (__m128i)other); - } + friend simdutf_really_inline Mask operator==(const simd8 lhs, const simd8 rhs) + { + return (__m128i)vec_cmpeq(lhs.value, (__m128i)rhs); + } - static const int SIZE = sizeof(base>::value); + static const int SIZE = sizeof(base>::value); - template - simdutf_really_inline simd8 prev(simd8 prev_chunk) const { - __m128i chunk = this->value; + template + simdutf_really_inline simd8 prev(simd8 prev_chunk) const + { + __m128i chunk = this->value; #ifdef __LITTLE_ENDIAN__ - chunk = (__m128i)vec_reve(this->value); - prev_chunk = (__m128i)vec_reve((__m128i)prev_chunk); + chunk = (__m128i)vec_reve(this->value); + prev_chunk = (__m128i)vec_reve((__m128i)prev_chunk); #endif - chunk = (__m128i)vec_sld((__m128i)prev_chunk, (__m128i)chunk, 16 - N); + chunk = (__m128i)vec_sld((__m128i)prev_chunk, (__m128i)chunk, 16 - N); #ifdef __LITTLE_ENDIAN__ - chunk = (__m128i)vec_reve((__m128i)chunk); + chunk = (__m128i)vec_reve((__m128i)chunk); #endif - return chunk; - } + return chunk; + } }; // SIMD byte mask type (returned by things like eq and gt) -template <> struct simd8 : base8 { - static simdutf_really_inline simd8 splat(bool _value) { - return (__m128i)vec_splats((unsigned char)(-(!!_value))); - } - - simdutf_really_inline simd8() : base8() {} - simdutf_really_inline simd8(const __m128i _value) - : base8(_value) {} - // Splat constructor - simdutf_really_inline simd8(bool _value) - : base8(splat(_value)) {} - - simdutf_really_inline int to_bitmask() const { - __vector unsigned long long result; - const __m128i perm_mask = {0x78, 0x70, 0x68, 0x60, 0x58, 0x50, 0x48, 0x40, - 0x38, 0x30, 0x28, 0x20, 0x18, 0x10, 0x08, 0x00}; - - result = ((__vector unsigned long long)vec_vbpermq((__m128i)this->value, - (__m128i)perm_mask)); +template<> struct simd8 : base8 { + static simdutf_really_inline simd8 splat(bool _value) + { + return (__m128i)vec_splats((unsigned char)(-(!!_value))); + } + + simdutf_really_inline simd8() + : base8() + { + } + simdutf_really_inline simd8(const __m128i _value) + : base8(_value) + { + } + // Splat constructor + simdutf_really_inline simd8(bool _value) + : base8(splat(_value)) + { + } + + simdutf_really_inline int to_bitmask() const + { + __vector unsigned long long result; + const __m128i perm_mask = { 0x78, 0x70, 0x68, 0x60, 0x58, 0x50, 0x48, 0x40, + 0x38, 0x30, 0x28, 0x20, 0x18, 0x10, 0x08, 0x00 }; + + result = ((__vector unsigned long long)vec_vbpermq((__m128i)this->value, + (__m128i)perm_mask)); #ifdef __LITTLE_ENDIAN__ - return static_cast(result[1]); + return static_cast(result[1]); #else - return static_cast(result[0]); + return static_cast(result[0]); #endif - } - simdutf_really_inline bool any() const { - return !vec_all_eq(this->value, (__m128i)vec_splats(0)); - } - simdutf_really_inline simd8 operator~() const { - return this->value ^ (__m128i)splat(true); - } + } + simdutf_really_inline bool any() const + { + return !vec_all_eq(this->value, (__m128i)vec_splats(0)); + } + simdutf_really_inline simd8 operator~() const + { + return this->value ^ (__m128i)splat(true); + } }; -template struct base8_numeric : base8 { - static simdutf_really_inline simd8 splat(T value) { - (void)value; - return (__m128i)vec_splats(value); - } - static simdutf_really_inline simd8 zero() { return splat(0); } - static simdutf_really_inline simd8 load(const T values[16]) { - return (__m128i)(vec_vsx_ld(0, reinterpret_cast(values))); - } - // Repeat 16 values as many times as necessary (usually for lookup tables) - static simdutf_really_inline simd8 repeat_16(T v0, T v1, T v2, T v3, T v4, - T v5, T v6, T v7, T v8, T v9, - T v10, T v11, T v12, T v13, - T v14, T v15) { - return simd8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, - v14, v15); - } - - simdutf_really_inline base8_numeric() : base8() {} - simdutf_really_inline base8_numeric(const __m128i _value) - : base8(_value) {} - - // Store to array - simdutf_really_inline void store(T dst[16]) const { - vec_vsx_st(this->value, 0, reinterpret_cast<__m128i *>(dst)); - } - - // Override to distinguish from bool version - simdutf_really_inline simd8 operator~() const { return *this ^ 0xFFu; } - - // Addition/subtraction are the same for signed and unsigned - simdutf_really_inline simd8 operator+(const simd8 other) const { - return (__m128i)((__m128i)this->value + (__m128i)other); - } - simdutf_really_inline simd8 operator-(const simd8 other) const { - return (__m128i)((__m128i)this->value - (__m128i)other); - } - simdutf_really_inline simd8 &operator+=(const simd8 other) { - *this = *this + other; - return *static_cast *>(this); - } - simdutf_really_inline simd8 &operator-=(const simd8 other) { - *this = *this - other; - return *static_cast *>(this); - } - - // Perform a lookup assuming the value is between 0 and 16 (undefined behavior - // for out of range values) - template - simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const { - return (__m128i)vec_perm((__m128i)lookup_table, (__m128i)lookup_table, this->value); - } - - template - simdutf_really_inline simd8 - lookup_16(L replace0, L replace1, L replace2, L replace3, L replace4, - L replace5, L replace6, L replace7, L replace8, L replace9, - L replace10, L replace11, L replace12, L replace13, L replace14, - L replace15) const { - return lookup_16(simd8::repeat_16( - replace0, replace1, replace2, replace3, replace4, replace5, replace6, - replace7, replace8, replace9, replace10, replace11, replace12, - replace13, replace14, replace15)); - } +template struct base8_numeric : base8 { + static simdutf_really_inline simd8 splat(T value) + { + (void)value; + return (__m128i)vec_splats(value); + } + static simdutf_really_inline simd8 zero() { return splat(0); } + static simdutf_really_inline simd8 load(const T values[16]) + { + return (__m128i)(vec_vsx_ld(0, reinterpret_cast(values))); + } + // Repeat 16 values as many times as necessary (usually for lookup tables) + static simdutf_really_inline simd8 repeat_16(T v0, T v1, T v2, T v3, T v4, + T v5, T v6, T v7, T v8, T v9, + T v10, T v11, T v12, T v13, + T v14, T v15) + { + return simd8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, + v14, v15); + } + + simdutf_really_inline base8_numeric() + : base8() + { + } + simdutf_really_inline base8_numeric(const __m128i _value) + : base8(_value) + { + } + + // Store to array + simdutf_really_inline void store(T dst[16]) const + { + vec_vsx_st(this->value, 0, reinterpret_cast<__m128i*>(dst)); + } + + // Override to distinguish from bool version + simdutf_really_inline simd8 operator~() const { return *this ^ 0xFFu; } + + // Addition/subtraction are the same for signed and unsigned + simdutf_really_inline simd8 operator+(const simd8 other) const + { + return (__m128i)((__m128i)this->value + (__m128i)other); + } + simdutf_really_inline simd8 operator-(const simd8 other) const + { + return (__m128i)((__m128i)this->value - (__m128i)other); + } + simdutf_really_inline simd8& operator+=(const simd8 other) + { + *this = *this + other; + return *static_cast*>(this); + } + simdutf_really_inline simd8& operator-=(const simd8 other) + { + *this = *this - other; + return *static_cast*>(this); + } + + // Perform a lookup assuming the value is between 0 and 16 (undefined behavior + // for out of range values) + template + simdutf_really_inline simd8 lookup_16(simd8 lookup_table) const + { + return (__m128i)vec_perm((__m128i)lookup_table, (__m128i)lookup_table, this->value); + } + + template + simdutf_really_inline simd8 + lookup_16(L replace0, L replace1, L replace2, L replace3, L replace4, + L replace5, L replace6, L replace7, L replace8, L replace9, + L replace10, L replace11, L replace12, L replace13, L replace14, + L replace15) const + { + return lookup_16(simd8::repeat_16( + replace0, replace1, replace2, replace3, replace4, replace5, replace6, + replace7, replace8, replace9, replace10, replace11, replace12, + replace13, replace14, replace15)); + } }; // Signed bytes -template <> struct simd8 : base8_numeric { - simdutf_really_inline simd8() : base8_numeric() {} - simdutf_really_inline simd8(const __m128i _value) - : base8_numeric(_value) {} - - // Splat constructor - simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {} - // Array constructor - simdutf_really_inline simd8(const int8_t *values) : simd8(load(values)) {} - // Member-by-member initialization - simdutf_really_inline simd8(int8_t v0, int8_t v1, int8_t v2, int8_t v3, - int8_t v4, int8_t v5, int8_t v6, int8_t v7, - int8_t v8, int8_t v9, int8_t v10, int8_t v11, - int8_t v12, int8_t v13, int8_t v14, int8_t v15) - : simd8((__m128i)(__vector signed char){v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10, v11, v12, v13, v14, - v15}) {} - // Repeat 16 values as many times as necessary (usually for lookup tables) - simdutf_really_inline static simd8 - repeat_16(int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, - int8_t v6, int8_t v7, int8_t v8, int8_t v9, int8_t v10, int8_t v11, - int8_t v12, int8_t v13, int8_t v14, int8_t v15) { - return simd8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, - v13, v14, v15); - } - - // Order-sensitive comparisons - simdutf_really_inline simd8 - max_val(const simd8 other) const { - return (__m128i)vec_max((__vector signed char)this->value, - (__vector signed char)(__m128i)other); - } - simdutf_really_inline simd8 - min_val(const simd8 other) const { - return (__m128i)vec_min((__vector signed char)this->value, - (__vector signed char)(__m128i)other); - } - simdutf_really_inline simd8 - operator>(const simd8 other) const { - return (__m128i)vec_cmpgt((__vector signed char)this->value, - (__vector signed char)(__m128i)other); - } - simdutf_really_inline simd8 - operator<(const simd8 other) const { - return (__m128i)vec_cmplt((__vector signed char)this->value, - (__vector signed char)(__m128i)other); - } +template<> struct simd8 : base8_numeric { + simdutf_really_inline simd8() + : base8_numeric() + { + } + simdutf_really_inline simd8(const __m128i _value) + : base8_numeric(_value) + { + } + + // Splat constructor + simdutf_really_inline simd8(int8_t _value) + : simd8(splat(_value)) + { + } + // Array constructor + simdutf_really_inline simd8(const int8_t* values) + : simd8(load(values)) + { + } + // Member-by-member initialization + simdutf_really_inline simd8(int8_t v0, int8_t v1, int8_t v2, int8_t v3, + int8_t v4, int8_t v5, int8_t v6, int8_t v7, + int8_t v8, int8_t v9, int8_t v10, int8_t v11, + int8_t v12, int8_t v13, int8_t v14, int8_t v15) + : simd8((__m128i)(__vector signed char) { v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, + v15 }) + { + } + // Repeat 16 values as many times as necessary (usually for lookup tables) + simdutf_really_inline static simd8 + repeat_16(int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, + int8_t v6, int8_t v7, int8_t v8, int8_t v9, int8_t v10, int8_t v11, + int8_t v12, int8_t v13, int8_t v14, int8_t v15) + { + return simd8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, + v13, v14, v15); + } + + // Order-sensitive comparisons + simdutf_really_inline simd8 + max_val(const simd8 other) const + { + return (__m128i)vec_max((__vector signed char)this->value, + (__vector signed char)(__m128i)other); + } + simdutf_really_inline simd8 + min_val(const simd8 other) const + { + return (__m128i)vec_min((__vector signed char)this->value, + (__vector signed char)(__m128i)other); + } + simdutf_really_inline simd8 + operator>(const simd8 other) const + { + return (__m128i)vec_cmpgt((__vector signed char)this->value, + (__vector signed char)(__m128i)other); + } + simdutf_really_inline simd8 + operator<(const simd8 other) const + { + return (__m128i)vec_cmplt((__vector signed char)this->value, + (__vector signed char)(__m128i)other); + } }; // Unsigned bytes -template <> struct simd8 : base8_numeric { - simdutf_really_inline simd8() : base8_numeric() {} - simdutf_really_inline simd8(const __m128i _value) - : base8_numeric(_value) {} - // Splat constructor - simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {} - // Array constructor - simdutf_really_inline simd8(const uint8_t *values) : simd8(load(values)) {} - // Member-by-member initialization - simdutf_really_inline - simd8(uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, +template<> struct simd8 : base8_numeric { + simdutf_really_inline simd8() + : base8_numeric() + { + } + simdutf_really_inline simd8(const __m128i _value) + : base8_numeric(_value) + { + } + // Splat constructor + simdutf_really_inline simd8(uint8_t _value) + : simd8(splat(_value)) + { + } + // Array constructor + simdutf_really_inline simd8(const uint8_t* values) + : simd8(load(values)) + { + } + // Member-by-member initialization + simdutf_really_inline + simd8(uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7, uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15) - : simd8((__m128i){v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, - v13, v14, v15}) {} - // Repeat 16 values as many times as necessary (usually for lookup tables) - simdutf_really_inline static simd8 - repeat_16(uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, - uint8_t v5, uint8_t v6, uint8_t v7, uint8_t v8, uint8_t v9, - uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, - uint8_t v15) { - return simd8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, - v13, v14, v15); - } - - // Saturated math - simdutf_really_inline simd8 - saturating_add(const simd8 other) const { - return (__m128i)vec_adds(this->value, (__m128i)other); - } - simdutf_really_inline simd8 - saturating_sub(const simd8 other) const { - return (__m128i)vec_subs(this->value, (__m128i)other); - } - - // Order-specific operations - simdutf_really_inline simd8 - max_val(const simd8 other) const { - return (__m128i)vec_max(this->value, (__m128i)other); - } - simdutf_really_inline simd8 - min_val(const simd8 other) const { - return (__m128i)vec_min(this->value, (__m128i)other); - } - // Same as >, but only guarantees true is nonzero (< guarantees true = -1) - simdutf_really_inline simd8 - gt_bits(const simd8 other) const { - return this->saturating_sub(other); - } - // Same as <, but only guarantees true is nonzero (< guarantees true = -1) - simdutf_really_inline simd8 - lt_bits(const simd8 other) const { - return other.saturating_sub(*this); - } - simdutf_really_inline simd8 - operator<=(const simd8 other) const { - return other.max_val(*this) == other; - } - simdutf_really_inline simd8 - operator>=(const simd8 other) const { - return other.min_val(*this) == other; - } - simdutf_really_inline simd8 - operator>(const simd8 other) const { - return this->gt_bits(other).any_bits_set(); - } - simdutf_really_inline simd8 - operator<(const simd8 other) const { - return this->gt_bits(other).any_bits_set(); - } - - // Bit-specific operations - simdutf_really_inline simd8 bits_not_set() const { - return (__m128i)vec_cmpeq(this->value, (__m128i)vec_splats(uint8_t(0))); - } - simdutf_really_inline simd8 bits_not_set(simd8 bits) const { - return (*this & bits).bits_not_set(); - } - simdutf_really_inline simd8 any_bits_set() const { - return ~this->bits_not_set(); - } - simdutf_really_inline simd8 any_bits_set(simd8 bits) const { - return ~this->bits_not_set(bits); - } - - simdutf_really_inline bool is_ascii() const { - return this->saturating_sub(0b01111111u).bits_not_set_anywhere(); - } - - simdutf_really_inline bool bits_not_set_anywhere() const { - return vec_all_eq(this->value, (__m128i)vec_splats(0)); - } - simdutf_really_inline bool any_bits_set_anywhere() const { - return !bits_not_set_anywhere(); - } - simdutf_really_inline bool bits_not_set_anywhere(simd8 bits) const { - return vec_all_eq(vec_and(this->value, (__m128i)bits), - (__m128i)vec_splats(0)); - } - simdutf_really_inline bool any_bits_set_anywhere(simd8 bits) const { - return !bits_not_set_anywhere(bits); - } - template simdutf_really_inline simd8 shr() const { - return simd8( - (__m128i)vec_sr(this->value, (__m128i)vec_splat_u8(N))); - } - template simdutf_really_inline simd8 shl() const { - return simd8( - (__m128i)vec_sl(this->value, (__m128i)vec_splat_u8(N))); - } -}; + : simd8((__m128i) { v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, + v13, v14, v15 }) + { + } + // Repeat 16 values as many times as necessary (usually for lookup tables) + simdutf_really_inline static simd8 + repeat_16(uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, + uint8_t v5, uint8_t v6, uint8_t v7, uint8_t v8, uint8_t v9, + uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, + uint8_t v15) + { + return simd8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, + v13, v14, v15); + } + + // Saturated math + simdutf_really_inline simd8 + saturating_add(const simd8 other) const + { + return (__m128i)vec_adds(this->value, (__m128i)other); + } + simdutf_really_inline simd8 + saturating_sub(const simd8 other) const + { + return (__m128i)vec_subs(this->value, (__m128i)other); + } -template struct simd8x64 { - static constexpr int NUM_CHUNKS = 64 / sizeof(simd8); - static_assert(NUM_CHUNKS == 4, - "PPC64 kernel should use four registers per 64-byte block."); - simd8 chunks[NUM_CHUNKS]; + // Order-specific operations + simdutf_really_inline simd8 + max_val(const simd8 other) const + { + return (__m128i)vec_max(this->value, (__m128i)other); + } + simdutf_really_inline simd8 + min_val(const simd8 other) const + { + return (__m128i)vec_min(this->value, (__m128i)other); + } + // Same as >, but only guarantees true is nonzero (< guarantees true = -1) + simdutf_really_inline simd8 + gt_bits(const simd8 other) const + { + return this->saturating_sub(other); + } + // Same as <, but only guarantees true is nonzero (< guarantees true = -1) + simdutf_really_inline simd8 + lt_bits(const simd8 other) const + { + return other.saturating_sub(*this); + } + simdutf_really_inline simd8 + operator<=(const simd8 other) const + { + return other.max_val(*this) == other; + } + simdutf_really_inline simd8 + operator>=(const simd8 other) const + { + return other.min_val(*this) == other; + } + simdutf_really_inline simd8 + operator>(const simd8 other) const + { + return this->gt_bits(other).any_bits_set(); + } + simdutf_really_inline simd8 + operator<(const simd8 other) const + { + return this->gt_bits(other).any_bits_set(); + } - simd8x64(const simd8x64 &o) = delete; // no copy allowed - simd8x64 & - operator=(const simd8 other) = delete; // no assignment allowed - simd8x64() = delete; // no default constructor allowed + // Bit-specific operations + simdutf_really_inline simd8 bits_not_set() const + { + return (__m128i)vec_cmpeq(this->value, (__m128i)vec_splats(uint8_t(0))); + } + simdutf_really_inline simd8 bits_not_set(simd8 bits) const + { + return (*this & bits).bits_not_set(); + } + simdutf_really_inline simd8 any_bits_set() const + { + return ~this->bits_not_set(); + } + simdutf_really_inline simd8 any_bits_set(simd8 bits) const + { + return ~this->bits_not_set(bits); + } - simdutf_really_inline simd8x64(const simd8 chunk0, const simd8 chunk1, - const simd8 chunk2, const simd8 chunk3) - : chunks{chunk0, chunk1, chunk2, chunk3} {} + simdutf_really_inline bool is_ascii() const + { + return this->saturating_sub(0b01111111u).bits_not_set_anywhere(); + } - simdutf_really_inline simd8x64(const T* ptr) : chunks{simd8::load(ptr), simd8::load(ptr+sizeof(simd8)/sizeof(T)), simd8::load(ptr+2*sizeof(simd8)/sizeof(T)), simd8::load(ptr+3*sizeof(simd8)/sizeof(T))} {} + simdutf_really_inline bool bits_not_set_anywhere() const + { + return vec_all_eq(this->value, (__m128i)vec_splats(0)); + } + simdutf_really_inline bool any_bits_set_anywhere() const + { + return !bits_not_set_anywhere(); + } + simdutf_really_inline bool bits_not_set_anywhere(simd8 bits) const + { + return vec_all_eq(vec_and(this->value, (__m128i)bits), + (__m128i)vec_splats(0)); + } + simdutf_really_inline bool any_bits_set_anywhere(simd8 bits) const + { + return !bits_not_set_anywhere(bits); + } + template simdutf_really_inline simd8 shr() const + { + return simd8( + (__m128i)vec_sr(this->value, (__m128i)vec_splat_u8(N))); + } + template simdutf_really_inline simd8 shl() const + { + return simd8( + (__m128i)vec_sl(this->value, (__m128i)vec_splat_u8(N))); + } +}; - simdutf_really_inline void store(T* ptr) const { - this->chunks[0].store(ptr + sizeof(simd8) * 0/sizeof(T)); - this->chunks[1].store(ptr + sizeof(simd8) * 1/sizeof(T)); - this->chunks[2].store(ptr + sizeof(simd8) * 2/sizeof(T)); - this->chunks[3].store(ptr + sizeof(simd8) * 3/sizeof(T)); - } +template struct simd8x64 { + static constexpr int NUM_CHUNKS = 64 / sizeof(simd8); + static_assert(NUM_CHUNKS == 4, + "PPC64 kernel should use four registers per 64-byte block."); + simd8 chunks[NUM_CHUNKS]; + simd8x64(const simd8x64& o) = delete; // no copy allowed + simd8x64& + operator=(const simd8 other) + = delete; // no assignment allowed + simd8x64() = delete; // no default constructor allowed - simdutf_really_inline simd8x64& operator |=(const simd8x64 &other) { - this->chunks[0] |= other.chunks[0]; - this->chunks[1] |= other.chunks[1]; - this->chunks[2] |= other.chunks[2]; - this->chunks[3] |= other.chunks[3]; - return *this; + simdutf_really_inline simd8x64(const simd8 chunk0, const simd8 chunk1, + const simd8 chunk2, const simd8 chunk3) + : chunks { chunk0, chunk1, chunk2, chunk3 } + { } - simdutf_really_inline simd8 reduce_or() const { - return (this->chunks[0] | this->chunks[1]) | - (this->chunks[2] | this->chunks[3]); - } + simdutf_really_inline simd8x64(const T* ptr) + : chunks { simd8::load(ptr), simd8::load(ptr + sizeof(simd8) / sizeof(T)), simd8::load(ptr + 2 * sizeof(simd8) / sizeof(T)), simd8::load(ptr + 3 * sizeof(simd8) / sizeof(T)) } + { + } + simdutf_really_inline void store(T* ptr) const + { + this->chunks[0].store(ptr + sizeof(simd8) * 0 / sizeof(T)); + this->chunks[1].store(ptr + sizeof(simd8) * 1 / sizeof(T)); + this->chunks[2].store(ptr + sizeof(simd8) * 2 / sizeof(T)); + this->chunks[3].store(ptr + sizeof(simd8) * 3 / sizeof(T)); + } - simdutf_really_inline bool is_ascii() const { - return input.reduce_or().is_ascii(); - } - - simdutf_really_inline uint64_t to_bitmask() const { - uint64_t r0 = uint32_t(this->chunks[0].to_bitmask()); - uint64_t r1 = this->chunks[1].to_bitmask(); - uint64_t r2 = this->chunks[2].to_bitmask(); - uint64_t r3 = this->chunks[3].to_bitmask(); - return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48); - } - - simdutf_really_inline uint64_t eq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64(this->chunks[0] == mask, this->chunks[1] == mask, - this->chunks[2] == mask, this->chunks[3] == mask) - .to_bitmask(); - } - - simdutf_really_inline uint64_t eq(const simd8x64 &other) const { - return simd8x64(this->chunks[0] == other.chunks[0], - this->chunks[1] == other.chunks[1], - this->chunks[2] == other.chunks[2], - this->chunks[3] == other.chunks[3]) - .to_bitmask(); - } - - simdutf_really_inline uint64_t lteq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64(this->chunks[0] <= mask, this->chunks[1] <= mask, - this->chunks[2] <= mask, this->chunks[3] <= mask) - .to_bitmask(); - } - - simdutf_really_inline uint64_t in_range(const T low, const T high) const { - const simd8 mask_low = simd8::splat(low); - const simd8 mask_high = simd8::splat(high); - - return simd8x64( - (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), - (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), - (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), - (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t not_in_range(const T low, const T high) const { - const simd8 mask_low = simd8::splat(low); - const simd8 mask_high = simd8::splat(high); - return simd8x64( - (this->chunks[0] > mask_high) | (this->chunks[0] < mask_low), - (this->chunks[1] > mask_high) | (this->chunks[1] < mask_low), - (this->chunks[2] > mask_high) | (this->chunks[2] < mask_low), - (this->chunks[3] > mask_high) | (this->chunks[3] < mask_low) - ).to_bitmask(); - } - simdutf_really_inline uint64_t lt(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64(this->chunks[0] < mask, this->chunks[1] < mask, - this->chunks[2] < mask, this->chunks[3] < mask) - .to_bitmask(); - } - - simdutf_really_inline uint64_t gt(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] > mask, - this->chunks[1] > mask, - this->chunks[2] > mask, - this->chunks[3] > mask - ).to_bitmask(); - } - simdutf_really_inline uint64_t gteq(const T m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - this->chunks[0] >= mask, - this->chunks[1] >= mask, - this->chunks[2] >= mask, - this->chunks[3] >= mask - ).to_bitmask(); - } - simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const { - const simd8 mask = simd8::splat(m); - return simd8x64( - simd8(this->chunks[0]) >= mask, - simd8(this->chunks[1]) >= mask, - simd8(this->chunks[2]) >= mask, - simd8(this->chunks[3]) >= mask - ).to_bitmask(); - } -}; // struct simd8x64 + simdutf_really_inline simd8x64& operator|=(const simd8x64& other) + { + this->chunks[0] |= other.chunks[0]; + this->chunks[1] |= other.chunks[1]; + this->chunks[2] |= other.chunks[2]; + this->chunks[3] |= other.chunks[3]; + return *this; + } -} // namespace simd -} // unnamed namespace -} // namespace ppc64 -} // namespace simdutf + simdutf_really_inline simd8 reduce_or() const + { + return (this->chunks[0] | this->chunks[1]) | (this->chunks[2] | this->chunks[3]); + } -#endif // SIMDUTF_PPC64_SIMD_INPUT_H -/* end file src/simdutf/ppc64/simd.h */ + simdutf_really_inline bool is_ascii() const + { + return input.reduce_or().is_ascii(); + } + + simdutf_really_inline uint64_t to_bitmask() const + { + uint64_t r0 = uint32_t(this->chunks[0].to_bitmask()); + uint64_t r1 = this->chunks[1].to_bitmask(); + uint64_t r2 = this->chunks[2].to_bitmask(); + uint64_t r3 = this->chunks[3].to_bitmask(); + return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48); + } + + simdutf_really_inline uint64_t eq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64(this->chunks[0] == mask, this->chunks[1] == mask, + this->chunks[2] == mask, this->chunks[3] == mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t eq(const simd8x64& other) const + { + return simd8x64(this->chunks[0] == other.chunks[0], + this->chunks[1] == other.chunks[1], + this->chunks[2] == other.chunks[2], + this->chunks[3] == other.chunks[3]) + .to_bitmask(); + } + + simdutf_really_inline uint64_t lteq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64(this->chunks[0] <= mask, this->chunks[1] <= mask, + this->chunks[2] <= mask, this->chunks[3] <= mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t in_range(const T low, const T high) const + { + const simd8 mask_low = simd8::splat(low); + const simd8 mask_high = simd8::splat(high); + + return simd8x64( + (this->chunks[0] <= mask_high) & (this->chunks[0] >= mask_low), + (this->chunks[1] <= mask_high) & (this->chunks[1] >= mask_low), + (this->chunks[2] <= mask_high) & (this->chunks[2] >= mask_low), + (this->chunks[3] <= mask_high) & (this->chunks[3] >= mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t not_in_range(const T low, const T high) const + { + const simd8 mask_low = simd8::splat(low); + const simd8 mask_high = simd8::splat(high); + return simd8x64( + (this->chunks[0] > mask_high) | (this->chunks[0] < mask_low), + (this->chunks[1] > mask_high) | (this->chunks[1] < mask_low), + (this->chunks[2] > mask_high) | (this->chunks[2] < mask_low), + (this->chunks[3] > mask_high) | (this->chunks[3] < mask_low)) + .to_bitmask(); + } + simdutf_really_inline uint64_t lt(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64(this->chunks[0] < mask, this->chunks[1] < mask, + this->chunks[2] < mask, this->chunks[3] < mask) + .to_bitmask(); + } + + simdutf_really_inline uint64_t gt(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] > mask, + this->chunks[1] > mask, + this->chunks[2] > mask, + this->chunks[3] > mask) + .to_bitmask(); + } + simdutf_really_inline uint64_t gteq(const T m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + this->chunks[0] >= mask, + this->chunks[1] >= mask, + this->chunks[2] >= mask, + this->chunks[3] >= mask) + .to_bitmask(); + } + simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const + { + const simd8 mask = simd8::splat(m); + return simd8x64( + simd8(this->chunks[0]) >= mask, + simd8(this->chunks[1]) >= mask, + simd8(this->chunks[2]) >= mask, + simd8(this->chunks[3]) >= mask) + .to_bitmask(); + } +}; // struct simd8x64 + +} // namespace simd +} // unnamed namespace +} // namespace ppc64 +} // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64/end.h +#endif // SIMDUTF_PPC64_SIMD_INPUT_H +/* end file src/simdutf/ppc64/simd.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64/end.h /* begin file src/simdutf/ppc64/end.h */ /* end file src/simdutf/ppc64/end.h */ @@ -3943,12 +4714,11 @@ template struct simd8x64 { #endif // SIMDUTF_PPC64_H /* end file src/simdutf/ppc64.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/fallback.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/fallback.h /* begin file src/simdutf/fallback.h */ #ifndef SIMDUTF_FALLBACK_H #define SIMDUTF_FALLBACK_H - // Note that fallback.h is always imported last. // Default Fallback to on unless a builtin implementation has already been selected. @@ -3972,12 +4742,11 @@ namespace fallback { } // namespace fallback } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/fallback/implementation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/fallback/implementation.h /* begin file src/simdutf/fallback/implementation.h */ #ifndef SIMDUTF_FALLBACK_IMPLEMENTATION_H #define SIMDUTF_FALLBACK_IMPLEMENTATION_H - namespace simdutf { namespace fallback { @@ -3987,64 +4756,88 @@ using namespace simdutf; class implementation final : public simdutf::implementation { public: - simdutf_really_inline implementation() : simdutf::implementation( - "fallback", - "Generic fallback implementation", - 0 - ) {} - simdutf_warn_unused int detect_encodings(const char * input, size_t length) const noexcept final; - simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16le(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf16be(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept final; - simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * buf, size_t len, char32_t* utf32_output) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) const noexcept final; - void change_endianness_utf16(const char16_t * buf, size_t length, char16_t * output) const noexcept final; - simdutf_warn_unused size_t count_utf16le(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf16be(const char16_t * buf, size_t length) const noexcept; - simdutf_warn_unused size_t count_utf8(const char * buf, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept; - simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t length) const noexcept; + simdutf_really_inline implementation() + : simdutf::implementation( + "fallback", + "Generic fallback implementation", + 0) + { + } + simdutf_warn_unused int detect_encodings(const char* input, size_t length) const noexcept final; + simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept final; + simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_latin1_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) const noexcept final; + void change_endianness_utf16(const char16_t* buf, size_t length, char16_t* output) const noexcept final; + simdutf_warn_unused size_t count_utf16le(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf16be(const char16_t* buf, size_t length) const noexcept; + simdutf_warn_unused size_t count_utf8(const char* buf, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf8(const char* input, size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf16(size_t length) const noexcept; + simdutf_warn_unused size_t latin1_length_from_utf32(size_t length) const noexcept; + simdutf_warn_unused size_t utf32_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf16_length_from_latin1(size_t length) const noexcept; + simdutf_warn_unused size_t utf8_length_from_latin1(const char* input, size_t length) const noexcept; }; } // namespace fallback @@ -4053,14 +4846,14 @@ public: #endif // SIMDUTF_FALLBACK_IMPLEMENTATION_H /* end file src/simdutf/fallback/implementation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/fallback/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/fallback/begin.h /* begin file src/simdutf/fallback/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "fallback" // #define SIMDUTF_IMPLEMENTATION fallback /* end file src/simdutf/fallback/begin.h */ // Declarations -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/fallback/bitmanipulation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/fallback/bitmanipulation.h /* begin file src/simdutf/fallback/bitmanipulation.h */ #ifndef SIMDUTF_FALLBACK_BITMANIPULATION_H #define SIMDUTF_FALLBACK_BITMANIPULATION_H @@ -4072,19 +4865,21 @@ namespace fallback { namespace { #if defined(_MSC_VER) && !defined(_M_ARM64) && !defined(_M_X64) -static inline unsigned char _BitScanForward64(unsigned long* ret, uint64_t x) { - unsigned long x0 = (unsigned long)x, top, bottom; - _BitScanForward(&top, (unsigned long)(x >> 32)); - _BitScanForward(&bottom, x0); - *ret = x0 ? bottom : 32 + top; - return x != 0; -} -static unsigned char _BitScanReverse64(unsigned long* ret, uint64_t x) { - unsigned long x1 = (unsigned long)(x >> 32), top, bottom; - _BitScanReverse(&top, x1); - _BitScanReverse(&bottom, (unsigned long)x); - *ret = x1 ? top + 32 : bottom; - return x != 0; +static inline unsigned char _BitScanForward64(unsigned long* ret, uint64_t x) +{ + unsigned long x0 = (unsigned long)x, top, bottom; + _BitScanForward(&top, (unsigned long)(x >> 32)); + _BitScanForward(&bottom, x0); + *ret = x0 ? bottom : 32 + top; + return x != 0; +} +static unsigned char _BitScanReverse64(unsigned long* ret, uint64_t x) +{ + unsigned long x1 = (unsigned long)(x >> 32), top, bottom; + _BitScanReverse(&top, x1); + _BitScanReverse(&bottom, (unsigned long)x); + *ret = x1 ? top + 32 : bottom; + return x != 0; } #endif @@ -4095,7 +4890,7 @@ static unsigned char _BitScanReverse64(unsigned long* ret, uint64_t x) { #endif // SIMDUTF_FALLBACK_BITMANIPULATION_H /* end file src/simdutf/fallback/bitmanipulation.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/fallback/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/fallback/end.h /* begin file src/simdutf/fallback/end.h */ /* end file src/simdutf/fallback/end.h */ @@ -4104,16 +4899,20 @@ static unsigned char _BitScanReverse64(unsigned long* ret, uint64_t x) { /* end file src/simdutf/fallback.h */ namespace simdutf { -bool implementation::supported_by_runtime_system() const { - uint32_t required_instruction_sets = this->required_instruction_sets(); - uint32_t supported_instruction_sets = internal::detect_supported_architectures(); - return ((supported_instruction_sets & required_instruction_sets) == required_instruction_sets); +bool implementation::supported_by_runtime_system() const +{ + uint32_t required_instruction_sets = this->required_instruction_sets(); + uint32_t supported_instruction_sets = internal::detect_supported_architectures(); + return ((supported_instruction_sets & required_instruction_sets) == required_instruction_sets); } -simdutf_warn_unused encoding_type implementation::autodetect_encoding(const char * input, size_t length) const noexcept { +simdutf_warn_unused encoding_type implementation::autodetect_encoding(const char* input, size_t length) const noexcept +{ // If there is a BOM, then we trust it. auto bom_encoding = simdutf::BOM::check_bom(input, length); - if(bom_encoding != encoding_type::unspecified) { return bom_encoding; } + if (bom_encoding != encoding_type::unspecified) { + return bom_encoding; + } // UTF8 is common, it includes ASCII, and is commonly represented // without a BOM, so if it fits, go with that. Note that it is still // possible to get it wrong, we are only 'guessing'. If some has UTF-16 @@ -4121,15 +4920,21 @@ simdutf_warn_unused encoding_type implementation::autodetect_encoding(const char // // An interesting twist might be to check for UTF-16 ASCII first (every // other byte is zero). - if(validate_utf8(input, length)) { return encoding_type::UTF8; } + if (validate_utf8(input, length)) { + return encoding_type::UTF8; + } // The next most common encoding that might appear without BOM is probably // UTF-16LE, so try that next. - if((length % 2) == 0) { - // important: we need to divide by two - if(validate_utf16le(reinterpret_cast(input), length/2)) { return encoding_type::UTF16_LE; } + if ((length % 2) == 0) { + // important: we need to divide by two + if (validate_utf16le(reinterpret_cast(input), length / 2)) { + return encoding_type::UTF16_LE; + } } - if((length % 4) == 0) { - if(validate_utf32(reinterpret_cast(input), length/4)) { return encoding_type::UTF32_LE; } + if ((length % 4) == 0) { + if (validate_utf32(reinterpret_cast(input), length / 4)) { + return encoding_type::UTF32_LE; + } } return encoding_type::unspecified; } @@ -4139,24 +4944,47 @@ namespace internal { // Static array of known implementations. We're hoping these get baked into the executable // without requiring a static initializer. - #if SIMDUTF_IMPLEMENTATION_ICELAKE -const icelake::implementation icelake_singleton{}; +static const icelake::implementation* get_icelake_singleton() +{ + static const icelake::implementation icelake_singleton {}; + return &icelake_singleton; +} #endif #if SIMDUTF_IMPLEMENTATION_HASWELL -const haswell::implementation haswell_singleton{}; +static const haswell::implementation* get_haswell_singleton() +{ + static const haswell::implementation haswell_singleton {}; + return &haswell_singleton; +} #endif #if SIMDUTF_IMPLEMENTATION_WESTMERE -const westmere::implementation westmere_singleton{}; +static const westmere::implementation* get_westmere_singleton() +{ + static const westmere::implementation westmere_singleton {}; + return &westmere_singleton; +} #endif #if SIMDUTF_IMPLEMENTATION_ARM64 -const arm64::implementation arm64_singleton{}; +static const arm64::implementation* get_arm64_singleton() +{ + static const arm64::implementation arm64_singleton {}; + return &arm64_singleton; +} #endif #if SIMDUTF_IMPLEMENTATION_PPC64 -const ppc64::implementation ppc64_singleton{}; +static const ppc64::implementation* get_ppc64_singleton() +{ + static const ppc64::implementation ppc64_singleton {}; + return &ppc64_singleton; +} #endif #if SIMDUTF_IMPLEMENTATION_FALLBACK -const fallback::implementation fallback_singleton{}; +static const fallback::implementation* get_fallback_singleton() +{ + static const fallback::implementation fallback_singleton {}; + return &fallback_singleton; +} #endif /** @@ -4164,7471 +4992,8861 @@ const fallback::implementation fallback_singleton{}; */ class detect_best_supported_implementation_on_first_use final : public implementation { public: - const std::string &name() const noexcept final { return set_best()->name(); } - const std::string &description() const noexcept final { return set_best()->description(); } - uint32_t required_instruction_sets() const noexcept final { return set_best()->required_instruction_sets(); } - - simdutf_warn_unused int detect_encodings(const char * input, size_t length) const noexcept override { - return set_best()->detect_encodings(input, length); - } - - simdutf_warn_unused bool validate_utf8(const char * buf, size_t len) const noexcept final override { - return set_best()->validate_utf8(buf, len); - } + const std::string& name() const noexcept final { return set_best()->name(); } + const std::string& description() const noexcept final { return set_best()->description(); } + uint32_t required_instruction_sets() const noexcept final { return set_best()->required_instruction_sets(); } - simdutf_warn_unused result validate_utf8_with_errors(const char * buf, size_t len) const noexcept final override { - return set_best()->validate_utf8_with_errors(buf, len); - } + simdutf_warn_unused int detect_encodings(const char* input, size_t length) const noexcept override + { + return set_best()->detect_encodings(input, length); + } - simdutf_warn_unused bool validate_ascii(const char * buf, size_t len) const noexcept final override { - return set_best()->validate_ascii(buf, len); - } + simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) const noexcept final override + { + return set_best()->validate_utf8(buf, len); + } - simdutf_warn_unused result validate_ascii_with_errors(const char * buf, size_t len) const noexcept final override { - return set_best()->validate_ascii_with_errors(buf, len); - } + simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) const noexcept final override + { + return set_best()->validate_utf8_with_errors(buf, len); + } - simdutf_warn_unused bool validate_utf16le(const char16_t * buf, size_t len) const noexcept final override { - return set_best()->validate_utf16le(buf, len); - } + simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) const noexcept final override + { + return set_best()->validate_ascii(buf, len); + } - simdutf_warn_unused bool validate_utf16be(const char16_t * buf, size_t len) const noexcept final override { - return set_best()->validate_utf16be(buf, len); - } + simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) const noexcept final override + { + return set_best()->validate_ascii_with_errors(buf, len); + } - simdutf_warn_unused result validate_utf16le_with_errors(const char16_t * buf, size_t len) const noexcept final override { - return set_best()->validate_utf16le_with_errors(buf, len); - } + simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) const noexcept final override + { + return set_best()->validate_utf16le(buf, len); + } - simdutf_warn_unused result validate_utf16be_with_errors(const char16_t * buf, size_t len) const noexcept final override { - return set_best()->validate_utf16be_with_errors(buf, len); - } + simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) const noexcept final override + { + return set_best()->validate_utf16be(buf, len); + } - simdutf_warn_unused bool validate_utf32(const char32_t * buf, size_t len) const noexcept final override { - return set_best()->validate_utf32(buf, len); - } + simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept final override + { + return set_best()->validate_utf16le_with_errors(buf, len); + } - simdutf_warn_unused result validate_utf32_with_errors(const char32_t * buf, size_t len) const noexcept final override { - return set_best()->validate_utf32_with_errors(buf, len); - } + simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept final override + { + return set_best()->validate_utf16be_with_errors(buf, len); + } - simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_utf8_to_utf16le(buf, len, utf16_output); - } + simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) const noexcept final override + { + return set_best()->validate_utf32(buf, len); + } - simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_utf8_to_utf16be(buf, len, utf16_output); - } + simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept final override + { + return set_best()->validate_utf32_with_errors(buf, len); + } - simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_utf8_to_utf16le_with_errors(buf, len, utf16_output); - } + simdutf_warn_unused size_t convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_latin1_to_utf8(buf, len, utf8_output); + } - simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_utf8_to_utf16be_with_errors(buf, len, utf16_output); - } + simdutf_warn_unused size_t convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_latin1_to_utf16le(buf, len, utf16_output); + } - simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_valid_utf8_to_utf16le(buf, len, utf16_output); - } + simdutf_warn_unused size_t convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_latin1_to_utf16be(buf, len, utf16_output); + } - simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_valid_utf8_to_utf16be(buf, len, utf16_output); - } + simdutf_warn_unused size_t convert_latin1_to_utf32(const char* buf, size_t len, char32_t* latin1_output) const noexcept final override + { + return set_best()->convert_latin1_to_utf32(buf, len, latin1_output); + } - simdutf_warn_unused size_t convert_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_utf8_to_utf32(buf, len, utf32_output); - } + simdutf_warn_unused size_t convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf8_to_latin1(buf, len, latin1_output); + } - simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_utf8_to_utf32_with_errors(buf, len, utf32_output); - } + simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf8_to_latin1_with_errors(buf, len, latin1_output); + } - simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_valid_utf8_to_utf32(buf, len, utf32_output); - } + simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_valid_utf8_to_latin1(buf, len, latin1_output); + } - simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_utf16le_to_utf8(buf, len, utf8_output); - } + simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_utf8_to_utf16le(buf, len, utf16_output); + } - simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_utf16be_to_utf8(buf, len, utf8_output); - } + simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_utf8_to_utf16be(buf, len, utf16_output); + } - simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_utf16le_to_utf8_with_errors(buf, len, utf8_output); - } + simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_utf8_to_utf16le_with_errors(buf, len, utf16_output); + } - simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_utf16be_to_utf8_with_errors(buf, len, utf8_output); - } + simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_utf8_to_utf16be_with_errors(buf, len, utf16_output); + } - simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_valid_utf16le_to_utf8(buf, len, utf8_output); - } + simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_valid_utf8_to_utf16le(buf, len, utf16_output); + } - simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_valid_utf16be_to_utf8(buf, len, utf8_output); - } + simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_valid_utf8_to_utf16be(buf, len, utf16_output); + } - simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_utf32_to_utf8(buf, len, utf8_output); - } + simdutf_warn_unused size_t convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_utf8_to_utf32(buf, len, utf32_output); + } - simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_utf32_to_utf8_with_errors(buf, len, utf8_output); - } + simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_utf8_to_utf32_with_errors(buf, len, utf32_output); + } - simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_output) const noexcept final override { - return set_best()->convert_valid_utf32_to_utf8(buf, len, utf8_output); - } + simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_valid_utf8_to_utf32(buf, len, utf32_output); + } - simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_utf32_to_utf16le(buf, len, utf16_output); - } + simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf16le_to_latin1(buf, len, latin1_output); + } - simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_utf32_to_utf16be(buf, len, utf16_output); - } + simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf16be_to_latin1(buf, len, latin1_output); + } - simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_utf32_to_utf16le_with_errors(buf, len, utf16_output); - } + simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf16le_to_latin1_with_errors(buf, len, latin1_output); + } - simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_utf32_to_utf16be_with_errors(buf, len, utf16_output); - } + simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf16be_to_latin1_with_errors(buf, len, latin1_output); + } - simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_valid_utf32_to_utf16le(buf, len, utf16_output); - } + simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_valid_utf16le_to_latin1(buf, len, latin1_output); + } - simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_output) const noexcept final override { - return set_best()->convert_valid_utf32_to_utf16be(buf, len, utf16_output); - } + simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_valid_utf16be_to_latin1(buf, len, latin1_output); + } - simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_utf16le_to_utf32(buf, len, utf32_output); - } + simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_utf16le_to_utf8(buf, len, utf8_output); + } - simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_utf16be_to_utf32(buf, len, utf32_output); - } + simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_utf16be_to_utf8(buf, len, utf8_output); + } - simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_utf16le_to_utf32_with_errors(buf, len, utf32_output); - } + simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_utf16le_to_utf8_with_errors(buf, len, utf8_output); + } - simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_utf16be_to_utf32_with_errors(buf, len, utf32_output); - } + simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_utf16be_to_utf8_with_errors(buf, len, utf8_output); + } - simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_valid_utf16le_to_utf32(buf, len, utf32_output); - } + simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_valid_utf16le_to_utf8(buf, len, utf8_output); + } - simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_output) const noexcept final override { - return set_best()->convert_valid_utf16be_to_utf32(buf, len, utf32_output); - } + simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_valid_utf16be_to_utf8(buf, len, utf8_output); + } - void change_endianness_utf16(const char16_t * buf, size_t len, char16_t * output) const noexcept final override { - set_best()->change_endianness_utf16(buf, len, output); - } + simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf32_to_latin1(buf, len, latin1_output); + } - simdutf_warn_unused size_t count_utf16le(const char16_t * buf, size_t len) const noexcept final override { - return set_best()->count_utf16le(buf, len); - } + simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf32_to_latin1_with_errors(buf, len, latin1_output); + } - simdutf_warn_unused size_t count_utf16be(const char16_t * buf, size_t len) const noexcept final override { - return set_best()->count_utf16be(buf, len); - } + simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept final override + { + return set_best()->convert_utf32_to_latin1(buf, len, latin1_output); + } - simdutf_warn_unused size_t count_utf8(const char * buf, size_t len) const noexcept final override { - return set_best()->count_utf8(buf, len); - } + simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_utf32_to_utf8(buf, len, utf8_output); + } - simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * buf, size_t len) const noexcept override { - return set_best()->utf8_length_from_utf16le(buf, len); - } + simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_utf32_to_utf8_with_errors(buf, len, utf8_output); + } - simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * buf, size_t len) const noexcept override { - return set_best()->utf8_length_from_utf16be(buf, len); - } + simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept final override + { + return set_best()->convert_valid_utf32_to_utf8(buf, len, utf8_output); + } - simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * buf, size_t len) const noexcept override { - return set_best()->utf32_length_from_utf16le(buf, len); - } + simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_utf32_to_utf16le(buf, len, utf16_output); + } - simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * buf, size_t len) const noexcept override { - return set_best()->utf32_length_from_utf16be(buf, len); - } + simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_utf32_to_utf16be(buf, len, utf16_output); + } - simdutf_warn_unused size_t utf16_length_from_utf8(const char * buf, size_t len) const noexcept override { - return set_best()->utf16_length_from_utf8(buf, len); - } + simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_utf32_to_utf16le_with_errors(buf, len, utf16_output); + } - simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * buf, size_t len) const noexcept override { - return set_best()->utf8_length_from_utf32(buf, len); - } + simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_utf32_to_utf16be_with_errors(buf, len, utf16_output); + } - simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * buf, size_t len) const noexcept override { - return set_best()->utf16_length_from_utf32(buf, len); - } + simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_valid_utf32_to_utf16le(buf, len, utf16_output); + } - simdutf_warn_unused size_t utf32_length_from_utf8(const char * buf, size_t len) const noexcept override { - return set_best()->utf32_length_from_utf8(buf, len); - } + simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept final override + { + return set_best()->convert_valid_utf32_to_utf16be(buf, len, utf16_output); + } - simdutf_really_inline detect_best_supported_implementation_on_first_use() noexcept : implementation("best_supported_detector", "Detects the best supported implementation and sets it", 0) {} + simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_utf16le_to_utf32(buf, len, utf32_output); + } -private: - const implementation *set_best() const noexcept; -}; + simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_utf16be_to_utf32(buf, len, utf32_output); + } + simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_utf16le_to_utf32_with_errors(buf, len, utf32_output); + } -const std::initializer_list available_implementation_pointers { -#if SIMDUTF_IMPLEMENTATION_ICELAKE - &icelake_singleton, -#endif -#if SIMDUTF_IMPLEMENTATION_HASWELL - &haswell_singleton, -#endif -#if SIMDUTF_IMPLEMENTATION_WESTMERE - &westmere_singleton, -#endif -#if SIMDUTF_IMPLEMENTATION_ARM64 - &arm64_singleton, -#endif -#if SIMDUTF_IMPLEMENTATION_PPC64 - &ppc64_singleton, -#endif -#if SIMDUTF_IMPLEMENTATION_FALLBACK - &fallback_singleton, -#endif -}; // available_implementation_pointers + simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_utf16be_to_utf32_with_errors(buf, len, utf32_output); + } -// So we can return UNSUPPORTED_ARCHITECTURE from the parser when there is no support -class unsupported_implementation final : public implementation { -public: - simdutf_warn_unused int detect_encodings(const char *, size_t) const noexcept override { - return encoding_type::unspecified; - } - - simdutf_warn_unused bool validate_utf8(const char *, size_t) const noexcept final override { - return false; // Just refuse to validate. Given that we have a fallback implementation - // it seems unlikely that unsupported_implementation will ever be used. If it is used, - // then it will flag all strings as invalid. The alternative is to return an error_code - // from which the user has to figure out whether the string is valid UTF-8... which seems - // like a lot of work just to handle the very unlikely case that we have an unsupported - // implementation. And, when it does happen (that we have an unsupported implementation), - // what are the chances that the programmer has a fallback? Given that *we* provide the - // fallback, it implies that the programmer would need a fallback for our fallback. - } - - simdutf_warn_unused result validate_utf8_with_errors(const char *, size_t) const noexcept final override { - return result(error_code::OTHER, 0); - } - - simdutf_warn_unused bool validate_ascii(const char *, size_t) const noexcept final override { - return false; - } - - simdutf_warn_unused result validate_ascii_with_errors(const char *, size_t) const noexcept final override { - return result(error_code::OTHER, 0); - } - - simdutf_warn_unused bool validate_utf16le(const char16_t*, size_t) const noexcept final override { - return false; - } - - simdutf_warn_unused bool validate_utf16be(const char16_t*, size_t) const noexcept final override { - return false; - } - - simdutf_warn_unused result validate_utf16le_with_errors(const char16_t*, size_t) const noexcept final override { - return result(error_code::OTHER, 0); - } - - simdutf_warn_unused result validate_utf16be_with_errors(const char16_t*, size_t) const noexcept final override { - return result(error_code::OTHER, 0); - } - - simdutf_warn_unused bool validate_utf32(const char32_t*, size_t) const noexcept final override { - return false; - } - - simdutf_warn_unused result validate_utf32_with_errors(const char32_t*, size_t) const noexcept final override { - return result(error_code::OTHER, 0); - } - - simdutf_warn_unused size_t convert_utf8_to_utf16le(const char*, size_t, char16_t*) const noexcept final override { - return 0; - } - - simdutf_warn_unused size_t convert_utf8_to_utf16be(const char*, size_t, char16_t*) const noexcept final override { - return 0; - } - - simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char*, size_t, char16_t*) const noexcept final override { - return result(error_code::OTHER, 0); - } - - simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char*, size_t, char16_t*) const noexcept final override { - return result(error_code::OTHER, 0); - } - - simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char*, size_t, char16_t*) const noexcept final override { - return 0; - } - - simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char*, size_t, char16_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_valid_utf16le_to_utf32(buf, len, utf32_output); + } - simdutf_warn_unused size_t convert_utf8_to_utf32(const char*, size_t, char32_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept final override + { + return set_best()->convert_valid_utf16be_to_utf32(buf, len, utf32_output); + } - simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char*, size_t, char32_t*) const noexcept final override { - return result(error_code::OTHER, 0); - } + void change_endianness_utf16(const char16_t* buf, size_t len, char16_t* output) const noexcept final override + { + set_best()->change_endianness_utf16(buf, len, output); + } - simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char*, size_t, char32_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t count_utf16le(const char16_t* buf, size_t len) const noexcept final override + { + return set_best()->count_utf16le(buf, len); + } - simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t*, size_t, char*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t count_utf16be(const char16_t* buf, size_t len) const noexcept final override + { + return set_best()->count_utf16be(buf, len); + } - simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t*, size_t, char*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t count_utf8(const char* buf, size_t len) const noexcept final override + { + return set_best()->count_utf8(buf, len); + } - simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t*, size_t, char*) const noexcept final override { - return result(error_code::OTHER, 0); - } + simdutf_warn_unused size_t latin1_length_from_utf8(const char* buf, size_t len) const noexcept override + { + return set_best()->latin1_length_from_utf8(buf, len); + } - simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t*, size_t, char*) const noexcept final override { - return result(error_code::OTHER, 0); - } + simdutf_warn_unused size_t latin1_length_from_utf16(size_t len) const noexcept override + { + return set_best()->latin1_length_from_utf16(len); + } - simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t*, size_t, char*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t latin1_length_from_utf32(size_t len) const noexcept override + { + return set_best()->latin1_length_from_utf32(len); + } - simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t*, size_t, char*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t utf8_length_from_latin1(const char* buf, size_t len) const noexcept override + { + return set_best()->utf8_length_from_latin1(buf, len); + } - simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t*, size_t, char*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* buf, size_t len) const noexcept override + { + return set_best()->utf8_length_from_utf16le(buf, len); + } - simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t*, size_t, char*) const noexcept final override { - return result(error_code::OTHER, 0); - } + simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* buf, size_t len) const noexcept override + { + return set_best()->utf8_length_from_utf16be(buf, len); + } - simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t*, size_t, char*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t utf16_length_from_latin1(size_t len) const noexcept override + { + return set_best()->utf16_length_from_latin1(len); + } - simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t*, size_t, char16_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t utf32_length_from_latin1(size_t len) const noexcept override + { + return set_best()->utf32_length_from_latin1(len); + } - simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t*, size_t, char16_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* buf, size_t len) const noexcept override + { + return set_best()->utf32_length_from_utf16le(buf, len); + } - simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t*, size_t, char16_t*) const noexcept final override { - return result(error_code::OTHER, 0); - } + simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* buf, size_t len) const noexcept override + { + return set_best()->utf32_length_from_utf16be(buf, len); + } - simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t*, size_t, char16_t*) const noexcept final override { - return result(error_code::OTHER, 0); - } + simdutf_warn_unused size_t utf16_length_from_utf8(const char* buf, size_t len) const noexcept override + { + return set_best()->utf16_length_from_utf8(buf, len); + } - simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t*, size_t, char16_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* buf, size_t len) const noexcept override + { + return set_best()->utf8_length_from_utf32(buf, len); + } - simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t*, size_t, char16_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* buf, size_t len) const noexcept override + { + return set_best()->utf16_length_from_utf32(buf, len); + } - simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t*, size_t, char32_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused size_t utf32_length_from_utf8(const char* buf, size_t len) const noexcept override + { + return set_best()->utf32_length_from_utf8(buf, len); + } - simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t*, size_t, char32_t*) const noexcept final override { - return 0; - } + simdutf_really_inline detect_best_supported_implementation_on_first_use() noexcept + : implementation("best_supported_detector", "Detects the best supported implementation and sets it", 0) + { + } - simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t*, size_t, char32_t*) const noexcept final override { - return result(error_code::OTHER, 0); - } +private: + const implementation* set_best() const noexcept; +}; - simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t*, size_t, char32_t*) const noexcept final override { - return result(error_code::OTHER, 0); - } +static const std::initializer_list& get_available_implementation_pointers() +{ + static const std::initializer_list available_implementation_pointers + { +#if SIMDUTF_IMPLEMENTATION_ICELAKE + get_icelake_singleton(), +#endif +#if SIMDUTF_IMPLEMENTATION_HASWELL + get_haswell_singleton(), +#endif +#if SIMDUTF_IMPLEMENTATION_WESTMERE + get_westmere_singleton(), +#endif +#if SIMDUTF_IMPLEMENTATION_ARM64 + get_arm64_singleton(), +#endif +#if SIMDUTF_IMPLEMENTATION_PPC64 + get_ppc64_singleton(), +#endif +#if SIMDUTF_IMPLEMENTATION_FALLBACK + get_fallback_singleton(), +#endif + }; // available_implementation_pointers + return available_implementation_pointers; +} - simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t*, size_t, char32_t*) const noexcept final override { - return 0; - } +// So we can return UNSUPPORTED_ARCHITECTURE from the parser when there is no support +class unsupported_implementation final : public implementation { +public: + simdutf_warn_unused int detect_encodings(const char*, size_t) const noexcept override + { + return encoding_type::unspecified; + } - simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t*, size_t, char32_t*) const noexcept final override { - return 0; - } + simdutf_warn_unused bool validate_utf8(const char*, size_t) const noexcept final override + { + return false; // Just refuse to validate. Given that we have a fallback implementation + // it seems unlikely that unsupported_implementation will ever be used. If it is used, + // then it will flag all strings as invalid. The alternative is to return an error_code + // from which the user has to figure out whether the string is valid UTF-8... which seems + // like a lot of work just to handle the very unlikely case that we have an unsupported + // implementation. And, when it does happen (that we have an unsupported implementation), + // what are the chances that the programmer has a fallback? Given that *we* provide the + // fallback, it implies that the programmer would need a fallback for our fallback. + } - void change_endianness_utf16(const char16_t *, size_t, char16_t *) const noexcept final override { + simdutf_warn_unused result validate_utf8_with_errors(const char*, size_t) const noexcept final override + { + return result(error_code::OTHER, 0); + } - } + simdutf_warn_unused bool validate_ascii(const char*, size_t) const noexcept final override + { + return false; + } - simdutf_warn_unused size_t count_utf16le(const char16_t *, size_t) const noexcept final override { - return 0; - } + simdutf_warn_unused result validate_ascii_with_errors(const char*, size_t) const noexcept final override + { + return result(error_code::OTHER, 0); + } - simdutf_warn_unused size_t count_utf16be(const char16_t *, size_t) const noexcept final override { - return 0; - } + simdutf_warn_unused bool validate_utf16le(const char16_t*, size_t) const noexcept final override + { + return false; + } - simdutf_warn_unused size_t count_utf8(const char *, size_t) const noexcept final override { - return 0; - } + simdutf_warn_unused bool validate_utf16be(const char16_t*, size_t) const noexcept final override + { + return false; + } + + simdutf_warn_unused result validate_utf16le_with_errors(const char16_t*, size_t) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused result validate_utf16be_with_errors(const char16_t*, size_t) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused bool validate_utf32(const char32_t*, size_t) const noexcept final override + { + return false; + } + + simdutf_warn_unused result validate_utf32_with_errors(const char32_t*, size_t) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_latin1_to_utf8(const char*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_latin1_to_utf16le(const char*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_latin1_to_utf16be(const char*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_latin1_to_utf32(const char*, size_t, char32_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf8_to_latin1(const char*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char*, size_t, char*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf8_to_utf16le(const char*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf8_to_utf16be(const char*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char*, size_t, char16_t*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char*, size_t, char16_t*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf8_to_utf32(const char*, size_t, char32_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char*, size_t, char32_t*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char*, size_t, char32_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t*, size_t, char*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t*, size_t, char*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t*, size_t, char*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t*, size_t, char*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t*, size_t, char*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t*, size_t, char*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t*, size_t, char*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t*, size_t, char16_t*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t*, size_t, char16_t*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t*, size_t, char16_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t*, size_t, char32_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t*, size_t, char32_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t*, size_t, char32_t*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t*, size_t, char32_t*) const noexcept final override + { + return result(error_code::OTHER, 0); + } + + simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t*, size_t, char32_t*) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t*, size_t, char32_t*) const noexcept final override + { + return 0; + } + + void change_endianness_utf16(const char16_t*, size_t, char16_t*) const noexcept final override + { + } + + simdutf_warn_unused size_t count_utf16le(const char16_t*, size_t) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t count_utf16be(const char16_t*, size_t) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t count_utf8(const char*, size_t) const noexcept final override + { + return 0; + } + + simdutf_warn_unused size_t latin1_length_from_utf8(const char*, size_t) const noexcept override + { + return 0; + } + + simdutf_warn_unused size_t latin1_length_from_utf16(size_t) const noexcept override + { + return 0; + } + + simdutf_warn_unused size_t latin1_length_from_utf32(size_t) const noexcept override + { + return 0; + } + simdutf_warn_unused size_t utf8_length_from_latin1(const char*, size_t) const noexcept override + { + return 0; + } - simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t *, size_t) const noexcept override { - return 0; - } + simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t*, size_t) const noexcept override + { + return 0; + } - simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t *, size_t) const noexcept override { - return 0; - } + simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t*, size_t) const noexcept override + { + return 0; + } - simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t *, size_t) const noexcept override { - return 0; - } + simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t*, size_t) const noexcept override + { + return 0; + } - simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t *, size_t) const noexcept override { - return 0; - } + simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t*, size_t) const noexcept override + { + return 0; + } - simdutf_warn_unused size_t utf16_length_from_utf8(const char *, size_t) const noexcept override { - return 0; - } + simdutf_warn_unused size_t utf32_length_from_latin1(size_t) const noexcept override + { + return 0; + } - simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t *, size_t) const noexcept override { - return 0; - } + simdutf_warn_unused size_t utf16_length_from_utf8(const char*, size_t) const noexcept override + { + return 0; + } + simdutf_warn_unused size_t utf16_length_from_latin1(size_t) const noexcept override + { + return 0; + } + simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t*, size_t) const noexcept override + { + return 0; + } - simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t *, size_t) const noexcept override { - return 0; - } + simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t*, size_t) const noexcept override + { + return 0; + } - simdutf_warn_unused size_t utf32_length_from_utf8(const char *, size_t) const noexcept override { - return 0; - } + simdutf_warn_unused size_t utf32_length_from_utf8(const char*, size_t) const noexcept override + { + return 0; + } - unsupported_implementation() : implementation("unsupported", "Unsupported CPU (no detected SIMD instructions)", 0) {} + unsupported_implementation() + : implementation("unsupported", "Unsupported CPU (no detected SIMD instructions)", 0) + { + } }; -const unsupported_implementation unsupported_singleton{}; +const unsupported_implementation unsupported_singleton {}; -size_t available_implementation_list::size() const noexcept { - return internal::available_implementation_pointers.size(); +size_t available_implementation_list::size() const noexcept +{ + return internal::get_available_implementation_pointers().size(); } -const implementation * const *available_implementation_list::begin() const noexcept { - return internal::available_implementation_pointers.begin(); +const implementation* const* available_implementation_list::begin() const noexcept +{ + return internal::get_available_implementation_pointers().begin(); } -const implementation * const *available_implementation_list::end() const noexcept { - return internal::available_implementation_pointers.end(); +const implementation* const* available_implementation_list::end() const noexcept +{ + return internal::get_available_implementation_pointers().end(); } -const implementation *available_implementation_list::detect_best_supported() const noexcept { - // They are prelisted in priority order, so we just go down the list - uint32_t supported_instruction_sets = internal::detect_supported_architectures(); - for (const implementation *impl : internal::available_implementation_pointers) { - uint32_t required_instruction_sets = impl->required_instruction_sets(); - if ((supported_instruction_sets & required_instruction_sets) == required_instruction_sets) { return impl; } - } - return &unsupported_singleton; // this should never happen? +const implementation* available_implementation_list::detect_best_supported() const noexcept +{ + // They are prelisted in priority order, so we just go down the list + uint32_t supported_instruction_sets = internal::detect_supported_architectures(); + for (const implementation* impl : internal::get_available_implementation_pointers()) { + uint32_t required_instruction_sets = impl->required_instruction_sets(); + if ((supported_instruction_sets & required_instruction_sets) == required_instruction_sets) { + return impl; + } + } + return &unsupported_singleton; // this should never happen? } -const implementation *detect_best_supported_implementation_on_first_use::set_best() const noexcept { - SIMDUTF_PUSH_DISABLE_WARNINGS - SIMDUTF_DISABLE_DEPRECATED_WARNING // Disable CRT_SECURE warning on MSVC: manually verified this is safe - char *force_implementation_name = getenv("SIMDUTF_FORCE_IMPLEMENTATION"); - SIMDUTF_POP_DISABLE_WARNINGS +const implementation* detect_best_supported_implementation_on_first_use::set_best() const noexcept +{ + SIMDUTF_PUSH_DISABLE_WARNINGS + SIMDUTF_DISABLE_DEPRECATED_WARNING // Disable CRT_SECURE warning on MSVC: manually verified this is safe + char* force_implementation_name + = getenv("SIMDUTF_FORCE_IMPLEMENTATION"); + SIMDUTF_POP_DISABLE_WARNINGS - if (force_implementation_name) { - auto force_implementation = get_available_implementations()[force_implementation_name]; - if (force_implementation) { - return get_active_implementation() = force_implementation; - } else { - // Note: abort() and stderr usage within the library is forbidden. - return get_active_implementation() = &unsupported_singleton; + if (force_implementation_name) { + auto force_implementation = get_available_implementations()[force_implementation_name]; + if (force_implementation) { + return get_active_implementation() = force_implementation; + } else { + // Note: abort() and stderr usage within the library is forbidden. + return get_active_implementation() = &unsupported_singleton; + } } - } - return get_active_implementation() = get_available_implementations().detect_best_supported(); + return get_active_implementation() = get_available_implementations().detect_best_supported(); } } // namespace internal - - /** * The list of available implementations compiled into simdutf. */ -SIMDUTF_DLLIMPORTEXPORT const internal::available_implementation_list& get_available_implementations() { - static const internal::available_implementation_list available_implementations{}; - return available_implementations; +SIMDUTF_DLLIMPORTEXPORT const internal::available_implementation_list& get_available_implementations() +{ + static const internal::available_implementation_list available_implementations {}; + return available_implementations; } /** - * The active implementation. - */ -SIMDUTF_DLLIMPORTEXPORT internal::atomic_ptr& get_active_implementation() { + * The active implementation. + */ +SIMDUTF_DLLIMPORTEXPORT internal::atomic_ptr& get_active_implementation() +{ static const internal::detect_best_supported_implementation_on_first_use detect_best_supported_implementation_on_first_use_singleton; - static internal::atomic_ptr active_implementation{&detect_best_supported_implementation_on_first_use_singleton}; + static internal::atomic_ptr active_implementation { &detect_best_supported_implementation_on_first_use_singleton }; return active_implementation; } -simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) noexcept { - return get_active_implementation()->validate_utf8(buf, len); +simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_utf8(buf, len); } -simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len) noexcept { - return get_active_implementation()->validate_utf8_with_errors(buf, len); +simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_utf8_with_errors(buf, len); } -simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) noexcept { - return get_active_implementation()->validate_ascii(buf, len); +simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_ascii(buf, len); } -simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t len) noexcept { - return get_active_implementation()->validate_ascii_with_errors(buf, len); +simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_ascii_with_errors(buf, len); } -simdutf_warn_unused size_t convert_utf8_to_utf16(const char * input, size_t length, char16_t* utf16_output) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_utf8_to_utf16be(input, length, utf16_output); - #else - return convert_utf8_to_utf16le(input, length, utf16_output); - #endif +simdutf_warn_unused size_t convert_utf8_to_utf16(const char* input, size_t length, char16_t* utf16_output) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_utf8_to_utf16be(input, length, utf16_output); +#else + return convert_utf8_to_utf16le(input, length, utf16_output); +#endif } -simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * input, size_t length, char16_t* utf16_output) noexcept { - return get_active_implementation()->convert_utf8_to_utf16le(input, length, utf16_output); +simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* input, size_t length, char16_t* utf16_output) noexcept +{ + return get_active_implementation()->convert_utf8_to_utf16le(input, length, utf16_output); } -simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * input, size_t length, char16_t* utf16_output) noexcept { - return get_active_implementation()->convert_utf8_to_utf16be(input, length, utf16_output); +simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* input, size_t length, char16_t* utf16_output) noexcept +{ + return get_active_implementation()->convert_utf8_to_utf16be(input, length, utf16_output); } -simdutf_warn_unused result convert_utf8_to_utf16_with_errors(const char * input, size_t length, char16_t* utf16_output) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_utf8_to_utf16be_with_errors(input, length, utf16_output); - #else - return convert_utf8_to_utf16le_with_errors(input, length, utf16_output); - #endif +simdutf_warn_unused result convert_utf8_to_utf16_with_errors(const char* input, size_t length, char16_t* utf16_output) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_utf8_to_utf16be_with_errors(input, length, utf16_output); +#else + return convert_utf8_to_utf16le_with_errors(input, length, utf16_output); +#endif } -simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * input, size_t length, char16_t* utf16_output) noexcept { - return get_active_implementation()->convert_utf8_to_utf16le_with_errors(input, length, utf16_output); +simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* input, size_t length, char16_t* utf16_output) noexcept +{ + return get_active_implementation()->convert_utf8_to_utf16le_with_errors(input, length, utf16_output); } -simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * input, size_t length, char16_t* utf16_output) noexcept { - return get_active_implementation()->convert_utf8_to_utf16be_with_errors(input, length, utf16_output); +simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* input, size_t length, char16_t* utf16_output) noexcept +{ + return get_active_implementation()->convert_utf8_to_utf16be_with_errors(input, length, utf16_output); } -simdutf_warn_unused size_t convert_utf8_to_utf32(const char * input, size_t length, char32_t* utf32_output) noexcept { - return get_active_implementation()->convert_utf8_to_utf32(input, length, utf32_output); +simdutf_warn_unused size_t convert_latin1_to_utf16le(const char* input, size_t length, char16_t* utf16_output) noexcept +{ + return get_active_implementation()->convert_latin1_to_utf16le(input, length, utf16_output); } -simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * input, size_t length, char32_t* utf32_output) noexcept { - return get_active_implementation()->convert_utf8_to_utf32_with_errors(input, length, utf32_output); +simdutf_warn_unused size_t convert_latin1_to_utf16be(const char* input, size_t length, char16_t* utf16_output) noexcept +{ + return get_active_implementation()->convert_latin1_to_utf16be(input, length, utf16_output); } -simdutf_warn_unused bool validate_utf16(const char16_t * buf, size_t len) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return validate_utf16be(buf, len); - #else - return validate_utf16le(buf, len); - #endif +simdutf_warn_unused size_t convert_utf8_to_utf32(const char* input, size_t length, char32_t* utf32_output) noexcept +{ + return get_active_implementation()->convert_utf8_to_utf32(input, length, utf32_output); } -simdutf_warn_unused bool validate_utf16le(const char16_t * buf, size_t len) noexcept { - return get_active_implementation()->validate_utf16le(buf, len); +simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* input, size_t length, char32_t* utf32_output) noexcept +{ + return get_active_implementation()->convert_utf8_to_utf32_with_errors(input, length, utf32_output); } -simdutf_warn_unused bool validate_utf16be(const char16_t * buf, size_t len) noexcept { - return get_active_implementation()->validate_utf16be(buf, len); +simdutf_warn_unused bool validate_utf16(const char16_t* buf, size_t len) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return validate_utf16be(buf, len); +#else + return validate_utf16le(buf, len); +#endif } -simdutf_warn_unused result validate_utf16_with_errors(const char16_t * buf, size_t len) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return validate_utf16be_with_errors(buf, len); - #else - return validate_utf16le_with_errors(buf, len); - #endif +simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_utf16le(buf, len); } -simdutf_warn_unused result validate_utf16le_with_errors(const char16_t * buf, size_t len) noexcept { - return get_active_implementation()->validate_utf16le_with_errors(buf, len); +simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_utf16be(buf, len); } -simdutf_warn_unused result validate_utf16be_with_errors(const char16_t * buf, size_t len) noexcept { - return get_active_implementation()->validate_utf16be_with_errors(buf, len); +simdutf_warn_unused result validate_utf16_with_errors(const char16_t* buf, size_t len) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return validate_utf16be_with_errors(buf, len); +#else + return validate_utf16le_with_errors(buf, len); +#endif } -simdutf_warn_unused bool validate_utf32(const char32_t * buf, size_t len) noexcept { - return get_active_implementation()->validate_utf32(buf, len); +simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_utf16le_with_errors(buf, len); } -simdutf_warn_unused result validate_utf32_with_errors(const char32_t * buf, size_t len) noexcept { - return get_active_implementation()->validate_utf32_with_errors(buf, len); +simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_utf16be_with_errors(buf, len); } -simdutf_warn_unused size_t convert_valid_utf8_to_utf16(const char * input, size_t length, char16_t* utf16_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_valid_utf8_to_utf16be(input, length, utf16_buffer); - #else - return convert_valid_utf8_to_utf16le(input, length, utf16_buffer); - #endif +simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_utf32(buf, len); } -simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * input, size_t length, char16_t* utf16_buffer) noexcept { - return get_active_implementation()->convert_valid_utf8_to_utf16le(input, length, utf16_buffer); +simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) noexcept +{ + return get_active_implementation()->validate_utf32_with_errors(buf, len); } -simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * input, size_t length, char16_t* utf16_buffer) noexcept { - return get_active_implementation()->convert_valid_utf8_to_utf16be(input, length, utf16_buffer); +simdutf_warn_unused size_t convert_valid_utf8_to_utf16(const char* input, size_t length, char16_t* utf16_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_valid_utf8_to_utf16be(input, length, utf16_buffer); +#else + return convert_valid_utf8_to_utf16le(input, length, utf16_buffer); +#endif } -simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * input, size_t length, char32_t* utf32_buffer) noexcept { - return get_active_implementation()->convert_valid_utf8_to_utf32(input, length, utf32_buffer); +simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* input, size_t length, char16_t* utf16_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf8_to_utf16le(input, length, utf16_buffer); } -simdutf_warn_unused size_t convert_utf16_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_utf16be_to_utf8(buf, len, utf8_buffer); - #else - return convert_utf16le_to_utf8(buf, len, utf8_buffer); - #endif +simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* input, size_t length, char16_t* utf16_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf8_to_utf16be(input, length, utf16_buffer); } -simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_utf16le_to_utf8(buf, len, utf8_buffer); +simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* input, size_t length, char32_t* utf32_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf8_to_utf32(input, length, utf32_buffer); } -simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_utf16be_to_utf8(buf, len, utf8_buffer); +simdutf_warn_unused size_t convert_utf16_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_utf16be_to_utf8(buf, len, utf8_buffer); +#else + return convert_utf16le_to_utf8(buf, len, utf8_buffer); +#endif } -simdutf_warn_unused result convert_utf16_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_utf16be_to_utf8_with_errors(buf, len, utf8_buffer); - #else - return convert_utf16le_to_utf8_with_errors(buf, len, utf8_buffer); - #endif -} -simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_utf16le_to_utf8_with_errors(buf, len, utf8_buffer); -} -simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_utf16be_to_utf8_with_errors(buf, len, utf8_buffer); +simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) noexcept +{ + return get_active_implementation()->convert_utf16be_to_latin1(buf, len, latin1_buffer); } -simdutf_warn_unused size_t convert_valid_utf16_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - #if BIG_ENDIAN - return convert_valid_utf16be_to_utf8(buf, len, utf8_buffer); - #else - return convert_valid_utf16le_to_utf8(buf, len, utf8_buffer); - #endif -} -simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_valid_utf16le_to_utf8(buf, len, utf8_buffer); -} -simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_valid_utf16be_to_utf8(buf, len, utf8_buffer); +simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_buffer) noexcept +{ + return get_active_implementation()->convert_utf16le_to_latin1(buf, len, latin1_buffer); } -simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_utf32_to_utf8(buf, len, utf8_buffer); +simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) noexcept +{ + return get_active_implementation()->convert_utf16le_to_latin1_with_errors(buf, len, latin1_buffer); } -simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_utf32_to_utf8_with_errors(buf, len, utf8_buffer); +simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_buffer) noexcept +{ + return get_active_implementation()->convert_utf16be_to_latin1_with_errors(buf, len, latin1_buffer); } -simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * buf, size_t len, char* utf8_buffer) noexcept { - return get_active_implementation()->convert_valid_utf32_to_utf8(buf, len, utf8_buffer); -} -simdutf_warn_unused size_t convert_utf32_to_utf16(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_utf32_to_utf16be(buf, len, utf16_buffer); - #else - return convert_utf32_to_utf16le(buf, len, utf16_buffer); - #endif -} -simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - return get_active_implementation()->convert_utf32_to_utf16le(buf, len, utf16_buffer); +simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_utf16le_to_utf8(buf, len, utf8_buffer); } -simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - return get_active_implementation()->convert_utf32_to_utf16be(buf, len, utf16_buffer); -} -simdutf_warn_unused result convert_utf32_to_utf16_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_utf32_to_utf16be_with_errors(buf, len, utf16_buffer); - #else - return convert_utf32_to_utf16le_with_errors(buf, len, utf16_buffer); - #endif -} -simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - return get_active_implementation()->convert_utf32_to_utf16le_with_errors(buf, len, utf16_buffer); +simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_utf16be_to_utf8(buf, len, utf8_buffer); } -simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - return get_active_implementation()->convert_utf32_to_utf16be_with_errors(buf, len, utf16_buffer); +simdutf_warn_unused result convert_utf16_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_utf16be_to_utf8_with_errors(buf, len, utf8_buffer); +#else + return convert_utf16le_to_utf8_with_errors(buf, len, utf8_buffer); +#endif } -simdutf_warn_unused size_t convert_valid_utf32_to_utf16(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_valid_utf32_to_utf16be(buf, len, utf16_buffer); - #else - return convert_valid_utf32_to_utf16le(buf, len, utf16_buffer); - #endif +simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_utf16le_to_utf8_with_errors(buf, len, utf8_buffer); } -simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - return get_active_implementation()->convert_valid_utf32_to_utf16le(buf, len, utf16_buffer); +simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_utf16be_to_utf8_with_errors(buf, len, utf8_buffer); } -simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * buf, size_t len, char16_t* utf16_buffer) noexcept { - return get_active_implementation()->convert_valid_utf32_to_utf16be(buf, len, utf16_buffer); +simdutf_warn_unused size_t convert_valid_utf16_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_valid_utf16be_to_utf8(buf, len, utf8_buffer); +#else + return convert_valid_utf16le_to_utf8(buf, len, utf8_buffer); +#endif } -simdutf_warn_unused size_t convert_utf16_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_utf16be_to_utf32(buf, len, utf32_buffer); - #else - return convert_utf16le_to_utf32(buf, len, utf32_buffer); - #endif +simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf16le_to_utf8(buf, len, utf8_buffer); } -simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - return get_active_implementation()->convert_utf16le_to_utf32(buf, len, utf32_buffer); +simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf16be_to_utf8(buf, len, utf8_buffer); } -simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - return get_active_implementation()->convert_utf16be_to_utf32(buf, len, utf32_buffer); +simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_utf32_to_utf8(buf, len, utf8_buffer); } -simdutf_warn_unused result convert_utf16_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_utf16be_to_utf32_with_errors(buf, len, utf32_buffer); - #else - return convert_utf16le_to_utf32_with_errors(buf, len, utf32_buffer); - #endif +simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_utf32_to_utf8_with_errors(buf, len, utf8_buffer); } -simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - return get_active_implementation()->convert_utf16le_to_utf32_with_errors(buf, len, utf32_buffer); +simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf32_to_utf8(buf, len, utf8_buffer); } -simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - return get_active_implementation()->convert_utf16be_to_utf32_with_errors(buf, len, utf32_buffer); +simdutf_warn_unused size_t convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_utf32_to_utf16be(buf, len, utf16_buffer); +#else + return convert_utf32_to_utf16le(buf, len, utf16_buffer); +#endif +} +simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t* input, size_t length, char* latin1_output) noexcept +{ + return get_active_implementation()->convert_utf32_to_latin1(input, length, latin1_output); +} +simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ + return get_active_implementation()->convert_utf32_to_utf16le(buf, len, utf16_buffer); +} +simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ + return get_active_implementation()->convert_utf32_to_utf16be(buf, len, utf16_buffer); +} +simdutf_warn_unused result convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_utf32_to_utf16be_with_errors(buf, len, utf16_buffer); +#else + return convert_utf32_to_utf16le_with_errors(buf, len, utf16_buffer); +#endif } -simdutf_warn_unused size_t convert_valid_utf16_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return convert_valid_utf16be_to_utf32(buf, len, utf32_buffer); - #else - return convert_valid_utf16le_to_utf32(buf, len, utf32_buffer); - #endif +simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ + return get_active_implementation()->convert_utf32_to_utf16le_with_errors(buf, len, utf16_buffer); } -simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - return get_active_implementation()->convert_valid_utf16le_to_utf32(buf, len, utf32_buffer); +simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ + return get_active_implementation()->convert_utf32_to_utf16be_with_errors(buf, len, utf16_buffer); +} +simdutf_warn_unused size_t convert_valid_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_valid_utf32_to_utf16be(buf, len, utf16_buffer); +#else + return convert_valid_utf32_to_utf16le(buf, len, utf16_buffer); +#endif } -simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * buf, size_t len, char32_t* utf32_buffer) noexcept { - return get_active_implementation()->convert_valid_utf16be_to_utf32(buf, len, utf32_buffer); +simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf32_to_utf16le(buf, len, utf16_buffer); } -void change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) noexcept { - get_active_implementation()->change_endianness_utf16(input, length, output); +simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf32_to_utf16be(buf, len, utf16_buffer); } -simdutf_warn_unused size_t count_utf16(const char16_t * input, size_t length) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return count_utf16be(input, length); - #else - return count_utf16le(input, length); - #endif +simdutf_warn_unused size_t convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_utf16be_to_utf32(buf, len, utf32_buffer); +#else + return convert_utf16le_to_utf32(buf, len, utf32_buffer); +#endif } -simdutf_warn_unused size_t count_utf16le(const char16_t * input, size_t length) noexcept { - return get_active_implementation()->count_utf16le(input, length); +simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ + return get_active_implementation()->convert_utf16le_to_utf32(buf, len, utf32_buffer); } -simdutf_warn_unused size_t count_utf16be(const char16_t * input, size_t length) noexcept { - return get_active_implementation()->count_utf16be(input, length); +simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ + return get_active_implementation()->convert_utf16be_to_utf32(buf, len, utf32_buffer); } -simdutf_warn_unused size_t count_utf8(const char * input, size_t length) noexcept { - return get_active_implementation()->count_utf8(input, length); +simdutf_warn_unused result convert_utf16_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_utf16be_to_utf32_with_errors(buf, len, utf32_buffer); +#else + return convert_utf16le_to_utf32_with_errors(buf, len, utf32_buffer); +#endif } -simdutf_warn_unused size_t utf8_length_from_utf16(const char16_t * input, size_t length) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return utf8_length_from_utf16be(input, length); - #else - return utf8_length_from_utf16le(input, length); - #endif +simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ + return get_active_implementation()->convert_utf16le_to_utf32_with_errors(buf, len, utf32_buffer); } -simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size_t length) noexcept { - return get_active_implementation()->utf8_length_from_utf16le(input, length); +simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ + return get_active_implementation()->convert_utf16be_to_utf32_with_errors(buf, len, utf32_buffer); } -simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size_t length) noexcept { - return get_active_implementation()->utf8_length_from_utf16be(input, length); +simdutf_warn_unused size_t convert_valid_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return convert_valid_utf16be_to_utf32(buf, len, utf32_buffer); +#else + return convert_valid_utf16le_to_utf32(buf, len, utf32_buffer); +#endif } -simdutf_warn_unused size_t utf32_length_from_utf16(const char16_t * input, size_t length) noexcept { - #if SIMDUTF_IS_BIG_ENDIAN - return utf32_length_from_utf16be(input, length); - #else - return utf32_length_from_utf16le(input, length); - #endif +simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf16le_to_utf32(buf, len, utf32_buffer); } -simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, size_t length) noexcept { - return get_active_implementation()->utf32_length_from_utf16le(input, length); +simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_buffer) noexcept +{ + return get_active_implementation()->convert_valid_utf16be_to_utf32(buf, len, utf32_buffer); } -simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, size_t length) noexcept { - return get_active_implementation()->utf32_length_from_utf16be(input, length); +void change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) noexcept +{ + get_active_implementation()->change_endianness_utf16(input, length, output); } -simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t length) noexcept { - return get_active_implementation()->utf16_length_from_utf8(input, length); +simdutf_warn_unused size_t count_utf16(const char16_t* input, size_t length) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return count_utf16be(input, length); +#else + return count_utf16le(input, length); +#endif +} +simdutf_warn_unused size_t count_utf16le(const char16_t* input, size_t length) noexcept +{ + return get_active_implementation()->count_utf16le(input, length); +} +simdutf_warn_unused size_t count_utf16be(const char16_t* input, size_t length) noexcept +{ + return get_active_implementation()->count_utf16be(input, length); +} +simdutf_warn_unused size_t count_utf8(const char* input, size_t length) noexcept +{ + return get_active_implementation()->count_utf8(input, length); +} +simdutf_warn_unused size_t utf8_length_from_utf16(const char16_t* input, size_t length) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return utf8_length_from_utf16be(input, length); +#else + return utf8_length_from_utf16le(input, length); +#endif +} +simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* input, size_t length) noexcept +{ + return get_active_implementation()->utf8_length_from_utf16le(input, length); +} +simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* input, size_t length) noexcept +{ + return get_active_implementation()->utf8_length_from_utf16be(input, length); +} +simdutf_warn_unused size_t utf32_length_from_utf16(const char16_t* input, size_t length) noexcept +{ +#if SIMDUTF_IS_BIG_ENDIAN + return utf32_length_from_utf16be(input, length); +#else + return utf32_length_from_utf16le(input, length); +#endif +} +simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* input, size_t length) noexcept +{ + return get_active_implementation()->utf32_length_from_utf16le(input, length); +} +simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* input, size_t length) noexcept +{ + return get_active_implementation()->utf32_length_from_utf16be(input, length); +} +simdutf_warn_unused size_t utf16_length_from_utf8(const char* input, size_t length) noexcept +{ + return get_active_implementation()->utf16_length_from_utf8(input, length); +} +simdutf_warn_unused size_t utf16_length_from_latin1(size_t length) noexcept +{ + return get_active_implementation()->utf16_length_from_latin1(length); +} +simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* input, size_t length) noexcept +{ + return get_active_implementation()->utf8_length_from_utf32(input, length); +} +simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* input, size_t length) noexcept +{ + return get_active_implementation()->utf16_length_from_utf32(input, length); +} +simdutf_warn_unused size_t utf32_length_from_utf8(const char* input, size_t length) noexcept +{ + return get_active_implementation()->utf32_length_from_utf8(input, length); +} +simdutf_warn_unused simdutf::encoding_type autodetect_encoding(const char* buf, size_t length) noexcept +{ + return get_active_implementation()->autodetect_encoding(buf, length); +} +simdutf_warn_unused int detect_encodings(const char* buf, size_t length) noexcept +{ + return get_active_implementation()->detect_encodings(buf, length); +} + +const implementation* builtin_implementation() +{ + static const implementation* builtin_impl = get_available_implementations()[SIMDUTF_STRINGIFY(SIMDUTF_BUILTIN_IMPLEMENTATION)]; + return builtin_impl; +} + +} // namespace simdutf + +/* end file src/implementation.cpp */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=encoding_types.cpp +/* begin file src/encoding_types.cpp */ + +namespace simdutf { +bool match_system(endianness e) +{ +#if SIMDUTF_IS_BIG_ENDIAN + return e == endianness::BIG; +#else + return e == endianness::LITTLE; +#endif +} + +std::string to_string(encoding_type bom) +{ + switch (bom) { + case UTF16_LE: + return "UTF16 little-endian"; + case UTF16_BE: + return "UTF16 big-endian"; + case UTF32_LE: + return "UTF32 little-endian"; + case UTF32_BE: + return "UTF32 big-endian"; + case UTF8: + return "UTF8"; + case unspecified: + return "unknown"; + default: + return "error"; + } +} + +namespace BOM { +// Note that BOM for UTF8 is discouraged. +encoding_type check_bom(const uint8_t* byte, size_t length) +{ + if (length >= 2 && byte[0] == 0xff and byte[1] == 0xfe) { + if (length >= 4 && byte[2] == 0x00 and byte[3] == 0x0) { + return encoding_type::UTF32_LE; + } else { + return encoding_type::UTF16_LE; + } + } else if (length >= 2 && byte[0] == 0xfe and byte[1] == 0xff) { + return encoding_type::UTF16_BE; + } else if (length >= 4 && byte[0] == 0x00 and byte[1] == 0x00 and byte[2] == 0xfe and byte[3] == 0xff) { + return encoding_type::UTF32_BE; + } else if (length >= 4 && byte[0] == 0xef and byte[1] == 0xbb and byte[3] == 0xbf) { + return encoding_type::UTF8; + } + return encoding_type::unspecified; +} + +encoding_type check_bom(const char* byte, size_t length) +{ + return check_bom(reinterpret_cast(byte), length); +} + +size_t bom_byte_size(encoding_type bom) +{ + switch (bom) { + case UTF16_LE: + return 2; + case UTF16_BE: + return 2; + case UTF32_LE: + return 4; + case UTF32_BE: + return 4; + case UTF8: + return 3; + case unspecified: + return 0; + default: + return 0; + } +} + +} +} +/* end file src/encoding_types.cpp */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=error.cpp +/* begin file src/error.cpp */ +namespace simdutf { + +simdutf_really_inline result::result() + : error { error_code::SUCCESS } + , count { 0 } {}; + +simdutf_really_inline result::result(error_code _err, size_t _pos) + : error { _err } + , count { _pos } {}; + +} +/* end file src/error.cpp */ +// The large tables should be included once and they +// should not depend on a kernel. +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=tables/utf8_to_utf16_tables.h +/* begin file src/tables/utf8_to_utf16_tables.h */ +#ifndef SIMDUTF_UTF8_TO_UTF16_TABLES_H +#define SIMDUTF_UTF8_TO_UTF16_TABLES_H +#include + +namespace simdutf { +namespace { +namespace tables { +namespace utf8_to_utf16 { +/** + * utf8bigindex uses about 8 kB + * shufutf8 uses about 3344 B + * + * So we use a bit over 11 kB. It would be + * easy to save about 4 kB by only + * storing the index in utf8bigindex, and + * deriving the consumed bytes otherwise. + * However, this may come at a significant (10% to 20%) + * performance penalty. + */ + +const uint8_t shufutf8[209][16] = { { 0, 255, 1, 255, 2, 255, 3, 255, 4, 255, 5, 255, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 2, 255, 3, 255, 4, 255, 6, 5, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 2, 255, 3, 255, 5, 4, 6, 255, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 2, 255, 3, 255, 5, 4, 7, 6, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 2, 255, 4, 3, 5, 255, 6, 255, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 2, 255, 4, 3, 5, 255, 7, 6, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 2, 255, 4, 3, 6, 5, 7, 255, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 2, 255, 4, 3, 6, 5, 8, 7, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 3, 2, 4, 255, 5, 255, 6, 255, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 3, 2, 4, 255, 5, 255, 7, 6, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 3, 2, 4, 255, 6, 5, 7, 255, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 3, 2, 4, 255, 6, 5, 8, 7, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 3, 2, 5, 4, 6, 255, 7, 255, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 3, 2, 5, 4, 6, 255, 8, 7, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 3, 2, 5, 4, 7, 6, 8, 255, 0, 0, 0, 0 }, + { 0, 255, 1, 255, 3, 2, 5, 4, 7, 6, 9, 8, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 3, 255, 4, 255, 5, 255, 6, 255, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 3, 255, 4, 255, 5, 255, 7, 6, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 3, 255, 4, 255, 6, 5, 7, 255, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 3, 255, 4, 255, 6, 5, 8, 7, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 3, 255, 5, 4, 6, 255, 7, 255, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 3, 255, 5, 4, 6, 255, 8, 7, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 3, 255, 5, 4, 7, 6, 8, 255, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 3, 255, 5, 4, 7, 6, 9, 8, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 4, 3, 5, 255, 6, 255, 7, 255, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 4, 3, 5, 255, 6, 255, 8, 7, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 4, 3, 5, 255, 7, 6, 8, 255, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 4, 3, 5, 255, 7, 6, 9, 8, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 4, 3, 6, 5, 7, 255, 8, 255, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 4, 3, 6, 5, 7, 255, 9, 8, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 4, 3, 6, 5, 8, 7, 9, 255, 0, 0, 0, 0 }, + { 0, 255, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 3, 255, 4, 255, 5, 255, 6, 255, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 3, 255, 4, 255, 5, 255, 7, 6, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 3, 255, 4, 255, 6, 5, 7, 255, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 3, 255, 4, 255, 6, 5, 8, 7, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 3, 255, 5, 4, 6, 255, 7, 255, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 3, 255, 5, 4, 6, 255, 8, 7, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 3, 255, 5, 4, 7, 6, 8, 255, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 3, 255, 5, 4, 7, 6, 9, 8, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 4, 3, 5, 255, 6, 255, 7, 255, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 4, 3, 5, 255, 6, 255, 8, 7, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 4, 3, 5, 255, 7, 6, 8, 255, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 4, 3, 5, 255, 7, 6, 9, 8, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 4, 3, 6, 5, 7, 255, 8, 255, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 4, 3, 6, 5, 7, 255, 9, 8, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 4, 3, 6, 5, 8, 7, 9, 255, 0, 0, 0, 0 }, + { 1, 0, 2, 255, 4, 3, 6, 5, 8, 7, 10, 9, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 4, 255, 5, 255, 6, 255, 7, 255, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 4, 255, 5, 255, 6, 255, 8, 7, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 4, 255, 5, 255, 7, 6, 8, 255, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 4, 255, 5, 255, 7, 6, 9, 8, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 4, 255, 6, 5, 7, 255, 8, 255, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 4, 255, 6, 5, 7, 255, 9, 8, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 4, 255, 6, 5, 8, 7, 9, 255, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 4, 255, 6, 5, 8, 7, 10, 9, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 5, 4, 6, 255, 7, 255, 8, 255, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 5, 4, 6, 255, 7, 255, 9, 8, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 5, 4, 6, 255, 8, 7, 9, 255, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 5, 4, 6, 255, 8, 7, 10, 9, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 5, 4, 7, 6, 8, 255, 9, 255, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 5, 4, 7, 6, 8, 255, 10, 9, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 255, 0, 0, 0, 0 }, + { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 3, 255, 255, 255, 4, 255, 255, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 3, 255, 255, 255, 5, 4, 255, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 3, 255, 255, 255, 6, 5, 4, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 4, 3, 255, 255, 5, 255, 255, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 4, 3, 255, 255, 6, 5, 255, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 4, 3, 255, 255, 7, 6, 5, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 5, 4, 3, 255, 6, 255, 255, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 5, 4, 3, 255, 7, 6, 255, 255 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 5, 4, 3, 255, 8, 7, 6, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 4, 255, 255, 255, 5, 255, 255, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 4, 255, 255, 255, 6, 5, 255, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 4, 255, 255, 255, 7, 6, 5, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 5, 4, 255, 255, 6, 255, 255, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 5, 4, 255, 255, 7, 6, 255, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 5, 4, 255, 255, 8, 7, 6, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 6, 5, 4, 255, 7, 255, 255, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 6, 5, 4, 255, 8, 7, 255, 255 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 6, 5, 4, 255, 9, 8, 7, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255, 4, 255, 255, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255, 5, 4, 255, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255, 6, 5, 4, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255, 5, 255, 255, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255, 6, 5, 255, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255, 7, 6, 5, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255, 6, 255, 255, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255, 7, 6, 255, 255 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255, 8, 7, 6, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255, 5, 255, 255, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255, 6, 5, 255, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255, 7, 6, 5, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255, 6, 255, 255, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255, 7, 6, 255, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255, 8, 7, 6, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255, 7, 255, 255, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255, 8, 7, 255, 255 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255, 9, 8, 7, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255, 6, 255, 255, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255, 7, 6, 255, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255, 8, 7, 6, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255, 7, 255, 255, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255, 8, 7, 255, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255, 9, 8, 7, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255, 8, 255, 255, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255, 9, 8, 255, 255 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255, 10, 9, 8, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 4, 255, 255, 255, 5, 255, 255, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 4, 255, 255, 255, 6, 5, 255, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 4, 255, 255, 255, 7, 6, 5, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 5, 4, 255, 255, 6, 255, 255, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 5, 4, 255, 255, 7, 6, 255, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 5, 4, 255, 255, 8, 7, 6, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 6, 5, 4, 255, 7, 255, 255, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 6, 5, 4, 255, 8, 7, 255, 255 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 6, 5, 4, 255, 9, 8, 7, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 5, 255, 255, 255, 6, 255, 255, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 5, 255, 255, 255, 7, 6, 255, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 5, 255, 255, 255, 8, 7, 6, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 6, 5, 255, 255, 7, 255, 255, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 6, 5, 255, 255, 8, 7, 255, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 6, 5, 255, 255, 9, 8, 7, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 7, 6, 5, 255, 8, 255, 255, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 7, 6, 5, 255, 9, 8, 255, 255 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 7, 6, 5, 255, 10, 9, 8, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 6, 255, 255, 255, 7, 255, 255, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 6, 255, 255, 255, 8, 7, 255, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 6, 255, 255, 255, 9, 8, 7, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 7, 6, 255, 255, 8, 255, 255, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 7, 6, 255, 255, 9, 8, 255, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 7, 6, 255, 255, 10, 9, 8, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 9, 255, 255, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 10, 9, 255, 255 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 2, 255, 255, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 3, 2, 255, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 4, 3, 2, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 1, 255, 255, 255, 5, 4, 3, 2, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 3, 255, 255, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 4, 3, 255, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 5, 4, 3, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 2, 1, 255, 255, 6, 5, 4, 3, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 4, 255, 255, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 5, 4, 255, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 6, 5, 4, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 3, 2, 1, 255, 7, 6, 5, 4, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 4, 3, 2, 1, 5, 255, 255, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 4, 3, 2, 1, 6, 5, 255, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 4, 3, 2, 1, 7, 6, 5, 255, 0, 0, 0, 0 }, + { 0, 255, 255, 255, 4, 3, 2, 1, 8, 7, 6, 5, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 2, 255, 255, 255, 6, 5, 4, 3, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 3, 2, 255, 255, 7, 6, 5, 4, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 4, 3, 2, 255, 8, 7, 6, 5, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 5, 4, 3, 2, 6, 255, 255, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 5, 4, 3, 2, 7, 6, 255, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 5, 4, 3, 2, 8, 7, 6, 255, 0, 0, 0, 0 }, + { 1, 0, 255, 255, 5, 4, 3, 2, 9, 8, 7, 6, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 4, 255, 255, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 5, 4, 255, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 6, 5, 4, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 3, 255, 255, 255, 7, 6, 5, 4, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 5, 255, 255, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 6, 5, 255, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 7, 6, 5, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 4, 3, 255, 255, 8, 7, 6, 5, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 6, 255, 255, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 7, 6, 255, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 5, 4, 3, 255, 9, 8, 7, 6, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 6, 5, 4, 3, 7, 255, 255, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 6, 5, 4, 3, 8, 7, 255, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 6, 5, 4, 3, 9, 8, 7, 255, 0, 0, 0, 0 }, + { 2, 1, 0, 255, 6, 5, 4, 3, 10, 9, 8, 7, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 4, 255, 255, 255, 5, 255, 255, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 4, 255, 255, 255, 6, 5, 255, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 4, 255, 255, 255, 7, 6, 5, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 4, 255, 255, 255, 8, 7, 6, 5, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 5, 4, 255, 255, 6, 255, 255, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 5, 4, 255, 255, 7, 6, 255, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 5, 4, 255, 255, 8, 7, 6, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 5, 4, 255, 255, 9, 8, 7, 6, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 6, 5, 4, 255, 7, 255, 255, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 6, 5, 4, 255, 8, 7, 255, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 6, 5, 4, 255, 9, 8, 7, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 6, 5, 4, 255, 10, 9, 8, 7, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 7, 6, 5, 4, 8, 255, 255, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 7, 6, 5, 4, 9, 8, 255, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 7, 6, 5, 4, 10, 9, 8, 255, 0, 0, 0, 0 }, + { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 0, 0, 0, 0 } }; +/* number of two bytes : 64 */ +/* number of two + three bytes : 145 */ +/* number of two + three + four bytes : 209 */ +const uint8_t utf8bigindex[4096][2] = { { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 147, 5 }, + { 209, 12 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 209, 12 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 148, 6 }, + { 209, 12 }, + { 151, 6 }, + { 163, 6 }, + { 66, 6 }, + { 209, 12 }, + { 154, 6 }, + { 166, 6 }, + { 68, 6 }, + { 178, 6 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 169, 6 }, + { 70, 6 }, + { 181, 6 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 209, 12 }, + { 155, 7 }, + { 167, 7 }, + { 69, 7 }, + { 179, 7 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 170, 7 }, + { 71, 7 }, + { 182, 7 }, + { 77, 7 }, + { 95, 7 }, + { 65, 5 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 67, 5 }, + { 119, 7 }, + { 73, 5 }, + { 91, 5 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 185, 7 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 68, 6 }, + { 121, 7 }, + { 74, 6 }, + { 92, 6 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 76, 6 }, + { 94, 6 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 171, 8 }, + { 72, 8 }, + { 183, 8 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 186, 8 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 104, 8 }, + { 68, 6 }, + { 122, 8 }, + { 74, 6 }, + { 92, 6 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 76, 6 }, + { 94, 6 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 77, 7 }, + { 95, 7 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 160, 9 }, + { 172, 9 }, + { 147, 5 }, + { 184, 9 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 196, 9 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 175, 9 }, + { 148, 6 }, + { 187, 9 }, + { 81, 9 }, + { 99, 9 }, + { 66, 6 }, + { 199, 9 }, + { 87, 9 }, + { 105, 9 }, + { 68, 6 }, + { 123, 9 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 111, 9 }, + { 70, 6 }, + { 129, 9 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 190, 9 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 202, 9 }, + { 89, 9 }, + { 107, 9 }, + { 69, 7 }, + { 125, 9 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 113, 9 }, + { 71, 7 }, + { 131, 9 }, + { 77, 7 }, + { 95, 7 }, + { 7, 9 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 11, 9 }, + { 119, 7 }, + { 19, 9 }, + { 35, 9 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 137, 9 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 13, 9 }, + { 121, 7 }, + { 21, 9 }, + { 37, 9 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 25, 9 }, + { 41, 9 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 49, 9 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 205, 9 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 115, 9 }, + { 72, 8 }, + { 133, 9 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 139, 9 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 104, 8 }, + { 14, 9 }, + { 122, 8 }, + { 22, 9 }, + { 38, 9 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 26, 9 }, + { 42, 9 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 50, 9 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 28, 9 }, + { 44, 9 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 52, 9 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 56, 9 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 147, 5 }, + { 209, 12 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 209, 12 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 176, 10 }, + { 148, 6 }, + { 188, 10 }, + { 151, 6 }, + { 163, 6 }, + { 66, 6 }, + { 200, 10 }, + { 154, 6 }, + { 166, 6 }, + { 68, 6 }, + { 178, 6 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 169, 6 }, + { 70, 6 }, + { 181, 6 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 191, 10 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 203, 10 }, + { 90, 10 }, + { 108, 10 }, + { 69, 7 }, + { 126, 10 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 114, 10 }, + { 71, 7 }, + { 132, 10 }, + { 77, 7 }, + { 95, 7 }, + { 65, 5 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 67, 5 }, + { 119, 7 }, + { 73, 5 }, + { 91, 5 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 138, 10 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 68, 6 }, + { 121, 7 }, + { 74, 6 }, + { 92, 6 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 76, 6 }, + { 94, 6 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 206, 10 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 116, 10 }, + { 72, 8 }, + { 134, 10 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 140, 10 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 104, 8 }, + { 15, 10 }, + { 122, 8 }, + { 23, 10 }, + { 39, 10 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 27, 10 }, + { 43, 10 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 51, 10 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 29, 10 }, + { 45, 10 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 53, 10 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 57, 10 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 160, 9 }, + { 172, 9 }, + { 147, 5 }, + { 184, 9 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 196, 9 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 175, 9 }, + { 148, 6 }, + { 142, 10 }, + { 81, 9 }, + { 99, 9 }, + { 66, 6 }, + { 199, 9 }, + { 87, 9 }, + { 105, 9 }, + { 68, 6 }, + { 123, 9 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 111, 9 }, + { 70, 6 }, + { 129, 9 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 190, 9 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 202, 9 }, + { 89, 9 }, + { 107, 9 }, + { 69, 7 }, + { 125, 9 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 113, 9 }, + { 71, 7 }, + { 131, 9 }, + { 30, 10 }, + { 46, 10 }, + { 7, 9 }, + { 194, 7 }, + { 83, 7 }, + { 54, 10 }, + { 11, 9 }, + { 119, 7 }, + { 19, 9 }, + { 35, 9 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 137, 9 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 58, 10 }, + { 13, 9 }, + { 121, 7 }, + { 21, 9 }, + { 37, 9 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 25, 9 }, + { 41, 9 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 49, 9 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 205, 9 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 115, 9 }, + { 72, 8 }, + { 133, 9 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 139, 9 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 60, 10 }, + { 14, 9 }, + { 122, 8 }, + { 22, 9 }, + { 38, 9 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 26, 9 }, + { 42, 9 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 50, 9 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 28, 9 }, + { 44, 9 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 52, 9 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 56, 9 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 147, 5 }, + { 209, 12 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 209, 12 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 148, 6 }, + { 209, 12 }, + { 151, 6 }, + { 163, 6 }, + { 66, 6 }, + { 209, 12 }, + { 154, 6 }, + { 166, 6 }, + { 68, 6 }, + { 178, 6 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 169, 6 }, + { 70, 6 }, + { 181, 6 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 192, 11 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 204, 11 }, + { 155, 7 }, + { 167, 7 }, + { 69, 7 }, + { 179, 7 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 170, 7 }, + { 71, 7 }, + { 182, 7 }, + { 77, 7 }, + { 95, 7 }, + { 65, 5 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 67, 5 }, + { 119, 7 }, + { 73, 5 }, + { 91, 5 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 185, 7 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 68, 6 }, + { 121, 7 }, + { 74, 6 }, + { 92, 6 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 76, 6 }, + { 94, 6 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 207, 11 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 117, 11 }, + { 72, 8 }, + { 135, 11 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 141, 11 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 104, 8 }, + { 68, 6 }, + { 122, 8 }, + { 74, 6 }, + { 92, 6 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 76, 6 }, + { 94, 6 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 77, 7 }, + { 95, 7 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 160, 9 }, + { 172, 9 }, + { 147, 5 }, + { 184, 9 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 196, 9 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 175, 9 }, + { 148, 6 }, + { 143, 11 }, + { 81, 9 }, + { 99, 9 }, + { 66, 6 }, + { 199, 9 }, + { 87, 9 }, + { 105, 9 }, + { 68, 6 }, + { 123, 9 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 111, 9 }, + { 70, 6 }, + { 129, 9 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 190, 9 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 202, 9 }, + { 89, 9 }, + { 107, 9 }, + { 69, 7 }, + { 125, 9 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 113, 9 }, + { 71, 7 }, + { 131, 9 }, + { 31, 11 }, + { 47, 11 }, + { 7, 9 }, + { 194, 7 }, + { 83, 7 }, + { 55, 11 }, + { 11, 9 }, + { 119, 7 }, + { 19, 9 }, + { 35, 9 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 137, 9 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 59, 11 }, + { 13, 9 }, + { 121, 7 }, + { 21, 9 }, + { 37, 9 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 25, 9 }, + { 41, 9 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 49, 9 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 205, 9 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 115, 9 }, + { 72, 8 }, + { 133, 9 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 139, 9 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 61, 11 }, + { 14, 9 }, + { 122, 8 }, + { 22, 9 }, + { 38, 9 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 26, 9 }, + { 42, 9 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 50, 9 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 28, 9 }, + { 44, 9 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 52, 9 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 56, 9 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 147, 5 }, + { 209, 12 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 209, 12 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 176, 10 }, + { 148, 6 }, + { 188, 10 }, + { 151, 6 }, + { 163, 6 }, + { 66, 6 }, + { 200, 10 }, + { 154, 6 }, + { 166, 6 }, + { 68, 6 }, + { 178, 6 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 169, 6 }, + { 70, 6 }, + { 181, 6 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 191, 10 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 203, 10 }, + { 90, 10 }, + { 108, 10 }, + { 69, 7 }, + { 126, 10 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 114, 10 }, + { 71, 7 }, + { 132, 10 }, + { 77, 7 }, + { 95, 7 }, + { 65, 5 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 67, 5 }, + { 119, 7 }, + { 73, 5 }, + { 91, 5 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 138, 10 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 68, 6 }, + { 121, 7 }, + { 74, 6 }, + { 92, 6 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 76, 6 }, + { 94, 6 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 206, 10 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 116, 10 }, + { 72, 8 }, + { 134, 10 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 140, 10 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 62, 11 }, + { 15, 10 }, + { 122, 8 }, + { 23, 10 }, + { 39, 10 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 27, 10 }, + { 43, 10 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 51, 10 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 29, 10 }, + { 45, 10 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 53, 10 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 57, 10 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 160, 9 }, + { 172, 9 }, + { 147, 5 }, + { 184, 9 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 196, 9 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 175, 9 }, + { 148, 6 }, + { 142, 10 }, + { 81, 9 }, + { 99, 9 }, + { 66, 6 }, + { 199, 9 }, + { 87, 9 }, + { 105, 9 }, + { 68, 6 }, + { 123, 9 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 111, 9 }, + { 70, 6 }, + { 129, 9 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 190, 9 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 202, 9 }, + { 89, 9 }, + { 107, 9 }, + { 69, 7 }, + { 125, 9 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 113, 9 }, + { 71, 7 }, + { 131, 9 }, + { 30, 10 }, + { 46, 10 }, + { 7, 9 }, + { 194, 7 }, + { 83, 7 }, + { 54, 10 }, + { 11, 9 }, + { 119, 7 }, + { 19, 9 }, + { 35, 9 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 137, 9 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 58, 10 }, + { 13, 9 }, + { 121, 7 }, + { 21, 9 }, + { 37, 9 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 25, 9 }, + { 41, 9 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 49, 9 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 205, 9 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 115, 9 }, + { 72, 8 }, + { 133, 9 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 139, 9 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 60, 10 }, + { 14, 9 }, + { 122, 8 }, + { 22, 9 }, + { 38, 9 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 26, 9 }, + { 42, 9 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 50, 9 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 28, 9 }, + { 44, 9 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 52, 9 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 56, 9 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 147, 5 }, + { 209, 12 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 209, 12 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 148, 6 }, + { 209, 12 }, + { 151, 6 }, + { 163, 6 }, + { 66, 6 }, + { 209, 12 }, + { 154, 6 }, + { 166, 6 }, + { 68, 6 }, + { 178, 6 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 169, 6 }, + { 70, 6 }, + { 181, 6 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 209, 12 }, + { 155, 7 }, + { 167, 7 }, + { 69, 7 }, + { 179, 7 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 170, 7 }, + { 71, 7 }, + { 182, 7 }, + { 77, 7 }, + { 95, 7 }, + { 65, 5 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 67, 5 }, + { 119, 7 }, + { 73, 5 }, + { 91, 5 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 185, 7 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 68, 6 }, + { 121, 7 }, + { 74, 6 }, + { 92, 6 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 76, 6 }, + { 94, 6 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 208, 12 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 171, 8 }, + { 72, 8 }, + { 183, 8 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 186, 8 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 104, 8 }, + { 68, 6 }, + { 122, 8 }, + { 74, 6 }, + { 92, 6 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 76, 6 }, + { 94, 6 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 77, 7 }, + { 95, 7 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 160, 9 }, + { 172, 9 }, + { 147, 5 }, + { 184, 9 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 196, 9 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 175, 9 }, + { 148, 6 }, + { 144, 12 }, + { 81, 9 }, + { 99, 9 }, + { 66, 6 }, + { 199, 9 }, + { 87, 9 }, + { 105, 9 }, + { 68, 6 }, + { 123, 9 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 111, 9 }, + { 70, 6 }, + { 129, 9 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 190, 9 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 202, 9 }, + { 89, 9 }, + { 107, 9 }, + { 69, 7 }, + { 125, 9 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 113, 9 }, + { 71, 7 }, + { 131, 9 }, + { 77, 7 }, + { 95, 7 }, + { 7, 9 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 11, 9 }, + { 119, 7 }, + { 19, 9 }, + { 35, 9 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 137, 9 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 13, 9 }, + { 121, 7 }, + { 21, 9 }, + { 37, 9 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 25, 9 }, + { 41, 9 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 49, 9 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 205, 9 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 115, 9 }, + { 72, 8 }, + { 133, 9 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 139, 9 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 104, 8 }, + { 14, 9 }, + { 122, 8 }, + { 22, 9 }, + { 38, 9 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 26, 9 }, + { 42, 9 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 50, 9 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 28, 9 }, + { 44, 9 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 52, 9 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 56, 9 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 147, 5 }, + { 209, 12 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 209, 12 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 176, 10 }, + { 148, 6 }, + { 188, 10 }, + { 151, 6 }, + { 163, 6 }, + { 66, 6 }, + { 200, 10 }, + { 154, 6 }, + { 166, 6 }, + { 68, 6 }, + { 178, 6 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 169, 6 }, + { 70, 6 }, + { 181, 6 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 191, 10 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 203, 10 }, + { 90, 10 }, + { 108, 10 }, + { 69, 7 }, + { 126, 10 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 114, 10 }, + { 71, 7 }, + { 132, 10 }, + { 77, 7 }, + { 95, 7 }, + { 65, 5 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 67, 5 }, + { 119, 7 }, + { 73, 5 }, + { 91, 5 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 138, 10 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 68, 6 }, + { 121, 7 }, + { 74, 6 }, + { 92, 6 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 76, 6 }, + { 94, 6 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 206, 10 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 116, 10 }, + { 72, 8 }, + { 134, 10 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 140, 10 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 63, 12 }, + { 15, 10 }, + { 122, 8 }, + { 23, 10 }, + { 39, 10 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 27, 10 }, + { 43, 10 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 51, 10 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 29, 10 }, + { 45, 10 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 53, 10 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 57, 10 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 160, 9 }, + { 172, 9 }, + { 147, 5 }, + { 184, 9 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 196, 9 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 175, 9 }, + { 148, 6 }, + { 142, 10 }, + { 81, 9 }, + { 99, 9 }, + { 66, 6 }, + { 199, 9 }, + { 87, 9 }, + { 105, 9 }, + { 68, 6 }, + { 123, 9 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 111, 9 }, + { 70, 6 }, + { 129, 9 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 190, 9 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 202, 9 }, + { 89, 9 }, + { 107, 9 }, + { 69, 7 }, + { 125, 9 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 113, 9 }, + { 71, 7 }, + { 131, 9 }, + { 30, 10 }, + { 46, 10 }, + { 7, 9 }, + { 194, 7 }, + { 83, 7 }, + { 54, 10 }, + { 11, 9 }, + { 119, 7 }, + { 19, 9 }, + { 35, 9 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 137, 9 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 58, 10 }, + { 13, 9 }, + { 121, 7 }, + { 21, 9 }, + { 37, 9 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 25, 9 }, + { 41, 9 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 49, 9 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 205, 9 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 115, 9 }, + { 72, 8 }, + { 133, 9 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 139, 9 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 60, 10 }, + { 14, 9 }, + { 122, 8 }, + { 22, 9 }, + { 38, 9 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 26, 9 }, + { 42, 9 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 50, 9 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 28, 9 }, + { 44, 9 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 52, 9 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 56, 9 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 147, 5 }, + { 209, 12 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 209, 12 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 148, 6 }, + { 209, 12 }, + { 151, 6 }, + { 163, 6 }, + { 66, 6 }, + { 209, 12 }, + { 154, 6 }, + { 166, 6 }, + { 68, 6 }, + { 178, 6 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 169, 6 }, + { 70, 6 }, + { 181, 6 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 192, 11 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 204, 11 }, + { 155, 7 }, + { 167, 7 }, + { 69, 7 }, + { 179, 7 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 170, 7 }, + { 71, 7 }, + { 182, 7 }, + { 77, 7 }, + { 95, 7 }, + { 65, 5 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 67, 5 }, + { 119, 7 }, + { 73, 5 }, + { 91, 5 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 185, 7 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 68, 6 }, + { 121, 7 }, + { 74, 6 }, + { 92, 6 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 76, 6 }, + { 94, 6 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 207, 11 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 117, 11 }, + { 72, 8 }, + { 135, 11 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 141, 11 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 104, 8 }, + { 68, 6 }, + { 122, 8 }, + { 74, 6 }, + { 92, 6 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 76, 6 }, + { 94, 6 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 77, 7 }, + { 95, 7 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 160, 9 }, + { 172, 9 }, + { 147, 5 }, + { 184, 9 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 196, 9 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 175, 9 }, + { 148, 6 }, + { 143, 11 }, + { 81, 9 }, + { 99, 9 }, + { 66, 6 }, + { 199, 9 }, + { 87, 9 }, + { 105, 9 }, + { 68, 6 }, + { 123, 9 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 111, 9 }, + { 70, 6 }, + { 129, 9 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 190, 9 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 202, 9 }, + { 89, 9 }, + { 107, 9 }, + { 69, 7 }, + { 125, 9 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 113, 9 }, + { 71, 7 }, + { 131, 9 }, + { 31, 11 }, + { 47, 11 }, + { 7, 9 }, + { 194, 7 }, + { 83, 7 }, + { 55, 11 }, + { 11, 9 }, + { 119, 7 }, + { 19, 9 }, + { 35, 9 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 137, 9 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 59, 11 }, + { 13, 9 }, + { 121, 7 }, + { 21, 9 }, + { 37, 9 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 25, 9 }, + { 41, 9 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 49, 9 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 205, 9 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 115, 9 }, + { 72, 8 }, + { 133, 9 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 139, 9 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 61, 11 }, + { 14, 9 }, + { 122, 8 }, + { 22, 9 }, + { 38, 9 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 26, 9 }, + { 42, 9 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 50, 9 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 28, 9 }, + { 44, 9 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 52, 9 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 56, 9 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 147, 5 }, + { 209, 12 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 209, 12 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 176, 10 }, + { 148, 6 }, + { 188, 10 }, + { 151, 6 }, + { 163, 6 }, + { 66, 6 }, + { 200, 10 }, + { 154, 6 }, + { 166, 6 }, + { 68, 6 }, + { 178, 6 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 169, 6 }, + { 70, 6 }, + { 181, 6 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 191, 10 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 203, 10 }, + { 90, 10 }, + { 108, 10 }, + { 69, 7 }, + { 126, 10 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 114, 10 }, + { 71, 7 }, + { 132, 10 }, + { 77, 7 }, + { 95, 7 }, + { 65, 5 }, + { 194, 7 }, + { 83, 7 }, + { 101, 7 }, + { 67, 5 }, + { 119, 7 }, + { 73, 5 }, + { 91, 5 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 138, 10 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 103, 7 }, + { 68, 6 }, + { 121, 7 }, + { 74, 6 }, + { 92, 6 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 76, 6 }, + { 94, 6 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 206, 10 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 116, 10 }, + { 72, 8 }, + { 134, 10 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 140, 10 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 62, 11 }, + { 15, 10 }, + { 122, 8 }, + { 23, 10 }, + { 39, 10 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 27, 10 }, + { 43, 10 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 51, 10 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 29, 10 }, + { 45, 10 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 53, 10 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 57, 10 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 146, 4 }, + { 209, 12 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 160, 9 }, + { 172, 9 }, + { 147, 5 }, + { 184, 9 }, + { 150, 5 }, + { 162, 5 }, + { 65, 5 }, + { 196, 9 }, + { 153, 5 }, + { 165, 5 }, + { 67, 5 }, + { 177, 5 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 175, 9 }, + { 148, 6 }, + { 142, 10 }, + { 81, 9 }, + { 99, 9 }, + { 66, 6 }, + { 199, 9 }, + { 87, 9 }, + { 105, 9 }, + { 68, 6 }, + { 123, 9 }, + { 74, 6 }, + { 92, 6 }, + { 64, 4 }, + { 209, 12 }, + { 157, 6 }, + { 111, 9 }, + { 70, 6 }, + { 129, 9 }, + { 76, 6 }, + { 94, 6 }, + { 65, 5 }, + { 193, 6 }, + { 82, 6 }, + { 100, 6 }, + { 67, 5 }, + { 118, 6 }, + { 73, 5 }, + { 91, 5 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 190, 9 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 202, 9 }, + { 89, 9 }, + { 107, 9 }, + { 69, 7 }, + { 125, 9 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 113, 9 }, + { 71, 7 }, + { 131, 9 }, + { 30, 10 }, + { 46, 10 }, + { 7, 9 }, + { 194, 7 }, + { 83, 7 }, + { 54, 10 }, + { 11, 9 }, + { 119, 7 }, + { 19, 9 }, + { 35, 9 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 137, 9 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 58, 10 }, + { 13, 9 }, + { 121, 7 }, + { 21, 9 }, + { 37, 9 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 25, 9 }, + { 41, 9 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 49, 9 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 145, 3 }, + { 205, 9 }, + { 156, 8 }, + { 168, 8 }, + { 146, 4 }, + { 180, 8 }, + { 149, 4 }, + { 161, 4 }, + { 64, 4 }, + { 209, 12 }, + { 159, 8 }, + { 115, 9 }, + { 72, 8 }, + { 133, 9 }, + { 78, 8 }, + { 96, 8 }, + { 65, 5 }, + { 195, 8 }, + { 84, 8 }, + { 102, 8 }, + { 67, 5 }, + { 120, 8 }, + { 73, 5 }, + { 91, 5 }, + { 64, 4 }, + { 209, 12 }, + { 209, 12 }, + { 174, 8 }, + { 148, 6 }, + { 139, 9 }, + { 80, 8 }, + { 98, 8 }, + { 66, 6 }, + { 198, 8 }, + { 86, 8 }, + { 60, 10 }, + { 14, 9 }, + { 122, 8 }, + { 22, 9 }, + { 38, 9 }, + { 3, 8 }, + { 209, 12 }, + { 157, 6 }, + { 110, 8 }, + { 70, 6 }, + { 128, 8 }, + { 26, 9 }, + { 42, 9 }, + { 5, 8 }, + { 193, 6 }, + { 82, 6 }, + { 50, 9 }, + { 9, 8 }, + { 118, 6 }, + { 17, 8 }, + { 33, 8 }, + { 0, 6 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 209, 12 }, + { 189, 8 }, + { 152, 7 }, + { 164, 7 }, + { 145, 3 }, + { 201, 8 }, + { 88, 8 }, + { 106, 8 }, + { 69, 7 }, + { 124, 8 }, + { 75, 7 }, + { 93, 7 }, + { 64, 4 }, + { 209, 12 }, + { 158, 7 }, + { 112, 8 }, + { 71, 7 }, + { 130, 8 }, + { 28, 9 }, + { 44, 9 }, + { 6, 8 }, + { 194, 7 }, + { 83, 7 }, + { 52, 9 }, + { 10, 8 }, + { 119, 7 }, + { 18, 8 }, + { 34, 8 }, + { 1, 7 }, + { 209, 12 }, + { 209, 12 }, + { 173, 7 }, + { 148, 6 }, + { 136, 8 }, + { 79, 7 }, + { 97, 7 }, + { 66, 6 }, + { 197, 7 }, + { 85, 7 }, + { 56, 9 }, + { 12, 8 }, + { 121, 7 }, + { 20, 8 }, + { 36, 8 }, + { 2, 7 }, + { 209, 12 }, + { 157, 6 }, + { 109, 7 }, + { 70, 6 }, + { 127, 7 }, + { 24, 8 }, + { 40, 8 }, + { 4, 7 }, + { 193, 6 }, + { 82, 6 }, + { 48, 8 }, + { 8, 7 }, + { 118, 6 }, + { 16, 7 }, + { 32, 7 }, + { 0, 6 } }; +} // utf8_to_utf16 namespace +} // tables namespace +} // unnamed namespace +} // namespace simdutf + +#endif // SIMDUTF_UTF8_TO_UTF16_TABLES_H +/* end file src/tables/utf8_to_utf16_tables.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=tables/utf16_to_utf8_tables.h +/* begin file src/tables/utf16_to_utf8_tables.h */ +// file generated by scripts/sse_convert_utf16_to_utf8.py +#ifndef SIMDUTF_UTF16_TO_UTF8_TABLES_H +#define SIMDUTF_UTF16_TO_UTF8_TABLES_H + +namespace simdutf { +namespace { +namespace tables { +namespace utf16_to_utf8 { + +// 1 byte for length, 16 bytes for mask +const uint8_t pack_1_2_utf8_bytes[256][17] = { + { 16, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }, + { 15, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80 }, + { 15, 1, 0, 3, 2, 5, 4, 7, 6, 8, 11, 10, 13, 12, 15, 14, 0x80 }, + { 14, 0, 3, 2, 5, 4, 7, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 15, 1, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80 }, + { 14, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 14, 1, 0, 2, 5, 4, 7, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 2, 5, 4, 7, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 15, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 13, 12, 15, 14, 0x80 }, + { 14, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 7, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 7, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 2, 5, 4, 7, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 2, 5, 4, 7, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 7, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 7, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 15, 1, 0, 3, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80 }, + { 14, 0, 3, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 4, 7, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 4, 7, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 4, 7, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 4, 7, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 4, 7, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 4, 7, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 7, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 7, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 4, 7, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 4, 7, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 7, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 7, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 15, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12, 15, 14, 0x80 }, + { 14, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 7, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 7, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 7, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 7, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 7, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 7, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 7, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 7, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 7, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 7, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 4, 7, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 4, 7, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 7, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 7, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 4, 7, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 4, 7, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 7, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 7, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 7, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 7, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 7, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 7, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 7, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 7, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 7, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 7, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 15, 1, 0, 3, 2, 5, 4, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80 }, + { 14, 0, 3, 2, 5, 4, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 2, 5, 4, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 2, 5, 4, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 4, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 4, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 4, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 4, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 6, 8, 11, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 6, 9, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 6, 8, 10, 13, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 5, 4, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 5, 4, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 5, 4, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 5, 4, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 6, 9, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 6, 8, 11, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 3, 2, 4, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 3, 2, 4, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 6, 9, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 1, 0, 2, 4, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 2, 4, 6, 8, 10, 12, 15, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 15, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 0x80 }, + { 14, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 7, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 7, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80 }, + { 13, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 7, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 7, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 7, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 7, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 7, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 7, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 7, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 7, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 7, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 7, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 7, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 7, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 7, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 7, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 7, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 7, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 7, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 7, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 7, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 7, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 7, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 7, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 7, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 7, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 5, 4, 7, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 5, 4, 7, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 7, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 7, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 5, 4, 7, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 5, 4, 7, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 7, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 7, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 7, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 7, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 7, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 7, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 7, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 7, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 7, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 7, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 3, 2, 4, 7, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 3, 2, 4, 7, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 7, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 7, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 1, 0, 2, 4, 7, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 2, 4, 7, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 14, 1, 0, 3, 2, 5, 4, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80 }, + { 13, 0, 3, 2, 5, 4, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 2, 5, 4, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 2, 5, 4, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 5, 4, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 5, 4, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 5, 4, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 5, 4, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 4, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 4, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 4, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 4, 6, 9, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 6, 8, 11, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 3, 2, 4, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 3, 2, 4, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 6, 9, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 1, 0, 2, 4, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 2, 4, 6, 8, 10, 13, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 13, 1, 0, 3, 2, 5, 4, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80 }, + { 12, 0, 3, 2, 5, 4, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 5, 4, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 5, 4, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 2, 5, 4, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 2, 5, 4, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 5, 4, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 5, 4, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 5, 4, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 5, 4, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 3, 2, 5, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 3, 2, 5, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 5, 4, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 5, 4, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 1, 0, 2, 5, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 2, 5, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 12, 1, 0, 3, 2, 4, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80 }, + { 11, 0, 3, 2, 4, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 3, 2, 4, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 3, 2, 4, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 2, 4, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 2, 4, 6, 9, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 1, 0, 2, 4, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 2, 4, 6, 8, 11, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 1, 0, 3, 2, 4, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 3, 2, 4, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 1, 0, 3, 2, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 3, 2, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 1, 0, 2, 4, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 2, 4, 6, 9, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 1, 0, 2, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 0, 2, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 } +}; + +// 1 byte for length, 16 bytes for mask +const uint8_t pack_1_2_3_utf8_bytes[256][17] = { + { 12, 2, 3, 1, 6, 7, 5, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80 }, + { 9, 6, 7, 5, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 3, 1, 6, 7, 5, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 0, 6, 7, 5, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 2, 3, 1, 7, 5, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 7, 5, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 3, 1, 7, 5, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 7, 5, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 2, 3, 1, 4, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 4, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 3, 1, 4, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 0, 4, 10, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 6, 7, 5, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 6, 7, 5, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 6, 7, 5, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 6, 7, 5, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 7, 5, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 7, 5, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 7, 5, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 7, 5, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 4, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 4, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 4, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 4, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 2, 3, 1, 6, 7, 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 6, 7, 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 3, 1, 6, 7, 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 6, 7, 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 2, 3, 1, 7, 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 7, 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 3, 1, 7, 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 0, 7, 5, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 4, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 4, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 4, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 4, 11, 9, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 2, 3, 1, 6, 7, 5, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 6, 7, 5, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 3, 1, 6, 7, 5, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 0, 6, 7, 5, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 7, 5, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 7, 5, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 7, 5, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 7, 5, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 4, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 4, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 4, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 4, 8, 14, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 6, 7, 5, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 6, 7, 5, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 6, 7, 5, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 6, 7, 5, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 7, 5, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 7, 5, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 7, 5, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 7, 5, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 4, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 4, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 4, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 4, 10, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 6, 7, 5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 6, 7, 5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 6, 7, 5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 6, 7, 5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 2, 3, 1, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 3, 1, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 1, 0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 2, 3, 1, 7, 5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 7, 5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 3, 1, 7, 5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 0, 7, 5, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 2, 3, 1, 4, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 1, 4, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 3, 1, 4, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 0, 4, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 6, 7, 5, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 6, 7, 5, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 6, 7, 5, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 6, 7, 5, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 2, 3, 1, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 3, 1, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 0, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 7, 5, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 7, 5, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 7, 5, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 7, 5, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 4, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 4, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 4, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 4, 11, 9, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 6, 7, 5, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 6, 7, 5, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 6, 7, 5, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 6, 7, 5, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 2, 3, 1, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 1, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 3, 1, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 0, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 7, 5, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 7, 5, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 7, 5, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 7, 5, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 2, 3, 1, 4, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 4, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 3, 1, 4, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 0, 4, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 11, 2, 3, 1, 6, 7, 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 6, 7, 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 3, 1, 6, 7, 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 0, 6, 7, 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 2, 3, 1, 7, 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 7, 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 3, 1, 7, 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 0, 7, 5, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 4, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 4, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 4, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 4, 10, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 6, 7, 5, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 6, 7, 5, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 6, 7, 5, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 6, 7, 5, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 2, 3, 1, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 3, 1, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 0, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 7, 5, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 7, 5, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 7, 5, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 7, 5, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 4, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 4, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 4, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 4, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 2, 3, 1, 6, 7, 5, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 6, 7, 5, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 3, 1, 6, 7, 5, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 0, 6, 7, 5, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 7, 5, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 7, 5, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 7, 5, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 7, 5, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 4, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 4, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 4, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 4, 11, 9, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 6, 7, 5, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 6, 7, 5, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 6, 7, 5, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 6, 7, 5, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 7, 5, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 7, 5, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 7, 5, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 7, 5, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 4, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 4, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 4, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 4, 8, 15, 13, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 10, 2, 3, 1, 6, 7, 5, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 6, 7, 5, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 3, 1, 6, 7, 5, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 0, 6, 7, 5, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 7, 5, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 7, 5, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 7, 5, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 7, 5, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 4, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 4, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 4, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 4, 10, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 6, 7, 5, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 6, 7, 5, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 6, 7, 5, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 6, 7, 5, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 2, 3, 1, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 1, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 3, 1, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 0, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 7, 5, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 7, 5, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 7, 5, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 7, 5, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 2, 3, 1, 4, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 4, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 3, 1, 4, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 0, 4, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 9, 2, 3, 1, 6, 7, 5, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 6, 7, 5, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 3, 1, 6, 7, 5, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 0, 6, 7, 5, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 7, 5, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 7, 5, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 7, 5, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 7, 5, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 4, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 4, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 4, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 4, 11, 9, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 8, 2, 3, 1, 6, 7, 5, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 6, 7, 5, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 3, 1, 6, 7, 5, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 0, 6, 7, 5, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 2, 3, 1, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 2, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 3, 1, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 0, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 7, 2, 3, 1, 7, 5, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 7, 5, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 3, 1, 7, 5, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 0, 7, 5, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 6, 2, 3, 1, 4, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 3, 4, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 5, 3, 1, 4, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 4, 0, 4, 8, 12, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 } +}; + +} // utf16_to_utf8 namespace +} // tables namespace +} // unnamed namespace +} // namespace simdutf + +#endif // SIMDUTF_UTF16_TO_UTF8_TABLES_H +/* end file src/tables/utf16_to_utf8_tables.h */ +// End of tables. + +// The scalar routines should be included once. +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/ascii.h +/* begin file src/scalar/ascii.h */ +#ifndef SIMDUTF_ASCII_H +#define SIMDUTF_ASCII_H + +namespace simdutf { +namespace scalar { +namespace { +namespace ascii { +#if SIMDUTF_IMPLEMENTATION_FALLBACK +// Only used by the fallback kernel. +inline simdutf_warn_unused bool validate(const char* buf, size_t len) noexcept +{ + const uint8_t* data = reinterpret_cast(buf); + uint64_t pos = 0; + // process in blocks of 16 bytes when possible + for (; pos + 16 < len; pos += 16) { + uint64_t v1; + std::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; + if ((v & 0x8080808080808080) != 0) { + return false; + } + } + // process the tail byte-by-byte + for (; pos < len; pos++) { + if (data[pos] >= 0b10000000) { + return false; + } + } + return true; +} +#endif + +inline simdutf_warn_unused result validate_with_errors(const char* buf, size_t len) noexcept +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + // process in blocks of 16 bytes when possible + for (; pos + 16 < len; pos += 16) { + uint64_t v1; + std::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; + if ((v & 0x8080808080808080) != 0) { + for (; pos < len; pos++) { + if (data[pos] >= 0b10000000) { + return result(error_code::TOO_LARGE, pos); + } + } + } + } + // process the tail byte-by-byte + for (; pos < len; pos++) { + if (data[pos] >= 0b10000000) { + return result(error_code::TOO_LARGE, pos); + } + } + return result(error_code::SUCCESS, pos); +} + +} // ascii namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/ascii.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf8.h +/* begin file src/scalar/utf8.h */ +#ifndef SIMDUTF_UTF8_H +#define SIMDUTF_UTF8_H + +namespace simdutf { +namespace scalar { +namespace { +namespace utf8 { +#if SIMDUTF_IMPLEMENTATION_FALLBACK +// only used by the fallback kernel. +// credit: based on code from Google Fuchsia (Apache Licensed) +inline simdutf_warn_unused bool validate(const char* buf, size_t len) noexcept +{ + const uint8_t* data = reinterpret_cast(buf); + uint64_t pos = 0; + uint32_t code_point = 0; + while (pos < len) { + // check of the next 8 bytes are ascii. + uint64_t next_pos = pos + 16; + if (next_pos <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v1; + std::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; + if ((v & 0x8080808080808080) == 0) { + pos = next_pos; + continue; + } + } + unsigned char byte = data[pos]; + + while (byte < 0b10000000) { + if (++pos == len) { + return true; + } + byte = data[pos]; + } + + if ((byte & 0b11100000) == 0b11000000) { + next_pos = pos + 2; + if (next_pos > len) { + return false; + } + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return false; + } + // range check + code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); + if ((code_point < 0x80) || (0x7ff < code_point)) { + return false; + } + } else if ((byte & 0b11110000) == 0b11100000) { + next_pos = pos + 3; + if (next_pos > len) { + return false; + } + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return false; + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return false; + } + // range check + code_point = (byte & 0b00001111) << 12 | (data[pos + 1] & 0b00111111) << 6 | (data[pos + 2] & 0b00111111); + if ((code_point < 0x800) || (0xffff < code_point) || (0xd7ff < code_point && code_point < 0xe000)) { + return false; + } + } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000 + next_pos = pos + 4; + if (next_pos > len) { + return false; + } + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return false; + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return false; + } + if ((data[pos + 3] & 0b11000000) != 0b10000000) { + return false; + } + // range check + code_point = (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); + if (code_point <= 0xffff || 0x10ffff < code_point) { + return false; + } + } else { + // we may have a continuation + return false; + } + pos = next_pos; + } + return true; +} +#endif + +inline simdutf_warn_unused result validate_with_errors(const char* buf, size_t len) noexcept +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + uint32_t code_point = 0; + while (pos < len) { + // check of the next 8 bytes are ascii. + size_t next_pos = pos + 16; + if (next_pos <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v1; + std::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; + if ((v & 0x8080808080808080) == 0) { + pos = next_pos; + continue; + } + } + unsigned char byte = data[pos]; + + while (byte < 0b10000000) { + if (++pos == len) { + return result(error_code::SUCCESS, len); + } + byte = data[pos]; + } + + if ((byte & 0b11100000) == 0b11000000) { + next_pos = pos + 2; + if (next_pos > len) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + // range check + code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); + if ((code_point < 0x80) || (0x7ff < code_point)) { + return result(error_code::OVERLONG, pos); + } + } else if ((byte & 0b11110000) == 0b11100000) { + next_pos = pos + 3; + if (next_pos > len) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + // range check + code_point = (byte & 0b00001111) << 12 | (data[pos + 1] & 0b00111111) << 6 | (data[pos + 2] & 0b00111111); + if ((code_point < 0x800) || (0xffff < code_point)) { + return result(error_code::OVERLONG, pos); + } + if (0xd7ff < code_point && code_point < 0xe000) { + return result(error_code::SURROGATE, pos); + } + } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000 + next_pos = pos + 4; + if (next_pos > len) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 3] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + // range check + code_point = (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); + if (code_point <= 0xffff) { + return result(error_code::OVERLONG, pos); + } + if (0x10ffff < code_point) { + return result(error_code::TOO_LARGE, pos); + } + } else { + // we either have too many continuation bytes or an invalid leading byte + if ((byte & 0b11000000) == 0b10000000) { + return result(error_code::TOO_LONG, pos); + } else { + return result(error_code::HEADER_BITS, pos); + } + } + pos = next_pos; + } + return result(error_code::SUCCESS, len); +} + +// Finds the previous leading byte and validates with errors from there +// Used to pinpoint the location of an error when an invalid chunk is detected +inline simdutf_warn_unused result rewind_and_validate_with_errors(const char* buf, size_t len) noexcept +{ + size_t extra_len { 0 }; + // A leading byte cannot be further than 4 bytes away + for (int i = 0; i < 5; i++) { + unsigned char byte = *buf; + if ((byte & 0b11000000) != 0b10000000) { + break; + } else { + buf--; + extra_len++; + } + } + + result res = validate_with_errors(buf, len + extra_len); + res.count -= extra_len; + return res; +} + +inline size_t count_code_points(const char* buf, size_t len) +{ + const int8_t* p = reinterpret_cast(buf); + size_t counter { 0 }; + for (size_t i = 0; i < len; i++) { + // -65 is 0b10111111, anything larger in two-complement's should start a new code point. + if (p[i] > -65) { + counter++; + } + } + return counter; +} + +inline size_t utf16_length_from_utf8(const char* buf, size_t len) +{ + const int8_t* p = reinterpret_cast(buf); + size_t counter { 0 }; + for (size_t i = 0; i < len; i++) { + if (p[i] > -65) { + counter++; + } + if (uint8_t(p[i]) >= 240) { + counter++; + } + } + return counter; +} + +inline size_t latin1_length_from_utf8(const char* buf, size_t len) +{ + const uint8_t* c = reinterpret_cast(buf); + + size_t answer = len; + for (size_t i = 0; i < len; i++) { + if ((c[i] & 0b11100000) == 0b11000000) { + answer--; + } // if we have a two-byte UTF8 character + } + return answer; +} + +} // utf8 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf8.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf16.h +/* begin file src/scalar/utf16.h */ +#ifndef SIMDUTF_UTF16_H +#define SIMDUTF_UTF16_H + +namespace simdutf { +namespace scalar { +namespace { +namespace utf16 { + +inline simdutf_warn_unused uint16_t swap_bytes(const uint16_t word) +{ + return uint16_t((word >> 8) | (word << 8)); +} + +template +inline simdutf_warn_unused bool validate(const char16_t* buf, size_t len) noexcept +{ + const uint16_t* data = reinterpret_cast(buf); + uint64_t pos = 0; + while (pos < len) { + uint16_t word = !match_system(big_endian) ? swap_bytes(data[pos]) : data[pos]; + if ((word & 0xF800) == 0xD800) { + if (pos + 1 >= len) { + return false; + } + uint16_t diff = uint16_t(word - 0xD800); + if (diff > 0x3FF) { + return false; + } + uint16_t next_word = !match_system(big_endian) ? swap_bytes(data[pos + 1]) : data[pos + 1]; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if (diff2 > 0x3FF) { + return false; + } + pos += 2; + } else { + pos++; + } + } + return true; +} + +template +inline simdutf_warn_unused result validate_with_errors(const char16_t* buf, size_t len) noexcept +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + while (pos < len) { + uint16_t word = !match_system(big_endian) ? swap_bytes(data[pos]) : data[pos]; + if ((word & 0xF800) == 0xD800) { + if (pos + 1 >= len) { + return result(error_code::SURROGATE, pos); + } + uint16_t diff = uint16_t(word - 0xD800); + if (diff > 0x3FF) { + return result(error_code::SURROGATE, pos); + } + uint16_t next_word = !match_system(big_endian) ? swap_bytes(data[pos + 1]) : data[pos + 1]; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if (diff2 > 0x3FF) { + return result(error_code::SURROGATE, pos); + } + pos += 2; + } else { + pos++; + } + } + return result(error_code::SUCCESS, pos); +} + +template +inline size_t count_code_points(const char16_t* buf, size_t len) +{ + // We are not BOM aware. + const uint16_t* p = reinterpret_cast(buf); + size_t counter { 0 }; + for (size_t i = 0; i < len; i++) { + uint16_t word = !match_system(big_endian) ? swap_bytes(p[i]) : p[i]; + counter += ((word & 0xFC00) != 0xDC00); + } + return counter; +} + +template +inline size_t utf8_length_from_utf16(const char16_t* buf, size_t len) +{ + // We are not BOM aware. + const uint16_t* p = reinterpret_cast(buf); + size_t counter { 0 }; + for (size_t i = 0; i < len; i++) { + uint16_t word = !match_system(big_endian) ? swap_bytes(p[i]) : p[i]; + /** ASCII **/ + if (word <= 0x7F) { + counter++; + } + /** two-byte **/ + else if (word <= 0x7FF) { + counter += 2; + } + /** three-byte **/ + else if ((word <= 0xD7FF) || (word >= 0xE000)) { + counter += 3; + } + /** surrogates -- 4 bytes **/ + else { + counter += 2; + } + } + return counter; +} + +template +inline size_t utf32_length_from_utf16(const char16_t* buf, size_t len) +{ + // We are not BOM aware. + const uint16_t* p = reinterpret_cast(buf); + size_t counter { 0 }; + for (size_t i = 0; i < len; i++) { + uint16_t word = !match_system(big_endian) ? swap_bytes(p[i]) : p[i]; + counter += ((word & 0xFC00) != 0xDC00); + } + return counter; +} + +inline size_t latin1_length_from_utf16(size_t len) +{ + return len; +} + +simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* out) +{ + const uint16_t* input = reinterpret_cast(in); + uint16_t* output = reinterpret_cast(out); + for (size_t i = 0; i < size; i++) { + *output++ = uint16_t(input[i] >> 8 | input[i] << 8); + } +} + +} // utf16 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf16.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf32.h +/* begin file src/scalar/utf32.h */ +#ifndef SIMDUTF_UTF32_H +#define SIMDUTF_UTF32_H + +namespace simdutf { +namespace scalar { +namespace { +namespace utf32 { + +inline simdutf_warn_unused bool validate(const char32_t* buf, size_t len) noexcept +{ + const uint32_t* data = reinterpret_cast(buf); + uint64_t pos = 0; + for (; pos < len; pos++) { + uint32_t word = data[pos]; + if (word > 0x10FFFF || (word >= 0xD800 && word <= 0xDFFF)) { + return false; + } + } + return true; } -simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t length) noexcept { - return get_active_implementation()->utf8_length_from_utf32(input, length); + +inline simdutf_warn_unused result validate_with_errors(const char32_t* buf, size_t len) noexcept +{ + const uint32_t* data = reinterpret_cast(buf); + size_t pos = 0; + for (; pos < len; pos++) { + uint32_t word = data[pos]; + if (word > 0x10FFFF) { + return result(error_code::TOO_LARGE, pos); + } + if (word >= 0xD800 && word <= 0xDFFF) { + return result(error_code::SURROGATE, pos); + } + } + return result(error_code::SUCCESS, pos); } -simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_t length) noexcept { - return get_active_implementation()->utf16_length_from_utf32(input, length); + +inline size_t utf8_length_from_utf32(const char32_t* buf, size_t len) +{ + // We are not BOM aware. + const uint32_t* p = reinterpret_cast(buf); + size_t counter { 0 }; + for (size_t i = 0; i < len; i++) { + /** ASCII **/ + if (p[i] <= 0x7F) { + counter++; + } + /** two-byte **/ + else if (p[i] <= 0x7FF) { + counter += 2; + } + /** three-byte **/ + else if (p[i] <= 0xFFFF) { + counter += 3; + } + /** four-bytes **/ + else { + counter += 4; + } + } + return counter; } -simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t length) noexcept { - return get_active_implementation()->utf32_length_from_utf8(input, length); + +inline size_t utf16_length_from_utf32(const char32_t* buf, size_t len) +{ + // We are not BOM aware. + const uint32_t* p = reinterpret_cast(buf); + size_t counter { 0 }; + for (size_t i = 0; i < len; i++) { + /** non-surrogate word **/ + if (p[i] <= 0xFFFF) { + counter++; + } + /** surrogate pair **/ + else { + counter += 2; + } + } + return counter; } -simdutf_warn_unused simdutf::encoding_type autodetect_encoding(const char * buf, size_t length) noexcept { - return get_active_implementation()->autodetect_encoding(buf, length); + +inline size_t latin1_length_from_utf32(size_t len) +{ + // We are not BOM aware. + return len; // a utf32 codepoint will always represent 1 latin1 character } -simdutf_warn_unused int detect_encodings(const char * buf, size_t length) noexcept { - return get_active_implementation()->detect_encodings(buf, length); + +} // utf32 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf32.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/latin1.h +/* begin file src/scalar/latin1.h */ +#ifndef SIMDUTF_LATIN1_H +#define SIMDUTF_LATIN1_H + +namespace simdutf { +namespace scalar { +namespace { +namespace latin1 { + +inline size_t utf32_length_from_latin1(size_t len) +{ + // We are not BOM aware. + return len; // a utf32 unit will always represent 1 latin1 character } -const implementation * builtin_implementation() { - static const implementation * builtin_impl = get_available_implementations()[SIMDUTF_STRINGIFY(SIMDUTF_BUILTIN_IMPLEMENTATION)]; - return builtin_impl; +inline size_t utf8_length_from_latin1(const char* buf, size_t len) +{ + const uint8_t* c = reinterpret_cast(buf); + size_t answer = 0; + for (size_t i = 0; i < len; i++) { + if ((c[i] >> 7)) { + answer++; + } + } + return answer + len; } +inline size_t utf16_length_from_latin1(size_t len) +{ + return len; +} +} // utf32 namespace +} // unnamed namespace +} // namespace scalar } // namespace simdutf -/* end file src/implementation.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=encoding_types.cpp -/* begin file src/encoding_types.cpp */ +#endif +/* end file src/scalar/latin1.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf32_to_utf8/valid_utf32_to_utf8.h +/* begin file src/scalar/utf32_to_utf8/valid_utf32_to_utf8.h */ +#ifndef SIMDUTF_VALID_UTF32_TO_UTF8_H +#define SIMDUTF_VALID_UTF32_TO_UTF8_H namespace simdutf { -bool match_system(endianness e) { -#if SIMDUTF_IS_BIG_ENDIAN - return e == endianness::BIG; -#else - return e == endianness::LITTLE; -#endif +namespace scalar { +namespace { +namespace utf32_to_utf8 { + +#if SIMDUTF_IMPLEMENTATION_FALLBACK || SIMDUTF_IMPLEMENTATION_PPC64 +// only used by the fallback and POWER kernel +inline size_t convert_valid(const char32_t* buf, size_t len, char* utf8_output) +{ + const uint32_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { utf8_output }; + while (pos < len) { + // try to convert the next block of 2 ASCII characters + if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if ((v & 0xFFFFFF80FFFFFF80) == 0) { + *utf8_output++ = char(buf[pos]); + *utf8_output++ = char(buf[pos + 1]); + pos += 2; + continue; + } + } + uint32_t word = data[pos]; + if ((word & 0xFFFFFF80) == 0) { + // will generate one UTF-8 bytes + *utf8_output++ = char(word); + pos++; + } else if ((word & 0xFFFFF800) == 0) { + // will generate two UTF-8 bytes + // we have 0b110XXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else if ((word & 0xFFFF0000) == 0) { + // will generate three UTF-8 bytes + // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else { + // will generate four UTF-8 bytes + // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } + } + return utf8_output - start; } +#endif // SIMDUTF_IMPLEMENTATION_FALLBACK || SIMDUTF_IMPLEMENTATION_PPC64 + +} // utf32_to_utf8 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf32_to_utf8/valid_utf32_to_utf8.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf32_to_utf8/utf32_to_utf8.h +/* begin file src/scalar/utf32_to_utf8/utf32_to_utf8.h */ +#ifndef SIMDUTF_UTF32_TO_UTF8_H +#define SIMDUTF_UTF32_TO_UTF8_H + +namespace simdutf { +namespace scalar { +namespace { +namespace utf32_to_utf8 { -std::string to_string(encoding_type bom) { - switch (bom) { - case UTF16_LE: return "UTF16 little-endian"; - case UTF16_BE: return "UTF16 big-endian"; - case UTF32_LE: return "UTF32 little-endian"; - case UTF32_BE: return "UTF32 big-endian"; - case UTF8: return "UTF8"; - case unspecified: return "unknown"; - default: return "error"; - } +inline size_t convert(const char32_t* buf, size_t len, char* utf8_output) +{ + const uint32_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { utf8_output }; + while (pos < len) { + // try to convert the next block of 2 ASCII characters + if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if ((v & 0xFFFFFF80FFFFFF80) == 0) { + *utf8_output++ = char(buf[pos]); + *utf8_output++ = char(buf[pos + 1]); + pos += 2; + continue; + } + } + uint32_t word = data[pos]; + if ((word & 0xFFFFFF80) == 0) { + // will generate one UTF-8 bytes + *utf8_output++ = char(word); + pos++; + } else if ((word & 0xFFFFF800) == 0) { + // will generate two UTF-8 bytes + // we have 0b110XXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else if ((word & 0xFFFF0000) == 0) { + // will generate three UTF-8 bytes + // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX + if (word >= 0xD800 && word <= 0xDFFF) { + return 0; + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else { + // will generate four UTF-8 bytes + // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX + if (word > 0x10FFFF) { + return 0; + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } + } + return utf8_output - start; } -namespace BOM { -// Note that BOM for UTF8 is discouraged. -encoding_type check_bom(const uint8_t* byte, size_t length) { - if (length >= 2 && byte[0] == 0xff and byte[1] == 0xfe) { - if (length >= 4 && byte[2] == 0x00 and byte[3] == 0x0) { - return encoding_type::UTF32_LE; - } else { - return encoding_type::UTF16_LE; +inline result convert_with_errors(const char32_t* buf, size_t len, char* utf8_output) +{ + const uint32_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { utf8_output }; + while (pos < len) { + // try to convert the next block of 2 ASCII characters + if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if ((v & 0xFFFFFF80FFFFFF80) == 0) { + *utf8_output++ = char(buf[pos]); + *utf8_output++ = char(buf[pos + 1]); + pos += 2; + continue; } - } else if (length >= 2 && byte[0] == 0xfe and byte[1] == 0xff) { - return encoding_type::UTF16_BE; - } else if (length >= 4 && byte[0] == 0x00 and byte[1] == 0x00 and byte[2] == 0xfe and byte[3] == 0xff) { - return encoding_type::UTF32_BE; - } else if (length >= 4 && byte[0] == 0xef and byte[1] == 0xbb and byte[3] == 0xbf) { - return encoding_type::UTF8; } - return encoding_type::unspecified; + uint32_t word = data[pos]; + if ((word & 0xFFFFFF80) == 0) { + // will generate one UTF-8 bytes + *utf8_output++ = char(word); + pos++; + } else if ((word & 0xFFFFF800) == 0) { + // will generate two UTF-8 bytes + // we have 0b110XXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else if ((word & 0xFFFF0000) == 0) { + // will generate three UTF-8 bytes + // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX + if (word >= 0xD800 && word <= 0xDFFF) { + return result(error_code::SURROGATE, pos); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else { + // will generate four UTF-8 bytes + // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX + if (word > 0x10FFFF) { + return result(error_code::TOO_LARGE, pos); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } } + return result(error_code::SUCCESS, utf8_output - start); +} + +} // utf32_to_utf8 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf32_to_utf8/utf32_to_utf8.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf32_to_utf16/valid_utf32_to_utf16.h +/* begin file src/scalar/utf32_to_utf16/valid_utf32_to_utf16.h */ +#ifndef SIMDUTF_VALID_UTF32_TO_UTF16_H +#define SIMDUTF_VALID_UTF32_TO_UTF16_H -encoding_type check_bom(const char* byte, size_t length) { - return check_bom(reinterpret_cast(byte), length); - } +namespace simdutf { +namespace scalar { +namespace { +namespace utf32_to_utf16 { - size_t bom_byte_size(encoding_type bom) { - switch (bom) { - case UTF16_LE: return 2; - case UTF16_BE: return 2; - case UTF32_LE: return 4; - case UTF32_BE: return 4; - case UTF8: return 3; - case unspecified: return 0; - default: return 0; +template +inline size_t convert_valid(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + const uint32_t* data = reinterpret_cast(buf); + size_t pos = 0; + char16_t* start { utf16_output }; + while (pos < len) { + uint32_t word = data[pos]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(uint16_t(word))) : char16_t(word); + pos++; + } else { + // will generate a surrogate pair + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (!match_system(big_endian)) { + high_surrogate = utf16::swap_bytes(high_surrogate); + low_surrogate = utf16::swap_bytes(low_surrogate); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + pos++; } + } + return utf16_output - start; } +} // utf32_to_utf16 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf32_to_utf16/valid_utf32_to_utf16.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf32_to_utf16/utf32_to_utf16.h +/* begin file src/scalar/utf32_to_utf16/utf32_to_utf16.h */ +#ifndef SIMDUTF_UTF32_TO_UTF16_H +#define SIMDUTF_UTF32_TO_UTF16_H + +namespace simdutf { +namespace scalar { +namespace { +namespace utf32_to_utf16 { + +template +inline size_t convert(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + const uint32_t* data = reinterpret_cast(buf); + size_t pos = 0; + char16_t* start { utf16_output }; + while (pos < len) { + uint32_t word = data[pos]; + if ((word & 0xFFFF0000) == 0) { + if (word >= 0xD800 && word <= 0xDFFF) { + return 0; + } + // will not generate a surrogate pair + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(uint16_t(word))) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return 0; + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (!match_system(big_endian)) { + high_surrogate = utf16::swap_bytes(high_surrogate); + low_surrogate = utf16::swap_bytes(low_surrogate); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + pos++; + } + return utf16_output - start; } + +template +inline result convert_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + const uint32_t* data = reinterpret_cast(buf); + size_t pos = 0; + char16_t* start { utf16_output }; + while (pos < len) { + uint32_t word = data[pos]; + if ((word & 0xFFFF0000) == 0) { + if (word >= 0xD800 && word <= 0xDFFF) { + return result(error_code::SURROGATE, pos); + } + // will not generate a surrogate pair + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(uint16_t(word))) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return result(error_code::TOO_LARGE, pos); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (!match_system(big_endian)) { + high_surrogate = utf16::swap_bytes(high_surrogate); + low_surrogate = utf16::swap_bytes(low_surrogate); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + pos++; + } + return result(error_code::SUCCESS, utf16_output - start); } -/* end file src/encoding_types.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=error.cpp -/* begin file src/error.cpp */ -namespace simdutf { - simdutf_really_inline result::result() : error{error_code::SUCCESS}, count{0} {}; +} // utf32_to_utf16 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf32_to_utf16/utf32_to_utf16.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf16_to_utf8/valid_utf16_to_utf8.h +/* begin file src/scalar/utf16_to_utf8/valid_utf16_to_utf8.h */ +#ifndef SIMDUTF_VALID_UTF16_TO_UTF8_H +#define SIMDUTF_VALID_UTF16_TO_UTF8_H + +namespace simdutf { +namespace scalar { +namespace { +namespace utf16_to_utf8 { - simdutf_really_inline result::result(error_code _err, size_t _pos) : error{_err}, count{_pos} {}; +template +inline size_t convert_valid(const char16_t* buf, size_t len, char* utf8_output) +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { utf8_output }; + while (pos < len) { + // try to convert the next block of 4 ASCII characters + if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if (!match_system(big_endian)) { + v = (v >> 8) | (v << (64 - 8)); + } + if ((v & 0xFF80FF80FF80FF80) == 0) { + size_t final_pos = pos + 4; + while (pos < final_pos) { + *utf8_output++ = !match_system(big_endian) ? char(utf16::swap_bytes(buf[pos])) : char(buf[pos]); + pos++; + } + continue; + } + } + uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + if ((word & 0xFF80) == 0) { + // will generate one UTF-8 bytes + *utf8_output++ = char(word); + pos++; + } else if ((word & 0xF800) == 0) { + // will generate two UTF-8 bytes + // we have 0b110XXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else if ((word & 0xF800) != 0xD800) { + // will generate three UTF-8 bytes + // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + if (pos + 1 >= len) { + return 0; + } // minimal bound checking + uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + uint32_t value = (diff << 10) + diff2 + 0x10000; + // will generate four UTF-8 bytes + // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + pos += 2; + } + } + return utf8_output - start; } -/* end file src/error.cpp */ -// The large tables should be included once and they -// should not depend on a kernel. -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=tables/utf8_to_utf16_tables.h -/* begin file src/tables/utf8_to_utf16_tables.h */ -#ifndef SIMDUTF_UTF8_TO_UTF16_TABLES_H -#define SIMDUTF_UTF8_TO_UTF16_TABLES_H -#include + +} // utf16_to_utf8 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf16_to_utf8/valid_utf16_to_utf8.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf16_to_utf8/utf16_to_utf8.h +/* begin file src/scalar/utf16_to_utf8/utf16_to_utf8.h */ +#ifndef SIMDUTF_UTF16_TO_UTF8_H +#define SIMDUTF_UTF16_TO_UTF8_H namespace simdutf { +namespace scalar { namespace { -namespace tables { -namespace utf8_to_utf16 { -/** - * utf8bigindex uses about 8 kB - * shufutf8 uses about 3344 B - * - * So we use a bit over 11 kB. It would be - * easy to save about 4 kB by only - * storing the index in utf8bigindex, and - * deriving the consumed bytes otherwise. - * However, this may come at a significant (10% to 20%) - * performance penalty. - */ +namespace utf16_to_utf8 { -const uint8_t shufutf8[209][16] = -{ {0, 255, 1, 255, 2, 255, 3, 255, 4, 255, 5, 255, 0, 0, 0, 0}, - {0, 255, 1, 255, 2, 255, 3, 255, 4, 255, 6, 5, 0, 0, 0, 0}, - {0, 255, 1, 255, 2, 255, 3, 255, 5, 4, 6, 255, 0, 0, 0, 0}, - {0, 255, 1, 255, 2, 255, 3, 255, 5, 4, 7, 6, 0, 0, 0, 0}, - {0, 255, 1, 255, 2, 255, 4, 3, 5, 255, 6, 255, 0, 0, 0, 0}, - {0, 255, 1, 255, 2, 255, 4, 3, 5, 255, 7, 6, 0, 0, 0, 0}, - {0, 255, 1, 255, 2, 255, 4, 3, 6, 5, 7, 255, 0, 0, 0, 0}, - {0, 255, 1, 255, 2, 255, 4, 3, 6, 5, 8, 7, 0, 0, 0, 0}, - {0, 255, 1, 255, 3, 2, 4, 255, 5, 255, 6, 255, 0, 0, 0, 0}, - {0, 255, 1, 255, 3, 2, 4, 255, 5, 255, 7, 6, 0, 0, 0, 0}, - {0, 255, 1, 255, 3, 2, 4, 255, 6, 5, 7, 255, 0, 0, 0, 0}, - {0, 255, 1, 255, 3, 2, 4, 255, 6, 5, 8, 7, 0, 0, 0, 0}, - {0, 255, 1, 255, 3, 2, 5, 4, 6, 255, 7, 255, 0, 0, 0, 0}, - {0, 255, 1, 255, 3, 2, 5, 4, 6, 255, 8, 7, 0, 0, 0, 0}, - {0, 255, 1, 255, 3, 2, 5, 4, 7, 6, 8, 255, 0, 0, 0, 0}, - {0, 255, 1, 255, 3, 2, 5, 4, 7, 6, 9, 8, 0, 0, 0, 0}, - {0, 255, 2, 1, 3, 255, 4, 255, 5, 255, 6, 255, 0, 0, 0, 0}, - {0, 255, 2, 1, 3, 255, 4, 255, 5, 255, 7, 6, 0, 0, 0, 0}, - {0, 255, 2, 1, 3, 255, 4, 255, 6, 5, 7, 255, 0, 0, 0, 0}, - {0, 255, 2, 1, 3, 255, 4, 255, 6, 5, 8, 7, 0, 0, 0, 0}, - {0, 255, 2, 1, 3, 255, 5, 4, 6, 255, 7, 255, 0, 0, 0, 0}, - {0, 255, 2, 1, 3, 255, 5, 4, 6, 255, 8, 7, 0, 0, 0, 0}, - {0, 255, 2, 1, 3, 255, 5, 4, 7, 6, 8, 255, 0, 0, 0, 0}, - {0, 255, 2, 1, 3, 255, 5, 4, 7, 6, 9, 8, 0, 0, 0, 0}, - {0, 255, 2, 1, 4, 3, 5, 255, 6, 255, 7, 255, 0, 0, 0, 0}, - {0, 255, 2, 1, 4, 3, 5, 255, 6, 255, 8, 7, 0, 0, 0, 0}, - {0, 255, 2, 1, 4, 3, 5, 255, 7, 6, 8, 255, 0, 0, 0, 0}, - {0, 255, 2, 1, 4, 3, 5, 255, 7, 6, 9, 8, 0, 0, 0, 0}, - {0, 255, 2, 1, 4, 3, 6, 5, 7, 255, 8, 255, 0, 0, 0, 0}, - {0, 255, 2, 1, 4, 3, 6, 5, 7, 255, 9, 8, 0, 0, 0, 0}, - {0, 255, 2, 1, 4, 3, 6, 5, 8, 7, 9, 255, 0, 0, 0, 0}, - {0, 255, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 0, 0, 0, 0}, - {1, 0, 2, 255, 3, 255, 4, 255, 5, 255, 6, 255, 0, 0, 0, 0}, - {1, 0, 2, 255, 3, 255, 4, 255, 5, 255, 7, 6, 0, 0, 0, 0}, - {1, 0, 2, 255, 3, 255, 4, 255, 6, 5, 7, 255, 0, 0, 0, 0}, - {1, 0, 2, 255, 3, 255, 4, 255, 6, 5, 8, 7, 0, 0, 0, 0}, - {1, 0, 2, 255, 3, 255, 5, 4, 6, 255, 7, 255, 0, 0, 0, 0}, - {1, 0, 2, 255, 3, 255, 5, 4, 6, 255, 8, 7, 0, 0, 0, 0}, - {1, 0, 2, 255, 3, 255, 5, 4, 7, 6, 8, 255, 0, 0, 0, 0}, - {1, 0, 2, 255, 3, 255, 5, 4, 7, 6, 9, 8, 0, 0, 0, 0}, - {1, 0, 2, 255, 4, 3, 5, 255, 6, 255, 7, 255, 0, 0, 0, 0}, - {1, 0, 2, 255, 4, 3, 5, 255, 6, 255, 8, 7, 0, 0, 0, 0}, - {1, 0, 2, 255, 4, 3, 5, 255, 7, 6, 8, 255, 0, 0, 0, 0}, - {1, 0, 2, 255, 4, 3, 5, 255, 7, 6, 9, 8, 0, 0, 0, 0}, - {1, 0, 2, 255, 4, 3, 6, 5, 7, 255, 8, 255, 0, 0, 0, 0}, - {1, 0, 2, 255, 4, 3, 6, 5, 7, 255, 9, 8, 0, 0, 0, 0}, - {1, 0, 2, 255, 4, 3, 6, 5, 8, 7, 9, 255, 0, 0, 0, 0}, - {1, 0, 2, 255, 4, 3, 6, 5, 8, 7, 10, 9, 0, 0, 0, 0}, - {1, 0, 3, 2, 4, 255, 5, 255, 6, 255, 7, 255, 0, 0, 0, 0}, - {1, 0, 3, 2, 4, 255, 5, 255, 6, 255, 8, 7, 0, 0, 0, 0}, - {1, 0, 3, 2, 4, 255, 5, 255, 7, 6, 8, 255, 0, 0, 0, 0}, - {1, 0, 3, 2, 4, 255, 5, 255, 7, 6, 9, 8, 0, 0, 0, 0}, - {1, 0, 3, 2, 4, 255, 6, 5, 7, 255, 8, 255, 0, 0, 0, 0}, - {1, 0, 3, 2, 4, 255, 6, 5, 7, 255, 9, 8, 0, 0, 0, 0}, - {1, 0, 3, 2, 4, 255, 6, 5, 8, 7, 9, 255, 0, 0, 0, 0}, - {1, 0, 3, 2, 4, 255, 6, 5, 8, 7, 10, 9, 0, 0, 0, 0}, - {1, 0, 3, 2, 5, 4, 6, 255, 7, 255, 8, 255, 0, 0, 0, 0}, - {1, 0, 3, 2, 5, 4, 6, 255, 7, 255, 9, 8, 0, 0, 0, 0}, - {1, 0, 3, 2, 5, 4, 6, 255, 8, 7, 9, 255, 0, 0, 0, 0}, - {1, 0, 3, 2, 5, 4, 6, 255, 8, 7, 10, 9, 0, 0, 0, 0}, - {1, 0, 3, 2, 5, 4, 7, 6, 8, 255, 9, 255, 0, 0, 0, 0}, - {1, 0, 3, 2, 5, 4, 7, 6, 8, 255, 10, 9, 0, 0, 0, 0}, - {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 10, 255, 0, 0, 0, 0}, - {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 0, 0, 0, 0}, - {0, 255, 255, 255, 1, 255, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 3, 255, 255, 255, 4, 255, 255, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 3, 255, 255, 255, 5, 4, 255, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 3, 255, 255, 255, 6, 5, 4, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 4, 3, 255, 255, 5, 255, 255, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 4, 3, 255, 255, 6, 5, 255, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 4, 3, 255, 255, 7, 6, 5, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 5, 4, 3, 255, 6, 255, 255, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 5, 4, 3, 255, 7, 6, 255, 255}, - {0, 255, 255, 255, 2, 1, 255, 255, 5, 4, 3, 255, 8, 7, 6, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 4, 255, 255, 255, 5, 255, 255, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 4, 255, 255, 255, 6, 5, 255, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 4, 255, 255, 255, 7, 6, 5, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 5, 4, 255, 255, 6, 255, 255, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 5, 4, 255, 255, 7, 6, 255, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 5, 4, 255, 255, 8, 7, 6, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 6, 5, 4, 255, 7, 255, 255, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 6, 5, 4, 255, 8, 7, 255, 255}, - {0, 255, 255, 255, 3, 2, 1, 255, 6, 5, 4, 255, 9, 8, 7, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255, 4, 255, 255, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255, 5, 4, 255, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255, 6, 5, 4, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255, 5, 255, 255, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255, 6, 5, 255, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255, 7, 6, 5, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255, 6, 255, 255, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255, 7, 6, 255, 255}, - {1, 0, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255, 8, 7, 6, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255, 5, 255, 255, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255, 6, 5, 255, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255, 7, 6, 5, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255, 6, 255, 255, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255, 7, 6, 255, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255, 8, 7, 6, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255, 7, 255, 255, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255, 8, 7, 255, 255}, - {1, 0, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255, 9, 8, 7, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255, 6, 255, 255, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255, 7, 6, 255, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255, 8, 7, 6, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255, 7, 255, 255, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255, 8, 7, 255, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255, 9, 8, 7, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255, 8, 255, 255, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255, 9, 8, 255, 255}, - {1, 0, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255, 10, 9, 8, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 4, 255, 255, 255, 5, 255, 255, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 4, 255, 255, 255, 6, 5, 255, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 4, 255, 255, 255, 7, 6, 5, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 5, 4, 255, 255, 6, 255, 255, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 5, 4, 255, 255, 7, 6, 255, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 5, 4, 255, 255, 8, 7, 6, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 6, 5, 4, 255, 7, 255, 255, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 6, 5, 4, 255, 8, 7, 255, 255}, - {2, 1, 0, 255, 3, 255, 255, 255, 6, 5, 4, 255, 9, 8, 7, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 5, 255, 255, 255, 6, 255, 255, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 5, 255, 255, 255, 7, 6, 255, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 5, 255, 255, 255, 8, 7, 6, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 6, 5, 255, 255, 7, 255, 255, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 6, 5, 255, 255, 8, 7, 255, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 6, 5, 255, 255, 9, 8, 7, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 7, 6, 5, 255, 8, 255, 255, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 7, 6, 5, 255, 9, 8, 255, 255}, - {2, 1, 0, 255, 4, 3, 255, 255, 7, 6, 5, 255, 10, 9, 8, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 6, 255, 255, 255, 7, 255, 255, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 6, 255, 255, 255, 8, 7, 255, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 6, 255, 255, 255, 9, 8, 7, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 7, 6, 255, 255, 8, 255, 255, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 7, 6, 255, 255, 9, 8, 255, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 7, 6, 255, 255, 10, 9, 8, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 9, 255, 255, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 10, 9, 255, 255}, - {2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255}, - {0, 255, 255, 255, 1, 255, 255, 255, 2, 255, 255, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 1, 255, 255, 255, 3, 2, 255, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 1, 255, 255, 255, 4, 3, 2, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 1, 255, 255, 255, 5, 4, 3, 2, 0, 0, 0, 0}, - {0, 255, 255, 255, 2, 1, 255, 255, 3, 255, 255, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 2, 1, 255, 255, 4, 3, 255, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 2, 1, 255, 255, 5, 4, 3, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 2, 1, 255, 255, 6, 5, 4, 3, 0, 0, 0, 0}, - {0, 255, 255, 255, 3, 2, 1, 255, 4, 255, 255, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 3, 2, 1, 255, 5, 4, 255, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 3, 2, 1, 255, 6, 5, 4, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 3, 2, 1, 255, 7, 6, 5, 4, 0, 0, 0, 0}, - {0, 255, 255, 255, 4, 3, 2, 1, 5, 255, 255, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 4, 3, 2, 1, 6, 5, 255, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 4, 3, 2, 1, 7, 6, 5, 255, 0, 0, 0, 0}, - {0, 255, 255, 255, 4, 3, 2, 1, 8, 7, 6, 5, 0, 0, 0, 0}, - {1, 0, 255, 255, 2, 255, 255, 255, 3, 255, 255, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 2, 255, 255, 255, 4, 3, 255, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 2, 255, 255, 255, 5, 4, 3, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 2, 255, 255, 255, 6, 5, 4, 3, 0, 0, 0, 0}, - {1, 0, 255, 255, 3, 2, 255, 255, 4, 255, 255, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 3, 2, 255, 255, 5, 4, 255, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 3, 2, 255, 255, 6, 5, 4, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 3, 2, 255, 255, 7, 6, 5, 4, 0, 0, 0, 0}, - {1, 0, 255, 255, 4, 3, 2, 255, 5, 255, 255, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 4, 3, 2, 255, 6, 5, 255, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 4, 3, 2, 255, 7, 6, 5, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 4, 3, 2, 255, 8, 7, 6, 5, 0, 0, 0, 0}, - {1, 0, 255, 255, 5, 4, 3, 2, 6, 255, 255, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 5, 4, 3, 2, 7, 6, 255, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 5, 4, 3, 2, 8, 7, 6, 255, 0, 0, 0, 0}, - {1, 0, 255, 255, 5, 4, 3, 2, 9, 8, 7, 6, 0, 0, 0, 0}, - {2, 1, 0, 255, 3, 255, 255, 255, 4, 255, 255, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 3, 255, 255, 255, 5, 4, 255, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 3, 255, 255, 255, 6, 5, 4, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 3, 255, 255, 255, 7, 6, 5, 4, 0, 0, 0, 0}, - {2, 1, 0, 255, 4, 3, 255, 255, 5, 255, 255, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 4, 3, 255, 255, 6, 5, 255, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 4, 3, 255, 255, 7, 6, 5, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 4, 3, 255, 255, 8, 7, 6, 5, 0, 0, 0, 0}, - {2, 1, 0, 255, 5, 4, 3, 255, 6, 255, 255, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 5, 4, 3, 255, 7, 6, 255, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 5, 4, 3, 255, 9, 8, 7, 6, 0, 0, 0, 0}, - {2, 1, 0, 255, 6, 5, 4, 3, 7, 255, 255, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 6, 5, 4, 3, 8, 7, 255, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 6, 5, 4, 3, 9, 8, 7, 255, 0, 0, 0, 0}, - {2, 1, 0, 255, 6, 5, 4, 3, 10, 9, 8, 7, 0, 0, 0, 0}, - {3, 2, 1, 0, 4, 255, 255, 255, 5, 255, 255, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 4, 255, 255, 255, 6, 5, 255, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 4, 255, 255, 255, 7, 6, 5, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 4, 255, 255, 255, 8, 7, 6, 5, 0, 0, 0, 0}, - {3, 2, 1, 0, 5, 4, 255, 255, 6, 255, 255, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 5, 4, 255, 255, 7, 6, 255, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 5, 4, 255, 255, 8, 7, 6, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 5, 4, 255, 255, 9, 8, 7, 6, 0, 0, 0, 0}, - {3, 2, 1, 0, 6, 5, 4, 255, 7, 255, 255, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 6, 5, 4, 255, 8, 7, 255, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 6, 5, 4, 255, 9, 8, 7, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 6, 5, 4, 255, 10, 9, 8, 7, 0, 0, 0, 0}, - {3, 2, 1, 0, 7, 6, 5, 4, 8, 255, 255, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 7, 6, 5, 4, 9, 8, 255, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 7, 6, 5, 4, 10, 9, 8, 255, 0, 0, 0, 0}, - {3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 0, 0, 0, 0}}; -/* number of two bytes : 64 */ -/* number of two + three bytes : 145 */ -/* number of two + three + four bytes : 209 */ -const uint8_t utf8bigindex[4096][2] = -{ {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {147, 5}, - {0, 12}, - {150, 5}, - {162, 5}, - {65, 5}, - {0, 12}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {148, 6}, - {0, 12}, - {151, 6}, - {163, 6}, - {66, 6}, - {0, 12}, - {154, 6}, - {166, 6}, - {68, 6}, - {178, 6}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {169, 6}, - {70, 6}, - {181, 6}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {152, 7}, - {164, 7}, - {145, 3}, - {0, 12}, - {155, 7}, - {167, 7}, - {69, 7}, - {179, 7}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {170, 7}, - {71, 7}, - {182, 7}, - {77, 7}, - {95, 7}, - {65, 5}, - {194, 7}, - {83, 7}, - {101, 7}, - {67, 5}, - {119, 7}, - {73, 5}, - {91, 5}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {185, 7}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {68, 6}, - {121, 7}, - {74, 6}, - {92, 6}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {76, 6}, - {94, 6}, - {4, 7}, - {193, 6}, - {82, 6}, - {100, 6}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {171, 8}, - {72, 8}, - {183, 8}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {186, 8}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {104, 8}, - {68, 6}, - {122, 8}, - {74, 6}, - {92, 6}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {76, 6}, - {94, 6}, - {5, 8}, - {193, 6}, - {82, 6}, - {100, 6}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {77, 7}, - {95, 7}, - {6, 8}, - {194, 7}, - {83, 7}, - {101, 7}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {160, 9}, - {172, 9}, - {147, 5}, - {184, 9}, - {150, 5}, - {162, 5}, - {65, 5}, - {196, 9}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {175, 9}, - {148, 6}, - {187, 9}, - {81, 9}, - {99, 9}, - {66, 6}, - {199, 9}, - {87, 9}, - {105, 9}, - {68, 6}, - {123, 9}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {111, 9}, - {70, 6}, - {129, 9}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {190, 9}, - {152, 7}, - {164, 7}, - {145, 3}, - {202, 9}, - {89, 9}, - {107, 9}, - {69, 7}, - {125, 9}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {113, 9}, - {71, 7}, - {131, 9}, - {77, 7}, - {95, 7}, - {7, 9}, - {194, 7}, - {83, 7}, - {101, 7}, - {11, 9}, - {119, 7}, - {19, 9}, - {35, 9}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {137, 9}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {13, 9}, - {121, 7}, - {21, 9}, - {37, 9}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {25, 9}, - {41, 9}, - {4, 7}, - {193, 6}, - {82, 6}, - {49, 9}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {205, 9}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {115, 9}, - {72, 8}, - {133, 9}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {139, 9}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {104, 8}, - {14, 9}, - {122, 8}, - {22, 9}, - {38, 9}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {26, 9}, - {42, 9}, - {5, 8}, - {193, 6}, - {82, 6}, - {50, 9}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {28, 9}, - {44, 9}, - {6, 8}, - {194, 7}, - {83, 7}, - {52, 9}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {56, 9}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {147, 5}, - {0, 12}, - {150, 5}, - {162, 5}, - {65, 5}, - {0, 12}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {176, 10}, - {148, 6}, - {188, 10}, - {151, 6}, - {163, 6}, - {66, 6}, - {200, 10}, - {154, 6}, - {166, 6}, - {68, 6}, - {178, 6}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {169, 6}, - {70, 6}, - {181, 6}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {191, 10}, - {152, 7}, - {164, 7}, - {145, 3}, - {203, 10}, - {90, 10}, - {108, 10}, - {69, 7}, - {126, 10}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {114, 10}, - {71, 7}, - {132, 10}, - {77, 7}, - {95, 7}, - {65, 5}, - {194, 7}, - {83, 7}, - {101, 7}, - {67, 5}, - {119, 7}, - {73, 5}, - {91, 5}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {138, 10}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {68, 6}, - {121, 7}, - {74, 6}, - {92, 6}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {76, 6}, - {94, 6}, - {4, 7}, - {193, 6}, - {82, 6}, - {100, 6}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {206, 10}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {116, 10}, - {72, 8}, - {134, 10}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {140, 10}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {104, 8}, - {15, 10}, - {122, 8}, - {23, 10}, - {39, 10}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {27, 10}, - {43, 10}, - {5, 8}, - {193, 6}, - {82, 6}, - {51, 10}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {29, 10}, - {45, 10}, - {6, 8}, - {194, 7}, - {83, 7}, - {53, 10}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {57, 10}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {160, 9}, - {172, 9}, - {147, 5}, - {184, 9}, - {150, 5}, - {162, 5}, - {65, 5}, - {196, 9}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {175, 9}, - {148, 6}, - {142, 10}, - {81, 9}, - {99, 9}, - {66, 6}, - {199, 9}, - {87, 9}, - {105, 9}, - {68, 6}, - {123, 9}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {111, 9}, - {70, 6}, - {129, 9}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {190, 9}, - {152, 7}, - {164, 7}, - {145, 3}, - {202, 9}, - {89, 9}, - {107, 9}, - {69, 7}, - {125, 9}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {113, 9}, - {71, 7}, - {131, 9}, - {30, 10}, - {46, 10}, - {7, 9}, - {194, 7}, - {83, 7}, - {54, 10}, - {11, 9}, - {119, 7}, - {19, 9}, - {35, 9}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {137, 9}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {58, 10}, - {13, 9}, - {121, 7}, - {21, 9}, - {37, 9}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {25, 9}, - {41, 9}, - {4, 7}, - {193, 6}, - {82, 6}, - {49, 9}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {205, 9}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {115, 9}, - {72, 8}, - {133, 9}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {139, 9}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {60, 10}, - {14, 9}, - {122, 8}, - {22, 9}, - {38, 9}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {26, 9}, - {42, 9}, - {5, 8}, - {193, 6}, - {82, 6}, - {50, 9}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {28, 9}, - {44, 9}, - {6, 8}, - {194, 7}, - {83, 7}, - {52, 9}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {56, 9}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {147, 5}, - {0, 12}, - {150, 5}, - {162, 5}, - {65, 5}, - {0, 12}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {148, 6}, - {0, 12}, - {151, 6}, - {163, 6}, - {66, 6}, - {0, 12}, - {154, 6}, - {166, 6}, - {68, 6}, - {178, 6}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {169, 6}, - {70, 6}, - {181, 6}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {192, 11}, - {152, 7}, - {164, 7}, - {145, 3}, - {204, 11}, - {155, 7}, - {167, 7}, - {69, 7}, - {179, 7}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {170, 7}, - {71, 7}, - {182, 7}, - {77, 7}, - {95, 7}, - {65, 5}, - {194, 7}, - {83, 7}, - {101, 7}, - {67, 5}, - {119, 7}, - {73, 5}, - {91, 5}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {185, 7}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {68, 6}, - {121, 7}, - {74, 6}, - {92, 6}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {76, 6}, - {94, 6}, - {4, 7}, - {193, 6}, - {82, 6}, - {100, 6}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {207, 11}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {117, 11}, - {72, 8}, - {135, 11}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {141, 11}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {104, 8}, - {68, 6}, - {122, 8}, - {74, 6}, - {92, 6}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {76, 6}, - {94, 6}, - {5, 8}, - {193, 6}, - {82, 6}, - {100, 6}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {77, 7}, - {95, 7}, - {6, 8}, - {194, 7}, - {83, 7}, - {101, 7}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {160, 9}, - {172, 9}, - {147, 5}, - {184, 9}, - {150, 5}, - {162, 5}, - {65, 5}, - {196, 9}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {175, 9}, - {148, 6}, - {143, 11}, - {81, 9}, - {99, 9}, - {66, 6}, - {199, 9}, - {87, 9}, - {105, 9}, - {68, 6}, - {123, 9}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {111, 9}, - {70, 6}, - {129, 9}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {190, 9}, - {152, 7}, - {164, 7}, - {145, 3}, - {202, 9}, - {89, 9}, - {107, 9}, - {69, 7}, - {125, 9}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {113, 9}, - {71, 7}, - {131, 9}, - {31, 11}, - {47, 11}, - {7, 9}, - {194, 7}, - {83, 7}, - {55, 11}, - {11, 9}, - {119, 7}, - {19, 9}, - {35, 9}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {137, 9}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {59, 11}, - {13, 9}, - {121, 7}, - {21, 9}, - {37, 9}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {25, 9}, - {41, 9}, - {4, 7}, - {193, 6}, - {82, 6}, - {49, 9}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {205, 9}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {115, 9}, - {72, 8}, - {133, 9}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {139, 9}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {61, 11}, - {14, 9}, - {122, 8}, - {22, 9}, - {38, 9}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {26, 9}, - {42, 9}, - {5, 8}, - {193, 6}, - {82, 6}, - {50, 9}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {28, 9}, - {44, 9}, - {6, 8}, - {194, 7}, - {83, 7}, - {52, 9}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {56, 9}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {147, 5}, - {0, 12}, - {150, 5}, - {162, 5}, - {65, 5}, - {0, 12}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {176, 10}, - {148, 6}, - {188, 10}, - {151, 6}, - {163, 6}, - {66, 6}, - {200, 10}, - {154, 6}, - {166, 6}, - {68, 6}, - {178, 6}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {169, 6}, - {70, 6}, - {181, 6}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {191, 10}, - {152, 7}, - {164, 7}, - {145, 3}, - {203, 10}, - {90, 10}, - {108, 10}, - {69, 7}, - {126, 10}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {114, 10}, - {71, 7}, - {132, 10}, - {77, 7}, - {95, 7}, - {65, 5}, - {194, 7}, - {83, 7}, - {101, 7}, - {67, 5}, - {119, 7}, - {73, 5}, - {91, 5}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {138, 10}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {68, 6}, - {121, 7}, - {74, 6}, - {92, 6}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {76, 6}, - {94, 6}, - {4, 7}, - {193, 6}, - {82, 6}, - {100, 6}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {206, 10}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {116, 10}, - {72, 8}, - {134, 10}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {140, 10}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {62, 11}, - {15, 10}, - {122, 8}, - {23, 10}, - {39, 10}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {27, 10}, - {43, 10}, - {5, 8}, - {193, 6}, - {82, 6}, - {51, 10}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {29, 10}, - {45, 10}, - {6, 8}, - {194, 7}, - {83, 7}, - {53, 10}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {57, 10}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {160, 9}, - {172, 9}, - {147, 5}, - {184, 9}, - {150, 5}, - {162, 5}, - {65, 5}, - {196, 9}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {175, 9}, - {148, 6}, - {142, 10}, - {81, 9}, - {99, 9}, - {66, 6}, - {199, 9}, - {87, 9}, - {105, 9}, - {68, 6}, - {123, 9}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {111, 9}, - {70, 6}, - {129, 9}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {190, 9}, - {152, 7}, - {164, 7}, - {145, 3}, - {202, 9}, - {89, 9}, - {107, 9}, - {69, 7}, - {125, 9}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {113, 9}, - {71, 7}, - {131, 9}, - {30, 10}, - {46, 10}, - {7, 9}, - {194, 7}, - {83, 7}, - {54, 10}, - {11, 9}, - {119, 7}, - {19, 9}, - {35, 9}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {137, 9}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {58, 10}, - {13, 9}, - {121, 7}, - {21, 9}, - {37, 9}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {25, 9}, - {41, 9}, - {4, 7}, - {193, 6}, - {82, 6}, - {49, 9}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {205, 9}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {115, 9}, - {72, 8}, - {133, 9}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {139, 9}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {60, 10}, - {14, 9}, - {122, 8}, - {22, 9}, - {38, 9}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {26, 9}, - {42, 9}, - {5, 8}, - {193, 6}, - {82, 6}, - {50, 9}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {28, 9}, - {44, 9}, - {6, 8}, - {194, 7}, - {83, 7}, - {52, 9}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {56, 9}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {147, 5}, - {0, 12}, - {150, 5}, - {162, 5}, - {65, 5}, - {0, 12}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {148, 6}, - {0, 12}, - {151, 6}, - {163, 6}, - {66, 6}, - {0, 12}, - {154, 6}, - {166, 6}, - {68, 6}, - {178, 6}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {169, 6}, - {70, 6}, - {181, 6}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {152, 7}, - {164, 7}, - {145, 3}, - {0, 12}, - {155, 7}, - {167, 7}, - {69, 7}, - {179, 7}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {170, 7}, - {71, 7}, - {182, 7}, - {77, 7}, - {95, 7}, - {65, 5}, - {194, 7}, - {83, 7}, - {101, 7}, - {67, 5}, - {119, 7}, - {73, 5}, - {91, 5}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {185, 7}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {68, 6}, - {121, 7}, - {74, 6}, - {92, 6}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {76, 6}, - {94, 6}, - {4, 7}, - {193, 6}, - {82, 6}, - {100, 6}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {208, 12}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {171, 8}, - {72, 8}, - {183, 8}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {186, 8}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {104, 8}, - {68, 6}, - {122, 8}, - {74, 6}, - {92, 6}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {76, 6}, - {94, 6}, - {5, 8}, - {193, 6}, - {82, 6}, - {100, 6}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {77, 7}, - {95, 7}, - {6, 8}, - {194, 7}, - {83, 7}, - {101, 7}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {160, 9}, - {172, 9}, - {147, 5}, - {184, 9}, - {150, 5}, - {162, 5}, - {65, 5}, - {196, 9}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {175, 9}, - {148, 6}, - {144, 12}, - {81, 9}, - {99, 9}, - {66, 6}, - {199, 9}, - {87, 9}, - {105, 9}, - {68, 6}, - {123, 9}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {111, 9}, - {70, 6}, - {129, 9}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {190, 9}, - {152, 7}, - {164, 7}, - {145, 3}, - {202, 9}, - {89, 9}, - {107, 9}, - {69, 7}, - {125, 9}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {113, 9}, - {71, 7}, - {131, 9}, - {77, 7}, - {95, 7}, - {7, 9}, - {194, 7}, - {83, 7}, - {101, 7}, - {11, 9}, - {119, 7}, - {19, 9}, - {35, 9}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {137, 9}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {13, 9}, - {121, 7}, - {21, 9}, - {37, 9}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {25, 9}, - {41, 9}, - {4, 7}, - {193, 6}, - {82, 6}, - {49, 9}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {205, 9}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {115, 9}, - {72, 8}, - {133, 9}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {139, 9}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {104, 8}, - {14, 9}, - {122, 8}, - {22, 9}, - {38, 9}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {26, 9}, - {42, 9}, - {5, 8}, - {193, 6}, - {82, 6}, - {50, 9}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {28, 9}, - {44, 9}, - {6, 8}, - {194, 7}, - {83, 7}, - {52, 9}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {56, 9}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {147, 5}, - {0, 12}, - {150, 5}, - {162, 5}, - {65, 5}, - {0, 12}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {176, 10}, - {148, 6}, - {188, 10}, - {151, 6}, - {163, 6}, - {66, 6}, - {200, 10}, - {154, 6}, - {166, 6}, - {68, 6}, - {178, 6}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {169, 6}, - {70, 6}, - {181, 6}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {191, 10}, - {152, 7}, - {164, 7}, - {145, 3}, - {203, 10}, - {90, 10}, - {108, 10}, - {69, 7}, - {126, 10}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {114, 10}, - {71, 7}, - {132, 10}, - {77, 7}, - {95, 7}, - {65, 5}, - {194, 7}, - {83, 7}, - {101, 7}, - {67, 5}, - {119, 7}, - {73, 5}, - {91, 5}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {138, 10}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {68, 6}, - {121, 7}, - {74, 6}, - {92, 6}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {76, 6}, - {94, 6}, - {4, 7}, - {193, 6}, - {82, 6}, - {100, 6}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {206, 10}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {116, 10}, - {72, 8}, - {134, 10}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {140, 10}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {63, 12}, - {15, 10}, - {122, 8}, - {23, 10}, - {39, 10}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {27, 10}, - {43, 10}, - {5, 8}, - {193, 6}, - {82, 6}, - {51, 10}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {29, 10}, - {45, 10}, - {6, 8}, - {194, 7}, - {83, 7}, - {53, 10}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {57, 10}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {160, 9}, - {172, 9}, - {147, 5}, - {184, 9}, - {150, 5}, - {162, 5}, - {65, 5}, - {196, 9}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {175, 9}, - {148, 6}, - {142, 10}, - {81, 9}, - {99, 9}, - {66, 6}, - {199, 9}, - {87, 9}, - {105, 9}, - {68, 6}, - {123, 9}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {111, 9}, - {70, 6}, - {129, 9}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {190, 9}, - {152, 7}, - {164, 7}, - {145, 3}, - {202, 9}, - {89, 9}, - {107, 9}, - {69, 7}, - {125, 9}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {113, 9}, - {71, 7}, - {131, 9}, - {30, 10}, - {46, 10}, - {7, 9}, - {194, 7}, - {83, 7}, - {54, 10}, - {11, 9}, - {119, 7}, - {19, 9}, - {35, 9}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {137, 9}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {58, 10}, - {13, 9}, - {121, 7}, - {21, 9}, - {37, 9}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {25, 9}, - {41, 9}, - {4, 7}, - {193, 6}, - {82, 6}, - {49, 9}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {205, 9}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {115, 9}, - {72, 8}, - {133, 9}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {139, 9}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {60, 10}, - {14, 9}, - {122, 8}, - {22, 9}, - {38, 9}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {26, 9}, - {42, 9}, - {5, 8}, - {193, 6}, - {82, 6}, - {50, 9}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {28, 9}, - {44, 9}, - {6, 8}, - {194, 7}, - {83, 7}, - {52, 9}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {56, 9}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {147, 5}, - {0, 12}, - {150, 5}, - {162, 5}, - {65, 5}, - {0, 12}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {148, 6}, - {0, 12}, - {151, 6}, - {163, 6}, - {66, 6}, - {0, 12}, - {154, 6}, - {166, 6}, - {68, 6}, - {178, 6}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {169, 6}, - {70, 6}, - {181, 6}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {192, 11}, - {152, 7}, - {164, 7}, - {145, 3}, - {204, 11}, - {155, 7}, - {167, 7}, - {69, 7}, - {179, 7}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {170, 7}, - {71, 7}, - {182, 7}, - {77, 7}, - {95, 7}, - {65, 5}, - {194, 7}, - {83, 7}, - {101, 7}, - {67, 5}, - {119, 7}, - {73, 5}, - {91, 5}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {185, 7}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {68, 6}, - {121, 7}, - {74, 6}, - {92, 6}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {76, 6}, - {94, 6}, - {4, 7}, - {193, 6}, - {82, 6}, - {100, 6}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {207, 11}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {117, 11}, - {72, 8}, - {135, 11}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {141, 11}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {104, 8}, - {68, 6}, - {122, 8}, - {74, 6}, - {92, 6}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {76, 6}, - {94, 6}, - {5, 8}, - {193, 6}, - {82, 6}, - {100, 6}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {77, 7}, - {95, 7}, - {6, 8}, - {194, 7}, - {83, 7}, - {101, 7}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {160, 9}, - {172, 9}, - {147, 5}, - {184, 9}, - {150, 5}, - {162, 5}, - {65, 5}, - {196, 9}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {175, 9}, - {148, 6}, - {143, 11}, - {81, 9}, - {99, 9}, - {66, 6}, - {199, 9}, - {87, 9}, - {105, 9}, - {68, 6}, - {123, 9}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {111, 9}, - {70, 6}, - {129, 9}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {190, 9}, - {152, 7}, - {164, 7}, - {145, 3}, - {202, 9}, - {89, 9}, - {107, 9}, - {69, 7}, - {125, 9}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {113, 9}, - {71, 7}, - {131, 9}, - {31, 11}, - {47, 11}, - {7, 9}, - {194, 7}, - {83, 7}, - {55, 11}, - {11, 9}, - {119, 7}, - {19, 9}, - {35, 9}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {137, 9}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {59, 11}, - {13, 9}, - {121, 7}, - {21, 9}, - {37, 9}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {25, 9}, - {41, 9}, - {4, 7}, - {193, 6}, - {82, 6}, - {49, 9}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {205, 9}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {115, 9}, - {72, 8}, - {133, 9}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {139, 9}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {61, 11}, - {14, 9}, - {122, 8}, - {22, 9}, - {38, 9}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {26, 9}, - {42, 9}, - {5, 8}, - {193, 6}, - {82, 6}, - {50, 9}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {28, 9}, - {44, 9}, - {6, 8}, - {194, 7}, - {83, 7}, - {52, 9}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {56, 9}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {0, 12}, - {0, 12}, - {147, 5}, - {0, 12}, - {150, 5}, - {162, 5}, - {65, 5}, - {0, 12}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {176, 10}, - {148, 6}, - {188, 10}, - {151, 6}, - {163, 6}, - {66, 6}, - {200, 10}, - {154, 6}, - {166, 6}, - {68, 6}, - {178, 6}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {169, 6}, - {70, 6}, - {181, 6}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {191, 10}, - {152, 7}, - {164, 7}, - {145, 3}, - {203, 10}, - {90, 10}, - {108, 10}, - {69, 7}, - {126, 10}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {114, 10}, - {71, 7}, - {132, 10}, - {77, 7}, - {95, 7}, - {65, 5}, - {194, 7}, - {83, 7}, - {101, 7}, - {67, 5}, - {119, 7}, - {73, 5}, - {91, 5}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {138, 10}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {103, 7}, - {68, 6}, - {121, 7}, - {74, 6}, - {92, 6}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {76, 6}, - {94, 6}, - {4, 7}, - {193, 6}, - {82, 6}, - {100, 6}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {206, 10}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {116, 10}, - {72, 8}, - {134, 10}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {140, 10}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {62, 11}, - {15, 10}, - {122, 8}, - {23, 10}, - {39, 10}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {27, 10}, - {43, 10}, - {5, 8}, - {193, 6}, - {82, 6}, - {51, 10}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {29, 10}, - {45, 10}, - {6, 8}, - {194, 7}, - {83, 7}, - {53, 10}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {57, 10}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {0, 12}, - {0, 12}, - {0, 12}, - {146, 4}, - {0, 12}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {160, 9}, - {172, 9}, - {147, 5}, - {184, 9}, - {150, 5}, - {162, 5}, - {65, 5}, - {196, 9}, - {153, 5}, - {165, 5}, - {67, 5}, - {177, 5}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {175, 9}, - {148, 6}, - {142, 10}, - {81, 9}, - {99, 9}, - {66, 6}, - {199, 9}, - {87, 9}, - {105, 9}, - {68, 6}, - {123, 9}, - {74, 6}, - {92, 6}, - {64, 4}, - {0, 12}, - {157, 6}, - {111, 9}, - {70, 6}, - {129, 9}, - {76, 6}, - {94, 6}, - {65, 5}, - {193, 6}, - {82, 6}, - {100, 6}, - {67, 5}, - {118, 6}, - {73, 5}, - {91, 5}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {190, 9}, - {152, 7}, - {164, 7}, - {145, 3}, - {202, 9}, - {89, 9}, - {107, 9}, - {69, 7}, - {125, 9}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {113, 9}, - {71, 7}, - {131, 9}, - {30, 10}, - {46, 10}, - {7, 9}, - {194, 7}, - {83, 7}, - {54, 10}, - {11, 9}, - {119, 7}, - {19, 9}, - {35, 9}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {137, 9}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {58, 10}, - {13, 9}, - {121, 7}, - {21, 9}, - {37, 9}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {25, 9}, - {41, 9}, - {4, 7}, - {193, 6}, - {82, 6}, - {49, 9}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {145, 3}, - {205, 9}, - {156, 8}, - {168, 8}, - {146, 4}, - {180, 8}, - {149, 4}, - {161, 4}, - {64, 4}, - {0, 12}, - {159, 8}, - {115, 9}, - {72, 8}, - {133, 9}, - {78, 8}, - {96, 8}, - {65, 5}, - {195, 8}, - {84, 8}, - {102, 8}, - {67, 5}, - {120, 8}, - {73, 5}, - {91, 5}, - {64, 4}, - {0, 12}, - {0, 12}, - {174, 8}, - {148, 6}, - {139, 9}, - {80, 8}, - {98, 8}, - {66, 6}, - {198, 8}, - {86, 8}, - {60, 10}, - {14, 9}, - {122, 8}, - {22, 9}, - {38, 9}, - {3, 8}, - {0, 12}, - {157, 6}, - {110, 8}, - {70, 6}, - {128, 8}, - {26, 9}, - {42, 9}, - {5, 8}, - {193, 6}, - {82, 6}, - {50, 9}, - {9, 8}, - {118, 6}, - {17, 8}, - {33, 8}, - {0, 6}, - {0, 12}, - {0, 12}, - {0, 12}, - {0, 12}, - {189, 8}, - {152, 7}, - {164, 7}, - {145, 3}, - {201, 8}, - {88, 8}, - {106, 8}, - {69, 7}, - {124, 8}, - {75, 7}, - {93, 7}, - {64, 4}, - {0, 12}, - {158, 7}, - {112, 8}, - {71, 7}, - {130, 8}, - {28, 9}, - {44, 9}, - {6, 8}, - {194, 7}, - {83, 7}, - {52, 9}, - {10, 8}, - {119, 7}, - {18, 8}, - {34, 8}, - {1, 7}, - {0, 12}, - {0, 12}, - {173, 7}, - {148, 6}, - {136, 8}, - {79, 7}, - {97, 7}, - {66, 6}, - {197, 7}, - {85, 7}, - {56, 9}, - {12, 8}, - {121, 7}, - {20, 8}, - {36, 8}, - {2, 7}, - {0, 12}, - {157, 6}, - {109, 7}, - {70, 6}, - {127, 7}, - {24, 8}, - {40, 8}, - {4, 7}, - {193, 6}, - {82, 6}, - {48, 8}, - {8, 7}, - {118, 6}, - {16, 7}, - {32, 7}, - {0, 6}}; -} // utf8_to_utf16 namespace -} // tables namespace +template +inline size_t convert(const char16_t* buf, size_t len, char* utf8_output) +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { utf8_output }; + while (pos < len) { + // try to convert the next block of 8 ASCII characters + if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if (!match_system(big_endian)) { + v = (v >> 8) | (v << (64 - 8)); + } + if ((v & 0xFF80FF80FF80FF80) == 0) { + size_t final_pos = pos + 4; + while (pos < final_pos) { + *utf8_output++ = !match_system(big_endian) ? char(utf16::swap_bytes(buf[pos])) : char(buf[pos]); + pos++; + } + continue; + } + } + uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + if ((word & 0xFF80) == 0) { + // will generate one UTF-8 bytes + *utf8_output++ = char(word); + pos++; + } else if ((word & 0xF800) == 0) { + // will generate two UTF-8 bytes + // we have 0b110XXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else if ((word & 0xF800) != 0xD800) { + // will generate three UTF-8 bytes + // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else { + // must be a surrogate pair + if (pos + 1 >= len) { + return 0; + } + uint16_t diff = uint16_t(word - 0xD800); + if (diff > 0x3FF) { + return 0; + } + uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if (diff2 > 0x3FF) { + return 0; + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + // will generate four UTF-8 bytes + // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + pos += 2; + } + } + return utf8_output - start; +} + +template +inline result convert_with_errors(const char16_t* buf, size_t len, char* utf8_output) +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { utf8_output }; + while (pos < len) { + // try to convert the next block of 8 ASCII characters + if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if (!match_system(big_endian)) + v = (v >> 8) | (v << (64 - 8)); + if ((v & 0xFF80FF80FF80FF80) == 0) { + size_t final_pos = pos + 4; + while (pos < final_pos) { + *utf8_output++ = !match_system(big_endian) ? char(utf16::swap_bytes(buf[pos])) : char(buf[pos]); + pos++; + } + continue; + } + } + uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + if ((word & 0xFF80) == 0) { + // will generate one UTF-8 bytes + *utf8_output++ = char(word); + pos++; + } else if ((word & 0xF800) == 0) { + // will generate two UTF-8 bytes + // we have 0b110XXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else if ((word & 0xF800) != 0xD800) { + // will generate three UTF-8 bytes + // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + pos++; + } else { + // must be a surrogate pair + if (pos + 1 >= len) { + return result(error_code::SURROGATE, pos); + } + uint16_t diff = uint16_t(word - 0xD800); + if (diff > 0x3FF) { + return result(error_code::SURROGATE, pos); + } + uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if (diff2 > 0x3FF) { + return result(error_code::SURROGATE, pos); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + // will generate four UTF-8 bytes + // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + pos += 2; + } + } + return result(error_code::SUCCESS, utf8_output - start); +} + +} // utf16_to_utf8 namespace } // unnamed namespace +} // namespace scalar } // namespace simdutf -#endif // SIMDUTF_UTF8_TO_UTF16_TABLES_H -/* end file src/tables/utf8_to_utf16_tables.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=tables/utf16_to_utf8_tables.h -/* begin file src/tables/utf16_to_utf8_tables.h */ -// file generated by scripts/sse_convert_utf16_to_utf8.py -#ifndef SIMDUTF_UTF16_TO_UTF8_TABLES_H -#define SIMDUTF_UTF16_TO_UTF8_TABLES_H +#endif +/* end file src/scalar/utf16_to_utf8/utf16_to_utf8.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf16_to_utf32/valid_utf16_to_utf32.h +/* begin file src/scalar/utf16_to_utf32/valid_utf16_to_utf32.h */ +#ifndef SIMDUTF_VALID_UTF16_TO_UTF32_H +#define SIMDUTF_VALID_UTF16_TO_UTF32_H namespace simdutf { +namespace scalar { namespace { -namespace tables { -namespace utf16_to_utf8 { +namespace utf16_to_utf32 { - // 1 byte for length, 16 bytes for mask - const uint8_t pack_1_2_utf8_bytes[256][17] = { - {16,1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14}, - {15,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14,0x80}, - {15,1,0,3,2,5,4,7,6,8,11,10,13,12,15,14,0x80}, - {14,0,3,2,5,4,7,6,8,11,10,13,12,15,14,0x80,0x80}, - {15,1,0,2,5,4,7,6,9,8,11,10,13,12,15,14,0x80}, - {14,0,2,5,4,7,6,9,8,11,10,13,12,15,14,0x80,0x80}, - {14,1,0,2,5,4,7,6,8,11,10,13,12,15,14,0x80,0x80}, - {13,0,2,5,4,7,6,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {15,1,0,3,2,5,4,7,6,9,8,10,13,12,15,14,0x80}, - {14,0,3,2,5,4,7,6,9,8,10,13,12,15,14,0x80,0x80}, - {14,1,0,3,2,5,4,7,6,8,10,13,12,15,14,0x80,0x80}, - {13,0,3,2,5,4,7,6,8,10,13,12,15,14,0x80,0x80,0x80}, - {14,1,0,2,5,4,7,6,9,8,10,13,12,15,14,0x80,0x80}, - {13,0,2,5,4,7,6,9,8,10,13,12,15,14,0x80,0x80,0x80}, - {13,1,0,2,5,4,7,6,8,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,2,5,4,7,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {15,1,0,3,2,4,7,6,9,8,11,10,13,12,15,14,0x80}, - {14,0,3,2,4,7,6,9,8,11,10,13,12,15,14,0x80,0x80}, - {14,1,0,3,2,4,7,6,8,11,10,13,12,15,14,0x80,0x80}, - {13,0,3,2,4,7,6,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {14,1,0,2,4,7,6,9,8,11,10,13,12,15,14,0x80,0x80}, - {13,0,2,4,7,6,9,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {13,1,0,2,4,7,6,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,2,4,7,6,8,11,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,4,7,6,9,8,10,13,12,15,14,0x80,0x80}, - {13,0,3,2,4,7,6,9,8,10,13,12,15,14,0x80,0x80,0x80}, - {13,1,0,3,2,4,7,6,8,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,4,7,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,4,7,6,9,8,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,2,4,7,6,9,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,7,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,7,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {15,1,0,3,2,5,4,7,6,9,8,11,10,12,15,14,0x80}, - {14,0,3,2,5,4,7,6,9,8,11,10,12,15,14,0x80,0x80}, - {14,1,0,3,2,5,4,7,6,8,11,10,12,15,14,0x80,0x80}, - {13,0,3,2,5,4,7,6,8,11,10,12,15,14,0x80,0x80,0x80}, - {14,1,0,2,5,4,7,6,9,8,11,10,12,15,14,0x80,0x80}, - {13,0,2,5,4,7,6,9,8,11,10,12,15,14,0x80,0x80,0x80}, - {13,1,0,2,5,4,7,6,8,11,10,12,15,14,0x80,0x80,0x80}, - {12,0,2,5,4,7,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,5,4,7,6,9,8,10,12,15,14,0x80,0x80}, - {13,0,3,2,5,4,7,6,9,8,10,12,15,14,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,7,6,8,10,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,7,6,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,5,4,7,6,9,8,10,12,15,14,0x80,0x80,0x80}, - {12,0,2,5,4,7,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,7,6,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,7,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,4,7,6,9,8,11,10,12,15,14,0x80,0x80}, - {13,0,3,2,4,7,6,9,8,11,10,12,15,14,0x80,0x80,0x80}, - {13,1,0,3,2,4,7,6,8,11,10,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,4,7,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,4,7,6,9,8,11,10,12,15,14,0x80,0x80,0x80}, - {12,0,2,4,7,6,9,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,7,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,7,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,4,7,6,9,8,10,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,4,7,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,7,6,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,7,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,7,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,7,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,7,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,7,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {15,1,0,3,2,5,4,6,9,8,11,10,13,12,15,14,0x80}, - {14,0,3,2,5,4,6,9,8,11,10,13,12,15,14,0x80,0x80}, - {14,1,0,3,2,5,4,6,8,11,10,13,12,15,14,0x80,0x80}, - {13,0,3,2,5,4,6,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {14,1,0,2,5,4,6,9,8,11,10,13,12,15,14,0x80,0x80}, - {13,0,2,5,4,6,9,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {13,1,0,2,5,4,6,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,2,5,4,6,8,11,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,5,4,6,9,8,10,13,12,15,14,0x80,0x80}, - {13,0,3,2,5,4,6,9,8,10,13,12,15,14,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,6,8,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,5,4,6,9,8,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,2,5,4,6,9,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,4,6,9,8,11,10,13,12,15,14,0x80,0x80}, - {13,0,3,2,4,6,9,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {13,1,0,3,2,4,6,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,4,6,8,11,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,4,6,9,8,11,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,2,4,6,9,8,11,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,6,8,11,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,6,8,11,10,13,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,4,6,9,8,10,13,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,4,6,9,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,6,9,8,10,13,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,6,9,8,10,13,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,6,8,10,13,12,15,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,5,4,6,9,8,11,10,12,15,14,0x80,0x80}, - {13,0,3,2,5,4,6,9,8,11,10,12,15,14,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,6,8,11,10,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,5,4,6,9,8,11,10,12,15,14,0x80,0x80,0x80}, - {12,0,2,5,4,6,9,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,6,9,8,10,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,5,4,6,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,5,4,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,5,4,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,5,4,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,4,6,9,8,11,10,12,15,14,0x80,0x80,0x80}, - {12,0,3,2,4,6,9,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,6,9,8,11,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,6,9,8,11,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,6,8,11,10,12,15,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,3,2,4,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,3,2,4,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,6,9,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,1,0,2,4,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,2,4,6,8,10,12,15,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {15,1,0,3,2,5,4,7,6,9,8,11,10,13,12,14,0x80}, - {14,0,3,2,5,4,7,6,9,8,11,10,13,12,14,0x80,0x80}, - {14,1,0,3,2,5,4,7,6,8,11,10,13,12,14,0x80,0x80}, - {13,0,3,2,5,4,7,6,8,11,10,13,12,14,0x80,0x80,0x80}, - {14,1,0,2,5,4,7,6,9,8,11,10,13,12,14,0x80,0x80}, - {13,0,2,5,4,7,6,9,8,11,10,13,12,14,0x80,0x80,0x80}, - {13,1,0,2,5,4,7,6,8,11,10,13,12,14,0x80,0x80,0x80}, - {12,0,2,5,4,7,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,5,4,7,6,9,8,10,13,12,14,0x80,0x80}, - {13,0,3,2,5,4,7,6,9,8,10,13,12,14,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,7,6,8,10,13,12,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,7,6,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,5,4,7,6,9,8,10,13,12,14,0x80,0x80,0x80}, - {12,0,2,5,4,7,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,7,6,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,7,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,4,7,6,9,8,11,10,13,12,14,0x80,0x80}, - {13,0,3,2,4,7,6,9,8,11,10,13,12,14,0x80,0x80,0x80}, - {13,1,0,3,2,4,7,6,8,11,10,13,12,14,0x80,0x80,0x80}, - {12,0,3,2,4,7,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,4,7,6,9,8,11,10,13,12,14,0x80,0x80,0x80}, - {12,0,2,4,7,6,9,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,7,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,7,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,4,7,6,9,8,10,13,12,14,0x80,0x80,0x80}, - {12,0,3,2,4,7,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,7,6,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,7,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,7,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,7,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,7,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,7,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,5,4,7,6,9,8,11,10,12,14,0x80,0x80}, - {13,0,3,2,5,4,7,6,9,8,11,10,12,14,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,7,6,8,11,10,12,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,7,6,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,5,4,7,6,9,8,11,10,12,14,0x80,0x80,0x80}, - {12,0,2,5,4,7,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,7,6,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,7,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,7,6,9,8,10,12,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,7,6,9,8,10,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,5,4,7,6,8,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,5,4,7,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,7,6,9,8,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,7,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,5,4,7,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,5,4,7,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,4,7,6,9,8,11,10,12,14,0x80,0x80,0x80}, - {12,0,3,2,4,7,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,7,6,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,7,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,7,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,7,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,7,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,7,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,7,6,9,8,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,7,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,3,2,4,7,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,3,2,4,7,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,7,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,7,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,1,0,2,4,7,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,2,4,7,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {14,1,0,3,2,5,4,6,9,8,11,10,13,12,14,0x80,0x80}, - {13,0,3,2,5,4,6,9,8,11,10,13,12,14,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,6,8,11,10,13,12,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {13,1,0,2,5,4,6,9,8,11,10,13,12,14,0x80,0x80,0x80}, - {12,0,2,5,4,6,9,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,6,9,8,10,13,12,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,5,4,6,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,5,4,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,5,4,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,5,4,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,4,6,9,8,11,10,13,12,14,0x80,0x80,0x80}, - {12,0,3,2,4,6,9,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,4,6,9,8,11,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,4,6,9,8,11,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,6,8,11,10,13,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,3,2,4,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,3,2,4,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,6,9,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,1,0,2,4,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,2,4,6,8,10,13,12,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {13,1,0,3,2,5,4,6,9,8,11,10,12,14,0x80,0x80,0x80}, - {12,0,3,2,5,4,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,5,4,6,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,5,4,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,2,5,4,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,2,5,4,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,5,4,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,5,4,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,5,4,6,9,8,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,5,4,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,3,2,5,4,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,3,2,5,4,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,5,4,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,5,4,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,1,0,2,5,4,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,2,5,4,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {12,1,0,3,2,4,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80}, - {11,0,3,2,4,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,3,2,4,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,3,2,4,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,2,4,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,2,4,6,9,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,1,0,2,4,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,2,4,6,8,11,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,1,0,3,2,4,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80}, - {10,0,3,2,4,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,1,0,3,2,4,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,3,2,4,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,1,0,2,4,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,2,4,6,9,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,1,0,2,4,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,0,2,4,6,8,10,12,14,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80} - }; - - // 1 byte for length, 16 bytes for mask - const uint8_t pack_1_2_3_utf8_bytes[256][17] = { - {12,2,3,1,6,7,5,10,11,9,14,15,13,0x80,0x80,0x80,0x80}, - {9,6,7,5,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,3,1,6,7,5,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80}, - {10,0,6,7,5,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,2,3,1,7,5,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80}, - {8,7,5,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,3,1,7,5,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,7,5,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,2,3,1,4,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,4,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,3,1,4,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,0,4,10,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,6,7,5,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,6,7,5,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,6,7,5,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,6,7,5,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,7,5,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,7,5,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,7,5,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,7,5,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,4,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,4,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,4,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,4,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,2,3,1,6,7,5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80}, - {8,6,7,5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,3,1,6,7,5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,6,7,5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,2,3,1,7,5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,7,5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,3,1,7,5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,0,7,5,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,4,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,4,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,4,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,4,11,9,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,2,3,1,6,7,5,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,6,7,5,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,3,1,6,7,5,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,0,6,7,5,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,7,5,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,7,5,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,7,5,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,7,5,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,4,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,4,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,4,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,4,8,14,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,6,7,5,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,6,7,5,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,6,7,5,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,6,7,5,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,7,5,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,7,5,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,7,5,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,7,5,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,4,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,4,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,4,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,4,10,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,6,7,5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,6,7,5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,6,7,5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,6,7,5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,2,3,1,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,3,1,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {1,0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,2,3,1,7,5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,7,5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,3,1,7,5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,0,7,5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,2,3,1,4,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {1,4,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,3,1,4,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,0,4,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,6,7,5,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,6,7,5,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,6,7,5,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,6,7,5,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,2,3,1,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,3,1,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,0,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,7,5,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,7,5,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,7,5,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,7,5,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,4,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,4,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,4,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,4,11,9,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,6,7,5,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,6,7,5,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,6,7,5,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,6,7,5,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,2,3,1,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {1,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,3,1,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,0,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,7,5,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,7,5,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,7,5,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,7,5,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,2,3,1,4,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,4,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,3,1,4,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,0,4,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {11,2,3,1,6,7,5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80}, - {8,6,7,5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,3,1,6,7,5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,0,6,7,5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,2,3,1,7,5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,7,5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,3,1,7,5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,0,7,5,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,4,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,4,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,4,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,4,10,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,6,7,5,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,6,7,5,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,6,7,5,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,6,7,5,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,2,3,1,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,3,1,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,0,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,7,5,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,7,5,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,7,5,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,7,5,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,4,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,4,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,4,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,4,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,2,3,1,6,7,5,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,6,7,5,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,3,1,6,7,5,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,0,6,7,5,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,7,5,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,7,5,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,7,5,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,7,5,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,4,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,4,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,4,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,4,11,9,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,6,7,5,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,6,7,5,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,6,7,5,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,6,7,5,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,7,5,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,7,5,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,7,5,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,7,5,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,4,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,4,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,4,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,4,8,15,13,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {10,2,3,1,6,7,5,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,6,7,5,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,3,1,6,7,5,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,0,6,7,5,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,7,5,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,7,5,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,7,5,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,7,5,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,4,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,4,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,4,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,4,10,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,6,7,5,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,6,7,5,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,6,7,5,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,6,7,5,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,2,3,1,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {1,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,3,1,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,0,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,7,5,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,7,5,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,7,5,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,7,5,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,2,3,1,4,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,4,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,3,1,4,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,0,4,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {9,2,3,1,6,7,5,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,6,7,5,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,3,1,6,7,5,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,0,6,7,5,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,7,5,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,7,5,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,7,5,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,7,5,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,4,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,4,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,4,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,4,11,9,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {8,2,3,1,6,7,5,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,6,7,5,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,3,1,6,7,5,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,0,6,7,5,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,2,3,1,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {2,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,3,1,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,0,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {7,2,3,1,7,5,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,7,5,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,3,1,7,5,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,0,7,5,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {6,2,3,1,4,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {3,4,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {5,3,1,4,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, - {4,0,4,8,12,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80} - }; +template +inline size_t convert_valid(const char16_t* buf, size_t len, char32_t* utf32_output) +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + char32_t* start { utf32_output }; + while (pos < len) { + uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + if ((word & 0xF800) != 0xD800) { + // No surrogate pair, extend 16-bit word to 32-bit word + *utf32_output++ = char32_t(word); + pos++; + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + if (pos + 1 >= len) { + return 0; + } // minimal bound checking + uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + pos += 2; + } + } + return utf32_output - start; +} -} // utf16_to_utf8 namespace -} // tables namespace +} // utf16_to_utf32 namespace } // unnamed namespace +} // namespace scalar } // namespace simdutf -#endif // SIMDUTF_UTF16_TO_UTF8_TABLES_H -/* end file src/tables/utf16_to_utf8_tables.h */ -// End of tables. - -// The scalar routines should be included once. -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/ascii.h -/* begin file src/scalar/ascii.h */ -#ifndef SIMDUTF_ASCII_H -#define SIMDUTF_ASCII_H +#endif +/* end file src/scalar/utf16_to_utf32/valid_utf16_to_utf32.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf16_to_utf32/utf16_to_utf32.h +/* begin file src/scalar/utf16_to_utf32/utf16_to_utf32.h */ +#ifndef SIMDUTF_UTF16_TO_UTF32_H +#define SIMDUTF_UTF16_TO_UTF32_H namespace simdutf { namespace scalar { namespace { -namespace ascii { -#if SIMDUTF_IMPLEMENTATION_FALLBACK -// Only used by the fallback kernel. -inline simdutf_warn_unused bool validate(const char *buf, size_t len) noexcept { - const uint8_t *data = reinterpret_cast(buf); - uint64_t pos = 0; - // process in blocks of 16 bytes when possible - for (;pos + 16 < len; pos += 16) { - uint64_t v1; - std::memcpy(&v1, data + pos, sizeof(uint64_t)); - uint64_t v2; - std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); - uint64_t v{v1 | v2}; - if ((v & 0x8080808080808080) != 0) { return false; } - } - // process the tail byte-by-byte - for (;pos < len; pos ++) { - if (data[pos] >= 0b10000000) { return false; } +namespace utf16_to_utf32 { + +template +inline size_t convert(const char16_t* buf, size_t len, char32_t* utf32_output) +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + char32_t* start { utf32_output }; + while (pos < len) { + uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + if ((word & 0xF800) != 0xD800) { + // No surrogate pair, extend 16-bit word to 32-bit word + *utf32_output++ = char32_t(word); + pos++; + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + if (diff > 0x3FF) { + return 0; + } + if (pos + 1 >= len) { + return 0; + } // minimal bound checking + uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if (diff2 > 0x3FF) { + return 0; + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + pos += 2; + } } - return true; + return utf32_output - start; } -#endif -inline simdutf_warn_unused result validate_with_errors(const char *buf, size_t len) noexcept { - const uint8_t *data = reinterpret_cast(buf); +template +inline result convert_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) +{ + const uint16_t* data = reinterpret_cast(buf); size_t pos = 0; - // process in blocks of 16 bytes when possible - for (;pos + 16 < len; pos += 16) { - uint64_t v1; - std::memcpy(&v1, data + pos, sizeof(uint64_t)); - uint64_t v2; - std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); - uint64_t v{v1 | v2}; - if ((v & 0x8080808080808080) != 0) { - for (;pos < len; pos ++) { - if (data[pos] >= 0b10000000) { return result(error_code::TOO_LARGE, pos); } + char32_t* start { utf32_output }; + while (pos < len) { + uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + if ((word & 0xF800) != 0xD800) { + // No surrogate pair, extend 16-bit word to 32-bit word + *utf32_output++ = char32_t(word); + pos++; + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + if (diff > 0x3FF) { + return result(error_code::SURROGATE, pos); } + if (pos + 1 >= len) { + return result(error_code::SURROGATE, pos); + } // minimal bound checking + uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if (diff2 > 0x3FF) { + return result(error_code::SURROGATE, pos); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + pos += 2; } } - // process the tail byte-by-byte - for (;pos < len; pos ++) { - if (data[pos] >= 0b10000000) { return result(error_code::TOO_LARGE, pos); } - } - return result(error_code::SUCCESS, pos); + return result(error_code::SUCCESS, utf32_output - start); } -} // ascii namespace +} // utf16_to_utf32 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/ascii.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf8.h -/* begin file src/scalar/utf8.h */ -#ifndef SIMDUTF_UTF8_H -#define SIMDUTF_UTF8_H +/* end file src/scalar/utf16_to_utf32/utf16_to_utf32.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf8_to_utf16/valid_utf8_to_utf16.h +/* begin file src/scalar/utf8_to_utf16/valid_utf8_to_utf16.h */ +#ifndef SIMDUTF_VALID_UTF8_TO_UTF16_H +#define SIMDUTF_VALID_UTF8_TO_UTF16_H namespace simdutf { namespace scalar { namespace { -namespace utf8 { -#if SIMDUTF_IMPLEMENTATION_FALLBACK -// only used by the fallback kernel. -// credit: based on code from Google Fuchsia (Apache Licensed) -inline simdutf_warn_unused bool validate(const char *buf, size_t len) noexcept { - const uint8_t *data = reinterpret_cast(buf); - uint64_t pos = 0; - uint32_t code_point = 0; - while (pos < len) { - // check of the next 8 bytes are ascii. - uint64_t next_pos = pos + 16; - if (next_pos <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v1; - std::memcpy(&v1, data + pos, sizeof(uint64_t)); - uint64_t v2; - std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); - uint64_t v{v1 | v2}; - if ((v & 0x8080808080808080) == 0) { - pos = next_pos; - continue; - } - } - unsigned char byte = data[pos]; - - while (byte < 0b10000000) { - if (++pos == len) { return true; } - byte = data[pos]; - } - - if ((byte & 0b11100000) == 0b11000000) { - next_pos = pos + 2; - if (next_pos > len) { return false; } - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return false; } - // range check - code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); - if ((code_point < 0x80) || (0x7ff < code_point)) { return false; } - } else if ((byte & 0b11110000) == 0b11100000) { - next_pos = pos + 3; - if (next_pos > len) { return false; } - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return false; } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return false; } - // range check - code_point = (byte & 0b00001111) << 12 | - (data[pos + 1] & 0b00111111) << 6 | - (data[pos + 2] & 0b00111111); - if ((code_point < 0x800) || (0xffff < code_point) || - (0xd7ff < code_point && code_point < 0xe000)) { - return false; - } - } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000 - next_pos = pos + 4; - if (next_pos > len) { return false; } - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return false; } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return false; } - if ((data[pos + 3] & 0b11000000) != 0b10000000) { return false; } - // range check - code_point = - (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | - (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); - if (code_point <= 0xffff || 0x10ffff < code_point) { return false; } - } else { - // we may have a continuation - return false; +namespace utf8_to_utf16 { + +template +inline size_t convert_valid(const char* buf, size_t len, char16_t* utf16_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char16_t* start { utf16_output }; + while (pos < len) { + // try to convert the next block of 8 ASCII bytes + if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if ((v & 0x8080808080808080) == 0) { + size_t final_pos = pos + 8; + while (pos < final_pos) { + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(buf[pos])) : char16_t(buf[pos]); + pos++; + } + continue; + } + } + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(leading_byte)) : char16_t(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { + // We have a two-byte UTF-8, it should become + // a single UTF-16 word. + if (pos + 1 >= len) { + break; + } // minimal bound checking + uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) | (data[pos + 1] & 0b00111111)); + if (!match_system(big_endian)) { + code_point = utf16::swap_bytes(uint16_t(code_point)); + } + *utf16_output++ = char16_t(code_point); + pos += 2; + } else if ((leading_byte & 0b11110000) == 0b11100000) { + // We have a three-byte UTF-8, it should become + // a single UTF-16 word. + if (pos + 2 >= len) { + break; + } // minimal bound checking + uint16_t code_point = uint16_t(((leading_byte & 0b00001111) << 12) | ((data[pos + 1] & 0b00111111) << 6) | (data[pos + 2] & 0b00111111)); + if (!match_system(big_endian)) { + code_point = utf16::swap_bytes(uint16_t(code_point)); + } + *utf16_output++ = char16_t(code_point); + pos += 3; + } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 + // we have a 4-byte UTF-8 word. + if (pos + 3 >= len) { + break; + } // minimal bound checking + uint32_t code_point = ((leading_byte & 0b00000111) << 18) | ((data[pos + 1] & 0b00111111) << 12) + | ((data[pos + 2] & 0b00111111) << 6) | (data[pos + 3] & 0b00111111); + code_point -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF)); + if (!match_system(big_endian)) { + high_surrogate = utf16::swap_bytes(high_surrogate); + low_surrogate = utf16::swap_bytes(low_surrogate); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + pos += 4; + } else { + // we may have a continuation but we do not do error checking + return 0; + } } - pos = next_pos; - } - return true; + return utf16_output - start; } + +} // namespace utf8_to_utf16 +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + #endif +/* end file src/scalar/utf8_to_utf16/valid_utf8_to_utf16.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf8_to_utf16/utf8_to_utf16.h +/* begin file src/scalar/utf8_to_utf16/utf8_to_utf16.h */ +#ifndef SIMDUTF_UTF8_TO_UTF16_H +#define SIMDUTF_UTF8_TO_UTF16_H -inline simdutf_warn_unused result validate_with_errors(const char *buf, size_t len) noexcept { - const uint8_t *data = reinterpret_cast(buf); - size_t pos = 0; - uint32_t code_point = 0; - while (pos < len) { - // check of the next 8 bytes are ascii. - size_t next_pos = pos + 16; - if (next_pos <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v1; - std::memcpy(&v1, data + pos, sizeof(uint64_t)); - uint64_t v2; - std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); - uint64_t v{v1 | v2}; - if ((v & 0x8080808080808080) == 0) { - pos = next_pos; - continue; - } - } - unsigned char byte = data[pos]; - - while (byte < 0b10000000) { - if (++pos == len) { return result(error_code::SUCCESS, len); } - byte = data[pos]; - } - - if ((byte & 0b11100000) == 0b11000000) { - next_pos = pos + 2; - if (next_pos > len) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - // range check - code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); - if ((code_point < 0x80) || (0x7ff < code_point)) { return result(error_code::OVERLONG, pos); } - } else if ((byte & 0b11110000) == 0b11100000) { - next_pos = pos + 3; - if (next_pos > len) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - // range check - code_point = (byte & 0b00001111) << 12 | - (data[pos + 1] & 0b00111111) << 6 | - (data[pos + 2] & 0b00111111); - if ((code_point < 0x800) || (0xffff < code_point)) { return result(error_code::OVERLONG, pos);} - if (0xd7ff < code_point && code_point < 0xe000) { return result(error_code::SURROGATE, pos); } - } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000 - next_pos = pos + 4; - if (next_pos > len) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 3] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - // range check - code_point = - (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | - (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); - if (code_point <= 0xffff) { return result(error_code::OVERLONG, pos); } - if (0x10ffff < code_point) { return result(error_code::TOO_LARGE, pos); } - } else { - // we either have too many continuation bytes or an invalid leading byte - if ((byte & 0b11000000) == 0b10000000) { return result(error_code::TOO_LONG, pos); } - else { return result(error_code::HEADER_BITS, pos); } +namespace simdutf { +namespace scalar { +namespace { +namespace utf8_to_utf16 { + +template +inline size_t convert(const char* buf, size_t len, char16_t* utf16_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char16_t* start { utf16_output }; + while (pos < len) { + // try to convert the next block of 16 ASCII bytes + if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii + uint64_t v1; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; + if ((v & 0x8080808080808080) == 0) { + size_t final_pos = pos + 16; + while (pos < final_pos) { + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(buf[pos])) : char16_t(buf[pos]); + pos++; + } + continue; + } + } + + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(leading_byte)) : char16_t(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { + // We have a two-byte UTF-8, it should become + // a single UTF-16 word. + if (pos + 1 >= len) { + return 0; + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return 0; + } + // range check + uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); + if (code_point < 0x80 || 0x7ff < code_point) { + return 0; + } + if (!match_system(big_endian)) { + code_point = uint32_t(utf16::swap_bytes(uint16_t(code_point))); + } + *utf16_output++ = char16_t(code_point); + pos += 2; + } else if ((leading_byte & 0b11110000) == 0b11100000) { + // We have a three-byte UTF-8, it should become + // a single UTF-16 word. + if (pos + 2 >= len) { + return 0; + } // minimal bound checking + + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return 0; + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return 0; + } + // range check + uint32_t code_point = (leading_byte & 0b00001111) << 12 | (data[pos + 1] & 0b00111111) << 6 | (data[pos + 2] & 0b00111111); + if (code_point < 0x800 || 0xffff < code_point || (0xd7ff < code_point && code_point < 0xe000)) { + return 0; + } + if (!match_system(big_endian)) { + code_point = uint32_t(utf16::swap_bytes(uint16_t(code_point))); + } + *utf16_output++ = char16_t(code_point); + pos += 3; + } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 + // we have a 4-byte UTF-8 word. + if (pos + 3 >= len) { + return 0; + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return 0; + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return 0; + } + if ((data[pos + 3] & 0b11000000) != 0b10000000) { + return 0; + } + + // range check + uint32_t code_point = (leading_byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); + if (code_point <= 0xffff || 0x10ffff < code_point) { + return 0; + } + code_point -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF)); + if (!match_system(big_endian)) { + high_surrogate = utf16::swap_bytes(high_surrogate); + low_surrogate = utf16::swap_bytes(low_surrogate); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + pos += 4; + } else { + return 0; + } } - pos = next_pos; - } - return result(error_code::SUCCESS, len); + return utf16_output - start; } -// Finds the previous leading byte and validates with errors from there -// Used to pinpoint the location of an error when an invalid chunk is detected -inline simdutf_warn_unused result rewind_and_validate_with_errors(const char *buf, size_t len) noexcept { - size_t extra_len{0}; - // A leading byte cannot be further than 4 bytes away - for(int i = 0; i < 5; i++) { - unsigned char byte = *buf; - if ((byte & 0b11000000) != 0b10000000) { - break; - } else { - buf--; - extra_len++; - } - } +template +inline result convert_with_errors(const char* buf, size_t len, char16_t* utf16_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char16_t* start { utf16_output }; + while (pos < len) { + // try to convert the next block of 16 ASCII bytes + if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii + uint64_t v1; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; + if ((v & 0x8080808080808080) == 0) { + size_t final_pos = pos + 16; + while (pos < final_pos) { + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(buf[pos])) : char16_t(buf[pos]); + pos++; + } + continue; + } + } + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(leading_byte)) : char16_t(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { + // We have a two-byte UTF-8, it should become + // a single UTF-16 word. + if (pos + 1 >= len) { + return result(error_code::TOO_SHORT, pos); + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + // range check + uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); + if (code_point < 0x80 || 0x7ff < code_point) { + return result(error_code::OVERLONG, pos); + } + if (!match_system(big_endian)) { + code_point = uint32_t(utf16::swap_bytes(uint16_t(code_point))); + } + *utf16_output++ = char16_t(code_point); + pos += 2; + } else if ((leading_byte & 0b11110000) == 0b11100000) { + // We have a three-byte UTF-8, it should become + // a single UTF-16 word. + if (pos + 2 >= len) { + return result(error_code::TOO_SHORT, pos); + } // minimal bound checking + + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + // range check + uint32_t code_point = (leading_byte & 0b00001111) << 12 | (data[pos + 1] & 0b00111111) << 6 | (data[pos + 2] & 0b00111111); + if ((code_point < 0x800) || (0xffff < code_point)) { + return result(error_code::OVERLONG, pos); + } + if (0xd7ff < code_point && code_point < 0xe000) { + return result(error_code::SURROGATE, pos); + } + if (!match_system(big_endian)) { + code_point = uint32_t(utf16::swap_bytes(uint16_t(code_point))); + } + *utf16_output++ = char16_t(code_point); + pos += 3; + } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 + // we have a 4-byte UTF-8 word. + if (pos + 3 >= len) { + return result(error_code::TOO_SHORT, pos); + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 3] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } - result res = validate_with_errors(buf, len + extra_len); - res.count -= extra_len; - return res; + // range check + uint32_t code_point = (leading_byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); + if (code_point <= 0xffff) { + return result(error_code::OVERLONG, pos); + } + if (0x10ffff < code_point) { + return result(error_code::TOO_LARGE, pos); + } + code_point -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF)); + if (!match_system(big_endian)) { + high_surrogate = utf16::swap_bytes(high_surrogate); + low_surrogate = utf16::swap_bytes(low_surrogate); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + pos += 4; + } else { + // we either have too many continuation bytes or an invalid leading byte + if ((leading_byte & 0b11000000) == 0b10000000) { + return result(error_code::TOO_LONG, pos); + } else { + return result(error_code::HEADER_BITS, pos); + } + } + } + return result(error_code::SUCCESS, utf16_output - start); } -inline size_t count_code_points(const char* buf, size_t len) { - const int8_t * p = reinterpret_cast(buf); - size_t counter{0}; - for(size_t i = 0; i < len; i++) { - // -65 is 0b10111111, anything larger in two-complement's should start a new code point. - if(p[i] > -65) { counter++; } +/** + * When rewind_and_convert_with_errors is called, we are pointing at 'buf' and we have + * up to len input bytes left, and we encountered some error. It is possible that + * the error is at 'buf' exactly, but it could also be in the previous bytes (up to 3 bytes back). + * + * prior_bytes indicates how many bytes, prior to 'buf' may belong to the current memory section + * and can be safely accessed. We prior_bytes to access safely up to three bytes before 'buf'. + * + * The caller is responsible to ensure that len > 0. + * + * If the error is believed to have occured prior to 'buf', the count value contain in the result + * will be SIZE_T - 1, SIZE_T - 2, or SIZE_T - 3. + */ +template +inline result rewind_and_convert_with_errors(size_t prior_bytes, const char* buf, size_t len, char16_t* utf16_output) +{ + size_t extra_len { 0 }; + // We potentially need to go back in time and find a leading byte. + // In theory '3' would be sufficient, but sometimes the error can go back quite far. + size_t how_far_back = prior_bytes; + // size_t how_far_back = 3; // 3 bytes in the past + current position + // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; } + bool found_leading_bytes { false }; + // important: it is i <= how_far_back and not 'i < how_far_back'. + for (size_t i = 0; i <= how_far_back; i++) { + unsigned char byte = buf[0 - i]; + found_leading_bytes = ((byte & 0b11000000) != 0b10000000); + if (found_leading_bytes) { + buf -= i; + extra_len = i; + break; + } } - return counter; + // + // It is possible for this function to return a negative count in its result. + // C++ Standard Section 18.1 defines size_t is in which is described in C Standard as . + // C Standard Section 4.1.5 defines size_t as an unsigned integral type of the result of the sizeof operator + // + // An unsigned type will simply wrap round arithmetically (well defined). + // + if (!found_leading_bytes) { + // If how_far_back == 3, we may have four consecutive continuation bytes!!! + // [....] [continuation] [continuation] [continuation] | [buf is continuation] + // Or we possibly have a stream that does not start with a leading byte. + return result(error_code::TOO_LONG, 0 - how_far_back); + } + result res = convert_with_errors(buf, len + extra_len, utf16_output); + if (res.error) { + res.count -= extra_len; + } + return res; } -inline size_t utf16_length_from_utf8(const char* buf, size_t len) { - const int8_t * p = reinterpret_cast(buf); - size_t counter{0}; - for(size_t i = 0; i < len; i++) { - if(p[i] > -65) { counter++; } - if(uint8_t(p[i]) >= 240) { counter++; } +} // utf8_to_utf16 namespace +} // unnamed namespace +} // namespace scalar +} // namespace simdutf + +#endif +/* end file src/scalar/utf8_to_utf16/utf8_to_utf16.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf8_to_utf32/valid_utf8_to_utf32.h +/* begin file src/scalar/utf8_to_utf32/valid_utf8_to_utf32.h */ +#ifndef SIMDUTF_VALID_UTF8_TO_UTF32_H +#define SIMDUTF_VALID_UTF8_TO_UTF32_H + +namespace simdutf { +namespace scalar { +namespace { +namespace utf8_to_utf32 { + +inline size_t convert_valid(const char* buf, size_t len, char32_t* utf32_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char32_t* start { utf32_output }; + while (pos < len) { + // try to convert the next block of 8 ASCII bytes + if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that they are ascii + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if ((v & 0x8080808080808080) == 0) { + size_t final_pos = pos + 8; + while (pos < final_pos) { + *utf32_output++ = char32_t(buf[pos]); + pos++; + } + continue; + } + } + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *utf32_output++ = char32_t(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { + // We have a two-byte UTF-8 + if (pos + 1 >= len) { + break; + } // minimal bound checking + *utf32_output++ = char32_t(((leading_byte & 0b00011111) << 6) | (data[pos + 1] & 0b00111111)); + pos += 2; + } else if ((leading_byte & 0b11110000) == 0b11100000) { + // We have a three-byte UTF-8 + if (pos + 2 >= len) { + break; + } // minimal bound checking + *utf32_output++ = char32_t(((leading_byte & 0b00001111) << 12) | ((data[pos + 1] & 0b00111111) << 6) | (data[pos + 2] & 0b00111111)); + pos += 3; + } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 + // we have a 4-byte UTF-8 word. + if (pos + 3 >= len) { + break; + } // minimal bound checking + uint32_t code_word = ((leading_byte & 0b00000111) << 18) | ((data[pos + 1] & 0b00111111) << 12) + | ((data[pos + 2] & 0b00111111) << 6) | (data[pos + 3] & 0b00111111); + *utf32_output++ = char32_t(code_word); + pos += 4; + } else { + // we may have a continuation but we do not do error checking + return 0; + } } - return counter; + return utf32_output - start; } -} // utf8 namespace +} // namespace utf8_to_utf32 } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf8.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf16.h -/* begin file src/scalar/utf16.h */ -#ifndef SIMDUTF_UTF16_H -#define SIMDUTF_UTF16_H +/* end file src/scalar/utf8_to_utf32/valid_utf8_to_utf32.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf8_to_utf32/utf8_to_utf32.h +/* begin file src/scalar/utf8_to_utf32/utf8_to_utf32.h */ +#ifndef SIMDUTF_UTF8_TO_UTF32_H +#define SIMDUTF_UTF8_TO_UTF32_H namespace simdutf { namespace scalar { namespace { -namespace utf16 { +namespace utf8_to_utf32 { -inline simdutf_warn_unused uint16_t swap_bytes(const uint16_t word) { - return uint16_t((word >> 8) | (word << 8)); -} - -template -inline simdutf_warn_unused bool validate(const char16_t *buf, size_t len) noexcept { - const uint16_t *data = reinterpret_cast(buf); - uint64_t pos = 0; - while (pos < len) { - uint16_t word = !match_system(big_endian) ? swap_bytes(data[pos]) : data[pos]; - if((word &0xF800) == 0xD800) { - if(pos + 1 >= len) { return false; } - uint16_t diff = uint16_t(word - 0xD800); - if(diff > 0x3FF) { return false; } - uint16_t next_word = !match_system(big_endian) ? swap_bytes(data[pos + 1]) : data[pos + 1]; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if(diff2 > 0x3FF) { return false; } - pos += 2; - } else { - pos++; +inline size_t convert(const char* buf, size_t len, char32_t* utf32_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char32_t* start { utf32_output }; + while (pos < len) { + // try to convert the next block of 16 ASCII bytes + if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii + uint64_t v1; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; + if ((v & 0x8080808080808080) == 0) { + size_t final_pos = pos + 16; + while (pos < final_pos) { + *utf32_output++ = char32_t(buf[pos]); + pos++; + } + continue; + } + } + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *utf32_output++ = char32_t(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { + // We have a two-byte UTF-8 + if (pos + 1 >= len) { + return 0; + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return 0; + } + // range check + uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); + if (code_point < 0x80 || 0x7ff < code_point) { + return 0; + } + *utf32_output++ = char32_t(code_point); + pos += 2; + } else if ((leading_byte & 0b11110000) == 0b11100000) { + // We have a three-byte UTF-8 + if (pos + 2 >= len) { + return 0; + } // minimal bound checking + + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return 0; + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return 0; + } + // range check + uint32_t code_point = (leading_byte & 0b00001111) << 12 | (data[pos + 1] & 0b00111111) << 6 | (data[pos + 2] & 0b00111111); + if (code_point < 0x800 || 0xffff < code_point || (0xd7ff < code_point && code_point < 0xe000)) { + return 0; + } + *utf32_output++ = char32_t(code_point); + pos += 3; + } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 + // we have a 4-byte UTF-8 word. + if (pos + 3 >= len) { + return 0; + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return 0; + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return 0; + } + if ((data[pos + 3] & 0b11000000) != 0b10000000) { + return 0; + } + + // range check + uint32_t code_point = (leading_byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); + if (code_point <= 0xffff || 0x10ffff < code_point) { + return 0; + } + *utf32_output++ = char32_t(code_point); + pos += 4; + } else { + return 0; + } } - } - return true; -} - -template -inline simdutf_warn_unused result validate_with_errors(const char16_t *buf, size_t len) noexcept { - const uint16_t *data = reinterpret_cast(buf); - size_t pos = 0; - while (pos < len) { - uint16_t word = !match_system(big_endian) ? swap_bytes(data[pos]) : data[pos]; - if((word & 0xF800) == 0xD800) { - if(pos + 1 >= len) { return result(error_code::SURROGATE, pos); } - uint16_t diff = uint16_t(word - 0xD800); - if(diff > 0x3FF) { return result(error_code::SURROGATE, pos); } - uint16_t next_word = !match_system(big_endian) ? swap_bytes(data[pos + 1]) : data[pos + 1]; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if(diff2 > 0x3FF) { return result(error_code::SURROGATE, pos); } - pos += 2; - } else { - pos++; + return utf32_output - start; +} + +inline result convert_with_errors(const char* buf, size_t len, char32_t* utf32_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char32_t* start { utf32_output }; + while (pos < len) { + // try to convert the next block of 16 ASCII bytes + if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii + uint64_t v1; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; + if ((v & 0x8080808080808080) == 0) { + size_t final_pos = pos + 16; + while (pos < final_pos) { + *utf32_output++ = char32_t(buf[pos]); + pos++; + } + continue; + } + } + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *utf32_output++ = char32_t(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { + // We have a two-byte UTF-8 + if (pos + 1 >= len) { + return result(error_code::TOO_SHORT, pos); + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + // range check + uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); + if (code_point < 0x80 || 0x7ff < code_point) { + return result(error_code::OVERLONG, pos); + } + *utf32_output++ = char32_t(code_point); + pos += 2; + } else if ((leading_byte & 0b11110000) == 0b11100000) { + // We have a three-byte UTF-8 + if (pos + 2 >= len) { + return result(error_code::TOO_SHORT, pos); + } // minimal bound checking + + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + // range check + uint32_t code_point = (leading_byte & 0b00001111) << 12 | (data[pos + 1] & 0b00111111) << 6 | (data[pos + 2] & 0b00111111); + if (code_point < 0x800 || 0xffff < code_point) { + return result(error_code::OVERLONG, pos); + } + if (0xd7ff < code_point && code_point < 0xe000) { + return result(error_code::SURROGATE, pos); + } + *utf32_output++ = char32_t(code_point); + pos += 3; + } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 + // we have a 4-byte UTF-8 word. + if (pos + 3 >= len) { + return result(error_code::TOO_SHORT, pos); + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 2] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + if ((data[pos + 3] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } + + // range check + uint32_t code_point = (leading_byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); + if (code_point <= 0xffff) { + return result(error_code::OVERLONG, pos); + } + if (0x10ffff < code_point) { + return result(error_code::TOO_LARGE, pos); + } + *utf32_output++ = char32_t(code_point); + pos += 4; + } else { + // we either have too many continuation bytes or an invalid leading byte + if ((leading_byte & 0b11000000) == 0b10000000) { + return result(error_code::TOO_LONG, pos); + } else { + return result(error_code::HEADER_BITS, pos); + } + } } - } - return result(error_code::SUCCESS, pos); -} - -template -inline size_t count_code_points(const char16_t* buf, size_t len) { - // We are not BOM aware. - const uint16_t * p = reinterpret_cast(buf); - size_t counter{0}; - for(size_t i = 0; i < len; i++) { - uint16_t word = !match_system(big_endian) ? swap_bytes(p[i]) : p[i]; - counter += ((word & 0xFC00) != 0xDC00); - } - return counter; -} - -template -inline size_t utf8_length_from_utf16(const char16_t* buf, size_t len) { - // We are not BOM aware. - const uint16_t * p = reinterpret_cast(buf); - size_t counter{0}; - for(size_t i = 0; i < len; i++) { - uint16_t word = !match_system(big_endian) ? swap_bytes(p[i]) : p[i]; - /** ASCII **/ - if(word <= 0x7F) { counter++; } - /** two-byte **/ - else if (word <= 0x7FF) { counter += 2; } - /** three-byte **/ - else if((word <= 0xD7FF) || (word >= 0xE000)) { counter += 3; } - /** surrogates -- 4 bytes **/ - else { counter += 2; } - } - return counter; -} - -template -inline size_t utf32_length_from_utf16(const char16_t* buf, size_t len) { - // We are not BOM aware. - const uint16_t * p = reinterpret_cast(buf); - size_t counter{0}; - for(size_t i = 0; i < len; i++) { - uint16_t word = !match_system(big_endian) ? swap_bytes(p[i]) : p[i]; - counter += ((word & 0xFC00) != 0xDC00); - } - return counter; -} - -simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* out) { - const uint16_t * input = reinterpret_cast(in); - uint16_t * output = reinterpret_cast(out); - for (size_t i = 0; i < size; i++) { - *output++ = uint16_t(input[i] >> 8 | input[i] << 8); - } + return result(error_code::SUCCESS, utf32_output - start); } -} // utf16 namespace -} // unnamed namespace -} // namespace scalar -} // namespace simdutf - -#endif -/* end file src/scalar/utf16.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf32.h -/* begin file src/scalar/utf32.h */ -#ifndef SIMDUTF_UTF32_H -#define SIMDUTF_UTF32_H - -namespace simdutf { -namespace scalar { -namespace { -namespace utf32 { +/** + * When rewind_and_convert_with_errors is called, we are pointing at 'buf' and we have + * up to len input bytes left, and we encountered some error. It is possible that + * the error is at 'buf' exactly, but it could also be in the previous bytes location (up to 3 bytes back). + * + * prior_bytes indicates how many bytes, prior to 'buf' may belong to the current memory section + * and can be safely accessed. We prior_bytes to access safely up to three bytes before 'buf'. + * + * The caller is responsible to ensure that len > 0. + * + * If the error is believed to have occured prior to 'buf', the count value contain in the result + * will be SIZE_T - 1, SIZE_T - 2, or SIZE_T - 3. + */ +inline result rewind_and_convert_with_errors(size_t prior_bytes, const char* buf, size_t len, char32_t* utf32_output) +{ + size_t extra_len { 0 }; + // We potentially need to go back in time and find a leading byte. + size_t how_far_back = 3; // 3 bytes in the past + current position + if (how_far_back > prior_bytes) { + how_far_back = prior_bytes; + } + bool found_leading_bytes { false }; + // important: it is i <= how_far_back and not 'i < how_far_back'. + for (size_t i = 0; i <= how_far_back; i++) { + unsigned char byte = buf[0 - i]; + found_leading_bytes = ((byte & 0b11000000) != 0b10000000); + if (found_leading_bytes) { + buf -= i; + extra_len = i; + break; + } + } + // + // It is possible for this function to return a negative count in its result. + // C++ Standard Section 18.1 defines size_t is in which is described in C Standard as . + // C Standard Section 4.1.5 defines size_t as an unsigned integral type of the result of the sizeof operator + // + // An unsigned type will simply wrap round arithmetically (well defined). + // + if (!found_leading_bytes) { + // If how_far_back == 3, we may have four consecutive continuation bytes!!! + // [....] [continuation] [continuation] [continuation] | [buf is continuation] + // Or we possibly have a stream that does not start with a leading byte. + return result(error_code::TOO_LONG, 0 - how_far_back); + } -inline simdutf_warn_unused bool validate(const char32_t *buf, size_t len) noexcept { - const uint32_t *data = reinterpret_cast(buf); - uint64_t pos = 0; - for(;pos < len; pos++) { - uint32_t word = data[pos]; - if(word > 0x10FFFF || (word >= 0xD800 && word <= 0xDFFF)) { - return false; + result res = convert_with_errors(buf, len + extra_len, utf32_output); + if (res.error) { + res.count -= extra_len; } - } - return true; -} - -inline simdutf_warn_unused result validate_with_errors(const char32_t *buf, size_t len) noexcept { - const uint32_t *data = reinterpret_cast(buf); - size_t pos = 0; - for(;pos < len; pos++) { - uint32_t word = data[pos]; - if(word > 0x10FFFF) { - return result(error_code::TOO_LARGE, pos); - } - if(word >= 0xD800 && word <= 0xDFFF) { - return result(error_code::SURROGATE, pos); - } - } - return result(error_code::SUCCESS, pos); -} - -inline size_t utf8_length_from_utf32(const char32_t* buf, size_t len) { - // We are not BOM aware. - const uint32_t * p = reinterpret_cast(buf); - size_t counter{0}; - for(size_t i = 0; i < len; i++) { - /** ASCII **/ - if(p[i] <= 0x7F) { counter++; } - /** two-byte **/ - else if(p[i] <= 0x7FF) { counter += 2; } - /** three-byte **/ - else if(p[i] <= 0xFFFF) { counter += 3; } - /** four-bytes **/ - else { counter += 4; } - } - return counter; -} - -inline size_t utf16_length_from_utf32(const char32_t* buf, size_t len) { - // We are not BOM aware. - const uint32_t * p = reinterpret_cast(buf); - size_t counter{0}; - for(size_t i = 0; i < len; i++) { - /** non-surrogate word **/ - if(p[i] <= 0xFFFF) { counter++; } - /** surrogate pair **/ - else { counter += 2; } - } - return counter; + return res; } -} // utf32 namespace +} // utf8_to_utf32 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf32.h */ +/* end file src/scalar/utf8_to_utf32/utf8_to_utf32.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf32_to_utf8/valid_utf32_to_utf8.h -/* begin file src/scalar/utf32_to_utf8/valid_utf32_to_utf8.h */ -#ifndef SIMDUTF_VALID_UTF32_TO_UTF8_H -#define SIMDUTF_VALID_UTF32_TO_UTF8_H +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/latin1_to_utf8/latin1_to_utf8.h +/* begin file src/scalar/latin1_to_utf8/latin1_to_utf8.h */ +#ifndef SIMDUTF_LATIN1_TO_UTF8_H +#define SIMDUTF_LATIN1_TO_UTF8_H namespace simdutf { namespace scalar { namespace { -namespace utf32_to_utf8 { +namespace latin1_to_utf8 { -#if SIMDUTF_IMPLEMENTATION_FALLBACK || SIMDUTF_IMPLEMENTATION_PPC64 -// only used by the fallback and POWER kernel -inline size_t convert_valid(const char32_t* buf, size_t len, char* utf8_output) { - const uint32_t *data = reinterpret_cast(buf); - size_t pos = 0; - char* start{utf8_output}; - while (pos < len) { - // try to convert the next block of 2 ASCII characters - if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v; - ::memcpy(&v, data + pos, sizeof(uint64_t)); - if ((v & 0xFFFFFF80FFFFFF80) == 0) { - *utf8_output++ = char(buf[pos]); - *utf8_output++ = char(buf[pos+1]); - pos += 2; - continue; - } - } - uint32_t word = data[pos]; - if((word & 0xFFFFFF80)==0) { - // will generate one UTF-8 bytes - *utf8_output++ = char(word); - pos++; - } else if((word & 0xFFFFF800)==0) { - // will generate two UTF-8 bytes - // we have 0b110XXXXX 0b10XXXXXX - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else if((word & 0xFFFF0000)==0) { - // will generate three UTF-8 bytes - // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else { - // will generate four UTF-8 bytes - // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos ++; +inline size_t convert(const char* buf, size_t len, char* utf8_output) +{ + const unsigned char* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { utf8_output }; + while (pos < len) { + // try to convert the next block of 16 ASCII bytes + if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii + uint64_t v1; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; // We are only interested in these bits: 1000 1000 1000 1000, so it makes sense to concatenate everything + if ((v & 0x8080808080808080) == 0) { // if NONE of these are set, e.g. all of them are zero, then everything is ASCII + size_t final_pos = pos + 16; + while (pos < final_pos) { + *utf8_output++ = char(buf[pos]); + pos++; + } + continue; + } + } + + unsigned char byte = data[pos]; + if ((byte & 0x80) == 0) { // if ASCII + // will generate one UTF-8 bytes + *utf8_output++ = char(byte); + pos++; + } else { + // will generate two UTF-8 bytes + *utf8_output++ = char((byte >> 6) | 0b11000000); + *utf8_output++ = char((byte & 0b111111) | 0b10000000); + pos++; + } } - } - return utf8_output - start; + return utf8_output - start; } -#endif // SIMDUTF_IMPLEMENTATION_FALLBACK || SIMDUTF_IMPLEMENTATION_PPC64 -} // utf32_to_utf8 namespace +} // latin1_to_utf8 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf32_to_utf8/valid_utf32_to_utf8.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf32_to_utf8/utf32_to_utf8.h -/* begin file src/scalar/utf32_to_utf8/utf32_to_utf8.h */ -#ifndef SIMDUTF_UTF32_TO_UTF8_H -#define SIMDUTF_UTF32_TO_UTF8_H +/* end file src/scalar/latin1_to_utf8/latin1_to_utf8.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/latin1_to_utf16/latin1_to_utf16.h +/* begin file src/scalar/latin1_to_utf16/latin1_to_utf16.h */ +#ifndef SIMDUTF_LATIN1_TO_UTF16_H +#define SIMDUTF_LATIN1_TO_UTF16_H namespace simdutf { namespace scalar { namespace { -namespace utf32_to_utf8 { +namespace latin1_to_utf16 { -inline size_t convert(const char32_t* buf, size_t len, char* utf8_output) { - const uint32_t *data = reinterpret_cast(buf); - size_t pos = 0; - char* start{utf8_output}; - while (pos < len) { - // try to convert the next block of 2 ASCII characters - if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v; - ::memcpy(&v, data + pos, sizeof(uint64_t)); - if ((v & 0xFFFFFF80FFFFFF80) == 0) { - *utf8_output++ = char(buf[pos]); - *utf8_output++ = char(buf[pos+1]); - pos += 2; - continue; - } - } - uint32_t word = data[pos]; - if((word & 0xFFFFFF80)==0) { - // will generate one UTF-8 bytes - *utf8_output++ = char(word); - pos++; - } else if((word & 0xFFFFF800)==0) { - // will generate two UTF-8 bytes - // we have 0b110XXXXX 0b10XXXXXX - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else if((word & 0xFFFF0000)==0) { - // will generate three UTF-8 bytes - // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX - if (word >= 0xD800 && word <= 0xDFFF) { return 0; } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else { - // will generate four UTF-8 bytes - // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX - if (word > 0x10FFFF) { return 0; } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos ++; - } - } - return utf8_output - start; -} - -inline result convert_with_errors(const char32_t* buf, size_t len, char* utf8_output) { - const uint32_t *data = reinterpret_cast(buf); - size_t pos = 0; - char* start{utf8_output}; - while (pos < len) { - // try to convert the next block of 2 ASCII characters - if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v; - ::memcpy(&v, data + pos, sizeof(uint64_t)); - if ((v & 0xFFFFFF80FFFFFF80) == 0) { - *utf8_output++ = char(buf[pos]); - *utf8_output++ = char(buf[pos+1]); - pos += 2; - continue; - } - } - uint32_t word = data[pos]; - if((word & 0xFFFFFF80)==0) { - // will generate one UTF-8 bytes - *utf8_output++ = char(word); - pos++; - } else if((word & 0xFFFFF800)==0) { - // will generate two UTF-8 bytes - // we have 0b110XXXXX 0b10XXXXXX - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else if((word & 0xFFFF0000)==0) { - // will generate three UTF-8 bytes - // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX - if (word >= 0xD800 && word <= 0xDFFF) { return result(error_code::SURROGATE, pos); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else { - // will generate four UTF-8 bytes - // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX - if (word > 0x10FFFF) { return result(error_code::TOO_LARGE, pos); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos ++; - } - } - return result(error_code::SUCCESS, utf8_output - start); -} +template +inline size_t convert(const char* buf, size_t len, char16_t* utf16_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char16_t* start { utf16_output }; -} // utf32_to_utf8 namespace -} // unnamed namespace -} // namespace scalar -} // namespace simdutf + while (pos < len) { + uint16_t word = uint16_t(data[pos]); // extend Latin-1 char to 16-bit Unicode code point + *utf16_output++ = char16_t(match_system(big_endian) ? word : utf16::swap_bytes(word)); + pos++; + } -#endif -/* end file src/scalar/utf32_to_utf8/utf32_to_utf8.h */ + return utf16_output - start; +} -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf32_to_utf16/valid_utf32_to_utf16.h -/* begin file src/scalar/utf32_to_utf16/valid_utf32_to_utf16.h */ -#ifndef SIMDUTF_VALID_UTF32_TO_UTF16_H -#define SIMDUTF_VALID_UTF32_TO_UTF16_H +template +inline result convert_with_errors(const char* buf, size_t len, char16_t* utf16_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char16_t* start { utf16_output }; -namespace simdutf { -namespace scalar { -namespace { -namespace utf32_to_utf16 { + while (pos < len) { + uint16_t word = uint16_t(data[pos]); // extend Latin-1 char to 16-bit Unicode code point + *utf16_output++ = char16_t(match_system(big_endian) ? word : utf16::swap_bytes(word)); + pos++; + } -template -inline size_t convert_valid(const char32_t* buf, size_t len, char16_t* utf16_output) { - const uint32_t *data = reinterpret_cast(buf); - size_t pos = 0; - char16_t* start{utf16_output}; - while (pos < len) { - uint32_t word = data[pos]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(uint16_t(word))) : char16_t(word); - pos++; - } else { - // will generate a surrogate pair - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (!match_system(big_endian)) { - high_surrogate = utf16::swap_bytes(high_surrogate); - low_surrogate = utf16::swap_bytes(low_surrogate); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); - pos++; - } - } - return utf16_output - start; + return result(error_code::SUCCESS, utf16_output - start); } -} // utf32_to_utf16 namespace +} // latin1_to_utf16 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf32_to_utf16/valid_utf32_to_utf16.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf32_to_utf16/utf32_to_utf16.h -/* begin file src/scalar/utf32_to_utf16/utf32_to_utf16.h */ -#ifndef SIMDUTF_UTF32_TO_UTF16_H -#define SIMDUTF_UTF32_TO_UTF16_H +/* end file src/scalar/latin1_to_utf16/latin1_to_utf16.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/latin1_to_utf32/latin1_to_utf32.h +/* begin file src/scalar/latin1_to_utf32/latin1_to_utf32.h */ +#ifndef SIMDUTF_LATIN1_TO_UTF32_H +#define SIMDUTF_LATIN1_TO_UTF32_H namespace simdutf { namespace scalar { namespace { -namespace utf32_to_utf16 { +namespace latin1_to_utf32 { -template -inline size_t convert(const char32_t* buf, size_t len, char16_t* utf16_output) { - const uint32_t *data = reinterpret_cast(buf); - size_t pos = 0; - char16_t* start{utf16_output}; - while (pos < len) { - uint32_t word = data[pos]; - if((word & 0xFFFF0000)==0) { - if (word >= 0xD800 && word <= 0xDFFF) { return 0; } - // will not generate a surrogate pair - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(uint16_t(word))) : char16_t(word); - } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return 0; } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (!match_system(big_endian)) { - high_surrogate = utf16::swap_bytes(high_surrogate); - low_surrogate = utf16::swap_bytes(low_surrogate); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); - } - pos++; - } - return utf16_output - start; -} - -template -inline result convert_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) { - const uint32_t *data = reinterpret_cast(buf); - size_t pos = 0; - char16_t* start{utf16_output}; - while (pos < len) { - uint32_t word = data[pos]; - if((word & 0xFFFF0000)==0) { - if (word >= 0xD800 && word <= 0xDFFF) { return result(error_code::SURROGATE, pos); } - // will not generate a surrogate pair - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(uint16_t(word))) : char16_t(word); - } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return result(error_code::TOO_LARGE, pos); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (!match_system(big_endian)) { - high_surrogate = utf16::swap_bytes(high_surrogate); - low_surrogate = utf16::swap_bytes(low_surrogate); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); - } - pos++; - } - return result(error_code::SUCCESS, utf16_output - start); +inline size_t convert(const char* buf, size_t len, char32_t* utf32_output) +{ + const unsigned char* data = reinterpret_cast(buf); + char32_t* start { utf32_output }; + for (size_t i = 0; i < len; i++) { + *utf32_output++ = (char32_t)data[i]; + } + return utf32_output - start; } -} // utf32_to_utf16 namespace +inline result convert_with_errors(const char32_t* buf, size_t len, char32_t* utf32_output) +{ + const uint32_t* data = reinterpret_cast(buf); + char32_t* start { utf32_output }; + for (size_t i = 0; i < len; i++) { + *utf32_output++ = (char32_t)data[i]; + } + return result(error_code::SUCCESS, utf32_output - start); +} + +} // latin1_to_utf32 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf32_to_utf16/utf32_to_utf16.h */ +/* end file src/scalar/latin1_to_utf32/latin1_to_utf32.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf16_to_utf8/valid_utf16_to_utf8.h -/* begin file src/scalar/utf16_to_utf8/valid_utf16_to_utf8.h */ -#ifndef SIMDUTF_VALID_UTF16_TO_UTF8_H -#define SIMDUTF_VALID_UTF16_TO_UTF8_H +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf8_to_latin1/utf8_to_latin1.h +/* begin file src/scalar/utf8_to_latin1/utf8_to_latin1.h */ +#ifndef SIMDUTF_UTF8_TO_LATIN1_H +#define SIMDUTF_UTF8_TO_LATIN1_H +#include namespace simdutf { namespace scalar { namespace { -namespace utf16_to_utf8 { - -template -inline size_t convert_valid(const char16_t* buf, size_t len, char* utf8_output) { - const uint16_t *data = reinterpret_cast(buf); - size_t pos = 0; - char* start{utf8_output}; - while (pos < len) { - // try to convert the next block of 4 ASCII characters - if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v; - ::memcpy(&v, data + pos, sizeof(uint64_t)); - if (!match_system(big_endian)) v = (v >> 8) | (v << (64 - 8)); - if ((v & 0xFF80FF80FF80FF80) == 0) { - size_t final_pos = pos + 4; - while(pos < final_pos) { - *utf8_output++ = !match_system(big_endian) ? char(utf16::swap_bytes(buf[pos])) : char(buf[pos]); - pos++; - } - continue; - } - } - - uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; - if((word & 0xFF80)==0) { - // will generate one UTF-8 bytes - *utf8_output++ = char(word); - pos++; - } else if((word & 0xF800)==0) { - // will generate two UTF-8 bytes - // we have 0b110XXXXX 0b10XXXXXX - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else if((word &0xF800 ) != 0xD800) { - // will generate three UTF-8 bytes - // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - if(pos + 1 >= len) { return 0; } // minimal bound checking - uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - uint32_t value = (diff << 10) + diff2 + 0x10000; - // will generate four UTF-8 bytes - // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); - pos += 2; - } - } - return utf8_output - start; -} +namespace utf8_to_latin1 { -} // utf16_to_utf8 namespace -} // unnamed namespace -} // namespace scalar -} // namespace simdutf +inline size_t convert(const char* buf, size_t len, char* latin_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { latin_output }; + + while (pos < len) { + // try to convert the next block of 16 ASCII bytes + if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii + uint64_t v1; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; // We are only interested in these bits: 1000 1000 1000 1000 .... etc + if ((v & 0x8080808080808080) == 0) { // if NONE of these are set, e.g. all of them are zero, then everything is ASCII + size_t final_pos = pos + 16; + while (pos < final_pos) { + *latin_output++ = char(buf[pos]); + pos++; + } + continue; + } + } -#endif -/* end file src/scalar/utf16_to_utf8/valid_utf16_to_utf8.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf16_to_utf8/utf16_to_utf8.h -/* begin file src/scalar/utf16_to_utf8/utf16_to_utf8.h */ -#ifndef SIMDUTF_UTF16_TO_UTF8_H -#define SIMDUTF_UTF16_TO_UTF8_H + // suppose it is not an all ASCII byte sequence + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *latin_output++ = char(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { // the first three bits indicate: + // We have a two-byte UTF-8 + if (pos + 1 >= len) { + return 0; + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return 0; + } // checks if the next byte is a valid continuation byte in UTF-8. A valid continuation byte starts with 10. + // range check - + uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); // assembles the Unicode code point from the two bytes. It does this by discarding the leading 110 and 10 bits from the two bytes, shifting the remaining bits of the first byte, and then combining the results with a bitwise OR operation. + if (0xFF < code_point) { + return 0; // We only care about the range 129-255 which is Non-ASCII latin1 characters + } + *latin_output++ = char(code_point); + pos += 2; + } else { + return 0; + } + } + return latin_output - start; +} -namespace simdutf { -namespace scalar { -namespace { -namespace utf16_to_utf8 { +inline result convert_with_errors(const char* buf, size_t len, char* latin_output) +{ + const uint8_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { latin_output }; + + while (pos < len) { + // try to convert the next block of 16 ASCII bytes + if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii + uint64_t v1; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; // We are only interested in these bits: 1000 1000 1000 1000...etc + if ((v & 0x8080808080808080) == 0) { // if NONE of these are set, e.g. all of them are zero, then everything is ASCII + size_t final_pos = pos + 16; + while (pos < final_pos) { + *latin_output++ = char(buf[pos]); + pos++; + } + continue; + } + } + // suppose it is not an all ASCII byte sequence + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *latin_output++ = char(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { // the first three bits indicate: + // We have a two-byte UTF-8 + if (pos + 1 >= len) { + return result(error_code::TOO_SHORT, pos); + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return result(error_code::TOO_SHORT, pos); + } // checks if the next byte is a valid continuation byte in UTF-8. A valid continuation byte starts with 10. + // range check - + uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); // assembles the Unicode code point from the two bytes. It does this by discarding the leading 110 and 10 bits from the two bytes, shifting the remaining bits of the first byte, and then combining the results with a bitwise OR operation. + if (code_point < 0x80) { + return result(error_code::OVERLONG, pos); + } + if (0xFF < code_point) { + return result(error_code::TOO_LARGE, pos); + } // We only care about the range 129-255 which is Non-ASCII latin1 characters + *latin_output++ = char(code_point); + pos += 2; + } else if ((leading_byte & 0b11110000) == 0b11100000) { + // We have a three-byte UTF-8 + return result(error_code::TOO_LARGE, pos); + } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 + // we have a 4-byte UTF-8 word. + return result(error_code::TOO_LARGE, pos); + } else { + // we either have too many continuation bytes or an invalid leading byte + if ((leading_byte & 0b11000000) == 0b10000000) { + return result(error_code::TOO_LONG, pos); + } -template -inline size_t convert(const char16_t* buf, size_t len, char* utf8_output) { - const uint16_t *data = reinterpret_cast(buf); - size_t pos = 0; - char* start{utf8_output}; - while (pos < len) { - // try to convert the next block of 8 ASCII characters - if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v; - ::memcpy(&v, data + pos, sizeof(uint64_t)); - if (!match_system(big_endian)) v = (v >> 8) | (v << (64 - 8)); - if ((v & 0xFF80FF80FF80FF80) == 0) { - size_t final_pos = pos + 4; - while(pos < final_pos) { - *utf8_output++ = !match_system(big_endian) ? char(utf16::swap_bytes(buf[pos])) : char(buf[pos]); - pos++; - } - continue; - } - } - uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; - if((word & 0xFF80)==0) { - // will generate one UTF-8 bytes - *utf8_output++ = char(word); - pos++; - } else if((word & 0xF800)==0) { - // will generate two UTF-8 bytes - // we have 0b110XXXXX 0b10XXXXXX - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else if((word &0xF800 ) != 0xD800) { - // will generate three UTF-8 bytes - // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else { - // must be a surrogate pair - if(pos + 1 >= len) { return 0; } - uint16_t diff = uint16_t(word - 0xD800); - if(diff > 0x3FF) { return 0; } - uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if(diff2 > 0x3FF) { return 0; } - uint32_t value = (diff << 10) + diff2 + 0x10000; - // will generate four UTF-8 bytes - // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); - pos += 2; - } - } - return utf8_output - start; -} - -template -inline result convert_with_errors(const char16_t* buf, size_t len, char* utf8_output) { - const uint16_t *data = reinterpret_cast(buf); - size_t pos = 0; - char* start{utf8_output}; - while (pos < len) { - // try to convert the next block of 8 ASCII characters - if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v; - ::memcpy(&v, data + pos, sizeof(uint64_t)); - if (!match_system(big_endian)) v = (v >> 8) | (v << (64 - 8)); - if ((v & 0xFF80FF80FF80FF80) == 0) { - size_t final_pos = pos + 4; - while(pos < final_pos) { - *utf8_output++ = !match_system(big_endian) ? char(utf16::swap_bytes(buf[pos])) : char(buf[pos]); - pos++; - } - continue; - } - } - uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; - if((word & 0xFF80)==0) { - // will generate one UTF-8 bytes - *utf8_output++ = char(word); - pos++; - } else if((word & 0xF800)==0) { - // will generate two UTF-8 bytes - // we have 0b110XXXXX 0b10XXXXXX - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else if((word &0xF800 ) != 0xD800) { - // will generate three UTF-8 bytes - // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - pos++; - } else { - // must be a surrogate pair - if(pos + 1 >= len) { return result(error_code::SURROGATE, pos); } - uint16_t diff = uint16_t(word - 0xD800); - if(diff > 0x3FF) { return result(error_code::SURROGATE, pos); } - uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if(diff2 > 0x3FF) { return result(error_code::SURROGATE, pos); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - // will generate four UTF-8 bytes - // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); - pos += 2; - } - } - return result(error_code::SUCCESS, utf8_output - start); + return result(error_code::HEADER_BITS, pos); + } + } + return result(error_code::SUCCESS, latin_output - start); } -} // utf16_to_utf8 namespace +} // utf8_to_latin1 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf16_to_utf8/utf16_to_utf8.h */ - -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf16_to_utf32/valid_utf16_to_utf32.h -/* begin file src/scalar/utf16_to_utf32/valid_utf16_to_utf32.h */ -#ifndef SIMDUTF_VALID_UTF16_TO_UTF32_H -#define SIMDUTF_VALID_UTF16_TO_UTF32_H +/* end file src/scalar/utf8_to_latin1/utf8_to_latin1.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf16_to_latin1/utf16_to_latin1.h +/* begin file src/scalar/utf16_to_latin1/utf16_to_latin1.h */ +#ifndef SIMDUTF_UTF16_TO_LATIN1_H +#define SIMDUTF_UTF16_TO_LATIN1_H namespace simdutf { namespace scalar { namespace { -namespace utf16_to_utf32 { +namespace utf16_to_latin1 { -template -inline size_t convert_valid(const char16_t* buf, size_t len, char32_t* utf32_output) { - const uint16_t *data = reinterpret_cast(buf); - size_t pos = 0; - char32_t* start{utf32_output}; - while (pos < len) { - uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; - if((word &0xF800 ) != 0xD800) { - // No surrogate pair, extend 16-bit word to 32-bit word - *utf32_output++ = char32_t(word); - pos++; - } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - if(pos + 1 >= len) { return 0; } // minimal bound checking - uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); - pos += 2; +#include // for std::memcpy + +template +inline size_t convert(const char16_t* buf, size_t len, char* latin_output) +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + std::vector temp_output(len); + char* current_write = temp_output.data(); + uint16_t word = 0; + uint16_t too_large = 0; + + while (pos < len) { + word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + too_large |= word; + *current_write++ = char(word & 0xFF); + pos++; + } + if ((too_large & 0xFF00) != 0) { + return 0; } - } - return utf32_output - start; -} -} // utf16_to_utf32 namespace -} // unnamed namespace -} // namespace scalar -} // namespace simdutf + // Only copy to latin_output if there were no errors + std::memcpy(latin_output, temp_output.data(), len); -#endif -/* end file src/scalar/utf16_to_utf32/valid_utf16_to_utf32.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf16_to_utf32/utf16_to_utf32.h -/* begin file src/scalar/utf16_to_utf32/utf16_to_utf32.h */ -#ifndef SIMDUTF_UTF16_TO_UTF32_H -#define SIMDUTF_UTF16_TO_UTF32_H + return current_write - temp_output.data(); +} -namespace simdutf { -namespace scalar { -namespace { -namespace utf16_to_utf32 { +template +inline result convert_with_errors(const char16_t* buf, size_t len, char* latin_output) +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { latin_output }; + uint16_t word; + + while (pos < len) { + if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that they are Latin1 + uint64_t v1, v2, v3, v4; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + ::memcpy(&v2, data + pos + 4, sizeof(uint64_t)); + ::memcpy(&v3, data + pos + 8, sizeof(uint64_t)); + ::memcpy(&v4, data + pos + 12, sizeof(uint64_t)); + + if (!match_system(big_endian)) { + v1 = (v1 >> 8) | (v1 << (64 - 8)); + } + if (!match_system(big_endian)) { + v2 = (v2 >> 8) | (v2 << (64 - 8)); + } + if (!match_system(big_endian)) { + v3 = (v3 >> 8) | (v3 << (64 - 8)); + } + if (!match_system(big_endian)) { + v4 = (v1 >> 8) | (v4 << (64 - 8)); + } -template -inline size_t convert(const char16_t* buf, size_t len, char32_t* utf32_output) { - const uint16_t *data = reinterpret_cast(buf); - size_t pos = 0; - char32_t* start{utf32_output}; - while (pos < len) { - uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; - if((word &0xF800 ) != 0xD800) { - // No surrogate pair, extend 16-bit word to 32-bit word - *utf32_output++ = char32_t(word); - pos++; - } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - if(diff > 0x3FF) { return 0; } - if(pos + 1 >= len) { return 0; } // minimal bound checking - uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if(diff2 > 0x3FF) { return 0; } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); - pos += 2; - } - } - return utf32_output - start; -} - -template -inline result convert_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) { - const uint16_t *data = reinterpret_cast(buf); - size_t pos = 0; - char32_t* start{utf32_output}; - while (pos < len) { - uint16_t word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; - if((word &0xF800 ) != 0xD800) { - // No surrogate pair, extend 16-bit word to 32-bit word - *utf32_output++ = char32_t(word); - pos++; - } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - if(diff > 0x3FF) { return result(error_code::SURROGATE, pos); } - if(pos + 1 >= len) { return result(error_code::SURROGATE, pos); } // minimal bound checking - uint16_t next_word = !match_system(big_endian) ? utf16::swap_bytes(data[pos + 1]) : data[pos + 1]; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if(diff2 > 0x3FF) { return result(error_code::SURROGATE, pos); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); - pos += 2; + if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) { + size_t final_pos = pos + 16; + while (pos < final_pos) { + *latin_output++ = !match_system(big_endian) ? char(utf16::swap_bytes(data[pos])) : char(data[pos]); + pos++; + } + continue; + } + } + word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + if ((word & 0xFF00) == 0) { + *latin_output++ = char(word & 0xFF); + pos++; + } else { + return result(error_code::TOO_LARGE, pos); + } } - } - return result(error_code::SUCCESS, utf32_output - start); + return result(error_code::SUCCESS, latin_output - start); } -} // utf16_to_utf32 namespace +} // utf16_to_latin1 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf16_to_utf32/utf16_to_utf32.h */ - -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf8_to_utf16/valid_utf8_to_utf16.h -/* begin file src/scalar/utf8_to_utf16/valid_utf8_to_utf16.h */ -#ifndef SIMDUTF_VALID_UTF8_TO_UTF16_H -#define SIMDUTF_VALID_UTF8_TO_UTF16_H +/* end file src/scalar/utf16_to_latin1/utf16_to_latin1.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf32_to_latin1/utf32_to_latin1.h +/* begin file src/scalar/utf32_to_latin1/utf32_to_latin1.h */ +#ifndef SIMDUTF_UTF32_TO_LATIN1_H +#define SIMDUTF_UTF32_TO_LATIN1_H namespace simdutf { namespace scalar { namespace { -namespace utf8_to_utf16 { +namespace utf32_to_latin1 { -template -inline size_t convert_valid(const char* buf, size_t len, char16_t* utf16_output) { - const uint8_t *data = reinterpret_cast(buf); - size_t pos = 0; - char16_t* start{utf16_output}; - while (pos < len) { - // try to convert the next block of 8 ASCII bytes - if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v; - ::memcpy(&v, data + pos, sizeof(uint64_t)); - if ((v & 0x8080808080808080) == 0) { - size_t final_pos = pos + 8; - while(pos < final_pos) { - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(buf[pos])) : char16_t(buf[pos]); - pos++; - } - continue; - } - } - uint8_t leading_byte = data[pos]; // leading byte - if (leading_byte < 0b10000000) { - // converting one ASCII byte !!! - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(leading_byte)) : char16_t(leading_byte); - pos++; - } else if ((leading_byte & 0b11100000) == 0b11000000) { - // We have a two-byte UTF-8, it should become - // a single UTF-16 word. - if(pos + 1 >= len) { break; } // minimal bound checking - uint16_t code_point = uint16_t(((leading_byte &0b00011111) << 6) | (data[pos + 1] &0b00111111)); - if (!match_system(big_endian)) { - code_point = utf16::swap_bytes(uint16_t(code_point)); - } - *utf16_output++ = char16_t(code_point); - pos += 2; - } else if ((leading_byte & 0b11110000) == 0b11100000) { - // We have a three-byte UTF-8, it should become - // a single UTF-16 word. - if(pos + 2 >= len) { break; } // minimal bound checking - uint16_t code_point = uint16_t(((leading_byte &0b00001111) << 12) | ((data[pos + 1] &0b00111111) << 6) | (data[pos + 2] &0b00111111)); - if (!match_system(big_endian)) { - code_point = utf16::swap_bytes(uint16_t(code_point)); - } - *utf16_output++ = char16_t(code_point); - pos += 3; - } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 - // we have a 4-byte UTF-8 word. - if(pos + 3 >= len) { break; } // minimal bound checking - uint32_t code_point = ((leading_byte & 0b00000111) << 18 )| ((data[pos + 1] &0b00111111) << 12) - | ((data[pos + 2] &0b00111111) << 6) | (data[pos + 3] &0b00111111); - code_point -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF)); - if (!match_system(big_endian)) { - high_surrogate = utf16::swap_bytes(high_surrogate); - low_surrogate = utf16::swap_bytes(low_surrogate); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); - pos += 4; - } else { - // we may have a continuation but we do not do error checking - return 0; +inline size_t convert(const char32_t* buf, size_t len, char* latin1_output) +{ + const uint32_t* data = reinterpret_cast(buf); + char* start = latin1_output; + uint32_t utf32_char; + size_t pos = 0; + uint32_t too_large = 0; + + while (pos < len) { + utf32_char = (uint32_t)data[pos]; + too_large |= utf32_char; + *latin1_output++ = (char)(utf32_char & 0xFF); + pos++; } - } - return utf16_output - start; + if ((too_large & 0xFFFFFF00) != 0) { + return 0; + } + return latin1_output - start; } +inline result convert_with_errors(const char32_t* buf, size_t len, char* latin1_output) +{ + const uint32_t* data = reinterpret_cast(buf); + char* start { latin1_output }; + size_t pos = 0; + while (pos < len) { + if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that they are Latin1 + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if ((v & 0xFFFFFF00FFFFFF00) == 0) { + *latin1_output++ = char(buf[pos]); + *latin1_output++ = char(buf[pos + 1]); + pos += 2; + continue; + } + } + uint32_t utf32_char = data[pos]; + if ((utf32_char & 0xFFFFFF00) == 0) { // Check if the character can be represented in Latin-1 + *latin1_output++ = (char)(utf32_char & 0xFF); + pos++; + } else { + return result(error_code::TOO_LARGE, pos); + }; + } + return result(error_code::SUCCESS, latin1_output - start); +} -} // namespace utf8_to_utf16 +} // utf32_to_latin1 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf8_to_utf16/valid_utf8_to_utf16.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf8_to_utf16/utf8_to_utf16.h -/* begin file src/scalar/utf8_to_utf16/utf8_to_utf16.h */ -#ifndef SIMDUTF_UTF8_TO_UTF16_H -#define SIMDUTF_UTF8_TO_UTF16_H +/* end file src/scalar/utf32_to_latin1/utf32_to_latin1.h */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf8_to_latin1/valid_utf8_to_latin1.h +/* begin file src/scalar/utf8_to_latin1/valid_utf8_to_latin1.h */ +#ifndef SIMDUTF_VALID_UTF8_TO_LATIN1_H +#define SIMDUTF_VALID_UTF8_TO_LATIN1_H namespace simdutf { namespace scalar { namespace { -namespace utf8_to_utf16 { +namespace utf8_to_latin1 { -template -inline size_t convert(const char* buf, size_t len, char16_t* utf16_output) { - const uint8_t *data = reinterpret_cast(buf); - size_t pos = 0; - char16_t* start{utf16_output}; - while (pos < len) { - // try to convert the next block of 16 ASCII bytes - if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii - uint64_t v1; - ::memcpy(&v1, data + pos, sizeof(uint64_t)); - uint64_t v2; - ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); - uint64_t v{v1 | v2}; - if ((v & 0x8080808080808080) == 0) { - size_t final_pos = pos + 16; - while(pos < final_pos) { - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(buf[pos])) : char16_t(buf[pos]); - pos++; - } - continue; - } - } - - uint8_t leading_byte = data[pos]; // leading byte - if (leading_byte < 0b10000000) { - // converting one ASCII byte !!! - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(leading_byte)): char16_t(leading_byte); - pos++; - } else if ((leading_byte & 0b11100000) == 0b11000000) { - // We have a two-byte UTF-8, it should become - // a single UTF-16 word. - if(pos + 1 >= len) { return 0; } // minimal bound checking - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return 0; } - // range check - uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); - if (code_point < 0x80 || 0x7ff < code_point) { return 0; } - if (!match_system(big_endian)) { - code_point = uint32_t(utf16::swap_bytes(uint16_t(code_point))); - } - *utf16_output++ = char16_t(code_point); - pos += 2; - } else if ((leading_byte & 0b11110000) == 0b11100000) { - // We have a three-byte UTF-8, it should become - // a single UTF-16 word. - if(pos + 2 >= len) { return 0; } // minimal bound checking - - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return 0; } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return 0; } - // range check - uint32_t code_point = (leading_byte & 0b00001111) << 12 | - (data[pos + 1] & 0b00111111) << 6 | - (data[pos + 2] & 0b00111111); - if (code_point < 0x800 || 0xffff < code_point || - (0xd7ff < code_point && code_point < 0xe000)) { - return 0; - } - if (!match_system(big_endian)) { - code_point = uint32_t(utf16::swap_bytes(uint16_t(code_point))); - } - *utf16_output++ = char16_t(code_point); - pos += 3; - } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 - // we have a 4-byte UTF-8 word. - if(pos + 3 >= len) { return 0; } // minimal bound checking - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return 0; } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return 0; } - if ((data[pos + 3] & 0b11000000) != 0b10000000) { return 0; } - - // range check - uint32_t code_point = - (leading_byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | - (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); - if (code_point <= 0xffff || 0x10ffff < code_point) { return 0; } - code_point -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF)); - if (!match_system(big_endian)) { - high_surrogate = utf16::swap_bytes(high_surrogate); - low_surrogate = utf16::swap_bytes(low_surrogate); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); - pos += 4; - } else { - return 0; - } - } - return utf16_output - start; -} - -template -inline result convert_with_errors(const char* buf, size_t len, char16_t* utf16_output) { - const uint8_t *data = reinterpret_cast(buf); - size_t pos = 0; - char16_t* start{utf16_output}; - while (pos < len) { - // try to convert the next block of 16 ASCII bytes - if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii - uint64_t v1; - ::memcpy(&v1, data + pos, sizeof(uint64_t)); - uint64_t v2; - ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); - uint64_t v{v1 | v2}; - if ((v & 0x8080808080808080) == 0) { - size_t final_pos = pos + 16; - while(pos < final_pos) { - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(buf[pos])) : char16_t(buf[pos]); - pos++; - } - continue; - } - } - uint8_t leading_byte = data[pos]; // leading byte - if (leading_byte < 0b10000000) { - // converting one ASCII byte !!! - *utf16_output++ = !match_system(big_endian) ? char16_t(utf16::swap_bytes(leading_byte)): char16_t(leading_byte); - pos++; - } else if ((leading_byte & 0b11100000) == 0b11000000) { - // We have a two-byte UTF-8, it should become - // a single UTF-16 word. - if(pos + 1 >= len) { return result(error_code::TOO_SHORT, pos); } // minimal bound checking - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - // range check - uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); - if (code_point < 0x80 || 0x7ff < code_point) { return result(error_code::OVERLONG, pos); } - if (!match_system(big_endian)) { - code_point = uint32_t(utf16::swap_bytes(uint16_t(code_point))); - } - *utf16_output++ = char16_t(code_point); - pos += 2; - } else if ((leading_byte & 0b11110000) == 0b11100000) { - // We have a three-byte UTF-8, it should become - // a single UTF-16 word. - if(pos + 2 >= len) { return result(error_code::TOO_SHORT, pos); } // minimal bound checking - - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - // range check - uint32_t code_point = (leading_byte & 0b00001111) << 12 | - (data[pos + 1] & 0b00111111) << 6 | - (data[pos + 2] & 0b00111111); - if ((code_point < 0x800) || (0xffff < code_point)) { return result(error_code::OVERLONG, pos);} - if (0xd7ff < code_point && code_point < 0xe000) { return result(error_code::SURROGATE, pos); } - if (!match_system(big_endian)) { - code_point = uint32_t(utf16::swap_bytes(uint16_t(code_point))); - } - *utf16_output++ = char16_t(code_point); - pos += 3; - } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 - // we have a 4-byte UTF-8 word. - if(pos + 3 >= len) { return result(error_code::TOO_SHORT, pos); } // minimal bound checking - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 3] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - - // range check - uint32_t code_point = - (leading_byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | - (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); - if (code_point <= 0xffff) { return result(error_code::OVERLONG, pos); } - if (0x10ffff < code_point) { return result(error_code::TOO_LARGE, pos); } - code_point -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF)); - if (!match_system(big_endian)) { - high_surrogate = utf16::swap_bytes(high_surrogate); - low_surrogate = utf16::swap_bytes(low_surrogate); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); - pos += 4; - } else { - // we either have too many continuation bytes or an invalid leading byte - if ((leading_byte & 0b11000000) == 0b10000000) { return result(error_code::TOO_LONG, pos); } - else { return result(error_code::HEADER_BITS, pos); } - } - } - return result(error_code::SUCCESS, utf16_output - start); -} +inline size_t convert_valid(const char* buf, size_t len, char* latin_output) +{ + const uint8_t* data = reinterpret_cast(buf); -/** - * When rewind_and_convert_with_errors is called, we are pointing at 'buf' and we have - * up to len input bytes left, and we encountered some error. It is possible that - * the error is at 'buf' exactly, but it could also be in the previous bytes (up to 3 bytes back). - * - * prior_bytes indicates how many bytes, prior to 'buf' may belong to the current memory section - * and can be safely accessed. We prior_bytes to access safely up to three bytes before 'buf'. - * - * The caller is responsible to ensure that len > 0. - * - * If the error is believed to have occured prior to 'buf', the count value contain in the result - * will be SIZE_T - 1, SIZE_T - 2, or SIZE_T - 3. - */ -template -inline result rewind_and_convert_with_errors(size_t prior_bytes, const char* buf, size_t len, char16_t* utf16_output) { - size_t extra_len{0}; - // We potentially need to go back in time and find a leading byte. - size_t how_far_back = 3; // 3 bytes in the past + current position - if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; } - bool found_leading_bytes{false}; - // important: it is i <= how_far_back and not 'i < how_far_back'. - for(size_t i = 0; i <= how_far_back; i++) { - unsigned char byte = buf[-i]; - found_leading_bytes = ((byte & 0b11000000) != 0b10000000); - if(found_leading_bytes) { - buf -= i; - extra_len = i; - break; - } - } - // - // It is possible for this function to return a negative count in its result. - // C++ Standard Section 18.1 defines size_t is in which is described in C Standard as . - // C Standard Section 4.1.5 defines size_t as an unsigned integral type of the result of the sizeof operator - // - // An unsigned type will simply wrap round arithmetically (well defined). - // - if(!found_leading_bytes) { - // If how_far_back == 3, we may have four consecutive continuation bytes!!! - // [....] [continuation] [continuation] [continuation] | [buf is continuation] - // Or we possibly have a stream that does not start with a leading byte. - return result(error_code::TOO_LONG, -how_far_back); - } - result res = convert_with_errors(buf, len + extra_len, utf16_output); - if (res.error) { - res.count -= extra_len; - } - return res; + size_t pos = 0; + char* start { latin_output }; + + while (pos < len) { + // try to convert the next block of 16 ASCII bytes + if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii + uint64_t v1; + ::memcpy(&v1, data + pos, sizeof(uint64_t)); + uint64_t v2; + ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); + uint64_t v { v1 | v2 }; // We are only interested in these bits: 1000 1000 1000 1000, so it makes sense to concatenate everything + if ((v & 0x8080808080808080) == 0) { // if NONE of these are set, e.g. all of them are zero, then everything is ASCII + size_t final_pos = pos + 16; + while (pos < final_pos) { + *latin_output++ = char(buf[pos]); + pos++; + } + continue; + } + } + + // suppose it is not an all ASCII byte sequence + uint8_t leading_byte = data[pos]; // leading byte + if (leading_byte < 0b10000000) { + // converting one ASCII byte !!! + *latin_output++ = char(leading_byte); + pos++; + } else if ((leading_byte & 0b11100000) == 0b11000000) { // the first three bits indicate: + // We have a two-byte UTF-8 + if (pos + 1 >= len) { + break; + } // minimal bound checking + if ((data[pos + 1] & 0b11000000) != 0b10000000) { + return 0; + } // checks if the next byte is a valid continuation byte in UTF-8. A valid continuation byte starts with 10. + // range check - + uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); // assembles the Unicode code point from the two bytes. It does this by discarding the leading 110 and 10 bits from the two bytes, shifting the remaining bits of the first byte, and then combining the results with a bitwise OR operation. + *latin_output++ = char(code_point); + pos += 2; + } else { + // we may have a continuation but we do not do error checking + return 0; + } + } + return latin_output - start; } -} // utf8_to_utf16 namespace +} // utf8_to_latin1 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf8_to_utf16/utf8_to_utf16.h */ - -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf8_to_utf32/valid_utf8_to_utf32.h -/* begin file src/scalar/utf8_to_utf32/valid_utf8_to_utf32.h */ -#ifndef SIMDUTF_VALID_UTF8_TO_UTF32_H -#define SIMDUTF_VALID_UTF8_TO_UTF32_H +/* end file src/scalar/utf8_to_latin1/valid_utf8_to_latin1.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf16_to_latin1/valid_utf16_to_latin1.h +/* begin file src/scalar/utf16_to_latin1/valid_utf16_to_latin1.h */ +#ifndef SIMDUTF_VALID_UTF16_TO_LATIN1_H +#define SIMDUTF_VALID_UTF16_TO_LATIN1_H namespace simdutf { namespace scalar { namespace { -namespace utf8_to_utf32 { +namespace utf16_to_latin1 { -inline size_t convert_valid(const char* buf, size_t len, char32_t* utf32_output) { - const uint8_t *data = reinterpret_cast(buf); - size_t pos = 0; - char32_t* start{utf32_output}; - while (pos < len) { - // try to convert the next block of 8 ASCII bytes - if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that they are ascii - uint64_t v; - ::memcpy(&v, data + pos, sizeof(uint64_t)); - if ((v & 0x8080808080808080) == 0) { - size_t final_pos = pos + 8; - while(pos < final_pos) { - *utf32_output++ = char32_t(buf[pos]); - pos++; - } - continue; - } - } - uint8_t leading_byte = data[pos]; // leading byte - if (leading_byte < 0b10000000) { - // converting one ASCII byte !!! - *utf32_output++ = char32_t(leading_byte); - pos++; - } else if ((leading_byte & 0b11100000) == 0b11000000) { - // We have a two-byte UTF-8 - if(pos + 1 >= len) { break; } // minimal bound checking - *utf32_output++ = char32_t(((leading_byte &0b00011111) << 6) | (data[pos + 1] &0b00111111)); - pos += 2; - } else if ((leading_byte & 0b11110000) == 0b11100000) { - // We have a three-byte UTF-8 - if(pos + 2 >= len) { break; } // minimal bound checking - *utf32_output++ = char32_t(((leading_byte &0b00001111) << 12) | ((data[pos + 1] &0b00111111) << 6) | (data[pos + 2] &0b00111111)); - pos += 3; - } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 - // we have a 4-byte UTF-8 word. - if(pos + 3 >= len) { break; } // minimal bound checking - uint32_t code_word = ((leading_byte & 0b00000111) << 18 )| ((data[pos + 1] &0b00111111) << 12) - | ((data[pos + 2] &0b00111111) << 6) | (data[pos + 3] &0b00111111); - *utf32_output++ = char32_t(code_word); - pos += 4; - } else { - // we may have a continuation but we do not do error checking - return 0; +template +inline size_t convert_valid(const char16_t* buf, size_t len, char* latin_output) +{ + const uint16_t* data = reinterpret_cast(buf); + size_t pos = 0; + char* start { latin_output }; + uint16_t word = 0; + + while (pos < len) { + word = !match_system(big_endian) ? utf16::swap_bytes(data[pos]) : data[pos]; + *latin_output++ = char(word); + pos++; } - } - return utf32_output - start; -} + return latin_output - start; +} -} // namespace utf8_to_utf32 +} // utf16_to_latin1 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf8_to_utf32/valid_utf8_to_utf32.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=scalar/utf8_to_utf32/utf8_to_utf32.h -/* begin file src/scalar/utf8_to_utf32/utf8_to_utf32.h */ -#ifndef SIMDUTF_UTF8_TO_UTF32_H -#define SIMDUTF_UTF8_TO_UTF32_H +/* end file src/scalar/utf16_to_latin1/valid_utf16_to_latin1.h */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=scalar/utf32_to_latin1/valid_utf32_to_latin1.h +/* begin file src/scalar/utf32_to_latin1/valid_utf32_to_latin1.h */ +#ifndef SIMDUTF_VALID_UTF32_TO_LATIN1_H +#define SIMDUTF_VALID_UTF32_TO_LATIN1_H namespace simdutf { namespace scalar { namespace { -namespace utf8_to_utf32 { +namespace utf32_to_latin1 { -inline size_t convert(const char* buf, size_t len, char32_t* utf32_output) { - const uint8_t *data = reinterpret_cast(buf); - size_t pos = 0; - char32_t* start{utf32_output}; - while (pos < len) { - // try to convert the next block of 16 ASCII bytes - if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii - uint64_t v1; - ::memcpy(&v1, data + pos, sizeof(uint64_t)); - uint64_t v2; - ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); - uint64_t v{v1 | v2}; - if ((v & 0x8080808080808080) == 0) { - size_t final_pos = pos + 16; - while(pos < final_pos) { - *utf32_output++ = char32_t(buf[pos]); - pos++; - } - continue; - } - } - uint8_t leading_byte = data[pos]; // leading byte - if (leading_byte < 0b10000000) { - // converting one ASCII byte !!! - *utf32_output++ = char32_t(leading_byte); - pos++; - } else if ((leading_byte & 0b11100000) == 0b11000000) { - // We have a two-byte UTF-8 - if(pos + 1 >= len) { return 0; } // minimal bound checking - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return 0; } - // range check - uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); - if (code_point < 0x80 || 0x7ff < code_point) { return 0; } - *utf32_output++ = char32_t(code_point); - pos += 2; - } else if ((leading_byte & 0b11110000) == 0b11100000) { - // We have a three-byte UTF-8 - if(pos + 2 >= len) { return 0; } // minimal bound checking - - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return 0; } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return 0; } - // range check - uint32_t code_point = (leading_byte & 0b00001111) << 12 | - (data[pos + 1] & 0b00111111) << 6 | - (data[pos + 2] & 0b00111111); - if (code_point < 0x800 || 0xffff < code_point || - (0xd7ff < code_point && code_point < 0xe000)) { - return 0; - } - *utf32_output++ = char32_t(code_point); - pos += 3; - } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 - // we have a 4-byte UTF-8 word. - if(pos + 3 >= len) { return 0; } // minimal bound checking - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return 0; } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return 0; } - if ((data[pos + 3] & 0b11000000) != 0b10000000) { return 0; } - - // range check - uint32_t code_point = - (leading_byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | - (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); - if (code_point <= 0xffff || 0x10ffff < code_point) { return 0; } - *utf32_output++ = char32_t(code_point); - pos += 4; - } else { - return 0; - } - } - return utf32_output - start; -} - -inline result convert_with_errors(const char* buf, size_t len, char32_t* utf32_output) { - const uint8_t *data = reinterpret_cast(buf); - size_t pos = 0; - char32_t* start{utf32_output}; - while (pos < len) { - // try to convert the next block of 16 ASCII bytes - if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that they are ascii - uint64_t v1; - ::memcpy(&v1, data + pos, sizeof(uint64_t)); - uint64_t v2; - ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t)); - uint64_t v{v1 | v2}; - if ((v & 0x8080808080808080) == 0) { - size_t final_pos = pos + 16; - while(pos < final_pos) { - *utf32_output++ = char32_t(buf[pos]); - pos++; - } - continue; - } - } - uint8_t leading_byte = data[pos]; // leading byte - if (leading_byte < 0b10000000) { - // converting one ASCII byte !!! - *utf32_output++ = char32_t(leading_byte); - pos++; - } else if ((leading_byte & 0b11100000) == 0b11000000) { - // We have a two-byte UTF-8 - if(pos + 1 >= len) { return result(error_code::TOO_SHORT, pos); } // minimal bound checking - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - // range check - uint32_t code_point = (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111); - if (code_point < 0x80 || 0x7ff < code_point) { return result(error_code::OVERLONG, pos); } - *utf32_output++ = char32_t(code_point); - pos += 2; - } else if ((leading_byte & 0b11110000) == 0b11100000) { - // We have a three-byte UTF-8 - if(pos + 2 >= len) { return result(error_code::TOO_SHORT, pos); } // minimal bound checking - - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - // range check - uint32_t code_point = (leading_byte & 0b00001111) << 12 | - (data[pos + 1] & 0b00111111) << 6 | - (data[pos + 2] & 0b00111111); - if (code_point < 0x800 || 0xffff < code_point) { return result(error_code::OVERLONG, pos); } - if (0xd7ff < code_point && code_point < 0xe000) { return result(error_code::SURROGATE, pos); } - *utf32_output++ = char32_t(code_point); - pos += 3; - } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000 - // we have a 4-byte UTF-8 word. - if(pos + 3 >= len) { return result(error_code::TOO_SHORT, pos); } // minimal bound checking - if ((data[pos + 1] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos);} - if ((data[pos + 2] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - if ((data[pos + 3] & 0b11000000) != 0b10000000) { return result(error_code::TOO_SHORT, pos); } - - // range check - uint32_t code_point = - (leading_byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 | - (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111); - if (code_point <= 0xffff) { return result(error_code::OVERLONG, pos); } - if (0x10ffff < code_point) { return result(error_code::TOO_LARGE, pos); } - *utf32_output++ = char32_t(code_point); - pos += 4; - } else { - // we either have too many continuation bytes or an invalid leading byte - if ((leading_byte & 0b11000000) == 0b10000000) { return result(error_code::TOO_LONG, pos); } - else { return result(error_code::HEADER_BITS, pos); } - } - } - return result(error_code::SUCCESS, utf32_output - start); -} +inline size_t convert_valid(const char32_t* buf, size_t len, char* latin1_output) +{ + const uint32_t* data = reinterpret_cast(buf); + char* start = latin1_output; + uint32_t utf32_char; + size_t pos = 0; -/** - * When rewind_and_convert_with_errors is called, we are pointing at 'buf' and we have - * up to len input bytes left, and we encountered some error. It is possible that - * the error is at 'buf' exactly, but it could also be in the previous bytes location (up to 3 bytes back). - * - * prior_bytes indicates how many bytes, prior to 'buf' may belong to the current memory section - * and can be safely accessed. We prior_bytes to access safely up to three bytes before 'buf'. - * - * The caller is responsible to ensure that len > 0. - * - * If the error is believed to have occured prior to 'buf', the count value contain in the result - * will be SIZE_T - 1, SIZE_T - 2, or SIZE_T - 3. - */ -inline result rewind_and_convert_with_errors(size_t prior_bytes, const char* buf, size_t len, char32_t* utf32_output) { - size_t extra_len{0}; - // We potentially need to go back in time and find a leading byte. - size_t how_far_back = 3; // 3 bytes in the past + current position - if(how_far_back > prior_bytes) { how_far_back = prior_bytes; } - bool found_leading_bytes{false}; - // important: it is i <= how_far_back and not 'i < how_far_back'. - for(size_t i = 0; i <= how_far_back; i++) { - unsigned char byte = buf[-i]; - found_leading_bytes = ((byte & 0b11000000) != 0b10000000); - if(found_leading_bytes) { - buf -= i; - extra_len = i; - break; - } - } - // - // It is possible for this function to return a negative count in its result. - // C++ Standard Section 18.1 defines size_t is in which is described in C Standard as . - // C Standard Section 4.1.5 defines size_t as an unsigned integral type of the result of the sizeof operator - // - // An unsigned type will simply wrap round arithmetically (well defined). - // - if(!found_leading_bytes) { - // If how_far_back == 3, we may have four consecutive continuation bytes!!! - // [....] [continuation] [continuation] [continuation] | [buf is continuation] - // Or we possibly have a stream that does not start with a leading byte. - return result(error_code::TOO_LONG, -how_far_back); - } - - result res = convert_with_errors(buf, len + extra_len, utf32_output); - if (res.error) { - res.count -= extra_len; - } - return res; + while (pos < len) { + utf32_char = (uint32_t)data[pos]; + + if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that they are Latin1 + uint64_t v; + ::memcpy(&v, data + pos, sizeof(uint64_t)); + if ((v & 0xFFFFFF00FFFFFF00) == 0) { + *latin1_output++ = char(buf[pos]); + *latin1_output++ = char(buf[pos + 1]); + pos += 2; + continue; + } + } + *latin1_output++ = (char)(utf32_char & 0xFF); + pos++; + } + return latin1_output - start; } -} // utf8_to_utf32 namespace +} // utf32_to_latin1 namespace } // unnamed namespace } // namespace scalar } // namespace simdutf #endif -/* end file src/scalar/utf8_to_utf32/utf8_to_utf32.h */ -// - +/* end file src/scalar/utf32_to_latin1/valid_utf32_to_latin1.h */ SIMDUTF_PUSH_DISABLE_WARNINGS SIMDUTF_DISABLE_UNDESIRED_WARNINGS - #if SIMDUTF_IMPLEMENTATION_ARM64 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/implementation.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/implementation.cpp /* begin file src/arm64/implementation.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/begin.h /* begin file src/simdutf/arm64/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "arm64" // #define SIMDUTF_IMPLEMENTATION arm64 @@ -11641,14 +13859,16 @@ namespace { #endif using namespace simd; -simdutf_really_inline bool is_ascii(const simd8x64& input) { +simdutf_really_inline bool is_ascii(const simd8x64& input) +{ simd8 bits = input.reduce_or(); return bits.max_val() < 0b10000000u; } -simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { +simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) +{ simd8 is_second_byte = prev1 >= uint8_t(0b11000000u); - simd8 is_third_byte = prev2 >= uint8_t(0b11100000u); + simd8 is_third_byte = prev2 >= uint8_t(0b11100000u); simd8 is_fourth_byte = prev3 >= uint8_t(0b11110000u); // Use ^ instead of | for is_*_byte, because ^ is commutative, and the caller is using ^ as well. // This will work fine because we only have to report errors for cases with 0-1 lead bytes. @@ -11658,17 +13878,19 @@ simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd return is_second_byte ^ is_third_byte ^ is_fourth_byte; } -simdutf_really_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2 >= uint8_t(0b11100000u); +simdutf_really_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) +{ + simd8 is_third_byte = prev2 >= uint8_t(0b11100000u); simd8 is_fourth_byte = prev3 >= uint8_t(0b11110000u); return is_third_byte ^ is_fourth_byte; } -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_detect_encodings.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_detect_encodings.cpp /* begin file src/arm64/arm_detect_encodings.cpp */ template // len is known to be a multiple of 2 when this is called -int arm_detect_encodings(const char * buf, size_t len) { +int arm_detect_encodings(const char* buf, size_t len) +{ const char* start = buf; const char* end = buf + len; @@ -11683,13 +13905,13 @@ int arm_detect_encodings(const char * buf, size_t len) { uint32x4_t currentmax = vmovq_n_u32(0x0); - checker check{}; + checker check {}; - while(buf + 64 <= end) { + while (buf + 64 <= end) { uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); uint16x8_t secondin = vld1q_u16(reinterpret_cast(buf) + simd16::SIZE / sizeof(char16_t)); - uint16x8_t thirdin = vld1q_u16(reinterpret_cast(buf) + 2*simd16::SIZE / sizeof(char16_t)); - uint16x8_t fourthin = vld1q_u16(reinterpret_cast(buf) + 3*simd16::SIZE / sizeof(char16_t)); + uint16x8_t thirdin = vld1q_u16(reinterpret_cast(buf) + 2 * simd16::SIZE / sizeof(char16_t)); + uint16x8_t fourthin = vld1q_u16(reinterpret_cast(buf) + 3 * simd16::SIZE / sizeof(char16_t)); const auto u0 = simd16(in); const auto u1 = simd16(secondin); @@ -11721,15 +13943,15 @@ int arm_detect_encodings(const char * buf, size_t len) { is_utf32 = false; // Code from arm_validate_utf16le.cpp // Not efficient, we do not process surrogates_wordmask1 - const char16_t * input = reinterpret_cast(buf); - const char16_t* end16 = reinterpret_cast(start) + len/2; + const char16_t* input = reinterpret_cast(buf); + const char16_t* end16 = reinterpret_cast(start) + len / 2; const auto v_fc = simd8::splat(0xfc); const auto v_dc = simd8::splat(0xdc); const uint64_t V0 = ~surrogates_wordmask0; - const auto vH0 = ((in16 & v_fc) == v_dc); + const auto vH0 = ((in16 & v_fc) == v_dc); const uint64_t H0 = vH0.to_bitmask64(); const uint64_t L0 = ~H0 & surrogates_wordmask0; @@ -11756,12 +13978,12 @@ int arm_detect_encodings(const char * buf, size_t len) { const simd8 in_16 = simd16::pack(t0, t1); const uint64_t surrogates_wordmask = ((in_16 & v_f8) == v_d8).to_bitmask64(); - if(surrogates_wordmask == 0) { + if (surrogates_wordmask == 0) { input += 16; } else { const uint64_t V = ~surrogates_wordmask; - const auto vH = ((in_16 & v_fc) == v_dc); + const auto vH = ((in_16 & v_fc) == v_dc); const uint64_t H = vH.to_bitmask64(); const uint64_t L = ~H & surrogates_wordmask; @@ -11785,23 +14007,23 @@ int arm_detect_encodings(const char * buf, size_t len) { is_utf16 = false; // Check for UTF-32 if (len % 4 == 0) { - const char32_t * input = reinterpret_cast(buf); - const char32_t* end32 = reinterpret_cast(start) + len/4; + const char32_t* input = reinterpret_cast(buf); + const char32_t* end32 = reinterpret_cast(start) + len / 4; // Must start checking for surrogates uint32x4_t currentoffsetmax = vmovq_n_u32(0x0); const uint32x4_t offset = vmovq_n_u32(0xffff2000); const uint32x4_t standardoffsetmax = vmovq_n_u32(0xfffff7ff); - const uint32x4_t in32 = vreinterpretq_u32_u16(in); - const uint32x4_t secondin32 = vreinterpretq_u32_u16(secondin); - const uint32x4_t thirdin32 = vreinterpretq_u32_u16(thirdin); - const uint32x4_t fourthin32 = vreinterpretq_u32_u16(fourthin); + const uint32x4_t in32 = vreinterpretq_u32_u16(in); + const uint32x4_t secondin32 = vreinterpretq_u32_u16(secondin); + const uint32x4_t thirdin32 = vreinterpretq_u32_u16(thirdin); + const uint32x4_t fourthin32 = vreinterpretq_u32_u16(fourthin); - currentmax = vmaxq_u32(in32,currentmax); - currentmax = vmaxq_u32(secondin32,currentmax); - currentmax = vmaxq_u32(thirdin32,currentmax); - currentmax = vmaxq_u32(fourthin32,currentmax); + currentmax = vmaxq_u32(in32, currentmax); + currentmax = vmaxq_u32(secondin32, currentmax); + currentmax = vmaxq_u32(thirdin32, currentmax); + currentmax = vmaxq_u32(fourthin32, currentmax); currentoffsetmax = vmaxq_u32(vaddq_u32(in32, offset), currentoffsetmax); currentoffsetmax = vmaxq_u32(vaddq_u32(secondin32, offset), currentoffsetmax); @@ -11810,13 +14032,13 @@ int arm_detect_encodings(const char * buf, size_t len) { while (input + 4 < end32) { const uint32x4_t in_32 = vld1q_u32(reinterpret_cast(input)); - currentmax = vmaxq_u32(in_32,currentmax); + currentmax = vmaxq_u32(in_32, currentmax); currentoffsetmax = vmaxq_u32(vaddq_u32(in_32, offset), currentoffsetmax); input += 4; } uint32x4_t forbidden_words = veorq_u32(vmaxq_u32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(vmaxvq_u32(forbidden_words) != 0) { + if (vmaxvq_u32(forbidden_words) != 0) { is_utf32 = false; } } else { @@ -11828,10 +14050,10 @@ int arm_detect_encodings(const char * buf, size_t len) { // If no surrogate, validate under other encodings as well // UTF-32 validation - currentmax = vmaxq_u32(vreinterpretq_u32_u16(in),currentmax); - currentmax = vmaxq_u32(vreinterpretq_u32_u16(secondin),currentmax); - currentmax = vmaxq_u32(vreinterpretq_u32_u16(thirdin),currentmax); - currentmax = vmaxq_u32(vreinterpretq_u32_u16(fourthin),currentmax); + currentmax = vmaxq_u32(vreinterpretq_u32_u16(in), currentmax); + currentmax = vmaxq_u32(vreinterpretq_u32_u16(secondin), currentmax); + currentmax = vmaxq_u32(vreinterpretq_u32_u16(thirdin), currentmax); + currentmax = vmaxq_u32(vreinterpretq_u32_u16(fourthin), currentmax); // UTF-8 validation // Relies on ../generic/utf8_validation/utf8_lookup4_algorithm.h @@ -11845,7 +14067,7 @@ int arm_detect_encodings(const char * buf, size_t len) { if (is_utf8) { if (static_cast(buf - start) != len) { - uint8_t block[64]{}; + uint8_t block[64] {}; std::memset(block, 0x20, 64); std::memcpy(block, buf, len - (buf - start)); simd::simd8x64 in(block); @@ -11856,14 +14078,14 @@ int arm_detect_encodings(const char * buf, size_t len) { } } - if (is_utf16 && scalar::utf16::validate(reinterpret_cast(buf), (len - (buf - start))/2)) { + if (is_utf16 && scalar::utf16::validate(reinterpret_cast(buf), (len - (buf - start)) / 2)) { out |= simdutf::encoding_type::UTF16_LE; } if (is_utf32 && (len % 4 == 0)) { const uint32x4_t standardmax = vmovq_n_u32(0x10ffff); uint32x4_t is_zero = veorq_u32(vmaxq_u32(currentmax, standardmax), standardmax); - if (vmaxvq_u32(is_zero) == 0 && scalar::utf32::validate(reinterpret_cast(buf), (len - (buf - start))/4)) { + if (vmaxvq_u32(is_zero) == 0 && scalar::utf32::validate(reinterpret_cast(buf), (len - (buf - start)) / 4)) { out |= simdutf::encoding_type::UTF32_LE; } } @@ -11872,10 +14094,11 @@ int arm_detect_encodings(const char * buf, size_t len) { } /* end file src/arm64/arm_detect_encodings.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_validate_utf16.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_validate_utf16.cpp /* begin file src/arm64/arm_validate_utf16.cpp */ -template -const char16_t* arm_validate_utf16(const char16_t* input, size_t size) { +template +const char16_t* arm_validate_utf16(const char16_t* input, size_t size) +{ const char16_t* end = input + size; const auto v_d8 = simd8::splat(0xd8); const auto v_f8 = simd8::splat(0xf8); @@ -11888,11 +14111,11 @@ const char16_t* arm_validate_utf16(const char16_t* input, size_t size) { auto in0 = simd16(input); auto in1 = simd16(input + simd16::SIZE / sizeof(char16_t)); if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif in0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in0), swap)); in1 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in1), swap)); } @@ -11901,7 +14124,7 @@ const char16_t* arm_validate_utf16(const char16_t* input, size_t size) { const simd8 in = simd16::pack(t0, t1); // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy). const uint64_t surrogates_wordmask = ((in & v_f8) == v_d8).to_bitmask64(); - if(surrogates_wordmask == 0) { + if (surrogates_wordmask == 0) { input += 16; } else { // 2. We have some surrogates that have to be distinguished: @@ -11915,7 +14138,7 @@ const char16_t* arm_validate_utf16(const char16_t* input, size_t size) { const uint64_t V = ~surrogates_wordmask; // H - word-mask for high surrogates: the six highest bits are 0b1101'11 - const auto vH = ((in & v_fc) == v_dc); + const auto vH = ((in & v_fc) == v_dc); const uint64_t H = vH.to_bitmask64(); // L - word mask for low surrogates @@ -11923,11 +14146,11 @@ const char16_t* arm_validate_utf16(const char16_t* input, size_t size) { const uint64_t L = ~H & surrogates_wordmask; const uint64_t a = L & (H >> 4); // A low surrogate must be followed by high one. - // (A low surrogate placed in the 7th register's word - // is an exception we handle.) + // (A low surrogate placed in the 7th register's word + // is an exception we handle.) const uint64_t b = a << 4; // Just mark that the opposite fact is hold, - // thanks to that we have only two masks for valid case. - const uint64_t c = V | a | b; // Combine all the masks into the final one. + // thanks to that we have only two masks for valid case. + const uint64_t c = V | a | b; // Combine all the masks into the final one. if (c == ~0ull) { // The whole input register contains valid UTF-16, i.e., // either single words or proper surrogate pairs. @@ -11946,9 +14169,9 @@ const char16_t* arm_validate_utf16(const char16_t* input, size_t size) { return input; } - -template -const result arm_validate_utf16_with_errors(const char16_t* input, size_t size) { +template +const result arm_validate_utf16_with_errors(const char16_t* input, size_t size) +{ const char16_t* start = input; const char16_t* end = input + size; @@ -11964,11 +14187,11 @@ const result arm_validate_utf16_with_errors(const char16_t* input, size_t size) auto in1 = simd16(input + simd16::SIZE / sizeof(char16_t)); if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif in0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in0), swap)); in1 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in1), swap)); } @@ -11977,7 +14200,7 @@ const result arm_validate_utf16_with_errors(const char16_t* input, size_t size) const simd8 in = simd16::pack(t0, t1); // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy). const uint64_t surrogates_wordmask = ((in & v_f8) == v_d8).to_bitmask64(); - if(surrogates_wordmask == 0) { + if (surrogates_wordmask == 0) { input += 16; } else { // 2. We have some surrogates that have to be distinguished: @@ -11991,7 +14214,7 @@ const result arm_validate_utf16_with_errors(const char16_t* input, size_t size) const uint64_t V = ~surrogates_wordmask; // H - word-mask for high surrogates: the six highest bits are 0b1101'11 - const auto vH = ((in & v_fc) == v_dc); + const auto vH = ((in & v_fc) == v_dc); const uint64_t H = vH.to_bitmask64(); // L - word mask for low surrogates @@ -11999,11 +14222,11 @@ const result arm_validate_utf16_with_errors(const char16_t* input, size_t size) const uint64_t L = ~H & surrogates_wordmask; const uint64_t a = L & (H >> 4); // A low surrogate must be followed by high one. - // (A low surrogate placed in the 7th register's word - // is an exception we handle.) + // (A low surrogate placed in the 7th register's word + // is an exception we handle.) const uint64_t b = a << 4; // Just mark that the opposite fact is hold, - // thanks to that we have only two masks for valid case. - const uint64_t c = V | a | b; // Combine all the masks into the final one. + // thanks to that we have only two masks for valid case. + const uint64_t c = V | a | b; // Combine all the masks into the final one. if (c == ~0ull) { // The whole input register contains valid UTF-16, i.e., // either single words or proper surrogate pairs. @@ -12022,10 +14245,11 @@ const result arm_validate_utf16_with_errors(const char16_t* input, size_t size) return result(error_code::SUCCESS, input - start); } /* end file src/arm64/arm_validate_utf16.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_validate_utf32le.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_validate_utf32le.cpp /* begin file src/arm64/arm_validate_utf32le.cpp */ -const char32_t* arm_validate_utf32le(const char32_t* input, size_t size) { +const char32_t* arm_validate_utf32le(const char32_t* input, size_t size) +{ const char32_t* end = input + size; const uint32x4_t standardmax = vmovq_n_u32(0x10ffff); @@ -12036,26 +14260,26 @@ const char32_t* arm_validate_utf32le(const char32_t* input, size_t size) { while (input + 4 < end) { const uint32x4_t in = vld1q_u32(reinterpret_cast(input)); - currentmax = vmaxq_u32(in,currentmax); + currentmax = vmaxq_u32(in, currentmax); currentoffsetmax = vmaxq_u32(vaddq_u32(in, offset), currentoffsetmax); input += 4; } uint32x4_t is_zero = veorq_u32(vmaxq_u32(currentmax, standardmax), standardmax); - if(vmaxvq_u32(is_zero) != 0) { + if (vmaxvq_u32(is_zero) != 0) { return nullptr; } is_zero = veorq_u32(vmaxq_u32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(vmaxvq_u32(is_zero) != 0) { + if (vmaxvq_u32(is_zero) != 0) { return nullptr; } return input; } - -const result arm_validate_utf32le_with_errors(const char32_t* input, size_t size) { +const result arm_validate_utf32le_with_errors(const char32_t* input, size_t size) +{ const char32_t* start = input; const char32_t* end = input + size; @@ -12067,16 +14291,16 @@ const result arm_validate_utf32le_with_errors(const char32_t* input, size_t size while (input + 4 < end) { const uint32x4_t in = vld1q_u32(reinterpret_cast(input)); - currentmax = vmaxq_u32(in,currentmax); + currentmax = vmaxq_u32(in, currentmax); currentoffsetmax = vmaxq_u32(vaddq_u32(in, offset), currentoffsetmax); uint32x4_t is_zero = veorq_u32(vmaxq_u32(currentmax, standardmax), standardmax); - if(vmaxvq_u32(is_zero) != 0) { + if (vmaxvq_u32(is_zero) != 0) { return result(error_code::TOO_LARGE, input - start); } is_zero = veorq_u32(vmaxq_u32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(vmaxvq_u32(is_zero) != 0) { + if (vmaxvq_u32(is_zero) != 0) { return result(error_code::SURROGATE, input - start); } @@ -12087,316 +14311,308 @@ const result arm_validate_utf32le_with_errors(const char32_t* input, size_t size } /* end file src/arm64/arm_validate_utf32le.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_convert_utf8_to_utf16.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_convert_utf8_to_utf16.cpp /* begin file src/arm64/arm_convert_utf8_to_utf16.cpp */ // Convert up to 12 bytes from utf8 to utf16 using a mask indicating the // end of the code points. Only the least significant 12 bits of the mask // are accessed. // It returns how many bytes were consumed (up to 12). -template -size_t convert_masked_utf8_to_utf16(const char *input, - uint64_t utf8_end_of_code_point_mask, - char16_t *&utf16_output) { - // we use an approach where we try to process up to 12 input bytes. - // Why 12 input bytes and not 16? Because we are concerned with the size of - // the lookup tables. Also 12 is nicely divisible by two and three. - // - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - uint8x16_t in = vld1q_u8(reinterpret_cast(input)); - const uint16_t input_utf8_end_of_code_point_mask = - utf8_end_of_code_point_mask & 0xfff; - // - // Optimization note: our main path below is load-latency dependent. Thus it is maybe - // beneficial to have fast paths that depend on branch prediction but have less latency. - // This results in more instructions but, potentially, also higher speeds. - // - // We first try a few fast paths. - if((utf8_end_of_code_point_mask & 0xffff) == 0xffff) { - // We process in chunks of 16 bytes - uint16x8_t ascii_first = vmovl_u8(vget_low_u8 (in)); - uint16x8_t ascii_second = vmovl_high_u8(in); - if (!match_system(big_endian)) { - ascii_first = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(ascii_first), swap)); - ascii_second = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(ascii_second), swap)); - } - vst1q_u16(reinterpret_cast(utf16_output), ascii_first); - vst1q_u16(reinterpret_cast(utf16_output) + 8, ascii_second); - utf16_output += 16; // We wrote 16 16-bit characters. - return 16; // We consumed 16 bytes. - } - if((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa) { - // We want to take 8 2-byte UTF-8 words and turn them into 8 2-byte UTF-16 words. - // There is probably a more efficient sequence, but the following might do. - uint8x16_t perm = vqtbl1q_u8(in, swap); - uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x7f))); - uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x1f00))); - uint8x16_t composed = vorrq_u8(ascii, vreinterpretq_u8_u16(vshrq_n_u16(vreinterpretq_u16_u8(highbyte), 2))); - if (!match_system(big_endian)) composed = vqtbl1q_u8(composed, swap); - vst1q_u8(reinterpret_cast(utf16_output), composed); - utf16_output += 8; // We wrote 16 bytes, 8 code points. - return 16; - } - if(input_utf8_end_of_code_point_mask == 0x924) { - // We want to take 4 3-byte UTF-8 words and turn them into 4 2-byte UTF-16 words. - // There is probably a more efficient sequence, but the following might do. +template +size_t convert_masked_utf8_to_utf16(const char* input, + uint64_t utf8_end_of_code_point_mask, + char16_t*& utf16_output) +{ +// we use an approach where we try to process up to 12 input bytes. +// Why 12 input bytes and not 16? Because we are concerned with the size of +// the lookup tables. Also 12 is nicely divisible by two and three. +// +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + uint8x16_t in = vld1q_u8(reinterpret_cast(input)); + const uint16_t input_utf8_end_of_code_point_mask = utf8_end_of_code_point_mask & 0xfff; + // + // Optimization note: our main path below is load-latency dependent. Thus it is maybe + // beneficial to have fast paths that depend on branch prediction but have less latency. + // This results in more instructions but, potentially, also higher speeds. + // + // We first try a few fast paths. + if ((utf8_end_of_code_point_mask & 0xffff) == 0xffff) { + // We process in chunks of 16 bytes + uint16x8_t ascii_first = vmovl_u8(vget_low_u8(in)); + uint16x8_t ascii_second = vmovl_high_u8(in); + if (!match_system(big_endian)) { + ascii_first = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(ascii_first), swap)); + ascii_second = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(ascii_second), swap)); + } + vst1q_u16(reinterpret_cast(utf16_output), ascii_first); + vst1q_u16(reinterpret_cast(utf16_output) + 8, ascii_second); + utf16_output += 16; // We wrote 16 16-bit characters. + return 16; // We consumed 16 bytes. + } + if ((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa) { + // We want to take 8 2-byte UTF-8 words and turn them into 8 2-byte UTF-16 words. + // There is probably a more efficient sequence, but the following might do. + uint8x16_t perm = vqtbl1q_u8(in, swap); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x7f))); + uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x1f00))); + uint8x16_t composed = vorrq_u8(ascii, vreinterpretq_u8_u16(vshrq_n_u16(vreinterpretq_u16_u8(highbyte), 2))); + if (!match_system(big_endian)) { + composed = vqtbl1q_u8(composed, swap); + } + vst1q_u8(reinterpret_cast(utf16_output), composed); + utf16_output += 8; // We wrote 16 bytes, 8 code points. + return 16; + } + if (input_utf8_end_of_code_point_mask == 0x924) { + // We want to take 4 3-byte UTF-8 words and turn them into 4 2-byte UTF-16 words. + // There is probably a more efficient sequence, but the following might do. #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t sh = make_uint8x16_t(2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255); + const uint8x16_t sh = make_uint8x16_t(2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255); #else - const uint8x16_t sh = {2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255}; + const uint8x16_t sh = { 2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255 }; #endif - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = - vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); // 7 or 6 bits - uint8x16_t middlebyte = - vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); // 5 or 6 bits - uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); - uint32x4_t highbyte = - vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x0f0000)))); // 4 bits - uint32x4_t highbyte_shifted = vshrq_n_u32(highbyte, 4); - uint32x4_t composed = - vorrq_u32(vorrq_u32(vreinterpretq_u32_u8(ascii), vreinterpretq_u32_u8(middlebyte_shifted)), highbyte_shifted); - uint16x8_t composed_repacked = vmovn_high_u32(vmovn_u32(composed), composed); - if (!match_system(big_endian)) composed_repacked = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(composed_repacked), swap)); - vst1q_u16(reinterpret_cast(utf16_output), composed_repacked); - utf16_output += 4; - return 12; - } - /// We do not have a fast path available, so we fallback. - - const uint8_t idx = - simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; - const uint8_t consumed = - simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; - - - if (idx < 64) { - // SIX (6) input code-words - // this is a relatively easy scenario - // we process SIX (6) input code-words. The max length in bytes of six code - // words spanning between 1 and 2 bytes each is 12 bytes. - uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x7f))); - uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x1f00))); - uint8x16_t composed = vorrq_u8(ascii, vreinterpretq_u8_u16(vshrq_n_u16(vreinterpretq_u16_u8(highbyte), 2))); - if (!match_system(big_endian)) composed = vqtbl1q_u8(composed, swap); - vst1q_u8(reinterpret_cast(utf16_output), composed); - utf16_output += 6; // We wrote 12 bytes, 6 code points. - } else if (idx < 145) { - // FOUR (4) input code-words - uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = - vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); // 7 or 6 bits - uint8x16_t middlebyte = - vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); // 5 or 6 bits - uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); - uint32x4_t highbyte = - vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x0f0000)))); // 4 bits - uint32x4_t highbyte_shifted = vshrq_n_u32(highbyte, 4); - uint32x4_t composed = - vorrq_u32(vorrq_u32(vreinterpretq_u32_u8(ascii), vreinterpretq_u32_u8(middlebyte_shifted)), highbyte_shifted); - uint16x8_t composed_repacked = vmovn_high_u32(vmovn_u32(composed), composed); - if (!match_system(big_endian)) composed_repacked = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(composed_repacked), swap)); - vst1q_u16(reinterpret_cast(utf16_output), composed_repacked); - utf16_output += 4; - } else if (idx < 209) { - // TWO (2) input code-words - uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); - uint8x16_t middlebyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); - uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); - uint8x16_t middlehighbyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f0000))); - // correct for spurious high bit - uint8x16_t correct = - vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x400000)))), 1)); - middlehighbyte = veorq_u8(correct, middlehighbyte); - uint8x16_t middlehighbyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlehighbyte), 4)); - uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x07000000))); - uint8x16_t highbyte_shifted =vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(highbyte), 6)); - uint8x16_t composed = - vorrq_u8(vorrq_u8(ascii, middlebyte_shifted), - vorrq_u8(highbyte_shifted, middlehighbyte_shifted)); - uint32x4_t composedminus = - vsubq_u32(vreinterpretq_u32_u8(composed), vmovq_n_u32(0x10000)); - uint32x4_t lowtenbits = - vandq_u32(composedminus, vmovq_n_u32(0x3ff)); - uint32x4_t hightenbits = vshrq_n_u32(composedminus, 10); - uint32x4_t lowtenbitsadd = - vaddq_u32(lowtenbits, vmovq_n_u32(0xDC00)); - uint32x4_t hightenbitsadd = - vaddq_u32(hightenbits, vmovq_n_u32(0xD800)); - uint32x4_t lowtenbitsaddshifted = vshlq_n_u32(lowtenbitsadd, 16); - uint32x4_t surrogates = - vorrq_u32(hightenbitsadd, lowtenbitsaddshifted); - uint32_t basic_buffer[4]; - uint32_t basic_buffer_swap[4]; - if (!match_system(big_endian)) { - vst1q_u32(basic_buffer_swap, vreinterpretq_u32_u8(vqtbl1q_u8(composed, swap))); - surrogates = vreinterpretq_u32_u8(vqtbl1q_u8(vreinterpretq_u8_u32(surrogates), swap)); - } - vst1q_u32(basic_buffer, vreinterpretq_u32_u8(composed)); - uint32_t surrogate_buffer[4]; - vst1q_u32(surrogate_buffer, surrogates); - for (size_t i = 0; i < 3; i++) { - if (basic_buffer[i] < 65536) { - utf16_output[0] = !match_system(big_endian) ? uint16_t(basic_buffer_swap[i]) : uint16_t(basic_buffer[i]); - utf16_output++; - } else { - utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff); - utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16); - utf16_output += 2; - } - } - } else { - // here we know that there is an error but we do not handle errors - } - return consumed; + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); // 7 or 6 bits + uint8x16_t middlebyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); // 5 or 6 bits + uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); + uint32x4_t highbyte = vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x0f0000)))); // 4 bits + uint32x4_t highbyte_shifted = vshrq_n_u32(highbyte, 4); + uint32x4_t composed = vorrq_u32(vorrq_u32(vreinterpretq_u32_u8(ascii), vreinterpretq_u32_u8(middlebyte_shifted)), highbyte_shifted); + uint16x8_t composed_repacked = vmovn_high_u32(vmovn_u32(composed), composed); + if (!match_system(big_endian)) { + composed_repacked = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(composed_repacked), swap)); + } + vst1q_u16(reinterpret_cast(utf16_output), composed_repacked); + utf16_output += 4; + return 12; + } + /// We do not have a fast path available, so we fallback. + + const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; + const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; + + if (idx < 64) { + // SIX (6) input code-words + // this is a relatively easy scenario + // we process SIX (6) input code-words. The max length in bytes of six code + // words spanning between 1 and 2 bytes each is 12 bytes. + uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x7f))); + uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x1f00))); + uint8x16_t composed = vorrq_u8(ascii, vreinterpretq_u8_u16(vshrq_n_u16(vreinterpretq_u16_u8(highbyte), 2))); + if (!match_system(big_endian)) { + composed = vqtbl1q_u8(composed, swap); + } + vst1q_u8(reinterpret_cast(utf16_output), composed); + utf16_output += 6; // We wrote 12 bytes, 6 code points. + } else if (idx < 145) { + // FOUR (4) input code-words + uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); // 7 or 6 bits + uint8x16_t middlebyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); // 5 or 6 bits + uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); + uint32x4_t highbyte = vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x0f0000)))); // 4 bits + uint32x4_t highbyte_shifted = vshrq_n_u32(highbyte, 4); + uint32x4_t composed = vorrq_u32(vorrq_u32(vreinterpretq_u32_u8(ascii), vreinterpretq_u32_u8(middlebyte_shifted)), highbyte_shifted); + uint16x8_t composed_repacked = vmovn_high_u32(vmovn_u32(composed), composed); + if (!match_system(big_endian)) { + composed_repacked = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(composed_repacked), swap)); + } + vst1q_u16(reinterpret_cast(utf16_output), composed_repacked); + utf16_output += 4; + } else if (idx < 209) { + // TWO (2) input code-words + ////////////// + // There might be garbage inputs where a leading byte mascarades as a four-byte + // leading byte (by being followed by 3 continuation byte), but is not greater than + // 0xf0. This could trigger a buffer overflow if we only counted leading + // bytes of the form 0xf0 as generating surrogate pairs, without further UTF-8 validation. + // Thus we must be careful to ensure that only leading bytes at least as large as 0xf0 generate surrogate pairs. + // We do as at the cost of an extra mask. + ///////////// + uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); + uint8x16_t middlebyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); + uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); + uint8x16_t middlehighbyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f0000))); + // correct for spurious high bit + uint8x16_t correct = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x400000)))), 1)); + middlehighbyte = veorq_u8(correct, middlehighbyte); + uint8x16_t middlehighbyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlehighbyte), 4)); + // We deliberately carry the leading four bits if they are present, we remove + // them later when computing hightenbits. + uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0xff000000))); + uint8x16_t highbyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(highbyte), 6)); + // When we need to generate a surrogate pair (leading byte > 0xF0), then + // the corresponding 32-bit value in 'composed' will be greater than + // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the + // location of the surrogate pairs. + uint8x16_t composed = vorrq_u8(vorrq_u8(ascii, middlebyte_shifted), + vorrq_u8(highbyte_shifted, middlehighbyte_shifted)); + uint32x4_t composedminus = vsubq_u32(vreinterpretq_u32_u8(composed), vmovq_n_u32(0x10000)); + uint32x4_t lowtenbits = vandq_u32(composedminus, vmovq_n_u32(0x3ff)); + // Notice the 0x3ff mask: + uint32x4_t hightenbits = vandq_u32(vshrq_n_u32(composedminus, 10), vmovq_n_u32(0x3ff)); + uint32x4_t lowtenbitsadd = vaddq_u32(lowtenbits, vmovq_n_u32(0xDC00)); + uint32x4_t hightenbitsadd = vaddq_u32(hightenbits, vmovq_n_u32(0xD800)); + uint32x4_t lowtenbitsaddshifted = vshlq_n_u32(lowtenbitsadd, 16); + uint32x4_t surrogates = vorrq_u32(hightenbitsadd, lowtenbitsaddshifted); + uint32_t basic_buffer[4]; + uint32_t basic_buffer_swap[4]; + if (!match_system(big_endian)) { + vst1q_u32(basic_buffer_swap, vreinterpretq_u32_u8(vqtbl1q_u8(composed, swap))); + surrogates = vreinterpretq_u32_u8(vqtbl1q_u8(vreinterpretq_u8_u32(surrogates), swap)); + } + vst1q_u32(basic_buffer, vreinterpretq_u32_u8(composed)); + uint32_t surrogate_buffer[4]; + vst1q_u32(surrogate_buffer, surrogates); + for (size_t i = 0; i < 3; i++) { + if (basic_buffer[i] > 0x3c00000) { + utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff); + utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16); + utf16_output += 2; + } else { + utf16_output[0] = !match_system(big_endian) ? uint16_t(basic_buffer_swap[i]) : uint16_t(basic_buffer[i]); + utf16_output++; + } + } + } else { + // here we know that there is an error but we do not handle errors + } + return consumed; } /* end file src/arm64/arm_convert_utf8_to_utf16.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_convert_utf8_to_utf32.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_convert_utf8_to_utf32.cpp /* begin file src/arm64/arm_convert_utf8_to_utf32.cpp */ // Convert up to 12 bytes from utf8 to utf32 using a mask indicating the // end of the code points. Only the least significant 12 bits of the mask // are accessed. // It returns how many bytes were consumed (up to 12). -size_t convert_masked_utf8_to_utf32(const char *input, - uint64_t utf8_end_of_code_point_mask, - char32_t *&utf32_out) { - // we use an approach where we try to process up to 12 input bytes. - // Why 12 input bytes and not 16? Because we are concerned with the size of - // the lookup tables. Also 12 is nicely divisible by two and three. - // - uint32_t*& utf32_output = reinterpret_cast(utf32_out); - uint8x16_t in = vld1q_u8(reinterpret_cast(input)); - const uint16_t input_utf8_end_of_code_point_mask = - utf8_end_of_code_point_mask & 0xFFF; - // - // Optimization note: our main path below is load-latency dependent. Thus it is maybe - // beneficial to have fast paths that depend on branch prediction but have less latency. - // This results in more instructions but, potentially, also higher speeds. - // - // We first try a few fast paths. - if((utf8_end_of_code_point_mask & 0xffff) == 0xffff) { - // We process in chunks of 16 bytes - vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(vmovl_u8(vget_low_u8 (in))))); - vst1q_u32(utf32_output + 4, vmovl_high_u16(vmovl_u8(vget_low_u8 (in)))); - vst1q_u32(utf32_output + 8, vmovl_u16(vget_low_u16(vmovl_high_u8(in)))); - vst1q_u32(utf32_output + 12, vmovl_high_u16(vmovl_high_u8(in))); - utf32_output += 16; // We wrote 16 16-bit characters. - return 16; // We consumed 16 bytes. - } - if((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa) { - // We want to take 8 2-byte UTF-8 words and turn them into 8 4-byte UTF-32 words. - // There is probably a more efficient sequence, but the following might do. +size_t convert_masked_utf8_to_utf32(const char* input, + uint64_t utf8_end_of_code_point_mask, + char32_t*& utf32_out) +{ + // we use an approach where we try to process up to 12 input bytes. + // Why 12 input bytes and not 16? Because we are concerned with the size of + // the lookup tables. Also 12 is nicely divisible by two and three. + // + uint32_t*& utf32_output = reinterpret_cast(utf32_out); + uint8x16_t in = vld1q_u8(reinterpret_cast(input)); + const uint16_t input_utf8_end_of_code_point_mask = utf8_end_of_code_point_mask & 0xFFF; + // + // Optimization note: our main path below is load-latency dependent. Thus it is maybe + // beneficial to have fast paths that depend on branch prediction but have less latency. + // This results in more instructions but, potentially, also higher speeds. + // + // We first try a few fast paths. + if ((utf8_end_of_code_point_mask & 0xffff) == 0xffff) { + // We process in chunks of 16 bytes + vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(vmovl_u8(vget_low_u8(in))))); + vst1q_u32(utf32_output + 4, vmovl_high_u16(vmovl_u8(vget_low_u8(in)))); + vst1q_u32(utf32_output + 8, vmovl_u16(vget_low_u16(vmovl_high_u8(in)))); + vst1q_u32(utf32_output + 12, vmovl_high_u16(vmovl_high_u8(in))); + utf32_output += 16; // We wrote 16 16-bit characters. + return 16; // We consumed 16 bytes. + } + if ((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa) { + // We want to take 8 2-byte UTF-8 words and turn them into 8 4-byte UTF-32 words. + // There is probably a more efficient sequence, but the following might do. #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t sh = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + const uint8x16_t sh = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); #else - //const uint8x16_t sh = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - const uint8x16_t sh = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; + // const uint8x16_t sh = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; + const uint8x16_t sh = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; #endif - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x7f))); - uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x1f00))); - uint8x16_t composed = vorrq_u8(ascii, vreinterpretq_u8_u16(vshrq_n_u16(vreinterpretq_u16_u8(highbyte), 2))); - vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(vreinterpretq_u16_u8(composed)))); - vst1q_u32(utf32_output+4, vmovl_high_u16(vreinterpretq_u16_u8(composed))); - utf32_output += 8; // We wrote 32 bytes, 8 code points. - return 16; - } - if(input_utf8_end_of_code_point_mask == 0x924) { - // We want to take 4 3-byte UTF-8 words and turn them into 4 4-byte UTF-32 words. - // There is probably a more efficient sequence, but the following might do. + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x7f))); + uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x1f00))); + uint8x16_t composed = vorrq_u8(ascii, vreinterpretq_u8_u16(vshrq_n_u16(vreinterpretq_u16_u8(highbyte), 2))); + vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(vreinterpretq_u16_u8(composed)))); + vst1q_u32(utf32_output + 4, vmovl_high_u16(vreinterpretq_u16_u8(composed))); + utf32_output += 8; // We wrote 32 bytes, 8 code points. + return 16; + } + if (input_utf8_end_of_code_point_mask == 0x924) { + // We want to take 4 3-byte UTF-8 words and turn them into 4 4-byte UTF-32 words. + // There is probably a more efficient sequence, but the following might do. #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t sh = make_uint8x16_t(2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255); + const uint8x16_t sh = make_uint8x16_t(2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255); #else - const uint8x16_t sh = {2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255}; + const uint8x16_t sh = { 2, 1, 0, 255, 5, 4, 3, 255, 8, 7, 6, 255, 11, 10, 9, 255 }; #endif - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = - vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); // 7 or 6 bits - uint8x16_t middlebyte = - vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); // 5 or 6 bits - uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); - uint32x4_t highbyte = - vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x0f0000)))); // 4 bits - uint32x4_t highbyte_shifted = vshrq_n_u32(highbyte, 4); - uint32x4_t composed = - vorrq_u32(vorrq_u32(vreinterpretq_u32_u8(ascii), vreinterpretq_u32_u8(middlebyte_shifted)), highbyte_shifted); - vst1q_u32(utf32_output, composed); - utf32_output += 4; - return 12; - } - /// We do not have a fast path available, so we fallback. - - const uint8_t idx = - simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; - const uint8_t consumed = - simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; - - - if (idx < 64) { - // SIX (6) input code-words - // this is a relatively easy scenario - // we process SIX (6) input code-words. The max length in bytes of six code - // words spanning between 1 and 2 bytes each is 12 bytes. - uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x7f))); - uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x1f00))); - uint8x16_t composed = vorrq_u8(ascii, vreinterpretq_u8_u16(vshrq_n_u16(vreinterpretq_u16_u8(highbyte), 2))); - vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(vreinterpretq_u16_u8(composed)))); - vst1q_u32(utf32_output+4, vmovl_high_u16(vreinterpretq_u16_u8(composed))); - utf32_output += 6; // We wrote 12 bytes, 6 code points. - } else if (idx < 145) { - // FOUR (4) input code-words - uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = - vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); // 7 or 6 bits - uint8x16_t middlebyte = - vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); // 5 or 6 bits - uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); - uint32x4_t highbyte = - vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x0f0000)))); // 4 bits - uint32x4_t highbyte_shifted = vshrq_n_u32(highbyte, 4); - uint32x4_t composed = - vorrq_u32(vorrq_u32(vreinterpretq_u32_u8(ascii), vreinterpretq_u32_u8(middlebyte_shifted)), highbyte_shifted); - vst1q_u32(utf32_output, composed); - utf32_output += 4; - } else if (idx < 209) { - // TWO (2) input code-words - uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); - uint8x16_t perm = vqtbl1q_u8(in, sh); - uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); - uint8x16_t middlebyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); - uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); - uint8x16_t middlehighbyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f0000))); - // correct for spurious high bit - uint8x16_t correct = - vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x400000)))), 1)); - middlehighbyte = veorq_u8(correct, middlehighbyte); - uint8x16_t middlehighbyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlehighbyte), 4)); - uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x07000000))); - uint8x16_t highbyte_shifted =vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(highbyte), 6)); - uint8x16_t composed = - vorrq_u8(vorrq_u8(ascii, middlebyte_shifted), - vorrq_u8(highbyte_shifted, middlehighbyte_shifted)); - vst1q_u32(utf32_output, vreinterpretq_u32_u8(composed)); - utf32_output += 3; - } else { - // here we know that there is an error but we do not handle errors - } - return consumed; + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); // 7 or 6 bits + uint8x16_t middlebyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); // 5 or 6 bits + uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); + uint32x4_t highbyte = vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x0f0000)))); // 4 bits + uint32x4_t highbyte_shifted = vshrq_n_u32(highbyte, 4); + uint32x4_t composed = vorrq_u32(vorrq_u32(vreinterpretq_u32_u8(ascii), vreinterpretq_u32_u8(middlebyte_shifted)), highbyte_shifted); + vst1q_u32(utf32_output, composed); + utf32_output += 4; + return 12; + } + /// We do not have a fast path available, so we fallback. + + const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; + const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; + + if (idx < 64) { + // SIX (6) input code-words + // this is a relatively easy scenario + // we process SIX (6) input code-words. The max length in bytes of six code + // words spanning between 1 and 2 bytes each is 12 bytes. + uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x7f))); + uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u16(vmovq_n_u16(0x1f00))); + uint8x16_t composed = vorrq_u8(ascii, vreinterpretq_u8_u16(vshrq_n_u16(vreinterpretq_u16_u8(highbyte), 2))); + vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(vreinterpretq_u16_u8(composed)))); + vst1q_u32(utf32_output + 4, vmovl_high_u16(vreinterpretq_u16_u8(composed))); + utf32_output += 6; // We wrote 12 bytes, 6 code points. + } else if (idx < 145) { + // FOUR (4) input code-words + uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); // 7 or 6 bits + uint8x16_t middlebyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); // 5 or 6 bits + uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); + uint32x4_t highbyte = vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x0f0000)))); // 4 bits + uint32x4_t highbyte_shifted = vshrq_n_u32(highbyte, 4); + uint32x4_t composed = vorrq_u32(vorrq_u32(vreinterpretq_u32_u8(ascii), vreinterpretq_u32_u8(middlebyte_shifted)), highbyte_shifted); + vst1q_u32(utf32_output, composed); + utf32_output += 4; + } else if (idx < 209) { + // TWO (2) input code-words + uint8x16_t sh = vld1q_u8(reinterpret_cast(simdutf::tables::utf8_to_utf16::shufutf8[idx])); + uint8x16_t perm = vqtbl1q_u8(in, sh); + uint8x16_t ascii = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x7f))); + uint8x16_t middlebyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f00))); + uint8x16_t middlebyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlebyte), 2)); + uint8x16_t middlehighbyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x3f0000))); + // correct for spurious high bit + uint8x16_t correct = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x400000)))), 1)); + middlehighbyte = veorq_u8(correct, middlehighbyte); + uint8x16_t middlehighbyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(middlehighbyte), 4)); + uint8x16_t highbyte = vandq_u8(perm, vreinterpretq_u8_u32(vmovq_n_u32(0x07000000))); + uint8x16_t highbyte_shifted = vreinterpretq_u8_u32(vshrq_n_u32(vreinterpretq_u32_u8(highbyte), 6)); + uint8x16_t composed = vorrq_u8(vorrq_u8(ascii, middlebyte_shifted), + vorrq_u8(highbyte_shifted, middlehighbyte_shifted)); + vst1q_u32(utf32_output, vreinterpretq_u32_u8(composed)); + utf32_output += 3; + } else { + // here we know that there is an error but we do not handle errors + } + return consumed; } /* end file src/arm64/arm_convert_utf8_to_utf32.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_convert_utf16_to_utf8.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_convert_utf16_to_utf8.cpp /* begin file src/arm64/arm_convert_utf16_to_utf8.cpp */ /* The vectorized algorithm works on single SSE register i.e., it @@ -12450,533 +14666,540 @@ size_t convert_masked_utf8_to_utf32(const char *input, Returns a pair: the first unprocessed byte from buf and utf8_output A scalar routing should carry on the conversion of the tail. */ -template -std::pair arm_convert_utf16_to_utf8(const char16_t* buf, size_t len, char* utf8_out) { - uint8_t * utf8_output = reinterpret_cast(utf8_out); - const char16_t* end = buf + len; - - const uint16x8_t v_f800 = vmovq_n_u16((uint16_t)0xf800); - const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); - const uint16x8_t v_c080 = vmovq_n_u16((uint16_t)0xc080); - - while (buf + 16 <= end) { - uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); - if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - in = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), swap)); - } - if(vmaxvq_u16(in) <= 0x7F) { // ASCII fast path!!!! - // It is common enough that we have sequences of 16 consecutive ASCII characters. - uint16x8_t nextin = vld1q_u16(reinterpret_cast(buf) + 8); +template +std::pair arm_convert_utf16_to_utf8(const char16_t* buf, size_t len, char* utf8_out) +{ + uint8_t* utf8_output = reinterpret_cast(utf8_out); + const char16_t* end = buf + len; + + const uint16x8_t v_f800 = vmovq_n_u16((uint16_t)0xf800); + const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); + const uint16x8_t v_c080 = vmovq_n_u16((uint16_t)0xc080); + + while (buf + 16 <= end) { + uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - nextin = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(nextin), swap)); - } - if(vmaxvq_u16(nextin) > 0x7F) { - // 1. pack the bytes - // obviously suboptimal. - uint8x8_t utf8_packed = vmovn_u16(in); - // 2. store (8 bytes) - vst1_u8(utf8_output, utf8_packed); - // 3. adjust pointers - buf += 8; - utf8_output += 8; - in = nextin; - } else { - // 1. pack the bytes - // obviously suboptimal. - uint8x16_t utf8_packed = vmovn_high_u16(vmovn_u16(in), nextin); - // 2. store (16 bytes) - vst1q_u8(utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - } - - if (vmaxvq_u16(in) <= 0x7FF) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const uint16x8_t v_1f00 = vmovq_n_u16((int16_t)0x1f00); - const uint16x8_t v_003f = vmovq_n_u16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const uint16x8_t t0 = vshlq_n_u16(in, 2); - // t1 = [000a|aaaa|0000|0000] - const uint16x8_t t1 = vandq_u16(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const uint16x8_t t2 = vandq_u16(in, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const uint16x8_t t3 = vorrq_u16(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const uint16x8_t t4 = vorrq_u16(t3, v_c080); - // 2. merge ASCII and 2-byte codewords - const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); - const uint16x8_t one_byte_bytemask = vcleq_u16(in, v_007f); - const uint8x16_t utf8_unpacked = vreinterpretq_u8_u16(vbslq_u16(one_byte_bytemask, in, t4)); - // 3. prepare bitmask for 8-bit lookup #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t mask = make_uint16x8_t(0x0001, 0x0004, - 0x0010, 0x0040, - 0x0002, 0x0008, - 0x0020, 0x0080); + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + in = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), swap)); + } + if (vmaxvq_u16(in) <= 0x7F) { // ASCII fast path!!!! + // It is common enough that we have sequences of 16 consecutive ASCII characters. + uint16x8_t nextin = vld1q_u16(reinterpret_cast(buf) + 8); + if (!match_system(big_endian)) { +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + nextin = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(nextin), swap)); + } + if (vmaxvq_u16(nextin) > 0x7F) { + // 1. pack the bytes + // obviously suboptimal. + uint8x8_t utf8_packed = vmovn_u16(in); + // 2. store (8 bytes) + vst1_u8(utf8_output, utf8_packed); + // 3. adjust pointers + buf += 8; + utf8_output += 8; + in = nextin; + } else { + // 1. pack the bytes + // obviously suboptimal. + uint8x16_t utf8_packed = vmovn_high_u16(vmovn_u16(in), nextin); + // 2. store (16 bytes) + vst1q_u8(utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + } + + if (vmaxvq_u16(in) <= 0x7FF) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const uint16x8_t v_1f00 = vmovq_n_u16((int16_t)0x1f00); + const uint16x8_t v_003f = vmovq_n_u16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const uint16x8_t t0 = vshlq_n_u16(in, 2); + // t1 = [000a|aaaa|0000|0000] + const uint16x8_t t1 = vandq_u16(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const uint16x8_t t2 = vandq_u16(in, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const uint16x8_t t3 = vorrq_u16(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const uint16x8_t t4 = vorrq_u16(t3, v_c080); + // 2. merge ASCII and 2-byte codewords + const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); + const uint16x8_t one_byte_bytemask = vcleq_u16(in, v_007f); + const uint8x16_t utf8_unpacked = vreinterpretq_u8_u16(vbslq_u16(one_byte_bytemask, in, t4)); + // 3. prepare bitmask for 8-bit lookup +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint16x8_t mask = make_uint16x8_t(0x0001, 0x0004, + 0x0010, 0x0040, + 0x0002, 0x0008, + 0x0020, 0x0080); #else - const uint16x8_t mask = { 0x0001, 0x0004, - 0x0010, 0x0040, - 0x0002, 0x0008, - 0x0020, 0x0080 }; + const uint16x8_t mask = { 0x0001, 0x0004, + 0x0010, 0x0040, + 0x0002, 0x0008, + 0x0020, 0x0080 }; #endif - uint16_t m2 = vaddvq_u16(vandq_u16(one_byte_bytemask, mask)); - // 4. pack the bytes - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; - const uint8x16_t shuffle = vld1q_u8(row + 1); - const uint8x16_t utf8_packed = vqtbl1q_u8(utf8_unpacked, shuffle); - - // 5. store bytes - vst1q_u8(utf8_output, utf8_packed); - - // 6. adjust pointers - buf += 8; - utf8_output += row[0]; - continue; - - } - const uint16x8_t surrogates_bytemask = vceqq_u16(vandq_u16(in, v_f800), v_d800); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (vmaxvq_u16(surrogates_bytemask) == 0) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes + uint16_t m2 = vaddvq_u16(vandq_u16(one_byte_bytemask, mask)); + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; + const uint8x16_t shuffle = vld1q_u8(row + 1); + const uint8x16_t utf8_packed = vqtbl1q_u8(utf8_unpacked, shuffle); + + // 5. store bytes + vst1q_u8(utf8_output, utf8_packed); + + // 6. adjust pointers + buf += 8; + utf8_output += row[0]; + continue; + } + const uint16x8_t surrogates_bytemask = vceqq_u16(vandq_u16(in, v_f800), v_d800); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (vmaxvq_u16(surrogates_bytemask) == 0) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t dup_even = make_uint16x8_t(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + const uint16x8_t dup_even = make_uint16x8_t(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); #else - const uint16x8_t dup_even = {0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e}; + const uint16x8_t dup_even = { 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e }; #endif - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) vmovq_n_u16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const uint16x8_t t0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), vreinterpretq_u8_u16(dup_even))); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const uint16x8_t t1 = vandq_u16(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const uint16x8_t t2 = vorrq_u16 (t1, vec(0b1000000000000000)); - - // s0: [aaaa|bbbb|bbcc|cccc] => [0000|0000|0000|aaaa] - const uint16x8_t s0 = vshrq_n_u16(in, 12); - // s1: [aaaa|bbbb|bbcc|cccc] => [0000|bbbb|bb00|0000] - const uint16x8_t s1 = vandq_u16(in, vec(0b0000111111000000)); - // [0000|bbbb|bb00|0000] => [00bb|bbbb|0000|0000] - const uint16x8_t s1s = vshlq_n_u16(s1, 2); - // [00bb|bbbb|0000|aaaa] - const uint16x8_t s2 = vorrq_u16(s0, s1s); - // s3: [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const uint16x8_t s3 = vorrq_u16(s2, vec(0b1100000011100000)); - const uint16x8_t v_07ff = vmovq_n_u16((uint16_t)0x07FF); - const uint16x8_t one_or_two_bytes_bytemask = vcleq_u16(in, v_07ff); - const uint16x8_t m0 = vbicq_u16(vec(0b0100000000000000), one_or_two_bytes_bytemask); - const uint16x8_t s4 = veorq_u16(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const uint8x16_t out0 = vreinterpretq_u8_u16(vzip1q_u16(t2, s4)); - const uint8x16_t out1 = vreinterpretq_u8_u16(vzip2q_u16(t2, s4)); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); - const uint16x8_t one_byte_bytemask = vcleq_u16(in, v_007f); + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) vmovq_n_u16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const uint16x8_t t0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), vreinterpretq_u8_u16(dup_even))); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const uint16x8_t t1 = vandq_u16(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const uint16x8_t t2 = vorrq_u16(t1, simdutf_vec(0b1000000000000000)); + + // s0: [aaaa|bbbb|bbcc|cccc] => [0000|0000|0000|aaaa] + const uint16x8_t s0 = vshrq_n_u16(in, 12); + // s1: [aaaa|bbbb|bbcc|cccc] => [0000|bbbb|bb00|0000] + const uint16x8_t s1 = vandq_u16(in, simdutf_vec(0b0000111111000000)); + // [0000|bbbb|bb00|0000] => [00bb|bbbb|0000|0000] + const uint16x8_t s1s = vshlq_n_u16(s1, 2); + // [00bb|bbbb|0000|aaaa] + const uint16x8_t s2 = vorrq_u16(s0, s1s); + // s3: [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const uint16x8_t s3 = vorrq_u16(s2, simdutf_vec(0b1100000011100000)); + const uint16x8_t v_07ff = vmovq_n_u16((uint16_t)0x07FF); + const uint16x8_t one_or_two_bytes_bytemask = vcleq_u16(in, v_07ff); + const uint16x8_t m0 = vbicq_u16(simdutf_vec(0b0100000000000000), one_or_two_bytes_bytemask); + const uint16x8_t s4 = veorq_u16(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const uint8x16_t out0 = vreinterpretq_u8_u16(vzip1q_u16(t2, s4)); + const uint8x16_t out1 = vreinterpretq_u8_u16(vzip2q_u16(t2, s4)); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); + const uint16x8_t one_byte_bytemask = vcleq_u16(in, v_007f); #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t onemask = make_uint16x8_t(0x0001, 0x0004, - 0x0010, 0x0040, - 0x0100, 0x0400, - 0x1000, 0x4000 ); - const uint16x8_t twomask = make_uint16x8_t(0x0002, 0x0008, - 0x0020, 0x0080, - 0x0200, 0x0800, - 0x2000, 0x8000 ); + const uint16x8_t onemask = make_uint16x8_t(0x0001, 0x0004, + 0x0010, 0x0040, + 0x0100, 0x0400, + 0x1000, 0x4000); + const uint16x8_t twomask = make_uint16x8_t(0x0002, 0x0008, + 0x0020, 0x0080, + 0x0200, 0x0800, + 0x2000, 0x8000); #else - const uint16x8_t onemask = { 0x0001, 0x0004, - 0x0010, 0x0040, - 0x0100, 0x0400, - 0x1000, 0x4000 }; - const uint16x8_t twomask = { 0x0002, 0x0008, - 0x0020, 0x0080, - 0x0200, 0x0800, - 0x2000, 0x8000 }; + const uint16x8_t onemask = { 0x0001, 0x0004, + 0x0010, 0x0040, + 0x0100, 0x0400, + 0x1000, 0x4000 }; + const uint16x8_t twomask = { 0x0002, 0x0008, + 0x0020, 0x0080, + 0x0200, 0x0800, + 0x2000, 0x8000 }; #endif - const uint16x8_t combined = vorrq_u16(vandq_u16(one_byte_bytemask, onemask), vandq_u16(one_or_two_bytes_bytemask, twomask)); - const uint16_t mask = vaddvq_u16(combined); - // The following fast path may or may not be beneficial. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const uint8x16_t shuffle = {2,3,1,6,7,5,10,11,9,14,15,13,0,0,0,0}; - const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle); - const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle); - vst1q_u8(utf8_output, utf8_0); - utf8_output += 12; - vst1q_u8(utf8_output, utf8_1); - utf8_output += 12; - buf += 8; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const uint8x16_t shuffle0 = vld1q_u8(row0 + 1); - const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const uint8x16_t shuffle1 = vld1q_u8(row1 + 1); - const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle1); - - vst1q_u8(utf8_output, utf8_0); - utf8_output += row0[0]; - vst1q_u8(utf8_output, utf8_1); - utf8_output += row1[0]; - - buf += 8; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word & 0xFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word &0xF800 ) != 0xD800) { - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); + const uint16x8_t combined = vorrq_u16(vandq_u16(one_byte_bytemask, onemask), vandq_u16(one_or_two_bytes_bytemask, twomask)); + const uint16_t mask = vaddvq_u16(combined); + // The following fast path may or may not be beneficial. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const uint8x16_t shuffle = {2,3,1,6,7,5,10,11,9,14,15,13,0,0,0,0}; + const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle); + const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle); + vst1q_u8(utf8_output, utf8_0); + utf8_output += 12; + vst1q_u8(utf8_output, utf8_1); + utf8_output += 12; + buf += 8; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const uint8x16_t shuffle0 = vld1q_u8(row0 + 1); + const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const uint8x16_t shuffle1 = vld1q_u8(row1 + 1); + const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle1); + + vst1q_u8(utf8_output, utf8_0); + utf8_output += row0[0]; + vst1q_u8(utf8_output, utf8_1); + utf8_output += row1[0]; + + buf += 8; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(nullptr, reinterpret_cast(utf8_output)); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xF800) != 0xD800) { + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(nullptr, reinterpret_cast(utf8_output)); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + } + } + buf += k; } - } - buf += k; - } - } // while + } // while - return std::make_pair(buf, reinterpret_cast(utf8_output)); + return std::make_pair(buf, reinterpret_cast(utf8_output)); } - /* Returns a pair: a result struct and utf8_output. If there is an error, the count field of the result is the position of the error. Otherwise, it is the position of the first unprocessed byte in buf (even if finished). A scalar routing should carry on the conversion of the tail if needed. */ -template -std::pair arm_convert_utf16_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_out) { - uint8_t * utf8_output = reinterpret_cast(utf8_out); +template +std::pair arm_convert_utf16_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_out) +{ + uint8_t* utf8_output = reinterpret_cast(utf8_out); const char16_t* start = buf; - const char16_t* end = buf + len; - - const uint16x8_t v_f800 = vmovq_n_u16((uint16_t)0xf800); - const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); - const uint16x8_t v_c080 = vmovq_n_u16((uint16_t)0xc080); - - while (buf + 16 <= end) { - uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); - if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - in = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), swap)); - } - if(vmaxvq_u16(in) <= 0x7F) { // ASCII fast path!!!! - // It is common enough that we have sequences of 16 consecutive ASCII characters. - uint16x8_t nextin = vld1q_u16(reinterpret_cast(buf) + 8); + const char16_t* end = buf + len; + + const uint16x8_t v_f800 = vmovq_n_u16((uint16_t)0xf800); + const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); + const uint16x8_t v_c080 = vmovq_n_u16((uint16_t)0xc080); + + while (buf + 16 <= end) { + uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - nextin = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(nextin), swap)); - } - if(vmaxvq_u16(nextin) > 0x7F) { - // 1. pack the bytes - // obviously suboptimal. - uint8x8_t utf8_packed = vmovn_u16(in); - // 2. store (8 bytes) - vst1_u8(utf8_output, utf8_packed); - // 3. adjust pointers - buf += 8; - utf8_output += 8; - in = nextin; - } else { - // 1. pack the bytes - // obviously suboptimal. - uint8x16_t utf8_packed = vmovn_high_u16(vmovn_u16(in), nextin); - // 2. store (16 bytes) - vst1q_u8(utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - } - - if (vmaxvq_u16(in) <= 0x7FF) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const uint16x8_t v_1f00 = vmovq_n_u16((int16_t)0x1f00); - const uint16x8_t v_003f = vmovq_n_u16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const uint16x8_t t0 = vshlq_n_u16(in, 2); - // t1 = [000a|aaaa|0000|0000] - const uint16x8_t t1 = vandq_u16(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const uint16x8_t t2 = vandq_u16(in, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const uint16x8_t t3 = vorrq_u16(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const uint16x8_t t4 = vorrq_u16(t3, v_c080); - // 2. merge ASCII and 2-byte codewords - const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); - const uint16x8_t one_byte_bytemask = vcleq_u16(in, v_007f); - const uint8x16_t utf8_unpacked = vreinterpretq_u8_u16(vbslq_u16(one_byte_bytemask, in, t4)); - // 3. prepare bitmask for 8-bit lookup #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t mask = make_uint16x8_t(0x0001, 0x0004, - 0x0010, 0x0040, - 0x0002, 0x0008, - 0x0020, 0x0080); + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + in = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), swap)); + } + if (vmaxvq_u16(in) <= 0x7F) { // ASCII fast path!!!! + // It is common enough that we have sequences of 16 consecutive ASCII characters. + uint16x8_t nextin = vld1q_u16(reinterpret_cast(buf) + 8); + if (!match_system(big_endian)) { +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + nextin = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(nextin), swap)); + } + if (vmaxvq_u16(nextin) > 0x7F) { + // 1. pack the bytes + // obviously suboptimal. + uint8x8_t utf8_packed = vmovn_u16(in); + // 2. store (8 bytes) + vst1_u8(utf8_output, utf8_packed); + // 3. adjust pointers + buf += 8; + utf8_output += 8; + in = nextin; + } else { + // 1. pack the bytes + // obviously suboptimal. + uint8x16_t utf8_packed = vmovn_high_u16(vmovn_u16(in), nextin); + // 2. store (16 bytes) + vst1q_u8(utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + } + + if (vmaxvq_u16(in) <= 0x7FF) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const uint16x8_t v_1f00 = vmovq_n_u16((int16_t)0x1f00); + const uint16x8_t v_003f = vmovq_n_u16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const uint16x8_t t0 = vshlq_n_u16(in, 2); + // t1 = [000a|aaaa|0000|0000] + const uint16x8_t t1 = vandq_u16(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const uint16x8_t t2 = vandq_u16(in, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const uint16x8_t t3 = vorrq_u16(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const uint16x8_t t4 = vorrq_u16(t3, v_c080); + // 2. merge ASCII and 2-byte codewords + const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); + const uint16x8_t one_byte_bytemask = vcleq_u16(in, v_007f); + const uint8x16_t utf8_unpacked = vreinterpretq_u8_u16(vbslq_u16(one_byte_bytemask, in, t4)); + // 3. prepare bitmask for 8-bit lookup +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint16x8_t mask = make_uint16x8_t(0x0001, 0x0004, + 0x0010, 0x0040, + 0x0002, 0x0008, + 0x0020, 0x0080); #else - const uint16x8_t mask = { 0x0001, 0x0004, - 0x0010, 0x0040, - 0x0002, 0x0008, - 0x0020, 0x0080 }; + const uint16x8_t mask = { 0x0001, 0x0004, + 0x0010, 0x0040, + 0x0002, 0x0008, + 0x0020, 0x0080 }; #endif - uint16_t m2 = vaddvq_u16(vandq_u16(one_byte_bytemask, mask)); - // 4. pack the bytes - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; - const uint8x16_t shuffle = vld1q_u8(row + 1); - const uint8x16_t utf8_packed = vqtbl1q_u8(utf8_unpacked, shuffle); - - // 5. store bytes - vst1q_u8(utf8_output, utf8_packed); - - // 6. adjust pointers - buf += 8; - utf8_output += row[0]; - continue; - - } - const uint16x8_t surrogates_bytemask = vceqq_u16(vandq_u16(in, v_f800), v_d800); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (vmaxvq_u16(surrogates_bytemask) == 0) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes + uint16_t m2 = vaddvq_u16(vandq_u16(one_byte_bytemask, mask)); + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; + const uint8x16_t shuffle = vld1q_u8(row + 1); + const uint8x16_t utf8_packed = vqtbl1q_u8(utf8_unpacked, shuffle); + + // 5. store bytes + vst1q_u8(utf8_output, utf8_packed); + + // 6. adjust pointers + buf += 8; + utf8_output += row[0]; + continue; + } + const uint16x8_t surrogates_bytemask = vceqq_u16(vandq_u16(in, v_f800), v_d800); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (vmaxvq_u16(surrogates_bytemask) == 0) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t dup_even = make_uint16x8_t(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + const uint16x8_t dup_even = make_uint16x8_t(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); #else - const uint16x8_t dup_even = {0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e}; + const uint16x8_t dup_even = { 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e }; #endif - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) vmovq_n_u16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const uint16x8_t t0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), vreinterpretq_u8_u16(dup_even))); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const uint16x8_t t1 = vandq_u16(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const uint16x8_t t2 = vorrq_u16 (t1, vec(0b1000000000000000)); - - // s0: [aaaa|bbbb|bbcc|cccc] => [0000|0000|0000|aaaa] - const uint16x8_t s0 = vshrq_n_u16(in, 12); - // s1: [aaaa|bbbb|bbcc|cccc] => [0000|bbbb|bb00|0000] - const uint16x8_t s1 = vandq_u16(in, vec(0b0000111111000000)); - // [0000|bbbb|bb00|0000] => [00bb|bbbb|0000|0000] - const uint16x8_t s1s = vshlq_n_u16(s1, 2); - // [00bb|bbbb|0000|aaaa] - const uint16x8_t s2 = vorrq_u16(s0, s1s); - // s3: [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const uint16x8_t s3 = vorrq_u16(s2, vec(0b1100000011100000)); - const uint16x8_t v_07ff = vmovq_n_u16((uint16_t)0x07FF); - const uint16x8_t one_or_two_bytes_bytemask = vcleq_u16(in, v_07ff); - const uint16x8_t m0 = vbicq_u16(vec(0b0100000000000000), one_or_two_bytes_bytemask); - const uint16x8_t s4 = veorq_u16(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const uint8x16_t out0 = vreinterpretq_u8_u16(vzip1q_u16(t2, s4)); - const uint8x16_t out1 = vreinterpretq_u8_u16(vzip2q_u16(t2, s4)); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); - const uint16x8_t one_byte_bytemask = vcleq_u16(in, v_007f); + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) vmovq_n_u16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const uint16x8_t t0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), vreinterpretq_u8_u16(dup_even))); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const uint16x8_t t1 = vandq_u16(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const uint16x8_t t2 = vorrq_u16(t1, simdutf_vec(0b1000000000000000)); + + // s0: [aaaa|bbbb|bbcc|cccc] => [0000|0000|0000|aaaa] + const uint16x8_t s0 = vshrq_n_u16(in, 12); + // s1: [aaaa|bbbb|bbcc|cccc] => [0000|bbbb|bb00|0000] + const uint16x8_t s1 = vandq_u16(in, simdutf_vec(0b0000111111000000)); + // [0000|bbbb|bb00|0000] => [00bb|bbbb|0000|0000] + const uint16x8_t s1s = vshlq_n_u16(s1, 2); + // [00bb|bbbb|0000|aaaa] + const uint16x8_t s2 = vorrq_u16(s0, s1s); + // s3: [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const uint16x8_t s3 = vorrq_u16(s2, simdutf_vec(0b1100000011100000)); + const uint16x8_t v_07ff = vmovq_n_u16((uint16_t)0x07FF); + const uint16x8_t one_or_two_bytes_bytemask = vcleq_u16(in, v_07ff); + const uint16x8_t m0 = vbicq_u16(simdutf_vec(0b0100000000000000), one_or_two_bytes_bytemask); + const uint16x8_t s4 = veorq_u16(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const uint8x16_t out0 = vreinterpretq_u8_u16(vzip1q_u16(t2, s4)); + const uint8x16_t out1 = vreinterpretq_u8_u16(vzip2q_u16(t2, s4)); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); + const uint16x8_t one_byte_bytemask = vcleq_u16(in, v_007f); #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t onemask = make_uint16x8_t(0x0001, 0x0004, - 0x0010, 0x0040, - 0x0100, 0x0400, - 0x1000, 0x4000 ); - const uint16x8_t twomask = make_uint16x8_t(0x0002, 0x0008, - 0x0020, 0x0080, - 0x0200, 0x0800, - 0x2000, 0x8000 ); + const uint16x8_t onemask = make_uint16x8_t(0x0001, 0x0004, + 0x0010, 0x0040, + 0x0100, 0x0400, + 0x1000, 0x4000); + const uint16x8_t twomask = make_uint16x8_t(0x0002, 0x0008, + 0x0020, 0x0080, + 0x0200, 0x0800, + 0x2000, 0x8000); #else - const uint16x8_t onemask = { 0x0001, 0x0004, - 0x0010, 0x0040, - 0x0100, 0x0400, - 0x1000, 0x4000 }; - const uint16x8_t twomask = { 0x0002, 0x0008, - 0x0020, 0x0080, - 0x0200, 0x0800, - 0x2000, 0x8000 }; + const uint16x8_t onemask = { 0x0001, 0x0004, + 0x0010, 0x0040, + 0x0100, 0x0400, + 0x1000, 0x4000 }; + const uint16x8_t twomask = { 0x0002, 0x0008, + 0x0020, 0x0080, + 0x0200, 0x0800, + 0x2000, 0x8000 }; #endif - const uint16x8_t combined = vorrq_u16(vandq_u16(one_byte_bytemask, onemask), vandq_u16(one_or_two_bytes_bytemask, twomask)); - const uint16_t mask = vaddvq_u16(combined); - // The following fast path may or may not be beneficial. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const uint8x16_t shuffle = {2,3,1,6,7,5,10,11,9,14,15,13,0,0,0,0}; - const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle); - const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle); - vst1q_u8(utf8_output, utf8_0); - utf8_output += 12; - vst1q_u8(utf8_output, utf8_1); - utf8_output += 12; - buf += 8; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const uint8x16_t shuffle0 = vld1q_u8(row0 + 1); - const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const uint8x16_t shuffle1 = vld1q_u8(row1 + 1); - const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle1); - - vst1q_u8(utf8_output, utf8_0); - utf8_output += row0[0]; - vst1q_u8(utf8_output, utf8_1); - utf8_output += row1[0]; - - buf += 8; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word & 0xFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word &0xF800 ) != 0xD800) { - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); + const uint16x8_t combined = vorrq_u16(vandq_u16(one_byte_bytemask, onemask), vandq_u16(one_or_two_bytes_bytemask, twomask)); + const uint16_t mask = vaddvq_u16(combined); + // The following fast path may or may not be beneficial. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const uint8x16_t shuffle = {2,3,1,6,7,5,10,11,9,14,15,13,0,0,0,0}; + const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle); + const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle); + vst1q_u8(utf8_output, utf8_0); + utf8_output += 12; + vst1q_u8(utf8_output, utf8_1); + utf8_output += 12; + buf += 8; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const uint8x16_t shuffle0 = vld1q_u8(row0 + 1); + const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const uint8x16_t shuffle1 = vld1q_u8(row1 + 1); + const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle1); + + vst1q_u8(utf8_output, utf8_0); + utf8_output += row0[0]; + vst1q_u8(utf8_output, utf8_1); + utf8_output += row1[0]; + + buf += 8; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), reinterpret_cast(utf8_output)); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xF800) != 0xD800) { + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), reinterpret_cast(utf8_output)); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + } + } + buf += k; } - } - buf += k; - } - } // while + } // while - return std::make_pair(result(error_code::SUCCESS, buf - start), reinterpret_cast(utf8_output)); + return std::make_pair(result(error_code::SUCCESS, buf - start), reinterpret_cast(utf8_output)); } /* end file src/arm64/arm_convert_utf16_to_utf8.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_convert_utf16_to_utf32.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_convert_utf16_to_utf32.cpp /* begin file src/arm64/arm_convert_utf16_to_utf32.cpp */ /* The vectorized algorithm works on single SSE register i.e., it @@ -13030,736 +15253,770 @@ std::pair arm_convert_utf16_to_utf8_with_errors(const char16_t* b Returns a pair: the first unprocessed byte from buf and utf8_output A scalar routing should carry on the conversion of the tail. */ -template -std::pair arm_convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_out) { - uint32_t * utf32_output = reinterpret_cast(utf32_out); - const char16_t* end = buf + len; - - const uint16x8_t v_f800 = vmovq_n_u16((uint16_t)0xf800); - const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); - - while (buf + 16 <= end) { - uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); - if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - in = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), swap)); - } - - const uint16x8_t surrogates_bytemask = vceqq_u16(vandq_u16(in, v_f800), v_d800); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (vmaxvq_u16(surrogates_bytemask) == 0) { - // case: no surrogate pairs, extend all 16-bit words to 32-bit words - vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(in))); - vst1q_u32(utf32_output+4, vmovl_high_u16(in)); - utf32_output += 8; - buf += 8; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word &0xF800 ) != 0xD800) { - *utf32_output++ = char32_t(word); +template +std::pair arm_convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_out) +{ + uint32_t* utf32_output = reinterpret_cast(utf32_out); + const char16_t* end = buf + len; + + const uint16x8_t v_f800 = vmovq_n_u16((uint16_t)0xf800); + const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); + + while (buf + 16 <= end) { + uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); + if (!match_system(big_endian)) { +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + in = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), swap)); + } + + const uint16x8_t surrogates_bytemask = vceqq_u16(vandq_u16(in, v_f800), v_d800); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (vmaxvq_u16(surrogates_bytemask) == 0) { + // case: no surrogate pairs, extend all 16-bit words to 32-bit words + vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(in))); + vst1q_u32(utf32_output + 4, vmovl_high_u16(in)); + utf32_output += 8; + buf += 8; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(nullptr, reinterpret_cast(utf32_output)); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xF800) != 0xD800) { + *utf32_output++ = char32_t(word); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(nullptr, reinterpret_cast(utf32_output)); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + } + } + buf += k; } - } - buf += k; - } - } // while - return std::make_pair(buf, reinterpret_cast(utf32_output)); + } // while + return std::make_pair(buf, reinterpret_cast(utf32_output)); } - /* Returns a pair: a result struct and utf8_output. If there is an error, the count field of the result is the position of the error. Otherwise, it is the position of the first unprocessed byte in buf (even if finished). A scalar routing should carry on the conversion of the tail if needed. */ -template -std::pair arm_convert_utf16_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_out) { - uint32_t * utf32_output = reinterpret_cast(utf32_out); - const char16_t* start = buf; - const char16_t* end = buf + len; - - const uint16x8_t v_f800 = vmovq_n_u16((uint16_t)0xf800); - const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); - - while (buf + 16 <= end) { - uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); - if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - #else - const uint8x16_t swap = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; - #endif - in = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), swap)); - } - - const uint16x8_t surrogates_bytemask = vceqq_u16(vandq_u16(in, v_f800), v_d800); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (vmaxvq_u16(surrogates_bytemask) == 0) { - // case: no surrogate pairs, extend all 16-bit words to 32-bit words - vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(in))); - vst1q_u32(utf32_output+4, vmovl_high_u16(in)); - utf32_output += 8; - buf += 8; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word &0xF800 ) != 0xD800) { - *utf32_output++ = char32_t(word); +template +std::pair arm_convert_utf16_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_out) +{ + uint32_t* utf32_output = reinterpret_cast(utf32_out); + const char16_t* start = buf; + const char16_t* end = buf + len; + + const uint16x8_t v_f800 = vmovq_n_u16((uint16_t)0xf800); + const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); + + while (buf + 16 <= end) { + uint16x8_t in = vld1q_u16(reinterpret_cast(buf)); + if (!match_system(big_endian)) { +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x16_t swap = make_uint8x16_t(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); +#else + const uint8x16_t swap = { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; +#endif + in = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(in), swap)); + } + + const uint16x8_t surrogates_bytemask = vceqq_u16(vandq_u16(in, v_f800), v_d800); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (vmaxvq_u16(surrogates_bytemask) == 0) { + // case: no surrogate pairs, extend all 16-bit words to 32-bit words + vst1q_u32(utf32_output, vmovl_u16(vget_low_u16(in))); + vst1q_u32(utf32_output + 4, vmovl_high_u16(in)); + utf32_output += 8; + buf += 8; + // surrogate pair(s) in a register + } else { + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xF800) != 0xD800) { + *utf32_output++ = char32_t(word); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), reinterpret_cast(utf32_output)); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + } + } + buf += k; + } + } // while + return std::make_pair(result(error_code::SUCCESS, buf - start), reinterpret_cast(utf32_output)); +} +/* end file src/arm64/arm_convert_utf16_to_utf32.cpp */ + +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_convert_utf32_to_utf8.cpp +/* begin file src/arm64/arm_convert_utf32_to_utf8.cpp */ +std::pair arm_convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_out) +{ + uint8_t* utf8_output = reinterpret_cast(utf8_out); + const char32_t* end = buf + len; + + const uint16x8_t v_c080 = vmovq_n_u16((uint16_t)0xc080); + + uint16x8_t forbidden_bytemask = vmovq_n_u16(0x0); + + while (buf + 16 <= end) { + uint32x4_t in = vld1q_u32(reinterpret_cast(buf)); + uint32x4_t nextin = vld1q_u32(reinterpret_cast(buf + 4)); + + // Check if no bits set above 16th + if (vmaxvq_u32(vorrq_u32(in, nextin)) <= 0xFFFF) { + // Pack UTF-32 to UTF-16 safely (without surrogate pairs) + // Apply UTF-16 => UTF-8 routine (arm_convert_utf16_to_utf8.cpp) + uint16x8_t utf16_packed = vcombine_u16(vmovn_u32(in), vmovn_u32(nextin)); + if (vmaxvq_u16(utf16_packed) <= 0x7F) { // ASCII fast path!!!! + // 1. pack the bytes + // obviously suboptimal. + uint8x8_t utf8_packed = vmovn_u16(utf16_packed); + // 2. store (8 bytes) + vst1_u8(utf8_output, utf8_packed); + // 3. adjust pointers + buf += 8; + utf8_output += 8; + continue; // we are done for this round! + } + + if (vmaxvq_u16(utf16_packed) <= 0x7FF) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const uint16x8_t v_1f00 = vmovq_n_u16((int16_t)0x1f00); + const uint16x8_t v_003f = vmovq_n_u16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const uint16x8_t t0 = vshlq_n_u16(utf16_packed, 2); + // t1 = [000a|aaaa|0000|0000] + const uint16x8_t t1 = vandq_u16(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const uint16x8_t t2 = vandq_u16(utf16_packed, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const uint16x8_t t3 = vorrq_u16(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const uint16x8_t t4 = vorrq_u16(t3, v_c080); + // 2. merge ASCII and 2-byte codewords + const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); + const uint16x8_t one_byte_bytemask = vcleq_u16(utf16_packed, v_007f); + const uint8x16_t utf8_unpacked = vreinterpretq_u8_u16(vbslq_u16(one_byte_bytemask, utf16_packed, t4)); + // 3. prepare bitmask for 8-bit lookup +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint16x8_t mask = make_uint16x8_t(0x0001, 0x0004, + 0x0010, 0x0040, + 0x0002, 0x0008, + 0x0020, 0x0080); +#else + const uint16x8_t mask = { 0x0001, 0x0004, + 0x0010, 0x0040, + 0x0002, 0x0008, + 0x0020, 0x0080 }; +#endif + uint16_t m2 = vaddvq_u16(vandq_u16(one_byte_bytemask, mask)); + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; + const uint8x16_t shuffle = vld1q_u8(row + 1); + const uint8x16_t utf8_packed = vqtbl1q_u8(utf8_unpacked, shuffle); + + // 5. store bytes + vst1q_u8(utf8_output, utf8_packed); + + // 6. adjust pointers + buf += 8; + utf8_output += row[0]; + continue; + + } else { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); + const uint16x8_t v_dfff = vmovq_n_u16((uint16_t)0xdfff); + forbidden_bytemask = vorrq_u16(vandq_u16(vcleq_u16(utf16_packed, v_dfff), vcgeq_u16(utf16_packed, v_d800)), forbidden_bytemask); + +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint16x8_t dup_even = make_uint16x8_t(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); +#else + const uint16x8_t dup_even = { 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e }; +#endif + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) vmovq_n_u16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const uint16x8_t t0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(utf16_packed), vreinterpretq_u8_u16(dup_even))); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const uint16x8_t t1 = vandq_u16(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const uint16x8_t t2 = vorrq_u16(t1, simdutf_vec(0b1000000000000000)); + + // s0: [aaaa|bbbb|bbcc|cccc] => [0000|0000|0000|aaaa] + const uint16x8_t s0 = vshrq_n_u16(utf16_packed, 12); + // s1: [aaaa|bbbb|bbcc|cccc] => [0000|bbbb|bb00|0000] + const uint16x8_t s1 = vandq_u16(utf16_packed, simdutf_vec(0b0000111111000000)); + // [0000|bbbb|bb00|0000] => [00bb|bbbb|0000|0000] + const uint16x8_t s1s = vshlq_n_u16(s1, 2); + // [00bb|bbbb|0000|aaaa] + const uint16x8_t s2 = vorrq_u16(s0, s1s); + // s3: [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const uint16x8_t s3 = vorrq_u16(s2, simdutf_vec(0b1100000011100000)); + const uint16x8_t v_07ff = vmovq_n_u16((uint16_t)0x07FF); + const uint16x8_t one_or_two_bytes_bytemask = vcleq_u16(utf16_packed, v_07ff); + const uint16x8_t m0 = vbicq_u16(simdutf_vec(0b0100000000000000), one_or_two_bytes_bytemask); + const uint16x8_t s4 = veorq_u16(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const uint8x16_t out0 = vreinterpretq_u8_u16(vzip1q_u16(t2, s4)); + const uint8x16_t out1 = vreinterpretq_u8_u16(vzip2q_u16(t2, s4)); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); + const uint16x8_t one_byte_bytemask = vcleq_u16(utf16_packed, v_007f); +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint16x8_t onemask = make_uint16x8_t(0x0001, 0x0004, + 0x0010, 0x0040, + 0x0100, 0x0400, + 0x1000, 0x4000); + const uint16x8_t twomask = make_uint16x8_t(0x0002, 0x0008, + 0x0020, 0x0080, + 0x0200, 0x0800, + 0x2000, 0x8000); +#else + const uint16x8_t onemask = { 0x0001, 0x0004, + 0x0010, 0x0040, + 0x0100, 0x0400, + 0x1000, 0x4000 }; + const uint16x8_t twomask = { 0x0002, 0x0008, + 0x0020, 0x0080, + 0x0200, 0x0800, + 0x2000, 0x8000 }; +#endif + const uint16x8_t combined = vorrq_u16(vandq_u16(one_byte_bytemask, onemask), vandq_u16(one_or_two_bytes_bytemask, twomask)); + const uint16_t mask = vaddvq_u16(combined); + // The following fast path may or may not be beneficial. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const uint8x16_t shuffle = {2,3,1,6,7,5,10,11,9,14,15,13,0,0,0,0}; + const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle); + const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle); + vst1q_u8(utf8_output, utf8_0); + utf8_output += 12; + vst1q_u8(utf8_output, utf8_1); + utf8_output += 12; + buf += 8; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const uint8x16_t shuffle0 = vld1q_u8(row0 + 1); + const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const uint8x16_t shuffle1 = vld1q_u8(row1 + 1); + const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle1); + + vst1q_u8(utf8_output, utf8_0); + utf8_output += row0[0]; + vst1q_u8(utf8_output, utf8_1); + utf8_output += row1[0]; + + buf += 8; + } + // At least one 32-bit word will produce a surrogate pair in UTF-16 <=> will produce four UTF-8 bytes. } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = !match_system(big_endian) ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), reinterpret_cast(utf32_output)); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFFFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xFFFFF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xFFFF0000) == 0) { + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(nullptr, reinterpret_cast(utf8_output)); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + if (word > 0x10FFFF) { + return std::make_pair(nullptr, reinterpret_cast(utf8_output)); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } + } + buf += k; } - } - buf += k; - } - } // while - return std::make_pair(result(error_code::SUCCESS, buf - start), reinterpret_cast(utf32_output)); -} -/* end file src/arm64/arm_convert_utf16_to_utf32.cpp */ + } // while + + // check for invalid input + if (vmaxvq_u16(forbidden_bytemask) != 0) { + return std::make_pair(nullptr, reinterpret_cast(utf8_output)); + } + return std::make_pair(buf, reinterpret_cast(utf8_output)); +} + +std::pair arm_convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_out) +{ + uint8_t* utf8_output = reinterpret_cast(utf8_out); + const char32_t* start = buf; + const char32_t* end = buf + len; + + const uint16x8_t v_c080 = vmovq_n_u16((uint16_t)0xc080); + + while (buf + 16 <= end) { + uint32x4_t in = vld1q_u32(reinterpret_cast(buf)); + uint32x4_t nextin = vld1q_u32(reinterpret_cast(buf + 4)); + + // Check if no bits set above 16th + if (vmaxvq_u32(vorrq_u32(in, nextin)) <= 0xFFFF) { + // Pack UTF-32 to UTF-16 safely (without surrogate pairs) + // Apply UTF-16 => UTF-8 routine (arm_convert_utf16_to_utf8.cpp) + uint16x8_t utf16_packed = vcombine_u16(vmovn_u32(in), vmovn_u32(nextin)); + if (vmaxvq_u16(utf16_packed) <= 0x7F) { // ASCII fast path!!!! + // 1. pack the bytes + // obviously suboptimal. + uint8x8_t utf8_packed = vmovn_u16(utf16_packed); + // 2. store (8 bytes) + vst1_u8(utf8_output, utf8_packed); + // 3. adjust pointers + buf += 8; + utf8_output += 8; + continue; // we are done for this round! + } -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_convert_utf32_to_utf8.cpp -/* begin file src/arm64/arm_convert_utf32_to_utf8.cpp */ -std::pair arm_convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_out) { - uint8_t * utf8_output = reinterpret_cast(utf8_out); - const char32_t* end = buf + len; - - const uint16x8_t v_c080 = vmovq_n_u16((uint16_t)0xc080); - - uint16x8_t forbidden_bytemask = vmovq_n_u16(0x0); - - while (buf + 16 <= end) { - uint32x4_t in = vld1q_u32(reinterpret_cast(buf)); - uint32x4_t nextin = vld1q_u32(reinterpret_cast(buf+4)); - - // Check if no bits set above 16th - if(vmaxvq_u32(vorrq_u32(in, nextin)) <= 0xFFFF) { - // Pack UTF-32 to UTF-16 safely (without surrogate pairs) - // Apply UTF-16 => UTF-8 routine (arm_convert_utf16_to_utf8.cpp) - uint16x8_t utf16_packed = vcombine_u16(vmovn_u32(in), vmovn_u32(nextin)); - if(vmaxvq_u16(utf16_packed) <= 0x7F) { // ASCII fast path!!!! - // 1. pack the bytes - // obviously suboptimal. - uint8x8_t utf8_packed = vmovn_u16(utf16_packed); - // 2. store (8 bytes) - vst1_u8(utf8_output, utf8_packed); - // 3. adjust pointers - buf += 8; - utf8_output += 8; - continue; // we are done for this round! - } - - if (vmaxvq_u16(utf16_packed) <= 0x7FF) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const uint16x8_t v_1f00 = vmovq_n_u16((int16_t)0x1f00); - const uint16x8_t v_003f = vmovq_n_u16((int16_t)0x003f); + if (vmaxvq_u16(utf16_packed) <= 0x7FF) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const uint16x8_t v_1f00 = vmovq_n_u16((int16_t)0x1f00); + const uint16x8_t v_003f = vmovq_n_u16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const uint16x8_t t0 = vshlq_n_u16(utf16_packed, 2); + // t1 = [000a|aaaa|0000|0000] + const uint16x8_t t1 = vandq_u16(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const uint16x8_t t2 = vandq_u16(utf16_packed, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const uint16x8_t t3 = vorrq_u16(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const uint16x8_t t4 = vorrq_u16(t3, v_c080); + // 2. merge ASCII and 2-byte codewords + const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); + const uint16x8_t one_byte_bytemask = vcleq_u16(utf16_packed, v_007f); + const uint8x16_t utf8_unpacked = vreinterpretq_u8_u16(vbslq_u16(one_byte_bytemask, utf16_packed, t4)); + // 3. prepare bitmask for 8-bit lookup +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint16x8_t mask = make_uint16x8_t(0x0001, 0x0004, + 0x0010, 0x0040, + 0x0002, 0x0008, + 0x0020, 0x0080); +#else + const uint16x8_t mask = { 0x0001, 0x0004, + 0x0010, 0x0040, + 0x0002, 0x0008, + 0x0020, 0x0080 }; +#endif + uint16_t m2 = vaddvq_u16(vandq_u16(one_byte_bytemask, mask)); + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; + const uint8x16_t shuffle = vld1q_u8(row + 1); + const uint8x16_t utf8_packed = vqtbl1q_u8(utf8_unpacked, shuffle); - // t0 = [000a|aaaa|bbbb|bb00] - const uint16x8_t t0 = vshlq_n_u16(utf16_packed, 2); - // t1 = [000a|aaaa|0000|0000] - const uint16x8_t t1 = vandq_u16(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const uint16x8_t t2 = vandq_u16(utf16_packed, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const uint16x8_t t3 = vorrq_u16(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const uint16x8_t t4 = vorrq_u16(t3, v_c080); - // 2. merge ASCII and 2-byte codewords - const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); - const uint16x8_t one_byte_bytemask = vcleq_u16(utf16_packed, v_007f); - const uint8x16_t utf8_unpacked = vreinterpretq_u8_u16(vbslq_u16(one_byte_bytemask, utf16_packed, t4)); - // 3. prepare bitmask for 8-bit lookup - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t mask = make_uint16x8_t(0x0001, 0x0004, - 0x0010, 0x0040, - 0x0002, 0x0008, - 0x0020, 0x0080); - #else - const uint16x8_t mask = { 0x0001, 0x0004, - 0x0010, 0x0040, - 0x0002, 0x0008, - 0x0020, 0x0080 }; - #endif - uint16_t m2 = vaddvq_u16(vandq_u16(one_byte_bytemask, mask)); - // 4. pack the bytes - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; - const uint8x16_t shuffle = vld1q_u8(row + 1); - const uint8x16_t utf8_packed = vqtbl1q_u8(utf8_unpacked, shuffle); + // 5. store bytes + vst1q_u8(utf8_output, utf8_packed); - // 5. store bytes - vst1q_u8(utf8_output, utf8_packed); + // 6. adjust pointers + buf += 8; + utf8_output += row[0]; + continue; - // 6. adjust pointers - buf += 8; - utf8_output += row[0]; - continue; + } else { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + + // check for invalid input + const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); + const uint16x8_t v_dfff = vmovq_n_u16((uint16_t)0xdfff); + const uint16x8_t forbidden_bytemask = vandq_u16(vcleq_u16(utf16_packed, v_dfff), vcgeq_u16(utf16_packed, v_d800)); + if (vmaxvq_u16(forbidden_bytemask) != 0) { + return std::make_pair(result(error_code::SURROGATE, buf - start), reinterpret_cast(utf8_output)); + } - } else { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); - const uint16x8_t v_dfff = vmovq_n_u16((uint16_t)0xdfff); - forbidden_bytemask = vorrq_u16(vandq_u16(vcleq_u16(utf16_packed, v_dfff), vcgeq_u16(utf16_packed, v_d800)), forbidden_bytemask); - - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t dup_even = make_uint16x8_t(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - #else - const uint16x8_t dup_even = {0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e}; - #endif - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ - #define vec(x) vmovq_n_u16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const uint16x8_t t0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(utf16_packed), vreinterpretq_u8_u16(dup_even))); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const uint16x8_t t1 = vandq_u16(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const uint16x8_t t2 = vorrq_u16 (t1, vec(0b1000000000000000)); - - // s0: [aaaa|bbbb|bbcc|cccc] => [0000|0000|0000|aaaa] - const uint16x8_t s0 = vshrq_n_u16(utf16_packed, 12); - // s1: [aaaa|bbbb|bbcc|cccc] => [0000|bbbb|bb00|0000] - const uint16x8_t s1 = vandq_u16(utf16_packed, vec(0b0000111111000000)); - // [0000|bbbb|bb00|0000] => [00bb|bbbb|0000|0000] - const uint16x8_t s1s = vshlq_n_u16(s1, 2); - // [00bb|bbbb|0000|aaaa] - const uint16x8_t s2 = vorrq_u16(s0, s1s); - // s3: [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const uint16x8_t s3 = vorrq_u16(s2, vec(0b1100000011100000)); - const uint16x8_t v_07ff = vmovq_n_u16((uint16_t)0x07FF); - const uint16x8_t one_or_two_bytes_bytemask = vcleq_u16(utf16_packed, v_07ff); - const uint16x8_t m0 = vbicq_u16(vec(0b0100000000000000), one_or_two_bytes_bytemask); - const uint16x8_t s4 = veorq_u16(s3, m0); - #undef vec - - // 4. expand words 16-bit => 32-bit - const uint8x16_t out0 = vreinterpretq_u8_u16(vzip1q_u16(t2, s4)); - const uint8x16_t out1 = vreinterpretq_u8_u16(vzip2q_u16(t2, s4)); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); - const uint16x8_t one_byte_bytemask = vcleq_u16(utf16_packed, v_007f); - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t onemask = make_uint16x8_t(0x0001, 0x0004, - 0x0010, 0x0040, - 0x0100, 0x0400, - 0x1000, 0x4000 ); - const uint16x8_t twomask = make_uint16x8_t(0x0002, 0x0008, - 0x0020, 0x0080, - 0x0200, 0x0800, - 0x2000, 0x8000 ); - #else - const uint16x8_t onemask = { 0x0001, 0x0004, - 0x0010, 0x0040, - 0x0100, 0x0400, - 0x1000, 0x4000 }; - const uint16x8_t twomask = { 0x0002, 0x0008, - 0x0020, 0x0080, - 0x0200, 0x0800, - 0x2000, 0x8000 }; - #endif - const uint16x8_t combined = vorrq_u16(vandq_u16(one_byte_bytemask, onemask), vandq_u16(one_or_two_bytes_bytemask, twomask)); - const uint16_t mask = vaddvq_u16(combined); - // The following fast path may or may not be beneficial. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const uint8x16_t shuffle = {2,3,1,6,7,5,10,11,9,14,15,13,0,0,0,0}; - const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle); - const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle); - vst1q_u8(utf8_output, utf8_0); - utf8_output += 12; - vst1q_u8(utf8_output, utf8_1); - utf8_output += 12; - buf += 8; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const uint8x16_t shuffle0 = vld1q_u8(row0 + 1); - const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const uint8x16_t shuffle1 = vld1q_u8(row1 + 1); - const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle1); - - vst1q_u8(utf8_output, utf8_0); - utf8_output += row0[0]; - vst1q_u8(utf8_output, utf8_1); - utf8_output += row1[0]; - - buf += 8; - } - // At least one 32-bit word will produce a surrogate pair in UTF-16 <=> will produce four UTF-8 bytes. - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFFFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xFFFFF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word & 0xFFFF0000)==0) { - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(nullptr, reinterpret_cast(utf8_output)); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint16x8_t dup_even = make_uint16x8_t(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); +#else + const uint16x8_t dup_even = { 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e }; +#endif + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) vmovq_n_u16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const uint16x8_t t0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(utf16_packed), vreinterpretq_u8_u16(dup_even))); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const uint16x8_t t1 = vandq_u16(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const uint16x8_t t2 = vorrq_u16(t1, simdutf_vec(0b1000000000000000)); + + // s0: [aaaa|bbbb|bbcc|cccc] => [0000|0000|0000|aaaa] + const uint16x8_t s0 = vshrq_n_u16(utf16_packed, 12); + // s1: [aaaa|bbbb|bbcc|cccc] => [0000|bbbb|bb00|0000] + const uint16x8_t s1 = vandq_u16(utf16_packed, simdutf_vec(0b0000111111000000)); + // [0000|bbbb|bb00|0000] => [00bb|bbbb|0000|0000] + const uint16x8_t s1s = vshlq_n_u16(s1, 2); + // [00bb|bbbb|0000|aaaa] + const uint16x8_t s2 = vorrq_u16(s0, s1s); + // s3: [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const uint16x8_t s3 = vorrq_u16(s2, simdutf_vec(0b1100000011100000)); + const uint16x8_t v_07ff = vmovq_n_u16((uint16_t)0x07FF); + const uint16x8_t one_or_two_bytes_bytemask = vcleq_u16(utf16_packed, v_07ff); + const uint16x8_t m0 = vbicq_u16(simdutf_vec(0b0100000000000000), one_or_two_bytes_bytemask); + const uint16x8_t s4 = veorq_u16(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const uint8x16_t out0 = vreinterpretq_u8_u16(vzip1q_u16(t2, s4)); + const uint8x16_t out1 = vreinterpretq_u8_u16(vzip2q_u16(t2, s4)); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); + const uint16x8_t one_byte_bytemask = vcleq_u16(utf16_packed, v_007f); +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint16x8_t onemask = make_uint16x8_t(0x0001, 0x0004, + 0x0010, 0x0040, + 0x0100, 0x0400, + 0x1000, 0x4000); + const uint16x8_t twomask = make_uint16x8_t(0x0002, 0x0008, + 0x0020, 0x0080, + 0x0200, 0x0800, + 0x2000, 0x8000); +#else + const uint16x8_t onemask = { 0x0001, 0x0004, + 0x0010, 0x0040, + 0x0100, 0x0400, + 0x1000, 0x4000 }; + const uint16x8_t twomask = { 0x0002, 0x0008, + 0x0020, 0x0080, + 0x0200, 0x0800, + 0x2000, 0x8000 }; +#endif + const uint16x8_t combined = vorrq_u16(vandq_u16(one_byte_bytemask, onemask), vandq_u16(one_or_two_bytes_bytemask, twomask)); + const uint16_t mask = vaddvq_u16(combined); + // The following fast path may or may not be beneficial. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const uint8x16_t shuffle = {2,3,1,6,7,5,10,11,9,14,15,13,0,0,0,0}; + const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle); + const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle); + vst1q_u8(utf8_output, utf8_0); + utf8_output += 12; + vst1q_u8(utf8_output, utf8_1); + utf8_output += 12; + buf += 8; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const uint8x16_t shuffle0 = vld1q_u8(row0 + 1); + const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const uint8x16_t shuffle1 = vld1q_u8(row1 + 1); + const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle1); + + vst1q_u8(utf8_output, utf8_0); + utf8_output += row0[0]; + vst1q_u8(utf8_output, utf8_1); + utf8_output += row1[0]; + + buf += 8; + } + // At least one 32-bit word will produce a surrogate pair in UTF-16 <=> will produce four UTF-8 bytes. } else { - if (word > 0x10FFFF) { return std::make_pair(nullptr, reinterpret_cast(utf8_output)); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } - } - buf += k; - } - } // while - - // check for invalid input - if (vmaxvq_u16(forbidden_bytemask) != 0) { - return std::make_pair(nullptr, reinterpret_cast(utf8_output)); - } - return std::make_pair(buf, reinterpret_cast(utf8_output)); -} - - -std::pair arm_convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_out) { - uint8_t * utf8_output = reinterpret_cast(utf8_out); - const char32_t* start = buf; - const char32_t* end = buf + len; - - const uint16x8_t v_c080 = vmovq_n_u16((uint16_t)0xc080); - - while (buf + 16 <= end) { - uint32x4_t in = vld1q_u32(reinterpret_cast(buf)); - uint32x4_t nextin = vld1q_u32(reinterpret_cast(buf+4)); - - // Check if no bits set above 16th - if(vmaxvq_u32(vorrq_u32(in, nextin)) <= 0xFFFF) { - // Pack UTF-32 to UTF-16 safely (without surrogate pairs) - // Apply UTF-16 => UTF-8 routine (arm_convert_utf16_to_utf8.cpp) - uint16x8_t utf16_packed = vcombine_u16(vmovn_u32(in), vmovn_u32(nextin)); - if(vmaxvq_u16(utf16_packed) <= 0x7F) { // ASCII fast path!!!! - // 1. pack the bytes - // obviously suboptimal. - uint8x8_t utf8_packed = vmovn_u16(utf16_packed); - // 2. store (8 bytes) - vst1_u8(utf8_output, utf8_packed); - // 3. adjust pointers - buf += 8; - utf8_output += 8; - continue; // we are done for this round! - } - - if (vmaxvq_u16(utf16_packed) <= 0x7FF) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const uint16x8_t v_1f00 = vmovq_n_u16((int16_t)0x1f00); - const uint16x8_t v_003f = vmovq_n_u16((int16_t)0x003f); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFFFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xFFFFF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xFFFF0000) == 0) { + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k), reinterpret_cast(utf8_output)); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + if (word > 0x10FFFF) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), reinterpret_cast(utf8_output)); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while - // t0 = [000a|aaaa|bbbb|bb00] - const uint16x8_t t0 = vshlq_n_u16(utf16_packed, 2); - // t1 = [000a|aaaa|0000|0000] - const uint16x8_t t1 = vandq_u16(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const uint16x8_t t2 = vandq_u16(utf16_packed, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const uint16x8_t t3 = vorrq_u16(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const uint16x8_t t4 = vorrq_u16(t3, v_c080); - // 2. merge ASCII and 2-byte codewords - const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); - const uint16x8_t one_byte_bytemask = vcleq_u16(utf16_packed, v_007f); - const uint8x16_t utf8_unpacked = vreinterpretq_u8_u16(vbslq_u16(one_byte_bytemask, utf16_packed, t4)); - // 3. prepare bitmask for 8-bit lookup - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t mask = make_uint16x8_t(0x0001, 0x0004, - 0x0010, 0x0040, - 0x0002, 0x0008, - 0x0020, 0x0080); - #else - const uint16x8_t mask = { 0x0001, 0x0004, - 0x0010, 0x0040, - 0x0002, 0x0008, - 0x0020, 0x0080 }; - #endif - uint16_t m2 = vaddvq_u16(vandq_u16(one_byte_bytemask, mask)); - // 4. pack the bytes - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; - const uint8x16_t shuffle = vld1q_u8(row + 1); - const uint8x16_t utf8_packed = vqtbl1q_u8(utf8_unpacked, shuffle); + return std::make_pair(result(error_code::SUCCESS, buf - start), reinterpret_cast(utf8_output)); +} +/* end file src/arm64/arm_convert_utf32_to_utf8.cpp */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=arm64/arm_convert_utf32_to_utf16.cpp +/* begin file src/arm64/arm_convert_utf32_to_utf16.cpp */ +template +std::pair arm_convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_out) +{ + uint16_t* utf16_output = reinterpret_cast(utf16_out); + const char32_t* end = buf + len; - // 5. store bytes - vst1q_u8(utf8_output, utf8_packed); + uint16x4_t forbidden_bytemask = vmov_n_u16(0x0); - // 6. adjust pointers - buf += 8; - utf8_output += row[0]; - continue; + while (buf + 4 <= end) { + uint32x4_t in = vld1q_u32(reinterpret_cast(buf)); - } else { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - - // check for invalid input - const uint16x8_t v_d800 = vmovq_n_u16((uint16_t)0xd800); - const uint16x8_t v_dfff = vmovq_n_u16((uint16_t)0xdfff); - const uint16x8_t forbidden_bytemask = vandq_u16(vcleq_u16(utf16_packed, v_dfff), vcgeq_u16(utf16_packed, v_d800)); - if (vmaxvq_u16(forbidden_bytemask) != 0) { - return std::make_pair(result(error_code::SURROGATE, buf - start), reinterpret_cast(utf8_output)); - } - - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t dup_even = make_uint16x8_t(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - #else - const uint16x8_t dup_even = {0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e}; - #endif - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ - #define vec(x) vmovq_n_u16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const uint16x8_t t0 = vreinterpretq_u16_u8(vqtbl1q_u8(vreinterpretq_u8_u16(utf16_packed), vreinterpretq_u8_u16(dup_even))); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const uint16x8_t t1 = vandq_u16(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const uint16x8_t t2 = vorrq_u16 (t1, vec(0b1000000000000000)); - - // s0: [aaaa|bbbb|bbcc|cccc] => [0000|0000|0000|aaaa] - const uint16x8_t s0 = vshrq_n_u16(utf16_packed, 12); - // s1: [aaaa|bbbb|bbcc|cccc] => [0000|bbbb|bb00|0000] - const uint16x8_t s1 = vandq_u16(utf16_packed, vec(0b0000111111000000)); - // [0000|bbbb|bb00|0000] => [00bb|bbbb|0000|0000] - const uint16x8_t s1s = vshlq_n_u16(s1, 2); - // [00bb|bbbb|0000|aaaa] - const uint16x8_t s2 = vorrq_u16(s0, s1s); - // s3: [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const uint16x8_t s3 = vorrq_u16(s2, vec(0b1100000011100000)); - const uint16x8_t v_07ff = vmovq_n_u16((uint16_t)0x07FF); - const uint16x8_t one_or_two_bytes_bytemask = vcleq_u16(utf16_packed, v_07ff); - const uint16x8_t m0 = vbicq_u16(vec(0b0100000000000000), one_or_two_bytes_bytemask); - const uint16x8_t s4 = veorq_u16(s3, m0); - #undef vec - - // 4. expand words 16-bit => 32-bit - const uint8x16_t out0 = vreinterpretq_u8_u16(vzip1q_u16(t2, s4)); - const uint8x16_t out1 = vreinterpretq_u8_u16(vzip2q_u16(t2, s4)); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint16x8_t v_007f = vmovq_n_u16((uint16_t)0x007F); - const uint16x8_t one_byte_bytemask = vcleq_u16(utf16_packed, v_007f); - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint16x8_t onemask = make_uint16x8_t(0x0001, 0x0004, - 0x0010, 0x0040, - 0x0100, 0x0400, - 0x1000, 0x4000 ); - const uint16x8_t twomask = make_uint16x8_t(0x0002, 0x0008, - 0x0020, 0x0080, - 0x0200, 0x0800, - 0x2000, 0x8000 ); - #else - const uint16x8_t onemask = { 0x0001, 0x0004, - 0x0010, 0x0040, - 0x0100, 0x0400, - 0x1000, 0x4000 }; - const uint16x8_t twomask = { 0x0002, 0x0008, - 0x0020, 0x0080, - 0x0200, 0x0800, - 0x2000, 0x8000 }; - #endif - const uint16x8_t combined = vorrq_u16(vandq_u16(one_byte_bytemask, onemask), vandq_u16(one_or_two_bytes_bytemask, twomask)); - const uint16_t mask = vaddvq_u16(combined); - // The following fast path may or may not be beneficial. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const uint8x16_t shuffle = {2,3,1,6,7,5,10,11,9,14,15,13,0,0,0,0}; - const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle); - const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle); - vst1q_u8(utf8_output, utf8_0); - utf8_output += 12; - vst1q_u8(utf8_output, utf8_1); - utf8_output += 12; - buf += 8; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const uint8x16_t shuffle0 = vld1q_u8(row0 + 1); - const uint8x16_t utf8_0 = vqtbl1q_u8(out0, shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const uint8x16_t shuffle1 = vld1q_u8(row1 + 1); - const uint8x16_t utf8_1 = vqtbl1q_u8(out1, shuffle1); - - vst1q_u8(utf8_output, utf8_0); - utf8_output += row0[0]; - vst1q_u8(utf8_output, utf8_1); - utf8_output += row1[0]; - - buf += 8; - } - // At least one 32-bit word will produce a surrogate pair in UTF-16 <=> will produce four UTF-8 bytes. - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFFFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xFFFFF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word & 0xFFFF0000)==0) { - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k), reinterpret_cast(utf8_output)); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); + // Check if no bits set above 16th + if (vmaxvq_u32(in) <= 0xFFFF) { + uint16x4_t utf16_packed = vmovn_u32(in); + + const uint16x4_t v_d800 = vmov_n_u16((uint16_t)0xd800); + const uint16x4_t v_dfff = vmov_n_u16((uint16_t)0xdfff); + forbidden_bytemask = vorr_u16(vand_u16(vcle_u16(utf16_packed, v_dfff), vcge_u16(utf16_packed, v_d800)), forbidden_bytemask); + + if (!match_system(big_endian)) { +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x8_t swap = make_uint8x8_t(1, 0, 3, 2, 5, 4, 7, 6); +#else + const uint8x8_t swap = { 1, 0, 3, 2, 5, 4, 7, 6 }; +#endif + utf16_packed = vreinterpret_u16_u8(vtbl1_u8(vreinterpret_u8_u16(utf16_packed), swap)); + } + vst1_u16(utf16_output, utf16_packed); + utf16_output += 4; + buf += 4; } else { - if (word > 0x10FFFF) { return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), reinterpret_cast(utf8_output)); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); + size_t forward = 3; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(nullptr, reinterpret_cast(utf16_output)); + } + *utf16_output++ = !match_system(big_endian) ? char16_t(word >> 8 | word << 8) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return std::make_pair(nullptr, reinterpret_cast(utf16_output)); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (!match_system(big_endian)) { + high_surrogate = uint16_t(high_surrogate >> 8 | high_surrogate << 8); + low_surrogate = uint16_t(low_surrogate << 8 | low_surrogate >> 8); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + } + buf += k; } - } - buf += k; } - } // while - return std::make_pair(result(error_code::SUCCESS, buf - start), reinterpret_cast(utf8_output)); + // check for invalid input + if (vmaxv_u16(forbidden_bytemask) != 0) { + return std::make_pair(nullptr, reinterpret_cast(utf16_output)); + } + + return std::make_pair(buf, reinterpret_cast(utf16_output)); } -/* end file src/arm64/arm_convert_utf32_to_utf8.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=arm64/arm_convert_utf32_to_utf16.cpp -/* begin file src/arm64/arm_convert_utf32_to_utf16.cpp */ -template -std::pair arm_convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_out) { - uint16_t * utf16_output = reinterpret_cast(utf16_out); - const char32_t* end = buf + len; - - uint16x4_t forbidden_bytemask = vmov_n_u16(0x0); - - while(buf + 4 <= end) { - uint32x4_t in = vld1q_u32(reinterpret_cast(buf)); - - // Check if no bits set above 16th - if(vmaxvq_u32(in) <= 0xFFFF) { - uint16x4_t utf16_packed = vmovn_u32(in); - - const uint16x4_t v_d800 = vmov_n_u16((uint16_t)0xd800); - const uint16x4_t v_dfff = vmov_n_u16((uint16_t)0xdfff); - forbidden_bytemask = vorr_u16(vand_u16(vcle_u16(utf16_packed, v_dfff), vcge_u16(utf16_packed, v_d800)), forbidden_bytemask); - - if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x8_t swap = make_uint8x8_t(1, 0, 3, 2, 5, 4, 7, 6); - #else - const uint8x8_t swap = {1, 0, 3, 2, 5, 4, 7, 6}; - #endif - utf16_packed = vreinterpret_u16_u8(vtbl1_u8(vreinterpret_u8_u16(utf16_packed), swap)); - } - vst1_u16(utf16_output, utf16_packed); - utf16_output += 4; - buf += 4; - } else { - size_t forward = 3; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(nullptr, reinterpret_cast(utf16_output)); } - *utf16_output++ = !match_system(big_endian) ? char16_t(word >> 8 | word << 8) : char16_t(word); - } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return std::make_pair(nullptr, reinterpret_cast(utf16_output)); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (!match_system(big_endian)) { - high_surrogate = uint16_t(high_surrogate >> 8 | high_surrogate << 8); - low_surrogate = uint16_t(low_surrogate << 8 | low_surrogate >> 8); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); - } - } - buf += k; - } - } - - // check for invalid input - if (vmaxv_u16(forbidden_bytemask) != 0) { - return std::make_pair(nullptr, reinterpret_cast(utf16_output)); - } - - return std::make_pair(buf, reinterpret_cast(utf16_output)); -} - - -template -std::pair arm_convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_out) { - uint16_t * utf16_output = reinterpret_cast(utf16_out); - const char32_t* start = buf; - const char32_t* end = buf + len; - - while(buf + 4 <= end) { - uint32x4_t in = vld1q_u32(reinterpret_cast(buf)); - - // Check if no bits set above 16th - if(vmaxvq_u32(in) <= 0xFFFF) { - uint16x4_t utf16_packed = vmovn_u32(in); - - const uint16x4_t v_d800 = vmov_n_u16((uint16_t)0xd800); - const uint16x4_t v_dfff = vmov_n_u16((uint16_t)0xdfff); - const uint16x4_t forbidden_bytemask = vand_u16(vcle_u16(utf16_packed, v_dfff), vcge_u16(utf16_packed, v_d800)); - if (vmaxv_u16(forbidden_bytemask) != 0) { - return std::make_pair(result(error_code::SURROGATE, buf - start), reinterpret_cast(utf16_output)); - } - - if (!match_system(big_endian)) { - #ifdef SIMDUTF_REGULAR_VISUAL_STUDIO - const uint8x8_t swap = make_uint8x8_t(1, 0, 3, 2, 5, 4, 7, 6); - #else - const uint8x8_t swap = {1, 0, 3, 2, 5, 4, 7, 6}; - #endif - utf16_packed = vreinterpret_u16_u8(vtbl1_u8(vreinterpret_u8_u16(utf16_packed), swap)); - } - vst1_u16(utf16_output, utf16_packed); - utf16_output += 4; - buf += 4; - } else { - size_t forward = 3; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k), reinterpret_cast(utf16_output)); } - *utf16_output++ = !match_system(big_endian) ? char16_t(word >> 8 | word << 8) : char16_t(word); + +template +std::pair arm_convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_out) +{ + uint16_t* utf16_output = reinterpret_cast(utf16_out); + const char32_t* start = buf; + const char32_t* end = buf + len; + + while (buf + 4 <= end) { + uint32x4_t in = vld1q_u32(reinterpret_cast(buf)); + + // Check if no bits set above 16th + if (vmaxvq_u32(in) <= 0xFFFF) { + uint16x4_t utf16_packed = vmovn_u32(in); + + const uint16x4_t v_d800 = vmov_n_u16((uint16_t)0xd800); + const uint16x4_t v_dfff = vmov_n_u16((uint16_t)0xdfff); + const uint16x4_t forbidden_bytemask = vand_u16(vcle_u16(utf16_packed, v_dfff), vcge_u16(utf16_packed, v_d800)); + if (vmaxv_u16(forbidden_bytemask) != 0) { + return std::make_pair(result(error_code::SURROGATE, buf - start), reinterpret_cast(utf16_output)); + } + + if (!match_system(big_endian)) { +#ifdef SIMDUTF_REGULAR_VISUAL_STUDIO + const uint8x8_t swap = make_uint8x8_t(1, 0, 3, 2, 5, 4, 7, 6); +#else + const uint8x8_t swap = { 1, 0, 3, 2, 5, 4, 7, 6 }; +#endif + utf16_packed = vreinterpret_u16_u8(vtbl1_u8(vreinterpret_u8_u16(utf16_packed), swap)); + } + vst1_u16(utf16_output, utf16_packed); + utf16_output += 4; + buf += 4; } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), reinterpret_cast(utf16_output)); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (!match_system(big_endian)) { - high_surrogate = uint16_t(high_surrogate >> 8 | high_surrogate << 8); - low_surrogate = uint16_t(low_surrogate << 8 | low_surrogate >> 8); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); + size_t forward = 3; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k), reinterpret_cast(utf16_output)); + } + *utf16_output++ = !match_system(big_endian) ? char16_t(word >> 8 | word << 8) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), reinterpret_cast(utf16_output)); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (!match_system(big_endian)) { + high_surrogate = uint16_t(high_surrogate >> 8 | high_surrogate << 8); + low_surrogate = uint16_t(low_surrogate << 8 | low_surrogate >> 8); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + } + buf += k; } - } - buf += k; } - } - return std::make_pair(result(error_code::SUCCESS, buf - start), reinterpret_cast(utf16_output)); + return std::make_pair(result(error_code::SUCCESS, buf - start), reinterpret_cast(utf16_output)); } /* end file src/arm64/arm_convert_utf32_to_utf16.cpp */ } // unnamed namespace } // namespace arm64 } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/buf_block_reader.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/buf_block_reader.h /* begin file src/generic/buf_block_reader.h */ namespace simdutf { namespace arm64 { @@ -13769,92 +16026,110 @@ namespace { template struct buf_block_reader { public: - simdutf_really_inline buf_block_reader(const uint8_t *_buf, size_t _len); - simdutf_really_inline size_t block_index(); - simdutf_really_inline bool has_full_block() const; - simdutf_really_inline const uint8_t *full_block() const; - /** - * Get the last block, padded with spaces. - * - * There will always be a last block, with at least 1 byte, unless len == 0 (in which case this - * function fills the buffer with spaces and returns 0. In particular, if len == STEP_SIZE there - * will be 0 full_blocks and 1 remainder block with STEP_SIZE bytes and no spaces for padding. - * - * @return the number of effective characters in the last block. - */ - simdutf_really_inline size_t get_remainder(uint8_t *dst) const; - simdutf_really_inline void advance(); + simdutf_really_inline buf_block_reader(const uint8_t* _buf, size_t _len); + simdutf_really_inline size_t block_index(); + simdutf_really_inline bool has_full_block() const; + simdutf_really_inline const uint8_t* full_block() const; + /** + * Get the last block, padded with spaces. + * + * There will always be a last block, with at least 1 byte, unless len == 0 (in which case this + * function fills the buffer with spaces and returns 0. In particular, if len == STEP_SIZE there + * will be 0 full_blocks and 1 remainder block with STEP_SIZE bytes and no spaces for padding. + * + * @return the number of effective characters in the last block. + */ + simdutf_really_inline size_t get_remainder(uint8_t* dst) const; + simdutf_really_inline void advance(); + private: - const uint8_t *buf; - const size_t len; - const size_t lenminusstep; - size_t idx; + const uint8_t* buf; + const size_t len; + const size_t lenminusstep; + size_t idx; }; // Routines to print masks and text for debugging bitmask operations -simdutf_unused static char * format_input_text_64(const uint8_t *text) { - static char *buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); - for (size_t i=0; i); i++) { - buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); - } - buf[sizeof(simd8x64)] = '\0'; - return buf; +simdutf_unused static char* format_input_text_64(const uint8_t* text) +{ + static char* buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); + for (size_t i = 0; i < sizeof(simd8x64); i++) { + buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); + } + buf[sizeof(simd8x64)] = '\0'; + return buf; } // Routines to print masks and text for debugging bitmask operations -simdutf_unused static char * format_input_text(const simd8x64& in) { - static char *buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); - in.store(reinterpret_cast(buf)); - for (size_t i=0; i); i++) { - if (buf[i] < ' ') { buf[i] = '_'; } - } - buf[sizeof(simd8x64)] = '\0'; - return buf; +simdutf_unused static char* format_input_text(const simd8x64& in) +{ + static char* buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); + in.store(reinterpret_cast(buf)); + for (size_t i = 0; i < sizeof(simd8x64); i++) { + if (buf[i] < ' ') { + buf[i] = '_'; + } + } + buf[sizeof(simd8x64)] = '\0'; + return buf; } -simdutf_unused static char * format_mask(uint64_t mask) { - static char *buf = reinterpret_cast(malloc(64 + 1)); - for (size_t i=0; i<64; i++) { - buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; - } - buf[64] = '\0'; - return buf; +simdutf_unused static char* format_mask(uint64_t mask) +{ + static char* buf = reinterpret_cast(malloc(64 + 1)); + for (size_t i = 0; i < 64; i++) { + buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; + } + buf[64] = '\0'; + return buf; } template -simdutf_really_inline buf_block_reader::buf_block_reader(const uint8_t *_buf, size_t _len) : buf{_buf}, len{_len}, lenminusstep{len < STEP_SIZE ? 0 : len - STEP_SIZE}, idx{0} {} +simdutf_really_inline buf_block_reader::buf_block_reader(const uint8_t* _buf, size_t _len) + : buf { _buf } + , len { _len } + , lenminusstep { len < STEP_SIZE ? 0 : len - STEP_SIZE } + , idx { 0 } +{ +} template simdutf_really_inline size_t buf_block_reader::block_index() { return idx; } template -simdutf_really_inline bool buf_block_reader::has_full_block() const { - return idx < lenminusstep; +simdutf_really_inline bool buf_block_reader::has_full_block() const +{ + return idx < lenminusstep; } template -simdutf_really_inline const uint8_t *buf_block_reader::full_block() const { - return &buf[idx]; +simdutf_really_inline const uint8_t* buf_block_reader::full_block() const +{ + return &buf[idx]; } template -simdutf_really_inline size_t buf_block_reader::get_remainder(uint8_t *dst) const { - if(len == idx) { return 0; } // memcpy(dst, null, 0) will trigger an error with some sanitizers - std::memset(dst, 0x20, STEP_SIZE); // std::memset STEP_SIZE because it's more efficient to write out 8 or 16 bytes at once. - std::memcpy(dst, buf + idx, len - idx); - return len - idx; +simdutf_really_inline size_t buf_block_reader::get_remainder(uint8_t* dst) const +{ + if (len == idx) { + return 0; + } // memcpy(dst, null, 0) will trigger an error with some sanitizers + std::memset(dst, 0x20, STEP_SIZE); // std::memset STEP_SIZE because it's more efficient to write out 8 or 16 bytes at once. + std::memcpy(dst, buf + idx, len - idx); + return len - idx; } template -simdutf_really_inline void buf_block_reader::advance() { - idx += STEP_SIZE; +simdutf_really_inline void buf_block_reader::advance() +{ + idx += STEP_SIZE; } } // unnamed namespace } // namespace arm64 } // namespace simdutf /* end file src/generic/buf_block_reader.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_validation/utf8_lookup4_algorithm.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_validation/utf8_lookup4_algorithm.h /* begin file src/generic/utf8_validation/utf8_lookup4_algorithm.h */ namespace simdutf { namespace arm64 { @@ -13863,21 +16138,22 @@ namespace utf8_validation { using namespace simd; - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -13885,101 +16161,92 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } +} - // - // Return nonzero if there are incomplete multibyte characters at the end of the block: - // e.g. if there is a 4-byte character, but it's 3 bytes from the end. - // - simdutf_really_inline simd8 is_incomplete(const simd8 input) { +// +// Return nonzero if there are incomplete multibyte characters at the end of the block: +// e.g. if there is a 4-byte character, but it's 3 bytes from the end. +// +simdutf_really_inline simd8 is_incomplete(const simd8 input) +{ // If the previous input's last 3 bytes match this, they're too short (they ended at EOF): // ... 1111____ 111_____ 11______ static const uint8_t max_array[32] = { - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 0b11110000u-1, 0b11100000u-1, 0b11000000u-1 + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 0b11110000u - 1, 0b11100000u - 1, 0b11000000u - 1 }; - const simd8 max_value(&max_array[sizeof(max_array)-sizeof(simd8)]); + const simd8 max_value(&max_array[sizeof(max_array) - sizeof(simd8)]); return input.gt_bits(max_value); - } +} - struct utf8_checker { +struct utf8_checker { // If this is nonzero, there has been a UTF-8 error. simd8 error; // The last input we received @@ -13990,51 +16257,54 @@ using namespace simd; // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); } // The only problem that can happen at EOF is that a multibyte character is too short // or a byte value too large in the last bytes: check_special_cases only checks for bytes // too large in the first of two bytes. - simdutf_really_inline void check_eof() { - // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't - // possibly finish them. - this->error |= this->prev_incomplete; + simdutf_really_inline void check_eof() + { + // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't + // possibly finish them. + this->error |= this->prev_incomplete; } - simdutf_really_inline void check_next_input(const simd8x64& input) { - if(simdutf_likely(is_ascii(input))) { - this->error |= this->prev_incomplete; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + simdutf_really_inline void check_next_input(const simd8x64& input) + { + if (simdutf_likely(is_ascii(input))) { + this->error |= this->prev_incomplete; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + this->prev_incomplete = is_incomplete(input.chunks[simd8x64::NUM_CHUNKS - 1]); + this->prev_input_block = input.chunks[simd8x64::NUM_CHUNKS - 1]; } - this->prev_incomplete = is_incomplete(input.chunks[simd8x64::NUM_CHUNKS-1]); - this->prev_input_block = input.chunks[simd8x64::NUM_CHUNKS-1]; - - } } // do not forget to call check_eof! - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // namespace utf8_validation using utf8_validation::utf8_checker; @@ -14043,7 +16313,7 @@ using utf8_validation::utf8_checker; } // namespace arm64 } // namespace simdutf /* end file src/generic/utf8_validation/utf8_lookup4_algorithm.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_validation/utf8_validator.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_validation/utf8_validator.h /* begin file src/generic/utf8_validation/utf8_validator.h */ namespace simdutf { namespace arm64 { @@ -14054,15 +16324,16 @@ namespace utf8_validation { * Validates that the string is actual UTF-8. */ template -bool generic_validate_utf8(const uint8_t * input, size_t length) { - checker c{}; +bool generic_validate_utf8(const uint8_t* input, size_t length) +{ + checker c {}; buf_block_reader<64> reader(input, length); while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - c.check_next_input(in); - reader.advance(); + simd::simd8x64 in(reader.full_block()); + c.check_next_input(in); + reader.advance(); } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); c.check_next_input(in); @@ -14071,97 +16342,106 @@ bool generic_validate_utf8(const uint8_t * input, size_t length) { return !c.errors(); } -bool generic_validate_utf8(const char * input, size_t length) { - return generic_validate_utf8(reinterpret_cast(input),length); +bool generic_validate_utf8(const char* input, size_t length) +{ + return generic_validate_utf8(reinterpret_cast(input), length); } /** * Validates that the string is actual UTF-8 and stops on errors. */ template -result generic_validate_utf8_with_errors(const uint8_t * input, size_t length) { - checker c{}; +result generic_validate_utf8_with_errors(const uint8_t* input, size_t length) +{ + checker c {}; buf_block_reader<64> reader(input, length); - size_t count{0}; + size_t count { 0 }; while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - c.check_next_input(in); - if(c.errors()) { - if (count != 0) { count--; } // Sometimes the error is only detected in the next chunk - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input + count), length - count); - res.count += count; - return res; - } - reader.advance(); - count += 64; + simd::simd8x64 in(reader.full_block()); + c.check_next_input(in); + if (c.errors()) { + if (count != 0) { + count--; + } // Sometimes the error is only detected in the next chunk + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input + count), length - count); + res.count += count; + return res; + } + reader.advance(); + count += 64; } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); c.check_next_input(in); reader.advance(); c.check_eof(); if (c.errors()) { - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input) + count, length - count); - res.count += count; - return res; + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input) + count, length - count); + res.count += count; + return res; } else { - return result(error_code::SUCCESS, length); + return result(error_code::SUCCESS, length); } } -result generic_validate_utf8_with_errors(const char * input, size_t length) { - return generic_validate_utf8_with_errors(reinterpret_cast(input),length); +result generic_validate_utf8_with_errors(const char* input, size_t length) +{ + return generic_validate_utf8_with_errors(reinterpret_cast(input), length); } template -bool generic_validate_ascii(const uint8_t * input, size_t length) { +bool generic_validate_ascii(const uint8_t* input, size_t length) +{ buf_block_reader<64> reader(input, length); - uint8_t blocks[64]{}; + uint8_t blocks[64] {}; simd::simd8x64 running_or(blocks); while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - running_or |= in; - reader.advance(); + simd::simd8x64 in(reader.full_block()); + running_or |= in; + reader.advance(); } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); running_or |= in; return running_or.is_ascii(); } -bool generic_validate_ascii(const char * input, size_t length) { - return generic_validate_ascii(reinterpret_cast(input),length); +bool generic_validate_ascii(const char* input, size_t length) +{ + return generic_validate_ascii(reinterpret_cast(input), length); } template -result generic_validate_ascii_with_errors(const uint8_t * input, size_t length) { - buf_block_reader<64> reader(input, length); - size_t count{0}; - while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); +result generic_validate_ascii_with_errors(const uint8_t* input, size_t length) +{ + buf_block_reader<64> reader(input, length); + size_t count { 0 }; + while (reader.has_full_block()) { + simd::simd8x64 in(reader.full_block()); + if (!in.is_ascii()) { + result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); + return result(res.error, count + res.count); + } + reader.advance(); + + count += 64; + } + uint8_t block[64] {}; + reader.get_remainder(block); + simd::simd8x64 in(block); if (!in.is_ascii()) { - result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); - return result(res.error, count + res.count); + result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); + return result(res.error, count + res.count); + } else { + return result(error_code::SUCCESS, length); } - reader.advance(); - - count += 64; - } - uint8_t block[64]{}; - reader.get_remainder(block); - simd::simd8x64 in(block); - if (!in.is_ascii()) { - result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); - return result(res.error, count + res.count); - } else { - return result(error_code::SUCCESS, length); - } } -result generic_validate_ascii_with_errors(const char * input, size_t length) { - return generic_validate_ascii_with_errors(reinterpret_cast(input),length); +result generic_validate_ascii_with_errors(const char* input, size_t length) +{ + return generic_validate_ascii_with_errors(reinterpret_cast(input), length); } } // namespace utf8_validation @@ -14170,10 +16450,9 @@ result generic_validate_ascii_with_errors(const char * input, size_t length) { } // namespace simdutf /* end file src/generic/utf8_validation/utf8_validator.h */ // transcoding from UTF-8 to UTF-16 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf16/valid_utf8_to_utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf16/valid_utf8_to_utf16.h /* begin file src/generic/utf8_to_utf16/valid_utf8_to_utf16.h */ - namespace simdutf { namespace arm64 { namespace { @@ -14181,63 +16460,64 @@ namespace utf8_to_utf16 { using namespace simd; -template +template simdutf_warn_unused size_t convert_valid(const char* input, size_t size, - char16_t* utf16_output) noexcept { - // The implementation is not specific to haswell and should be moved to the generic directory. - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - // this loop could be unrolled further. For example, we could process the mask - // far more than 64 bytes. - simd8x64 in(reinterpret_cast(input + pos)); - if(in.is_ascii()) { - in.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // Slow path. We hope that the compiler will recognize that this is a slow path. - // Anything that is not a continuation mask is a 'leading byte', that is, the - // start of a new code point. - uint64_t utf8_continuation_mask = in.lt(-65 + 1); - // -65 is 0b10111111 in two-complement's, so largest possible continuation byte - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - // The *start* of code points is not so useful, rather, we want the *end* of code points. - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times when using solely - // the slow/regular path, and at least four times if there are fast paths. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - // - // Thus we may allow convert_masked_utf8_to_utf16 to process - // more bytes at a time under a fast-path mode where 16 bytes - // are consumed at once (e.g., when encountering ASCII). - size_t consumed = convert_masked_utf8_to_utf16(input + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - utf16_output += scalar::utf8_to_utf16::convert_valid(input + pos, size - pos, utf16_output); - return utf16_output - start; + char16_t* utf16_output) noexcept +{ + // The implementation is not specific to haswell and should be moved to the generic directory. + size_t pos = 0; + char16_t* start { utf16_output }; + const size_t safety_margin = 16; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + // this loop could be unrolled further. For example, we could process the mask + // far more than 64 bytes. + simd8x64 in(reinterpret_cast(input + pos)); + if (in.is_ascii()) { + in.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // Slow path. We hope that the compiler will recognize that this is a slow path. + // Anything that is not a continuation mask is a 'leading byte', that is, the + // start of a new code point. + uint64_t utf8_continuation_mask = in.lt(-65 + 1); + // -65 is 0b10111111 in two-complement's, so largest possible continuation byte + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + // The *start* of code points is not so useful, rather, we want the *end* of code points. + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times when using solely + // the slow/regular path, and at least four times if there are fast paths. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + // + // Thus we may allow convert_masked_utf8_to_utf16 to process + // more bytes at a time under a fast-path mode where 16 bytes + // are consumed at once (e.g., when encountering ASCII). + size_t consumed = convert_masked_utf8_to_utf16(input + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + utf16_output += scalar::utf8_to_utf16::convert_valid(input + pos, size - pos, utf16_output); + return utf16_output - start; } } // namespace utf8_to_utf16 @@ -14245,32 +16525,31 @@ simdutf_warn_unused size_t convert_valid(const char* input, size_t size, } // namespace arm64 } // namespace simdutf /* end file src/generic/utf8_to_utf16/valid_utf8_to_utf16.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf16/utf8_to_utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf16/utf8_to_utf16.h /* begin file src/generic/utf8_to_utf16/utf8_to_utf16.h */ - namespace simdutf { namespace arm64 { namespace { namespace utf8_to_utf16 { using namespace simd; - - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -14278,258 +16557,281 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } - +} - struct validating_transcoder { +struct validating_transcoder { // If this is nonzero, there has been a UTF-8 error. simd8 error; - validating_transcoder() : error(uint8_t(0)) {} + validating_transcoder() + : error(uint8_t(0)) + { + } // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); - } - - - template - simdutf_really_inline size_t convert(const char* in, size_t size, char16_t* utf16_output) { - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf16(in + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { return 0; } - if(pos < size) { - size_t howmany = scalar::utf8_to_utf16::convert(in + pos, size - pos, utf16_output); - if(howmany == 0) { return 0; } - utf16_output += howmany; - } - return utf16_output - start; - } - - template - simdutf_really_inline result convert_with_errors(const char* in, size_t size, char16_t* utf16_output) { - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - if (errors()) { + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); + } + + template + simdutf_really_inline size_t convert(const char* in, size_t size, char16_t* utf16_output) + { + size_t pos = 0; + char16_t* start { utf16_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 8 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 8; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the eight last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf16(in + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { + return 0; + } + if (pos < size) { + size_t howmany = scalar::utf8_to_utf16::convert(in + pos, size - pos, utf16_output); + if (howmany == 0) { + return 0; + } + utf16_output += howmany; + } + return utf16_output - start; + } + + template + simdutf_really_inline result convert_with_errors(const char* in, size_t size, char16_t* utf16_output) + { + size_t pos = 0; + char16_t* start { utf16_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 8 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 8; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the eight last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + if (errors()) { + // rewind_and_convert_with_errors will seek a potential error from in+pos onward, + // with the ability to go back up to pos bytes, and read size-pos bytes forward. + result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); + res.count += pos; + return res; + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf16(in + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { // rewind_and_convert_with_errors will seek a potential error from in+pos onward, // with the ability to go back up to pos bytes, and read size-pos bytes forward. result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); res.count += pos; return res; - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf16(in + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { - // rewind_and_convert_with_errors will seek a potential error from in+pos onward, - // with the ability to go back up to pos bytes, and read size-pos bytes forward. - result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); - res.count += pos; - return res; - } - if(pos < size) { - // rewind_and_convert_with_errors will seek a potential error from in+pos onward, - // with the ability to go back up to pos bytes, and read size-pos bytes forward. - result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); - if (res.error) { // In case of error, we want the error position - res.count += pos; - return res; - } else { // In case of success, we want the number of word written - utf16_output += res.count; } - } - return result(error_code::SUCCESS, utf16_output - start); + if (pos < size) { + // rewind_and_convert_with_errors will seek a potential error from in+pos onward, + // with the ability to go back up to pos bytes, and read size-pos bytes forward. + result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); + if (res.error) { // In case of error, we want the error position + res.count += pos; + return res; + } else { // In case of success, we want the number of word written + utf16_output += res.count; + } + } + return result(error_code::SUCCESS, utf16_output - start); } - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // utf8_to_utf16 namespace } // unnamed namespace } // namespace arm64 } // namespace simdutf /* end file src/generic/utf8_to_utf16/utf8_to_utf16.h */ // transcoding from UTF-8 to UTF-32 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf32/valid_utf8_to_utf32.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf32/valid_utf8_to_utf32.h /* begin file src/generic/utf8_to_utf32/valid_utf8_to_utf32.h */ namespace simdutf { @@ -14539,68 +16841,66 @@ namespace utf8_to_utf32 { using namespace simd; - simdutf_warn_unused size_t convert_valid(const char* input, size_t size, - char32_t* utf32_output) noexcept { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 in(reinterpret_cast(input + pos)); - if(in.is_ascii()) { - in.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // -65 is 0b10111111 in two-complement's, so largest possible continuation byte - uint64_t utf8_continuation_mask = in.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - size_t max_starting_point = (pos + 64) - 12; - while(pos < max_starting_point) { - size_t consumed = convert_masked_utf8_to_utf32(input + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } + char32_t* utf32_output) noexcept +{ + size_t pos = 0; + char32_t* start { utf32_output }; + const size_t safety_margin = 16; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 in(reinterpret_cast(input + pos)); + if (in.is_ascii()) { + in.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // -65 is 0b10111111 in two-complement's, so largest possible continuation byte + uint64_t utf8_continuation_mask = in.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + size_t max_starting_point = (pos + 64) - 12; + while (pos < max_starting_point) { + size_t consumed = convert_masked_utf8_to_utf32(input + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + } } - } - utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos, utf32_output); - return utf32_output - start; + utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos, utf32_output); + return utf32_output - start; } - } // namespace utf8_to_utf32 } // unnamed namespace } // namespace arm64 } // namespace simdutf /* end file src/generic/utf8_to_utf32/valid_utf8_to_utf32.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf32/utf8_to_utf32.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf32/utf8_to_utf32.h /* begin file src/generic/utf8_to_utf32/utf8_to_utf32.h */ - namespace simdutf { namespace arm64 { namespace { namespace utf8_to_utf32 { using namespace simd; - - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -14608,251 +16908,273 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } - +} - struct validating_transcoder { +struct validating_transcoder { // If this is nonzero, there has been a UTF-8 error. simd8 error; - validating_transcoder() : error(uint8_t(0)) {} - // - // Check whether the current bytes are valid UTF-8. - // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); - } - - - - simdutf_really_inline size_t convert(const char* in, size_t size, char32_t* utf32_output) { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf32(in + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { return 0; } - if(pos < size) { - size_t howmany = scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output); - if(howmany == 0) { return 0; } - utf32_output += howmany; - } - return utf32_output - start; - } - - simdutf_really_inline result convert_with_errors(const char* in, size_t size, char32_t* utf32_output) { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - if (errors()) { + validating_transcoder() + : error(uint8_t(0)) + { + } + // + // Check whether the current bytes are valid UTF-8. + // + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); + } + + simdutf_really_inline size_t convert(const char* in, size_t size, char32_t* utf32_output) + { + size_t pos = 0; + char32_t* start { utf32_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 4 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 4; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the fourth last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf32(in + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { + return 0; + } + if (pos < size) { + size_t howmany = scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output); + if (howmany == 0) { + return 0; + } + utf32_output += howmany; + } + return utf32_output - start; + } + + simdutf_really_inline result convert_with_errors(const char* in, size_t size, char32_t* utf32_output) + { + size_t pos = 0; + char32_t* start { utf32_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 4 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 4; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the fourth last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + if (errors()) { + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); + res.count += pos; + return res; + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf32(in + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); res.count += pos; return res; - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf32(in + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); - res.count += pos; - return res; - } - if(pos < size) { - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); - if (res.error) { // In case of error, we want the error position - res.count += pos; - return res; - } else { // In case of success, we want the number of word written - utf32_output += res.count; } - } - return result(error_code::SUCCESS, utf32_output - start); + if (pos < size) { + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); + if (res.error) { // In case of error, we want the error position + res.count += pos; + return res; + } else { // In case of success, we want the number of word written + utf32_output += res.count; + } + } + return result(error_code::SUCCESS, utf32_output - start); } - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // utf8_to_utf32 namespace } // unnamed namespace } // namespace arm64 } // namespace simdutf /* end file src/generic/utf8_to_utf32/utf8_to_utf32.h */ // other functions -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8.h /* begin file src/generic/utf8.h */ namespace simdutf { @@ -14862,36 +17184,37 @@ namespace utf8 { using namespace simd; -simdutf_really_inline size_t count_code_points(const char* in, size_t size) { +simdutf_really_inline size_t count_code_points(const char* in, size_t size) +{ size_t pos = 0; size_t count = 0; - for(;pos + 64 <= size; pos += 64) { - simd8x64 input(reinterpret_cast(in + pos)); - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - count += 64 - count_ones(utf8_continuation_mask); + for (; pos + 64 <= size; pos += 64) { + simd8x64 input(reinterpret_cast(in + pos)); + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + count += 64 - count_ones(utf8_continuation_mask); } return count + scalar::utf8::count_code_points(in + pos, size - pos); } - -simdutf_really_inline size_t utf16_length_from_utf8(const char* in, size_t size) { +simdutf_really_inline size_t utf16_length_from_utf8(const char* in, size_t size) +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 64 <= size; pos += 64) { - simd8x64 input(reinterpret_cast(in + pos)); - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - // We count one word for anything that is not a continuation (so - // leading bytes). - count += 64 - count_ones(utf8_continuation_mask); - int64_t utf8_4byte = input.gteq_unsigned(240); - count += count_ones(utf8_4byte); + for (; pos + 64 <= size; pos += 64) { + simd8x64 input(reinterpret_cast(in + pos)); + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + // We count one word for anything that is not a continuation (so + // leading bytes). + count += 64 - count_ones(utf8_continuation_mask); + int64_t utf8_4byte = input.gteq_unsigned(240); + count += count_ones(utf8_4byte); } return count + scalar::utf8::utf16_length_from_utf8(in + pos, size - pos); } - -simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) { +simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) +{ return count_code_points(in, size); } } // utf8 namespace @@ -14899,64 +17222,72 @@ simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) } // namespace arm64 } // namespace simdutf /* end file src/generic/utf8.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf16.h /* begin file src/generic/utf16.h */ namespace simdutf { namespace arm64 { namespace { namespace utf16 { -template -simdutf_really_inline size_t count_code_points(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t count_code_points(const char16_t* in, size_t size) +{ size_t pos = 0; size_t count = 0; - for(;pos + 32 <= size; pos += 32) { - simd16x32 input(reinterpret_cast(in + pos)); - if (!match_system(big_endian)) input.swap_bytes(); - uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF); - count += count_ones(not_pair) / 2; + for (; pos + 32 <= size; pos += 32) { + simd16x32 input(reinterpret_cast(in + pos)); + if (!match_system(big_endian)) { + input.swap_bytes(); + } + uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF); + count += count_ones(not_pair) / 2; } return count + scalar::utf16::count_code_points(in + pos, size - pos); } -template -simdutf_really_inline size_t utf8_length_from_utf16(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t utf8_length_from_utf16(const char16_t* in, size_t size) +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 32 <= size; pos += 32) { - simd16x32 input(reinterpret_cast(in + pos)); - if (!match_system(big_endian)) input.swap_bytes(); - uint64_t ascii_mask = input.lteq(0x7F); - uint64_t twobyte_mask = input.lteq(0x7FF); - uint64_t not_pair_mask = input.not_in_range(0xD800, 0xDFFF); - - size_t ascii_count = count_ones(ascii_mask) / 2; - size_t twobyte_count = count_ones(twobyte_mask & ~ ascii_mask) / 2; - size_t threebyte_count = count_ones(not_pair_mask & ~ twobyte_mask) / 2; - size_t fourbyte_count = 32 - count_ones(not_pair_mask) / 2; - count += 2 * fourbyte_count + 3 * threebyte_count + 2 * twobyte_count + ascii_count; + for (; pos + 32 <= size; pos += 32) { + simd16x32 input(reinterpret_cast(in + pos)); + if (!match_system(big_endian)) { + input.swap_bytes(); + } + uint64_t ascii_mask = input.lteq(0x7F); + uint64_t twobyte_mask = input.lteq(0x7FF); + uint64_t not_pair_mask = input.not_in_range(0xD800, 0xDFFF); + + size_t ascii_count = count_ones(ascii_mask) / 2; + size_t twobyte_count = count_ones(twobyte_mask & ~ascii_mask) / 2; + size_t threebyte_count = count_ones(not_pair_mask & ~twobyte_mask) / 2; + size_t fourbyte_count = 32 - count_ones(not_pair_mask) / 2; + count += 2 * fourbyte_count + 3 * threebyte_count + 2 * twobyte_count + ascii_count; } return count + scalar::utf16::utf8_length_from_utf16(in + pos, size - pos); } -template -simdutf_really_inline size_t utf32_length_from_utf16(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t utf32_length_from_utf16(const char16_t* in, size_t size) +{ return count_code_points(in, size); } -simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* output) { - size_t pos = 0; +simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* output) +{ + size_t pos = 0; - while (pos + 32 <= size) { - simd16x32 input(reinterpret_cast(in + pos)); - input.swap_bytes(); - input.store(reinterpret_cast(output)); - pos += 32; - output += 32; - } + while (pos + 32 <= size) { + simd16x32 input(reinterpret_cast(in + pos)); + input.swap_bytes(); + input.store(reinterpret_cast(output)); + pos += 32; + output += 32; + } - scalar::utf16::change_endianness_utf16(in + pos, size - pos, output); + scalar::utf16::change_endianness_utf16(in + pos, size - pos, output); } } // utf16 @@ -14964,739 +17295,1106 @@ simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t si } // namespace arm64 } // namespace simdutf /* end file src/generic/utf16.h */ + +// placeholder scalars + // // Implementation-specific overrides // namespace simdutf { namespace arm64 { -simdutf_warn_unused int implementation::detect_encodings(const char * input, size_t length) const noexcept { - // If there is a BOM, then we trust it. - auto bom_encoding = simdutf::BOM::check_bom(input, length); - if(bom_encoding != encoding_type::unspecified) { return bom_encoding; } - if (length % 2 == 0) { - return arm_detect_encodings(input, length); - } else { - if (implementation::validate_utf8(input, length)) { - return simdutf::encoding_type::UTF8; +simdutf_warn_unused int implementation::detect_encodings(const char* input, size_t length) const noexcept +{ + // If there is a BOM, then we trust it. + auto bom_encoding = simdutf::BOM::check_bom(input, length); + if (bom_encoding != encoding_type::unspecified) { + return bom_encoding; + } + if (length % 2 == 0) { + return arm_detect_encodings(input, length); } else { - return simdutf::encoding_type::unspecified; + if (implementation::validate_utf8(input, length)) { + return simdutf::encoding_type::UTF8; + } else { + return simdutf::encoding_type::unspecified; + } } - } } -simdutf_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { - return arm64::utf8_validation::generic_validate_utf8(buf,len); +simdutf_warn_unused bool implementation::validate_utf8(const char* buf, size_t len) const noexcept +{ + return arm64::utf8_validation::generic_validate_utf8(buf, len); } -simdutf_warn_unused result implementation::validate_utf8_with_errors(const char *buf, size_t len) const noexcept { - return arm64::utf8_validation::generic_validate_utf8_with_errors(buf,len); +simdutf_warn_unused result implementation::validate_utf8_with_errors(const char* buf, size_t len) const noexcept +{ + return arm64::utf8_validation::generic_validate_utf8_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_ascii(const char *buf, size_t len) const noexcept { - return arm64::utf8_validation::generic_validate_ascii(buf,len); +simdutf_warn_unused bool implementation::validate_ascii(const char* buf, size_t len) const noexcept +{ + return arm64::utf8_validation::generic_validate_ascii(buf, len); } -simdutf_warn_unused result implementation::validate_ascii_with_errors(const char *buf, size_t len) const noexcept { - return arm64::utf8_validation::generic_validate_ascii_with_errors(buf,len); +simdutf_warn_unused result implementation::validate_ascii_with_errors(const char* buf, size_t len) const noexcept +{ + return arm64::utf8_validation::generic_validate_ascii_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_utf16le(const char16_t *buf, size_t len) const noexcept { - const char16_t* tail = arm_validate_utf16(buf, len); - if (tail) { - return scalar::utf16::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf16le(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* tail = arm_validate_utf16(buf, len); + if (tail) { + return scalar::utf16::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused bool implementation::validate_utf16be(const char16_t *buf, size_t len) const noexcept { - const char16_t* tail = arm_validate_utf16(buf, len); - if (tail) { - return scalar::utf16::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf16be(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* tail = arm_validate_utf16(buf, len); + if (tail) { + return scalar::utf16::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept { - result res = arm_validate_utf16_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept +{ + result res = arm_validate_utf16_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } } -simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept { - result res = arm_validate_utf16_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept +{ + result res = arm_validate_utf16_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } } -simdutf_warn_unused bool implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept { - const char32_t* tail = arm_validate_utf32le(buf, len); - if (tail) { - return scalar::utf32::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf32(const char32_t* buf, size_t len) const noexcept +{ + const char32_t* tail = arm_validate_utf32le(buf, len); + if (tail) { + return scalar::utf32::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept { - result res = arm_validate_utf32le_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf32::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept +{ + result res = arm_validate_utf32le_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf32::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::latin1_to_utf8::convert(buf, len, utf8_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf32(const char* buf, size_t len, char32_t* latin1_output) const noexcept +{ + return scalar::latin1_to_utf32::convert(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_valid(buf, len, latin1_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf16_output); } simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* input, size_t size, - char16_t* utf16_output) const noexcept { - return utf8_to_utf16::convert_valid(input, size, utf16_output); + char16_t* utf16_output) const noexcept +{ + return utf8_to_utf16::convert_valid(input, size, utf16_output); } simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* input, size_t size, - char16_t* utf16_output) const noexcept { - return utf8_to_utf16::convert_valid(input, size, utf16_output); + char16_t* utf16_output) const noexcept +{ + return utf8_to_utf16::convert_valid(input, size, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept { - utf8_to_utf32::validating_transcoder converter; - return converter.convert(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + utf8_to_utf32::validating_transcoder converter; + return converter.convert(buf, len, utf32_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept { - utf8_to_utf32::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf32_output); +simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + utf8_to_utf32::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf32_output); } simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* input, size_t size, - char32_t* utf32_output) const noexcept { - return utf8_to_utf32::convert_valid(input, size, utf32_output); -} - -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = arm_convert_utf16_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = arm_convert_utf16_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = arm_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = arm_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; + char32_t* utf32_output) const noexcept +{ + return utf8_to_utf32::convert_valid(input, size, utf32_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = arm_convert_utf16_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = arm_convert_utf16_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; + return saved_bytes; } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf16le_to_utf8(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = arm_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = arm_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf16be_to_utf8(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf16le_to_utf8(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = arm_convert_utf32_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf16be_to_utf8(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = arm_convert_utf32_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::pair ret = arm_convert_utf16_to_utf32(buf, len, utf32_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf32_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::pair ret = arm_convert_utf16_to_utf32(buf, len, utf32_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf32_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = arm_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = arm_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf32_to_utf8(buf, len, utf8_output); -} - -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - std::pair ret = arm_convert_utf32_to_utf16(buf, len, utf16_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf16_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - std::pair ret = arm_convert_utf32_to_utf16(buf, len, utf16_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf16_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = arm_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf16::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = arm_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf16::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; +simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = arm_convert_utf32_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = arm_convert_utf32_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::pair ret = arm_convert_utf16_to_utf32(buf, len, utf32_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf32_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::pair ret = arm_convert_utf16_to_utf32(buf, len, utf32_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf32_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = arm_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = arm_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf32_to_utf8(buf, len, utf8_output); +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + std::pair ret = arm_convert_utf32_to_utf16(buf, len, utf16_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf16_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + std::pair ret = arm_convert_utf32_to_utf16(buf, len, utf16_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf16_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = arm_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf16::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = arm_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf16::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } } - } - ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written - return ret.first; + ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return convert_utf32_to_utf16le(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return convert_utf32_to_utf16le(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return convert_utf32_to_utf16be(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return convert_utf32_to_utf16be(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return convert_utf16le_to_utf32(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return convert_utf16le_to_utf32(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return convert_utf16be_to_utf32(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return convert_utf16be_to_utf32(buf, len, utf32_output); +void implementation::change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) const noexcept +{ + utf16::change_endianness_utf16(input, length, output); } -void implementation::change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) const noexcept { - utf16::change_endianness_utf16(input, length, output); +simdutf_warn_unused size_t implementation::count_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::count_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::count_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::count_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::count_utf8(const char* input, size_t length) const noexcept +{ + return utf8::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::count_utf8(const char * input, size_t length) const noexcept { - return utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf8(const char* buf, size_t len) const noexcept +{ + return scalar::utf8::latin1_length_from_utf8(buf, len); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf16(size_t length) const noexcept +{ + return scalar::utf16::latin1_length_from_utf16(length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf32(size_t length) const noexcept +{ + return scalar::utf32::latin1_length_from_utf32(length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_latin1(const char* input, size_t length) const noexcept +{ + return scalar::latin1::utf8_length_from_latin1(input, length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char * input, size_t length) const noexcept { - return utf8::utf16_length_from_utf8(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept { - const uint32x4_t v_7f = vmovq_n_u32((uint32_t)0x7f); - const uint32x4_t v_7ff = vmovq_n_u32((uint32_t)0x7ff); - const uint32x4_t v_ffff = vmovq_n_u32((uint32_t)0xffff); - const uint32x4_t v_1 = vmovq_n_u32((uint32_t)0x1); - size_t pos = 0; - size_t count = 0; - for(;pos + 4 <= length; pos += 4) { - uint32x4_t in = vld1q_u32(reinterpret_cast(input + pos)); - const uint32x4_t ascii_bytes_bytemask = vcleq_u32(in, v_7f); - const uint32x4_t one_two_bytes_bytemask = vcleq_u32(in, v_7ff); - const uint32x4_t two_bytes_bytemask = veorq_u32(one_two_bytes_bytemask, ascii_bytes_bytemask); - const uint32x4_t three_bytes_bytemask = veorq_u32(vcleq_u32(in, v_ffff), one_two_bytes_bytemask); +simdutf_warn_unused size_t implementation::utf16_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf16_length_from_latin1(length); +} + +simdutf_warn_unused size_t implementation::utf32_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf32_length_from_latin1(length); +} + +simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf32_length_from_utf16(input, length); +} + +simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf32_length_from_utf16(input, length); +} + +simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char* input, size_t length) const noexcept +{ + return utf8::utf16_length_from_utf8(input, length); +} + +simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + const uint32x4_t v_7f = vmovq_n_u32((uint32_t)0x7f); + const uint32x4_t v_7ff = vmovq_n_u32((uint32_t)0x7ff); + const uint32x4_t v_ffff = vmovq_n_u32((uint32_t)0xffff); + const uint32x4_t v_1 = vmovq_n_u32((uint32_t)0x1); + size_t pos = 0; + size_t count = 0; + for (; pos + 4 <= length; pos += 4) { + uint32x4_t in = vld1q_u32(reinterpret_cast(input + pos)); + const uint32x4_t ascii_bytes_bytemask = vcleq_u32(in, v_7f); + const uint32x4_t one_two_bytes_bytemask = vcleq_u32(in, v_7ff); + const uint32x4_t two_bytes_bytemask = veorq_u32(one_two_bytes_bytemask, ascii_bytes_bytemask); + const uint32x4_t three_bytes_bytemask = veorq_u32(vcleq_u32(in, v_ffff), one_two_bytes_bytemask); - const uint16x8_t reduced_ascii_bytes_bytemask = vreinterpretq_u16_u32(vandq_u32(ascii_bytes_bytemask, v_1)); - const uint16x8_t reduced_two_bytes_bytemask = vreinterpretq_u16_u32(vandq_u32(two_bytes_bytemask, v_1)); - const uint16x8_t reduced_three_bytes_bytemask = vreinterpretq_u16_u32(vandq_u32(three_bytes_bytemask, v_1)); + const uint16x8_t reduced_ascii_bytes_bytemask = vreinterpretq_u16_u32(vandq_u32(ascii_bytes_bytemask, v_1)); + const uint16x8_t reduced_two_bytes_bytemask = vreinterpretq_u16_u32(vandq_u32(two_bytes_bytemask, v_1)); + const uint16x8_t reduced_three_bytes_bytemask = vreinterpretq_u16_u32(vandq_u32(three_bytes_bytemask, v_1)); - const uint16x8_t compressed_bytemask0 = vpaddq_u16(reduced_ascii_bytes_bytemask, reduced_two_bytes_bytemask); - const uint16x8_t compressed_bytemask1 = vpaddq_u16(reduced_three_bytes_bytemask, reduced_three_bytes_bytemask); + const uint16x8_t compressed_bytemask0 = vpaddq_u16(reduced_ascii_bytes_bytemask, reduced_two_bytes_bytemask); + const uint16x8_t compressed_bytemask1 = vpaddq_u16(reduced_three_bytes_bytemask, reduced_three_bytes_bytemask); - size_t ascii_count = count_ones(vgetq_lane_u64(vreinterpretq_u64_u16(compressed_bytemask0), 0)); - size_t two_bytes_count = count_ones(vgetq_lane_u64(vreinterpretq_u64_u16(compressed_bytemask0), 1)); - size_t three_bytes_count = count_ones(vgetq_lane_u64(vreinterpretq_u64_u16(compressed_bytemask1), 0)); + size_t ascii_count = count_ones(vgetq_lane_u64(vreinterpretq_u64_u16(compressed_bytemask0), 0)); + size_t two_bytes_count = count_ones(vgetq_lane_u64(vreinterpretq_u64_u16(compressed_bytemask0), 1)); + size_t three_bytes_count = count_ones(vgetq_lane_u64(vreinterpretq_u64_u16(compressed_bytemask1), 0)); - count += 16 - 3*ascii_count - 2*two_bytes_count - three_bytes_count; - } - return count + scalar::utf32::utf8_length_from_utf32(input + pos, length - pos); + count += 16 - 3 * ascii_count - 2 * two_bytes_count - three_bytes_count; + } + return count + scalar::utf32::utf8_length_from_utf32(input + pos, length - pos); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept { - const uint32x4_t v_ffff = vmovq_n_u32((uint32_t)0xffff); - const uint32x4_t v_1 = vmovq_n_u32((uint32_t)0x1); - size_t pos = 0; - size_t count = 0; - for(;pos + 4 <= length; pos += 4) { - uint32x4_t in = vld1q_u32(reinterpret_cast(input + pos)); - const uint32x4_t surrogate_bytemask = vcgtq_u32(in, v_ffff); - const uint16x8_t reduced_bytemask = vreinterpretq_u16_u32(vandq_u32(surrogate_bytemask, v_1)); - const uint16x8_t compressed_bytemask = vpaddq_u16(reduced_bytemask, reduced_bytemask); - size_t surrogate_count = count_ones(vgetq_lane_u64(vreinterpretq_u64_u16(compressed_bytemask), 0)); - count += 4 + surrogate_count; - } - return count + scalar::utf32::utf16_length_from_utf32(input + pos, length - pos); +simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + const uint32x4_t v_ffff = vmovq_n_u32((uint32_t)0xffff); + const uint32x4_t v_1 = vmovq_n_u32((uint32_t)0x1); + size_t pos = 0; + size_t count = 0; + for (; pos + 4 <= length; pos += 4) { + uint32x4_t in = vld1q_u32(reinterpret_cast(input + pos)); + const uint32x4_t surrogate_bytemask = vcgtq_u32(in, v_ffff); + const uint16x8_t reduced_bytemask = vreinterpretq_u16_u32(vandq_u32(surrogate_bytemask, v_1)); + const uint16x8_t compressed_bytemask = vpaddq_u16(reduced_bytemask, reduced_bytemask); + size_t surrogate_count = count_ones(vgetq_lane_u64(vreinterpretq_u64_u16(compressed_bytemask), 0)); + count += 4 + surrogate_count; + } + return count + scalar::utf32::utf16_length_from_utf32(input + pos, length - pos); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char * input, size_t length) const noexcept { - return utf8::utf32_length_from_utf8(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char* input, size_t length) const noexcept +{ + return utf8::utf32_length_from_utf8(input, length); } } // namespace arm64 } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/arm64/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/arm64/end.h /* begin file src/simdutf/arm64/end.h */ /* end file src/simdutf/arm64/end.h */ /* end file src/arm64/implementation.cpp */ #endif #if SIMDUTF_IMPLEMENTATION_FALLBACK -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=fallback/implementation.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=fallback/implementation.cpp /* begin file src/fallback/implementation.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/fallback/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/fallback/begin.h /* begin file src/simdutf/fallback/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "fallback" // #define SIMDUTF_IMPLEMENTATION fallback /* end file src/simdutf/fallback/begin.h */ - - - - - - - namespace simdutf { namespace fallback { -simdutf_warn_unused int implementation::detect_encodings(const char * input, size_t length) const noexcept { - // If there is a BOM, then we trust it. - auto bom_encoding = simdutf::BOM::check_bom(input, length); - if(bom_encoding != encoding_type::unspecified) { return bom_encoding; } - int out = 0; - if(validate_utf8(input, length)) { out |= encoding_type::UTF8; } - if((length % 2) == 0) { - if(validate_utf16le(reinterpret_cast(input), length/2)) { out |= encoding_type::UTF16_LE; } - } - if((length % 4) == 0) { - if(validate_utf32(reinterpret_cast(input), length/4)) { out |= encoding_type::UTF32_LE; } - } +simdutf_warn_unused int implementation::detect_encodings(const char* input, size_t length) const noexcept +{ + // If there is a BOM, then we trust it. + auto bom_encoding = simdutf::BOM::check_bom(input, length); + if (bom_encoding != encoding_type::unspecified) { + return bom_encoding; + } + int out = 0; + if (validate_utf8(input, length)) { + out |= encoding_type::UTF8; + } + if ((length % 2) == 0) { + if (validate_utf16le(reinterpret_cast(input), length / 2)) { + out |= encoding_type::UTF16_LE; + } + } + if ((length % 4) == 0) { + if (validate_utf32(reinterpret_cast(input), length / 4)) { + out |= encoding_type::UTF32_LE; + } + } - return out; + return out; } -simdutf_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { +simdutf_warn_unused bool implementation::validate_utf8(const char* buf, size_t len) const noexcept +{ return scalar::utf8::validate(buf, len); } -simdutf_warn_unused result implementation::validate_utf8_with_errors(const char *buf, size_t len) const noexcept { +simdutf_warn_unused result implementation::validate_utf8_with_errors(const char* buf, size_t len) const noexcept +{ return scalar::utf8::validate_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_ascii(const char *buf, size_t len) const noexcept { +simdutf_warn_unused bool implementation::validate_ascii(const char* buf, size_t len) const noexcept +{ return scalar::ascii::validate(buf, len); } -simdutf_warn_unused result implementation::validate_ascii_with_errors(const char *buf, size_t len) const noexcept { +simdutf_warn_unused result implementation::validate_ascii_with_errors(const char* buf, size_t len) const noexcept +{ return scalar::ascii::validate_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_utf16le(const char16_t *buf, size_t len) const noexcept { +simdutf_warn_unused bool implementation::validate_utf16le(const char16_t* buf, size_t len) const noexcept +{ return scalar::utf16::validate(buf, len); } -simdutf_warn_unused bool implementation::validate_utf16be(const char16_t *buf, size_t len) const noexcept { +simdutf_warn_unused bool implementation::validate_utf16be(const char16_t* buf, size_t len) const noexcept +{ return scalar::utf16::validate(buf, len); } -simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept { +simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept +{ return scalar::utf16::validate_with_errors(buf, len); } -simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept { +simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept +{ return scalar::utf16::validate_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept { - return scalar::utf32::validate(buf, len); +simdutf_warn_unused bool implementation::validate_utf32(const char32_t* buf, size_t len) const noexcept +{ + return scalar::utf32::validate(buf, len); +} + +simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept +{ + return scalar::utf32::validate_with_errors(buf, len); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::latin1_to_utf8::convert(buf, len, utf8_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::latin1_to_utf32::convert(buf, len, utf32_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf8_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf8_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf8_to_utf16::convert_with_errors(buf, len, utf16_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf8_to_utf16::convert_with_errors(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf8_to_utf16::convert_valid(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf8_to_utf16::convert_valid(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf8_to_utf32::convert(buf, len, utf32_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf8_to_utf32::convert_with_errors(buf, len, utf32_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* input, size_t size, + char32_t* utf32_output) const noexcept +{ + return scalar::utf8_to_utf32::convert_valid(input, size, utf32_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); } -simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept { - return scalar::utf32::validate_with_errors(buf, len); +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf8_to_utf16::convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf8_to_utf16::convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf8_to_utf16::convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert_with_errors(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf8_to_utf16::convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert_with_errors(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf8_to_utf16::convert_valid(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert_valid(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf8_to_utf16::convert_valid(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert_valid(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf8_to_utf32::convert(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert(buf, len, latin1_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf8_to_utf32::convert_with_errors(buf, len, utf32_output); +simdutf_warn_unused result implementation::convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_with_errors(buf, len, latin1_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* input, size_t size, - char32_t* utf32_output) const noexcept { - return scalar::utf8_to_utf32::convert_valid(input, size, utf32_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_valid(buf, len, latin1_output); } -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf32_to_utf8::convert(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf32_to_utf8::convert_with_errors(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert_with_errors(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf32_to_utf8::convert_valid(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert_with_errors(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert_valid(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert_valid(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert_with_errors(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf32_to_utf8::convert(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert_with_errors(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf32_to_utf8::convert_with_errors(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert_valid(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf32_to_utf8::convert_valid(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert_valid(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert(buf, len, utf32_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert_with_errors(buf, len, utf32_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert_with_errors(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert_valid(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert_valid(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert_valid(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert_valid(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert(buf, len, utf32_output); +void implementation::change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) const noexcept +{ + scalar::utf16::change_endianness_utf16(input, length, output); } -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::count_utf16le(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::count_code_points(input, length); } -simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert_with_errors(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::count_utf16be(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::count_code_points(input, length); } -simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert_with_errors(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::count_utf8(const char* input, size_t length) const noexcept +{ + return scalar::utf8::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert_valid(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::latin1_length_from_utf8(const char* buf, size_t len) const noexcept +{ + return scalar::utf8::latin1_length_from_utf8(buf, len); } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert_valid(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::latin1_length_from_utf16(size_t length) const noexcept +{ + return scalar::utf16::latin1_length_from_utf16(length); } -void implementation::change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) const noexcept { - scalar::utf16::change_endianness_utf16(input, length, output); +simdutf_warn_unused size_t implementation::latin1_length_from_utf32(size_t length) const noexcept +{ + return length; } -simdutf_warn_unused size_t implementation::count_utf16le(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_latin1(const char* input, size_t length) const noexcept +{ + return scalar::latin1::utf8_length_from_latin1(input, length); } -simdutf_warn_unused size_t implementation::count_utf16be(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::count_utf8(const char * input, size_t length) const noexcept { - return scalar::utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::utf32_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::utf32_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf16_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf16_length_from_latin1(length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char* input, size_t length) const noexcept +{ + return scalar::utf8::utf16_length_from_utf8(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char * input, size_t length) const noexcept { - return scalar::utf8::utf16_length_from_utf8(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + return scalar::utf32::utf8_length_from_utf32(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept { - return scalar::utf32::utf8_length_from_utf32(input, length); +simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + return scalar::utf32::utf16_length_from_utf32(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept { - return scalar::utf32::utf16_length_from_utf32(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf32_length_from_latin1(length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char * input, size_t length) const noexcept { - return scalar::utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char* input, size_t length) const noexcept +{ + return scalar::utf8::count_code_points(input, length); } } // namespace fallback } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/fallback/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/fallback/end.h /* begin file src/simdutf/fallback/end.h */ /* end file src/simdutf/fallback/end.h */ /* end file src/fallback/implementation.cpp */ #endif #if SIMDUTF_IMPLEMENTATION_ICELAKE -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/implementation.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/implementation.cpp /* begin file src/icelake/implementation.cpp */ - -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/icelake/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/icelake/begin.h /* begin file src/simdutf/icelake/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "icelake" // #define SIMDUTF_IMPLEMENTATION icelake @@ -15708,7 +18406,7 @@ SIMDUTF_TARGET_ICELAKE #endif #if SIMDUTF_GCC11ORMORE // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593 -SIMDUTF_DISABLE_GCC_WARNING(-Wmaybe-uninitialized) +SIMDUTF_DISABLE_GCC_WARNING(-Wmaybe - uninitialized) #endif // end of workaround /* end file src/simdutf/icelake/begin.h */ namespace simdutf { @@ -15717,10 +18415,11 @@ namespace { #ifndef SIMDUTF_ICELAKE_H #error "icelake.h must be included" #endif -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_utf8_common.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_utf8_common.inl.cpp /* begin file src/icelake/icelake_utf8_common.inl.cpp */ // Common procedures for both validating and non-validating conversions from UTF-8. -enum block_processing_mode { SIMDUTF_FULL, SIMDUTF_TAIL}; +enum block_processing_mode { SIMDUTF_FULL, + SIMDUTF_TAIL }; using utf8_to_utf16_result = std::pair; using utf8_to_utf32_result = std::pair; @@ -15736,302 +18435,329 @@ using utf8_to_utf32_result = std::pair; The provided in and out pointers are advanced according to how many input bytes have been processed, upon success. */ -template -simdutf_really_inline bool process_block_utf8_to_utf16(const char *&in, char16_t *&out, size_t gap) { - // constants - __m512i mask_identity = _mm512_set_epi8(63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); - __m512i mask_c0c0c0c0 = _mm512_set1_epi32(0xc0c0c0c0); - __m512i mask_80808080 = _mm512_set1_epi32(0x80808080); - __m512i mask_f0f0f0f0 = _mm512_set1_epi32(0xf0f0f0f0); - __m512i mask_dfdfdfdf_tail = _mm512_set_epi64(0xffffdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf); - __m512i mask_c2c2c2c2 = _mm512_set1_epi32(0xc2c2c2c2); - __m512i mask_ffffffff = _mm512_set1_epi32(0xffffffff); - __m512i mask_d7c0d7c0 = _mm512_set1_epi32(0xd7c0d7c0); - __m512i mask_dc00dc00 = _mm512_set1_epi32(0xdc00dc00); - __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); - // Note that 'tail' is a compile-time constant ! - __mmask64 b = (tail == SIMDUTF_FULL) ? 0xFFFFFFFFFFFFFFFF : (uint64_t(1) << gap) - 1; - __m512i input = (tail == SIMDUTF_FULL) ? _mm512_loadu_si512(in) : _mm512_maskz_loadu_epi8(b, in); - __mmask64 m1 = (tail == SIMDUTF_FULL) ? _mm512_cmplt_epu8_mask(input, mask_80808080) : _mm512_mask_cmplt_epu8_mask(b, input, mask_80808080); - if(_ktestc_mask64_u8(m1, b)) {// NOT(m1) AND b -- if all zeroes, then all ASCII - // alternatively, we could do 'if (m1 == b) { ' +template +simdutf_really_inline bool process_block_utf8_to_utf16(const char*& in, char16_t*& out, size_t gap) +{ + // constants + __m512i mask_identity = _mm512_set_epi8(63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); + __m512i mask_c0c0c0c0 = _mm512_set1_epi32(0xc0c0c0c0); + __m512i mask_80808080 = _mm512_set1_epi32(0x80808080); + __m512i mask_f0f0f0f0 = _mm512_set1_epi32(0xf0f0f0f0); + __m512i mask_dfdfdfdf_tail = _mm512_set_epi64(0xffffdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf, 0xdfdfdfdfdfdfdfdf); + __m512i mask_c2c2c2c2 = _mm512_set1_epi32(0xc2c2c2c2); + __m512i mask_ffffffff = _mm512_set1_epi32(0xffffffff); + __m512i mask_d7c0d7c0 = _mm512_set1_epi32(0xd7c0d7c0); + __m512i mask_dc00dc00 = _mm512_set1_epi32(0xdc00dc00); + __m512i byteflip = _mm512_setr_epi64( + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); + // Note that 'tail' is a compile-time constant ! + __mmask64 b = (tail == SIMDUTF_FULL) ? 0xFFFFFFFFFFFFFFFF : (uint64_t(1) << gap) - 1; + __m512i input = (tail == SIMDUTF_FULL) ? _mm512_loadu_si512(in) : _mm512_maskz_loadu_epi8(b, in); + __mmask64 m1 = (tail == SIMDUTF_FULL) ? _mm512_cmplt_epu8_mask(input, mask_80808080) : _mm512_mask_cmplt_epu8_mask(b, input, mask_80808080); + if (_ktestc_mask64_u8(m1, b)) { // NOT(m1) AND b -- if all zeroes, then all ASCII + // alternatively, we could do 'if (m1 == b) { ' + if (tail == SIMDUTF_FULL) { + in += 64; // consumed 64 bytes + // we convert a full 64-byte block, writing 128 bytes. + __m512i input1 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(input)); + if (big_endian) { + input1 = _mm512_shuffle_epi8(input1, byteflip); + } + _mm512_storeu_si512(out, input1); + out += 32; + __m512i input2 = _mm512_cvtepu8_epi16(_mm512_extracti64x4_epi64(input, 1)); + if (big_endian) { + input2 = _mm512_shuffle_epi8(input2, byteflip); + } + _mm512_storeu_si512(out, input2); + out += 32; + return true; // we are done + } else { + in += gap; + if (gap <= 32) { + __m512i input1 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(input)); + if (big_endian) { + input1 = _mm512_shuffle_epi8(input1, byteflip); + } + _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << (gap)) - 1), input1); + out += gap; + } else { + __m512i input1 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(input)); + if (big_endian) { + input1 = _mm512_shuffle_epi8(input1, byteflip); + } + _mm512_storeu_si512(out, input1); + out += 32; + __m512i input2 = _mm512_cvtepu8_epi16(_mm512_extracti64x4_epi64(input, 1)); + if (big_endian) { + input2 = _mm512_shuffle_epi8(input2, byteflip); + } + _mm512_mask_storeu_epi16(out, __mmask32((uint32_t(1) << (gap - 32)) - 1), input2); + out += gap - 32; + } + return true; // we are done + } + } + // classify characters further + __mmask64 m234 = _mm512_cmp_epu8_mask(mask_c0c0c0c0, input, + _MM_CMPINT_LE); // 0xc0 <= input, 2, 3, or 4 leading byte + __mmask64 m34 = _mm512_cmp_epu8_mask(mask_dfdfdfdf_tail, input, + _MM_CMPINT_LT); // 0xdf < input, 3 or 4 leading byte + + __mmask64 milltwobytes = _mm512_mask_cmp_epu8_mask(m234, input, mask_c2c2c2c2, + _MM_CMPINT_LT); // 0xc0 <= input < 0xc2 (illegal two byte sequence) + // Overlong 2-byte sequence + if (_ktestz_mask64_u8(milltwobytes, milltwobytes) == 0) { + // Overlong 2-byte sequence + return false; + } + if (_ktestz_mask64_u8(m34, m34) == 0) { + // We have a 3-byte sequence and/or a 2-byte sequence, or possibly even a 4-byte sequence! + __mmask64 m4 = _mm512_cmp_epu8_mask(input, mask_f0f0f0f0, + _MM_CMPINT_NLT); // 0xf0 <= zmm0 (4 byte start bytes) + + __mmask64 mask_not_ascii = (tail == SIMDUTF_FULL) ? _knot_mask64(m1) : _kand_mask64(_knot_mask64(m1), b); + + __mmask64 mp1 = _kshiftli_mask64(m234, 1); + __mmask64 mp2 = _kshiftli_mask64(m34, 2); + // We could do it as follows... + // if (_kortestz_mask64_u8(m4,m4)) { // compute the bitwise OR of the 64-bit masks a and b and return 1 if all zeroes + // but GCC generates better code when we do: + if (m4 == 0) { // compute the bitwise OR of the 64-bit masks a and b and return 1 if all zeroes + // Fast path with 1,2,3 bytes + __mmask64 mc = _kor_mask64(mp1, mp2); // expected continuation bytes + __mmask64 m1234 = _kor_mask64(m1, m234); + // mismatched continuation bytes: + if (tail == SIMDUTF_FULL) { + __mmask64 xnormcm1234 = _kxnor_mask64(mc, m1234); // XNOR of mc and m1234 should be all zero if they differ + // the presence of a 1 bit indicates that they overlap. + // _kortestz_mask64_u8: compute the bitwise OR of 64-bit masksand return 1 if all zeroes. + if (!_kortestz_mask64_u8(xnormcm1234, xnormcm1234)) { + return false; + } + } else { + __mmask64 bxorm1234 = _kxor_mask64(b, m1234); + if (mc != bxorm1234) { + return false; + } + } + // mend: identifying the last bytes of each sequence to be decoded + __mmask64 mend = _kshiftri_mask64(m1234, 1); + if (tail != SIMDUTF_FULL) { + mend = _kor_mask64(mend, (uint64_t(1) << (gap - 1))); + } + + __m512i last_and_third = _mm512_maskz_compress_epi8(mend, mask_identity); + __m512i last_and_thirdu16 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(last_and_third)); + + __m512i nonasciitags = _mm512_maskz_mov_epi8(mask_not_ascii, mask_c0c0c0c0); // ASCII: 00000000 other: 11000000 + __m512i clearedbytes = _mm512_andnot_si512(nonasciitags, input); // high two bits cleared where not ASCII + __m512i lastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, last_and_thirdu16, + clearedbytes); // the last byte of each character + + __mmask64 mask_before_non_ascii = _kshiftri_mask64(mask_not_ascii, 1); // bytes that precede non-ASCII bytes + __m512i indexofsecondlastbytes = _mm512_add_epi16(mask_ffffffff, last_and_thirdu16); // indices of the second last bytes + __m512i beforeasciibytes = _mm512_maskz_mov_epi8(mask_before_non_ascii, clearedbytes); + __m512i secondlastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, indexofsecondlastbytes, + beforeasciibytes); // the second last bytes (of two, three byte seq, + // surrogates) + secondlastbytes = _mm512_slli_epi16(secondlastbytes, 6); // shifted into position + + __m512i indexofthirdlastbytes = _mm512_add_epi16(mask_ffffffff, + indexofsecondlastbytes); // indices of the second last bytes + __m512i thirdlastbyte = _mm512_maskz_mov_epi8(m34, + clearedbytes); // only those that are the third last byte of a sequece + __m512i thirdlastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, indexofthirdlastbytes, + thirdlastbyte); // the third last bytes (of three byte sequences, hi + // surrogate) + thirdlastbytes = _mm512_slli_epi16(thirdlastbytes, 12); // shifted into position + __m512i Wout = _mm512_ternarylogic_epi32(lastbytes, secondlastbytes, thirdlastbytes, 254); + // the elements of Wout excluding the last element if it happens to be a high surrogate: + + __mmask64 mprocessed = (tail == SIMDUTF_FULL) ? _pdep_u64(0xFFFFFFFF, mend) : _pdep_u64(0xFFFFFFFF, _kand_mask64(mend, b)); // we adjust mend at the end of the output. + + // Encodings out of range... + { + // the location of 3-byte sequence start bytes in the input + __mmask64 m3 = m34 & (b ^ m4); + // words in Wout corresponding to 3-byte sequences. + __mmask32 M3 = __mmask32(_pext_u64(m3 << 2, mend)); + __m512i mask_08000800 = _mm512_set1_epi32(0x08000800); + __mmask32 Msmall800 = _mm512_mask_cmplt_epu16_mask(M3, Wout, mask_08000800); + __m512i mask_d800d800 = _mm512_set1_epi32(0xd800d800); + __m512i Moutminusd800 = _mm512_sub_epi16(Wout, mask_d800d800); + __mmask32 M3s = _mm512_mask_cmplt_epu16_mask(M3, Moutminusd800, mask_08000800); + if (_kor_mask32(Msmall800, M3s)) { + return false; + } + } + int64_t nout = _mm_popcnt_u64(mprocessed); + in += 64 - _lzcnt_u64(mprocessed); + if (big_endian) { + Wout = _mm512_shuffle_epi8(Wout, byteflip); + } + _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << nout) - 1), Wout); + out += nout; + return true; // ok + } + // + // We have a 4-byte sequence, this is the general case. + // Slow! + __mmask64 mp3 = _kshiftli_mask64(m4, 3); + __mmask64 mc = _kor_mask64(_kor_mask64(mp1, mp2), mp3); // expected continuation bytes + __mmask64 m1234 = _kor_mask64(m1, m234); + + // mend: identifying the last bytes of each sequence to be decoded + __mmask64 mend = _kor_mask64(_kshiftri_mask64(_kor_mask64(mp3, m1234), 1), mp3); + if (tail != SIMDUTF_FULL) { + mend = _kor_mask64(mend, __mmask64(uint64_t(1) << (gap - 1))); + } + __m512i last_and_third = _mm512_maskz_compress_epi8(mend, mask_identity); + __m512i last_and_thirdu16 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(last_and_third)); + + __m512i nonasciitags = _mm512_maskz_mov_epi8(mask_not_ascii, mask_c0c0c0c0); // ASCII: 00000000 other: 11000000 + __m512i clearedbytes = _mm512_andnot_si512(nonasciitags, input); // high two bits cleared where not ASCII + __m512i lastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, last_and_thirdu16, + clearedbytes); // the last byte of each character + + __mmask64 mask_before_non_ascii = _kshiftri_mask64(mask_not_ascii, 1); // bytes that precede non-ASCII bytes + __m512i indexofsecondlastbytes = _mm512_add_epi16(mask_ffffffff, last_and_thirdu16); // indices of the second last bytes + __m512i beforeasciibytes = _mm512_maskz_mov_epi8(mask_before_non_ascii, clearedbytes); + __m512i secondlastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, indexofsecondlastbytes, + beforeasciibytes); // the second last bytes (of two, three byte seq, + // surrogates) + secondlastbytes = _mm512_slli_epi16(secondlastbytes, 6); // shifted into position + + __m512i indexofthirdlastbytes = _mm512_add_epi16(mask_ffffffff, + indexofsecondlastbytes); // indices of the second last bytes + __m512i thirdlastbyte = _mm512_maskz_mov_epi8(m34, + clearedbytes); // only those that are the third last byte of a sequece + __m512i thirdlastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, indexofthirdlastbytes, + thirdlastbyte); // the third last bytes (of three byte sequences, hi + // surrogate) + thirdlastbytes = _mm512_slli_epi16(thirdlastbytes, 12); // shifted into position + __m512i thirdsecondandlastbytes = _mm512_ternarylogic_epi32(lastbytes, secondlastbytes, thirdlastbytes, 254); + uint64_t Mlo_uint64 = _pext_u64(mp3, mend); + __mmask32 Mlo = __mmask32(Mlo_uint64); + __mmask32 Mhi = __mmask32(Mlo_uint64 >> 1); + __m512i lo_surr_mask = _mm512_maskz_mov_epi16(Mlo, + mask_dc00dc00); // lo surr: 1101110000000000, other: 0000000000000000 + __m512i shifted4_thirdsecondandlastbytes = _mm512_srli_epi16(thirdsecondandlastbytes, + 4); // hi surr: 00000WVUTSRQPNML vuts = WVUTS - 1 + __m512i tagged_lo_surrogates = _mm512_or_si512(thirdsecondandlastbytes, + lo_surr_mask); // lo surr: 110111KJHGFEDCBA, other: unchanged + __m512i Wout = _mm512_mask_add_epi16(tagged_lo_surrogates, Mhi, shifted4_thirdsecondandlastbytes, + mask_d7c0d7c0); // hi sur: 110110vutsRQPNML, other: unchanged + // the elements of Wout excluding the last element if it happens to be a high surrogate: + __mmask32 Mout = ~(Mhi & 0x80000000); + __mmask64 mprocessed = (tail == SIMDUTF_FULL) ? _pdep_u64(Mout, mend) : _pdep_u64(Mout, _kand_mask64(mend, b)); // we adjust mend at the end of the output. + + // mismatched continuation bytes: + if (tail == SIMDUTF_FULL) { + __mmask64 xnormcm1234 = _kxnor_mask64(mc, m1234); // XNOR of mc and m1234 should be all zero if they differ + // the presence of a 1 bit indicates that they overlap. + // _kortestz_mask64_u8: compute the bitwise OR of 64-bit masksand return 1 if all zeroes. + if (!_kortestz_mask64_u8(xnormcm1234, xnormcm1234)) { + return false; + } + } else { + __mmask64 bxorm1234 = _kxor_mask64(b, m1234); + if (mc != bxorm1234) { + return false; + } + } + // Encodings out of range... + { + // the location of 3-byte sequence start bytes in the input + __mmask64 m3 = m34 & (b ^ m4); + // words in Wout corresponding to 3-byte sequences. + __mmask32 M3 = __mmask32(_pext_u64(m3 << 2, mend)); + __m512i mask_08000800 = _mm512_set1_epi32(0x08000800); + __mmask32 Msmall800 = _mm512_mask_cmplt_epu16_mask(M3, Wout, mask_08000800); + __m512i mask_d800d800 = _mm512_set1_epi32(0xd800d800); + __m512i Moutminusd800 = _mm512_sub_epi16(Wout, mask_d800d800); + __mmask32 M3s = _mm512_mask_cmplt_epu16_mask(M3, Moutminusd800, mask_08000800); + __m512i mask_04000400 = _mm512_set1_epi32(0x04000400); + __mmask32 M4s = _mm512_mask_cmpge_epu16_mask(Mhi, Moutminusd800, mask_04000400); + if (!_kortestz_mask32_u8(M4s, _kor_mask32(Msmall800, M3s))) { + return false; + } + } + in += 64 - _lzcnt_u64(mprocessed); + int64_t nout = _mm_popcnt_u64(mprocessed); + if (big_endian) { + Wout = _mm512_shuffle_epi8(Wout, byteflip); + } + _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << nout) - 1), Wout); + out += nout; + return true; // ok + } + // Fast path 2: all ASCII or 2 byte + __mmask64 continuation_or_ascii = (tail == SIMDUTF_FULL) ? _knot_mask64(m234) : _kand_mask64(_knot_mask64(m234), b); + // on top of -0xc0 we substract -2 which we get back later of the + // continuation byte tags + __m512i leading2byte = _mm512_maskz_sub_epi8(m234, input, mask_c2c2c2c2); + __mmask64 leading = tail == (tail == SIMDUTF_FULL) ? _kor_mask64(m1, m234) : _kand_mask64(_kor_mask64(m1, m234), b); // first bytes of each sequence if (tail == SIMDUTF_FULL) { - in += 64; // consumed 64 bytes - // we convert a full 64-byte block, writing 128 bytes. - __m512i input1 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(input)); - if(big_endian) { input1 = _mm512_shuffle_epi8(input1, byteflip); } - _mm512_storeu_si512(out, input1); - out += 32; - __m512i input2 = _mm512_cvtepu8_epi16(_mm512_extracti64x4_epi64(input, 1)); - if(big_endian) { input2 = _mm512_shuffle_epi8(input2, byteflip); } - _mm512_storeu_si512(out, input2); - out += 32; - return true; // we are done + __mmask64 xnor234leading = _kxnor_mask64(_kshiftli_mask64(m234, 1), leading); + if (!_kortestz_mask64_u8(xnor234leading, xnor234leading)) { + return false; + } } else { - in += gap; - if (gap <= 32) { - __m512i input1 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(input)); - if(big_endian) { input1 = _mm512_shuffle_epi8(input1, byteflip); } - _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << (gap)) - 1), input1); - out += gap; - } else { - __m512i input1 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(input)); - if(big_endian) { input1 = _mm512_shuffle_epi8(input1, byteflip); } - _mm512_storeu_si512(out, input1); - out += 32; - __m512i input2 = _mm512_cvtepu8_epi16(_mm512_extracti64x4_epi64(input, 1)); - if(big_endian) { input2 = _mm512_shuffle_epi8(input2, byteflip); } - _mm512_mask_storeu_epi16(out, __mmask32((uint32_t(1) << (gap - 32)) - 1), input2); - out += gap - 32; - } - return true; // we are done - } - } - // classify characters further - __mmask64 m234 = _mm512_cmp_epu8_mask(mask_c0c0c0c0, input, - _MM_CMPINT_LE); // 0xc0 <= input, 2, 3, or 4 leading byte - __mmask64 m34 = _mm512_cmp_epu8_mask(mask_dfdfdfdf_tail, input, - _MM_CMPINT_LT); // 0xdf < input, 3 or 4 leading byte - - __mmask64 milltwobytes = _mm512_mask_cmp_epu8_mask(m234, input, mask_c2c2c2c2, - _MM_CMPINT_LT); // 0xc0 <= input < 0xc2 (illegal two byte sequence) - // Overlong 2-byte sequence - if (_ktestz_mask64_u8(milltwobytes, milltwobytes) == 0) { - // Overlong 2-byte sequence - return false; - } - if (_ktestz_mask64_u8(m34, m34) == 0) { - // We have a 3-byte sequence and/or a 2-byte sequence, or possibly even a 4-byte sequence! - __mmask64 m4 = _mm512_cmp_epu8_mask(input, mask_f0f0f0f0, - _MM_CMPINT_NLT); // 0xf0 <= zmm0 (4 byte start bytes) - - __mmask64 mask_not_ascii = (tail == SIMDUTF_FULL) ? _knot_mask64(m1) : _kand_mask64(_knot_mask64(m1), b); - - __mmask64 mp1 = _kshiftli_mask64(m234, 1); - __mmask64 mp2 = _kshiftli_mask64(m34, 2); - // We could do it as follows... - // if (_kortestz_mask64_u8(m4,m4)) { // compute the bitwise OR of the 64-bit masks a and b and return 1 if all zeroes - // but GCC generates better code when we do: - if (m4 == 0) { // compute the bitwise OR of the 64-bit masks a and b and return 1 if all zeroes - // Fast path with 1,2,3 bytes - __mmask64 mc = _kor_mask64(mp1, mp2); // expected continuation bytes - __mmask64 m1234 = _kor_mask64(m1, m234); - // mismatched continuation bytes: - if (tail == SIMDUTF_FULL) { - __mmask64 xnormcm1234 = _kxnor_mask64(mc, m1234); // XNOR of mc and m1234 should be all zero if they differ - // the presence of a 1 bit indicates that they overlap. - // _kortestz_mask64_u8: compute the bitwise OR of 64-bit masksand return 1 if all zeroes. - if (!_kortestz_mask64_u8(xnormcm1234, xnormcm1234)) { return false; } - } else { - __mmask64 bxorm1234 = _kxor_mask64(b, m1234); - if (mc != bxorm1234) { return false; } - } - // mend: identifying the last bytes of each sequence to be decoded - __mmask64 mend = _kshiftri_mask64(m1234, 1); - if (tail != SIMDUTF_FULL) { - mend = _kor_mask64(mend, (uint64_t(1) << (gap - 1))); - } - - - __m512i last_and_third = _mm512_maskz_compress_epi8(mend, mask_identity); - __m512i last_and_thirdu16 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(last_and_third)); - - __m512i nonasciitags = _mm512_maskz_mov_epi8(mask_not_ascii, mask_c0c0c0c0); // ASCII: 00000000 other: 11000000 - __m512i clearedbytes = _mm512_andnot_si512(nonasciitags, input); // high two bits cleared where not ASCII - __m512i lastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, last_and_thirdu16, - clearedbytes); // the last byte of each character - - __mmask64 mask_before_non_ascii = _kshiftri_mask64(mask_not_ascii, 1); // bytes that precede non-ASCII bytes - __m512i indexofsecondlastbytes = _mm512_add_epi16(mask_ffffffff, last_and_thirdu16); // indices of the second last bytes - __m512i beforeasciibytes = _mm512_maskz_mov_epi8(mask_before_non_ascii, clearedbytes); - __m512i secondlastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, indexofsecondlastbytes, - beforeasciibytes); // the second last bytes (of two, three byte seq, - // surrogates) - secondlastbytes = _mm512_slli_epi16(secondlastbytes, 6); // shifted into position - - __m512i indexofthirdlastbytes = _mm512_add_epi16(mask_ffffffff, - indexofsecondlastbytes); // indices of the second last bytes - __m512i thirdlastbyte = _mm512_maskz_mov_epi8(m34, - clearedbytes); // only those that are the third last byte of a sequece - __m512i thirdlastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, indexofthirdlastbytes, - thirdlastbyte); // the third last bytes (of three byte sequences, hi - // surrogate) - thirdlastbytes = _mm512_slli_epi16(thirdlastbytes, 12); // shifted into position - __m512i Wout = _mm512_ternarylogic_epi32(lastbytes, secondlastbytes, thirdlastbytes, 254); - // the elements of Wout excluding the last element if it happens to be a high surrogate: - - __mmask64 mprocessed = (tail == SIMDUTF_FULL) ? _pdep_u64(0xFFFFFFFF, mend) : _pdep_u64(0xFFFFFFFF, _kand_mask64(mend, b)); // we adjust mend at the end of the output. - - - // Encodings out of range... - { - // the location of 3-byte sequence start bytes in the input - __mmask64 m3 = m34 & (b ^ m4); - // words in Wout corresponding to 3-byte sequences. - __mmask32 M3 = __mmask32(_pext_u64(m3 << 2, mend)); - __m512i mask_08000800 = _mm512_set1_epi32(0x08000800); - __mmask32 Msmall800 = _mm512_mask_cmplt_epu16_mask(M3, Wout, mask_08000800); - __m512i mask_d800d800 = _mm512_set1_epi32(0xd800d800); - __m512i Moutminusd800 = _mm512_sub_epi16(Wout, mask_d800d800); - __mmask32 M3s = _mm512_mask_cmplt_epu16_mask(M3, Moutminusd800, mask_08000800); - if (_kor_mask32(Msmall800, M3s)) { return false; } - } - int64_t nout = _mm_popcnt_u64(mprocessed); - in += 64 - _lzcnt_u64(mprocessed); - if(big_endian) { Wout = _mm512_shuffle_epi8(Wout, byteflip); } - _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << nout) - 1), Wout); - out += nout; - return true; // ok + __mmask64 bxorleading = _kxor_mask64(b, leading); + if (_kshiftli_mask64(m234, 1) != bxorleading) { + return false; + } } // - // We have a 4-byte sequence, this is the general case. - // Slow! - __mmask64 mp3 = _kshiftli_mask64(m4, 3); - __mmask64 mc = _kor_mask64(_kor_mask64(mp1, mp2), mp3); // expected continuation bytes - __mmask64 m1234 = _kor_mask64(m1, m234); - - // mend: identifying the last bytes of each sequence to be decoded - __mmask64 mend = _kor_mask64(_kshiftri_mask64(_kor_mask64(mp3, m1234), 1), mp3); - if (tail != SIMDUTF_FULL) { - mend = _kor_mask64(mend, __mmask64(uint64_t(1) << (gap - 1))); - } - __m512i last_and_third = _mm512_maskz_compress_epi8(mend, mask_identity); - __m512i last_and_thirdu16 = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(last_and_third)); - - __m512i nonasciitags = _mm512_maskz_mov_epi8(mask_not_ascii, mask_c0c0c0c0); // ASCII: 00000000 other: 11000000 - __m512i clearedbytes = _mm512_andnot_si512(nonasciitags, input); // high two bits cleared where not ASCII - __m512i lastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, last_and_thirdu16, - clearedbytes); // the last byte of each character - - __mmask64 mask_before_non_ascii = _kshiftri_mask64(mask_not_ascii, 1); // bytes that precede non-ASCII bytes - __m512i indexofsecondlastbytes = _mm512_add_epi16(mask_ffffffff, last_and_thirdu16); // indices of the second last bytes - __m512i beforeasciibytes = _mm512_maskz_mov_epi8(mask_before_non_ascii, clearedbytes); - __m512i secondlastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, indexofsecondlastbytes, - beforeasciibytes); // the second last bytes (of two, three byte seq, - // surrogates) - secondlastbytes = _mm512_slli_epi16(secondlastbytes, 6); // shifted into position - - __m512i indexofthirdlastbytes = _mm512_add_epi16(mask_ffffffff, - indexofsecondlastbytes); // indices of the second last bytes - __m512i thirdlastbyte = _mm512_maskz_mov_epi8(m34, - clearedbytes); // only those that are the third last byte of a sequece - __m512i thirdlastbytes = _mm512_maskz_permutexvar_epi8(0x5555555555555555, indexofthirdlastbytes, - thirdlastbyte); // the third last bytes (of three byte sequences, hi - // surrogate) - thirdlastbytes = _mm512_slli_epi16(thirdlastbytes, 12); // shifted into position - __m512i thirdsecondandlastbytes = _mm512_ternarylogic_epi32(lastbytes, secondlastbytes, thirdlastbytes, 254); - uint64_t Mlo_uint64 = _pext_u64(mp3, mend); - __mmask32 Mlo = __mmask32(Mlo_uint64); - __mmask32 Mhi = __mmask32(Mlo_uint64 >> 1); - __m512i lo_surr_mask = _mm512_maskz_mov_epi16(Mlo, - mask_dc00dc00); // lo surr: 1101110000000000, other: 0000000000000000 - __m512i shifted4_thirdsecondandlastbytes = _mm512_srli_epi16(thirdsecondandlastbytes, - 4); // hi surr: 00000WVUTSRQPNML vuts = WVUTS - 1 - __m512i tagged_lo_surrogates = _mm512_or_si512(thirdsecondandlastbytes, - lo_surr_mask); // lo surr: 110111KJHGFEDCBA, other: unchanged - __m512i Wout = _mm512_mask_add_epi16(tagged_lo_surrogates, Mhi, shifted4_thirdsecondandlastbytes, - mask_d7c0d7c0); // hi sur: 110110vutsRQPNML, other: unchanged - // the elements of Wout excluding the last element if it happens to be a high surrogate: - __mmask32 Mout = ~(Mhi & 0x80000000); - __mmask64 mprocessed = (tail == SIMDUTF_FULL) ? _pdep_u64(Mout, mend) : _pdep_u64(Mout, _kand_mask64(mend, b)); // we adjust mend at the end of the output. - - - // mismatched continuation bytes: if (tail == SIMDUTF_FULL) { - __mmask64 xnormcm1234 = _kxnor_mask64(mc, m1234); // XNOR of mc and m1234 should be all zero if they differ - // the presence of a 1 bit indicates that they overlap. - // _kortestz_mask64_u8: compute the bitwise OR of 64-bit masksand return 1 if all zeroes. - if (!_kortestz_mask64_u8(xnormcm1234, xnormcm1234)) { return false; } + // In the two-byte/ASCII scenario, we are easily latency bound, so we want + // to increment the input buffer as quickly as possible. + // We process 32 bytes unless the byte at index 32 is a continuation byte, + // in which case we include it as well for a total of 33 bytes. + // Note that if x is an ASCII byte, then the following is false: + // int8_t(x) <= int8_t(0xc0) under two's complement. + in += 32; + if (int8_t(*in) <= int8_t(0xc0)) + in++; + // The alternative is to do + // in += 64 - _lzcnt_u64(_pdep_u64(0xFFFFFFFF, continuation_or_ascii)); + // but it requires loading the input, doing the mask computation, and converting + // back the mask to a general register. It just takes too long, leaving the + // processor likely to be idle. } else { - __mmask64 bxorm1234 = _kxor_mask64(b, m1234); - if (mc != bxorm1234) { return false; } - } - // Encodings out of range... - { - // the location of 3-byte sequence start bytes in the input - __mmask64 m3 = m34 & (b ^ m4); - // words in Wout corresponding to 3-byte sequences. - __mmask32 M3 = __mmask32(_pext_u64(m3 << 2, mend)); - __m512i mask_08000800 = _mm512_set1_epi32(0x08000800); - __mmask32 Msmall800 = _mm512_mask_cmplt_epu16_mask(M3, Wout, mask_08000800); - __m512i mask_d800d800 = _mm512_set1_epi32(0xd800d800); - __m512i Moutminusd800 = _mm512_sub_epi16(Wout, mask_d800d800); - __mmask32 M3s = _mm512_mask_cmplt_epu16_mask(M3, Moutminusd800, mask_08000800); - __m512i mask_04000400 = _mm512_set1_epi32(0x04000400); - __mmask32 M4s = _mm512_mask_cmpge_epu16_mask(Mhi, Moutminusd800, mask_04000400); - if (!_kortestz_mask32_u8(M4s, _kor_mask32(Msmall800, M3s))) { return false; } - } - in += 64 - _lzcnt_u64(mprocessed); - int64_t nout = _mm_popcnt_u64(mprocessed); - if(big_endian) { Wout = _mm512_shuffle_epi8(Wout, byteflip); } - _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << nout) - 1), Wout); - out += nout; - return true; // ok - } - // Fast path 2: all ASCII or 2 byte - __mmask64 continuation_or_ascii = (tail == SIMDUTF_FULL) ? _knot_mask64(m234) : _kand_mask64(_knot_mask64(m234), b); - // on top of -0xc0 we substract -2 which we get back later of the - // continuation byte tags - __m512i leading2byte = _mm512_maskz_sub_epi8(m234, input, mask_c2c2c2c2); - __mmask64 leading = tail == (tail == SIMDUTF_FULL) ? _kor_mask64(m1, m234) : _kand_mask64(_kor_mask64(m1, m234), b); // first bytes of each sequence - if (tail == SIMDUTF_FULL) { - __mmask64 xnor234leading = _kxnor_mask64(_kshiftli_mask64(m234, 1), leading); - if (!_kortestz_mask64_u8(xnor234leading, xnor234leading)) { return false; } - } else { - __mmask64 bxorleading = _kxor_mask64(b, leading); - if (_kshiftli_mask64(m234, 1) != bxorleading) { return false; } - } - // - if (tail == SIMDUTF_FULL) { - // In the two-byte/ASCII scenario, we are easily latency bound, so we want - // to increment the input buffer as quickly as possible. - // We process 32 bytes unless the byte at index 32 is a continuation byte, - // in which case we include it as well for a total of 33 bytes. - // Note that if x is an ASCII byte, then the following is false: - // int8_t(x) <= int8_t(0xc0) under two's complement. - in += 32; - if(int8_t(*in) <= int8_t(0xc0)) in++; - // The alternative is to do - // in += 64 - _lzcnt_u64(_pdep_u64(0xFFFFFFFF, continuation_or_ascii)); - // but it requires loading the input, doing the mask computation, and converting - // back the mask to a general register. It just takes too long, leaving the - // processor likely to be idle. - } else { - in += 64 - _lzcnt_u64(_pdep_u64(0xFFFFFFFF, continuation_or_ascii)); - } - __m512i lead = _mm512_maskz_compress_epi8(leading, leading2byte); // will contain zero for ascii, and the data - lead = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(lead)); // ... zero extended into words - __m512i follow = _mm512_maskz_compress_epi8(continuation_or_ascii, input); // the last bytes of each sequence - follow = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(follow)); // ... zero extended into words - lead = _mm512_slli_epi16(lead, 6); // shifted into position - __m512i final = _mm512_add_epi16(follow, lead); // combining lead and follow - - if(big_endian) { final = _mm512_shuffle_epi8(final, byteflip); } - if (tail == SIMDUTF_FULL) { - // Next part is UTF-16 specific and can be generalized to UTF-32. - int nout = _mm_popcnt_u32(uint32_t(leading)); - _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << nout) - 1), final); - out += nout; // UTF-8 to UTF-16 is only expansionary in this case. - } else { - int nout = int(_mm_popcnt_u64(_pdep_u64(0xFFFFFFFF, leading))); - _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << nout) - 1), final); - out += nout; // UTF-8 to UTF-16 is only expansionary in this case. - } - - return true; // we are fine. -} - + in += 64 - _lzcnt_u64(_pdep_u64(0xFFFFFFFF, continuation_or_ascii)); + } + __m512i lead = _mm512_maskz_compress_epi8(leading, leading2byte); // will contain zero for ascii, and the data + lead = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(lead)); // ... zero extended into words + __m512i follow = _mm512_maskz_compress_epi8(continuation_or_ascii, input); // the last bytes of each sequence + follow = _mm512_cvtepu8_epi16(_mm512_castsi512_si256(follow)); // ... zero extended into words + lead = _mm512_slli_epi16(lead, 6); // shifted into position + __m512i final = _mm512_add_epi16(follow, lead); // combining lead and follow + if (big_endian) { + final = _mm512_shuffle_epi8(final, byteflip); + } + if (tail == SIMDUTF_FULL) { + // Next part is UTF-16 specific and can be generalized to UTF-32. + int nout = _mm_popcnt_u32(uint32_t(leading)); + _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << nout) - 1), final); + out += nout; // UTF-8 to UTF-16 is only expansionary in this case. + } else { + int nout = int(_mm_popcnt_u64(_pdep_u64(0xFFFFFFFF, leading))); + _mm512_mask_storeu_epi16(out, __mmask32((uint64_t(1) << nout) - 1), final); + out += nout; // UTF-8 to UTF-16 is only expansionary in this case. + } + return true; // we are fine. +} /* utf32_to_utf16_masked converts `count` lower UTF-32 words @@ -16054,8 +18780,9 @@ simdutf_really_inline bool process_block_utf8_to_utf16(const char *&in, char16_t We pass it to the (always inlined) function to encourage the compiler to keep the value in a (constant) register. */ -template -simdutf_really_inline size_t utf32_to_utf16_masked(const __m512i byteflip, __m512i utf32, unsigned int count, char16_t* output) { +template +simdutf_really_inline size_t utf32_to_utf16_masked(const __m512i byteflip, __m512i utf32, unsigned int count, char16_t* output) +{ const __mmask16 valid = uint16_t((1 << count) - 1); // 1. check if we have any surrogate pairs @@ -16063,11 +18790,11 @@ simdutf_really_inline size_t utf32_to_utf16_masked(const __m512i byteflip, __m51 const __mmask16 sp_mask = _mm512_mask_cmpgt_epu32_mask(valid, utf32, v_0000_ffff); if (sp_mask == 0) { - if(big_endian) { - _mm256_mask_storeu_epi16((__m256i*)output, valid, _mm256_shuffle_epi8(_mm512_cvtepi32_epi16(utf32), _mm512_castsi512_si256(byteflip))); + if (big_endian) { + _mm256_mask_storeu_epi16((__m256i*)output, valid, _mm256_shuffle_epi8(_mm512_cvtepi32_epi16(utf32), _mm512_castsi512_si256(byteflip))); } else { - _mm256_mask_storeu_epi16((__m256i*)output, valid, _mm512_cvtepi32_epi16(utf32)); + _mm256_mask_storeu_epi16((__m256i*)output, valid, _mm512_cvtepi32_epi16(utf32)); } return count; } @@ -16097,12 +18824,14 @@ simdutf_really_inline size_t utf32_to_utf16_masked(const __m512i byteflip, __m51 // Here we want to trim all of the upper 16-bit words from the 2-byte // characters represented as 4-byte values. We can compute it from // sp_mask or the following... It can be more optimized! - const __mmask32 nonzero = _kor_mask32(0xaaaaaaaa,_mm512_cmpneq_epi16_mask(t5, _mm512_setzero_si512())); - const __mmask32 nonzero_masked = _kand_mask32(nonzero, __mmask32((uint64_t(1) << (2*count)) - 1)); - if(big_endian) { t5 = _mm512_shuffle_epi8(t5, byteflip); } + const __mmask32 nonzero = _kor_mask32(0xaaaaaaaa, _mm512_cmpneq_epi16_mask(t5, _mm512_setzero_si512())); + const __mmask32 nonzero_masked = _kand_mask32(nonzero, __mmask32((uint64_t(1) << (2 * count)) - 1)); + if (big_endian) { + t5 = _mm512_shuffle_epi8(t5, byteflip); + } // we deliberately avoid _mm512_mask_compressstoreu_epi16 for portability (zen4) __m512i compressed = _mm512_maskz_compress_epi16(nonzero_masked, t5); - _mm512_mask_storeu_epi16(output, (1<<(count + static_cast(count_ones(sp_mask)))) - 1, compressed); + _mm512_mask_storeu_epi16(output, (1 << (count + static_cast(count_ones(sp_mask)))) - 1, compressed); //_mm512_mask_compressstoreu_epi16(output, nonzero_masked, t5); } @@ -16129,18 +18858,19 @@ simdutf_really_inline size_t utf32_to_utf16_masked(const __m512i byteflip, __m51 We pass it to the (always inlined) function to encourage the compiler to keep the value in a (constant) register. */ -template -simdutf_really_inline size_t utf32_to_utf16(const __m512i byteflip, __m512i utf32, unsigned int count, char16_t* output) { +template +simdutf_really_inline size_t utf32_to_utf16(const __m512i byteflip, __m512i utf32, unsigned int count, char16_t* output) +{ // check if we have any surrogate pairs const __m512i v_0000_ffff = _mm512_set1_epi32(0x0000ffff); const __mmask16 sp_mask = _mm512_cmpgt_epu32_mask(utf32, v_0000_ffff); if (sp_mask == 0) { // technically, it should be _mm256_storeu_epi16 - if(big_endian) { - _mm256_storeu_si256((__m256i*)output, _mm256_shuffle_epi8(_mm512_cvtepi32_epi16(utf32),_mm512_castsi512_si256(byteflip))); + if (big_endian) { + _mm256_storeu_si256((__m256i*)output, _mm256_shuffle_epi8(_mm512_cvtepi32_epi16(utf32), _mm512_castsi512_si256(byteflip))); } else { - _mm256_storeu_si256((__m256i*)output, _mm512_cvtepi32_epi16(utf32)); + _mm256_storeu_si256((__m256i*)output, _mm512_cvtepi32_epi16(utf32)); } return count; } @@ -16167,11 +18897,13 @@ simdutf_really_inline size_t utf32_to_utf16(const __m512i byteflip, __m512i utf3 const __m512i t3 = _mm512_ternarylogic_epi32(t2, v_fc00_fc00, v_d800_dc00, 0xba); const __m512i t4 = _mm512_mask_blend_epi32(sp_mask, utf32, t3); __m512i t5 = _mm512_ror_epi32(t4, 16); - const __mmask32 nonzero = _kor_mask32(0xaaaaaaaa,_mm512_cmpneq_epi16_mask(t5, _mm512_setzero_si512())); - if(big_endian) { t5 = _mm512_shuffle_epi8(t5, byteflip); } + const __mmask32 nonzero = _kor_mask32(0xaaaaaaaa, _mm512_cmpneq_epi16_mask(t5, _mm512_setzero_si512())); + if (big_endian) { + t5 = _mm512_shuffle_epi8(t5, byteflip); + } // we deliberately avoid _mm512_mask_compressstoreu_epi16 for portability (zen4) __m512i compressed = _mm512_maskz_compress_epi16(nonzero, t5); - _mm512_mask_storeu_epi16(output, (1<<(count + static_cast(count_ones(sp_mask)))) - 1, compressed); + _mm512_mask_storeu_epi16(output, (1 << (count + static_cast(count_ones(sp_mask)))) - 1, compressed); //_mm512_mask_compressstoreu_epi16(output, nonzero, t5); } @@ -16181,21 +18913,23 @@ simdutf_really_inline size_t utf32_to_utf16(const __m512i byteflip, __m512i utf3 /** * Store the last N bytes of previous followed by 512-N bytes from input. */ -template -__m512i prev(__m512i input, __m512i previous) { - static_assert(N<=32, "N must be no larger than 32"); - const __m512i movemask = _mm512_setr_epi32(28,29,30,31,0,1,2,3,4,5,6,7,8,9,10,11); +template +__m512i prev(__m512i input, __m512i previous) +{ + static_assert(N <= 32, "N must be no larger than 32"); + const __m512i movemask = _mm512_setr_epi32(28, 29, 30, 31, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); const __m512i rotated = _mm512_permutex2var_epi32(input, movemask, previous); #if SIMDUTF_GCC8 || SIMDUTF_GCC9 - constexpr int shift = 16-N; // workaround for GCC8,9 + constexpr int shift = 16 - N; // workaround for GCC8,9 return _mm512_alignr_epi8(input, rotated, shift); #else - return _mm512_alignr_epi8(input, rotated, 16-N); + return _mm512_alignr_epi8(input, rotated, 16 - N); #endif // SIMDUTF_GCC8 || SIMDUTF_GCC9 } -template -__m512i shuffle_epi128(__m512i v) { +template +__m512i shuffle_epi128(__m512i v) +{ static_assert((idx0 >= 0 && idx0 <= 3), "idx0 must be in range 0..3"); static_assert((idx1 >= 0 && idx1 <= 3), "idx1 must be in range 0..3"); static_assert((idx2 >= 0 && idx2 <= 3), "idx2 must be in range 0..3"); @@ -16205,16 +18939,18 @@ __m512i shuffle_epi128(__m512i v) { return _mm512_shuffle_i32x4(v, v, shuffle); } -template -constexpr __m512i broadcast_epi128(__m512i v) { +template +constexpr __m512i broadcast_epi128(__m512i v) +{ return shuffle_epi128(v); } /** * Current unused. */ -template -__m512i rotate_by_N_epi8(const __m512i input) { +template +__m512i rotate_by_N_epi8(const __m512i input) +{ // lanes order: 1, 2, 3, 0 => 0b00_11_10_01 const __m512i permuted = _mm512_shuffle_i32x4(input, input, 0x39); @@ -16230,7 +18966,8 @@ __m512i rotate_by_N_epi8(const __m512i input) { 0x8080800N, where N is 4 higest bits from the leading byte; 0x80 resets corresponding bytes during pshufb. */ -simdutf_really_inline __m512i expanded_utf8_to_utf32(__m512i char_class, __m512i utf8) { +simdutf_really_inline __m512i expanded_utf8_to_utf32(__m512i char_class, __m512i utf8) +{ /* Input: - utf8: bytes stored at separate 32-bit words @@ -16319,8 +19056,7 @@ simdutf_really_inline __m512i expanded_utf8_to_utf32(__m512i char_class, __m512i 0x0707070707070707, 0x0b0a090900000000, 0x0707070707070707, - 0x0b0a090900000000 - ); + 0x0b0a090900000000); const __m512i shift = _mm512_shuffle_epi8(shift_left_v3, char_class); values = _mm512_sllv_epi32(values, shift); @@ -16341,8 +19077,7 @@ simdutf_really_inline __m512i expanded_utf8_to_utf32(__m512i char_class, __m512i 0x1919191919191919, 0x0b10151500000000, 0x1919191919191919, - 0x0b10151500000000 - ); + 0x0b10151500000000); const __m512i shift = _mm512_shuffle_epi8(shift_right, char_class); values = _mm512_srlv_epi32(values, shift); @@ -16351,29 +19086,29 @@ simdutf_really_inline __m512i expanded_utf8_to_utf32(__m512i char_class, __m512i return values; } - -simdutf_really_inline __m512i expand_and_identify(__m512i lane0, __m512i lane1, int &count) { +simdutf_really_inline __m512i expand_and_identify(__m512i lane0, __m512i lane1, int& count) +{ const __m512i merged = _mm512_mask_mov_epi32(lane0, 0x1000, lane1); const __m512i expand_ver2 = _mm512_setr_epi64( - 0x0403020103020100, - 0x0605040305040302, - 0x0807060507060504, - 0x0a09080709080706, - 0x0c0b0a090b0a0908, - 0x0e0d0c0b0d0c0b0a, - 0x000f0e0d0f0e0d0c, - 0x0201000f01000f0e - ); + 0x0403020103020100, + 0x0605040305040302, + 0x0807060507060504, + 0x0a09080709080706, + 0x0c0b0a090b0a0908, + 0x0e0d0c0b0d0c0b0a, + 0x000f0e0d0f0e0d0c, + 0x0201000f01000f0e); const __m512i input = _mm512_shuffle_epi8(merged, expand_ver2); const __m512i v_0000_00c0 = _mm512_set1_epi32(0xc0); const __m512i t0 = _mm512_and_si512(input, v_0000_00c0); const __m512i v_0000_0080 = _mm512_set1_epi32(0x80); const __mmask16 leading_bytes = _mm512_cmpneq_epu32_mask(t0, v_0000_0080); count = static_cast(count_ones(leading_bytes)); - return _mm512_mask_compress_epi32(_mm512_setzero_si512(), leading_bytes, input); + return _mm512_mask_compress_epi32(_mm512_setzero_si512(), leading_bytes, input); } -simdutf_really_inline __m512i expand_utf8_to_utf32(__m512i input) { +simdutf_really_inline __m512i expand_utf8_to_utf32(__m512i input) +{ __m512i char_class = _mm512_srli_epi32(input, 4); /* char_class = ((input >> 4) & 0x0f) | 0x80808000 */ const __m512i v_0000_000f = _mm512_set1_epi32(0x0f); @@ -16382,7 +19117,7 @@ simdutf_really_inline __m512i expand_utf8_to_utf32(__m512i input) { return expanded_utf8_to_utf32(char_class, input); } /* end file src/icelake/icelake_utf8_common.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_macros.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_macros.inl.cpp /* begin file src/icelake/icelake_macros.inl.cpp */ /* @@ -16426,99 +19161,97 @@ simdutf_really_inline __m512i expand_utf8_to_utf32(__m512i input) { ] */ -#define SIMDUTF_ICELAKE_TRANSCODE16(LANE0, LANE1, MASKED) \ - { \ - const __m512i merged = _mm512_mask_mov_epi32(LANE0, 0x1000, LANE1); \ - const __m512i expand_ver2 = _mm512_setr_epi64( \ - 0x0403020103020100, \ - 0x0605040305040302, \ - 0x0807060507060504, \ - 0x0a09080709080706, \ - 0x0c0b0a090b0a0908, \ - 0x0e0d0c0b0d0c0b0a, \ - 0x000f0e0d0f0e0d0c, \ - 0x0201000f01000f0e \ - ); \ - const __m512i input = _mm512_shuffle_epi8(merged, expand_ver2); \ - \ - __mmask16 leading_bytes; \ - const __m512i v_0000_00c0 = _mm512_set1_epi32(0xc0); \ - const __m512i t0 = _mm512_and_si512(input, v_0000_00c0); \ - const __m512i v_0000_0080 = _mm512_set1_epi32(0x80); \ - leading_bytes = _mm512_cmpneq_epu32_mask(t0, v_0000_0080); \ - \ - __m512i char_class; \ - char_class = _mm512_srli_epi32(input, 4); \ - /* char_class = ((input >> 4) & 0x0f) | 0x80808000 */ \ - const __m512i v_0000_000f = _mm512_set1_epi32(0x0f); \ - const __m512i v_8080_8000 = _mm512_set1_epi32(0x80808000); \ - char_class = _mm512_ternarylogic_epi32(char_class, v_0000_000f, v_8080_8000, 0xea); \ - \ - const int valid_count = static_cast(count_ones(leading_bytes)); \ - const __m512i utf32 = expanded_utf8_to_utf32(char_class, input); \ - \ - const __m512i out = _mm512_mask_compress_epi32(_mm512_setzero_si512(), leading_bytes, utf32); \ - \ - if (UTF32) { \ - if(MASKED) { \ - const __mmask16 valid = uint16_t((1 << valid_count) - 1); \ - _mm512_mask_storeu_epi32((__m512i*)output, valid, out); \ - } else { \ - _mm512_storeu_si512((__m512i*)output, out); \ - } \ - output += valid_count; \ - } else { \ - if(MASKED) { \ - output += utf32_to_utf16_masked(byteflip, out, valid_count, reinterpret_cast(output)); \ - } else { \ - output += utf32_to_utf16(byteflip, out, valid_count, reinterpret_cast(output)); \ - } \ - } \ - } - -#define SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(INPUT, VALID_COUNT, MASKED) \ -{ \ - if (UTF32) { \ - if(MASKED) { \ - const __mmask16 valid_mask = uint16_t((1 << VALID_COUNT) - 1); \ - _mm512_mask_storeu_epi32((__m512i*)output, valid_mask, INPUT); \ - } else { \ - _mm512_storeu_si512((__m512i*)output, INPUT); \ - } \ - output += VALID_COUNT; \ - } else { \ - if(MASKED) { \ - output += utf32_to_utf16_masked(byteflip, INPUT, VALID_COUNT, reinterpret_cast(output)); \ - } else { \ - output += utf32_to_utf16(byteflip, INPUT, VALID_COUNT, reinterpret_cast(output)); \ - } \ - } \ -} - - -#define SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output) \ - if (UTF32) { \ - const __m128i t0 = _mm512_castsi512_si128(utf8); \ - const __m128i t1 = _mm512_extracti32x4_epi32(utf8, 1); \ - const __m128i t2 = _mm512_extracti32x4_epi32(utf8, 2); \ - const __m128i t3 = _mm512_extracti32x4_epi32(utf8, 3); \ - _mm512_storeu_si512((__m512i*)(output + 0*16), _mm512_cvtepu8_epi32(t0)); \ - _mm512_storeu_si512((__m512i*)(output + 1*16), _mm512_cvtepu8_epi32(t1)); \ - _mm512_storeu_si512((__m512i*)(output + 2*16), _mm512_cvtepu8_epi32(t2)); \ - _mm512_storeu_si512((__m512i*)(output + 3*16), _mm512_cvtepu8_epi32(t3)); \ - } else { \ - const __m256i h0 = _mm512_castsi512_si256(utf8); \ - const __m256i h1 = _mm512_extracti64x4_epi64(utf8, 1); \ - if(big_endian) { \ - _mm512_storeu_si512((__m512i*)(output + 0*16), _mm512_shuffle_epi8(_mm512_cvtepu8_epi16(h0), byteflip)); \ - _mm512_storeu_si512((__m512i*)(output + 2*16), _mm512_shuffle_epi8(_mm512_cvtepu8_epi16(h1), byteflip)); \ - } else { \ - _mm512_storeu_si512((__m512i*)(output + 0*16), _mm512_cvtepu8_epi16(h0)); \ - _mm512_storeu_si512((__m512i*)(output + 2*16), _mm512_cvtepu8_epi16(h1)); \ - } \ - } +#define SIMDUTF_ICELAKE_TRANSCODE16(LANE0, LANE1, MASKED) \ + { \ + const __m512i merged = _mm512_mask_mov_epi32(LANE0, 0x1000, LANE1); \ + const __m512i expand_ver2 = _mm512_setr_epi64( \ + 0x0403020103020100, \ + 0x0605040305040302, \ + 0x0807060507060504, \ + 0x0a09080709080706, \ + 0x0c0b0a090b0a0908, \ + 0x0e0d0c0b0d0c0b0a, \ + 0x000f0e0d0f0e0d0c, \ + 0x0201000f01000f0e); \ + const __m512i input = _mm512_shuffle_epi8(merged, expand_ver2); \ + \ + __mmask16 leading_bytes; \ + const __m512i v_0000_00c0 = _mm512_set1_epi32(0xc0); \ + const __m512i t0 = _mm512_and_si512(input, v_0000_00c0); \ + const __m512i v_0000_0080 = _mm512_set1_epi32(0x80); \ + leading_bytes = _mm512_cmpneq_epu32_mask(t0, v_0000_0080); \ + \ + __m512i char_class; \ + char_class = _mm512_srli_epi32(input, 4); \ + /* char_class = ((input >> 4) & 0x0f) | 0x80808000 */ \ + const __m512i v_0000_000f = _mm512_set1_epi32(0x0f); \ + const __m512i v_8080_8000 = _mm512_set1_epi32(0x80808000); \ + char_class = _mm512_ternarylogic_epi32(char_class, v_0000_000f, v_8080_8000, 0xea); \ + \ + const int valid_count = static_cast(count_ones(leading_bytes)); \ + const __m512i utf32 = expanded_utf8_to_utf32(char_class, input); \ + \ + const __m512i out = _mm512_mask_compress_epi32(_mm512_setzero_si512(), leading_bytes, utf32); \ + \ + if (UTF32) { \ + if (MASKED) { \ + const __mmask16 valid = uint16_t((1 << valid_count) - 1); \ + _mm512_mask_storeu_epi32((__m512i*)output, valid, out); \ + } else { \ + _mm512_storeu_si512((__m512i*)output, out); \ + } \ + output += valid_count; \ + } else { \ + if (MASKED) { \ + output += utf32_to_utf16_masked(byteflip, out, valid_count, reinterpret_cast(output)); \ + } else { \ + output += utf32_to_utf16(byteflip, out, valid_count, reinterpret_cast(output)); \ + } \ + } \ + } + +#define SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(INPUT, VALID_COUNT, MASKED) \ + { \ + if (UTF32) { \ + if (MASKED) { \ + const __mmask16 valid_mask = uint16_t((1 << VALID_COUNT) - 1); \ + _mm512_mask_storeu_epi32((__m512i*)output, valid_mask, INPUT); \ + } else { \ + _mm512_storeu_si512((__m512i*)output, INPUT); \ + } \ + output += VALID_COUNT; \ + } else { \ + if (MASKED) { \ + output += utf32_to_utf16_masked(byteflip, INPUT, VALID_COUNT, reinterpret_cast(output)); \ + } else { \ + output += utf32_to_utf16(byteflip, INPUT, VALID_COUNT, reinterpret_cast(output)); \ + } \ + } \ + } + +#define SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output) \ + if (UTF32) { \ + const __m128i t0 = _mm512_castsi512_si128(utf8); \ + const __m128i t1 = _mm512_extracti32x4_epi32(utf8, 1); \ + const __m128i t2 = _mm512_extracti32x4_epi32(utf8, 2); \ + const __m128i t3 = _mm512_extracti32x4_epi32(utf8, 3); \ + _mm512_storeu_si512((__m512i*)(output + 0 * 16), _mm512_cvtepu8_epi32(t0)); \ + _mm512_storeu_si512((__m512i*)(output + 1 * 16), _mm512_cvtepu8_epi32(t1)); \ + _mm512_storeu_si512((__m512i*)(output + 2 * 16), _mm512_cvtepu8_epi32(t2)); \ + _mm512_storeu_si512((__m512i*)(output + 3 * 16), _mm512_cvtepu8_epi32(t3)); \ + } else { \ + const __m256i h0 = _mm512_castsi512_si256(utf8); \ + const __m256i h1 = _mm512_extracti64x4_epi64(utf8, 1); \ + if (big_endian) { \ + _mm512_storeu_si512((__m512i*)(output + 0 * 16), _mm512_shuffle_epi8(_mm512_cvtepu8_epi16(h0), byteflip)); \ + _mm512_storeu_si512((__m512i*)(output + 2 * 16), _mm512_shuffle_epi8(_mm512_cvtepu8_epi16(h1), byteflip)); \ + } else { \ + _mm512_storeu_si512((__m512i*)(output + 0 * 16), _mm512_cvtepu8_epi16(h0)); \ + _mm512_storeu_si512((__m512i*)(output + 2 * 16), _mm512_cvtepu8_epi16(h1)); \ + } \ + } /* end file src/icelake/icelake_macros.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_from_valid_utf8.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_from_valid_utf8.inl.cpp /* begin file src/icelake/icelake_from_valid_utf8.inl.cpp */ // file included directly @@ -16539,23 +19272,23 @@ simdutf_really_inline __m512i expand_utf8_to_utf32(__m512i input) { - pair.first - the first unprocessed input byte - pair.second - the first unprocessed output word */ -template -std::pair valid_utf8_to_fixed_length(const char* str, size_t len, OUTPUT* dwords) { +template +std::pair valid_utf8_to_fixed_length(const char* str, size_t len, OUTPUT* dwords) +{ constexpr bool UTF32 = std::is_same::value; constexpr bool UTF16 = std::is_same::value; static_assert(UTF32 or UTF16, "output type has to be uint32_t (for UTF-32) or char16_t (for UTF-16)"); static_assert(!(UTF32 and big_endian), "we do not currently support big-endian UTF-32"); __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); const char* ptr = str; const char* end = ptr + len; @@ -16570,7 +19303,7 @@ std::pair valid_utf8_to_fixed_length(const char* str, size const __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); const __m512i v_80 = _mm512_set1_epi8(char(0x80)); const __mmask64 ascii = _mm512_test_epi8_mask(utf8, v_80); - if(ascii == 0) { + if (ascii == 0) { SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output) output += 64; ptr += 64; @@ -16584,8 +19317,8 @@ std::pair valid_utf8_to_fixed_length(const char* str, size const __m512i lane2 = broadcast_epi128<2>(utf8); int valid_count1; __m512i vec1 = expand_and_identify(lane1, lane2, valid_count1); - if(valid_count0 + valid_count1 <= 16) { - vec0 = _mm512_mask_expand_epi32(vec0, __mmask16(((1< valid_utf8_to_fixed_length(const char* str, size const __m512i lane4 = _mm512_set1_epi32(tmp1); int valid_count3; __m512i vec3 = expand_and_identify(lane3, lane4, valid_count3); - if(valid_count2 + valid_count3 <= 16) { - vec2 = _mm512_mask_expand_epi32(vec2, __mmask16(((1< valid_utf8_to_fixed_length(const char* str, size SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, false) SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec3, valid_count3, false) } - ptr += 4*16; + ptr += 4 * 16; } if (ptr + 64 <= end) { const __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); const __m512i v_80 = _mm512_set1_epi8(char(0x80)); const __mmask64 ascii = _mm512_test_epi8_mask(utf8, v_80); - if(ascii == 0) { + if (ascii == 0) { SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output) output += 64; ptr += 64; @@ -16633,8 +19366,8 @@ std::pair valid_utf8_to_fixed_length(const char* str, size const __m512i lane2 = broadcast_epi128<2>(utf8); int valid_count1; __m512i vec1 = expand_and_identify(lane1, lane2, valid_count1); - if(valid_count0 + valid_count1 <= 16) { - vec0 = _mm512_mask_expand_epi32(vec0, __mmask16(((1< valid_utf8_to_fixed_length(const char* str, size const __m512i lane3 = broadcast_epi128<3>(utf8); SIMDUTF_ICELAKE_TRANSCODE16(lane2, lane3, true) - ptr += 3*16; + ptr += 3 * 16; } } - return {ptr, output}; + return { ptr, output }; } - using utf8_to_utf16_result = std::pair; /* end file src/icelake/icelake_from_valid_utf8.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_utf8_validation.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_utf8_validation.inl.cpp /* begin file src/icelake/icelake_utf8_validation.inl.cpp */ // file included directly - -simdutf_really_inline __m512i check_special_cases(__m512i input, const __m512i prev1) { - __m512i mask1 = _mm512_setr_epi64( +simdutf_really_inline __m512i check_special_cases(__m512i input, const __m512i prev1) +{ + __m512i mask1 = _mm512_setr_epi64( 0x0202020202020202, 0x4915012180808080, 0x0202020202020202, @@ -16685,7 +19417,7 @@ simdutf_really_inline __m512i check_special_cases(__m512i input, const __m512i p 0xcbcbdbcbcbcbcbcb, 0xcbcbcb8b8383a3e7, 0xcbcbdbcbcbcbcbcb); - __m512i index2 = _mm512_and_si512(prev1, v_0f); + __m512i index2 = _mm512_and_si512(prev1, v_0f); __m512i byte_1_low = _mm512_shuffle_epi8(mask2, index2); __m512i mask3 = _mm512_setr_epi64( @@ -16696,19 +19428,19 @@ simdutf_really_inline __m512i check_special_cases(__m512i input, const __m512i p 0x101010101010101, 0x1010101babaaee6, 0x101010101010101, - 0x1010101babaaee6 - ); + 0x1010101babaaee6); __m512i index3 = _mm512_and_si512(_mm512_srli_epi16(input, 4), v_0f); __m512i byte_2_high = _mm512_shuffle_epi8(mask3, index3); return _mm512_ternarylogic_epi64(byte_1_high, byte_1_low, byte_2_high, 128); - } +} - simdutf_really_inline __m512i check_multibyte_lengths(const __m512i input, - const __m512i prev_input, const __m512i sc) { +simdutf_really_inline __m512i check_multibyte_lengths(const __m512i input, + const __m512i prev_input, const __m512i sc) +{ __m512i prev2 = prev<2>(input, prev_input); __m512i prev3 = prev<3>(input, prev_input); - __m512i is_third_byte = _mm512_subs_epu8(prev2, _mm512_set1_epi8(0b11100000u-1)); // Only 111_____ will be > 0 - __m512i is_fourth_byte = _mm512_subs_epu8(prev3, _mm512_set1_epi8(0b11110000u-1)); // Only 1111____ will be > 0 + __m512i is_third_byte = _mm512_subs_epu8(prev2, _mm512_set1_epi8(0b11100000u - 1)); // Only 111_____ will be > 0 + __m512i is_fourth_byte = _mm512_subs_epu8(prev3, _mm512_set1_epi8(0b11110000u - 1)); // Only 1111____ will be > 0 __m512i is_third_or_fourth_byte = _mm512_or_si512(is_third_byte, is_fourth_byte); const __m512i v_7f = _mm512_set1_epi8(char(0x7f)); is_third_or_fourth_byte = _mm512_adds_epu8(v_7f, is_third_or_fourth_byte); @@ -16716,13 +19448,14 @@ simdutf_really_inline __m512i check_special_cases(__m512i input, const __m512i p const __m512i v_80 = _mm512_set1_epi8(char(0x80)); return _mm512_ternarylogic_epi32(is_third_or_fourth_byte, v_80, sc, 0b1101010); //__m512i is_third_or_fourth_byte_mask = _mm512_and_si512(is_third_or_fourth_byte, v_80); - //return _mm512_xor_si512(is_third_or_fourth_byte_mask, sc); - } - // - // Return nonzero if there are incomplete multibyte characters at the end of the block: - // e.g. if there is a 4-byte character, but it's 3 bytes from the end. - // - simdutf_really_inline __m512i is_incomplete(const __m512i input) { + // return _mm512_xor_si512(is_third_or_fourth_byte_mask, sc); +} +// +// Return nonzero if there are incomplete multibyte characters at the end of the block: +// e.g. if there is a 4-byte character, but it's 3 bytes from the end. +// +simdutf_really_inline __m512i is_incomplete(const __m512i input) +{ // If the previous input's last 3 bytes match this, they're too short (they ended at EOF): // ... 1111____ 111_____ 11______ __m512i max_value = _mm512_setr_epi64( @@ -16735,59 +19468,63 @@ simdutf_really_inline __m512i check_special_cases(__m512i input, const __m512i p 0xffffffffffffffff, 0xbfdfefffffffffff); return _mm512_subs_epu8(input, max_value); - } +} - struct avx512_utf8_checker { +struct avx512_utf8_checker { // If this is nonzero, there has been a UTF-8 error. - __m512i error{}; + __m512i error {}; // The last input we received - __m512i prev_input_block{}; + __m512i prev_input_block {}; // Whether the last input we received was incomplete (used for ASCII fast path) - __m512i prev_incomplete{}; + __m512i prev_incomplete {}; // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const __m512i input, const __m512i prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - __m512i prev1 = prev<1>(input, prev_input); - __m512i sc = check_special_cases(input, prev1); - this->error = _mm512_or_si512(check_multibyte_lengths(input, prev_input, sc), this->error); + simdutf_really_inline void check_utf8_bytes(const __m512i input, const __m512i prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + __m512i prev1 = prev<1>(input, prev_input); + __m512i sc = check_special_cases(input, prev1); + this->error = _mm512_or_si512(check_multibyte_lengths(input, prev_input, sc), this->error); } // The only problem that can happen at EOF is that a multibyte character is too short // or a byte value too large in the last bytes: check_special_cases only checks for bytes // too large in the first of two bytes. - simdutf_really_inline void check_eof() { - // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't - // possibly finish them. - this->error = _mm512_or_si512(this->error, this->prev_incomplete); + simdutf_really_inline void check_eof() + { + // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't + // possibly finish them. + this->error = _mm512_or_si512(this->error, this->prev_incomplete); } // returns true if ASCII. - simdutf_really_inline bool check_next_input(const __m512i input) { - const __m512i v_80 = _mm512_set1_epi8(char(0x80)); - const __mmask64 ascii = _mm512_test_epi8_mask(input, v_80); - if(ascii == 0) { - this->error = _mm512_or_si512(this->error, this->prev_incomplete); - return true; - } else { - this->check_utf8_bytes(input, this->prev_input_block); - this->prev_incomplete = is_incomplete(input); - this->prev_input_block = input; - return false; - } + simdutf_really_inline bool check_next_input(const __m512i input) + { + const __m512i v_80 = _mm512_set1_epi8(char(0x80)); + const __mmask64 ascii = _mm512_test_epi8_mask(input, v_80); + if (ascii == 0) { + this->error = _mm512_or_si512(this->error, this->prev_incomplete); + return true; + } else { + this->check_utf8_bytes(input, this->prev_input_block); + this->prev_incomplete = is_incomplete(input); + this->prev_input_block = input; + return false; + } } // do not forget to call check_eof! - simdutf_really_inline bool errors() const { + simdutf_really_inline bool errors() const + { return _mm512_test_epi8_mask(this->error, this->error) != 0; } - }; // struct avx512_utf8_checker +}; // struct avx512_utf8_checker /* end file src/icelake/icelake_utf8_validation.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_from_utf8.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_from_utf8.inl.cpp /* begin file src/icelake/icelake_from_utf8.inl.cpp */ // file included directly @@ -16800,48 +19537,56 @@ simdutf_really_inline __m512i check_special_cases(__m512i input, const __m512i p * completed. Upon error, the output is set to null. */ -template -utf8_to_utf16_result fast_avx512_convert_utf8_to_utf16(const char *in, size_t len, char16_t *out) { - const char *const final_in = in + len; - bool result = true; - while (result) { - if (in + 64 <= final_in) { - result = process_block_utf8_to_utf16(in, out, final_in - in); - } else if(in < final_in) { - result = process_block_utf8_to_utf16(in, out, final_in - in); - } else { break; } - } - if(!result) { out = nullptr; } - return std::make_pair(in, out); -} - -template -simdutf::result fast_avx512_convert_utf8_to_utf16_with_errors(const char *in, size_t len, char16_t *out) { - const char *const init_in = in; - const char16_t *const init_out = out; - const char *const final_in = in + len; - bool result = true; - while (result) { - if (in + 64 <= final_in) { - result = process_block_utf8_to_utf16(in, out, final_in - in); - } else if(in < final_in) { - result = process_block_utf8_to_utf16(in, out, final_in - in); - } else { break; } - } - if(!result) { - // rewind_and_convert_with_errors will seek a potential error from in onward, - // with the ability to go back up to in - init_in bytes, and read final_in - in bytes forward. - simdutf::result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(in - init_in, in, final_in - in, out); - res.count += (in - init_in); - return res; - } else { - return simdutf::result(error_code::SUCCESS,out - init_out); - } +template +utf8_to_utf16_result fast_avx512_convert_utf8_to_utf16(const char* in, size_t len, char16_t* out) +{ + const char* const final_in = in + len; + bool result = true; + while (result) { + if (in + 64 <= final_in) { + result = process_block_utf8_to_utf16(in, out, final_in - in); + } else if (in < final_in) { + result = process_block_utf8_to_utf16(in, out, final_in - in); + } else { + break; + } + } + if (!result) { + out = nullptr; + } + return std::make_pair(in, out); } +template +simdutf::result fast_avx512_convert_utf8_to_utf16_with_errors(const char* in, size_t len, char16_t* out) +{ + const char* const init_in = in; + const char16_t* const init_out = out; + const char* const final_in = in + len; + bool result = true; + while (result) { + if (in + 64 <= final_in) { + result = process_block_utf8_to_utf16(in, out, final_in - in); + } else if (in < final_in) { + result = process_block_utf8_to_utf16(in, out, final_in - in); + } else { + break; + } + } + if (!result) { + // rewind_and_convert_with_errors will seek a potential error from in onward, + // with the ability to go back up to in - init_in bytes, and read final_in - in bytes forward. + simdutf::result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(in - init_in, in, final_in - in, out); + res.count += (in - init_in); + return res; + } else { + return simdutf::result(error_code::SUCCESS, out - init_out); + } +} -template -std::pair validating_utf8_to_fixed_length(const char* str, size_t len, OUTPUT* dwords) { +template +std::pair validating_utf8_to_fixed_length(const char* str, size_t len, OUTPUT* dwords) +{ constexpr bool UTF32 = std::is_same::value; constexpr bool UTF16 = std::is_same::value; static_assert(UTF32 or UTF16, "output type has to be uint32_t (for UTF-32) or char16_t (for UTF-16)"); @@ -16850,17 +19595,16 @@ std::pair validating_utf8_to_fixed_length(const char* str, const char* ptr = str; const char* end = ptr + len; __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); OUTPUT* output = dwords; - avx512_utf8_checker checker{}; + avx512_utf8_checker checker {}; /** * In the main loop, we consume 64 bytes per iteration, * but we access 64 + 4 bytes. @@ -16869,7 +19613,7 @@ std::pair validating_utf8_to_fixed_length(const char* str, */ while (ptr + 64 + 64 <= end) { const __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); - if(checker.check_next_input(utf8)) { + if (checker.check_next_input(utf8)) { SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output) output += 64; ptr += 64; @@ -16882,8 +19626,8 @@ std::pair validating_utf8_to_fixed_length(const char* str, const __m512i lane2 = broadcast_epi128<2>(utf8); int valid_count1; __m512i vec1 = expand_and_identify(lane1, lane2, valid_count1); - if(valid_count0 + valid_count1 <= 16) { - vec0 = _mm512_mask_expand_epi32(vec0, __mmask16(((1< validating_utf8_to_fixed_length(const char* str, const __m512i lane4 = _mm512_set1_epi32(tmp1); int valid_count3; __m512i vec3 = expand_and_identify(lane3, lane4, valid_count3); - if(valid_count2 + valid_count3 <= 16) { - vec2 = _mm512_mask_expand_epi32(vec2, __mmask16(((1< validating_utf8_to_fixed_length(const char* str, SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, false) SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec3, valid_count3, false) } - ptr += 4*16; + ptr += 4 * 16; } const char* validatedptr = ptr; // validated up to ptr @@ -16920,7 +19664,7 @@ std::pair validating_utf8_to_fixed_length(const char* str, // 3*16 bytes, so we may end up double-validating 16 bytes. if (ptr + 64 <= end) { const __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); - if(checker.check_next_input(utf8)) { + if (checker.check_next_input(utf8)) { SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output) output += 64; ptr += 64; @@ -16932,8 +19676,8 @@ std::pair validating_utf8_to_fixed_length(const char* str, const __m512i lane2 = broadcast_epi128<2>(utf8); int valid_count1; __m512i vec1 = expand_and_identify(lane1, lane2, valid_count1); - if(valid_count0 + valid_count1 <= 16) { - vec0 = _mm512_mask_expand_epi32(vec0, __mmask16(((1< validating_utf8_to_fixed_length(const char* str, const __m512i lane3 = broadcast_epi128<3>(utf8); SIMDUTF_ICELAKE_TRANSCODE16(lane2, lane3, true) - ptr += 3*16; + ptr += 3 * 16; } - validatedptr += 4*16; + validatedptr += 4 * 16; } { - const __m512i utf8 = _mm512_maskz_loadu_epi8((1ULL<<(end - validatedptr))-1, (const __m512i*)validatedptr); - checker.check_next_input(utf8); + const __m512i utf8 = _mm512_maskz_loadu_epi8((1ULL << (end - validatedptr)) - 1, (const __m512i*)validatedptr); + checker.check_next_input(utf8); } checker.check_eof(); - if(checker.errors()) { - return {ptr, nullptr}; // We found an error. + if (checker.errors()) { + return { ptr, nullptr }; // We found an error. } - return {ptr, output}; + return { ptr, output }; } // Like validating_utf8_to_fixed_length but returns as soon as an error is identified -template -std::tuple validating_utf8_to_fixed_length_with_constant_checks(const char* str, size_t len, OUTPUT* dwords) { +template +std::tuple validating_utf8_to_fixed_length_with_constant_checks(const char* str, size_t len, OUTPUT* dwords) +{ constexpr bool UTF32 = std::is_same::value; constexpr bool UTF16 = std::is_same::value; static_assert(UTF32 or UTF16, "output type has to be uint32_t (for UTF-32) or char16_t (for UTF-16)"); @@ -16973,17 +19718,16 @@ std::tuple validating_utf8_to_fixed_length_with_cons const char* ptr = str; const char* end = ptr + len; __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); OUTPUT* output = dwords; - avx512_utf8_checker checker{}; + avx512_utf8_checker checker {}; /** * In the main loop, we consume 64 bytes per iteration, * but we access 64 + 4 bytes. @@ -16992,14 +19736,14 @@ std::tuple validating_utf8_to_fixed_length_with_cons */ while (ptr + 64 + 64 <= end) { const __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); - if(checker.check_next_input(utf8)) { + if (checker.check_next_input(utf8)) { SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output) output += 64; ptr += 64; continue; } - if(checker.errors()) { - return {ptr, output, false}; // We found an error. + if (checker.errors()) { + return { ptr, output, false }; // We found an error. } const __m512i lane0 = broadcast_epi128<0>(utf8); const __m512i lane1 = broadcast_epi128<1>(utf8); @@ -17008,8 +19752,8 @@ std::tuple validating_utf8_to_fixed_length_with_cons const __m512i lane2 = broadcast_epi128<2>(utf8); int valid_count1; __m512i vec1 = expand_and_identify(lane1, lane2, valid_count1); - if(valid_count0 + valid_count1 <= 16) { - vec0 = _mm512_mask_expand_epi32(vec0, __mmask16(((1< validating_utf8_to_fixed_length_with_cons const __m512i lane4 = _mm512_set1_epi32(tmp1); int valid_count3; __m512i vec3 = expand_and_identify(lane3, lane4, valid_count3); - if(valid_count2 + valid_count3 <= 16) { - vec2 = _mm512_mask_expand_epi32(vec2, __mmask16(((1< validating_utf8_to_fixed_length_with_cons SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, false) SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec3, valid_count3, false) } - ptr += 4*16; + ptr += 4 * 16; } const char* validatedptr = ptr; // validated up to ptr @@ -17046,12 +19790,12 @@ std::tuple validating_utf8_to_fixed_length_with_cons // 3*16 bytes, so we may end up double-validating 16 bytes. if (ptr + 64 <= end) { const __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); - if(checker.check_next_input(utf8)) { + if (checker.check_next_input(utf8)) { SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output) output += 64; ptr += 64; - } else if(checker.errors()) { - return {ptr, output, false}; // We found an error. + } else if (checker.errors()) { + return { ptr, output, false }; // We found an error. } else { const __m512i lane0 = broadcast_epi128<0>(utf8); const __m512i lane1 = broadcast_epi128<1>(utf8); @@ -17060,8 +19804,8 @@ std::tuple validating_utf8_to_fixed_length_with_cons const __m512i lane2 = broadcast_epi128<2>(utf8); int valid_count1; __m512i vec1 = expand_and_identify(lane1, lane2, valid_count1); - if(valid_count0 + valid_count1 <= 16) { - vec0 = _mm512_mask_expand_epi32(vec0, __mmask16(((1< validating_utf8_to_fixed_length_with_cons const __m512i lane3 = broadcast_epi128<3>(utf8); SIMDUTF_ICELAKE_TRANSCODE16(lane2, lane3, true) - ptr += 3*16; + ptr += 3 * 16; } - validatedptr += 4*16; + validatedptr += 4 * 16; } { - const __m512i utf8 = _mm512_maskz_loadu_epi8((1ULL<<(end - validatedptr))-1, (const __m512i*)validatedptr); - checker.check_next_input(utf8); + const __m512i utf8 = _mm512_maskz_loadu_epi8((1ULL << (end - validatedptr)) - 1, (const __m512i*)validatedptr); + checker.check_next_input(utf8); } checker.check_eof(); - if(checker.errors()) { - return {ptr, output, false}; // We found an error. + if (checker.errors()) { + return { ptr, output, false }; // We found an error. } - return {ptr, output, true}; + return { ptr, output, true }; } /* end file src/icelake/icelake_from_utf8.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_convert_utf16_to_utf32.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_convert_utf16_to_utf32.inl.cpp /* begin file src/icelake/icelake_convert_utf16_to_utf32.inl.cpp */ // file included directly @@ -17098,755 +19842,786 @@ std::tuple validating_utf8_to_fixed_length_with_cons Returns a pair: the first unprocessed byte from buf and utf32_output A scalar routing should carry on the conversion of the tail. */ -template -std::tuple convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) { - const char16_t* end = buf + len; - const __m512i v_fc00 = _mm512_set1_epi16((uint16_t)0xfc00); - const __m512i v_d800 = _mm512_set1_epi16((uint16_t)0xd800); - const __m512i v_dc00 = _mm512_set1_epi16((uint16_t)0xdc00); - __mmask32 carry{0}; - const __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); - while (buf + 32 <= end) { - // Always safe because buf + 32 <= end so that end - buf >= 32 bytes: - __m512i in = _mm512_loadu_si512((__m512i*)buf); - if(big_endian) { in = _mm512_shuffle_epi8(in, byteflip); } - - // H - bitmask for high surrogates - const __mmask32 H = _mm512_cmpeq_epi16_mask(_mm512_and_si512(in, v_fc00), v_d800); - // H - bitmask for low surrogates - const __mmask32 L = _mm512_cmpeq_epi16_mask(_mm512_and_si512(in, v_fc00), v_dc00); - - if ((H|L)) { - // surrogate pair(s) in a register - const __mmask32 V = (L ^ (carry | (H << 1))); // A high surrogate must be followed by low one and a low one must be preceded by a high one. - // If valid, V should be equal to 0 - - if(V == 0) { - // valid case - /* - Input surrogate pair: - |1101.11aa.aaaa.aaaa|1101.10bb.bbbb.bbbb| - low surrogate high surrogate - */ - /* 1. Expand all words to 32-bit words - in |0000.0000.0000.0000.1101.11aa.aaaa.aaaa|0000.0000.0000.0000.1101.10bb.bbbb.bbbb| - */ - const __m512i first = _mm512_cvtepu16_epi32(_mm512_castsi512_si256(in)); - const __m512i second = _mm512_cvtepu16_epi32(_mm512_extracti32x8_epi32(in,1)); - - /* 2. Shift by one 16-bit word to align low surrogates with high surrogates - in |0000.0000.0000.0000.1101.11aa.aaaa.aaaa|0000.0000.0000.0000.1101.10bb.bbbb.bbbb| - shifted |????.????.????.????.????.????.????.????|0000.0000.0000.0000.1101.11aa.aaaa.aaaa| - */ - const __m512i shifted_first = _mm512_alignr_epi32(second, first, 1); - const __m512i shifted_second = _mm512_alignr_epi32(_mm512_setzero_si512(), second, 1); - - /* 3. Align all high surrogates in first and second by shifting to the left by 10 bits - |0000.0000.0000.0000.1101.11aa.aaaa.aaaa|0000.0011.0110.bbbb.bbbb.bb00.0000.0000| - */ - const __m512i aligned_first = _mm512_mask_slli_epi32(first, (__mmask16)H, first, 10); - const __m512i aligned_second = _mm512_mask_slli_epi32(second, (__mmask16)(H>>16), second, 10); - - /* 4. Remove surrogate prefixes and add offset 0x10000 by adding in, shifted and constant - in |0000.0000.0000.0000.1101.11aa.aaaa.aaaa|0000.0011.0110.bbbb.bbbb.bb00.0000.0000| - shifted |????.????.????.????.????.????.????.????|0000.0000.0000.0000.1101.11aa.aaaa.aaaa| - constant|1111.1100.1010.0000.0010.0100.0000.0000|1111.1100.1010.0000.0010.0100.0000.0000| - */ - const __m512i constant = _mm512_set1_epi32((uint32_t)0xfca02400); - const __m512i added_first = _mm512_mask_add_epi32(aligned_first, (__mmask16)H, aligned_first, shifted_first); - const __m512i utf32_first = _mm512_mask_add_epi32(added_first, (__mmask16)H, added_first, constant); - - const __m512i added_second = _mm512_mask_add_epi32(aligned_second, (__mmask16)(H>>16), aligned_second, shifted_second); - const __m512i utf32_second = _mm512_mask_add_epi32(added_second, (__mmask16)(H>>16), added_second, constant); - - // 5. Store all valid UTF-32 words (low surrogate positions and 32nd word are invalid) - const __mmask32 valid = ~L & 0x7fffffff; - // We deliberately do a _mm512_maskz_compress_epi32 followed by storeu_epi32 - // to ease performance portability to Zen 4. - const __m512i compressed_first = _mm512_maskz_compress_epi32((__mmask16)(valid), utf32_first); - const size_t howmany1 = count_ones((uint16_t)(valid)); - _mm512_storeu_si512((__m512i *) utf32_output, compressed_first); - utf32_output += howmany1; - const __m512i compressed_second = _mm512_maskz_compress_epi32((__mmask16)(valid >> 16), utf32_second); - const size_t howmany2 = count_ones((uint16_t)(valid >> 16)); - // The following could be unsafe in some cases? - //_mm512_storeu_epi32((__m512i *) utf32_output, compressed_second); - _mm512_mask_storeu_epi32((__m512i *) utf32_output, __mmask16((1<> 30) & 0x1; - } else { - // invalid case - return std::make_tuple(buf+carry, utf32_output, false); - } - } else { - // no surrogates - // extend all thirty-two 16-bit words to thirty-two 32-bit words - _mm512_storeu_si512((__m512i *)(utf32_output), _mm512_cvtepu16_epi32(_mm512_castsi512_si256(in))); - _mm512_storeu_si512((__m512i *)(utf32_output) + 1, _mm512_cvtepu16_epi32(_mm512_extracti32x8_epi32(in,1))); - utf32_output += 32; - buf += 32; - carry = 0; - } - } // while - return std::make_tuple(buf+carry, utf32_output, true); +template +std::tuple convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) +{ + const char16_t* end = buf + len; + const __m512i v_fc00 = _mm512_set1_epi16((uint16_t)0xfc00); + const __m512i v_d800 = _mm512_set1_epi16((uint16_t)0xd800); + const __m512i v_dc00 = _mm512_set1_epi16((uint16_t)0xdc00); + __mmask32 carry { 0 }; + const __m512i byteflip = _mm512_setr_epi64( + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); + while (buf + 32 <= end) { + // Always safe because buf + 32 <= end so that end - buf >= 32 bytes: + __m512i in = _mm512_loadu_si512((__m512i*)buf); + if (big_endian) { + in = _mm512_shuffle_epi8(in, byteflip); + } + + // H - bitmask for high surrogates + const __mmask32 H = _mm512_cmpeq_epi16_mask(_mm512_and_si512(in, v_fc00), v_d800); + // H - bitmask for low surrogates + const __mmask32 L = _mm512_cmpeq_epi16_mask(_mm512_and_si512(in, v_fc00), v_dc00); + + if ((H | L)) { + // surrogate pair(s) in a register + const __mmask32 V = (L ^ (carry | (H << 1))); // A high surrogate must be followed by low one and a low one must be preceded by a high one. + // If valid, V should be equal to 0 + + if (V == 0) { + // valid case + /* + Input surrogate pair: + |1101.11aa.aaaa.aaaa|1101.10bb.bbbb.bbbb| + low surrogate high surrogate + */ + /* 1. Expand all words to 32-bit words + in |0000.0000.0000.0000.1101.11aa.aaaa.aaaa|0000.0000.0000.0000.1101.10bb.bbbb.bbbb| + */ + const __m512i first = _mm512_cvtepu16_epi32(_mm512_castsi512_si256(in)); + const __m512i second = _mm512_cvtepu16_epi32(_mm512_extracti32x8_epi32(in, 1)); + + /* 2. Shift by one 16-bit word to align low surrogates with high surrogates + in |0000.0000.0000.0000.1101.11aa.aaaa.aaaa|0000.0000.0000.0000.1101.10bb.bbbb.bbbb| + shifted |????.????.????.????.????.????.????.????|0000.0000.0000.0000.1101.11aa.aaaa.aaaa| + */ + const __m512i shifted_first = _mm512_alignr_epi32(second, first, 1); + const __m512i shifted_second = _mm512_alignr_epi32(_mm512_setzero_si512(), second, 1); + + /* 3. Align all high surrogates in first and second by shifting to the left by 10 bits + |0000.0000.0000.0000.1101.11aa.aaaa.aaaa|0000.0011.0110.bbbb.bbbb.bb00.0000.0000| + */ + const __m512i aligned_first = _mm512_mask_slli_epi32(first, (__mmask16)H, first, 10); + const __m512i aligned_second = _mm512_mask_slli_epi32(second, (__mmask16)(H >> 16), second, 10); + + /* 4. Remove surrogate prefixes and add offset 0x10000 by adding in, shifted and constant + in |0000.0000.0000.0000.1101.11aa.aaaa.aaaa|0000.0011.0110.bbbb.bbbb.bb00.0000.0000| + shifted |????.????.????.????.????.????.????.????|0000.0000.0000.0000.1101.11aa.aaaa.aaaa| + constant|1111.1100.1010.0000.0010.0100.0000.0000|1111.1100.1010.0000.0010.0100.0000.0000| + */ + const __m512i constant = _mm512_set1_epi32((uint32_t)0xfca02400); + const __m512i added_first = _mm512_mask_add_epi32(aligned_first, (__mmask16)H, aligned_first, shifted_first); + const __m512i utf32_first = _mm512_mask_add_epi32(added_first, (__mmask16)H, added_first, constant); + + const __m512i added_second = _mm512_mask_add_epi32(aligned_second, (__mmask16)(H >> 16), aligned_second, shifted_second); + const __m512i utf32_second = _mm512_mask_add_epi32(added_second, (__mmask16)(H >> 16), added_second, constant); + + // 5. Store all valid UTF-32 words (low surrogate positions and 32nd word are invalid) + const __mmask32 valid = ~L & 0x7fffffff; + // We deliberately do a _mm512_maskz_compress_epi32 followed by storeu_epi32 + // to ease performance portability to Zen 4. + const __m512i compressed_first = _mm512_maskz_compress_epi32((__mmask16)(valid), utf32_first); + const size_t howmany1 = count_ones((uint16_t)(valid)); + _mm512_storeu_si512((__m512i*)utf32_output, compressed_first); + utf32_output += howmany1; + const __m512i compressed_second = _mm512_maskz_compress_epi32((__mmask16)(valid >> 16), utf32_second); + const size_t howmany2 = count_ones((uint16_t)(valid >> 16)); + // The following could be unsafe in some cases? + //_mm512_storeu_epi32((__m512i *) utf32_output, compressed_second); + _mm512_mask_storeu_epi32((__m512i*)utf32_output, __mmask16((1 << howmany2) - 1), compressed_second); + utf32_output += howmany2; + // Only process 31 words, but keep track if the 31st word is a high surrogate as a carry + buf += 31; + carry = (H >> 30) & 0x1; + } else { + // invalid case + return std::make_tuple(buf + carry, utf32_output, false); + } + } else { + // no surrogates + // extend all thirty-two 16-bit words to thirty-two 32-bit words + _mm512_storeu_si512((__m512i*)(utf32_output), _mm512_cvtepu16_epi32(_mm512_castsi512_si256(in))); + _mm512_storeu_si512((__m512i*)(utf32_output) + 1, _mm512_cvtepu16_epi32(_mm512_extracti32x8_epi32(in, 1))); + utf32_output += 32; + buf += 32; + carry = 0; + } + } // while + return std::make_tuple(buf + carry, utf32_output, true); } /* end file src/icelake/icelake_convert_utf16_to_utf32.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_convert_utf32_to_utf8.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_convert_utf32_to_utf8.inl.cpp /* begin file src/icelake/icelake_convert_utf32_to_utf8.inl.cpp */ // file included directly // Todo: currently, this is just the haswell code, optimize for icelake kernel. -std::pair avx512_convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) { - const char32_t* end = buf + len; - const __m256i v_0000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); - const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80); - const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800); - const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080); - const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff); - __m256i running_max = _mm256_setzero_si256(); - __m256i forbidden_bytemask = _mm256_setzero_si256(); - - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); - __m256i nextin = _mm256_loadu_si256((__m256i*)buf+1); - running_max = _mm256_max_epu32(_mm256_max_epu32(in, running_max), nextin); - - // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation - __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff), _mm256_and_si256(nextin, v_7fffffff)); - in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000); - - // Try to apply UTF-16 => UTF-8 routine on 256 bits (haswell/avx2_convert_utf16_to_utf8.cpp) - - if(_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!! - // 1. pack the bytes - const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in_16),_mm256_extractf128_si256(in_16,1)); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - // no bits set above 7th bit - const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000); - const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000); - const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); - if (one_or_two_bytes_bitmask == 0xffffffff) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); - const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m256i t0 = _mm256_slli_epi16(in_16, 2); - // t1 = [000a|aaaa|0000|0000] - const __m256i t1 = _mm256_and_si256(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m256i t2 = _mm256_and_si256(in_16, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m256i t3 = _mm256_or_si256(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m256i t4 = _mm256_or_si256(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in_16, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - const uint32_t M0 = one_byte_bitmask & 0x55555555; - const uint32_t M1 = M0 >> 7; - const uint32_t M2 = (M1 | M0) & 0x00ff00ff; - // 4. pack the bytes - - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; - const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2>>16)][0]; - - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); - - const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle,shuffle_2)); - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); - utf8_output += row[0]; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed,1)); - utf8_output += row_2[0]; - - // 6. adjust pointers - buf += 16; - continue; - } - // Must check for overflow in packing - const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000); - const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); - if (saturation_bitmask == 0xffffffff) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800); - forbidden_bytemask = _mm256_or_si256(forbidden_bytemask, _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800)); - - const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, - 0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm256_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m256i t1 = _mm256_and_si256(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m256i t2 = _mm256_or_si256 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m256i s0 = _mm256_srli_epi16(in_16, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m256i s1 = _mm256_and_si256(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m256i s2 = _mm256_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m256i s3 = _mm256_or_si256(s2, vec(0b1100000011100000)); - const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m256i s4 = _mm256_xor_si256(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); - const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint32_t mask = (one_byte_bitmask & 0x55555555) | - (one_or_two_bytes_bitmask & 0xaaaaaaaa); - // Due to the wider registers, the following path is less likely to be useful. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); - const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); - utf8_output += 12; - buf += 16; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); - - const uint8_t mask2 = static_cast(mask >> 16); - const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; - const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); - const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0,1), shuffle2); - - - const uint8_t mask3 = static_cast(mask >> 24); - const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; - const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); - const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1,1), shuffle3); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_2); - utf8_output += row2[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_3); - utf8_output += row3[0]; - buf += 16; - } else { - // case: at least one 32-bit word is larger than 0xFFFF <=> it will produce four UTF-8 bytes. - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // may require large, non-trivial tables? - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFFFF80)==0) { // 1-byte (ASCII) - *utf8_output++ = char(word); - } else if((word & 0xFFFFF800)==0) { // 2-byte - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word & 0xFFFF0000 )==0) { // 3-byte - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(nullptr, utf8_output); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else { // 4-byte - if (word > 0x10FFFF) { return std::make_pair(nullptr, utf8_output); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } - } - buf += k; - } - } // while - - // check for invalid input - const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff); - if(static_cast(_mm256_movemask_epi8(_mm256_cmpeq_epi32(_mm256_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffffffff) { - return std::make_pair(nullptr, utf8_output); - } - - if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0) { return std::make_pair(nullptr, utf8_output); } - - return std::make_pair(buf, utf8_output); +std::pair avx512_convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) +{ + const char32_t* end = buf + len; + const __m256i v_0000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); + const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80); + const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800); + const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080); + const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff); + __m256i running_max = _mm256_setzero_si256(); + __m256i forbidden_bytemask = _mm256_setzero_si256(); + + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); + __m256i nextin = _mm256_loadu_si256((__m256i*)buf + 1); + running_max = _mm256_max_epu32(_mm256_max_epu32(in, running_max), nextin); + + // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation + __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff), _mm256_and_si256(nextin, v_7fffffff)); + in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000); + + // Try to apply UTF-16 => UTF-8 routine on 256 bits (haswell/avx2_convert_utf16_to_utf8.cpp) + + if (_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!! + // 1. pack the bytes + const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in_16), _mm256_extractf128_si256(in_16, 1)); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + // no bits set above 7th bit + const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000); + const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000); + const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); + if (one_or_two_bytes_bitmask == 0xffffffff) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); + const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m256i t0 = _mm256_slli_epi16(in_16, 2); + // t1 = [000a|aaaa|0000|0000] + const __m256i t1 = _mm256_and_si256(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m256i t2 = _mm256_and_si256(in_16, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m256i t3 = _mm256_or_si256(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m256i t4 = _mm256_or_si256(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in_16, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + const uint32_t M0 = one_byte_bitmask & 0x55555555; + const uint32_t M1 = M0 >> 7; + const uint32_t M2 = (M1 | M0) & 0x00ff00ff; + // 4. pack the bytes + + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; + const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >> 16)][0]; + + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); + + const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2)); + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); + utf8_output += row[0]; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed, 1)); + utf8_output += row_2[0]; + + // 6. adjust pointers + buf += 16; + continue; + } + // Must check for overflow in packing + const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000); + const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); + if (saturation_bitmask == 0xffffffff) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800); + forbidden_bytemask = _mm256_or_si256(forbidden_bytemask, _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800)); + + const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, + 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm256_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m256i s0 = _mm256_srli_epi16(in_16, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000)); + const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m256i s4 = _mm256_xor_si256(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); + const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint32_t mask = (one_byte_bitmask & 0x55555555) | (one_or_two_bytes_bitmask & 0xaaaaaaaa); + // Due to the wider registers, the following path is less likely to be useful. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); + const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); + const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); + utf8_output += 12; + buf += 16; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); + + const uint8_t mask2 = static_cast(mask >> 16); + const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; + const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); + const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2); + + const uint8_t mask3 = static_cast(mask >> 24); + const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; + const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); + const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_2); + utf8_output += row2[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_3); + utf8_output += row3[0]; + buf += 16; + } else { + // case: at least one 32-bit word is larger than 0xFFFF <=> it will produce four UTF-8 bytes. + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // may require large, non-trivial tables? + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFFFF80) == 0) { // 1-byte (ASCII) + *utf8_output++ = char(word); + } else if ((word & 0xFFFFF800) == 0) { // 2-byte + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xFFFF0000) == 0) { // 3-byte + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(nullptr, utf8_output); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { // 4-byte + if (word > 0x10FFFF) { + return std::make_pair(nullptr, utf8_output); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while + + // check for invalid input + const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff); + if (static_cast(_mm256_movemask_epi8(_mm256_cmpeq_epi32(_mm256_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffffffff) { + return std::make_pair(nullptr, utf8_output); + } + + if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0) { + return std::make_pair(nullptr, utf8_output); + } + + return std::make_pair(buf, utf8_output); } // Todo: currently, this is just the haswell code, optimize for icelake kernel. -std::pair avx512_convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) { - const char32_t* end = buf + len; - const char32_t* start = buf; - - const __m256i v_0000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); - const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80); - const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800); - const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080); - const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff); - const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff); - - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); - __m256i nextin = _mm256_loadu_si256((__m256i*)buf+1); - // Check for too large input - const __m256i max_input = _mm256_max_epu32(_mm256_max_epu32(in, nextin), v_10ffff); - if(static_cast(_mm256_movemask_epi8(_mm256_cmpeq_epi32(max_input, v_10ffff))) != 0xffffffff) { - return std::make_pair(result(error_code::TOO_LARGE, buf - start), utf8_output); - } - - // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation - __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff), _mm256_and_si256(nextin, v_7fffffff)); - in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000); - - // Try to apply UTF-16 => UTF-8 routine on 256 bits (haswell/avx2_convert_utf16_to_utf8.cpp) - - if(_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!! - // 1. pack the bytes - const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in_16),_mm256_extractf128_si256(in_16,1)); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - // no bits set above 7th bit - const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000); - const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000); - const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); - if (one_or_two_bytes_bitmask == 0xffffffff) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); - const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m256i t0 = _mm256_slli_epi16(in_16, 2); - // t1 = [000a|aaaa|0000|0000] - const __m256i t1 = _mm256_and_si256(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m256i t2 = _mm256_and_si256(in_16, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m256i t3 = _mm256_or_si256(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m256i t4 = _mm256_or_si256(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in_16, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - const uint32_t M0 = one_byte_bitmask & 0x55555555; - const uint32_t M1 = M0 >> 7; - const uint32_t M2 = (M1 | M0) & 0x00ff00ff; - // 4. pack the bytes - - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; - const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2>>16)][0]; - - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); - - const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle,shuffle_2)); - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); - utf8_output += row[0]; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed,1)); - utf8_output += row_2[0]; - - // 6. adjust pointers - buf += 16; - continue; - } - // Must check for overflow in packing - const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000); - const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); - if (saturation_bitmask == 0xffffffff) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - - // Check for illegal surrogate words - const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800); - const __m256i forbidden_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800); - if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0x0) { - return std::make_pair(result(error_code::SURROGATE, buf - start), utf8_output); - } - - const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, - 0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm256_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m256i t1 = _mm256_and_si256(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m256i t2 = _mm256_or_si256 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m256i s0 = _mm256_srli_epi16(in_16, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m256i s1 = _mm256_and_si256(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m256i s2 = _mm256_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m256i s3 = _mm256_or_si256(s2, vec(0b1100000011100000)); - const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m256i s4 = _mm256_xor_si256(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); - const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint32_t mask = (one_byte_bitmask & 0x55555555) | - (one_or_two_bytes_bitmask & 0xaaaaaaaa); - // Due to the wider registers, the following path is less likely to be useful. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); - const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); - utf8_output += 12; - buf += 16; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); - - const uint8_t mask2 = static_cast(mask >> 16); - const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; - const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); - const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0,1), shuffle2); - - - const uint8_t mask3 = static_cast(mask >> 24); - const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; - const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); - const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1,1), shuffle3); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_2); - utf8_output += row2[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_3); - utf8_output += row3[0]; - buf += 16; - } else { - // case: at least one 32-bit word is larger than 0xFFFF <=> it will produce four UTF-8 bytes. - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // may require large, non-trivial tables? - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFFFF80)==0) { // 1-byte (ASCII) - *utf8_output++ = char(word); - } else if((word & 0xFFFFF800)==0) { // 2-byte - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word & 0xFFFF0000 )==0) { // 3-byte - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf8_output); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else { // 4-byte - if (word > 0x10FFFF) { return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf8_output); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } - } - buf += k; - } - } // while - - return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); +std::pair avx512_convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) +{ + const char32_t* end = buf + len; + const char32_t* start = buf; + + const __m256i v_0000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); + const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80); + const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800); + const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080); + const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff); + const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff); + + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); + __m256i nextin = _mm256_loadu_si256((__m256i*)buf + 1); + // Check for too large input + const __m256i max_input = _mm256_max_epu32(_mm256_max_epu32(in, nextin), v_10ffff); + if (static_cast(_mm256_movemask_epi8(_mm256_cmpeq_epi32(max_input, v_10ffff))) != 0xffffffff) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start), utf8_output); + } + + // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation + __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff), _mm256_and_si256(nextin, v_7fffffff)); + in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000); + + // Try to apply UTF-16 => UTF-8 routine on 256 bits (haswell/avx2_convert_utf16_to_utf8.cpp) + + if (_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!! + // 1. pack the bytes + const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in_16), _mm256_extractf128_si256(in_16, 1)); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + // no bits set above 7th bit + const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000); + const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000); + const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); + if (one_or_two_bytes_bitmask == 0xffffffff) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); + const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m256i t0 = _mm256_slli_epi16(in_16, 2); + // t1 = [000a|aaaa|0000|0000] + const __m256i t1 = _mm256_and_si256(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m256i t2 = _mm256_and_si256(in_16, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m256i t3 = _mm256_or_si256(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m256i t4 = _mm256_or_si256(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in_16, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + const uint32_t M0 = one_byte_bitmask & 0x55555555; + const uint32_t M1 = M0 >> 7; + const uint32_t M2 = (M1 | M0) & 0x00ff00ff; + // 4. pack the bytes + + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; + const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >> 16)][0]; + + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); + + const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2)); + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); + utf8_output += row[0]; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed, 1)); + utf8_output += row_2[0]; + + // 6. adjust pointers + buf += 16; + continue; + } + // Must check for overflow in packing + const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000); + const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); + if (saturation_bitmask == 0xffffffff) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + + // Check for illegal surrogate words + const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800); + const __m256i forbidden_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800); + if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0x0) { + return std::make_pair(result(error_code::SURROGATE, buf - start), utf8_output); + } + + const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, + 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm256_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m256i s0 = _mm256_srli_epi16(in_16, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000)); + const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m256i s4 = _mm256_xor_si256(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); + const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint32_t mask = (one_byte_bitmask & 0x55555555) | (one_or_two_bytes_bitmask & 0xaaaaaaaa); + // Due to the wider registers, the following path is less likely to be useful. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); + const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); + const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); + utf8_output += 12; + buf += 16; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); + + const uint8_t mask2 = static_cast(mask >> 16); + const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; + const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); + const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2); + + const uint8_t mask3 = static_cast(mask >> 24); + const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; + const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); + const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_2); + utf8_output += row2[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_3); + utf8_output += row3[0]; + buf += 16; + } else { + // case: at least one 32-bit word is larger than 0xFFFF <=> it will produce four UTF-8 bytes. + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // may require large, non-trivial tables? + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFFFF80) == 0) { // 1-byte (ASCII) + *utf8_output++ = char(word); + } else if ((word & 0xFFFFF800) == 0) { // 2-byte + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xFFFF0000) == 0) { // 3-byte + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf8_output); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { // 4-byte + if (word > 0x10FFFF) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf8_output); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while + + return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); } /* end file src/icelake/icelake_convert_utf32_to_utf8.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_convert_utf32_to_utf16.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_convert_utf32_to_utf16.inl.cpp /* begin file src/icelake/icelake_convert_utf32_to_utf16.inl.cpp */ // file included directly // Todo: currently, this is just the haswell code, optimize for icelake kernel. -template -std::pair avx512_convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_output) { - const char32_t* end = buf + len; - - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - __m256i forbidden_bytemask = _mm256_setzero_si256(); +template +std::pair avx512_convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + const char32_t* end = buf + len; + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + __m256i forbidden_bytemask = _mm256_setzero_si256(); - while (buf + 8 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); + while (buf + 8 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); - const __m256i v_00000000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000); + const __m256i v_00000000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000); - // no bits set above 16th bit <=> can pack to UTF16 without surrogate pairs - const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); - const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); + // no bits set above 16th bit <=> can pack to UTF16 without surrogate pairs + const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); + const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); - if (saturation_bitmask == 0xffffffff) { - const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800); - const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800); - forbidden_bytemask = _mm256_or_si256(forbidden_bytemask, _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800)); + if (saturation_bitmask == 0xffffffff) { + const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800); + const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800); + forbidden_bytemask = _mm256_or_si256(forbidden_bytemask, _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800)); - __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),_mm256_extractf128_si256(in,1)); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); - } - _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); - utf16_output += 8; - buf += 8; - } else { - size_t forward = 7; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(nullptr, utf16_output); } - *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1)); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); + } + _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); + utf16_output += 8; + buf += 8; } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return std::make_pair(nullptr, utf16_output); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (big_endian) { - high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); - low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); + size_t forward = 7; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(nullptr, utf16_output); + } + *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return std::make_pair(nullptr, utf16_output); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (big_endian) { + high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); + low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + } + buf += k; } - } - buf += k; } - } - // check for invalid input - if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0) { return std::make_pair(nullptr, utf16_output); } + // check for invalid input + if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0) { + return std::make_pair(nullptr, utf16_output); + } - return std::make_pair(buf, utf16_output); + return std::make_pair(buf, utf16_output); } // Todo: currently, this is just the haswell code, optimize for icelake kernel. -template -std::pair avx512_convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) { - const char32_t* start = buf; - const char32_t* end = buf + len; +template +std::pair avx512_convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + const char32_t* start = buf; + const char32_t* end = buf + len; - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - while (buf + 8 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); + while (buf + 8 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); - const __m256i v_00000000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000); - - // no bits set above 16th bit <=> can pack to UTF16 without surrogate pairs - const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); - const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); - - if (saturation_bitmask == 0xffffffff) { - const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800); - const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800); - const __m256i forbidden_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800); - if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0x0) { - return std::make_pair(result(error_code::SURROGATE, buf - start), utf16_output); - } - - __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),_mm256_extractf128_si256(in,1)); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); - } - _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); - utf16_output += 8; - buf += 8; - } else { - size_t forward = 7; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf16_output); } - *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + const __m256i v_00000000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000); + + // no bits set above 16th bit <=> can pack to UTF16 without surrogate pairs + const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); + const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); + + if (saturation_bitmask == 0xffffffff) { + const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800); + const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800); + const __m256i forbidden_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800); + if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0x0) { + return std::make_pair(result(error_code::SURROGATE, buf - start), utf16_output); + } + + __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1)); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); + } + _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); + utf16_output += 8; + buf += 8; } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf16_output); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (big_endian) { - high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); - low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); + size_t forward = 7; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf16_output); + } + *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf16_output); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (big_endian) { + high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); + low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + } + buf += k; } - } - buf += k; } - } - return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output); + return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output); } /* end file src/icelake/icelake_convert_utf32_to_utf16.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_ascii_validation.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_ascii_validation.inl.cpp /* begin file src/icelake/icelake_ascii_validation.inl.cpp */ // file included directly -bool validate_ascii(const char* buf, size_t len) { - const char* end = buf + len; - const __m512i ascii = _mm512_set1_epi8((uint8_t)0x80); - __m512i running_or = _mm512_setzero_si512(); - for (; buf + 64 <= end; buf += 64) { - const __m512i utf8 = _mm512_loadu_si512((const __m512i*)buf); - running_or = _mm512_ternarylogic_epi32(running_or, utf8, ascii, 0xf8); // running_or | (utf8 & ascii) - } - if(buf < end) { - const __m512i utf8 = _mm512_maskz_loadu_epi8((uint64_t(1) << (end-buf)) - 1,(const __m512i*)buf); - running_or = _mm512_ternarylogic_epi32(running_or, utf8, ascii, 0xf8); // running_or | (utf8 & ascii) - } - return (_mm512_test_epi8_mask(running_or, running_or) == 0); +bool validate_ascii(const char* buf, size_t len) +{ + const char* end = buf + len; + const __m512i ascii = _mm512_set1_epi8((uint8_t)0x80); + __m512i running_or = _mm512_setzero_si512(); + for (; buf + 64 <= end; buf += 64) { + const __m512i utf8 = _mm512_loadu_si512((const __m512i*)buf); + running_or = _mm512_ternarylogic_epi32(running_or, utf8, ascii, 0xf8); // running_or | (utf8 & ascii) + } + if (buf < end) { + const __m512i utf8 = _mm512_maskz_loadu_epi8((uint64_t(1) << (end - buf)) - 1, (const __m512i*)buf); + running_or = _mm512_ternarylogic_epi32(running_or, utf8, ascii, 0xf8); // running_or | (utf8 & ascii) + } + return (_mm512_test_epi8_mask(running_or, running_or) == 0); } /* end file src/icelake/icelake_ascii_validation.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_utf32_validation.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_utf32_validation.inl.cpp /* begin file src/icelake/icelake_utf32_validation.inl.cpp */ // file included directly -const char32_t* validate_utf32(const char32_t* buf, size_t len) { +const char32_t* validate_utf32(const char32_t* buf, size_t len) +{ const char32_t* end = len >= 16 ? buf + len - 16 : nullptr; const __m512i offset = _mm512_set1_epi32((uint32_t)0xffff2000); @@ -17854,27 +20629,27 @@ const char32_t* validate_utf32(const char32_t* buf, size_t len) { __m512i currentoffsetmax = _mm512_setzero_si512(); while (buf <= end) { - __m512i utf32 = _mm512_loadu_si512((const __m512i*)buf); - buf += 16; - currentoffsetmax = _mm512_max_epu32(_mm512_add_epi32(utf32, offset), currentoffsetmax); - currentmax = _mm512_max_epu32(utf32, currentmax); + __m512i utf32 = _mm512_loadu_si512((const __m512i*)buf); + buf += 16; + currentoffsetmax = _mm512_max_epu32(_mm512_add_epi32(utf32, offset), currentoffsetmax); + currentmax = _mm512_max_epu32(utf32, currentmax); } const __m512i standardmax = _mm512_set1_epi32((uint32_t)0x10ffff); const __m512i standardoffsetmax = _mm512_set1_epi32((uint32_t)0xfffff7ff); __m512i is_zero = _mm512_xor_si512(_mm512_max_epu32(currentmax, standardmax), standardmax); if (_mm512_test_epi8_mask(is_zero, is_zero) != 0) { - return nullptr; + return nullptr; } is_zero = _mm512_xor_si512(_mm512_max_epu32(currentoffsetmax, standardoffsetmax), standardoffsetmax); if (_mm512_test_epi8_mask(is_zero, is_zero) != 0) { - return nullptr; + return nullptr; } return buf; } /* end file src/icelake/icelake_utf32_validation.inl.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=icelake/icelake_convert_utf16_to_utf8.inl.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=icelake/icelake_convert_utf16_to_utf8.inl.cpp /* begin file src/icelake/icelake_convert_utf16_to_utf8.inl.cpp */ // file included directly @@ -17884,194 +20659,188 @@ const char32_t* validate_utf32(const char32_t* buf, size_t len) { * is written to 'outlen' and the function reports the number of input word * consumed. */ -template -size_t utf16_to_utf8_avx512i(const char16_t *inbuf, size_t inlen, - unsigned char *outbuf, size_t *outlen) { - __m512i in; - __mmask32 inmask = _cvtu32_mask32(0x7fffffff); - __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); - const char16_t * const inbuf_orig = inbuf; - const unsigned char * const outbuf_orig = outbuf; - size_t adjust = 0; - int carry = 0; - - while (inlen >= 32) { - in = _mm512_loadu_si512(inbuf); - if(big_endian) { in = _mm512_shuffle_epi8(in, byteflip); } - inlen -= 31; - lastiteration: - inbuf += 31; - - failiteration: - const __mmask32 is234byte = _mm512_mask_cmp_epu16_mask( - inmask, in, _mm512_set1_epi16(0x0080), _MM_CMPINT_NLT); - - if (_ktestz_mask32_u8(inmask, is234byte)) { - // fast path for ASCII only - _mm512_mask_cvtepi16_storeu_epi8(outbuf, inmask, in); - outbuf += 31; - carry = 0; - - if (inlen < 32) { - goto tail; - } else { - continue; - } - } - - const __mmask32 is12byte = - _mm512_cmp_epu16_mask(in, _mm512_set1_epi16(0x0800), _MM_CMPINT_LT); - - if (_ktestc_mask32_u8(is12byte, inmask)) { - // fast path for 1 and 2 byte only - - const __m512i twobytes = _mm512_ternarylogic_epi32( - _mm512_slli_epi16(in, 8), _mm512_srli_epi16(in, 6), - _mm512_set1_epi16(0x3f3f), 0xa8); // (A|B)&C - in = _mm512_mask_add_epi16(in, is234byte, twobytes, - _mm512_set1_epi16(int16_t(0x80c0))); - const __m512i cmpmask = - _mm512_mask_blend_epi16(inmask, _mm512_set1_epi16(int16_t(0xffff)), - _mm512_set1_epi16(0x0800)); - const __mmask64 smoosh = _mm512_cmp_epu8_mask(in, cmpmask, _MM_CMPINT_NLT); - const __m512i out = _mm512_maskz_compress_epi8(smoosh, in); - _mm512_mask_storeu_epi8(outbuf, _cvtu64_mask64(_pext_u64(_cvtmask64_u64(smoosh), _cvtmask64_u64(smoosh))), - out); - outbuf += 31 + _mm_popcnt_u32(_cvtmask32_u32(is234byte)); - carry = 0; - - if (inlen < 32) { - goto tail; - } else { - continue; - } - } - __m512i lo = _mm512_cvtepu16_epi32(_mm512_castsi512_si256(in)); - __m512i hi = _mm512_cvtepu16_epi32(_mm512_extracti32x8_epi32(in, 1)); - - - __m512i taglo = _mm512_set1_epi32(0x8080e000); - __m512i taghi = taglo; - - const __m512i fc00masked = _mm512_and_epi32(in, _mm512_set1_epi16(int16_t(0xfc00))); - const __mmask32 hisurr = _mm512_mask_cmp_epu16_mask( - inmask, fc00masked, _mm512_set1_epi16(int16_t(0xd800)), _MM_CMPINT_EQ); - const __mmask32 losurr = _mm512_cmp_epu16_mask( - fc00masked, _mm512_set1_epi16(int16_t(0xdc00)), _MM_CMPINT_EQ); - - int carryout = 0; - if (!_kortestz_mask32_u8(hisurr, losurr)) { - // handle surrogates - - __m512i los = _mm512_alignr_epi32(hi, lo, 1); - __m512i his = _mm512_alignr_epi32(lo, hi, 1); - - const __mmask32 hisurrhi = _kshiftri_mask32(hisurr, 16); - taglo = - _mm512_mask_mov_epi32(taglo,__mmask16(hisurr), _mm512_set1_epi32(0x808080f0)); - taghi = - _mm512_mask_mov_epi32(taghi, __mmask16(hisurrhi), _mm512_set1_epi32(0x808080f0)); - - lo = _mm512_mask_slli_epi32(lo, __mmask16(hisurr), lo, 10); - hi = _mm512_mask_slli_epi32(hi, __mmask16(hisurrhi), hi, 10); - los = _mm512_add_epi32(los, _mm512_set1_epi32(0xfca02400)); - his = _mm512_add_epi32(his, _mm512_set1_epi32(0xfca02400)); - lo = _mm512_mask_add_epi32(lo, __mmask16(hisurr), lo, los); - hi = _mm512_mask_add_epi32(hi, __mmask16(hisurrhi), hi, his); - - carryout = _cvtu32_mask32(_kshiftri_mask32(hisurr, 30)); - - const uint32_t h = _cvtmask32_u32(hisurr); - const uint32_t l = _cvtmask32_u32(losurr); - // check for mismatched surrogates - if ((h + h + carry) ^ l) { - const uint32_t lonohi = l & ~(h + h + carry); - const uint32_t hinolo = h & ~(l >> 1); - inlen = _tzcnt_u32(hinolo | lonohi); - inmask = __mmask32(0x7fffffff & ((1 << inlen) - 1)); - in = _mm512_maskz_mov_epi16(inmask, in); - adjust = (int)inlen - 31; - inlen = 0; - goto failiteration; - } - } +template +size_t utf16_to_utf8_avx512i(const char16_t* inbuf, size_t inlen, + unsigned char* outbuf, size_t* outlen) +{ + __m512i in; + __mmask32 inmask = _cvtu32_mask32(0x7fffffff); + __m512i byteflip = _mm512_setr_epi64( + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); + const char16_t* const inbuf_orig = inbuf; + const unsigned char* const outbuf_orig = outbuf; + size_t adjust = 0; + int carry = 0; + + while (inlen >= 32) { + in = _mm512_loadu_si512(inbuf); + if (big_endian) { + in = _mm512_shuffle_epi8(in, byteflip); + } + inlen -= 31; + lastiteration: + inbuf += 31; + + failiteration: + const __mmask32 is234byte = _mm512_mask_cmp_epu16_mask( + inmask, in, _mm512_set1_epi16(0x0080), _MM_CMPINT_NLT); + + if (_ktestz_mask32_u8(inmask, is234byte)) { + // fast path for ASCII only + _mm512_mask_cvtepi16_storeu_epi8(outbuf, inmask, in); + outbuf += 31; + carry = 0; + + if (inlen < 32) { + goto tail; + } else { + continue; + } + } - hi = _mm512_maskz_mov_epi32(_cvtu32_mask16(0x7fff),hi); - carry = carryout; + const __mmask32 is12byte = _mm512_cmp_epu16_mask(in, _mm512_set1_epi16(0x0800), _MM_CMPINT_LT); + + if (_ktestc_mask32_u8(is12byte, inmask)) { + // fast path for 1 and 2 byte only + + const __m512i twobytes = _mm512_ternarylogic_epi32( + _mm512_slli_epi16(in, 8), _mm512_srli_epi16(in, 6), + _mm512_set1_epi16(0x3f3f), 0xa8); // (A|B)&C + in = _mm512_mask_add_epi16(in, is234byte, twobytes, + _mm512_set1_epi16(int16_t(0x80c0))); + const __m512i cmpmask = _mm512_mask_blend_epi16(inmask, _mm512_set1_epi16(int16_t(0xffff)), + _mm512_set1_epi16(0x0800)); + const __mmask64 smoosh = _mm512_cmp_epu8_mask(in, cmpmask, _MM_CMPINT_NLT); + const __m512i out = _mm512_maskz_compress_epi8(smoosh, in); + _mm512_mask_storeu_epi8(outbuf, _cvtu64_mask64(_pext_u64(_cvtmask64_u64(smoosh), _cvtmask64_u64(smoosh))), + out); + outbuf += 31 + _mm_popcnt_u32(_cvtmask32_u32(is234byte)); + carry = 0; + + if (inlen < 32) { + goto tail; + } else { + continue; + } + } + __m512i lo = _mm512_cvtepu16_epi32(_mm512_castsi512_si256(in)); + __m512i hi = _mm512_cvtepu16_epi32(_mm512_extracti32x8_epi32(in, 1)); + + __m512i taglo = _mm512_set1_epi32(0x8080e000); + __m512i taghi = taglo; + + const __m512i fc00masked = _mm512_and_epi32(in, _mm512_set1_epi16(int16_t(0xfc00))); + const __mmask32 hisurr = _mm512_mask_cmp_epu16_mask( + inmask, fc00masked, _mm512_set1_epi16(int16_t(0xd800)), _MM_CMPINT_EQ); + const __mmask32 losurr = _mm512_cmp_epu16_mask( + fc00masked, _mm512_set1_epi16(int16_t(0xdc00)), _MM_CMPINT_EQ); + + int carryout = 0; + if (!_kortestz_mask32_u8(hisurr, losurr)) { + // handle surrogates + + __m512i los = _mm512_alignr_epi32(hi, lo, 1); + __m512i his = _mm512_alignr_epi32(lo, hi, 1); + + const __mmask32 hisurrhi = _kshiftri_mask32(hisurr, 16); + taglo = _mm512_mask_mov_epi32(taglo, __mmask16(hisurr), _mm512_set1_epi32(0x808080f0)); + taghi = _mm512_mask_mov_epi32(taghi, __mmask16(hisurrhi), _mm512_set1_epi32(0x808080f0)); + + lo = _mm512_mask_slli_epi32(lo, __mmask16(hisurr), lo, 10); + hi = _mm512_mask_slli_epi32(hi, __mmask16(hisurrhi), hi, 10); + los = _mm512_add_epi32(los, _mm512_set1_epi32(0xfca02400)); + his = _mm512_add_epi32(his, _mm512_set1_epi32(0xfca02400)); + lo = _mm512_mask_add_epi32(lo, __mmask16(hisurr), lo, los); + hi = _mm512_mask_add_epi32(hi, __mmask16(hisurrhi), hi, his); + + carryout = _cvtu32_mask32(_kshiftri_mask32(hisurr, 30)); + + const uint32_t h = _cvtmask32_u32(hisurr); + const uint32_t l = _cvtmask32_u32(losurr); + // check for mismatched surrogates + if ((h + h + carry) ^ l) { + const uint32_t lonohi = l & ~(h + h + carry); + const uint32_t hinolo = h & ~(l >> 1); + inlen = _tzcnt_u32(hinolo | lonohi); + inmask = __mmask32(0x7fffffff & ((1 << inlen) - 1)); + in = _mm512_maskz_mov_epi16(inmask, in); + adjust = (int)inlen - 31; + inlen = 0; + goto failiteration; + } + } - __m512i mslo = - _mm512_multishift_epi64_epi8(_mm512_set1_epi64(0x20262c3200060c12), lo); + hi = _mm512_maskz_mov_epi32(_cvtu32_mask16(0x7fff), hi); + carry = carryout; - __m512i mshi = - _mm512_multishift_epi64_epi8(_mm512_set1_epi64(0x20262c3200060c12), hi); + __m512i mslo = _mm512_multishift_epi64_epi8(_mm512_set1_epi64(0x20262c3200060c12), lo); - const __mmask32 outmask = __mmask32(_kandn_mask64(losurr, inmask)); - const __mmask64 outmhi = _kshiftri_mask64(outmask, 16); + __m512i mshi = _mm512_multishift_epi64_epi8(_mm512_set1_epi64(0x20262c3200060c12), hi); - const __mmask32 is1byte = __mmask32(_knot_mask64(is234byte)); - const __mmask64 is1bhi = _kshiftri_mask64(is1byte, 16); - const __mmask64 is12bhi = _kshiftri_mask64(is12byte, 16); + const __mmask32 outmask = __mmask32(_kandn_mask64(losurr, inmask)); + const __mmask64 outmhi = _kshiftri_mask64(outmask, 16); - taglo = - _mm512_mask_mov_epi32(taglo, __mmask16(is12byte), _mm512_set1_epi32(0x80c00000)); - taghi = - _mm512_mask_mov_epi32(taghi, __mmask16(is12bhi), _mm512_set1_epi32(0x80c00000)); - __m512i magiclo = _mm512_mask_blend_epi32(__mmask16(outmask), _mm512_set1_epi32(0xffffffff), - _mm512_set1_epi32(0x00010101)); - __m512i magichi = _mm512_mask_blend_epi32(__mmask16(outmhi), _mm512_set1_epi32(0xffffffff), - _mm512_set1_epi32(0x00010101)); + const __mmask32 is1byte = __mmask32(_knot_mask64(is234byte)); + const __mmask64 is1bhi = _kshiftri_mask64(is1byte, 16); + const __mmask64 is12bhi = _kshiftri_mask64(is12byte, 16); + taglo = _mm512_mask_mov_epi32(taglo, __mmask16(is12byte), _mm512_set1_epi32(0x80c00000)); + taghi = _mm512_mask_mov_epi32(taghi, __mmask16(is12bhi), _mm512_set1_epi32(0x80c00000)); + __m512i magiclo = _mm512_mask_blend_epi32(__mmask16(outmask), _mm512_set1_epi32(0xffffffff), + _mm512_set1_epi32(0x00010101)); + __m512i magichi = _mm512_mask_blend_epi32(__mmask16(outmhi), _mm512_set1_epi32(0xffffffff), + _mm512_set1_epi32(0x00010101)); - magiclo = _mm512_mask_blend_epi32(__mmask16(outmask), _mm512_set1_epi32(0xffffffff), - _mm512_set1_epi32(0x00010101)); - magichi = _mm512_mask_blend_epi32(__mmask16(outmhi), _mm512_set1_epi32(0xffffffff), - _mm512_set1_epi32(0x00010101)); + magiclo = _mm512_mask_blend_epi32(__mmask16(outmask), _mm512_set1_epi32(0xffffffff), + _mm512_set1_epi32(0x00010101)); + magichi = _mm512_mask_blend_epi32(__mmask16(outmhi), _mm512_set1_epi32(0xffffffff), + _mm512_set1_epi32(0x00010101)); - mslo = _mm512_ternarylogic_epi32(mslo, _mm512_set1_epi32(0x3f3f3f3f), taglo, - 0xea); // A&B|C - mshi = _mm512_ternarylogic_epi32(mshi, _mm512_set1_epi32(0x3f3f3f3f), taghi, - 0xea); - mslo = _mm512_mask_slli_epi32(mslo, __mmask16(is1byte), lo, 24); + mslo = _mm512_ternarylogic_epi32(mslo, _mm512_set1_epi32(0x3f3f3f3f), taglo, + 0xea); // A&B|C + mshi = _mm512_ternarylogic_epi32(mshi, _mm512_set1_epi32(0x3f3f3f3f), taghi, + 0xea); + mslo = _mm512_mask_slli_epi32(mslo, __mmask16(is1byte), lo, 24); - mshi = _mm512_mask_slli_epi32(mshi, __mmask16(is1bhi), hi, 24); + mshi = _mm512_mask_slli_epi32(mshi, __mmask16(is1bhi), hi, 24); - const __mmask64 wantlo = _mm512_cmp_epu8_mask(mslo, magiclo, _MM_CMPINT_NLT); - const __mmask64 wanthi = _mm512_cmp_epu8_mask(mshi, magichi, _MM_CMPINT_NLT); - const __m512i outlo = _mm512_maskz_compress_epi8(wantlo, mslo); - const __m512i outhi = _mm512_maskz_compress_epi8(wanthi, mshi); - const uint64_t wantlo_uint64 = _cvtmask64_u64(wantlo); - const uint64_t wanthi_uint64 = _cvtmask64_u64(wanthi); + const __mmask64 wantlo = _mm512_cmp_epu8_mask(mslo, magiclo, _MM_CMPINT_NLT); + const __mmask64 wanthi = _mm512_cmp_epu8_mask(mshi, magichi, _MM_CMPINT_NLT); + const __m512i outlo = _mm512_maskz_compress_epi8(wantlo, mslo); + const __m512i outhi = _mm512_maskz_compress_epi8(wanthi, mshi); + const uint64_t wantlo_uint64 = _cvtmask64_u64(wantlo); + const uint64_t wanthi_uint64 = _cvtmask64_u64(wanthi); - uint64_t advlo = _mm_popcnt_u64(wantlo_uint64); - uint64_t advhi = _mm_popcnt_u64(wanthi_uint64); + uint64_t advlo = _mm_popcnt_u64(wantlo_uint64); + uint64_t advhi = _mm_popcnt_u64(wanthi_uint64); - _mm512_mask_storeu_epi8(outbuf, _cvtu64_mask64(_pext_u64(wantlo_uint64, wantlo_uint64)), outlo); - _mm512_mask_storeu_epi8(outbuf + advlo, _cvtu64_mask64(_pext_u64(wanthi_uint64, wanthi_uint64)), outhi); - outbuf += advlo + advhi; - } - outbuf -= adjust; + _mm512_mask_storeu_epi8(outbuf, _cvtu64_mask64(_pext_u64(wantlo_uint64, wantlo_uint64)), outlo); + _mm512_mask_storeu_epi8(outbuf + advlo, _cvtu64_mask64(_pext_u64(wanthi_uint64, wanthi_uint64)), outhi); + outbuf += advlo + advhi; + } + outbuf -= adjust; tail: - if (inlen != 0) { - // We must have inlen < 31. - inmask = _cvtu32_mask32((1 << inlen) - 1); - in = _mm512_maskz_loadu_epi16(inmask, inbuf); - if(big_endian) { in = _mm512_shuffle_epi8(in, byteflip); } - adjust = inlen - 31; - inlen = 0; - goto lastiteration; - } - *outlen = (outbuf - outbuf_orig) + adjust; - return ((inbuf - inbuf_orig) + adjust); + if (inlen != 0) { + // We must have inlen < 31. + inmask = _cvtu32_mask32((1 << inlen) - 1); + in = _mm512_maskz_loadu_epi16(inmask, inbuf); + if (big_endian) { + in = _mm512_shuffle_epi8(in, byteflip); + } + adjust = inlen - 31; + inlen = 0; + goto lastiteration; + } + *outlen = (outbuf - outbuf_orig) + adjust; + return ((inbuf - inbuf_orig) + adjust); } /* end file src/icelake/icelake_convert_utf16_to_utf8.inl.cpp */ @@ -18082,141 +20851,138 @@ tail: namespace simdutf { namespace icelake { - simdutf_warn_unused int -implementation::detect_encodings(const char *input, - size_t length) const noexcept { - // If there is a BOM, then we trust it. - auto bom_encoding = simdutf::BOM::check_bom(input, length); - if(bom_encoding != encoding_type::unspecified) { return bom_encoding; } - if (length % 2 == 0) { - const char *buf = input; +implementation::detect_encodings(const char* input, + size_t length) const noexcept +{ + // If there is a BOM, then we trust it. + auto bom_encoding = simdutf::BOM::check_bom(input, length); + if (bom_encoding != encoding_type::unspecified) { + return bom_encoding; + } + if (length % 2 == 0) { + const char* buf = input; + + const char* start = buf; + const char* end = input + length; + + bool is_utf8 = true; + bool is_utf16 = true; + bool is_utf32 = true; + + int out = 0; + + avx512_utf8_checker checker {}; + __m512i currentmax = _mm512_setzero_si512(); + while (buf + 64 <= end) { + __m512i in = _mm512_loadu_si512((__m512i*)buf); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + is_utf8 = false; + + // Can still be either UTF-16LE or UTF-32 depending on the positions + // of the surrogates To be valid UTF-32, a surrogate cannot be in the + // two most significant bytes of any 32-bit word. On the other hand, to + // be valid UTF-16LE, at least one surrogate must be in the two most + // significant bytes of a 32-bit word since they always come in pairs in + // UTF-16LE. Note that we always proceed in multiple of 4 before this + // point so there is no offset in 32-bit words. + + if ((surrogates & 0xaaaaaaaa) != 0) { + is_utf32 = false; + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask( + diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + return simdutf::encoding_type::unspecified; + } - const char *start = buf; - const char *end = input + length; + bool ends_with_high = ((highsurrogates & 0x80000000) != 0); + if (ends_with_high) { + buf += 31 * sizeof(char16_t); // advance only by 31 words so that we start + // with the high surrogate on the next round. + } else { + buf += 32 * sizeof(char16_t); + } + is_utf16 = validate_utf16le(reinterpret_cast(buf), + (end - buf) / sizeof(char16_t)); + if (!is_utf16) { + return simdutf::encoding_type::unspecified; - bool is_utf8 = true; - bool is_utf16 = true; - bool is_utf32 = true; + } else { + return simdutf::encoding_type::UTF16_LE; + } - int out = 0; + } else { + is_utf16 = false; + // Check for UTF-32 + if (length % 4 == 0) { + const char32_t* input32 = reinterpret_cast(buf); + const char32_t* end32 = reinterpret_cast(start) + length / 4; + if (validate_utf32(input32, end32 - input32)) { + return simdutf::encoding_type::UTF32_LE; + } + } + return simdutf::encoding_type::unspecified; + } + break; + } + // If no surrogate, validate under other encodings as well - avx512_utf8_checker checker{}; - __m512i currentmax = _mm512_setzero_si512(); - while (buf + 64 <= end) { - __m512i in = _mm512_loadu_si512((__m512i *)buf); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = - _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if (surrogates) { - is_utf8 = false; - - // Can still be either UTF-16LE or UTF-32 depending on the positions - // of the surrogates To be valid UTF-32, a surrogate cannot be in the - // two most significant bytes of any 32-bit word. On the other hand, to - // be valid UTF-16LE, at least one surrogate must be in the two most - // significant bytes of a 32-bit word since they always come in pairs in - // UTF-16LE. Note that we always proceed in multiple of 4 before this - // point so there is no offset in 32-bit words. - - if ((surrogates & 0xaaaaaaaa) != 0) { - is_utf32 = false; - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask( - diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - return simdutf::encoding_type::unspecified; - } - - bool ends_with_high = ((highsurrogates & 0x80000000) != 0); - if (ends_with_high) { - buf += - 31 * - sizeof(char16_t); // advance only by 31 words so that we start - // with the high surrogate on the next round. - } else { - buf += 32 * sizeof(char16_t); - } - is_utf16 = validate_utf16le(reinterpret_cast(buf), - (end - buf) / sizeof(char16_t)); - if (!is_utf16) { - return simdutf::encoding_type::unspecified; + // UTF-32 validation + currentmax = _mm512_max_epu32(in, currentmax); - } else { - return simdutf::encoding_type::UTF16_LE; - } + // UTF-8 validation + checker.check_next_input(in); - } else { - is_utf16 = false; - // Check for UTF-32 - if (length % 4 == 0) { - const char32_t *input32 = reinterpret_cast(buf); - const char32_t *end32 = - reinterpret_cast(start) + length / 4; - if (validate_utf32(input32, end32 - input32)) { - return simdutf::encoding_type::UTF32_LE; - } - } - return simdutf::encoding_type::unspecified; + buf += 64; } - break; - } - // If no surrogate, validate under other encodings as well - - // UTF-32 validation - currentmax = _mm512_max_epu32(in, currentmax); - - // UTF-8 validation - checker.check_next_input(in); - buf += 64; - } + // Check which encodings are possible - // Check which encodings are possible + if (is_utf8) { + size_t current_length = static_cast(buf - start); + if (current_length != length) { + const __m512i utf8 = _mm512_maskz_loadu_epi8( + (1ULL << (length - current_length)) - 1, (const __m512i*)buf); + checker.check_next_input(utf8); + } + checker.check_eof(); + if (!checker.errors()) { + out |= simdutf::encoding_type::UTF8; + } + } - if (is_utf8) { - size_t current_length = static_cast(buf - start); - if (current_length != length) { - const __m512i utf8 = _mm512_maskz_loadu_epi8( - (1ULL << (length - current_length)) - 1, (const __m512i *)buf); - checker.check_next_input(utf8); - } - checker.check_eof(); - if (!checker.errors()) { - out |= simdutf::encoding_type::UTF8; - } - } + if (is_utf16 && scalar::utf16::validate(reinterpret_cast(buf), (length - (buf - start)) / 2)) { + out |= simdutf::encoding_type::UTF16_LE; + } - if (is_utf16 && scalar::utf16::validate( - reinterpret_cast(buf), - (length - (buf - start)) / 2)) { - out |= simdutf::encoding_type::UTF16_LE; - } + if (is_utf32 && (length % 4 == 0)) { + currentmax = _mm512_max_epu32( + _mm512_maskz_loadu_epi8( + (1ULL << (length - static_cast(buf - start))) - 1, + (const __m512i*)buf), + currentmax); + __mmask16 outside_range = _mm512_cmp_epu32_mask(currentmax, _mm512_set1_epi32(0x10ffff), + _MM_CMPINT_GT); + if (outside_range == 0) { + out |= simdutf::encoding_type::UTF32_LE; + } + } - if (is_utf32 && (length % 4 == 0)) { - currentmax = _mm512_max_epu32( - _mm512_maskz_loadu_epi8( - (1ULL << (length - static_cast(buf - start))) - 1, - (const __m512i *)buf), - currentmax); - __mmask16 outside_range = _mm512_cmp_epu32_mask(currentmax, _mm512_set1_epi32(0x10ffff), - _MM_CMPINT_GT); - if (outside_range == 0) { - out |= simdutf::encoding_type::UTF32_LE; - } + return out; + } else if (implementation::validate_utf8(input, length)) { + return simdutf::encoding_type::UTF8; + } else { + return simdutf::encoding_type::unspecified; } - - return out; - } else if (implementation::validate_utf8(input, length)) { - return simdutf::encoding_type::UTF8; - } else { - return simdutf::encoding_type::unspecified; - } } -simdutf_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { - avx512_utf8_checker checker{}; +simdutf_warn_unused bool implementation::validate_utf8(const char* buf, size_t len) const noexcept +{ + avx512_utf8_checker checker {}; const char* ptr = buf; const char* end = ptr + len; for (; ptr + 64 <= end; ptr += 64) { @@ -18224,969 +20990,1163 @@ simdutf_warn_unused bool implementation::validate_utf8(const char *buf, size_t l checker.check_next_input(utf8); } { - const __m512i utf8 = _mm512_maskz_loadu_epi8((1ULL<<(end - ptr))-1, (const __m512i*)ptr); - checker.check_next_input(utf8); + const __m512i utf8 = _mm512_maskz_loadu_epi8((1ULL << (end - ptr)) - 1, (const __m512i*)ptr); + checker.check_next_input(utf8); } checker.check_eof(); - return ! checker.errors(); + return !checker.errors(); } -simdutf_warn_unused result implementation::validate_utf8_with_errors(const char *buf, size_t len) const noexcept { - avx512_utf8_checker checker{}; +simdutf_warn_unused result implementation::validate_utf8_with_errors(const char* buf, size_t len) const noexcept +{ + avx512_utf8_checker checker {}; const char* ptr = buf; const char* end = ptr + len; - size_t count{0}; + size_t count { 0 }; for (; ptr + 64 <= end; ptr += 64) { - const __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); - checker.check_next_input(utf8); - if(checker.errors()) { - if (count != 0) { count--; } // Sometimes the error is only detected in the next chunk - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(buf + count), len - count); - res.count += count; - return res; - } - count += 64; + const __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); + checker.check_next_input(utf8); + if (checker.errors()) { + if (count != 0) { + count--; + } // Sometimes the error is only detected in the next chunk + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(buf + count), len - count); + res.count += count; + return res; + } + count += 64; } { - const __m512i utf8 = _mm512_maskz_loadu_epi8((1ULL<<(end - ptr))-1, (const __m512i*)ptr); - checker.check_next_input(utf8); - if(checker.errors()) { - if (count != 0) { count--; } // Sometimes the error is only detected in the next chunk - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(buf + count), len - count); - res.count += count; - return res; - } else { - return result(error_code::SUCCESS, len); - } - } -} - -simdutf_warn_unused bool implementation::validate_ascii(const char *buf, size_t len) const noexcept { - return icelake::validate_ascii(buf, len); -} - -simdutf_warn_unused result implementation::validate_ascii_with_errors(const char *buf, size_t len) const noexcept { - const char* buf_orig = buf; - const char* end = buf + len; - const __m512i ascii = _mm512_set1_epi8((uint8_t)0x80); - for (; buf + 64 <= end; buf += 64) { - const __m512i input = _mm512_loadu_si512((const __m512i*)buf); - __mmask64 notascii = _mm512_cmp_epu8_mask(input, ascii, _MM_CMPINT_NLT); - if(notascii) { - return result(error_code::TOO_LARGE, buf - buf_orig + _tzcnt_u64(notascii)); - } - } - { - const __m512i input = _mm512_maskz_loadu_epi8((1ULL<<(end - buf))-1, (const __m512i*)buf); - __mmask64 notascii = _mm512_cmp_epu8_mask(input, ascii, _MM_CMPINT_NLT); - if(notascii) { - return result(error_code::TOO_LARGE, buf - buf_orig + _tzcnt_u64(notascii)); - } - } - return result(error_code::SUCCESS, len); -} - -simdutf_warn_unused bool implementation::validate_utf16le(const char16_t *buf, size_t len) const noexcept { - const char16_t *end = buf + len; - - for(;buf + 32 <= end; ) { - __m512i in = _mm512_loadu_si512((__m512i*)buf); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if(surrogates) { - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - return false; - } - bool ends_with_high = ((highsurrogates & 0x80000000) != 0); - if(ends_with_high) { - buf += 31; // advance only by 31 words so that we start with the high surrogate on the next round. + const __m512i utf8 = _mm512_maskz_loadu_epi8((1ULL << (end - ptr)) - 1, (const __m512i*)ptr); + checker.check_next_input(utf8); + if (checker.errors()) { + if (count != 0) { + count--; + } // Sometimes the error is only detected in the next chunk + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(buf + count), len - count); + res.count += count; + return res; + } else { + return result(error_code::SUCCESS, len); + } + } +} + +simdutf_warn_unused bool implementation::validate_ascii(const char* buf, size_t len) const noexcept +{ + return icelake::validate_ascii(buf, len); +} + +simdutf_warn_unused result implementation::validate_ascii_with_errors(const char* buf, size_t len) const noexcept +{ + const char* buf_orig = buf; + const char* end = buf + len; + const __m512i ascii = _mm512_set1_epi8((uint8_t)0x80); + for (; buf + 64 <= end; buf += 64) { + const __m512i input = _mm512_loadu_si512((const __m512i*)buf); + __mmask64 notascii = _mm512_cmp_epu8_mask(input, ascii, _MM_CMPINT_NLT); + if (notascii) { + return result(error_code::TOO_LARGE, buf - buf_orig + _tzcnt_u64(notascii)); + } + } + { + const __m512i input = _mm512_maskz_loadu_epi8((1ULL << (end - buf)) - 1, (const __m512i*)buf); + __mmask64 notascii = _mm512_cmp_epu8_mask(input, ascii, _MM_CMPINT_NLT); + if (notascii) { + return result(error_code::TOO_LARGE, buf - buf_orig + _tzcnt_u64(notascii)); + } + } + return result(error_code::SUCCESS, len); +} + +simdutf_warn_unused bool implementation::validate_utf16le(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* end = buf + len; + + for (; buf + 32 <= end;) { + __m512i in = _mm512_loadu_si512((__m512i*)buf); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + return false; + } + bool ends_with_high = ((highsurrogates & 0x80000000) != 0); + if (ends_with_high) { + buf += 31; // advance only by 31 words so that we start with the high surrogate on the next round. + } else { + buf += 32; + } } else { - buf += 32; + buf += 32; } - } else { - buf += 32; - } } - if(buf < end) { - __m512i in = _mm512_maskz_loadu_epi16((1<<(end-buf))-1,(__m512i*)buf); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if(surrogates) { - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - return false; + if (buf < end) { + __m512i in = _mm512_maskz_loadu_epi16((1 << (end - buf)) - 1, (__m512i*)buf); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + return false; + } } - } } return true; } -simdutf_warn_unused bool implementation::validate_utf16be(const char16_t *buf, size_t len) const noexcept { - const char16_t *end = buf + len; - const __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); - for(;buf + 32 <= end; ) { - __m512i in = _mm512_shuffle_epi8(_mm512_loadu_si512((__m512i*)buf), byteflip); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if(surrogates) { - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - return false; - } - bool ends_with_high = ((highsurrogates & 0x80000000) != 0); - if(ends_with_high) { - buf += 31; // advance only by 31 words so that we start with the high surrogate on the next round. +simdutf_warn_unused bool implementation::validate_utf16be(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* end = buf + len; + const __m512i byteflip = _mm512_setr_epi64( + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); + for (; buf + 32 <= end;) { + __m512i in = _mm512_shuffle_epi8(_mm512_loadu_si512((__m512i*)buf), byteflip); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + return false; + } + bool ends_with_high = ((highsurrogates & 0x80000000) != 0); + if (ends_with_high) { + buf += 31; // advance only by 31 words so that we start with the high surrogate on the next round. + } else { + buf += 32; + } } else { - buf += 32; + buf += 32; } - } else { - buf += 32; - } } - if(buf < end) { - __m512i in = _mm512_shuffle_epi8(_mm512_maskz_loadu_epi16((1<<(end-buf))-1,(__m512i*)buf), byteflip); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if(surrogates) { - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - return false; + if (buf < end) { + __m512i in = _mm512_shuffle_epi8(_mm512_maskz_loadu_epi16((1 << (end - buf)) - 1, (__m512i*)buf), byteflip); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + return false; + } } - } } return true; } -simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept { - const char16_t *start_buf = buf; - const char16_t *end = buf + len; - for(;buf + 32 <= end; ) { - __m512i in = _mm512_loadu_si512((__m512i*)buf); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if(surrogates) { - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - uint32_t extra_low = _tzcnt_u32(lowsurrogates &~(highsurrogates << 1)); - uint32_t extra_high = _tzcnt_u32(highsurrogates &~(lowsurrogates >> 1)); - return result(error_code::SURROGATE, (buf - start_buf) + (extra_low < extra_high ? extra_low : extra_high)); - } - bool ends_with_high = ((highsurrogates & 0x80000000) != 0); - if(ends_with_high) { - buf += 31; // advance only by 31 words so that we start with the high surrogate on the next round. - } else { - buf += 32; - } - } else { - buf += 32; - } - } - if(buf < end) { - __m512i in = _mm512_maskz_loadu_epi16((1<<(end-buf))-1,(__m512i*)buf); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if(surrogates) { - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - uint32_t extra_low = _tzcnt_u32(lowsurrogates &~(highsurrogates << 1)); - uint32_t extra_high = _tzcnt_u32(highsurrogates &~(lowsurrogates >> 1)); - return result(error_code::SURROGATE, (buf - start_buf) + (extra_low < extra_high ? extra_low : extra_high)); - } - } - } - return result(error_code::SUCCESS, len); +simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* start_buf = buf; + const char16_t* end = buf + len; + for (; buf + 32 <= end;) { + __m512i in = _mm512_loadu_si512((__m512i*)buf); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + uint32_t extra_low = _tzcnt_u32(lowsurrogates & ~(highsurrogates << 1)); + uint32_t extra_high = _tzcnt_u32(highsurrogates & ~(lowsurrogates >> 1)); + return result(error_code::SURROGATE, (buf - start_buf) + (extra_low < extra_high ? extra_low : extra_high)); + } + bool ends_with_high = ((highsurrogates & 0x80000000) != 0); + if (ends_with_high) { + buf += 31; // advance only by 31 words so that we start with the high surrogate on the next round. + } else { + buf += 32; + } + } else { + buf += 32; + } + } + if (buf < end) { + __m512i in = _mm512_maskz_loadu_epi16((1 << (end - buf)) - 1, (__m512i*)buf); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + uint32_t extra_low = _tzcnt_u32(lowsurrogates & ~(highsurrogates << 1)); + uint32_t extra_high = _tzcnt_u32(highsurrogates & ~(lowsurrogates >> 1)); + return result(error_code::SURROGATE, (buf - start_buf) + (extra_low < extra_high ? extra_low : extra_high)); + } + } + } + return result(error_code::SUCCESS, len); +} + +simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* start_buf = buf; + const char16_t* end = buf + len; + const __m512i byteflip = _mm512_setr_epi64( + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); + for (; buf + 32 <= end;) { + __m512i in = _mm512_shuffle_epi8(_mm512_loadu_si512((__m512i*)buf), byteflip); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + uint32_t extra_low = _tzcnt_u32(lowsurrogates & ~(highsurrogates << 1)); + uint32_t extra_high = _tzcnt_u32(highsurrogates & ~(lowsurrogates >> 1)); + return result(error_code::SURROGATE, (buf - start_buf) + (extra_low < extra_high ? extra_low : extra_high)); + } + bool ends_with_high = ((highsurrogates & 0x80000000) != 0); + if (ends_with_high) { + buf += 31; // advance only by 31 words so that we start with the high surrogate on the next round. + } else { + buf += 32; + } + } else { + buf += 32; + } + } + if (buf < end) { + __m512i in = _mm512_shuffle_epi8(_mm512_maskz_loadu_epi16((1 << (end - buf)) - 1, (__m512i*)buf), byteflip); + __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); + __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); + if (surrogates) { + __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); + __mmask32 lowsurrogates = surrogates ^ highsurrogates; + // high must be followed by low + if ((highsurrogates << 1) != lowsurrogates) { + uint32_t extra_low = _tzcnt_u32(lowsurrogates & ~(highsurrogates << 1)); + uint32_t extra_high = _tzcnt_u32(highsurrogates & ~(lowsurrogates >> 1)); + return result(error_code::SURROGATE, (buf - start_buf) + (extra_low < extra_high ? extra_low : extra_high)); + } + } + } + return result(error_code::SUCCESS, len); +} + +simdutf_warn_unused bool implementation::validate_utf32(const char32_t* buf, size_t len) const noexcept +{ + const char32_t* tail = icelake::validate_utf32(buf, len); + if (tail) { + return scalar::utf32::validate(tail, len - (tail - buf)); + } else { + return false; + } +} + +simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept +{ + + const char32_t* end = len >= 16 ? buf + len - 16 : nullptr; + const char32_t* buf_orig = buf; + while (buf <= end) { + __m512i utf32 = _mm512_loadu_si512((const __m512i*)buf); + __mmask16 outside_range = _mm512_cmp_epu32_mask(utf32, _mm512_set1_epi32(0x10ffff), + _MM_CMPINT_GT); + if (outside_range) { + return result(error_code::TOO_LARGE, buf - buf_orig + _tzcnt_u32(outside_range)); + } + + __m512i utf32_off = _mm512_add_epi32(utf32, _mm512_set1_epi32(0xffff2000)); + + __mmask16 surrogate_range = _mm512_cmp_epu32_mask(utf32_off, _mm512_set1_epi32(0xfffff7ff), + _MM_CMPINT_GT); + if (surrogate_range) { + return result(error_code::SURROGATE, buf - buf_orig + _tzcnt_u32(surrogate_range)); + } + buf += 16; + } + if (buf < buf_orig + len) { + __m512i utf32 = _mm512_maskz_loadu_epi32(__mmask16((1 << (buf_orig + len - buf)) - 1), (const __m512i*)buf); + __mmask16 outside_range = _mm512_cmp_epu32_mask(utf32, _mm512_set1_epi32(0x10ffff), + _MM_CMPINT_GT); + if (outside_range) { + return result(error_code::TOO_LARGE, buf - buf_orig + _tzcnt_u32(outside_range)); + } + __m512i utf32_off = _mm512_add_epi32(utf32, _mm512_set1_epi32(0xffff2000)); + + __mmask16 surrogate_range = _mm512_cmp_epu32_mask(utf32_off, _mm512_set1_epi32(0xfffff7ff), + _MM_CMPINT_GT); + if (surrogate_range) { + return result(error_code::SURROGATE, buf - buf_orig + _tzcnt_u32(surrogate_range)); + } + } + + return result(error_code::SUCCESS, len); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::latin1_to_utf8::convert(buf, len, utf8_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf32(const char* buf, size_t len, char32_t* latin1_output) const noexcept +{ + return scalar::latin1_to_utf32::convert(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16_result ret = fast_avx512_convert_utf8_to_utf16(buf, len, utf16_output); + if (ret.second == nullptr) { + return 0; + } + return ret.second - utf16_output; +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16_result ret = fast_avx512_convert_utf8_to_utf16(buf, len, utf16_output); + if (ret.second == nullptr) { + return 0; + } + return ret.second - utf16_output; +} + +simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return fast_avx512_convert_utf8_to_utf16_with_errors(buf, len, utf16_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return fast_avx512_convert_utf8_to_utf16_with_errors(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16_result ret = icelake::valid_utf8_to_fixed_length(buf, len, utf16_output); + size_t saved_bytes = ret.second - utf16_output; + const char* end = buf + len; + if (ret.first == end) { + return saved_bytes; + } + + // Note: AVX512 procedure looks up 4 bytes forward, and + // correctly converts multi-byte chars even if their + // continuation bytes lie outsiede 16-byte window. + // It meas, we have to skip continuation bytes from + // the beginning ret.first, as they were already consumed. + while (ret.first != end && ((uint8_t(*ret.first) & 0xc0) == 0x80)) { + ret.first += 1; + } + + if (ret.first != end) { + const size_t scalar_saved_bytes = scalar::utf8_to_utf16::convert_valid( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16_result ret = icelake::valid_utf8_to_fixed_length(buf, len, utf16_output); + size_t saved_bytes = ret.second - utf16_output; + const char* end = buf + len; + if (ret.first == end) { + return saved_bytes; + } + + // Note: AVX512 procedure looks up 4 bytes forward, and + // correctly converts multi-byte chars even if their + // continuation bytes lie outsiede 16-byte window. + // It meas, we have to skip continuation bytes from + // the beginning ret.first, as they were already consumed. + while (ret.first != end && ((uint8_t(*ret.first) & 0xc0) == 0x80)) { + ret.first += 1; + } + + if (ret.first != end) { + const size_t scalar_saved_bytes = scalar::utf8_to_utf16::convert_valid( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_out) const noexcept +{ + uint32_t* utf32_output = reinterpret_cast(utf32_out); + utf8_to_utf32_result ret = icelake::validating_utf8_to_fixed_length(buf, len, utf32_output); + if (ret.second == nullptr) + return 0; + + size_t saved_bytes = ret.second - utf32_output; + const char* end = buf + len; + if (ret.first == end) { + return saved_bytes; + } + + // Note: the AVX512 procedure looks up 4 bytes forward, and + // correctly converts multi-byte chars even if their + // continuation bytes lie outside 16-byte window. + // It means, we have to skip continuation bytes from + // the beginning ret.first, as they were already consumed. + while (ret.first != end and ((uint8_t(*ret.first) & 0xc0) == 0x80)) { + ret.first += 1; + } + + if (ret.first != end) { + const size_t scalar_saved_bytes = scalar::utf8_to_utf32::convert( + ret.first, len - (ret.first - buf), utf32_out + saved_bytes); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32) const noexcept +{ + uint32_t* utf32_output = reinterpret_cast(utf32); + auto ret = icelake::validating_utf8_to_fixed_length_with_constant_checks(buf, len, utf32_output); + if (!std::get<2>(ret)) { + auto new_buf = std::get<0>(ret); + // rewind_and_convert_with_errors will seek a potential error from new_buf onward, + // with the ability to go back up to new_buf - buf bytes, and read len - (new_buf - buf) bytes forward. + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(new_buf - buf, new_buf, len - (new_buf - buf), reinterpret_cast(std::get<1>(ret))); + res.count += (std::get<0>(ret) - buf); + return res; + } + size_t saved_bytes = std::get<1>(ret) - utf32_output; + const char* end = buf + len; + if (std::get<0>(ret) == end) { + return { simdutf::SUCCESS, saved_bytes }; + } + + // Note: the AVX512 procedure looks up 4 bytes forward, and + // correctly converts multi-byte chars even if their + // continuation bytes lie outside 16-byte window. + // It means, we have to skip continuation bytes from + // the beginning ret.first, as they were already consumed. + while (std::get<0>(ret) != end and ((uint8_t(*std::get<0>(ret)) & 0xc0) == 0x80)) { + std::get<0>(ret) += 1; + } + + if (std::get<0>(ret) != end) { + auto scalar_result = scalar::utf8_to_utf32::convert_with_errors( + std::get<0>(ret), len - (std::get<0>(ret) - buf), reinterpret_cast(utf32_output) + saved_bytes); + if (scalar_result.error != simdutf::SUCCESS) { + scalar_result.count += (std::get<0>(ret) - buf); + } else { + scalar_result.count += saved_bytes; + } + return scalar_result; + } + + return { simdutf::SUCCESS, size_t(std::get<1>(ret) - utf32_output) }; +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_out) const noexcept +{ + uint32_t* utf32_output = reinterpret_cast(utf32_out); + utf8_to_utf32_result ret = icelake::valid_utf8_to_fixed_length(buf, len, utf32_output); + size_t saved_bytes = ret.second - utf32_output; + const char* end = buf + len; + if (ret.first == end) { + return saved_bytes; + } + + // Note: AVX512 procedure looks up 4 bytes forward, and + // correctly converts multi-byte chars even if their + // continuation bytes lie outsiede 16-byte window. + // It meas, we have to skip continuation bytes from + // the beginning ret.first, as they were already consumed. + while (ret.first != end && ((uint8_t(*ret.first) & 0xc0) == 0x80)) { + ret.first += 1; + } + + if (ret.first != end) { + const size_t scalar_saved_bytes = scalar::utf8_to_utf32::convert_valid( + ret.first, len - (ret.first - buf), utf32_out + saved_bytes); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); } -simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept { - const char16_t *start_buf = buf; - const char16_t *end = buf + len; - const __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); - for(;buf + 32 <= end; ) { - __m512i in = _mm512_shuffle_epi8(_mm512_loadu_si512((__m512i*)buf), byteflip); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if(surrogates) { - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - uint32_t extra_low = _tzcnt_u32(lowsurrogates &~(highsurrogates << 1)); - uint32_t extra_high = _tzcnt_u32(highsurrogates &~(lowsurrogates >> 1)); - return result(error_code::SURROGATE, (buf - start_buf) + (extra_low < extra_high ? extra_low : extra_high)); - } - bool ends_with_high = ((highsurrogates & 0x80000000) != 0); - if(ends_with_high) { - buf += 31; // advance only by 31 words so that we start with the high surrogate on the next round. - } else { - buf += 32; - } - } else { - buf += 32; - } - } - if(buf < end) { - __m512i in = _mm512_shuffle_epi8(_mm512_maskz_loadu_epi16((1<<(end-buf))-1,(__m512i*)buf), byteflip); - __m512i diff = _mm512_sub_epi16(in, _mm512_set1_epi16(uint16_t(0xD800))); - __mmask32 surrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0800))); - if(surrogates) { - __mmask32 highsurrogates = _mm512_cmplt_epu16_mask(diff, _mm512_set1_epi16(uint16_t(0x0400))); - __mmask32 lowsurrogates = surrogates ^ highsurrogates; - // high must be followed by low - if ((highsurrogates << 1) != lowsurrogates) { - uint32_t extra_low = _tzcnt_u32(lowsurrogates &~(highsurrogates << 1)); - uint32_t extra_high = _tzcnt_u32(highsurrogates &~(lowsurrogates >> 1)); - return result(error_code::SURROGATE, (buf - start_buf) + (extra_low < extra_high ? extra_low : extra_high)); - } - } - } - return result(error_code::SUCCESS, len); +simdutf_warn_unused size_t implementation::convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); } -simdutf_warn_unused bool implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept { - const char32_t * tail = icelake::validate_utf32(buf, len); - if (tail) { - return scalar::utf32::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused result implementation::convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); } -simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept { +simdutf_warn_unused result implementation::convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} - const char32_t* end = len >= 16 ? buf + len - 16 : nullptr; - const char32_t* buf_orig = buf; - while (buf <= end) { - __m512i utf32 = _mm512_loadu_si512((const __m512i*)buf); - __mmask16 outside_range = _mm512_cmp_epu32_mask(utf32, _mm512_set1_epi32(0x10ffff), - _MM_CMPINT_GT); - if (outside_range) { - return result(error_code::TOO_LARGE, buf - buf_orig + _tzcnt_u32(outside_range)); - } - - __m512i utf32_off = _mm512_add_epi32(utf32, _mm512_set1_epi32(0xffff2000)); - - __mmask16 surrogate_range = _mm512_cmp_epu32_mask(utf32_off, _mm512_set1_epi32(0xfffff7ff), - _MM_CMPINT_GT); - if (surrogate_range) { - return result(error_code::SURROGATE, buf - buf_orig + _tzcnt_u32(surrogate_range)); - } - buf += 16; - } - if(buf < buf_orig + len) { - __m512i utf32 = _mm512_maskz_loadu_epi32(__mmask16((1<<(buf_orig + len - buf))-1),(const __m512i*)buf); - __mmask16 outside_range = _mm512_cmp_epu32_mask(utf32, _mm512_set1_epi32(0x10ffff), - _MM_CMPINT_GT); - if (outside_range) { - return result(error_code::TOO_LARGE, buf - buf_orig + _tzcnt_u32(outside_range)); - } - __m512i utf32_off = _mm512_add_epi32(utf32, _mm512_set1_epi32(0xffff2000)); - - __mmask16 surrogate_range = _mm512_cmp_epu32_mask(utf32_off, _mm512_set1_epi32(0xfffff7ff), - _MM_CMPINT_GT); - if (surrogate_range) { - return result(error_code::SURROGATE, buf - buf_orig + _tzcnt_u32(surrogate_range)); - } +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + size_t outlen; + size_t inlen = utf16_to_utf8_avx512i(buf, len, (unsigned char*)utf8_output, &outlen); + if (inlen != len) { + return 0; } + return outlen; +} - return result(error_code::SUCCESS, len); +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + size_t outlen; + size_t inlen = utf16_to_utf8_avx512i(buf, len, (unsigned char*)utf8_output, &outlen); + if (inlen != len) { + return 0; + } + return outlen; } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16_result ret = fast_avx512_convert_utf8_to_utf16(buf, len, utf16_output); - if (ret.second == nullptr) { - return 0; - } - return ret.second - utf16_output; +simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + size_t outlen; + size_t inlen = utf16_to_utf8_avx512i(buf, len, (unsigned char*)utf8_output, &outlen); + if (inlen != len) { + result res = scalar::utf16_to_utf8::convert_with_errors(buf + inlen, len - outlen, utf8_output + outlen); + res.count += inlen; + return res; + } + return { simdutf::SUCCESS, outlen }; } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16_result ret = fast_avx512_convert_utf8_to_utf16(buf, len, utf16_output); - if (ret.second == nullptr) { - return 0; - } - return ret.second - utf16_output; +simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + size_t outlen; + size_t inlen = utf16_to_utf8_avx512i(buf, len, (unsigned char*)utf8_output, &outlen); + if (inlen != len) { + result res = scalar::utf16_to_utf8::convert_with_errors(buf + inlen, len - outlen, utf8_output + outlen); + res.count += inlen; + return res; + } + return { simdutf::SUCCESS, outlen }; } -simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - return fast_avx512_convert_utf8_to_utf16_with_errors(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf16le_to_utf8(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - return fast_avx512_convert_utf8_to_utf16_with_errors(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf16be_to_utf8(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16_result ret = icelake::valid_utf8_to_fixed_length(buf, len, utf16_output); - size_t saved_bytes = ret.second - utf16_output; - const char* end = buf + len; - if (ret.first == end) { - return saved_bytes; - } - - // Note: AVX512 procedure looks up 4 bytes forward, and - // correctly converts multi-byte chars even if their - // continuation bytes lie outsiede 16-byte window. - // It meas, we have to skip continuation bytes from - // the beginning ret.first, as they were already consumed. - while (ret.first != end && ((uint8_t(*ret.first) & 0xc0) == 0x80)) { - ret.first += 1; - } - - if (ret.first != end) { - const size_t scalar_saved_bytes = scalar::utf8_to_utf16::convert_valid( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16_result ret = icelake::valid_utf8_to_fixed_length(buf, len, utf16_output); - size_t saved_bytes = ret.second - utf16_output; - const char* end = buf + len; - if (ret.first == end) { - return saved_bytes; - } +simdutf_warn_unused size_t implementation::convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert(buf, len, latin1_output); +} - // Note: AVX512 procedure looks up 4 bytes forward, and - // correctly converts multi-byte chars even if their - // continuation bytes lie outsiede 16-byte window. - // It meas, we have to skip continuation bytes from - // the beginning ret.first, as they were already consumed. - while (ret.first != end && ((uint8_t(*ret.first) & 0xc0) == 0x80)) { - ret.first += 1; - } +simdutf_warn_unused result implementation::convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_with_errors(buf, len, latin1_output); +} - if (ret.first != end) { - const size_t scalar_saved_bytes = scalar::utf8_to_utf16::convert_valid( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_valid(buf, len, latin1_output); +} - return saved_bytes; +simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = avx512_convert_utf32_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; } +simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = icelake::avx512_convert_utf32_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; +} -simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_out) const noexcept { - uint32_t * utf32_output = reinterpret_cast(utf32_out); - utf8_to_utf32_result ret = icelake::validating_utf8_to_fixed_length(buf, len, utf32_output); - if (ret.second == nullptr) - return 0; +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf32_to_utf8(buf, len, utf8_output); +} - size_t saved_bytes = ret.second - utf32_output; - const char* end = buf + len; - if (ret.first == end) { +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + std::pair ret = avx512_convert_utf32_to_utf16(buf, len, utf16_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf16_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } return saved_bytes; - } - - // Note: the AVX512 procedure looks up 4 bytes forward, and - // correctly converts multi-byte chars even if their - // continuation bytes lie outside 16-byte window. - // It means, we have to skip continuation bytes from - // the beginning ret.first, as they were already consumed. - while (ret.first != end and ((uint8_t(*ret.first) & 0xc0) == 0x80)) { - ret.first += 1; - } - - if (ret.first != end) { - const size_t scalar_saved_bytes = scalar::utf8_to_utf32::convert( - ret.first, len - (ret.first - buf), utf32_out + saved_bytes); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32) const noexcept { - uint32_t * utf32_output = reinterpret_cast(utf32); - auto ret = icelake::validating_utf8_to_fixed_length_with_constant_checks(buf, len, utf32_output); - if (!std::get<2>(ret)) { - auto new_buf = std::get<0>(ret); - // rewind_and_convert_with_errors will seek a potential error from new_buf onward, - // with the ability to go back up to new_buf - buf bytes, and read len - (new_buf - buf) bytes forward. - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(new_buf - buf, new_buf, len - (new_buf - buf), reinterpret_cast(std::get<1>(ret))); - res.count += (std::get<0>(ret) - buf); - return res; - } - size_t saved_bytes = std::get<1>(ret) - utf32_output; - const char* end = buf + len; - if (std::get<0>(ret) == end) { - return {simdutf::SUCCESS, saved_bytes}; - } - - // Note: the AVX512 procedure looks up 4 bytes forward, and - // correctly converts multi-byte chars even if their - // continuation bytes lie outside 16-byte window. - // It means, we have to skip continuation bytes from - // the beginning ret.first, as they were already consumed. - while (std::get<0>(ret) != end and ((uint8_t(*std::get<0>(ret)) & 0xc0) == 0x80)) { - std::get<0>(ret) += 1; - } - - if (std::get<0>(ret) != end) { - auto scalar_result = scalar::utf8_to_utf32::convert_with_errors( - std::get<0>(ret), len - (std::get<0>(ret) - buf), reinterpret_cast(utf32_output) + saved_bytes); - if (scalar_result.error != simdutf::SUCCESS) { - scalar_result.count += (std::get<0>(ret) - buf); - } else { - scalar_result.count += saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + std::pair ret = avx512_convert_utf32_to_utf16(buf, len, utf16_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf16_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; } - return scalar_result; - } + return saved_bytes; +} - return {simdutf::SUCCESS, size_t(std::get<1>(ret) - utf32_output)}; +simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = avx512_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf16::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written + return ret.first; } +simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = avx512_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf16::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written + return ret.first; +} -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_out) const noexcept { - uint32_t * utf32_output = reinterpret_cast(utf32_out); - utf8_to_utf32_result ret = icelake::valid_utf8_to_fixed_length(buf, len, utf32_output); - size_t saved_bytes = ret.second - utf32_output; - const char* end = buf + len; - if (ret.first == end) { - return saved_bytes; - } - - // Note: AVX512 procedure looks up 4 bytes forward, and - // correctly converts multi-byte chars even if their - // continuation bytes lie outsiede 16-byte window. - // It meas, we have to skip continuation bytes from - // the beginning ret.first, as they were already consumed. - while (ret.first != end && ((uint8_t(*ret.first) & 0xc0) == 0x80)) { - ret.first += 1; - } - - if (ret.first != end) { - const size_t scalar_saved_bytes = scalar::utf8_to_utf32::convert_valid( - ret.first, len - (ret.first - buf), utf32_out + saved_bytes); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - size_t outlen; - size_t inlen = utf16_to_utf8_avx512i(buf, len, (unsigned char*)utf8_output, &outlen); - if(inlen != len) { return 0; } - return outlen; -} - -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - size_t outlen; - size_t inlen = utf16_to_utf8_avx512i(buf, len, (unsigned char*)utf8_output, &outlen); - if(inlen != len) { return 0; } - return outlen; -} - -simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - size_t outlen; - size_t inlen = utf16_to_utf8_avx512i(buf, len, (unsigned char*)utf8_output, &outlen); - if(inlen != len) { - result res = scalar::utf16_to_utf8::convert_with_errors(buf + inlen, len - outlen, utf8_output + outlen); - res.count += inlen; - return res; - } - return {simdutf::SUCCESS, outlen}; +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return convert_utf32_to_utf16le(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - size_t outlen; - size_t inlen = utf16_to_utf8_avx512i(buf, len, (unsigned char*)utf8_output, &outlen); - if(inlen != len) { - result res = scalar::utf16_to_utf8::convert_with_errors(buf + inlen, len - outlen, utf8_output + outlen); - res.count += inlen; - return res; - } - return {simdutf::SUCCESS, outlen}; +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return convert_utf32_to_utf16be(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf16le_to_utf8(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); + if (!std::get<2>(ret)) { + return 0; + } + size_t saved_bytes = std::get<1>(ret) - utf32_output; + if (std::get<0>(ret) != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf16be_to_utf8(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); + if (!std::get<2>(ret)) { + return 0; + } + size_t saved_bytes = std::get<1>(ret) - utf32_output; + if (std::get<0>(ret) != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; } +simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); + if (!std::get<2>(ret)) { + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); + scalar_res.count += (std::get<0>(ret) - buf); + return scalar_res; + } + size_t saved_bytes = std::get<1>(ret) - utf32_output; + if (std::get<0>(ret) != buf + len) { + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); + if (scalar_res.error) { + scalar_res.count += (std::get<0>(ret) - buf); + return scalar_res; + } else { + scalar_res.count += saved_bytes; + return scalar_res; + } + } + return simdutf::result(simdutf::SUCCESS, saved_bytes); +} + +simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); + if (!std::get<2>(ret)) { + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); + scalar_res.count += (std::get<0>(ret) - buf); + return scalar_res; + } + size_t saved_bytes = std::get<1>(ret) - utf32_output; + if (std::get<0>(ret) != buf + len) { + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); + if (scalar_res.error) { + scalar_res.count += (std::get<0>(ret) - buf); + return scalar_res; + } else { + scalar_res.count += saved_bytes; + return scalar_res; + } + } + return simdutf::result(simdutf::SUCCESS, saved_bytes); +} -simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = avx512_convert_utf32_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); + if (!std::get<2>(ret)) { + return 0; + } + size_t saved_bytes = std::get<1>(ret) - utf32_output; + if (std::get<0>(ret) != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; } -simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = icelake::avx512_convert_utf32_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf32_to_utf8(buf, len, utf8_output); -} - -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - std::pair ret = avx512_convert_utf32_to_utf16(buf, len, utf16_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf16_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - std::pair ret = avx512_convert_utf32_to_utf16(buf, len, utf16_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf16_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = avx512_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf16::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = avx512_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf16::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return convert_utf32_to_utf16le(buf, len, utf16_output); -} - -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return convert_utf32_to_utf16be(buf, len, utf16_output); -} - -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); - if (!std::get<2>(ret)) { return 0; } - size_t saved_bytes = std::get<1>(ret) - utf32_output; - if (std::get<0>(ret) != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); - if (!std::get<2>(ret)) { return 0; } - size_t saved_bytes = std::get<1>(ret) - utf32_output; - if (std::get<0>(ret) != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); - if (!std::get<2>(ret)) { - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); - scalar_res.count += (std::get<0>(ret) - buf); - return scalar_res; - } - size_t saved_bytes = std::get<1>(ret) - utf32_output; - if (std::get<0>(ret) != buf + len) { - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); - if (scalar_res.error) { - scalar_res.count += (std::get<0>(ret) - buf); - return scalar_res; - } else { - scalar_res.count += saved_bytes; - return scalar_res; - } - } - return simdutf::result(simdutf::SUCCESS, saved_bytes); -} - -simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); - if (!std::get<2>(ret)) { - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); - scalar_res.count += (std::get<0>(ret) - buf); - return scalar_res; - } - size_t saved_bytes = std::get<1>(ret) - utf32_output; - if (std::get<0>(ret) != buf + len) { - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); - if (scalar_res.error) { - scalar_res.count += (std::get<0>(ret) - buf); - return scalar_res; - } else { - scalar_res.count += saved_bytes; - return scalar_res; - } - } - return simdutf::result(simdutf::SUCCESS, saved_bytes); -} - -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); - if (!std::get<2>(ret)) { return 0; } - size_t saved_bytes = std::get<1>(ret) - utf32_output; - if (std::get<0>(ret) != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); - if (!std::get<2>(ret)) { return 0; } - size_t saved_bytes = std::get<1>(ret) - utf32_output; - if (std::get<0>(ret) != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -void implementation::change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) const noexcept { - size_t pos = 0; - const __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); - while (pos + 32 <= length) { - __m512i utf16 = _mm512_loadu_si512((const __m512i*)(input + pos)); - utf16 = _mm512_shuffle_epi8(utf16, byteflip); - _mm512_storeu_si512(output + pos, utf16); - pos += 32; - } - if(pos < length) { - __mmask32 m((1<< (length - pos))-1); - __m512i utf16 = _mm512_maskz_loadu_epi16(m, (const __m512i*)(input + pos)); - utf16 = _mm512_shuffle_epi8(utf16, byteflip); - _mm512_mask_storeu_epi16(output + pos, m, utf16); - } +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::tuple ret = icelake::convert_utf16_to_utf32(buf, len, utf32_output); + if (!std::get<2>(ret)) { + return 0; + } + size_t saved_bytes = std::get<1>(ret) - utf32_output; + if (std::get<0>(ret) != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + std::get<0>(ret), len - (std::get<0>(ret) - buf), std::get<1>(ret)); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; } +void implementation::change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) const noexcept +{ + size_t pos = 0; + const __m512i byteflip = _mm512_setr_epi64( + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); + while (pos + 32 <= length) { + __m512i utf16 = _mm512_loadu_si512((const __m512i*)(input + pos)); + utf16 = _mm512_shuffle_epi8(utf16, byteflip); + _mm512_storeu_si512(output + pos, utf16); + pos += 32; + } + if (pos < length) { + __mmask32 m((1 << (length - pos)) - 1); + __m512i utf16 = _mm512_maskz_loadu_epi16(m, (const __m512i*)(input + pos)); + utf16 = _mm512_shuffle_epi8(utf16, byteflip); + _mm512_mask_storeu_epi16(output + pos, m, utf16); + } +} -simdutf_warn_unused size_t implementation::count_utf16le(const char16_t * input, size_t length) const noexcept { - const char16_t* end = length >= 32 ? input + length - 32 : nullptr; - const char16_t* ptr = input; +simdutf_warn_unused size_t implementation::count_utf16le(const char16_t* input, size_t length) const noexcept +{ + const char16_t* end = length >= 32 ? input + length - 32 : nullptr; + const char16_t* ptr = input; - const __m512i low = _mm512_set1_epi16((uint16_t)0xdc00); - const __m512i high = _mm512_set1_epi16((uint16_t)0xdfff); + const __m512i low = _mm512_set1_epi16((uint16_t)0xdc00); + const __m512i high = _mm512_set1_epi16((uint16_t)0xdfff); - size_t count{0}; + size_t count { 0 }; - while (ptr <= end) { - __m512i utf16 = _mm512_loadu_si512((const __m512i*)ptr); - ptr += 32; - uint64_t not_high_surrogate = static_cast(_mm512_cmpgt_epu16_mask(utf16, high) | _mm512_cmplt_epu16_mask(utf16, low)); - count += count_ones(not_high_surrogate); - } + while (ptr <= end) { + __m512i utf16 = _mm512_loadu_si512((const __m512i*)ptr); + ptr += 32; + uint64_t not_high_surrogate = static_cast(_mm512_cmpgt_epu16_mask(utf16, high) | _mm512_cmplt_epu16_mask(utf16, low)); + count += count_ones(not_high_surrogate); + } - return count + scalar::utf16::count_code_points(ptr, length - (ptr - input)); + return count + scalar::utf16::count_code_points(ptr, length - (ptr - input)); } -simdutf_warn_unused size_t implementation::count_utf16be(const char16_t * input, size_t length) const noexcept { - const char16_t* end = length >= 32 ? input + length - 32 : nullptr; - const char16_t* ptr = input; +simdutf_warn_unused size_t implementation::count_utf16be(const char16_t* input, size_t length) const noexcept +{ + const char16_t* end = length >= 32 ? input + length - 32 : nullptr; + const char16_t* ptr = input; - const __m512i low = _mm512_set1_epi16((uint16_t)0xdc00); - const __m512i high = _mm512_set1_epi16((uint16_t)0xdfff); + const __m512i low = _mm512_set1_epi16((uint16_t)0xdc00); + const __m512i high = _mm512_set1_epi16((uint16_t)0xdfff); - size_t count{0}; - const __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); - while (ptr <= end) { - __m512i utf16 = _mm512_shuffle_epi8(_mm512_loadu_si512((__m512i*)ptr), byteflip); - ptr += 32; - uint64_t not_high_surrogate = static_cast(_mm512_cmpgt_epu16_mask(utf16, high) | _mm512_cmplt_epu16_mask(utf16, low)); - count += count_ones(not_high_surrogate); - } + size_t count { 0 }; + const __m512i byteflip = _mm512_setr_epi64( + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); + while (ptr <= end) { + __m512i utf16 = _mm512_shuffle_epi8(_mm512_loadu_si512((__m512i*)ptr), byteflip); + ptr += 32; + uint64_t not_high_surrogate = static_cast(_mm512_cmpgt_epu16_mask(utf16, high) | _mm512_cmplt_epu16_mask(utf16, low)); + count += count_ones(not_high_surrogate); + } - return count + scalar::utf16::count_code_points(ptr, length - (ptr - input)); + return count + scalar::utf16::count_code_points(ptr, length - (ptr - input)); } +simdutf_warn_unused size_t implementation::count_utf8(const char* input, size_t length) const noexcept +{ + const char* end = length >= 64 ? input + length - 64 : nullptr; + const char* ptr = input; -simdutf_warn_unused size_t implementation::count_utf8(const char * input, size_t length) const noexcept { - const char* end = length >= 64 ? input + length - 64 : nullptr; - const char* ptr = input; + const __m512i continuation = _mm512_set1_epi8(char(0b10111111)); - const __m512i continuation = _mm512_set1_epi8(char(0b10111111)); + size_t count { 0 }; + + while (ptr <= end) { + __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); + ptr += 64; + uint64_t continuation_bitmask = static_cast(_mm512_cmple_epi8_mask(utf8, continuation)); + count += 64 - count_ones(continuation_bitmask); + } - size_t count{0}; + return count + scalar::utf8::count_code_points(ptr, length - (ptr - input)); +} - while (ptr <= end) { - __m512i utf8 = _mm512_loadu_si512((const __m512i*)ptr); - ptr += 64; - uint64_t continuation_bitmask = static_cast(_mm512_cmple_epi8_mask(utf8, continuation)); - count += 64 - count_ones(continuation_bitmask); - } +simdutf_warn_unused size_t implementation::latin1_length_from_utf8(const char* buf, size_t len) const noexcept +{ + return scalar::utf8::latin1_length_from_utf8(buf, len); +} - return count + scalar::utf8::count_code_points(ptr, length - (ptr - input)); +simdutf_warn_unused size_t implementation::latin1_length_from_utf16(size_t length) const noexcept +{ + return scalar::utf16::latin1_length_from_utf16(length); } +simdutf_warn_unused size_t implementation::latin1_length_from_utf32(size_t length) const noexcept +{ + return scalar::utf32::latin1_length_from_utf32(length); +} -simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - const char16_t* end = length >= 32 ? input + length - 32 : nullptr; - const char16_t* ptr = input; +simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + const char16_t* end = length >= 32 ? input + length - 32 : nullptr; + const char16_t* ptr = input; - const __m512i v_007f = _mm512_set1_epi16((uint16_t)0x007f); - const __m512i v_07ff = _mm512_set1_epi16((uint16_t)0x07ff); - const __m512i v_dfff = _mm512_set1_epi16((uint16_t)0xdfff); - const __m512i v_d800 = _mm512_set1_epi16((uint16_t)0xd800); + const __m512i v_007f = _mm512_set1_epi16((uint16_t)0x007f); + const __m512i v_07ff = _mm512_set1_epi16((uint16_t)0x07ff); + const __m512i v_dfff = _mm512_set1_epi16((uint16_t)0xdfff); + const __m512i v_d800 = _mm512_set1_epi16((uint16_t)0xd800); - size_t count{0}; + size_t count { 0 }; - while (ptr <= end) { - __m512i utf16 = _mm512_loadu_si512((const __m512i*)ptr); - ptr += 32; - __mmask32 ascii_bitmask = _mm512_cmple_epu16_mask(utf16, v_007f); - __mmask32 two_bytes_bitmask = _mm512_mask_cmple_epu16_mask(~ascii_bitmask, utf16, v_07ff); - __mmask32 not_one_two_bytes = ~(ascii_bitmask | two_bytes_bitmask); - __mmask32 surrogates_bitmask = _mm512_mask_cmple_epu16_mask(not_one_two_bytes, utf16, v_dfff) & _mm512_mask_cmpge_epu16_mask(not_one_two_bytes, utf16, v_d800); + while (ptr <= end) { + __m512i utf16 = _mm512_loadu_si512((const __m512i*)ptr); + ptr += 32; + __mmask32 ascii_bitmask = _mm512_cmple_epu16_mask(utf16, v_007f); + __mmask32 two_bytes_bitmask = _mm512_mask_cmple_epu16_mask(~ascii_bitmask, utf16, v_07ff); + __mmask32 not_one_two_bytes = ~(ascii_bitmask | two_bytes_bitmask); + __mmask32 surrogates_bitmask = _mm512_mask_cmple_epu16_mask(not_one_two_bytes, utf16, v_dfff) & _mm512_mask_cmpge_epu16_mask(not_one_two_bytes, utf16, v_d800); - size_t ascii_count = count_ones(ascii_bitmask); - size_t two_bytes_count = count_ones(two_bytes_bitmask); - size_t surrogate_bytes_count = count_ones(surrogates_bitmask); - size_t three_bytes_count = 32 - ascii_count - two_bytes_count - surrogate_bytes_count; + size_t ascii_count = count_ones(ascii_bitmask); + size_t two_bytes_count = count_ones(two_bytes_bitmask); + size_t surrogate_bytes_count = count_ones(surrogates_bitmask); + size_t three_bytes_count = 32 - ascii_count - two_bytes_count - surrogate_bytes_count; - count += ascii_count + 2*two_bytes_count + 3*three_bytes_count + 2*surrogate_bytes_count; - } + count += ascii_count + 2 * two_bytes_count + 3 * three_bytes_count + 2 * surrogate_bytes_count; + } - return count + scalar::utf16::utf8_length_from_utf16(ptr, length - (ptr - input)); + return count + scalar::utf16::utf8_length_from_utf16(ptr, length - (ptr - input)); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - const char16_t* end = length >= 32 ? input + length - 32 : nullptr; - const char16_t* ptr = input; +simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + const char16_t* end = length >= 32 ? input + length - 32 : nullptr; + const char16_t* ptr = input; - const __m512i v_007f = _mm512_set1_epi16((uint16_t)0x007f); - const __m512i v_07ff = _mm512_set1_epi16((uint16_t)0x07ff); - const __m512i v_dfff = _mm512_set1_epi16((uint16_t)0xdfff); - const __m512i v_d800 = _mm512_set1_epi16((uint16_t)0xd800); + const __m512i v_007f = _mm512_set1_epi16((uint16_t)0x007f); + const __m512i v_07ff = _mm512_set1_epi16((uint16_t)0x07ff); + const __m512i v_dfff = _mm512_set1_epi16((uint16_t)0xdfff); + const __m512i v_d800 = _mm512_set1_epi16((uint16_t)0xd800); - size_t count{0}; - const __m512i byteflip = _mm512_setr_epi64( - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809, - 0x0607040502030001, - 0x0e0f0c0d0a0b0809 - ); - while (ptr <= end) { - __m512i utf16 = _mm512_loadu_si512((const __m512i*)ptr); - utf16 = _mm512_shuffle_epi8(utf16, byteflip); - ptr += 32; - __mmask32 ascii_bitmask = _mm512_cmple_epu16_mask(utf16, v_007f); - __mmask32 two_bytes_bitmask = _mm512_mask_cmple_epu16_mask(~ascii_bitmask, utf16, v_07ff); - __mmask32 not_one_two_bytes = ~(ascii_bitmask | two_bytes_bitmask); - __mmask32 surrogates_bitmask = _mm512_mask_cmple_epu16_mask(not_one_two_bytes, utf16, v_dfff) & _mm512_mask_cmpge_epu16_mask(not_one_two_bytes, utf16, v_d800); + size_t count { 0 }; + const __m512i byteflip = _mm512_setr_epi64( + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809, + 0x0607040502030001, + 0x0e0f0c0d0a0b0809); + while (ptr <= end) { + __m512i utf16 = _mm512_loadu_si512((const __m512i*)ptr); + utf16 = _mm512_shuffle_epi8(utf16, byteflip); + ptr += 32; + __mmask32 ascii_bitmask = _mm512_cmple_epu16_mask(utf16, v_007f); + __mmask32 two_bytes_bitmask = _mm512_mask_cmple_epu16_mask(~ascii_bitmask, utf16, v_07ff); + __mmask32 not_one_two_bytes = ~(ascii_bitmask | two_bytes_bitmask); + __mmask32 surrogates_bitmask = _mm512_mask_cmple_epu16_mask(not_one_two_bytes, utf16, v_dfff) & _mm512_mask_cmpge_epu16_mask(not_one_two_bytes, utf16, v_d800); + + size_t ascii_count = count_ones(ascii_bitmask); + size_t two_bytes_count = count_ones(two_bytes_bitmask); + size_t surrogate_bytes_count = count_ones(surrogates_bitmask); + size_t three_bytes_count = 32 - ascii_count - two_bytes_count - surrogate_bytes_count; + count += ascii_count + 2 * two_bytes_count + 3 * three_bytes_count + 2 * surrogate_bytes_count; + } + + return count + scalar::utf16::utf8_length_from_utf16(ptr, length - (ptr - input)); +} + +simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return implementation::count_utf16le(input, length); +} - size_t ascii_count = count_ones(ascii_bitmask); - size_t two_bytes_count = count_ones(two_bytes_bitmask); - size_t surrogate_bytes_count = count_ones(surrogates_bitmask); - size_t three_bytes_count = 32 - ascii_count - two_bytes_count - surrogate_bytes_count; - count += ascii_count + 2*two_bytes_count + 3*three_bytes_count + 2*surrogate_bytes_count; - } +simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return implementation::count_utf16be(input, length); +} - return count + scalar::utf16::utf8_length_from_utf16(ptr, length - (ptr - input)); +simdutf_warn_unused size_t implementation::utf16_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf16_length_from_latin1(length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return implementation::count_utf16le(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf32_length_from_latin1(length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return implementation::count_utf16be(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_latin1(const char* input, size_t length) const noexcept +{ + return scalar::latin1::utf8_length_from_latin1(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char * input, size_t length) const noexcept { +simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char* input, size_t length) const noexcept +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 64 <= length; pos += 64) { - __m512i utf8 = _mm512_loadu_si512((const __m512i*)(input+pos)); - uint64_t utf8_continuation_mask = _mm512_cmple_epi8_mask(utf8, _mm512_set1_epi8(-65+1)); - // We count one word for anything that is not a continuation (so - // leading bytes). - count += 64 - count_ones(utf8_continuation_mask); - uint64_t utf8_4byte = _mm512_cmpge_epu8_mask(utf8, _mm512_set1_epi8(int8_t(240))); - count += count_ones(utf8_4byte); + for (; pos + 64 <= length; pos += 64) { + __m512i utf8 = _mm512_loadu_si512((const __m512i*)(input + pos)); + uint64_t utf8_continuation_mask = _mm512_cmple_epi8_mask(utf8, _mm512_set1_epi8(-65 + 1)); + // We count one word for anything that is not a continuation (so + // leading bytes). + count += 64 - count_ones(utf8_continuation_mask); + uint64_t utf8_4byte = _mm512_cmpge_epu8_mask(utf8, _mm512_set1_epi8(int8_t(240))); + count += count_ones(utf8_4byte); } return count + scalar::utf8::utf16_length_from_utf8(input + pos, length - pos); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept { - const char32_t* end = length >= 16 ? input + length - 16 : nullptr; - const char32_t* ptr = input; +simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + const char32_t* end = length >= 16 ? input + length - 16 : nullptr; + const char32_t* ptr = input; - const __m512i v_0000_007f = _mm512_set1_epi32((uint32_t)0x7f); - const __m512i v_0000_07ff = _mm512_set1_epi32((uint32_t)0x7ff); - const __m512i v_0000_ffff = _mm512_set1_epi32((uint32_t)0x0000ffff); + const __m512i v_0000_007f = _mm512_set1_epi32((uint32_t)0x7f); + const __m512i v_0000_07ff = _mm512_set1_epi32((uint32_t)0x7ff); + const __m512i v_0000_ffff = _mm512_set1_epi32((uint32_t)0x0000ffff); - size_t count{0}; + size_t count { 0 }; - while (ptr <= end) { - __m512i utf32 = _mm512_loadu_si512((const __m512i*)ptr); - ptr += 16; - __mmask16 ascii_bitmask = _mm512_cmple_epu32_mask(utf32, v_0000_007f); - __mmask16 two_bytes_bitmask = _mm512_mask_cmple_epu32_mask(_knot_mask16(ascii_bitmask), utf32, v_0000_07ff); - __mmask16 three_bytes_bitmask = _mm512_mask_cmple_epu32_mask(_knot_mask16(_mm512_kor(ascii_bitmask, two_bytes_bitmask)), utf32, v_0000_ffff); + while (ptr <= end) { + __m512i utf32 = _mm512_loadu_si512((const __m512i*)ptr); + ptr += 16; + __mmask16 ascii_bitmask = _mm512_cmple_epu32_mask(utf32, v_0000_007f); + __mmask16 two_bytes_bitmask = _mm512_mask_cmple_epu32_mask(_knot_mask16(ascii_bitmask), utf32, v_0000_07ff); + __mmask16 three_bytes_bitmask = _mm512_mask_cmple_epu32_mask(_knot_mask16(_mm512_kor(ascii_bitmask, two_bytes_bitmask)), utf32, v_0000_ffff); - size_t ascii_count = count_ones(ascii_bitmask); - size_t two_bytes_count = count_ones(two_bytes_bitmask); - size_t three_bytes_count = count_ones(three_bytes_bitmask); - size_t four_bytes_count = 16 - ascii_count - two_bytes_count - three_bytes_count; - count += ascii_count + 2*two_bytes_count + 3*three_bytes_count + 4*four_bytes_count; - } + size_t ascii_count = count_ones(ascii_bitmask); + size_t two_bytes_count = count_ones(two_bytes_bitmask); + size_t three_bytes_count = count_ones(three_bytes_bitmask); + size_t four_bytes_count = 16 - ascii_count - two_bytes_count - three_bytes_count; + count += ascii_count + 2 * two_bytes_count + 3 * three_bytes_count + 4 * four_bytes_count; + } - return count + scalar::utf32::utf8_length_from_utf32(ptr, length - (ptr - input)); + return count + scalar::utf32::utf8_length_from_utf32(ptr, length - (ptr - input)); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept { - const char32_t* end = length >= 16 ? input + length - 16 : nullptr; - const char32_t* ptr = input; +simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + const char32_t* end = length >= 16 ? input + length - 16 : nullptr; + const char32_t* ptr = input; - const __m512i v_0000_ffff = _mm512_set1_epi32((uint32_t)0x0000ffff); + const __m512i v_0000_ffff = _mm512_set1_epi32((uint32_t)0x0000ffff); - size_t count{0}; + size_t count { 0 }; - while (ptr <= end) { - __m512i utf32 = _mm512_loadu_si512((const __m512i*)ptr); - ptr += 16; - __mmask16 surrogates_bitmask = _mm512_cmpgt_epu32_mask(utf32, v_0000_ffff); + while (ptr <= end) { + __m512i utf32 = _mm512_loadu_si512((const __m512i*)ptr); + ptr += 16; + __mmask16 surrogates_bitmask = _mm512_cmpgt_epu32_mask(utf32, v_0000_ffff); - count += 16 + count_ones(surrogates_bitmask); - } + count += 16 + count_ones(surrogates_bitmask); + } - return count + scalar::utf32::utf16_length_from_utf32(ptr, length - (ptr - input)); + return count + scalar::utf32::utf16_length_from_utf32(ptr, length - (ptr - input)); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char * input, size_t length) const noexcept { - return implementation::count_utf8(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char* input, size_t length) const noexcept +{ + return implementation::count_utf8(input, length); } } // namespace icelake } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/icelake/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/icelake/end.h /* begin file src/simdutf/icelake/end.h */ #if SIMDUTF_CAN_ALWAYS_RUN_ICELAKE // nothing needed. @@ -19194,7 +22154,6 @@ simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char * i SIMDUTF_UNTARGET_REGION #endif - #if SIMDUTF_GCC11ORMORE // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593 SIMDUTF_POP_DISABLE_WARNINGS #endif // end of workaround @@ -19202,10 +22161,10 @@ SIMDUTF_POP_DISABLE_WARNINGS /* end file src/icelake/implementation.cpp */ #endif #if SIMDUTF_IMPLEMENTATION_HASWELL -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/implementation.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/implementation.cpp /* begin file src/haswell/implementation.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/begin.h /* begin file src/simdutf/haswell/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "haswell" // #define SIMDUTF_IMPLEMENTATION haswell @@ -19217,7 +22176,7 @@ SIMDUTF_TARGET_HASWELL #endif #if SIMDUTF_GCC11ORMORE // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593 -SIMDUTF_DISABLE_GCC_WARNING(-Wmaybe-uninitialized) +SIMDUTF_DISABLE_GCC_WARNING(-Wmaybe - uninitialized) #endif // end of workaround /* end file src/simdutf/haswell/begin.h */ namespace simdutf { @@ -19228,31 +22187,34 @@ namespace { #endif using namespace simd; - -simdutf_really_inline bool is_ascii(const simd8x64& input) { - return input.reduce_or().is_ascii(); +simdutf_really_inline bool is_ascii(const simd8x64& input) +{ + return input.reduce_or().is_ascii(); } -simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { - simd8 is_second_byte = prev1.saturating_sub(0b11000000u-1); // Only 11______ will be > 0 - simd8 is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); +simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) +{ + simd8 is_second_byte = prev1.saturating_sub(0b11000000u - 1); // Only 11______ will be > 0 + simd8 is_third_byte = prev2.saturating_sub(0b11100000u - 1); // Only 111_____ will be > 0 + simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u - 1); // Only 1111____ will be > 0 + // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. + return simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); } -simdutf_really_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_third_byte | is_fourth_byte) > int8_t(0); +simdutf_really_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) +{ + simd8 is_third_byte = prev2.saturating_sub(0b11100000u - 1); // Only 111_____ will be > 0 + simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u - 1); // Only 1111____ will be > 0 + // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. + return simd8(is_third_byte | is_fourth_byte) > int8_t(0); } -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_detect_encodings.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_detect_encodings.cpp /* begin file src/haswell/avx2_detect_encodings.cpp */ template // len is known to be a multiple of 2 when this is called -int avx2_detect_encodings(const char * buf, size_t len) { +int avx2_detect_encodings(const char* buf, size_t len) +{ const char* start = buf; const char* end = buf + len; @@ -19267,11 +22229,11 @@ int avx2_detect_encodings(const char * buf, size_t len) { __m256i currentmax = _mm256_setzero_si256(); - checker check{}; + checker check {}; - while(buf + 64 <= end) { + while (buf + 64 <= end) { __m256i in = _mm256_loadu_si256((__m256i*)buf); - __m256i nextin = _mm256_loadu_si256((__m256i*)buf+1); + __m256i nextin = _mm256_loadu_si256((__m256i*)buf + 1); const auto u0 = simd16(in); const auto u1 = simd16(nextin); @@ -19297,15 +22259,15 @@ int avx2_detect_encodings(const char * buf, size_t len) { if ((surrogates_bitmask0 & 0xaaaaaaaa) != 0) { is_utf32 = false; // Code from avx2_validate_utf16le.cpp - const char16_t * input = reinterpret_cast(buf); - const char16_t* end16 = reinterpret_cast(start) + len/2; + const char16_t* input = reinterpret_cast(buf); + const char16_t* end16 = reinterpret_cast(start) + len / 2; const auto v_fc = simd8::splat(0xfc); const auto v_dc = simd8::splat(0xdc); const uint32_t V0 = ~surrogates_bitmask0; - const auto vH0 = (in16 & v_fc) == v_dc; + const auto vH0 = (in16 & v_fc) == v_dc; const uint32_t H0 = vH0.to_bitmask(); const uint32_t L0 = ~H0 & surrogates_bitmask0; @@ -19338,7 +22300,7 @@ int avx2_detect_encodings(const char * buf, size_t len) { } else { const uint32_t V = ~surrogates_bitmask; - const auto vH = (in_16 & v_fc) == v_dc; + const auto vH = (in_16 & v_fc) == v_dc; const uint32_t H = vH.to_bitmask(); const uint32_t L = ~H & surrogates_bitmask; @@ -19362,8 +22324,8 @@ int avx2_detect_encodings(const char * buf, size_t len) { is_utf16 = false; // Check for UTF-32 if (len % 4 == 0) { - const char32_t * input = reinterpret_cast(buf); - const char32_t* end32 = reinterpret_cast(start) + len/4; + const char32_t* input = reinterpret_cast(buf); + const char32_t* end32 = reinterpret_cast(start) + len / 4; // Must start checking for surrogates __m256i currentoffsetmax = _mm256_setzero_si256(); @@ -19377,14 +22339,14 @@ int avx2_detect_encodings(const char * buf, size_t len) { currentoffsetmax = _mm256_max_epu32(_mm256_add_epi32(nextin, offset), currentoffsetmax); while (input + 8 < end32) { - const __m256i in32 = _mm256_loadu_si256((__m256i *)input); - currentmax = _mm256_max_epu32(in32,currentmax); + const __m256i in32 = _mm256_loadu_si256((__m256i*)input); + currentmax = _mm256_max_epu32(in32, currentmax); currentoffsetmax = _mm256_max_epu32(_mm256_add_epi32(in32, offset), currentoffsetmax); input += 8; } __m256i forbidden_words = _mm256_xor_si256(_mm256_max_epu32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(_mm256_testz_si256(forbidden_words, forbidden_words) == 0) { + if (_mm256_testz_si256(forbidden_words, forbidden_words) == 0) { return simdutf::encoding_type::unspecified; } } else { @@ -19411,7 +22373,7 @@ int avx2_detect_encodings(const char * buf, size_t len) { if (is_utf8) { if (static_cast(buf - start) != len) { - uint8_t block[64]{}; + uint8_t block[64] {}; std::memset(block, 0x20, 64); std::memcpy(block, buf, len - (buf - start)); simd::simd8x64 in(block); @@ -19422,14 +22384,14 @@ int avx2_detect_encodings(const char * buf, size_t len) { } } - if (is_utf16 && scalar::utf16::validate(reinterpret_cast(buf), (len - (buf - start))/2)) { + if (is_utf16 && scalar::utf16::validate(reinterpret_cast(buf), (len - (buf - start)) / 2)) { out |= simdutf::encoding_type::UTF16_LE; } if (is_utf32 && (len % 4 == 0)) { const __m256i standardmax = _mm256_set1_epi32(0x10ffff); __m256i is_zero = _mm256_xor_si256(_mm256_max_epu32(currentmax, standardmax), standardmax); - if (_mm256_testz_si256(is_zero, is_zero) == 1 && scalar::utf32::validate(reinterpret_cast(buf), (len - (buf - start))/4)) { + if (_mm256_testz_si256(is_zero, is_zero) == 1 && scalar::utf32::validate(reinterpret_cast(buf), (len - (buf - start)) / 4)) { out |= simdutf::encoding_type::UTF32_LE; } } @@ -19438,7 +22400,7 @@ int avx2_detect_encodings(const char * buf, size_t len) { } /* end file src/haswell/avx2_detect_encodings.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_validate_utf16.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_validate_utf16.cpp /* begin file src/haswell/avx2_validate_utf16.cpp */ /* In UTF-16 words in range 0xD800 to 0xDFFF have special meaning. @@ -19485,8 +22447,9 @@ int avx2_detect_encodings(const char * buf, size_t len) { - pointer to the last unprocessed character (a scalar fallback should check the rest); - nullptr if an error was detected. */ -template -const char16_t* avx2_validate_utf16(const char16_t* input, size_t size) { +template +const char16_t* avx2_validate_utf16(const char16_t* input, size_t size) +{ const char16_t* end = input + size; const auto v_d8 = simd8::splat(0xd8); @@ -19528,19 +22491,19 @@ const char16_t* avx2_validate_utf16(const char16_t* input, size_t size) { const uint32_t V = ~surrogates_bitmask; // H - word-mask for high surrogates: the six highest bits are 0b1101'11 - const auto vH = (in & v_fc) == v_dc; + const auto vH = (in & v_fc) == v_dc; const uint32_t H = vH.to_bitmask(); // L - word mask for low surrogates // L = not H and surrogates_wordmask const uint32_t L = ~H & surrogates_bitmask; - const uint32_t a = L & (H >> 1); // A low surrogate must be followed by high one. - // (A low surrogate placed in the 7th register's word - // is an exception we handle.) - const uint32_t b = a << 1; // Just mark that the opposite fact is hold, - // thanks to that we have only two masks for valid case. - const uint32_t c = V | a | b; // Combine all the masks into the final one. + const uint32_t a = L & (H >> 1); // A low surrogate must be followed by high one. + // (A low surrogate placed in the 7th register's word + // is an exception we handle.) + const uint32_t b = a << 1; // Just mark that the opposite fact is hold, + // thanks to that we have only two masks for valid case. + const uint32_t c = V | a | b; // Combine all the masks into the final one. if (c == 0xffffffff) { // The whole input register contains valid UTF-16, i.e., @@ -19561,9 +22524,9 @@ const char16_t* avx2_validate_utf16(const char16_t* input, size_t size) { return input; } - -template -const result avx2_validate_utf16_with_errors(const char16_t* input, size_t size) { +template +const result avx2_validate_utf16_with_errors(const char16_t* input, size_t size) +{ const char16_t* start = input; const char16_t* end = input + size; @@ -19606,19 +22569,19 @@ const result avx2_validate_utf16_with_errors(const char16_t* input, size_t size) const uint32_t V = ~surrogates_bitmask; // H - word-mask for high surrogates: the six highest bits are 0b1101'11 - const auto vH = (in & v_fc) == v_dc; + const auto vH = (in & v_fc) == v_dc; const uint32_t H = vH.to_bitmask(); // L - word mask for low surrogates // L = not H and surrogates_wordmask const uint32_t L = ~H & surrogates_bitmask; - const uint32_t a = L & (H >> 1); // A low surrogate must be followed by high one. - // (A low surrogate placed in the 7th register's word - // is an exception we handle.) - const uint32_t b = a << 1; // Just mark that the opposite fact is hold, - // thanks to that we have only two masks for valid case. - const uint32_t c = V | a | b; // Combine all the masks into the final one. + const uint32_t a = L & (H >> 1); // A low surrogate must be followed by high one. + // (A low surrogate placed in the 7th register's word + // is an exception we handle.) + const uint32_t b = a << 1; // Just mark that the opposite fact is hold, + // thanks to that we have only two masks for valid case. + const uint32_t c = V | a | b; // Combine all the masks into the final one. if (c == 0xffffffff) { // The whole input register contains valid UTF-16, i.e., @@ -19639,13 +22602,14 @@ const result avx2_validate_utf16_with_errors(const char16_t* input, size_t size) return result(error_code::SUCCESS, input - start); } /* end file src/haswell/avx2_validate_utf16.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_validate_utf32le.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_validate_utf32le.cpp /* begin file src/haswell/avx2_validate_utf32le.cpp */ /* Returns: - pointer to the last unprocessed character (a scalar fallback should check the rest); - nullptr if an error was detected. */ -const char32_t* avx2_validate_utf32le(const char32_t* input, size_t size) { +const char32_t* avx2_validate_utf32le(const char32_t* input, size_t size) +{ const char32_t* end = input + size; const __m256i standardmax = _mm256_set1_epi32(0x10ffff); @@ -19655,26 +22619,26 @@ const char32_t* avx2_validate_utf32le(const char32_t* input, size_t size) { __m256i currentoffsetmax = _mm256_setzero_si256(); while (input + 8 < end) { - const __m256i in = _mm256_loadu_si256((__m256i *)input); - currentmax = _mm256_max_epu32(in,currentmax); + const __m256i in = _mm256_loadu_si256((__m256i*)input); + currentmax = _mm256_max_epu32(in, currentmax); currentoffsetmax = _mm256_max_epu32(_mm256_add_epi32(in, offset), currentoffsetmax); input += 8; } __m256i is_zero = _mm256_xor_si256(_mm256_max_epu32(currentmax, standardmax), standardmax); - if(_mm256_testz_si256(is_zero, is_zero) == 0) { + if (_mm256_testz_si256(is_zero, is_zero) == 0) { return nullptr; } is_zero = _mm256_xor_si256(_mm256_max_epu32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(_mm256_testz_si256(is_zero, is_zero) == 0) { + if (_mm256_testz_si256(is_zero, is_zero) == 0) { return nullptr; } return input; } - -const result avx2_validate_utf32le_with_errors(const char32_t* input, size_t size) { +const result avx2_validate_utf32le_with_errors(const char32_t* input, size_t size) +{ const char32_t* start = input; const char32_t* end = input + size; @@ -19685,17 +22649,17 @@ const result avx2_validate_utf32le_with_errors(const char32_t* input, size_t siz __m256i currentoffsetmax = _mm256_setzero_si256(); while (input + 8 < end) { - const __m256i in = _mm256_loadu_si256((__m256i *)input); - currentmax = _mm256_max_epu32(in,currentmax); + const __m256i in = _mm256_loadu_si256((__m256i*)input); + currentmax = _mm256_max_epu32(in, currentmax); currentoffsetmax = _mm256_max_epu32(_mm256_add_epi32(in, offset), currentoffsetmax); __m256i is_zero = _mm256_xor_si256(_mm256_max_epu32(currentmax, standardmax), standardmax); - if(_mm256_testz_si256(is_zero, is_zero) == 0) { + if (_mm256_testz_si256(is_zero, is_zero) == 0) { return result(error_code::TOO_LARGE, input - start); } is_zero = _mm256_xor_si256(_mm256_max_epu32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(_mm256_testz_si256(is_zero, is_zero) == 0) { + if (_mm256_testz_si256(is_zero, is_zero) == 0) { return result(error_code::SURROGATE, input - start); } input += 8; @@ -19705,303 +22669,286 @@ const result avx2_validate_utf32le_with_errors(const char32_t* input, size_t siz } /* end file src/haswell/avx2_validate_utf32le.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_convert_utf8_to_utf16.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_convert_utf8_to_utf16.cpp /* begin file src/haswell/avx2_convert_utf8_to_utf16.cpp */ // depends on "tables/utf8_to_utf16_tables.h" - // Convert up to 12 bytes from utf8 to utf16 using a mask indicating the // end of the code points. Only the least significant 12 bits of the mask // are accessed. // It returns how many bytes were consumed (up to 12). -template -size_t convert_masked_utf8_to_utf16(const char *input, - uint64_t utf8_end_of_code_point_mask, - char16_t *&utf16_output) { - // we use an approach where we try to process up to 12 input bytes. - // Why 12 input bytes and not 16? Because we are concerned with the size of - // the lookup tables. Also 12 is nicely divisible by two and three. - // - // - // Optimization note: our main path below is load-latency dependent. Thus it is maybe - // beneficial to have fast paths that depend on branch prediction but have less latency. - // This results in more instructions but, potentially, also higher speeds. - // - // We first try a few fast paths. - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - const __m128i in = _mm_loadu_si128((__m128i *)input); - const uint16_t input_utf8_end_of_code_point_mask = - utf8_end_of_code_point_mask & 0xfff; - if(((utf8_end_of_code_point_mask & 0xffff) == 0xffff)) { - // We process the data in chunks of 16 bytes. - __m256i ascii = _mm256_cvtepu8_epi16(in); - if (big_endian) { - const __m256i swap256 = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, - 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); - ascii = _mm256_shuffle_epi8(ascii, swap256); - } - _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii); - utf16_output += 16; // We wrote 16 16-bit characters. - return 16; // We consumed 16 bytes. - } - if(((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) { - // We want to take 8 2-byte UTF-8 words and turn them into 8 2-byte UTF-16 words. - // There is probably a more efficient sequence, but the following might do. - const __m128i sh = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); - __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); - if (big_endian) composed = _mm_shuffle_epi8(composed, swap); - _mm_storeu_si128((__m128i *)utf16_output, composed); - utf16_output += 8; // We wrote 16 bytes, 8 code points. - return 16; - } - if(input_utf8_end_of_code_point_mask == 0x924) { - // We want to take 4 3-byte UTF-8 words and turn them into 4 2-byte UTF-16 words. - // There is probably a more efficient sequence, but the following might do. - const __m128i sh = _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = - _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits - const __m128i middlebyte = - _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - const __m128i highbyte = - _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); - __m128i composed_repacked = _mm_packus_epi32(composed, composed); - if (big_endian) composed_repacked = _mm_shuffle_epi8(composed_repacked, swap); - _mm_storeu_si128((__m128i *)utf16_output, composed_repacked); - utf16_output += 4; - return 12; - } - - const uint8_t idx = - simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; - const uint8_t consumed = - simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; - if (idx < 64) { - // SIX (6) input code-words - // this is a relatively easy scenario - // we process SIX (6) input code-words. The max length in bytes of six code - // words spanning between 1 and 2 bytes each is 12 bytes. On processors - // where pdep/pext is fast, we might be able to use a small lookup table. - const __m128i sh = - _mm_loadu_si128((const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); - __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); - if (big_endian) composed = _mm_shuffle_epi8(composed, swap); - _mm_storeu_si128((__m128i *)utf16_output, composed); - utf16_output += 6; // We wrote 12 bytes, 6 code points. - } else if (idx < 145) { - // FOUR (4) input code-words - const __m128i sh = - _mm_loadu_si128((const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = - _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits - const __m128i middlebyte = - _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - const __m128i highbyte = - _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); - __m128i composed_repacked = _mm_packus_epi32(composed, composed); - if (big_endian) composed_repacked = _mm_shuffle_epi8(composed_repacked, swap); - _mm_storeu_si128((__m128i *)utf16_output, composed_repacked); - utf16_output += 4; - } else if (idx < 209) { - // TWO (2) input code-words - const __m128i sh = - _mm_loadu_si128((const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); - const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000)); - // correct for spurious high bit - const __m128i correct = - _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1); - middlehighbyte = _mm_xor_si128(correct, middlehighbyte); - const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000)); - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), - _mm_or_si128(highbyte_shifted, middlehighbyte_shifted)); - const __m128i composedminus = - _mm_sub_epi32(composed, _mm_set1_epi32(0x10000)); - const __m128i lowtenbits = - _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff)); - const __m128i hightenbits = _mm_srli_epi32(composedminus, 10); - const __m128i lowtenbitsadd = - _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00)); - const __m128i hightenbitsadd = - _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800)); - const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16); - __m128i surrogates = - _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted); - uint32_t basic_buffer[4]; - uint32_t basic_buffer_swap[4]; - if (big_endian) { - _mm_storeu_si128((__m128i *)basic_buffer_swap, _mm_shuffle_epi8(composed, swap)); - surrogates = _mm_shuffle_epi8(surrogates, swap); - } - _mm_storeu_si128((__m128i *)basic_buffer, composed); - uint32_t surrogate_buffer[4]; - _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates); - for (size_t i = 0; i < 3; i++) { - if (basic_buffer[i] < 65536) { - utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i]) : uint16_t(basic_buffer[i]); - utf16_output++; - } else { - utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff); - utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16); - utf16_output += 2; - } - } - } else { - // here we know that there is an error but we do not handle errors - } - return consumed; +template +size_t convert_masked_utf8_to_utf16(const char* input, + uint64_t utf8_end_of_code_point_mask, + char16_t*& utf16_output) +{ + // we use an approach where we try to process up to 12 input bytes. + // Why 12 input bytes and not 16? Because we are concerned with the size of + // the lookup tables. Also 12 is nicely divisible by two and three. + // + // + // Optimization note: our main path below is load-latency dependent. Thus it is maybe + // beneficial to have fast paths that depend on branch prediction but have less latency. + // This results in more instructions but, potentially, also higher speeds. + // + // We first try a few fast paths. + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + const __m128i in = _mm_loadu_si128((__m128i*)input); + const uint16_t input_utf8_end_of_code_point_mask = utf8_end_of_code_point_mask & 0xfff; + if (((utf8_end_of_code_point_mask & 0xffff) == 0xffff)) { + // We process the data in chunks of 16 bytes. + __m256i ascii = _mm256_cvtepu8_epi16(in); + if (big_endian) { + const __m256i swap256 = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, + 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); + ascii = _mm256_shuffle_epi8(ascii, swap256); + } + _mm256_storeu_si256(reinterpret_cast<__m256i*>(utf16_output), ascii); + utf16_output += 16; // We wrote 16 16-bit characters. + return 16; // We consumed 16 bytes. + } + if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) { + // We want to take 8 2-byte UTF-8 words and turn them into 8 2-byte UTF-16 words. + // There is probably a more efficient sequence, but the following might do. + const __m128i sh = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); + __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); + if (big_endian) + composed = _mm_shuffle_epi8(composed, swap); + _mm_storeu_si128((__m128i*)utf16_output, composed); + utf16_output += 8; // We wrote 16 bytes, 8 code points. + return 16; + } + if (input_utf8_end_of_code_point_mask == 0x924) { + // We want to take 4 3-byte UTF-8 words and turn them into 4 2-byte UTF-16 words. + // There is probably a more efficient sequence, but the following might do. + const __m128i sh = _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); + __m128i composed_repacked = _mm_packus_epi32(composed, composed); + if (big_endian) + composed_repacked = _mm_shuffle_epi8(composed_repacked, swap); + _mm_storeu_si128((__m128i*)utf16_output, composed_repacked); + utf16_output += 4; + return 12; + } + + const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; + const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; + if (idx < 64) { + // SIX (6) input code-words + // this is a relatively easy scenario + // we process SIX (6) input code-words. The max length in bytes of six code + // words spanning between 1 and 2 bytes each is 12 bytes. On processors + // where pdep/pext is fast, we might be able to use a small lookup table. + const __m128i sh = _mm_loadu_si128((const __m128i*)simdutf::tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); + __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); + if (big_endian) + composed = _mm_shuffle_epi8(composed, swap); + _mm_storeu_si128((__m128i*)utf16_output, composed); + utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential overflow of 4 bytes. + } else if (idx < 145) { + // FOUR (4) input code-words + const __m128i sh = _mm_loadu_si128((const __m128i*)simdutf::tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); + __m128i composed_repacked = _mm_packus_epi32(composed, composed); + if (big_endian) + composed_repacked = _mm_shuffle_epi8(composed_repacked, swap); + _mm_storeu_si128((__m128i*)utf16_output, composed_repacked); + utf16_output += 4; // Here we overflow by 8 bytes. + } else if (idx < 209) { + // TWO (2) input code-words + ////////////// + // There might be garbage inputs where a leading byte mascarades as a four-byte + // leading byte (by being followed by 3 continuation byte), but is not greater than + // 0xf0. This could trigger a buffer overflow if we only counted leading + // bytes of the form 0xf0 as generating surrogate pairs, without further UTF-8 validation. + // Thus we must be careful to ensure that only leading bytes at least as large as 0xf0 generate surrogate pairs. + // We do as at the cost of an extra mask. + ///////////// + const __m128i sh = _mm_loadu_si128((const __m128i*)simdutf::tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000)); + // correct for spurious high bit + const __m128i correct = _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1); + middlehighbyte = _mm_xor_si128(correct, middlehighbyte); + const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4); + // We deliberately carry the leading four bits in highbyte if they are present, + // we remove them later when computing hightenbits. + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000)); + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6); + // When we need to generate a surrogate pair (leading byte > 0xF0), then + // the corresponding 32-bit value in 'composed' will be greater than + // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the + // location of the surrogate pairs. + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), + _mm_or_si128(highbyte_shifted, middlehighbyte_shifted)); + const __m128i composedminus = _mm_sub_epi32(composed, _mm_set1_epi32(0x10000)); + const __m128i lowtenbits = _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff)); + // Notice the 0x3ff mask: + const __m128i hightenbits = _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff)); + const __m128i lowtenbitsadd = _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00)); + const __m128i hightenbitsadd = _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800)); + const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16); + __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted); + uint32_t basic_buffer[4]; + uint32_t basic_buffer_swap[4]; + if (big_endian) { + _mm_storeu_si128((__m128i*)basic_buffer_swap, _mm_shuffle_epi8(composed, swap)); + surrogates = _mm_shuffle_epi8(surrogates, swap); + } + _mm_storeu_si128((__m128i*)basic_buffer, composed); + uint32_t surrogate_buffer[4]; + _mm_storeu_si128((__m128i*)surrogate_buffer, surrogates); + for (size_t i = 0; i < 3; i++) { + if (basic_buffer[i] > 0x3c00000) { + utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff); + utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16); + utf16_output += 2; + } else { + utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i]) : uint16_t(basic_buffer[i]); + utf16_output++; + } + } + } else { + // here we know that there is an error but we do not handle errors + } + return consumed; } /* end file src/haswell/avx2_convert_utf8_to_utf16.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_convert_utf8_to_utf32.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_convert_utf8_to_utf32.cpp /* begin file src/haswell/avx2_convert_utf8_to_utf32.cpp */ // depends on "tables/utf8_to_utf16_tables.h" - // Convert up to 12 bytes from utf8 to utf32 using a mask indicating the // end of the code points. Only the least significant 12 bits of the mask // are accessed. // It returns how many bytes were consumed (up to 12). -size_t convert_masked_utf8_to_utf32(const char *input, - uint64_t utf8_end_of_code_point_mask, - char32_t *&utf32_output) { - // we use an approach where we try to process up to 12 input bytes. - // Why 12 input bytes and not 16? Because we are concerned with the size of - // the lookup tables. Also 12 is nicely divisible by two and three. - // - // - // Optimization note: our main path below is load-latency dependent. Thus it is maybe - // beneficial to have fast paths that depend on branch prediction but have less latency. - // This results in more instructions but, potentially, also higher speeds. - // - // We first try a few fast paths. - const __m128i in = _mm_loadu_si128((__m128i *)input); - const uint16_t input_utf8_end_of_code_point_mask = - utf8_end_of_code_point_mask & 0xfff; - if(((utf8_end_of_code_point_mask & 0xffff) == 0xffff)) { - // We process the data in chunks of 16 bytes. - _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output), _mm256_cvtepu8_epi32(in)); - _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output+8), _mm256_cvtepu8_epi32(_mm_srli_si128(in,8))); - utf32_output += 16; // We wrote 16 32-bit characters. - return 16; // We consumed 16 bytes. - } - if(((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) { - // We want to take 8 2-byte UTF-8 words and turn them into 8 4-byte UTF-32 words. - // There is probably a more efficient sequence, but the following might do. - const __m128i sh = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); - const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); - _mm256_storeu_si256((__m256i *)utf32_output, _mm256_cvtepu16_epi32(composed)); - utf32_output += 8; // We wrote 16 bytes, 8 code points. - return 16; - } - if(input_utf8_end_of_code_point_mask == 0x924) { - // We want to take 4 3-byte UTF-8 words and turn them into 4 4-byte UTF-32 words. - // There is probably a more efficient sequence, but the following might do. - const __m128i sh = _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = - _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits - const __m128i middlebyte = - _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - const __m128i highbyte = - _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); - _mm_storeu_si128((__m128i *)utf32_output, composed); - utf32_output += 4; - return 12; - } - /// We do not have a fast path available, so we fallback. - - const uint8_t idx = - tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; - const uint8_t consumed = - tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; - if (idx < 64) { - // SIX (6) input code-words - // this is a relatively easy scenario - // we process SIX (6) input code-words. The max length in bytes of six code - // words spanning between 1 and 2 bytes each is 12 bytes. On processors - // where pdep/pext is fast, we might be able to use a small lookup table. - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); - const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); - _mm256_storeu_si256((__m256i *)utf32_output, _mm256_cvtepu16_epi32(composed)); - utf32_output += 6; // We wrote 12 bytes, 6 code points. - } else if (idx < 145) { - // FOUR (4) input code-words - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = - _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits - const __m128i middlebyte = - _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - const __m128i highbyte = - _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); - _mm_storeu_si128((__m128i *)utf32_output, composed); - utf32_output += 4; - } else if (idx < 209) { - // TWO (2) input code-words - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); - const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000)); - // correct for spurious high bit - const __m128i correct = - _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1); - middlehighbyte = _mm_xor_si128(correct, middlehighbyte); - const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000)); - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), - _mm_or_si128(highbyte_shifted, middlehighbyte_shifted)); - _mm_storeu_si128((__m128i *)utf32_output, composed); - utf32_output += 3; - } else { - // here we know that there is an error but we do not handle errors - } - return consumed; +size_t convert_masked_utf8_to_utf32(const char* input, + uint64_t utf8_end_of_code_point_mask, + char32_t*& utf32_output) +{ + // we use an approach where we try to process up to 12 input bytes. + // Why 12 input bytes and not 16? Because we are concerned with the size of + // the lookup tables. Also 12 is nicely divisible by two and three. + // + // + // Optimization note: our main path below is load-latency dependent. Thus it is maybe + // beneficial to have fast paths that depend on branch prediction but have less latency. + // This results in more instructions but, potentially, also higher speeds. + // + // We first try a few fast paths. + const __m128i in = _mm_loadu_si128((__m128i*)input); + const uint16_t input_utf8_end_of_code_point_mask = utf8_end_of_code_point_mask & 0xfff; + if (((utf8_end_of_code_point_mask & 0xffff) == 0xffff)) { + // We process the data in chunks of 16 bytes. + _mm256_storeu_si256(reinterpret_cast<__m256i*>(utf32_output), _mm256_cvtepu8_epi32(in)); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(utf32_output + 8), _mm256_cvtepu8_epi32(_mm_srli_si128(in, 8))); + utf32_output += 16; // We wrote 16 32-bit characters. + return 16; // We consumed 16 bytes. + } + if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) { + // We want to take 8 2-byte UTF-8 words and turn them into 8 4-byte UTF-32 words. + // There is probably a more efficient sequence, but the following might do. + const __m128i sh = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); + const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); + _mm256_storeu_si256((__m256i*)utf32_output, _mm256_cvtepu16_epi32(composed)); + utf32_output += 8; // We wrote 16 bytes, 8 code points. + return 16; + } + if (input_utf8_end_of_code_point_mask == 0x924) { + // We want to take 4 3-byte UTF-8 words and turn them into 4 4-byte UTF-32 words. + // There is probably a more efficient sequence, but the following might do. + const __m128i sh = _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); + _mm_storeu_si128((__m128i*)utf32_output, composed); + utf32_output += 4; + return 12; + } + /// We do not have a fast path available, so we fallback. + + const uint8_t idx = tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; + const uint8_t consumed = tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; + if (idx < 64) { + // SIX (6) input code-words + // this is a relatively easy scenario + // we process SIX (6) input code-words. The max length in bytes of six code + // words spanning between 1 and 2 bytes each is 12 bytes. On processors + // where pdep/pext is fast, we might be able to use a small lookup table. + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); + const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); + _mm256_storeu_si256((__m256i*)utf32_output, _mm256_cvtepu16_epi32(composed)); + utf32_output += 6; // We wrote 24 bytes, 6 code points. There is a potential + // overflow of 32 - 24 = 8 bytes. + } else if (idx < 145) { + // FOUR (4) input code-words + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); + _mm_storeu_si128((__m128i*)utf32_output, composed); + utf32_output += 4; + } else if (idx < 209) { + // TWO (2) input code-words + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000)); + // correct for spurious high bit + const __m128i correct = _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1); + middlehighbyte = _mm_xor_si128(correct, middlehighbyte); + const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000)); + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), + _mm_or_si128(highbyte_shifted, middlehighbyte_shifted)); + _mm_storeu_si128((__m128i*)utf32_output, composed); + utf32_output += 3; // We wrote 3 * 4 bytes, there is a potential overflow of 4 bytes. + } else { + // here we know that there is an error but we do not handle errors + } + return consumed; } /* end file src/haswell/avx2_convert_utf8_to_utf32.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_convert_utf16_to_utf8.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_convert_utf16_to_utf8.cpp /* begin file src/haswell/avx2_convert_utf16_to_utf8.cpp */ /* The vectorized algorithm works on single SSE register i.e., it @@ -20048,493 +22995,497 @@ size_t convert_masked_utf8_to_utf32(const char *input, Each entry occupies 17 bytes. - To summarize: - - We need two 256-entry tables that have 8704 bytes in total. -*/ + To summarize: + - We need two 256-entry tables that have 8704 bytes in total. +*/ + +/* + Returns a pair: the first unprocessed byte from buf and utf8_output + A scalar routing should carry on the conversion of the tail. +*/ +template +std::pair avx2_convert_utf16_to_utf8(const char16_t* buf, size_t len, char* utf8_output) +{ + const char16_t* end = buf + len; + const __m256i v_0000 = _mm256_setzero_si256(); + const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800); + const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800); + const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080); + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); + if (big_endian) { + const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, + 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); + in = _mm256_shuffle_epi8(in, swap); + } + // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes + const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80); + if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!! + // 1. pack the bytes + const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1)); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + // no bits set above 7th bit + const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000); + const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000); + const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); + if (one_or_two_bytes_bitmask == 0xffffffff) { + + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); + const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m256i t0 = _mm256_slli_epi16(in, 2); + // t1 = [000a|aaaa|0000|0000] + const __m256i t1 = _mm256_and_si256(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m256i t2 = _mm256_and_si256(in, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m256i t3 = _mm256_or_si256(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m256i t4 = _mm256_or_si256(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + const uint32_t M0 = one_byte_bitmask & 0x55555555; + const uint32_t M1 = M0 >> 7; + const uint32_t M2 = (M1 | M0) & 0x00ff00ff; + // 4. pack the bytes + + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; + const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >> 16)][0]; + + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); + + const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2)); + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); + utf8_output += row[0]; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed, 1)); + utf8_output += row_2[0]; + + // 6. adjust pointers + buf += 16; + continue; + } + // 1. Check if there are any surrogate word in the input chunk. + // We have also deal with situation when there is a surrogate word + // at the end of a chunk. + const __m256i surrogates_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800); + + // bitmask = 0x0000 if there are no surrogates + // = 0xc000 if the last word is a surrogate + const uint32_t surrogates_bitmask = static_cast(_mm256_movemask_epi8(surrogates_bytemask)); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (surrogates_bitmask == 0x00000000) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, + 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm256_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m256i t0 = _mm256_shuffle_epi8(in, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m256i s0 = _mm256_srli_epi16(in, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000)); + const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m256i s4 = _mm256_xor_si256(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); + const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint32_t mask = (one_byte_bitmask & 0x55555555) | (one_or_two_bytes_bitmask & 0xaaaaaaaa); + // Due to the wider registers, the following path is less likely to be useful. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); + const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); + const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); + utf8_output += 12; + buf += 16; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); + + const uint8_t mask2 = static_cast(mask >> 16); + const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; + const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); + const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2); + + const uint8_t mask3 = static_cast(mask >> 24); + const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; + const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); + const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_2); + utf8_output += row2[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_3); + utf8_output += row3[0]; + buf += 16; + // surrogate pair(s) in a register + } else { + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xF800) != 0xD800) { + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(nullptr, utf8_output); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while + return std::make_pair(buf, utf8_output); +} + +/* + Returns a pair: a result struct and utf8_output. + If there is an error, the count field of the result is the position of the error. + Otherwise, it is the position of the first unprocessed byte in buf (even if finished). + A scalar routing should carry on the conversion of the tail if needed. +*/ +template +std::pair avx2_convert_utf16_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) +{ + const char16_t* start = buf; + const char16_t* end = buf + len; + + const __m256i v_0000 = _mm256_setzero_si256(); + const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800); + const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800); + const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080); + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); + if (big_endian) { + const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, + 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); + in = _mm256_shuffle_epi8(in, swap); + } + // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes + const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80); + if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!! + // 1. pack the bytes + const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1)); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + // no bits set above 7th bit + const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000); + const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000); + const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); + if (one_or_two_bytes_bitmask == 0xffffffff) { + + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); + const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m256i t0 = _mm256_slli_epi16(in, 2); + // t1 = [000a|aaaa|0000|0000] + const __m256i t1 = _mm256_and_si256(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m256i t2 = _mm256_and_si256(in, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m256i t3 = _mm256_or_si256(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m256i t4 = _mm256_or_si256(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + const uint32_t M0 = one_byte_bitmask & 0x55555555; + const uint32_t M1 = M0 >> 7; + const uint32_t M2 = (M1 | M0) & 0x00ff00ff; + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; + const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >> 16)][0]; -/* - Returns a pair: the first unprocessed byte from buf and utf8_output - A scalar routing should carry on the conversion of the tail. -*/ -template -std::pair avx2_convert_utf16_to_utf8(const char16_t* buf, size_t len, char* utf8_output) { - const char16_t* end = buf + len; - const __m256i v_0000 = _mm256_setzero_si256(); - const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800); - const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800); - const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080); - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); - if (big_endian) { - const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, - 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); - in = _mm256_shuffle_epi8(in, swap); - } - // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes - const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80); - if(_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!! - // 1. pack the bytes - const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in),_mm256_extractf128_si256(in,1)); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - // no bits set above 7th bit - const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000); - const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000); - const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); - if (one_or_two_bytes_bitmask == 0xffffffff) { - - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); - const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m256i t0 = _mm256_slli_epi16(in, 2); - // t1 = [000a|aaaa|0000|0000] - const __m256i t1 = _mm256_and_si256(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m256i t2 = _mm256_and_si256(in, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m256i t3 = _mm256_or_si256(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m256i t4 = _mm256_or_si256(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - const uint32_t M0 = one_byte_bitmask & 0x55555555; - const uint32_t M1 = M0 >> 7; - const uint32_t M2 = (M1 | M0) & 0x00ff00ff; - // 4. pack the bytes - - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; - const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2>>16)][0]; - - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); - - const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle,shuffle_2)); - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); - utf8_output += row[0]; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed,1)); - utf8_output += row_2[0]; - - // 6. adjust pointers - buf += 16; - continue; - } - // 1. Check if there are any surrogate word in the input chunk. - // We have also deal with situation when there is a surrogate word - // at the end of a chunk. - const __m256i surrogates_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800); - - // bitmask = 0x0000 if there are no surrogates - // = 0xc000 if the last word is a surrogate - const uint32_t surrogates_bitmask = static_cast(_mm256_movemask_epi8(surrogates_bytemask)); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (surrogates_bitmask == 0x00000000) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, - 0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm256_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m256i t0 = _mm256_shuffle_epi8(in, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m256i t1 = _mm256_and_si256(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m256i t2 = _mm256_or_si256 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m256i s0 = _mm256_srli_epi16(in, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m256i s1 = _mm256_and_si256(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m256i s2 = _mm256_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m256i s3 = _mm256_or_si256(s2, vec(0b1100000011100000)); - const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m256i s4 = _mm256_xor_si256(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); - const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint32_t mask = (one_byte_bitmask & 0x55555555) | - (one_or_two_bytes_bitmask & 0xaaaaaaaa); - // Due to the wider registers, the following path is less likely to be useful. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); - const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); - utf8_output += 12; - buf += 16; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); - - const uint8_t mask2 = static_cast(mask >> 16); - const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; - const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); - const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0,1), shuffle2); - - - const uint8_t mask3 = static_cast(mask >> 24); - const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; - const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); - const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1,1), shuffle3); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_2); - utf8_output += row2[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_3); - utf8_output += row3[0]; - buf += 16; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word & 0xFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word &0xF800 ) != 0xD800) { - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k+1]) : buf[k+1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(nullptr, utf8_output); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); - } - } - buf += k; - } - } // while - return std::make_pair(buf, utf8_output); -} + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); + const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2)); + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); + utf8_output += row[0]; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed, 1)); + utf8_output += row_2[0]; -/* - Returns a pair: a result struct and utf8_output. - If there is an error, the count field of the result is the position of the error. - Otherwise, it is the position of the first unprocessed byte in buf (even if finished). - A scalar routing should carry on the conversion of the tail if needed. -*/ -template -std::pair avx2_convert_utf16_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) { - const char16_t* start = buf; - const char16_t* end = buf + len; - - const __m256i v_0000 = _mm256_setzero_si256(); - const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800); - const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800); - const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080); - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); - if (big_endian) { - const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, - 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); - in = _mm256_shuffle_epi8(in, swap); - } - // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes - const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80); - if(_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!! - // 1. pack the bytes - const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in),_mm256_extractf128_si256(in,1)); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - // no bits set above 7th bit - const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000); - const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000); - const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); - if (one_or_two_bytes_bitmask == 0xffffffff) { - - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); - const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m256i t0 = _mm256_slli_epi16(in, 2); - // t1 = [000a|aaaa|0000|0000] - const __m256i t1 = _mm256_and_si256(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m256i t2 = _mm256_and_si256(in, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m256i t3 = _mm256_or_si256(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m256i t4 = _mm256_or_si256(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - const uint32_t M0 = one_byte_bitmask & 0x55555555; - const uint32_t M1 = M0 >> 7; - const uint32_t M2 = (M1 | M0) & 0x00ff00ff; - // 4. pack the bytes - - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; - const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2>>16)][0]; - - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); - - const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle,shuffle_2)); - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); - utf8_output += row[0]; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed,1)); - utf8_output += row_2[0]; - - // 6. adjust pointers - buf += 16; - continue; - } - // 1. Check if there are any surrogate word in the input chunk. - // We have also deal with situation when there is a surrogate word - // at the end of a chunk. - const __m256i surrogates_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800); - - // bitmask = 0x0000 if there are no surrogates - // = 0xc000 if the last word is a surrogate - const uint32_t surrogates_bitmask = static_cast(_mm256_movemask_epi8(surrogates_bytemask)); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (surrogates_bitmask == 0x00000000) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, - 0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm256_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m256i t0 = _mm256_shuffle_epi8(in, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m256i t1 = _mm256_and_si256(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m256i t2 = _mm256_or_si256 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m256i s0 = _mm256_srli_epi16(in, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m256i s1 = _mm256_and_si256(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m256i s2 = _mm256_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m256i s3 = _mm256_or_si256(s2, vec(0b1100000011100000)); - const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m256i s4 = _mm256_xor_si256(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); - const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint32_t mask = (one_byte_bitmask & 0x55555555) | - (one_or_two_bytes_bitmask & 0xaaaaaaaa); - // Due to the wider registers, the following path is less likely to be useful. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); - const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); - utf8_output += 12; - buf += 16; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); - - const uint8_t mask2 = static_cast(mask >> 16); - const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; - const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); - const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0,1), shuffle2); - - - const uint8_t mask3 = static_cast(mask >> 24); - const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; - const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); - const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1,1), shuffle3); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_2); - utf8_output += row2[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_3); - utf8_output += row3[0]; - buf += 16; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word & 0xFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word &0xF800 ) != 0xD800) { - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); + // 6. adjust pointers + buf += 16; + continue; + } + // 1. Check if there are any surrogate word in the input chunk. + // We have also deal with situation when there is a surrogate word + // at the end of a chunk. + const __m256i surrogates_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800); + + // bitmask = 0x0000 if there are no surrogates + // = 0xc000 if the last word is a surrogate + const uint32_t surrogates_bitmask = static_cast(_mm256_movemask_epi8(surrogates_bytemask)); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (surrogates_bitmask == 0x00000000) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, + 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm256_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m256i t0 = _mm256_shuffle_epi8(in, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m256i s0 = _mm256_srli_epi16(in, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000)); + const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m256i s4 = _mm256_xor_si256(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); + const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint32_t mask = (one_byte_bitmask & 0x55555555) | (one_or_two_bytes_bitmask & 0xaaaaaaaa); + // Due to the wider registers, the following path is less likely to be useful. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); + const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); + const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); + utf8_output += 12; + buf += 16; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); + + const uint8_t mask2 = static_cast(mask >> 16); + const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; + const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); + const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2); + + const uint8_t mask3 = static_cast(mask >> 24); + const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; + const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); + const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_2); + utf8_output += row2[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_3); + utf8_output += row3[0]; + buf += 16; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k+1]) : buf[k+1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), utf8_output); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); - } - } - buf += k; - } - } // while - return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xF800) != 0xD800) { + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), utf8_output); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while + return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); } /* end file src/haswell/avx2_convert_utf16_to_utf8.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_convert_utf16_to_utf32.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_convert_utf16_to_utf32.cpp /* begin file src/haswell/avx2_convert_utf16_to_utf32.cpp */ /* The vectorized algorithm works on single SSE register i.e., it @@ -20585,760 +23536,793 @@ std::pair avx2_convert_utf16_to_utf8_with_errors(const char16_t* - We need two 256-entry tables that have 8704 bytes in total. */ - /* Returns a pair: the first unprocessed byte from buf and utf32_output A scalar routing should carry on the conversion of the tail. */ -template -std::pair avx2_convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) { - const char16_t* end = buf + len; - const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800); - const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800); - - while (buf + 16 <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); - if (big_endian) { - const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, - 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); - in = _mm256_shuffle_epi8(in, swap); - } - - // 1. Check if there are any surrogate word in the input chunk. - // We have also deal with situation when there is a surrogate word - // at the end of a chunk. - const __m256i surrogates_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800); - - // bitmask = 0x0000 if there are no surrogates - // = 0xc000 if the last word is a surrogate - const uint32_t surrogates_bitmask = static_cast(_mm256_movemask_epi8(surrogates_bytemask)); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (surrogates_bitmask == 0x00000000) { - // case: we extend all sixteen 16-bit words to sixteen 32-bit words - _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output), _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in))); - _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output + 8), _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in,1))); - utf32_output += 16; - buf += 16; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word &0xF800 ) != 0xD800) { - // No surrogate pair - *utf32_output++ = char32_t(word); +template +std::pair avx2_convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) +{ + const char16_t* end = buf + len; + const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800); + const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800); + + while (buf + 16 <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); + if (big_endian) { + const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, + 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); + in = _mm256_shuffle_epi8(in, swap); + } + + // 1. Check if there are any surrogate word in the input chunk. + // We have also deal with situation when there is a surrogate word + // at the end of a chunk. + const __m256i surrogates_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800); + + // bitmask = 0x0000 if there are no surrogates + // = 0xc000 if the last word is a surrogate + const uint32_t surrogates_bitmask = static_cast(_mm256_movemask_epi8(surrogates_bytemask)); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (surrogates_bitmask == 0x00000000) { + // case: we extend all sixteen 16-bit words to sixteen 32-bit words + _mm256_storeu_si256(reinterpret_cast<__m256i*>(utf32_output), _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in))); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(utf32_output + 8), _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1))); + utf32_output += 16; + buf += 16; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k+1]) : buf[k+1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(nullptr, utf32_output); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xF800) != 0xD800) { + // No surrogate pair + *utf32_output++ = char32_t(word); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(nullptr, utf32_output); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + } + } + buf += k; } - } - buf += k; - } - } // while - return std::make_pair(buf, utf32_output); + } // while + return std::make_pair(buf, utf32_output); } - /* Returns a pair: a result struct and utf8_output. If there is an error, the count field of the result is the position of the error. Otherwise, it is the position of the first unprocessed byte in buf (even if finished). A scalar routing should carry on the conversion of the tail if needed. */ -template -std::pair avx2_convert_utf16_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) { - const char16_t* start = buf; - const char16_t* end = buf + len; - const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800); - const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800); - - while (buf + 16 <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); - if (big_endian) { - const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, - 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); - in = _mm256_shuffle_epi8(in, swap); - } - - // 1. Check if there are any surrogate word in the input chunk. - // We have also deal with situation when there is a surrogate word - // at the end of a chunk. - const __m256i surrogates_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800); - - // bitmask = 0x0000 if there are no surrogates - // = 0xc000 if the last word is a surrogate - const uint32_t surrogates_bitmask = static_cast(_mm256_movemask_epi8(surrogates_bytemask)); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (surrogates_bitmask == 0x00000000) { - // case: we extend all sixteen 16-bit words to sixteen 32-bit words - _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output), _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in))); - _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output + 8), _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in,1))); - utf32_output += 16; - buf += 16; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word &0xF800 ) != 0xD800) { - // No surrogate pair - *utf32_output++ = char32_t(word); +template +std::pair avx2_convert_utf16_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) +{ + const char16_t* start = buf; + const char16_t* end = buf + len; + const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800); + const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800); + + while (buf + 16 <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); + if (big_endian) { + const __m256i swap = _mm256_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, + 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30); + in = _mm256_shuffle_epi8(in, swap); + } + + // 1. Check if there are any surrogate word in the input chunk. + // We have also deal with situation when there is a surrogate word + // at the end of a chunk. + const __m256i surrogates_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800); + + // bitmask = 0x0000 if there are no surrogates + // = 0xc000 if the last word is a surrogate + const uint32_t surrogates_bitmask = static_cast(_mm256_movemask_epi8(surrogates_bytemask)); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (surrogates_bitmask == 0x00000000) { + // case: we extend all sixteen 16-bit words to sixteen 32-bit words + _mm256_storeu_si256(reinterpret_cast<__m256i*>(utf32_output), _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in))); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(utf32_output + 8), _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1))); + utf32_output += 16; + buf += 16; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k+1]) : buf[k+1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), utf32_output); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xF800) != 0xD800) { + // No surrogate pair + *utf32_output++ = char32_t(word); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), utf32_output); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + } + } + buf += k; } - } - buf += k; - } - } // while - return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output); + } // while + return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output); } /* end file src/haswell/avx2_convert_utf16_to_utf32.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_convert_utf32_to_utf8.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_convert_utf32_to_utf8.cpp /* begin file src/haswell/avx2_convert_utf32_to_utf8.cpp */ -std::pair avx2_convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) { - const char32_t* end = buf + len; - const __m256i v_0000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); - const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80); - const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800); - const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080); - const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff); - __m256i running_max = _mm256_setzero_si256(); - __m256i forbidden_bytemask = _mm256_setzero_si256(); - - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); - __m256i nextin = _mm256_loadu_si256((__m256i*)buf+1); - running_max = _mm256_max_epu32(_mm256_max_epu32(in, running_max), nextin); - - // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation - __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff), _mm256_and_si256(nextin, v_7fffffff)); - in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000); - - // Try to apply UTF-16 => UTF-8 routine on 256 bits (haswell/avx2_convert_utf16_to_utf8.cpp) - - if(_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!! - // 1. pack the bytes - const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in_16),_mm256_extractf128_si256(in_16,1)); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - // no bits set above 7th bit - const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000); - const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000); - const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); - if (one_or_two_bytes_bitmask == 0xffffffff) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); - const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m256i t0 = _mm256_slli_epi16(in_16, 2); - // t1 = [000a|aaaa|0000|0000] - const __m256i t1 = _mm256_and_si256(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m256i t2 = _mm256_and_si256(in_16, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m256i t3 = _mm256_or_si256(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m256i t4 = _mm256_or_si256(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in_16, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - const uint32_t M0 = one_byte_bitmask & 0x55555555; - const uint32_t M1 = M0 >> 7; - const uint32_t M2 = (M1 | M0) & 0x00ff00ff; - // 4. pack the bytes - - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; - const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2>>16)][0]; - - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); - - const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle,shuffle_2)); - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); - utf8_output += row[0]; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed,1)); - utf8_output += row_2[0]; - - // 6. adjust pointers - buf += 16; - continue; - } - // Must check for overflow in packing - const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000); - const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); - if (saturation_bitmask == 0xffffffff) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800); - forbidden_bytemask = _mm256_or_si256(forbidden_bytemask, _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800)); - - const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, - 0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm256_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m256i t1 = _mm256_and_si256(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m256i t2 = _mm256_or_si256 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m256i s0 = _mm256_srli_epi16(in_16, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m256i s1 = _mm256_and_si256(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m256i s2 = _mm256_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m256i s3 = _mm256_or_si256(s2, vec(0b1100000011100000)); - const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m256i s4 = _mm256_xor_si256(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); - const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint32_t mask = (one_byte_bitmask & 0x55555555) | - (one_or_two_bytes_bitmask & 0xaaaaaaaa); - // Due to the wider registers, the following path is less likely to be useful. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); - const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); - utf8_output += 12; - buf += 16; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); - - const uint8_t mask2 = static_cast(mask >> 16); - const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; - const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); - const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0,1), shuffle2); - - - const uint8_t mask3 = static_cast(mask >> 24); - const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; - const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); - const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1,1), shuffle3); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_2); - utf8_output += row2[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_3); - utf8_output += row3[0]; - buf += 16; - } else { - // case: at least one 32-bit word is larger than 0xFFFF <=> it will produce four UTF-8 bytes. - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // may require large, non-trivial tables? - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFFFF80)==0) { // 1-byte (ASCII) - *utf8_output++ = char(word); - } else if((word & 0xFFFFF800)==0) { // 2-byte - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word & 0xFFFF0000 )==0) { // 3-byte - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(nullptr, utf8_output); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else { // 4-byte - if (word > 0x10FFFF) { return std::make_pair(nullptr, utf8_output); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } - } - buf += k; - } - } // while - - // check for invalid input - const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff); - if(static_cast(_mm256_movemask_epi8(_mm256_cmpeq_epi32(_mm256_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffffffff) { - return std::make_pair(nullptr, utf8_output); - } - - if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0) { return std::make_pair(nullptr, utf8_output); } - - return std::make_pair(buf, utf8_output); -} - - -std::pair avx2_convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) { - const char32_t* end = buf + len; - const char32_t* start = buf; - - const __m256i v_0000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); - const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80); - const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800); - const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080); - const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff); - const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff); - - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); - __m256i nextin = _mm256_loadu_si256((__m256i*)buf+1); - // Check for too large input - const __m256i max_input = _mm256_max_epu32(_mm256_max_epu32(in, nextin), v_10ffff); - if(static_cast(_mm256_movemask_epi8(_mm256_cmpeq_epi32(max_input, v_10ffff))) != 0xffffffff) { - return std::make_pair(result(error_code::TOO_LARGE, buf - start), utf8_output); - } - - // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation - __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff), _mm256_and_si256(nextin, v_7fffffff)); - in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000); - - // Try to apply UTF-16 => UTF-8 routine on 256 bits (haswell/avx2_convert_utf16_to_utf8.cpp) - - if(_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!! - // 1. pack the bytes - const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in_16),_mm256_extractf128_si256(in_16,1)); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - // no bits set above 7th bit - const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000); - const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000); - const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); - if (one_or_two_bytes_bitmask == 0xffffffff) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); - const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m256i t0 = _mm256_slli_epi16(in_16, 2); - // t1 = [000a|aaaa|0000|0000] - const __m256i t1 = _mm256_and_si256(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m256i t2 = _mm256_and_si256(in_16, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m256i t3 = _mm256_or_si256(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m256i t4 = _mm256_or_si256(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in_16, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - const uint32_t M0 = one_byte_bitmask & 0x55555555; - const uint32_t M1 = M0 >> 7; - const uint32_t M2 = (M1 | M0) & 0x00ff00ff; - // 4. pack the bytes - - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; - const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2>>16)][0]; - - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); - - const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle,shuffle_2)); - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); - utf8_output += row[0]; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed,1)); - utf8_output += row_2[0]; - - // 6. adjust pointers - buf += 16; - continue; - } - // Must check for overflow in packing - const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000); - const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); - if (saturation_bitmask == 0xffffffff) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - - // Check for illegal surrogate words - const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800); - const __m256i forbidden_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800); - if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0x0) { - return std::make_pair(result(error_code::SURROGATE, buf - start), utf8_output); - } - - const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, - 0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm256_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m256i t1 = _mm256_and_si256(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m256i t2 = _mm256_or_si256 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m256i s0 = _mm256_srli_epi16(in_16, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m256i s1 = _mm256_and_si256(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m256i s2 = _mm256_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m256i s3 = _mm256_or_si256(s2, vec(0b1100000011100000)); - const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m256i s4 = _mm256_xor_si256(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); - const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint32_t mask = (one_byte_bitmask & 0x55555555) | - (one_or_two_bytes_bitmask & 0xaaaaaaaa); - // Due to the wider registers, the following path is less likely to be useful. - /*if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); - const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); - utf8_output += 12; - buf += 16; - continue; - }*/ - const uint8_t mask0 = uint8_t(mask); - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); - - const uint8_t mask2 = static_cast(mask >> 16); - const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; - const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); - const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0,1), shuffle2); - - - const uint8_t mask3 = static_cast(mask >> 24); - const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; - const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); - const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1,1), shuffle3); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_2); - utf8_output += row2[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_3); - utf8_output += row3[0]; - buf += 16; - } else { - // case: at least one 32-bit word is larger than 0xFFFF <=> it will produce four UTF-8 bytes. - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // may require large, non-trivial tables? - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFFFF80)==0) { // 1-byte (ASCII) - *utf8_output++ = char(word); - } else if((word & 0xFFFFF800)==0) { // 2-byte - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word & 0xFFFF0000 )==0) { // 3-byte - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf8_output); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else { // 4-byte - if (word > 0x10FFFF) { return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf8_output); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } - } - buf += k; - } - } // while - - return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); +std::pair avx2_convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) +{ + const char32_t* end = buf + len; + const __m256i v_0000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); + const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80); + const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800); + const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080); + const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff); + __m256i running_max = _mm256_setzero_si256(); + __m256i forbidden_bytemask = _mm256_setzero_si256(); + + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); + __m256i nextin = _mm256_loadu_si256((__m256i*)buf + 1); + running_max = _mm256_max_epu32(_mm256_max_epu32(in, running_max), nextin); + + // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation + __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff), _mm256_and_si256(nextin, v_7fffffff)); + in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000); + + // Try to apply UTF-16 => UTF-8 routine on 256 bits (haswell/avx2_convert_utf16_to_utf8.cpp) + + if (_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!! + // 1. pack the bytes + const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in_16), _mm256_extractf128_si256(in_16, 1)); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + // no bits set above 7th bit + const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000); + const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000); + const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); + if (one_or_two_bytes_bitmask == 0xffffffff) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); + const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m256i t0 = _mm256_slli_epi16(in_16, 2); + // t1 = [000a|aaaa|0000|0000] + const __m256i t1 = _mm256_and_si256(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m256i t2 = _mm256_and_si256(in_16, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m256i t3 = _mm256_or_si256(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m256i t4 = _mm256_or_si256(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in_16, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + const uint32_t M0 = one_byte_bitmask & 0x55555555; + const uint32_t M1 = M0 >> 7; + const uint32_t M2 = (M1 | M0) & 0x00ff00ff; + // 4. pack the bytes + + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; + const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >> 16)][0]; + + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); + + const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2)); + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); + utf8_output += row[0]; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed, 1)); + utf8_output += row_2[0]; + + // 6. adjust pointers + buf += 16; + continue; + } + // Must check for overflow in packing + const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000); + const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); + if (saturation_bitmask == 0xffffffff) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800); + forbidden_bytemask = _mm256_or_si256(forbidden_bytemask, _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800)); + + const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, + 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm256_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m256i s0 = _mm256_srli_epi16(in_16, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000)); + const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m256i s4 = _mm256_xor_si256(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); + const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint32_t mask = (one_byte_bitmask & 0x55555555) | (one_or_two_bytes_bitmask & 0xaaaaaaaa); + // Due to the wider registers, the following path is less likely to be useful. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); + const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); + const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); + utf8_output += 12; + buf += 16; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); + + const uint8_t mask2 = static_cast(mask >> 16); + const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; + const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); + const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2); + + const uint8_t mask3 = static_cast(mask >> 24); + const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; + const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); + const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_2); + utf8_output += row2[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_3); + utf8_output += row3[0]; + buf += 16; + } else { + // case: at least one 32-bit word is larger than 0xFFFF <=> it will produce four UTF-8 bytes. + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // may require large, non-trivial tables? + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFFFF80) == 0) { // 1-byte (ASCII) + *utf8_output++ = char(word); + } else if ((word & 0xFFFFF800) == 0) { // 2-byte + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xFFFF0000) == 0) { // 3-byte + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(nullptr, utf8_output); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { // 4-byte + if (word > 0x10FFFF) { + return std::make_pair(nullptr, utf8_output); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while + + // check for invalid input + const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff); + if (static_cast(_mm256_movemask_epi8(_mm256_cmpeq_epi32(_mm256_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffffffff) { + return std::make_pair(nullptr, utf8_output); + } + + if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0) { + return std::make_pair(nullptr, utf8_output); + } + + return std::make_pair(buf, utf8_output); +} + +std::pair avx2_convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) +{ + const char32_t* end = buf + len; + const char32_t* start = buf; + + const __m256i v_0000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); + const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80); + const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800); + const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080); + const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff); + const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff); + + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); + __m256i nextin = _mm256_loadu_si256((__m256i*)buf + 1); + // Check for too large input + const __m256i max_input = _mm256_max_epu32(_mm256_max_epu32(in, nextin), v_10ffff); + if (static_cast(_mm256_movemask_epi8(_mm256_cmpeq_epi32(max_input, v_10ffff))) != 0xffffffff) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start), utf8_output); + } + + // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation + __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff), _mm256_and_si256(nextin, v_7fffffff)); + in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000); + + // Try to apply UTF-16 => UTF-8 routine on 256 bits (haswell/avx2_convert_utf16_to_utf8.cpp) + + if (_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!! + // 1. pack the bytes + const __m128i utf8_packed = _mm_packus_epi16(_mm256_castsi256_si128(in_16), _mm256_extractf128_si256(in_16, 1)); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + // no bits set above 7th bit + const __m256i one_byte_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000); + const uint32_t one_byte_bitmask = static_cast(_mm256_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m256i one_or_two_bytes_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000); + const uint32_t one_or_two_bytes_bitmask = static_cast(_mm256_movemask_epi8(one_or_two_bytes_bytemask)); + if (one_or_two_bytes_bitmask == 0xffffffff) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00); + const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m256i t0 = _mm256_slli_epi16(in_16, 2); + // t1 = [000a|aaaa|0000|0000] + const __m256i t1 = _mm256_and_si256(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m256i t2 = _mm256_and_si256(in_16, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m256i t3 = _mm256_or_si256(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m256i t4 = _mm256_or_si256(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in_16, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + const uint32_t M0 = one_byte_bitmask & 0x55555555; + const uint32_t M1 = M0 >> 7; + const uint32_t M2 = (M1 | M0) & 0x00ff00ff; + // 4. pack the bytes + + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0]; + const uint8_t* row_2 = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >> 16)][0]; + + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i shuffle_2 = _mm_loadu_si128((__m128i*)(row_2 + 1)); + + const __m256i utf8_packed = _mm256_shuffle_epi8(utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2)); + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_packed)); + utf8_output += row[0]; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_packed, 1)); + utf8_output += row_2[0]; + + // 6. adjust pointers + buf += 16; + continue; + } + // Must check for overflow in packing + const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000); + const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); + if (saturation_bitmask == 0xffffffff) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + + // Check for illegal surrogate words + const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800); + const __m256i forbidden_bytemask = _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800); + if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0x0) { + return std::make_pair(result(error_code::SURROGATE, buf - start), utf8_output); + } + + const __m256i dup_even = _mm256_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e, + 0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm256_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m256i s0 = _mm256_srli_epi16(in_16, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000)); + const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m256i s4 = _mm256_xor_si256(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m256i out0 = _mm256_unpacklo_epi16(t2, s4); + const __m256i out1 = _mm256_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint32_t mask = (one_byte_bitmask & 0x55555555) | (one_or_two_bytes_bitmask & 0xaaaaaaaa); + // Due to the wider registers, the following path is less likely to be useful. + /*if(mask == 0) { + // We only have three-byte words. Use fast path. + const __m256i shuffle = _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1, 2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); + const __m256i utf8_0 = _mm256_shuffle_epi8(out0, shuffle); + const __m256i utf8_1 = _mm256_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_0,1)); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, _mm256_extractf128_si256(utf8_1,1)); + utf8_output += 12; + buf += 16; + continue; + }*/ + const uint8_t mask0 = uint8_t(mask); + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1); + + const uint8_t mask2 = static_cast(mask >> 16); + const uint8_t* row2 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0]; + const __m128i shuffle2 = _mm_loadu_si128((__m128i*)(row2 + 1)); + const __m128i utf8_2 = _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2); + + const uint8_t mask3 = static_cast(mask >> 24); + const uint8_t* row3 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0]; + const __m128i shuffle3 = _mm_loadu_si128((__m128i*)(row3 + 1)); + const __m128i utf8_3 = _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_2); + utf8_output += row2[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_3); + utf8_output += row3[0]; + buf += 16; + } else { + // case: at least one 32-bit word is larger than 0xFFFF <=> it will produce four UTF-8 bytes. + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // may require large, non-trivial tables? + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFFFF80) == 0) { // 1-byte (ASCII) + *utf8_output++ = char(word); + } else if ((word & 0xFFFFF800) == 0) { // 2-byte + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xFFFF0000) == 0) { // 3-byte + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf8_output); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { // 4-byte + if (word > 0x10FFFF) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf8_output); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while + + return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); } /* end file src/haswell/avx2_convert_utf32_to_utf8.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=haswell/avx2_convert_utf32_to_utf16.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=haswell/avx2_convert_utf32_to_utf16.cpp /* begin file src/haswell/avx2_convert_utf32_to_utf16.cpp */ -template -std::pair avx2_convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_output) { - const char32_t* end = buf + len; - - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - __m256i forbidden_bytemask = _mm256_setzero_si256(); +template +std::pair avx2_convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + const char32_t* end = buf + len; + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + __m256i forbidden_bytemask = _mm256_setzero_si256(); - while (buf + 8 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); + while (buf + 8 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); - const __m256i v_00000000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000); + const __m256i v_00000000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000); - // no bits set above 16th bit <=> can pack to UTF16 without surrogate pairs - const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); - const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); + // no bits set above 16th bit <=> can pack to UTF16 without surrogate pairs + const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); + const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); - if (saturation_bitmask == 0xffffffff) { - const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800); - const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800); - forbidden_bytemask = _mm256_or_si256(forbidden_bytemask, _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800)); + if (saturation_bitmask == 0xffffffff) { + const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800); + const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800); + forbidden_bytemask = _mm256_or_si256(forbidden_bytemask, _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800)); - __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),_mm256_extractf128_si256(in,1)); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); - } - _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); - utf16_output += 8; - buf += 8; - } else { - size_t forward = 7; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(nullptr, utf16_output); } - *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1)); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); + } + _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); + utf16_output += 8; + buf += 8; } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return std::make_pair(nullptr, utf16_output); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (big_endian) { - high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); - low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); + size_t forward = 7; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(nullptr, utf16_output); + } + *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return std::make_pair(nullptr, utf16_output); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (big_endian) { + high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); + low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + } + buf += k; } - } - buf += k; } - } - // check for invalid input - if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0) { return std::make_pair(nullptr, utf16_output); } + // check for invalid input + if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0) { + return std::make_pair(nullptr, utf16_output); + } - return std::make_pair(buf, utf16_output); + return std::make_pair(buf, utf16_output); } +template +std::pair avx2_convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + const char32_t* start = buf; + const char32_t* end = buf + len; -template -std::pair avx2_convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) { - const char32_t* start = buf; - const char32_t* end = buf + len; + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + while (buf + 8 + safety_margin <= end) { + __m256i in = _mm256_loadu_si256((__m256i*)buf); - while (buf + 8 + safety_margin <= end) { - __m256i in = _mm256_loadu_si256((__m256i*)buf); + const __m256i v_00000000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000); - const __m256i v_00000000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000); - - // no bits set above 16th bit <=> can pack to UTF16 without surrogate pairs - const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); - const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); - - if (saturation_bitmask == 0xffffffff) { - const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800); - const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800); - const __m256i forbidden_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800); - if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0x0) { - return std::make_pair(result(error_code::SURROGATE, buf - start), utf16_output); - } - - __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),_mm256_extractf128_si256(in,1)); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); - } - _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); - utf16_output += 8; - buf += 8; - } else { - size_t forward = 7; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf16_output); } - *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + // no bits set above 16th bit <=> can pack to UTF16 without surrogate pairs + const __m256i saturation_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); + const uint32_t saturation_bitmask = static_cast(_mm256_movemask_epi8(saturation_bytemask)); + + if (saturation_bitmask == 0xffffffff) { + const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800); + const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800); + const __m256i forbidden_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800); + if (static_cast(_mm256_movemask_epi8(forbidden_bytemask)) != 0x0) { + return std::make_pair(result(error_code::SURROGATE, buf - start), utf16_output); + } + + __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1)); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); + } + _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); + utf16_output += 8; + buf += 8; } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf16_output); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (big_endian) { - high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); - low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); + size_t forward = 7; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf16_output); + } + *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf16_output); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (big_endian) { + high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); + low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + } + buf += k; } - } - buf += k; } - } - return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output); + return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output); } /* end file src/haswell/avx2_convert_utf32_to_utf16.cpp */ } // unnamed namespace } // namespace haswell } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/buf_block_reader.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/buf_block_reader.h /* begin file src/generic/buf_block_reader.h */ namespace simdutf { namespace haswell { @@ -21348,92 +24332,110 @@ namespace { template struct buf_block_reader { public: - simdutf_really_inline buf_block_reader(const uint8_t *_buf, size_t _len); - simdutf_really_inline size_t block_index(); - simdutf_really_inline bool has_full_block() const; - simdutf_really_inline const uint8_t *full_block() const; - /** - * Get the last block, padded with spaces. - * - * There will always be a last block, with at least 1 byte, unless len == 0 (in which case this - * function fills the buffer with spaces and returns 0. In particular, if len == STEP_SIZE there - * will be 0 full_blocks and 1 remainder block with STEP_SIZE bytes and no spaces for padding. - * - * @return the number of effective characters in the last block. - */ - simdutf_really_inline size_t get_remainder(uint8_t *dst) const; - simdutf_really_inline void advance(); + simdutf_really_inline buf_block_reader(const uint8_t* _buf, size_t _len); + simdutf_really_inline size_t block_index(); + simdutf_really_inline bool has_full_block() const; + simdutf_really_inline const uint8_t* full_block() const; + /** + * Get the last block, padded with spaces. + * + * There will always be a last block, with at least 1 byte, unless len == 0 (in which case this + * function fills the buffer with spaces and returns 0. In particular, if len == STEP_SIZE there + * will be 0 full_blocks and 1 remainder block with STEP_SIZE bytes and no spaces for padding. + * + * @return the number of effective characters in the last block. + */ + simdutf_really_inline size_t get_remainder(uint8_t* dst) const; + simdutf_really_inline void advance(); + private: - const uint8_t *buf; - const size_t len; - const size_t lenminusstep; - size_t idx; + const uint8_t* buf; + const size_t len; + const size_t lenminusstep; + size_t idx; }; // Routines to print masks and text for debugging bitmask operations -simdutf_unused static char * format_input_text_64(const uint8_t *text) { - static char *buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); - for (size_t i=0; i); i++) { - buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); - } - buf[sizeof(simd8x64)] = '\0'; - return buf; +simdutf_unused static char* format_input_text_64(const uint8_t* text) +{ + static char* buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); + for (size_t i = 0; i < sizeof(simd8x64); i++) { + buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); + } + buf[sizeof(simd8x64)] = '\0'; + return buf; } // Routines to print masks and text for debugging bitmask operations -simdutf_unused static char * format_input_text(const simd8x64& in) { - static char *buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); - in.store(reinterpret_cast(buf)); - for (size_t i=0; i); i++) { - if (buf[i] < ' ') { buf[i] = '_'; } - } - buf[sizeof(simd8x64)] = '\0'; - return buf; +simdutf_unused static char* format_input_text(const simd8x64& in) +{ + static char* buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); + in.store(reinterpret_cast(buf)); + for (size_t i = 0; i < sizeof(simd8x64); i++) { + if (buf[i] < ' ') { + buf[i] = '_'; + } + } + buf[sizeof(simd8x64)] = '\0'; + return buf; } -simdutf_unused static char * format_mask(uint64_t mask) { - static char *buf = reinterpret_cast(malloc(64 + 1)); - for (size_t i=0; i<64; i++) { - buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; - } - buf[64] = '\0'; - return buf; +simdutf_unused static char* format_mask(uint64_t mask) +{ + static char* buf = reinterpret_cast(malloc(64 + 1)); + for (size_t i = 0; i < 64; i++) { + buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; + } + buf[64] = '\0'; + return buf; } template -simdutf_really_inline buf_block_reader::buf_block_reader(const uint8_t *_buf, size_t _len) : buf{_buf}, len{_len}, lenminusstep{len < STEP_SIZE ? 0 : len - STEP_SIZE}, idx{0} {} +simdutf_really_inline buf_block_reader::buf_block_reader(const uint8_t* _buf, size_t _len) + : buf { _buf } + , len { _len } + , lenminusstep { len < STEP_SIZE ? 0 : len - STEP_SIZE } + , idx { 0 } +{ +} template simdutf_really_inline size_t buf_block_reader::block_index() { return idx; } template -simdutf_really_inline bool buf_block_reader::has_full_block() const { - return idx < lenminusstep; +simdutf_really_inline bool buf_block_reader::has_full_block() const +{ + return idx < lenminusstep; } template -simdutf_really_inline const uint8_t *buf_block_reader::full_block() const { - return &buf[idx]; +simdutf_really_inline const uint8_t* buf_block_reader::full_block() const +{ + return &buf[idx]; } template -simdutf_really_inline size_t buf_block_reader::get_remainder(uint8_t *dst) const { - if(len == idx) { return 0; } // memcpy(dst, null, 0) will trigger an error with some sanitizers - std::memset(dst, 0x20, STEP_SIZE); // std::memset STEP_SIZE because it's more efficient to write out 8 or 16 bytes at once. - std::memcpy(dst, buf + idx, len - idx); - return len - idx; +simdutf_really_inline size_t buf_block_reader::get_remainder(uint8_t* dst) const +{ + if (len == idx) { + return 0; + } // memcpy(dst, null, 0) will trigger an error with some sanitizers + std::memset(dst, 0x20, STEP_SIZE); // std::memset STEP_SIZE because it's more efficient to write out 8 or 16 bytes at once. + std::memcpy(dst, buf + idx, len - idx); + return len - idx; } template -simdutf_really_inline void buf_block_reader::advance() { - idx += STEP_SIZE; +simdutf_really_inline void buf_block_reader::advance() +{ + idx += STEP_SIZE; } } // unnamed namespace } // namespace haswell } // namespace simdutf /* end file src/generic/buf_block_reader.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_validation/utf8_lookup4_algorithm.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_validation/utf8_lookup4_algorithm.h /* begin file src/generic/utf8_validation/utf8_lookup4_algorithm.h */ namespace simdutf { namespace haswell { @@ -21442,21 +24444,22 @@ namespace utf8_validation { using namespace simd; - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -21464,101 +24467,92 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } +} - // - // Return nonzero if there are incomplete multibyte characters at the end of the block: - // e.g. if there is a 4-byte character, but it's 3 bytes from the end. - // - simdutf_really_inline simd8 is_incomplete(const simd8 input) { +// +// Return nonzero if there are incomplete multibyte characters at the end of the block: +// e.g. if there is a 4-byte character, but it's 3 bytes from the end. +// +simdutf_really_inline simd8 is_incomplete(const simd8 input) +{ // If the previous input's last 3 bytes match this, they're too short (they ended at EOF): // ... 1111____ 111_____ 11______ static const uint8_t max_array[32] = { - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 0b11110000u-1, 0b11100000u-1, 0b11000000u-1 + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 0b11110000u - 1, 0b11100000u - 1, 0b11000000u - 1 }; - const simd8 max_value(&max_array[sizeof(max_array)-sizeof(simd8)]); + const simd8 max_value(&max_array[sizeof(max_array) - sizeof(simd8)]); return input.gt_bits(max_value); - } +} - struct utf8_checker { +struct utf8_checker { // If this is nonzero, there has been a UTF-8 error. simd8 error; // The last input we received @@ -21569,51 +24563,54 @@ using namespace simd; // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); } // The only problem that can happen at EOF is that a multibyte character is too short // or a byte value too large in the last bytes: check_special_cases only checks for bytes // too large in the first of two bytes. - simdutf_really_inline void check_eof() { - // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't - // possibly finish them. - this->error |= this->prev_incomplete; + simdutf_really_inline void check_eof() + { + // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't + // possibly finish them. + this->error |= this->prev_incomplete; } - simdutf_really_inline void check_next_input(const simd8x64& input) { - if(simdutf_likely(is_ascii(input))) { - this->error |= this->prev_incomplete; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + simdutf_really_inline void check_next_input(const simd8x64& input) + { + if (simdutf_likely(is_ascii(input))) { + this->error |= this->prev_incomplete; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + this->prev_incomplete = is_incomplete(input.chunks[simd8x64::NUM_CHUNKS - 1]); + this->prev_input_block = input.chunks[simd8x64::NUM_CHUNKS - 1]; } - this->prev_incomplete = is_incomplete(input.chunks[simd8x64::NUM_CHUNKS-1]); - this->prev_input_block = input.chunks[simd8x64::NUM_CHUNKS-1]; - - } } // do not forget to call check_eof! - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // namespace utf8_validation using utf8_validation::utf8_checker; @@ -21622,7 +24619,7 @@ using utf8_validation::utf8_checker; } // namespace haswell } // namespace simdutf /* end file src/generic/utf8_validation/utf8_lookup4_algorithm.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_validation/utf8_validator.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_validation/utf8_validator.h /* begin file src/generic/utf8_validation/utf8_validator.h */ namespace simdutf { namespace haswell { @@ -21633,15 +24630,16 @@ namespace utf8_validation { * Validates that the string is actual UTF-8. */ template -bool generic_validate_utf8(const uint8_t * input, size_t length) { - checker c{}; +bool generic_validate_utf8(const uint8_t* input, size_t length) +{ + checker c {}; buf_block_reader<64> reader(input, length); while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - c.check_next_input(in); - reader.advance(); + simd::simd8x64 in(reader.full_block()); + c.check_next_input(in); + reader.advance(); } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); c.check_next_input(in); @@ -21650,97 +24648,106 @@ bool generic_validate_utf8(const uint8_t * input, size_t length) { return !c.errors(); } -bool generic_validate_utf8(const char * input, size_t length) { - return generic_validate_utf8(reinterpret_cast(input),length); +bool generic_validate_utf8(const char* input, size_t length) +{ + return generic_validate_utf8(reinterpret_cast(input), length); } /** * Validates that the string is actual UTF-8 and stops on errors. */ template -result generic_validate_utf8_with_errors(const uint8_t * input, size_t length) { - checker c{}; +result generic_validate_utf8_with_errors(const uint8_t* input, size_t length) +{ + checker c {}; buf_block_reader<64> reader(input, length); - size_t count{0}; + size_t count { 0 }; while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - c.check_next_input(in); - if(c.errors()) { - if (count != 0) { count--; } // Sometimes the error is only detected in the next chunk - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input + count), length - count); - res.count += count; - return res; - } - reader.advance(); - count += 64; + simd::simd8x64 in(reader.full_block()); + c.check_next_input(in); + if (c.errors()) { + if (count != 0) { + count--; + } // Sometimes the error is only detected in the next chunk + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input + count), length - count); + res.count += count; + return res; + } + reader.advance(); + count += 64; } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); c.check_next_input(in); reader.advance(); c.check_eof(); if (c.errors()) { - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input) + count, length - count); - res.count += count; - return res; + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input) + count, length - count); + res.count += count; + return res; } else { - return result(error_code::SUCCESS, length); + return result(error_code::SUCCESS, length); } } -result generic_validate_utf8_with_errors(const char * input, size_t length) { - return generic_validate_utf8_with_errors(reinterpret_cast(input),length); +result generic_validate_utf8_with_errors(const char* input, size_t length) +{ + return generic_validate_utf8_with_errors(reinterpret_cast(input), length); } template -bool generic_validate_ascii(const uint8_t * input, size_t length) { +bool generic_validate_ascii(const uint8_t* input, size_t length) +{ buf_block_reader<64> reader(input, length); - uint8_t blocks[64]{}; + uint8_t blocks[64] {}; simd::simd8x64 running_or(blocks); while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - running_or |= in; - reader.advance(); + simd::simd8x64 in(reader.full_block()); + running_or |= in; + reader.advance(); } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); running_or |= in; return running_or.is_ascii(); } -bool generic_validate_ascii(const char * input, size_t length) { - return generic_validate_ascii(reinterpret_cast(input),length); +bool generic_validate_ascii(const char* input, size_t length) +{ + return generic_validate_ascii(reinterpret_cast(input), length); } template -result generic_validate_ascii_with_errors(const uint8_t * input, size_t length) { - buf_block_reader<64> reader(input, length); - size_t count{0}; - while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); +result generic_validate_ascii_with_errors(const uint8_t* input, size_t length) +{ + buf_block_reader<64> reader(input, length); + size_t count { 0 }; + while (reader.has_full_block()) { + simd::simd8x64 in(reader.full_block()); + if (!in.is_ascii()) { + result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); + return result(res.error, count + res.count); + } + reader.advance(); + + count += 64; + } + uint8_t block[64] {}; + reader.get_remainder(block); + simd::simd8x64 in(block); if (!in.is_ascii()) { - result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); - return result(res.error, count + res.count); + result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); + return result(res.error, count + res.count); + } else { + return result(error_code::SUCCESS, length); } - reader.advance(); - - count += 64; - } - uint8_t block[64]{}; - reader.get_remainder(block); - simd::simd8x64 in(block); - if (!in.is_ascii()) { - result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); - return result(res.error, count + res.count); - } else { - return result(error_code::SUCCESS, length); - } } -result generic_validate_ascii_with_errors(const char * input, size_t length) { - return generic_validate_ascii_with_errors(reinterpret_cast(input),length); +result generic_validate_ascii_with_errors(const char* input, size_t length) +{ + return generic_validate_ascii_with_errors(reinterpret_cast(input), length); } } // namespace utf8_validation @@ -21749,10 +24756,9 @@ result generic_validate_ascii_with_errors(const char * input, size_t length) { } // namespace simdutf /* end file src/generic/utf8_validation/utf8_validator.h */ // transcoding from UTF-8 to UTF-16 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf16/valid_utf8_to_utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf16/valid_utf8_to_utf16.h /* begin file src/generic/utf8_to_utf16/valid_utf8_to_utf16.h */ - namespace simdutf { namespace haswell { namespace { @@ -21760,63 +24766,64 @@ namespace utf8_to_utf16 { using namespace simd; -template +template simdutf_warn_unused size_t convert_valid(const char* input, size_t size, - char16_t* utf16_output) noexcept { - // The implementation is not specific to haswell and should be moved to the generic directory. - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - // this loop could be unrolled further. For example, we could process the mask - // far more than 64 bytes. - simd8x64 in(reinterpret_cast(input + pos)); - if(in.is_ascii()) { - in.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // Slow path. We hope that the compiler will recognize that this is a slow path. - // Anything that is not a continuation mask is a 'leading byte', that is, the - // start of a new code point. - uint64_t utf8_continuation_mask = in.lt(-65 + 1); - // -65 is 0b10111111 in two-complement's, so largest possible continuation byte - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - // The *start* of code points is not so useful, rather, we want the *end* of code points. - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times when using solely - // the slow/regular path, and at least four times if there are fast paths. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - // - // Thus we may allow convert_masked_utf8_to_utf16 to process - // more bytes at a time under a fast-path mode where 16 bytes - // are consumed at once (e.g., when encountering ASCII). - size_t consumed = convert_masked_utf8_to_utf16(input + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - utf16_output += scalar::utf8_to_utf16::convert_valid(input + pos, size - pos, utf16_output); - return utf16_output - start; + char16_t* utf16_output) noexcept +{ + // The implementation is not specific to haswell and should be moved to the generic directory. + size_t pos = 0; + char16_t* start { utf16_output }; + const size_t safety_margin = 16; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + // this loop could be unrolled further. For example, we could process the mask + // far more than 64 bytes. + simd8x64 in(reinterpret_cast(input + pos)); + if (in.is_ascii()) { + in.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // Slow path. We hope that the compiler will recognize that this is a slow path. + // Anything that is not a continuation mask is a 'leading byte', that is, the + // start of a new code point. + uint64_t utf8_continuation_mask = in.lt(-65 + 1); + // -65 is 0b10111111 in two-complement's, so largest possible continuation byte + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + // The *start* of code points is not so useful, rather, we want the *end* of code points. + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times when using solely + // the slow/regular path, and at least four times if there are fast paths. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + // + // Thus we may allow convert_masked_utf8_to_utf16 to process + // more bytes at a time under a fast-path mode where 16 bytes + // are consumed at once (e.g., when encountering ASCII). + size_t consumed = convert_masked_utf8_to_utf16(input + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + utf16_output += scalar::utf8_to_utf16::convert_valid(input + pos, size - pos, utf16_output); + return utf16_output - start; } } // namespace utf8_to_utf16 @@ -21824,32 +24831,31 @@ simdutf_warn_unused size_t convert_valid(const char* input, size_t size, } // namespace haswell } // namespace simdutf /* end file src/generic/utf8_to_utf16/valid_utf8_to_utf16.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf16/utf8_to_utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf16/utf8_to_utf16.h /* begin file src/generic/utf8_to_utf16/utf8_to_utf16.h */ - namespace simdutf { namespace haswell { namespace { namespace utf8_to_utf16 { using namespace simd; - - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -21857,258 +24863,281 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } - +} - struct validating_transcoder { +struct validating_transcoder { // If this is nonzero, there has been a UTF-8 error. simd8 error; - validating_transcoder() : error(uint8_t(0)) {} - // - // Check whether the current bytes are valid UTF-8. - // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); - } - - - template - simdutf_really_inline size_t convert(const char* in, size_t size, char16_t* utf16_output) { - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf16(in + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { return 0; } - if(pos < size) { - size_t howmany = scalar::utf8_to_utf16::convert(in + pos, size - pos, utf16_output); - if(howmany == 0) { return 0; } - utf16_output += howmany; - } - return utf16_output - start; - } - - template - simdutf_really_inline result convert_with_errors(const char* in, size_t size, char16_t* utf16_output) { - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - if (errors()) { + validating_transcoder() + : error(uint8_t(0)) + { + } + // + // Check whether the current bytes are valid UTF-8. + // + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); + } + + template + simdutf_really_inline size_t convert(const char* in, size_t size, char16_t* utf16_output) + { + size_t pos = 0; + char16_t* start { utf16_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 8 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 8; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the eight last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf16(in + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { + return 0; + } + if (pos < size) { + size_t howmany = scalar::utf8_to_utf16::convert(in + pos, size - pos, utf16_output); + if (howmany == 0) { + return 0; + } + utf16_output += howmany; + } + return utf16_output - start; + } + + template + simdutf_really_inline result convert_with_errors(const char* in, size_t size, char16_t* utf16_output) + { + size_t pos = 0; + char16_t* start { utf16_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 8 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 8; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the eight last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + if (errors()) { + // rewind_and_convert_with_errors will seek a potential error from in+pos onward, + // with the ability to go back up to pos bytes, and read size-pos bytes forward. + result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); + res.count += pos; + return res; + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf16(in + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { // rewind_and_convert_with_errors will seek a potential error from in+pos onward, // with the ability to go back up to pos bytes, and read size-pos bytes forward. result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); res.count += pos; return res; - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf16(in + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { - // rewind_and_convert_with_errors will seek a potential error from in+pos onward, - // with the ability to go back up to pos bytes, and read size-pos bytes forward. - result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); - res.count += pos; - return res; - } - if(pos < size) { - // rewind_and_convert_with_errors will seek a potential error from in+pos onward, - // with the ability to go back up to pos bytes, and read size-pos bytes forward. - result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); - if (res.error) { // In case of error, we want the error position - res.count += pos; - return res; - } else { // In case of success, we want the number of word written - utf16_output += res.count; } - } - return result(error_code::SUCCESS, utf16_output - start); + if (pos < size) { + // rewind_and_convert_with_errors will seek a potential error from in+pos onward, + // with the ability to go back up to pos bytes, and read size-pos bytes forward. + result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); + if (res.error) { // In case of error, we want the error position + res.count += pos; + return res; + } else { // In case of success, we want the number of word written + utf16_output += res.count; + } + } + return result(error_code::SUCCESS, utf16_output - start); } - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // utf8_to_utf16 namespace } // unnamed namespace } // namespace haswell } // namespace simdutf /* end file src/generic/utf8_to_utf16/utf8_to_utf16.h */ // transcoding from UTF-8 to UTF-32 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf32/valid_utf8_to_utf32.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf32/valid_utf8_to_utf32.h /* begin file src/generic/utf8_to_utf32/valid_utf8_to_utf32.h */ namespace simdutf { @@ -22118,68 +25147,66 @@ namespace utf8_to_utf32 { using namespace simd; - simdutf_warn_unused size_t convert_valid(const char* input, size_t size, - char32_t* utf32_output) noexcept { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 in(reinterpret_cast(input + pos)); - if(in.is_ascii()) { - in.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // -65 is 0b10111111 in two-complement's, so largest possible continuation byte - uint64_t utf8_continuation_mask = in.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - size_t max_starting_point = (pos + 64) - 12; - while(pos < max_starting_point) { - size_t consumed = convert_masked_utf8_to_utf32(input + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } + char32_t* utf32_output) noexcept +{ + size_t pos = 0; + char32_t* start { utf32_output }; + const size_t safety_margin = 16; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 in(reinterpret_cast(input + pos)); + if (in.is_ascii()) { + in.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // -65 is 0b10111111 in two-complement's, so largest possible continuation byte + uint64_t utf8_continuation_mask = in.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + size_t max_starting_point = (pos + 64) - 12; + while (pos < max_starting_point) { + size_t consumed = convert_masked_utf8_to_utf32(input + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + } } - } - utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos, utf32_output); - return utf32_output - start; + utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos, utf32_output); + return utf32_output - start; } - } // namespace utf8_to_utf32 } // unnamed namespace } // namespace haswell } // namespace simdutf /* end file src/generic/utf8_to_utf32/valid_utf8_to_utf32.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf32/utf8_to_utf32.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf32/utf8_to_utf32.h /* begin file src/generic/utf8_to_utf32/utf8_to_utf32.h */ - namespace simdutf { namespace haswell { namespace { namespace utf8_to_utf32 { using namespace simd; - - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -22187,251 +25214,273 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } - +} - struct validating_transcoder { +struct validating_transcoder { // If this is nonzero, there has been a UTF-8 error. simd8 error; - validating_transcoder() : error(uint8_t(0)) {} + validating_transcoder() + : error(uint8_t(0)) + { + } // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); - } - - - - simdutf_really_inline size_t convert(const char* in, size_t size, char32_t* utf32_output) { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf32(in + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { return 0; } - if(pos < size) { - size_t howmany = scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output); - if(howmany == 0) { return 0; } - utf32_output += howmany; - } - return utf32_output - start; - } - - simdutf_really_inline result convert_with_errors(const char* in, size_t size, char32_t* utf32_output) { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - if (errors()) { + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); + } + + simdutf_really_inline size_t convert(const char* in, size_t size, char32_t* utf32_output) + { + size_t pos = 0; + char32_t* start { utf32_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 4 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 4; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the fourth last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf32(in + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { + return 0; + } + if (pos < size) { + size_t howmany = scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output); + if (howmany == 0) { + return 0; + } + utf32_output += howmany; + } + return utf32_output - start; + } + + simdutf_really_inline result convert_with_errors(const char* in, size_t size, char32_t* utf32_output) + { + size_t pos = 0; + char32_t* start { utf32_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 4 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 4; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the fourth last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + if (errors()) { + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); + res.count += pos; + return res; + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf32(in + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); res.count += pos; return res; - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf32(in + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); - res.count += pos; - return res; - } - if(pos < size) { - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); - if (res.error) { // In case of error, we want the error position - res.count += pos; - return res; - } else { // In case of success, we want the number of word written - utf32_output += res.count; } - } - return result(error_code::SUCCESS, utf32_output - start); + if (pos < size) { + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); + if (res.error) { // In case of error, we want the error position + res.count += pos; + return res; + } else { // In case of success, we want the number of word written + utf32_output += res.count; + } + } + return result(error_code::SUCCESS, utf32_output - start); } - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // utf8_to_utf32 namespace } // unnamed namespace } // namespace haswell } // namespace simdutf /* end file src/generic/utf8_to_utf32/utf8_to_utf32.h */ // other functions -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8.h /* begin file src/generic/utf8.h */ namespace simdutf { @@ -22441,36 +25490,37 @@ namespace utf8 { using namespace simd; -simdutf_really_inline size_t count_code_points(const char* in, size_t size) { +simdutf_really_inline size_t count_code_points(const char* in, size_t size) +{ size_t pos = 0; size_t count = 0; - for(;pos + 64 <= size; pos += 64) { - simd8x64 input(reinterpret_cast(in + pos)); - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - count += 64 - count_ones(utf8_continuation_mask); + for (; pos + 64 <= size; pos += 64) { + simd8x64 input(reinterpret_cast(in + pos)); + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + count += 64 - count_ones(utf8_continuation_mask); } return count + scalar::utf8::count_code_points(in + pos, size - pos); } - -simdutf_really_inline size_t utf16_length_from_utf8(const char* in, size_t size) { +simdutf_really_inline size_t utf16_length_from_utf8(const char* in, size_t size) +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 64 <= size; pos += 64) { - simd8x64 input(reinterpret_cast(in + pos)); - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - // We count one word for anything that is not a continuation (so - // leading bytes). - count += 64 - count_ones(utf8_continuation_mask); - int64_t utf8_4byte = input.gteq_unsigned(240); - count += count_ones(utf8_4byte); + for (; pos + 64 <= size; pos += 64) { + simd8x64 input(reinterpret_cast(in + pos)); + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + // We count one word for anything that is not a continuation (so + // leading bytes). + count += 64 - count_ones(utf8_continuation_mask); + int64_t utf8_4byte = input.gteq_unsigned(240); + count += count_ones(utf8_4byte); } return count + scalar::utf8::utf16_length_from_utf8(in + pos, size - pos); } - -simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) { +simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) +{ return count_code_points(in, size); } } // utf8 namespace @@ -22478,64 +25528,72 @@ simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) } // namespace haswell } // namespace simdutf /* end file src/generic/utf8.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf16.h /* begin file src/generic/utf16.h */ namespace simdutf { namespace haswell { namespace { namespace utf16 { -template -simdutf_really_inline size_t count_code_points(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t count_code_points(const char16_t* in, size_t size) +{ size_t pos = 0; size_t count = 0; - for(;pos + 32 <= size; pos += 32) { - simd16x32 input(reinterpret_cast(in + pos)); - if (!match_system(big_endian)) input.swap_bytes(); - uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF); - count += count_ones(not_pair) / 2; + for (; pos + 32 <= size; pos += 32) { + simd16x32 input(reinterpret_cast(in + pos)); + if (!match_system(big_endian)) { + input.swap_bytes(); + } + uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF); + count += count_ones(not_pair) / 2; } return count + scalar::utf16::count_code_points(in + pos, size - pos); } -template -simdutf_really_inline size_t utf8_length_from_utf16(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t utf8_length_from_utf16(const char16_t* in, size_t size) +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 32 <= size; pos += 32) { - simd16x32 input(reinterpret_cast(in + pos)); - if (!match_system(big_endian)) input.swap_bytes(); - uint64_t ascii_mask = input.lteq(0x7F); - uint64_t twobyte_mask = input.lteq(0x7FF); - uint64_t not_pair_mask = input.not_in_range(0xD800, 0xDFFF); - - size_t ascii_count = count_ones(ascii_mask) / 2; - size_t twobyte_count = count_ones(twobyte_mask & ~ ascii_mask) / 2; - size_t threebyte_count = count_ones(not_pair_mask & ~ twobyte_mask) / 2; - size_t fourbyte_count = 32 - count_ones(not_pair_mask) / 2; - count += 2 * fourbyte_count + 3 * threebyte_count + 2 * twobyte_count + ascii_count; + for (; pos + 32 <= size; pos += 32) { + simd16x32 input(reinterpret_cast(in + pos)); + if (!match_system(big_endian)) { + input.swap_bytes(); + } + uint64_t ascii_mask = input.lteq(0x7F); + uint64_t twobyte_mask = input.lteq(0x7FF); + uint64_t not_pair_mask = input.not_in_range(0xD800, 0xDFFF); + + size_t ascii_count = count_ones(ascii_mask) / 2; + size_t twobyte_count = count_ones(twobyte_mask & ~ascii_mask) / 2; + size_t threebyte_count = count_ones(not_pair_mask & ~twobyte_mask) / 2; + size_t fourbyte_count = 32 - count_ones(not_pair_mask) / 2; + count += 2 * fourbyte_count + 3 * threebyte_count + 2 * twobyte_count + ascii_count; } return count + scalar::utf16::utf8_length_from_utf16(in + pos, size - pos); } -template -simdutf_really_inline size_t utf32_length_from_utf16(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t utf32_length_from_utf16(const char16_t* in, size_t size) +{ return count_code_points(in, size); } -simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* output) { - size_t pos = 0; +simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* output) +{ + size_t pos = 0; - while (pos + 32 <= size) { - simd16x32 input(reinterpret_cast(in + pos)); - input.swap_bytes(); - input.store(reinterpret_cast(output)); - pos += 32; - output += 32; - } + while (pos + 32 <= size) { + simd16x32 input(reinterpret_cast(in + pos)); + input.swap_bytes(); + input.store(reinterpret_cast(output)); + pos += 32; + output += 32; + } - scalar::utf16::change_endianness_utf16(in + pos, size - pos, output); + scalar::utf16::change_endianness_utf16(in + pos, size - pos, output); } } // utf16 @@ -22547,466 +25605,667 @@ simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t si namespace simdutf { namespace haswell { -simdutf_warn_unused int implementation::detect_encodings(const char * input, size_t length) const noexcept { - // If there is a BOM, then we trust it. - auto bom_encoding = simdutf::BOM::check_bom(input, length); - if(bom_encoding != encoding_type::unspecified) { return bom_encoding; } - if (length % 2 == 0) { - return avx2_detect_encodings(input, length); - } else { - if (implementation::validate_utf8(input, length)) { - return simdutf::encoding_type::UTF8; +simdutf_warn_unused int implementation::detect_encodings(const char* input, size_t length) const noexcept +{ + // If there is a BOM, then we trust it. + auto bom_encoding = simdutf::BOM::check_bom(input, length); + if (bom_encoding != encoding_type::unspecified) { + return bom_encoding; + } + if (length % 2 == 0) { + return avx2_detect_encodings(input, length); } else { - return simdutf::encoding_type::unspecified; + if (implementation::validate_utf8(input, length)) { + return simdutf::encoding_type::UTF8; + } else { + return simdutf::encoding_type::unspecified; + } } - } } -simdutf_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { - return haswell::utf8_validation::generic_validate_utf8(buf,len); +simdutf_warn_unused bool implementation::validate_utf8(const char* buf, size_t len) const noexcept +{ + return haswell::utf8_validation::generic_validate_utf8(buf, len); } -simdutf_warn_unused result implementation::validate_utf8_with_errors(const char *buf, size_t len) const noexcept { - return haswell::utf8_validation::generic_validate_utf8_with_errors(buf,len); +simdutf_warn_unused result implementation::validate_utf8_with_errors(const char* buf, size_t len) const noexcept +{ + return haswell::utf8_validation::generic_validate_utf8_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_ascii(const char *buf, size_t len) const noexcept { - return haswell::utf8_validation::generic_validate_ascii(buf,len); +simdutf_warn_unused bool implementation::validate_ascii(const char* buf, size_t len) const noexcept +{ + return haswell::utf8_validation::generic_validate_ascii(buf, len); } -simdutf_warn_unused result implementation::validate_ascii_with_errors(const char *buf, size_t len) const noexcept { - return haswell::utf8_validation::generic_validate_ascii_with_errors(buf,len); +simdutf_warn_unused result implementation::validate_ascii_with_errors(const char* buf, size_t len) const noexcept +{ + return haswell::utf8_validation::generic_validate_ascii_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_utf16le(const char16_t *buf, size_t len) const noexcept { - const char16_t* tail = avx2_validate_utf16(buf, len); - if (tail) { - return scalar::utf16::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf16le(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* tail = avx2_validate_utf16(buf, len); + if (tail) { + return scalar::utf16::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused bool implementation::validate_utf16be(const char16_t *buf, size_t len) const noexcept { - const char16_t* tail = avx2_validate_utf16(buf, len); - if (tail) { - return scalar::utf16::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf16be(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* tail = avx2_validate_utf16(buf, len); + if (tail) { + return scalar::utf16::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept { - result res = avx2_validate_utf16_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept +{ + result res = avx2_validate_utf16_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } } -simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept { - result res = avx2_validate_utf16_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept +{ + result res = avx2_validate_utf16_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } } -simdutf_warn_unused bool implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept { - const char32_t* tail = avx2_validate_utf32le(buf, len); - if (tail) { - return scalar::utf32::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf32(const char32_t* buf, size_t len) const noexcept +{ + const char32_t* tail = avx2_validate_utf32le(buf, len); + if (tail) { + return scalar::utf32::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept { - result res = avx2_validate_utf32le_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf32::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept +{ + result res = avx2_validate_utf32le_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf32::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::latin1_to_utf8::convert(buf, len, utf8_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_latin1_to_utf32(const char* buf, size_t len, char32_t* latin1_output) const noexcept +{ + return scalar::latin1_to_utf32::convert(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_valid(buf, len, latin1_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf16_output); } simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* input, size_t size, - char16_t* utf16_output) const noexcept { - return utf8_to_utf16::convert_valid(input, size, utf16_output); + char16_t* utf16_output) const noexcept +{ + return utf8_to_utf16::convert_valid(input, size, utf16_output); } simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* input, size_t size, - char16_t* utf16_output) const noexcept { - return utf8_to_utf16::convert_valid(input, size, utf16_output); + char16_t* utf16_output) const noexcept +{ + return utf8_to_utf16::convert_valid(input, size, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept { - utf8_to_utf32::validating_transcoder converter; - return converter.convert(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + utf8_to_utf32::validating_transcoder converter; + return converter.convert(buf, len, utf32_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept { - utf8_to_utf32::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf32_output); +simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + utf8_to_utf32::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf32_output); } simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* input, size_t size, - char32_t* utf32_output) const noexcept { - return utf8_to_utf32::convert_valid(input, size, utf32_output); -} - -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = haswell::avx2_convert_utf16_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = haswell::avx2_convert_utf16_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = haswell::avx2_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = haswell::avx2_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; + char32_t* utf32_output) const noexcept +{ + return utf8_to_utf32::convert_valid(input, size, utf32_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = haswell::avx2_convert_utf16_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = haswell::avx2_convert_utf16_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf16le_to_utf8(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = haswell::avx2_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = haswell::avx2_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf16be_to_utf8(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf16le_to_utf8(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = avx2_convert_utf32_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf16be_to_utf8(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = haswell::avx2_convert_utf32_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::pair ret = haswell::avx2_convert_utf16_to_utf32(buf, len, utf32_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf32_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::pair ret = haswell::avx2_convert_utf16_to_utf32(buf, len, utf32_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf32_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = haswell::avx2_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = haswell::avx2_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf32_to_utf8(buf, len, utf8_output); -} - -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - std::pair ret = avx2_convert_utf32_to_utf16(buf, len, utf16_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf16_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - std::pair ret = avx2_convert_utf32_to_utf16(buf, len, utf16_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf16_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = haswell::avx2_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf16::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = haswell::avx2_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf16::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; +simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = avx2_convert_utf32_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = haswell::avx2_convert_utf32_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::pair ret = haswell::avx2_convert_utf16_to_utf32(buf, len, utf32_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf32_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::pair ret = haswell::avx2_convert_utf16_to_utf32(buf, len, utf32_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf32_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = haswell::avx2_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = haswell::avx2_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } } - } - ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written - return ret.first; + ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written + return ret.first; } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return convert_utf32_to_utf16le(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf32_to_utf8(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return convert_utf32_to_utf16be(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + std::pair ret = avx2_convert_utf32_to_utf16(buf, len, utf16_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf16_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + std::pair ret = avx2_convert_utf32_to_utf16(buf, len, utf16_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf16_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = haswell::avx2_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf16::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = haswell::avx2_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf16::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return convert_utf32_to_utf16le(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return convert_utf32_to_utf16be(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return convert_utf16le_to_utf32(buf, len, utf32_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return convert_utf16be_to_utf32(buf, len, utf32_output); +} + +void implementation::change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) const noexcept +{ + utf16::change_endianness_utf16(input, length, output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return convert_utf16le_to_utf32(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::count_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return convert_utf16be_to_utf32(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::count_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::count_code_points(input, length); } -void implementation::change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) const noexcept { - utf16::change_endianness_utf16(input, length, output); +simdutf_warn_unused size_t implementation::count_utf8(const char* input, size_t length) const noexcept +{ + return utf8::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::count_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf8(const char* buf, size_t len) const noexcept +{ + return scalar::utf8::latin1_length_from_utf8(buf, len); } -simdutf_warn_unused size_t implementation::count_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf16(size_t length) const noexcept +{ + return scalar::utf16::latin1_length_from_utf16(length); } -simdutf_warn_unused size_t implementation::count_utf8(const char * input, size_t length) const noexcept { - return utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf32(size_t length) const noexcept +{ + return scalar::utf32::latin1_length_from_utf32(length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf32_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf32_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char * input, size_t length) const noexcept { - return utf8::utf16_length_from_utf8(input, length); +simdutf_warn_unused size_t implementation::utf16_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf16_length_from_latin1(length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept { - const __m256i v_00000000 = _mm256_setzero_si256(); - const __m256i v_ffffff80 = _mm256_set1_epi32((uint32_t)0xffffff80); - const __m256i v_fffff800 = _mm256_set1_epi32((uint32_t)0xfffff800); - const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); - size_t pos = 0; - size_t count = 0; - for(;pos + 8 <= length; pos += 8) { - __m256i in = _mm256_loadu_si256((__m256i*)(input + pos)); - const __m256i ascii_bytes_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffffff80), v_00000000); - const __m256i one_two_bytes_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_fffff800), v_00000000); - const __m256i two_bytes_bytemask = _mm256_xor_si256(one_two_bytes_bytemask, ascii_bytes_bytemask); - const __m256i one_two_three_bytes_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); - const __m256i three_bytes_bytemask = _mm256_xor_si256(one_two_three_bytes_bytemask, one_two_bytes_bytemask); - const uint32_t ascii_bytes_bitmask = static_cast(_mm256_movemask_epi8(ascii_bytes_bytemask)); - const uint32_t two_bytes_bitmask = static_cast(_mm256_movemask_epi8(two_bytes_bytemask)); - const uint32_t three_bytes_bitmask = static_cast(_mm256_movemask_epi8(three_bytes_bytemask)); +simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char* input, size_t length) const noexcept +{ + return utf8::utf16_length_from_utf8(input, length); +} + +simdutf_warn_unused size_t implementation::utf32_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf32_length_from_latin1(length); +} - size_t ascii_count = count_ones(ascii_bytes_bitmask) / 4; - size_t two_bytes_count = count_ones(two_bytes_bitmask) / 4; - size_t three_bytes_count = count_ones(three_bytes_bitmask) / 4; - count += 32 - 3*ascii_count - 2*two_bytes_count - three_bytes_count; - } - return count + scalar::utf32::utf8_length_from_utf32(input + pos, length - pos); +simdutf_warn_unused size_t implementation::utf8_length_from_latin1(const char* input, size_t length) const noexcept +{ + return scalar::latin1::utf8_length_from_latin1(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept { - const __m256i v_00000000 = _mm256_setzero_si256(); - const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); - size_t pos = 0; - size_t count = 0; - for(;pos + 8 <= length; pos += 8) { - __m256i in = _mm256_loadu_si256((__m256i*)(input + pos)); - const __m256i surrogate_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); - const uint32_t surrogate_bitmask = static_cast(_mm256_movemask_epi8(surrogate_bytemask)); - size_t surrogate_count = (32-count_ones(surrogate_bitmask))/4; - count += 8 + surrogate_count; - } - return count + scalar::utf32::utf16_length_from_utf32(input + pos, length - pos); +simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + const __m256i v_00000000 = _mm256_setzero_si256(); + const __m256i v_ffffff80 = _mm256_set1_epi32((uint32_t)0xffffff80); + const __m256i v_fffff800 = _mm256_set1_epi32((uint32_t)0xfffff800); + const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); + size_t pos = 0; + size_t count = 0; + for (; pos + 8 <= length; pos += 8) { + __m256i in = _mm256_loadu_si256((__m256i*)(input + pos)); + const __m256i ascii_bytes_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffffff80), v_00000000); + const __m256i one_two_bytes_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_fffff800), v_00000000); + const __m256i two_bytes_bytemask = _mm256_xor_si256(one_two_bytes_bytemask, ascii_bytes_bytemask); + const __m256i one_two_three_bytes_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); + const __m256i three_bytes_bytemask = _mm256_xor_si256(one_two_three_bytes_bytemask, one_two_bytes_bytemask); + const uint32_t ascii_bytes_bitmask = static_cast(_mm256_movemask_epi8(ascii_bytes_bytemask)); + const uint32_t two_bytes_bitmask = static_cast(_mm256_movemask_epi8(two_bytes_bytemask)); + const uint32_t three_bytes_bitmask = static_cast(_mm256_movemask_epi8(three_bytes_bytemask)); + + size_t ascii_count = count_ones(ascii_bytes_bitmask) / 4; + size_t two_bytes_count = count_ones(two_bytes_bitmask) / 4; + size_t three_bytes_count = count_ones(three_bytes_bitmask) / 4; + count += 32 - 3 * ascii_count - 2 * two_bytes_count - three_bytes_count; + } + return count + scalar::utf32::utf8_length_from_utf32(input + pos, length - pos); +} + +simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + const __m256i v_00000000 = _mm256_setzero_si256(); + const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000); + size_t pos = 0; + size_t count = 0; + for (; pos + 8 <= length; pos += 8) { + __m256i in = _mm256_loadu_si256((__m256i*)(input + pos)); + const __m256i surrogate_bytemask = _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000); + const uint32_t surrogate_bitmask = static_cast(_mm256_movemask_epi8(surrogate_bytemask)); + size_t surrogate_count = (32 - count_ones(surrogate_bitmask)) / 4; + count += 8 + surrogate_count; + } + return count + scalar::utf32::utf16_length_from_utf32(input + pos, length - pos); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char * input, size_t length) const noexcept { - return scalar::utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char* input, size_t length) const noexcept +{ + return scalar::utf8::count_code_points(input, length); } } // namespace haswell } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/haswell/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/haswell/end.h /* begin file src/simdutf/haswell/end.h */ #if SIMDUTF_CAN_ALWAYS_RUN_HASWELL // nothing needed. @@ -23014,7 +26273,6 @@ simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char * i SIMDUTF_UNTARGET_REGION #endif - #if SIMDUTF_GCC11ORMORE // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593 SIMDUTF_POP_DISABLE_WARNINGS #endif // end of workaround @@ -23022,14 +26280,10 @@ SIMDUTF_POP_DISABLE_WARNINGS /* end file src/haswell/implementation.cpp */ #endif #if SIMDUTF_IMPLEMENTATION_PPC64 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=ppc64/implementation.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=ppc64/implementation.cpp /* begin file src/ppc64/implementation.cpp */ - - - - -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64/begin.h /* begin file src/simdutf/ppc64/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "ppc64" // #define SIMDUTF_IMPLEMENTATION ppc64 @@ -23042,32 +26296,34 @@ namespace { #endif using namespace simd; - -simdutf_really_inline bool is_ascii(const simd8x64& input) { - // careful: 0x80 is not ascii. - return input.reduce_or().saturating_sub(0b01111111u).bits_not_set_anywhere(); +simdutf_really_inline bool is_ascii(const simd8x64& input) +{ + // careful: 0x80 is not ascii. + return input.reduce_or().saturating_sub(0b01111111u).bits_not_set_anywhere(); } -simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { - simd8 is_second_byte = prev1.saturating_sub(0b11000000u-1); // Only 11______ will be > 0 - simd8 is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); +simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) +{ + simd8 is_second_byte = prev1.saturating_sub(0b11000000u - 1); // Only 11______ will be > 0 + simd8 is_third_byte = prev2.saturating_sub(0b11100000u - 1); // Only 111_____ will be > 0 + simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u - 1); // Only 1111____ will be > 0 + // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. + return simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); } -simdutf_really_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_third_byte | is_fourth_byte) > int8_t(0); +simdutf_really_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) +{ + simd8 is_third_byte = prev2.saturating_sub(0b11100000u - 1); // Only 111_____ will be > 0 + simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u - 1); // Only 1111____ will be > 0 + // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. + return simd8(is_third_byte | is_fourth_byte) > int8_t(0); } } // unnamed namespace } // namespace ppc64 } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/buf_block_reader.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/buf_block_reader.h /* begin file src/generic/buf_block_reader.h */ namespace simdutf { namespace ppc64 { @@ -23077,92 +26333,110 @@ namespace { template struct buf_block_reader { public: - simdutf_really_inline buf_block_reader(const uint8_t *_buf, size_t _len); - simdutf_really_inline size_t block_index(); - simdutf_really_inline bool has_full_block() const; - simdutf_really_inline const uint8_t *full_block() const; - /** - * Get the last block, padded with spaces. - * - * There will always be a last block, with at least 1 byte, unless len == 0 (in which case this - * function fills the buffer with spaces and returns 0. In particular, if len == STEP_SIZE there - * will be 0 full_blocks and 1 remainder block with STEP_SIZE bytes and no spaces for padding. - * - * @return the number of effective characters in the last block. - */ - simdutf_really_inline size_t get_remainder(uint8_t *dst) const; - simdutf_really_inline void advance(); + simdutf_really_inline buf_block_reader(const uint8_t* _buf, size_t _len); + simdutf_really_inline size_t block_index(); + simdutf_really_inline bool has_full_block() const; + simdutf_really_inline const uint8_t* full_block() const; + /** + * Get the last block, padded with spaces. + * + * There will always be a last block, with at least 1 byte, unless len == 0 (in which case this + * function fills the buffer with spaces and returns 0. In particular, if len == STEP_SIZE there + * will be 0 full_blocks and 1 remainder block with STEP_SIZE bytes and no spaces for padding. + * + * @return the number of effective characters in the last block. + */ + simdutf_really_inline size_t get_remainder(uint8_t* dst) const; + simdutf_really_inline void advance(); + private: - const uint8_t *buf; - const size_t len; - const size_t lenminusstep; - size_t idx; + const uint8_t* buf; + const size_t len; + const size_t lenminusstep; + size_t idx; }; // Routines to print masks and text for debugging bitmask operations -simdutf_unused static char * format_input_text_64(const uint8_t *text) { - static char *buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); - for (size_t i=0; i); i++) { - buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); - } - buf[sizeof(simd8x64)] = '\0'; - return buf; +simdutf_unused static char* format_input_text_64(const uint8_t* text) +{ + static char* buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); + for (size_t i = 0; i < sizeof(simd8x64); i++) { + buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); + } + buf[sizeof(simd8x64)] = '\0'; + return buf; } // Routines to print masks and text for debugging bitmask operations -simdutf_unused static char * format_input_text(const simd8x64& in) { - static char *buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); - in.store(reinterpret_cast(buf)); - for (size_t i=0; i); i++) { - if (buf[i] < ' ') { buf[i] = '_'; } - } - buf[sizeof(simd8x64)] = '\0'; - return buf; +simdutf_unused static char* format_input_text(const simd8x64& in) +{ + static char* buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); + in.store(reinterpret_cast(buf)); + for (size_t i = 0; i < sizeof(simd8x64); i++) { + if (buf[i] < ' ') { + buf[i] = '_'; + } + } + buf[sizeof(simd8x64)] = '\0'; + return buf; } -simdutf_unused static char * format_mask(uint64_t mask) { - static char *buf = reinterpret_cast(malloc(64 + 1)); - for (size_t i=0; i<64; i++) { - buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; - } - buf[64] = '\0'; - return buf; +simdutf_unused static char* format_mask(uint64_t mask) +{ + static char* buf = reinterpret_cast(malloc(64 + 1)); + for (size_t i = 0; i < 64; i++) { + buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; + } + buf[64] = '\0'; + return buf; } template -simdutf_really_inline buf_block_reader::buf_block_reader(const uint8_t *_buf, size_t _len) : buf{_buf}, len{_len}, lenminusstep{len < STEP_SIZE ? 0 : len - STEP_SIZE}, idx{0} {} +simdutf_really_inline buf_block_reader::buf_block_reader(const uint8_t* _buf, size_t _len) + : buf { _buf } + , len { _len } + , lenminusstep { len < STEP_SIZE ? 0 : len - STEP_SIZE } + , idx { 0 } +{ +} template simdutf_really_inline size_t buf_block_reader::block_index() { return idx; } template -simdutf_really_inline bool buf_block_reader::has_full_block() const { - return idx < lenminusstep; +simdutf_really_inline bool buf_block_reader::has_full_block() const +{ + return idx < lenminusstep; } template -simdutf_really_inline const uint8_t *buf_block_reader::full_block() const { - return &buf[idx]; +simdutf_really_inline const uint8_t* buf_block_reader::full_block() const +{ + return &buf[idx]; } template -simdutf_really_inline size_t buf_block_reader::get_remainder(uint8_t *dst) const { - if(len == idx) { return 0; } // memcpy(dst, null, 0) will trigger an error with some sanitizers - std::memset(dst, 0x20, STEP_SIZE); // std::memset STEP_SIZE because it's more efficient to write out 8 or 16 bytes at once. - std::memcpy(dst, buf + idx, len - idx); - return len - idx; +simdutf_really_inline size_t buf_block_reader::get_remainder(uint8_t* dst) const +{ + if (len == idx) { + return 0; + } // memcpy(dst, null, 0) will trigger an error with some sanitizers + std::memset(dst, 0x20, STEP_SIZE); // std::memset STEP_SIZE because it's more efficient to write out 8 or 16 bytes at once. + std::memcpy(dst, buf + idx, len - idx); + return len - idx; } template -simdutf_really_inline void buf_block_reader::advance() { - idx += STEP_SIZE; +simdutf_really_inline void buf_block_reader::advance() +{ + idx += STEP_SIZE; } } // unnamed namespace } // namespace ppc64 } // namespace simdutf /* end file src/generic/buf_block_reader.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_validation/utf8_lookup4_algorithm.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_validation/utf8_lookup4_algorithm.h /* begin file src/generic/utf8_validation/utf8_lookup4_algorithm.h */ namespace simdutf { namespace ppc64 { @@ -23171,21 +26445,22 @@ namespace utf8_validation { using namespace simd; - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -23193,101 +26468,92 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } +} - // - // Return nonzero if there are incomplete multibyte characters at the end of the block: - // e.g. if there is a 4-byte character, but it's 3 bytes from the end. - // - simdutf_really_inline simd8 is_incomplete(const simd8 input) { +// +// Return nonzero if there are incomplete multibyte characters at the end of the block: +// e.g. if there is a 4-byte character, but it's 3 bytes from the end. +// +simdutf_really_inline simd8 is_incomplete(const simd8 input) +{ // If the previous input's last 3 bytes match this, they're too short (they ended at EOF): // ... 1111____ 111_____ 11______ static const uint8_t max_array[32] = { - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 0b11110000u-1, 0b11100000u-1, 0b11000000u-1 + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 0b11110000u - 1, 0b11100000u - 1, 0b11000000u - 1 }; - const simd8 max_value(&max_array[sizeof(max_array)-sizeof(simd8)]); + const simd8 max_value(&max_array[sizeof(max_array) - sizeof(simd8)]); return input.gt_bits(max_value); - } +} - struct utf8_checker { +struct utf8_checker { // If this is nonzero, there has been a UTF-8 error. simd8 error; // The last input we received @@ -23298,51 +26564,54 @@ using namespace simd; // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); } // The only problem that can happen at EOF is that a multibyte character is too short // or a byte value too large in the last bytes: check_special_cases only checks for bytes // too large in the first of two bytes. - simdutf_really_inline void check_eof() { - // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't - // possibly finish them. - this->error |= this->prev_incomplete; + simdutf_really_inline void check_eof() + { + // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't + // possibly finish them. + this->error |= this->prev_incomplete; } - simdutf_really_inline void check_next_input(const simd8x64& input) { - if(simdutf_likely(is_ascii(input))) { - this->error |= this->prev_incomplete; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + simdutf_really_inline void check_next_input(const simd8x64& input) + { + if (simdutf_likely(is_ascii(input))) { + this->error |= this->prev_incomplete; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + this->prev_incomplete = is_incomplete(input.chunks[simd8x64::NUM_CHUNKS - 1]); + this->prev_input_block = input.chunks[simd8x64::NUM_CHUNKS - 1]; } - this->prev_incomplete = is_incomplete(input.chunks[simd8x64::NUM_CHUNKS-1]); - this->prev_input_block = input.chunks[simd8x64::NUM_CHUNKS-1]; - - } } // do not forget to call check_eof! - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // namespace utf8_validation using utf8_validation::utf8_checker; @@ -23351,7 +26620,7 @@ using utf8_validation::utf8_checker; } // namespace ppc64 } // namespace simdutf /* end file src/generic/utf8_validation/utf8_lookup4_algorithm.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_validation/utf8_validator.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_validation/utf8_validator.h /* begin file src/generic/utf8_validation/utf8_validator.h */ namespace simdutf { namespace ppc64 { @@ -23362,15 +26631,16 @@ namespace utf8_validation { * Validates that the string is actual UTF-8. */ template -bool generic_validate_utf8(const uint8_t * input, size_t length) { - checker c{}; +bool generic_validate_utf8(const uint8_t* input, size_t length) +{ + checker c {}; buf_block_reader<64> reader(input, length); while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - c.check_next_input(in); - reader.advance(); + simd::simd8x64 in(reader.full_block()); + c.check_next_input(in); + reader.advance(); } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); c.check_next_input(in); @@ -23379,97 +26649,106 @@ bool generic_validate_utf8(const uint8_t * input, size_t length) { return !c.errors(); } -bool generic_validate_utf8(const char * input, size_t length) { - return generic_validate_utf8(reinterpret_cast(input),length); +bool generic_validate_utf8(const char* input, size_t length) +{ + return generic_validate_utf8(reinterpret_cast(input), length); } /** * Validates that the string is actual UTF-8 and stops on errors. */ template -result generic_validate_utf8_with_errors(const uint8_t * input, size_t length) { - checker c{}; +result generic_validate_utf8_with_errors(const uint8_t* input, size_t length) +{ + checker c {}; buf_block_reader<64> reader(input, length); - size_t count{0}; + size_t count { 0 }; while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - c.check_next_input(in); - if(c.errors()) { - if (count != 0) { count--; } // Sometimes the error is only detected in the next chunk - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input + count), length - count); - res.count += count; - return res; - } - reader.advance(); - count += 64; + simd::simd8x64 in(reader.full_block()); + c.check_next_input(in); + if (c.errors()) { + if (count != 0) { + count--; + } // Sometimes the error is only detected in the next chunk + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input + count), length - count); + res.count += count; + return res; + } + reader.advance(); + count += 64; } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); c.check_next_input(in); reader.advance(); c.check_eof(); if (c.errors()) { - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input) + count, length - count); - res.count += count; - return res; + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input) + count, length - count); + res.count += count; + return res; } else { - return result(error_code::SUCCESS, length); + return result(error_code::SUCCESS, length); } } -result generic_validate_utf8_with_errors(const char * input, size_t length) { - return generic_validate_utf8_with_errors(reinterpret_cast(input),length); +result generic_validate_utf8_with_errors(const char* input, size_t length) +{ + return generic_validate_utf8_with_errors(reinterpret_cast(input), length); } template -bool generic_validate_ascii(const uint8_t * input, size_t length) { +bool generic_validate_ascii(const uint8_t* input, size_t length) +{ buf_block_reader<64> reader(input, length); - uint8_t blocks[64]{}; + uint8_t blocks[64] {}; simd::simd8x64 running_or(blocks); while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - running_or |= in; - reader.advance(); + simd::simd8x64 in(reader.full_block()); + running_or |= in; + reader.advance(); } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); running_or |= in; return running_or.is_ascii(); } -bool generic_validate_ascii(const char * input, size_t length) { - return generic_validate_ascii(reinterpret_cast(input),length); +bool generic_validate_ascii(const char* input, size_t length) +{ + return generic_validate_ascii(reinterpret_cast(input), length); } template -result generic_validate_ascii_with_errors(const uint8_t * input, size_t length) { - buf_block_reader<64> reader(input, length); - size_t count{0}; - while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); +result generic_validate_ascii_with_errors(const uint8_t* input, size_t length) +{ + buf_block_reader<64> reader(input, length); + size_t count { 0 }; + while (reader.has_full_block()) { + simd::simd8x64 in(reader.full_block()); + if (!in.is_ascii()) { + result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); + return result(res.error, count + res.count); + } + reader.advance(); + + count += 64; + } + uint8_t block[64] {}; + reader.get_remainder(block); + simd::simd8x64 in(block); if (!in.is_ascii()) { - result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); - return result(res.error, count + res.count); + result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); + return result(res.error, count + res.count); + } else { + return result(error_code::SUCCESS, length); } - reader.advance(); - - count += 64; - } - uint8_t block[64]{}; - reader.get_remainder(block); - simd::simd8x64 in(block); - if (!in.is_ascii()) { - result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); - return result(res.error, count + res.count); - } else { - return result(error_code::SUCCESS, length); - } } -result generic_validate_ascii_with_errors(const char * input, size_t length) { - return generic_validate_ascii_with_errors(reinterpret_cast(input),length); +result generic_validate_ascii_with_errors(const char* input, size_t length) +{ + return generic_validate_ascii_with_errors(reinterpret_cast(input), length); } } // namespace utf8_validation @@ -23478,10 +26757,9 @@ result generic_validate_ascii_with_errors(const char * input, size_t length) { } // namespace simdutf /* end file src/generic/utf8_validation/utf8_validator.h */ // transcoding from UTF-8 to UTF-16 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf16/valid_utf8_to_utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf16/valid_utf8_to_utf16.h /* begin file src/generic/utf8_to_utf16/valid_utf8_to_utf16.h */ - namespace simdutf { namespace ppc64 { namespace { @@ -23489,63 +26767,64 @@ namespace utf8_to_utf16 { using namespace simd; -template +template simdutf_warn_unused size_t convert_valid(const char* input, size_t size, - char16_t* utf16_output) noexcept { - // The implementation is not specific to haswell and should be moved to the generic directory. - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - // this loop could be unrolled further. For example, we could process the mask - // far more than 64 bytes. - simd8x64 in(reinterpret_cast(input + pos)); - if(in.is_ascii()) { - in.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // Slow path. We hope that the compiler will recognize that this is a slow path. - // Anything that is not a continuation mask is a 'leading byte', that is, the - // start of a new code point. - uint64_t utf8_continuation_mask = in.lt(-65 + 1); - // -65 is 0b10111111 in two-complement's, so largest possible continuation byte - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - // The *start* of code points is not so useful, rather, we want the *end* of code points. - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times when using solely - // the slow/regular path, and at least four times if there are fast paths. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - // - // Thus we may allow convert_masked_utf8_to_utf16 to process - // more bytes at a time under a fast-path mode where 16 bytes - // are consumed at once (e.g., when encountering ASCII). - size_t consumed = convert_masked_utf8_to_utf16(input + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - utf16_output += scalar::utf8_to_utf16::convert_valid(input + pos, size - pos, utf16_output); - return utf16_output - start; + char16_t* utf16_output) noexcept +{ + // The implementation is not specific to haswell and should be moved to the generic directory. + size_t pos = 0; + char16_t* start { utf16_output }; + const size_t safety_margin = 16; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + // this loop could be unrolled further. For example, we could process the mask + // far more than 64 bytes. + simd8x64 in(reinterpret_cast(input + pos)); + if (in.is_ascii()) { + in.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // Slow path. We hope that the compiler will recognize that this is a slow path. + // Anything that is not a continuation mask is a 'leading byte', that is, the + // start of a new code point. + uint64_t utf8_continuation_mask = in.lt(-65 + 1); + // -65 is 0b10111111 in two-complement's, so largest possible continuation byte + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + // The *start* of code points is not so useful, rather, we want the *end* of code points. + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times when using solely + // the slow/regular path, and at least four times if there are fast paths. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + // + // Thus we may allow convert_masked_utf8_to_utf16 to process + // more bytes at a time under a fast-path mode where 16 bytes + // are consumed at once (e.g., when encountering ASCII). + size_t consumed = convert_masked_utf8_to_utf16(input + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + utf16_output += scalar::utf8_to_utf16::convert_valid(input + pos, size - pos, utf16_output); + return utf16_output - start; } } // namespace utf8_to_utf16 @@ -23553,32 +26832,31 @@ simdutf_warn_unused size_t convert_valid(const char* input, size_t size, } // namespace ppc64 } // namespace simdutf /* end file src/generic/utf8_to_utf16/valid_utf8_to_utf16.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf16/utf8_to_utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf16/utf8_to_utf16.h /* begin file src/generic/utf8_to_utf16/utf8_to_utf16.h */ - namespace simdutf { namespace ppc64 { namespace { namespace utf8_to_utf16 { using namespace simd; - - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -23586,258 +26864,281 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } - +} - struct validating_transcoder { +struct validating_transcoder { // If this is nonzero, there has been a UTF-8 error. simd8 error; - validating_transcoder() : error(uint8_t(0)) {} + validating_transcoder() + : error(uint8_t(0)) + { + } // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); - } - - - template - simdutf_really_inline size_t convert(const char* in, size_t size, char16_t* utf16_output) { - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf16(in + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { return 0; } - if(pos < size) { - size_t howmany = scalar::utf8_to_utf16::convert(in + pos, size - pos, utf16_output); - if(howmany == 0) { return 0; } - utf16_output += howmany; - } - return utf16_output - start; - } - - template - simdutf_really_inline result convert_with_errors(const char* in, size_t size, char16_t* utf16_output) { - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - if (errors()) { + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); + } + + template + simdutf_really_inline size_t convert(const char* in, size_t size, char16_t* utf16_output) + { + size_t pos = 0; + char16_t* start { utf16_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 8 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 8; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the eight last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf16(in + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { + return 0; + } + if (pos < size) { + size_t howmany = scalar::utf8_to_utf16::convert(in + pos, size - pos, utf16_output); + if (howmany == 0) { + return 0; + } + utf16_output += howmany; + } + return utf16_output - start; + } + + template + simdutf_really_inline result convert_with_errors(const char* in, size_t size, char16_t* utf16_output) + { + size_t pos = 0; + char16_t* start { utf16_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 8 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 8; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the eight last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + if (errors()) { + // rewind_and_convert_with_errors will seek a potential error from in+pos onward, + // with the ability to go back up to pos bytes, and read size-pos bytes forward. + result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); + res.count += pos; + return res; + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf16(in + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { // rewind_and_convert_with_errors will seek a potential error from in+pos onward, // with the ability to go back up to pos bytes, and read size-pos bytes forward. result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); res.count += pos; return res; - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf16(in + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { - // rewind_and_convert_with_errors will seek a potential error from in+pos onward, - // with the ability to go back up to pos bytes, and read size-pos bytes forward. - result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); - res.count += pos; - return res; - } - if(pos < size) { - // rewind_and_convert_with_errors will seek a potential error from in+pos onward, - // with the ability to go back up to pos bytes, and read size-pos bytes forward. - result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); - if (res.error) { // In case of error, we want the error position - res.count += pos; - return res; - } else { // In case of success, we want the number of word written - utf16_output += res.count; } - } - return result(error_code::SUCCESS, utf16_output - start); + if (pos < size) { + // rewind_and_convert_with_errors will seek a potential error from in+pos onward, + // with the ability to go back up to pos bytes, and read size-pos bytes forward. + result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); + if (res.error) { // In case of error, we want the error position + res.count += pos; + return res; + } else { // In case of success, we want the number of word written + utf16_output += res.count; + } + } + return result(error_code::SUCCESS, utf16_output - start); } - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // utf8_to_utf16 namespace } // unnamed namespace } // namespace ppc64 } // namespace simdutf /* end file src/generic/utf8_to_utf16/utf8_to_utf16.h */ // transcoding from UTF-8 to UTF-32 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf32/valid_utf8_to_utf32.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf32/valid_utf8_to_utf32.h /* begin file src/generic/utf8_to_utf32/valid_utf8_to_utf32.h */ namespace simdutf { @@ -23847,68 +27148,66 @@ namespace utf8_to_utf32 { using namespace simd; - simdutf_warn_unused size_t convert_valid(const char* input, size_t size, - char32_t* utf32_output) noexcept { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 in(reinterpret_cast(input + pos)); - if(in.is_ascii()) { - in.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // -65 is 0b10111111 in two-complement's, so largest possible continuation byte - uint64_t utf8_continuation_mask = in.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - size_t max_starting_point = (pos + 64) - 12; - while(pos < max_starting_point) { - size_t consumed = convert_masked_utf8_to_utf32(input + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } + char32_t* utf32_output) noexcept +{ + size_t pos = 0; + char32_t* start { utf32_output }; + const size_t safety_margin = 16; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 in(reinterpret_cast(input + pos)); + if (in.is_ascii()) { + in.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // -65 is 0b10111111 in two-complement's, so largest possible continuation byte + uint64_t utf8_continuation_mask = in.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + size_t max_starting_point = (pos + 64) - 12; + while (pos < max_starting_point) { + size_t consumed = convert_masked_utf8_to_utf32(input + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + } } - } - utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos, utf32_output); - return utf32_output - start; + utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos, utf32_output); + return utf32_output - start; } - } // namespace utf8_to_utf32 } // unnamed namespace } // namespace ppc64 } // namespace simdutf /* end file src/generic/utf8_to_utf32/valid_utf8_to_utf32.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf32/utf8_to_utf32.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf32/utf8_to_utf32.h /* begin file src/generic/utf8_to_utf32/utf8_to_utf32.h */ - namespace simdutf { namespace ppc64 { namespace { namespace utf8_to_utf32 { using namespace simd; - - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -23916,251 +27215,273 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } - +} - struct validating_transcoder { +struct validating_transcoder { // If this is nonzero, there has been a UTF-8 error. simd8 error; - validating_transcoder() : error(uint8_t(0)) {} + validating_transcoder() + : error(uint8_t(0)) + { + } // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); - } - - - - simdutf_really_inline size_t convert(const char* in, size_t size, char32_t* utf32_output) { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf32(in + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { return 0; } - if(pos < size) { - size_t howmany = scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output); - if(howmany == 0) { return 0; } - utf32_output += howmany; - } - return utf32_output - start; - } - - simdutf_really_inline result convert_with_errors(const char* in, size_t size, char32_t* utf32_output) { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - if (errors()) { + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); + } + + simdutf_really_inline size_t convert(const char* in, size_t size, char32_t* utf32_output) + { + size_t pos = 0; + char32_t* start { utf32_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 4 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 4; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the fourth last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf32(in + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { + return 0; + } + if (pos < size) { + size_t howmany = scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output); + if (howmany == 0) { + return 0; + } + utf32_output += howmany; + } + return utf32_output - start; + } + + simdutf_really_inline result convert_with_errors(const char* in, size_t size, char32_t* utf32_output) + { + size_t pos = 0; + char32_t* start { utf32_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 4 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 4; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the fourth last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + if (errors()) { + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); + res.count += pos; + return res; + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf32(in + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); res.count += pos; return res; - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf32(in + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); - res.count += pos; - return res; - } - if(pos < size) { - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); - if (res.error) { // In case of error, we want the error position - res.count += pos; - return res; - } else { // In case of success, we want the number of word written - utf32_output += res.count; } - } - return result(error_code::SUCCESS, utf32_output - start); + if (pos < size) { + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); + if (res.error) { // In case of error, we want the error position + res.count += pos; + return res; + } else { // In case of success, we want the number of word written + utf32_output += res.count; + } + } + return result(error_code::SUCCESS, utf32_output - start); } - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // utf8_to_utf32 namespace } // unnamed namespace } // namespace ppc64 } // namespace simdutf /* end file src/generic/utf8_to_utf32/utf8_to_utf32.h */ // other functions -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8.h /* begin file src/generic/utf8.h */ namespace simdutf { @@ -24170,36 +27491,37 @@ namespace utf8 { using namespace simd; -simdutf_really_inline size_t count_code_points(const char* in, size_t size) { +simdutf_really_inline size_t count_code_points(const char* in, size_t size) +{ size_t pos = 0; size_t count = 0; - for(;pos + 64 <= size; pos += 64) { - simd8x64 input(reinterpret_cast(in + pos)); - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - count += 64 - count_ones(utf8_continuation_mask); + for (; pos + 64 <= size; pos += 64) { + simd8x64 input(reinterpret_cast(in + pos)); + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + count += 64 - count_ones(utf8_continuation_mask); } return count + scalar::utf8::count_code_points(in + pos, size - pos); } - -simdutf_really_inline size_t utf16_length_from_utf8(const char* in, size_t size) { +simdutf_really_inline size_t utf16_length_from_utf8(const char* in, size_t size) +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 64 <= size; pos += 64) { - simd8x64 input(reinterpret_cast(in + pos)); - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - // We count one word for anything that is not a continuation (so - // leading bytes). - count += 64 - count_ones(utf8_continuation_mask); - int64_t utf8_4byte = input.gteq_unsigned(240); - count += count_ones(utf8_4byte); + for (; pos + 64 <= size; pos += 64) { + simd8x64 input(reinterpret_cast(in + pos)); + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + // We count one word for anything that is not a continuation (so + // leading bytes). + count += 64 - count_ones(utf8_continuation_mask); + int64_t utf8_4byte = input.gteq_unsigned(240); + count += count_ones(utf8_4byte); } return count + scalar::utf8::utf16_length_from_utf8(in + pos, size - pos); } - -simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) { +simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) +{ return count_code_points(in, size); } } // utf8 namespace @@ -24207,64 +27529,72 @@ simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) } // namespace ppc64 } // namespace simdutf /* end file src/generic/utf8.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf16.h /* begin file src/generic/utf16.h */ namespace simdutf { namespace ppc64 { namespace { namespace utf16 { -template -simdutf_really_inline size_t count_code_points(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t count_code_points(const char16_t* in, size_t size) +{ size_t pos = 0; size_t count = 0; - for(;pos + 32 <= size; pos += 32) { - simd16x32 input(reinterpret_cast(in + pos)); - if (!match_system(big_endian)) input.swap_bytes(); - uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF); - count += count_ones(not_pair) / 2; + for (; pos + 32 <= size; pos += 32) { + simd16x32 input(reinterpret_cast(in + pos)); + if (!match_system(big_endian)) { + input.swap_bytes(); + } + uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF); + count += count_ones(not_pair) / 2; } return count + scalar::utf16::count_code_points(in + pos, size - pos); } -template -simdutf_really_inline size_t utf8_length_from_utf16(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t utf8_length_from_utf16(const char16_t* in, size_t size) +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 32 <= size; pos += 32) { - simd16x32 input(reinterpret_cast(in + pos)); - if (!match_system(big_endian)) input.swap_bytes(); - uint64_t ascii_mask = input.lteq(0x7F); - uint64_t twobyte_mask = input.lteq(0x7FF); - uint64_t not_pair_mask = input.not_in_range(0xD800, 0xDFFF); - - size_t ascii_count = count_ones(ascii_mask) / 2; - size_t twobyte_count = count_ones(twobyte_mask & ~ ascii_mask) / 2; - size_t threebyte_count = count_ones(not_pair_mask & ~ twobyte_mask) / 2; - size_t fourbyte_count = 32 - count_ones(not_pair_mask) / 2; - count += 2 * fourbyte_count + 3 * threebyte_count + 2 * twobyte_count + ascii_count; + for (; pos + 32 <= size; pos += 32) { + simd16x32 input(reinterpret_cast(in + pos)); + if (!match_system(big_endian)) { + input.swap_bytes(); + } + uint64_t ascii_mask = input.lteq(0x7F); + uint64_t twobyte_mask = input.lteq(0x7FF); + uint64_t not_pair_mask = input.not_in_range(0xD800, 0xDFFF); + + size_t ascii_count = count_ones(ascii_mask) / 2; + size_t twobyte_count = count_ones(twobyte_mask & ~ascii_mask) / 2; + size_t threebyte_count = count_ones(not_pair_mask & ~twobyte_mask) / 2; + size_t fourbyte_count = 32 - count_ones(not_pair_mask) / 2; + count += 2 * fourbyte_count + 3 * threebyte_count + 2 * twobyte_count + ascii_count; } return count + scalar::utf16::utf8_length_from_utf16(in + pos, size - pos); } -template -simdutf_really_inline size_t utf32_length_from_utf16(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t utf32_length_from_utf16(const char16_t* in, size_t size) +{ return count_code_points(in, size); } -simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* output) { - size_t pos = 0; +simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* output) +{ + size_t pos = 0; - while (pos + 32 <= size) { - simd16x32 input(reinterpret_cast(in + pos)); - input.swap_bytes(); - input.store(reinterpret_cast(output)); - pos += 32; - output += 32; - } + while (pos + 32 <= size) { + simd16x32 input(reinterpret_cast(in + pos)); + input.swap_bytes(); + input.store(reinterpret_cast(output)); + pos += 32; + output += 32; + } - scalar::utf16::change_endianness_utf16(in + pos, size - pos, output); + scalar::utf16::change_endianness_utf16(in + pos, size - pos, output); } } // utf16 @@ -24279,242 +27609,303 @@ simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t si namespace simdutf { namespace ppc64 { -simdutf_warn_unused int implementation::detect_encodings(const char * input, size_t length) const noexcept { - // If there is a BOM, then we trust it. - auto bom_encoding = simdutf::BOM::check_bom(input, length); - if(bom_encoding != encoding_type::unspecified) { return bom_encoding; } - int out = 0; - if(validate_utf8(input, length)) { out |= encoding_type::UTF8; } - if((length % 2) == 0) { - if(validate_utf16(reinterpret_cast(input), length/2)) { out |= encoding_type::UTF16_LE; } - } - if((length % 4) == 0) { - if(validate_utf32(reinterpret_cast(input), length/4)) { out |= encoding_type::UTF32_LE; } - } +simdutf_warn_unused int implementation::detect_encodings(const char* input, size_t length) const noexcept +{ + // If there is a BOM, then we trust it. + auto bom_encoding = simdutf::BOM::check_bom(input, length); + if (bom_encoding != encoding_type::unspecified) { + return bom_encoding; + } + int out = 0; + if (validate_utf8(input, length)) { + out |= encoding_type::UTF8; + } + if ((length % 2) == 0) { + if (validate_utf16(reinterpret_cast(input), length / 2)) { + out |= encoding_type::UTF16_LE; + } + } + if ((length % 4) == 0) { + if (validate_utf32(reinterpret_cast(input), length / 4)) { + out |= encoding_type::UTF32_LE; + } + } - return out; + return out; } -simdutf_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { - return ppc64::utf8_validation::generic_validate_utf8(buf,len); +simdutf_warn_unused bool implementation::validate_utf8(const char* buf, size_t len) const noexcept +{ + return ppc64::utf8_validation::generic_validate_utf8(buf, len); } -simdutf_warn_unused result implementation::validate_utf8_with_errors(const char *buf, size_t len) const noexcept { - return ppc64::utf8_validation::generic_validate_utf8_with_errors(buf,len); +simdutf_warn_unused result implementation::validate_utf8_with_errors(const char* buf, size_t len) const noexcept +{ + return ppc64::utf8_validation::generic_validate_utf8_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_ascii(const char *buf, size_t len) const noexcept { - return ppc64::utf8_validation::generic_validate_ascii(buf,len); +simdutf_warn_unused bool implementation::validate_ascii(const char* buf, size_t len) const noexcept +{ + return ppc64::utf8_validation::generic_validate_ascii(buf, len); } -simdutf_warn_unused result implementation::validate_ascii_with_errors(const char *buf, size_t len) const noexcept { - return ppc64::utf8_validation::generic_validate_ascii_with_errors(buf,len); +simdutf_warn_unused result implementation::validate_ascii_with_errors(const char* buf, size_t len) const noexcept +{ + return ppc64::utf8_validation::generic_validate_ascii_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_utf16le(const char16_t *buf, size_t len) const noexcept { - return scalar::utf16::validate(buf, len); +simdutf_warn_unused bool implementation::validate_utf16le(const char16_t* buf, size_t len) const noexcept +{ + return scalar::utf16::validate(buf, len); } -simdutf_warn_unused bool implementation::validate_utf16be(const char16_t *buf, size_t len) const noexcept { - return scalar::utf16::validate(buf, len); +simdutf_warn_unused bool implementation::validate_utf16be(const char16_t* buf, size_t len) const noexcept +{ + return scalar::utf16::validate(buf, len); } -simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept { - return scalar::utf16::validate_with_errors(buf, len); +simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept +{ + return scalar::utf16::validate_with_errors(buf, len); } -simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept { - return scalar::utf16::validate_with_errors(buf, len); +simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept +{ + return scalar::utf16::validate_with_errors(buf, len); } -simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept { - return scalar::utf32::validate_with_errors(buf, len); +simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept +{ + return scalar::utf32::validate_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_utf32(const char16_t *buf, size_t len) const noexcept { - return scalar::utf32::validate(buf, len); +simdutf_warn_unused bool implementation::validate_utf32(const char16_t* buf, size_t len) const noexcept +{ + return scalar::utf32::validate(buf, len); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept { - return 0; // stub +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept +{ + return 0; // stub } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept { - return 0; // stub +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept +{ + return 0; // stub } -simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept { - return result(error_code::OTHER, 0); // stub +simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept +{ + return result(error_code::OTHER, 0); // stub } -simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept { - return result(error_code::OTHER, 0); // stub +simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept +{ + return result(error_code::OTHER, 0); // stub } -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept { - return 0; // stub +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept +{ + return 0; // stub } -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept { - return 0; // stub +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* /*buf*/, size_t /*len*/, char16_t* /*utf16_output*/) const noexcept +{ + return 0; // stub } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* /*buf*/, size_t /*len*/, char32_t* /*utf16_output*/) const noexcept { - return 0; // stub +simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* /*buf*/, size_t /*len*/, char32_t* /*utf16_output*/) const noexcept +{ + return 0; // stub } -simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* /*buf*/, size_t /*len*/, char32_t* /*utf16_output*/) const noexcept { - return result(error_code::OTHER, 0); // stub +simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* /*buf*/, size_t /*len*/, char32_t* /*utf16_output*/) const noexcept +{ + return result(error_code::OTHER, 0); // stub } -simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* /*buf*/, size_t /*len*/, char32_t* /*utf16_output*/) const noexcept { - return 0; // stub +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* /*buf*/, size_t /*len*/, char32_t* /*utf16_output*/) const noexcept +{ + return 0; // stub } -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert_with_errors(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert_with_errors(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert_with_errors(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert_with_errors(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert_valid(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert_valid(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf16_to_utf8::convert_valid(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf16_to_utf8::convert_valid(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf32_to_utf8::convert(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf32_to_utf8::convert(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf32_to_utf8::convert_with_errors(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf32_to_utf8::convert_with_errors(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return scalar::utf32_to_utf8::convert_valid(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::utf32_to_utf8::convert_valid(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert_with_errors(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert_with_errors(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert_valid(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert_valid(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return scalar::utf32_to_utf16::convert_valid(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::utf32_to_utf16::convert_valid(buf, len, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert(buf, len, utf32_output); } -simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert_with_errors(buf, len, utf32_output); +simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert_with_errors(buf, len, utf32_output); } -simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert_with_errors(buf, len, utf32_output); +simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert_with_errors(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert_valid(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert_valid(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return scalar::utf16_to_utf32::convert_valid(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return scalar::utf16_to_utf32::convert_valid(buf, len, utf32_output); } -void implementation::change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) const noexcept { - scalar::utf16::change_endianness_utf16(input, length, output); +void implementation::change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) const noexcept +{ + scalar::utf16::change_endianness_utf16(input, length, output); } -simdutf_warn_unused size_t implementation::count_utf16le(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::count_utf16le(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::count_utf16be(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::count_utf16be(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::count_utf8(const char * input, size_t length) const noexcept { - return utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::count_utf8(const char* input, size_t length) const noexcept +{ + return utf8::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::utf32_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return scalar::utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return scalar::utf16::utf32_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char * input, size_t length) const noexcept { - return scalar::utf8::utf16_length_from_utf8(input, length); +simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char* input, size_t length) const noexcept +{ + return scalar::utf8::utf16_length_from_utf8(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept { - return scalar::utf32::utf8_length_from_utf32(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + return scalar::utf32::utf8_length_from_utf32(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept { - return scalar::utf32::utf16_length_from_utf32(input, length); +simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + return scalar::utf32::utf16_length_from_utf32(input, length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char * input, size_t length) const noexcept { - return scalar::utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char* input, size_t length) const noexcept +{ + return scalar::utf8::count_code_points(input, length); } } // namespace ppc64 } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/ppc64/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/ppc64/end.h /* begin file src/simdutf/ppc64/end.h */ /* end file src/simdutf/ppc64/end.h */ /* end file src/ppc64/implementation.cpp */ #endif #if SIMDUTF_IMPLEMENTATION_WESTMERE -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/implementation.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/implementation.cpp /* begin file src/westmere/implementation.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/begin.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/begin.h /* begin file src/simdutf/westmere/begin.h */ // redefining SIMDUTF_IMPLEMENTATION to "westmere" // #define SIMDUTF_IMPLEMENTATION westmere @@ -24533,30 +27924,34 @@ namespace { #endif using namespace simd; -simdutf_really_inline bool is_ascii(const simd8x64& input) { - return input.reduce_or().is_ascii(); +simdutf_really_inline bool is_ascii(const simd8x64& input) +{ + return input.reduce_or().is_ascii(); } -simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) { - simd8 is_second_byte = prev1.saturating_sub(0b11000000u-1); // Only 11______ will be > 0 - simd8 is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); +simdutf_unused simdutf_really_inline simd8 must_be_continuation(const simd8 prev1, const simd8 prev2, const simd8 prev3) +{ + simd8 is_second_byte = prev1.saturating_sub(0b11000000u - 1); // Only 11______ will be > 0 + simd8 is_third_byte = prev2.saturating_sub(0b11100000u - 1); // Only 111_____ will be > 0 + simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u - 1); // Only 1111____ will be > 0 + // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. + return simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); } -simdutf_really_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2.saturating_sub(0b11100000u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_third_byte | is_fourth_byte) > int8_t(0); +simdutf_really_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) +{ + simd8 is_third_byte = prev2.saturating_sub(0b11100000u - 1); // Only 111_____ will be > 0 + simd8 is_fourth_byte = prev3.saturating_sub(0b11110000u - 1); // Only 1111____ will be > 0 + // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. + return simd8(is_third_byte | is_fourth_byte) > int8_t(0); } -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_detect_encodings.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_detect_encodings.cpp /* begin file src/westmere/sse_detect_encodings.cpp */ template // len is known to be a multiple of 2 when this is called -int sse_detect_encodings(const char * buf, size_t len) { +int sse_detect_encodings(const char* buf, size_t len) +{ const char* start = buf; const char* end = buf + len; @@ -24571,13 +27966,13 @@ int sse_detect_encodings(const char * buf, size_t len) { __m128i currentmax = _mm_setzero_si128(); - checker check{}; + checker check {}; - while(buf + 64 <= end) { + while (buf + 64 <= end) { __m128i in = _mm_loadu_si128((__m128i*)buf); - __m128i secondin = _mm_loadu_si128((__m128i*)buf+1); - __m128i thirdin = _mm_loadu_si128((__m128i*)buf+2); - __m128i fourthin = _mm_loadu_si128((__m128i*)buf+3); + __m128i secondin = _mm_loadu_si128((__m128i*)buf + 1); + __m128i thirdin = _mm_loadu_si128((__m128i*)buf + 2); + __m128i fourthin = _mm_loadu_si128((__m128i*)buf + 3); const auto u0 = simd16(in); const auto u1 = simd16(secondin); @@ -24611,15 +28006,15 @@ int sse_detect_encodings(const char * buf, size_t len) { is_utf32 = false; // Code from sse_validate_utf16le.cpp // Not efficient, we do not process surrogates_bitmask1 - const char16_t * input = reinterpret_cast(buf); - const char16_t* end16 = reinterpret_cast(start) + len/2; + const char16_t* input = reinterpret_cast(buf); + const char16_t* end16 = reinterpret_cast(start) + len / 2; const auto v_fc = simd8::splat(0xfc); const auto v_dc = simd8::splat(0xdc); const uint16_t V0 = static_cast(~surrogates_bitmask0); - const auto vH0 = (in16 & v_fc) == v_dc; + const auto vH0 = (in16 & v_fc) == v_dc; const uint16_t H0 = static_cast(vH0.to_bitmask()); const uint16_t L0 = static_cast(~H0 & surrogates_bitmask0); @@ -24655,7 +28050,7 @@ int sse_detect_encodings(const char * buf, size_t len) { } else { const uint16_t V = static_cast(~surrogates_bitmask); - const auto vH = (in_16 & v_fc) == v_dc; + const auto vH = (in_16 & v_fc) == v_dc; const uint16_t H = static_cast(vH.to_bitmask()); const uint16_t L = static_cast(~H & surrogates_bitmask); @@ -24680,8 +28075,8 @@ int sse_detect_encodings(const char * buf, size_t len) { is_utf16 = false; // Check for UTF-32 if (len % 4 == 0) { - const char32_t * input = reinterpret_cast(buf); - const char32_t* end32 = reinterpret_cast(start) + len/4; + const char32_t* input = reinterpret_cast(buf); + const char32_t* end32 = reinterpret_cast(start) + len / 4; // Must start checking for surrogates __m128i currentoffsetmax = _mm_setzero_si128(); @@ -24699,14 +28094,14 @@ int sse_detect_encodings(const char * buf, size_t len) { currentoffsetmax = _mm_max_epu32(_mm_add_epi32(fourthin, offset), currentoffsetmax); while (input + 4 < end32) { - const __m128i in32 = _mm_loadu_si128((__m128i *)input); - currentmax = _mm_max_epu32(in32,currentmax); + const __m128i in32 = _mm_loadu_si128((__m128i*)input); + currentmax = _mm_max_epu32(in32, currentmax); currentoffsetmax = _mm_max_epu32(_mm_add_epi32(in32, offset), currentoffsetmax); input += 4; } __m128i forbidden_words = _mm_xor_si128(_mm_max_epu32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(_mm_testz_si128(forbidden_words, forbidden_words) == 0) { + if (_mm_testz_si128(forbidden_words, forbidden_words) == 0) { is_utf32 = false; } } else { @@ -24735,7 +28130,7 @@ int sse_detect_encodings(const char * buf, size_t len) { if (is_utf8) { if (static_cast(buf - start) != len) { - uint8_t block[64]{}; + uint8_t block[64] {}; std::memset(block, 0x20, 64); std::memcpy(block, buf, len - (buf - start)); simd::simd8x64 in(block); @@ -24746,14 +28141,14 @@ int sse_detect_encodings(const char * buf, size_t len) { } } - if (is_utf16 && scalar::utf16::validate(reinterpret_cast(buf), (len - (buf - start))/2)) { + if (is_utf16 && scalar::utf16::validate(reinterpret_cast(buf), (len - (buf - start)) / 2)) { out |= simdutf::encoding_type::UTF16_LE; } if (is_utf32 && (len % 4 == 0)) { const __m128i standardmax = _mm_set1_epi32(0x10ffff); __m128i is_zero = _mm_xor_si128(_mm_max_epu32(currentmax, standardmax), standardmax); - if (_mm_testz_si128(is_zero, is_zero) == 1 && scalar::utf32::validate(reinterpret_cast(buf), (len - (buf - start))/4)) { + if (_mm_testz_si128(is_zero, is_zero) == 1 && scalar::utf32::validate(reinterpret_cast(buf), (len - (buf - start)) / 4)) { out |= simdutf::encoding_type::UTF32_LE; } } @@ -24762,7 +28157,7 @@ int sse_detect_encodings(const char * buf, size_t len) { } /* end file src/westmere/sse_detect_encodings.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_validate_utf16.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_validate_utf16.cpp /* begin file src/westmere/sse_validate_utf16.cpp */ /* In UTF-16 words in range 0xD800 to 0xDFFF have special meaning. @@ -24809,8 +28204,9 @@ int sse_detect_encodings(const char * buf, size_t len) { - pointer to the last unprocessed character (a scalar fallback should check the rest); - nullptr if an error was detected. */ -template -const char16_t* sse_validate_utf16(const char16_t* input, size_t size) { +template +const char16_t* sse_validate_utf16(const char16_t* input, size_t size) +{ const char16_t* end = input + size; const auto v_d8 = simd8::splat(0xd8); @@ -24851,19 +28247,19 @@ const char16_t* sse_validate_utf16(const char16_t* input, size_t size) { const uint16_t V = static_cast(~surrogates_bitmask); // H - word-mask for high surrogates: the six highest bits are 0b1101'11 - const auto vH = (in & v_fc) == v_dc; + const auto vH = (in & v_fc) == v_dc; const uint16_t H = static_cast(vH.to_bitmask()); // L - word mask for low surrogates // L = not H and surrogates_wordmask const uint16_t L = static_cast(~H & surrogates_bitmask); - const uint16_t a = static_cast(L & (H >> 1)); // A low surrogate must be followed by high one. - // (A low surrogate placed in the 7th register's word - // is an exception we handle.) - const uint16_t b = static_cast(a << 1); // Just mark that the opinput - startite fact is hold, - // thanks to that we have only two masks for valid case. - const uint16_t c = static_cast(V | a | b); // Combine all the masks into the final one. + const uint16_t a = static_cast(L & (H >> 1)); // A low surrogate must be followed by high one. + // (A low surrogate placed in the 7th register's word + // is an exception we handle.) + const uint16_t b = static_cast(a << 1); // Just mark that the opinput - startite fact is hold, + // thanks to that we have only two masks for valid case. + const uint16_t c = static_cast(V | a | b); // Combine all the masks into the final one. if (c == 0xffff) { // The whole input register contains valid UTF-16, i.e., @@ -24884,9 +28280,9 @@ const char16_t* sse_validate_utf16(const char16_t* input, size_t size) { return input; } - -template -const result sse_validate_utf16_with_errors(const char16_t* input, size_t size) { +template +const result sse_validate_utf16_with_errors(const char16_t* input, size_t size) +{ const char16_t* start = input; const char16_t* end = input + size; @@ -24929,19 +28325,19 @@ const result sse_validate_utf16_with_errors(const char16_t* input, size_t size) const uint16_t V = static_cast(~surrogates_bitmask); // H - word-mask for high surrogates: the six highest bits are 0b1101'11 - const auto vH = (in & v_fc) == v_dc; + const auto vH = (in & v_fc) == v_dc; const uint16_t H = static_cast(vH.to_bitmask()); // L - word mask for low surrogates // L = not H and surrogates_wordmask const uint16_t L = static_cast(~H & surrogates_bitmask); - const uint16_t a = static_cast(L & (H >> 1)); // A low surrogate must be followed by high one. - // (A low surrogate placed in the 7th register's word - // is an exception we handle.) - const uint16_t b = static_cast(a << 1); // Just mark that the opinput - startite fact is hold, - // thanks to that we have only two masks for valid case. - const uint16_t c = static_cast(V | a | b); // Combine all the masks into the final one. + const uint16_t a = static_cast(L & (H >> 1)); // A low surrogate must be followed by high one. + // (A low surrogate placed in the 7th register's word + // is an exception we handle.) + const uint16_t b = static_cast(a << 1); // Just mark that the opinput - startite fact is hold, + // thanks to that we have only two masks for valid case. + const uint16_t c = static_cast(V | a | b); // Combine all the masks into the final one. if (c == 0xffff) { // The whole input register contains valid UTF-16, i.e., @@ -24962,13 +28358,14 @@ const result sse_validate_utf16_with_errors(const char16_t* input, size_t size) return result(error_code::SUCCESS, input - start); } /* end file src/westmere/sse_validate_utf16.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_validate_utf32le.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_validate_utf32le.cpp /* begin file src/westmere/sse_validate_utf32le.cpp */ /* Returns: - pointer to the last unprocessed character (a scalar fallback should check the rest); - nullptr if an error was detected. */ -const char32_t* sse_validate_utf32le(const char32_t* input, size_t size) { +const char32_t* sse_validate_utf32le(const char32_t* input, size_t size) +{ const char32_t* end = input + size; const __m128i standardmax = _mm_set1_epi32(0x10ffff); @@ -24978,26 +28375,26 @@ const char32_t* sse_validate_utf32le(const char32_t* input, size_t size) { __m128i currentoffsetmax = _mm_setzero_si128(); while (input + 4 < end) { - const __m128i in = _mm_loadu_si128((__m128i *)input); - currentmax = _mm_max_epu32(in,currentmax); + const __m128i in = _mm_loadu_si128((__m128i*)input); + currentmax = _mm_max_epu32(in, currentmax); currentoffsetmax = _mm_max_epu32(_mm_add_epi32(in, offset), currentoffsetmax); input += 4; } __m128i is_zero = _mm_xor_si128(_mm_max_epu32(currentmax, standardmax), standardmax); - if(_mm_test_all_zeros(is_zero, is_zero) == 0) { + if (_mm_test_all_zeros(is_zero, is_zero) == 0) { return nullptr; } is_zero = _mm_xor_si128(_mm_max_epu32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(_mm_test_all_zeros(is_zero, is_zero) == 0) { + if (_mm_test_all_zeros(is_zero, is_zero) == 0) { return nullptr; } return input; } - -const result sse_validate_utf32le_with_errors(const char32_t* input, size_t size) { +const result sse_validate_utf32le_with_errors(const char32_t* input, size_t size) +{ const char32_t* start = input; const char32_t* end = input + size; @@ -25008,17 +28405,17 @@ const result sse_validate_utf32le_with_errors(const char32_t* input, size_t size __m128i currentoffsetmax = _mm_setzero_si128(); while (input + 4 < end) { - const __m128i in = _mm_loadu_si128((__m128i *)input); - currentmax = _mm_max_epu32(in,currentmax); + const __m128i in = _mm_loadu_si128((__m128i*)input); + currentmax = _mm_max_epu32(in, currentmax); currentoffsetmax = _mm_max_epu32(_mm_add_epi32(in, offset), currentoffsetmax); __m128i is_zero = _mm_xor_si128(_mm_max_epu32(currentmax, standardmax), standardmax); - if(_mm_test_all_zeros(is_zero, is_zero) == 0) { + if (_mm_test_all_zeros(is_zero, is_zero) == 0) { return result(error_code::TOO_LARGE, input - start); } is_zero = _mm_xor_si128(_mm_max_epu32(currentoffsetmax, standardoffsetmax), standardoffsetmax); - if(_mm_test_all_zeros(is_zero, is_zero) == 0) { + if (_mm_test_all_zeros(is_zero, is_zero) == 0) { return result(error_code::SURROGATE, input - start); } input += 4; @@ -25028,309 +28425,291 @@ const result sse_validate_utf32le_with_errors(const char32_t* input, size_t size } /* end file src/westmere/sse_validate_utf32le.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_convert_utf8_to_utf16.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_convert_utf8_to_utf16.cpp /* begin file src/westmere/sse_convert_utf8_to_utf16.cpp */ // depends on "tables/utf8_to_utf16_tables.h" - // Convert up to 12 bytes from utf8 to utf16 using a mask indicating the // end of the code points. Only the least significant 12 bits of the mask // are accessed. // It returns how many bytes were consumed (up to 12). -template -size_t convert_masked_utf8_to_utf16(const char *input, - uint64_t utf8_end_of_code_point_mask, - char16_t *&utf16_output) { - // we use an approach where we try to process up to 12 input bytes. - // Why 12 input bytes and not 16? Because we are concerned with the size of - // the lookup tables. Also 12 is nicely divisible by two and three. - // - // - // Optimization note: our main path below is load-latency dependent. Thus it is maybe - // beneficial to have fast paths that depend on branch prediction but have less latency. - // This results in more instructions but, potentially, also higher speeds. - // - // We first try a few fast paths. - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - const __m128i in = _mm_loadu_si128((__m128i *)input); - const uint16_t input_utf8_end_of_code_point_mask = - utf8_end_of_code_point_mask & 0xfff; - if(((utf8_end_of_code_point_mask & 0xffff) == 0xffff)) { - // We process the data in chunks of 16 bytes. - __m128i ascii_first = _mm_cvtepu8_epi16(in); - __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in,8)); - if (big_endian) { - ascii_first = _mm_shuffle_epi8(ascii_first, swap); - ascii_second = _mm_shuffle_epi8(ascii_second, swap); - } - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8), ascii_second); - utf16_output += 16; // We wrote 16 16-bit characters. - return 16; // We consumed 16 bytes. - } - if(((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) { - // We want to take 8 2-byte UTF-8 words and turn them into 8 2-byte UTF-16 words. - // There is probably a more efficient sequence, but the following might do. - const __m128i sh = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); - __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); - if (big_endian) composed = _mm_shuffle_epi8(composed, swap); - _mm_storeu_si128((__m128i *)utf16_output, composed); - utf16_output += 8; // We wrote 16 bytes, 8 code points. - return 16; - } - if(input_utf8_end_of_code_point_mask == 0x924) { - // We want to take 4 3-byte UTF-8 words and turn them into 4 2-byte UTF-16 words. - // There is probably a more efficient sequence, but the following might do. - const __m128i sh = _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = - _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits - const __m128i middlebyte = - _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - const __m128i highbyte = - _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); - __m128i composed_repacked = _mm_packus_epi32(composed, composed); - if (big_endian) composed_repacked = _mm_shuffle_epi8(composed_repacked, swap); - _mm_storeu_si128((__m128i *)utf16_output, composed_repacked); - utf16_output += 4; - return 12; - } - /// We do not have a fast path available, so we fallback. - - const uint8_t idx = - tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; - const uint8_t consumed = - tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; - if (idx < 64) { - // SIX (6) input code-words - // this is a relatively easy scenario - // we process SIX (6) input code-words. The max length in bytes of six code - // words spanning between 1 and 2 bytes each is 12 bytes. On processors - // where pdep/pext is fast, we might be able to use a small lookup table. - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); - __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); - if (big_endian) composed = _mm_shuffle_epi8(composed, swap); - _mm_storeu_si128((__m128i *)utf16_output, composed); - utf16_output += 6; // We wrote 12 bytes, 6 code points. - } else if (idx < 145) { - // FOUR (4) input code-words - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = - _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits - const __m128i middlebyte = - _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - const __m128i highbyte = - _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); - __m128i composed_repacked = _mm_packus_epi32(composed, composed); - if (big_endian) composed_repacked = _mm_shuffle_epi8(composed_repacked, swap); - _mm_storeu_si128((__m128i *)utf16_output, composed_repacked); - utf16_output += 4; - } else if (idx < 209) { - // TWO (2) input code-words - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); - const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000)); - // correct for spurious high bit - const __m128i correct = - _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1); - middlehighbyte = _mm_xor_si128(correct, middlehighbyte); - const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000)); - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), - _mm_or_si128(highbyte_shifted, middlehighbyte_shifted)); - const __m128i composedminus = - _mm_sub_epi32(composed, _mm_set1_epi32(0x10000)); - const __m128i lowtenbits = - _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff)); - const __m128i hightenbits = _mm_srli_epi32(composedminus, 10); - const __m128i lowtenbitsadd = - _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00)); - const __m128i hightenbitsadd = - _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800)); - const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16); - __m128i surrogates = - _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted); - uint32_t basic_buffer[4]; - uint32_t basic_buffer_swap[4]; - if (big_endian) { - _mm_storeu_si128((__m128i *)basic_buffer_swap, _mm_shuffle_epi8(composed, swap)); - surrogates = _mm_shuffle_epi8(surrogates, swap); - } - _mm_storeu_si128((__m128i *)basic_buffer, composed); - uint32_t surrogate_buffer[4]; - _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates); - for (size_t i = 0; i < 3; i++) { - if (basic_buffer[i] < 65536) { - utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i]) : uint16_t(basic_buffer[i]); - utf16_output++; - } else { - utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff); - utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16); - utf16_output += 2; - } - } - } else { - // here we know that there is an error but we do not handle errors - } - return consumed; +template +size_t convert_masked_utf8_to_utf16(const char* input, + uint64_t utf8_end_of_code_point_mask, + char16_t*& utf16_output) +{ + // we use an approach where we try to process up to 12 input bytes. + // Why 12 input bytes and not 16? Because we are concerned with the size of + // the lookup tables. Also 12 is nicely divisible by two and three. + // + // + // Optimization note: our main path below is load-latency dependent. Thus it is maybe + // beneficial to have fast paths that depend on branch prediction but have less latency. + // This results in more instructions but, potentially, also higher speeds. + // + // We first try a few fast paths. + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + const __m128i in = _mm_loadu_si128((__m128i*)input); + const uint16_t input_utf8_end_of_code_point_mask = utf8_end_of_code_point_mask & 0xfff; + if (((utf8_end_of_code_point_mask & 0xffff) == 0xffff)) { + // We process the data in chunks of 16 bytes. + __m128i ascii_first = _mm_cvtepu8_epi16(in); + __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8)); + if (big_endian) { + ascii_first = _mm_shuffle_epi8(ascii_first, swap); + ascii_second = _mm_shuffle_epi8(ascii_second, swap); + } + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf16_output), ascii_first); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf16_output + 8), ascii_second); + utf16_output += 16; // We wrote 16 16-bit characters. + return 16; // We consumed 16 bytes. + } + if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) { + // We want to take 8 2-byte UTF-8 words and turn them into 8 2-byte UTF-16 words. + // There is probably a more efficient sequence, but the following might do. + const __m128i sh = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); + __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); + if (big_endian) + composed = _mm_shuffle_epi8(composed, swap); + _mm_storeu_si128((__m128i*)utf16_output, composed); + utf16_output += 8; // We wrote 16 bytes, 8 code points. + return 16; + } + if (input_utf8_end_of_code_point_mask == 0x924) { + // We want to take 4 3-byte UTF-8 words and turn them into 4 2-byte UTF-16 words. + // There is probably a more efficient sequence, but the following might do. + const __m128i sh = _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); + __m128i composed_repacked = _mm_packus_epi32(composed, composed); + if (big_endian) + composed_repacked = _mm_shuffle_epi8(composed_repacked, swap); + _mm_storeu_si128((__m128i*)utf16_output, composed_repacked); + utf16_output += 4; + return 12; + } + /// We do not have a fast path available, so we fallback. + + const uint8_t idx = tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; + const uint8_t consumed = tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; + if (idx < 64) { + // SIX (6) input code-words + // this is a relatively easy scenario + // we process SIX (6) input code-words. The max length in bytes of six code + // words spanning between 1 and 2 bytes each is 12 bytes. On processors + // where pdep/pext is fast, we might be able to use a small lookup table. + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); + __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); + if (big_endian) + composed = _mm_shuffle_epi8(composed, swap); + _mm_storeu_si128((__m128i*)utf16_output, composed); + utf16_output += 6; // We wrote 12 bytes, 6 code points. + } else if (idx < 145) { + // FOUR (4) input code-words + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); + __m128i composed_repacked = _mm_packus_epi32(composed, composed); + if (big_endian) + composed_repacked = _mm_shuffle_epi8(composed_repacked, swap); + _mm_storeu_si128((__m128i*)utf16_output, composed_repacked); + utf16_output += 4; + } else if (idx < 209) { + // TWO (2) input code-words + ////////////// + // There might be garbage inputs where a leading byte mascarades as a four-byte + // leading byte (by being followed by 3 continuation byte), but is not greater than + // 0xf0. This could trigger a buffer overflow if we only counted leading + // bytes of the form 0xf0 as generating surrogate pairs, without further UTF-8 validation. + // Thus we must be careful to ensure that only leading bytes at least as large as 0xf0 generate surrogate pairs. + // We do as at the cost of an extra mask. + ///////////// + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000)); + // correct for spurious high bit + const __m128i correct = _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1); + middlehighbyte = _mm_xor_si128(correct, middlehighbyte); + const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4); + // We deliberately carry the leading four bits in highbyte if they are present, + // we remove them later when computing hightenbits. + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000)); + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6); + // When we need to generate a surrogate pair (leading byte > 0xF0), then + // the corresponding 32-bit value in 'composed' will be greater than + // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the + // location of the surrogate pairs. + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), + _mm_or_si128(highbyte_shifted, middlehighbyte_shifted)); + const __m128i composedminus = _mm_sub_epi32(composed, _mm_set1_epi32(0x10000)); + const __m128i lowtenbits = _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff)); + // Notice the 0x3ff mask: + const __m128i hightenbits = _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff)); + const __m128i lowtenbitsadd = _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00)); + const __m128i hightenbitsadd = _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800)); + const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16); + __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted); + uint32_t basic_buffer[4]; + uint32_t basic_buffer_swap[4]; + if (big_endian) { + _mm_storeu_si128((__m128i*)basic_buffer_swap, _mm_shuffle_epi8(composed, swap)); + surrogates = _mm_shuffle_epi8(surrogates, swap); + } + _mm_storeu_si128((__m128i*)basic_buffer, composed); + uint32_t surrogate_buffer[4]; + _mm_storeu_si128((__m128i*)surrogate_buffer, surrogates); + for (size_t i = 0; i < 3; i++) { + if (basic_buffer[i] > 0x3c00000) { + utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff); + utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16); + utf16_output += 2; + } else { + utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i]) : uint16_t(basic_buffer[i]); + utf16_output++; + } + } + } else { + // here we know that there is an error but we do not handle errors + } + return consumed; } /* end file src/westmere/sse_convert_utf8_to_utf16.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_convert_utf8_to_utf32.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_convert_utf8_to_utf32.cpp /* begin file src/westmere/sse_convert_utf8_to_utf32.cpp */ // depends on "tables/utf8_to_utf16_tables.h" - // Convert up to 12 bytes from utf8 to utf32 using a mask indicating the // end of the code points. Only the least significant 12 bits of the mask // are accessed. // It returns how many bytes were consumed (up to 12). -size_t convert_masked_utf8_to_utf32(const char *input, - uint64_t utf8_end_of_code_point_mask, - char32_t *&utf32_output) { - // we use an approach where we try to process up to 12 input bytes. - // Why 12 input bytes and not 16? Because we are concerned with the size of - // the lookup tables. Also 12 is nicely divisible by two and three. - // - // - // Optimization note: our main path below is load-latency dependent. Thus it is maybe - // beneficial to have fast paths that depend on branch prediction but have less latency. - // This results in more instructions but, potentially, also higher speeds. - // - // We first try a few fast paths. - const __m128i in = _mm_loadu_si128((__m128i *)input); - const uint16_t input_utf8_end_of_code_point_mask = - utf8_end_of_code_point_mask & 0xfff; - if(((utf8_end_of_code_point_mask & 0xffff) == 0xffff)) { - // We process the data in chunks of 16 bytes. - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output), _mm_cvtepu8_epi32(in)); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output+4), _mm_cvtepu8_epi32(_mm_srli_si128(in,4))); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output+8), _mm_cvtepu8_epi32(_mm_srli_si128(in,8))); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output+12), _mm_cvtepu8_epi32(_mm_srli_si128(in,12))); - utf32_output += 16; // We wrote 16 32-bit characters. - return 16; // We consumed 16 bytes. - } - if(((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) { - // We want to take 8 2-byte UTF-8 words and turn them into 8 4-byte UTF-32 words. - // There is probably a more efficient sequence, but the following might do. - const __m128i sh = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); - const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output), _mm_cvtepu16_epi32(composed)); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output+4), _mm_cvtepu16_epi32(_mm_srli_si128(composed,8))); - utf32_output += 8; // We wrote 32 bytes, 8 code points. - return 16; - } - if(input_utf8_end_of_code_point_mask == 0x924) { - // We want to take 4 3-byte UTF-8 words and turn them into 4 4-byte UTF-32 words. - // There is probably a more efficient sequence, but the following might do. - const __m128i sh = _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = - _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits - const __m128i middlebyte = - _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - const __m128i highbyte = - _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); - _mm_storeu_si128((__m128i *)utf32_output, composed); - utf32_output += 4; - return 12; - } - /// We do not have a fast path available, so we fallback. - - const uint8_t idx = - tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; - const uint8_t consumed = - tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; - if (idx < 64) { - // SIX (6) input code-words - // this is a relatively easy scenario - // we process SIX (6) input code-words. The max length in bytes of six code - // words spanning between 1 and 2 bytes each is 12 bytes. On processors - // where pdep/pext is fast, we might be able to use a small lookup table. - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); - const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output), _mm_cvtepu16_epi32(composed)); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output+4), _mm_cvtepu16_epi32(_mm_srli_si128(composed,8))); - utf32_output += 6; // We wrote 12 bytes, 6 code points. - } else if (idx < 145) { - // FOUR (4) input code-words - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = - _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits - const __m128i middlebyte = - _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - const __m128i highbyte = - _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); - _mm_storeu_si128((__m128i *)utf32_output, composed); - utf32_output += 4; - } else if (idx < 209) { - // TWO (2) input code-words - const __m128i sh = - _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]); - const __m128i perm = _mm_shuffle_epi8(in, sh); - const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); - const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); - const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); - __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000)); - // correct for spurious high bit - const __m128i correct = - _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1); - middlehighbyte = _mm_xor_si128(correct, middlehighbyte); - const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4); - const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000)); - const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6); - const __m128i composed = - _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), - _mm_or_si128(highbyte_shifted, middlehighbyte_shifted)); - _mm_storeu_si128((__m128i *)utf32_output, composed); - utf32_output += 3; - } else { - // here we know that there is an error but we do not handle errors - } - return consumed; +size_t convert_masked_utf8_to_utf32(const char* input, + uint64_t utf8_end_of_code_point_mask, + char32_t*& utf32_output) +{ + // we use an approach where we try to process up to 12 input bytes. + // Why 12 input bytes and not 16? Because we are concerned with the size of + // the lookup tables. Also 12 is nicely divisible by two and three. + // + // + // Optimization note: our main path below is load-latency dependent. Thus it is maybe + // beneficial to have fast paths that depend on branch prediction but have less latency. + // This results in more instructions but, potentially, also higher speeds. + // + // We first try a few fast paths. + const __m128i in = _mm_loadu_si128((__m128i*)input); + const uint16_t input_utf8_end_of_code_point_mask = utf8_end_of_code_point_mask & 0xfff; + if (((utf8_end_of_code_point_mask & 0xffff) == 0xffff)) { + // We process the data in chunks of 16 bytes. + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output), _mm_cvtepu8_epi32(in)); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output + 4), _mm_cvtepu8_epi32(_mm_srli_si128(in, 4))); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output + 8), _mm_cvtepu8_epi32(_mm_srli_si128(in, 8))); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output + 12), _mm_cvtepu8_epi32(_mm_srli_si128(in, 12))); + utf32_output += 16; // We wrote 16 32-bit characters. + return 16; // We consumed 16 bytes. + } + if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) { + // We want to take 8 2-byte UTF-8 words and turn them into 8 4-byte UTF-32 words. + // There is probably a more efficient sequence, but the following might do. + const __m128i sh = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); + const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output), _mm_cvtepu16_epi32(composed)); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output + 4), _mm_cvtepu16_epi32(_mm_srli_si128(composed, 8))); + utf32_output += 8; // We wrote 32 bytes, 8 code points. + return 16; + } + if (input_utf8_end_of_code_point_mask == 0x924) { + // We want to take 4 3-byte UTF-8 words and turn them into 4 4-byte UTF-32 words. + // There is probably a more efficient sequence, but the following might do. + const __m128i sh = _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); + _mm_storeu_si128((__m128i*)utf32_output, composed); + utf32_output += 4; + return 12; + } + /// We do not have a fast path available, so we fallback. + + const uint8_t idx = tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0]; + const uint8_t consumed = tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1]; + if (idx < 64) { + // SIX (6) input code-words + // this is a relatively easy scenario + // we process SIX (6) input code-words. The max length in bytes of six code + // words spanning between 1 and 2 bytes each is 12 bytes. On processors + // where pdep/pext is fast, we might be able to use a small lookup table. + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f)); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00)); + const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2)); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output), _mm_cvtepu16_epi32(composed)); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output + 4), _mm_cvtepu16_epi32(_mm_srli_si128(composed, 8))); + utf32_output += 6; // We wrote 12 bytes, 6 code points. + } else if (idx < 145) { + // FOUR (4) input code-words + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted); + _mm_storeu_si128((__m128i*)utf32_output, composed); + utf32_output += 4; + } else if (idx < 209) { + // TWO (2) input code-words + const __m128i sh = _mm_loadu_si128((const __m128i*)tables::utf8_to_utf16::shufutf8[idx]); + const __m128i perm = _mm_shuffle_epi8(in, sh); + const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f)); + const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); + const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2); + __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000)); + // correct for spurious high bit + const __m128i correct = _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1); + middlehighbyte = _mm_xor_si128(correct, middlehighbyte); + const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4); + const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000)); + const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6); + const __m128i composed = _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), + _mm_or_si128(highbyte_shifted, middlehighbyte_shifted)); + _mm_storeu_si128((__m128i*)utf32_output, composed); + utf32_output += 3; + } else { + // here we know that there is an error but we do not handle errors + } + return consumed; } /* end file src/westmere/sse_convert_utf8_to_utf32.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_convert_utf16_to_utf8.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_convert_utf16_to_utf8.cpp /* begin file src/westmere/sse_convert_utf16_to_utf8.cpp */ /* The vectorized algorithm works on single SSE register i.e., it @@ -25385,480 +28764,485 @@ size_t convert_masked_utf8_to_utf32(const char *input, Returns a pair: the first unprocessed byte from buf and utf8_output A scalar routing should carry on the conversion of the tail. */ -template -std::pair sse_convert_utf16_to_utf8(const char16_t* buf, size_t len, char* utf8_output) { +template +std::pair sse_convert_utf16_to_utf8(const char16_t* buf, size_t len, char* utf8_output) +{ + + const char16_t* end = buf + len; + + const __m128i v_0000 = _mm_setzero_si128(); + const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800); + const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800); + const __m128i v_c080 = _mm_set1_epi16((int16_t)0xc080); + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { + __m128i in = _mm_loadu_si128((__m128i*)buf); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + in = _mm_shuffle_epi8(in, swap); + } + // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes + const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80); + if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!! + __m128i nextin = _mm_loadu_si128((__m128i*)buf + 1); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + nextin = _mm_shuffle_epi8(nextin, swap); + } + if (!_mm_testz_si128(nextin, v_ff80)) { + // 1. pack the bytes + // obviously suboptimal. + const __m128i utf8_packed = _mm_packus_epi16(in, in); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 8; + utf8_output += 8; + in = nextin; + } else { + // 1. pack the bytes + // obviously suboptimal. + const __m128i utf8_packed = _mm_packus_epi16(in, nextin); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + } + + // no bits set above 7th bit + const __m128i one_byte_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000); + const uint16_t one_byte_bitmask = static_cast(_mm_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m128i one_or_two_bytes_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000); + const uint16_t one_or_two_bytes_bitmask = static_cast(_mm_movemask_epi8(one_or_two_bytes_bytemask)); + + if (one_or_two_bytes_bitmask == 0xffff) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00); + const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m128i t0 = _mm_slli_epi16(in, 2); + // t1 = [000a|aaaa|0000|0000] + const __m128i t1 = _mm_and_si128(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m128i t2 = _mm_and_si128(in, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m128i t3 = _mm_or_si128(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m128i t4 = _mm_or_si128(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m128i utf8_unpacked = _mm_blendv_epi8(t4, in, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + // one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a - LSB) + const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a + const uint16_t m1 = static_cast(m0 >> 7); // m1 = 00000000h0g0f0e0 + const uint8_t m2 = static_cast((m0 | m1) & 0xff); // m2 = hdgcfbea + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle); + + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + + // 6. adjust pointers + buf += 8; + utf8_output += row[0]; + continue; + } + + // 1. Check if there are any surrogate word in the input chunk. + // We have also deal with situation when there is a surrogate word + // at the end of a chunk. + const __m128i surrogates_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800); + + // bitmask = 0x0000 if there are no surrogates + // = 0xc000 if the last word is a surrogate + const uint16_t surrogates_bitmask = static_cast(_mm_movemask_epi8(surrogates_bytemask)); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (surrogates_bitmask == 0x0000) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m128i t0 = _mm_shuffle_epi8(in, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m128i s0 = _mm_srli_epi16(in, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000)); + const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m128i s4 = _mm_xor_si128(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m128i out0 = _mm_unpacklo_epi16(t2, s4); + const __m128i out1 = _mm_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint16_t mask = (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa); + if (mask == 0) { + // We only have three-byte words. Use fast path. + const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14, 15, 13, -1, -1, -1, -1); + const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle); + const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += 12; + buf += 8; + continue; + } + const uint8_t mask0 = uint8_t(mask); + + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + + buf += 8; + // surrogate pair(s) in a register + } else { + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xF800) != 0xD800) { + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(nullptr, utf8_output); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while + + return std::make_pair(buf, utf8_output); +} + +/* + Returns a pair: a result struct and utf8_output. + If there is an error, the count field of the result is the position of the error. + Otherwise, it is the position of the first unprocessed byte in buf (even if finished). + A scalar routing should carry on the conversion of the tail if needed. +*/ +template +std::pair sse_convert_utf16_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) +{ + const char16_t* start = buf; + const char16_t* end = buf + len; + + const __m128i v_0000 = _mm_setzero_si128(); + const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800); + const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800); + const __m128i v_c080 = _mm_set1_epi16((int16_t)0xc080); + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { + __m128i in = _mm_loadu_si128((__m128i*)buf); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + in = _mm_shuffle_epi8(in, swap); + } + // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes + const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80); + if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!! + __m128i nextin = _mm_loadu_si128((__m128i*)buf + 1); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + nextin = _mm_shuffle_epi8(nextin, swap); + } + if (!_mm_testz_si128(nextin, v_ff80)) { + // 1. pack the bytes + // obviously suboptimal. + const __m128i utf8_packed = _mm_packus_epi16(in, in); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 8; + utf8_output += 8; + in = nextin; + } else { + // 1. pack the bytes + // obviously suboptimal. + const __m128i utf8_packed = _mm_packus_epi16(in, nextin); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + } + + // no bits set above 7th bit + const __m128i one_byte_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000); + const uint16_t one_byte_bitmask = static_cast(_mm_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m128i one_or_two_bytes_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000); + const uint16_t one_or_two_bytes_bitmask = static_cast(_mm_movemask_epi8(one_or_two_bytes_bytemask)); + + if (one_or_two_bytes_bitmask == 0xffff) { + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00); + const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m128i t0 = _mm_slli_epi16(in, 2); + // t1 = [000a|aaaa|0000|0000] + const __m128i t1 = _mm_and_si128(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m128i t2 = _mm_and_si128(in, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m128i t3 = _mm_or_si128(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m128i t4 = _mm_or_si128(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m128i utf8_unpacked = _mm_blendv_epi8(t4, in, one_byte_bytemask); - const char16_t* end = buf + len; + // 3. prepare bitmask for 8-bit lookup + // one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a - LSB) + const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a + const uint16_t m1 = static_cast(m0 >> 7); // m1 = 00000000h0g0f0e0 + const uint8_t m2 = static_cast((m0 | m1) & 0xff); // m2 = hdgcfbea + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle); - const __m128i v_0000 = _mm_setzero_si128(); - const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800); - const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800); - const __m128i v_c080 = _mm_set1_epi16((int16_t)0xc080); - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - while (buf + 16 + safety_margin <= end) { - __m128i in = _mm_loadu_si128((__m128i*)buf); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - in = _mm_shuffle_epi8(in, swap); - } - // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes - const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80); - if(_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!! - __m128i nextin = _mm_loadu_si128((__m128i*)buf+1); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - nextin = _mm_shuffle_epi8(nextin, swap); - } - if(!_mm_testz_si128(nextin, v_ff80)) { - // 1. pack the bytes - // obviously suboptimal. - const __m128i utf8_packed = _mm_packus_epi16(in,in); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 8; - utf8_output += 8; - in = nextin; - } else { - // 1. pack the bytes - // obviously suboptimal. - const __m128i utf8_packed = _mm_packus_epi16(in,nextin); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - } - - // no bits set above 7th bit - const __m128i one_byte_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000); - const uint16_t one_byte_bitmask = static_cast(_mm_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m128i one_or_two_bytes_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000); - const uint16_t one_or_two_bytes_bitmask = static_cast(_mm_movemask_epi8(one_or_two_bytes_bytemask)); - - if (one_or_two_bytes_bitmask == 0xffff) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00); - const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m128i t0 = _mm_slli_epi16(in, 2); - // t1 = [000a|aaaa|0000|0000] - const __m128i t1 = _mm_and_si128(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m128i t2 = _mm_and_si128(in, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m128i t3 = _mm_or_si128(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m128i t4 = _mm_or_si128(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m128i utf8_unpacked = _mm_blendv_epi8(t4, in, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - // one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a - LSB) - const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a - const uint16_t m1 = static_cast(m0 >> 7); // m1 = 00000000h0g0f0e0 - const uint8_t m2 = static_cast((m0 | m1) & 0xff); // m2 = hdgcfbea - // 4. pack the bytes - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle); - - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - - // 6. adjust pointers - buf += 8; - utf8_output += row[0]; - continue; - - } - - // 1. Check if there are any surrogate word in the input chunk. - // We have also deal with situation when there is a surrogate word - // at the end of a chunk. - const __m128i surrogates_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800); - - // bitmask = 0x0000 if there are no surrogates - // = 0xc000 if the last word is a surrogate - const uint16_t surrogates_bitmask = static_cast(_mm_movemask_epi8(surrogates_bytemask)); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (surrogates_bitmask == 0x0000) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m128i t0 = _mm_shuffle_epi8(in, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m128i t1 = _mm_and_si128(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m128i t2 = _mm_or_si128 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m128i s0 = _mm_srli_epi16(in, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m128i s1 = _mm_and_si128(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m128i s2 = _mm_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m128i s3 = _mm_or_si128(s2, vec(0b1100000011100000)); - const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m128i s4 = _mm_xor_si128(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m128i out0 = _mm_unpacklo_epi16(t2, s4); - const __m128i out1 = _mm_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint16_t mask = (one_byte_bitmask & 0x5555) | - (one_or_two_bytes_bitmask & 0xaaaa); - if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m128i shuffle = _mm_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle); - const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += 12; - buf += 8; - continue; - } - const uint8_t mask0 = uint8_t(mask); - - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - - buf += 8; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word & 0xFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word &0xF800 ) != 0xD800) { - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k+1]) : buf[k+1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(nullptr, utf8_output); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); + // 6. adjust pointers + buf += 8; + utf8_output += row[0]; + continue; } - } - buf += k; - } - } // while - return std::make_pair(buf, utf8_output); -} + // 1. Check if there are any surrogate word in the input chunk. + // We have also deal with situation when there is a surrogate word + // at the end of a chunk. + const __m128i surrogates_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800); + // bitmask = 0x0000 if there are no surrogates + // = 0xc000 if the last word is a surrogate + const uint16_t surrogates_bitmask = static_cast(_mm_movemask_epi8(surrogates_bytemask)); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (surrogates_bitmask == 0x0000) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m128i t0 = _mm_shuffle_epi8(in, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m128i s0 = _mm_srli_epi16(in, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000)); + const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m128i s4 = _mm_xor_si128(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m128i out0 = _mm_unpacklo_epi16(t2, s4); + const __m128i out1 = _mm_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint16_t mask = (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa); + if (mask == 0) { + // We only have three-byte words. Use fast path. + const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14, 15, 13, -1, -1, -1, -1); + const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle); + const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += 12; + buf += 8; + continue; + } + const uint8_t mask0 = uint8_t(mask); -/* - Returns a pair: a result struct and utf8_output. - If there is an error, the count field of the result is the position of the error. - Otherwise, it is the position of the first unprocessed byte in buf (even if finished). - A scalar routing should carry on the conversion of the tail if needed. -*/ -template -std::pair sse_convert_utf16_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) { - const char16_t* start = buf; - const char16_t* end = buf + len; - - const __m128i v_0000 = _mm_setzero_si128(); - const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800); - const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800); - const __m128i v_c080 = _mm_set1_epi16((int16_t)0xc080); - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m128i in = _mm_loadu_si128((__m128i*)buf); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - in = _mm_shuffle_epi8(in, swap); - } - // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes - const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80); - if(_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!! - __m128i nextin = _mm_loadu_si128((__m128i*)buf+1); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - nextin = _mm_shuffle_epi8(nextin, swap); - } - if(!_mm_testz_si128(nextin, v_ff80)) { - // 1. pack the bytes - // obviously suboptimal. - const __m128i utf8_packed = _mm_packus_epi16(in,in); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 8; - utf8_output += 8; - in = nextin; - } else { - // 1. pack the bytes - // obviously suboptimal. - const __m128i utf8_packed = _mm_packus_epi16(in,nextin); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - } - - // no bits set above 7th bit - const __m128i one_byte_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000); - const uint16_t one_byte_bitmask = static_cast(_mm_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m128i one_or_two_bytes_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000); - const uint16_t one_or_two_bytes_bitmask = static_cast(_mm_movemask_epi8(one_or_two_bytes_bytemask)); - - if (one_or_two_bytes_bitmask == 0xffff) { - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00); - const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m128i t0 = _mm_slli_epi16(in, 2); - // t1 = [000a|aaaa|0000|0000] - const __m128i t1 = _mm_and_si128(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m128i t2 = _mm_and_si128(in, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m128i t3 = _mm_or_si128(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m128i t4 = _mm_or_si128(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m128i utf8_unpacked = _mm_blendv_epi8(t4, in, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - // one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a - LSB) - const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a - const uint16_t m1 = static_cast(m0 >> 7); // m1 = 00000000h0g0f0e0 - const uint8_t m2 = static_cast((m0 | m1) & 0xff); // m2 = hdgcfbea - // 4. pack the bytes - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle); - - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - - // 6. adjust pointers - buf += 8; - utf8_output += row[0]; - continue; - - } - - // 1. Check if there are any surrogate word in the input chunk. - // We have also deal with situation when there is a surrogate word - // at the end of a chunk. - const __m128i surrogates_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800); - - // bitmask = 0x0000 if there are no surrogates - // = 0xc000 if the last word is a surrogate - const uint16_t surrogates_bitmask = static_cast(_mm_movemask_epi8(surrogates_bytemask)); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (surrogates_bitmask == 0x0000) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m128i t0 = _mm_shuffle_epi8(in, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m128i t1 = _mm_and_si128(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m128i t2 = _mm_or_si128 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m128i s0 = _mm_srli_epi16(in, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m128i s1 = _mm_and_si128(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m128i s2 = _mm_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m128i s3 = _mm_or_si128(s2, vec(0b1100000011100000)); - const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m128i s4 = _mm_xor_si128(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m128i out0 = _mm_unpacklo_epi16(t2, s4); - const __m128i out1 = _mm_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint16_t mask = (one_byte_bitmask & 0x5555) | - (one_or_two_bytes_bitmask & 0xaaaa); - if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m128i shuffle = _mm_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle); - const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += 12; - buf += 8; - continue; - } - const uint8_t mask0 = uint8_t(mask); - - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - - buf += 8; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word & 0xFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word &0xF800 ) != 0xD800) { - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + + buf += 8; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k+1]) : buf[k+1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), utf8_output); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf8_output++ = char((value>>18) | 0b11110000); - *utf8_output++ = char(((value>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((value>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((value & 0b111111) | 0b10000000); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xF800) != 0xD800) { + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), utf8_output); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf8_output++ = char((value >> 18) | 0b11110000); + *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((value & 0b111111) | 0b10000000); + } + } + buf += k; } - } - buf += k; - } - } // while + } // while - return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); + return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); } /* end file src/westmere/sse_convert_utf16_to_utf8.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_convert_utf16_to_utf32.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_convert_utf16_to_utf32.cpp /* begin file src/westmere/sse_convert_utf16_to_utf32.cpp */ /* The vectorized algorithm works on single SSE register i.e., it @@ -25913,754 +29297,816 @@ std::pair sse_convert_utf16_to_utf8_with_errors(const char16_t* b Returns a pair: the first unprocessed byte from buf and utf8_output A scalar routing should carry on the conversion of the tail. */ -template -std::pair sse_convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) { - const char16_t* end = buf + len; +template +std::pair sse_convert_utf16_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) +{ + const char16_t* end = buf + len; - const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800); - const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800); + const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800); + const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800); - while (buf + 16 <= end) { - __m128i in = _mm_loadu_si128((__m128i*)buf); + while (buf + 16 <= end) { + __m128i in = _mm_loadu_si128((__m128i*)buf); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - in = _mm_shuffle_epi8(in, swap); - } - - // 1. Check if there are any surrogate word in the input chunk. - // We have also deal with situation when there is a surrogate word - // at the end of a chunk. - const __m128i surrogates_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800); - - // bitmask = 0x0000 if there are no surrogates - // = 0xc000 if the last word is a surrogate - const uint16_t surrogates_bitmask = static_cast(_mm_movemask_epi8(surrogates_bytemask)); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (surrogates_bitmask == 0x0000) { - // case: no surrogate pair, extend 16-bit words to 32-bit words - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output), _mm_cvtepu16_epi32(in)); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output+4), _mm_cvtepu16_epi32(_mm_srli_si128(in,8))); - utf32_output += 8; - buf += 8; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word &0xF800 ) != 0xD800) { - *utf32_output++ = char32_t(word); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + in = _mm_shuffle_epi8(in, swap); + } + + // 1. Check if there are any surrogate word in the input chunk. + // We have also deal with situation when there is a surrogate word + // at the end of a chunk. + const __m128i surrogates_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800); + + // bitmask = 0x0000 if there are no surrogates + // = 0xc000 if the last word is a surrogate + const uint16_t surrogates_bitmask = static_cast(_mm_movemask_epi8(surrogates_bytemask)); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (surrogates_bitmask == 0x0000) { + // case: no surrogate pair, extend 16-bit words to 32-bit words + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output), _mm_cvtepu16_epi32(in)); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output + 4), _mm_cvtepu16_epi32(_mm_srli_si128(in, 8))); + utf32_output += 8; + buf += 8; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k+1]) : buf[k+1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(nullptr, utf32_output); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xF800) != 0xD800) { + *utf32_output++ = char32_t(word); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(nullptr, utf32_output); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + } + } + buf += k; } - } - buf += k; - } - } // while - return std::make_pair(buf, utf32_output); + } // while + return std::make_pair(buf, utf32_output); } - /* Returns a pair: a result struct and utf8_output. If there is an error, the count field of the result is the position of the error. Otherwise, it is the position of the first unprocessed byte in buf (even if finished). A scalar routing should carry on the conversion of the tail if needed. */ -template -std::pair sse_convert_utf16_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) { - const char16_t* start = buf; - const char16_t* end = buf + len; +template +std::pair sse_convert_utf16_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) +{ + const char16_t* start = buf; + const char16_t* end = buf + len; - const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800); - const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800); + const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800); + const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800); - while (buf + 16 <= end) { - __m128i in = _mm_loadu_si128((__m128i*)buf); + while (buf + 16 <= end) { + __m128i in = _mm_loadu_si128((__m128i*)buf); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - in = _mm_shuffle_epi8(in, swap); - } - - // 1. Check if there are any surrogate word in the input chunk. - // We have also deal with situation when there is a surrogate word - // at the end of a chunk. - const __m128i surrogates_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800); - - // bitmask = 0x0000 if there are no surrogates - // = 0xc000 if the last word is a surrogate - const uint16_t surrogates_bitmask = static_cast(_mm_movemask_epi8(surrogates_bytemask)); - // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, - // it is likely an uncommon occurrence. - if (surrogates_bitmask == 0x0000) { - // case: no surrogate pair, extend 16-bit words to 32-bit words - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output), _mm_cvtepu16_epi32(in)); - _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output+4), _mm_cvtepu16_epi32(_mm_srli_si128(in,8))); - utf32_output += 8; - buf += 8; - // surrogate pair(s) in a register - } else { - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; - if((word &0xF800 ) != 0xD800) { - *utf32_output++ = char32_t(word); + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + in = _mm_shuffle_epi8(in, swap); + } + + // 1. Check if there are any surrogate word in the input chunk. + // We have also deal with situation when there is a surrogate word + // at the end of a chunk. + const __m128i surrogates_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800); + + // bitmask = 0x0000 if there are no surrogates + // = 0xc000 if the last word is a surrogate + const uint16_t surrogates_bitmask = static_cast(_mm_movemask_epi8(surrogates_bytemask)); + // It might seem like checking for surrogates_bitmask == 0xc000 could help. However, + // it is likely an uncommon occurrence. + if (surrogates_bitmask == 0x0000) { + // case: no surrogate pair, extend 16-bit words to 32-bit words + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output), _mm_cvtepu16_epi32(in)); + _mm_storeu_si128(reinterpret_cast<__m128i*>(utf32_output + 4), _mm_cvtepu16_epi32(_mm_srli_si128(in, 8))); + utf32_output += 8; + buf += 8; + // surrogate pair(s) in a register } else { - // must be a surrogate pair - uint16_t diff = uint16_t(word - 0xD800); - uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k+1]) : buf[k+1]; - k++; - uint16_t diff2 = uint16_t(next_word - 0xDC00); - if((diff | diff2) > 0x3FF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), utf32_output); } - uint32_t value = (diff << 10) + diff2 + 0x10000; - *utf32_output++ = char32_t(value); + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint16_t word = big_endian ? scalar::utf16::swap_bytes(buf[k]) : buf[k]; + if ((word & 0xF800) != 0xD800) { + *utf32_output++ = char32_t(word); + } else { + // must be a surrogate pair + uint16_t diff = uint16_t(word - 0xD800); + uint16_t next_word = big_endian ? scalar::utf16::swap_bytes(buf[k + 1]) : buf[k + 1]; + k++; + uint16_t diff2 = uint16_t(next_word - 0xDC00); + if ((diff | diff2) > 0x3FF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k - 1), utf32_output); + } + uint32_t value = (diff << 10) + diff2 + 0x10000; + *utf32_output++ = char32_t(value); + } + } + buf += k; } - } - buf += k; - } - } // while - return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output); + } // while + return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output); } /* end file src/westmere/sse_convert_utf16_to_utf32.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_convert_utf32_to_utf8.cpp +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_convert_utf32_to_utf8.cpp /* begin file src/westmere/sse_convert_utf32_to_utf8.cpp */ -std::pair sse_convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) { - - const char32_t* end = buf + len; - - const __m128i v_0000 = _mm_setzero_si128(); - const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); - const __m128i v_c080 = _mm_set1_epi16((uint16_t)0xc080); - const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80); - const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000); - const __m128i v_7fffffff = _mm_set1_epi32((uint32_t)0x7fffffff); - __m128i running_max = _mm_setzero_si128(); - __m128i forbidden_bytemask = _mm_setzero_si128(); - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m128i in = _mm_loadu_si128((__m128i*)buf); - __m128i nextin = _mm_loadu_si128((__m128i*)buf+1); - running_max = _mm_max_epu32(_mm_max_epu32(in, running_max), nextin); - - // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation - __m128i in_16 = _mm_packus_epi32(_mm_and_si128(in, v_7fffffff), _mm_and_si128(nextin, v_7fffffff)); - - // Try to apply UTF-16 => UTF-8 from ./sse_convert_utf16_to_utf8.cpp - - // Check for ASCII fast path - if(_mm_testz_si128(in_16, v_ff80)) { // ASCII fast path!!!! - __m128i thirdin = _mm_loadu_si128((__m128i*)buf+2); - __m128i fourthin = _mm_loadu_si128((__m128i*)buf+3); - running_max = _mm_max_epu32(_mm_max_epu32(thirdin, running_max), fourthin); - __m128i nextin_16 = _mm_packus_epi32(_mm_and_si128(thirdin, v_7fffffff), _mm_and_si128(fourthin, v_7fffffff)); - if(!_mm_testz_si128(nextin_16, v_ff80)) { - // 1. pack the bytes - // obviously suboptimal. - const __m128i utf8_packed = _mm_packus_epi16(in_16,in_16); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 8; - utf8_output += 8; - // Proceed with next input - in_16 = nextin_16; - } else { - // 1. pack the bytes - const __m128i utf8_packed = _mm_packus_epi16(in_16, nextin_16); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - } - - // no bits set above 7th bit - const __m128i one_byte_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_ff80), v_0000); - const uint16_t one_byte_bitmask = static_cast(_mm_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m128i one_or_two_bytes_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_0000); - const uint16_t one_or_two_bytes_bitmask = static_cast(_mm_movemask_epi8(one_or_two_bytes_bytemask)); - - if (one_or_two_bytes_bitmask == 0xffff) { - // case: all words either produce 1 or 2 UTF-8 bytes (at least one produces 2 bytes) - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00); - const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m128i t0 = _mm_slli_epi16(in_16, 2); - // t1 = [000a|aaaa|0000|0000] - const __m128i t1 = _mm_and_si128(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m128i t2 = _mm_and_si128(in_16, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m128i t3 = _mm_or_si128(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m128i t4 = _mm_or_si128(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m128i utf8_unpacked = _mm_blendv_epi8(t4, in_16, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - // one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a - LSB) - const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a - const uint16_t m1 = static_cast(m0 >> 7); // m1 = 00000000h0g0f0e0 - const uint8_t m2 = static_cast((m0 | m1) & 0xff); // m2 = hdgcfbea - // 4. pack the bytes - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle); - - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - - // 6. adjust pointers - buf += 8; - utf8_output += row[0]; - continue; - } - - - // Check for overflow in packing - const __m128i saturation_bytemask = _mm_cmpeq_epi32(_mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000); - const uint32_t saturation_bitmask = static_cast(_mm_movemask_epi8(saturation_bytemask)); - - if (saturation_bitmask == 0xffff) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800); - forbidden_bytemask = _mm_or_si128(forbidden_bytemask, _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_d800)); - - const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m128i t0 = _mm_shuffle_epi8(in_16, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m128i t1 = _mm_and_si128(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m128i t2 = _mm_or_si128 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m128i s0 = _mm_srli_epi16(in_16, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m128i s1 = _mm_and_si128(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m128i s2 = _mm_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m128i s3 = _mm_or_si128(s2, vec(0b1100000011100000)); - const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m128i s4 = _mm_xor_si128(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m128i out0 = _mm_unpacklo_epi16(t2, s4); - const __m128i out1 = _mm_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint16_t mask = (one_byte_bitmask & 0x5555) | - (one_or_two_bytes_bitmask & 0xaaaa); - if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m128i shuffle = _mm_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle); - const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += 12; - buf += 8; - continue; - } - const uint8_t mask0 = uint8_t(mask); - - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - - buf += 8; - } else { - // case: at least one 32-bit word produce a surrogate pair in UTF-16 <=> will produce four UTF-8 bytes - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFFFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xFFFFF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word &0xFFFF0000 )==0) { - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(nullptr, utf8_output); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else { - if (word > 0x10FFFF) { return std::make_pair(nullptr, utf8_output); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } - } - buf += k; - } - } // while - - // check for invalid input - const __m128i v_10ffff = _mm_set1_epi32((uint32_t)0x10ffff); - if(static_cast(_mm_movemask_epi8(_mm_cmpeq_epi32(_mm_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffff) { - return std::make_pair(nullptr, utf8_output); - } - - if (static_cast(_mm_movemask_epi8(forbidden_bytemask)) != 0) { return std::make_pair(nullptr, utf8_output); } - - return std::make_pair(buf, utf8_output); -} - - -std::pair sse_convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) { - - const char32_t* end = buf + len; - const char32_t* start = buf; - - const __m128i v_0000 = _mm_setzero_si128(); - const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); - const __m128i v_c080 = _mm_set1_epi16((uint16_t)0xc080); - const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80); - const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000); - const __m128i v_7fffffff = _mm_set1_epi32((uint32_t)0x7fffffff); - const __m128i v_10ffff = _mm_set1_epi32((uint32_t)0x10ffff); - - const size_t safety_margin = 11; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - - while (buf + 16 + safety_margin <= end) { - __m128i in = _mm_loadu_si128((__m128i*)buf); - __m128i nextin = _mm_loadu_si128((__m128i*)buf+1); - - // Check for too large input - __m128i max_input = _mm_max_epu32(_mm_max_epu32(in, nextin), v_10ffff); - if(static_cast(_mm_movemask_epi8(_mm_cmpeq_epi32(max_input, v_10ffff))) != 0xffff) { - return std::make_pair(result(error_code::TOO_LARGE, buf - start), utf8_output); - } - - // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation - __m128i in_16 = _mm_packus_epi32(_mm_and_si128(in, v_7fffffff), _mm_and_si128(nextin, v_7fffffff)); - - // Try to apply UTF-16 => UTF-8 from ./sse_convert_utf16_to_utf8.cpp - - // Check for ASCII fast path - if(_mm_testz_si128(in_16, v_ff80)) { // ASCII fast path!!!! - __m128i thirdin = _mm_loadu_si128((__m128i*)buf+2); - __m128i fourthin = _mm_loadu_si128((__m128i*)buf+3); - __m128i nextin_16 = _mm_packus_epi32(_mm_and_si128(thirdin, v_7fffffff), _mm_and_si128(fourthin, v_7fffffff)); - if(!_mm_testz_si128(nextin_16, v_ff80)) { - // 1. pack the bytes - // obviously suboptimal. - const __m128i utf8_packed = _mm_packus_epi16(in_16,in_16); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 8; - utf8_output += 8; - // Proceed with next input - in_16 = nextin_16; - __m128i next_max_input = _mm_max_epu32(_mm_max_epu32(thirdin, fourthin), v_10ffff); - if(static_cast(_mm_movemask_epi8(_mm_cmpeq_epi32(next_max_input, v_10ffff))) != 0xffff) { - return std::make_pair(result(error_code::TOO_LARGE, buf - start), utf8_output); - } - } else { - // 1. pack the bytes - const __m128i utf8_packed = _mm_packus_epi16(in_16, nextin_16); - // 2. store (16 bytes) - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - // 3. adjust pointers - buf += 16; - utf8_output += 16; - continue; // we are done for this round! - } - } - - // no bits set above 7th bit - const __m128i one_byte_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_ff80), v_0000); - const uint16_t one_byte_bitmask = static_cast(_mm_movemask_epi8(one_byte_bytemask)); - - // no bits set above 11th bit - const __m128i one_or_two_bytes_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_0000); - const uint16_t one_or_two_bytes_bitmask = static_cast(_mm_movemask_epi8(one_or_two_bytes_bytemask)); - - if (one_or_two_bytes_bitmask == 0xffff) { - // case: all words either produce 1 or 2 UTF-8 bytes (at least one produces 2 bytes) - // 1. prepare 2-byte values - // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 - // expected output : [110a|aaaa|10bb|bbbb] x 8 - const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00); - const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f); - - // t0 = [000a|aaaa|bbbb|bb00] - const __m128i t0 = _mm_slli_epi16(in_16, 2); - // t1 = [000a|aaaa|0000|0000] - const __m128i t1 = _mm_and_si128(t0, v_1f00); - // t2 = [0000|0000|00bb|bbbb] - const __m128i t2 = _mm_and_si128(in_16, v_003f); - // t3 = [000a|aaaa|00bb|bbbb] - const __m128i t3 = _mm_or_si128(t1, t2); - // t4 = [110a|aaaa|10bb|bbbb] - const __m128i t4 = _mm_or_si128(t3, v_c080); - - // 2. merge ASCII and 2-byte codewords - const __m128i utf8_unpacked = _mm_blendv_epi8(t4, in_16, one_byte_bytemask); - - // 3. prepare bitmask for 8-bit lookup - // one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a - LSB) - const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a - const uint16_t m1 = static_cast(m0 >> 7); // m1 = 00000000h0g0f0e0 - const uint8_t m2 = static_cast((m0 | m1) & 0xff); // m2 = hdgcfbea - // 4. pack the bytes - const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; - const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); - const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle); - - // 5. store bytes - _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); - - // 6. adjust pointers - buf += 8; - utf8_output += row[0]; - continue; - } - - - // Check for overflow in packing - const __m128i saturation_bytemask = _mm_cmpeq_epi32(_mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000); - const uint32_t saturation_bitmask = static_cast(_mm_movemask_epi8(saturation_bytemask)); - - if (saturation_bitmask == 0xffff) { - // case: words from register produce either 1, 2 or 3 UTF-8 bytes - - // Check for illegal surrogate words - const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800); - const __m128i forbidden_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_d800); - if (static_cast(_mm_movemask_epi8(forbidden_bytemask)) != 0) { - return std::make_pair(result(error_code::SURROGATE, buf - start), utf8_output); - } - - const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, - 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); - - /* In this branch we handle three cases: - 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte - 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes - 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes - - We expand the input word (16-bit) into two words (32-bit), thus - we have room for four bytes. However, we need five distinct bit - layouts. Note that the last byte in cases #2 and #3 is the same. - - We precompute byte 1 for case #1 and the common byte for cases #2 & #3 - in register t2. - - We precompute byte 1 for case #3 and -- **conditionally** -- precompute - either byte 1 for case #2 or byte 2 for case #3. Note that they - differ by exactly one bit. - - Finally from these two words we build proper UTF-8 sequence, taking - into account the case (i.e, the number of bytes to write). - */ - /** - * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: - * t2 => [0ccc|cccc] [10cc|cccc] - * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) - */ -#define vec(x) _mm_set1_epi16(static_cast(x)) - // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] - const __m128i t0 = _mm_shuffle_epi8(in_16, dup_even); - // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] - const __m128i t1 = _mm_and_si128(t0, vec(0b0011111101111111)); - // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] - const __m128i t2 = _mm_or_si128 (t1, vec(0b1000000000000000)); - - // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] - const __m128i s0 = _mm_srli_epi16(in_16, 4); - // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] - const __m128i s1 = _mm_and_si128(s0, vec(0b0000111111111100)); - // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] - const __m128i s2 = _mm_maddubs_epi16(s1, vec(0x0140)); - // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] - const __m128i s3 = _mm_or_si128(s2, vec(0b1100000011100000)); - const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask, vec(0b0100000000000000)); - const __m128i s4 = _mm_xor_si128(s3, m0); -#undef vec - - // 4. expand words 16-bit => 32-bit - const __m128i out0 = _mm_unpacklo_epi16(t2, s4); - const __m128i out1 = _mm_unpackhi_epi16(t2, s4); - - // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle - const uint16_t mask = (one_byte_bitmask & 0x5555) | - (one_or_two_bytes_bitmask & 0xaaaa); - if(mask == 0) { - // We only have three-byte words. Use fast path. - const __m128i shuffle = _mm_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); - const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle); - const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle); - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += 12; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += 12; - buf += 8; - continue; - } - const uint8_t mask0 = uint8_t(mask); - - const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; - const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); - const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0); - - const uint8_t mask1 = static_cast(mask >> 8); - - const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; - const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); - const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1); - - _mm_storeu_si128((__m128i*)utf8_output, utf8_0); - utf8_output += row0[0]; - _mm_storeu_si128((__m128i*)utf8_output, utf8_1); - utf8_output += row1[0]; - - buf += 8; - } else { - // case: at least one 32-bit word produce a surrogate pair in UTF-16 <=> will produce four UTF-8 bytes - // Let us do a scalar fallback. - // It may seem wasteful to use scalar code, but being efficient with SIMD - // in the presence of surrogate pairs may require non-trivial tables. - size_t forward = 15; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFFFF80)==0) { - *utf8_output++ = char(word); - } else if((word & 0xFFFFF800)==0) { - *utf8_output++ = char((word>>6) | 0b11000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); - } else if((word &0xFFFF0000 )==0) { - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf8_output); } - *utf8_output++ = char((word>>12) | 0b11100000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); +std::pair sse_convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) +{ + const char32_t* end = buf + len; + + const __m128i v_0000 = _mm_setzero_si128(); //__m128 = 128 bits + const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); // 1111 1000 0000 0000 + const __m128i v_c080 = _mm_set1_epi16((uint16_t)0xc080); // 1100 0000 1000 0000 + const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80); // 1111 1111 1000 0000 + const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000); // 1111 1111 1111 1111 0000 0000 0000 0000 + const __m128i v_7fffffff = _mm_set1_epi32((uint32_t)0x7fffffff); // 0111 1111 1111 1111 1111 1111 1111 1111 + __m128i running_max = _mm_setzero_si128(); + __m128i forbidden_bytemask = _mm_setzero_si128(); + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 + + while (buf + 16 + safety_margin <= end) { // buf is a char32_t pointer, each char32_t has 4 bytes or 32 bits, thus buf + 16 * char_32t = 512 bits = 64 bytes + // We load two 16 bytes registers for a total of 32 bytes or 16 characters. + __m128i in = _mm_loadu_si128((__m128i*)buf); + __m128i nextin = _mm_loadu_si128((__m128i*)buf + 1); // These two values can hold only 8 UTF32 chars + running_max = _mm_max_epu32( + _mm_max_epu32(in, running_max), // take element-wise max char32_t from in and running_max vector + nextin); // and take element-wise max element from nextin and running_max vector + + // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation + __m128i in_16 = _mm_packus_epi32( + _mm_and_si128(in, v_7fffffff), + _mm_and_si128(nextin, v_7fffffff)); // in this context pack the two __m128 into a single + // By ensuring the highest bit is set to 0(&v_7fffffff), we're making sure all values are interpreted as non-negative, or specifically, the values are within the range of valid Unicode code points. + // remember : having leading byte 0 means a positive number by the two complements system. Unicode is well beneath the range where you'll start getting issues so that's OK. + + // Try to apply UTF-16 => UTF-8 from ./sse_convert_utf16_to_utf8.cpp + + // Check for ASCII fast path + + // ASCII fast path!!!! + // We eagerly load another 32 bytes, hoping that they will be ASCII too. + // The intuition is that we try to collect 16 ASCII characters which requires + // a total of 64 bytes of input. If we fail, we just pass thirdin and fourthin + // as our new inputs. + if (_mm_testz_si128(in_16, v_ff80)) { // if the first two blocks are ASCII + __m128i thirdin = _mm_loadu_si128((__m128i*)buf + 2); + __m128i fourthin = _mm_loadu_si128((__m128i*)buf + 3); + running_max = _mm_max_epu32(_mm_max_epu32(thirdin, running_max), fourthin); // take the running max of all 4 vectors thus far + __m128i nextin_16 = _mm_packus_epi32(_mm_and_si128(thirdin, v_7fffffff), _mm_and_si128(fourthin, v_7fffffff)); // pack into 1 vector, now you have two + if (!_mm_testz_si128(nextin_16, v_ff80)) { // checks if the second packed vector is ASCII, if not: + // 1. pack the bytes + // obviously suboptimal. + const __m128i utf8_packed = _mm_packus_epi16(in_16, in_16); // creates two copy of in_16 in 1 vector + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); // put them into the output + // 3. adjust pointers + buf += 8; // the char32_t buffer pointer goes up 8 char32_t chars* 32 bits = 256 bits + utf8_output += 8; // same with output, e.g. lift the first two blocks alone. + // Proceed with next input + in_16 = nextin_16; + // We need to update in and nextin because they are used later. + in = thirdin; + nextin = fourthin; + } else { + // 1. pack the bytes + const __m128i utf8_packed = _mm_packus_epi16(in_16, nextin_16); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } + } + + // no bits set above 7th bit -- find out all the ASCII characters + const __m128i one_byte_bytemask = _mm_cmpeq_epi16( // this takes four bytes at a time and compares: + _mm_and_si128(in_16, v_ff80), // the vector that get only the first 9 bits of each 16-bit/2-byte units + v_0000 // + ); // they should be all zero if they are ASCII. E.g. ASCII in UTF32 is of format 0000 0000 0000 0XXX XXXX + // _mm_cmpeq_epi16 should now return a 1111 1111 1111 1111 for equals, and 0000 0000 0000 0000 if not for each 16-bit/2-byte units + const uint16_t one_byte_bitmask = static_cast(_mm_movemask_epi8(one_byte_bytemask)); // collect the MSB from previous vector and put them into uint16_t mas + + // no bits set above 11th bit + const __m128i one_or_two_bytes_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_0000); + const uint16_t one_or_two_bytes_bitmask = static_cast(_mm_movemask_epi8(one_or_two_bytes_bytemask)); + + if (one_or_two_bytes_bitmask == 0xffff) { + // case: all words either produce 1 or 2 UTF-8 bytes (at least one produces 2 bytes) + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00); // 0001 1111 0000 0000 + const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f); // 0000 0000 0011 1111 + + // t0 = [000a|aaaa|bbbb|bb00] + const __m128i t0 = _mm_slli_epi16(in_16, 2); // shift packed vector by two + // t1 = [000a|aaaa|0000|0000] + const __m128i t1 = _mm_and_si128(t0, v_1f00); // potentital first utf8 byte + // t2 = [0000|0000|00bb|bbbb] + const __m128i t2 = _mm_and_si128(in_16, v_003f); // potential second utf8 byte + // t3 = [000a|aaaa|00bb|bbbb] + const __m128i t3 = _mm_or_si128(t1, t2); // first and second potential utf8 byte together + // t4 = [110a|aaaa|10bb|bbbb] + const __m128i t4 = _mm_or_si128(t3, v_c080); // t3 | 1100 0000 1000 0000 = full potential 2-byte utf8 unit + + // 2. merge ASCII and 2-byte codewords + const __m128i utf8_unpacked = _mm_blendv_epi8(t4, in_16, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + // one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a - LSB) + const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a + const uint16_t m1 = static_cast(m0 >> 7); // m1 = 00000000h0g0f0e0 + const uint8_t m2 = static_cast((m0 | m1) & 0xff); // m2 = hdgcfbea + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle); + + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + + // 6. adjust pointers + buf += 8; + utf8_output += row[0]; + continue; + } + + // Check for overflow in packing + + const __m128i saturation_bytemask = _mm_cmpeq_epi32(_mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000); + const uint32_t saturation_bitmask = static_cast(_mm_movemask_epi8(saturation_bytemask)); + if (saturation_bitmask == 0xffff) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800); + forbidden_bytemask = _mm_or_si128(forbidden_bytemask, _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_d800)); + + const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m128i t0 = _mm_shuffle_epi8(in_16, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m128i s0 = _mm_srli_epi16(in_16, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000)); + const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m128i s4 = _mm_xor_si128(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m128i out0 = _mm_unpacklo_epi16(t2, s4); + const __m128i out1 = _mm_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint16_t mask = (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa); + if (mask == 0) { + // We only have three-byte words. Use fast path. + const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14, 15, 13, -1, -1, -1, -1); + const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle); + const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += 12; + buf += 8; + continue; + } + const uint8_t mask0 = uint8_t(mask); + + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + + buf += 8; } else { - if (word > 0x10FFFF) { return std::make_pair(result(error_code::TOO_LARGE, buf- start + k), utf8_output); } - *utf8_output++ = char((word>>18) | 0b11110000); - *utf8_output++ = char(((word>>12) & 0b111111) | 0b10000000); - *utf8_output++ = char(((word>>6) & 0b111111) | 0b10000000); - *utf8_output++ = char((word & 0b111111) | 0b10000000); + // case: at least one 32-bit word produce a surrogate pair in UTF-16 <=> will produce four UTF-8 bytes + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFFFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xFFFFF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xFFFF0000) == 0) { + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(nullptr, utf8_output); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + if (word > 0x10FFFF) { + return std::make_pair(nullptr, utf8_output); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } + } + buf += k; } - } - buf += k; + } // while + + // check for invalid input + const __m128i v_10ffff = _mm_set1_epi32((uint32_t)0x10ffff); + if (static_cast(_mm_movemask_epi8(_mm_cmpeq_epi32(_mm_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffff) { + return std::make_pair(nullptr, utf8_output); + } + + if (static_cast(_mm_movemask_epi8(forbidden_bytemask)) != 0) { + return std::make_pair(nullptr, utf8_output); } - } // while - return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); + return std::make_pair(buf, utf8_output); } -/* end file src/westmere/sse_convert_utf32_to_utf8.cpp */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=westmere/sse_convert_utf32_to_utf16.cpp -/* begin file src/westmere/sse_convert_utf32_to_utf16.cpp */ -template -std::pair sse_convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_output) { - const char32_t* end = buf + len; +std::pair sse_convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) +{ - const __m128i v_0000 = _mm_setzero_si128(); - const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000); - __m128i forbidden_bytemask = _mm_setzero_si128(); + const char32_t* end = buf + len; + const char32_t* start = buf; - while (buf + 8 <= end) { - __m128i in = _mm_loadu_si128((__m128i*)buf); - __m128i nextin = _mm_loadu_si128((__m128i*)buf+1); - const __m128i saturation_bytemask = _mm_cmpeq_epi32(_mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000); - const uint32_t saturation_bitmask = static_cast(_mm_movemask_epi8(saturation_bytemask)); + const __m128i v_0000 = _mm_setzero_si128(); + const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); + const __m128i v_c080 = _mm_set1_epi16((uint16_t)0xc080); + const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80); + const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000); + const __m128i v_7fffffff = _mm_set1_epi32((uint32_t)0x7fffffff); + const __m128i v_10ffff = _mm_set1_epi32((uint32_t)0x10ffff); - // Check if no bits set above 16th - if (saturation_bitmask == 0xffff) { - // Pack UTF-32 to UTF-16 - __m128i utf16_packed = _mm_packus_epi32(in, nextin); + const size_t safety_margin = 12; // to avoid overruns, see issue https://github.com/simdutf/simdutf/issues/92 - const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); - const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800); - forbidden_bytemask = _mm_or_si128(forbidden_bytemask, _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800)); + while (buf + 16 + safety_margin <= end) { + // We load two 16 bytes registers for a total of 32 bytes or 16 characters. + __m128i in = _mm_loadu_si128((__m128i*)buf); + __m128i nextin = _mm_loadu_si128((__m128i*)buf + 1); - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); - } + // Check for too large input + __m128i max_input = _mm_max_epu32(_mm_max_epu32(in, nextin), v_10ffff); + if (static_cast(_mm_movemask_epi8(_mm_cmpeq_epi32(max_input, v_10ffff))) != 0xffff) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start), utf8_output); + } - _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); - utf16_output += 8; - buf += 8; - } else { - size_t forward = 7; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(nullptr, utf16_output); } - *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); - } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return std::make_pair(nullptr, utf16_output); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (big_endian) { - high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); - low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); + // Pack 32-bit UTF-32 words to 16-bit UTF-16 words with unsigned saturation + __m128i in_16 = _mm_packus_epi32(_mm_and_si128(in, v_7fffffff), _mm_and_si128(nextin, v_7fffffff)); + + // Try to apply UTF-16 => UTF-8 from ./sse_convert_utf16_to_utf8.cpp + + // Check for ASCII fast path + if (_mm_testz_si128(in_16, v_ff80)) { // ASCII fast path!!!! + // We eagerly load another 32 bytes, hoping that they will be ASCII too. + // The intuition is that we try to collect 16 ASCII characters which requires + // a total of 64 bytes of input. If we fail, we just pass thirdin and fourthin + // as our new inputs. + __m128i thirdin = _mm_loadu_si128((__m128i*)buf + 2); + __m128i fourthin = _mm_loadu_si128((__m128i*)buf + 3); + __m128i nextin_16 = _mm_packus_epi32(_mm_and_si128(thirdin, v_7fffffff), _mm_and_si128(fourthin, v_7fffffff)); + if (!_mm_testz_si128(nextin_16, v_ff80)) { + // 1. pack the bytes + // obviously suboptimal. + const __m128i utf8_packed = _mm_packus_epi16(in_16, in_16); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 8; + utf8_output += 8; + // Proceed with next input + in_16 = nextin_16; + __m128i next_max_input = _mm_max_epu32(_mm_max_epu32(thirdin, fourthin), v_10ffff); + if (static_cast(_mm_movemask_epi8(_mm_cmpeq_epi32(next_max_input, v_10ffff))) != 0xffff) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start), utf8_output); + } + // We need to update in and nextin because they are used later. + in = thirdin; + nextin = fourthin; + } else { + // 1. pack the bytes + const __m128i utf8_packed = _mm_packus_epi16(in_16, nextin_16); + // 2. store (16 bytes) + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + // 3. adjust pointers + buf += 16; + utf8_output += 16; + continue; // we are done for this round! + } } - } - buf += k; - } - } - // check for invalid input - if (static_cast(_mm_movemask_epi8(forbidden_bytemask)) != 0) { return std::make_pair(nullptr, utf16_output); } + // no bits set above 7th bit + const __m128i one_byte_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_ff80), v_0000); + const uint16_t one_byte_bitmask = static_cast(_mm_movemask_epi8(one_byte_bytemask)); + + // no bits set above 11th bit + const __m128i one_or_two_bytes_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_0000); + const uint16_t one_or_two_bytes_bitmask = static_cast(_mm_movemask_epi8(one_or_two_bytes_bytemask)); + + if (one_or_two_bytes_bitmask == 0xffff) { + // case: all words either produce 1 or 2 UTF-8 bytes (at least one produces 2 bytes) + // 1. prepare 2-byte values + // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8 + // expected output : [110a|aaaa|10bb|bbbb] x 8 + const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00); + const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f); + + // t0 = [000a|aaaa|bbbb|bb00] + const __m128i t0 = _mm_slli_epi16(in_16, 2); + // t1 = [000a|aaaa|0000|0000] + const __m128i t1 = _mm_and_si128(t0, v_1f00); + // t2 = [0000|0000|00bb|bbbb] + const __m128i t2 = _mm_and_si128(in_16, v_003f); + // t3 = [000a|aaaa|00bb|bbbb] + const __m128i t3 = _mm_or_si128(t1, t2); + // t4 = [110a|aaaa|10bb|bbbb] + const __m128i t4 = _mm_or_si128(t3, v_c080); + + // 2. merge ASCII and 2-byte codewords + const __m128i utf8_unpacked = _mm_blendv_epi8(t4, in_16, one_byte_bytemask); + + // 3. prepare bitmask for 8-bit lookup + // one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a - LSB) + const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a + const uint16_t m1 = static_cast(m0 >> 7); // m1 = 00000000h0g0f0e0 + const uint8_t m2 = static_cast((m0 | m1) & 0xff); // m2 = hdgcfbea + // 4. pack the bytes + const uint8_t* row = &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0]; + const __m128i shuffle = _mm_loadu_si128((__m128i*)(row + 1)); + const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle); + + // 5. store bytes + _mm_storeu_si128((__m128i*)utf8_output, utf8_packed); + + // 6. adjust pointers + buf += 8; + utf8_output += row[0]; + continue; + } + + // Check for overflow in packing + const __m128i saturation_bytemask = _mm_cmpeq_epi32(_mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000); + const uint32_t saturation_bitmask = static_cast(_mm_movemask_epi8(saturation_bytemask)); + + if (saturation_bitmask == 0xffff) { + // case: words from register produce either 1, 2 or 3 UTF-8 bytes + + // Check for illegal surrogate words + const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800); + const __m128i forbidden_bytemask = _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_d800); + if (static_cast(_mm_movemask_epi8(forbidden_bytemask)) != 0) { + return std::make_pair(result(error_code::SURROGATE, buf - start), utf8_output); + } + + const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606, + 0x0808, 0x0a0a, 0x0c0c, 0x0e0e); + + /* In this branch we handle three cases: + 1. [0000|0000|0ccc|cccc] => [0ccc|cccc] - single UFT-8 byte + 2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc] - two UTF-8 bytes + 3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] - three UTF-8 bytes + + We expand the input word (16-bit) into two words (32-bit), thus + we have room for four bytes. However, we need five distinct bit + layouts. Note that the last byte in cases #2 and #3 is the same. + + We precompute byte 1 for case #1 and the common byte for cases #2 & #3 + in register t2. + + We precompute byte 1 for case #3 and -- **conditionally** -- precompute + either byte 1 for case #2 or byte 2 for case #3. Note that they + differ by exactly one bit. + + Finally from these two words we build proper UTF-8 sequence, taking + into account the case (i.e, the number of bytes to write). + */ + /** + * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce: + * t2 => [0ccc|cccc] [10cc|cccc] + * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb]) + */ +#define simdutf_vec(x) _mm_set1_epi16(static_cast(x)) + // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc] + const __m128i t0 = _mm_shuffle_epi8(in_16, dup_even); + // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc] + const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111)); + // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc] + const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000)); + + // [aaaa|bbbb|bbcc|cccc] => [0000|aaaa|bbbb|bbcc] + const __m128i s0 = _mm_srli_epi16(in_16, 4); + // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00] + const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100)); + // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa] + const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140)); + // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa] + const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000)); + const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask, simdutf_vec(0b0100000000000000)); + const __m128i s4 = _mm_xor_si128(s3, m0); +#undef simdutf_vec + + // 4. expand words 16-bit => 32-bit + const __m128i out0 = _mm_unpacklo_epi16(t2, s4); + const __m128i out1 = _mm_unpackhi_epi16(t2, s4); + + // 5. compress 32-bit words into 1, 2 or 3 bytes -- 2 x shuffle + const uint16_t mask = (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa); + if (mask == 0) { + // We only have three-byte words. Use fast path. + const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14, 15, 13, -1, -1, -1, -1); + const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle); + const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle); + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += 12; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += 12; + buf += 8; + continue; + } + const uint8_t mask0 = uint8_t(mask); + + const uint8_t* row0 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0]; + const __m128i shuffle0 = _mm_loadu_si128((__m128i*)(row0 + 1)); + const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0); + + const uint8_t mask1 = static_cast(mask >> 8); + + const uint8_t* row1 = &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0]; + const __m128i shuffle1 = _mm_loadu_si128((__m128i*)(row1 + 1)); + const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1); + + _mm_storeu_si128((__m128i*)utf8_output, utf8_0); + utf8_output += row0[0]; + _mm_storeu_si128((__m128i*)utf8_output, utf8_1); + utf8_output += row1[0]; + + buf += 8; + } else { + // case: at least one 32-bit word produce a surrogate pair in UTF-16 <=> will produce four UTF-8 bytes + // Let us do a scalar fallback. + // It may seem wasteful to use scalar code, but being efficient with SIMD + // in the presence of surrogate pairs may require non-trivial tables. + size_t forward = 15; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFFFF80) == 0) { + *utf8_output++ = char(word); + } else if ((word & 0xFFFFF800) == 0) { + *utf8_output++ = char((word >> 6) | 0b11000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else if ((word & 0xFFFF0000) == 0) { + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf8_output); + } + *utf8_output++ = char((word >> 12) | 0b11100000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } else { + if (word > 0x10FFFF) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf8_output); + } + *utf8_output++ = char((word >> 18) | 0b11110000); + *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000); + *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000); + *utf8_output++ = char((word & 0b111111) | 0b10000000); + } + } + buf += k; + } + } // while - return std::make_pair(buf, utf16_output); + return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output); } +/* end file src/westmere/sse_convert_utf32_to_utf8.cpp */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=westmere/sse_convert_utf32_to_utf16.cpp +/* begin file src/westmere/sse_convert_utf32_to_utf16.cpp */ +template +std::pair sse_convert_utf32_to_utf16(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + + const char32_t* end = buf + len; + + const __m128i v_0000 = _mm_setzero_si128(); + const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000); + __m128i forbidden_bytemask = _mm_setzero_si128(); + while (buf + 8 <= end) { + __m128i in = _mm_loadu_si128((__m128i*)buf); + __m128i nextin = _mm_loadu_si128((__m128i*)buf + 1); + const __m128i saturation_bytemask = _mm_cmpeq_epi32(_mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000); + const uint32_t saturation_bitmask = static_cast(_mm_movemask_epi8(saturation_bytemask)); + + // Check if no bits set above 16th + if (saturation_bitmask == 0xffff) { + // Pack UTF-32 to UTF-16 + __m128i utf16_packed = _mm_packus_epi32(in, nextin); + + const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); + const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800); + forbidden_bytemask = _mm_or_si128(forbidden_bytemask, _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800)); + + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); + } + + _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); + utf16_output += 8; + buf += 8; + } else { + size_t forward = 7; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(nullptr, utf16_output); + } + *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return std::make_pair(nullptr, utf16_output); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (big_endian) { + high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); + low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + } + buf += k; + } + } -template -std::pair sse_convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) { - const char32_t* start = buf; - const char32_t* end = buf + len; + // check for invalid input + if (static_cast(_mm_movemask_epi8(forbidden_bytemask)) != 0) { + return std::make_pair(nullptr, utf16_output); + } - const __m128i v_0000 = _mm_setzero_si128(); - const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000); + return std::make_pair(buf, utf16_output); +} - while (buf + 8 <= end) { - __m128i in = _mm_loadu_si128((__m128i*)buf); - __m128i nextin = _mm_loadu_si128((__m128i*)buf+1); - const __m128i saturation_bytemask = _mm_cmpeq_epi32(_mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000); - const uint32_t saturation_bitmask = static_cast(_mm_movemask_epi8(saturation_bytemask)); +template +std::pair sse_convert_utf32_to_utf16_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) +{ + const char32_t* start = buf; + const char32_t* end = buf + len; - // Check if no bits set above 16th - if (saturation_bitmask == 0xffff) { - // Pack UTF-32 to UTF-16 - __m128i utf16_packed = _mm_packus_epi32(in, nextin); + const __m128i v_0000 = _mm_setzero_si128(); + const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000); - const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); - const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800); - const __m128i forbidden_bytemask = _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800); - if (static_cast(_mm_movemask_epi8(forbidden_bytemask)) != 0) { - return std::make_pair(result(error_code::SURROGATE, buf - start), utf16_output); - } + while (buf + 8 <= end) { + __m128i in = _mm_loadu_si128((__m128i*)buf); + __m128i nextin = _mm_loadu_si128((__m128i*)buf + 1); + const __m128i saturation_bytemask = _mm_cmpeq_epi32(_mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000); + const uint32_t saturation_bitmask = static_cast(_mm_movemask_epi8(saturation_bytemask)); + + // Check if no bits set above 16th + if (saturation_bitmask == 0xffff) { + // Pack UTF-32 to UTF-16 + __m128i utf16_packed = _mm_packus_epi32(in, nextin); + + const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); + const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800); + const __m128i forbidden_bytemask = _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800); + if (static_cast(_mm_movemask_epi8(forbidden_bytemask)) != 0) { + return std::make_pair(result(error_code::SURROGATE, buf - start), utf16_output); + } - if (big_endian) { - const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); - utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); - } + if (big_endian) { + const __m128i swap = _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); + utf16_packed = _mm_shuffle_epi8(utf16_packed, swap); + } - _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); - utf16_output += 8; - buf += 8; - } else { - size_t forward = 7; - size_t k = 0; - if(size_t(end - buf) < forward + 1) { forward = size_t(end - buf - 1);} - for(; k < forward; k++) { - uint32_t word = buf[k]; - if((word & 0xFFFF0000)==0) { - // will not generate a surrogate pair - if (word >= 0xD800 && word <= 0xDFFF) { return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf16_output); } - *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + _mm_storeu_si128((__m128i*)utf16_output, utf16_packed); + utf16_output += 8; + buf += 8; } else { - // will generate a surrogate pair - if (word > 0x10FFFF) { return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf16_output); } - word -= 0x10000; - uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); - uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); - if (big_endian) { - high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); - low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); - } - *utf16_output++ = char16_t(high_surrogate); - *utf16_output++ = char16_t(low_surrogate); + size_t forward = 7; + size_t k = 0; + if (size_t(end - buf) < forward + 1) { + forward = size_t(end - buf - 1); + } + for (; k < forward; k++) { + uint32_t word = buf[k]; + if ((word & 0xFFFF0000) == 0) { + // will not generate a surrogate pair + if (word >= 0xD800 && word <= 0xDFFF) { + return std::make_pair(result(error_code::SURROGATE, buf - start + k), utf16_output); + } + *utf16_output++ = big_endian ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8)) : char16_t(word); + } else { + // will generate a surrogate pair + if (word > 0x10FFFF) { + return std::make_pair(result(error_code::TOO_LARGE, buf - start + k), utf16_output); + } + word -= 0x10000; + uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10)); + uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF)); + if (big_endian) { + high_surrogate = uint16_t((high_surrogate >> 8) | (high_surrogate << 8)); + low_surrogate = uint16_t((low_surrogate >> 8) | (low_surrogate << 8)); + } + *utf16_output++ = char16_t(high_surrogate); + *utf16_output++ = char16_t(low_surrogate); + } + } + buf += k; } - } - buf += k; } - } - return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output); + return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output); } /* end file src/westmere/sse_convert_utf32_to_utf16.cpp */ @@ -26668,7 +30114,7 @@ std::pair sse_convert_utf32_to_utf16_with_errors(const char32 } // namespace westmere } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/buf_block_reader.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/buf_block_reader.h /* begin file src/generic/buf_block_reader.h */ namespace simdutf { namespace westmere { @@ -26678,92 +30124,110 @@ namespace { template struct buf_block_reader { public: - simdutf_really_inline buf_block_reader(const uint8_t *_buf, size_t _len); - simdutf_really_inline size_t block_index(); - simdutf_really_inline bool has_full_block() const; - simdutf_really_inline const uint8_t *full_block() const; - /** - * Get the last block, padded with spaces. - * - * There will always be a last block, with at least 1 byte, unless len == 0 (in which case this - * function fills the buffer with spaces and returns 0. In particular, if len == STEP_SIZE there - * will be 0 full_blocks and 1 remainder block with STEP_SIZE bytes and no spaces for padding. - * - * @return the number of effective characters in the last block. - */ - simdutf_really_inline size_t get_remainder(uint8_t *dst) const; - simdutf_really_inline void advance(); + simdutf_really_inline buf_block_reader(const uint8_t* _buf, size_t _len); + simdutf_really_inline size_t block_index(); + simdutf_really_inline bool has_full_block() const; + simdutf_really_inline const uint8_t* full_block() const; + /** + * Get the last block, padded with spaces. + * + * There will always be a last block, with at least 1 byte, unless len == 0 (in which case this + * function fills the buffer with spaces and returns 0. In particular, if len == STEP_SIZE there + * will be 0 full_blocks and 1 remainder block with STEP_SIZE bytes and no spaces for padding. + * + * @return the number of effective characters in the last block. + */ + simdutf_really_inline size_t get_remainder(uint8_t* dst) const; + simdutf_really_inline void advance(); + private: - const uint8_t *buf; - const size_t len; - const size_t lenminusstep; - size_t idx; + const uint8_t* buf; + const size_t len; + const size_t lenminusstep; + size_t idx; }; // Routines to print masks and text for debugging bitmask operations -simdutf_unused static char * format_input_text_64(const uint8_t *text) { - static char *buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); - for (size_t i=0; i); i++) { - buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); - } - buf[sizeof(simd8x64)] = '\0'; - return buf; +simdutf_unused static char* format_input_text_64(const uint8_t* text) +{ + static char* buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); + for (size_t i = 0; i < sizeof(simd8x64); i++) { + buf[i] = int8_t(text[i]) < ' ' ? '_' : int8_t(text[i]); + } + buf[sizeof(simd8x64)] = '\0'; + return buf; } // Routines to print masks and text for debugging bitmask operations -simdutf_unused static char * format_input_text(const simd8x64& in) { - static char *buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); - in.store(reinterpret_cast(buf)); - for (size_t i=0; i); i++) { - if (buf[i] < ' ') { buf[i] = '_'; } - } - buf[sizeof(simd8x64)] = '\0'; - return buf; +simdutf_unused static char* format_input_text(const simd8x64& in) +{ + static char* buf = reinterpret_cast(malloc(sizeof(simd8x64) + 1)); + in.store(reinterpret_cast(buf)); + for (size_t i = 0; i < sizeof(simd8x64); i++) { + if (buf[i] < ' ') { + buf[i] = '_'; + } + } + buf[sizeof(simd8x64)] = '\0'; + return buf; } -simdutf_unused static char * format_mask(uint64_t mask) { - static char *buf = reinterpret_cast(malloc(64 + 1)); - for (size_t i=0; i<64; i++) { - buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; - } - buf[64] = '\0'; - return buf; +simdutf_unused static char* format_mask(uint64_t mask) +{ + static char* buf = reinterpret_cast(malloc(64 + 1)); + for (size_t i = 0; i < 64; i++) { + buf[i] = (mask & (size_t(1) << i)) ? 'X' : ' '; + } + buf[64] = '\0'; + return buf; } template -simdutf_really_inline buf_block_reader::buf_block_reader(const uint8_t *_buf, size_t _len) : buf{_buf}, len{_len}, lenminusstep{len < STEP_SIZE ? 0 : len - STEP_SIZE}, idx{0} {} +simdutf_really_inline buf_block_reader::buf_block_reader(const uint8_t* _buf, size_t _len) + : buf { _buf } + , len { _len } + , lenminusstep { len < STEP_SIZE ? 0 : len - STEP_SIZE } + , idx { 0 } +{ +} template simdutf_really_inline size_t buf_block_reader::block_index() { return idx; } template -simdutf_really_inline bool buf_block_reader::has_full_block() const { - return idx < lenminusstep; +simdutf_really_inline bool buf_block_reader::has_full_block() const +{ + return idx < lenminusstep; } template -simdutf_really_inline const uint8_t *buf_block_reader::full_block() const { - return &buf[idx]; +simdutf_really_inline const uint8_t* buf_block_reader::full_block() const +{ + return &buf[idx]; } template -simdutf_really_inline size_t buf_block_reader::get_remainder(uint8_t *dst) const { - if(len == idx) { return 0; } // memcpy(dst, null, 0) will trigger an error with some sanitizers - std::memset(dst, 0x20, STEP_SIZE); // std::memset STEP_SIZE because it's more efficient to write out 8 or 16 bytes at once. - std::memcpy(dst, buf + idx, len - idx); - return len - idx; +simdutf_really_inline size_t buf_block_reader::get_remainder(uint8_t* dst) const +{ + if (len == idx) { + return 0; + } // memcpy(dst, null, 0) will trigger an error with some sanitizers + std::memset(dst, 0x20, STEP_SIZE); // std::memset STEP_SIZE because it's more efficient to write out 8 or 16 bytes at once. + std::memcpy(dst, buf + idx, len - idx); + return len - idx; } template -simdutf_really_inline void buf_block_reader::advance() { - idx += STEP_SIZE; +simdutf_really_inline void buf_block_reader::advance() +{ + idx += STEP_SIZE; } } // unnamed namespace } // namespace westmere } // namespace simdutf /* end file src/generic/buf_block_reader.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_validation/utf8_lookup4_algorithm.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_validation/utf8_lookup4_algorithm.h /* begin file src/generic/utf8_validation/utf8_lookup4_algorithm.h */ namespace simdutf { namespace westmere { @@ -26772,21 +30236,22 @@ namespace utf8_validation { using namespace simd; - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -26794,101 +30259,92 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } +} - // - // Return nonzero if there are incomplete multibyte characters at the end of the block: - // e.g. if there is a 4-byte character, but it's 3 bytes from the end. - // - simdutf_really_inline simd8 is_incomplete(const simd8 input) { +// +// Return nonzero if there are incomplete multibyte characters at the end of the block: +// e.g. if there is a 4-byte character, but it's 3 bytes from the end. +// +simdutf_really_inline simd8 is_incomplete(const simd8 input) +{ // If the previous input's last 3 bytes match this, they're too short (they ended at EOF): // ... 1111____ 111_____ 11______ static const uint8_t max_array[32] = { - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 0b11110000u-1, 0b11100000u-1, 0b11000000u-1 + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 0b11110000u - 1, 0b11100000u - 1, 0b11000000u - 1 }; - const simd8 max_value(&max_array[sizeof(max_array)-sizeof(simd8)]); + const simd8 max_value(&max_array[sizeof(max_array) - sizeof(simd8)]); return input.gt_bits(max_value); - } +} - struct utf8_checker { +struct utf8_checker { // If this is nonzero, there has been a UTF-8 error. simd8 error; // The last input we received @@ -26899,51 +30355,54 @@ using namespace simd; // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); } // The only problem that can happen at EOF is that a multibyte character is too short // or a byte value too large in the last bytes: check_special_cases only checks for bytes // too large in the first of two bytes. - simdutf_really_inline void check_eof() { - // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't - // possibly finish them. - this->error |= this->prev_incomplete; + simdutf_really_inline void check_eof() + { + // If the previous block had incomplete UTF-8 characters at the end, an ASCII block can't + // possibly finish them. + this->error |= this->prev_incomplete; } - simdutf_really_inline void check_next_input(const simd8x64& input) { - if(simdutf_likely(is_ascii(input))) { - this->error |= this->prev_incomplete; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], this->prev_input_block); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + simdutf_really_inline void check_next_input(const simd8x64& input) + { + if (simdutf_likely(is_ascii(input))) { + this->error |= this->prev_incomplete; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], this->prev_input_block); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + this->prev_incomplete = is_incomplete(input.chunks[simd8x64::NUM_CHUNKS - 1]); + this->prev_input_block = input.chunks[simd8x64::NUM_CHUNKS - 1]; } - this->prev_incomplete = is_incomplete(input.chunks[simd8x64::NUM_CHUNKS-1]); - this->prev_input_block = input.chunks[simd8x64::NUM_CHUNKS-1]; - - } } // do not forget to call check_eof! - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // namespace utf8_validation using utf8_validation::utf8_checker; @@ -26952,7 +30411,7 @@ using utf8_validation::utf8_checker; } // namespace westmere } // namespace simdutf /* end file src/generic/utf8_validation/utf8_lookup4_algorithm.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_validation/utf8_validator.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_validation/utf8_validator.h /* begin file src/generic/utf8_validation/utf8_validator.h */ namespace simdutf { namespace westmere { @@ -26963,15 +30422,16 @@ namespace utf8_validation { * Validates that the string is actual UTF-8. */ template -bool generic_validate_utf8(const uint8_t * input, size_t length) { - checker c{}; +bool generic_validate_utf8(const uint8_t* input, size_t length) +{ + checker c {}; buf_block_reader<64> reader(input, length); while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - c.check_next_input(in); - reader.advance(); + simd::simd8x64 in(reader.full_block()); + c.check_next_input(in); + reader.advance(); } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); c.check_next_input(in); @@ -26980,97 +30440,106 @@ bool generic_validate_utf8(const uint8_t * input, size_t length) { return !c.errors(); } -bool generic_validate_utf8(const char * input, size_t length) { - return generic_validate_utf8(reinterpret_cast(input),length); +bool generic_validate_utf8(const char* input, size_t length) +{ + return generic_validate_utf8(reinterpret_cast(input), length); } /** * Validates that the string is actual UTF-8 and stops on errors. */ template -result generic_validate_utf8_with_errors(const uint8_t * input, size_t length) { - checker c{}; +result generic_validate_utf8_with_errors(const uint8_t* input, size_t length) +{ + checker c {}; buf_block_reader<64> reader(input, length); - size_t count{0}; + size_t count { 0 }; while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - c.check_next_input(in); - if(c.errors()) { - if (count != 0) { count--; } // Sometimes the error is only detected in the next chunk - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input + count), length - count); - res.count += count; - return res; - } - reader.advance(); - count += 64; + simd::simd8x64 in(reader.full_block()); + c.check_next_input(in); + if (c.errors()) { + if (count != 0) { + count--; + } // Sometimes the error is only detected in the next chunk + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input + count), length - count); + res.count += count; + return res; + } + reader.advance(); + count += 64; } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); c.check_next_input(in); reader.advance(); c.check_eof(); if (c.errors()) { - result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input) + count, length - count); - res.count += count; - return res; + result res = scalar::utf8::rewind_and_validate_with_errors(reinterpret_cast(input) + count, length - count); + res.count += count; + return res; } else { - return result(error_code::SUCCESS, length); + return result(error_code::SUCCESS, length); } } -result generic_validate_utf8_with_errors(const char * input, size_t length) { - return generic_validate_utf8_with_errors(reinterpret_cast(input),length); +result generic_validate_utf8_with_errors(const char* input, size_t length) +{ + return generic_validate_utf8_with_errors(reinterpret_cast(input), length); } template -bool generic_validate_ascii(const uint8_t * input, size_t length) { +bool generic_validate_ascii(const uint8_t* input, size_t length) +{ buf_block_reader<64> reader(input, length); - uint8_t blocks[64]{}; + uint8_t blocks[64] {}; simd::simd8x64 running_or(blocks); while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - running_or |= in; - reader.advance(); + simd::simd8x64 in(reader.full_block()); + running_or |= in; + reader.advance(); } - uint8_t block[64]{}; + uint8_t block[64] {}; reader.get_remainder(block); simd::simd8x64 in(block); running_or |= in; return running_or.is_ascii(); } -bool generic_validate_ascii(const char * input, size_t length) { - return generic_validate_ascii(reinterpret_cast(input),length); +bool generic_validate_ascii(const char* input, size_t length) +{ + return generic_validate_ascii(reinterpret_cast(input), length); } template -result generic_validate_ascii_with_errors(const uint8_t * input, size_t length) { - buf_block_reader<64> reader(input, length); - size_t count{0}; - while (reader.has_full_block()) { - simd::simd8x64 in(reader.full_block()); - if (!in.is_ascii()) { - result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); - return result(res.error, count + res.count); - } - reader.advance(); +result generic_validate_ascii_with_errors(const uint8_t* input, size_t length) +{ + buf_block_reader<64> reader(input, length); + size_t count { 0 }; + while (reader.has_full_block()) { + simd::simd8x64 in(reader.full_block()); + if (!in.is_ascii()) { + result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); + return result(res.error, count + res.count); + } + reader.advance(); - count += 64; - } - uint8_t block[64]{}; - reader.get_remainder(block); - simd::simd8x64 in(block); - if (!in.is_ascii()) { - result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); - return result(res.error, count + res.count); - } else { - return result(error_code::SUCCESS, length); - } + count += 64; + } + uint8_t block[64] {}; + reader.get_remainder(block); + simd::simd8x64 in(block); + if (!in.is_ascii()) { + result res = scalar::ascii::validate_with_errors(reinterpret_cast(input + count), length - count); + return result(res.error, count + res.count); + } else { + return result(error_code::SUCCESS, length); + } } -result generic_validate_ascii_with_errors(const char * input, size_t length) { - return generic_validate_ascii_with_errors(reinterpret_cast(input),length); +result generic_validate_ascii_with_errors(const char* input, size_t length) +{ + return generic_validate_ascii_with_errors(reinterpret_cast(input), length); } } // namespace utf8_validation @@ -27079,10 +30548,9 @@ result generic_validate_ascii_with_errors(const char * input, size_t length) { } // namespace simdutf /* end file src/generic/utf8_validation/utf8_validator.h */ // transcoding from UTF-8 to UTF-16 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf16/valid_utf8_to_utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf16/valid_utf8_to_utf16.h /* begin file src/generic/utf8_to_utf16/valid_utf8_to_utf16.h */ - namespace simdutf { namespace westmere { namespace { @@ -27090,63 +30558,64 @@ namespace utf8_to_utf16 { using namespace simd; -template +template simdutf_warn_unused size_t convert_valid(const char* input, size_t size, - char16_t* utf16_output) noexcept { - // The implementation is not specific to haswell and should be moved to the generic directory. - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - // this loop could be unrolled further. For example, we could process the mask - // far more than 64 bytes. - simd8x64 in(reinterpret_cast(input + pos)); - if(in.is_ascii()) { - in.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // Slow path. We hope that the compiler will recognize that this is a slow path. - // Anything that is not a continuation mask is a 'leading byte', that is, the - // start of a new code point. - uint64_t utf8_continuation_mask = in.lt(-65 + 1); - // -65 is 0b10111111 in two-complement's, so largest possible continuation byte - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - // The *start* of code points is not so useful, rather, we want the *end* of code points. - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times when using solely - // the slow/regular path, and at least four times if there are fast paths. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - // - // Thus we may allow convert_masked_utf8_to_utf16 to process - // more bytes at a time under a fast-path mode where 16 bytes - // are consumed at once (e.g., when encountering ASCII). - size_t consumed = convert_masked_utf8_to_utf16(input + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - utf16_output += scalar::utf8_to_utf16::convert_valid(input + pos, size - pos, utf16_output); - return utf16_output - start; + char16_t* utf16_output) noexcept +{ + // The implementation is not specific to haswell and should be moved to the generic directory. + size_t pos = 0; + char16_t* start { utf16_output }; + const size_t safety_margin = 16; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + // this loop could be unrolled further. For example, we could process the mask + // far more than 64 bytes. + simd8x64 in(reinterpret_cast(input + pos)); + if (in.is_ascii()) { + in.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // Slow path. We hope that the compiler will recognize that this is a slow path. + // Anything that is not a continuation mask is a 'leading byte', that is, the + // start of a new code point. + uint64_t utf8_continuation_mask = in.lt(-65 + 1); + // -65 is 0b10111111 in two-complement's, so largest possible continuation byte + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + // The *start* of code points is not so useful, rather, we want the *end* of code points. + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times when using solely + // the slow/regular path, and at least four times if there are fast paths. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + // + // Thus we may allow convert_masked_utf8_to_utf16 to process + // more bytes at a time under a fast-path mode where 16 bytes + // are consumed at once (e.g., when encountering ASCII). + size_t consumed = convert_masked_utf8_to_utf16(input + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + utf16_output += scalar::utf8_to_utf16::convert_valid(input + pos, size - pos, utf16_output); + return utf16_output - start; } } // namespace utf8_to_utf16 @@ -27154,32 +30623,31 @@ simdutf_warn_unused size_t convert_valid(const char* input, size_t size, } // namespace westmere } // namespace simdutf /* end file src/generic/utf8_to_utf16/valid_utf8_to_utf16.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf16/utf8_to_utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf16/utf8_to_utf16.h /* begin file src/generic/utf8_to_utf16/utf8_to_utf16.h */ - namespace simdutf { namespace westmere { namespace { namespace utf8_to_utf16 { using namespace simd; - - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -27187,258 +30655,281 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } - +} - struct validating_transcoder { +struct validating_transcoder { // If this is nonzero, there has been a UTF-8 error. simd8 error; - validating_transcoder() : error(uint8_t(0)) {} + validating_transcoder() + : error(uint8_t(0)) + { + } // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); - } - - - template - simdutf_really_inline size_t convert(const char* in, size_t size, char16_t* utf16_output) { - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf16(in + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { return 0; } - if(pos < size) { - size_t howmany = scalar::utf8_to_utf16::convert(in + pos, size - pos, utf16_output); - if(howmany == 0) { return 0; } - utf16_output += howmany; - } - return utf16_output - start; - } - - template - simdutf_really_inline result convert_with_errors(const char* in, size_t size, char16_t* utf16_output) { - size_t pos = 0; - char16_t* start{utf16_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf16(utf16_output); - utf16_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - if (errors()) { + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); + } + + template + simdutf_really_inline size_t convert(const char* in, size_t size, char16_t* utf16_output) + { + size_t pos = 0; + char16_t* start { utf16_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 8 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 8; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the eight last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf16(in + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { + return 0; + } + if (pos < size) { + size_t howmany = scalar::utf8_to_utf16::convert(in + pos, size - pos, utf16_output); + if (howmany == 0) { + return 0; + } + utf16_output += howmany; + } + return utf16_output - start; + } + + template + simdutf_really_inline result convert_with_errors(const char* in, size_t size, char16_t* utf16_output) + { + size_t pos = 0; + char16_t* start { utf16_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 8 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 8; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the eight last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf16(utf16_output); + utf16_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + if (errors()) { + // rewind_and_convert_with_errors will seek a potential error from in+pos onward, + // with the ability to go back up to pos bytes, and read size-pos bytes forward. + result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); + res.count += pos; + return res; + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf16(in + pos, + utf8_end_of_code_point_mask, utf16_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { // rewind_and_convert_with_errors will seek a potential error from in+pos onward, // with the ability to go back up to pos bytes, and read size-pos bytes forward. result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); res.count += pos; return res; - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf16(in + pos, - utf8_end_of_code_point_mask, utf16_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { - // rewind_and_convert_with_errors will seek a potential error from in+pos onward, - // with the ability to go back up to pos bytes, and read size-pos bytes forward. - result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); - res.count += pos; - return res; - } - if(pos < size) { - // rewind_and_convert_with_errors will seek a potential error from in+pos onward, - // with the ability to go back up to pos bytes, and read size-pos bytes forward. - result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); - if (res.error) { // In case of error, we want the error position - res.count += pos; - return res; - } else { // In case of success, we want the number of word written - utf16_output += res.count; } - } - return result(error_code::SUCCESS, utf16_output - start); + if (pos < size) { + // rewind_and_convert_with_errors will seek a potential error from in+pos onward, + // with the ability to go back up to pos bytes, and read size-pos bytes forward. + result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf16_output); + if (res.error) { // In case of error, we want the error position + res.count += pos; + return res; + } else { // In case of success, we want the number of word written + utf16_output += res.count; + } + } + return result(error_code::SUCCESS, utf16_output - start); } - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // utf8_to_utf16 namespace } // unnamed namespace } // namespace westmere } // namespace simdutf /* end file src/generic/utf8_to_utf16/utf8_to_utf16.h */ // transcoding from UTF-8 to UTF-32 -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf32/valid_utf8_to_utf32.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf32/valid_utf8_to_utf32.h /* begin file src/generic/utf8_to_utf32/valid_utf8_to_utf32.h */ namespace simdutf { @@ -27448,68 +30939,66 @@ namespace utf8_to_utf32 { using namespace simd; - simdutf_warn_unused size_t convert_valid(const char* input, size_t size, - char32_t* utf32_output) noexcept { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 in(reinterpret_cast(input + pos)); - if(in.is_ascii()) { - in.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // -65 is 0b10111111 in two-complement's, so largest possible continuation byte - uint64_t utf8_continuation_mask = in.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - size_t max_starting_point = (pos + 64) - 12; - while(pos < max_starting_point) { - size_t consumed = convert_masked_utf8_to_utf32(input + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } + char32_t* utf32_output) noexcept +{ + size_t pos = 0; + char32_t* start { utf32_output }; + const size_t safety_margin = 16; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 in(reinterpret_cast(input + pos)); + if (in.is_ascii()) { + in.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // -65 is 0b10111111 in two-complement's, so largest possible continuation byte + uint64_t utf8_continuation_mask = in.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + size_t max_starting_point = (pos + 64) - 12; + while (pos < max_starting_point) { + size_t consumed = convert_masked_utf8_to_utf32(input + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + } } - } - utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos, utf32_output); - return utf32_output - start; + utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos, utf32_output); + return utf32_output - start; } - } // namespace utf8_to_utf32 } // unnamed namespace } // namespace westmere } // namespace simdutf /* end file src/generic/utf8_to_utf32/valid_utf8_to_utf32.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8_to_utf32/utf8_to_utf32.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8_to_utf32/utf8_to_utf32.h /* begin file src/generic/utf8_to_utf32/utf8_to_utf32.h */ - namespace simdutf { namespace westmere { namespace { namespace utf8_to_utf32 { using namespace simd; - - simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) { -// Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) -// Bit 1 = Too Long (ASCII followed by continuation) -// Bit 2 = Overlong 3-byte -// Bit 4 = Surrogate -// Bit 5 = Overlong 2-byte -// Bit 7 = Two Continuations - constexpr const uint8_t TOO_SHORT = 1<<0; // 11______ 0_______ +simdutf_really_inline simd8 check_special_cases(const simd8 input, const simd8 prev1) +{ + // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII) + // Bit 1 = Too Long (ASCII followed by continuation) + // Bit 2 = Overlong 3-byte + // Bit 4 = Surrogate + // Bit 5 = Overlong 2-byte + // Bit 7 = Two Continuations + constexpr const uint8_t TOO_SHORT = 1 << 0; // 11______ 0_______ // 11______ 11______ - constexpr const uint8_t TOO_LONG = 1<<1; // 0_______ 10______ - constexpr const uint8_t OVERLONG_3 = 1<<2; // 11100000 100_____ - constexpr const uint8_t SURROGATE = 1<<4; // 11101101 101_____ - constexpr const uint8_t OVERLONG_2 = 1<<5; // 1100000_ 10______ - constexpr const uint8_t TWO_CONTS = 1<<7; // 10______ 10______ - constexpr const uint8_t TOO_LARGE = 1<<3; // 11110100 1001____ + constexpr const uint8_t TOO_LONG = 1 << 1; // 0_______ 10______ + constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____ + constexpr const uint8_t SURROGATE = 1 << 4; // 11101101 101_____ + constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______ + constexpr const uint8_t TWO_CONTS = 1 << 7; // 10______ 10______ + constexpr const uint8_t TOO_LARGE = 1 << 3; // 11110100 1001____ // 11110100 101_____ // 11110101 1001____ // 11110101 101_____ @@ -27517,251 +31006,273 @@ using namespace simd; // 1111011_ 101_____ // 11111___ 1001____ // 11111___ 101_____ - constexpr const uint8_t TOO_LARGE_1000 = 1<<6; - // 11110101 1000____ - // 1111011_ 1000____ - // 11111___ 1000____ - constexpr const uint8_t OVERLONG_4 = 1<<6; // 11110000 1000____ + constexpr const uint8_t TOO_LARGE_1000 = 1 << 6; + // 11110101 1000____ + // 1111011_ 1000____ + // 11111___ 1000____ + constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____ const simd8 byte_1_high = prev1.shr<4>().lookup_16( - // 0_______ ________ - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, - // 10______ ________ - TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, - // 1100____ ________ - TOO_SHORT | OVERLONG_2, - // 1101____ ________ - TOO_SHORT, - // 1110____ ________ - TOO_SHORT | OVERLONG_3 | SURROGATE, - // 1111____ ________ - TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4 - ); + // 0_______ ________ + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, + // 10______ ________ + TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS, + // 1100____ ________ + TOO_SHORT | OVERLONG_2, + // 1101____ ________ + TOO_SHORT, + // 1110____ ________ + TOO_SHORT | OVERLONG_3 | SURROGATE, + // 1111____ ________ + TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4); constexpr const uint8_t CARRY = TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 . const simd8 byte_1_low = (prev1 & 0x0F).lookup_16( - // ____0000 ________ - CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, - // ____0001 ________ - CARRY | OVERLONG_2, - // ____001_ ________ - CARRY, - CARRY, - - // ____0100 ________ - CARRY | TOO_LARGE, - // ____0101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____011_ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - - // ____1___ ________ - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000, - // ____1101 ________ - CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, - CARRY | TOO_LARGE | TOO_LARGE_1000, - CARRY | TOO_LARGE | TOO_LARGE_1000 - ); + // ____0000 ________ + CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4, + // ____0001 ________ + CARRY | OVERLONG_2, + // ____001_ ________ + CARRY, CARRY, + + // ____0100 ________ + CARRY | TOO_LARGE, + // ____0101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____011_ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + + // ____1___ ________ + CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000, + // ____1101 ________ + CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE, CARRY | TOO_LARGE | TOO_LARGE_1000, CARRY | TOO_LARGE | TOO_LARGE_1000); const simd8 byte_2_high = input.shr<4>().lookup_16( - // ________ 0_______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, - - // ________ 1000____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, - // ________ 1001____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, - // ________ 101_____ - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, - - // ________ 11______ - TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT - ); + // ________ 0_______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, + + // ________ 1000____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 | OVERLONG_4, + // ________ 1001____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE, + // ________ 101_____ + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE, + + // ________ 11______ + TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT); return (byte_1_high & byte_1_low & byte_2_high); - } - simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, - const simd8 prev_input, const simd8 sc) { +} +simdutf_really_inline simd8 check_multibyte_lengths(const simd8 input, + const simd8 prev_input, const simd8 sc) +{ simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; - } - +} - struct validating_transcoder { +struct validating_transcoder { // If this is nonzero, there has been a UTF-8 error. simd8 error; - validating_transcoder() : error(uint8_t(0)) {} + validating_transcoder() + : error(uint8_t(0)) + { + } // // Check whether the current bytes are valid UTF-8. // - simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) { - // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes - // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) - simd8 prev1 = input.prev<1>(prev_input); - simd8 sc = check_special_cases(input, prev1); - this->error |= check_multibyte_lengths(input, prev_input, sc); - } - - - - simdutf_really_inline size_t convert(const char* in, size_t size, char32_t* utf32_output) { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf32(in + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { return 0; } - if(pos < size) { - size_t howmany = scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output); - if(howmany == 0) { return 0; } - utf32_output += howmany; - } - return utf32_output - start; - } - - simdutf_really_inline result convert_with_errors(const char* in, size_t size, char32_t* utf32_output) { - size_t pos = 0; - char32_t* start{utf32_output}; - const size_t safety_margin = 16; // to avoid overruns! - while(pos + 64 + safety_margin <= size) { - simd8x64 input(reinterpret_cast(in + pos)); - if(input.is_ascii()) { - input.store_ascii_as_utf32(utf32_output); - utf32_output += 64; - pos += 64; - } else { - // you might think that a for-loop would work, but under Visual Studio, it is not good enough. - static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), - "We support either two or four chunks per 64-byte block."); - auto zero = simd8{uint8_t(0)}; - if(simd8x64::NUM_CHUNKS == 2) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - } else if(simd8x64::NUM_CHUNKS == 4) { - this->check_utf8_bytes(input.chunks[0], zero); - this->check_utf8_bytes(input.chunks[1], input.chunks[0]); - this->check_utf8_bytes(input.chunks[2], input.chunks[1]); - this->check_utf8_bytes(input.chunks[3], input.chunks[2]); - } - if (errors()) { + simdutf_really_inline void check_utf8_bytes(const simd8 input, const simd8 prev_input) + { + // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+ lead bytes + // (2, 3, 4-byte leads become large positive numbers instead of small negative numbers) + simd8 prev1 = input.prev<1>(prev_input); + simd8 sc = check_special_cases(input, prev1); + this->error |= check_multibyte_lengths(input, prev_input, sc); + } + + simdutf_really_inline size_t convert(const char* in, size_t size, char32_t* utf32_output) + { + size_t pos = 0; + char32_t* start { utf32_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 4 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 4; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the fourth last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf32(in + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { + return 0; + } + if (pos < size) { + size_t howmany = scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output); + if (howmany == 0) { + return 0; + } + utf32_output += howmany; + } + return utf32_output - start; + } + + simdutf_really_inline result convert_with_errors(const char* in, size_t size, char32_t* utf32_output) + { + size_t pos = 0; + char32_t* start { utf32_output }; + // In the worst case, we have the haswell kernel which can cause an overflow of + // 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the last 16 bytes, + // and if the data is valid, then it is entirely safe because 16 UTF-8 bytes generate + // much more than 8 bytes. However, you cannot generally assume that you have valid + // UTF-8 input, so we are going to go back from the end counting 4 leading bytes, + // to give us a good margin. + size_t leading_byte = 0; + size_t margin = size; + for (; margin > 0 && leading_byte < 4; margin--) { + leading_byte += (int8_t(in[margin - 1]) > -65); + } + // If the input is long enough, then we have that margin-1 is the fourth last leading byte. + const size_t safety_margin = size - margin + 1; // to avoid overruns! + while (pos + 64 + safety_margin <= size) { + simd8x64 input(reinterpret_cast(in + pos)); + if (input.is_ascii()) { + input.store_ascii_as_utf32(utf32_output); + utf32_output += 64; + pos += 64; + } else { + // you might think that a for-loop would work, but under Visual Studio, it is not good enough. + static_assert((simd8x64::NUM_CHUNKS == 2) || (simd8x64::NUM_CHUNKS == 4), + "We support either two or four chunks per 64-byte block."); + auto zero = simd8 { uint8_t(0) }; + if (simd8x64::NUM_CHUNKS == 2) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + } else if (simd8x64::NUM_CHUNKS == 4) { + this->check_utf8_bytes(input.chunks[0], zero); + this->check_utf8_bytes(input.chunks[1], input.chunks[0]); + this->check_utf8_bytes(input.chunks[2], input.chunks[1]); + this->check_utf8_bytes(input.chunks[3], input.chunks[2]); + } + if (errors()) { + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); + res.count += pos; + return res; + } + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + uint64_t utf8_leading_mask = ~utf8_continuation_mask; + uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1; + // We process in blocks of up to 12 bytes except possibly + // for fast paths which may process up to 16 bytes. For the + // slow path to work, we should have at least 12 input bytes left. + size_t max_starting_point = (pos + 64) - 12; + // Next loop is going to run at least five times. + while (pos < max_starting_point) { + // Performance note: our ability to compute 'consumed' and + // then shift and recompute is critical. If there is a + // latency of, say, 4 cycles on getting 'consumed', then + // the inner loop might have a total latency of about 6 cycles. + // Yet we process between 6 to 12 inputs bytes, thus we get + // a speed limit between 1 cycle/byte and 0.5 cycle/byte + // for this section of the code. Hence, there is a limit + // to how much we can further increase this latency before + // it seriously harms performance. + size_t consumed = convert_masked_utf8_to_utf32(in + pos, + utf8_end_of_code_point_mask, utf32_output); + pos += consumed; + utf8_end_of_code_point_mask >>= consumed; + } + // At this point there may remain between 0 and 12 bytes in the + // 64-byte block. These bytes will be processed again. So we have an + // 80% efficiency (in the worst case). In practice we expect an + // 85% to 90% efficiency. + } + } + if (errors()) { result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); res.count += pos; return res; - } - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - uint64_t utf8_leading_mask = ~utf8_continuation_mask; - uint64_t utf8_end_of_code_point_mask = utf8_leading_mask>>1; - // We process in blocks of up to 12 bytes except possibly - // for fast paths which may process up to 16 bytes. For the - // slow path to work, we should have at least 12 input bytes left. - size_t max_starting_point = (pos + 64) - 12; - // Next loop is going to run at least five times. - while(pos < max_starting_point) { - // Performance note: our ability to compute 'consumed' and - // then shift and recompute is critical. If there is a - // latency of, say, 4 cycles on getting 'consumed', then - // the inner loop might have a total latency of about 6 cycles. - // Yet we process between 6 to 12 inputs bytes, thus we get - // a speed limit between 1 cycle/byte and 0.5 cycle/byte - // for this section of the code. Hence, there is a limit - // to how much we can further increase this latency before - // it seriously harms performance. - size_t consumed = convert_masked_utf8_to_utf32(in + pos, - utf8_end_of_code_point_mask, utf32_output); - pos += consumed; - utf8_end_of_code_point_mask >>= consumed; - } - // At this point there may remain between 0 and 12 bytes in the - // 64-byte block.These bytes will be processed again. So we have an - // 80% efficiency (in the worst case). In practice we expect an - // 85% to 90% efficiency. - } - } - if(errors()) { - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); - res.count += pos; - return res; - } - if(pos < size) { - result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); - if (res.error) { // In case of error, we want the error position - res.count += pos; - return res; - } else { // In case of success, we want the number of word written - utf32_output += res.count; } - } - return result(error_code::SUCCESS, utf32_output - start); + if (pos < size) { + result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(pos, in + pos, size - pos, utf32_output); + if (res.error) { // In case of error, we want the error position + res.count += pos; + return res; + } else { // In case of success, we want the number of word written + utf32_output += res.count; + } + } + return result(error_code::SUCCESS, utf32_output - start); } - simdutf_really_inline bool errors() const { - return this->error.any_bits_set_anywhere(); + simdutf_really_inline bool errors() const + { + return this->error.any_bits_set_anywhere(); } - }; // struct utf8_checker +}; // struct utf8_checker } // utf8_to_utf32 namespace } // unnamed namespace } // namespace westmere } // namespace simdutf /* end file src/generic/utf8_to_utf32/utf8_to_utf32.h */ // other functions -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf8.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf8.h /* begin file src/generic/utf8.h */ namespace simdutf { @@ -27771,36 +31282,37 @@ namespace utf8 { using namespace simd; -simdutf_really_inline size_t count_code_points(const char* in, size_t size) { +simdutf_really_inline size_t count_code_points(const char* in, size_t size) +{ size_t pos = 0; size_t count = 0; - for(;pos + 64 <= size; pos += 64) { - simd8x64 input(reinterpret_cast(in + pos)); - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - count += 64 - count_ones(utf8_continuation_mask); + for (; pos + 64 <= size; pos += 64) { + simd8x64 input(reinterpret_cast(in + pos)); + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + count += 64 - count_ones(utf8_continuation_mask); } return count + scalar::utf8::count_code_points(in + pos, size - pos); } - -simdutf_really_inline size_t utf16_length_from_utf8(const char* in, size_t size) { +simdutf_really_inline size_t utf16_length_from_utf8(const char* in, size_t size) +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 64 <= size; pos += 64) { - simd8x64 input(reinterpret_cast(in + pos)); - uint64_t utf8_continuation_mask = input.lt(-65 + 1); - // We count one word for anything that is not a continuation (so - // leading bytes). - count += 64 - count_ones(utf8_continuation_mask); - int64_t utf8_4byte = input.gteq_unsigned(240); - count += count_ones(utf8_4byte); + for (; pos + 64 <= size; pos += 64) { + simd8x64 input(reinterpret_cast(in + pos)); + uint64_t utf8_continuation_mask = input.lt(-65 + 1); + // We count one word for anything that is not a continuation (so + // leading bytes). + count += 64 - count_ones(utf8_continuation_mask); + int64_t utf8_4byte = input.gteq_unsigned(240); + count += count_ones(utf8_4byte); } return count + scalar::utf8::utf16_length_from_utf8(in + pos, size - pos); } - -simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) { +simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) +{ return count_code_points(in, size); } } // utf8 namespace @@ -27808,64 +31320,72 @@ simdutf_really_inline size_t utf32_length_from_utf8(const char* in, size_t size) } // namespace westmere } // namespace simdutf /* end file src/generic/utf8.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=generic/utf16.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=generic/utf16.h /* begin file src/generic/utf16.h */ namespace simdutf { namespace westmere { namespace { namespace utf16 { -template -simdutf_really_inline size_t count_code_points(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t count_code_points(const char16_t* in, size_t size) +{ size_t pos = 0; size_t count = 0; - for(;pos + 32 <= size; pos += 32) { - simd16x32 input(reinterpret_cast(in + pos)); - if (!match_system(big_endian)) input.swap_bytes(); - uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF); - count += count_ones(not_pair) / 2; + for (; pos + 32 <= size; pos += 32) { + simd16x32 input(reinterpret_cast(in + pos)); + if (!match_system(big_endian)) { + input.swap_bytes(); + } + uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF); + count += count_ones(not_pair) / 2; } return count + scalar::utf16::count_code_points(in + pos, size - pos); } -template -simdutf_really_inline size_t utf8_length_from_utf16(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t utf8_length_from_utf16(const char16_t* in, size_t size) +{ size_t pos = 0; size_t count = 0; // This algorithm could no doubt be improved! - for(;pos + 32 <= size; pos += 32) { - simd16x32 input(reinterpret_cast(in + pos)); - if (!match_system(big_endian)) input.swap_bytes(); - uint64_t ascii_mask = input.lteq(0x7F); - uint64_t twobyte_mask = input.lteq(0x7FF); - uint64_t not_pair_mask = input.not_in_range(0xD800, 0xDFFF); - - size_t ascii_count = count_ones(ascii_mask) / 2; - size_t twobyte_count = count_ones(twobyte_mask & ~ ascii_mask) / 2; - size_t threebyte_count = count_ones(not_pair_mask & ~ twobyte_mask) / 2; - size_t fourbyte_count = 32 - count_ones(not_pair_mask) / 2; - count += 2 * fourbyte_count + 3 * threebyte_count + 2 * twobyte_count + ascii_count; + for (; pos + 32 <= size; pos += 32) { + simd16x32 input(reinterpret_cast(in + pos)); + if (!match_system(big_endian)) { + input.swap_bytes(); + } + uint64_t ascii_mask = input.lteq(0x7F); + uint64_t twobyte_mask = input.lteq(0x7FF); + uint64_t not_pair_mask = input.not_in_range(0xD800, 0xDFFF); + + size_t ascii_count = count_ones(ascii_mask) / 2; + size_t twobyte_count = count_ones(twobyte_mask & ~ascii_mask) / 2; + size_t threebyte_count = count_ones(not_pair_mask & ~twobyte_mask) / 2; + size_t fourbyte_count = 32 - count_ones(not_pair_mask) / 2; + count += 2 * fourbyte_count + 3 * threebyte_count + 2 * twobyte_count + ascii_count; } return count + scalar::utf16::utf8_length_from_utf16(in + pos, size - pos); } -template -simdutf_really_inline size_t utf32_length_from_utf16(const char16_t* in, size_t size) { +template +simdutf_really_inline size_t utf32_length_from_utf16(const char16_t* in, size_t size) +{ return count_code_points(in, size); } -simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* output) { - size_t pos = 0; +simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t size, char16_t* output) +{ + size_t pos = 0; - while (pos + 32 <= size) { - simd16x32 input(reinterpret_cast(in + pos)); - input.swap_bytes(); - input.store(reinterpret_cast(output)); - pos += 32; - output += 32; - } + while (pos + 32 <= size) { + simd16x32 input(reinterpret_cast(in + pos)); + input.swap_bytes(); + input.store(reinterpret_cast(output)); + pos += 32; + output += 32; + } - scalar::utf16::change_endianness_utf16(in + pos, size - pos, output); + scalar::utf16::change_endianness_utf16(in + pos, size - pos, output); } } // utf16 @@ -27880,467 +31400,667 @@ simdutf_really_inline void change_endianness_utf16(const char16_t* in, size_t si namespace simdutf { namespace westmere { -simdutf_warn_unused int implementation::detect_encodings(const char * input, size_t length) const noexcept { - // If there is a BOM, then we trust it. - auto bom_encoding = simdutf::BOM::check_bom(input, length); - if(bom_encoding != encoding_type::unspecified) { return bom_encoding; } - if (length % 2 == 0) { - return sse_detect_encodings(input, length); - } else { - if (implementation::validate_utf8(input, length)) { - return simdutf::encoding_type::UTF8; +simdutf_warn_unused int implementation::detect_encodings(const char* input, size_t length) const noexcept +{ + // If there is a BOM, then we trust it. + auto bom_encoding = simdutf::BOM::check_bom(input, length); + if (bom_encoding != encoding_type::unspecified) { + return bom_encoding; + } + if (length % 2 == 0) { + return sse_detect_encodings(input, length); } else { - return simdutf::encoding_type::unspecified; + if (implementation::validate_utf8(input, length)) { + return simdutf::encoding_type::UTF8; + } else { + return simdutf::encoding_type::unspecified; + } } - } } -simdutf_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { - return westmere::utf8_validation::generic_validate_utf8(buf, len); +simdutf_warn_unused bool implementation::validate_utf8(const char* buf, size_t len) const noexcept +{ + return westmere::utf8_validation::generic_validate_utf8(buf, len); } -simdutf_warn_unused result implementation::validate_utf8_with_errors(const char *buf, size_t len) const noexcept { - return westmere::utf8_validation::generic_validate_utf8_with_errors(buf, len); +simdutf_warn_unused result implementation::validate_utf8_with_errors(const char* buf, size_t len) const noexcept +{ + return westmere::utf8_validation::generic_validate_utf8_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_ascii(const char *buf, size_t len) const noexcept { - return westmere::utf8_validation::generic_validate_ascii(buf, len); +simdutf_warn_unused bool implementation::validate_ascii(const char* buf, size_t len) const noexcept +{ + return westmere::utf8_validation::generic_validate_ascii(buf, len); } -simdutf_warn_unused result implementation::validate_ascii_with_errors(const char *buf, size_t len) const noexcept { - return westmere::utf8_validation::generic_validate_ascii_with_errors(buf,len); +simdutf_warn_unused result implementation::validate_ascii_with_errors(const char* buf, size_t len) const noexcept +{ + return westmere::utf8_validation::generic_validate_ascii_with_errors(buf, len); } -simdutf_warn_unused bool implementation::validate_utf16le(const char16_t *buf, size_t len) const noexcept { - const char16_t* tail = sse_validate_utf16(buf, len); - if (tail) { - return scalar::utf16::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf16le(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* tail = sse_validate_utf16(buf, len); + if (tail) { + return scalar::utf16::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused bool implementation::validate_utf16be(const char16_t *buf, size_t len) const noexcept { - const char16_t* tail = sse_validate_utf16(buf, len); - if (tail) { - return scalar::utf16::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf16be(const char16_t* buf, size_t len) const noexcept +{ + const char16_t* tail = sse_validate_utf16(buf, len); + if (tail) { + return scalar::utf16::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept { - result res = sse_validate_utf16_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept +{ + result res = sse_validate_utf16_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } } -simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept { - result res = sse_validate_utf16_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept +{ + result res = sse_validate_utf16_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf16::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } } -simdutf_warn_unused bool implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept { - const char32_t* tail = sse_validate_utf32le(buf, len); - if (tail) { - return scalar::utf32::validate(tail, len - (tail - buf)); - } else { - return false; - } +simdutf_warn_unused bool implementation::validate_utf32(const char32_t* buf, size_t len) const noexcept +{ + const char32_t* tail = sse_validate_utf32le(buf, len); + if (tail) { + return scalar::utf32::validate(tail, len - (tail - buf)); + } else { + return false; + } } -simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept { - result res = sse_validate_utf32le_with_errors(buf, len); - if (res.count != len) { - result scalar_res = scalar::utf32::validate_with_errors(buf + res.count, len - res.count); - return result(scalar_res.error, res.count + scalar_res.count); - } else { - return res; - } +simdutf_warn_unused result implementation::validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept +{ + result res = sse_validate_utf32le_with_errors(buf, len); + if (res.count != len) { + result scalar_res = scalar::utf32::validate_with_errors(buf + res.count, len - res.count); + return result(scalar_res.error, res.count + scalar_res.count); + } else { + return res; + } } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_latin1_to_utf8(const char* buf, size_t len, char* utf8_output) const noexcept +{ + return scalar::latin1_to_utf8::convert(buf, len, utf8_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_latin1_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return scalar::latin1_to_utf16::convert(buf, len, utf16_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept { - utf8_to_utf16::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_latin1_to_utf32(const char* buf, size_t len, char32_t* latin1_output) const noexcept +{ + return scalar::latin1_to_utf32::convert(buf, len, latin1_output); } +simdutf_warn_unused size_t implementation::convert_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_latin1_with_errors(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf8_to_latin1(const char* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf8_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16le(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_utf8_to_utf16be(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert(buf, len, utf16_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_utf16le_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf16_output); +} + +simdutf_warn_unused result implementation::convert_utf8_to_utf16be_with_errors(const char* buf, size_t len, char16_t* utf16_output) const noexcept +{ + utf8_to_utf16::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf16_output); +} simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16le(const char* input, size_t size, - char16_t* utf16_output) const noexcept { - return utf8_to_utf16::convert_valid(input, size, utf16_output); + char16_t* utf16_output) const noexcept +{ + return utf8_to_utf16::convert_valid(input, size, utf16_output); } simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf16be(const char* input, size_t size, - char16_t* utf16_output) const noexcept { - return utf8_to_utf16::convert_valid(input, size, utf16_output); + char16_t* utf16_output) const noexcept +{ + return utf8_to_utf16::convert_valid(input, size, utf16_output); } -simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept { - utf8_to_utf32::validating_transcoder converter; - return converter.convert(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::convert_utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + utf8_to_utf32::validating_transcoder converter; + return converter.convert(buf, len, utf32_output); } -simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept { - utf8_to_utf32::validating_transcoder converter; - return converter.convert_with_errors(buf, len, utf32_output); +simdutf_warn_unused result implementation::convert_utf8_to_utf32_with_errors(const char* buf, size_t len, char32_t* utf32_output) const noexcept +{ + utf8_to_utf32::validating_transcoder converter; + return converter.convert_with_errors(buf, len, utf32_output); } simdutf_warn_unused size_t implementation::convert_valid_utf8_to_utf32(const char* input, size_t size, - char32_t* utf32_output) const noexcept { - return utf8_to_utf32::convert_valid(input, size, utf32_output); -} - -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = sse_convert_utf16_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = sse_convert_utf16_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = westmere::sse_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = westmere::sse_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; + char32_t* utf32_output) const noexcept +{ + return utf8_to_utf32::convert_valid(input, size, utf32_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf16le_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf16be_to_latin1_with_errors(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_latin1(const char16_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf16_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = sse_convert_utf16_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; + return saved_bytes; } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf16le_to_utf8(buf, len, utf8_output); +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = sse_convert_utf16_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf16be_to_utf8(buf, len, utf8_output); +simdutf_warn_unused result implementation::convert_utf16le_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = westmere::sse_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf16be_to_utf8_with_errors(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = westmere::sse_convert_utf16_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; } -simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - std::pair ret = sse_convert_utf32_to_utf8(buf, len, utf8_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf8_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf16le_to_utf8(buf, len, utf8_output); } -simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = westmere::sse_convert_utf32_to_utf8_with_errors(buf, len, utf8_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf8::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::pair ret = sse_convert_utf16_to_utf32(buf, len, utf32_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf32_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - std::pair ret = sse_convert_utf16_to_utf32(buf, len, utf32_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf32_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = westmere::sse_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = westmere::sse_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); - if (ret.first.error) { return ret.first; } // Can return directly since scalar fallback already found correct ret.first.count - if (ret.first.count != len) { // All good so far, but not finished - result scalar_res = scalar::utf16_to_utf32::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept { - return convert_utf32_to_utf8(buf, len, utf8_output); -} - -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - std::pair ret = sse_convert_utf32_to_utf16(buf, len, utf16_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf16_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - std::pair ret = sse_convert_utf32_to_utf16(buf, len, utf16_output); - if (ret.first == nullptr) { return 0; } - size_t saved_bytes = ret.second - utf16_output; - if (ret.first != buf + len) { - const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( - ret.first, len - (ret.first - buf), ret.second); - if (scalar_saved_bytes == 0) { return 0; } - saved_bytes += scalar_saved_bytes; - } - return saved_bytes; -} - -simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = westmere::sse_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf16::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; - } - } - ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written - return ret.first; -} - -simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - // ret.first.count is always the position in the buffer, not the number of words written even if finished - std::pair ret = westmere::sse_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); - if (ret.first.count != len) { - result scalar_res = scalar::utf32_to_utf16::convert_with_errors( - buf + ret.first.count, len - ret.first.count, ret.second); - if (scalar_res.error) { - scalar_res.count += ret.first.count; - return scalar_res; - } else { - ret.second += scalar_res.count; +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf8(const char16_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf16be_to_utf8(buf, len, utf8_output); +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert(buf, len, latin1_output); +} + +simdutf_warn_unused result implementation::convert_utf32_to_latin1_with_errors(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_with_errors(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_latin1(const char32_t* buf, size_t len, char* latin1_output) const noexcept +{ + return scalar::utf32_to_latin1::convert_valid(buf, len, latin1_output); +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + std::pair ret = sse_convert_utf32_to_utf8(buf, len, utf8_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf8_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf8_with_errors(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = westmere::sse_convert_utf32_to_utf8_with_errors(buf, len, utf8_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf8::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf8_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused size_t implementation::convert_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::pair ret = sse_convert_utf16_to_utf32(buf, len, utf32_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf32_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + std::pair ret = sse_convert_utf16_to_utf32(buf, len, utf32_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf32_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf16_to_utf32::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf16le_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = westmere::sse_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf16be_to_utf32_with_errors(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = westmere::sse_convert_utf16_to_utf32_with_errors(buf, len, utf32_output); + if (ret.first.error) { + return ret.first; + } // Can return directly since scalar fallback already found correct ret.first.count + if (ret.first.count != len) { // All good so far, but not finished + result scalar_res = scalar::utf16_to_utf32::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf32_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) const noexcept +{ + return convert_utf32_to_utf8(buf, len, utf8_output); +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + std::pair ret = sse_convert_utf32_to_utf16(buf, len, utf16_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf16_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; } - } - ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written - return ret.first; + return saved_bytes; +} + +simdutf_warn_unused size_t implementation::convert_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + std::pair ret = sse_convert_utf32_to_utf16(buf, len, utf16_output); + if (ret.first == nullptr) { + return 0; + } + size_t saved_bytes = ret.second - utf16_output; + if (ret.first != buf + len) { + const size_t scalar_saved_bytes = scalar::utf32_to_utf16::convert( + ret.first, len - (ret.first - buf), ret.second); + if (scalar_saved_bytes == 0) { + return 0; + } + saved_bytes += scalar_saved_bytes; + } + return saved_bytes; +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf16le_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = westmere::sse_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf16::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused result implementation::convert_utf32_to_utf16be_with_errors(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + // ret.first.count is always the position in the buffer, not the number of words written even if finished + std::pair ret = westmere::sse_convert_utf32_to_utf16_with_errors(buf, len, utf16_output); + if (ret.first.count != len) { + result scalar_res = scalar::utf32_to_utf16::convert_with_errors( + buf + ret.first.count, len - ret.first.count, ret.second); + if (scalar_res.error) { + scalar_res.count += ret.first.count; + return scalar_res; + } else { + ret.second += scalar_res.count; + } + } + ret.first.count = ret.second - utf16_output; // Set count to the number of 8-bit words written + return ret.first; +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return convert_utf32_to_utf16le(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept +{ + return convert_utf32_to_utf16be(buf, len, utf16_output); +} + +simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return convert_utf16le_to_utf32(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16le(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return convert_utf32_to_utf16le(buf, len, utf16_output); +simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept +{ + return convert_utf16be_to_utf32(buf, len, utf32_output); } -simdutf_warn_unused size_t implementation::convert_valid_utf32_to_utf16be(const char32_t* buf, size_t len, char16_t* utf16_output) const noexcept { - return convert_utf32_to_utf16be(buf, len, utf16_output); +void implementation::change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) const noexcept +{ + utf16::change_endianness_utf16(input, length, output); } -simdutf_warn_unused size_t implementation::convert_valid_utf16le_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return convert_utf16le_to_utf32(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::count_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::convert_valid_utf16be_to_utf32(const char16_t* buf, size_t len, char32_t* utf32_output) const noexcept { - return convert_utf16be_to_utf32(buf, len, utf32_output); +simdutf_warn_unused size_t implementation::count_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::count_code_points(input, length); } -void implementation::change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) const noexcept { - utf16::change_endianness_utf16(input, length, output); +simdutf_warn_unused size_t implementation::count_utf8(const char* input, size_t length) const noexcept +{ + return utf8::count_code_points(input, length); } -simdutf_warn_unused size_t implementation::count_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf8(const char* buf, size_t len) const noexcept +{ + return scalar::utf8::latin1_length_from_utf8(buf, len); } -simdutf_warn_unused size_t implementation::count_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::count_code_points(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf16(size_t length) const noexcept +{ + return scalar::utf16::latin1_length_from_utf16(length); } -simdutf_warn_unused size_t implementation::count_utf8(const char * input, size_t length) const noexcept { - return utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::latin1_length_from_utf32(size_t length) const noexcept +{ + return scalar::utf32::latin1_length_from_utf32(length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::utf8_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf8_length_from_utf16(input, length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept { - return utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf16_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf16_length_from_latin1(length); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept { - return utf16::utf32_length_from_utf16(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_latin1(size_t length) const noexcept +{ + return scalar::latin1::utf32_length_from_latin1(length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char * input, size_t length) const noexcept { - return utf8::utf16_length_from_utf8(input, length); +simdutf_warn_unused size_t implementation::utf8_length_from_latin1(const char* input, size_t length) const noexcept +{ + return scalar::latin1::utf8_length_from_latin1(input, length); } -simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept { - const __m128i v_00000000 = _mm_setzero_si128(); - const __m128i v_ffffff80 = _mm_set1_epi32((uint32_t)0xffffff80); - const __m128i v_fffff800 = _mm_set1_epi32((uint32_t)0xfffff800); - const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000); - size_t pos = 0; - size_t count = 0; - for(;pos + 4 <= length; pos += 4) { - __m128i in = _mm_loadu_si128((__m128i*)(input + pos)); - const __m128i ascii_bytes_bytemask = _mm_cmpeq_epi32(_mm_and_si128(in, v_ffffff80), v_00000000); - const __m128i one_two_bytes_bytemask = _mm_cmpeq_epi32(_mm_and_si128(in, v_fffff800), v_00000000); - const __m128i two_bytes_bytemask = _mm_xor_si128(one_two_bytes_bytemask, ascii_bytes_bytemask); - const __m128i one_two_three_bytes_bytemask = _mm_cmpeq_epi32(_mm_and_si128(in, v_ffff0000), v_00000000); - const __m128i three_bytes_bytemask = _mm_xor_si128(one_two_three_bytes_bytemask, one_two_bytes_bytemask); - const uint16_t ascii_bytes_bitmask = static_cast(_mm_movemask_epi8(ascii_bytes_bytemask)); - const uint16_t two_bytes_bitmask = static_cast(_mm_movemask_epi8(two_bytes_bytemask)); - const uint16_t three_bytes_bitmask = static_cast(_mm_movemask_epi8(three_bytes_bytemask)); +simdutf_warn_unused size_t implementation::utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf32_length_from_utf16(input, length); +} + +simdutf_warn_unused size_t implementation::utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept +{ + return utf16::utf32_length_from_utf16(input, length); +} - size_t ascii_count = count_ones(ascii_bytes_bitmask) / 4; - size_t two_bytes_count = count_ones(two_bytes_bitmask) / 4; - size_t three_bytes_count = count_ones(three_bytes_bitmask) / 4; - count += 16 - 3*ascii_count - 2*two_bytes_count - three_bytes_count; - } - return count + scalar::utf32::utf8_length_from_utf32(input + pos, length - pos); +simdutf_warn_unused size_t implementation::utf16_length_from_utf8(const char* input, size_t length) const noexcept +{ + return utf8::utf16_length_from_utf8(input, length); } -simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept { - const __m128i v_00000000 = _mm_setzero_si128(); - const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000); - size_t pos = 0; - size_t count = 0; - for(;pos + 4 <= length; pos += 4) { - __m128i in = _mm_loadu_si128((__m128i*)(input + pos)); - const __m128i surrogate_bytemask = _mm_cmpeq_epi32(_mm_and_si128(in, v_ffff0000), v_00000000); - const uint16_t surrogate_bitmask = static_cast(_mm_movemask_epi8(surrogate_bytemask)); - size_t surrogate_count = (16-count_ones(surrogate_bitmask))/4; - count += 4 + surrogate_count; - } - return count + scalar::utf32::utf16_length_from_utf32(input + pos, length - pos); +simdutf_warn_unused size_t implementation::utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + const __m128i v_00000000 = _mm_setzero_si128(); + const __m128i v_ffffff80 = _mm_set1_epi32((uint32_t)0xffffff80); + const __m128i v_fffff800 = _mm_set1_epi32((uint32_t)0xfffff800); + const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000); + size_t pos = 0; + size_t count = 0; + for (; pos + 4 <= length; pos += 4) { + __m128i in = _mm_loadu_si128((__m128i*)(input + pos)); + const __m128i ascii_bytes_bytemask = _mm_cmpeq_epi32(_mm_and_si128(in, v_ffffff80), v_00000000); + const __m128i one_two_bytes_bytemask = _mm_cmpeq_epi32(_mm_and_si128(in, v_fffff800), v_00000000); + const __m128i two_bytes_bytemask = _mm_xor_si128(one_two_bytes_bytemask, ascii_bytes_bytemask); + const __m128i one_two_three_bytes_bytemask = _mm_cmpeq_epi32(_mm_and_si128(in, v_ffff0000), v_00000000); + const __m128i three_bytes_bytemask = _mm_xor_si128(one_two_three_bytes_bytemask, one_two_bytes_bytemask); + const uint16_t ascii_bytes_bitmask = static_cast(_mm_movemask_epi8(ascii_bytes_bytemask)); + const uint16_t two_bytes_bitmask = static_cast(_mm_movemask_epi8(two_bytes_bytemask)); + const uint16_t three_bytes_bitmask = static_cast(_mm_movemask_epi8(three_bytes_bytemask)); + + size_t ascii_count = count_ones(ascii_bytes_bitmask) / 4; + size_t two_bytes_count = count_ones(two_bytes_bitmask) / 4; + size_t three_bytes_count = count_ones(three_bytes_bitmask) / 4; + count += 16 - 3 * ascii_count - 2 * two_bytes_count - three_bytes_count; + } + return count + scalar::utf32::utf8_length_from_utf32(input + pos, length - pos); +} + +simdutf_warn_unused size_t implementation::utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept +{ + const __m128i v_00000000 = _mm_setzero_si128(); + const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000); + size_t pos = 0; + size_t count = 0; + for (; pos + 4 <= length; pos += 4) { + __m128i in = _mm_loadu_si128((__m128i*)(input + pos)); + const __m128i surrogate_bytemask = _mm_cmpeq_epi32(_mm_and_si128(in, v_ffff0000), v_00000000); + const uint16_t surrogate_bitmask = static_cast(_mm_movemask_epi8(surrogate_bytemask)); + size_t surrogate_count = (16 - count_ones(surrogate_bitmask)) / 4; + count += 4 + surrogate_count; + } + return count + scalar::utf32::utf16_length_from_utf32(input + pos, length - pos); } -simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char * input, size_t length) const noexcept { - return scalar::utf8::count_code_points(input, length); +simdutf_warn_unused size_t implementation::utf32_length_from_utf8(const char* input, size_t length) const noexcept +{ + return scalar::utf8::count_code_points(input, length); } } // namespace westmere } // namespace simdutf -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/src, filename=simdutf/westmere/end.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/src, filename=simdutf/westmere/end.h /* begin file src/simdutf/westmere/end.h */ #if SIMDUTF_CAN_ALWAYS_RUN_WESTMERE // nothing needed. diff --git a/src/bun.js/bindings/simdutf.h b/src/bun.js/bindings/simdutf.h index 0a57a69f7..7fb388e9e 100644 --- a/src/bun.js/bindings/simdutf.h +++ b/src/bun.js/bindings/simdutf.h @@ -1,11 +1,11 @@ -/* auto-generated on 2023-02-10 14:42:58 -0500. Do not edit! */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf.h +/* auto-generated on 2023-06-21 08:09:45 -0400. Do not edit! */ +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf.h /* begin file include/simdutf.h */ #ifndef SIMDUTF_H #define SIMDUTF_H #include -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/compiler_check.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/compiler_check.h /* begin file include/simdutf/compiler_check.h */ #ifndef SIMDUTF_COMPILER_CHECK_H #define SIMDUTF_COMPILER_CHECK_H @@ -43,13 +43,13 @@ #endif // SIMDUTF_COMPILER_CHECK_H /* end file include/simdutf/compiler_check.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/common_defs.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/common_defs.h /* begin file include/simdutf/common_defs.h */ #ifndef SIMDUTF_COMMON_DEFS_H #define SIMDUTF_COMMON_DEFS_H #include -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/portability.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/portability.h /* begin file include/simdutf/portability.h */ #ifndef SIMDUTF_PORTABILITY_H #define SIMDUTF_PORTABILITY_H @@ -144,6 +144,8 @@ // POWER processors. Please see https://github.com/lemire/simdutf/issues/51 #elif defined(__s390__) // s390 IBM system. Big endian. +#elif (defined(__riscv) || defined(__riscv__)) && __riscv_xlen == 64 +// RISC-V 64-bit #else // The simdutf library is designed // for 64-bit processors and it seems that you are not @@ -278,7 +280,7 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") #endif // SIMDUTF_PORTABILITY_H /* end file include/simdutf/portability.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/avx512.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/avx512.h /* begin file include/simdutf/avx512.h */ #ifndef SIMDUTF_AVX512_H_ #define SIMDUTF_AVX512_H_ @@ -458,19 +460,21 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") #endif // MSC_VER -#if defined(SIMDUTF_VISUAL_STUDIO) - /** - * It does not matter here whether you are using - * the regular visual studio or clang under visual - * studio. - */ - #if SIMDUTF_USING_LIBRARY - #define SIMDUTF_DLLIMPORTEXPORT __declspec(dllimport) +#ifndef SIMDUTF_DLLIMPORTEXPORT + #if defined(SIMDUTF_VISUAL_STUDIO) + /** + * It does not matter here whether you are using + * the regular visual studio or clang under visual + * studio. + */ + #if SIMDUTF_USING_LIBRARY + #define SIMDUTF_DLLIMPORTEXPORT __declspec(dllimport) + #else + #define SIMDUTF_DLLIMPORTEXPORT __declspec(dllexport) + #endif #else - #define SIMDUTF_DLLIMPORTEXPORT __declspec(dllexport) + #define SIMDUTF_DLLIMPORTEXPORT #endif -#else - #define SIMDUTF_DLLIMPORTEXPORT #endif /// If EXPR is an error, returns it. @@ -479,7 +483,7 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") #endif // SIMDUTF_COMMON_DEFS_H /* end file include/simdutf/common_defs.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/encoding_types.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/encoding_types.h /* begin file include/simdutf/encoding_types.h */ #include @@ -491,6 +495,7 @@ enum encoding_type { UTF16_BE = 4, // BOM 0xfe 0xff UTF32_LE = 8, // BOM 0xff 0xfe 0x00 0x00 UTF32_BE = 16, // BOM 0x00 0x00 0xfe 0xff + Latin1 = 32, unspecified = 0 }; @@ -527,7 +532,7 @@ size_t bom_byte_size(encoding_type bom); } // BOM namespace } // simdutf namespace /* end file include/simdutf/encoding_types.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/error.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/error.h /* begin file include/simdutf/error.h */ #ifndef ERROR_H #define ERROR_H @@ -541,9 +546,10 @@ enum error_code { TOO_LONG, // We either have too many consecutive continuation bytes or the string starts with a continuation byte. OVERLONG, // The decoded character must be above U+7F for two-byte characters, U+7FF for three-byte characters, // and U+FFFF for four-byte characters. - TOO_LARGE, // The decoded character must be less than or equal to U+10FFFF OR less than or equal than U+7F for ASCII. + TOO_LARGE, // The decoded character must be less than or equal to U+10FFFF,less than or equal than U+7F for ASCII OR less than equal than U+FF for Latin1 SURROGATE, // The decoded character must be not be in U+D800...DFFF (UTF-8 or UTF-32) OR - // a high surrogate must be followed by a low surrogate and a low surrogate must be preceded by a high surrogate (UTF-16) + // a high surrogate must be followed by a low surrogate and a low surrogate must be preceded by a high surrogate (UTF-16) OR + // there must be no surrogate at all (Latin1) OTHER // Not related to validation/transcoding. }; @@ -564,7 +570,7 @@ SIMDUTF_PUSH_DISABLE_WARNINGS SIMDUTF_DISABLE_UNDESIRED_WARNINGS // Public API -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/simdutf_version.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/simdutf_version.h /* begin file include/simdutf/simdutf_version.h */ // /include/simdutf/simdutf_version.h automatically generated by release.py, // do not change by hand @@ -572,7 +578,7 @@ SIMDUTF_DISABLE_UNDESIRED_WARNINGS #define SIMDUTF_SIMDUTF_VERSION_H /** The version of simdutf being used (major.minor.revision) */ -#define SIMDUTF_VERSION "3.2.0" +#define SIMDUTF_VERSION "3.2.14" namespace simdutf { enum { @@ -587,13 +593,13 @@ enum { /** * The revision (major.minor.REVISION) of simdutf being used. */ - SIMDUTF_VERSION_REVISION = 0 + SIMDUTF_VERSION_REVISION = 14 }; } // namespace simdutf #endif // SIMDUTF_SIMDUTF_VERSION_H /* end file include/simdutf/simdutf_version.h */ -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/implementation.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/implementation.h /* begin file include/simdutf/implementation.h */ #ifndef SIMDUTF_IMPLEMENTATION_H #define SIMDUTF_IMPLEMENTATION_H @@ -603,7 +609,7 @@ enum { #endif #include #include -// dofile: invoked with prepath=/Users/dlemire/CVS/github/simdutf/include, filename=simdutf/internal/isadetection.h +// dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/internal/isadetection.h /* begin file include/simdutf/internal/isadetection.h */ /* From https://github.com/endorno/pytorch/blob/master/torch/lib/TH/generic/simd/simd.h @@ -690,22 +696,12 @@ static inline uint32_t detect_supported_architectures() { return instruction_set::ALTIVEC; } -#elif defined(__arm__) || defined(__aarch64__) // incl. armel, armhf, arm64 - -#if defined(__ARM_NEON) +#elif defined(__aarch64__) || defined(_M_ARM64) static inline uint32_t detect_supported_architectures() { return instruction_set::NEON; } -#else // ARM without NEON - -static inline uint32_t detect_supported_architectures() { - return instruction_set::DEFAULT; -} - -#endif - #elif defined(__x86_64__) || defined(_M_AMD64) // x64 @@ -716,6 +712,7 @@ namespace cpuid_bit { // EAX = 0x01 constexpr uint32_t pclmulqdq = uint32_t(1) << 1; ///< @private bit 1 of ECX for EAX=0x1 constexpr uint32_t sse42 = uint32_t(1) << 20; ///< @private bit 20 of ECX for EAX=0x1 + constexpr uint32_t osxsave = (uint32_t(1) << 26) | (uint32_t(1) << 27); ///< @private bits 26+27 of ECX for EAX=0x1 // EAX = 0x7f (Structured Extended Feature Flags), ECX = 0x00 (Sub-leaf) // See: "Table 3-8. Information Returned by CPUID Instruction" @@ -741,6 +738,10 @@ namespace cpuid_bit { namespace edx { constexpr uint32_t avx512vp2intersect = uint32_t(1) << 8; } + namespace xcr0_bit { + constexpr uint64_t avx256_saved = uint64_t(1) << 2; ///< @private bit 2 = AVX + constexpr uint64_t avx512_saved = uint64_t(7) << 5; ///< @private bits 5,6,7 = opmask, ZMM_hi256, hi16_ZMM + } } } @@ -750,7 +751,7 @@ static inline void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { #if defined(_MSC_VER) int cpu_info[4]; - __cpuid(cpu_info, *eax); + __cpuidex(cpu_info, *eax, *ecx); *eax = cpu_info[0]; *ebx = cpu_info[1]; *ecx = cpu_info[2]; @@ -768,6 +769,16 @@ static inline void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, #endif } +static inline uint64_t xgetbv() { + #if defined(_MSC_VER) + return _xgetbv(0); + #else + uint32_t xcr0_lo, xcr0_hi; + asm volatile("xgetbv\n\t" : "=a" (xcr0_lo), "=d" (xcr0_hi) : "c" (0)); + return xcr0_lo | ((uint64_t)xcr0_hi << 32); + #endif + } + static inline uint32_t detect_supported_architectures() { uint32_t eax; uint32_t ebx = 0; @@ -787,6 +798,16 @@ static inline uint32_t detect_supported_architectures() { host_isa |= instruction_set::PCLMULQDQ; } + if ((ecx & cpuid_bit::osxsave) != cpuid_bit::osxsave) { + return host_isa; + } + + // xgetbv for checking if the OS saves registers + uint64_t xcr0 = xgetbv(); + + if ((xcr0 & cpuid_bit::xcr0_bit::avx256_saved) == 0) { + return host_isa; + } // ECX for EAX=0x7 eax = 0x7; ecx = 0x0; // Sub-leaf = 0 @@ -800,6 +821,9 @@ static inline uint32_t detect_supported_architectures() { if (ebx & cpuid_bit::ebx::bmi2) { host_isa |= instruction_set::BMI2; } + if (!((xcr0 & cpuid_bit::xcr0_bit::avx512_saved) == cpuid_bit::xcr0_bit::avx512_saved)) { + return host_isa; + } if (ebx & cpuid_bit::ebx::avx512f) { host_isa |= instruction_set::AVX512F; } @@ -822,7 +846,7 @@ static inline uint32_t detect_supported_architectures() { } #else // fallback - +// includes 32-bit ARM. static inline uint32_t detect_supported_architectures() { return instruction_set::DEFAULT; } @@ -870,7 +894,6 @@ simdutf_really_inline simdutf_warn_unused int detect_encodings(const uint8_t * i return detect_encodings(reinterpret_cast(input), length); } - /** * Validate the UTF-8 string. This function may be best when you expect * the input to be almost always valid. Otherwise, consider using @@ -1034,6 +1057,68 @@ simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) noexcep */ simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_t len) noexcept; + /** + * Convert Latin1 string into UTF8 string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if conversion is not possible + */ + simdutf_warn_unused size_t convert_latin1_to_utf8(const char * input, size_t length, char* utf8_output) noexcept; + + + /** + * Convert possibly Latin1 string into UTF-16LE string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if conversion is not possible + */ + simdutf_warn_unused size_t convert_latin1_to_utf16le(const char * input, size_t length, char16_t* utf16_output) noexcept; + + /** + * Convert Latin1 string into UTF-16BE string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if conversion is not possible + */ + simdutf_warn_unused size_t convert_latin1_to_utf16be(const char * input, size_t length, char16_t* utf16_output) noexcept; + + /** + * Convert Latin1 string into UTF-32 string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return the number of written char32_t; 0 if conversion is not possible + */ + simdutf_warn_unused size_t convert_latin1_to_utf32(const char * input, size_t length, char32_t* utf32_buffer) noexcept; + + /** + * Convert possibly broken UTF-8 string into latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused size_t convert_utf8_to_latin1(const char * input, size_t length, char* latin1_output) noexcept; + /** * Using native endianness; Convert possibly broken UTF-8 string into UTF-16 string. * @@ -1073,6 +1158,20 @@ simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * input, size_t le */ simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * input, size_t length, char16_t* utf16_output) noexcept; + + /** + * Convert possibly broken UTF-8 string into latin1 string. with errors + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char * input, size_t length, char* latin1_output) noexcept; + /** * Using native endianness; Convert possibly broken UTF-8 string into UTF-16 * string and stop on error. @@ -1139,6 +1238,21 @@ simdutf_warn_unused size_t convert_utf8_to_utf32(const char * input, size_t leng */ simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * input, size_t length, char32_t* utf32_output) noexcept; + /** + * Convert valid UTF-8 string into latin1 string. + * + * This function assumes that the input string is valid UTF-8. + * + * This function is not BOM-aware. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char * input, size_t length, char* latin1_output) noexcept; + + /** * Using native endianness; Convert valid UTF-8 string into UTF-16 string. * @@ -1187,6 +1301,29 @@ simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * input, siz */ simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * input, size_t length, char32_t* utf32_buffer) noexcept; + + /** + * Return the number of bytes that this Latin1 string would require in UTF-8 format. + * + * @param input the Latin1 string to convert + * @param length the length of the string bytes + * @return the number of bytes required to encode the Latin1 string as UTF-8 + */ + simdutf_warn_unused size_t utf8_length_from_latin1(const char * input, size_t length) noexcept; + + /** + * Compute the number of bytes that this UTF-8 string would require in Latin1 format. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in byte + * @return the number of bytes required to encode the UTF-8 string as Latin1 + */ + simdutf_warn_unused size_t latin1_length_from_utf8(const char * input, size_t length) noexcept; + /** * Compute the number of 2-byte words that this UTF-8 string would require in UTF-16LE format. * @@ -1230,6 +1367,38 @@ simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t len */ simdutf_warn_unused size_t convert_utf16_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; + + /** + * Convert possibly broken UTF-16LE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-16LE string + */ + simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) noexcept; + + /** + * Convert possibly broken UTF-16BE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) noexcept; + + /** * Convert possibly broken UTF-16LE string into UTF-8 string. * @@ -1260,6 +1429,35 @@ simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * input, size_ */ simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; + /** + * Convert possibly broken UTF-16LE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t * input, size_t length, char* latin1_buffer) noexcept; + + /** + * Convert possibly broken UTF-16BE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t * input, size_t length, char* latin1_buffer) noexcept; + + /** * Using native endianness; Convert possibly broken UTF-16 string into UTF-8 string and stop on error. * @@ -1319,6 +1517,36 @@ simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * */ simdutf_warn_unused size_t convert_valid_utf16_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; + + /** + * Convert valid UTF-16LE string into Latin1 string. + * + * This function assumes that the input string is valid UTF-8. + + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) noexcept; + + /** + * Convert valid UTF-16BE string into Latin1 string. + * + * This function assumes that the input string is valid UTF-8. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) noexcept; + + /** * Convert valid UTF-16LE string into UTF-8 string. * @@ -1480,6 +1708,21 @@ simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * input */ simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; + +/* + * Compute the number of bytes that this UTF-16LE/BE string would require in Latin1 format. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16LE string as Latin1 + */ + simdutf_warn_unused size_t latin1_length_from_utf16(size_t length) noexcept; + + /** * Using native endianness; Compute the number of bytes that this UTF-16 * string would require in UTF-8 format. @@ -1588,6 +1831,53 @@ simdutf_warn_unused size_t convert_utf32_to_utf16(const char32_t * input, size_t */ simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; + /** + * Convert possibly broken UTF-32 string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-32 string + */ + + simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t * input, size_t length, char* latin1_buffer) noexcept; + + + /** + * Convert possibly broken UTF-32 string into Latin1 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + + simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t * input, size_t length, char* latin1_buffer) noexcept; + + /** + * Convert valid UTF-32 string into Latin1 string. + * + * This function assumes that the input string is valid UTF-32. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t * input, size_t length, char* latin1_buffer) noexcept; + /** * Convert possibly broken UTF-32 string into UTF-16BE string. * @@ -2020,6 +2310,96 @@ public: */ simdutf_warn_unused virtual result validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept = 0; + /** + * Convert Latin1 string into UTF8 string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_latin1_to_utf8(const char * input, size_t length, char* utf8_output) const noexcept = 0; + + + /** + * Convert possibly Latin1 string into UTF-16LE string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_latin1_to_utf16le(const char * input, size_t length, char16_t* utf16_output) const noexcept = 0; + + /** + * Convert Latin1 string into UTF-16BE string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_latin1_to_utf16be(const char * input, size_t length, char16_t* utf16_output) const noexcept = 0; + + /** + * Convert Latin1 string into UTF-32 string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return the number of written char32_t; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_latin1_to_utf32(const char * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused virtual size_t convert_utf8_to_latin1(const char * input, size_t length, char* latin1_output) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into latin1 string. with errors + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result convert_utf8_to_latin1_with_errors(const char * input, size_t length, char* latin1_output) const noexcept = 0; + + /** + * Convert valid UTF-8 string into latin1 string. + * + * This function assumes that the input string is valid UTF-8. + * + * This function is not BOM-aware. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused virtual size_t convert_valid_utf8_to_latin1(const char * input, size_t length, char* latin1_output) const noexcept = 0; + + /** * Convert possibly broken UTF-8 string into UTF-16LE string. * @@ -2158,6 +2538,92 @@ public: */ simdutf_warn_unused virtual size_t utf32_length_from_utf8(const char * input, size_t length) const noexcept = 0; + /** + * Convert possibly broken UTF-16LE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-16LE string + */ + simdutf_warn_unused virtual size_t convert_utf16le_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16BE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual size_t convert_utf16be_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16LE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual result convert_utf16le_to_latin1_with_errors(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16BE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual result convert_utf16be_to_latin1_with_errors(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert valid UTF-16LE string into Latin1 string. + * + * This function assumes that the input string is valid UTF-8. + + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf16le_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert valid UTF-16BE string into Latin1 string. + * + * This function assumes that the input string is valid UTF-8. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf16be_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + /** * Convert possibly broken UTF-16LE string into UTF-8 string. * @@ -2360,6 +2826,52 @@ public: */ simdutf_warn_unused virtual size_t utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept = 0; + /** + * Convert possibly broken UTF-32 string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-32 string + */ + + simdutf_warn_unused virtual size_t convert_utf32_to_latin1(const char32_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-32 string into Latin1 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + + simdutf_warn_unused virtual result convert_utf32_to_latin1_with_errors(const char32_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert valid UTF-32 string into Latin1 string. + * + * This function assumes that the input string is valid UTF-32. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf32_to_latin1(const char32_t * input, size_t length, char* latin1_buffer) const noexcept = 0; + /** * Convert possibly broken UTF-32 string into UTF-8 string. * @@ -2404,6 +2916,17 @@ public: */ simdutf_warn_unused virtual size_t convert_valid_utf32_to_utf8(const char32_t * input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Return the number of bytes that this UTF-16 string would require in Latin1 format. + * + * + * @param input the UTF-16 string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16 string as Latin1 + */ + simdutf_warn_unused virtual size_t utf16_length_from_latin1(size_t length) const noexcept = 0; + /** * Convert possibly broken UTF-32 string into UTF-16LE string. * @@ -2506,6 +3029,15 @@ public: */ virtual void change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) const noexcept = 0; + /** + * Return the number of bytes that this Latin1 string would require in UTF-8 format. + * + * @param input the Latin1 string to convert + * @param length the length of the string bytes + * @return the number of bytes required to encode the Latin1 string as UTF-8 + */ + simdutf_warn_unused virtual size_t utf8_length_from_latin1(const char * input, size_t length) const noexcept = 0; + /** * Compute the number of bytes that this UTF-32 string would require in UTF-8 format. * @@ -2517,6 +3049,41 @@ public: */ simdutf_warn_unused virtual size_t utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept = 0; + /** + * Compute the number of bytes that this UTF-32 string would require in Latin1 format. + * + * This function does not validate the input. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @return the number of bytes required to encode the UTF-32 string as Latin1 + */ + simdutf_warn_unused virtual size_t latin1_length_from_utf32( size_t length) const noexcept = 0; + + /** + * Compute the number of bytes that this UTF-8 string would require in Latin1 format. + * + * This function does not validate the input. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in byte + * @return the number of bytes required to encode the UTF-8 string as Latin1 + */ + simdutf_warn_unused virtual size_t latin1_length_from_utf8(const char * input, size_t length) const noexcept = 0; + +/* + * Compute the number of bytes that this UTF-16LE/BE string would require in Latin1 format. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16LE string as Latin1 + */ + simdutf_warn_unused virtual size_t latin1_length_from_utf16(size_t length) const noexcept = 0; + /** * Compute the number of two-byte words that this UTF-32 string would require in UTF-16 format. * @@ -2528,6 +3095,18 @@ public: */ simdutf_warn_unused virtual size_t utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept = 0; + + /** + * Return the number of bytes that this UTF-32 string would require in Latin1 format. + * + * This function does not validate the input. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @return the number of bytes required to encode the UTF-32 string as Latin1 + */ + simdutf_warn_unused virtual size_t utf32_length_from_latin1(size_t length) const noexcept = 0; + /* * Compute the number of bytes that this UTF-16LE string would require in UTF-32 format. * diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index e79c353e3..ee0fb9c77 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -757,7 +757,7 @@ const Copy = union(enum) { return WebsocketHeader.frameSizeIncludingMask(byte_len.*); }, .latin1 => { - byte_len.* = this.latin1.len; + byte_len.* = strings.elementLengthLatin1IntoUTF8([]const u8, this.latin1); return WebsocketHeader.frameSizeIncludingMask(byte_len.*); }, .bytes => { @@ -821,7 +821,10 @@ const Copy = union(enum) { .latin1 => |latin1| { const encode_into_result = strings.copyLatin1IntoUTF8(to_mask, []const u8, latin1); std.debug.assert(@as(usize, encode_into_result.written) == content_byte_len); + + // latin1 can contain non-ascii std.debug.assert(@as(usize, encode_into_result.read) == latin1.len); + header.len = WebsocketHeader.packLength(encode_into_result.written); header.opcode = Opcode.Text; var fib = std.io.fixedBufferStream(buf); @@ -1467,9 +1470,10 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { // fast path: small frame, no backpressure, attempt to send without allocating if (!str.is16Bit() and str.len < stack_frame_size) { const bytes = Copy{ .latin1 = str.slice() }; - const frame_size = WebsocketHeader.frameSizeIncludingMask(str.len); + var byte_len: usize = 0; + const frame_size = bytes.len(&byte_len); if (!this.hasBackpressure() and frame_size < stack_frame_size) { - bytes.copy(this.globalThis, inline_buf[0..frame_size], str.len); + bytes.copy(this.globalThis, inline_buf[0..frame_size], byte_len); _ = this.enqueueEncodedBytes(this.tcp, inline_buf[0..frame_size]); return; } diff --git a/src/string_immutable.zig b/src/string_immutable.zig index d075b38f5..3931648b8 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -1946,61 +1946,44 @@ pub fn replaceLatin1WithUTF8(buf_: []u8) void { } pub fn elementLengthLatin1IntoUTF8(comptime Type: type, latin1_: Type) usize { + // https://zig.godbolt.org/z/zzYexPPs9 + var latin1 = latin1_; + const input_len = latin1.len; var total_non_ascii_count: usize = 0; - const latin1_last = latin1.ptr + latin1.len; - if (latin1.ptr != latin1_last) { - - // reference the pointer directly because it improves codegen - var ptr = latin1.ptr; - - if (comptime Environment.enableSIMD) { - const wrapped_len = latin1.len - (latin1.len % ascii_vector_size); - const latin1_vec_end = ptr + wrapped_len; - while (ptr != latin1_vec_end) { - const vec: AsciiVector = ptr[0..ascii_vector_size].*; - const cmp = vec & @splat(ascii_vector_size, @as(u8, 0x80)); - total_non_ascii_count += @reduce(.Add, cmp); - ptr += ascii_vector_size; - } - } else { - while (@intFromPtr(ptr + 8) < @intFromPtr(latin1_last)) { - if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) <= @intFromPtr(latin1_last) and @intFromPtr(ptr) >= @intFromPtr(latin1_.ptr)); - const bytes = @bitCast(u64, ptr[0..8].*) & 0x8080808080808080; - total_non_ascii_count += @popCount(bytes); - ptr += 8; - } + // This is about 30% faster on large input compared to auto-vectorization + if (comptime Environment.enableSIMD) { + const end = latin1.ptr + (latin1.len - (latin1.len % ascii_vector_size)); + while (latin1.ptr != end) { + const vec: AsciiVector = latin1[0..ascii_vector_size].*; + + // Shifting a unsigned 8 bit integer to the right by 7 bits always produces a value of 0 or 1. + const cmp = vec >> @splat( + ascii_vector_size, + @as(u8, 7), + ); - if (@intFromPtr(ptr + 4) < @intFromPtr(latin1_last)) { - if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) <= @intFromPtr(latin1_last) and @intFromPtr(ptr) >= @intFromPtr(latin1_.ptr)); - const bytes = @bitCast(u32, ptr[0..4].*) & 0x80808080; - total_non_ascii_count += @popCount(bytes); - ptr += 4; - } + // Anding that value rather than converting it into a @Vector(16, u1) produces better code from LLVM. + const mask = cmp & @splat( + ascii_vector_size, + @as(u8, 1), + ); - if (@intFromPtr(ptr + 2) < @intFromPtr(latin1_last)) { - if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) <= @intFromPtr(latin1_last) and @intFromPtr(ptr) >= @intFromPtr(latin1_.ptr)); - const bytes = @bitCast(u16, ptr[0..2].*) & 0x8080; - total_non_ascii_count += @popCount(bytes); - ptr += 2; - } + total_non_ascii_count += @as(usize, @reduce(.Add, mask)); + latin1 = latin1[ascii_vector_size..]; } - while (ptr != latin1_last) { - if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) < @intFromPtr(latin1_last)); - - total_non_ascii_count += @as(usize, @intFromBool(ptr[0] > 127)); - ptr += 1; - } + // an important hint to the compiler to not auto-vectorize the loop below + if (latin1.len >= ascii_vector_size) unreachable; + } - // assert we never go out of bounds - if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) <= @intFromPtr(latin1_last) and @intFromPtr(ptr) >= @intFromPtr(latin1_.ptr)); + for (latin1) |c| { + total_non_ascii_count += @as(usize, @intFromBool(c > 127)); } // each non-ascii latin1 character becomes 2 UTF8 characters - // since latin1_.len is the original length, we only need to add up the number of non-ascii characters to get the final count - return latin1_.len + total_non_ascii_count; + return input_len + total_non_ascii_count; } const JSC = @import("root").bun.JSC; -- cgit v1.2.3 From 30798c7078a080e9779551d073e7362046ccd5d1 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 03:01:01 -0700 Subject: Make timeout longer --- test/js/bun/websocket/websocket-server.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/bun/websocket/websocket-server.test.ts b/test/js/bun/websocket/websocket-server.test.ts index 7d43c7e65..2c2352f91 100644 --- a/test/js/bun/websocket/websocket-server.test.ts +++ b/test/js/bun/websocket/websocket-server.test.ts @@ -1037,7 +1037,7 @@ describe("websocket server", () => { }); expect(serverCounter).toBe(sendQueue.length); server.stop(true); - }, 10_000); + }, 30_000); it("can close with reason and code #2631", done => { let timeout: any; let server = Bun.serve({ -- cgit v1.2.3 From 777f98bd1068239033718c44bdcfca87e58a91d5 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 03:31:55 -0700 Subject: make these strings lazy --- src/bun.js/bindings/webcore/WebSocket.cpp | 63 ++++++++++++++++++------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/src/bun.js/bindings/webcore/WebSocket.cpp b/src/bun.js/bindings/webcore/WebSocket.cpp index a346175df..519b86d59 100644 --- a/src/bun.js/bindings/webcore/WebSocket.cpp +++ b/src/bun.js/bindings/webcore/WebSocket.cpp @@ -1032,6 +1032,17 @@ void WebSocket::didConnect(us_socket_t* socket, char* bufferedData, size_t buffe this->didConnect(); } + +#define LAZY_NEVER_DESTROYED(name) \ + ([]() -> const String& { \ + static LazyNeverDestroyed str; \ + static std::once_flag onceFlag; \ + std::call_once(onceFlag, [] { \ + str.construct(MAKE_STATIC_STRING_IMPL(name)); \ + }); \ + return str; \ + })() + void WebSocket::didFailWithErrorCode(int32_t code) { // from new WebSocket() -> connect() @@ -1050,158 +1061,158 @@ void WebSocket::didFailWithErrorCode(int32_t code) } // invalid_response case 1: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Invalid response"); + const String& message = LAZY_NEVER_DESTROYED("Invalid response"); didReceiveMessageError(1002, message); break; } // expected_101_status_code case 2: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Expected 101 status code"); + const String& message = LAZY_NEVER_DESTROYED("Expected 101 status code"); didReceiveMessageError(1002, message); break; } // missing_upgrade_header case 3: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Missing upgrade header"); + const String& message = LAZY_NEVER_DESTROYED("Missing upgrade header"); didReceiveMessageError(1002, message); break; } // missing_connection_header case 4: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Missing connection header"); + const String& message = LAZY_NEVER_DESTROYED("Missing connection header"); didReceiveMessageError(1002, message); break; } // missing_websocket_accept_header case 5: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Missing websocket accept header"); + const String& message = LAZY_NEVER_DESTROYED("Missing websocket accept header"); didReceiveMessageError(1002, message); break; } // invalid_upgrade_header case 6: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Invalid upgrade header"); + const String& message = LAZY_NEVER_DESTROYED("Invalid upgrade header"); didReceiveMessageError(1002, message); break; } // invalid_connection_header case 7: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Invalid connection header"); + const String& message = LAZY_NEVER_DESTROYED("Invalid connection header"); didReceiveMessageError(1002, message); break; } // invalid_websocket_version case 8: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Invalid websocket version"); + const String& message = LAZY_NEVER_DESTROYED("Invalid websocket version"); didReceiveMessageError(1002, message); break; } // mismatch_websocket_accept_header case 9: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Mismatch websocket accept header"); + const String& message = LAZY_NEVER_DESTROYED("Mismatch websocket accept header"); didReceiveMessageError(1002, message); break; } // missing_client_protocol case 10: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Missing client protocol"); + const String& message = LAZY_NEVER_DESTROYED("Missing client protocol"); didReceiveMessageError(1002, message); break; } // mismatch_client_protocol case 11: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Mismatch client protocol"); + const String& message = LAZY_NEVER_DESTROYED("Mismatch client protocol"); didReceiveMessageError(1002, message); break; } // timeout case 12: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Timeout"); + const String& message = LAZY_NEVER_DESTROYED("Timeout"); didReceiveMessageError(1013, message); break; } // closed case 13: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Closed by client"); + const String& message = LAZY_NEVER_DESTROYED("Closed by client"); didReceiveMessageError(1000, message); break; } // failed_to_write case 14: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Failed to write"); + const String& message = LAZY_NEVER_DESTROYED("Failed to write"); didReceiveMessageError(1006, message); break; } // failed_to_connect case 15: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Failed to connect"); + const String& message = LAZY_NEVER_DESTROYED("Failed to connect"); didReceiveMessageError(1006, message); break; } // headers_too_large case 16: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Headers too large"); + const String& message = LAZY_NEVER_DESTROYED("Headers too large"); didReceiveMessageError(1007, message); break; } // ended case 17: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Closed by server"); + const String& message = LAZY_NEVER_DESTROYED("Closed by server"); didReceiveMessageError(1001, message); break; } // failed_to_allocate_memory case 18: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Failed to allocate memory"); + const String& message = LAZY_NEVER_DESTROYED("Failed to allocate memory"); didReceiveMessageError(1001, message); break; } // control_frame_is_fragmented case 19: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - control frame is fragmented"); + const String& message = LAZY_NEVER_DESTROYED("Protocol error - control frame is fragmented"); didReceiveMessageError(1002, message); break; } // invalid_control_frame case 20: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - invalid control frame"); + const String& message = LAZY_NEVER_DESTROYED("Protocol error - invalid control frame"); didReceiveMessageError(1002, message); break; } // compression_unsupported case 21: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Compression not implemented yet"); + const String& message = LAZY_NEVER_DESTROYED("Compression not implemented yet"); didReceiveMessageError(1011, message); break; } // unexpected_mask_from_server case 22: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - unexpected mask from server"); + const String& message = LAZY_NEVER_DESTROYED("Protocol error - unexpected mask from server"); didReceiveMessageError(1002, message); break; } // expected_control_frame case 23: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - expected control frame"); + const String& message = LAZY_NEVER_DESTROYED("Protocol error - expected control frame"); didReceiveMessageError(1002, message); break; } // unsupported_control_frame case 24: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - unsupported control frame"); + const String& message = LAZY_NEVER_DESTROYED("Protocol error - unsupported control frame"); didReceiveMessageError(1002, message); break; } // unexpected_opcode case 25: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - unexpected opcode"); + const String& message = LAZY_NEVER_DESTROYED("Protocol error - unexpected opcode"); didReceiveMessageError(1002, message); break; } // invalid_utf8 case 26: { - static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Server sent invalid UTF8"); + const String& message = LAZY_NEVER_DESTROYED("Server sent invalid UTF8"); didReceiveMessageError(1003, message); break; } -- cgit v1.2.3 From f8abd167d86b94da817d91631ef0137b019a9999 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 04:17:07 -0700 Subject: Revert "make these strings lazy" This reverts commit 777f98bd1068239033718c44bdcfca87e58a91d5. --- src/bun.js/bindings/webcore/WebSocket.cpp | 63 +++++++++++++------------------ 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/src/bun.js/bindings/webcore/WebSocket.cpp b/src/bun.js/bindings/webcore/WebSocket.cpp index 519b86d59..a346175df 100644 --- a/src/bun.js/bindings/webcore/WebSocket.cpp +++ b/src/bun.js/bindings/webcore/WebSocket.cpp @@ -1032,17 +1032,6 @@ void WebSocket::didConnect(us_socket_t* socket, char* bufferedData, size_t buffe this->didConnect(); } - -#define LAZY_NEVER_DESTROYED(name) \ - ([]() -> const String& { \ - static LazyNeverDestroyed str; \ - static std::once_flag onceFlag; \ - std::call_once(onceFlag, [] { \ - str.construct(MAKE_STATIC_STRING_IMPL(name)); \ - }); \ - return str; \ - })() - void WebSocket::didFailWithErrorCode(int32_t code) { // from new WebSocket() -> connect() @@ -1061,158 +1050,158 @@ void WebSocket::didFailWithErrorCode(int32_t code) } // invalid_response case 1: { - const String& message = LAZY_NEVER_DESTROYED("Invalid response"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Invalid response"); didReceiveMessageError(1002, message); break; } // expected_101_status_code case 2: { - const String& message = LAZY_NEVER_DESTROYED("Expected 101 status code"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Expected 101 status code"); didReceiveMessageError(1002, message); break; } // missing_upgrade_header case 3: { - const String& message = LAZY_NEVER_DESTROYED("Missing upgrade header"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Missing upgrade header"); didReceiveMessageError(1002, message); break; } // missing_connection_header case 4: { - const String& message = LAZY_NEVER_DESTROYED("Missing connection header"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Missing connection header"); didReceiveMessageError(1002, message); break; } // missing_websocket_accept_header case 5: { - const String& message = LAZY_NEVER_DESTROYED("Missing websocket accept header"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Missing websocket accept header"); didReceiveMessageError(1002, message); break; } // invalid_upgrade_header case 6: { - const String& message = LAZY_NEVER_DESTROYED("Invalid upgrade header"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Invalid upgrade header"); didReceiveMessageError(1002, message); break; } // invalid_connection_header case 7: { - const String& message = LAZY_NEVER_DESTROYED("Invalid connection header"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Invalid connection header"); didReceiveMessageError(1002, message); break; } // invalid_websocket_version case 8: { - const String& message = LAZY_NEVER_DESTROYED("Invalid websocket version"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Invalid websocket version"); didReceiveMessageError(1002, message); break; } // mismatch_websocket_accept_header case 9: { - const String& message = LAZY_NEVER_DESTROYED("Mismatch websocket accept header"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Mismatch websocket accept header"); didReceiveMessageError(1002, message); break; } // missing_client_protocol case 10: { - const String& message = LAZY_NEVER_DESTROYED("Missing client protocol"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Missing client protocol"); didReceiveMessageError(1002, message); break; } // mismatch_client_protocol case 11: { - const String& message = LAZY_NEVER_DESTROYED("Mismatch client protocol"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Mismatch client protocol"); didReceiveMessageError(1002, message); break; } // timeout case 12: { - const String& message = LAZY_NEVER_DESTROYED("Timeout"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Timeout"); didReceiveMessageError(1013, message); break; } // closed case 13: { - const String& message = LAZY_NEVER_DESTROYED("Closed by client"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Closed by client"); didReceiveMessageError(1000, message); break; } // failed_to_write case 14: { - const String& message = LAZY_NEVER_DESTROYED("Failed to write"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Failed to write"); didReceiveMessageError(1006, message); break; } // failed_to_connect case 15: { - const String& message = LAZY_NEVER_DESTROYED("Failed to connect"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Failed to connect"); didReceiveMessageError(1006, message); break; } // headers_too_large case 16: { - const String& message = LAZY_NEVER_DESTROYED("Headers too large"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Headers too large"); didReceiveMessageError(1007, message); break; } // ended case 17: { - const String& message = LAZY_NEVER_DESTROYED("Closed by server"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Closed by server"); didReceiveMessageError(1001, message); break; } // failed_to_allocate_memory case 18: { - const String& message = LAZY_NEVER_DESTROYED("Failed to allocate memory"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Failed to allocate memory"); didReceiveMessageError(1001, message); break; } // control_frame_is_fragmented case 19: { - const String& message = LAZY_NEVER_DESTROYED("Protocol error - control frame is fragmented"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - control frame is fragmented"); didReceiveMessageError(1002, message); break; } // invalid_control_frame case 20: { - const String& message = LAZY_NEVER_DESTROYED("Protocol error - invalid control frame"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - invalid control frame"); didReceiveMessageError(1002, message); break; } // compression_unsupported case 21: { - const String& message = LAZY_NEVER_DESTROYED("Compression not implemented yet"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Compression not implemented yet"); didReceiveMessageError(1011, message); break; } // unexpected_mask_from_server case 22: { - const String& message = LAZY_NEVER_DESTROYED("Protocol error - unexpected mask from server"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - unexpected mask from server"); didReceiveMessageError(1002, message); break; } // expected_control_frame case 23: { - const String& message = LAZY_NEVER_DESTROYED("Protocol error - expected control frame"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - expected control frame"); didReceiveMessageError(1002, message); break; } // unsupported_control_frame case 24: { - const String& message = LAZY_NEVER_DESTROYED("Protocol error - unsupported control frame"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - unsupported control frame"); didReceiveMessageError(1002, message); break; } // unexpected_opcode case 25: { - const String& message = LAZY_NEVER_DESTROYED("Protocol error - unexpected opcode"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Protocol error - unexpected opcode"); didReceiveMessageError(1002, message); break; } // invalid_utf8 case 26: { - const String& message = LAZY_NEVER_DESTROYED("Server sent invalid UTF8"); + static NeverDestroyed message = MAKE_STATIC_STRING_IMPL("Server sent invalid UTF8"); didReceiveMessageError(1003, message); break; } -- cgit v1.2.3 From c4c714f10b033d1317cc609ded7310d3b0e2a8cc Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 25 Jun 2023 04:52:43 -0700 Subject: Speculative fix for regression causing a hang with `install --production` (#3400) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/install/lockfile.zig | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index 04c6ccec1..ce9199ab3 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -343,31 +343,23 @@ pub const Tree = struct { dependencies: []const Dependency, resolution_lists: []const Lockfile.DependencyIDSlice, queue: Lockfile.TreeFiller, - log: ?*logger.Log = null, - old_lockfile: ?*Lockfile = null, + log: *logger.Log, + old_lockfile: *Lockfile, pub fn maybeReportError(this: *Builder, comptime fmt: string, args: anytype) void { - var log = this.log orelse return; - if (this.old_lockfile == null) return; - - log.addErrorFmt(null, logger.Loc.Empty, this.allocator, fmt, args) catch {}; + this.log.addErrorFmt(null, logger.Loc.Empty, this.allocator, fmt, args) catch {}; } pub fn buf(this: *const Builder) []const u8 { - var lockfile = this.old_lockfile orelse return ""; - return lockfile.buffers.string_bytes.items; + return this.old_lockfile.buffers.string_bytes.items; } pub fn packageName(this: *Builder, id: PackageID) String.Formatter { - var lockfile = this.old_lockfile orelse return undefined; - - return lockfile.packages.items(.name)[id].fmt(lockfile.buffers.string_bytes.items); + return this.old_lockfile.packages.items(.name)[id].fmt(this.old_lockfile.buffers.string_bytes.items); } pub fn packageVersion(this: *Builder, id: PackageID) Resolution.Formatter { - var lockfile = this.old_lockfile orelse return undefined; - - return lockfile.packages.items(.resolution)[id].fmt(lockfile.buffers.string_bytes.items); + return this.old_lockfile.packages.items(.resolution)[id].fmt(this.old_lockfile.buffers.string_bytes.items); } pub const Entry = struct { @@ -499,15 +491,14 @@ pub const Tree = struct { if (dep.name_hash != dependency.name_hash) continue; if (builder.resolutions[dep_id] != package_id) { if (as_defined and !dep.behavior.isPeer()) { - if (builder.log != null) - builder.maybeReportError("Package \"{}@{}\" has a dependency loop\n Resolution: \"{}@{}\"\n Dependency: \"{}@{}\"", .{ - builder.packageName(package_id), - builder.packageVersion(package_id), - builder.packageName(builder.resolutions[dep_id]), - builder.packageVersion(builder.resolutions[dep_id]), - dependency.name.fmt(builder.buf()), - dependency.version.literal.fmt(builder.buf()), - }); + builder.maybeReportError("Package \"{}@{}\" has a dependency loop\n Resolution: \"{}@{}\"\n Dependency: \"{}@{}\"", .{ + builder.packageName(package_id), + builder.packageVersion(package_id), + builder.packageName(builder.resolutions[dep_id]), + builder.packageVersion(builder.resolutions[dep_id]), + dependency.name.fmt(builder.buf()), + dependency.version.literal.fmt(builder.buf()), + }); return error.DependencyLoop; } // ignore versioning conflicts caused by peer dependencies @@ -629,10 +620,19 @@ fn preprocessUpdateRequests(old: *Lockfile, updates: []PackageManager.UpdateRequ } } pub fn clean(old: *Lockfile, updates: []PackageManager.UpdateRequest) !*Lockfile { - return old.cleanWithLogger(updates, null); + // This is wasteful, but we rarely log anything so it's fine. + var log = logger.Log.init(bun.default_allocator); + defer { + for (log.msgs.items) |*item| { + item.deinit(bun.default_allocator); + } + log.deinit(); + } + + return old.cleanWithLogger(updates, &log); } -pub fn cleanWithLogger(old: *Lockfile, updates: []PackageManager.UpdateRequest, log: ?*logger.Log) !*Lockfile { +pub fn cleanWithLogger(old: *Lockfile, updates: []PackageManager.UpdateRequest, log: *logger.Log) !*Lockfile { const old_scripts = old.scripts; // We will only shrink the number of packages here. // never grow @@ -780,7 +780,7 @@ const Cloner = struct { mapping: []PackageID, trees: Tree.List = Tree.List{}, trees_count: u32 = 1, - log: ?*logger.Log = null, + log: *logger.Log, pub fn flush(this: *Cloner) anyerror!void { const max_package_id = this.old.packages.len; -- cgit v1.2.3 From aa5432e162be03dbeddb25c5145169859eaeef32 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:33:13 -0700 Subject: FIx launch.json cwd --- .vscode/launch.json | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index ea8218179..22c8bdadd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,7 +14,8 @@ "name": "bun test [file]", "program": "bun-debug", "args": ["test", "${file}"], - "cwd": "${fileDirname}", + // The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI. + "cwd": "${workspaceFolder}/test", "env": { "FORCE_COLOR": "1", "BUN_DEBUG_QUIET_LOGS": "1", @@ -29,7 +30,8 @@ "name": "bun test [file] (fast)", "program": "bun-debug", "args": ["test", "${file}"], - "cwd": "${fileDirname}", + // The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI. + "cwd": "${workspaceFolder}/test", "env": { "FORCE_COLOR": "1", "BUN_DEBUG_QUIET_LOGS": "1" @@ -44,7 +46,8 @@ "name": "bun test [file] (verbose)", "program": "bun-debug", "args": ["test", "${file}"], - "cwd": "${fileDirname}", + // The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI. + "cwd": "${workspaceFolder}/test", "env": { "FORCE_COLOR": "1" }, @@ -57,7 +60,8 @@ "name": "bun test [file] --watch", "program": "bun-debug", "args": ["test", "--watch", "${file}"], - "cwd": "${fileDirname}", + // The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI. + "cwd": "${workspaceFolder}/test", "env": { "FORCE_COLOR": "1", "BUN_DEBUG_QUIET_LOGS": "1" @@ -71,7 +75,8 @@ "name": "bun test [file] --only", "program": "bun-debug", "args": ["test", "--only", "${file}"], - "cwd": "${fileDirname}", + // The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI. + "cwd": "${workspaceFolder}/test", "env": { "FORCE_COLOR": "1", "BUN_DEBUG_QUIET_LOGS": "1" @@ -100,6 +105,7 @@ "name": "bun test [*] (fast)", "program": "bun-debug", "args": ["test"], + // The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI. "cwd": "${workspaceFolder}/test", "env": { "FORCE_COLOR": "1", @@ -114,6 +120,7 @@ "name": "bun test [*] --only", "program": "bun-debug", "args": ["test", "--only"], + // The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI. "cwd": "${workspaceFolder}/test", "env": { "FORCE_COLOR": "1", -- cgit v1.2.3 From 5bd94b8f47efab5ca736e6ec76b72e991df1da11 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:43:54 -0700 Subject: Add `process.mainModule` --- src/bun.js/bindings/Process.cpp | 12 ++++++++++++ test/cli/run/require-cache-fixture.cjs | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 69ee11e60..a369faee2 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -10,6 +10,7 @@ #include "ImportMetaObject.h" #include #include "ZigConsoleClient.h" +#include #pragma mark - Node.js Process namespace Zig { @@ -787,6 +788,17 @@ void Process::finishCreation(JSC::VM& vm) this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "emitWarning"_s), 1, Process_emitWarning, ImplementationVisibility::Public, NoIntrinsic, 0); + + JSC::JSFunction* requireDotMainFunction = JSFunction::create( + vm, + moduleMainCodeGenerator(vm), + globalObject->globalScope()); + // https://nodejs.org/api/process.html#processmainmodule + this->putDirect( + vm, + JSC::Identifier::fromString(vm, "mainModule"_s), + JSC::GetterSetter::create(vm, globalObject, requireDotMainFunction, JSValue()), + PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); } const JSC::ClassInfo Process::s_info = { "Process"_s, &Base::s_info, nullptr, nullptr, diff --git a/test/cli/run/require-cache-fixture.cjs b/test/cli/run/require-cache-fixture.cjs index ce02b86d7..838be9ceb 100644 --- a/test/cli/run/require-cache-fixture.cjs +++ b/test/cli/run/require-cache-fixture.cjs @@ -8,6 +8,11 @@ if (require.main !== module) { throw new Error("require.main !== module"); } +if (process.mainModule !== module) { + console.error(__filename, module.id); + throw new Error("process.mainModule !== module"); +} + if (__filename !== resolve(module.filename)) { console.error(__filename, module.id); throw new Error("__filename !== module.id"); -- cgit v1.2.3 From 33903ea892db861416f1f68d4c40536540719f4e Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 26 Jun 2023 01:43:58 +0300 Subject: [install] fix hang in `bun install --production` (#3406) --- src/install/lockfile.zig | 13 +++++----- test/cli/install/bun-install.test.ts | 49 ++++++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index ce9199ab3..b17691853 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -2033,19 +2033,20 @@ pub const Package = extern struct { cloner.trees_count += @as(u32, @intFromBool(old_resolutions.len > 0)); - for (old_resolutions, 0..) |old_resolution, i| { - if (old_resolution >= max_package_id) continue; + for (old_resolutions, resolutions, 0..) |old_resolution, *resolution, i| { + if (old_resolution >= max_package_id) { + resolution.* = invalid_package_id; + continue; + } const mapped = package_id_mapping[old_resolution]; - const resolve_id = new_package.resolutions.off + @intCast(PackageID, i); - if (mapped < max_package_id) { - resolutions[i] = mapped; + resolution.* = mapped; } else { try cloner.clone_queue.append(.{ .old_resolution = old_resolution, .parent = new_package.meta.id, - .resolve_id = resolve_id, + .resolve_id = new_package.resolutions.off + @intCast(PackageID, i), }); } } diff --git a/test/cli/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts index f44dc5a7e..4b3342e3a 100644 --- a/test/cli/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -4259,7 +4259,11 @@ it("should perform bin-linking across multiple dependencies", async () => { cache = false `, ); - const { stdout, stderr, exited } = spawn({ + const { + stdout: stdout1, + stderr: stderr1, + exited: exited1, + } = spawn({ cmd: [bunExe(), "install"], cwd: package_dir, stdout: null, @@ -4267,13 +4271,13 @@ cache = false stderr: "pipe", env, }); - expect(stderr).toBeDefined(); - const err = await new Response(stderr).text(); - expect(err).toContain("Saved lockfile"); - expect(err).not.toContain("error:"); - expect(stdout).toBeDefined(); - const out = await new Response(stdout).text(); - expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ + expect(stderr1).toBeDefined(); + const err1 = await new Response(stderr1).text(); + expect(err1).toContain("Saved lockfile"); + expect(err1).not.toContain("error:"); + expect(stdout1).toBeDefined(); + const out1 = await new Response(stdout1).text(); + expect(out1.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + conditional-type-checks@1.0.6", " + prettier@2.8.8", " + tsd@0.22.0", @@ -4281,7 +4285,7 @@ cache = false "", " 119 packages installed", ]); - expect(await exited).toBe(0); + expect(await exited1).toBe(0); expect(await readdirSorted(package_dir)).toEqual(["bun.lockb", "bunfig.toml", "node_modules", "package.json"]); expect(await file(join(package_dir, "package.json")).text()).toEqual(foo_package); expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([ @@ -4394,4 +4398,29 @@ cache = false "tsd", "tsserver", ]); -}, 10000); + // Perform `bun install --production` with lockfile from before + await rm(join(package_dir, "node_modules"), { force: true, recursive: true }); + const { + stdout: stdout2, + stderr: stderr2, + exited: exited2, + } = spawn({ + cmd: [bunExe(), "install", "--production"], + cwd: package_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + expect(stderr2).toBeDefined(); + const err2 = await new Response(stderr2).text(); + expect(err2).not.toContain("Saved lockfile"); + expect(err2).not.toContain("error:"); + expect(stdout2).toBeDefined(); + const out2 = await new Response(stdout2).text(); + expect(out2.replace(/\[[0-9\.]+m?s\]/, "[]").split(/\r?\n/)).toEqual(["[] done", ""]); + expect(await exited2).toBe(0); + expect(await readdirSorted(package_dir)).toEqual(["bun.lockb", "bunfig.toml", "node_modules", "package.json"]); + expect(await file(join(package_dir, "package.json")).text()).toEqual(foo_package); + expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([]); +}, 20000); -- cgit v1.2.3 From fcf9f0a7eeb3d462d5c6c2110ecdf5a4460c1736 Mon Sep 17 00:00:00 2001 From: Ai Hoshino Date: Mon, 26 Jun 2023 07:15:56 +0800 Subject: Fix the parameters of WriteStream constructor. (#3402) * Fix the parameters of the `WriteStream` constructor. Close: https://github.com/oven-sh/bun/issues/3395 * test append mode in `createWriteStream` * fix lint * wait first stream finished --- src/js/node/fs.js | 4 ++-- test/js/node/fs/fs.test.ts | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/js/node/fs.js b/src/js/node/fs.js index 2bd752d19..8d9f0d235 100644 --- a/src/js/node/fs.js +++ b/src/js/node/fs.js @@ -642,8 +642,8 @@ WriteStream = (function (InternalWriteStream) { }); return Object.defineProperty( - function WriteStream(options) { - return new InternalWriteStream(options); + function WriteStream(path, options) { + return new InternalWriteStream(path, options); }, Symbol.hasInstance, { diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index 37c3253a4..0353968fe 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -1068,6 +1068,44 @@ describe("createWriteStream", () => { expect(exception.code).toBe("ERR_INVALID_ARG_TYPE"); } }); + + it("writing in append mode should not truncate the file", async () => { + const path = `${tmpdir()}/fs.test.js/${Date.now()}.createWriteStreamAppend.txt`; + const stream = createWriteStream(path, { + // @ts-ignore-next-line + flags: "a", + }); + stream.write("first line\n"); + stream.end(); + + await new Promise((resolve, reject) => { + stream.on("error", e => { + reject(e); + }); + + stream.on("finish", () => { + resolve(true); + }); + }); + + const stream2 = createWriteStream(path, { + // @ts-ignore-next-line + flags: "a", + }); + stream2.write("second line\n"); + stream2.end(); + + return await new Promise((resolve, reject) => { + stream2.on("error", e => { + reject(e); + }); + + stream2.on("finish", () => { + expect(readFileSync(path, "utf8")).toBe("first line\nsecond line\n"); + resolve(true); + }); + }); + }); }); describe("fs/promises", () => { -- cgit v1.2.3 From 3ed28f2828a29129a1791b7a4f6935d842d6493c Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Sun, 25 Jun 2023 20:16:25 -0300 Subject: [fs.watch] fix reference/deinit (#3396) * fix js reference * fix close oops * refactor + hasPendingActivity * fmt * fix race conditions * fixup * add test calling close on error event * fix close inside close + test * cleanup --- src/bun.js/WebKit | 2 +- src/bun.js/bindings/JSSink.cpp | 2 +- src/bun.js/bindings/JSSink.h | 2 +- src/bun.js/bindings/ZigGeneratedClasses.cpp | 10 + src/bun.js/bindings/ZigGeneratedClasses.h | 27 ++ src/bun.js/bindings/generated_classes.zig | 1 + src/bun.js/bindings/generated_classes_list.zig | 2 +- src/bun.js/node/node.classes.ts | 1 + src/bun.js/node/node_fs_watcher.zig | 500 +++++++++++++------------ src/watcher.zig | 20 +- test/js/node/watch/fs.watch.test.js | 45 ++- 11 files changed, 352 insertions(+), 260 deletions(-) diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit index 4c8ab8fdf..b2f1006a0 160000 --- a/src/bun.js/WebKit +++ b/src/bun.js/WebKit @@ -1 +1 @@ -Subproject commit 4c8ab8fdfb102522fdd8e55d4eea53e8ce2755c2 +Subproject commit b2f1006a06f81bc860c89dd4c7cec3e7117c4c4c diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index 4acf01ff7..19bf05599 100644 --- a/src/bun.js/bindings/JSSink.cpp +++ b/src/bun.js/bindings/JSSink.cpp @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-06-14T21:38:04.394Z +// Generated by 'make generate-sink' at 2023-06-25T17:34:54.187Z // To regenerate this file, run: // // make generate-sink diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h index 37c458e9b..9bf5554c4 100644 --- a/src/bun.js/bindings/JSSink.h +++ b/src/bun.js/bindings/JSSink.h @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-06-14T21:38:04.394Z +// Generated by 'make generate-sink' at 2023-06-25T17:34:54.186Z // #pragma once diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp index e0a3f33d6..387580d54 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.cpp +++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp @@ -5565,6 +5565,12 @@ void JSFSWatcherPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* glob JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } +extern "C" bool FSWatcher__hasPendingActivity(void* ptr); +bool JSFSWatcher::hasPendingActivity(void* ctx) +{ + return FSWatcher__hasPendingActivity(ctx); +} + JSFSWatcher::~JSFSWatcher() { if (m_ctx) { @@ -5649,6 +5655,8 @@ void JSFSWatcher::visitChildrenImpl(JSCell* cell, Visitor& visitor) ASSERT_GC_OBJECT_INHERITS(thisObject, info()); Base::visitChildren(thisObject, visitor); visitor.append(thisObject->m_listener); + + visitor.addOpaqueRoot(thisObject->wrapped()); } DEFINE_VISIT_CHILDREN(JSFSWatcher); @@ -5659,6 +5667,8 @@ void JSFSWatcher::visitAdditionalChildren(Visitor& visitor) JSFSWatcher* thisObject = this; ASSERT_GC_OBJECT_INHERITS(thisObject, info()); visitor.append(thisObject->m_listener); + + visitor.addOpaqueRoot(this->wrapped()); } DEFINE_VISIT_ADDITIONAL_CHILDREN(JSFSWatcher); diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h index 3fa0e26d2..1631f960e 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.h +++ b/src/bun.js/bindings/ZigGeneratedClasses.h @@ -623,10 +623,37 @@ public: : Base(vm, structure) { m_ctx = sinkPtr; + m_weakThis = JSC::Weak(this, getOwner()); } void finishCreation(JSC::VM&); + JSC::Weak m_weakThis; + + static bool hasPendingActivity(void* ctx); + + class Owner final : public JSC::WeakHandleOwner { + public: + bool isReachableFromOpaqueRoots(JSC::Handle handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final + { + auto* controller = JSC::jsCast(handle.slot()->asCell()); + if (JSFSWatcher::hasPendingActivity(controller->wrapped())) { + if (UNLIKELY(reason)) + *reason = "has pending activity"; + return true; + } + + return visitor.containsOpaqueRoot(context); + } + void finalize(JSC::Handle, void* context) final {} + }; + + static JSC::WeakHandleOwner* getOwner() + { + static NeverDestroyed m_owner; + return &m_owner.get(); + } + DECLARE_VISIT_CHILDREN; template void visitAdditionalChildren(Visitor&); DECLARE_VISIT_OUTPUT_CONSTRAINTS; diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig index 74e30cd83..bdde69c1a 100644 --- a/src/bun.js/bindings/generated_classes.zig +++ b/src/bun.js/bindings/generated_classes.zig @@ -1492,6 +1492,7 @@ pub const JSFSWatcher = struct { @export(FSWatcher.doRef, .{ .name = "FSWatcherPrototype__doRef" }); @export(FSWatcher.doUnref, .{ .name = "FSWatcherPrototype__doUnref" }); @export(FSWatcher.finalize, .{ .name = "FSWatcherClass__finalize" }); + @export(FSWatcher.hasPendingActivity, .{ .name = "FSWatcher__hasPendingActivity" }); @export(FSWatcher.hasRef, .{ .name = "FSWatcherPrototype__hasRef" }); } } diff --git a/src/bun.js/bindings/generated_classes_list.zig b/src/bun.js/bindings/generated_classes_list.zig index d90267337..543d492b5 100644 --- a/src/bun.js/bindings/generated_classes_list.zig +++ b/src/bun.js/bindings/generated_classes_list.zig @@ -37,5 +37,5 @@ pub const Classes = struct { pub const BuildArtifact = JSC.API.BuildArtifact; pub const BuildMessage = JSC.BuildMessage; pub const ResolveMessage = JSC.ResolveMessage; - pub const FSWatcher = JSC.Node.FSWatcher.JSObject; + pub const FSWatcher = JSC.Node.FSWatcher; }; diff --git a/src/bun.js/node/node.classes.ts b/src/bun.js/node/node.classes.ts index ce35c940a..2efad5245 100644 --- a/src/bun.js/node/node.classes.ts +++ b/src/bun.js/node/node.classes.ts @@ -7,6 +7,7 @@ export default [ noConstructor: true, finalize: true, configurable: false, + hasPendingActivity: true, klass: {}, JSType: "0b11101110", proto: { diff --git a/src/bun.js/node/node_fs_watcher.zig b/src/bun.js/node/node_fs_watcher.zig index 397d51916..b1f4ec8a9 100644 --- a/src/bun.js/node/node_fs_watcher.zig +++ b/src/bun.js/node/node_fs_watcher.zig @@ -4,6 +4,7 @@ const bun = @import("root").bun; const Fs = @import("../../fs.zig"); const Path = @import("../../resolver/resolve_path.zig"); const Encoder = JSC.WebCore.Encoder; +const Mutex = @import("../../lock.zig").Lock; const FSEvents = @import("./fs_events.zig"); @@ -30,17 +31,28 @@ pub const FSWatcher = struct { onAccept: std.ArrayHashMapUnmanaged(FSWatcher.Watcher.HashType, bun.BabyList(OnAcceptCallback), bun.ArrayIdentityContext, false) = .{}, ctx: *VirtualMachine, - js_watcher: ?*JSObject = null, - watcher_instance: ?*FSWatcher.Watcher = null, verbose: bool = false, file_paths: bun.BabyList(string) = .{}, entry_path: ?string = null, entry_dir: string = "", last_change_event: ChangeEvent = .{}, - pub fn toJS(this: *FSWatcher) JSC.JSValue { - return if (this.js_watcher) |js| js.js_this else JSC.JSValue.jsUndefined(); - } + // JSObject + mutex: Mutex, + signal: ?*JSC.AbortSignal, + persistent: bool, + default_watcher: ?*FSWatcher.Watcher, + fsevents_watcher: ?*FSEvents.FSEventsWatcher, + poll_ref: JSC.PollRef = .{}, + globalThis: *JSC.JSGlobalObject, + js_this: JSC.JSValue, + encoding: JSC.Node.Encoding, + // user can call close and pre-detach so we need to track this + closed: bool, + // counts pending tasks so we only deinit after all tasks are done + task_count: u32, + has_pending_activity: std.atomic.Atomic(bool), + pub usingnamespace JSC.Codegen.JSFSWatcher; pub fn eventLoop(this: FSWatcher) *EventLoop { return this.ctx.eventLoop(); @@ -51,6 +63,9 @@ pub const FSWatcher = struct { } pub fn deinit(this: *FSWatcher) void { + // stop all managers and signals + this.detach(); + while (this.file_paths.popOrNull()) |file_path| { bun.default_allocator.destroy(file_path); } @@ -107,41 +122,47 @@ pub const FSWatcher = struct { } pub fn run(this: *FSWatchTask) void { - // this runs on JS Context - if (this.ctx.js_watcher) |js_watcher| { - for (this.entries[0..this.count]) |entry| { - switch (entry.event_type) { - .rename => { - js_watcher.emit(entry.file_path, "rename"); - }, - .change => { - js_watcher.emit(entry.file_path, "change"); - }, - .@"error" => { - // file_path is the error message in this case - js_watcher.emitError(entry.file_path); - }, - .abort => { - js_watcher.emitIfAborted(); - }, - } + // this runs on JS Context Thread + + for (this.entries[0..this.count]) |entry| { + switch (entry.event_type) { + .rename => { + this.ctx.emit(entry.file_path, "rename"); + }, + .change => { + this.ctx.emit(entry.file_path, "change"); + }, + .@"error" => { + // file_path is the error message in this case + this.ctx.emitError(entry.file_path); + }, + .abort => { + this.ctx.emitIfAborted(); + }, } } + + this.ctx.unrefTask(); } pub fn enqueue(this: *FSWatchTask) void { if (this.count == 0) return; - var that = bun.default_allocator.create(FSWatchTask) catch unreachable; + // if false is closed or detached (can still contain valid refs but will not create a new one) + if (this.ctx.refTask()) { + var that = bun.default_allocator.create(FSWatchTask) catch unreachable; - that.* = this.*; - this.count = 0; - that.concurrent_task.task = JSC.Task.init(that); - this.ctx.enqueueTaskConcurrent(&that.concurrent_task); + that.* = this.*; + this.count = 0; + that.concurrent_task.task = JSC.Task.init(that); + this.ctx.enqueueTaskConcurrent(&that.concurrent_task); + return; + } + // closed or detached so just cleanEntries + this.cleanEntries(); } - - pub fn deinit(this: *FSWatchTask) void { + pub fn cleanEntries(this: *FSWatchTask) void { while (this.count > 0) { this.count -= 1; switch (this.entries[this.count].free_type) { @@ -150,6 +171,10 @@ pub const FSWatcher = struct { else => {}, } } + } + + pub fn deinit(this: *FSWatchTask) void { + this.cleanEntries(); bun.default_allocator.destroy(this); } }; @@ -275,7 +300,7 @@ pub const FSWatcher = struct { const kinds = slice.items(.kind); var _on_file_update_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; - var ctx = this.watcher_instance.?; + var ctx = this.default_watcher.?; defer ctx.flushEvictions(); defer Output.flush(); @@ -540,241 +565,225 @@ pub const FSWatcher = struct { pub fn createFSWatcher(this: Arguments) !JSC.JSValue { const obj = try FSWatcher.init(this); - return obj.toJS(); + if (obj.js_this != .zero) { + return obj.js_this; + } + return JSC.JSValue.jsUndefined(); } }; - pub const JSObject = struct { - signal: ?*JSC.AbortSignal, - persistent: bool, - manager: ?*FSWatcher.Watcher, - fsevents_watcher: ?*FSEvents.FSEventsWatcher, - poll_ref: JSC.PollRef = .{}, - globalThis: ?*JSC.JSGlobalObject, - js_this: JSC.JSValue, - encoding: JSC.Node.Encoding, - closed: bool, - - pub usingnamespace JSC.Codegen.JSFSWatcher; - - pub fn getFSWatcher(this: *JSObject) *FSWatcher { - if (this.manager) |manager| return manager.ctx; - if (this.fsevents_watcher) |manager| return bun.cast(*FSWatcher, manager.ctx.?); - - @panic("No context attached to JSFSWatcher"); + pub fn initJS(this: *FSWatcher, listener: JSC.JSValue) void { + if (this.persistent) { + this.poll_ref.ref(this.ctx); } - pub fn init(globalThis: *JSC.JSGlobalObject, manager: ?*FSWatcher.Watcher, fsevents_watcher: ?*FSEvents.FSEventsWatcher, signal: ?*JSC.AbortSignal, listener: JSC.JSValue, persistent: bool, encoding: JSC.Node.Encoding) !*JSObject { - var obj = try globalThis.allocator().create(JSObject); - obj.* = .{ - .signal = null, - .persistent = persistent, - .manager = manager, - .fsevents_watcher = fsevents_watcher, - .globalThis = globalThis, - .js_this = .zero, - .encoding = encoding, - .closed = false, - }; - const instance = obj.getFSWatcher(); - - if (persistent) { - obj.poll_ref.ref(instance.ctx); - } - - var js_this = JSObject.toJS(obj, globalThis); - JSObject.listenerSetCached(js_this, globalThis, listener); - obj.js_this = js_this; - obj.js_this.protect(); - - if (signal) |s| { - - // already aborted? - if (s.aborted()) { - obj.signal = s.ref(); - // abort next tick - var current_task: FSWatchTask = .{ - .ctx = instance, - }; - current_task.append("", .abort, .none); - current_task.enqueue(); - } else { - // watch for abortion - obj.signal = s.ref().listen(JSObject, obj, JSObject.emitAbort); - } + const js_this = FSWatcher.toJS(this, this.globalThis); + js_this.ensureStillAlive(); + this.js_this = js_this; + FSWatcher.listenerSetCached(js_this, this.globalThis, listener); + + if (this.signal) |s| { + // already aborted? + if (s.aborted()) { + // safely abort next tick + var current_task: FSWatchTask = .{ + .ctx = this, + }; + current_task.append("", .abort, .none); + current_task.enqueue(); + } else { + // watch for abortion + this.signal = s.listen(FSWatcher, this, FSWatcher.emitAbort); } - return obj; } + } - pub fn emitIfAborted(this: *JSObject) void { - if (this.signal) |s| { - if (s.aborted()) { - const err = s.abortReason(); - this.emitAbort(err); - } + pub fn emitIfAborted(this: *FSWatcher) void { + if (this.signal) |s| { + if (s.aborted()) { + const err = s.abortReason(); + this.emitAbort(err); } } + } - pub fn emitAbort(this: *JSObject, err: JSC.JSValue) void { - if (this.closed) return; - defer this.close(true); - - err.ensureStillAlive(); - - if (this.globalThis) |globalThis| { - if (this.js_this != .zero) { - if (JSObject.listenerGetCached(this.js_this)) |listener| { - var args = [_]JSC.JSValue{ - JSC.ZigString.static("error").toValue(globalThis), - if (err.isEmptyOrUndefinedOrNull()) JSC.WebCore.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, globalThis) else err, - }; - _ = listener.callWithGlobalThis( - globalThis, - &args, - ); - } - } + pub fn emitAbort(this: *FSWatcher, err: JSC.JSValue) void { + if (this.closed) return; + defer this.close(); + + err.ensureStillAlive(); + if (this.js_this != .zero) { + const js_this = this.js_this; + js_this.ensureStillAlive(); + if (FSWatcher.listenerGetCached(js_this)) |listener| { + listener.ensureStillAlive(); + var args = [_]JSC.JSValue{ + JSC.ZigString.static("error").toValue(this.globalThis), + if (err.isEmptyOrUndefinedOrNull()) JSC.WebCore.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, this.globalThis) else err, + }; + _ = listener.callWithGlobalThis( + this.globalThis, + &args, + ); } } - pub fn emitError(this: *JSObject, err: string) void { - if (this.closed) return; - defer this.close(true); - - if (this.globalThis) |globalThis| { - if (this.js_this != .zero) { - if (JSObject.listenerGetCached(this.js_this)) |listener| { - var args = [_]JSC.JSValue{ - JSC.ZigString.static("error").toValue(globalThis), - JSC.ZigString.fromUTF8(err).toErrorInstance(globalThis), - }; - _ = listener.callWithGlobalThis( - globalThis, - &args, - ); - } - } + } + pub fn emitError(this: *FSWatcher, err: string) void { + if (this.closed) return; + defer this.close(); + + if (this.js_this != .zero) { + const js_this = this.js_this; + js_this.ensureStillAlive(); + if (FSWatcher.listenerGetCached(js_this)) |listener| { + listener.ensureStillAlive(); + var args = [_]JSC.JSValue{ + JSC.ZigString.static("error").toValue(this.globalThis), + JSC.ZigString.fromUTF8(err).toErrorInstance(this.globalThis), + }; + _ = listener.callWithGlobalThis( + this.globalThis, + &args, + ); } } + } - pub fn emit(this: *JSObject, file_name: string, comptime eventType: string) void { - if (this.globalThis) |globalThis| { - if (this.js_this != .zero) { - if (JSObject.listenerGetCached(this.js_this)) |listener| { - var filename: JSC.JSValue = JSC.JSValue.jsUndefined(); - if (file_name.len > 0) { - if (this.encoding == .buffer) - filename = JSC.ArrayBuffer.createBuffer(globalThis, file_name) - else if (this.encoding == .utf8) { - filename = JSC.ZigString.fromUTF8(file_name).toValueGC(globalThis); - } else { - // convert to desired encoding - filename = Encoder.toStringAtRuntime(file_name.ptr, file_name.len, globalThis, this.encoding); - } - } - var args = [_]JSC.JSValue{ - JSC.ZigString.static(eventType).toValue(globalThis), - filename, - }; - _ = listener.callWithGlobalThis( - globalThis, - &args, - ); + pub fn emit(this: *FSWatcher, file_name: string, comptime eventType: string) void { + if (this.js_this != .zero) { + const js_this = this.js_this; + js_this.ensureStillAlive(); + if (FSWatcher.listenerGetCached(js_this)) |listener| { + listener.ensureStillAlive(); + var filename: JSC.JSValue = JSC.JSValue.jsUndefined(); + if (file_name.len > 0) { + if (this.encoding == .buffer) + filename = JSC.ArrayBuffer.createBuffer(this.globalThis, file_name) + else if (this.encoding == .utf8) { + filename = JSC.ZigString.fromUTF8(file_name).toValueGC(this.globalThis); + } else { + // convert to desired encoding + filename = Encoder.toStringAtRuntime(file_name.ptr, file_name.len, this.globalThis, this.encoding); } } + var args = [_]JSC.JSValue{ + JSC.ZigString.static(eventType).toValue(this.globalThis), + filename, + }; + _ = listener.callWithGlobalThis( + this.globalThis, + &args, + ); } } + } - pub fn ref(this: *JSObject) void { - if (this.closed) return; - - if (!this.persistent) { - this.persistent = true; - this.poll_ref.ref(this.getFSWatcher().ctx); - } - } - - pub fn doRef(this: *JSObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { - this.ref(); - return JSC.JSValue.jsUndefined(); + pub fn doRef(this: *FSWatcher, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + if (!this.closed and !this.persistent) { + this.persistent = true; + this.poll_ref.ref(this.ctx); } + return JSC.JSValue.jsUndefined(); + } - pub fn unref(this: *JSObject) void { - if (this.persistent) { - this.persistent = false; - this.poll_ref.unref(this.getFSWatcher().ctx); - } + pub fn doUnref(this: *FSWatcher, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + if (this.persistent) { + this.persistent = false; + this.poll_ref.unref(this.ctx); } + return JSC.JSValue.jsUndefined(); + } - pub fn doUnref(this: *JSObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { - this.unref(); - return JSC.JSValue.jsUndefined(); - } + pub fn hasRef(this: *FSWatcher, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + return JSC.JSValue.jsBoolean(this.persistent); + } - pub fn hasRef(this: *JSObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { - return JSC.JSValue.jsBoolean(this.persistent); - } + // this can be called from Watcher Thread or JS Context Thread + pub fn refTask(this: *FSWatcher) bool { + this.mutex.lock(); + defer this.mutex.unlock(); + // stop new references + if (this.closed) return false; + this.task_count += 1; + return true; + } - pub fn close( - this: *JSObject, - emitEvent: bool, - ) void { - if (!this.closed) { - if (this.signal) |signal| { - this.signal = null; - signal.detach(this); - } - this.closed = true; - if (emitEvent) { - this.emit("", "close"); - } + pub fn hasPendingActivity(this: *FSWatcher) callconv(.C) bool { + @fence(.Acquire); + return this.has_pending_activity.load(.Acquire); + } + // only called from Main Thread + pub fn updateHasPendingActivity(this: *FSWatcher) void { + @fence(.Release); + this.has_pending_activity.store(false, .Release); + } - this.detach(); - } + // unref is always called on main JS Context Thread + pub fn unrefTask(this: *FSWatcher) void { + this.mutex.lock(); + defer this.mutex.unlock(); + this.task_count -= 1; + if (this.closed and this.task_count == 0) { + this.updateHasPendingActivity(); } + } - pub fn detach(this: *JSObject) void { - this.unref(); + pub fn close( + this: *FSWatcher, + ) void { + this.mutex.lock(); + if (!this.closed) { + this.closed = true; - if (this.js_this != .zero) { - this.js_this.unprotect(); - this.js_this = .zero; - } + // emit should only be called unlocked + this.mutex.unlock(); - this.globalThis = null; + this.emit("", "close"); + // we immediately detach here + this.detach(); - if (this.signal) |signal| { - this.signal = null; - signal.detach(this); - } - if (this.manager) |manager| { - var ctx = manager.ctx; - this.manager = null; - ctx.js_watcher = null; - ctx.deinit(); - manager.deinit(true); + // no need to lock again, because ref checks closed and unref is only called on main thread + if (this.task_count == 0) { + this.updateHasPendingActivity(); } + } else { + this.mutex.unlock(); + } + } - if (this.fsevents_watcher) |manager| { - var ctx = bun.cast(*FSWatcher, manager.ctx.?); - ctx.js_watcher = null; - ctx.deinit(); - manager.deinit(); - } + // this can be called multiple times + pub fn detach(this: *FSWatcher) void { + if (this.persistent) { + this.persistent = false; + this.poll_ref.unref(this.ctx); } - pub fn doClose(this: *JSObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { - this.close(true); - return JSC.JSValue.jsUndefined(); + if (this.signal) |signal| { + this.signal = null; + signal.detach(this); } - pub fn finalize(this: *JSObject) callconv(.C) void { - if (!this.closed) { - this.detach(); - } + if (this.default_watcher) |default_watcher| { + this.default_watcher = null; + default_watcher.deinit(true); + } - bun.default_allocator.destroy(this); + if (this.fsevents_watcher) |fsevents_watcher| { + this.fsevents_watcher = null; + fsevents_watcher.deinit(); } - }; + + this.js_this = .zero; + } + + pub fn doClose(this: *FSWatcher, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { + this.close(); + return JSC.JSValue.jsUndefined(); + } + + pub fn finalize(this: *FSWatcher) callconv(.C) void { + this.deinit(); + } const PathResult = struct { fd: StoredFileDescriptorType = 0, @@ -837,6 +846,17 @@ pub const FSWatcher = struct { const vm = args.global_this.bunVM(); ctx.* = .{ .ctx = vm, + .mutex = Mutex.init(), + .signal = if (args.signal) |s| s.ref() else null, + .persistent = args.persistent, + .default_watcher = null, + .fsevents_watcher = null, + .globalThis = args.global_this, + .js_this = .zero, + .encoding = args.encoding, + .closed = false, + .task_count = 0, + .has_pending_activity = std.atomic.Atomic(bool).init(true), .verbose = args.verbose, .file_paths = bun.BabyList(string).initCapacity(bun.default_allocator, 1) catch |err| { ctx.deinit(); @@ -850,22 +870,17 @@ pub const FSWatcher = struct { ctx.entry_path = dir_path_clone; ctx.entry_dir = dir_path_clone; - var fsevents_watcher = FSEvents.watch(dir_path_clone, args.recursive, onFSEventUpdate, bun.cast(*anyopaque, ctx)) catch |err| { + ctx.fsevents_watcher = FSEvents.watch(dir_path_clone, args.recursive, onFSEventUpdate, bun.cast(*anyopaque, ctx)) catch |err| { ctx.deinit(); return err; }; - ctx.js_watcher = JSObject.init(args.global_this, null, fsevents_watcher, args.signal, args.listener, args.persistent, args.encoding) catch |err| { - ctx.deinit(); - fsevents_watcher.deinit(); - return err; - }; - + ctx.initJS(args.listener); return ctx; } } - var fs_watcher = FSWatcher.Watcher.init( + var default_watcher = FSWatcher.Watcher.init( ctx, vm.bundler.fs, bun.default_allocator, @@ -874,7 +889,7 @@ pub const FSWatcher = struct { return err; }; - ctx.watcher_instance = fs_watcher; + ctx.default_watcher = default_watcher; if (fs_type.is_file) { var file_path_clone = bun.default_allocator.dupeZ(u8, file_path) catch unreachable; @@ -882,32 +897,23 @@ pub const FSWatcher = struct { ctx.entry_path = file_path_clone; ctx.entry_dir = std.fs.path.dirname(file_path_clone) orelse file_path_clone; - fs_watcher.addFile(fs_type.fd, file_path_clone, FSWatcher.Watcher.getHash(file_path), options.Loader.file, 0, null, false) catch |err| { + default_watcher.addFile(fs_type.fd, file_path_clone, FSWatcher.Watcher.getHash(file_path), options.Loader.file, 0, null, false) catch |err| { ctx.deinit(); - fs_watcher.deinit(true); return err; }; } else { - addDirectory(ctx, fs_watcher, fs_type.fd, file_path, args.recursive, &buf, true) catch |err| { + addDirectory(ctx, default_watcher, fs_type.fd, file_path, args.recursive, &buf, true) catch |err| { ctx.deinit(); - fs_watcher.deinit(true); return err; }; } - fs_watcher.start() catch |err| { + default_watcher.start() catch |err| { ctx.deinit(); - - fs_watcher.deinit(true); - return err; - }; - - ctx.js_watcher = JSObject.init(args.global_this, fs_watcher, null, args.signal, args.listener, args.persistent, args.encoding) catch |err| { - ctx.deinit(); - fs_watcher.deinit(true); return err; }; + ctx.initJS(args.listener); return ctx; } }; diff --git a/src/watcher.zig b/src/watcher.zig index 044770dc4..e3b3600ad 100644 --- a/src/watcher.zig +++ b/src/watcher.zig @@ -519,7 +519,7 @@ pub fn NewWatcher(comptime ContextType: type) type { var changelist_array: [128]KEvent = std.mem.zeroes([128]KEvent); var changelist = &changelist_array; - while (this.running) { + while (true) { defer Output.flush(); var count_ = std.os.system.kevent( @@ -576,10 +576,12 @@ pub fn NewWatcher(comptime ContextType: type) type { defer this.mutex.unlock(); if (this.running) { this.ctx.onFileUpdate(watchevents, this.changed_filepaths[0..watchevents.len], this.watchlist); + } else { + break; } } } else if (Environment.isLinux) { - restart: while (this.running) { + restart: while (true) { defer Output.flush(); var events = try INotify.read(); @@ -588,14 +590,14 @@ pub fn NewWatcher(comptime ContextType: type) type { // TODO: is this thread safe? var remaining_events = events.len; - var name_off: u8 = 0; - var temp_name_list: [128]?[:0]u8 = undefined; - var temp_name_off: u8 = 0; - const eventlist_index = this.watchlist.items(.eventlist_index); while (remaining_events > 0) { - const slice = events[0..@min(remaining_events, this.watch_events.len)]; + var name_off: u8 = 0; + var temp_name_list: [128]?[:0]u8 = undefined; + var temp_name_off: u8 = 0; + + const slice = events[0..@min(128, remaining_events, this.watch_events.len)]; var watchevents = this.watch_events[0..slice.len]; var watch_event_id: u32 = 0; for (slice) |event| { @@ -647,8 +649,10 @@ pub fn NewWatcher(comptime ContextType: type) type { defer this.mutex.unlock(); if (this.running) { this.ctx.onFileUpdate(all_events[0 .. last_event_index + 1], this.changed_filepaths[0 .. name_off + 1], this.watchlist); - remaining_events -= slice.len; + } else { + break; } + remaining_events -= slice.len; } } } diff --git a/test/js/node/watch/fs.watch.test.js b/test/js/node/watch/fs.watch.test.js index 56e1798f1..33d05df29 100644 --- a/test/js/node/watch/fs.watch.test.js +++ b/test/js/node/watch/fs.watch.test.js @@ -17,6 +17,8 @@ const testDir = tempDirWithFiles("watch", { "relative.txt": "hello", "abort.txt": "hello", "url.txt": "hello", + "close.txt": "hello", + "close-close.txt": "hello", [encodingFileName]: "hello", }); @@ -105,6 +107,7 @@ describe("fs.watch", () => { let err = undefined; watcher.on("change", (event, filename) => { const basename = path.basename(filename); + if (basename === "subfolder") return; count++; try { @@ -274,6 +277,46 @@ describe("fs.watch", () => { } }); + test("calling close from error event should not throw", done => { + const filepath = path.join(testDir, "close.txt"); + try { + const ac = new AbortController(); + const watcher = fs.watch(pathToFileURL(filepath), { signal: ac.signal }); + watcher.once("error", () => { + try { + watcher.close(); + done(); + } catch (e) { + done("Should not error when calling close from error event"); + } + }); + ac.abort(); + } catch (e) { + done(e); + } + }); + + test("calling close from close event should not throw", done => { + const filepath = path.join(testDir, "close-close.txt"); + try { + const ac = new AbortController(); + const watcher = fs.watch(pathToFileURL(filepath), { signal: ac.signal }); + + watcher.once("close", () => { + try { + watcher.close(); + done(); + } catch (e) { + done("Should not error when calling close from close event"); + } + }); + + ac.abort(); + } catch (e) { + done(e); + } + }); + test("Signal aborted after creating the watcher", async () => { const filepath = path.join(testDir, "abort.txt"); @@ -300,7 +343,7 @@ describe("fs.watch", () => { }); }); -describe("fs.promises.watchFile", () => { +describe("fs.promises.watch", () => { test("add file/folder to folder", async () => { let count = 0; const root = path.join(testDir, "add-promise-directory"); -- 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(-) 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 15ac08474ef0b18b94bbf4863b2497e18e968379 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 16:40:51 -0700 Subject: fixup --- src/bun.js/node/node_fs.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 35c616a89..1298c5d45 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -3457,13 +3457,13 @@ pub const NodeFS = struct { }, }; } else if (comptime string_type == .default) - .{ + return .{ .result = .{ .string = bun.default_allocator.dupe(u8, file.contents) catch @panic("out of memory"), }, } else - .{ + return .{ .result = .{ .null_terminated = bun.default_allocator.dupeZ(u8, file.contents) catch @panic("out of memory"), }, -- cgit v1.2.3 From d8817c2d32a237440a7677622ba351aa95f47c22 Mon Sep 17 00:00:00 2001 From: Tiago Teixeira Date: Mon, 26 Jun 2023 01:43:39 +0200 Subject: Add support for install with --frozen-lockfile (#3365) * Add support for install with --frozen-lockfile * Add test * Add test for frozenLockfile in config file --- completions/bun.bash | 4 +-- completions/bun.zsh | 6 +++++ completions/spec.yaml | 3 +++ docs/cli/bun-install.md | 4 +++ docs/cli/install.md | 9 +++++++ docs/install/index.md | 9 +++++++ docs/runtime/configuration.md | 3 +++ src/api/demo/schema.d.ts | 1 + src/api/demo/schema.js | 4 +++ src/api/demo/schema.peechy | 1 + src/api/demo/schema.zig | 10 ++++++++ src/api/schema.d.ts | 1 + src/api/schema.js | 10 ++++++++ src/api/schema.peechy | 1 + src/api/schema.zig | 10 ++++++++ src/bunfig.zig | 6 +++++ src/install/install.zig | 13 ++++++++++ test/cli/install/bun-install.test.ts | 49 ++++++++++++++++++++++++++++++++++++ 18 files changed, 142 insertions(+), 2 deletions(-) diff --git a/completions/bun.bash b/completions/bun.bash index 7eb83c48b..499adc470 100644 --- a/completions/bun.bash +++ b/completions/bun.bash @@ -92,10 +92,10 @@ _bun_completions() { PACKAGE_OPTIONS[REMOVE_OPTIONS_LONG]=""; PACKAGE_OPTIONS[REMOVE_OPTIONS_SHORT]=""; - PACKAGE_OPTIONS[SHARED_OPTIONS_LONG]="--config --yarn --production --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --global --cwd --backend --link-native-bins --help"; + PACKAGE_OPTIONS[SHARED_OPTIONS_LONG]="--config --yarn --production --frozen-lockfile --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --global --cwd --backend --link-native-bins --help"; PACKAGE_OPTIONS[SHARED_OPTIONS_SHORT]="-c -y -p -f -g"; - PM_OPTIONS[LONG_OPTIONS]="--config --yarn --production --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --no-progress --no-summary --no-verify --ignore-scripts --global --cwd --backend --link-native-bins --help" + PM_OPTIONS[LONG_OPTIONS]="--config --yarn --production --frozen-lockfile --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --no-progress --no-summary --no-verify --ignore-scripts --global --cwd --backend --link-native-bins --help" PM_OPTIONS[SHORT_OPTIONS]="-c -y -p -f -g" local cur_word="${COMP_WORDS[${COMP_CWORD}]}"; diff --git a/completions/bun.zsh b/completions/bun.zsh index 946445b64..a8f66b4fa 100644 --- a/completions/bun.zsh +++ b/completions/bun.zsh @@ -47,6 +47,7 @@ _bun() { '-g[Add a package globally]' \ '--global[Add a package globally]' \ '--production[Don'"'"'t install devDependencies]' \ + '--frozen-lockfile[Disallow changes to lockfile]' \ '--optional[Add dependency to optionalDependencies]' \ '--development[Add dependency to devDependencies]' \ '-d[Add dependency to devDependencies]' \ @@ -88,6 +89,7 @@ _bun() { '--yarn[Write a yarn.lock file (yarn v1)]' \ '--global[Add a package globally]' \ '--production[Don'"'"'t install devDependencies]' \ + '--frozen-lockfile[Disallow changes to lockfile]' \ '--optional[Add dependency to optionalDependencies]' \ '--development[Add dependency to devDependencies]' \ '-d[Add dependency to devDependencies]' \ @@ -123,6 +125,7 @@ _bun() { '--yarn[Write a yarn.lock file (yarn v1)]' \ '--global[Add a package globally]' \ '--production[Don'"'"'t install devDependencies]' \ + '--frozen-lockfile[Disallow changes to lockfile]' \ '--optional[Add dependency to optionalDependencies]' \ '--development[Add dependency to devDependencies]' \ '-d[Add dependency to devDependencies]' \ @@ -278,6 +281,7 @@ _bun() { '--yarn[Write a yarn.lock file (yarn v1)]' '-p[Do not install devDependencies]' '--production[Do not install devDependencies]' + '--frozen-lockfile[Disallow changes to lockfile]' \ '--no-save[Do not save a lockfile]' '--dry-run[Do not install anything]' '--lockfile[Store & load a lockfile at a specific filepath]' @@ -532,6 +536,7 @@ _bun() { '--yarn[Write a yarn.lock file (yarn v1)]' \ '--production[Don'"'"'t install devDependencies]' \ '-p[Don'"'"'t install devDependencies]' \ + '--frozen-lockfile[Disallow changes to lockfile]' \ '--no-save[]' \ '--dry-run[Don'"'"'t install anything]' \ '--force[Always request the latest versions from the registry & reinstall all dependenices]' \ @@ -565,6 +570,7 @@ _bun() { '--yarn[Write a yarn.lock file (yarn v1)]' \ '--production[Don'"'"'t install devDependencies]' \ '-p[Don'"'"'t install devDependencies]' \ + '--frozen-lockfile[Disallow changes to lockfile]' \ '--no-save[]' \ '--dry-run[Don'"'"'t install anything]' \ '-g[Remove a package globally]' \ diff --git a/completions/spec.yaml b/completions/spec.yaml index 9c37ae89e..c3391c192 100644 --- a/completions/spec.yaml +++ b/completions/spec.yaml @@ -115,6 +115,7 @@ subcommands: - yarn -- "Write a yarn.lock file (yarn v1)" - production -- "Don't install devDependencies" - p -- "Don't install devDependencies" + - frozen-lockfile -- "Disallow changes to lockfile" - no-save -- - dry-run -- "Don't install anything" - force -- "Always request the latest versions from the registry & reinstall all dependenices" @@ -152,6 +153,7 @@ subcommands: - development -- "Add dependency to devDependencies" - d -- "Add dependency to devDependencies" - p -- "Don't install devDependencies" + - frozen-lockfile -- "Disallow changes to lockfile" - no-save -- - dry-run -- "Don't install anything" - force -- "Always request the latest versions from the registry & reinstall all dependenices" @@ -192,6 +194,7 @@ subcommands: - yarn -- "Write a yarn.lock file (yarn v1)" - production -- "Don't install devDependencies" - p -- "Don't install devDependencies" + - frozen-lockfile -- "Disallow changes to lockfile" - no-save -- - dry-run -- "Don't install anything" - force -- "Always request the latest versions from the registry & reinstall all dependenices" diff --git a/docs/cli/bun-install.md b/docs/cli/bun-install.md index 11cf3ee81..8050070be 100644 --- a/docs/cli/bun-install.md +++ b/docs/cli/bun-install.md @@ -47,6 +47,9 @@ registry = "https://registry.yarnpkg.com/" # Install for production? This is the equivalent to the "--production" CLI argument production = false +# Disallow changes to lockfile? This is the equivalent to the "--fozen-lockfile" CLI argument +frozenLockfile = false + # Don't actually install dryRun = true @@ -108,6 +111,7 @@ export interface Install { scopes: Scopes; registry: Registry; production: boolean; + frozenLockfile: boolean; dryRun: boolean; optional: boolean; dev: boolean; diff --git a/docs/cli/install.md b/docs/cli/install.md index 695c975f9..4489a0d4a 100644 --- a/docs/cli/install.md +++ b/docs/cli/install.md @@ -49,6 +49,12 @@ To install in production mode (i.e. without `devDependencies`): $ bun install --production ``` +To install dependencies without allowing changes to lockfile (useful on CI): + +```bash +$ bun install --frozen-lockfile +``` + To perform a dry run (i.e. don't actually install anything): ```bash @@ -80,6 +86,9 @@ peer = false # equivalent to `--production` flag production = false +# equivalent to `--frozen-lockfile` flag +frozenLockfile = false + # equivalent to `--dry-run` flag dryRun = false ``` diff --git a/docs/install/index.md b/docs/install/index.md index 48e001275..162a4abac 100644 --- a/docs/install/index.md +++ b/docs/install/index.md @@ -49,6 +49,12 @@ To install in production mode (i.e. without `devDependencies`): $ bun install --production ``` +To install dependencies without allowing changes to lockfile (useful on CI): + +```bash +$ bun install --frozen-lockfile +``` + To perform a dry run (i.e. don't actually install anything): ```bash @@ -80,6 +86,9 @@ peer = false # equivalent to `--production` flag production = false +# equivalent to `--frozen-lockfile` flag +frozenLockfile = false + # equivalent to `--dry-run` flag dryRun = false ``` diff --git a/docs/runtime/configuration.md b/docs/runtime/configuration.md index e1572c990..2ae81713a 100644 --- a/docs/runtime/configuration.md +++ b/docs/runtime/configuration.md @@ -129,6 +129,9 @@ peer = false # equivalent to `--production` flag production = false +# equivalent to `--frozen-lockfile` flag +frozenLockfile = false + # equivalent to `--dry-run` flag dryRun = false ``` diff --git a/src/api/demo/schema.d.ts b/src/api/demo/schema.d.ts index 6f3949c77..e8a6994e7 100644 --- a/src/api/demo/schema.d.ts +++ b/src/api/demo/schema.d.ts @@ -681,6 +681,7 @@ export interface BunInstall { disable_manifest_cache?: boolean; global_dir?: string; global_bin_dir?: string; + frozen_lockfile?: boolean; } export declare function encodeStackFrame(message: StackFrame, bb: ByteBuffer): void; diff --git a/src/api/demo/schema.js b/src/api/demo/schema.js index 7bdd13b65..d23d64a14 100644 --- a/src/api/demo/schema.js +++ b/src/api/demo/schema.js @@ -2992,6 +2992,10 @@ function decodeBunInstall(bb) { result["global_bin_dir"] = bb.readString(); break; + case 19: + result["frozen-lockfile"] = !!bb.readByte(); + break; + default: throw new Error("Attempted to parse invalid message"); } diff --git a/src/api/demo/schema.peechy b/src/api/demo/schema.peechy index 09d3c1fac..e495bb9c0 100644 --- a/src/api/demo/schema.peechy +++ b/src/api/demo/schema.peechy @@ -550,4 +550,5 @@ message BunInstall { bool disable_manifest_cache = 16; string global_dir = 17; string global_bin_dir = 18; + string frozen_lockfile = 19; } diff --git a/src/api/demo/schema.zig b/src/api/demo/schema.zig index d57a5c725..a6de100de 100644 --- a/src/api/demo/schema.zig +++ b/src/api/demo/schema.zig @@ -2728,6 +2728,9 @@ pub const Api = struct { /// global_bin_dir global_bin_dir: ?[]const u8 = null, + /// frozen_lockfile + frozen_lockfile: ?bool = null, + pub fn decode(reader: anytype) anyerror!BunInstall { var this = std.mem.zeroes(BunInstall); @@ -2791,6 +2794,9 @@ pub const Api = struct { 18 => { this.global_bin_dir = try reader.readValue([]const u8); }, + 19 => { + this.frozen_lockfile = try reader.readValue(bool); + }, else => { return error.InvalidMessage; }, @@ -2872,6 +2878,10 @@ pub const Api = struct { try writer.writeFieldID(18); try writer.writeValue(@TypeOf(global_bin_dir), global_bin_dir); } + if (this.frozen_lockfile) |frozen_lockfile| { + try writer.writeFieldID(19); + try writer.writeInt(@as(u8, @boolToInt(frozen_lockfile))); + } try writer.endMessage(); } }; diff --git a/src/api/schema.d.ts b/src/api/schema.d.ts index 4114d951d..ac6183878 100644 --- a/src/api/schema.d.ts +++ b/src/api/schema.d.ts @@ -709,6 +709,7 @@ export interface BunInstall { disable_manifest_cache?: boolean; global_dir?: string; global_bin_dir?: string; + frozen_lockfile?: boolean; } export interface ClientServerModule { diff --git a/src/api/schema.js b/src/api/schema.js index c4f2400ed..270eb9a62 100644 --- a/src/api/schema.js +++ b/src/api/schema.js @@ -3044,6 +3044,10 @@ function decodeBunInstall(bb) { result["global_bin_dir"] = bb.readString(); break; + case 19: + result["frozen_lockfile"] = !!bb.readByte(); + break; + default: throw new Error("Attempted to parse invalid message"); } @@ -3164,6 +3168,12 @@ function encodeBunInstall(message, bb) { bb.writeByte(18); bb.writeString(value); } + + var value = message["frozen_lockfile"]; + if (value != null) { + bb.writeByte(19); + bb.writeByte(value); + } bb.writeByte(0); } diff --git a/src/api/schema.peechy b/src/api/schema.peechy index 71e85d68e..6d28381c4 100644 --- a/src/api/schema.peechy +++ b/src/api/schema.peechy @@ -590,6 +590,7 @@ message BunInstall { bool disable_manifest_cache = 16; string global_dir = 17; string global_bin_dir = 18; + bool frozen_lockfile = 19; } struct ClientServerModule { diff --git a/src/api/schema.zig b/src/api/schema.zig index 1012e6051..708d32ca0 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -2901,6 +2901,9 @@ pub const Api = struct { /// global_bin_dir global_bin_dir: ?[]const u8 = null, + /// frozen_lockfile + frozen_lockfile: ?bool = null, + pub fn decode(reader: anytype) anyerror!BunInstall { var this = std.mem.zeroes(BunInstall); @@ -2964,6 +2967,9 @@ pub const Api = struct { 18 => { this.global_bin_dir = try reader.readValue([]const u8); }, + 19 => { + this.frozen_lockfile = try reader.readValue(bool); + }, else => { return error.InvalidMessage; }, @@ -3045,6 +3051,10 @@ pub const Api = struct { try writer.writeFieldID(18); try writer.writeValue(@TypeOf(global_bin_dir), global_bin_dir); } + if (this.frozen_lockfile) |frozen_lockfile| { + try writer.writeFieldID(19); + try writer.writeInt(@as(u8, @boolToInt(frozen_lockfile))); + } try writer.endMessage(); } }; diff --git a/src/bunfig.zig b/src/bunfig.zig index 9df2978b0..597fb0985 100644 --- a/src/bunfig.zig +++ b/src/bunfig.zig @@ -322,6 +322,12 @@ pub const Bunfig = struct { } } + if (_bun.get("frozenLockfile")) |frozen_lockfile| { + if (frozen_lockfile.asBool()) |value| { + install.frozen_lockfile = value; + } + } + if (_bun.get("lockfile")) |lockfile_expr| { if (lockfile_expr.get("print")) |lockfile| { try this.expect(lockfile, .e_string); diff --git a/src/install/install.zig b/src/install/install.zig index 32c24548c..81e2a7bb8 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -4443,6 +4443,12 @@ pub const PackageManager = struct { } } + if (bun_install.frozen_lockfile) |frozen_lockfile| { + if (frozen_lockfile) { + this.enable.frozen_lockfile = true; + } + } + if (bun_install.save_optional) |save| { this.remote_package_features.optional_dependencies = save; this.local_package_features.optional_dependencies = save; @@ -4676,6 +4682,10 @@ pub const PackageManager = struct { this.enable.frozen_lockfile = true; } + if (cli.frozen_lockfile) { + this.enable.frozen_lockfile = true; + } + if (cli.force) { this.enable.manifest_cache_control = false; this.enable.force_install = true; @@ -5649,6 +5659,7 @@ pub const PackageManager = struct { clap.parseParam("--save Save to package.json") catch unreachable, clap.parseParam("--dry-run Don't install anything") catch unreachable, clap.parseParam("--lockfile Store & load a lockfile at a specific filepath") catch unreachable, + clap.parseParam("--frozen-lockfile Disallow changes to lockfile") catch unreachable, clap.parseParam("-f, --force Always request the latest versions from the registry & reinstall all dependencies") catch unreachable, clap.parseParam("--cache-dir Store & load cached data from a specific directory path") catch unreachable, clap.parseParam("--no-cache Ignore manifest cache entirely") catch unreachable, @@ -5709,6 +5720,7 @@ pub const PackageManager = struct { yarn: bool = false, production: bool = false, + frozen_lockfile: bool = false, no_save: bool = false, dry_run: bool = false, force: bool = false, @@ -5777,6 +5789,7 @@ pub const PackageManager = struct { var cli = CommandLineArguments{}; cli.yarn = args.flag("--yarn"); cli.production = args.flag("--production"); + cli.frozen_lockfile = args.flag("--frozen-lockfile"); cli.no_progress = args.flag("--no-progress"); cli.dry_run = args.flag("--dry-run"); cli.global = args.flag("--global"); diff --git a/test/cli/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts index 4b3342e3a..6baee23a9 100644 --- a/test/cli/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -4241,6 +4241,55 @@ it("should handle --cwd", async () => { }); }); +it("should handle --frozen-lockfile", async () => { + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ name: "foo", version: "0.0.1", dependencies: { bar: "0.0.2" } }), + ); + + const { stderr, exited } = spawn({ + cmd: [bunExe(), "install", "--frozen-lockfile"], + cwd: package_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toContain("error: lockfile had changes, but lockfile is frozen"); + expect(await exited).toBe(1); +}); + +it("should handle frozenLockfile in config file", async () => { + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ name: "foo", version: "0.0.1", dependencies: { bar: "0.0.2" } }), + ); + await writeFile( + join(package_dir, "bunfig.toml"), + ` +[install] +frozenLockfile = true +`, + ); + + const { stderr, exited } = spawn({ + cmd: [bunExe(), "install"], + cwd: package_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toContain("error: lockfile had changes, but lockfile is frozen"); + expect(await exited).toBe(1); +}); + it("should perform bin-linking across multiple dependencies", async () => { const foo_package = JSON.stringify({ name: "foo", -- cgit v1.2.3 From 662335d81aa39dc53b83f2759312ff0ff3a93af2 Mon Sep 17 00:00:00 2001 From: Brúnó Salomon <35275408+bru02@users.noreply.github.com> Date: Mon, 26 Jun 2023 01:48:03 +0200 Subject: chore: update lol-html version (#3356) * chore: update lol-html version * add tests --------- Co-authored-by: Jarred Sumner --- src/bun.js/api/html_rewriter.zig | 7 +++++++ src/deps/lol-html | 2 +- src/deps/lol-html.zig | 8 ++++++-- src/generated_versions_list.zig | 2 +- test/js/workerd/html-rewriter.test.js | 15 +++++++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig index 93a41b095..d09c14e42 100644 --- a/src/bun.js/api/html_rewriter.zig +++ b/src/bun.js/api/html_rewriter.zig @@ -1016,6 +1016,9 @@ pub const TextChunk = struct { .removed = .{ .get = getterWrap(TextChunk, "removed"), }, + .lastInTextNode = .{ + .get = getterWrap(TextChunk, "lastInTextNode"), + }, .text = .{ .get = getterWrap(TextChunk, "getText"), }, @@ -1084,6 +1087,10 @@ pub const TextChunk = struct { return JSC.JSValue.jsBoolean(this.text_chunk.?.isRemoved()); } + pub fn lastInTextNode(this: *TextChunk, _: *JSGlobalObject) JSValue { + return JSC.JSValue.jsBoolean(this.text_chunk.?.isLastInTextNode()); + } + pub fn finalize(this: *TextChunk) void { this.text_chunk = null; bun.default_allocator.destroy(this); diff --git a/src/deps/lol-html b/src/deps/lol-html index 2eed349dc..2681dcf0b 160000 --- a/src/deps/lol-html +++ b/src/deps/lol-html @@ -1 +1 @@ -Subproject commit 2eed349dcdfa4ff5c19fe7c6e501cfd687601033 +Subproject commit 2681dcf0b3e6907111565199df8c43cc9aab7fe8 diff --git a/src/deps/lol-html.zig b/src/deps/lol-html.zig index 1d71e6aa6..9c5345046 100644 --- a/src/deps/lol-html.zig +++ b/src/deps/lol-html.zig @@ -393,7 +393,8 @@ pub const Element = opaque { extern fn lol_html_element_is_removed(element: *const Element) bool; extern fn lol_html_element_user_data_set(element: *const Element, user_data: ?*anyopaque) void; extern fn lol_html_element_user_data_get(element: *const Element) ?*anyopaque; - extern fn lol_html_element_on_end_tag(element: *Element, end_tag_handler: lol_html_end_tag_handler_t, user_data: ?*anyopaque) c_int; + extern fn lol_html_element_add_end_tag_handler(element: *Element, end_tag_handler: lol_html_end_tag_handler_t, user_data: ?*anyopaque) c_int; + extern fn lol_html_element_clear_end_tag_handlers(element: *Element) void; pub fn getAttribute(element: *const Element, name: []const u8) HTMLString { auto_disable(); @@ -502,7 +503,10 @@ pub const Element = opaque { } pub fn onEndTag(element: *Element, end_tag_handler: lol_html_end_tag_handler_t, user_data: ?*anyopaque) Error!void { auto_disable(); - return switch (lol_html_element_on_end_tag(element, end_tag_handler, user_data)) { + + lol_html_element_clear_end_tag_handlers(element); + + return switch (lol_html_element_add_end_tag_handler(element, end_tag_handler, user_data)) { 0 => {}, -1 => error.Fail, else => unreachable, diff --git a/src/generated_versions_list.zig b/src/generated_versions_list.zig index 90bee0b8c..c27f47c83 100644 --- a/src/generated_versions_list.zig +++ b/src/generated_versions_list.zig @@ -9,6 +9,6 @@ pub const webkit = "60d11703a533fd694cd1d6ddda04813eecb5d69f"; pub const zig = @import("std").fmt.comptimePrint("{}", .{@import("builtin").zig_version}); pub const zlib = "885674026394870b7e7a05b7bf1ec5eb7bd8a9c0"; pub const tinycc = "2d3ad9e0d32194ad7fd867b66ebe218dcc8cb5cd"; -pub const lolhtml = "2eed349dcdfa4ff5c19fe7c6e501cfd687601033"; +pub const lolhtml = "2681dcf0b3e6907111565199df8c43cc9aab7fe8"; pub const c_ares = "0e7a5dee0fbb04080750cf6eabbe89d8bae87faa"; pub const usockets = "fafc241e8664243fc0c51d69684d5d02b9805134"; diff --git a/test/js/workerd/html-rewriter.test.js b/test/js/workerd/html-rewriter.test.js index 1ca92a567..b6131a09f 100644 --- a/test/js/workerd/html-rewriter.test.js +++ b/test/js/workerd/html-rewriter.test.js @@ -300,4 +300,19 @@ describe("HTMLRewriter", () => { .text(), ).toEqual("
"); }); + + it("it supports lastInTextNode", async () => { + let lastInTextNode; + + await new HTMLRewriter() + .on("p", { + text(text) { + lastInTextNode ??= text.lastInTextNode; + }, + }) + .transform(new Response("

Lorem ipsum!

")) + .text(); + + expect(lastInTextNode).toBeBoolean(); + }); }); -- cgit v1.2.3 From 66195ffeed3948305853b8d95bcb51042b63aa15 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 16:50:26 -0700 Subject: Update WebKit --- src/bun.js/WebKit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit index b2f1006a0..a9e3ab9b8 160000 --- a/src/bun.js/WebKit +++ b/src/bun.js/WebKit @@ -1 +1 @@ -Subproject commit b2f1006a06f81bc860c89dd4c7cec3e7117c4c4c +Subproject commit a9e3ab9b85cf911218e1d51eed8079cd955ec578 -- cgit v1.2.3 From 9ebb25427ab4c8bb0f0edfe339471080204b9b52 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 17:51:24 -0700 Subject: remove very old stuff --- src/api/demo/.gitignore | 34 - src/api/demo/README.md | 34 - src/api/demo/api.js | 0 src/api/demo/bun.lockb | Bin 72411 -> 0 bytes src/api/demo/lib/api.ts | 280 --- src/api/demo/lib/run.ts | 70 - src/api/demo/lib/scan.ts | 44 - src/api/demo/next-env.d.ts | 5 - src/api/demo/package.json | 29 - src/api/demo/pages/_app.js | 7 - src/api/demo/pages/api/hello.js | 5 - src/api/demo/pages/index.tsx | 68 - src/api/demo/pages/scan.tsx | 67 - src/api/demo/pages/two.tsx | 1 - src/api/demo/pnpm-lock.yaml | 2038 ---------------------- src/api/demo/public/favicon.ico | Bin 15086 -> 0 bytes src/api/demo/public/vercel.svg | 4 - src/api/demo/schema.d.ts | 800 --------- src/api/demo/schema.js | 3261 ----------------------------------- src/api/demo/schema.peechy | 554 ------ src/api/demo/schema.zig | 2888 ------------------------------- src/api/demo/styles/Home.module.css | 122 -- src/api/demo/styles/globals.css | 16 - src/api/demo/tsconfig.json | 34 - 24 files changed, 10361 deletions(-) delete mode 100644 src/api/demo/.gitignore delete mode 100644 src/api/demo/README.md delete mode 100644 src/api/demo/api.js delete mode 100755 src/api/demo/bun.lockb delete mode 100644 src/api/demo/lib/api.ts delete mode 100644 src/api/demo/lib/run.ts delete mode 100644 src/api/demo/lib/scan.ts delete mode 100644 src/api/demo/next-env.d.ts delete mode 100644 src/api/demo/package.json delete mode 100644 src/api/demo/pages/_app.js delete mode 100644 src/api/demo/pages/api/hello.js delete mode 100644 src/api/demo/pages/index.tsx delete mode 100644 src/api/demo/pages/scan.tsx delete mode 100644 src/api/demo/pages/two.tsx delete mode 100644 src/api/demo/pnpm-lock.yaml delete mode 100644 src/api/demo/public/favicon.ico delete mode 100644 src/api/demo/public/vercel.svg delete mode 100644 src/api/demo/schema.d.ts delete mode 100644 src/api/demo/schema.js delete mode 100644 src/api/demo/schema.peechy delete mode 100644 src/api/demo/schema.zig delete mode 100644 src/api/demo/styles/Home.module.css delete mode 100644 src/api/demo/styles/globals.css delete mode 100644 src/api/demo/tsconfig.json diff --git a/src/api/demo/.gitignore b/src/api/demo/.gitignore deleted file mode 100644 index 1437c53f7..000000000 --- a/src/api/demo/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env.local -.env.development.local -.env.test.local -.env.production.local - -# vercel -.vercel diff --git a/src/api/demo/README.md b/src/api/demo/README.md deleted file mode 100644 index b12f3e33e..000000000 --- a/src/api/demo/README.md +++ /dev/null @@ -1,34 +0,0 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). - -## Getting Started - -First, run the development server: - -```bash -npm run dev -# or -yarn dev -``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file. - -[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`. - -The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. diff --git a/src/api/demo/api.js b/src/api/demo/api.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/api/demo/bun.lockb b/src/api/demo/bun.lockb deleted file mode 100755 index c58932f18..000000000 Binary files a/src/api/demo/bun.lockb and /dev/null differ diff --git a/src/api/demo/lib/api.ts b/src/api/demo/lib/api.ts deleted file mode 100644 index 88dd71001..000000000 --- a/src/api/demo/lib/api.ts +++ /dev/null @@ -1,280 +0,0 @@ -import * as Schema from "../../schema"; -import { ByteBuffer } from "peechy"; -import path from "path"; -import { Loader } from "../schema"; -// import { transform as sucraseTransform } from "sucrase"; - -export interface WebAssemblyModule { - init(): number; - transform(a: number): number; - bun_malloc(a: number): number; - bun_free(a: number): number; - scan(a: number): number; -} - -const wasm_imports_sym: symbol | string = - process.env.NODE_ENV === "development" ? "wasm_imports" : Symbol("wasm_imports"); - -const ptr_converter = new ArrayBuffer(16); -const ptr_float = new BigUint64Array(ptr_converter); -const slice = new Uint32Array(ptr_converter); - -const Wasi = { - clock_time_get(clk_id, tp) { - return Date.now(); - }, - environ_sizes_get() { - debugger; - return 0; - }, - environ_get(__environ, environ_buf) { - debugger; - return 0; - }, - - fd_close(fd) { - debugger; - return 0; - }, - proc_exit() {}, - - fd_seek(fd, offset_bigint, whence, newOffset) { - debugger; - }, - fd_write(fd, iov, iovcnt, pnum) { - debugger; - }, -}; - -var scratch: Uint8Array; -var scratch2: Uint8Array; - -export class Bun { - static has_initialized = false; - static wasm_source: WebAssembly.WebAssemblyInstantiatedSource = null; - static get wasm_exports(): WebAssemblyModule { - return Bun.wasm_source.instance.exports as any; - } - static get memory(): WebAssembly.Memory { - return Bun.wasm_source.instance.exports.memory as any; - } - - static memory_array: Uint8Array; - - static _decoder: TextDecoder; - - static _wasmPtrToSlice(offset: number | bigint) { - ptr_float[0] = typeof offset === "number" ? BigInt(offset) : offset; - return new Uint8Array(Bun.memory.buffer, slice[0], slice[1]); - } - - static _wasmPtrLenToString(slice: number) { - if (!Bun._decoder) { - Bun._decoder = new TextDecoder("utf8"); - } - - const region = this._wasmPtrToSlice(slice); - return Bun._decoder.decode(region); - } - - // We don't want people to be calling these manually - static [wasm_imports_sym] = { - console_log(slice: number) { - console.log(Bun._wasmPtrLenToString(slice)); - }, - console_error(slice: number) { - console.error(Bun._wasmPtrLenToString(slice)); - }, - console_warn(slice: number) { - console.warn(Bun._wasmPtrLenToString(slice)); - }, - console_info(slice: number) { - console.info(Bun._wasmPtrLenToString(slice)); - }, - - __indirect_function_table: new WebAssembly.Table({ - initial: 0, - element: "anyfunc", - }), - __stack_pointer: new WebAssembly.Global({ - mutable: true, - value: "i32", - }), - __multi3(one: number, two: number) { - return Math.imul(one | 0, two | 0); - }, - fmod(one: number, two: number) { - return one % two; - }, - memset(ptr: number, value: number, len: number) { - Bun.memory_array.fill(value, ptr, ptr + len); - }, - memcpy(ptr: number, value: number, len: number) { - Bun.memory_array.copyWithin(ptr, value, value + len); - }, - // These functions convert a to an unsigned long long, rounding toward zero. Negative values all become zero. - __fixunsdfti(a: number) { - return Math.floor(a); - }, - // These functions return the remainder of the unsigned division of a and b. - __umodti3(a: number, b: number) { - return (a | 0) % (b | 0); - }, - // These functions return the quotient of the unsigned division of a and b. - __udivti3(a: number, b: number) { - return (a | 0) / (b | 0); - }, - // These functions return the result of shifting a left by b bits. - __ashlti3(a: number, b: number) { - return (a | 0) >> (b | 0); - }, - /* Returns: convert a to a double, rounding toward even. */ - __floatuntidf(a: number) { - const mod = a % 2; - if (mod === 0) { - return Math.ceil(a); - } else if (mod === 1) { - return Math.floor(a); - } - }, - emscripten_notify_memory_growth() {}, - }; - - static async init(url) { - // globalThis.sucraseTransform = sucraseTransform; - scratch = new Uint8Array(8096); - - if (Bun.has_initialized) { - return; - } - - Bun.wasm_source = await globalThis.WebAssembly.instantiateStreaming(fetch(url), { - env: Bun[wasm_imports_sym], - wasi_snapshot_preview1: Wasi, - }); - - const res = Bun.wasm_exports.init(); - if (res < 0) { - throw `[Bun] Failed to initialize WASM module: code ${res}`; - } else { - console.log("WASM loaded."); - } - - Bun.has_initialized = true; - } - - static transformSync(content: Uint8Array | string, file_name: string) { - if (!Bun.has_initialized) { - throw "Please run await Bun.init(wasm_url) before using this."; - } - - // if (process.env.NODE_ENV === "development") { - // console.time("[Bun] Transform " + file_name); - // } - - const bb = new ByteBuffer(scratch); - bb.length = 0; - bb.index = 0; - var contents_buffer; - if (typeof content === "string") { - if (!scratch2) { - scratch2 = new Uint8Array(content.length * 2); - } - - let i = 0; - for (; i < content.length; i++) { - if (i > scratch2.length) { - var scratch3 = new Uint8Array(scratch2.length * 2); - scratch3.set(scratch2); - scratch2 = scratch3; - } - scratch2[i] = content.charCodeAt(i); - } - contents_buffer = scratch2.subarray(0, i); - } else { - contents_buffer = content; - } - - Schema.encodeTransform( - { - contents: contents_buffer, - path: file_name, - loader: { - ".jsx": Loader.jsx, - ".tsx": Loader.tsx, - ".ts": Loader.ts, - ".js": Loader.js, - ".json": Loader.json, - }[path.extname(file_name)], - }, - bb, - ); - const data = bb.toUint8Array(); - - const input_ptr = Bun.wasm_exports.bun_malloc(data.length); - var buffer = this._wasmPtrToSlice(input_ptr); - buffer.set(data); - - const resp_ptr = Bun.wasm_exports.transform(input_ptr); - var _bb = new ByteBuffer(this._wasmPtrToSlice(resp_ptr)); - const response = Schema.decodeTransformResponse(_bb); - Bun.wasm_exports.bun_free(input_ptr); - scratch = bb.data; - return response; - } - - static scan(content: Uint8Array | string, file_name: string, loader?: Loader) { - if (!Bun.has_initialized) { - throw "Please run await Bun.init(wasm_url) before using this."; - } - - // if (process.env.NODE_ENV === "development") { - // console.time("[Bun] Transform " + file_name); - // } - scratch.fill(0); - const bb = new ByteBuffer(scratch); - bb.length = 0; - bb.index = 0; - var contents_buffer; - if (typeof content === "string") { - if (!scratch2) { - scratch2 = new Uint8Array(content.length * 2); - } - const encode_into = new TextEncoder().encodeInto(content, scratch2); - contents_buffer = scratch2.subarray(0, encode_into.written); - } else { - contents_buffer = content; - } - - Schema.encodeScan( - { - contents: contents_buffer, - path: file_name, - loader: - loader || - { - ".jsx": Loader.jsx, - ".tsx": Loader.tsx, - ".ts": Loader.ts, - ".js": Loader.js, - ".json": Loader.json, - }[path.extname(file_name)], - }, - bb, - ); - const data = bb.toUint8Array(); - - const input_ptr = Bun.wasm_exports.bun_malloc(data.length); - var buffer = this._wasmPtrToSlice(input_ptr); - buffer.set(data); - - const resp_ptr = Bun.wasm_exports.scan(input_ptr); - var _bb = new ByteBuffer(this._wasmPtrToSlice(resp_ptr)); - const response = Schema.decodeScanResult(_bb); - Bun.wasm_exports.bun_free(input_ptr); - scratch = bb.data; - return response; - } -} - -globalThis.Bun = Bun; diff --git a/src/api/demo/lib/run.ts b/src/api/demo/lib/run.ts deleted file mode 100644 index 87d703556..000000000 --- a/src/api/demo/lib/run.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { transform as _transform, initialize } from "esbuild-wasm"; -import initSwc, { transformSync as transformSyncSWC } from "@swc/wasm-web"; -import { Bun } from "./api"; - -export async function start() { - await initialize({ - worker: false, - wasmURL: "/node_modules/esbuild-wasm/esbuild.wasm", - }); - await Bun.init("/bun-wasm.wasm"); - await initSwc("/node_modules/@swc/wasm-web/wasm_bg.wasm"); -} - -const swcOptions = { - sourceMaps: false, - inlineSourcesContent: false, - jsc: { - target: "es2022", - parser: { - jsx: true, - syntax: "typescript", - tsx: false, - decorators: false, - dynamicImport: false, - }, - }, -}; - -export async function transform(contents, file) { - var result: any = { - timings: { - esbuild: 0, - bun: 0, - swc: 0, - }, - }; - result.timings.esbuild = performance.now(); - result.esbuild = await _transform(contents, { - sourcefile: file, - loader: file.substring(file.lastIndexOf(".") + 1), - }); - result.timings.esbuild = performance.now() - result.timings.esbuild; - - result.timings.bun = performance.now(); - result.bun = Bun.transformSync(contents, file); - result.timings.bun = performance.now() - result.timings.bun; - - if (file.substring(file.lastIndexOf(".") + 1) === "tsx") { - swcOptions.jsc.parser.tsx = true; - swcOptions.jsc.parser.syntax = "typescript"; - } else if (file.substring(file.lastIndexOf(".") + 1) === "jsx") { - swcOptions.jsc.parser.tsx = false; - swcOptions.jsc.parser.jsx = true; - swcOptions.jsc.parser.syntax = "typescript"; - } else { - swcOptions.jsc.parser.tsx = false; - swcOptions.jsc.parser.jsx = false; - swcOptions.jsc.parser.syntax = "javascript"; - } - - result.timings.swc = performance.now(); - result.swc = transformSyncSWC(contents, swcOptions as any); - result.timings.swc = performance.now() - result.timings.swc; - - console.log("esbuild:", result.timings.esbuild, "ms"); - console.log("Bun:", result.timings.bun, "ms"); - console.log("SWC:", result.timings.swc, "ms"); - - return result; -} diff --git a/src/api/demo/lib/scan.ts b/src/api/demo/lib/scan.ts deleted file mode 100644 index c2fd7bb12..000000000 --- a/src/api/demo/lib/scan.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { init, parse } from "es-module-lexer"; - -import { Bun } from "./api"; - -export async function start() { - await init; - await Bun.init("/bun-wasm.wasm"); -} - -const swcOptions = { - sourceMaps: false, - inlineSourcesContent: false, - jsc: { - target: "es2022", - parser: { - jsx: true, - syntax: "typescript", - tsx: false, - decorators: false, - dynamicImport: false, - }, - }, -}; - -export async function transform(contents, file) { - var result: any = { - timings: { - lexer: 0, - bun: 0, - }, - }; - result.timings.lexer = performance.now(); - result.lexer = await parse(contents, file); - result.timings.lexer = performance.now() - result.timings.lexer; - - result.timings.bun = performance.now(); - result.bun = Bun.scan(contents, file); - result.timings.bun = performance.now() - result.timings.bun; - - console.log("lexer:", result.timings.lexer, "ms"); - console.log("Bun:", result.timings.bun, "ms"); - - return result; -} diff --git a/src/api/demo/next-env.d.ts b/src/api/demo/next-env.d.ts deleted file mode 100644 index 4f11a03dc..000000000 --- a/src/api/demo/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/src/api/demo/package.json b/src/api/demo/package.json deleted file mode 100644 index 59e70aed1..000000000 --- a/src/api/demo/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "demo", - "version": "0.1.0", - "private": true, - "scripts": { - "dev": "next dev", - "build": "next build", - "start": "next start" - }, - "dependencies": { - "@swc/wasm-web": "^1.2.146", - "bun-framework-next": "^12.1.0", - "es-module-loader": "^2.3.0", - "esbuild": "^0.14.23", - "esbuild-wasm": "^0.14.23", - "next": "12", - "peechy": "0.4.32", - "react": "17.0.2", - "react-dom": "17.0.2", - "sucrase": "^3.18.1" - }, - "devDependencies": { - "@types/react": "^17.0.8", - "bun-types": "^0.2.2", - "typescript": "^4.3.2", - "webpack": "^5.38.1", - "webpack-cli": "^4.7.0" - } -} \ No newline at end of file diff --git a/src/api/demo/pages/_app.js b/src/api/demo/pages/_app.js deleted file mode 100644 index 2fc3e0700..000000000 --- a/src/api/demo/pages/_app.js +++ /dev/null @@ -1,7 +0,0 @@ -import "../styles/globals.css"; - -function MyApp({ Component, pageProps }) { - return ; -} - -export default MyApp; diff --git a/src/api/demo/pages/api/hello.js b/src/api/demo/pages/api/hello.js deleted file mode 100644 index e963280fa..000000000 --- a/src/api/demo/pages/api/hello.js +++ /dev/null @@ -1,5 +0,0 @@ -// Next.js API route support: https://nextjs.org/docs/api-routes/introduction - -export default (req, res) => { - res.status(200).json({ name: "John Doe" }); -}; diff --git a/src/api/demo/pages/index.tsx b/src/api/demo/pages/index.tsx deleted file mode 100644 index 1f6e4bb82..000000000 --- a/src/api/demo/pages/index.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import Head from "next/head"; -import Image from "next/image"; -import styles from "../styles/Home.module.css"; -import { readFile } from "fs/promises"; - -import React from "react"; - -if (typeof window !== "undefined") { - globalThis.Run = await import("../lib/run"); - await import("../lib/api"); -} - -export async function getStaticProps(ctx) { - return { - props: { - // not tested - code: readFile("/Users/jarred/Build/es-module-lexer/test/samples/magic-string.js", { encoding: "utf-8" }), - }, - }; -} - -var textDecoder = new TextDecoder(); -export default function Home({ code }) { - const fileNameRef = React.useRef(null); - const [esbuildResult, setEsbuildResult] = React.useState(""); - const [bunResult, setBunResult] = React.useState(""); - const [swcResult, setSWCResult] = React.useState(""); - React.useEffect(() => { - globalThis.Run.start(); - }, []); - - const runBuild = React.useCallback( - event => { - globalThis.Run.transform(event.target.value, fileNameRef?.current?.value).then(result => { - setEsbuildResult(result.esbuild.code); - setBunResult(textDecoder.decode(result.bun.files[0].data)); - setSWCResult(result.swc.code); - }, console.error); - }, - [fileNameRef, setEsbuildResult, setBunResult, setSWCResult], - ); - return ( -
- - Next.js - - - - -
-
- - - - - - -
-
-
- ); -} diff --git a/src/api/demo/pages/scan.tsx b/src/api/demo/pages/scan.tsx deleted file mode 100644 index 656629dda..000000000 --- a/src/api/demo/pages/scan.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import Head from "next/head"; -import { readFile } from "fs/promises"; -import styles from "../styles/Home.module.css"; - -import React from "react"; - -if (typeof window !== "undefined") { - globalThis.Scan = await import("../lib/scan"); - await import("../lib/api"); -} - -export async function getStaticProps(ctx) { - return { - props: { - // not tested - code: readFile("/Users/jarred/Build/es-module-lexer/test/samples/magic-string.js", { encoding: "utf-8" }), - defaultFile: "magic-string.js", - }, - }; -} - -var textDecoder = new TextDecoder(); -export default function Home({ code, defaultFile }) { - const fileNameRef = React.useRef(null); - const [lexer, setLexer] = React.useState(""); - const [bunResult, setBunResult] = React.useState(""); - const [file, setFile] = React.useState(defaultFile); - React.useEffect(() => { - globalThis.Scan.start(); - }, []); - - const runBuild = React.useCallback( - event => { - globalThis.Scan.transform(event.target.value, fileNameRef?.current?.value).then(result => { - setLexer(JSON.stringify(result.lexer, null, 2)); - setBunResult(JSON.stringify(result.bun, null, 2)); - }, console.error); - }, - [fileNameRef, setBunResult, setLexer], - ); - return ( -
- - Next.js - - - - -
-
- setFile(event.target.value)} - ref={fileNameRef} - /> - - - - -
-
-
- ); -} diff --git a/src/api/demo/pages/two.tsx b/src/api/demo/pages/two.tsx deleted file mode 100644 index cb0ff5c3b..000000000 --- a/src/api/demo/pages/two.tsx +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/demo/pnpm-lock.yaml b/src/api/demo/pnpm-lock.yaml deleted file mode 100644 index bd5b33635..000000000 --- a/src/api/demo/pnpm-lock.yaml +++ /dev/null @@ -1,2038 +0,0 @@ -lockfileVersion: 5.3 - -specifiers: - next: 10.2.0 - peechy: 0.4.3 - react: 17.0.2 - react-dom: 17.0.2 - sucrase: ^3.18.1 - -dependencies: - next: 10.2.0_react-dom@17.0.2+react@17.0.2 - peechy: 0.4.3 - react: 17.0.2 - react-dom: 17.0.2_react@17.0.2 - sucrase: 3.18.1 - -packages: - - /@babel/code-frame/7.12.11: - resolution: {integrity: sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==} - dependencies: - '@babel/highlight': 7.14.0 - dev: false - - /@babel/helper-validator-identifier/7.14.0: - resolution: {integrity: sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A==} - dev: false - - /@babel/highlight/7.14.0: - resolution: {integrity: sha512-YSCOwxvTYEIMSGaBQb5kDDsCopDdiUGsqpatp3fOlI4+2HQSkTmEVWnVuySdAC5EWCqSWWTv0ib63RjR7dTBdg==} - dependencies: - '@babel/helper-validator-identifier': 7.14.0 - chalk: 2.4.2 - js-tokens: 4.0.0 - dev: false - - /@babel/runtime/7.12.5: - resolution: {integrity: sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==} - dependencies: - regenerator-runtime: 0.13.7 - dev: false - - /@babel/types/7.8.3: - resolution: {integrity: sha512-jBD+G8+LWpMBBWvVcdr4QysjUE4mU/syrhN17o1u3gx0/WzJB1kwiVZAXRtWbsIPOwW8pF/YJV5+nmetPzepXg==} - dependencies: - esutils: 2.0.3 - lodash: 4.17.21 - to-fast-properties: 2.0.0 - dev: false - - /@hapi/accept/5.0.1: - resolution: {integrity: sha512-fMr4d7zLzsAXo28PRRQPXR1o2Wmu+6z+VY1UzDp0iFo13Twj8WePakwXBiqn3E1aAlTpSNzCXdnnQXFhst8h8Q==} - dependencies: - '@hapi/boom': 9.1.2 - '@hapi/hoek': 9.2.0 - dev: false - - /@hapi/boom/9.1.2: - resolution: {integrity: sha512-uJEJtiNHzKw80JpngDGBCGAmWjBtzxDCz17A9NO2zCi8LLBlb5Frpq4pXwyN+2JQMod4pKz5BALwyneCgDg89Q==} - dependencies: - '@hapi/hoek': 9.2.0 - dev: false - - /@hapi/hoek/9.2.0: - resolution: {integrity: sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==} - dev: false - - /@next/env/10.2.0: - resolution: {integrity: sha512-tsWBsn1Rb6hXRaHc/pWMCpZ4Ipkf3OCbZ54ef5ukgIyEvzzGdGFXQshPP2AF7yb+8yMpunWs7vOMZW3e8oPF6A==} - dev: false - - /@next/polyfill-module/10.2.0: - resolution: {integrity: sha512-Nl3GexIUXsmuggkUqrRFyE/2k7UI44JaVzSywtXEyHzxpZm2a5bdMaWuC89pgLiFDDOqmbqyLAbtwm5lNxa7Eg==} - dev: false - - /@next/react-dev-overlay/10.2.0_react-dom@17.0.2+react@17.0.2: - resolution: {integrity: sha512-PRIAoWog41hLN4iJ8dChKp4ysOX0Q8yiNQ/cwzyqEd3EjugkDV5OiKl3mumGKaApJaIra1MX6j1wgQRuLhuWMA==} - peerDependencies: - react: ^16.9.0 || ^17 - react-dom: ^16.9.0 || ^17 - dependencies: - '@babel/code-frame': 7.12.11 - anser: 1.4.9 - chalk: 4.0.0 - classnames: 2.2.6 - css.escape: 1.5.1 - data-uri-to-buffer: 3.0.1 - platform: 1.3.6 - react: 17.0.2 - react-dom: 17.0.2_react@17.0.2 - shell-quote: 1.7.2 - source-map: 0.8.0-beta.0 - stacktrace-parser: 0.1.10 - strip-ansi: 6.0.0 - dev: false - - /@next/react-refresh-utils/10.2.0_react-refresh@0.8.3: - resolution: {integrity: sha512-3I31K9B4hEQRl7yQ44Umyz+szHtuMJrNdwsgJGhoEnUCXSBRHp5wv5Zv8eDa2NewSbe53b2C0oOpivrzmdBakw==} - peerDependencies: - react-refresh: 0.8.3 - webpack: ^4 || ^5 - peerDependenciesMeta: - webpack: - optional: true - dependencies: - react-refresh: 0.8.3 - dev: false - - /@opentelemetry/api/0.14.0: - resolution: {integrity: sha512-L7RMuZr5LzMmZiQSQDy9O1jo0q+DaLy6XpYJfIGfYSfoJA5qzYwUP3sP1uMIQ549DvxAgM3ng85EaPTM/hUHwQ==} - engines: {node: '>=8.0.0'} - dependencies: - '@opentelemetry/context-base': 0.14.0 - dev: false - - /@opentelemetry/context-base/0.14.0: - resolution: {integrity: sha512-sDOAZcYwynHFTbLo6n8kIbLiVF3a3BLkrmehJUyEbT9F+Smbi47kLGS2gG2g0fjBLR/Lr1InPD7kXL7FaTqEkw==} - engines: {node: '>=8.0.0'} - dev: false - - /@types/node/15.0.2: - resolution: {integrity: sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==} - dev: false - - /anser/1.4.9: - resolution: {integrity: sha512-AI+BjTeGt2+WFk4eWcqbQ7snZpDBt8SaLlj0RT2h5xfdWaiy51OjYvqwMrNzJLGy8iOAL6nKDITWO+rd4MkYEA==} - dev: false - - /ansi-regex/5.0.0: - resolution: {integrity: sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==} - engines: {node: '>=8'} - dev: false - - /ansi-styles/3.2.1: - resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} - engines: {node: '>=4'} - dependencies: - color-convert: 1.9.3 - dev: false - - /ansi-styles/4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} - dependencies: - color-convert: 2.0.1 - dev: false - - /any-promise/1.3.0: - resolution: {integrity: sha1-q8av7tzqUugJzcA3au0845Y10X8=} - dev: false - - /anymatch/3.1.2: - resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==} - engines: {node: '>= 8'} - dependencies: - normalize-path: 3.0.0 - picomatch: 2.2.3 - dev: false - - /array-filter/1.0.0: - resolution: {integrity: sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=} - dev: false - - /asn1.js/5.4.1: - resolution: {integrity: sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==} - dependencies: - bn.js: 4.12.0 - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - safer-buffer: 2.1.2 - dev: false - - /assert/1.5.0: - resolution: {integrity: sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==} - dependencies: - object-assign: 4.1.1 - util: 0.10.3 - dev: false - - /assert/2.0.0: - resolution: {integrity: sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==} - dependencies: - es6-object-assign: 1.1.0 - is-nan: 1.3.2 - object-is: 1.1.5 - util: 0.12.3 - dev: false - - /ast-types/0.13.2: - resolution: {integrity: sha512-uWMHxJxtfj/1oZClOxDEV1sQ1HCDkA4MG8Gr69KKeBjEVH0R84WlejZ0y2DcwyBlpAEMltmVYkVgqfLFb2oyiA==} - engines: {node: '>=4'} - dev: false - - /available-typed-arrays/1.0.2: - resolution: {integrity: sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ==} - engines: {node: '>= 0.4'} - dependencies: - array-filter: 1.0.0 - dev: false - - /babel-plugin-syntax-jsx/6.18.0: - resolution: {integrity: sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=} - dev: false - - /balanced-match/1.0.2: - resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - dev: false - - /base64-js/1.5.1: - resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - dev: false - - /big.js/5.2.2: - resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==} - dev: false - - /binary-extensions/2.2.0: - resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} - engines: {node: '>=8'} - dev: false - - /bn.js/4.12.0: - resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} - dev: false - - /bn.js/5.2.0: - resolution: {integrity: sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==} - dev: false - - /brace-expansion/1.1.11: - resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} - dependencies: - balanced-match: 1.0.2 - concat-map: 0.0.1 - dev: false - - /braces/3.0.2: - resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} - engines: {node: '>=8'} - dependencies: - fill-range: 7.0.1 - dev: false - - /brorand/1.1.0: - resolution: {integrity: sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=} - dev: false - - /browserify-aes/1.2.0: - resolution: {integrity: sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==} - dependencies: - buffer-xor: 1.0.3 - cipher-base: 1.0.4 - create-hash: 1.2.0 - evp_bytestokey: 1.0.3 - inherits: 2.0.4 - safe-buffer: 5.2.1 - dev: false - - /browserify-cipher/1.0.1: - resolution: {integrity: sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==} - dependencies: - browserify-aes: 1.2.0 - browserify-des: 1.0.2 - evp_bytestokey: 1.0.3 - dev: false - - /browserify-des/1.0.2: - resolution: {integrity: sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==} - dependencies: - cipher-base: 1.0.4 - des.js: 1.0.1 - inherits: 2.0.4 - safe-buffer: 5.2.1 - dev: false - - /browserify-rsa/4.1.0: - resolution: {integrity: sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==} - dependencies: - bn.js: 5.2.0 - randombytes: 2.1.0 - dev: false - - /browserify-sign/4.2.1: - resolution: {integrity: sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==} - dependencies: - bn.js: 5.2.0 - browserify-rsa: 4.1.0 - create-hash: 1.2.0 - create-hmac: 1.1.7 - elliptic: 6.5.4 - inherits: 2.0.4 - parse-asn1: 5.1.6 - readable-stream: 3.6.0 - safe-buffer: 5.2.1 - dev: false - - /browserify-zlib/0.2.0: - resolution: {integrity: sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==} - dependencies: - pako: 1.0.11 - dev: false - - /browserslist/4.16.1: - resolution: {integrity: sha512-UXhDrwqsNcpTYJBTZsbGATDxZbiVDsx6UjpmRUmtnP10pr8wAYr5LgFoEFw9ixriQH2mv/NX2SfGzE/o8GndLA==} - engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} - hasBin: true - dependencies: - caniuse-lite: 1.0.30001223 - colorette: 1.2.2 - electron-to-chromium: 1.3.727 - escalade: 3.1.1 - node-releases: 1.1.71 - dev: false - - /buffer-xor/1.0.3: - resolution: {integrity: sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=} - dev: false - - /buffer/4.9.2: - resolution: {integrity: sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==} - dependencies: - base64-js: 1.5.1 - ieee754: 1.2.1 - isarray: 1.0.0 - dev: false - - /buffer/5.6.0: - resolution: {integrity: sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==} - dependencies: - base64-js: 1.5.1 - ieee754: 1.2.1 - dev: false - - /builtin-status-codes/3.0.0: - resolution: {integrity: sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=} - dev: false - - /bytes/3.1.0: - resolution: {integrity: sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==} - engines: {node: '>= 0.8'} - dev: false - - /call-bind/1.0.2: - resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} - dependencies: - function-bind: 1.1.1 - get-intrinsic: 1.1.1 - dev: false - - /camel-case/4.1.2: - resolution: {integrity: sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==} - dependencies: - pascal-case: 3.1.2 - tslib: 2.2.0 - dev: false - - /caniuse-lite/1.0.30001223: - resolution: {integrity: sha512-k/RYs6zc/fjbxTjaWZemeSmOjO0JJV+KguOBA3NwPup8uzxM1cMhR2BD9XmO86GuqaqTCO8CgkgH9Rz//vdDiA==} - dev: false - - /capital-case/1.0.4: - resolution: {integrity: sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==} - dependencies: - no-case: 3.0.4 - tslib: 2.2.0 - upper-case-first: 2.0.2 - dev: false - - /chalk/2.4.2: - resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} - engines: {node: '>=4'} - dependencies: - ansi-styles: 3.2.1 - escape-string-regexp: 1.0.5 - supports-color: 5.5.0 - dev: false - - /chalk/4.0.0: - resolution: {integrity: sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - dev: false - - /change-case/4.1.2: - resolution: {integrity: sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==} - dependencies: - camel-case: 4.1.2 - capital-case: 1.0.4 - constant-case: 3.0.4 - dot-case: 3.0.4 - header-case: 2.0.4 - no-case: 3.0.4 - param-case: 3.0.4 - pascal-case: 3.1.2 - path-case: 3.0.4 - sentence-case: 3.0.4 - snake-case: 3.0.4 - tslib: 2.2.0 - dev: false - - /chokidar/3.5.1: - resolution: {integrity: sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==} - engines: {node: '>= 8.10.0'} - dependencies: - anymatch: 3.1.2 - braces: 3.0.2 - glob-parent: 5.1.2 - is-binary-path: 2.1.0 - is-glob: 4.0.1 - normalize-path: 3.0.0 - readdirp: 3.5.0 - optionalDependencies: - fsevents: 2.3.2 - dev: false - - /cipher-base/1.0.4: - resolution: {integrity: sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==} - dependencies: - inherits: 2.0.4 - safe-buffer: 5.2.1 - dev: false - - /classnames/2.2.6: - resolution: {integrity: sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==} - dev: false - - /color-convert/1.9.3: - resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} - dependencies: - color-name: 1.1.3 - dev: false - - /color-convert/2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} - dependencies: - color-name: 1.1.4 - dev: false - - /color-name/1.1.3: - resolution: {integrity: sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=} - dev: false - - /color-name/1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: false - - /colorette/1.2.2: - resolution: {integrity: sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==} - dev: false - - /commander/4.1.1: - resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} - engines: {node: '>= 6'} - dev: false - - /commondir/1.0.1: - resolution: {integrity: sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=} - dev: false - - /concat-map/0.0.1: - resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} - dev: false - - /console-browserify/1.2.0: - resolution: {integrity: sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==} - dev: false - - /constant-case/3.0.4: - resolution: {integrity: sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==} - dependencies: - no-case: 3.0.4 - tslib: 2.2.0 - upper-case: 2.0.2 - dev: false - - /constants-browserify/1.0.0: - resolution: {integrity: sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=} - dev: false - - /convert-source-map/1.7.0: - resolution: {integrity: sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==} - dependencies: - safe-buffer: 5.1.2 - dev: false - - /core-util-is/1.0.2: - resolution: {integrity: sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=} - dev: false - - /create-ecdh/4.0.4: - resolution: {integrity: sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==} - dependencies: - bn.js: 4.12.0 - elliptic: 6.5.4 - dev: false - - /create-hash/1.2.0: - resolution: {integrity: sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==} - dependencies: - cipher-base: 1.0.4 - inherits: 2.0.4 - md5.js: 1.3.5 - ripemd160: 2.0.2 - sha.js: 2.4.11 - dev: false - - /create-hmac/1.1.7: - resolution: {integrity: sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==} - dependencies: - cipher-base: 1.0.4 - create-hash: 1.2.0 - inherits: 2.0.4 - ripemd160: 2.0.2 - safe-buffer: 5.2.1 - sha.js: 2.4.11 - dev: false - - /crypto-browserify/3.12.0: - resolution: {integrity: sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==} - dependencies: - browserify-cipher: 1.0.1 - browserify-sign: 4.2.1 - create-ecdh: 4.0.4 - create-hash: 1.2.0 - create-hmac: 1.1.7 - diffie-hellman: 5.0.3 - inherits: 2.0.4 - pbkdf2: 3.1.2 - public-encrypt: 4.0.3 - randombytes: 2.1.0 - randomfill: 1.0.4 - dev: false - - /css.escape/1.5.1: - resolution: {integrity: sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=} - dev: false - - /cssnano-preset-simple/2.0.0_postcss@8.2.13: - resolution: {integrity: sha512-HkufSLkaBJbKBFx/7aj5HmCK9Ni/JedRQm0mT2qBzMG/dEuJOLnMt2lK6K1rwOOyV4j9aSY+knbW9WoS7BYpzg==} - peerDependencies: - postcss: ^8.2.1 - dependencies: - caniuse-lite: 1.0.30001223 - postcss: 8.2.13 - dev: false - - /cssnano-simple/2.0.0_postcss@8.2.13: - resolution: {integrity: sha512-0G3TXaFxlh/szPEG/o3VcmCwl0N3E60XNb9YZZijew5eIs6fLjJuOPxQd9yEBaX2p/YfJtt49i4vYi38iH6/6w==} - peerDependencies: - postcss: ^8.2.2 - dependencies: - cssnano-preset-simple: 2.0.0_postcss@8.2.13 - postcss: 8.2.13 - dev: false - - /data-uri-to-buffer/3.0.1: - resolution: {integrity: sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==} - engines: {node: '>= 6'} - dev: false - - /debug/2.6.9: - resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} - dependencies: - ms: 2.0.0 - dev: false - - /define-properties/1.1.3: - resolution: {integrity: sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==} - engines: {node: '>= 0.4'} - dependencies: - object-keys: 1.1.1 - dev: false - - /depd/1.1.2: - resolution: {integrity: sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=} - engines: {node: '>= 0.6'} - dev: false - - /des.js/1.0.1: - resolution: {integrity: sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==} - dependencies: - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - dev: false - - /diffie-hellman/5.0.3: - resolution: {integrity: sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==} - dependencies: - bn.js: 4.12.0 - miller-rabin: 4.0.1 - randombytes: 2.1.0 - dev: false - - /domain-browser/1.2.0: - resolution: {integrity: sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==} - engines: {node: '>=0.4', npm: '>=1.2'} - dev: false - - /domain-browser/4.19.0: - resolution: {integrity: sha512-fRA+BaAWOR/yr/t7T9E9GJztHPeFjj8U35ajyAjCDtAAnTn1Rc1f6W6VGPJrO1tkQv9zWu+JRof7z6oQtiYVFQ==} - engines: {node: '>=10'} - dev: false - - /dot-case/3.0.4: - resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==} - dependencies: - no-case: 3.0.4 - tslib: 2.2.0 - dev: false - - /electron-to-chromium/1.3.727: - resolution: {integrity: sha512-Mfz4FIB4FSvEwBpDfdipRIrwd6uo8gUDoRDF4QEYb4h4tSuI3ov594OrjU6on042UlFHouIJpClDODGkPcBSbg==} - dev: false - - /elliptic/6.5.4: - resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} - dependencies: - bn.js: 4.12.0 - brorand: 1.1.0 - hash.js: 1.1.7 - hmac-drbg: 1.0.1 - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - dev: false - - /emojis-list/2.1.0: - resolution: {integrity: sha1-TapNnbAPmBmIDHn6RXrlsJof04k=} - engines: {node: '>= 0.10'} - dev: false - - /encoding/0.1.13: - resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==} - dependencies: - iconv-lite: 0.6.2 - dev: false - - /es-abstract/1.18.0: - resolution: {integrity: sha512-LJzK7MrQa8TS0ja2w3YNLzUgJCGPdPOV1yVvezjNnS89D+VR08+Szt2mz3YB2Dck/+w5tfIq/RoUAFqJJGM2yw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - es-to-primitive: 1.2.1 - function-bind: 1.1.1 - get-intrinsic: 1.1.1 - has: 1.0.3 - has-symbols: 1.0.2 - is-callable: 1.2.3 - is-negative-zero: 2.0.1 - is-regex: 1.1.2 - is-string: 1.0.5 - object-inspect: 1.10.2 - object-keys: 1.1.1 - object.assign: 4.1.2 - string.prototype.trimend: 1.0.4 - string.prototype.trimstart: 1.0.4 - unbox-primitive: 1.0.1 - dev: false - - /es-to-primitive/1.2.1: - resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} - engines: {node: '>= 0.4'} - dependencies: - is-callable: 1.2.3 - is-date-object: 1.0.3 - is-symbol: 1.0.3 - dev: false - - /es6-object-assign/1.1.0: - resolution: {integrity: sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=} - dev: false - - /escalade/3.1.1: - resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} - engines: {node: '>=6'} - dev: false - - /escape-string-regexp/1.0.5: - resolution: {integrity: sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=} - engines: {node: '>=0.8.0'} - dev: false - - /esutils/2.0.3: - resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} - engines: {node: '>=0.10.0'} - dev: false - - /etag/1.8.1: - resolution: {integrity: sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=} - engines: {node: '>= 0.6'} - dev: false - - /events/3.3.0: - resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} - engines: {node: '>=0.8.x'} - dev: false - - /evp_bytestokey/1.0.3: - resolution: {integrity: sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==} - dependencies: - md5.js: 1.3.5 - safe-buffer: 5.2.1 - dev: false - - /fill-range/7.0.1: - resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} - engines: {node: '>=8'} - dependencies: - to-regex-range: 5.0.1 - dev: false - - /find-cache-dir/3.3.1: - resolution: {integrity: sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==} - engines: {node: '>=8'} - dependencies: - commondir: 1.0.1 - make-dir: 3.1.0 - pkg-dir: 4.2.0 - dev: false - - /find-up/4.1.0: - resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} - engines: {node: '>=8'} - dependencies: - locate-path: 5.0.0 - path-exists: 4.0.0 - dev: false - - /foreach/2.0.5: - resolution: {integrity: sha1-C+4AUBiusmDQo6865ljdATbsG5k=} - dev: false - - /fs.realpath/1.0.0: - resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=} - dev: false - - /fsevents/2.3.2: - resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - dev: false - optional: true - - /function-bind/1.1.1: - resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} - dev: false - - /get-intrinsic/1.1.1: - resolution: {integrity: sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==} - dependencies: - function-bind: 1.1.1 - has: 1.0.3 - has-symbols: 1.0.2 - dev: false - - /get-orientation/1.1.2: - resolution: {integrity: sha512-/pViTfifW+gBbh/RnlFYHINvELT9Znt+SYyDKAUL6uV6By019AK/s+i9XP4jSwq7lwP38Fd8HVeTxym3+hkwmQ==} - dependencies: - stream-parser: 0.3.1 - dev: false - - /glob-parent/5.1.2: - resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} - engines: {node: '>= 6'} - dependencies: - is-glob: 4.0.1 - dev: false - - /glob-to-regexp/0.4.1: - resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} - dev: false - - /glob/7.1.6: - resolution: {integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.0.4 - once: 1.4.0 - path-is-absolute: 1.0.1 - dev: false - - /graceful-fs/4.2.6: - resolution: {integrity: sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==} - dev: false - - /has-bigints/1.0.1: - resolution: {integrity: sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==} - dev: false - - /has-flag/3.0.0: - resolution: {integrity: sha1-tdRU3CGZriJWmfNGfloH87lVuv0=} - engines: {node: '>=4'} - dev: false - - /has-flag/4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - dev: false - - /has-symbols/1.0.2: - resolution: {integrity: sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==} - engines: {node: '>= 0.4'} - dev: false - - /has/1.0.3: - resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} - engines: {node: '>= 0.4.0'} - dependencies: - function-bind: 1.1.1 - dev: false - - /hash-base/3.1.0: - resolution: {integrity: sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==} - engines: {node: '>=4'} - dependencies: - inherits: 2.0.4 - readable-stream: 3.6.0 - safe-buffer: 5.2.1 - dev: false - - /hash.js/1.1.7: - resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} - dependencies: - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - dev: false - - /he/1.2.0: - resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} - hasBin: true - dev: false - - /header-case/2.0.4: - resolution: {integrity: sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==} - dependencies: - capital-case: 1.0.4 - tslib: 2.2.0 - dev: false - - /hmac-drbg/1.0.1: - resolution: {integrity: sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=} - dependencies: - hash.js: 1.1.7 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - dev: false - - /http-errors/1.7.3: - resolution: {integrity: sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==} - engines: {node: '>= 0.6'} - dependencies: - depd: 1.1.2 - inherits: 2.0.4 - setprototypeof: 1.1.1 - statuses: 1.5.0 - toidentifier: 1.0.0 - dev: false - - /https-browserify/1.0.0: - resolution: {integrity: sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=} - dev: false - - /iconv-lite/0.4.24: - resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} - engines: {node: '>=0.10.0'} - dependencies: - safer-buffer: 2.1.2 - dev: false - - /iconv-lite/0.6.2: - resolution: {integrity: sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==} - engines: {node: '>=0.10.0'} - dependencies: - safer-buffer: 2.1.2 - dev: false - - /ieee754/1.2.1: - resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} - dev: false - - /inflight/1.0.6: - resolution: {integrity: sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=} - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - dev: false - - /inherits/2.0.1: - resolution: {integrity: sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=} - dev: false - - /inherits/2.0.3: - resolution: {integrity: sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=} - dev: false - - /inherits/2.0.4: - resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - dev: false - - /is-arguments/1.1.0: - resolution: {integrity: sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - dev: false - - /is-bigint/1.0.2: - resolution: {integrity: sha512-0JV5+SOCQkIdzjBK9buARcV804Ddu7A0Qet6sHi3FimE9ne6m4BGQZfRn+NZiXbBk4F4XmHfDZIipLj9pX8dSA==} - dev: false - - /is-binary-path/2.1.0: - resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} - engines: {node: '>=8'} - dependencies: - binary-extensions: 2.2.0 - dev: false - - /is-boolean-object/1.1.0: - resolution: {integrity: sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - dev: false - - /is-callable/1.2.3: - resolution: {integrity: sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==} - engines: {node: '>= 0.4'} - dev: false - - /is-date-object/1.0.3: - resolution: {integrity: sha512-tDpEUInNcy2Yw3lNSepK3Wdw1RnXLcIVienz6Ou631Acl15cJyRWK4dgA1vCmOEgIbtOV0W7MHg+AR2Gdg1NXQ==} - engines: {node: '>= 0.4'} - dev: false - - /is-extglob/2.1.1: - resolution: {integrity: sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=} - engines: {node: '>=0.10.0'} - dev: false - - /is-generator-function/1.0.9: - resolution: {integrity: sha512-ZJ34p1uvIfptHCN7sFTjGibB9/oBg17sHqzDLfuwhvmN/qLVvIQXRQ8licZQ35WJ8KuEQt/etnnzQFI9C9Ue/A==} - engines: {node: '>= 0.4'} - dev: false - - /is-glob/4.0.1: - resolution: {integrity: sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==} - engines: {node: '>=0.10.0'} - dependencies: - is-extglob: 2.1.1 - dev: false - - /is-nan/1.3.2: - resolution: {integrity: sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.3 - dev: false - - /is-negative-zero/2.0.1: - resolution: {integrity: sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==} - engines: {node: '>= 0.4'} - dev: false - - /is-number-object/1.0.4: - resolution: {integrity: sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==} - engines: {node: '>= 0.4'} - dev: false - - /is-number/7.0.0: - resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} - engines: {node: '>=0.12.0'} - dev: false - - /is-regex/1.1.2: - resolution: {integrity: sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - has-symbols: 1.0.2 - dev: false - - /is-string/1.0.5: - resolution: {integrity: sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==} - engines: {node: '>= 0.4'} - dev: false - - /is-symbol/1.0.3: - resolution: {integrity: sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==} - engines: {node: '>= 0.4'} - dependencies: - has-symbols: 1.0.2 - dev: false - - /is-typed-array/1.1.5: - resolution: {integrity: sha512-S+GRDgJlR3PyEbsX/Fobd9cqpZBuvUS+8asRqYDMLCb2qMzt1oz5m5oxQCxOgUDxiWsOVNi4yaF+/uvdlHlYug==} - engines: {node: '>= 0.4'} - dependencies: - available-typed-arrays: 1.0.2 - call-bind: 1.0.2 - es-abstract: 1.18.0 - foreach: 2.0.5 - has-symbols: 1.0.2 - dev: false - - /isarray/1.0.0: - resolution: {integrity: sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=} - dev: false - - /jest-worker/27.0.0-next.5: - resolution: {integrity: sha512-mk0umAQ5lT+CaOJ+Qp01N6kz48sJG2kr2n1rX0koqKf6FIygQV0qLOdN9SCYID4IVeSigDOcPeGLozdMLYfb5g==} - engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} - dependencies: - '@types/node': 15.0.2 - merge-stream: 2.0.0 - supports-color: 8.1.1 - dev: false - - /js-tokens/4.0.0: - resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - dev: false - - /json5/1.0.1: - resolution: {integrity: sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==} - hasBin: true - dependencies: - minimist: 1.2.5 - dev: false - - /lines-and-columns/1.1.6: - resolution: {integrity: sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=} - dev: false - - /loader-utils/1.2.3: - resolution: {integrity: sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==} - engines: {node: '>=4.0.0'} - dependencies: - big.js: 5.2.2 - emojis-list: 2.1.0 - json5: 1.0.1 - dev: false - - /locate-path/5.0.0: - resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} - engines: {node: '>=8'} - dependencies: - p-locate: 4.1.0 - dev: false - - /lodash.sortby/4.7.0: - resolution: {integrity: sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=} - dev: false - - /lodash/4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: false - - /loose-envify/1.4.0: - resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} - hasBin: true - dependencies: - js-tokens: 4.0.0 - dev: false - - /lower-case/2.0.2: - resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==} - dependencies: - tslib: 2.2.0 - dev: false - - /make-dir/3.1.0: - resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} - engines: {node: '>=8'} - dependencies: - semver: 6.3.0 - dev: false - - /md5.js/1.3.5: - resolution: {integrity: sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==} - dependencies: - hash-base: 3.1.0 - inherits: 2.0.4 - safe-buffer: 5.2.1 - dev: false - - /merge-stream/2.0.0: - resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - dev: false - - /miller-rabin/4.0.1: - resolution: {integrity: sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==} - hasBin: true - dependencies: - bn.js: 4.12.0 - brorand: 1.1.0 - dev: false - - /minimalistic-assert/1.0.1: - resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} - dev: false - - /minimalistic-crypto-utils/1.0.1: - resolution: {integrity: sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=} - dev: false - - /minimatch/3.0.4: - resolution: {integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==} - dependencies: - brace-expansion: 1.1.11 - dev: false - - /minimist/1.2.5: - resolution: {integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==} - dev: false - - /ms/2.0.0: - resolution: {integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=} - dev: false - - /mz/2.7.0: - resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} - dependencies: - any-promise: 1.3.0 - object-assign: 4.1.1 - thenify-all: 1.6.0 - dev: false - - /nanoid/3.1.22: - resolution: {integrity: sha512-/2ZUaJX2ANuLtTvqTlgqBQNJoQO398KyJgZloL0PZkC0dpysjncRUPsFe3DUPzz/y3h+u7C46np8RMuvF3jsSQ==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - dev: false - - /native-url/0.3.4: - resolution: {integrity: sha512-6iM8R99ze45ivyH8vybJ7X0yekIcPf5GgLV5K0ENCbmRcaRIDoj37BC8iLEmaaBfqqb8enuZ5p0uhY+lVAbAcA==} - dependencies: - querystring: 0.2.1 - dev: false - - /next/10.2.0_react-dom@17.0.2+react@17.0.2: - resolution: {integrity: sha512-PKDKCSF7s82xudu3kQhOEaokxggpbLEWouEUtzP6OqV0YqKYHF+Ff+BFLycEem8ixtTM2M6ElN0VRJcskJfxPQ==} - engines: {node: '>=10.13.0'} - hasBin: true - peerDependencies: - fibers: '>= 3.1.0' - node-sass: ^4.0.0 || ^5.0.0 - react: ^16.6.0 || ^17 - react-dom: ^16.6.0 || ^17 - sass: ^1.3.0 - peerDependenciesMeta: - fibers: - optional: true - node-sass: - optional: true - sass: - optional: true - dependencies: - '@babel/runtime': 7.12.5 - '@hapi/accept': 5.0.1 - '@next/env': 10.2.0 - '@next/polyfill-module': 10.2.0 - '@next/react-dev-overlay': 10.2.0_react-dom@17.0.2+react@17.0.2 - '@next/react-refresh-utils': 10.2.0_react-refresh@0.8.3 - '@opentelemetry/api': 0.14.0 - assert: 2.0.0 - ast-types: 0.13.2 - browserify-zlib: 0.2.0 - browserslist: 4.16.1 - buffer: 5.6.0 - caniuse-lite: 1.0.30001223 - chalk: 2.4.2 - chokidar: 3.5.1 - constants-browserify: 1.0.0 - crypto-browserify: 3.12.0 - cssnano-simple: 2.0.0_postcss@8.2.13 - domain-browser: 4.19.0 - encoding: 0.1.13 - etag: 1.8.1 - find-cache-dir: 3.3.1 - get-orientation: 1.1.2 - https-browserify: 1.0.0 - jest-worker: 27.0.0-next.5 - native-url: 0.3.4 - node-fetch: 2.6.1 - node-html-parser: 1.4.9 - node-libs-browser: 2.2.1 - os-browserify: 0.3.0 - p-limit: 3.1.0 - path-browserify: 1.0.1 - pnp-webpack-plugin: 1.6.4 - postcss: 8.2.13 - process: 0.11.10 - prop-types: 15.7.2 - querystring-es3: 0.2.1 - raw-body: 2.4.1 - react: 17.0.2 - react-dom: 17.0.2_react@17.0.2 - react-is: 16.13.1 - react-refresh: 0.8.3 - stream-browserify: 3.0.0 - stream-http: 3.1.1 - string_decoder: 1.3.0 - styled-jsx: 3.3.2_react@17.0.2 - timers-browserify: 2.0.12 - tty-browserify: 0.0.1 - use-subscription: 1.5.1_react@17.0.2 - util: 0.12.3 - vm-browserify: 1.1.2 - watchpack: 2.1.1 - transitivePeerDependencies: - - typescript - - webpack - dev: false - - /no-case/3.0.4: - resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} - dependencies: - lower-case: 2.0.2 - tslib: 2.2.0 - dev: false - - /node-fetch/2.6.1: - resolution: {integrity: sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==} - engines: {node: 4.x || >=6.0.0} - dev: false - - /node-html-parser/1.4.9: - resolution: {integrity: sha512-UVcirFD1Bn0O+TSmloHeHqZZCxHjvtIeGdVdGMhyZ8/PWlEiZaZ5iJzR189yKZr8p0FXN58BUeC7RHRkf/KYGw==} - dependencies: - he: 1.2.0 - dev: false - - /node-libs-browser/2.2.1: - resolution: {integrity: sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q==} - dependencies: - assert: 1.5.0 - browserify-zlib: 0.2.0 - buffer: 4.9.2 - console-browserify: 1.2.0 - constants-browserify: 1.0.0 - crypto-browserify: 3.12.0 - domain-browser: 1.2.0 - events: 3.3.0 - https-browserify: 1.0.0 - os-browserify: 0.3.0 - path-browserify: 0.0.1 - process: 0.11.10 - punycode: 1.4.1 - querystring-es3: 0.2.1 - readable-stream: 2.3.7 - stream-browserify: 2.0.2 - stream-http: 2.8.3 - string_decoder: 1.3.0 - timers-browserify: 2.0.12 - tty-browserify: 0.0.0 - url: 0.11.0 - util: 0.11.1 - vm-browserify: 1.1.2 - dev: false - - /node-modules-regexp/1.0.0: - resolution: {integrity: sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=} - engines: {node: '>=0.10.0'} - dev: false - - /node-releases/1.1.71: - resolution: {integrity: sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg==} - dev: false - - /normalize-path/3.0.0: - resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} - engines: {node: '>=0.10.0'} - dev: false - - /object-assign/4.1.1: - resolution: {integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=} - engines: {node: '>=0.10.0'} - dev: false - - /object-inspect/1.10.2: - resolution: {integrity: sha512-gz58rdPpadwztRrPjZE9DZLOABUpTGdcANUgOwBFO1C+HZZhePoP83M65WGDmbpwFYJSWqavbl4SgDn4k8RYTA==} - dev: false - - /object-is/1.1.5: - resolution: {integrity: sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.3 - dev: false - - /object-keys/1.1.1: - resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} - engines: {node: '>= 0.4'} - dev: false - - /object.assign/4.1.2: - resolution: {integrity: sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.3 - has-symbols: 1.0.2 - object-keys: 1.1.1 - dev: false - - /once/1.4.0: - resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=} - dependencies: - wrappy: 1.0.2 - dev: false - - /os-browserify/0.3.0: - resolution: {integrity: sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=} - dev: false - - /p-limit/2.3.0: - resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} - engines: {node: '>=6'} - dependencies: - p-try: 2.2.0 - dev: false - - /p-limit/3.1.0: - resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} - engines: {node: '>=10'} - dependencies: - yocto-queue: 0.1.0 - dev: false - - /p-locate/4.1.0: - resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} - engines: {node: '>=8'} - dependencies: - p-limit: 2.3.0 - dev: false - - /p-try/2.2.0: - resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} - engines: {node: '>=6'} - dev: false - - /pako/1.0.11: - resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} - dev: false - - /param-case/3.0.4: - resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==} - dependencies: - dot-case: 3.0.4 - tslib: 2.2.0 - dev: false - - /parse-asn1/5.1.6: - resolution: {integrity: sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==} - dependencies: - asn1.js: 5.4.1 - browserify-aes: 1.2.0 - evp_bytestokey: 1.0.3 - pbkdf2: 3.1.2 - safe-buffer: 5.2.1 - dev: false - - /pascal-case/3.1.2: - resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==} - dependencies: - no-case: 3.0.4 - tslib: 2.2.0 - dev: false - - /path-browserify/0.0.1: - resolution: {integrity: sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==} - dev: false - - /path-browserify/1.0.1: - resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} - dev: false - - /path-case/3.0.4: - resolution: {integrity: sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==} - dependencies: - dot-case: 3.0.4 - tslib: 2.2.0 - dev: false - - /path-exists/4.0.0: - resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} - engines: {node: '>=8'} - dev: false - - /path-is-absolute/1.0.1: - resolution: {integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=} - engines: {node: '>=0.10.0'} - dev: false - - /pbkdf2/3.1.2: - resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==} - engines: {node: '>=0.12'} - dependencies: - create-hash: 1.2.0 - create-hmac: 1.1.7 - ripemd160: 2.0.2 - safe-buffer: 5.2.1 - sha.js: 2.4.11 - dev: false - - /peechy/0.4.3: - resolution: {integrity: sha512-V7caZQjhB1KYuvyLgUEtzyTT0xEfU5X+kK26fKoQVGuS5PpuBtJxnI1UcVW1dvxpfYJ/D+mCjUnq+bVCvZSSsw==} - hasBin: true - dependencies: - change-case: 4.1.2 - dev: false - - /picomatch/2.2.3: - resolution: {integrity: sha512-KpELjfwcCDUb9PeigTs2mBJzXUPzAuP2oPcA989He8Rte0+YUAjw1JVedDhuTKPkHjSYzMN3npC9luThGYEKdg==} - engines: {node: '>=8.6'} - dev: false - - /pirates/4.0.1: - resolution: {integrity: sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA==} - engines: {node: '>= 6'} - dependencies: - node-modules-regexp: 1.0.0 - dev: false - - /pkg-dir/4.2.0: - resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} - engines: {node: '>=8'} - dependencies: - find-up: 4.1.0 - dev: false - - /platform/1.3.6: - resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==} - dev: false - - /pnp-webpack-plugin/1.6.4: - resolution: {integrity: sha512-7Wjy+9E3WwLOEL30D+m8TSTF7qJJUJLONBnwQp0518siuMxUQUbgZwssaFX+QKlZkjHZcw/IpZCt/H0srrntSg==} - engines: {node: '>=6'} - dependencies: - ts-pnp: 1.2.0 - transitivePeerDependencies: - - typescript - dev: false - - /postcss/8.2.13: - resolution: {integrity: sha512-FCE5xLH+hjbzRdpbRb1IMCvPv9yZx2QnDarBEYSN0N0HYk+TcXsEhwdFcFb+SRWOKzKGErhIEbBK2ogyLdTtfQ==} - engines: {node: ^10 || ^12 || >=14} - dependencies: - colorette: 1.2.2 - nanoid: 3.1.22 - source-map: 0.6.1 - dev: false - - /process-nextick-args/2.0.1: - resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} - dev: false - - /process/0.11.10: - resolution: {integrity: sha1-czIwDoQBYb2j5podHZGn1LwW8YI=} - engines: {node: '>= 0.6.0'} - dev: false - - /prop-types/15.7.2: - resolution: {integrity: sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==} - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - react-is: 16.13.1 - dev: false - - /public-encrypt/4.0.3: - resolution: {integrity: sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==} - dependencies: - bn.js: 4.12.0 - browserify-rsa: 4.1.0 - create-hash: 1.2.0 - parse-asn1: 5.1.6 - randombytes: 2.1.0 - safe-buffer: 5.2.1 - dev: false - - /punycode/1.3.2: - resolution: {integrity: sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=} - dev: false - - /punycode/1.4.1: - resolution: {integrity: sha1-wNWmOycYgArY4esPpSachN1BhF4=} - dev: false - - /punycode/2.1.1: - resolution: {integrity: sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==} - engines: {node: '>=6'} - dev: false - - /querystring-es3/0.2.1: - resolution: {integrity: sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=} - engines: {node: '>=0.4.x'} - dev: false - - /querystring/0.2.0: - resolution: {integrity: sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=} - engines: {node: '>=0.4.x'} - dev: false - - /querystring/0.2.1: - resolution: {integrity: sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==} - engines: {node: '>=0.4.x'} - dev: false - - /randombytes/2.1.0: - resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} - dependencies: - safe-buffer: 5.2.1 - dev: false - - /randomfill/1.0.4: - resolution: {integrity: sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==} - dependencies: - randombytes: 2.1.0 - safe-buffer: 5.2.1 - dev: false - - /raw-body/2.4.1: - resolution: {integrity: sha512-9WmIKF6mkvA0SLmA2Knm9+qj89e+j1zqgyn8aXGd7+nAduPoqgI9lO57SAZNn/Byzo5P7JhXTyg9PzaJbH73bA==} - engines: {node: '>= 0.8'} - dependencies: - bytes: 3.1.0 - http-errors: 1.7.3 - iconv-lite: 0.4.24 - unpipe: 1.0.0 - dev: false - - /react-dom/17.0.2_react@17.0.2: - resolution: {integrity: sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==} - peerDependencies: - react: 17.0.2 - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - react: 17.0.2 - scheduler: 0.20.2 - dev: false - - /react-is/16.13.1: - resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} - dev: false - - /react-refresh/0.8.3: - resolution: {integrity: sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==} - engines: {node: '>=0.10.0'} - dev: false - - /react/17.0.2: - resolution: {integrity: sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==} - engines: {node: '>=0.10.0'} - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - dev: false - - /readable-stream/2.3.7: - resolution: {integrity: sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==} - dependencies: - core-util-is: 1.0.2 - inherits: 2.0.4 - isarray: 1.0.0 - process-nextick-args: 2.0.1 - safe-buffer: 5.1.2 - string_decoder: 1.1.1 - util-deprecate: 1.0.2 - dev: false - - /readable-stream/3.6.0: - resolution: {integrity: sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==} - engines: {node: '>= 6'} - dependencies: - inherits: 2.0.4 - string_decoder: 1.3.0 - util-deprecate: 1.0.2 - dev: false - - /readdirp/3.5.0: - resolution: {integrity: sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==} - engines: {node: '>=8.10.0'} - dependencies: - picomatch: 2.2.3 - dev: false - - /regenerator-runtime/0.13.7: - resolution: {integrity: sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==} - dev: false - - /ripemd160/2.0.2: - resolution: {integrity: sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==} - dependencies: - hash-base: 3.1.0 - inherits: 2.0.4 - dev: false - - /safe-buffer/5.1.2: - resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} - dev: false - - /safe-buffer/5.2.1: - resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - dev: false - - /safer-buffer/2.1.2: - resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} - dev: false - - /scheduler/0.20.2: - resolution: {integrity: sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==} - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - dev: false - - /semver/6.3.0: - resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} - hasBin: true - dev: false - - /sentence-case/3.0.4: - resolution: {integrity: sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==} - dependencies: - no-case: 3.0.4 - tslib: 2.2.0 - upper-case-first: 2.0.2 - dev: false - - /setimmediate/1.0.5: - resolution: {integrity: sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=} - dev: false - - /setprototypeof/1.1.1: - resolution: {integrity: sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==} - dev: false - - /sha.js/2.4.11: - resolution: {integrity: sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==} - hasBin: true - dependencies: - inherits: 2.0.4 - safe-buffer: 5.2.1 - dev: false - - /shell-quote/1.7.2: - resolution: {integrity: sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==} - dev: false - - /snake-case/3.0.4: - resolution: {integrity: sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==} - dependencies: - dot-case: 3.0.4 - tslib: 2.2.0 - dev: false - - /source-map/0.6.1: - resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} - engines: {node: '>=0.10.0'} - dev: false - - /source-map/0.7.3: - resolution: {integrity: sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==} - engines: {node: '>= 8'} - dev: false - - /source-map/0.8.0-beta.0: - resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} - engines: {node: '>= 8'} - dependencies: - whatwg-url: 7.1.0 - dev: false - - /stacktrace-parser/0.1.10: - resolution: {integrity: sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg==} - engines: {node: '>=6'} - dependencies: - type-fest: 0.7.1 - dev: false - - /statuses/1.5.0: - resolution: {integrity: sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=} - engines: {node: '>= 0.6'} - dev: false - - /stream-browserify/2.0.2: - resolution: {integrity: sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==} - dependencies: - inherits: 2.0.4 - readable-stream: 2.3.7 - dev: false - - /stream-browserify/3.0.0: - resolution: {integrity: sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==} - dependencies: - inherits: 2.0.4 - readable-stream: 3.6.0 - dev: false - - /stream-http/2.8.3: - resolution: {integrity: sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==} - dependencies: - builtin-status-codes: 3.0.0 - inherits: 2.0.4 - readable-stream: 2.3.7 - to-arraybuffer: 1.0.1 - xtend: 4.0.2 - dev: false - - /stream-http/3.1.1: - resolution: {integrity: sha512-S7OqaYu0EkFpgeGFb/NPOoPLxFko7TPqtEeFg5DXPB4v/KETHG0Ln6fRFrNezoelpaDKmycEmmZ81cC9DAwgYg==} - dependencies: - builtin-status-codes: 3.0.0 - inherits: 2.0.4 - readable-stream: 3.6.0 - xtend: 4.0.2 - dev: false - - /stream-parser/0.3.1: - resolution: {integrity: sha1-FhhUhpRCACGhGC/wrxkRwSl2F3M=} - dependencies: - debug: 2.6.9 - dev: false - - /string-hash/1.1.3: - resolution: {integrity: sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs=} - dev: false - - /string.prototype.trimend/1.0.4: - resolution: {integrity: sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.3 - dev: false - - /string.prototype.trimstart/1.0.4: - resolution: {integrity: sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==} - dependencies: - call-bind: 1.0.2 - define-properties: 1.1.3 - dev: false - - /string_decoder/1.1.1: - resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} - dependencies: - safe-buffer: 5.1.2 - dev: false - - /string_decoder/1.3.0: - resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} - dependencies: - safe-buffer: 5.2.1 - dev: false - - /strip-ansi/6.0.0: - resolution: {integrity: sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==} - engines: {node: '>=8'} - dependencies: - ansi-regex: 5.0.0 - dev: false - - /styled-jsx/3.3.2_react@17.0.2: - resolution: {integrity: sha512-daAkGd5mqhbBhLd6jYAjYBa9LpxYCzsgo/f6qzPdFxVB8yoGbhxvzQgkC0pfmCVvW3JuAEBn0UzFLBfkHVZG1g==} - peerDependencies: - react: 15.x.x || 16.x.x || 17.x.x - dependencies: - '@babel/types': 7.8.3 - babel-plugin-syntax-jsx: 6.18.0 - convert-source-map: 1.7.0 - loader-utils: 1.2.3 - react: 17.0.2 - source-map: 0.7.3 - string-hash: 1.1.3 - stylis: 3.5.4 - stylis-rule-sheet: 0.0.10_stylis@3.5.4 - dev: false - - /stylis-rule-sheet/0.0.10_stylis@3.5.4: - resolution: {integrity: sha512-nTbZoaqoBnmK+ptANthb10ZRZOGC+EmTLLUxeYIuHNkEKcmKgXX1XWKkUBT2Ac4es3NybooPe0SmvKdhKJZAuw==} - peerDependencies: - stylis: ^3.5.0 - dependencies: - stylis: 3.5.4 - dev: false - - /stylis/3.5.4: - resolution: {integrity: sha512-8/3pSmthWM7lsPBKv7NXkzn2Uc9W7NotcwGNpJaa3k7WMM1XDCA4MgT5k/8BIexd5ydZdboXtU90XH9Ec4Bv/Q==} - dev: false - - /sucrase/3.18.1: - resolution: {integrity: sha512-TRyO38wwOPhLLlM8QLOG3TgMj0FKk+arlTrS9pRAanF8cAcHvgRPKIYWGO25mPSp/Rj87zMMTjFfkqIZGI6ZdA==} - engines: {node: '>=8'} - hasBin: true - dependencies: - commander: 4.1.1 - glob: 7.1.6 - lines-and-columns: 1.1.6 - mz: 2.7.0 - pirates: 4.0.1 - ts-interface-checker: 0.1.13 - dev: false - - /supports-color/5.5.0: - resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} - engines: {node: '>=4'} - dependencies: - has-flag: 3.0.0 - dev: false - - /supports-color/7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} - dependencies: - has-flag: 4.0.0 - dev: false - - /supports-color/8.1.1: - resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} - engines: {node: '>=10'} - dependencies: - has-flag: 4.0.0 - dev: false - - /thenify-all/1.6.0: - resolution: {integrity: sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=} - engines: {node: '>=0.8'} - dependencies: - thenify: 3.3.1 - dev: false - - /thenify/3.3.1: - resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==} - dependencies: - any-promise: 1.3.0 - dev: false - - /timers-browserify/2.0.12: - resolution: {integrity: sha512-9phl76Cqm6FhSX9Xe1ZUAMLtm1BLkKj2Qd5ApyWkXzsMRaA7dgr81kf4wJmQf/hAvg8EEyJxDo3du/0KlhPiKQ==} - engines: {node: '>=0.6.0'} - dependencies: - setimmediate: 1.0.5 - dev: false - - /to-arraybuffer/1.0.1: - resolution: {integrity: sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=} - dev: false - - /to-fast-properties/2.0.0: - resolution: {integrity: sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=} - engines: {node: '>=4'} - dev: false - - /to-regex-range/5.0.1: - resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} - engines: {node: '>=8.0'} - dependencies: - is-number: 7.0.0 - dev: false - - /toidentifier/1.0.0: - resolution: {integrity: sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==} - engines: {node: '>=0.6'} - dev: false - - /tr46/1.0.1: - resolution: {integrity: sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=} - dependencies: - punycode: 2.1.1 - dev: false - - /ts-interface-checker/0.1.13: - resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} - dev: false - - /ts-pnp/1.2.0: - resolution: {integrity: sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==} - engines: {node: '>=6'} - peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dev: false - - /tslib/2.2.0: - resolution: {integrity: sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==} - dev: false - - /tty-browserify/0.0.0: - resolution: {integrity: sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=} - dev: false - - /tty-browserify/0.0.1: - resolution: {integrity: sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==} - dev: false - - /type-fest/0.7.1: - resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} - engines: {node: '>=8'} - dev: false - - /unbox-primitive/1.0.1: - resolution: {integrity: sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==} - dependencies: - function-bind: 1.1.1 - has-bigints: 1.0.1 - has-symbols: 1.0.2 - which-boxed-primitive: 1.0.2 - dev: false - - /unpipe/1.0.0: - resolution: {integrity: sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=} - engines: {node: '>= 0.8'} - dev: false - - /upper-case-first/2.0.2: - resolution: {integrity: sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==} - dependencies: - tslib: 2.2.0 - dev: false - - /upper-case/2.0.2: - resolution: {integrity: sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==} - dependencies: - tslib: 2.2.0 - dev: false - - /url/0.11.0: - resolution: {integrity: sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=} - dependencies: - punycode: 1.3.2 - querystring: 0.2.0 - dev: false - - /use-subscription/1.5.1_react@17.0.2: - resolution: {integrity: sha512-Xv2a1P/yReAjAbhylMfFplFKj9GssgTwN7RlcTxBujFQcloStWNDQdc4g4NRWH9xS4i/FDk04vQBptAXoF3VcA==} - peerDependencies: - react: ^16.8.0 || ^17.0.0 - dependencies: - object-assign: 4.1.1 - react: 17.0.2 - dev: false - - /util-deprecate/1.0.2: - resolution: {integrity: sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=} - dev: false - - /util/0.10.3: - resolution: {integrity: sha1-evsa/lCAUkZInj23/g7TeTNqwPk=} - dependencies: - inherits: 2.0.1 - dev: false - - /util/0.11.1: - resolution: {integrity: sha512-HShAsny+zS2TZfaXxD9tYj4HQGlBezXZMZuM/S5PKLLoZkShZiGk9o5CzukI1LVHZvjdvZ2Sj1aW/Ndn2NB/HQ==} - dependencies: - inherits: 2.0.3 - dev: false - - /util/0.12.3: - resolution: {integrity: sha512-I8XkoQwE+fPQEhy9v012V+TSdH2kp9ts29i20TaaDUXsg7x/onePbhFJUExBfv/2ay1ZOp/Vsm3nDlmnFGSAog==} - dependencies: - inherits: 2.0.4 - is-arguments: 1.1.0 - is-generator-function: 1.0.9 - is-typed-array: 1.1.5 - safe-buffer: 5.2.1 - which-typed-array: 1.1.4 - dev: false - - /vm-browserify/1.1.2: - resolution: {integrity: sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==} - dev: false - - /watchpack/2.1.1: - resolution: {integrity: sha512-Oo7LXCmc1eE1AjyuSBmtC3+Wy4HcV8PxWh2kP6fOl8yTlNS7r0K9l1ao2lrrUza7V39Y3D/BbJgY8VeSlc5JKw==} - engines: {node: '>=10.13.0'} - dependencies: - glob-to-regexp: 0.4.1 - graceful-fs: 4.2.6 - dev: false - - /webidl-conversions/4.0.2: - resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} - dev: false - - /whatwg-url/7.1.0: - resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==} - dependencies: - lodash.sortby: 4.7.0 - tr46: 1.0.1 - webidl-conversions: 4.0.2 - dev: false - - /which-boxed-primitive/1.0.2: - resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} - dependencies: - is-bigint: 1.0.2 - is-boolean-object: 1.1.0 - is-number-object: 1.0.4 - is-string: 1.0.5 - is-symbol: 1.0.3 - dev: false - - /which-typed-array/1.1.4: - resolution: {integrity: sha512-49E0SpUe90cjpoc7BOJwyPHRqSAd12c10Qm2amdEZrJPCY2NDxaW01zHITrem+rnETY3dwrbH3UUrUwagfCYDA==} - engines: {node: '>= 0.4'} - dependencies: - available-typed-arrays: 1.0.2 - call-bind: 1.0.2 - es-abstract: 1.18.0 - foreach: 2.0.5 - function-bind: 1.1.1 - has-symbols: 1.0.2 - is-typed-array: 1.1.5 - dev: false - - /wrappy/1.0.2: - resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=} - dev: false - - /xtend/4.0.2: - resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} - engines: {node: '>=0.4'} - dev: false - - /yocto-queue/0.1.0: - resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} - engines: {node: '>=10'} - dev: false diff --git a/src/api/demo/public/favicon.ico b/src/api/demo/public/favicon.ico deleted file mode 100644 index 4965832f2..000000000 Binary files a/src/api/demo/public/favicon.ico and /dev/null differ diff --git a/src/api/demo/public/vercel.svg b/src/api/demo/public/vercel.svg deleted file mode 100644 index fbf0e25a6..000000000 --- a/src/api/demo/public/vercel.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/src/api/demo/schema.d.ts b/src/api/demo/schema.d.ts deleted file mode 100644 index e8a6994e7..000000000 --- a/src/api/demo/schema.d.ts +++ /dev/null @@ -1,800 +0,0 @@ -import type { ByteBuffer } from "peechy"; - -type byte = number; -type float = number; -type int = number; -type alphanumeric = string; -type uint = number; -type int8 = number; -type lowp = number; -type int16 = number; -type int32 = number; -type float32 = number; -type uint16 = number; -type uint32 = number; -export enum Loader { - jsx = 1, - js = 2, - ts = 3, - tsx = 4, - css = 5, - file = 6, - json = 7, - toml = 8, - wasm = 9, -} -export const LoaderKeys = { - 1: "jsx", - jsx: "jsx", - 2: "js", - js: "js", - 3: "ts", - ts: "ts", - 4: "tsx", - tsx: "tsx", - 5: "css", - css: "css", - 6: "file", - file: "file", - 7: "json", - json: "json", - 8: "toml", - toml: "toml", - 9: "wasm", - wasm: "wasm", -}; -export enum FrameworkEntryPointType { - client = 1, - server = 2, - fallback = 3, -} -export const FrameworkEntryPointTypeKeys = { - 1: "client", - client: "client", - 2: "server", - server: "server", - 3: "fallback", - fallback: "fallback", -}; -export enum StackFrameScope { - Eval = 1, - Module = 2, - Function = 3, - Global = 4, - Wasm = 5, - Constructor = 6, -} -export const StackFrameScopeKeys = { - 1: "Eval", - Eval: "Eval", - 2: "Module", - Module: "Module", - 3: "Function", - Function: "Function", - 4: "Global", - Global: "Global", - 5: "Wasm", - Wasm: "Wasm", - 6: "Constructor", - Constructor: "Constructor", -}; -export enum FallbackStep { - ssr_disabled = 1, - create_vm = 2, - configure_router = 3, - configure_defines = 4, - resolve_entry_point = 5, - load_entry_point = 6, - eval_entry_point = 7, - fetch_event_handler = 8, -} -export const FallbackStepKeys = { - 1: "ssr_disabled", - ssr_disabled: "ssr_disabled", - 2: "create_vm", - create_vm: "create_vm", - 3: "configure_router", - configure_router: "configure_router", - 4: "configure_defines", - configure_defines: "configure_defines", - 5: "resolve_entry_point", - resolve_entry_point: "resolve_entry_point", - 6: "load_entry_point", - load_entry_point: "load_entry_point", - 7: "eval_entry_point", - eval_entry_point: "eval_entry_point", - 8: "fetch_event_handler", - fetch_event_handler: "fetch_event_handler", -}; -export enum ResolveMode { - disable = 1, - lazy = 2, - dev = 3, - bundle = 4, -} -export const ResolveModeKeys = { - 1: "disable", - disable: "disable", - 2: "lazy", - lazy: "lazy", - 3: "dev", - dev: "dev", - 4: "bundle", - bundle: "bundle", -}; -export enum Platform { - browser = 1, - node = 2, - bun = 3, - bun_macro = 4, -} -export const PlatformKeys = { - 1: "browser", - browser: "browser", - 2: "node", - node: "node", - 3: "bun", - bun: "bun", - 4: "bun_macro", - bun_macro: "bun_macro", -}; -export enum CSSInJSBehavior { - facade = 1, - facade_onimportcss = 2, - auto_onimportcss = 3, -} -export const CSSInJSBehaviorKeys = { - 1: "facade", - facade: "facade", - 2: "facade_onimportcss", - facade_onimportcss: "facade_onimportcss", - 3: "auto_onimportcss", - auto_onimportcss: "auto_onimportcss", -}; -export enum JSXRuntime { - automatic = 1, - classic = 2, -} -export const JSXRuntimeKeys = { - 1: "automatic", - automatic: "automatic", - 2: "classic", - classic: "classic", -}; -export enum ScanDependencyMode { - app = 1, - all = 2, -} -export const ScanDependencyModeKeys = { - 1: "app", - app: "app", - 2: "all", - all: "all", -}; -export enum ModuleImportType { - import = 1, - require = 2, -} -export const ModuleImportTypeKeys = { - 1: "import", - import: "import", - 2: "require", - require: "require", -}; -export enum DotEnvBehavior { - disable = 1, - prefix = 2, - load_all = 3, -} -export const DotEnvBehaviorKeys = { - 1: "disable", - disable: "disable", - 2: "prefix", - prefix: "prefix", - 3: "load_all", - load_all: "load_all", -}; -export enum ImportKind { - entry_point = 1, - stmt = 2, - require = 3, - dynamic = 4, - require_resolve = 5, - at = 6, - url = 7, - internal = 8, -} -export const ImportKindKeys = { - 1: "entry_point", - entry_point: "entry_point", - 2: "stmt", - stmt: "stmt", - 3: "require", - require: "require", - 4: "dynamic", - dynamic: "dynamic", - 5: "require_resolve", - require_resolve: "require_resolve", - 6: "at", - at: "at", - 7: "url", - url: "url", - 8: "internal", - internal: "internal", -}; -export enum TransformResponseStatus { - success = 1, - fail = 2, -} -export const TransformResponseStatusKeys = { - 1: "success", - success: "success", - 2: "fail", - fail: "fail", -}; -export enum MessageLevel { - err = 1, - warn = 2, - note = 3, - info = 4, - debug = 5, -} -export const MessageLevelKeys = { - 1: "err", - err: "err", - 2: "warn", - warn: "warn", - 3: "note", - note: "note", - 4: "info", - info: "info", - 5: "debug", - debug: "debug", -}; -export enum Reloader { - disable = 1, - live = 2, - fast_refresh = 3, -} -export const ReloaderKeys = { - 1: "disable", - disable: "disable", - 2: "live", - live: "live", - 3: "fast_refresh", - fast_refresh: "fast_refresh", -}; -export enum WebsocketMessageKind { - welcome = 1, - file_change_notification = 2, - build_success = 3, - build_fail = 4, - manifest_success = 5, - manifest_fail = 6, - resolve_file = 7, - file_change_notification_with_hint = 8, -} -export const WebsocketMessageKindKeys = { - 1: "welcome", - welcome: "welcome", - 2: "file_change_notification", - file_change_notification: "file_change_notification", - 3: "build_success", - build_success: "build_success", - 4: "build_fail", - build_fail: "build_fail", - 5: "manifest_success", - manifest_success: "manifest_success", - 6: "manifest_fail", - manifest_fail: "manifest_fail", - 7: "resolve_file", - resolve_file: "resolve_file", - 8: "file_change_notification_with_hint", - file_change_notification_with_hint: "file_change_notification_with_hint", -}; -export enum WebsocketCommandKind { - build = 1, - manifest = 2, - build_with_file_path = 3, -} -export const WebsocketCommandKindKeys = { - 1: "build", - build: "build", - 2: "manifest", - manifest: "manifest", - 3: "build_with_file_path", - build_with_file_path: "build_with_file_path", -}; -export interface StackFrame { - function_name: string; - file: string; - position: StackFramePosition; - scope: StackFrameScope; -} - -export interface StackFramePosition { - source_offset: int32; - line: int32; - line_start: int32; - line_stop: int32; - column_start: int32; - column_stop: int32; - expression_start: int32; - expression_stop: int32; -} - -export interface SourceLine { - line: int32; - text: string; -} - -export interface StackTrace { - source_lines: SourceLine[]; - frames: StackFrame[]; -} - -export interface JSException { - name?: string; - message?: string; - runtime_type?: uint16; - code?: uint8; - stack?: StackTrace; -} - -export interface Problems { - code: uint16; - name: string; - exceptions: JSException[]; - build: Log; -} - -export interface Router { - routes: StringMap; - route: int32; - params: StringMap; -} - -export interface FallbackMessageContainer { - message?: string; - router?: Router; - reason?: FallbackStep; - problems?: Problems; - cwd?: string; -} - -export interface JSX { - factory: string; - runtime: JSXRuntime; - fragment: string; - development: boolean; - import_source: string; - react_fast_refresh: boolean; -} - -export interface StringPointer { - offset: uint32; - length: uint32; -} - -export interface JavascriptBundledModule { - path: StringPointer; - code: StringPointer; - package_id: uint32; - id: uint32; - path_extname_length: byte; -} - -export interface JavascriptBundledPackage { - name: StringPointer; - version: StringPointer; - hash: uint32; - modules_offset: uint32; - modules_length: uint32; -} - -export interface JavascriptBundle { - modules: JavascriptBundledModule[]; - packages: JavascriptBundledPackage[]; - etag: Uint8Array; - generated_at: uint32; - app_package_json_dependencies_hash: Uint8Array; - import_from_name: Uint8Array; - manifest_string: Uint8Array; -} - -export interface JavascriptBundleContainer { - bundle_format_version?: uint32; - routes?: LoadedRouteConfig; - framework?: LoadedFramework; - bundle?: JavascriptBundle; - code_length?: uint32; -} - -export interface ModuleImportRecord { - kind: ModuleImportType; - path: string; - dynamic: boolean; -} - -export interface Module { - path: string; - imports: ModuleImportRecord[]; -} - -export interface StringMap { - keys: string[]; - values: string[]; -} - -export interface LoaderMap { - extensions: string[]; - loaders: Loader[]; -} - -export interface EnvConfig { - prefix?: string; - defaults?: StringMap; -} - -export interface LoadedEnvConfig { - dotenv: DotEnvBehavior; - defaults: StringMap; - prefix: string; -} - -export interface FrameworkConfig { - package?: string; - client?: FrameworkEntryPointMessage; - server?: FrameworkEntryPointMessage; - fallback?: FrameworkEntryPointMessage; - development?: boolean; - client_css_in_js?: CSSInJSBehavior; - display_name?: string; - overrideModules?: StringMap; -} - -export interface FrameworkEntryPoint { - kind: FrameworkEntryPointType; - path: string; - env: LoadedEnvConfig; -} - -export interface FrameworkEntryPointMap { - client?: FrameworkEntryPoint; - server?: FrameworkEntryPoint; - fallback?: FrameworkEntryPoint; -} - -export interface FrameworkEntryPointMessage { - path?: string; - env?: EnvConfig; -} - -export interface LoadedFramework { - package: string; - display_name: string; - development: boolean; - entry_points: FrameworkEntryPointMap; - client_css_in_js: CSSInJSBehavior; - overrideModules: StringMap; -} - -export interface LoadedRouteConfig { - dir: string; - extensions: string[]; - static_dir: string; - asset_prefix: string; -} - -export interface RouteConfig { - dir?: string[]; - extensions?: string[]; - static_dir?: string; - asset_prefix?: string; -} - -export interface TransformOptions { - jsx?: JSX; - tsconfig_override?: string; - resolve?: ResolveMode; - origin?: string; - absolute_working_dir?: string; - define?: StringMap; - preserve_symlinks?: boolean; - entry_points?: string[]; - write?: boolean; - inject?: string[]; - output_dir?: string; - external?: string[]; - loaders?: LoaderMap; - main_fields?: string[]; - platform?: Platform; - serve?: boolean; - extension_order?: string[]; - generate_node_module_bundle?: boolean; - node_modules_bundle_path?: string; - node_modules_bundle_path_server?: string; - framework?: FrameworkConfig; - router?: RouteConfig; - no_summary?: boolean; - disable_hmr?: boolean; - port?: uint16; - logLevel?: MessageLevel; -} - -export interface FileHandle { - path: string; - size: uint; - fd: uint; -} - -export interface Transform { - handle?: FileHandle; - path?: string; - contents?: Uint8Array; - loader?: Loader; - options?: TransformOptions; -} - -export interface Scan { - path?: string; - contents?: Uint8Array; - loader?: Loader; -} - -export interface ScanResult { - exports: string[]; - imports: ScannedImport[]; -} - -export interface ScannedImport { - path: string; - kind: ImportKind; -} - -export interface OutputFile { - data: Uint8Array; - path: string; -} - -export interface TransformResponse { - status: TransformResponseStatus; - files: OutputFile[]; - errors: Message[]; -} - -export interface Location { - file: string; - namespace: string; - line: int32; - column: int32; - line_text: string; - suggestion: string; - offset: uint; -} - -export interface MessageData { - text?: string; - location?: Location; -} - -export interface MessageMeta { - resolve?: string; - build?: boolean; -} - -export interface Message { - level: MessageLevel; - data: MessageData; - notes: MessageData[]; - on: MessageMeta; -} - -export interface Log { - warnings: uint32; - errors: uint32; - msgs: Message[]; -} - -export interface WebsocketMessage { - timestamp: uint32; - kind: WebsocketMessageKind; -} - -export interface WebsocketMessageWelcome { - epoch: uint32; - javascriptReloader: Reloader; - cwd: string; -} - -export interface WebsocketMessageFileChangeNotification { - id: uint32; - loader: Loader; -} - -export interface WebsocketCommand { - kind: WebsocketCommandKind; - timestamp: uint32; -} - -export interface WebsocketCommandBuild { - id: uint32; -} - -export interface WebsocketCommandManifest { - id: uint32; -} - -export interface WebsocketMessageBuildSuccess { - id: uint32; - from_timestamp: uint32; - loader: Loader; - module_path: string; - blob_length: uint32; -} - -export interface WebsocketMessageBuildFailure { - id: uint32; - from_timestamp: uint32; - loader: Loader; - module_path: string; - log: Log; -} - -export interface WebsocketCommandBuildWithFilePath { - id: uint32; - file_path: string; -} - -export interface WebsocketMessageResolveID { - id: uint32; -} - -export interface NPMRegistry { - url: string; - username: string; - password: string; - token: string; -} - -export interface NPMRegistryMap { - scopes: string[]; - registries: NPMRegistry[]; -} - -export interface BunInstall { - default_registry?: NPMRegistry; - scoped?: NPMRegistryMap; - lockfile_path?: string; - save_lockfile_path?: string; - cache_directory?: string; - dry_run?: boolean; - force?: boolean; - save_dev?: boolean; - save_optional?: boolean; - save_peer?: boolean; - save_lockfile?: boolean; - production?: boolean; - save_yarn_lockfile?: boolean; - native_bin_links?: string[]; - disable_cache?: boolean; - disable_manifest_cache?: boolean; - global_dir?: string; - global_bin_dir?: string; - frozen_lockfile?: boolean; -} - -export declare function encodeStackFrame(message: StackFrame, bb: ByteBuffer): void; -export declare function decodeStackFrame(buffer: ByteBuffer): StackFrame; -export declare function encodeStackFramePosition(message: StackFramePosition, bb: ByteBuffer): void; -export declare function decodeStackFramePosition(buffer: ByteBuffer): StackFramePosition; -export declare function encodeSourceLine(message: SourceLine, bb: ByteBuffer): void; -export declare function decodeSourceLine(buffer: ByteBuffer): SourceLine; -export declare function encodeStackTrace(message: StackTrace, bb: ByteBuffer): void; -export declare function decodeStackTrace(buffer: ByteBuffer): StackTrace; -export declare function encodeJSException(message: JSException, bb: ByteBuffer): void; -export declare function decodeJSException(buffer: ByteBuffer): JSException; -export declare function encodeProblems(message: Problems, bb: ByteBuffer): void; -export declare function decodeProblems(buffer: ByteBuffer): Problems; -export declare function encodeRouter(message: Router, bb: ByteBuffer): void; -export declare function decodeRouter(buffer: ByteBuffer): Router; -export declare function encodeFallbackMessageContainer(message: FallbackMessageContainer, bb: ByteBuffer): void; -export declare function decodeFallbackMessageContainer(buffer: ByteBuffer): FallbackMessageContainer; -export declare function encodeJSX(message: JSX, bb: ByteBuffer): void; -export declare function decodeJSX(buffer: ByteBuffer): JSX; -export declare function encodeStringPointer(message: StringPointer, bb: ByteBuffer): void; -export declare function decodeStringPointer(buffer: ByteBuffer): StringPointer; -export declare function encodeJavascriptBundledModule(message: JavascriptBundledModule, bb: ByteBuffer): void; -export declare function decodeJavascriptBundledModule(buffer: ByteBuffer): JavascriptBundledModule; -export declare function encodeJavascriptBundledPackage(message: JavascriptBundledPackage, bb: ByteBuffer): void; -export declare function decodeJavascriptBundledPackage(buffer: ByteBuffer): JavascriptBundledPackage; -export declare function encodeJavascriptBundle(message: JavascriptBundle, bb: ByteBuffer): void; -export declare function decodeJavascriptBundle(buffer: ByteBuffer): JavascriptBundle; -export declare function encodeJavascriptBundleContainer(message: JavascriptBundleContainer, bb: ByteBuffer): void; -export declare function decodeJavascriptBundleContainer(buffer: ByteBuffer): JavascriptBundleContainer; -export declare function encodeModuleImportRecord(message: ModuleImportRecord, bb: ByteBuffer): void; -export declare function decodeModuleImportRecord(buffer: ByteBuffer): ModuleImportRecord; -export declare function encodeModule(message: Module, bb: ByteBuffer): void; -export declare function decodeModule(buffer: ByteBuffer): Module; -export declare function encodeStringMap(message: StringMap, bb: ByteBuffer): void; -export declare function decodeStringMap(buffer: ByteBuffer): StringMap; -export declare function encodeLoaderMap(message: LoaderMap, bb: ByteBuffer): void; -export declare function decodeLoaderMap(buffer: ByteBuffer): LoaderMap; -export declare function encodeEnvConfig(message: EnvConfig, bb: ByteBuffer): void; -export declare function decodeEnvConfig(buffer: ByteBuffer): EnvConfig; -export declare function encodeLoadedEnvConfig(message: LoadedEnvConfig, bb: ByteBuffer): void; -export declare function decodeLoadedEnvConfig(buffer: ByteBuffer): LoadedEnvConfig; -export declare function encodeFrameworkConfig(message: FrameworkConfig, bb: ByteBuffer): void; -export declare function decodeFrameworkConfig(buffer: ByteBuffer): FrameworkConfig; -export declare function encodeFrameworkEntryPoint(message: FrameworkEntryPoint, bb: ByteBuffer): void; -export declare function decodeFrameworkEntryPoint(buffer: ByteBuffer): FrameworkEntryPoint; -export declare function encodeFrameworkEntryPointMap(message: FrameworkEntryPointMap, bb: ByteBuffer): void; -export declare function decodeFrameworkEntryPointMap(buffer: ByteBuffer): FrameworkEntryPointMap; -export declare function encodeFrameworkEntryPointMessage(message: FrameworkEntryPointMessage, bb: ByteBuffer): void; -export declare function decodeFrameworkEntryPointMessage(buffer: ByteBuffer): FrameworkEntryPointMessage; -export declare function encodeLoadedFramework(message: LoadedFramework, bb: ByteBuffer): void; -export declare function decodeLoadedFramework(buffer: ByteBuffer): LoadedFramework; -export declare function encodeLoadedRouteConfig(message: LoadedRouteConfig, bb: ByteBuffer): void; -export declare function decodeLoadedRouteConfig(buffer: ByteBuffer): LoadedRouteConfig; -export declare function encodeRouteConfig(message: RouteConfig, bb: ByteBuffer): void; -export declare function decodeRouteConfig(buffer: ByteBuffer): RouteConfig; -export declare function encodeTransformOptions(message: TransformOptions, bb: ByteBuffer): void; -export declare function decodeTransformOptions(buffer: ByteBuffer): TransformOptions; -export declare function encodeFileHandle(message: FileHandle, bb: ByteBuffer): void; -export declare function decodeFileHandle(buffer: ByteBuffer): FileHandle; -export declare function encodeTransform(message: Transform, bb: ByteBuffer): void; -export declare function decodeTransform(buffer: ByteBuffer): Transform; -export declare function encodeScan(message: Scan, bb: ByteBuffer): void; -export declare function decodeScan(buffer: ByteBuffer): Scan; -export declare function encodeScanResult(message: ScanResult, bb: ByteBuffer): void; -export declare function decodeScanResult(buffer: ByteBuffer): ScanResult; -export declare function encodeScannedImport(message: ScannedImport, bb: ByteBuffer): void; -export declare function decodeScannedImport(buffer: ByteBuffer): ScannedImport; -export declare function encodeOutputFile(message: OutputFile, bb: ByteBuffer): void; -export declare function decodeOutputFile(buffer: ByteBuffer): OutputFile; -export declare function encodeTransformResponse(message: TransformResponse, bb: ByteBuffer): void; -export declare function decodeTransformResponse(buffer: ByteBuffer): TransformResponse; -export declare function encodeLocation(message: Location, bb: ByteBuffer): void; -export declare function decodeLocation(buffer: ByteBuffer): Location; -export declare function encodeMessageData(message: MessageData, bb: ByteBuffer): void; -export declare function decodeMessageData(buffer: ByteBuffer): MessageData; -export declare function encodeMessageMeta(message: MessageMeta, bb: ByteBuffer): void; -export declare function decodeMessageMeta(buffer: ByteBuffer): MessageMeta; -export declare function encodeMessage(message: Message, bb: ByteBuffer): void; -export declare function decodeMessage(buffer: ByteBuffer): Message; -export declare function encodeLog(message: Log, bb: ByteBuffer): void; -export declare function decodeLog(buffer: ByteBuffer): Log; -export declare function encodeWebsocketMessage(message: WebsocketMessage, bb: ByteBuffer): void; -export declare function decodeWebsocketMessage(buffer: ByteBuffer): WebsocketMessage; -export declare function encodeWebsocketMessageWelcome(message: WebsocketMessageWelcome, bb: ByteBuffer): void; -export declare function decodeWebsocketMessageWelcome(buffer: ByteBuffer): WebsocketMessageWelcome; -export declare function encodeWebsocketMessageFileChangeNotification( - message: WebsocketMessageFileChangeNotification, - bb: ByteBuffer, -): void; -export declare function decodeWebsocketMessageFileChangeNotification( - buffer: ByteBuffer, -): WebsocketMessageFileChangeNotification; -export declare function encodeWebsocketCommand(message: WebsocketCommand, bb: ByteBuffer): void; -export declare function decodeWebsocketCommand(buffer: ByteBuffer): WebsocketCommand; -export declare function encodeWebsocketCommandBuild(message: WebsocketCommandBuild, bb: ByteBuffer): void; -export declare function decodeWebsocketCommandBuild(buffer: ByteBuffer): WebsocketCommandBuild; -export declare function encodeWebsocketCommandManifest(message: WebsocketCommandManifest, bb: ByteBuffer): void; -export declare function decodeWebsocketCommandManifest(buffer: ByteBuffer): WebsocketCommandManifest; -export declare function encodeWebsocketMessageBuildSuccess(message: WebsocketMessageBuildSuccess, bb: ByteBuffer): void; -export declare function decodeWebsocketMessageBuildSuccess(buffer: ByteBuffer): WebsocketMessageBuildSuccess; -export declare function encodeWebsocketMessageBuildFailure(message: WebsocketMessageBuildFailure, bb: ByteBuffer): void; -export declare function decodeWebsocketMessageBuildFailure(buffer: ByteBuffer): WebsocketMessageBuildFailure; -export declare function encodeWebsocketCommandBuildWithFilePath( - message: WebsocketCommandBuildWithFilePath, - bb: ByteBuffer, -): void; -export declare function decodeWebsocketCommandBuildWithFilePath(buffer: ByteBuffer): WebsocketCommandBuildWithFilePath; -export declare function encodeWebsocketMessageResolveID(message: WebsocketMessageResolveID, bb: ByteBuffer): void; -export declare function decodeWebsocketMessageResolveID(buffer: ByteBuffer): WebsocketMessageResolveID; -export declare function encodeNPMRegistry(message: NPMRegistry, bb: ByteBuffer): void; -export declare function decodeNPMRegistry(buffer: ByteBuffer): NPMRegistry; -export declare function encodeNPMRegistryMap(message: NPMRegistryMap, bb: ByteBuffer): void; -export declare function decodeNPMRegistryMap(buffer: ByteBuffer): NPMRegistryMap; -export declare function encodeBunInstall(message: BunInstall, bb: ByteBuffer): void; -export declare function decodeBunInstall(buffer: ByteBuffer): BunInstall; diff --git a/src/api/demo/schema.js b/src/api/demo/schema.js deleted file mode 100644 index d23d64a14..000000000 --- a/src/api/demo/schema.js +++ /dev/null @@ -1,3261 +0,0 @@ -const Loader = { - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - 7: 7, - 8: 8, - 9: 9, - jsx: 1, - js: 2, - ts: 3, - tsx: 4, - css: 5, - file: 6, - json: 7, - toml: 8, - wasm: 9, -}; -const LoaderKeys = { - 1: "jsx", - 2: "js", - 3: "ts", - 4: "tsx", - 5: "css", - 6: "file", - 7: "json", - 8: "toml", - 9: "wasm", - jsx: "jsx", - js: "js", - ts: "ts", - tsx: "tsx", - css: "css", - file: "file", - json: "json", - toml: "toml", - wasm: "wasm", -}; -const FrameworkEntryPointType = { - 1: 1, - 2: 2, - 3: 3, - client: 1, - server: 2, - fallback: 3, -}; -const FrameworkEntryPointTypeKeys = { - 1: "client", - 2: "server", - 3: "fallback", - client: "client", - server: "server", - fallback: "fallback", -}; -const StackFrameScope = { - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - Eval: 1, - Module: 2, - Function: 3, - Global: 4, - Wasm: 5, - Constructor: 6, -}; -const StackFrameScopeKeys = { - 1: "Eval", - 2: "Module", - 3: "Function", - 4: "Global", - 5: "Wasm", - 6: "Constructor", - Eval: "Eval", - Module: "Module", - Function: "Function", - Global: "Global", - Wasm: "Wasm", - Constructor: "Constructor", -}; - -function decodeStackFrame(bb) { - var result = {}; - - result["function_name"] = bb.readString(); - result["file"] = bb.readString(); - result["position"] = decodeStackFramePosition(bb); - result["scope"] = StackFrameScope[bb.readByte()]; - return result; -} - -function encodeStackFrame(message, bb) { - var value = message["function_name"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "function_name"'); - } - - var value = message["file"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "file"'); - } - - var value = message["position"]; - if (value != null) { - encodeStackFramePosition(value, bb); - } else { - throw new Error('Missing required field "position"'); - } - - var value = message["scope"]; - if (value != null) { - var encoded = StackFrameScope[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "StackFrameScope"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "scope"'); - } -} - -function decodeStackFramePosition(bb) { - var result = {}; - - result["source_offset"] = bb.readInt32(); - result["line"] = bb.readInt32(); - result["line_start"] = bb.readInt32(); - result["line_stop"] = bb.readInt32(); - result["column_start"] = bb.readInt32(); - result["column_stop"] = bb.readInt32(); - result["expression_start"] = bb.readInt32(); - result["expression_stop"] = bb.readInt32(); - return result; -} - -function encodeStackFramePosition(message, bb) { - var value = message["source_offset"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "source_offset"'); - } - - var value = message["line"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "line"'); - } - - var value = message["line_start"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "line_start"'); - } - - var value = message["line_stop"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "line_stop"'); - } - - var value = message["column_start"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "column_start"'); - } - - var value = message["column_stop"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "column_stop"'); - } - - var value = message["expression_start"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "expression_start"'); - } - - var value = message["expression_stop"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "expression_stop"'); - } -} - -function decodeSourceLine(bb) { - var result = {}; - - result["line"] = bb.readInt32(); - result["text"] = bb.readString(); - return result; -} - -function encodeSourceLine(message, bb) { - var value = message["line"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "line"'); - } - - var value = message["text"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "text"'); - } -} - -function decodeStackTrace(bb) { - var result = {}; - - var length = bb.readVarUint(); - var values = (result["source_lines"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeSourceLine(bb); - var length = bb.readVarUint(); - var values = (result["frames"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeStackFrame(bb); - return result; -} - -function encodeStackTrace(message, bb) { - var value = message["source_lines"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeSourceLine(value, bb); - } - } else { - throw new Error('Missing required field "source_lines"'); - } - - var value = message["frames"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeStackFrame(value, bb); - } - } else { - throw new Error('Missing required field "frames"'); - } -} - -function decodeJSException(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["name"] = bb.readString(); - break; - - case 2: - result["message"] = bb.readString(); - break; - - case 3: - result["runtime_type"] = bb.readUint16(); - break; - - case 4: - result["code"] = bb.readByte(); - break; - - case 5: - result["stack"] = decodeStackTrace(bb); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeJSException(message, bb) { - var value = message["name"]; - if (value != null) { - bb.writeByte(1); - bb.writeString(value); - } - - var value = message["message"]; - if (value != null) { - bb.writeByte(2); - bb.writeString(value); - } - - var value = message["runtime_type"]; - if (value != null) { - bb.writeByte(3); - bb.writeUint16(value); - } - - var value = message["code"]; - if (value != null) { - bb.writeByte(4); - bb.writeByte(value); - } - - var value = message["stack"]; - if (value != null) { - bb.writeByte(5); - encodeStackTrace(value, bb); - } - bb.writeByte(0); -} -const FallbackStep = { - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - 7: 7, - 8: 8, - ssr_disabled: 1, - create_vm: 2, - configure_router: 3, - configure_defines: 4, - resolve_entry_point: 5, - load_entry_point: 6, - eval_entry_point: 7, - fetch_event_handler: 8, -}; -const FallbackStepKeys = { - 1: "ssr_disabled", - 2: "create_vm", - 3: "configure_router", - 4: "configure_defines", - 5: "resolve_entry_point", - 6: "load_entry_point", - 7: "eval_entry_point", - 8: "fetch_event_handler", - ssr_disabled: "ssr_disabled", - create_vm: "create_vm", - configure_router: "configure_router", - configure_defines: "configure_defines", - resolve_entry_point: "resolve_entry_point", - load_entry_point: "load_entry_point", - eval_entry_point: "eval_entry_point", - fetch_event_handler: "fetch_event_handler", -}; - -function decodeProblems(bb) { - var result = {}; - - result["code"] = bb.readUint16(); - result["name"] = bb.readString(); - var length = bb.readVarUint(); - var values = (result["exceptions"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeJSException(bb); - result["build"] = decodeLog(bb); - return result; -} - -function encodeProblems(message, bb) { - var value = message["code"]; - if (value != null) { - bb.writeUint16(value); - } else { - throw new Error('Missing required field "code"'); - } - - var value = message["name"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "name"'); - } - - var value = message["exceptions"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeJSException(value, bb); - } - } else { - throw new Error('Missing required field "exceptions"'); - } - - var value = message["build"]; - if (value != null) { - encodeLog(value, bb); - } else { - throw new Error('Missing required field "build"'); - } -} - -function decodeRouter(bb) { - var result = {}; - - result["routes"] = decodeStringMap(bb); - result["route"] = bb.readInt32(); - result["params"] = decodeStringMap(bb); - return result; -} - -function encodeRouter(message, bb) { - var value = message["routes"]; - if (value != null) { - encodeStringMap(value, bb); - } else { - throw new Error('Missing required field "routes"'); - } - - var value = message["route"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "route"'); - } - - var value = message["params"]; - if (value != null) { - encodeStringMap(value, bb); - } else { - throw new Error('Missing required field "params"'); - } -} - -function decodeFallbackMessageContainer(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["message"] = bb.readString(); - break; - - case 2: - result["router"] = decodeRouter(bb); - break; - - case 3: - result["reason"] = FallbackStep[bb.readByte()]; - break; - - case 4: - result["problems"] = decodeProblems(bb); - break; - - case 5: - result["cwd"] = bb.readString(); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeFallbackMessageContainer(message, bb) { - var value = message["message"]; - if (value != null) { - bb.writeByte(1); - bb.writeString(value); - } - - var value = message["router"]; - if (value != null) { - bb.writeByte(2); - encodeRouter(value, bb); - } - - var value = message["reason"]; - if (value != null) { - bb.writeByte(3); - var encoded = FallbackStep[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "FallbackStep"'); - bb.writeByte(encoded); - } - - var value = message["problems"]; - if (value != null) { - bb.writeByte(4); - encodeProblems(value, bb); - } - - var value = message["cwd"]; - if (value != null) { - bb.writeByte(5); - bb.writeString(value); - } - bb.writeByte(0); -} -const ResolveMode = { - 1: 1, - 2: 2, - 3: 3, - 4: 4, - disable: 1, - lazy: 2, - dev: 3, - bundle: 4, -}; -const ResolveModeKeys = { - 1: "disable", - 2: "lazy", - 3: "dev", - 4: "bundle", - disable: "disable", - lazy: "lazy", - dev: "dev", - bundle: "bundle", -}; -const Platform = { - 1: 1, - 2: 2, - 3: 3, - 4: 4, - browser: 1, - node: 2, - bun: 3, - bun_macro: 4, -}; -const PlatformKeys = { - 1: "browser", - 2: "node", - 3: "bun", - 4: "bun_macro", - browser: "browser", - node: "node", - bun: "bun", - bun_macro: "bun_macro", -}; -const CSSInJSBehavior = { - 1: 1, - 2: 2, - 3: 3, - facade: 1, - facade_onimportcss: 2, - auto_onimportcss: 3, -}; -const CSSInJSBehaviorKeys = { - 1: "facade", - 2: "facade_onimportcss", - 3: "auto_onimportcss", - facade: "facade", - facade_onimportcss: "facade_onimportcss", - auto_onimportcss: "auto_onimportcss", -}; -const JSXRuntime = { - 1: 1, - 2: 2, - automatic: 1, - classic: 2, -}; -const JSXRuntimeKeys = { - 1: "automatic", - 2: "classic", - automatic: "automatic", - classic: "classic", -}; - -function decodeJSX(bb) { - var result = {}; - - result["factory"] = bb.readString(); - result["runtime"] = JSXRuntime[bb.readByte()]; - result["fragment"] = bb.readString(); - result["development"] = !!bb.readByte(); - result["import_source"] = bb.readString(); - result["react_fast_refresh"] = !!bb.readByte(); - return result; -} - -function encodeJSX(message, bb) { - var value = message["factory"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "factory"'); - } - - var value = message["runtime"]; - if (value != null) { - var encoded = JSXRuntime[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "JSXRuntime"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "runtime"'); - } - - var value = message["fragment"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "fragment"'); - } - - var value = message["development"]; - if (value != null) { - bb.writeByte(value); - } else { - throw new Error('Missing required field "development"'); - } - - var value = message["import_source"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "import_source"'); - } - - var value = message["react_fast_refresh"]; - if (value != null) { - bb.writeByte(value); - } else { - throw new Error('Missing required field "react_fast_refresh"'); - } -} - -function decodeStringPointer(bb) { - var result = {}; - - result["offset"] = bb.readUint32(); - result["length"] = bb.readUint32(); - return result; -} - -function encodeStringPointer(message, bb) { - var value = message["offset"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "offset"'); - } - - var value = message["length"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "length"'); - } -} - -function decodeJavascriptBundledModule(bb) { - var result = {}; - - result["path"] = decodeStringPointer(bb); - result["code"] = decodeStringPointer(bb); - result["package_id"] = bb.readUint32(); - result["id"] = bb.readUint32(); - result["path_extname_length"] = bb.readByte(); - return result; -} - -function encodeJavascriptBundledModule(message, bb) { - var value = message["path"]; - if (value != null) { - encodeStringPointer(value, bb); - } else { - throw new Error('Missing required field "path"'); - } - - var value = message["code"]; - if (value != null) { - encodeStringPointer(value, bb); - } else { - throw new Error('Missing required field "code"'); - } - - var value = message["package_id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "package_id"'); - } - - var value = message["id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "id"'); - } - - var value = message["path_extname_length"]; - if (value != null) { - bb.writeByte(value); - } else { - throw new Error('Missing required field "path_extname_length"'); - } -} - -function decodeJavascriptBundledPackage(bb) { - var result = {}; - - result["name"] = decodeStringPointer(bb); - result["version"] = decodeStringPointer(bb); - result["hash"] = bb.readUint32(); - result["modules_offset"] = bb.readUint32(); - result["modules_length"] = bb.readUint32(); - return result; -} - -function encodeJavascriptBundledPackage(message, bb) { - var value = message["name"]; - if (value != null) { - encodeStringPointer(value, bb); - } else { - throw new Error('Missing required field "name"'); - } - - var value = message["version"]; - if (value != null) { - encodeStringPointer(value, bb); - } else { - throw new Error('Missing required field "version"'); - } - - var value = message["hash"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "hash"'); - } - - var value = message["modules_offset"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "modules_offset"'); - } - - var value = message["modules_length"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "modules_length"'); - } -} - -function decodeJavascriptBundle(bb) { - var result = {}; - - var length = bb.readVarUint(); - var values = (result["modules"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeJavascriptBundledModule(bb); - var length = bb.readVarUint(); - var values = (result["packages"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeJavascriptBundledPackage(bb); - result["etag"] = bb.readByteArray(); - result["generated_at"] = bb.readUint32(); - result["app_package_json_dependencies_hash"] = bb.readByteArray(); - result["import_from_name"] = bb.readByteArray(); - result["manifest_string"] = bb.readByteArray(); - return result; -} - -function encodeJavascriptBundle(message, bb) { - var value = message["modules"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeJavascriptBundledModule(value, bb); - } - } else { - throw new Error('Missing required field "modules"'); - } - - var value = message["packages"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeJavascriptBundledPackage(value, bb); - } - } else { - throw new Error('Missing required field "packages"'); - } - - var value = message["etag"]; - if (value != null) { - bb.writeByteArray(value); - } else { - throw new Error('Missing required field "etag"'); - } - - var value = message["generated_at"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "generated_at"'); - } - - var value = message["app_package_json_dependencies_hash"]; - if (value != null) { - bb.writeByteArray(value); - } else { - throw new Error('Missing required field "app_package_json_dependencies_hash"'); - } - - var value = message["import_from_name"]; - if (value != null) { - bb.writeByteArray(value); - } else { - throw new Error('Missing required field "import_from_name"'); - } - - var value = message["manifest_string"]; - if (value != null) { - bb.writeByteArray(value); - } else { - throw new Error('Missing required field "manifest_string"'); - } -} - -function decodeJavascriptBundleContainer(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["bundle_format_version"] = bb.readUint32(); - break; - - case 3: - result["routes"] = decodeLoadedRouteConfig(bb); - break; - - case 2: - result["framework"] = decodeLoadedFramework(bb); - break; - - case 4: - result["bundle"] = decodeJavascriptBundle(bb); - break; - - case 5: - result["code_length"] = bb.readUint32(); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeJavascriptBundleContainer(message, bb) { - var value = message["bundle_format_version"]; - if (value != null) { - bb.writeByte(1); - bb.writeUint32(value); - } - - var value = message["routes"]; - if (value != null) { - bb.writeByte(3); - encodeLoadedRouteConfig(value, bb); - } - - var value = message["framework"]; - if (value != null) { - bb.writeByte(2); - encodeLoadedFramework(value, bb); - } - - var value = message["bundle"]; - if (value != null) { - bb.writeByte(4); - encodeJavascriptBundle(value, bb); - } - - var value = message["code_length"]; - if (value != null) { - bb.writeByte(5); - bb.writeUint32(value); - } - bb.writeByte(0); -} -const ScanDependencyMode = { - 1: 1, - 2: 2, - app: 1, - all: 2, -}; -const ScanDependencyModeKeys = { - 1: "app", - 2: "all", - app: "app", - all: "all", -}; -const ModuleImportType = { - 1: 1, - 2: 2, - import: 1, - require: 2, -}; -const ModuleImportTypeKeys = { - 1: "import", - 2: "require", - import: "import", - require: "require", -}; - -function decodeModuleImportRecord(bb) { - var result = {}; - - result["kind"] = ModuleImportType[bb.readByte()]; - result["path"] = bb.readString(); - result["dynamic"] = !!bb.readByte(); - return result; -} - -function encodeModuleImportRecord(message, bb) { - var value = message["kind"]; - if (value != null) { - var encoded = ModuleImportType[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "ModuleImportType"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "kind"'); - } - - var value = message["path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "path"'); - } - - var value = message["dynamic"]; - if (value != null) { - bb.writeByte(value); - } else { - throw new Error('Missing required field "dynamic"'); - } -} - -function decodeModule(bb) { - var result = {}; - - result["path"] = bb.readString(); - var length = bb.readVarUint(); - var values = (result["imports"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeModuleImportRecord(bb); - return result; -} - -function encodeModule(message, bb) { - var value = message["path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "path"'); - } - - var value = message["imports"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeModuleImportRecord(value, bb); - } - } else { - throw new Error('Missing required field "imports"'); - } -} - -function decodeStringMap(bb) { - var result = {}; - - var length = bb.readVarUint(); - var values = (result["keys"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - var length = bb.readVarUint(); - var values = (result["values"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - return result; -} - -function encodeStringMap(message, bb) { - var value = message["keys"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } else { - throw new Error('Missing required field "keys"'); - } - - var value = message["values"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } else { - throw new Error('Missing required field "values"'); - } -} - -function decodeLoaderMap(bb) { - var result = {}; - - var length = bb.readVarUint(); - var values = (result["extensions"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - var length = bb.readVarUint(); - var values = (result["loaders"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = Loader[bb.readByte()]; - return result; -} - -function encodeLoaderMap(message, bb) { - var value = message["extensions"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } else { - throw new Error('Missing required field "extensions"'); - } - - var value = message["loaders"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - var encoded = Loader[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"'); - bb.writeByte(encoded); - } - } else { - throw new Error('Missing required field "loaders"'); - } -} -const DotEnvBehavior = { - 1: 1, - 2: 2, - 3: 3, - disable: 1, - prefix: 2, - load_all: 3, -}; -const DotEnvBehaviorKeys = { - 1: "disable", - 2: "prefix", - 3: "load_all", - disable: "disable", - prefix: "prefix", - load_all: "load_all", -}; - -function decodeEnvConfig(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["prefix"] = bb.readString(); - break; - - case 2: - result["defaults"] = decodeStringMap(bb); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeEnvConfig(message, bb) { - var value = message["prefix"]; - if (value != null) { - bb.writeByte(1); - bb.writeString(value); - } - - var value = message["defaults"]; - if (value != null) { - bb.writeByte(2); - encodeStringMap(value, bb); - } - bb.writeByte(0); -} - -function decodeLoadedEnvConfig(bb) { - var result = {}; - - result["dotenv"] = DotEnvBehavior[bb.readVarUint()]; - result["defaults"] = decodeStringMap(bb); - result["prefix"] = bb.readString(); - return result; -} - -function encodeLoadedEnvConfig(message, bb) { - var value = message["dotenv"]; - if (value != null) { - var encoded = DotEnvBehavior[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "DotEnvBehavior"'); - bb.writeVarUint(encoded); - } else { - throw new Error('Missing required field "dotenv"'); - } - - var value = message["defaults"]; - if (value != null) { - encodeStringMap(value, bb); - } else { - throw new Error('Missing required field "defaults"'); - } - - var value = message["prefix"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "prefix"'); - } -} - -function decodeFrameworkConfig(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["package"] = bb.readString(); - break; - - case 2: - result["client"] = decodeFrameworkEntryPointMessage(bb); - break; - - case 3: - result["server"] = decodeFrameworkEntryPointMessage(bb); - break; - - case 4: - result["fallback"] = decodeFrameworkEntryPointMessage(bb); - break; - - case 5: - result["development"] = !!bb.readByte(); - break; - - case 6: - result["client_css_in_js"] = CSSInJSBehavior[bb.readByte()]; - break; - - case 7: - result["display_name"] = bb.readString(); - break; - - case 8: - result["overrideModules"] = decodeStringMap(bb); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeFrameworkConfig(message, bb) { - var value = message["package"]; - if (value != null) { - bb.writeByte(1); - bb.writeString(value); - } - - var value = message["client"]; - if (value != null) { - bb.writeByte(2); - encodeFrameworkEntryPointMessage(value, bb); - } - - var value = message["server"]; - if (value != null) { - bb.writeByte(3); - encodeFrameworkEntryPointMessage(value, bb); - } - - var value = message["fallback"]; - if (value != null) { - bb.writeByte(4); - encodeFrameworkEntryPointMessage(value, bb); - } - - var value = message["development"]; - if (value != null) { - bb.writeByte(5); - bb.writeByte(value); - } - - var value = message["client_css_in_js"]; - if (value != null) { - bb.writeByte(6); - var encoded = CSSInJSBehavior[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "CSSInJSBehavior"'); - bb.writeByte(encoded); - } - - var value = message["display_name"]; - if (value != null) { - bb.writeByte(7); - bb.writeString(value); - } - - var value = message["overrideModules"]; - if (value != null) { - bb.writeByte(8); - encodeStringMap(value, bb); - } - bb.writeByte(0); -} - -function decodeFrameworkEntryPoint(bb) { - var result = {}; - - result["kind"] = FrameworkEntryPointType[bb.readByte()]; - result["path"] = bb.readString(); - result["env"] = decodeLoadedEnvConfig(bb); - return result; -} - -function encodeFrameworkEntryPoint(message, bb) { - var value = message["kind"]; - if (value != null) { - var encoded = FrameworkEntryPointType[value]; - if (encoded === void 0) - throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "FrameworkEntryPointType"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "kind"'); - } - - var value = message["path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "path"'); - } - - var value = message["env"]; - if (value != null) { - encodeLoadedEnvConfig(value, bb); - } else { - throw new Error('Missing required field "env"'); - } -} - -function decodeFrameworkEntryPointMap(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["client"] = decodeFrameworkEntryPoint(bb); - break; - - case 2: - result["server"] = decodeFrameworkEntryPoint(bb); - break; - - case 3: - result["fallback"] = decodeFrameworkEntryPoint(bb); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeFrameworkEntryPointMap(message, bb) { - var value = message["client"]; - if (value != null) { - bb.writeByte(1); - encodeFrameworkEntryPoint(value, bb); - } - - var value = message["server"]; - if (value != null) { - bb.writeByte(2); - encodeFrameworkEntryPoint(value, bb); - } - - var value = message["fallback"]; - if (value != null) { - bb.writeByte(3); - encodeFrameworkEntryPoint(value, bb); - } - bb.writeByte(0); -} - -function decodeFrameworkEntryPointMessage(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["path"] = bb.readString(); - break; - - case 2: - result["env"] = decodeEnvConfig(bb); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeFrameworkEntryPointMessage(message, bb) { - var value = message["path"]; - if (value != null) { - bb.writeByte(1); - bb.writeString(value); - } - - var value = message["env"]; - if (value != null) { - bb.writeByte(2); - encodeEnvConfig(value, bb); - } - bb.writeByte(0); -} - -function decodeLoadedFramework(bb) { - var result = {}; - - result["package"] = bb.readString(); - result["display_name"] = bb.readString(); - result["development"] = !!bb.readByte(); - result["entry_points"] = decodeFrameworkEntryPointMap(bb); - result["client_css_in_js"] = CSSInJSBehavior[bb.readByte()]; - result["overrideModules"] = decodeStringMap(bb); - return result; -} - -function encodeLoadedFramework(message, bb) { - var value = message["package"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "package"'); - } - - var value = message["display_name"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "display_name"'); - } - - var value = message["development"]; - if (value != null) { - bb.writeByte(value); - } else { - throw new Error('Missing required field "development"'); - } - - var value = message["entry_points"]; - if (value != null) { - encodeFrameworkEntryPointMap(value, bb); - } else { - throw new Error('Missing required field "entry_points"'); - } - - var value = message["client_css_in_js"]; - if (value != null) { - var encoded = CSSInJSBehavior[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "CSSInJSBehavior"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "client_css_in_js"'); - } - - var value = message["overrideModules"]; - if (value != null) { - encodeStringMap(value, bb); - } else { - throw new Error('Missing required field "overrideModules"'); - } -} - -function decodeLoadedRouteConfig(bb) { - var result = {}; - - result["dir"] = bb.readString(); - var length = bb.readVarUint(); - var values = (result["extensions"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - result["static_dir"] = bb.readString(); - result["asset_prefix"] = bb.readString(); - return result; -} - -function encodeLoadedRouteConfig(message, bb) { - var value = message["dir"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "dir"'); - } - - var value = message["extensions"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } else { - throw new Error('Missing required field "extensions"'); - } - - var value = message["static_dir"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "static_dir"'); - } - - var value = message["asset_prefix"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "asset_prefix"'); - } -} - -function decodeRouteConfig(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - var length = bb.readVarUint(); - var values = (result["dir"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - break; - - case 2: - var length = bb.readVarUint(); - var values = (result["extensions"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - break; - - case 3: - result["static_dir"] = bb.readString(); - break; - - case 4: - result["asset_prefix"] = bb.readString(); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeRouteConfig(message, bb) { - var value = message["dir"]; - if (value != null) { - bb.writeByte(1); - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } - - var value = message["extensions"]; - if (value != null) { - bb.writeByte(2); - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } - - var value = message["static_dir"]; - if (value != null) { - bb.writeByte(3); - bb.writeString(value); - } - - var value = message["asset_prefix"]; - if (value != null) { - bb.writeByte(4); - bb.writeString(value); - } - bb.writeByte(0); -} - -function decodeTransformOptions(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["jsx"] = decodeJSX(bb); - break; - - case 2: - result["tsconfig_override"] = bb.readString(); - break; - - case 3: - result["resolve"] = ResolveMode[bb.readByte()]; - break; - - case 4: - result["origin"] = bb.readString(); - break; - - case 5: - result["absolute_working_dir"] = bb.readString(); - break; - - case 6: - result["define"] = decodeStringMap(bb); - break; - - case 7: - result["preserve_symlinks"] = !!bb.readByte(); - break; - - case 8: - var length = bb.readVarUint(); - var values = (result["entry_points"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - break; - - case 9: - result["write"] = !!bb.readByte(); - break; - - case 10: - var length = bb.readVarUint(); - var values = (result["inject"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - break; - - case 11: - result["output_dir"] = bb.readString(); - break; - - case 12: - var length = bb.readVarUint(); - var values = (result["external"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - break; - - case 13: - result["loaders"] = decodeLoaderMap(bb); - break; - - case 14: - var length = bb.readVarUint(); - var values = (result["main_fields"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - break; - - case 15: - result["platform"] = Platform[bb.readByte()]; - break; - - case 16: - result["serve"] = !!bb.readByte(); - break; - - case 17: - var length = bb.readVarUint(); - var values = (result["extension_order"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - break; - - case 18: - result["generate_node_module_bundle"] = !!bb.readByte(); - break; - - case 19: - result["node_modules_bundle_path"] = bb.readString(); - break; - - case 20: - result["node_modules_bundle_path_server"] = bb.readString(); - break; - - case 21: - result["framework"] = decodeFrameworkConfig(bb); - break; - - case 22: - result["router"] = decodeRouteConfig(bb); - break; - - case 23: - result["no_summary"] = !!bb.readByte(); - break; - - case 24: - result["disable_hmr"] = !!bb.readByte(); - break; - - case 25: - result["port"] = bb.readUint16(); - break; - - case 26: - result["logLevel"] = MessageLevel[bb.readVarUint()]; - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeTransformOptions(message, bb) { - var value = message["jsx"]; - if (value != null) { - bb.writeByte(1); - encodeJSX(value, bb); - } - - var value = message["tsconfig_override"]; - if (value != null) { - bb.writeByte(2); - bb.writeString(value); - } - - var value = message["resolve"]; - if (value != null) { - bb.writeByte(3); - var encoded = ResolveMode[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "ResolveMode"'); - bb.writeByte(encoded); - } - - var value = message["origin"]; - if (value != null) { - bb.writeByte(4); - bb.writeString(value); - } - - var value = message["absolute_working_dir"]; - if (value != null) { - bb.writeByte(5); - bb.writeString(value); - } - - var value = message["define"]; - if (value != null) { - bb.writeByte(6); - encodeStringMap(value, bb); - } - - var value = message["preserve_symlinks"]; - if (value != null) { - bb.writeByte(7); - bb.writeByte(value); - } - - var value = message["entry_points"]; - if (value != null) { - bb.writeByte(8); - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } - - var value = message["write"]; - if (value != null) { - bb.writeByte(9); - bb.writeByte(value); - } - - var value = message["inject"]; - if (value != null) { - bb.writeByte(10); - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } - - var value = message["output_dir"]; - if (value != null) { - bb.writeByte(11); - bb.writeString(value); - } - - var value = message["external"]; - if (value != null) { - bb.writeByte(12); - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } - - var value = message["loaders"]; - if (value != null) { - bb.writeByte(13); - encodeLoaderMap(value, bb); - } - - var value = message["main_fields"]; - if (value != null) { - bb.writeByte(14); - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } - - var value = message["platform"]; - if (value != null) { - bb.writeByte(15); - var encoded = Platform[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Platform"'); - bb.writeByte(encoded); - } - - var value = message["serve"]; - if (value != null) { - bb.writeByte(16); - bb.writeByte(value); - } - - var value = message["extension_order"]; - if (value != null) { - bb.writeByte(17); - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } - - var value = message["generate_node_module_bundle"]; - if (value != null) { - bb.writeByte(18); - bb.writeByte(value); - } - - var value = message["node_modules_bundle_path"]; - if (value != null) { - bb.writeByte(19); - bb.writeString(value); - } - - var value = message["node_modules_bundle_path_server"]; - if (value != null) { - bb.writeByte(20); - bb.writeString(value); - } - - var value = message["framework"]; - if (value != null) { - bb.writeByte(21); - encodeFrameworkConfig(value, bb); - } - - var value = message["router"]; - if (value != null) { - bb.writeByte(22); - encodeRouteConfig(value, bb); - } - - var value = message["no_summary"]; - if (value != null) { - bb.writeByte(23); - bb.writeByte(value); - } - - var value = message["disable_hmr"]; - if (value != null) { - bb.writeByte(24); - bb.writeByte(value); - } - - var value = message["port"]; - if (value != null) { - bb.writeByte(25); - bb.writeUint16(value); - } - - var value = message["logLevel"]; - if (value != null) { - bb.writeByte(26); - var encoded = MessageLevel[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "MessageLevel"'); - bb.writeVarUint(encoded); - } - bb.writeByte(0); -} - -function decodeFileHandle(bb) { - var result = {}; - - result["path"] = bb.readString(); - result["size"] = bb.readVarUint(); - result["fd"] = bb.readVarUint(); - return result; -} - -function encodeFileHandle(message, bb) { - var value = message["path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "path"'); - } - - var value = message["size"]; - if (value != null) { - bb.writeVarUint(value); - } else { - throw new Error('Missing required field "size"'); - } - - var value = message["fd"]; - if (value != null) { - bb.writeVarUint(value); - } else { - throw new Error('Missing required field "fd"'); - } -} - -function decodeTransform(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["handle"] = decodeFileHandle(bb); - break; - - case 2: - result["path"] = bb.readString(); - break; - - case 3: - result["contents"] = bb.readByteArray(); - break; - - case 4: - result["loader"] = Loader[bb.readByte()]; - break; - - case 5: - result["options"] = decodeTransformOptions(bb); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeTransform(message, bb) { - var value = message["handle"]; - if (value != null) { - bb.writeByte(1); - encodeFileHandle(value, bb); - } - - var value = message["path"]; - if (value != null) { - bb.writeByte(2); - bb.writeString(value); - } - - var value = message["contents"]; - if (value != null) { - bb.writeByte(3); - bb.writeByteArray(value); - } - - var value = message["loader"]; - if (value != null) { - bb.writeByte(4); - var encoded = Loader[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"'); - bb.writeByte(encoded); - } - - var value = message["options"]; - if (value != null) { - bb.writeByte(5); - encodeTransformOptions(value, bb); - } - bb.writeByte(0); -} - -function decodeScan(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["path"] = bb.readString(); - break; - - case 2: - result["contents"] = bb.readByteArray(); - break; - - case 3: - result["loader"] = Loader[bb.readByte()]; - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeScan(message, bb) { - var value = message["path"]; - if (value != null) { - bb.writeByte(1); - bb.writeString(value); - } - - var value = message["contents"]; - if (value != null) { - bb.writeByte(2); - bb.writeByteArray(value); - } - - var value = message["loader"]; - if (value != null) { - bb.writeByte(3); - var encoded = Loader[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"'); - bb.writeByte(encoded); - } - bb.writeByte(0); -} - -function decodeScanResult(bb) { - var result = {}; - - var length = bb.readVarUint(); - var values = (result["exports"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - var length = bb.readVarUint(); - var values = (result["imports"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeScannedImport(bb); - return result; -} - -function encodeScanResult(message, bb) { - var value = message["exports"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } else { - throw new Error('Missing required field "exports"'); - } - - var value = message["imports"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeScannedImport(value, bb); - } - } else { - throw new Error('Missing required field "imports"'); - } -} - -function decodeScannedImport(bb) { - var result = {}; - - result["path"] = bb.readString(); - result["kind"] = ImportKind[bb.readByte()]; - return result; -} - -function encodeScannedImport(message, bb) { - var value = message["path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "path"'); - } - - var value = message["kind"]; - if (value != null) { - var encoded = ImportKind[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "ImportKind"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "kind"'); - } -} -const ImportKind = { - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - 7: 7, - 8: 8, - entry_point: 1, - stmt: 2, - require: 3, - dynamic: 4, - require_resolve: 5, - at: 6, - url: 7, - internal: 8, -}; -const ImportKindKeys = { - 1: "entry_point", - 2: "stmt", - 3: "require", - 4: "dynamic", - 5: "require_resolve", - 6: "at", - 7: "url", - 8: "internal", - entry_point: "entry_point", - stmt: "stmt", - require: "require", - dynamic: "dynamic", - require_resolve: "require_resolve", - at: "at", - url: "url", - internal: "internal", -}; -const TransformResponseStatus = { - 1: 1, - 2: 2, - success: 1, - fail: 2, -}; -const TransformResponseStatusKeys = { - 1: "success", - 2: "fail", - success: "success", - fail: "fail", -}; - -function decodeOutputFile(bb) { - var result = {}; - - result["data"] = bb.readByteArray(); - result["path"] = bb.readString(); - return result; -} - -function encodeOutputFile(message, bb) { - var value = message["data"]; - if (value != null) { - bb.writeByteArray(value); - } else { - throw new Error('Missing required field "data"'); - } - - var value = message["path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "path"'); - } -} - -function decodeTransformResponse(bb) { - var result = {}; - - result["status"] = TransformResponseStatus[bb.readVarUint()]; - var length = bb.readVarUint(); - var values = (result["files"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeOutputFile(bb); - var length = bb.readVarUint(); - var values = (result["errors"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeMessage(bb); - return result; -} - -function encodeTransformResponse(message, bb) { - var value = message["status"]; - if (value != null) { - var encoded = TransformResponseStatus[value]; - if (encoded === void 0) - throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "TransformResponseStatus"'); - bb.writeVarUint(encoded); - } else { - throw new Error('Missing required field "status"'); - } - - var value = message["files"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeOutputFile(value, bb); - } - } else { - throw new Error('Missing required field "files"'); - } - - var value = message["errors"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeMessage(value, bb); - } - } else { - throw new Error('Missing required field "errors"'); - } -} -const MessageLevel = { - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - err: 1, - warn: 2, - note: 3, - info: 4, - debug: 5, -}; -const MessageLevelKeys = { - 1: "err", - 2: "warn", - 3: "note", - 4: "info", - 5: "debug", - err: "err", - warn: "warn", - note: "note", - info: "info", - debug: "debug", -}; - -function decodeLocation(bb) { - var result = {}; - - result["file"] = bb.readString(); - result["namespace"] = bb.readString(); - result["line"] = bb.readInt32(); - result["column"] = bb.readInt32(); - result["line_text"] = bb.readString(); - result["suggestion"] = bb.readString(); - result["offset"] = bb.readVarUint(); - return result; -} - -function encodeLocation(message, bb) { - var value = message["file"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "file"'); - } - - var value = message["namespace"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "namespace"'); - } - - var value = message["line"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "line"'); - } - - var value = message["column"]; - if (value != null) { - bb.writeInt32(value); - } else { - throw new Error('Missing required field "column"'); - } - - var value = message["line_text"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "line_text"'); - } - - var value = message["suggestion"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "suggestion"'); - } - - var value = message["offset"]; - if (value != null) { - bb.writeVarUint(value); - } else { - throw new Error('Missing required field "offset"'); - } -} - -function decodeMessageData(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["text"] = bb.readString(); - break; - - case 2: - result["location"] = decodeLocation(bb); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeMessageData(message, bb) { - var value = message["text"]; - if (value != null) { - bb.writeByte(1); - bb.writeString(value); - } - - var value = message["location"]; - if (value != null) { - bb.writeByte(2); - encodeLocation(value, bb); - } - bb.writeByte(0); -} - -function decodeMessageMeta(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["resolve"] = bb.readString(); - break; - - case 2: - result["build"] = !!bb.readByte(); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeMessageMeta(message, bb) { - var value = message["resolve"]; - if (value != null) { - bb.writeByte(1); - bb.writeString(value); - } - - var value = message["build"]; - if (value != null) { - bb.writeByte(2); - bb.writeByte(value); - } - bb.writeByte(0); -} - -function decodeMessage(bb) { - var result = {}; - - result["level"] = MessageLevel[bb.readVarUint()]; - result["data"] = decodeMessageData(bb); - var length = bb.readVarUint(); - var values = (result["notes"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeMessageData(bb); - result["on"] = decodeMessageMeta(bb); - return result; -} - -function encodeMessage(message, bb) { - var value = message["level"]; - if (value != null) { - var encoded = MessageLevel[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "MessageLevel"'); - bb.writeVarUint(encoded); - } else { - throw new Error('Missing required field "level"'); - } - - var value = message["data"]; - if (value != null) { - encodeMessageData(value, bb); - } else { - throw new Error('Missing required field "data"'); - } - - var value = message["notes"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeMessageData(value, bb); - } - } else { - throw new Error('Missing required field "notes"'); - } - - var value = message["on"]; - if (value != null) { - encodeMessageMeta(value, bb); - } else { - throw new Error('Missing required field "on"'); - } -} - -function decodeLog(bb) { - var result = {}; - - result["warnings"] = bb.readUint32(); - result["errors"] = bb.readUint32(); - var length = bb.readVarUint(); - var values = (result["msgs"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeMessage(bb); - return result; -} - -function encodeLog(message, bb) { - var value = message["warnings"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "warnings"'); - } - - var value = message["errors"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "errors"'); - } - - var value = message["msgs"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeMessage(value, bb); - } - } else { - throw new Error('Missing required field "msgs"'); - } -} -const Reloader = { - 1: 1, - 2: 2, - 3: 3, - disable: 1, - live: 2, - fast_refresh: 3, -}; -const ReloaderKeys = { - 1: "disable", - 2: "live", - 3: "fast_refresh", - disable: "disable", - live: "live", - fast_refresh: "fast_refresh", -}; -const WebsocketMessageKind = { - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - 7: 7, - 8: 8, - welcome: 1, - file_change_notification: 2, - build_success: 3, - build_fail: 4, - manifest_success: 5, - manifest_fail: 6, - resolve_file: 7, - file_change_notification_with_hint: 8, -}; -const WebsocketMessageKindKeys = { - 1: "welcome", - 2: "file_change_notification", - 3: "build_success", - 4: "build_fail", - 5: "manifest_success", - 6: "manifest_fail", - 7: "resolve_file", - 8: "file_change_notification_with_hint", - welcome: "welcome", - file_change_notification: "file_change_notification", - build_success: "build_success", - build_fail: "build_fail", - manifest_success: "manifest_success", - manifest_fail: "manifest_fail", - resolve_file: "resolve_file", - file_change_notification_with_hint: "file_change_notification_with_hint", -}; -const WebsocketCommandKind = { - 1: 1, - 2: 2, - 3: 3, - build: 1, - manifest: 2, - build_with_file_path: 3, -}; -const WebsocketCommandKindKeys = { - 1: "build", - 2: "manifest", - 3: "build_with_file_path", - build: "build", - manifest: "manifest", - build_with_file_path: "build_with_file_path", -}; - -function decodeWebsocketMessage(bb) { - var result = {}; - - result["timestamp"] = bb.readUint32(); - result["kind"] = WebsocketMessageKind[bb.readByte()]; - return result; -} - -function encodeWebsocketMessage(message, bb) { - var value = message["timestamp"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "timestamp"'); - } - - var value = message["kind"]; - if (value != null) { - var encoded = WebsocketMessageKind[value]; - if (encoded === void 0) - throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "WebsocketMessageKind"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "kind"'); - } -} - -function decodeWebsocketMessageWelcome(bb) { - var result = {}; - - result["epoch"] = bb.readUint32(); - result["javascriptReloader"] = Reloader[bb.readByte()]; - result["cwd"] = bb.readString(); - return result; -} - -function encodeWebsocketMessageWelcome(message, bb) { - var value = message["epoch"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "epoch"'); - } - - var value = message["javascriptReloader"]; - if (value != null) { - var encoded = Reloader[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Reloader"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "javascriptReloader"'); - } - - var value = message["cwd"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "cwd"'); - } -} - -function decodeWebsocketMessageFileChangeNotification(bb) { - var result = {}; - - result["id"] = bb.readUint32(); - result["loader"] = Loader[bb.readByte()]; - return result; -} - -function encodeWebsocketMessageFileChangeNotification(message, bb) { - var value = message["id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "id"'); - } - - var value = message["loader"]; - if (value != null) { - var encoded = Loader[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "loader"'); - } -} - -function decodeWebsocketCommand(bb) { - var result = {}; - - result["kind"] = WebsocketCommandKind[bb.readByte()]; - result["timestamp"] = bb.readUint32(); - return result; -} - -function encodeWebsocketCommand(message, bb) { - var value = message["kind"]; - if (value != null) { - var encoded = WebsocketCommandKind[value]; - if (encoded === void 0) - throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "WebsocketCommandKind"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "kind"'); - } - - var value = message["timestamp"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "timestamp"'); - } -} - -function decodeWebsocketCommandBuild(bb) { - var result = {}; - - result["id"] = bb.readUint32(); - return result; -} - -function encodeWebsocketCommandBuild(message, bb) { - var value = message["id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "id"'); - } -} - -function decodeWebsocketCommandManifest(bb) { - var result = {}; - - result["id"] = bb.readUint32(); - return result; -} - -function encodeWebsocketCommandManifest(message, bb) { - var value = message["id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "id"'); - } -} - -function decodeWebsocketMessageBuildSuccess(bb) { - var result = {}; - - result["id"] = bb.readUint32(); - result["from_timestamp"] = bb.readUint32(); - result["loader"] = Loader[bb.readByte()]; - result["module_path"] = bb.readString(); - result["blob_length"] = bb.readUint32(); - return result; -} - -function encodeWebsocketMessageBuildSuccess(message, bb) { - var value = message["id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "id"'); - } - - var value = message["from_timestamp"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "from_timestamp"'); - } - - var value = message["loader"]; - if (value != null) { - var encoded = Loader[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "loader"'); - } - - var value = message["module_path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "module_path"'); - } - - var value = message["blob_length"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "blob_length"'); - } -} - -function decodeWebsocketMessageBuildFailure(bb) { - var result = {}; - - result["id"] = bb.readUint32(); - result["from_timestamp"] = bb.readUint32(); - result["loader"] = Loader[bb.readByte()]; - result["module_path"] = bb.readString(); - result["log"] = decodeLog(bb); - return result; -} - -function encodeWebsocketMessageBuildFailure(message, bb) { - var value = message["id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "id"'); - } - - var value = message["from_timestamp"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "from_timestamp"'); - } - - var value = message["loader"]; - if (value != null) { - var encoded = Loader[value]; - if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' for enum "Loader"'); - bb.writeByte(encoded); - } else { - throw new Error('Missing required field "loader"'); - } - - var value = message["module_path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "module_path"'); - } - - var value = message["log"]; - if (value != null) { - encodeLog(value, bb); - } else { - throw new Error('Missing required field "log"'); - } -} - -function decodeWebsocketCommandBuildWithFilePath(bb) { - var result = {}; - - result["id"] = bb.readUint32(); - result["file_path"] = bb.readString(); - return result; -} - -function encodeWebsocketCommandBuildWithFilePath(message, bb) { - var value = message["id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "id"'); - } - - var value = message["file_path"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "file_path"'); - } -} - -function decodeWebsocketMessageResolveID(bb) { - var result = {}; - - result["id"] = bb.readUint32(); - return result; -} - -function encodeWebsocketMessageResolveID(message, bb) { - var value = message["id"]; - if (value != null) { - bb.writeUint32(value); - } else { - throw new Error('Missing required field "id"'); - } -} - -function decodeNPMRegistry(bb) { - var result = {}; - - result["url"] = bb.readString(); - result["username"] = bb.readString(); - result["password"] = bb.readString(); - result["token"] = bb.readString(); - return result; -} - -function encodeNPMRegistry(message, bb) { - var value = message["url"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "url"'); - } - - var value = message["username"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "username"'); - } - - var value = message["password"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "password"'); - } - - var value = message["token"]; - if (value != null) { - bb.writeString(value); - } else { - throw new Error('Missing required field "token"'); - } -} - -function decodeNPMRegistryMap(bb) { - var result = {}; - - var length = bb.readVarUint(); - var values = (result["scopes"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - var length = bb.readVarUint(); - var values = (result["registries"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = decodeNPMRegistry(bb); - return result; -} - -function encodeNPMRegistryMap(message, bb) { - var value = message["scopes"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } else { - throw new Error('Missing required field "scopes"'); - } - - var value = message["registries"]; - if (value != null) { - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - encodeNPMRegistry(value, bb); - } - } else { - throw new Error('Missing required field "registries"'); - } -} - -function decodeBunInstall(bb) { - var result = {}; - - while (true) { - switch (bb.readByte()) { - case 0: - return result; - - case 1: - result["default_registry"] = decodeNPMRegistry(bb); - break; - - case 2: - result["scoped"] = decodeNPMRegistryMap(bb); - break; - - case 3: - result["lockfile_path"] = bb.readString(); - break; - - case 4: - result["save_lockfile_path"] = bb.readString(); - break; - - case 5: - result["cache_directory"] = bb.readString(); - break; - - case 6: - result["dry_run"] = !!bb.readByte(); - break; - - case 7: - result["force"] = !!bb.readByte(); - break; - - case 8: - result["save_dev"] = !!bb.readByte(); - break; - - case 9: - result["save_optional"] = !!bb.readByte(); - break; - - case 10: - result["save_peer"] = !!bb.readByte(); - break; - - case 11: - result["save_lockfile"] = !!bb.readByte(); - break; - - case 12: - result["production"] = !!bb.readByte(); - break; - - case 13: - result["save_yarn_lockfile"] = !!bb.readByte(); - break; - - case 14: - var length = bb.readVarUint(); - var values = (result["native_bin_links"] = Array(length)); - for (var i = 0; i < length; i++) values[i] = bb.readString(); - break; - - case 15: - result["disable_cache"] = !!bb.readByte(); - break; - - case 16: - result["disable_manifest_cache"] = !!bb.readByte(); - break; - - case 17: - result["global_dir"] = bb.readString(); - break; - - case 18: - result["global_bin_dir"] = bb.readString(); - break; - - case 19: - result["frozen-lockfile"] = !!bb.readByte(); - break; - - default: - throw new Error("Attempted to parse invalid message"); - } - } -} - -function encodeBunInstall(message, bb) { - var value = message["default_registry"]; - if (value != null) { - bb.writeByte(1); - encodeNPMRegistry(value, bb); - } - - var value = message["scoped"]; - if (value != null) { - bb.writeByte(2); - encodeNPMRegistryMap(value, bb); - } - - var value = message["lockfile_path"]; - if (value != null) { - bb.writeByte(3); - bb.writeString(value); - } - - var value = message["save_lockfile_path"]; - if (value != null) { - bb.writeByte(4); - bb.writeString(value); - } - - var value = message["cache_directory"]; - if (value != null) { - bb.writeByte(5); - bb.writeString(value); - } - - var value = message["dry_run"]; - if (value != null) { - bb.writeByte(6); - bb.writeByte(value); - } - - var value = message["force"]; - if (value != null) { - bb.writeByte(7); - bb.writeByte(value); - } - - var value = message["save_dev"]; - if (value != null) { - bb.writeByte(8); - bb.writeByte(value); - } - - var value = message["save_optional"]; - if (value != null) { - bb.writeByte(9); - bb.writeByte(value); - } - - var value = message["save_peer"]; - if (value != null) { - bb.writeByte(10); - bb.writeByte(value); - } - - var value = message["save_lockfile"]; - if (value != null) { - bb.writeByte(11); - bb.writeByte(value); - } - - var value = message["production"]; - if (value != null) { - bb.writeByte(12); - bb.writeByte(value); - } - - var value = message["save_yarn_lockfile"]; - if (value != null) { - bb.writeByte(13); - bb.writeByte(value); - } - - var value = message["native_bin_links"]; - if (value != null) { - bb.writeByte(14); - var values = value, - n = values.length; - bb.writeVarUint(n); - for (var i = 0; i < n; i++) { - value = values[i]; - bb.writeString(value); - } - } - - var value = message["disable_cache"]; - if (value != null) { - bb.writeByte(15); - bb.writeByte(value); - } - - var value = message["disable_manifest_cache"]; - if (value != null) { - bb.writeByte(16); - bb.writeByte(value); - } - - var value = message["global_dir"]; - if (value != null) { - bb.writeByte(17); - bb.writeString(value); - } - - var value = message["global_bin_dir"]; - if (value != null) { - bb.writeByte(18); - bb.writeString(value); - } - bb.writeByte(0); -} - -export { Loader }; -export { LoaderKeys }; -export { FrameworkEntryPointType }; -export { FrameworkEntryPointTypeKeys }; -export { StackFrameScope }; -export { StackFrameScopeKeys }; -export { decodeStackFrame }; -export { encodeStackFrame }; -export { decodeStackFramePosition }; -export { encodeStackFramePosition }; -export { decodeSourceLine }; -export { encodeSourceLine }; -export { decodeStackTrace }; -export { encodeStackTrace }; -export { decodeJSException }; -export { encodeJSException }; -export { FallbackStep }; -export { FallbackStepKeys }; -export { decodeProblems }; -export { encodeProblems }; -export { decodeRouter }; -export { encodeRouter }; -export { decodeFallbackMessageContainer }; -export { encodeFallbackMessageContainer }; -export { ResolveMode }; -export { ResolveModeKeys }; -export { Platform }; -export { PlatformKeys }; -export { CSSInJSBehavior }; -export { CSSInJSBehaviorKeys }; -export { JSXRuntime }; -export { JSXRuntimeKeys }; -export { decodeJSX }; -export { encodeJSX }; -export { decodeStringPointer }; -export { encodeStringPointer }; -export { decodeJavascriptBundledModule }; -export { encodeJavascriptBundledModule }; -export { decodeJavascriptBundledPackage }; -export { encodeJavascriptBundledPackage }; -export { decodeJavascriptBundle }; -export { encodeJavascriptBundle }; -export { decodeJavascriptBundleContainer }; -export { encodeJavascriptBundleContainer }; -export { ScanDependencyMode }; -export { ScanDependencyModeKeys }; -export { ModuleImportType }; -export { ModuleImportTypeKeys }; -export { decodeModuleImportRecord }; -export { encodeModuleImportRecord }; -export { decodeModule }; -export { encodeModule }; -export { decodeStringMap }; -export { encodeStringMap }; -export { decodeLoaderMap }; -export { encodeLoaderMap }; -export { DotEnvBehavior }; -export { DotEnvBehaviorKeys }; -export { decodeEnvConfig }; -export { encodeEnvConfig }; -export { decodeLoadedEnvConfig }; -export { encodeLoadedEnvConfig }; -export { decodeFrameworkConfig }; -export { encodeFrameworkConfig }; -export { decodeFrameworkEntryPoint }; -export { encodeFrameworkEntryPoint }; -export { decodeFrameworkEntryPointMap }; -export { encodeFrameworkEntryPointMap }; -export { decodeFrameworkEntryPointMessage }; -export { encodeFrameworkEntryPointMessage }; -export { decodeLoadedFramework }; -export { encodeLoadedFramework }; -export { decodeLoadedRouteConfig }; -export { encodeLoadedRouteConfig }; -export { decodeRouteConfig }; -export { encodeRouteConfig }; -export { decodeTransformOptions }; -export { encodeTransformOptions }; -export { decodeFileHandle }; -export { encodeFileHandle }; -export { decodeTransform }; -export { encodeTransform }; -export { decodeScan }; -export { encodeScan }; -export { decodeScanResult }; -export { encodeScanResult }; -export { decodeScannedImport }; -export { encodeScannedImport }; -export { ImportKind }; -export { ImportKindKeys }; -export { TransformResponseStatus }; -export { TransformResponseStatusKeys }; -export { decodeOutputFile }; -export { encodeOutputFile }; -export { decodeTransformResponse }; -export { encodeTransformResponse }; -export { MessageLevel }; -export { MessageLevelKeys }; -export { decodeLocation }; -export { encodeLocation }; -export { decodeMessageData }; -export { encodeMessageData }; -export { decodeMessageMeta }; -export { encodeMessageMeta }; -export { decodeMessage }; -export { encodeMessage }; -export { decodeLog }; -export { encodeLog }; -export { Reloader }; -export { ReloaderKeys }; -export { WebsocketMessageKind }; -export { WebsocketMessageKindKeys }; -export { WebsocketCommandKind }; -export { WebsocketCommandKindKeys }; -export { decodeWebsocketMessage }; -export { encodeWebsocketMessage }; -export { decodeWebsocketMessageWelcome }; -export { encodeWebsocketMessageWelcome }; -export { decodeWebsocketMessageFileChangeNotification }; -export { encodeWebsocketMessageFileChangeNotification }; -export { decodeWebsocketCommand }; -export { encodeWebsocketCommand }; -export { decodeWebsocketCommandBuild }; -export { encodeWebsocketCommandBuild }; -export { decodeWebsocketCommandManifest }; -export { encodeWebsocketCommandManifest }; -export { decodeWebsocketMessageBuildSuccess }; -export { encodeWebsocketMessageBuildSuccess }; -export { decodeWebsocketMessageBuildFailure }; -export { encodeWebsocketMessageBuildFailure }; -export { decodeWebsocketCommandBuildWithFilePath }; -export { encodeWebsocketCommandBuildWithFilePath }; -export { decodeWebsocketMessageResolveID }; -export { encodeWebsocketMessageResolveID }; -export { decodeNPMRegistry }; -export { encodeNPMRegistry }; -export { decodeNPMRegistryMap }; -export { encodeNPMRegistryMap }; -export { decodeBunInstall }; -export { encodeBunInstall }; diff --git a/src/api/demo/schema.peechy b/src/api/demo/schema.peechy deleted file mode 100644 index e495bb9c0..000000000 --- a/src/api/demo/schema.peechy +++ /dev/null @@ -1,554 +0,0 @@ -package Api; - -smol Loader { - jsx = 1; - js = 2; - ts = 3; - tsx = 4; - css = 5; - file = 6; - json = 7; - toml = 8; - wasm = 9; -} - -smol FrameworkEntryPointType { - client = 1; - server = 2; - fallback = 3; -} - -smol StackFrameScope { - Eval = 1; - Module = 2; - Function = 3; - Global = 4; - Wasm = 5; - Constructor = 6; -} - -struct StackFrame { - string function_name; - string file; - StackFramePosition position; - StackFrameScope scope; -} - -struct StackFramePosition { - int32 source_offset; - int32 line; - int32 line_start; - int32 line_stop; - int32 column_start; - int32 column_stop; - int32 expression_start; - int32 expression_stop; -} - -struct SourceLine { - int32 line; - string text; -} - -struct StackTrace { - SourceLine[] source_lines; - StackFrame[] frames; -} - - -message JSException { - string name = 1; - string message = 2; - - uint16 runtime_type = 3; - uint8 code = 4; - - StackTrace stack = 5; -} - -smol FallbackStep { - ssr_disabled = 1; - create_vm = 2; - configure_router = 3; - configure_defines = 4; - resolve_entry_point = 5; - load_entry_point = 6; - eval_entry_point = 7; - fetch_event_handler = 8; -} - -struct Problems { - uint16 code; - string name; - - JSException[] exceptions; - Log build; -} - -struct Router { - StringMap routes; - int32 route; - StringMap params; -} - -message FallbackMessageContainer { - string message = 1; - Router router = 2; - FallbackStep reason = 3; - Problems problems = 4; - string cwd = 5; -} - - -smol ResolveMode { - disable = 1; - lazy = 2; - dev = 3; - bundle = 4; -} - -smol Target { - browser = 1; - node = 2; - bun = 3; - bun_macro = 4; -} - -smol CSSInJSBehavior { - facade = 1; - facade_onimportcss = 2; - auto_onimportcss = 3; -} - -smol JSXRuntime { - automatic = 1; - classic = 2; -} - -struct JSX { - string factory; - JSXRuntime runtime; - string fragment; - bool development; - - // Probably react - string import_source; - - bool react_fast_refresh; -} - -struct StringPointer { - uint32 offset; - uint32 length; -} - -struct JavascriptBundledModule { - // package-relative path including file extension - StringPointer path; - - // Source code - StringPointer code; - - // index into JavascriptBundle.packages - uint32 package_id; - - // The ESM export is this id ("$" + number.toString(16)) - uint32 id; - - // This lets us efficiently compare strings ignoring the extension - byte path_extname_length; -} - -struct JavascriptBundledPackage { - StringPointer name; - StringPointer version; - uint32 hash; - - uint32 modules_offset; - uint32 modules_length; -} - -struct JavascriptBundle { - // These are sorted alphabetically so you can do binary search - JavascriptBundledModule[] modules; - JavascriptBundledPackage[] packages; - - // This is ASCII-encoded so you can send it directly over HTTP - byte[] etag; - - uint32 generated_at; - - // generated by hashing all ${name}@${version} in sorted order - byte[] app_package_json_dependencies_hash; - - byte[] import_from_name; - - // This is what StringPointer refers to - byte[] manifest_string; -} - -message JavascriptBundleContainer { - uint32 bundle_format_version = 1; - - // These go first so if we change JavaScriptBundle we can still read these - LoadedRouteConfig routes = 3; - LoadedFramework framework = 2; - - JavascriptBundle bundle = 4; - - // Don't technically need to store this, but it may be helpful as a sanity check - uint32 code_length = 5; -} - -smol ScanDependencyMode { - app = 1; - all = 2; -} - -smol ModuleImportType { - import = 1; - require = 2; -} - -struct ModuleImportRecord { - ModuleImportType kind; - string path; - - bool dynamic; -} - -struct Module { - string path; - ModuleImportRecord[] imports; -} - -struct StringMap { - string[] keys; - string[] values; -} - -struct LoaderMap { - string[] extensions; - Loader[] loaders; -} - -enum DotEnvBehavior { - disable = 1; - prefix = 2; - load_all = 3; -} - -message EnvConfig { - string prefix = 1; - StringMap defaults = 2; -} - -struct LoadedEnvConfig { - DotEnvBehavior dotenv; - - StringMap defaults; - string prefix; -} - -message FrameworkConfig { - string package = 1; - FrameworkEntryPointMessage client = 2; - FrameworkEntryPointMessage server = 3; - FrameworkEntryPointMessage fallback = 4; - bool development = 5; - - CSSInJSBehavior client_css_in_js = 6; - string display_name = 7; - - StringMap overrideModules = 8; -} - -struct FrameworkEntryPoint { - FrameworkEntryPointType kind; - string path; - LoadedEnvConfig env; -} - -message FrameworkEntryPointMap { - FrameworkEntryPoint client = 1; - FrameworkEntryPoint server = 2; - FrameworkEntryPoint fallback = 3; -} - -message FrameworkEntryPointMessage { - string path = 1; - EnvConfig env = 2; -} - -struct LoadedFramework { - string package; - string display_name; - bool development; - FrameworkEntryPointMap entry_points; - CSSInJSBehavior client_css_in_js; - StringMap overrideModules; -} - -struct LoadedRouteConfig { - string dir; - string[] extensions; - string static_dir; - string asset_prefix; -} - -message RouteConfig { - string[] dir = 1; - string[] extensions = 2; - string static_dir = 3; - string asset_prefix = 4; -} - -message TransformOptions { - JSX jsx = 1; - string tsconfig_override = 2; - ResolveMode resolve = 3; - - string origin = 4; - string absolute_working_dir = 5; - - StringMap define = 6; - - bool preserve_symlinks = 7; - - string[] entry_points = 8; - bool write = 9; - - string[] inject = 10; - string output_dir = 11; - - string[] external = 12; - - LoaderMap loaders = 13; - - string[] main_fields = 14; - Target target = 15; - - bool serve = 16; - - string[] extension_order = 17; - - bool generate_node_module_bundle = 18; - - string node_modules_bundle_path = 19; - string node_modules_bundle_path_server = 20; - - FrameworkConfig framework = 21; - RouteConfig router = 22; - bool no_summary = 23; - - bool disable_hmr = 24; - - uint16 port = 25; - MessageLevel logLevel = 26; -} - -struct FileHandle { - string path; - uint size; - uint fd; -} - -message Transform { - FileHandle handle = 1; - string path = 2; - byte[] contents = 3; - - Loader loader = 4; - TransformOptions options = 5; -} - -enum TransformResponseStatus { - success = 1; - fail = 2; -} - -struct OutputFile { - byte[] data; - string path; -} - -struct TransformResponse { - TransformResponseStatus status; - OutputFile[] files; - Message[] errors; -} - -enum MessageLevel { - err = 1; - warn =2; - note = 3; - info = 4; - debug = 5; -} - -struct Location { - string file; - string namespace; - int32 line; - int32 column; - string line_text; - string suggestion; - uint offset; -} - -message MessageData { - string text = 1; - Location location = 2; -} - - - -message MessageMeta { - string resolve = 1; - bool build = 2; -} - -struct Message { - MessageLevel level; - MessageData data; - MessageData[] notes; - MessageMeta on; -} - -struct Log { - uint32 warnings; - uint32 errors; - Message[] msgs; -} - - -smol Reloader { - disable = 1; - // equivalent of CMD + R - live = 2; - // React Fast Refresh - fast_refresh = 3; -} - -// The WebSocket protocol -// Server: "hey, this file changed. Does anyone want it?" -// Browser: *checks array* "uhh yeah, ok. rebuild that for me" -// Server: "here u go" -// This makes the client responsible for tracking which files it needs to listen for. -// From a server perspective, this means the filesystem watching thread can send the same WebSocket message -// to every client, which is good for performance. It means if you have 5 tabs open it won't really be different than one tab -// The clients can just ignore files they don't care about -smol WebsocketMessageKind { - welcome = 1; - file_change_notification = 2; - build_success = 3; - build_fail = 4; - manifest_success = 5; - manifest_fail = 6; - resolve_file = 7; - file_change_notification_with_hint = 8; -} - -smol WebsocketCommandKind { - build = 1; - manifest = 2; - build_with_file_path = 3; -} - -// Each websocket message has two messages in it! -// This is the first. -struct WebsocketMessage { - uint32 timestamp; - WebsocketMessageKind kind; -} - -// This is the first. -struct WebsocketMessageWelcome { - uint32 epoch; - Reloader javascriptReloader; - string cwd; -} - -struct WebsocketMessageFileChangeNotification { - uint32 id; - Loader loader; -} - -struct WebsocketCommand { - WebsocketCommandKind kind; - uint32 timestamp; -} - -// The timestamp is used for client-side deduping -struct WebsocketCommandBuild { - uint32 id; -} - -struct WebsocketCommandManifest { - uint32 id; -} - -// We copy the module_path here incase they don't already have it -struct WebsocketMessageBuildSuccess { - uint32 id; - uint32 from_timestamp; - - Loader loader; - string module_path; - - // This is the length of the blob that immediately follows this message. - uint32 blob_length; -} - -struct WebsocketMessageBuildFailure { - uint32 id; - uint32 from_timestamp; - Loader loader; - - string module_path; - Log log; -} - -struct WebsocketCommandBuildWithFilePath { - uint32 id; - string file_path; -} - -struct WebsocketMessageResolveID { - uint32 id; -} - -struct NPMRegistry { - string url; - string username; - string password; - string token; -} - -struct NPMRegistryMap { - string[] scopes; - NPMRegistry[] registries; -} - -message BunInstall { - NPMRegistry default_registry = 1; - NPMRegistryMap scoped = 2; - string lockfile_path = 3; - string save_lockfile_path = 4; - string cache_directory = 5; - bool dry_run = 6; - bool force = 7; - bool save_dev = 8; - bool save_optional = 9; - bool save_peer = 10; - bool save_lockfile = 11; - bool production = 12; - bool save_yarn_lockfile = 13; - string[] native_bin_links = 14; - - bool disable_cache = 15; - bool disable_manifest_cache = 16; - string global_dir = 17; - string global_bin_dir = 18; - string frozen_lockfile = 19; -} diff --git a/src/api/demo/schema.zig b/src/api/demo/schema.zig deleted file mode 100644 index a6de100de..000000000 --- a/src/api/demo/schema.zig +++ /dev/null @@ -1,2888 +0,0 @@ -const std = @import("std"); - -pub const Reader = struct { - const Self = @This(); - pub const ReadError = error{EOF}; - - buf: []u8, - remain: []u8, - allocator: std.mem.Allocator, - - pub fn init(buf: []u8, allocator: std.mem.Allocator) Reader { - return Reader{ - .buf = buf, - .remain = buf, - .allocator = allocator, - }; - } - - pub fn read(this: *Self, count: usize) ![]u8 { - const read_count = @min(count, this.remain.len); - if (read_count < count) { - return error.EOF; - } - - var slice = this.remain[0..read_count]; - - this.remain = this.remain[read_count..]; - - return slice; - } - - pub inline fn readAs(this: *Self, comptime T: type) !T { - if (!std.meta.trait.hasUniqueRepresentation(T)) { - @compileError(@typeName(T) ++ " must have unique representation."); - } - - return std.mem.bytesAsValue(T, try this.read(@sizeOf(T))); - } - - pub inline fn readByte(this: *Self) !u8 { - return (try this.read(1))[0]; - } - - pub fn readEnum(this: *Self, comptime Enum: type) !Enum { - const E = error{ - /// An integer was read, but it did not match any of the tags in the supplied enum. - InvalidValue, - }; - const type_info = @typeInfo(Enum).Enum; - const tag = try this.readInt(type_info.tag_type); - - inline for (std.meta.fields(Enum)) |field| { - if (tag == field.value) { - return @field(Enum, field.name); - } - } - - return E.InvalidValue; - } - - pub inline fn readArray(this: *Self, comptime T: type) ![]const T { - const length = try this.readInt(u32); - if (length == 0) { - return &([_]T{}); - } - - switch (comptime T) { - u8 => { - return try this.read(length); - }, - u16, u32, i8, i16, i32 => { - return std.mem.readIntSliceNative(T, this.read(length * @sizeOf(T))); - }, - [:0]const u8, []const u8 => { - var i: u32 = 0; - var array = try this.allocator.alloc(T, length); - while (i < length) : (i += 1) { - array[i] = try this.readArray(u8); - } - return array; - }, - else => { - switch (comptime @typeInfo(T)) { - .Struct => |Struct| { - switch (Struct.layout) { - .Packed => { - const sizeof = @sizeOf(T); - var slice = try this.read(sizeof * length); - return std.mem.bytesAsSlice(T, slice); - }, - else => {}, - } - }, - .Enum => |type_info| { - const enum_values = try this.read(length * @sizeOf(type_info.tag_type)); - return @ptrCast([*]T, enum_values.ptr)[0..length]; - }, - else => {}, - } - - var i: u32 = 0; - var array = try this.allocator.alloc(T, length); - while (i < length) : (i += 1) { - array[i] = try this.readValue(T); - } - - return array; - }, - } - } - - pub inline fn readByteArray(this: *Self) ![]u8 { - const length = try this.readInt(u32); - if (length == 0) { - return &([_]u8{}); - } - - return try this.read(@as(usize, length)); - } - - pub inline fn readInt(this: *Self, comptime T: type) !T { - var slice = try this.read(@sizeOf(T)); - - return std.mem.readIntSliceNative(T, slice); - } - - pub inline fn readBool(this: *Self) !bool { - return (try this.readByte()) > 0; - } - - pub inline fn readValue(this: *Self, comptime T: type) !T { - switch (comptime T) { - bool => { - return try this.readBool(); - }, - u8 => { - return try this.readByte(); - }, - [*:0]const u8, [:0]const u8, []const u8 => { - return try this.readArray(u8); - }, - - []const [:0]const u8, []const [*:0]const u8, []const []const u8 => { - return try this.readArray([]const u8); - }, - []u8, [:0]u8, [*:0]u8 => { - return try this.readArray([]u8); - }, - u16, u32, i8, i16, i32 => { - return std.mem.readIntSliceNative(T, try this.read(@sizeOf(T))); - }, - else => { - switch (comptime @typeInfo(T)) { - .Struct => |Struct| { - switch (Struct.layout) { - .Packed => { - const sizeof = @sizeOf(T); - var slice = try this.read(sizeof); - return @ptrCast(*T, slice[0..sizeof]).*; - }, - else => {}, - } - }, - .Enum => { - return try this.readEnum(T); - }, - else => {}, - } - - return try T.decode(this); - }, - } - - @compileError("Invalid type passed to readValue"); - } -}; - -pub fn Writer(comptime WritableStream: type) type { - return struct { - const Self = @This(); - writable: WritableStream, - - pub fn init(writable: WritableStream) Self { - return Self{ .writable = writable }; - } - - pub inline fn write(this: *Self, bytes: anytype) !void { - _ = try this.writable.write(bytes); - } - - pub inline fn writeByte(this: *Self, byte: u8) !void { - _ = try this.writable.write(&[1]u8{byte}); - } - - pub inline fn writeInt(this: *Self, int: anytype) !void { - try this.write(std.mem.asBytes(&int)); - } - - pub inline fn writeFieldID(this: *Self, comptime id: comptime_int) !void { - try this.writeByte(id); - } - - pub inline fn writeEnum(this: *Self, val: anytype) !void { - try this.writeInt(@intFromEnum(val)); - } - - pub fn writeValue(this: *Self, comptime SliceType: type, slice: SliceType) !void { - switch (SliceType) { - []u16, - []u32, - []i16, - []i32, - []i8, - []const u16, - []const u32, - []const i16, - []const i32, - []const i8, - [:0]u16, - [:0]u32, - [:0]i16, - [:0]i32, - [:0]i8, - [:0]const u16, - [:0]const u32, - [:0]const i16, - [:0]const i32, - [:0]const i8, - [*:0]u16, - [*:0]u32, - [*:0]i16, - [*:0]i32, - [*:0]i8, - [*:0]const u16, - [*:0]const u32, - [*:0]const i16, - [*:0]const i32, - [*:0]const i8, - => { - try this.writeArray(SliceType, slice); - }, - - []u8, - []const u8, - [:0]u8, - [:0]const u8, - [*:0]u8, - [*:0]const u8, - => { - try this.writeArray(u8, slice); - }, - - u8 => { - try this.write(slice); - }, - u16, u32, i16, i32, i8 => { - try this.write(std.mem.asBytes(slice)); - }, - - else => { - try slice.encode(this); - }, - } - } - - pub inline fn writeArray(this: *Self, comptime T: type, slice: anytype) !void { - try this.writeInt(@truncate(u32, slice.len)); - - switch (T) { - u8 => { - try this.write(slice); - }, - u16, u32, i16, i32, i8 => { - try this.write(std.mem.asBytes(slice)); - }, - [:0]u8, - []u8, - []u16, - []u32, - []i16, - []i32, - []i8, - []const u8, - [:0]const u8, - []const u16, - []const u32, - []const i16, - []const i32, - []const i8, - [:0]u16, - [:0]u32, - [:0]i16, - [:0]i32, - [:0]i8, - [:0]const u16, - [:0]const u32, - [:0]const i16, - [:0]const i32, - [:0]const i8, - [*:0]u16, - [*:0]u32, - [*:0]i16, - [*:0]i32, - [*:0]i8, - [*:0]const u16, - [*:0]const u32, - [*:0]const i16, - [*:0]const i32, - [*:0]const i8, - => { - for (slice) |num_slice| { - try this.writeArray(std.meta.Child(@TypeOf(num_slice)), num_slice); - } - }, - else => { - for (slice) |val| { - try val.encode(this); - } - }, - } - } - - pub inline fn endMessage(this: *Self) !void { - try this.writeByte(0); - } - }; -} - -pub const ByteWriter = Writer(*std.io.FixedBufferStream([]u8)); -pub const FileWriter = Writer(std.fs.File); - -pub const Api = struct { - pub const Loader = enum(u8) { - _none, - /// jsx - jsx, - - /// js - js, - - /// ts - ts, - - /// tsx - tsx, - - /// css - css, - - /// file - file, - - /// json - json, - - /// toml - toml, - - /// wasm - wasm, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const FrameworkEntryPointType = enum(u8) { - _none, - /// client - client, - - /// server - server, - - /// fallback - fallback, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const StackFrameScope = enum(u8) { - _none, - /// Eval - eval, - - /// Module - module, - - /// Function - function, - - /// Global - global, - - /// Wasm - wasm, - - /// Constructor - constructor, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const StackFrame = struct { - /// function_name - function_name: []const u8, - - /// file - file: []const u8, - - /// position - position: StackFramePosition, - - /// scope - scope: StackFrameScope, - - pub fn decode(reader: anytype) anyerror!StackFrame { - var this = std.mem.zeroes(StackFrame); - - this.function_name = try reader.readValue([]const u8); - this.file = try reader.readValue([]const u8); - this.position = try reader.readValue(StackFramePosition); - this.scope = try reader.readValue(StackFrameScope); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.function_name), this.function_name); - try writer.writeValue(@TypeOf(this.file), this.file); - try writer.writeValue(@TypeOf(this.position), this.position); - try writer.writeEnum(this.scope); - } - }; - - pub const StackFramePosition = packed struct { - /// source_offset - source_offset: i32 = 0, - - /// line - line: i32 = 0, - - /// line_start - line_start: i32 = 0, - - /// line_stop - line_stop: i32 = 0, - - /// column_start - column_start: i32 = 0, - - /// column_stop - column_stop: i32 = 0, - - /// expression_start - expression_start: i32 = 0, - - /// expression_stop - expression_stop: i32 = 0, - - pub fn decode(reader: anytype) anyerror!StackFramePosition { - var this = std.mem.zeroes(StackFramePosition); - - this.source_offset = try reader.readValue(i32); - this.line = try reader.readValue(i32); - this.line_start = try reader.readValue(i32); - this.line_stop = try reader.readValue(i32); - this.column_start = try reader.readValue(i32); - this.column_stop = try reader.readValue(i32); - this.expression_start = try reader.readValue(i32); - this.expression_stop = try reader.readValue(i32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.source_offset); - try writer.writeInt(this.line); - try writer.writeInt(this.line_start); - try writer.writeInt(this.line_stop); - try writer.writeInt(this.column_start); - try writer.writeInt(this.column_stop); - try writer.writeInt(this.expression_start); - try writer.writeInt(this.expression_stop); - } - }; - - pub const SourceLine = struct { - /// line - line: i32 = 0, - - /// text - text: []const u8, - - pub fn decode(reader: anytype) anyerror!SourceLine { - var this = std.mem.zeroes(SourceLine); - - this.line = try reader.readValue(i32); - this.text = try reader.readValue([]const u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.line); - try writer.writeValue(@TypeOf(this.text), this.text); - } - }; - - pub const StackTrace = struct { - /// source_lines - source_lines: []const SourceLine, - - /// frames - frames: []const StackFrame, - - pub fn decode(reader: anytype) anyerror!StackTrace { - var this = std.mem.zeroes(StackTrace); - - this.source_lines = try reader.readArray(SourceLine); - this.frames = try reader.readArray(StackFrame); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(SourceLine, this.source_lines); - try writer.writeArray(StackFrame, this.frames); - } - }; - - pub const JsException = struct { - /// name - name: ?[]const u8 = null, - - /// message - message: ?[]const u8 = null, - - /// runtime_type - runtime_type: ?u16 = null, - - /// code - code: ?u8 = null, - - /// stack - stack: ?StackTrace = null, - - pub fn decode(reader: anytype) anyerror!JsException { - var this = std.mem.zeroes(JsException); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.name = try reader.readValue([]const u8); - }, - 2 => { - this.message = try reader.readValue([]const u8); - }, - 3 => { - this.runtime_type = try reader.readValue(u16); - }, - 4 => { - this.code = try reader.readValue(u8); - }, - 5 => { - this.stack = try reader.readValue(StackTrace); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.name) |name| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(name), name); - } - if (this.message) |message| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(message), message); - } - if (this.runtime_type) |runtime_type| { - try writer.writeFieldID(3); - try writer.writeInt(runtime_type); - } - if (this.code) |code| { - try writer.writeFieldID(4); - try writer.writeInt(code); - } - if (this.stack) |stack| { - try writer.writeFieldID(5); - try writer.writeValue(@TypeOf(stack), stack); - } - try writer.endMessage(); - } - }; - - pub const FallbackStep = enum(u8) { - _none, - /// ssr_disabled - ssr_disabled, - - /// create_vm - create_vm, - - /// configure_router - configure_router, - - /// configure_defines - configure_defines, - - /// resolve_entry_point - resolve_entry_point, - - /// load_entry_point - load_entry_point, - - /// eval_entry_point - eval_entry_point, - - /// fetch_event_handler - fetch_event_handler, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const Problems = struct { - /// code - code: u16 = 0, - - /// name - name: []const u8, - - /// exceptions - exceptions: []const JsException, - - /// build - build: Log, - - pub fn decode(reader: anytype) anyerror!Problems { - var this = std.mem.zeroes(Problems); - - this.code = try reader.readValue(u16); - this.name = try reader.readValue([]const u8); - this.exceptions = try reader.readArray(JsException); - this.build = try reader.readValue(Log); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.code); - try writer.writeValue(@TypeOf(this.name), this.name); - try writer.writeArray(JsException, this.exceptions); - try writer.writeValue(@TypeOf(this.build), this.build); - } - }; - - pub const Router = struct { - /// routes - routes: StringMap, - - /// route - route: i32 = 0, - - /// params - params: StringMap, - - pub fn decode(reader: anytype) anyerror!Router { - var this = std.mem.zeroes(Router); - - this.routes = try reader.readValue(StringMap); - this.route = try reader.readValue(i32); - this.params = try reader.readValue(StringMap); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.routes), this.routes); - try writer.writeInt(this.route); - try writer.writeValue(@TypeOf(this.params), this.params); - } - }; - - pub const FallbackMessageContainer = struct { - /// message - message: ?[]const u8 = null, - - /// router - router: ?Router = null, - - /// reason - reason: ?FallbackStep = null, - - /// problems - problems: ?Problems = null, - - /// cwd - cwd: ?[]const u8 = null, - - pub fn decode(reader: anytype) anyerror!FallbackMessageContainer { - var this = std.mem.zeroes(FallbackMessageContainer); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.message = try reader.readValue([]const u8); - }, - 2 => { - this.router = try reader.readValue(Router); - }, - 3 => { - this.reason = try reader.readValue(FallbackStep); - }, - 4 => { - this.problems = try reader.readValue(Problems); - }, - 5 => { - this.cwd = try reader.readValue([]const u8); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.message) |message| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(message), message); - } - if (this.router) |router| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(router), router); - } - if (this.reason) |reason| { - try writer.writeFieldID(3); - try writer.writeEnum(reason); - } - if (this.problems) |problems| { - try writer.writeFieldID(4); - try writer.writeValue(@TypeOf(problems), problems); - } - if (this.cwd) |cwd| { - try writer.writeFieldID(5); - try writer.writeValue(@TypeOf(cwd), cwd); - } - try writer.endMessage(); - } - }; - - pub const ResolveMode = enum(u8) { - _none, - /// disable - disable, - - /// lazy - lazy, - - /// dev - dev, - - /// bundle - bundle, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const Target = enum(u8) { - _none, - /// browser - browser, - - /// node - node, - - /// bun - bun, - - /// bun_macro - bun_macro, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const CssInJsBehavior = enum(u8) { - _none, - /// facade - facade, - - /// facade_onimportcss - facade_onimportcss, - - /// auto_onimportcss - auto_onimportcss, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const JsxRuntime = enum(u8) { - _none, - /// automatic - automatic, - - /// classic - classic, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const Jsx = struct { - /// factory - factory: []const u8, - - /// runtime - runtime: JsxRuntime, - - /// fragment - fragment: []const u8, - - /// development - development: bool = false, - - /// import_source - import_source: []const u8, - - /// react_fast_refresh - react_fast_refresh: bool = false, - - pub fn decode(reader: anytype) anyerror!Jsx { - var this = std.mem.zeroes(Jsx); - - this.factory = try reader.readValue([]const u8); - this.runtime = try reader.readValue(JsxRuntime); - this.fragment = try reader.readValue([]const u8); - this.development = try reader.readValue(bool); - this.import_source = try reader.readValue([]const u8); - this.react_fast_refresh = try reader.readValue(bool); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.factory), this.factory); - try writer.writeEnum(this.runtime); - try writer.writeValue(@TypeOf(this.fragment), this.fragment); - try writer.writeInt(@as(u8, @intFromBool(this.development))); - try writer.writeValue(@TypeOf(this.import_source), this.import_source); - try writer.writeInt(@as(u8, @intFromBool(this.react_fast_refresh))); - } - }; - - pub const StringPointer = packed struct { - /// offset - offset: u32 = 0, - - /// length - length: u32 = 0, - - pub fn decode(reader: anytype) anyerror!StringPointer { - var this = std.mem.zeroes(StringPointer); - - this.offset = try reader.readValue(u32); - this.length = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.offset); - try writer.writeInt(this.length); - } - }; - - pub const JavascriptBundledModule = struct { - /// path - path: StringPointer, - - /// code - code: StringPointer, - - /// package_id - package_id: u32 = 0, - - /// id - id: u32 = 0, - - /// path_extname_length - path_extname_length: u8 = 0, - - pub fn decode(reader: anytype) anyerror!JavascriptBundledModule { - var this = std.mem.zeroes(JavascriptBundledModule); - - this.path = try reader.readValue(StringPointer); - this.code = try reader.readValue(StringPointer); - this.package_id = try reader.readValue(u32); - this.id = try reader.readValue(u32); - this.path_extname_length = try reader.readValue(u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.path), this.path); - try writer.writeValue(@TypeOf(this.code), this.code); - try writer.writeInt(this.package_id); - try writer.writeInt(this.id); - try writer.writeInt(this.path_extname_length); - } - }; - - pub const JavascriptBundledPackage = struct { - /// name - name: StringPointer, - - /// version - version: StringPointer, - - /// hash - hash: u32 = 0, - - /// modules_offset - modules_offset: u32 = 0, - - /// modules_length - modules_length: u32 = 0, - - pub fn decode(reader: anytype) anyerror!JavascriptBundledPackage { - var this = std.mem.zeroes(JavascriptBundledPackage); - - this.name = try reader.readValue(StringPointer); - this.version = try reader.readValue(StringPointer); - this.hash = try reader.readValue(u32); - this.modules_offset = try reader.readValue(u32); - this.modules_length = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.name), this.name); - try writer.writeValue(@TypeOf(this.version), this.version); - try writer.writeInt(this.hash); - try writer.writeInt(this.modules_offset); - try writer.writeInt(this.modules_length); - } - }; - - pub const JavascriptBundle = struct { - /// modules - modules: []const JavascriptBundledModule, - - /// packages - packages: []const JavascriptBundledPackage, - - /// etag - etag: []const u8, - - /// generated_at - generated_at: u32 = 0, - - /// app_package_json_dependencies_hash - app_package_json_dependencies_hash: []const u8, - - /// import_from_name - import_from_name: []const u8, - - /// manifest_string - manifest_string: []const u8, - - pub fn decode(reader: anytype) anyerror!JavascriptBundle { - var this = std.mem.zeroes(JavascriptBundle); - - this.modules = try reader.readArray(JavascriptBundledModule); - this.packages = try reader.readArray(JavascriptBundledPackage); - this.etag = try reader.readArray(u8); - this.generated_at = try reader.readValue(u32); - this.app_package_json_dependencies_hash = try reader.readArray(u8); - this.import_from_name = try reader.readArray(u8); - this.manifest_string = try reader.readArray(u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(JavascriptBundledModule, this.modules); - try writer.writeArray(JavascriptBundledPackage, this.packages); - try writer.writeArray(u8, this.etag); - try writer.writeInt(this.generated_at); - try writer.writeArray(u8, this.app_package_json_dependencies_hash); - try writer.writeArray(u8, this.import_from_name); - try writer.writeArray(u8, this.manifest_string); - } - }; - - pub const JavascriptBundleContainer = struct { - /// bundle_format_version - bundle_format_version: ?u32 = null, - - /// routes - routes: ?LoadedRouteConfig = null, - - /// framework - framework: ?LoadedFramework = null, - - /// bundle - bundle: ?JavascriptBundle = null, - - /// code_length - code_length: ?u32 = null, - - pub fn decode(reader: anytype) anyerror!JavascriptBundleContainer { - var this = std.mem.zeroes(JavascriptBundleContainer); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.bundle_format_version = try reader.readValue(u32); - }, - 2 => { - this.routes = try reader.readValue(LoadedRouteConfig); - }, - 3 => { - this.framework = try reader.readValue(LoadedFramework); - }, - 4 => { - this.bundle = try reader.readValue(JavascriptBundle); - }, - 5 => { - this.code_length = try reader.readValue(u32); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.bundle_format_version) |bundle_format_version| { - try writer.writeFieldID(1); - try writer.writeInt(bundle_format_version); - } - if (this.routes) |routes| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(routes), routes); - } - if (this.framework) |framework| { - try writer.writeFieldID(3); - try writer.writeValue(@TypeOf(framework), framework); - } - if (this.bundle) |bundle| { - try writer.writeFieldID(4); - try writer.writeValue(@TypeOf(bundle), bundle); - } - if (this.code_length) |code_length| { - try writer.writeFieldID(5); - try writer.writeInt(code_length); - } - try writer.endMessage(); - } - }; - - pub const ScanDependencyMode = enum(u8) { - _none, - /// app - app, - - /// all - all, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const ModuleImportType = enum(u8) { - _none, - /// import - import, - - /// require - require, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const ModuleImportRecord = struct { - /// kind - kind: ModuleImportType, - - /// path - path: []const u8, - - /// dynamic - dynamic: bool = false, - - pub fn decode(reader: anytype) anyerror!ModuleImportRecord { - var this = std.mem.zeroes(ModuleImportRecord); - - this.kind = try reader.readValue(ModuleImportType); - this.path = try reader.readValue([]const u8); - this.dynamic = try reader.readValue(bool); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.kind); - try writer.writeValue(@TypeOf(this.path), this.path); - try writer.writeInt(@as(u8, @intFromBool(this.dynamic))); - } - }; - - pub const Module = struct { - /// path - path: []const u8, - - /// imports - imports: []const ModuleImportRecord, - - pub fn decode(reader: anytype) anyerror!Module { - var this = std.mem.zeroes(Module); - - this.path = try reader.readValue([]const u8); - this.imports = try reader.readArray(ModuleImportRecord); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.path), this.path); - try writer.writeArray(ModuleImportRecord, this.imports); - } - }; - - pub const StringMap = struct { - /// keys - keys: []const []const u8, - - /// values - values: []const []const u8, - - pub fn decode(reader: anytype) anyerror!StringMap { - var this = std.mem.zeroes(StringMap); - - this.keys = try reader.readArray([]const u8); - this.values = try reader.readArray([]const u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray([]const u8, this.keys); - try writer.writeArray([]const u8, this.values); - } - }; - - pub const LoaderMap = struct { - /// extensions - extensions: []const []const u8, - - /// loaders - loaders: []const Loader, - - pub fn decode(reader: anytype) anyerror!LoaderMap { - var this = std.mem.zeroes(LoaderMap); - - this.extensions = try reader.readArray([]const u8); - this.loaders = try reader.readArray(Loader); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray([]const u8, this.extensions); - try writer.writeArray(Loader, this.loaders); - } - }; - - pub const DotEnvBehavior = enum(u32) { - _none, - /// disable - disable, - - /// prefix - prefix, - - /// load_all - load_all, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const EnvConfig = struct { - /// prefix - prefix: ?[]const u8 = null, - - /// defaults - defaults: ?StringMap = null, - - pub fn decode(reader: anytype) anyerror!EnvConfig { - var this = std.mem.zeroes(EnvConfig); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.prefix = try reader.readValue([]const u8); - }, - 2 => { - this.defaults = try reader.readValue(StringMap); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.prefix) |prefix| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(prefix), prefix); - } - if (this.defaults) |defaults| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(defaults), defaults); - } - try writer.endMessage(); - } - }; - - pub const LoadedEnvConfig = struct { - /// dotenv - dotenv: DotEnvBehavior, - - /// defaults - defaults: StringMap, - - /// prefix - prefix: []const u8, - - pub fn decode(reader: anytype) anyerror!LoadedEnvConfig { - var this = std.mem.zeroes(LoadedEnvConfig); - - this.dotenv = try reader.readValue(DotEnvBehavior); - this.defaults = try reader.readValue(StringMap); - this.prefix = try reader.readValue([]const u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.dotenv); - try writer.writeValue(@TypeOf(this.defaults), this.defaults); - try writer.writeValue(@TypeOf(this.prefix), this.prefix); - } - }; - - pub const FrameworkConfig = struct { - /// package - package: ?[]const u8 = null, - - /// client - client: ?FrameworkEntryPointMessage = null, - - /// server - server: ?FrameworkEntryPointMessage = null, - - /// fallback - fallback: ?FrameworkEntryPointMessage = null, - - /// development - development: ?bool = null, - - /// client_css_in_js - client_css_in_js: ?CssInJsBehavior = null, - - /// display_name - display_name: ?[]const u8 = null, - - /// overrideModules - override_modules: ?StringMap = null, - - pub fn decode(reader: anytype) anyerror!FrameworkConfig { - var this = std.mem.zeroes(FrameworkConfig); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.package = try reader.readValue([]const u8); - }, - 2 => { - this.client = try reader.readValue(FrameworkEntryPointMessage); - }, - 3 => { - this.server = try reader.readValue(FrameworkEntryPointMessage); - }, - 4 => { - this.fallback = try reader.readValue(FrameworkEntryPointMessage); - }, - 5 => { - this.development = try reader.readValue(bool); - }, - 6 => { - this.client_css_in_js = try reader.readValue(CssInJsBehavior); - }, - 7 => { - this.display_name = try reader.readValue([]const u8); - }, - 8 => { - this.override_modules = try reader.readValue(StringMap); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.package) |package| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(package), package); - } - if (this.client) |client| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(client), client); - } - if (this.server) |server| { - try writer.writeFieldID(3); - try writer.writeValue(@TypeOf(server), server); - } - if (this.fallback) |fallback| { - try writer.writeFieldID(4); - try writer.writeValue(@TypeOf(fallback), fallback); - } - if (this.development) |development| { - try writer.writeFieldID(5); - try writer.writeInt(@as(u8, @intFromBool(development))); - } - if (this.client_css_in_js) |client_css_in_js| { - try writer.writeFieldID(6); - try writer.writeEnum(client_css_in_js); - } - if (this.display_name) |display_name| { - try writer.writeFieldID(7); - try writer.writeValue(@TypeOf(display_name), display_name); - } - if (this.override_modules) |override_modules| { - try writer.writeFieldID(8); - try writer.writeValue(@TypeOf(override_modules), override_modules); - } - try writer.endMessage(); - } - }; - - pub const FrameworkEntryPoint = struct { - /// kind - kind: FrameworkEntryPointType, - - /// path - path: []const u8, - - /// env - env: LoadedEnvConfig, - - pub fn decode(reader: anytype) anyerror!FrameworkEntryPoint { - var this = std.mem.zeroes(FrameworkEntryPoint); - - this.kind = try reader.readValue(FrameworkEntryPointType); - this.path = try reader.readValue([]const u8); - this.env = try reader.readValue(LoadedEnvConfig); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.kind); - try writer.writeValue(@TypeOf(this.path), this.path); - try writer.writeValue(@TypeOf(this.env), this.env); - } - }; - - pub const FrameworkEntryPointMap = struct { - /// client - client: ?FrameworkEntryPoint = null, - - /// server - server: ?FrameworkEntryPoint = null, - - /// fallback - fallback: ?FrameworkEntryPoint = null, - - pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMap { - var this = std.mem.zeroes(FrameworkEntryPointMap); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.client = try reader.readValue(FrameworkEntryPoint); - }, - 2 => { - this.server = try reader.readValue(FrameworkEntryPoint); - }, - 3 => { - this.fallback = try reader.readValue(FrameworkEntryPoint); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.client) |client| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(client), client); - } - if (this.server) |server| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(server), server); - } - if (this.fallback) |fallback| { - try writer.writeFieldID(3); - try writer.writeValue(@TypeOf(fallback), fallback); - } - try writer.endMessage(); - } - }; - - pub const FrameworkEntryPointMessage = struct { - /// path - path: ?[]const u8 = null, - - /// env - env: ?EnvConfig = null, - - pub fn decode(reader: anytype) anyerror!FrameworkEntryPointMessage { - var this = std.mem.zeroes(FrameworkEntryPointMessage); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.path = try reader.readValue([]const u8); - }, - 2 => { - this.env = try reader.readValue(EnvConfig); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.path) |path| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(path), path); - } - if (this.env) |env| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(env), env); - } - try writer.endMessage(); - } - }; - - pub const LoadedFramework = struct { - /// package - package: []const u8, - - /// display_name - display_name: []const u8, - - /// development - development: bool = false, - - /// entry_points - entry_points: FrameworkEntryPointMap, - - /// client_css_in_js - client_css_in_js: CssInJsBehavior, - - /// overrideModules - override_modules: StringMap, - - pub fn decode(reader: anytype) anyerror!LoadedFramework { - var this = std.mem.zeroes(LoadedFramework); - - this.package = try reader.readValue([]const u8); - this.display_name = try reader.readValue([]const u8); - this.development = try reader.readValue(bool); - this.entry_points = try reader.readValue(FrameworkEntryPointMap); - this.client_css_in_js = try reader.readValue(CssInJsBehavior); - this.override_modules = try reader.readValue(StringMap); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.package), this.package); - try writer.writeValue(@TypeOf(this.display_name), this.display_name); - try writer.writeInt(@as(u8, @intFromBool(this.development))); - try writer.writeValue(@TypeOf(this.entry_points), this.entry_points); - try writer.writeEnum(this.client_css_in_js); - try writer.writeValue(@TypeOf(this.override_modules), this.override_modules); - } - }; - - pub const LoadedRouteConfig = struct { - /// dir - dir: []const u8, - - /// extensions - extensions: []const []const u8, - - /// static_dir - static_dir: []const u8, - - /// asset_prefix - asset_prefix: []const u8, - - pub fn decode(reader: anytype) anyerror!LoadedRouteConfig { - var this = std.mem.zeroes(LoadedRouteConfig); - - this.dir = try reader.readValue([]const u8); - this.extensions = try reader.readArray([]const u8); - this.static_dir = try reader.readValue([]const u8); - this.asset_prefix = try reader.readValue([]const u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.dir), this.dir); - try writer.writeArray([]const u8, this.extensions); - try writer.writeValue(@TypeOf(this.static_dir), this.static_dir); - try writer.writeValue(@TypeOf(this.asset_prefix), this.asset_prefix); - } - }; - - pub const RouteConfig = struct { - /// dir - dir: []const []const u8, - - /// extensions - extensions: []const []const u8, - - /// static_dir - static_dir: ?[]const u8 = null, - - /// asset_prefix - asset_prefix: ?[]const u8 = null, - - pub fn decode(reader: anytype) anyerror!RouteConfig { - var this = std.mem.zeroes(RouteConfig); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.dir = try reader.readArray([]const u8); - }, - 2 => { - this.extensions = try reader.readArray([]const u8); - }, - 3 => { - this.static_dir = try reader.readValue([]const u8); - }, - 4 => { - this.asset_prefix = try reader.readValue([]const u8); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.dir) |dir| { - try writer.writeFieldID(1); - try writer.writeArray([]const u8, dir); - } - if (this.extensions) |extensions| { - try writer.writeFieldID(2); - try writer.writeArray([]const u8, extensions); - } - if (this.static_dir) |static_dir| { - try writer.writeFieldID(3); - try writer.writeValue(@TypeOf(static_dir), static_dir); - } - if (this.asset_prefix) |asset_prefix| { - try writer.writeFieldID(4); - try writer.writeValue(@TypeOf(asset_prefix), asset_prefix); - } - try writer.endMessage(); - } - }; - - pub const TransformOptions = struct { - /// jsx - jsx: ?Jsx = null, - - /// tsconfig_override - tsconfig_override: ?[]const u8 = null, - - /// resolve - resolve: ?ResolveMode = null, - - /// origin - origin: ?[]const u8 = null, - - /// absolute_working_dir - absolute_working_dir: ?[]const u8 = null, - - /// define - define: ?StringMap = null, - - /// preserve_symlinks - preserve_symlinks: ?bool = null, - - /// entry_points - entry_points: []const []const u8, - - /// write - write: ?bool = null, - - /// inject - inject: []const []const u8, - - /// output_dir - output_dir: ?[]const u8 = null, - - /// external - external: []const []const u8, - - /// loaders - loaders: ?LoaderMap = null, - - /// main_fields - main_fields: []const []const u8, - - /// target - target: ?Target = null, - - /// serve - serve: ?bool = null, - - /// extension_order - extension_order: []const []const u8, - - /// generate_node_module_bundle - generate_node_module_bundle: ?bool = null, - - /// node_modules_bundle_path - node_modules_bundle_path: ?[]const u8 = null, - - /// node_modules_bundle_path_server - node_modules_bundle_path_server: ?[]const u8 = null, - - /// framework - framework: ?FrameworkConfig = null, - - /// router - router: ?RouteConfig = null, - - /// no_summary - no_summary: ?bool = null, - - /// disable_hmr - disable_hmr: ?bool = null, - - /// port - port: ?u16 = null, - - /// logLevel - log_level: ?MessageLevel = null, - - pub fn decode(reader: anytype) anyerror!TransformOptions { - var this = std.mem.zeroes(TransformOptions); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.jsx = try reader.readValue(Jsx); - }, - 2 => { - this.tsconfig_override = try reader.readValue([]const u8); - }, - 3 => { - this.resolve = try reader.readValue(ResolveMode); - }, - 4 => { - this.origin = try reader.readValue([]const u8); - }, - 5 => { - this.absolute_working_dir = try reader.readValue([]const u8); - }, - 6 => { - this.define = try reader.readValue(StringMap); - }, - 7 => { - this.preserve_symlinks = try reader.readValue(bool); - }, - 8 => { - this.entry_points = try reader.readArray([]const u8); - }, - 9 => { - this.write = try reader.readValue(bool); - }, - 10 => { - this.inject = try reader.readArray([]const u8); - }, - 11 => { - this.output_dir = try reader.readValue([]const u8); - }, - 12 => { - this.external = try reader.readArray([]const u8); - }, - 13 => { - this.loaders = try reader.readValue(LoaderMap); - }, - 14 => { - this.main_fields = try reader.readArray([]const u8); - }, - 15 => { - this.target = try reader.readValue(Target); - }, - 16 => { - this.serve = try reader.readValue(bool); - }, - 17 => { - this.extension_order = try reader.readArray([]const u8); - }, - 18 => { - this.generate_node_module_bundle = try reader.readValue(bool); - }, - 19 => { - this.node_modules_bundle_path = try reader.readValue([]const u8); - }, - 20 => { - this.node_modules_bundle_path_server = try reader.readValue([]const u8); - }, - 21 => { - this.framework = try reader.readValue(FrameworkConfig); - }, - 22 => { - this.router = try reader.readValue(RouteConfig); - }, - 23 => { - this.no_summary = try reader.readValue(bool); - }, - 24 => { - this.disable_hmr = try reader.readValue(bool); - }, - 25 => { - this.port = try reader.readValue(u16); - }, - 26 => { - this.log_level = try reader.readValue(MessageLevel); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.jsx) |jsx| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(jsx), jsx); - } - if (this.tsconfig_override) |tsconfig_override| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(tsconfig_override), tsconfig_override); - } - if (this.resolve) |resolve| { - try writer.writeFieldID(3); - try writer.writeEnum(resolve); - } - if (this.origin) |origin| { - try writer.writeFieldID(4); - try writer.writeValue(@TypeOf(origin), origin); - } - if (this.absolute_working_dir) |absolute_working_dir| { - try writer.writeFieldID(5); - try writer.writeValue(@TypeOf(absolute_working_dir), absolute_working_dir); - } - if (this.define) |define| { - try writer.writeFieldID(6); - try writer.writeValue(@TypeOf(define), define); - } - if (this.preserve_symlinks) |preserve_symlinks| { - try writer.writeFieldID(7); - try writer.writeInt(@as(u8, @intFromBool(preserve_symlinks))); - } - if (this.entry_points) |entry_points| { - try writer.writeFieldID(8); - try writer.writeArray([]const u8, entry_points); - } - if (this.write) |write| { - try writer.writeFieldID(9); - try writer.writeInt(@as(u8, @intFromBool(write))); - } - if (this.inject) |inject| { - try writer.writeFieldID(10); - try writer.writeArray([]const u8, inject); - } - if (this.output_dir) |output_dir| { - try writer.writeFieldID(11); - try writer.writeValue(@TypeOf(output_dir), output_dir); - } - if (this.external) |external| { - try writer.writeFieldID(12); - try writer.writeArray([]const u8, external); - } - if (this.loaders) |loaders| { - try writer.writeFieldID(13); - try writer.writeValue(@TypeOf(loaders), loaders); - } - if (this.main_fields) |main_fields| { - try writer.writeFieldID(14); - try writer.writeArray([]const u8, main_fields); - } - if (this.target) |target| { - try writer.writeFieldID(15); - try writer.writeEnum(target); - } - if (this.serve) |serve| { - try writer.writeFieldID(16); - try writer.writeInt(@as(u8, @intFromBool(serve))); - } - if (this.extension_order) |extension_order| { - try writer.writeFieldID(17); - try writer.writeArray([]const u8, extension_order); - } - if (this.generate_node_module_bundle) |generate_node_module_bundle| { - try writer.writeFieldID(18); - try writer.writeInt(@as(u8, @intFromBool(generate_node_module_bundle))); - } - if (this.node_modules_bundle_path) |node_modules_bundle_path| { - try writer.writeFieldID(19); - try writer.writeValue(@TypeOf(node_modules_bundle_path), node_modules_bundle_path); - } - if (this.node_modules_bundle_path_server) |node_modules_bundle_path_server| { - try writer.writeFieldID(20); - try writer.writeValue(@TypeOf(node_modules_bundle_path_server), node_modules_bundle_path_server); - } - if (this.framework) |framework| { - try writer.writeFieldID(21); - try writer.writeValue(@TypeOf(framework), framework); - } - if (this.router) |router| { - try writer.writeFieldID(22); - try writer.writeValue(@TypeOf(router), router); - } - if (this.no_summary) |no_summary| { - try writer.writeFieldID(23); - try writer.writeInt(@as(u8, @intFromBool(no_summary))); - } - if (this.disable_hmr) |disable_hmr| { - try writer.writeFieldID(24); - try writer.writeInt(@as(u8, @intFromBool(disable_hmr))); - } - if (this.port) |port| { - try writer.writeFieldID(25); - try writer.writeInt(port); - } - if (this.log_level) |log_level| { - try writer.writeFieldID(26); - try writer.writeEnum(log_level); - } - try writer.endMessage(); - } - }; - - pub const FileHandle = struct { - /// path - path: []const u8, - - /// size - size: u32 = 0, - - /// fd - fd: u32 = 0, - - pub fn decode(reader: anytype) anyerror!FileHandle { - var this = std.mem.zeroes(FileHandle); - - this.path = try reader.readValue([]const u8); - this.size = try reader.readValue(u32); - this.fd = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.path), this.path); - try writer.writeInt(this.size); - try writer.writeInt(this.fd); - } - }; - - pub const Transform = struct { - /// handle - handle: ?FileHandle = null, - - /// path - path: ?[]const u8 = null, - - /// contents - contents: []const u8, - - /// loader - loader: ?Loader = null, - - /// options - options: ?TransformOptions = null, - - pub fn decode(reader: anytype) anyerror!Transform { - var this = std.mem.zeroes(Transform); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.handle = try reader.readValue(FileHandle); - }, - 2 => { - this.path = try reader.readValue([]const u8); - }, - 3 => { - this.contents = try reader.readArray(u8); - }, - 4 => { - this.loader = try reader.readValue(Loader); - }, - 5 => { - this.options = try reader.readValue(TransformOptions); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.handle) |handle| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(handle), handle); - } - if (this.path) |path| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(path), path); - } - if (this.contents) |contents| { - try writer.writeFieldID(3); - try writer.writeArray(u8, contents); - } - if (this.loader) |loader| { - try writer.writeFieldID(4); - try writer.writeEnum(loader); - } - if (this.options) |options| { - try writer.writeFieldID(5); - try writer.writeValue(@TypeOf(options), options); - } - try writer.endMessage(); - } - }; - - pub const TransformResponseStatus = enum(u32) { - _none, - /// success - success, - - /// fail - fail, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const OutputFile = struct { - /// data - data: []const u8, - - /// path - path: []const u8, - - pub fn decode(reader: anytype) anyerror!OutputFile { - var this = std.mem.zeroes(OutputFile); - - this.data = try reader.readArray(u8); - this.path = try reader.readValue([]const u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray(u8, this.data); - try writer.writeValue(@TypeOf(this.path), this.path); - } - }; - - pub const TransformResponse = struct { - /// status - status: TransformResponseStatus, - - /// files - files: []const OutputFile, - - /// errors - errors: []const Message, - - pub fn decode(reader: anytype) anyerror!TransformResponse { - var this = std.mem.zeroes(TransformResponse); - - this.status = try reader.readValue(TransformResponseStatus); - this.files = try reader.readArray(OutputFile); - this.errors = try reader.readArray(Message); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.status); - try writer.writeArray(OutputFile, this.files); - try writer.writeArray(Message, this.errors); - } - }; - - pub const MessageLevel = enum(u32) { - _none, - /// err - err, - - /// warn - warn, - - /// note - note, - - /// info - info, - - /// debug - debug, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const Location = struct { - /// file - file: []const u8, - - /// namespace - namespace: []const u8, - - /// line - line: i32 = 0, - - /// column - column: i32 = 0, - - /// line_text - line_text: []const u8, - - /// suggestion - suggestion: []const u8, - - /// offset - offset: u32 = 0, - - pub fn decode(reader: anytype) anyerror!Location { - var this = std.mem.zeroes(Location); - - this.file = try reader.readValue([]const u8); - this.namespace = try reader.readValue([]const u8); - this.line = try reader.readValue(i32); - this.column = try reader.readValue(i32); - this.line_text = try reader.readValue([]const u8); - this.suggestion = try reader.readValue([]const u8); - this.offset = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.file), this.file); - try writer.writeValue(@TypeOf(this.namespace), this.namespace); - try writer.writeInt(this.line); - try writer.writeInt(this.column); - try writer.writeValue(@TypeOf(this.line_text), this.line_text); - try writer.writeValue(@TypeOf(this.suggestion), this.suggestion); - try writer.writeInt(this.offset); - } - }; - - pub const MessageData = struct { - /// text - text: ?[]const u8 = null, - - /// location - location: ?Location = null, - - pub fn decode(reader: anytype) anyerror!MessageData { - var this = std.mem.zeroes(MessageData); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.text = try reader.readValue([]const u8); - }, - 2 => { - this.location = try reader.readValue(Location); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.text) |text| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(text), text); - } - if (this.location) |location| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(location), location); - } - try writer.endMessage(); - } - }; - - pub const MessageMeta = struct { - /// resolve - resolve: ?[]const u8 = null, - - /// build - build: ?bool = null, - - pub fn decode(reader: anytype) anyerror!MessageMeta { - var this = std.mem.zeroes(MessageMeta); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.resolve = try reader.readValue([]const u8); - }, - 2 => { - this.build = try reader.readValue(bool); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.resolve) |resolve| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(resolve), resolve); - } - if (this.build) |build| { - try writer.writeFieldID(2); - try writer.writeInt(@as(u8, @intFromBool(build))); - } - try writer.endMessage(); - } - }; - - pub const Message = struct { - /// level - level: MessageLevel, - - /// data - data: MessageData, - - /// notes - notes: []const MessageData, - - /// on - on: MessageMeta, - - pub fn decode(reader: anytype) anyerror!Message { - var this = std.mem.zeroes(Message); - - this.level = try reader.readValue(MessageLevel); - this.data = try reader.readValue(MessageData); - this.notes = try reader.readArray(MessageData); - this.on = try reader.readValue(MessageMeta); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.level); - try writer.writeValue(@TypeOf(this.data), this.data); - try writer.writeArray(MessageData, this.notes); - try writer.writeValue(@TypeOf(this.on), this.on); - } - }; - - pub const Log = struct { - /// warnings - warnings: u32 = 0, - - /// errors - errors: u32 = 0, - - /// msgs - msgs: []const Message, - - pub fn decode(reader: anytype) anyerror!Log { - var this = std.mem.zeroes(Log); - - this.warnings = try reader.readValue(u32); - this.errors = try reader.readValue(u32); - this.msgs = try reader.readArray(Message); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.warnings); - try writer.writeInt(this.errors); - try writer.writeArray(Message, this.msgs); - } - }; - - pub const Reloader = enum(u8) { - _none, - /// disable - disable, - - /// live - live, - - /// fast_refresh - fast_refresh, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const WebsocketMessageKind = enum(u8) { - _none, - /// welcome - welcome, - - /// file_change_notification - file_change_notification, - - /// build_success - build_success, - - /// build_fail - build_fail, - - /// manifest_success - manifest_success, - - /// manifest_fail - manifest_fail, - - /// resolve_file - resolve_file, - - /// file_change_notification_with_hint - file_change_notification_with_hint, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const WebsocketCommandKind = enum(u8) { - _none, - /// build - build, - - /// manifest - manifest, - - /// build_with_file_path - build_with_file_path, - - _, - - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); - } - }; - - pub const WebsocketMessage = struct { - /// timestamp - timestamp: u32 = 0, - - /// kind - kind: WebsocketMessageKind, - - pub fn decode(reader: anytype) anyerror!WebsocketMessage { - var this = std.mem.zeroes(WebsocketMessage); - - this.timestamp = try reader.readValue(u32); - this.kind = try reader.readValue(WebsocketMessageKind); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.timestamp); - try writer.writeEnum(this.kind); - } - }; - - pub const WebsocketMessageWelcome = struct { - /// epoch - epoch: u32 = 0, - - /// javascriptReloader - javascript_reloader: Reloader, - - /// cwd - cwd: []const u8, - - pub fn decode(reader: anytype) anyerror!WebsocketMessageWelcome { - var this = std.mem.zeroes(WebsocketMessageWelcome); - - this.epoch = try reader.readValue(u32); - this.javascript_reloader = try reader.readValue(Reloader); - this.cwd = try reader.readValue([]const u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.epoch); - try writer.writeEnum(this.javascript_reloader); - try writer.writeValue(@TypeOf(this.cwd), this.cwd); - } - }; - - pub const WebsocketMessageFileChangeNotification = struct { - /// id - id: u32 = 0, - - /// loader - loader: Loader, - - pub fn decode(reader: anytype) anyerror!WebsocketMessageFileChangeNotification { - var this = std.mem.zeroes(WebsocketMessageFileChangeNotification); - - this.id = try reader.readValue(u32); - this.loader = try reader.readValue(Loader); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeEnum(this.loader); - } - }; - - pub const WebsocketCommand = struct { - /// kind - kind: WebsocketCommandKind, - - /// timestamp - timestamp: u32 = 0, - - pub fn decode(reader: anytype) anyerror!WebsocketCommand { - var this = std.mem.zeroes(WebsocketCommand); - - this.kind = try reader.readValue(WebsocketCommandKind); - this.timestamp = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeEnum(this.kind); - try writer.writeInt(this.timestamp); - } - }; - - pub const WebsocketCommandBuild = packed struct { - /// id - id: u32 = 0, - - pub fn decode(reader: anytype) anyerror!WebsocketCommandBuild { - var this = std.mem.zeroes(WebsocketCommandBuild); - - this.id = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - } - }; - - pub const WebsocketCommandManifest = packed struct { - /// id - id: u32 = 0, - - pub fn decode(reader: anytype) anyerror!WebsocketCommandManifest { - var this = std.mem.zeroes(WebsocketCommandManifest); - - this.id = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - } - }; - - pub const WebsocketMessageBuildSuccess = struct { - /// id - id: u32 = 0, - - /// from_timestamp - from_timestamp: u32 = 0, - - /// loader - loader: Loader, - - /// module_path - module_path: []const u8, - - /// blob_length - blob_length: u32 = 0, - - pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildSuccess { - var this = std.mem.zeroes(WebsocketMessageBuildSuccess); - - this.id = try reader.readValue(u32); - this.from_timestamp = try reader.readValue(u32); - this.loader = try reader.readValue(Loader); - this.module_path = try reader.readValue([]const u8); - this.blob_length = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeInt(this.from_timestamp); - try writer.writeEnum(this.loader); - try writer.writeValue(@TypeOf(this.module_path), this.module_path); - try writer.writeInt(this.blob_length); - } - }; - - pub const WebsocketMessageBuildFailure = struct { - /// id - id: u32 = 0, - - /// from_timestamp - from_timestamp: u32 = 0, - - /// loader - loader: Loader, - - /// module_path - module_path: []const u8, - - /// log - log: Log, - - pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildFailure { - var this = std.mem.zeroes(WebsocketMessageBuildFailure); - - this.id = try reader.readValue(u32); - this.from_timestamp = try reader.readValue(u32); - this.loader = try reader.readValue(Loader); - this.module_path = try reader.readValue([]const u8); - this.log = try reader.readValue(Log); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeInt(this.from_timestamp); - try writer.writeEnum(this.loader); - try writer.writeValue(@TypeOf(this.module_path), this.module_path); - try writer.writeValue(@TypeOf(this.log), this.log); - } - }; - - pub const WebsocketCommandBuildWithFilePath = struct { - /// id - id: u32 = 0, - - /// file_path - file_path: []const u8, - - pub fn decode(reader: anytype) anyerror!WebsocketCommandBuildWithFilePath { - var this = std.mem.zeroes(WebsocketCommandBuildWithFilePath); - - this.id = try reader.readValue(u32); - this.file_path = try reader.readValue([]const u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - try writer.writeValue(@TypeOf(this.file_path), this.file_path); - } - }; - - pub const WebsocketMessageResolveId = packed struct { - /// id - id: u32 = 0, - - pub fn decode(reader: anytype) anyerror!WebsocketMessageResolveId { - var this = std.mem.zeroes(WebsocketMessageResolveId); - - this.id = try reader.readValue(u32); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeInt(this.id); - } - }; - - pub const NpmRegistry = struct { - /// url - url: []const u8, - - /// username - username: []const u8, - - /// password - password: []const u8, - - /// token - token: []const u8, - - pub fn decode(reader: anytype) anyerror!NpmRegistry { - var this = std.mem.zeroes(NpmRegistry); - - this.url = try reader.readValue([]const u8); - this.username = try reader.readValue([]const u8); - this.password = try reader.readValue([]const u8); - this.token = try reader.readValue([]const u8); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeValue(@TypeOf(this.url), this.url); - try writer.writeValue(@TypeOf(this.username), this.username); - try writer.writeValue(@TypeOf(this.password), this.password); - try writer.writeValue(@TypeOf(this.token), this.token); - } - }; - - pub const NpmRegistryMap = struct { - /// scopes - scopes: []const []const u8, - - /// registries - registries: []const NpmRegistry, - - pub fn decode(reader: anytype) anyerror!NpmRegistryMap { - var this = std.mem.zeroes(NpmRegistryMap); - - this.scopes = try reader.readArray([]const u8); - this.registries = try reader.readArray(NpmRegistry); - return this; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - try writer.writeArray([]const u8, this.scopes); - try writer.writeArray(NpmRegistry, this.registries); - } - }; - - pub const BunInstall = struct { - /// default_registry - default_registry: ?NpmRegistry = null, - - /// scoped - scoped: ?NpmRegistryMap = null, - - /// lockfile_path - lockfile_path: ?[]const u8 = null, - - /// save_lockfile_path - save_lockfile_path: ?[]const u8 = null, - - /// cache_directory - cache_directory: ?[]const u8 = null, - - /// dry_run - dry_run: ?bool = null, - - /// force - force: ?bool = null, - - /// save_dev - save_dev: ?bool = null, - - /// save_optional - save_optional: ?bool = null, - - /// save_peer - save_peer: ?bool = null, - - /// save_lockfile - save_lockfile: ?bool = null, - - /// production - production: ?bool = null, - - /// save_yarn_lockfile - save_yarn_lockfile: ?bool = null, - - /// native_bin_links - native_bin_links: []const []const u8, - - /// disable_cache - disable_cache: ?bool = null, - - /// disable_manifest_cache - disable_manifest_cache: ?bool = null, - - /// global_dir - global_dir: ?[]const u8 = null, - - /// global_bin_dir - global_bin_dir: ?[]const u8 = null, - - /// frozen_lockfile - frozen_lockfile: ?bool = null, - - pub fn decode(reader: anytype) anyerror!BunInstall { - var this = std.mem.zeroes(BunInstall); - - while (true) { - switch (try reader.readByte()) { - 0 => { - return this; - }, - - 1 => { - this.default_registry = try reader.readValue(NpmRegistry); - }, - 2 => { - this.scoped = try reader.readValue(NpmRegistryMap); - }, - 3 => { - this.lockfile_path = try reader.readValue([]const u8); - }, - 4 => { - this.save_lockfile_path = try reader.readValue([]const u8); - }, - 5 => { - this.cache_directory = try reader.readValue([]const u8); - }, - 6 => { - this.dry_run = try reader.readValue(bool); - }, - 7 => { - this.force = try reader.readValue(bool); - }, - 8 => { - this.save_dev = try reader.readValue(bool); - }, - 9 => { - this.save_optional = try reader.readValue(bool); - }, - 10 => { - this.save_peer = try reader.readValue(bool); - }, - 11 => { - this.save_lockfile = try reader.readValue(bool); - }, - 12 => { - this.production = try reader.readValue(bool); - }, - 13 => { - this.save_yarn_lockfile = try reader.readValue(bool); - }, - 14 => { - this.native_bin_links = try reader.readArray([]const u8); - }, - 15 => { - this.disable_cache = try reader.readValue(bool); - }, - 16 => { - this.disable_manifest_cache = try reader.readValue(bool); - }, - 17 => { - this.global_dir = try reader.readValue([]const u8); - }, - 18 => { - this.global_bin_dir = try reader.readValue([]const u8); - }, - 19 => { - this.frozen_lockfile = try reader.readValue(bool); - }, - else => { - return error.InvalidMessage; - }, - } - } - unreachable; - } - - pub fn encode(this: *const @This(), writer: anytype) anyerror!void { - if (this.default_registry) |default_registry| { - try writer.writeFieldID(1); - try writer.writeValue(@TypeOf(default_registry), default_registry); - } - if (this.scoped) |scoped| { - try writer.writeFieldID(2); - try writer.writeValue(@TypeOf(scoped), scoped); - } - if (this.lockfile_path) |lockfile_path| { - try writer.writeFieldID(3); - try writer.writeValue(@TypeOf(lockfile_path), lockfile_path); - } - if (this.save_lockfile_path) |save_lockfile_path| { - try writer.writeFieldID(4); - try writer.writeValue(@TypeOf(save_lockfile_path), save_lockfile_path); - } - if (this.cache_directory) |cache_directory| { - try writer.writeFieldID(5); - try writer.writeValue(@TypeOf(cache_directory), cache_directory); - } - if (this.dry_run) |dry_run| { - try writer.writeFieldID(6); - try writer.writeInt(@as(u8, @intFromBool(dry_run))); - } - if (this.force) |force| { - try writer.writeFieldID(7); - try writer.writeInt(@as(u8, @intFromBool(force))); - } - if (this.save_dev) |save_dev| { - try writer.writeFieldID(8); - try writer.writeInt(@as(u8, @intFromBool(save_dev))); - } - if (this.save_optional) |save_optional| { - try writer.writeFieldID(9); - try writer.writeInt(@as(u8, @intFromBool(save_optional))); - } - if (this.save_peer) |save_peer| { - try writer.writeFieldID(10); - try writer.writeInt(@as(u8, @intFromBool(save_peer))); - } - if (this.save_lockfile) |save_lockfile| { - try writer.writeFieldID(11); - try writer.writeInt(@as(u8, @intFromBool(save_lockfile))); - } - if (this.production) |production| { - try writer.writeFieldID(12); - try writer.writeInt(@as(u8, @intFromBool(production))); - } - if (this.save_yarn_lockfile) |save_yarn_lockfile| { - try writer.writeFieldID(13); - try writer.writeInt(@as(u8, @intFromBool(save_yarn_lockfile))); - } - if (this.native_bin_links) |native_bin_links| { - try writer.writeFieldID(14); - try writer.writeArray([]const u8, native_bin_links); - } - if (this.disable_cache) |disable_cache| { - try writer.writeFieldID(15); - try writer.writeInt(@as(u8, @intFromBool(disable_cache))); - } - if (this.disable_manifest_cache) |disable_manifest_cache| { - try writer.writeFieldID(16); - try writer.writeInt(@as(u8, @intFromBool(disable_manifest_cache))); - } - if (this.global_dir) |global_dir| { - try writer.writeFieldID(17); - try writer.writeValue(@TypeOf(global_dir), global_dir); - } - if (this.global_bin_dir) |global_bin_dir| { - try writer.writeFieldID(18); - try writer.writeValue(@TypeOf(global_bin_dir), global_bin_dir); - } - if (this.frozen_lockfile) |frozen_lockfile| { - try writer.writeFieldID(19); - try writer.writeInt(@as(u8, @boolToInt(frozen_lockfile))); - } - try writer.endMessage(); - } - }; -}; diff --git a/src/api/demo/styles/Home.module.css b/src/api/demo/styles/Home.module.css deleted file mode 100644 index a2a622da0..000000000 --- a/src/api/demo/styles/Home.module.css +++ /dev/null @@ -1,122 +0,0 @@ -.container { - min-height: 100vh; - padding: 0 0.5rem; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - height: 100vh; -} - -.main { - padding: 5rem 0; - flex: 1; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; -} - -.footer { - width: 100%; - height: 100px; - border-top: 1px solid #eaeaea; - display: flex; - justify-content: center; - align-items: center; -} - -.footer a { - display: flex; - justify-content: center; - align-items: center; - flex-grow: 1; -} - -.title a { - color: #0070f3; - text-decoration: none; -} - -.title a:hover, -.title a:focus, -.title a:active { - text-decoration: underline; -} - -.title { - margin: 0; - line-height: 1.15; - font-size: 4rem; -} - -.title, -.description { - text-align: center; -} - -.description { - line-height: 1.5; - font-size: 1.5rem; -} - -.code { - background: #fafafa; - border-radius: 5px; - padding: 0.75rem; - font-size: 1.1rem; - font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, - Bitstream Vera Sans Mono, Courier New, monospace; -} - -.grid { - display: flex; - align-items: center; - justify-content: center; - flex-wrap: wrap; - max-width: 800px; - margin-top: 3rem; -} - -.card { - margin: 1rem; - padding: 1.5rem; - text-align: left; - color: inherit; - text-decoration: none; - border: 1px solid #eaeaea; - border-radius: 10px; - transition: color 0.15s ease, border-color 0.15s ease; - width: 45%; -} - -.card:hover, -.card:focus, -.card:active { - color: #0070f3; - border-color: #0070f3; -} - -.card h2 { - margin: 0 0 1rem 0; - font-size: 1.5rem; -} - -.card p { - margin: 0; - font-size: 1.25rem; - line-height: 1.5; -} - -.logo { - height: 1em; - margin-left: 0.5rem; -} - -@media (max-width: 600px) { - .grid { - width: 100%; - flex-direction: column; - } -} - diff --git a/src/api/demo/styles/globals.css b/src/api/demo/styles/globals.css deleted file mode 100644 index e5e2dcc23..000000000 --- a/src/api/demo/styles/globals.css +++ /dev/null @@ -1,16 +0,0 @@ -html, -body { - padding: 0; - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, - Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; -} - -a { - color: inherit; - text-decoration: none; -} - -* { - box-sizing: border-box; -} diff --git a/src/api/demo/tsconfig.json b/src/api/demo/tsconfig.json deleted file mode 100644 index 4fa2cd009..000000000 --- a/src/api/demo/tsconfig.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noImplicitAny": false, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "types": [ - "bun-types" - ], - "incremental": true - }, - "include": [ - "next-env.d.ts", - "**/*.ts", - "**/*.tsx" - ], - "exclude": [ - "node_modules" - ] -} \ No newline at end of file -- cgit v1.2.3 From e682ffb61c8cfd92d0a2787503a5e7ac611dff9e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 17:54:21 -0700 Subject: Update schema.zig --- src/api/schema.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/schema.zig b/src/api/schema.zig index 708d32ca0..2de80d42c 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -3053,7 +3053,7 @@ pub const Api = struct { } if (this.frozen_lockfile) |frozen_lockfile| { try writer.writeFieldID(19); - try writer.writeInt(@as(u8, @boolToInt(frozen_lockfile))); + try writer.writeInt(@as(u8, @intFromBool(frozen_lockfile))); } try writer.endMessage(); } -- cgit v1.2.3 From f2285a6d71eba0abc27bc449e9a50116447decf8 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 25 Jun 2023 17:54:55 -0700 Subject: Use bun.String in mkdir (#3404) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/node/node_fs.zig | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 1298c5d45..13d785e97 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -2368,7 +2368,7 @@ const Return = struct { pub const Lchown = void; pub const Link = void; pub const Lstat = Stats; - pub const Mkdir = string; + pub const Mkdir = bun.String; pub const Mkdtemp = JSC.ZigString; pub const Open = FileDescriptor; pub const WriteFile = void; @@ -2997,7 +2997,7 @@ pub const NodeFS = struct { .sync => { const path = args.path.sliceZ(&this.sync_error_buf); return switch (Syscall.mkdir(path, args.mode)) { - .result => Maybe(Return.Mkdir){ .result = "" }, + .result => Maybe(Return.Mkdir){ .result = bun.String.empty }, .err => |err| Maybe(Return.Mkdir){ .err = err }, }; }, @@ -3031,14 +3031,19 @@ pub const NodeFS = struct { }, .EXIST => { - return Option{ .result = "" }; + return Option{ .result = bun.String.empty }; }, // continue .NOENT => {}, } }, .result => { - return Option{ .result = args.path.slice() }; + return Option{ + .result = if (args.path == .slice_with_underlying_string) + args.path.slice_with_underlying_string.underlying + else + bun.String.create(args.path.slice()), + }; }, } @@ -3111,10 +3116,9 @@ pub const NodeFS = struct { switch (err.getErrno()) { // handle the race condition .EXIST => { - var display_path: []const u8 = ""; + var display_path = bun.String.empty; if (first_match != std.math.maxInt(u16)) { - // TODO: this leaks memory - display_path = bun.default_allocator.dupe(u8, display_path[0..first_match]) catch unreachable; + display_path = bun.String.create(working_mem[0..first_match]); } return Option{ .result = display_path }; }, @@ -3126,12 +3130,14 @@ pub const NodeFS = struct { } }, .result => { - var display_path = args.path.slice(); - if (first_match != std.math.maxInt(u16)) { - // TODO: this leaks memory - display_path = bun.default_allocator.dupe(u8, display_path[0..first_match]) catch unreachable; - } - return Option{ .result = display_path }; + return Option{ + .result = if (first_match != std.math.maxInt(u16)) + bun.String.create(working_mem[0..first_match]) + else if (args.path == .slice_with_underlying_string) + args.path.slice_with_underlying_string.underlying + else + bun.String.create(args.path.slice()), + }; }, } }, -- cgit v1.2.3 From 116bcf424564a5f38ddf5f99f34453c175526fdc Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 25 Jun 2023 18:49:16 -0700 Subject: Fixes #3334 (#3401) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/html_rewriter.zig | 97 +++++++++++++++++++++++------------ test/js/workerd/html-rewriter.test.js | 21 ++++++++ 2 files changed, 84 insertions(+), 34 deletions(-) diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig index d09c14e42..5e14d5503 100644 --- a/src/bun.js/api/html_rewriter.zig +++ b/src/bun.js/api/html_rewriter.zig @@ -106,7 +106,7 @@ pub const HTMLRewriter = struct { var selector = LOLHTML.HTMLSelector.parse(selector_slice) catch return throwLOLHTMLError(global); - var handler_ = ElementHandler.init(global, listener, exception); + var handler_ = ElementHandler.init(global, listener, exception) catch return .zero; if (exception.* != null) { selector.deinit(); return JSValue.fromRef(exception.*); @@ -154,7 +154,7 @@ pub const HTMLRewriter = struct { thisObject: JSC.C.JSObjectRef, exception: JSC.C.ExceptionRef, ) JSValue { - var handler_ = DocumentHandler.init(global, listener, exception); + var handler_ = DocumentHandler.init(global, listener, exception) catch return .zero; if (exception.* != null) { return JSValue.fromRef(exception.*); } @@ -446,10 +446,14 @@ pub const HTMLRewriter = struct { }, }; - result.body.init.headers = original.body.init.headers; result.body.init.method = original.body.init.method; result.body.init.status_code = original.body.init.status_code; + // https://github.com/oven-sh/bun/issues/3334 + if (original.body.init.headers) |headers| { + result.body.init.headers = headers.cloneThis(global); + } + result.url = bun.default_allocator.dupe(u8, original.url) catch unreachable; result.status_text = bun.default_allocator.dupe(u8, original.status_text) catch unreachable; @@ -723,29 +727,44 @@ const DocumentHandler = struct { "onEndCallback", ); - pub fn init(global: *JSGlobalObject, thisObject: JSValue, exception: JSC.C.ExceptionRef) DocumentHandler { + pub fn init(global: *JSGlobalObject, thisObject: JSValue, exception: JSC.C.ExceptionRef) !DocumentHandler { var handler = DocumentHandler{ .thisObject = thisObject, .global = global, }; - switch (thisObject.jsType()) { - .Object, .ProxyObject, .Cell, .FinalObject => {}, - else => |kind| { - JSC.throwInvalidArguments( - "Expected object but received {s}", - .{@as(string, @tagName(kind))}, - global, - exception, - ); - return undefined; - }, + if (!thisObject.isObject()) { + JSC.throwInvalidArguments( + "Expected object", + .{}, + global, + exception, + ); + return error.InvalidArguments; + } + + errdefer { + if (handler.onDocTypeCallback) |cb| { + cb.unprotect(); + } + + if (handler.onCommentCallback) |cb| { + cb.unprotect(); + } + + if (handler.onTextCallback) |cb| { + cb.unprotect(); + } + + if (handler.onEndCallback) |cb| { + cb.unprotect(); + } } if (thisObject.get(global, "doctype")) |val| { if (val.isUndefinedOrNull() or !val.isCell() or !val.isCallable(global.vm())) { JSC.throwInvalidArguments("doctype must be a function", .{}, global, exception); - return undefined; + return error.InvalidArguments; } JSC.C.JSValueProtect(global, val.asObjectRef()); handler.onDocTypeCallback = val; @@ -754,7 +773,7 @@ const DocumentHandler = struct { if (thisObject.get(global, "comments")) |val| { if (val.isUndefinedOrNull() or !val.isCell() or !val.isCallable(global.vm())) { JSC.throwInvalidArguments("comments must be a function", .{}, global, exception); - return undefined; + return error.InvalidArguments; } JSC.C.JSValueProtect(global, val.asObjectRef()); handler.onCommentCallback = val; @@ -763,7 +782,7 @@ const DocumentHandler = struct { if (thisObject.get(global, "text")) |val| { if (val.isUndefinedOrNull() or !val.isCell() or !val.isCallable(global.vm())) { JSC.throwInvalidArguments("text must be a function", .{}, global, exception); - return undefined; + return error.InvalidArguments; } JSC.C.JSValueProtect(global, val.asObjectRef()); handler.onTextCallback = val; @@ -772,7 +791,7 @@ const DocumentHandler = struct { if (thisObject.get(global, "end")) |val| { if (val.isUndefinedOrNull() or !val.isCell() or !val.isCallable(global.vm())) { JSC.throwInvalidArguments("end must be a function", .{}, global, exception); - return undefined; + return error.InvalidArguments; } JSC.C.JSValueProtect(global, val.asObjectRef()); handler.onEndCallback = val; @@ -863,29 +882,39 @@ const ElementHandler = struct { global: *JSGlobalObject, ctx: ?*HTMLRewriter.BufferOutputSink = null, - pub fn init(global: *JSGlobalObject, thisObject: JSValue, exception: JSC.C.ExceptionRef) ElementHandler { + pub fn init(global: *JSGlobalObject, thisObject: JSValue, exception: JSC.C.ExceptionRef) !ElementHandler { var handler = ElementHandler{ .thisObject = thisObject, .global = global, }; + errdefer { + if (handler.onCommentCallback) |cb| { + cb.unprotect(); + } - switch (thisObject.jsType()) { - .Object, .ProxyObject, .Cell, .FinalObject => {}, - else => |kind| { - JSC.throwInvalidArguments( - "Expected object but received {s}", - .{@as(string, @tagName(kind))}, - global, - exception, - ); - return undefined; - }, + if (handler.onElementCallback) |cb| { + cb.unprotect(); + } + + if (handler.onTextCallback) |cb| { + cb.unprotect(); + } + } + + if (!thisObject.isObject()) { + JSC.throwInvalidArguments( + "Expected object", + .{}, + global, + exception, + ); + return error.InvalidArguments; } if (thisObject.get(global, "element")) |val| { if (val.isUndefinedOrNull() or !val.isCell() or !val.isCallable(global.vm())) { JSC.throwInvalidArguments("element must be a function", .{}, global, exception); - return undefined; + return error.InvalidArguments; } JSC.C.JSValueProtect(global, val.asObjectRef()); handler.onElementCallback = val; @@ -894,7 +923,7 @@ const ElementHandler = struct { if (thisObject.get(global, "comments")) |val| { if (val.isUndefinedOrNull() or !val.isCell() or !val.isCallable(global.vm())) { JSC.throwInvalidArguments("comments must be a function", .{}, global, exception); - return undefined; + return error.InvalidArguments; } JSC.C.JSValueProtect(global, val.asObjectRef()); handler.onCommentCallback = val; @@ -903,7 +932,7 @@ const ElementHandler = struct { if (thisObject.get(global, "text")) |val| { if (val.isUndefinedOrNull() or !val.isCell() or !val.isCallable(global.vm())) { JSC.throwInvalidArguments("text must be a function", .{}, global, exception); - return undefined; + return error.InvalidArguments; } JSC.C.JSValueProtect(global, val.asObjectRef()); handler.onTextCallback = val; diff --git a/test/js/workerd/html-rewriter.test.js b/test/js/workerd/html-rewriter.test.js index b6131a09f..3f7b7493d 100644 --- a/test/js/workerd/html-rewriter.test.js +++ b/test/js/workerd/html-rewriter.test.js @@ -316,3 +316,24 @@ describe("HTMLRewriter", () => { expect(lastInTextNode).toBeBoolean(); }); }); + +// By not segfaulting, this test passes +it("#3334 regression", async () => { + for (let i = 0; i < 10; i++) { + const headers = new Headers({ + "content-type": "text/html", + }); + const response = new Response("
content
", { headers }); + + const result = await new HTMLRewriter() + .on("div", { + element(elem) { + elem.setInnerContent("new"); + }, + }) + .transform(response) + .text(); + expect(result).toEqual("
new
"); + } + Bun.gc(true); +}); -- cgit v1.2.3 From 76626ac54b83a5a9a24abee1bc35f13a2196504d Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 25 Jun 2023 19:48:56 -0700 Subject: Fix test failures in import.meta (#3403) * Fix test failures in import.meta * regenerate * Use bound functions for `import.meta.require` and `import.meta.require.resolve` and `Module.createRequire` --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/ImportMetaObject.cpp | 193 ++++++++++++++-------- src/bun.js/bindings/ImportMetaObject.h | 4 +- src/bun.js/bindings/ZigGlobalObject.cpp | 17 +- src/bun.js/bindings/ZigGlobalObject.h | 6 +- src/bun.js/modules/NodeModuleModule.cpp | 23 +-- src/js/builtins/ImportMetaObject.ts | 11 +- src/js/builtins/Module.ts | 4 +- src/js/out/WebCoreJSBuiltins.cpp | 238 ++++++++++++++-------------- src/js/out/modules/node/assert.js | 84 +++++----- src/js/out/modules/node/crypto.js | 8 +- src/js/out/modules/node/path.js | 2 +- src/js/out/modules/node/path.posix.js | 2 +- src/js/out/modules/node/stream.consumers.js | 2 +- src/js/out/modules/node/stream.js | 4 +- src/js/out/modules/node/util.js | 32 ++-- test/js/bun/resolve/import-meta.test.js | 11 +- 16 files changed, 350 insertions(+), 291 deletions(-) diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp index d201dafca..037305c81 100644 --- a/src/bun.js/bindings/ImportMetaObject.cpp +++ b/src/bun.js/bindings/ImportMetaObject.cpp @@ -59,6 +59,7 @@ static EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObject, return JSC::JSValue::encode(JSC::JSValue {}); } default: { + JSValue thisValue = callFrame->thisValue(); JSC::JSValue moduleName = callFrame->argument(0); auto doIt = [&](const WTF::String& fromStr) -> JSC::EncodedJSValue { @@ -130,7 +131,14 @@ 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)); + JSValue thisValue = callFrame->thisValue(); + WTF::String fromStr; + + if (thisValue.isString()) { + fromStr = thisValue.toWTFString(globalObject); + } + + return functionRequireResolve(globalObject, callFrame, fromStr); } JSC_DEFINE_CUSTOM_GETTER(jsRequireCacheGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) @@ -224,32 +232,49 @@ public: } }; -Structure* Zig::ImportMetaObject::createRequireFunctionStructure(VM& vm, JSGlobalObject* globalObject) +JSObject* Zig::ImportMetaObject::createRequireResolveFunctionUnbound(VM& vm, JSGlobalObject* globalObject) { - - return nullptr; + return ResolveFunction::create(globalObject); } -JSObject* Zig::ImportMetaObject::createRequireFunction(VM& vm, JSGlobalObject* lexicalGlobalObject, const WTF::String& pathString) +JSObject* Zig::ImportMetaObject::createRequireFunctionUnbound(VM& vm, JSGlobalObject* globalObject) { - auto* globalObject = lexicalGlobalObject; - JSFunction* requireFunction = JSFunction::create(vm, importMetaObjectRequireCodeGenerator(vm), lexicalGlobalObject); + auto& builtinNames = WebCore::builtinNames(vm); JSC::JSFunction* requireDotMainFunction = JSFunction::create( vm, moduleMainCodeGenerator(vm), globalObject->globalScope()); - requireFunction->putDirect( + auto* prototype = JSC::constructEmptyObject(globalObject, globalObject->functionPrototype()); + prototype->putDirect( vm, JSC::Identifier::fromString(vm, "main"_s), JSC::GetterSetter::create(vm, globalObject, requireDotMainFunction, JSValue()), PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | 0); + prototype->putDirect(vm, JSC::Identifier::fromString(vm, "extensions"_s), constructEmptyObject(globalObject), 0); + prototype->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "cache"_s), JSC::CustomGetterSetter::create(vm, Zig::jsRequireCacheGetter, Zig::jsRequireCacheSetter), 0); + return JSFunction::create(vm, importMetaObjectRequireCodeGenerator(vm), globalObject, JSFunction::createStructure(vm, globalObject, prototype)); +} + +JSObject* Zig::ImportMetaObject::createRequireFunction(VM& vm, JSGlobalObject* lexicalGlobalObject, const WTF::String& pathString) +{ + auto* globalObject = jsCast(lexicalGlobalObject); + auto& builtinNames = WebCore::builtinNames(vm); + + JSFunction* resolveFunctionUnbound = jsCast(globalObject->importMetaRequireResolveFunctionUnbound()); + JSFunction* requireFunctionUnbound = jsCast(globalObject->importMetaRequireFunctionUnbound()); + auto str = jsString(vm, pathString); + + JSFunction* requireFunction = JSC::JSBoundFunction::create(vm, + globalObject, requireFunctionUnbound, + str, ArgList(), 1, jsString(vm, String("require"_s))); - 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)); + JSFunction* resolveFunction = JSC::JSBoundFunction::create(vm, + globalObject, resolveFunctionUnbound, + str, ArgList(), 2, jsString(vm, String("resolve"_s))); + + requireFunction->putDirect(vm, builtinNames.resolvePublicName(), resolveFunction, PropertyAttribute::Function | 0); return requireFunction; } @@ -262,84 +287,107 @@ extern "C" EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObject* g JSC::VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - switch (callFrame->argumentCount()) { - case 0: { + JSValue thisValue = callFrame->thisValue(); + JSC::JSValue moduleName = callFrame->argument(0); + JSC::JSValue fromValue = callFrame->argument(1); - // not "requires" because "require" could be confusing - JSC::throwTypeError(globalObject, scope, "needs 1 argument (a string)"_s); + if (moduleName.isUndefinedOrNull()) { + JSC::throwTypeError(globalObject, scope, "expects a string"_s); scope.release(); return JSC::JSValue::encode(JSC::JSValue {}); } - default: { - JSC::JSValue moduleName = callFrame->argument(0); - if (moduleName.isUndefinedOrNull()) { - JSC::throwTypeError(globalObject, scope, "expects a string"_s); - scope.release(); - return JSC::JSValue::encode(JSC::JSValue {}); - } + JSC__JSValue from; + bool isESM = true; - JSC__JSValue from; - bool isESM = true; + if (callFrame->argumentCount() > 1) { - if (callFrame->argumentCount() > 1) { - JSC::JSValue fromValue = callFrame->argument(1); - - 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 (!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 {})); - } + 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 {})); - } - - if (fromValue.isString()) { - from = JSC::JSValue::encode(fromValue); } - } else { - JSC::JSObject* thisObject = JSC::jsDynamicCast(callFrame->thisValue()); - if (UNLIKELY(!thisObject)) { - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - JSC::throwTypeError(globalObject, scope, "import.meta.resolveSync must be bound to an import.meta object"_s); - return JSC::JSValue::encode(JSC::JSValue {}); - } - - auto clientData = WebCore::clientData(vm); - JSValue pathProperty = thisObject->getIfPropertyExists(globalObject, clientData->builtinNames().pathPublicName()); - - if (pathProperty && pathProperty.isString()) - from = JSC::JSValue::encode(pathProperty); + } else if (fromValue.isBoolean()) { + isESM = fromValue.toBoolean(globalObject); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + fromValue = JSC::jsUndefined(); } - auto result = Bun__resolveSync(globalObject, JSC::JSValue::encode(moduleName), from, isESM); + if (fromValue.isString()) { + from = JSC::JSValue::encode(fromValue); + } else if (thisValue.isString()) { + from = JSC::JSValue::encode(thisValue); + } - if (!JSC::JSValue::decode(result).isString()) { - JSC::throwException(globalObject, scope, JSC::JSValue::decode(result)); + } else if (thisValue.isString()) { + from = JSC::JSValue::encode(thisValue); + } else { + JSC::JSObject* thisObject = JSC::jsDynamicCast(thisValue); + if (UNLIKELY(!thisObject)) { + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + JSC::throwTypeError(globalObject, scope, "import.meta.resolveSync must be bound to an import.meta object"_s); return JSC::JSValue::encode(JSC::JSValue {}); } + auto clientData = WebCore::clientData(vm); + JSValue pathProperty = thisObject->getIfPropertyExists(globalObject, clientData->builtinNames().pathPublicName()); + + if (pathProperty && pathProperty.isString()) + from = JSC::JSValue::encode(pathProperty); + } + + auto result = Bun__resolveSync(globalObject, JSC::JSValue::encode(moduleName), from, isESM); + + if (!JSC::JSValue::decode(result).isString()) { + JSC::throwException(globalObject, scope, JSC::JSValue::decode(result)); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + scope.release(); + return result; +} + +extern "C" EncodedJSValue functionImportMeta__resolveSyncPrivate(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) +{ + JSC::VM& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + + JSC::JSValue moduleName = callFrame->argument(0); + JSValue from = callFrame->argument(1); + bool isESM = callFrame->argument(2).asBoolean(); + + if (moduleName.isUndefinedOrNull()) { + JSC::throwTypeError(globalObject, scope, "expected module name as a string"_s); scope.release(); - return result; + return JSC::JSValue::encode(JSC::JSValue {}); } + + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::JSValue {})); + + auto result = Bun__resolveSync(globalObject, JSC::JSValue::encode(moduleName), JSValue::encode(from), isESM); + + if (!JSC::JSValue::decode(result).isString()) { + JSC::throwException(globalObject, scope, JSC::JSValue::decode(result)); + return JSC::JSValue::encode(JSC::JSValue {}); } + + scope.release(); + return result; } JSC_DECLARE_HOST_FUNCTION(functionImportMeta__resolve); @@ -536,7 +584,16 @@ void ImportMetaObject::finishCreation(VM& vm) this->requireProperty.initLater([](const JSC::LazyProperty::Initializer& init) { ImportMetaObject* meta = jsCast(init.owner); - JSFunction* value = jsCast(ImportMetaObject::createRequireFunction(init.vm, meta->globalObject(), meta->url)); + + 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(); + } + + JSFunction* value = jsCast(ImportMetaObject::createRequireFunction(init.vm, meta->globalObject(), path.toString())); init.set(value); }); this->urlProperty.initLater([](const JSC::LazyProperty::Initializer& init) { diff --git a/src/bun.js/bindings/ImportMetaObject.h b/src/bun.js/bindings/ImportMetaObject.h index 2794ddbb6..6b5661039 100644 --- a/src/bun.js/bindings/ImportMetaObject.h +++ b/src/bun.js/bindings/ImportMetaObject.h @@ -9,6 +9,7 @@ #include "JSDOMWrapperCache.h" extern "C" JSC_DECLARE_HOST_FUNCTION(functionImportMeta__resolveSync); +extern "C" JSC_DECLARE_HOST_FUNCTION(functionImportMeta__resolveSyncPrivate); extern "C" JSC::EncodedJSValue Bun__resolve(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, JSC::EncodedJSValue from, bool is_esm); extern "C" JSC::EncodedJSValue Bun__resolveSync(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, JSC::EncodedJSValue from, bool is_esm); extern "C" JSC::EncodedJSValue Bun__resolveSyncWithSource(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, BunString* from, bool is_esm); @@ -27,7 +28,8 @@ public: static ImportMetaObject* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, const WTF::String& url); - static JSC::Structure* createRequireFunctionStructure(JSC::VM& vm, JSGlobalObject* globalObject); + static JSC::JSObject* createRequireFunctionUnbound(JSC::VM& vm, JSGlobalObject* globalObject); + static JSC::JSObject* createRequireResolveFunctionUnbound(JSC::VM& vm, JSGlobalObject* globalObject); static JSObject* createRequireFunction(VM& vm, JSGlobalObject* lexicalGlobalObject, const WTF::String& pathString); static ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSC::JSString* keyString); diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 401485f51..38d5fb1d6 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -2975,9 +2975,15 @@ void GlobalObject::finishCreation(VM& vm) init.set(structure); }); - m_importMetaRequireStructure.initLater( - [](const JSC::LazyProperty::Initializer& init) { - init.set(Zig::ImportMetaObject::createRequireFunctionStructure(init.vm, jsCast(init.owner))); + m_importMetaRequireFunctionUnbound.initLater( + [](const JSC::LazyProperty::Initializer& init) { + init.set( + Zig::ImportMetaObject::createRequireFunctionUnbound(init.vm, init.owner)); + }); + m_importMetaRequireResolveFunctionUnbound.initLater( + [](const JSC::LazyProperty::Initializer& init) { + init.set( + Zig::ImportMetaObject::createRequireResolveFunctionUnbound(init.vm, init.owner)); }); m_importMetaObjectStructure.initLater( @@ -3559,7 +3565,7 @@ void GlobalObject::addBuiltinGlobals(JSC::VM& vm) putDirectBuiltinFunction(vm, this, builtinNames.loadCJS2ESMPrivateName(), importMetaObjectLoadCJS2ESMCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); putDirectBuiltinFunction(vm, this, builtinNames.internalRequirePrivateName(), importMetaObjectInternalRequireCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); putDirectNativeFunction(vm, this, builtinNames.createUninitializedArrayBufferPrivateName(), 1, functionCreateUninitializedArrayBuffer, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function); - putDirectNativeFunction(vm, this, builtinNames.resolveSyncPrivateName(), 1, functionImportMeta__resolveSync, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function); + putDirectNativeFunction(vm, this, builtinNames.resolveSyncPrivateName(), 1, functionImportMeta__resolveSyncPrivate, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function); putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "process"_s), JSC::CustomGetterSetter::create(vm, property_lazyProcessGetter, property_lazyProcessSetter), JSC::PropertyAttribute::CustomAccessor | 0); @@ -4033,7 +4039,8 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) thisObject->m_emitReadableNextTickFunction.visit(visitor); thisObject->m_JSBufferSubclassStructure.visit(visitor); - thisObject->m_importMetaRequireStructure.visit(visitor); + thisObject->m_importMetaRequireFunctionUnbound.visit(visitor); + thisObject->m_importMetaRequireResolveFunctionUnbound.visit(visitor); thisObject->m_importMetaObjectStructure.visit(visitor); thisObject->m_dnsObject.visit(visitor); diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index daf0abc5b..a5b802ced 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -248,7 +248,8 @@ public: JSC::JSFunction* emitReadableNextTickFunction() { return m_emitReadableNextTickFunction.getInitializedOnMainThread(this); } - Structure* importMetaRequireStructure() { return m_importMetaRequireStructure.getInitializedOnMainThread(this); } + JSObject* importMetaRequireFunctionUnbound() { return m_importMetaRequireFunctionUnbound.getInitializedOnMainThread(this); } + JSObject* importMetaRequireResolveFunctionUnbound() { return m_importMetaRequireResolveFunctionUnbound.getInitializedOnMainThread(this); } JSObject* lazyRequireCacheObject() { return m_lazyRequireCacheObject.getInitializedOnMainThread(this); } @@ -494,7 +495,8 @@ private: LazyProperty m_commonJSModuleObjectStructure; LazyProperty m_commonJSFunctionArgumentsStructure; - LazyProperty m_importMetaRequireStructure; + LazyProperty m_importMetaRequireFunctionUnbound; + LazyProperty m_importMetaRequireResolveFunctionUnbound; LazyProperty m_importMetaObjectStructure; DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock); diff --git a/src/bun.js/modules/NodeModuleModule.cpp b/src/bun.js/modules/NodeModuleModule.cpp index f11277709..8b278ddd8 100644 --- a/src/bun.js/modules/NodeModuleModule.cpp +++ b/src/bun.js/modules/NodeModuleModule.cpp @@ -19,24 +19,12 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModuleCreateRequire, return JSC::JSValue::encode(JSC::jsUndefined()); } - auto str = callFrame->uncheckedArgument(0).toStringOrNull(globalObject); + auto val = callFrame->uncheckedArgument(0).toWTFString(globalObject); RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined())); - WTF::String val = str->value(globalObject); - auto *meta = Zig::ImportMetaObject::create(globalObject, str); auto clientData = WebCore::clientData(vm); - auto requireFunction = - Zig::ImportMetaObject::createRequireFunction(vm, globalObject, val); - auto nameStr = jsCast(requireFunction)->name(vm); - JSC::JSBoundFunction *boundRequireFunction = - JSC::JSBoundFunction::create(vm, globalObject, requireFunction, meta, - ArgList(), 0, jsString(vm, nameStr)); - boundRequireFunction->putDirect( - vm, clientData->builtinNames().resolvePublicName(), - requireFunction->getDirect( - vm, clientData->builtinNames().resolvePublicName()), - 0); - - RELEASE_AND_RETURN(scope, JSValue::encode(boundRequireFunction)); + RELEASE_AND_RETURN( + scope, JSValue::encode(Zig::ImportMetaObject::createRequireFunction( + vm, globalObject, val))); } JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModulePaths, (JSC::JSGlobalObject * globalObject, @@ -158,7 +146,8 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, jsFunctionNodeModulePaths, ImplementationVisibility::Public)); exportNames.append(JSC::Identifier::fromString(vm, "_cache"_s)); - exportValues.append(JSC::constructEmptyObject(globalObject)); + exportValues.append( + jsCast(globalObject)->lazyRequireCacheObject()); exportNames.append(JSC::Identifier::fromString(vm, "builtinModules"_s)); diff --git a/src/js/builtins/ImportMetaObject.ts b/src/js/builtins/ImportMetaObject.ts index 23b795735..934a37881 100644 --- a/src/js/builtins/ImportMetaObject.ts +++ b/src/js/builtins/ImportMetaObject.ts @@ -212,15 +212,8 @@ export function createRequireCache() { }); } -$sloppy; -export function require(this: ImportMetaObject, name) { - var from = this?.path ?? arguments.callee?.path; - - if (typeof name !== "string") { - throw new TypeError("require(name) must be a string"); - } - - return $internalRequire($resolveSync(name, from)); +export function require(this: string, name) { + return $internalRequire($resolveSync(name, $toString(this), false)); } $getter; diff --git a/src/js/builtins/Module.ts b/src/js/builtins/Module.ts index ebfc1c477..7ef108258 100644 --- a/src/js/builtins/Module.ts +++ b/src/js/builtins/Module.ts @@ -40,7 +40,7 @@ export function require(this: Module, id: string) { } let esm = Loader.registry.$get(id); - if (esm?.evaluated) { + if (esm?.evaluated && (esm.state ?? 0) >= $ModuleReady) { const mod = esm.module; const namespace = Loader.getModuleNamespaceObject(mod); const exports = @@ -75,7 +75,7 @@ export function require(this: Module, id: string) { esm = Loader.registry.$get(id); // If we can pull out a ModuleNamespaceObject, let's do it. - if (esm?.evaluated) { + if (esm?.evaluated && (esm.state ?? 0) >= $ModuleReady) { const namespace = Loader.getModuleNamespaceObject(esm!.module); return (mod.exports = // if they choose a module diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index f494e6635..d1250f0b9 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -108,7 +108,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeCons const JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateWritableStreamCodeLength = 278; static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (u,d,p,N,_,f){\"use strict\";@assert(typeof _===\"number\"&&!@isNaN(_)&&_>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,d,p,N,_,f),@createWritableStreamFromInternal(j)})\n"; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (u,p,d,N,_,f){\"use strict\";@assert(typeof _===\"number\"&&!@isNaN(_)&&_>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,p,d,N,_,f),@createWritableStreamFromInternal(j)})\n"; // createInternalWritableStreamFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -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 (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"; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,w){\"use strict\";const o={};if(f===@undefined)f={};if(w===@undefined)w={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const C=@extractSizeAlgorithm(w),E=@extractHighWaterMark(w,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(o,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(o,f,_,E,C),o})\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,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"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = "(function (n,h){\"use strict\";if(@isWritableStreamLocked(h))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(n,\"stream\",h),@putByIdDirectPrivate(h,\"writer\",n);const v=@newPromiseCapability(@Promise),B=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"readyPromise\",v),@putByIdDirectPrivate(n,\"closedPromise\",B);const _=@getByIdDirectPrivate(h,\"state\");if(_===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(h)||!@getByIdDirectPrivate(h,\"backpressure\"))v.@resolve.@call()}else if(_===\"erroring\")v.@reject.@call(@undefined,@getByIdDirectPrivate(h,\"storedError\")),@markPromiseAsHandled(v.@promise);else if(_===\"closed\")v.@resolve.@call(),B.@resolve.@call();else{@assert(_===\"errored\");const g=@getByIdDirectPrivate(h,\"storedError\");v.@reject.@call(@undefined,g),@markPromiseAsHandled(v.@promise),B.@reject.@call(@undefined,g),@markPromiseAsHandled(B.@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 (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"; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (c,h){\"use strict\";const f=@getByIdDirectPrivate(c,\"state\");if(f===\"closed\"||f===\"errored\")return @Promise.@resolve();const B=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(B!==@undefined)return B.promise.@promise;@assert(f===\"writable\"||f===\"erroring\");let j=!1;if(f===\"erroring\")j=!0,h=@undefined;const _=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:_,reason:h,wasAlreadyErroring:j}),!j)@writableStreamStartErroring(c,h);return _.@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 (_){\"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"; +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"; // 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 (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"; +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\"),i=@getByIdDirectPrivate(_,\"writeRequests\");for(var A=i.shift();A;A=i.shift())A.@reject.@call(@undefined,h);@putByIdDirectPrivate(_,\"writeRequests\",@createFIFO());const B=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(B===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}if(@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined),B.wasAlreadyErroring){B.promise.@reject.@call(@undefined,h),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}@getByIdDirectPrivate(p,\"abortSteps\").@call(@undefined,B.reason).@then(()=>{B.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)},(I)=>{B.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const c=@getByIdDirectPrivate(d,\"writer\");if(c!==@undefined)@getByIdDirectPrivate(c,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -220,7 +220,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength = 488; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,c){\"use strict\";const d=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(d!==@undefined),d.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(_,\"state\");@assert(n===\"writable\"||n===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,c)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,c){\"use strict\";const n=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(n!==@undefined),n.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const d=@getByIdDirectPrivate(_,\"state\");@assert(d===\"writable\"||d===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,c)})\n"; // writableStreamFinishInFlightWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -260,7 +260,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWrite const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength = 240; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"writeRequests\");@assert(@getByIdDirectPrivate(c,\"inFlightWriteRequest\")===@undefined),@assert(d.isNotEmpty());const h=d.shift();@putByIdDirectPrivate(c,\"inFlightWriteRequest\",h)})\n"; +const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (d){\"use strict\";const c=@getByIdDirectPrivate(d,\"writeRequests\");@assert(@getByIdDirectPrivate(d,\"inFlightWriteRequest\")===@undefined),@assert(c.isNotEmpty());const h=c.shift();@putByIdDirectPrivate(d,\"inFlightWriteRequest\",h)})\n"; // writableStreamRejectCloseAndClosedPromiseIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -268,7 +268,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAnd const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 516; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const h=@getByIdDirectPrivate(i,\"storedError\"),n=@getByIdDirectPrivate(i,\"closeRequest\");if(n!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),n.@reject.@call(@undefined,h),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(i,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,h),@markPromiseAsHandled(b.@promise)}})\n"; +const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (h){\"use strict\";@assert(@getByIdDirectPrivate(h,\"state\")===\"errored\");const i=@getByIdDirectPrivate(h,\"storedError\"),n=@getByIdDirectPrivate(h,\"closeRequest\");if(n!==@undefined)@assert(@getByIdDirectPrivate(h,\"inFlightCloseRequest\")===@undefined),n.@reject.@call(@undefined,i),@putByIdDirectPrivate(h,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(h,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,i),@markPromiseAsHandled(b.@promise)}})\n"; // writableStreamStartErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -276,7 +276,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamStartErroringC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamStartErroringCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamStartErroringCodeLength = 544; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamStartErroringCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamStartErroringCode = "(function (i,_){\"use strict\";@assert(@getByIdDirectPrivate(i,\"storedError\")===@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\");const d=@getByIdDirectPrivate(i,\"controller\");@assert(d!==@undefined),@putByIdDirectPrivate(i,\"state\",\"erroring\"),@putByIdDirectPrivate(i,\"storedError\",_);const h=@getByIdDirectPrivate(i,\"writer\");if(h!==@undefined)@writableStreamDefaultWriterEnsureReadyPromiseRejected(h,_);if(!@writableStreamHasOperationMarkedInFlight(i)&&@getByIdDirectPrivate(d,\"started\")===1)@writableStreamFinishErroring(i)})\n"; +const char* const s_writableStreamInternalsWritableStreamStartErroringCode = "(function (i,_){\"use strict\";@assert(@getByIdDirectPrivate(i,\"storedError\")===@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\");const h=@getByIdDirectPrivate(i,\"controller\");@assert(h!==@undefined),@putByIdDirectPrivate(i,\"state\",\"erroring\"),@putByIdDirectPrivate(i,\"storedError\",_);const d=@getByIdDirectPrivate(i,\"writer\");if(d!==@undefined)@writableStreamDefaultWriterEnsureReadyPromiseRejected(d,_);if(!@writableStreamHasOperationMarkedInFlight(i)&&@getByIdDirectPrivate(h,\"started\")===1)@writableStreamFinishErroring(i)})\n"; // writableStreamUpdateBackpressure const JSC::ConstructAbility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -324,7 +324,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 327; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (c,g){\"use strict\";let h=@getByIdDirectPrivate(c,\"readyPromise\"),n=h.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),n=h.@promise,@putByIdDirectPrivate(c,\"readyPromise\",h);h.@reject.@call(@undefined,g),@markPromiseAsHandled(n)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (c,n){\"use strict\";let g=@getByIdDirectPrivate(c,\"readyPromise\"),h=g.@promise;if((@getPromiseInternalField(h,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)g=@newPromiseCapability(@Promise),h=g.@promise,@putByIdDirectPrivate(c,\"readyPromise\",g);g.@reject.@call(@undefined,n),@markPromiseAsHandled(h)})\n"; // writableStreamDefaultWriterGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = 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 (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"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (d,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const _=@getByIdDirectPrivate(P,\"controller\");@assert(_!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(_,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const W=@getByIdDirectPrivate(P,\"state\");if(W===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||W===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||W===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(W===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(W===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(_,g,b),f})\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,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"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (_,U,d,f,B,j,v,q){\"use strict\";@assert(@isWritableStream(_)),@assert(@getByIdDirectPrivate(_,\"controller\")===@undefined),@putByIdDirectPrivate(U,\"stream\",_),@putByIdDirectPrivate(_,\"controller\",U),@resetQueue(@getByIdDirectPrivate(U,\"queue\")),@putByIdDirectPrivate(U,\"started\",-1),@putByIdDirectPrivate(U,\"startAlgorithm\",d),@putByIdDirectPrivate(U,\"strategySizeAlgorithm\",q),@putByIdDirectPrivate(U,\"strategyHWM\",v),@putByIdDirectPrivate(U,\"writeAlgorithm\",f),@putByIdDirectPrivate(U,\"closeAlgorithm\",B),@putByIdDirectPrivate(U,\"abortAlgorithm\",j);const P=@writableStreamDefaultControllerGetBackpressure(U);@writableStreamUpdateBackpressure(_,P),@writableStreamDefaultControllerStart(U)})\n"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -364,7 +364,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 647; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const _=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(_.@call()).@then(()=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(d,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,u)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (p){\"use strict\";if(@getByIdDirectPrivate(p,\"started\")!==-1)return;@putByIdDirectPrivate(p,\"started\",0);const i=@getByIdDirectPrivate(p,\"startAlgorithm\");@putByIdDirectPrivate(p,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(p,\"stream\");return @Promise.@resolve(i.@call()).@then(()=>{const _=@getByIdDirectPrivate(d,\"state\");@assert(_===\"writable\"||_===\"erroring\"),@putByIdDirectPrivate(p,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(p)},(_)=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(p,\"started\",1),@writableStreamDealWithRejection(d,_)})})\n"; // setUpWritableStreamDefaultControllerFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 573; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,q,P,_,j){\"use strict\";const p=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},f=()=>{return @Promise.@resolve()};if(\"start\"in P){const E=P[\"start\"];x=()=>@promiseInvokeOrNoopMethodNoCatch(q,E,[p])}if(\"write\"in P){const E=P[\"write\"];B=(F)=>@promiseInvokeOrNoopMethod(q,E,[F,p])}if(\"close\"in P){const E=P[\"close\"];C=()=>@promiseInvokeOrNoopMethod(q,E,[])}if(\"abort\"in P){const E=P[\"abort\"];f=(F)=>@promiseInvokeOrNoopMethod(q,E,[F])}@setUpWritableStreamDefaultController(v,p,x,B,C,f,_,j)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (P,j,B,v,f){\"use strict\";const _=new @WritableStreamDefaultController;let C=()=>{},p=()=>{return @Promise.@resolve()},E=()=>{return @Promise.@resolve()},q=()=>{return @Promise.@resolve()};if(\"start\"in B){const F=B[\"start\"];C=()=>@promiseInvokeOrNoopMethodNoCatch(j,F,[_])}if(\"write\"in B){const F=B[\"write\"];p=(x)=>@promiseInvokeOrNoopMethod(j,F,[x,_])}if(\"close\"in B){const F=B[\"close\"];E=()=>@promiseInvokeOrNoopMethod(j,F,[])}if(\"abort\"in B){const F=B[\"abort\"];q=(x)=>@promiseInvokeOrNoopMethod(j,F,[x])}@setUpWritableStreamDefaultController(P,_,C,p,E,q,v,f)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -380,7 +380,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength = 582; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"stream\");if(@getByIdDirectPrivate(_,\"started\")!==1)return;if(@assert(d!==@undefined),@getByIdDirectPrivate(d,\"inFlightWriteRequest\")!==@undefined)return;const f=@getByIdDirectPrivate(d,\"state\");if(@assert(f!==\"closed\"||f!==\"errored\"),f===\"erroring\"){@writableStreamFinishErroring(d);return}const h=@getByIdDirectPrivate(_,\"queue\");if(h.content\?.isEmpty()\?\?!1)return;const i=@peekQueueValue(h);if(i===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(_);else @writableStreamDefaultControllerProcessWrite(_,i)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (_){\"use strict\";const i=@getByIdDirectPrivate(_,\"stream\");if(@getByIdDirectPrivate(_,\"started\")!==1)return;if(@assert(i!==@undefined),@getByIdDirectPrivate(i,\"inFlightWriteRequest\")!==@undefined)return;const d=@getByIdDirectPrivate(i,\"state\");if(@assert(d!==\"closed\"||d!==\"errored\"),d===\"erroring\"){@writableStreamFinishErroring(i);return}const f=@getByIdDirectPrivate(_,\"queue\");if(f.content\?.isEmpty()\?\?!1)return;const h=@peekQueueValue(f);if(h===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(_);else @writableStreamDefaultControllerProcessWrite(_,h)})\n"; // isCloseSentinel const JSC::ConstructAbility s_writableStreamInternalsIsCloseSentinelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -436,7 +436,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength = 181; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode = "(function (a,i){\"use strict\";try{return @getByIdDirectPrivate(a,\"strategySizeAlgorithm\").@call(@undefined,i)}catch(d){return @writableStreamDefaultControllerErrorIfNeeded(a,d),1}})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode = "(function (a,d){\"use strict\";try{return @getByIdDirectPrivate(a,\"strategySizeAlgorithm\").@call(@undefined,d)}catch(i){return @writableStreamDefaultControllerErrorIfNeeded(a,i),1}})\n"; // writableStreamDefaultControllerGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructAbility = 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 (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"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = "(function (i,q){\"use strict\";const d=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(d),@getByIdDirectPrivate(i,\"writeAlgorithm\").@call(@undefined,q).@then(()=>{@writableStreamFinishInFlightWrite(d);const M=@getByIdDirectPrivate(d,\"state\");if(@assert(M===\"writable\"||M===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),!@writableStreamCloseQueuedOrInFlight(d)&&M===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(i);@writableStreamUpdateBackpressure(d,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(M)=>{if(@getByIdDirectPrivate(d,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(i);@writableStreamFinishInFlightWriteWithError(d,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 (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"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = "(function (d,D,y){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),D,y);const B=@getByIdDirectPrivate(d,\"stream\"),_=@getByIdDirectPrivate(B,\"state\");if(!@writableStreamCloseQueuedOrInFlight(B)&&_===\"writable\"){const I=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(B,I)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)}catch(B){@writableStreamDefaultControllerErrorIfNeeded(d,B)}})\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 (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"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (I,G,v,_,E,B,D){\"use strict\";if(_===@undefined)_=1;if(E===@undefined)E=()=>1;if(B===@undefined)B=0;if(D===@undefined)D=()=>1;@assert(_>=0),@assert(B>=0);const q={};@putByIdDirectPrivate(q,\"TransformStream\",!0);const F=new @TransformStream(q),j=@newPromiseCapability(@Promise);@initializeTransformStream(F,j.@promise,_,E,B,D);const x=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(F,x,G,v),I().@then(()=>{j.@resolve.@call()},(c)=>{j.@reject.@call(@undefined,c)}),F})\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 (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"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (B,T,E,j,F,f){\"use strict\";const G=()=>{return T},q=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(B,N)},I=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(B,N)},v=()=>{return @transformStreamDefaultSinkCloseAlgorithm(B)},J=@createWritableStream(G,q,v,I,E,j),x=()=>{return @transformStreamDefaultSourcePullAlgorithm(B)},K=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(B,N),@Promise.@resolve()},C={};@putByIdDirectPrivate(C,\"start\",G),@putByIdDirectPrivate(C,\"pull\",x),@putByIdDirectPrivate(C,\"cancel\",K);const L={};@putByIdDirectPrivate(L,\"size\",f),@putByIdDirectPrivate(L,\"highWaterMark\",F);const D=new @ReadableStream(C,L);@putByIdDirectPrivate(B,\"writable\",J),@putByIdDirectPrivate(B,\"internalWritable\",@getInternalWritableStream(J)),@putByIdDirectPrivate(B,\"readable\",D),@putByIdDirectPrivate(B,\"backpressure\",@undefined),@putByIdDirectPrivate(B,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(B,!0),@putByIdDirectPrivate(B,\"controller\",@undefined)})\n"; // transformStreamError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -518,7 +518,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeCon const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorCodeLength = 222; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (f,i){\"use strict\";const n=@getByIdDirectPrivate(f,\"readable\"),_=@getByIdDirectPrivate(n,\"readableStreamController\");@readableStreamDefaultControllerError(_,i),@transformStreamErrorWritableAndUnblockWrite(f,i)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (_,i){\"use strict\";const n=@getByIdDirectPrivate(_,\"readable\"),f=@getByIdDirectPrivate(n,\"readableStreamController\");@readableStreamDefaultControllerError(f,i),@transformStreamErrorWritableAndUnblockWrite(_,i)})\n"; // transformStreamErrorWritableAndUnblockWrite const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -526,7 +526,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritabl const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength = 339; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (_,n){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(_,\"controller\"));const o=@getByIdDirectPrivate(_,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(o,\"controller\"),n),@getByIdDirectPrivate(_,\"backpressure\"))@transformStreamSetBackpressure(_,!1)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (n,_){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(n,\"controller\"));const o=@getByIdDirectPrivate(n,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(o,\"controller\"),_),@getByIdDirectPrivate(n,\"backpressure\"))@transformStreamSetBackpressure(n,!1)})\n"; // transformStreamSetBackpressure const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility = 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,_,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"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode = "(function (d,b,_,P){\"use strict\";@assert(@isTransformStream(d)),@assert(@getByIdDirectPrivate(d,\"controller\")===@undefined),@putByIdDirectPrivate(b,\"stream\",d),@putByIdDirectPrivate(d,\"controller\",b),@putByIdDirectPrivate(b,\"transformAlgorithm\",_),@putByIdDirectPrivate(b,\"flushAlgorithm\",P)})\n"; // setUpTransformStreamDefaultControllerFromTransformer const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 449; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,d,p){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in p)b=(q)=>{return @promiseInvokeOrNoopMethod(d,p[\"transform\"],[q,v])};if(\"flush\"in p)j=()=>{return @promiseInvokeOrNoopMethod(d,p[\"flush\"],[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,j,d){\"use strict\";const q=new @TransformStreamDefaultController;let p=(b)=>{try{@transformStreamDefaultControllerEnqueue(q,b)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},v=()=>{return @Promise.@resolve()};if(\"transform\"in d)p=(b)=>{return @promiseInvokeOrNoopMethod(j,d[\"transform\"],[b,q])};if(\"flush\"in d)v=()=>{return @promiseInvokeOrNoopMethod(j,d[\"flush\"],[q])};@setUpTransformStreamDefaultController(_,q,p,v)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = 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){\"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"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (W,i){\"use strict\";const f=@getByIdDirectPrivate(W,\"stream\"),_=@getByIdDirectPrivate(f,\"readable\"),j=@getByIdDirectPrivate(_,\"readableStreamController\");if(@assert(j!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(j))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(j,i)}catch(S){throw @transformStreamErrorWritableAndUnblockWrite(f,S),@getByIdDirectPrivate(_,\"storedError\")}const g=!@readableStreamDefaultControllerShouldCallPull(j);if(g!==@getByIdDirectPrivate(f,\"backpressure\"))@assert(g),@transformStreamSetBackpressure(f,!0)})\n"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,g){\"use strict\";const d=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,g).@then(()=>{d.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),d.@reject.@call(@undefined,j)}),d.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -590,7 +590,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 367; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\"),f=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(f,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(_,u)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const f=@getByIdDirectPrivate(i,\"stream\"),k=@getByIdDirectPrivate(f,\"readable\"),u=@getByIdDirectPrivate(k,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(u))@readableStreamDefaultControllerClose(u);const _=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(f,_)})\n"; // transformStreamDefaultSinkWriteAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = 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 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"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode = "(function (u){\"use strict\";const j=@getByIdDirectPrivate(u,\"readable\"),f=@getByIdDirectPrivate(u,\"controller\"),I=@getByIdDirectPrivate(j,\"readableStreamController\"),q=@getByIdDirectPrivate(f,\"flushAlgorithm\");@assert(q!==@undefined);const _=@getByIdDirectPrivate(f,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(f);const k=@newPromiseCapability(@Promise);return _.@then(()=>{if(@getByIdDirectPrivate(j,\"state\")===@streamErrored){k.@reject.@call(@undefined,@getByIdDirectPrivate(j,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(I))@readableStreamDefaultControllerClose(I);k.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(f,\"stream\"),v),k.@reject.@call(@undefined,@getByIdDirectPrivate(j,\"storedError\"))}),k.@promise})\n"; // transformStreamDefaultSourcePullAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -640,7 +640,7 @@ const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsBindingCodeLength = 473; static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsBindingCode = "(function (l){\"use strict\";if(l!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var r=globalThis.Symbol.for(\"process.bindings.constants\"),I=globalThis[r];if(!I){const{constants:d}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");I={fs:d,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[r]=I}return I})\n"; +const char* const s_processObjectInternalsBindingCode = "(function (I){\"use strict\";if(I!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var d=globalThis.Symbol.for(\"process.bindings.constants\"),r=globalThis[d];if(!r){const{constants:l}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");r={fs:l,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[d]=r}return r})\n"; // getStdioWriteStream const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (j,H){\"use strict\";var J={path:\"node:process\",require:H},G=(N)=>J.require(N);function K(N){var{Duplex:O,eos:Q,destroy:U}=G(\"node:stream\"),V=class X extends O{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(N)}get fd(){return N}constructor(Z){super({readable:!0,writable:!0});this.#G=`/dev/fd/${Z}`}#N(Z){const Y=this.#H;if(this.#H=null,Y)Y(Z);else if(Z)this.destroy(Z);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Z,Y){if(!Z&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Z=new P}if(this.#J=null,this.#K=null,this.#H===null)Y(Z);else{if(this.#H=Y,this.#$)U(this.#$,Z);if(this.#B)U(this.#B,Z)}}_write(Z,Y,P){if(!this.#$){var{createWriteStream:A}=G(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),Q(T,(x)=>{if(this.#z=!1,x)U(T,x);this.#N(x)})}if(T.write(Z,Y))P();else this.#J=P}_final(Z){this.#$&&this.#$.end(),this.#K=Z}#O(){var{createReadStream:Z}=G(\"node:fs\"),Y=this.#B=Z(this.#G);return Y.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),Y.on(\"end\",()=>{this.push(null)}),Q(Y,(P)=>{if(this.#j=!1,P)U(Y,P);this.#N(P)}),Y}_read(){var Z=this.#B;if(!Z)Z=this.#O();while(!0){const Y=Z.read();if(Y===null||!this.push(Y))return}}};return new V(N)}var{EventEmitter:z}=G(\"node:events\");function L(N){if(!N)return!0;var O=N.toLowerCase();return O===\"utf8\"||O===\"utf-8\"||O===\"buffer\"||O===\"binary\"}var M,B=class N extends z{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(O){if(this.#B||!L(O))return this.#J(),this.#B.setDefaultEncoding(O)}#G(){switch(this.#$){case 1:{var O=@Bun.stdout.writer({highWaterMark:0});return O.unref(),O}case 2:{var O=@Bun.stderr.writer({highWaterMark:0});return O.unref(),O}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(O){super();this.#$=O}get fd(){return this.#$}get isTTY(){return this.#z\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(O,Q,U){return(M\?\?=G(\"readline\")).cursorTo(this,O,Q,U)}moveCursor(O,Q,U){return(M\?\?=G(\"readline\")).moveCursor(this,O,Q,U)}clearLine(O,Q){return(M\?\?=G(\"readline\")).clearLine(this,O,Q)}clearScreenDown(O){return(M\?\?=G(\"readline\")).clearScreenDown(this,O)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(O,Q){if(O===\"close\"||O===\"finish\")return this.#J(),this.#B.on(O,Q);if(O===\"drain\")return super.on(\"drain\",Q);if(O===\"error\")return super.on(\"error\",Q);return super.on(O,Q)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(O){return this.#J(),this.#B.pipe(O)}unpipe(O){return this.#J(),this.#B.unpipe(O)}#J(){if(this.#B)return;this.#B=K(this.#$);const O=this.eventNames();for(let Q of O)this.#B.on(Q,(...U)=>{this.emit(Q,...U)})}#K(O){var Q=this.#H();const U=Q.write(O);this.bytesWritten+=U;const V=Q.flush(!1);return!!(U||V)}#L(O,Q){if(!L(Q))return this.#J(),this.#B.write(O,Q);return this.#K(O)}#M(O,Q){if(Q)this.emit(\"error\",Q);try{O(Q\?Q:null)}catch(U){this.emit(\"error\",U)}}#N(O,Q,U){if(!L(Q))return this.#J(),this.#B.write(O,Q,U);var V=this.#H();const X=V.write(O),Z=V.flush(!0);if(Z\?.then)return Z.then(()=>{this.#M(U),this.emit(\"drain\")},(Y)=>this.#M(U,Y)),!1;return queueMicrotask(()=>{this.#M(U)}),!!(X||Z)}write(O,Q,U){const V=this._write(O,Q,U);if(V)this.emit(\"drain\");return V}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(O,Q,U){var V=this.#B;if(V)return V.write(O,Q,U);switch(arguments.length){case 0:{var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}case 1:return this.#K(O);case 2:if(typeof Q===\"function\")return this.#N(O,\"\",Q);else if(typeof Q===\"string\")return this.#L(O,Q);default:{if(typeof Q!==\"undefined\"&&typeof Q!==\"string\"||typeof U!==\"undefined\"&&typeof U!==\"function\"){var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}if(typeof U===\"undefined\")return this.#L(O,Q);return this.#N(O,Q,U)}}}destroy(){return this}end(){return this}};return new B(j)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (U,G){\"use strict\";var H={path:\"node:process\",require:G},J=(L)=>H.require(L);function K(L){var{Duplex:Q,eos:M,destroy:j}=J(\"node:stream\"),N=class Y extends Q{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=J(\"node:tty\").isatty(L)}get fd(){return L}constructor(O){super({readable:!0,writable:!0});this.#G=`/dev/fd/${O}`}#N(O){const z=this.#H;if(this.#H=null,z)z(O);else if(O)this.destroy(O);else if(!this.#j&&!this.#z)this.destroy()}_destroy(O,z){if(!O&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};O=new P}if(this.#J=null,this.#K=null,this.#H===null)z(O);else{if(this.#H=z,this.#$)j(this.#$,O);if(this.#B)j(this.#B,O)}}_write(O,z,P){if(!this.#$){var{createWriteStream:A}=J(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),M(T,(x)=>{if(this.#z=!1,x)j(T,x);this.#N(x)})}if(T.write(O,z))P();else this.#J=P}_final(O){this.#$&&this.#$.end(),this.#K=O}#O(){var{createReadStream:O}=J(\"node:fs\"),z=this.#B=O(this.#G);return z.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),z.on(\"end\",()=>{this.push(null)}),M(z,(P)=>{if(this.#j=!1,P)j(z,P);this.#N(P)}),z}_read(){var O=this.#B;if(!O)O=this.#O();while(!0){const z=O.read();if(z===null||!this.push(z))return}}};return new N(L)}var{EventEmitter:V}=J(\"node:events\");function X(L){if(!L)return!0;var Q=L.toLowerCase();return Q===\"utf8\"||Q===\"utf-8\"||Q===\"buffer\"||Q===\"binary\"}var Z,B=class L extends V{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(Q){if(this.#B||!X(Q))return this.#J(),this.#B.setDefaultEncoding(Q)}#G(){switch(this.#$){case 1:{var Q=@Bun.stdout.writer({highWaterMark:0});return Q.unref(),Q}case 2:{var Q=@Bun.stderr.writer({highWaterMark:0});return Q.unref(),Q}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(Q){super();this.#$=Q}get fd(){return this.#$}get isTTY(){return this.#z\?\?=J(\"node:tty\").isatty(this.#$)}cursorTo(Q,M,j){return(Z\?\?=J(\"readline\")).cursorTo(this,Q,M,j)}moveCursor(Q,M,j){return(Z\?\?=J(\"readline\")).moveCursor(this,Q,M,j)}clearLine(Q,M){return(Z\?\?=J(\"readline\")).clearLine(this,Q,M)}clearScreenDown(Q){return(Z\?\?=J(\"readline\")).clearScreenDown(this,Q)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(Q,M){if(Q===\"close\"||Q===\"finish\")return this.#J(),this.#B.on(Q,M);if(Q===\"drain\")return super.on(\"drain\",M);if(Q===\"error\")return super.on(\"error\",M);return super.on(Q,M)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(Q){return this.#J(),this.#B.pipe(Q)}unpipe(Q){return this.#J(),this.#B.unpipe(Q)}#J(){if(this.#B)return;this.#B=K(this.#$);const Q=this.eventNames();for(let M of Q)this.#B.on(M,(...j)=>{this.emit(M,...j)})}#K(Q){var M=this.#H();const j=M.write(Q);this.bytesWritten+=j;const N=M.flush(!1);return!!(j||N)}#L(Q,M){if(!X(M))return this.#J(),this.#B.write(Q,M);return this.#K(Q)}#M(Q,M){if(M)this.emit(\"error\",M);try{Q(M\?M:null)}catch(j){this.emit(\"error\",j)}}#N(Q,M,j){if(!X(M))return this.#J(),this.#B.write(Q,M,j);var N=this.#H();const Y=N.write(Q),O=N.flush(!0);if(O\?.then)return O.then(()=>{this.#M(j),this.emit(\"drain\")},(z)=>this.#M(j,z)),!1;return queueMicrotask(()=>{this.#M(j)}),!!(Y||O)}write(Q,M,j){const N=this._write(Q,M,j);if(N)this.emit(\"drain\");return N}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(Q,M,j){var N=this.#B;if(N)return N.write(Q,M,j);switch(arguments.length){case 0:{var Y=new Error(\"Invalid arguments\");throw Y.code=\"ERR_INVALID_ARG_TYPE\",Y}case 1:return this.#K(Q);case 2:if(typeof M===\"function\")return this.#N(Q,\"\",M);else if(typeof M===\"string\")return this.#L(Q,M);default:{if(typeof M!==\"undefined\"&&typeof M!==\"string\"||typeof j!==\"undefined\"&&typeof j!==\"function\"){var Y=new Error(\"Invalid arguments\");throw Y.code=\"ERR_INVALID_ARG_TYPE\",Y}if(typeof j===\"undefined\")return this.#L(Q,M);return this.#N(Q,M,j)}}}destroy(){return this}end(){return this}};return new B(U)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = 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,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"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (Y,j,H){\"use strict\";var I={path:\"node:process\",require:j},J=(N)=>I.require(N),{Duplex:K,eos:z,destroy:L}=J(\"node:stream\"),M=class N extends K{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return J(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(P){const Q=this.#J;if(this.#J=null,Q)Q(P);else if(P)this.destroy(P);else if(!this.#z&&!this.#H)this.destroy()}_destroy(P,Q){if(!P&&this.#J!==null){var G=class T extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};P=new G}if(this.#J===null)Q(P);else if(this.#J=Q,this.#j)L(this.#j,P)}setRawMode(P){}on(P,Q){if(P===\"readable\")this.ref(),this.#G=!0;return super.on(P,Q)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#Y\?\?=H.stdin.stream().getReader(),this.#$\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#$)clearInterval(this.#$),this.#$=null}async#M(){try{var P,Q;const G=this.#Y.readMany();if(!G\?.then)({done:P,value:Q}=G);else({done:P,value:Q}=await G);if(!P){this.push(Q[0]);const T=Q.length;for(let U=1;U{if(this.#I){const G=this.#I;this.#I=null,G()}}),Q.on(\"drain\",()=>{if(this.#K){const G=this.#K;this.#K=null,G()}}),z(Q,(G)=>{if(this.#H=!1,G)L(Q,G);this.#L(G)}),Q}_write(P,Q,G){var T=this.#j;if(!T)T=this.#N();if(T.write(P,Q))G();else this.#K=G}_final(P){this.#j.end(),this.#I=(...Q)=>P(...Q)}};return new M})\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 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"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let x=arguments[1],u=arguments[2];if(_===@undefined)_=null;if(u===@undefined)u={};if(x===@undefined)x={};let B={};if(_!==null){if(\"start\"in _){if(B[\"start\"]=_[\"start\"],typeof B[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(B[\"transform\"]=_[\"transform\"],typeof B[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(B[\"flush\"]=_[\"flush\"],typeof B[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const F=@extractHighWaterMark(u,0),j=@extractSizeAlgorithm(u),I=@extractHighWaterMark(x,1),q=@extractSizeAlgorithm(x),E=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,E.@promise,I,q,F,j),@setUpTransformStreamDefaultControllerFromTransformer(this,_,B),(\"start\"in B)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,B[\"start\"],[G]))().@then(()=>{E.@resolve.@call()},(v)=>{E.@reject.@call(@undefined,v)})}else E.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -714,9 +714,9 @@ const char* const s_moduleMainCode = "(function (){\"use strict\";return @requir 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; +const int s_moduleRequireCodeLength = 927; 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"; +const char* const s_moduleRequireCode = "(function (l){\"use strict\";const M=@requireMap.@get(l)||@requireMap.@get(l=@resolveSync(l,this.path,!1));if(M)return @evaluateCommonJSModule(M),M.exports;if(l.endsWith(\".json\")||l.endsWith(\".toml\")||l.endsWith(\".node\"))return @internalRequire(l);let y=@Loader.registry.@get(l);if(y\?.evaluated&&(y.state\?\?0)>=@ModuleReady){const _=y.module,S=@Loader.getModuleNamespaceObject(_),t=S\?.[@commonJSSymbol]===0||S\?.default\?.[@commonJSSymbol]===0\?S.default:S;return @requireMap.@set(l,@createCommonJSModule(l,t,!0)),t}const h=@createCommonJSModule(l,{},!1);@requireMap.@set(l,h);var L=this.@require(l,h);if(L===-1){try{L=@requireESM(l)}catch(_){throw @requireMap.@delete(l),_}if(y=@Loader.registry.@get(l),y\?.evaluated&&(y.state\?\?0)>=@ModuleReady){const _=@Loader.getModuleNamespaceObject(y.module);return h.exports=_\?.[@commonJSSymbol]===0||_\?.default\?.[@commonJSSymbol]===0\?_.default:_}}return @evaluateCommonJSModule(h),h.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return u.getInt8(d);case 2:return u.getInt16(d,!0);case 3:{const _=u.getUint16(d,!0)+u.getUint8(d+2)*65536;return _|(_&8388608)*510}case 4:return u.getInt32(d,!0);case 5:{const _=u.getUint8(d+4);return(_|(_&128)*33554430)*4294967296+u.getUint32(d,!0)}case 6:{const _=u.getUint16(d+4,!0);return(_|(_&32768)*131070)*4294967296+u.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -982,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 (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!1),c+4})\n"; +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"; // writeUInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1006,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 (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"; +const char* const s_jsBufferPrototypeWriteIntLECode = "(function (d,j,r){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:{c.setInt8(j,d);break}case 2:{c.setInt16(j,d,!0);break}case 3:{c.setUint16(j,d&65535,!0),c.setInt8(j+2,Math.floor(d*0.0000152587890625));break}case 4:{c.setInt32(j,d,!0);break}case 5:{c.setUint32(j,d|0,!0),c.setInt8(j+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{c.setUint32(j,d|0,!0),c.setInt16(j+4,Math.floor(d*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return j+r})\n"; // writeIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1030,7 +1030,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntBECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (d,r,p){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:{_.setUint8(r,d);break}case 2:{_.setUint16(r,d,!1);break}case 3:{_.setUint16(r+1,d&65535,!1),_.setUint8(r,Math.floor(d*0.0000152587890625));break}case 4:{_.setUint32(r,d,!1);break}case 5:{_.setUint32(r+1,d|0,!1),_.setUint8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{_.setUint32(r+2,d|0,!1),_.setUint16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+p})\n"; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (r,p,_){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{d.setUint8(p,r);break}case 2:{d.setUint16(p,r,!1);break}case 3:{d.setUint16(p+1,r&65535,!1),d.setUint8(p,Math.floor(r*0.0000152587890625));break}case 4:{d.setUint32(p,r,!1);break}case 5:{d.setUint32(p+1,r|0,!1),d.setUint8(p,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(p+2,r|0,!1),d.setUint16(p,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return p+_})\n"; // writeFloatLE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1126,7 +1126,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeLatin1WriteCodeLength = 67; static const JSC::Intrinsic s_jsBufferPrototypeLatin1WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"latin1\")})\n"; +const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"latin1\")})\n"; // asciiWrite const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1150,7 +1150,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlWriteCodeLength = 70; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64url\")})\n"; +const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"base64url\")})\n"; // hexWrite const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1198,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 (r,d){\"use strict\";return this.toString(r,d,\"ascii\")})\n"; +const char* const s_jsBufferPrototypeAsciiSliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"ascii\")})\n"; // base64Slice const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (i,m){\"use strict\";var{buffer:q,byteOffset:v,byteLength:c}=this;function w(z,k){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=k,z>0\?z:0;else return zp\?x-p:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (c,w){\"use strict\";var{buffer:m,byteOffset:x,byteLength:z}=this;function p(k,v){if(k=@trunc(k),k===0||@isNaN(k))return 0;else if(k<0)return k+=v,k>0\?k:0;else return ki\?q-i:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1280,7 +1280,7 @@ const JSC::ConstructorKind s_readableByteStreamControllerInitializeReadableByteS const JSC::ImplementationVisibility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength = 253; static const JSC::Intrinsic s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode = "(function (f,l,p){\"use strict\";if(arguments.length!==4&&arguments[3]!==@isReadableStream)@throwTypeError(\"ReadableByteStreamController constructor should not be called directly\");return @privateInitializeReadableByteStreamController.@call(this,f,l,p)})\n"; +const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode = "(function (f,p,l){\"use strict\";if(arguments.length!==4&&arguments[3]!==@isReadableStream)@throwTypeError(\"ReadableByteStreamController constructor should not be called directly\");return @privateInitializeReadableByteStreamController.@call(this,f,p,l)})\n"; // enqueue const JSC::ConstructAbility s_readableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,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 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"; +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"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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 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"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const j=async function*A(){var m=@Bun.stdin.stream().getReader(),D=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),F,G=@Bun.indexOfLine;try{while(!0){var q,H,J;const K=m.readMany();if(@isPromise(K))({done:q,value:H}=await K);else({done:q,value:H}=K);if(q){if(J)yield D.decode(J);return}var w;for(let _ of H){if(w=_,J)w=@Buffer.concat([J,_]),J=null;var L=0,M=G(w,L);while(M!==-1)yield D.decode(w.subarray(L,M)),L=M+1,M=G(w,L);J=w.subarray(L)}}}catch(K){F=K}finally{if(m.releaseLock(),F)throw F}},z=globalThis.Symbol.asyncIterator;return this[z]=j,j()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (d){\"use strict\";var _=@getByIdDirectPrivate(this,\"writer\");if(!_){var b=@toLength(d\?.length\?\?0);_=@Bun.stdout.writer({highWaterMark:b>65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a65536\?_:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var b=d.write(a);const f=@argumentCount();for(var c=1;c{},(S)=>{g.error(S)});function y(){@readableStreamDefaultReaderRead(h).@then(function(S){if(S.done){g.close();return}try{g.enqueue(S.value)}catch(_){g.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(S){g.error(S)})}y()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (_,y){\"use strict\";@assert(@isReadableStream(_));const c=new @ReadableStreamDefaultReader(_);@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise.@then(()=>{},(g)=>{y.error(g)});function h(){@readableStreamDefaultReaderRead(c).@then(function(g){if(g.done){y.close();return}try{y.enqueue(g.value)}catch(S){y.error(\"ReadableStream chunk enqueueing in the sink failed\");return}h()},function(g){y.error(g)})}h()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1404,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 (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"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (f,b,j,q,v,w,x){\"use strict\";const B=new @ReadableStreamDefaultController(f,b,j,q,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(b,w,[B]),D=(_)=>@promiseInvokeOrNoopMethod(b,x,[_]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",D),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(f,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (v,w,A){\"use strict\";const C=w.type,b=@toString(C);if(b===\"bytes\"){if(A.highWaterMark===@undefined)A.highWaterMark=0;if(A.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(v,\"readableStreamController\",new @ReadableByteStreamController(v,w,A.highWaterMark,@isReadableStream))}else if(b===\"direct\"){var f=A\?.highWaterMark;@initializeArrayBufferStream.@call(v,w,f)}else if(C===@undefined){if(A.highWaterMark===@undefined)A.highWaterMark=1;@setupReadableStreamDefaultController(v,w,A.size,A.highWaterMark,w.start,w.pull,w.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const C=v.type,b=@toString(C);if(b===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(b===\"direct\"){var A=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,A)}else if(C===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1420,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\"),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"; +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"; // readableStreamPipeToWritableStream const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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 (_,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"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (D,I,E,T,k,J){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(I)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(I)),@assert(J===@undefined||@isAbortSignal(J)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:D,destination:I,preventAbort:T,preventCancel:k,preventClose:E,signal:J};if(_.reader=@acquireReadableStreamDefaultReader(D),_.writer=@acquireWritableStreamDefaultWriter(I),@putByIdDirectPrivate(D,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),J!==@undefined){const q=(w)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const z=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,w):@Promise.@resolve(),F=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,w):@Promise.@resolve();let G=@newPromiseCapability(@Promise),H=!0,K=()=>{if(H){H=!1;return}G.@resolve.@call()},f=(L)=>{G.@reject.@call(@undefined,L)};return z.@then(K,f),F.@then(K,f),G.@promise},w)};if(@whenSignalAborted(J,q))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1444,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 (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"; +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"; // pipeToErrorsMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1452,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 (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"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode = "(function (_){\"use strict\";const d=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,b),b);return}@pipeToShutdown(_,b)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){d();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,d)})\n"; // pipeToErrorsMustBePropagatedBackward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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){\"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"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (_,g){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const b=arguments.length>2,d=arguments[2],m=()=>{g().@then(()=>{if(b)@pipeToFinalize(_,d);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(m,m)},(h)=>@pipeToFinalize(_,h));return}m()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (f,k){\"use strict\";@assert(@isReadableStream(f)),@assert(typeof k===\"boolean\");var i=@getByIdDirectPrivate(f,\"start\");if(i)@putByIdDirectPrivate(f,\"start\",@undefined),i();const q=new @ReadableStreamDefaultReader(f),_={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};_.cancelPromiseCapability=@newPromiseCapability(@Promise);const v=@readableStreamTeePullFunction(_,q,k),g={};@putByIdDirectPrivate(g,\"pull\",v),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch1CancelFunction(_,f));const w={};@putByIdDirectPrivate(w,\"pull\",v),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(_,f));const x=new @ReadableStream(g),j=new @ReadableStream(w);return @getByIdDirectPrivate(q,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(_.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,y),@readableStreamDefaultControllerError(j.@readableStreamController,y),_.closedOrErrored=!0,!_.canceled1||!_.canceled2)_.cancelPromiseCapability.@resolve.@call()}),_.branch1=x,_.branch2=j,[x,j]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (i,q){\"use strict\";@assert(@isReadableStream(i)),@assert(typeof q===\"boolean\");var k=@getByIdDirectPrivate(i,\"start\");if(k)@putByIdDirectPrivate(i,\"start\",@undefined),k();const _=new @ReadableStreamDefaultReader(i),v={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};v.cancelPromiseCapability=@newPromiseCapability(@Promise);const w=@readableStreamTeePullFunction(v,_,q),f={};@putByIdDirectPrivate(f,\"pull\",w),@putByIdDirectPrivate(f,\"cancel\",@readableStreamTeeBranch1CancelFunction(v,i));const j={};@putByIdDirectPrivate(j,\"pull\",w),@putByIdDirectPrivate(j,\"cancel\",@readableStreamTeeBranch2CancelFunction(v,i));const g=new @ReadableStream(f),x=new @ReadableStream(j);return @getByIdDirectPrivate(_,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(v.closedOrErrored)return;if(@readableStreamDefaultControllerError(g.@readableStreamController,y),@readableStreamDefaultControllerError(x.@readableStreamController,y),v.closedOrErrored=!0,!v.canceled1||!v.canceled2)v.cancelPromiseCapability.@resolve.@call()}),v.branch1=g,v.branch2=x,[g,x]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,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,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"; +const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = "(function (m,_,f){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(_),function(i){if(@assert(@isObject(i)),@assert(typeof i.done===\"boolean\"),i.done&&!m.closedOrErrored){if(!m.canceled1)@readableStreamDefaultControllerClose(m.branch1.@readableStreamController);if(!m.canceled2)@readableStreamDefaultControllerClose(m.branch2.@readableStreamController);if(m.closedOrErrored=!0,!m.canceled1||!m.canceled2)m.cancelPromiseCapability.@resolve.@call()}if(m.closedOrErrored)return;if(!m.canceled1)@readableStreamDefaultControllerEnqueue(m.branch1.@readableStreamController,i.value);if(!m.canceled2)@readableStreamDefaultControllerEnqueue(m.branch2.@readableStreamController,f\?@structuredCloneForStream(i.value):i.value)})}})\n"; // readableStreamTeeBranch1CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,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 (_,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"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (j,v,w){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function x(f,A){if(A&&w\?.cancel){try{var B=w.cancel(A);@markPromiseAsHandled(B)}catch(q){}w=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),A)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",A);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!w.pull){x();return}if(!@isCallable(w.pull)){x(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",v);const _=@getByIdDirectPrivate(j,\"highWaterMark\");v.start({highWaterMark:!_||_<64\?64:_}),@startDirectStream.@call(v,j,w.pull,x),@putByIdDirectPrivate(j,\"reader\",{});var z=w.pull(v);if(v=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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 (_,D,q){\"use strict\";var c=!1,x=!1;try{var E=_.getReader(),F=E.readMany();if(F&&@isPromise(F))F=await F;if(F.done)return c=!0,D.end();var G=F.value.length;const P=@getByIdDirectPrivate(_,\"highWaterMark\");if(q)@startDirectStream.@call(D,_,@undefined,()=>!x&&@markPromiseAsHandled(_.cancel()));D.start({highWaterMark:P||0});for(var H=0,f=F.value,J=F.value.length;H!B&&@markPromiseAsHandled(c.cancel()));q.start({highWaterMark:_||0});for(var I=0,H=F.value,P=F.value.length;I{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"; +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(B){}var C;try{C=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(B){if(this._pendingRead){var S=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(S,B)}@readableStreamError(v,B);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var b=@getByIdDirectPrivate(v,\"reader\");if(b&&@isReadableStreamDefaultReader(b)){var j=this._pendingRead;if(j&&@isPromise(j)&&C\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(j,{value:C,done:!1}),@readableStreamClose(v);return}}if(C\?.byteLength){var y=@getByIdDirectPrivate(b,\"readRequests\");if(y\?.isNotEmpty()){@readableStreamFulfillReadRequest(v,C,!1),@readableStreamClose(v);return}@putByIdDirectPrivate(v,\"state\",@streamReadable),this.@pull=()=>{var B=@createFulfilledPromise({value:C,done:!1});return C=@undefined,@readableStreamClose(v),v=@undefined,B}}else if(this._pendingRead){var S=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(S,{value:@undefined,done:!0})}@readableStreamClose(v)})\n"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var i=this.@sink.flush();if(i\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:i,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var i=this.@sink.flush();if(i\?.byteLength)@readableStreamFulfillReadRequest(c,i,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,b=@getByIdDirectPrivate(c,\"reader\");if(!b||!@isReadableStreamDefaultReader(b))return;var i=this._pendingRead;if(this._pendingRead=@undefined,i&&@isPromise(i)){var j=this.@sink.flush();if(j\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(i,{value:j,done:!1});else this._pendingRead=i}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var j=this.@sink.flush();if(j\?.byteLength)@readableStreamFulfillReadRequest(c,j,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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 (_){\"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"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (q){\"use strict\";var j,v=[],w=!1,x=!1,z=\"\",A=@toLength(0),C=@newPromiseCapability(@Promise),E=!1;return j={start(){},write(F){if(typeof F===\"string\"){var G=@toLength(F.length);if(G>0)z+=F,w=!0,A+=G;return G}if(!F||!(@ArrayBuffer.@isView(F)||F instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const _=@toLength(F.byteLength);if(_>0)if(x=!0,z.length>0)@arrayPush(v,z,F),z=\"\";else @arrayPush(v,F);return A+=_,_},flush(){return 0},end(){if(E)return\"\";return j.fulfill()},fulfill(){E=!0;const F=j.finishInternal();return @fulfillPromise(C.@promise,F),F},finishInternal(){if(!w&&!x)return\"\";if(w&&!x)return z;if(x&&!w)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(v));var F=new @Bun.ArrayBufferSink;F.start({highWaterMark:A,asUint8Array:!0});for(let G of v)F.write(G);if(v.length=0,z.length>0)F.write(z),z=\"\";return new globalThis.TextDecoder().decode(F.end())},close(){try{if(!E)E=!0,j.fulfill()}catch(F){}}},[j,C]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[b,p]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),p})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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){\"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"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (_,d){\"use strict\";var j=[],m=@newPromiseCapability(@Promise),t=!1;function b(){return t=!0,m.@resolve.@call(@undefined,j),j}var q={start(){},write(p){return @arrayPush(j,p),p.byteLength||p.length},flush(){return 0},end(){if(t)return[];return b()},close(){if(!t)b()}},v={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:q,close:@onCloseDirectStream,write:q.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",v),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),m})\n"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1668,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 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"; +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},b=new @Bun.ArrayBufferSink;b.start(w);var D={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write.bind(b),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",D),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; // readableStreamError const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const h=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,_){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",_);const c=@getByIdDirectPrivate(i,\"reader\");if(!c)return;if(@isReadableStreamDefaultReader(c)){const h=@getByIdDirectPrivate(c,\"readRequests\");@putByIdDirectPrivate(c,\"readRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,_)}else{@assert(@isReadableStreamBYOBReader(c));const h=@getByIdDirectPrivate(c,\"readIntoRequests\");@putByIdDirectPrivate(c,\"readIntoRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,_)}@getByIdDirectPrivate(c,\"closedPromiseCapability\").@reject.@call(@undefined,_);const f=@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(f)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1684,7 +1684,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength = 477; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode = "(function (h){\"use strict\";const i=@getByIdDirectPrivate(h,\"controlledReadableStream\");if(!@readableStreamDefaultControllerCanCloseOrEnqueue(h))return!1;if(@getByIdDirectPrivate(h,\"started\")!==1)return!1;if((!@isReadableStreamLocked(i)||!@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\")\?.isNotEmpty())&&@readableStreamDefaultControllerGetDesiredSize(h)<=0)return!1;const v=@readableStreamDefaultControllerGetDesiredSize(h);return @assert(v!==null),v>0})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode = "(function (h){\"use strict\";const v=@getByIdDirectPrivate(h,\"controlledReadableStream\");if(!@readableStreamDefaultControllerCanCloseOrEnqueue(h))return!1;if(@getByIdDirectPrivate(h,\"started\")!==1)return!1;if((!@isReadableStreamLocked(v)||!@getByIdDirectPrivate(@getByIdDirectPrivate(v,\"reader\"),\"readRequests\")\?.isNotEmpty())&&@readableStreamDefaultControllerGetDesiredSize(h)<=0)return!1;const i=@readableStreamDefaultControllerGetDesiredSize(h);return @assert(i!==null),i>0})\n"; // readableStreamDefaultControllerCallPullIfNeeded const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1708,7 +1708,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 283; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\"),g=@getByIdDirectPrivate(d,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const g=@getByIdDirectPrivate(i,\"controlledReadableStream\"),d=@getByIdDirectPrivate(g,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; // readableStreamReaderGenericCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1716,7 +1716,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 133; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,h){\"use strict\";const i=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,h)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,i){\"use strict\";const h=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!h),@readableStreamCancel(h,i)})\n"; // readableStreamCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (_,d){\"use strict\";@putByIdDirectPrivate(_,\"disturbed\",!0);const h=@getByIdDirectPrivate(_,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));@readableStreamClose(_);var p=@getByIdDirectPrivate(_,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,d).@then(function(){});var i=p.close;if(i)return @Promise.@resolve(p.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (d,h){\"use strict\";@putByIdDirectPrivate(d,\"disturbed\",!0);const p=@getByIdDirectPrivate(d,\"state\");if(p===@streamClosed)return @Promise.@resolve();if(p===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));@readableStreamClose(d);var u=@getByIdDirectPrivate(d,\"readableStreamController\"),_=u.@cancel;if(_)return _(u,h).@then(function(){});var i=u.close;if(i)return @Promise.@resolve(u.close(h));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1732,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(d,\"queue\",@newQueue()),@getByIdDirectPrivate(d,\"cancelAlgorithm\").@call(@undefined,_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode = "(function (_,d){\"use strict\";return @putByIdDirectPrivate(_,\"queue\",@newQueue()),@getByIdDirectPrivate(_,\"cancelAlgorithm\").@call(@undefined,d)})\n"; // readableStreamDefaultControllerPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1740,7 +1740,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 519; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const f=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:f,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),d})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (f){\"use strict\";var a=@getByIdDirectPrivate(f,\"queue\");if(a.content.isNotEmpty()){const _=@dequeueValue(a);if(@getByIdDirectPrivate(f,\"closeRequested\")&&a.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(f,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(f);return @createFulfilledPromise({value:_,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(f,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(f),d})\n"; // readableStreamDefaultControllerClose const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var i=d.shift();i;i=d.shift())@fulfillPromise(i,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1764,7 +1764,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadReq const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 157; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,p,y){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:p,done:y})})\n"; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (p,y,i){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(p,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:y,done:i})})\n"; // readableStreamDefaultControllerEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let D=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)D=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,D)}catch(D){throw @readableStreamDefaultControllerError(_,D),D}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1788,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 (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"; +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"; // isReadableStreamDisturbed const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,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 (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"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (f,b){\"use strict\";var D=@getByIdDirectPrivate(f,\"bunNativeType\"),E=@getByIdDirectPrivate(f,\"bunNativePtr\"),y=@lazyStreamPrototypeMap.@get(D);if(y===@undefined){let p=function(U){var{c:z,v:A}=this;this.c=@undefined,this.v=@undefined,J(U,z,A)},X=function(U){try{U.close()}catch(z){globalThis.reportError(z)}},P=function(U,z,A,Y){Y[0]=!1;var Q;try{Q=j(U,A,Y)}catch(Z){return z.error(Z)}return J(Q,z,A)};var O=p,W=X,N=P,[j,F,_,G,B,m,H]=@lazyLoad(D),I=[!1],J;J=function U(z,A,Y){if(z&&@isPromise(z))return z.then(p.bind({c:A,v:Y}),(Q)=>A.error(Q));else if(typeof z===\"number\")if(Y&&Y.byteLength===z&&Y.buffer===A.byobRequest\?.view\?.buffer)A.byobRequest.respondWithNewView(Y);else A.byobRequest.respond(z);else if(z.constructor===@Uint8Array)A.enqueue(z);if(I[0]||z===!1)@enqueueJob(X,A),I[0]=!1};const x=B\?new FinalizationRegistry(B):null;y=class U{constructor(z,A,Y){if(this.#f=z,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=A,Y!==@undefined)this.start=(Q)=>{Q.enqueue(Y)};if(x)x.register(this,z,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=F;#j(z){var A=this.#f;if(!A){z.close();return}P(A,z,z.byobRequest.view,I)}#m(z){var A=this.#f;x&&x.unregister(this.#b),m&&m(A,!1),_(A,z)}static deinit=B;static drain=H},@lazyStreamPrototypeMap.@set(D,y)}const K=y.startSync(E,b);var q;const{drain:L,deinit:M}=y;if(L)q=L(E);if(K===0){if(B&&E&&@enqueueJob(B,E),(q\?.byteLength\?\?0)>0)return{start(p){p.enqueue(q),p.close()},type:\"bytes\"};return{start(p){p.close()},type:\"bytes\"}}return new y(E,K,q)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var b=_.getReader(),g=b.readMany();async function j(p){if(p.done)return[];var f=p.value||[];while(!0){var q=await b.read();if(q.done)break;f=f.concat(q.value)}return f}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var _=f.getReader(),b=_.readMany();async function g(j){if(j.done)return[];var p=j.value||[];while(!0){var q=await _.read();if(q.done)break;p=p.concat(q.value)}return p}if(b&&@isPromise(b))return b.@then(g);return g(b)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1836,7 +1836,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 214; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (i){\"use strict\";const[_,d]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),h=@readStreamIntoSink(i,_,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (_){\"use strict\";const[i,d]=@createTextStream(@getByIdDirectPrivate(_,\"highWaterMark\")),h=@readStreamIntoSink(_,i,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; // readableStreamToArrayBufferDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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 (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"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (q,v){\"use strict\";var w=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(q,\"underlyingSource\",@undefined);var D=@getByIdDirectPrivate(q,\"highWaterMark\");w.start(D\?{highWaterMark:D}:{});var x=@newPromiseCapability(@Promise),F=!1,z=v.pull,A=v.close,B={start(){},close(C){if(!F){if(F=!0,A)A();@fulfillPromise(x.@promise,w.end())}},end(){if(!F){if(F=!0,A)A();@fulfillPromise(x.@promise,w.end())}},flush(){return 0},write:w.write.bind(w)},G=!1;try{const C=z(B);if(C&&@isObject(C)&&@isPromise(C))return async function(O,j,_){while(!F)await _(O);return await j}(B,promise,z);return x.@promise}catch(C){return G=!0,@readableStreamError(q,C),@Promise.@reject(C)}finally{if(!G&&q)@readableStreamClose(q);B=A=w=z=q=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,f){\"use strict\";const h=@initializeTextStream.@call(_,f,@undefined);var j=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await j.read();if(k.done)break}try{j.releaseLock()}catch(p){}return j=@undefined,_=@undefined,h.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var _=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var k=await _.read();if(k.done)break}try{_.releaseLock()}catch(p){}return _=@undefined,f=@undefined,j.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,_){\"use strict\";const j=@initializeArrayStream.@call(f,_,@undefined);_=@undefined;var k=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(q){}return k=@undefined,@Promise.@resolve(j.@promise)}catch(q){throw q}finally{f=@undefined,k=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,f){\"use strict\";const k=@initializeArrayStream.@call(_,f,@undefined);f=@undefined;var q=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var j=await q.read();if(j.done)break}try{q.releaseLock()}catch(p){}return q=@undefined,@Promise.@resolve(k.@promise)}catch(p){throw p}finally{_=@undefined,q=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (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"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (F){\"use strict\";var i=globalThis.Symbol.asyncIterator,z=async function*q(D,w){var j=D.getReader(),x;try{while(!0){var k,g;const G=j.readMany();if(@isPromise(G))({done:k,value:g}=await G);else({done:k,value:g}=G);if(k)return;yield*g}}catch(G){x=G}finally{if(j.releaseLock(),!w)D.cancel(x);if(x)throw x}},h=function q(){return z(this,!1)},B=function q({preventCancel:D=!1}={preventCancel:!1}){return z(this,D)};return @Object.@defineProperty(F,i,{value:h}),@Object.@defineProperty(F,\"values\",{value:B}),F})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1894,7 +1894,7 @@ const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeCons const JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 339; static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),i=@getByIdDirectPrivate(_,\"readable\"),u=@getByIdDirectPrivate(i,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(u)})\n"; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),u=@getByIdDirectPrivate(_,\"readable\"),i=@getByIdDirectPrivate(u,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(i)})\n"; // enqueue const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2020,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 _=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!_)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const x=@getByIdDirectPrivate(_,\"state\");if(@putByIdDirectPrivate(_,\"disturbed\",!0),x===@streamClosed)return{value:[],size:0,done:!0};else if(x===@streamErrored)throw @getByIdDirectPrivate(_,\"storedError\");var F=@getByIdDirectPrivate(_,\"readableStreamController\"),G=@getByIdDirectPrivate(F,\"queue\");if(!G)return F.@pull(F).@then(function({done:w,value:C}){return w\?{done:!0,value:[],size:0}:{value:[C],size:1,done:!1}});const H=G.content;var I=G.size,E=H.toArray(!1),J=E.length;if(J>0){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){var B=@newArrayWithSize(J);if(@isReadableByteStreamController(H)){{const w=W[0];if(!(@ArrayBuffer.@isView(w)||w instanceof @ArrayBuffer))@putByValDirect(B,0,new @Uint8Array(w.buffer,w.byteOffset,w.byteLength));else @putByValDirect(B,0,w)}for(var C=1;C{if(w.done)return{value:[],size:0,done:!0};var k=@getByIdDirectPrivate(_,\"readableStreamController\"),N=@getByIdDirectPrivate(k,\"queue\"),K=[w.value].concat(N.content.toArray(!1)),A=K.length;if(@isReadableByteStreamController(k))for(var G=0;G0}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"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var v=@Array.prototype.slice;class E{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:F,_tail:x,_list:g,_capacityMask:A}=this;if(F===x)return @undefined;var B=g[F];if(@putByValDirect(g,F,@undefined),F=this._head=F+1&A,F<2&&x>1e4&&x<=g.length>>>2)this._shrinkArray();return B}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(F){var x=this._tail;if(@putByValDirect(this._list,x,F),this._tail=x+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(F){var x=this._list,g=@toLength(x.length);if(F||this._head>this._tail){var A=@toLength(this._head),B=@toLength(this._tail),k=@toLength(g-A+B),z=@newArrayWithSize(k),G=0;for(var w=A;w>>=1,this._capacityMask>>>=1}}return new E})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2150,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,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"; +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"; // peekQueueValue const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2174,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 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"; +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"; // extractHighWaterMark const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2206,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,p,n){\"use strict\";if(c===@undefined||c===null)return p;if(!@isObject(c))@throwTypeError(n);return c})\n"; +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"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2224,7 +2224,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (D){\"use strict\";var J=@Loader,z=@createFIFO(),B=D;while(B){var F=J.registry.@get(B);if((F\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(B),F=J.registry.@get(B);var G=@getPromiseInternalField(F.fetch,@promiseFieldReactionsOrResult),H=J.parseModule(B,G),I=F.module;if(H&&@isPromise(H)){var L=@getPromiseInternalField(H,@promiseFieldReactionsOrResult),_=@getPromiseInternalField(H,@promiseFieldFlags),w=_&@promiseStateMask;if(w===@promiseStatePending||L&&@isPromise(L))@throwTypeError(`require() async module \"${B}\" is unsupported. use \"await import()\" instead.`);else if(w===@promiseStateRejected){if(!L\?.message)@throwTypeError(`${L+\"\"\?L:\"An error occurred\"} occurred while parsing module \\\"${B}\\\"`);throw L}F.module=I=L}else if(H&&!I)F.module=I=H;@setStateToMax(F,@ModuleLink);var Q=I.dependenciesMap,x=J.requestedModules(I),T=@newArrayWithSize(x.length);for(var U=0,V=x.length;U=@ModuleLink)B=z.shift()}var Z=J.linkAndEvaluateModule(D,@undefined);if(Z&&@isPromise(Z))@throwTypeError(`require() async module \\\"${D}\\\" is unsupported. use \"await import()\" instead.`);return J.registry.@get(D)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var _=@Loader.registry.@get(a);if(!_||!_.evaluated)_=@loadCJS2ESM(a);if(!_||!_.evaluated||!_.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var c=@Loader.getModuleNamespaceObject(_.module);if(c[@commonJSSymbol]===0)return;return c})\n"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_importMetaObjectInternalRequireCode = "(function (k){\"use strict\";var n=@requireMap.@get(k);const j=k.substring(k.length-5);if(n)return n.exports;if(j===\".json\"){var _=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=JSON.parse(_.readFileSync(k,\"utf8\"));return @requireMap.@set(k,@createCommonJSModule(k,q,!0)),q}else if(j===\".node\"){const v=@createCommonJSModule(k,{},!0);return process.dlopen(v,k),@requireMap.@set(k,v),v.exports}else if(j===\".toml\"){var _=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=@Bun.TOML.parse(_.readFileSync(k,\"utf8\"));return @requireMap.@set(k,@createCommonJSModule(k,q,!0)),q}else{var q=@requireESM(k);const g=@requireMap.@get(k);if(g)return g.exports;var b=q\?.default;if(b\?.[@commonJSSymbol]===0)q=b;return @requireMap.@set(k,@createCommonJSModule(k,q,!0)),q}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,15 +2248,15 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,f={};return new Proxy(f,{get(h,t){const u=@requireMap.@get(t);if(u)return u;const L=@Loader.registry.@get(t);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(t,c,!0);return @requireMap.@set(t,g),g}return f[t]},set(h,t,u){return @requireMap.@set(t,u),!0},has(h,t){return @requireMap.@has(t)||@Loader.registry.@has(t)},deleteProperty(h,t){return _.@delete(t),@requireMap.@delete(t),@Loader.registry.@delete(t),!0},ownKeys(h){var t=[...@requireMap.@keys()];const u=[...@Loader.registry.@keys()];for(let L of u)if(!t.includes(L))@arrayPush(t,L);return t},getPrototypeOf(h){return null},getOwnPropertyDescriptor(h,t){if(@requireMap.@has(t)||@Loader.registry.@has(t))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 = 173; +const int s_importMetaObjectRequireCodeLength = 89; static const JSC::Intrinsic s_importMetaObjectRequireCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_importMetaObjectRequireCode = "(function (l){\"use strict\";return @internalRequire(@resolveSync(l,@toString(this),!1))})\n"; // main const JSC::ConstructAbility s_importMetaObjectMainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2432,7 +2432,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,I=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!I){const _=@getByIdDirectPrivate(m,\"size\"),b=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,b!==@undefined\?b:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(I){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,_);if(b)@createReadableStreamController(this,b,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const m=_.type===\"direct\",v=!!_.@lazy,B=m||v;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!B){const I=@getByIdDirectPrivate(f,\"size\"),b=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,I,b!==@undefined\?b:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(m)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(B){const I=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,I);if(b)@createReadableStreamController(this,b,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2440,7 +2440,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorK const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayCodeLength = 173; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayCode = "(function (b){\"use strict\";var _=@getByIdDirectPrivate(b,\"underlyingSource\");if(_!==@undefined)return @readableStreamToArrayDirect(b,_);return @readableStreamIntoArray(b)})\n"; +const char* const s_readableStreamReadableStreamToArrayCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayDirect(_,b);return @readableStreamIntoArray(_)})\n"; // readableStreamToText const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2456,7 +2456,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2480,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 (F,q,w){\"use strict\";const x=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var A=globalThis[x];if(!A)A=globalThis[x]=[];var B=A[q];if(B===@undefined){var[D,_,k,G,j,H]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](q);B=class J{handleError;handleClosed;processResult;constructor(K,L){this.#_=L,this.#F=K,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),K.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var K=this.#_;this.#_=0,G(K),H(K)}_handleError(K){if(this.#$)return;this.#$=!0;var L=this.#_;this.#_=0,_(L,K),H(L)}#_;#$=!1;#F;_handleReadMany({value:K,done:L,size:N}){if(L){this.handleClosed();return}if(this.#$)return;k(this.#_,K,L,N)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(K){if(K&&@isPromise(K)){if(@getPromiseInternalField(K,@promiseFieldFlags)&@promiseStateFulfilled){const N=@getPromiseInternalField(K,@promiseFieldReactionsOrResult);if(N)K=N}}if(K&&@isPromise(K))return K.then(this.processResult,this.handleError),null;if(K.done)return this.handleClosed(),0;else if(K.value)return K.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const I=q+1;if(A.length{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(_)},(d)=>{if(@getByIdDirectPrivate(v,\"state\")===@streamReadable)@readableByteStreamControllerError(_,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (_,f,v){\"use strict\";if(!@isReadableStream(_))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(_,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",_),@putByIdDirectPrivate(this,\"underlyingByteSource\",f),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let b=@toNumber(v);if(@isNaN(b)||b<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",b);let p=f.autoAllocateChunkSize;if(p!==@undefined){if(p=@toNumber(p),p<=0||p===@Infinity||p===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",p),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const R=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(R,\"underlyingByteSource\"),\"start\",[R]).@then(()=>{@putByIdDirectPrivate(R,\"started\",1),@assert(!@getByIdDirectPrivate(R,\"pulling\")),@assert(!@getByIdDirectPrivate(R,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(R)},(d)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(R,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2676,7 +2676,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var p=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=p.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2708,7 +2708,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 272; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const _=@getByIdDirectPrivate(u,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\"),u=@getByIdDirectPrivate(d,\"state\");if(u===@streamErrored)return null;if(u===@streamClosed)return 0;return @getByIdDirectPrivate(_,\"strategyHWM\")-@getByIdDirectPrivate(_,\"queue\").size})\n"; // readableStreamHasBYOBReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2740,7 +2740,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const F=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(F)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const P=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=P.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let h;try{h=new @Uint8Array(P.buffer,P.byteOffset,P.byteLength)}catch(R){return @Promise.@reject(R)}return @createFulfilledPromise({value:h,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let P;try{P=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(R){return @Promise.@reject(R)}const h={buffer:P,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(h)}const d=@readableStreamAddReadRequest(F);return @readableByteStreamControllerCallPullIfNeeded(_),d})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (h){\"use strict\";const R=@getByIdDirectPrivate(h,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(R)),@getByIdDirectPrivate(h,\"queue\").content\?.isNotEmpty()){const d=@getByIdDirectPrivate(h,\"queue\").content.shift();@getByIdDirectPrivate(h,\"queue\").size-=d.byteLength,@readableByteStreamControllerHandleQueueDrain(h);let _;try{_=new @Uint8Array(d.buffer,d.byteOffset,d.byteLength)}catch(P){return @Promise.@reject(P)}return @createFulfilledPromise({value:_,done:!1})}if(@getByIdDirectPrivate(h,\"autoAllocateChunkSize\")!==@undefined){let d;try{d=@createUninitializedArrayBuffer(@getByIdDirectPrivate(h,\"autoAllocateChunkSize\"))}catch(P){return @Promise.@reject(P)}const _={buffer:d,byteOffset:0,byteLength:@getByIdDirectPrivate(h,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(h,\"pendingPullIntos\").push(_)}const F=@readableStreamAddReadRequest(R);return @readableByteStreamControllerCallPullIfNeeded(h),F})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 619; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const P=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(P,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const b=@getByIdDirectPrivate(P,\"reader\");if(b&&(@getByIdDirectPrivate(b,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(b,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(P)&&@getByIdDirectPrivate(@getByIdDirectPrivate(P,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const b=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(b,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const P=@getByIdDirectPrivate(b,\"reader\");if(P&&(@getByIdDirectPrivate(P,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(P,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(b)&&@getByIdDirectPrivate(@getByIdDirectPrivate(b,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; // readableByteStreamControllerCallPullIfNeeded const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2812,7 +2812,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength = 464; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,u){\"use strict\";let _=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),k=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){if(u!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,_)}else @assert(@getByIdDirectPrivate(k,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,u,_)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,_){\"use strict\";let u=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),k=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){if(_!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,u)}else @assert(@getByIdDirectPrivate(k,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,_,u)})\n"; // readableByteStreamControllerRespondInReadableState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2844,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 (j,w){\"use strict\";const _=w.bytesFilled-w.bytesFilled%w.elementSize,z=@getByIdDirectPrivate(j,\"queue\").size_)k=E-w.bytesFilled,G=!0;while(k>0){let H=@getByIdDirectPrivate(j,\"queue\").content.peek();const v=k0),@assert(w.bytesFilledv)q=H-k.bytesFilled,J=!0;while(q>0){let j=@getByIdDirectPrivate(_,\"queue\").content.peek();const z=q0),@assert(k.bytesFilled0){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"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (_,E){\"use strict\";const b=@getByIdDirectPrivate(_,\"controlledReadableStream\");let L=1;if(E.BYTES_PER_ELEMENT!==@undefined)L=E.BYTES_PER_ELEMENT;const d=E.constructor,A={buffer:E.buffer,byteOffset:E.byteOffset,byteLength:E.byteLength,bytesFilled:0,elementSize:L,ctor:d,readerType:\"byob\"};var N=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(N\?.isNotEmpty())return A.buffer=@transferBufferToCurrentRealm(A.buffer),N.push(A),@readableStreamAddReadIntoRequest(b);if(@getByIdDirectPrivate(b,\"state\")===@streamClosed){const k=new d(A.buffer,A.byteOffset,0);return @createFulfilledPromise({value:k,done:!0})}if(@getByIdDirectPrivate(_,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(_,A)){const k=@readableByteStreamControllerConvertDescriptor(A);return @readableByteStreamControllerHandleQueueDrain(_),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(_,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(_,k),@Promise.@reject(k)}}A.buffer=@transferBufferToCurrentRealm(A.buffer),@getByIdDirectPrivate(_,\"pendingPullIntos\").push(A);const R=@readableStreamAddReadIntoRequest(b);return @readableByteStreamControllerCallPullIfNeeded(_),R})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2952,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{#$;#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"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class A extends EventTarget{#Z;#K;#W;#L;#M;#j=!1;#$=null;#O=\"\";#B=\"\";#z=\"\";#Q=!0;#X=0;#F=0;#H=0;#U=null;static#G(U){U.#Y()}static#J(U,B){const V=U.data,F=V.#z\?`Last-Event-ID: ${V.#z}\\r\\n`:\"\",j=`GET ${B.pathname}${B.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${F}\\r\\n`,G=U.write(j);if(G!==j.length)V.#B=j.substring(G)}static#V(U,B,V){for(;;){if(V>=B.length)return;let F=-1,j=B.indexOf(\"\\r\\n\",V);const G=j+2;if(j>0)if(U.#X===0){const Y=parseInt(B.substring(V,j),16);if(Y===0){U.#K=2,U.#$\?.end();return}F=G+Y}else F=B.length;else{if(U.#O.length===0){U.#O+=B.substring(V);return}F=B.length}let W=B.substring(G,F);V=F+2;let J=0,X=W.indexOf(\"\\n\\n\");if(X==-1){U.#O+=B.substring(G);return}if(U.#O.length)U.#O+=W,W=U.#O,U.#O=\"\";let K=!0;while(K){const Y=W.substring(J,X);let L,Z=\"\",M,w=0,O=-1;for(;;){let Q=Y.indexOf(\"\\n\",w);if(Q===-1){if(w>=Y.length)break;Q=Y.length}const H=Y.substring(w,Q);if(H.startsWith(\"data:\"))if(Z.length)Z+=`\\n${H.substring(5).trim()}`;else Z=H.substring(5).trim();else if(H.startsWith(\"event:\"))L=H.substring(6).trim();else if(H.startsWith(\"id:\"))M=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(O=parseInt(H.substring(6).trim(),10),@isNaN(O))O=-1}w=Q+1}if(U.#z=M||\"\",O>=0)U.#H=O;if(Z||M||L)U.dispatchEvent(new MessageEvent(L||\"message\",{data:Z||\"\",origin:U.#Z.origin,source:U,lastEventId:M}));if(W.length===X+2){K=!1;break}const z=W.indexOf(\"\\n\\n\",X+1);if(z===-1)break;J=X,X=z}}}static#A={open(U){const B=U.data;if(B.#$=U,!B.#j)A.#J(U,B.#Z)},handshake(U,B,V){const F=U.data;if(B)A.#J(U,F.#Z);else F.#K=2,F.dispatchEvent(new ErrorEvent(\"error\",{error:V})),U.end()},data(U,B){const V=U.data;switch(V.#K){case 0:{let F=B.toString();const j=F.indexOf(\"\\r\\n\\r\\n\");if(j===-1){V.#O+=F;return}if(V.#O.length)V.#O+=F,F=V.#O,V.#O=\"\";const G=F.substring(0,j),W=G.indexOf(\"\\r\\n\");if(W===-1){V.#K=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),U.end();return}const J=G.substring(0,W);if(J!==\"HTTP/1.1 200 OK\"){V.#K=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(J)})),U.end();return}let X=W+1,K=!1,Y=-1;for(;;){let Z=G.indexOf(\"\\r\\n\",X);if(Z===-1){if(X>=G.length){if(!K)V.#K=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),U.end();return}Z=G.length}const M=G.substring(X+1,Z),w=M.indexOf(\":\"),O=M.substring(0,w),z=O.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(X=Z+1,z)if(M.endsWith(\" text/event-stream\"))K=!0;else{V.#K=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),U.end();return}else if(O.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(Y=parseInt(M.substring(w+1).trim(),10),@isNaN(Y)||Y<=0){V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),U.end();return}if(K)break}else if(O.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(M.substring(w+1).trim()!==\"chunked\"){V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),U.end();return}if(Y=0,K)break}}V.#X=Y,V.#K=1,V.dispatchEvent(new Event(\"open\"));const L=F.substring(j+4);if(A.#V(V,L,0),V.#X>0){if(V.#F+=L.length,V.#F>=V.#X)V.#K=2,U.end()}return}case 1:if(A.#V(V,B.toString(),2),V.#X>0){if(V.#F+=B.byteLength,V.#F>=V.#X)V.#K=2,U.end()}return;default:break}},drain(U){const B=U.data;if(B.#K===0){const V=B.#O;if(V.length){const F=U.write(V);if(F!==V.length)U.data.#B=V.substring(F);else U.data.#B=\"\"}}},close:A.#w,end(U){A.#w(U).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(U){A.#w(U).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#w(U){const B=U.data;if(B.#$=null,B.#F=0,B.#K=2,B.#Q){if(B.#U)clearTimeout(B.#U);B.#U=setTimeout(A.#G,B.#H,B)}return B}constructor(U,B=@undefined){super();const V=new URL(U);this.#j=V.protocol===\"https:\",this.#Z=V,this.#K=2,process.nextTick(A.#G,this)}ref(){this.#U\?.ref(),this.#$\?.ref()}unref(){this.#U\?.unref(),this.#$\?.unref()}#Y(){if(this.#K!==2)return;const U=this.#Z,B=this.#j;this.#K=0,@Bun.connect({data:this,socket:A.#A,hostname:U.hostname,port:parseInt(U.port||(B\?\"443\":\"80\"),10),tls:B\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((V)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:V})),this.#Q){if(this.#U)this.#U.unref\?.();this.#U=setTimeout(A.#G,1000,this)}})}get url(){return this.#Z.href}get readyState(){return this.#K}close(){this.#Q=!1,this.#K=2,this.#$\?.unref(),this.#$\?.end()}get onopen(){return this.#M}get onerror(){return this.#W}get onmessage(){return this.#L}set onopen(U){if(this.#M)super.removeEventListener(\"close\",this.#M);super.addEventListener(\"open\",U),this.#M=U}set onerror(U){if(this.#W)super.removeEventListener(\"error\",this.#W);super.addEventListener(\"error\",U),this.#W=U}set onmessage(U){if(this.#L)super.removeEventListener(\"message\",this.#L);super.addEventListener(\"message\",U),this.#L=U}}return Object.defineProperty(A.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(A.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(A.prototype,\"CLOSED\",{enumerable:!0,value:2}),A[Symbol.for(\"CommonJS\")]=0,A})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/src/js/out/modules/node/assert.js b/src/js/out/modules/node/assert.js index 4086ef8d5..bdaa04547 100644 --- a/src/js/out/modules/node/assert.js +++ b/src/js/out/modules/node/assert.js @@ -1,53 +1,53 @@ -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],` +import U1 from"node:util";var w1=function(){throw new Error("CallTracker is not supported yet")},{Bun:K1}=globalThis[Symbol.for("Bun.lazy")]("primordials"),X1=K1.deepEquals,Y1=(b1,Z)=>function(){return Z||(0,b1[Object.keys(b1)[0]])((Z={exports:{}}).exports,Z),Z.exports},B1=Y1({"assert/build/internal/errors.js"(b1,Z){function J(T){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?J=function(w){return typeof w}:J=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},J(T)}function z(T,w){if(!(T instanceof w))throw new TypeError("Cannot call a class as a function")}function X(T,w){return w&&(J(w)==="object"||typeof w=="function")?w:U(T)}function U(T){if(T===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return T}function $(T){return $=Object.setPrototypeOf?Object.getPrototypeOf:function(w){return w.__proto__||Object.getPrototypeOf(w)},$(T)}function K(T,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");T.prototype=Object.create(w&&w.prototype,{constructor:{value:T,writable:!0,configurable:!0}}),w&&W(T,w)}function W(T,w){return W=Object.setPrototypeOf||function(O,F){return O.__proto__=F,O},W(T,w)}var Y={},B,V;function D(T,w,O){O||(O=Error);function F(I,P,A){return typeof w=="string"?w:w(I,P,A)}var N=function(I){K(P,I);function P(A,S,j){var R;return z(this,P),R=X(this,$(P).call(this,F(A,S,j))),R.code=T,R}return P}(O);Y[T]=N}function M(T,w){if(Array.isArray(T)){var O=T.length;return T=T.map(function(F){return String(F)}),O>2?"one of ".concat(w," ").concat(T.slice(0,O-1).join(", "),", or ")+T[O-1]:O===2?"one of ".concat(w," ").concat(T[0]," or ").concat(T[1]):"of ".concat(w," ").concat(T[0])}else return"of ".concat(w," ").concat(String(T))}function q(T,w,O){return T.substr(!O||O<0?0:+O,w.length)===w}function v(T,w,O){return(O===void 0||O>T.length)&&(O=T.length),T.substring(O-w.length,O)===w}function G(T,w,O){return typeof O!="number"&&(O=0),O+w.length>T.length?!1:T.indexOf(w,O)!==-1}D("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),D("ERR_INVALID_ARG_TYPE",function(T,w,O){B===void 0&&(B=$1()),B(typeof T=="string","'name' must be a string");var F;typeof w=="string"&&q(w,"not ")?(F="must not be",w=w.replace(/^not /,"")):F="must be";var N;if(v(T," argument"))N="The ".concat(T," ").concat(F," ").concat(M(w,"type"));else{var I=G(T,".")?"property":"argument";N='The "'.concat(T,'" ').concat(I," ").concat(F," ").concat(M(w,"type"))}return N+=". Received type ".concat(J(O)),N},TypeError),D("ERR_INVALID_ARG_VALUE",function(T,w){var O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid",F=V.inspect(w);return F.length>128&&(F="".concat(F.slice(0,128),"...")),"The argument '".concat(T,"' ").concat(O,". Received ").concat(F)},TypeError,RangeError),D("ERR_INVALID_RETURN_VALUE",function(T,w,O){var F;return O&&O.constructor&&O.constructor.name?F="instance of ".concat(O.constructor.name):F="type ".concat(J(O)),"Expected ".concat(T,' to be returned from the "').concat(w,'"')+" function but got ".concat(F,".")},TypeError),D("ERR_MISSING_ARGS",function(){for(var T=arguments.length,w=new Array(T),O=0;O0,"At least one arg needs to be specified");var F="The ",N=w.length;switch(w=w.map(function(I){return'"'.concat(I,'"')}),N){case 1:F+="".concat(w[0]," argument");break;case 2:F+="".concat(w[0]," and ").concat(w[1]," arguments");break;default:F+=w.slice(0,N-1).join(", "),F+=", and ".concat(w[N-1]," arguments");break}return"".concat(F," must be specified")},TypeError),Z.exports.codes=Y}}),G1=Y1({"assert/build/internal/assert/assertion_error.js"(b1,Z){function J(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 I="",P="",A="",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(m){k[m]=b[m]}),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 m="",x="",y=0,g="",d=!1,_=C(b),u=_.split(` +`),n=C(h).split(` +`),i=0,p="";if(k==="strictEqual"&&G(b)==="object"&&G(h)==="object"&&b!==null&&h!==null&&(k="strictEqualObject"),u.length===1&&n.length===1&&u[0]!==n[0]){var l=u[0].length+n[0].length;if(l<=R){if((G(b)!=="object"||b===null)&&(G(h)!=="object"||h===null)&&(b!==0||h!==0))return"".concat(j[k],` -`)+"".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(u[0]," !== ").concat(n[0],` +`)}else if(k!=="strictEqualObject"){var c=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(l2&&(p=` + `.concat(N(" ",i),"^"),i=0)}}}for(var o=u[u.length-1],a=n[n.length-1];o===a&&(i++<2?g=` + `.concat(o).concat(g):m=o,u.pop(),n.pop(),!(u.length===0||n.length===0));)o=u[u.length-1],a=n[n.length-1];var t=Math.max(u.length,n.length);if(t===0){var r=_.split(` +`);if(r.length>30)for(r[26]="".concat(I,"...").concat(S);r.length>27;)r.pop();return"".concat(j.notIdentical,` -`).concat(t.join(` +`).concat(r.join(` `),` -`)}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,` +`)}i>3&&(g=` +`.concat(I,"...").concat(S).concat(g),d=!0),m!==""&&(g=` + `.concat(m).concat(g),m="");var s=0,e=j[k]+` +`.concat(P,"+ actual").concat(S," ").concat(A,"- expected").concat(S),H1=" ".concat(I,"...").concat(S," Lines skipped");for(i=0;i1&&i>2&&(Q1>4?(x+=` +`.concat(I,"...").concat(S),d=!0):Q1>3&&(x+=` + `.concat(n[i-2]),s++),x+=` + `.concat(n[i-1]),s++),y=i,m+=` +`.concat(A,"-").concat(S," ").concat(n[i]),s++;else if(n.length1&&i>2&&(Q1>4?(x+=` +`.concat(I,"...").concat(S),d=!0):Q1>3&&(x+=` + `.concat(u[i-2]),s++),x+=` + `.concat(u[i-1]),s++),y=i,x+=` +`.concat(P,"+").concat(S," ").concat(u[i]),s++;else{var Z1=n[i],J1=u[i],z1=J1!==Z1&&(!F(J1,",")||J1.slice(0,-1)!==Z1);z1&&F(Z1,",")&&Z1.slice(0,-1)===J1&&(z1=!1,J1+=","),z1?(Q1>1&&i>2&&(Q1>4?(x+=` +`.concat(I,"...").concat(S),d=!0):Q1>3&&(x+=` + `.concat(u[i-2]),s++),x+=` + `.concat(u[i-1]),s++),y=i,x+=` +`.concat(P,"+").concat(S," ").concat(J1),m+=` +`.concat(A,"-").concat(S," ").concat(Z1),s+=2):(x+=m,m="",(Q1===1||i===0)&&(x+=` + `.concat(J1),s++))}if(s>20&&i30)for(i[26]="".concat(I,"...").concat(S);i.length>27;)i.pop();i.length===1?m=K(this,v(h).call(this,"".concat(n," ").concat(i[0]))):m=K(this,v(h).call(this,"".concat(n,` -`).concat(n.join(` +`).concat(i.join(` `),` -`)))}else{var i=f(g),p="",l=S[x];x==="notDeepEqual"||x==="notEqual"?(i="".concat(S[x],` +`)))}else{var p=C(d),l="",c=j[y];y==="notDeepEqual"||y==="notEqual"?(p="".concat(j[y],` -`).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(p),p.length>1024&&(p="".concat(p.slice(0,1021),"..."))):(l="".concat(C(_)),p.length>512&&(p="".concat(p.slice(0,509),"...")),l.length>512&&(l="".concat(l.slice(0,509),"...")),y==="deepEqual"||y==="equal"?p="".concat(c,` -`).concat(i,` +`).concat(p,` should equal -`):p=" ".concat(x," ").concat(p)),k=$(this,q(b).call(this,"".concat(i).concat(p)))}return Error.stackTraceLimit=_,k.generatedMessage=!m,Object.defineProperty(K(k),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),k.code="ERR_ASSERTION",k.actual=g,k.expected=d,k.operator=x,Error.captureStackTrace&&Error.captureStackTrace(K(k),y),k.stack,k.name="AssertionError",$(k)}return U(b,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:G.custom,value:function(h,k){return G(this,Z({},k,{customInspect:!1,depth:0}))}}]),b}(Y(Error));Q.exports=E}}),U1=W1({"assert/build/assert.js"(H,Q){function Z(x){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Z=function(y){return typeof y}:Z=function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y},Z(x)}function J(x,y){if(!(x instanceof y))throw new TypeError("Cannot call a class as a function")}var z=Y1(),X=z.codes,U=X.ERR_AMBIGUOUS_ARGUMENT,$=X.ERR_INVALID_ARG_TYPE,K=X.ERR_INVALID_ARG_VALUE,W=X.ERR_INVALID_RETURN_VALUE,Y=X.ERR_MISSING_ARGS,B=B1(),V=X1,D=V.inspect,M=X1.types,q=M.isPromise,v=M.isRegExp,G=Object.assign,T=Object.is,w=new Map,O=!1,F=Q.exports=S,N={};function I(x){throw x.message instanceof Error?x.message:new B(x)}function P(x,y,g,d,_){var u=arguments.length,n;if(u===0)n="Failed";else if(u===1)g=x,x=void 0;else{if(O===!1){O=!0;var i=process.emitWarning?process.emitWarning:console.warn.bind(console);i("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 p={actual:x,expected:y,operator:d===void 0?"fail":d,stackStartFn:_||P};g!==void 0&&(p.message=g);var l=new B(p);throw n&&(l.message=n,l.generatedMessage=!0),l}F.fail=P,F.AssertionError=B;function A(x,y,g,d){if(!g){var _=!1;if(y===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:x});throw u.generatedMessage=_,u}}function S(){for(var x=arguments.length,y=new Array(x),g=0;g1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?d-1:0),u=1;u1?d-1:0),u=1;u1?d-1:0),u=1;u1?d-1:0),u=1;ufunction(){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}; +import{StringDecoder as a$} from"node:string_decoder";import*as e$ from"node:buffer";import*as h$ from"node:stream";var s$=Object.defineProperty;var t$=Object.getOwnPropertyNames;var r$=536870888,c$=globalThis.Buffer,d$=globalThis.crypto,i$=d$;var $Q=(X,K)=>function(){return K||(0,X[t$(X)[0]])((K={exports:{}}).exports,K),K.exports},QQ=(X,K)=>{for(var x0 in K)s$(X,x0,{get:K[x0],enumerable:!0})};var YQ=$Q({"node_modules/safe-buffer/index.js"(X,K){var x0=e$,G=x0.Buffer;function Y(Z,Q){for(var U in Z)Q[U]=Z[U]}G.from&&G.alloc&&G.allocUnsafe&&G.allocUnsafeSlow?K.exports=x0:(Y(x0,X),X.Buffer=$);function $(Z,Q,U){return G(Z,Q,U)}$.prototype=Object.create(G.prototype),Y(G,$),$.from=function(Z,Q,U){if(typeof Z=="number")throw new TypeError("Argument must not be a number");return G(Z,Q,U)},$.alloc=function(Z,Q,U){if(typeof Z!="number")throw new TypeError("Argument must be a number");var V=G(Z);return Q!==void 0?typeof U=="string"?V.fill(Q,U):V.fill(Q):V.fill(0),V},$.allocUnsafe=function(Z){if(typeof Z!="number")throw new TypeError("Argument must be a number");return G(Z)},$.allocUnsafeSlow=function(Z){if(typeof Z!="number")throw new TypeError("Argument must be a number");return x0.SlowBuffer(Z)}}}),ZQ=$Q({"node_modules/randombytes/browser.js"(X,K){var x0=65536,G=4294967295;function Y(){throw new Error(`Secure random number generation is not supported by this browser. +Use Chrome, Firefox or Internet Explorer 11`)}var $=YQ().Buffer,Z=i$;Z&&Z.getRandomValues?K.exports=Q:K.exports=Y;function Q(U,V){if(U>G)throw new RangeError("requested too many random bytes");var B0=$.allocUnsafe(U);if(U>0)if(U>x0)for(var H=0;H=this._blockSize;){for(var B0=this._blockOffset;B00;++H)this._length[H]+=y0,y0=this._length[H]/4294967296|0,y0>0&&(this._length[H]-=4294967296*y0);return this},$.prototype._update=function(){throw new Error("_update is not implemented")},$.prototype.digest=function(Z){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var Q=this._digest();Z!==void 0&&(Q=Q.toString(Z)),this._block.fill(0),this._blockOffset=0;for(var U=0;U<4;++U)this._length[U]=0;return Q},$.prototype._digest=function(){throw new Error("_digest is not implemented")},K.exports=$}}),I0=$Q({"node_modules/md5.js/index.js"(X,K){var x0=X0(),G=K0(),Y=YQ().Buffer,$=new Array(16);function Z(){G.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}x0(Z,G),Z.prototype._update=function(){for(var y0=$,W=0;W<16;++W)y0[W]=this._block.readInt32LE(W*4);var w0=this._a,E=this._b,p0=this._c,T=this._d;w0=U(w0,E,p0,T,y0[0],3614090360,7),T=U(T,w0,E,p0,y0[1],3905402710,12),p0=U(p0,T,w0,E,y0[2],606105819,17),E=U(E,p0,T,w0,y0[3],3250441966,22),w0=U(w0,E,p0,T,y0[4],4118548399,7),T=U(T,w0,E,p0,y0[5],1200080426,12),p0=U(p0,T,w0,E,y0[6],2821735955,17),E=U(E,p0,T,w0,y0[7],4249261313,22),w0=U(w0,E,p0,T,y0[8],1770035416,7),T=U(T,w0,E,p0,y0[9],2336552879,12),p0=U(p0,T,w0,E,y0[10],4294925233,17),E=U(E,p0,T,w0,y0[11],2304563134,22),w0=U(w0,E,p0,T,y0[12],1804603682,7),T=U(T,w0,E,p0,y0[13],4254626195,12),p0=U(p0,T,w0,E,y0[14],2792965006,17),E=U(E,p0,T,w0,y0[15],1236535329,22),w0=V(w0,E,p0,T,y0[1],4129170786,5),T=V(T,w0,E,p0,y0[6],3225465664,9),p0=V(p0,T,w0,E,y0[11],643717713,14),E=V(E,p0,T,w0,y0[0],3921069994,20),w0=V(w0,E,p0,T,y0[5],3593408605,5),T=V(T,w0,E,p0,y0[10],38016083,9),p0=V(p0,T,w0,E,y0[15],3634488961,14),E=V(E,p0,T,w0,y0[4],3889429448,20),w0=V(w0,E,p0,T,y0[9],568446438,5),T=V(T,w0,E,p0,y0[14],3275163606,9),p0=V(p0,T,w0,E,y0[3],4107603335,14),E=V(E,p0,T,w0,y0[8],1163531501,20),w0=V(w0,E,p0,T,y0[13],2850285829,5),T=V(T,w0,E,p0,y0[2],4243563512,9),p0=V(p0,T,w0,E,y0[7],1735328473,14),E=V(E,p0,T,w0,y0[12],2368359562,20),w0=B0(w0,E,p0,T,y0[5],4294588738,4),T=B0(T,w0,E,p0,y0[8],2272392833,11),p0=B0(p0,T,w0,E,y0[11],1839030562,16),E=B0(E,p0,T,w0,y0[14],4259657740,23),w0=B0(w0,E,p0,T,y0[1],2763975236,4),T=B0(T,w0,E,p0,y0[4],1272893353,11),p0=B0(p0,T,w0,E,y0[7],4139469664,16),E=B0(E,p0,T,w0,y0[10],3200236656,23),w0=B0(w0,E,p0,T,y0[13],681279174,4),T=B0(T,w0,E,p0,y0[0],3936430074,11),p0=B0(p0,T,w0,E,y0[3],3572445317,16),E=B0(E,p0,T,w0,y0[6],76029189,23),w0=B0(w0,E,p0,T,y0[9],3654602809,4),T=B0(T,w0,E,p0,y0[12],3873151461,11),p0=B0(p0,T,w0,E,y0[15],530742520,16),E=B0(E,p0,T,w0,y0[2],3299628645,23),w0=H(w0,E,p0,T,y0[0],4096336452,6),T=H(T,w0,E,p0,y0[7],1126891415,10),p0=H(p0,T,w0,E,y0[14],2878612391,15),E=H(E,p0,T,w0,y0[5],4237533241,21),w0=H(w0,E,p0,T,y0[12],1700485571,6),T=H(T,w0,E,p0,y0[3],2399980690,10),p0=H(p0,T,w0,E,y0[10],4293915773,15),E=H(E,p0,T,w0,y0[1],2240044497,21),w0=H(w0,E,p0,T,y0[8],1873313359,6),T=H(T,w0,E,p0,y0[15],4264355552,10),p0=H(p0,T,w0,E,y0[6],2734768916,15),E=H(E,p0,T,w0,y0[13],1309151649,21),w0=H(w0,E,p0,T,y0[4],4149444226,6),T=H(T,w0,E,p0,y0[11],3174756917,10),p0=H(p0,T,w0,E,y0[2],718787259,15),E=H(E,p0,T,w0,y0[9],3951481745,21),this._a=this._a+w0|0,this._b=this._b+E|0,this._c=this._c+p0|0,this._d=this._d+T|0},Z.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 y0=Y.allocUnsafe(16);return y0.writeInt32LE(this._a,0),y0.writeInt32LE(this._b,4),y0.writeInt32LE(this._c,8),y0.writeInt32LE(this._d,12),y0};function Q(y0,W){return y0<>>32-W}function U(y0,W,w0,E,p0,T,f0){return Q(y0+(W&w0|~W&E)+p0+T|0,f0)+W|0}function V(y0,W,w0,E,p0,T,f0){return Q(y0+(W&E|w0&~E)+p0+T|0,f0)+W|0}function B0(y0,W,w0,E,p0,T,f0){return Q(y0+(W^w0^E)+p0+T|0,f0)+W|0}function H(y0,W,w0,E,p0,T,f0){return Q(y0+(w0^(W|~E))+p0+T|0,f0)+W|0}K.exports=Z}}),O0=$Q({"node_modules/ripemd160/index.js"(X,K){var x0=c$,G=X0(),Y=K0(),$=new Array(16),Z=[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],Q=[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],U=[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],V=[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],B0=[0,1518500249,1859775393,2400959708,2840853838],H=[1352829926,1548603684,1836072691,2053994217,0];function y0(){Y.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}G(y0,Y),y0.prototype._update=function(){for(var D=$,c0=0;c0<16;++c0)D[c0]=this._block.readInt32LE(c0*4);for(var C=this._a|0,h0=this._b|0,L=this._c|0,d0=this._d|0,R=this._e|0,b0=this._a|0,P=this._b|0,l0=this._c|0,z=this._d|0,o0=this._e|0,M=0;M<80;M+=1){var u0,S;M<16?(u0=w0(C,h0,L,d0,R,D[Z[M]],B0[0],U[M]),S=f0(b0,P,l0,z,o0,D[Q[M]],H[0],V[M])):M<32?(u0=E(C,h0,L,d0,R,D[Z[M]],B0[1],U[M]),S=T(b0,P,l0,z,o0,D[Q[M]],H[1],V[M])):M<48?(u0=p0(C,h0,L,d0,R,D[Z[M]],B0[2],U[M]),S=p0(b0,P,l0,z,o0,D[Q[M]],H[2],V[M])):M<64?(u0=T(C,h0,L,d0,R,D[Z[M]],B0[3],U[M]),S=E(b0,P,l0,z,o0,D[Q[M]],H[3],V[M])):(u0=f0(C,h0,L,d0,R,D[Z[M]],B0[4],U[M]),S=w0(b0,P,l0,z,o0,D[Q[M]],H[4],V[M])),C=R,R=d0,d0=W(L,10),L=h0,h0=u0,b0=o0,o0=z,z=W(l0,10),l0=P,P=S}var n0=this._b+L+z|0;this._b=this._c+d0+o0|0,this._c=this._d+R+b0|0,this._d=this._e+C+P|0,this._e=this._a+h0+l0|0,this._a=n0},y0.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=x0.alloc?x0.alloc(20):new x0(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 W(D,c0){return D<>>32-c0}function w0(D,c0,C,h0,L,d0,R,b0){return W(D+(c0^C^h0)+d0+R|0,b0)+L|0}function E(D,c0,C,h0,L,d0,R,b0){return W(D+(c0&C|~c0&h0)+d0+R|0,b0)+L|0}function p0(D,c0,C,h0,L,d0,R,b0){return W(D+((c0|~C)^h0)+d0+R|0,b0)+L|0}function T(D,c0,C,h0,L,d0,R,b0){return W(D+(c0&h0|C&~h0)+d0+R|0,b0)+L|0}function f0(D,c0,C,h0,L,d0,R,b0){return W(D+(c0^(C|~h0))+d0+R|0,b0)+L|0}K.exports=y0}}),J0=$Q({"node_modules/sha.js/hash.js"(X,K){var x0=YQ().Buffer;function G(Y,$){this._block=x0.alloc(Y),this._finalSize=$,this._blockSize=Y,this._len=0}G.prototype.update=function(Y,$){typeof Y=="string"&&($=$||"utf8",Y=x0.from(Y,$));for(var Z=this._block,Q=this._blockSize,U=Y.length,V=this._len,B0=0;B0=this._finalSize&&(this._update(this._block),this._block.fill(0));var Z=this._len*8;if(Z<=4294967295)this._block.writeUInt32BE(Z,this._blockSize-4);else{var Q=(Z&4294967295)>>>0,U=(Z-Q)/4294967296;this._block.writeUInt32BE(U,this._blockSize-8),this._block.writeUInt32BE(Q,this._blockSize-4)}this._update(this._block);var V=this._hash();return Y?V.toString(Y):V},G.prototype._update=function(){throw new Error("_update must be implemented by subclass")},K.exports=G}}),F0=$Q({"node_modules/sha.js/sha.js"(X,K){var x0=X0(),G=J0(),Y=YQ().Buffer,$=[1518500249,1859775393,-1894007588,-899497514],Z=new Array(80);function Q(){this.init(),this._w=Z,G.call(this,64,56)}x0(Q,G),Q.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function U(H){return H<<5|H>>>27}function V(H){return H<<30|H>>>2}function B0(H,y0,W,w0){return H===0?y0&W|~y0&w0:H===2?y0&W|y0&w0|W&w0:y0^W^w0}Q.prototype._update=function(H){for(var y0=this._w,W=this._a|0,w0=this._b|0,E=this._c|0,p0=this._d|0,T=this._e|0,f0=0;f0<16;++f0)y0[f0]=H.readInt32BE(f0*4);for(;f0<80;++f0)y0[f0]=y0[f0-3]^y0[f0-8]^y0[f0-14]^y0[f0-16];for(var D=0;D<80;++D){var c0=~~(D/20),C=U(W)+B0(c0,w0,E,p0)+T+y0[D]+$[c0]|0;T=p0,p0=E,E=V(w0),w0=W,W=C}this._a=W+this._a|0,this._b=w0+this._b|0,this._c=E+this._c|0,this._d=p0+this._d|0,this._e=T+this._e|0},Q.prototype._hash=function(){var H=Y.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},K.exports=Q}}),A0=$Q({"node_modules/sha.js/sha1.js"(X,K){var x0=X0(),G=J0(),Y=YQ().Buffer,$=[1518500249,1859775393,-1894007588,-899497514],Z=new Array(80);function Q(){this.init(),this._w=Z,G.call(this,64,56)}x0(Q,G),Q.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function U(y0){return y0<<1|y0>>>31}function V(y0){return y0<<5|y0>>>27}function B0(y0){return y0<<30|y0>>>2}function H(y0,W,w0,E){return y0===0?W&w0|~W&E:y0===2?W&w0|W&E|w0&E:W^w0^E}Q.prototype._update=function(y0){for(var W=this._w,w0=this._a|0,E=this._b|0,p0=this._c|0,T=this._d|0,f0=this._e|0,D=0;D<16;++D)W[D]=y0.readInt32BE(D*4);for(;D<80;++D)W[D]=U(W[D-3]^W[D-8]^W[D-14]^W[D-16]);for(var c0=0;c0<80;++c0){var C=~~(c0/20),h0=V(w0)+H(C,E,p0,T)+f0+W[c0]+$[C]|0;f0=T,T=p0,p0=B0(E),E=w0,w0=h0}this._a=w0+this._a|0,this._b=E+this._b|0,this._c=p0+this._c|0,this._d=T+this._d|0,this._e=f0+this._e|0},Q.prototype._hash=function(){var y0=Y.allocUnsafe(20);return y0.writeInt32BE(this._a|0,0),y0.writeInt32BE(this._b|0,4),y0.writeInt32BE(this._c|0,8),y0.writeInt32BE(this._d|0,12),y0.writeInt32BE(this._e|0,16),y0},K.exports=Q}}),H0=$Q({"node_modules/sha.js/sha256.js"(X,K){var x0=X0(),G=J0(),Y=YQ().Buffer,$=[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],Z=new Array(64);function Q(){this.init(),this._w=Z,G.call(this,64,56)}x0(Q,G),Q.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 U(w0,E,p0){return p0^w0&(E^p0)}function V(w0,E,p0){return w0&E|p0&(w0|E)}function B0(w0){return(w0>>>2|w0<<30)^(w0>>>13|w0<<19)^(w0>>>22|w0<<10)}function H(w0){return(w0>>>6|w0<<26)^(w0>>>11|w0<<21)^(w0>>>25|w0<<7)}function y0(w0){return(w0>>>7|w0<<25)^(w0>>>18|w0<<14)^w0>>>3}function W(w0){return(w0>>>17|w0<<15)^(w0>>>19|w0<<13)^w0>>>10}Q.prototype._update=function(w0){for(var E=this._w,p0=this._a|0,T=this._b|0,f0=this._c|0,D=this._d|0,c0=this._e|0,C=this._f|0,h0=this._g|0,L=this._h|0,d0=0;d0<16;++d0)E[d0]=w0.readInt32BE(d0*4);for(;d0<64;++d0)E[d0]=W(E[d0-2])+E[d0-7]+y0(E[d0-15])+E[d0-16]|0;for(var R=0;R<64;++R){var b0=L+H(c0)+U(c0,C,h0)+$[R]+E[R]|0,P=B0(p0)+V(p0,T,f0)|0;L=h0,h0=C,C=c0,c0=D+b0|0,D=f0,f0=T,T=p0,p0=b0+P|0}this._a=p0+this._a|0,this._b=T+this._b|0,this._c=f0+this._c|0,this._d=D+this._d|0,this._e=c0+this._e|0,this._f=C+this._f|0,this._g=h0+this._g|0,this._h=L+this._h|0},Q.prototype._hash=function(){var w0=Y.allocUnsafe(32);return w0.writeInt32BE(this._a,0),w0.writeInt32BE(this._b,4),w0.writeInt32BE(this._c,8),w0.writeInt32BE(this._d,12),w0.writeInt32BE(this._e,16),w0.writeInt32BE(this._f,20),w0.writeInt32BE(this._g,24),w0.writeInt32BE(this._h,28),w0},K.exports=Q}}),W0=$Q({"node_modules/sha.js/sha224.js"(X,K){var x0=X0(),G=H0(),Y=J0(),$=YQ().Buffer,Z=new Array(64);function Q(){this.init(),this._w=Z,Y.call(this,64,56)}x0(Q,G),Q.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},Q.prototype._hash=function(){var U=$.allocUnsafe(28);return U.writeInt32BE(this._a,0),U.writeInt32BE(this._b,4),U.writeInt32BE(this._c,8),U.writeInt32BE(this._d,12),U.writeInt32BE(this._e,16),U.writeInt32BE(this._f,20),U.writeInt32BE(this._g,24),U},K.exports=Q}}),E0=$Q({"node_modules/sha.js/sha512.js"(X,K){var x0=X0(),G=J0(),Y=YQ().Buffer,$=[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],Z=new Array(160);function Q(){this.init(),this._w=Z,G.call(this,128,112)}x0(Q,G),Q.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 U(T,f0,D){return D^T&(f0^D)}function V(T,f0,D){return T&f0|D&(T|f0)}function B0(T,f0){return(T>>>28|f0<<4)^(f0>>>2|T<<30)^(f0>>>7|T<<25)}function H(T,f0){return(T>>>14|f0<<18)^(T>>>18|f0<<14)^(f0>>>9|T<<23)}function y0(T,f0){return(T>>>1|f0<<31)^(T>>>8|f0<<24)^T>>>7}function W(T,f0){return(T>>>1|f0<<31)^(T>>>8|f0<<24)^(T>>>7|f0<<25)}function w0(T,f0){return(T>>>19|f0<<13)^(f0>>>29|T<<3)^T>>>6}function E(T,f0){return(T>>>19|f0<<13)^(f0>>>29|T<<3)^(T>>>6|f0<<26)}function p0(T,f0){return T>>>0>>0?1:0}Q.prototype._update=function(T){for(var f0=this._w,D=this._ah|0,c0=this._bh|0,C=this._ch|0,h0=this._dh|0,L=this._eh|0,d0=this._fh|0,R=this._gh|0,b0=this._hh|0,P=this._al|0,l0=this._bl|0,z=this._cl|0,o0=this._dl|0,M=this._el|0,u0=this._fl|0,S=this._gl|0,n0=this._hl|0,v=0;v<32;v+=2)f0[v]=T.readInt32BE(v*4),f0[v+1]=T.readInt32BE(v*4+4);for(;v<160;v+=2){var s0=f0[v-30],I=f0[v-30+1],t0=y0(s0,I),m0=W(I,s0);s0=f0[v-4],I=f0[v-4+1];var a0=w0(s0,I),q=E(I,s0),e0=f0[v-14],r0=f0[v-14+1],i0=f0[v-32],j=f0[v-32+1],$$=m0+r0|0,k=t0+e0+p0($$,m0)|0;$$=$$+q|0,k=k+a0+p0($$,q)|0,$$=$$+j|0,k=k+i0+p0($$,j)|0,f0[v]=k,f0[v+1]=$$}for(var Q$=0;Q$<160;Q$+=2){k=f0[Q$],$$=f0[Q$+1];var g=V(D,c0,C),Y$=V(P,l0,z),_=B0(D,P),Z$=B0(P,D),N=H(L,M),G$=H(M,L),x=$[Q$],V$=$[Q$+1],B=U(L,d0,R),U$=U(M,u0,S),y=n0+G$|0,X$=b0+N+p0(y,n0)|0;y=y+U$|0,X$=X$+B+p0(y,U$)|0,y=y+V$|0,X$=X$+x+p0(y,V$)|0,y=y+$$|0,X$=X$+k+p0(y,$$)|0;var w=Z$+Y$|0,K$=_+g+p0(w,Z$)|0;b0=R,n0=S,R=d0,S=u0,d0=L,u0=M,M=o0+y|0,L=h0+X$+p0(M,o0)|0,h0=C,o0=z,C=c0,z=l0,c0=D,l0=P,P=y+w|0,D=X$+K$+p0(P,y)|0}this._al=this._al+P|0,this._bl=this._bl+l0|0,this._cl=this._cl+z|0,this._dl=this._dl+o0|0,this._el=this._el+M|0,this._fl=this._fl+u0|0,this._gl=this._gl+S|0,this._hl=this._hl+n0|0,this._ah=this._ah+D+p0(this._al,P)|0,this._bh=this._bh+c0+p0(this._bl,l0)|0,this._ch=this._ch+C+p0(this._cl,z)|0,this._dh=this._dh+h0+p0(this._dl,o0)|0,this._eh=this._eh+L+p0(this._el,M)|0,this._fh=this._fh+d0+p0(this._fl,u0)|0,this._gh=this._gh+R+p0(this._gl,S)|0,this._hh=this._hh+b0+p0(this._hl,n0)|0},Q.prototype._hash=function(){var T=Y.allocUnsafe(64);function f0(D,c0,C){T.writeInt32BE(D,C),T.writeInt32BE(c0,C+4)}return f0(this._ah,this._al,0),f0(this._bh,this._bl,8),f0(this._ch,this._cl,16),f0(this._dh,this._dl,24),f0(this._eh,this._el,32),f0(this._fh,this._fl,40),f0(this._gh,this._gl,48),f0(this._hh,this._hl,56),T},K.exports=Q}}),T0=$Q({"node_modules/sha.js/sha384.js"(X,K){var x0=X0(),G=E0(),Y=J0(),$=YQ().Buffer,Z=new Array(160);function Q(){this.init(),this._w=Z,Y.call(this,128,112)}x0(Q,G),Q.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},Q.prototype._hash=function(){var U=$.allocUnsafe(48);function V(B0,H,y0){U.writeInt32BE(B0,y0),U.writeInt32BE(H,y0+4)}return V(this._ah,this._al,0),V(this._bh,this._bl,8),V(this._ch,this._cl,16),V(this._dh,this._dl,24),V(this._eh,this._el,32),V(this._fh,this._fl,40),U},K.exports=Q}}),D0=$Q({"node_modules/sha.js/index.js"(x0,K){var x0=K.exports=function(G){G=G.toLowerCase();var Y=x0[G];if(!Y)throw new Error(G+" is not supported (we accept pull requests)");return new Y};x0.sha=F0(),x0.sha1=A0(),x0.sha224=W0(),x0.sha256=H0(),x0.sha384=T0(),x0.sha512=E0()}}),C0=$Q({"node_modules/cipher-base/index.js"(X,K){var x0=YQ().Buffer,G=X0();function Y($){h$.Transform.call(this),this.hashMode=typeof $=="string",this.hashMode?this[$]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}G(Y,h$.Transform),Y.prototype.update=function($,Z,Q){typeof $=="string"&&($=x0.from($,Z));var U=this._update($);return this.hashMode?this:(Q&&(U=this._toString(U,Q)),U)},Y.prototype.setAutoPadding=function(){},Y.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},Y.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},Y.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},Y.prototype._transform=function($,Z,Q){var U;try{this.hashMode?this._update($):this.push(this._update($))}catch(V){U=V}finally{Q(U)}},Y.prototype._flush=function($){var Z;try{this.push(this.__final())}catch(Q){Z=Q}$(Z)},Y.prototype._finalOrDigest=function($){var Z=this.__final()||x0.alloc(0);return $&&(Z=this._toString(Z,$,!0)),Z},Y.prototype._toString=function($,Z,Q){if(this._decoder||(this._decoder=new a$(Z),this._encoding=Z),this._encoding!==Z)throw new Error("can't switch encodings");var U=this._decoder.write($);return Q&&(U+=this._decoder.end()),U},K.exports=Y}}),L0=$Q({"node_modules/create-hash/browser.js"(X,K){const x0=function $(Z,Q){this._options=Q,this._hasher=new sY(Z,Q),this._finalized=!1};x0.prototype=Object.create(h$.Transform.prototype),x0.prototype.update=function $(Z,Q){return this._checkFinalized(),this._hasher.update(Z,Q),this},x0.prototype.digest=function $(Z,Q){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(Z,Q)},x0.prototype._checkFinalized=function $(){if(this._finalized){var Z=new Error("Digest already called");throw Z.code="ERR_CRYPTO_HASH_FINALIZED",Z}},x0.prototype.copy=function $(){const Z=Object.create(x0.prototype);return Z._options=this._options,Z._hasher=this._hasher.copy(),Z._finalized=this._finalized,Z};const G={__proto__:h$.Transform.prototype,...x0.prototype,_transform($,Z,Q){this.update($,Z),Q&&Q()},_flush($){this.push(this.digest()),$()}},Y=["_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 $ of Y)Object.defineProperty(x0.prototype,$,{get(){return Object.setPrototypeOf(this,G),h$.Transform.call(this,this._options),this[$]},enumerable:!1,configurable:!0});K.exports=function $(Z){return new x0(Z)},K.exports.createHash=K.exports,K.exports.Hash=x0}}),R0=$Q({"node_modules/create-hmac/legacy.js"(X,K){var x0=X0(),G=YQ().Buffer,Y=C0(),$=G.alloc(128),Z=64;function Q(U,V){Y.call(this,"digest"),typeof V=="string"&&(V=G.from(V)),this._alg=U,this._key=V,V.length>Z?V=U(V):V.lengthW){var w0=H==="rmd160"?new Q:U(H);y0=w0.update(y0).digest()}else y0.lengthx0||Y!==Y)throw new TypeError("Bad key length")}}}),q0=$Q({"node_modules/pbkdf2/lib/default-encoding.js"(X,K){var x0;global.process&&global.process.browser?x0="utf-8":global.process&&global.process.version?(G=parseInt(process.version.split(".")[0].slice(1),10),x0=G>=6?"utf-8":"binary"):x0="utf-8";var G;K.exports=x0}}),j0=$Q({"node_modules/pbkdf2/lib/to-buffer.js"(X,K){var x0=YQ().Buffer;K.exports=function(G,Y,$){if(x0.isBuffer(G))return G;if(typeof G=="string")return x0.from(G,Y);if(ArrayBuffer.isView(G))return x0.from(G.buffer);throw new TypeError($+" must be a string, a Buffer, a typed array or a DataView")}}}),k0=$Q({"node_modules/pbkdf2/lib/sync-browser.js"(X,K){var x0=P0(),G=O0(),Y=D0(),$=YQ().Buffer,Z=v0(),Q=q0(),U=j0(),V=$.alloc(128),B0={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function H(w0,E,p0){var T=y0(w0),f0=w0==="sha512"||w0==="sha384"?128:64;E.length>f0?E=T(E):E.length>>0},X.writeUInt32BE=function(Y,$,Z){Y[0+Z]=$>>>24,Y[1+Z]=$>>>16&255,Y[2+Z]=$>>>8&255,Y[3+Z]=$&255},X.ip=function(Y,$,Z,Q){for(var U=0,V=0,B0=6;B0>=0;B0-=2){for(var H=0;H<=24;H+=8)U<<=1,U|=$>>>H+B0&1;for(var H=0;H<=24;H+=8)U<<=1,U|=Y>>>H+B0&1}for(var B0=6;B0>=0;B0-=2){for(var H=1;H<=25;H+=8)V<<=1,V|=$>>>H+B0&1;for(var H=1;H<=25;H+=8)V<<=1,V|=Y>>>H+B0&1}Z[Q+0]=U>>>0,Z[Q+1]=V>>>0},X.rip=function(Y,$,Z,Q){for(var U=0,V=0,B0=0;B0<4;B0++)for(var H=24;H>=0;H-=8)U<<=1,U|=$>>>H+B0&1,U<<=1,U|=Y>>>H+B0&1;for(var B0=4;B0<8;B0++)for(var H=24;H>=0;H-=8)V<<=1,V|=$>>>H+B0&1,V<<=1,V|=Y>>>H+B0&1;Z[Q+0]=U>>>0,Z[Q+1]=V>>>0},X.pc1=function(Y,$,Z,Q){for(var U=0,V=0,B0=7;B0>=5;B0--){for(var H=0;H<=24;H+=8)U<<=1,U|=$>>H+B0&1;for(var H=0;H<=24;H+=8)U<<=1,U|=Y>>H+B0&1}for(var H=0;H<=24;H+=8)U<<=1,U|=$>>H+B0&1;for(var B0=1;B0<=3;B0++){for(var H=0;H<=24;H+=8)V<<=1,V|=$>>H+B0&1;for(var H=0;H<=24;H+=8)V<<=1,V|=Y>>H+B0&1}for(var H=0;H<=24;H+=8)V<<=1,V|=Y>>H+B0&1;Z[Q+0]=U>>>0,Z[Q+1]=V>>>0},X.r28shl=function(Y,$){return Y<<$&268435455|Y>>>28-$};var K=[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];X.pc2=function(Y,$,Z,Q){for(var U=0,V=0,B0=K.length>>>1,H=0;H>>K[H]&1;for(var H=B0;H>>K[H]&1;Z[Q+0]=U>>>0,Z[Q+1]=V>>>0},X.expand=function(Y,$,Z){var Q=0,U=0;Q=(Y&1)<<5|Y>>>27;for(var V=23;V>=15;V-=4)Q<<=6,Q|=Y>>>V&63;for(var V=11;V>=3;V-=4)U|=Y>>>V&63,U<<=6;U|=(Y&31)<<1|Y>>>31,$[Z+0]=Q>>>0,$[Z+1]=U>>>0};var x0=[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];X.substitute=function(Y,$){for(var Z=0,Q=0;Q<4;Q++){var U=Y>>>18-Q*6&63,V=x0[Q*64+U];Z<<=4,Z|=V}for(var Q=0;Q<4;Q++){var U=$>>>18-Q*6&63,V=x0[256+Q*64+U];Z<<=4,Z|=V}return Z>>>0};var G=[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];X.permute=function(Y){for(var $=0,Z=0;Z>>G[Z]&1;return $>>>0},X.padSplit=function(Y,$,Z){for(var Q=Y.toString(2);Q.length<$;)Q="0"+Q;for(var U=[],V=0;V<$;V+=Z)U.push(Q.slice(V,V+Z));return U.join(" ")}}}),N0=$Q({"node_modules/minimalistic-assert/index.js"(X,K){K.exports=x0;function x0(G,Y){if(!G)throw new Error(Y||"Assertion failed")}x0.equal=function(G,Y,$){if(G!=Y)throw new Error($||"Assertion failed: "+G+" != "+Y)}}}),VQ=$Q({"node_modules/des.js/lib/des/cipher.js"(X,K){var x0=N0();function G(Y){this.options=Y,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}K.exports=G,G.prototype._init=function(){},G.prototype.update=function(Y){return Y.length===0?[]:this.type==="decrypt"?this._updateDecrypt(Y):this._updateEncrypt(Y)},G.prototype._buffer=function(Y,$){for(var Z=Math.min(this.buffer.length-this.bufferOff,Y.length-$),Q=0;Q0;Q--)$+=this._buffer(Y,$),Z+=this._flushBuffer(U,Z);return $+=this._buffer(Y,$),U},G.prototype.final=function(Y){var $;Y&&($=this.update(Y));var Z;return this.type==="encrypt"?Z=this._finalEncrypt():Z=this._finalDecrypt(),$?$.concat(Z):Z},G.prototype._pad=function(Y,$){if($===0)return!1;for(;$>>1];H=Y.r28shl(H,w0),y0=Y.r28shl(y0,w0),Y.pc2(H,y0,V.keys,W)}},Q.prototype._update=function(V,B0,H,y0){var W=this._desState,w0=Y.readUInt32BE(V,B0),E=Y.readUInt32BE(V,B0+4);Y.ip(w0,E,W.tmp,0),w0=W.tmp[0],E=W.tmp[1],this.type==="encrypt"?this._encrypt(W,w0,E,W.tmp,0):this._decrypt(W,w0,E,W.tmp,0),w0=W.tmp[0],E=W.tmp[1],Y.writeUInt32BE(H,w0,y0),Y.writeUInt32BE(H,E,y0+4)},Q.prototype._pad=function(V,B0){for(var H=V.length-B0,y0=B0;y0>>0,w0=C}Y.rip(E,w0,y0,W)},Q.prototype._decrypt=function(V,B0,H,y0,W){for(var w0=H,E=B0,p0=V.keys.length-2;p0>=0;p0-=2){var T=V.keys[p0],f0=V.keys[p0+1];Y.expand(w0,V.tmp,0),T^=V.tmp[0],f0^=V.tmp[1];var D=Y.substitute(T,f0),c0=Y.permute(D),C=w0;w0=(E^c0)>>>0,E=C}Y.rip(w0,E,y0,W)}}}),XQ=$Q({"node_modules/des.js/lib/des/cbc.js"(X){var K=N0(),x0=X0(),G={};function Y(Z){K.equal(Z.length,8,"Invalid IV length"),this.iv=new Array(8);for(var Q=0;Q>U%8,Y._prev=G(Y._prev,Z?H:y0);return B0}function G(Y,$){var Z=Y.length,Q=-1,U=K.allocUnsafe(Y.length);for(Y=K.concat([Y,K.from([$])]);++Q>7;return U}X.encrypt=function(Y,$,Z){for(var Q=$.length,U=K.allocUnsafe(Q),V=-1;++V>>24]^E[D>>>16&255]^p0[c0>>>8&255]^T[C&255]^B0[b0++],L=w0[D>>>24]^E[c0>>>16&255]^p0[C>>>8&255]^T[f0&255]^B0[b0++],d0=w0[c0>>>24]^E[C>>>16&255]^p0[f0>>>8&255]^T[D&255]^B0[b0++],R=w0[C>>>24]^E[f0>>>16&255]^p0[D>>>8&255]^T[c0&255]^B0[b0++],f0=h0,D=L,c0=d0,C=R;return h0=(y0[f0>>>24]<<24|y0[D>>>16&255]<<16|y0[c0>>>8&255]<<8|y0[C&255])^B0[b0++],L=(y0[D>>>24]<<24|y0[c0>>>16&255]<<16|y0[C>>>8&255]<<8|y0[f0&255])^B0[b0++],d0=(y0[c0>>>24]<<24|y0[C>>>16&255]<<16|y0[f0>>>8&255]<<8|y0[D&255])^B0[b0++],R=(y0[C>>>24]<<24|y0[f0>>>16&255]<<16|y0[D>>>8&255]<<8|y0[c0&255])^B0[b0++],h0=h0>>>0,L=L>>>0,d0=d0>>>0,R=R>>>0,[h0,L,d0,R]}var Z=[0,1,2,4,8,16,32,64,128,27,54],Q=function(){for(var V=new Array(256),B0=0;B0<256;B0++)B0<128?V[B0]=B0<<1:V[B0]=B0<<1^283;for(var H=[],y0=[],W=[[],[],[],[]],w0=[[],[],[],[]],E=0,p0=0,T=0;T<256;++T){var f0=p0^p0<<1^p0<<2^p0<<3^p0<<4;f0=f0>>>8^f0&255^99,H[E]=f0,y0[f0]=E;var D=V[E],c0=V[D],C=V[c0],h0=V[f0]*257^f0*16843008;W[0][E]=h0<<24|h0>>>8,W[1][E]=h0<<16|h0>>>16,W[2][E]=h0<<8|h0>>>24,W[3][E]=h0,h0=C*16843009^c0*65537^D*257^E*16843008,w0[0][f0]=h0<<24|h0>>>8,w0[1][f0]=h0<<16|h0>>>16,w0[2][f0]=h0<<8|h0>>>24,w0[3][f0]=h0,E===0?E=p0=1:(E=D^V[V[V[C^D]]],p0^=V[V[p0]])}return{SBOX:H,INV_SBOX:y0,SUB_MIX:W,INV_SUB_MIX:w0}}();function U(V){this._key=G(V),this._reset()}U.blockSize=16,U.keySize=32,U.prototype.blockSize=U.blockSize,U.prototype.keySize=U.keySize,U.prototype._reset=function(){for(var V=this._key,B0=V.length,H=B0+6,y0=(H+1)*4,W=[],w0=0;w0>>24,E=Q.SBOX[E>>>24]<<24|Q.SBOX[E>>>16&255]<<16|Q.SBOX[E>>>8&255]<<8|Q.SBOX[E&255],E^=Z[w0/B0|0]<<24):B0>6&&w0%B0===4&&(E=Q.SBOX[E>>>24]<<24|Q.SBOX[E>>>16&255]<<16|Q.SBOX[E>>>8&255]<<8|Q.SBOX[E&255]),W[w0]=W[w0-B0]^E}for(var p0=[],T=0;T>>24]]^Q.INV_SUB_MIX[1][Q.SBOX[D>>>16&255]]^Q.INV_SUB_MIX[2][Q.SBOX[D>>>8&255]]^Q.INV_SUB_MIX[3][Q.SBOX[D&255]]}this._nRounds=H,this._keySchedule=W,this._invKeySchedule=p0},U.prototype.encryptBlockRaw=function(V){return V=G(V),$(V,this._keySchedule,Q.SUB_MIX,Q.SBOX,this._nRounds)},U.prototype.encryptBlock=function(V){var B0=this.encryptBlockRaw(V),H=x0.allocUnsafe(16);return H.writeUInt32BE(B0[0],0),H.writeUInt32BE(B0[1],4),H.writeUInt32BE(B0[2],8),H.writeUInt32BE(B0[3],12),H},U.prototype.decryptBlock=function(V){V=G(V);var B0=V[1];V[1]=V[3],V[3]=B0;var H=$(V,this._invKeySchedule,Q.INV_SUB_MIX,Q.INV_SBOX,this._nRounds),y0=x0.allocUnsafe(16);return y0.writeUInt32BE(H[0],0),y0.writeUInt32BE(H[3],4),y0.writeUInt32BE(H[2],8),y0.writeUInt32BE(H[1],12),y0},U.prototype.scrub=function(){Y(this._keySchedule),Y(this._invKeySchedule),Y(this._key)},K.exports.AES=U}}),PQ=$Q({"node_modules/browserify-aes/ghash.js"(X,K){var x0=YQ().Buffer,G=x0.alloc(16,0);function Y(Q){return[Q.readUInt32BE(0),Q.readUInt32BE(4),Q.readUInt32BE(8),Q.readUInt32BE(12)]}function $(Q){var U=x0.allocUnsafe(16);return U.writeUInt32BE(Q[0]>>>0,0),U.writeUInt32BE(Q[1]>>>0,4),U.writeUInt32BE(Q[2]>>>0,8),U.writeUInt32BE(Q[3]>>>0,12),U}function Z(Q){this.h=Q,this.state=x0.alloc(16,0),this.cache=x0.allocUnsafe(0)}Z.prototype.ghash=function(Q){for(var U=-1;++U0;V--)Q[V]=Q[V]>>>1|(Q[V-1]&1)<<31;Q[0]=Q[0]>>>1,H&&(Q[0]=Q[0]^225<<24)}this.state=$(U)},Z.prototype.update=function(Q){this.cache=x0.concat([this.cache,Q]);for(var U;this.cache.length>=16;)U=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(U)},Z.prototype.final=function(Q,U){return this.cache.length&&this.ghash(x0.concat([this.cache,G],16)),this.ghash($([0,Q,0,U])),this.state},K.exports=Z}}),zQ=$Q({"node_modules/browserify-aes/authCipher.js"(X,K){var x0=RQ(),G=YQ().Buffer,Y=C0(),$=X0(),Z=PQ(),Q=FQ(),U=DQ();function V(y0,W){var w0=0;y0.length!==W.length&&w0++;for(var E=Math.min(y0.length,W.length),p0=0;p00||U>0;){var W=new G;W.update(y0),W.update($),Z&&W.update(Z),y0=W.digest();var w0=0;if(V>0){var E=B0.length-V;w0=Math.min(V,y0.length),y0.copy(B0,E,0,w0),V-=w0}if(w00){var p0=H.length-U,T=Math.min(U,y0.length-w0);y0.copy(H,p0,w0,w0+T),U-=T}}return y0.fill(0),{key:B0,iv:H}}K.exports=Y}}),vQ=$Q({"node_modules/browserify-aes/encrypter.js"(X){var K=LQ(),x0=zQ(),G=YQ().Buffer,Y=MQ(),$=C0(),Z=RQ(),Q=SQ(),U=X0();function V(w0,E,p0){$.call(this),this._cache=new H,this._cipher=new Z.AES(E),this._prev=G.from(p0),this._mode=w0,this._autopadding=!0}U(V,$),V.prototype._update=function(w0){this._cache.add(w0);for(var E,p0,T=[];E=this._cache.get();)p0=this._mode.encrypt(this,E),T.push(p0);return G.concat(T)};var B0=G.alloc(16,16);V.prototype._final=function(){var w0=this._cache.flush();if(this._autopadding)return w0=this._mode.encrypt(this,w0),this._cipher.scrub(),w0;if(!w0.equals(B0))throw this._cipher.scrub(),new Error("data not multiple of block length")},V.prototype.setAutoPadding=function(w0){return this._autopadding=!!w0,this};function H(){this.cache=G.allocUnsafe(0)}H.prototype.add=function(w0){this.cache=G.concat([this.cache,w0])},H.prototype.get=function(){if(this.cache.length>15){var w0=this.cache.slice(0,16);return this.cache=this.cache.slice(16),w0}return null},H.prototype.flush=function(){for(var w0=16-this.cache.length,E=G.allocUnsafe(w0),p0=-1;++p016)return E=this.cache.slice(0,16),this.cache=this.cache.slice(16),E}else if(this.cache.length>=16)return E=this.cache.slice(0,16),this.cache=this.cache.slice(16),E;return null},B0.prototype.flush=function(){if(this.cache.length)return this.cache};function H(w0){var E=w0[15];if(E<1||E>16)throw new Error("unable to decrypt data");for(var p0=-1;++p00?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),_Q=$Q({"node_modules/miller-rabin/node_modules/bn.js/lib/bn.js"(X,K){(function(x0,G){function Y(l0,z){if(!l0)throw new Error(z||"Assertion failed")}function $(l0,z){l0.super_=z;var o0=function(){};o0.prototype=z.prototype,l0.prototype=new o0,l0.prototype.constructor=l0}function Z(l0,z,o0){if(Z.isBN(l0))return l0;this.negative=0,this.words=null,this.length=0,this.red=null,l0!==null&&((z==="le"||z==="be")&&(o0=z,z=10),this._init(l0||0,z||10,o0||"be"))}typeof x0=="object"?x0.exports=Z:G.BN=Z,Z.BN=Z,Z.wordSize=26;var Q=c$;Z.isBN=function(l0){return l0 instanceof Z?!0:l0!==null&&typeof l0=="object"&&l0.constructor.wordSize===Z.wordSize&&Array.isArray(l0.words)},Z.max=function(l0,z){return l0.cmp(z)>0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),NQ=$Q({"(disabled):node_modules/crypto-browserify/index.js"(){}}),xQ=$Q({"node_modules/brorand/index.js"(X,K){var x0;K.exports=function(Y){return x0||(x0=new G(null)),x0.generate(Y)};function G(Y){this.rand=Y}K.exports.Rand=G,G.prototype.generate=function(Y){return this._rand(Y)},G.prototype._rand=function(Y){var $=new c$(Y);return d$.getRandomValues($),$}}}),BQ=$Q({"node_modules/miller-rabin/lib/mr.js"(X,K){var x0=_Q(),G=xQ();function Y($){this.rand=$||new G.Rand}K.exports=Y,Y.create=function($){return new Y($)},Y.prototype._randbelow=function($){var Z=$.bitLength(),Q=Math.ceil(Z/8);do var U=new x0(this.rand.generate(Q));while(U.cmp($)>=0);return U},Y.prototype._randrange=function($,Z){var Q=Z.sub($);return $.add(this._randbelow(Q))},Y.prototype.test=function($,Z,Q){var U=$.bitLength(),V=x0.mont($),B0=new x0(1).toRed(V);Z||(Z=Math.max(1,U/48|0));for(var H=$.subn(1),y0=0;!H.testn(y0);y0++);for(var W=$.shrn(y0),w0=H.toRed(V),E=!0;Z>0;Z--){var p0=this._randrange(new x0(2),H);Q&&Q(p0);var T=p0.toRed(V).redPow(W);if(!(T.cmp(B0)===0||T.cmp(w0)===0)){for(var f0=1;f00;Z--){var w0=this._randrange(new x0(2),B0),E=$.gcd(w0);if(E.cmpn(1)!==0)return E;var p0=w0.toRed(U).redPow(y0);if(!(p0.cmp(V)===0||p0.cmp(W)===0)){for(var T=1;TL;)R.ishrn(1);if(R.isEven()&&R.iadd(Q),R.testn(1)||R.iadd(U),d0.cmp(U)){if(!d0.cmp(V))for(;R.mod(y0).cmp(W);)R.iadd(p0)}else for(;R.mod(Y).cmp(E);)R.iadd(p0);if(b0=R.shrn(1),c0(b0)&&c0(R)&&C(b0)&&C(R)&&Z.test(b0)&&Z.test(R))return R}}}}),wQ=$Q({"node_modules/diffie-hellman/lib/primes.json"(X,K){K.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"(X,K){var x0=A(),G=BQ(),Y=new G,$=new x0(24),Z=new x0(11),Q=new x0(10),U=new x0(3),V=new x0(7),B0=yQ(),H=ZQ();K.exports=p0;function y0(f0,D){return D=D||"utf8",c$.isBuffer(f0)||(f0=new c$(f0,D)),this._pub=new x0(f0),this}function W(f0,D){return D=D||"utf8",c$.isBuffer(f0)||(f0=new c$(f0,D)),this._priv=new x0(f0),this}var w0={};function E(f0,D){var c0=D.toString("hex"),C=[c0,f0.toString(16)].join("_");if(C in w0)return w0[C];var h0=0;if(f0.isEven()||!B0.simpleSieve||!B0.fermatTest(f0)||!Y.test(f0))return h0+=1,c0==="02"||c0==="05"?h0+=8:h0+=4,w0[C]=h0,h0;Y.test(f0.shrn(1))||(h0+=2);var L;switch(c0){case"02":f0.mod($).cmp(Z)&&(h0+=8);break;case"05":L=f0.mod(Q),L.cmp(U)&&L.cmp(V)&&(h0+=8);break;default:h0+=4}return w0[C]=h0,h0}function p0(f0,D,c0){this.setGenerator(D),this.__prime=new x0(f0),this._prime=x0.mont(this.__prime),this._primeLen=f0.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,c0?(this.setPublicKey=y0,this.setPrivateKey=W):this._primeCode=8}Object.defineProperty(p0.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=E(this.__prime,this.__gen)),this._primeCode}}),p0.prototype.generateKeys=function(){return this._priv||(this._priv=new x0(H(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},p0.prototype.computeSecret=function(f0){f0=new x0(f0),f0=f0.toRed(this._prime);var D=f0.redPow(this._priv).fromRed(),c0=new c$(D.toArray()),C=this.getPrime();if(c0.length0?M:u0},Z.min=function(M,u0){return M.cmp(u0)<0?M:u0},Z.prototype._init=function(M,u0,S){if(typeof M=="number")return this._initNumber(M,u0,S);if(typeof M=="object")return this._initArray(M,u0,S);u0==="hex"&&(u0=16),Y(u0===(u0|0)&&u0>=2&&u0<=36),M=M.toString().replace(/\s+/g,"");var n0=0;M[0]==="-"&&(n0++,this.negative=1),n0=0;n0-=3)s0=M[n0]|M[n0-1]<<8|M[n0-2]<<16,this.words[v]|=s0<>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);else if(S==="le")for(n0=0,v=0;n0>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);return this._strip()};function U(M,u0){var S=M.charCodeAt(u0);if(S>=48&&S<=57)return S-48;if(S>=65&&S<=70)return S-55;if(S>=97&&S<=102)return S-87;Y(!1,"Invalid character in "+M)}function V(M,u0,S){var n0=U(M,S);return S-1>=u0&&(n0|=U(M,S-1)<<4),n0}Z.prototype._parseHex=function(M,u0,S){this.length=Math.ceil((M.length-u0)/6),this.words=new Array(this.length);for(var n0=0;n0=u0;n0-=2)I=V(M,u0,n0)<=18?(v-=18,s0+=1,this.words[s0]|=I>>>26):v+=8;else{var t0=M.length-u0;for(n0=t0%2===0?u0+1:u0;n0=18?(v-=18,s0+=1,this.words[s0]|=I>>>26):v+=8}this._strip()};function B0(M,u0,S,n0){for(var v=0,s0=0,I=Math.min(M.length,S),t0=u0;t0=49?s0=m0-49+10:m0>=17?s0=m0-17+10:s0=m0,Y(m0>=0&&s01&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{Z.prototype[Symbol.for("nodejs.util.inspect.custom")]=y0}catch{Z.prototype.inspect=y0}else Z.prototype.inspect=y0;function y0(){return(this.red?""}var W=["","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"],w0=[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],E=[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];Z.prototype.toString=function(M,u0){M=M||10,u0=u0|0||1;var S;if(M===16||M==="hex"){S="";for(var n0=0,v=0,s0=0;s0>>24-n0&16777215,n0+=2,n0>=26&&(n0-=26,s0--),v!==0||s0!==this.length-1?S=W[6-t0.length]+t0+S:S=t0+S}for(v!==0&&(S=v.toString(16)+S);S.length%u0!==0;)S="0"+S;return this.negative!==0&&(S="-"+S),S}if(M===(M|0)&&M>=2&&M<=36){var m0=w0[M],a0=E[M];S="";var q=this.clone();for(q.negative=0;!q.isZero();){var e0=q.modrn(a0).toString(M);q=q.idivn(a0),q.isZero()?S=e0+S:S=W[m0-e0.length]+e0+S}for(this.isZero()&&(S="0"+S);S.length%u0!==0;)S="0"+S;return this.negative!==0&&(S="-"+S),S}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var M=this.words[0];return this.length===2?M+=this.words[1]*67108864:this.length===3&&this.words[2]===1?M+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-M:M},Z.prototype.toJSON=function(){return this.toString(16,2)},Q&&(Z.prototype.toBuffer=function(M,u0){return this.toArrayLike(Q,M,u0)}),Z.prototype.toArray=function(M,u0){return this.toArrayLike(Array,M,u0)};var p0=function(M,u0){return M.allocUnsafe?M.allocUnsafe(u0):new M(u0)};Z.prototype.toArrayLike=function(M,u0,S){this._strip();var n0=this.byteLength(),v=S||Math.max(1,n0);Y(n0<=v,"byte array longer than desired length"),Y(v>0,"Requested array length <= 0");var s0=p0(M,v),I=u0==="le"?"LE":"BE";return this["_toArrayLike"+I](s0,n0),s0},Z.prototype._toArrayLikeLE=function(M,u0){for(var S=0,n0=0,v=0,s0=0;v>8&255),S>16&255),s0===6?(S>24&255),n0=0,s0=0):(n0=I>>>24,s0+=2)}if(S=0&&(M[S--]=I>>8&255),S>=0&&(M[S--]=I>>16&255),s0===6?(S>=0&&(M[S--]=I>>24&255),n0=0,s0=0):(n0=I>>>24,s0+=2)}if(S>=0)for(M[S--]=n0;S>=0;)M[S--]=0},Math.clz32?Z.prototype._countBits=function(M){return 32-Math.clz32(M)}:Z.prototype._countBits=function(M){var u0=M,S=0;return u0>=4096&&(S+=13,u0>>>=13),u0>=64&&(S+=7,u0>>>=7),u0>=8&&(S+=4,u0>>>=4),u0>=2&&(S+=2,u0>>>=2),S+u0},Z.prototype._zeroBits=function(M){if(M===0)return 26;var u0=M,S=0;return(u0&8191)===0&&(S+=13,u0>>>=13),(u0&127)===0&&(S+=7,u0>>>=7),(u0&15)===0&&(S+=4,u0>>>=4),(u0&3)===0&&(S+=2,u0>>>=2),(u0&1)===0&&S++,S},Z.prototype.bitLength=function(){var M=this.words[this.length-1],u0=this._countBits(M);return(this.length-1)*26+u0};function T(M){for(var u0=new Array(M.bitLength()),S=0;S>>v&1}return u0}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var M=0,u0=0;u0M.length?this.clone().ior(M):M.clone().ior(this)},Z.prototype.uor=function(M){return this.length>M.length?this.clone().iuor(M):M.clone().iuor(this)},Z.prototype.iuand=function(M){var u0;this.length>M.length?u0=M:u0=this;for(var S=0;SM.length?this.clone().iand(M):M.clone().iand(this)},Z.prototype.uand=function(M){return this.length>M.length?this.clone().iuand(M):M.clone().iuand(this)},Z.prototype.iuxor=function(M){var u0,S;this.length>M.length?(u0=this,S=M):(u0=M,S=this);for(var n0=0;n0M.length?this.clone().ixor(M):M.clone().ixor(this)},Z.prototype.uxor=function(M){return this.length>M.length?this.clone().iuxor(M):M.clone().iuxor(this)},Z.prototype.inotn=function(M){Y(typeof M=="number"&&M>=0);var u0=Math.ceil(M/26)|0,S=M%26;this._expand(u0),S>0&&u0--;for(var n0=0;n00&&(this.words[n0]=~this.words[n0]&67108863>>26-S),this._strip()},Z.prototype.notn=function(M){return this.clone().inotn(M)},Z.prototype.setn=function(M,u0){Y(typeof M=="number"&&M>=0);var S=M/26|0,n0=M%26;return this._expand(S+1),u0?this.words[S]=this.words[S]|1<M.length?(S=this,n0=M):(S=M,n0=this);for(var v=0,s0=0;s0>>26;for(;v!==0&&s0>>26;if(this.length=S.length,v!==0)this.words[this.length]=v,this.length++;else if(S!==this)for(;s0M.length?this.clone().iadd(M):M.clone().iadd(this)},Z.prototype.isub=function(M){if(M.negative!==0){M.negative=0;var u0=this.iadd(M);return M.negative=1,u0._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(M),this.negative=1,this._normSign();var S=this.cmp(M);if(S===0)return this.negative=0,this.length=1,this.words[0]=0,this;var n0,v;S>0?(n0=this,v=M):(n0=M,v=this);for(var s0=0,I=0;I>26,this.words[I]=u0&67108863;for(;s0!==0&&I>26,this.words[I]=u0&67108863;if(s0===0&&I>>26,e0=m0&67108863,r0=Math.min(a0,u0.length-1),i0=Math.max(0,a0-M.length+1);i0<=r0;i0++){var j=a0-i0|0;v=M.words[j]|0,s0=u0.words[i0]|0,I=v*s0+e0,q+=I/67108864|0,e0=I&67108863}S.words[a0]=e0|0,m0=q|0}return m0!==0?S.words[a0]=m0|0:S.length--,S._strip()}var D=function(M,u0,S){var n0=M.words,v=u0.words,s0=S.words,I=0,t0,m0,a0,q=n0[0]|0,e0=q&8191,r0=q>>>13,i0=n0[1]|0,j=i0&8191,$$=i0>>>13,k=n0[2]|0,Q$=k&8191,g=k>>>13,Y$=n0[3]|0,_=Y$&8191,Z$=Y$>>>13,N=n0[4]|0,G$=N&8191,x=N>>>13,V$=n0[5]|0,B=V$&8191,U$=V$>>>13,y=n0[6]|0,X$=y&8191,w=y>>>13,K$=n0[7]|0,p=K$&8191,I$=K$>>>13,f=n0[8]|0,O$=f&8191,c=f>>>13,J$=n0[9]|0,h=J$&8191,F$=J$>>>13,d=v[0]|0,A$=d&8191,b=d>>>13,H$=v[1]|0,l=H$&8191,W$=H$>>>13,o=v[2]|0,E$=o&8191,u=o>>>13,T$=v[3]|0,n=T$&8191,D$=T$>>>13,s=v[4]|0,C$=s&8191,t=s>>>13,L$=v[5]|0,m=L$&8191,R$=L$>>>13,a=v[6]|0,P$=a&8191,O=a>>>13,z$=v[7]|0,e=z$&8191,M$=z$>>>13,J=v[8]|0,S$=J&8191,F=J>>>13,v$=v[9]|0,r=v$&8191,q$=v$>>>13;S.negative=M.negative^u0.negative,S.length=19,t0=Math.imul(e0,A$),m0=Math.imul(e0,b),m0=m0+Math.imul(r0,A$)|0,a0=Math.imul(r0,b);var i=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(i>>>26)|0,i&=67108863,t0=Math.imul(j,A$),m0=Math.imul(j,b),m0=m0+Math.imul($$,A$)|0,a0=Math.imul($$,b),t0=t0+Math.imul(e0,l)|0,m0=m0+Math.imul(e0,W$)|0,m0=m0+Math.imul(r0,l)|0,a0=a0+Math.imul(r0,W$)|0;var j$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(j$>>>26)|0,j$&=67108863,t0=Math.imul(Q$,A$),m0=Math.imul(Q$,b),m0=m0+Math.imul(g,A$)|0,a0=Math.imul(g,b),t0=t0+Math.imul(j,l)|0,m0=m0+Math.imul(j,W$)|0,m0=m0+Math.imul($$,l)|0,a0=a0+Math.imul($$,W$)|0,t0=t0+Math.imul(e0,E$)|0,m0=m0+Math.imul(e0,u)|0,m0=m0+Math.imul(r0,E$)|0,a0=a0+Math.imul(r0,u)|0;var k$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(k$>>>26)|0,k$&=67108863,t0=Math.imul(_,A$),m0=Math.imul(_,b),m0=m0+Math.imul(Z$,A$)|0,a0=Math.imul(Z$,b),t0=t0+Math.imul(Q$,l)|0,m0=m0+Math.imul(Q$,W$)|0,m0=m0+Math.imul(g,l)|0,a0=a0+Math.imul(g,W$)|0,t0=t0+Math.imul(j,E$)|0,m0=m0+Math.imul(j,u)|0,m0=m0+Math.imul($$,E$)|0,a0=a0+Math.imul($$,u)|0,t0=t0+Math.imul(e0,n)|0,m0=m0+Math.imul(e0,D$)|0,m0=m0+Math.imul(r0,n)|0,a0=a0+Math.imul(r0,D$)|0;var g$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(g$>>>26)|0,g$&=67108863,t0=Math.imul(G$,A$),m0=Math.imul(G$,b),m0=m0+Math.imul(x,A$)|0,a0=Math.imul(x,b),t0=t0+Math.imul(_,l)|0,m0=m0+Math.imul(_,W$)|0,m0=m0+Math.imul(Z$,l)|0,a0=a0+Math.imul(Z$,W$)|0,t0=t0+Math.imul(Q$,E$)|0,m0=m0+Math.imul(Q$,u)|0,m0=m0+Math.imul(g,E$)|0,a0=a0+Math.imul(g,u)|0,t0=t0+Math.imul(j,n)|0,m0=m0+Math.imul(j,D$)|0,m0=m0+Math.imul($$,n)|0,a0=a0+Math.imul($$,D$)|0,t0=t0+Math.imul(e0,C$)|0,m0=m0+Math.imul(e0,t)|0,m0=m0+Math.imul(r0,C$)|0,a0=a0+Math.imul(r0,t)|0;var _$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(_$>>>26)|0,_$&=67108863,t0=Math.imul(B,A$),m0=Math.imul(B,b),m0=m0+Math.imul(U$,A$)|0,a0=Math.imul(U$,b),t0=t0+Math.imul(G$,l)|0,m0=m0+Math.imul(G$,W$)|0,m0=m0+Math.imul(x,l)|0,a0=a0+Math.imul(x,W$)|0,t0=t0+Math.imul(_,E$)|0,m0=m0+Math.imul(_,u)|0,m0=m0+Math.imul(Z$,E$)|0,a0=a0+Math.imul(Z$,u)|0,t0=t0+Math.imul(Q$,n)|0,m0=m0+Math.imul(Q$,D$)|0,m0=m0+Math.imul(g,n)|0,a0=a0+Math.imul(g,D$)|0,t0=t0+Math.imul(j,C$)|0,m0=m0+Math.imul(j,t)|0,m0=m0+Math.imul($$,C$)|0,a0=a0+Math.imul($$,t)|0,t0=t0+Math.imul(e0,m)|0,m0=m0+Math.imul(e0,R$)|0,m0=m0+Math.imul(r0,m)|0,a0=a0+Math.imul(r0,R$)|0;var N$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(N$>>>26)|0,N$&=67108863,t0=Math.imul(X$,A$),m0=Math.imul(X$,b),m0=m0+Math.imul(w,A$)|0,a0=Math.imul(w,b),t0=t0+Math.imul(B,l)|0,m0=m0+Math.imul(B,W$)|0,m0=m0+Math.imul(U$,l)|0,a0=a0+Math.imul(U$,W$)|0,t0=t0+Math.imul(G$,E$)|0,m0=m0+Math.imul(G$,u)|0,m0=m0+Math.imul(x,E$)|0,a0=a0+Math.imul(x,u)|0,t0=t0+Math.imul(_,n)|0,m0=m0+Math.imul(_,D$)|0,m0=m0+Math.imul(Z$,n)|0,a0=a0+Math.imul(Z$,D$)|0,t0=t0+Math.imul(Q$,C$)|0,m0=m0+Math.imul(Q$,t)|0,m0=m0+Math.imul(g,C$)|0,a0=a0+Math.imul(g,t)|0,t0=t0+Math.imul(j,m)|0,m0=m0+Math.imul(j,R$)|0,m0=m0+Math.imul($$,m)|0,a0=a0+Math.imul($$,R$)|0,t0=t0+Math.imul(e0,P$)|0,m0=m0+Math.imul(e0,O)|0,m0=m0+Math.imul(r0,P$)|0,a0=a0+Math.imul(r0,O)|0;var $0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+($0>>>26)|0,$0&=67108863,t0=Math.imul(p,A$),m0=Math.imul(p,b),m0=m0+Math.imul(I$,A$)|0,a0=Math.imul(I$,b),t0=t0+Math.imul(X$,l)|0,m0=m0+Math.imul(X$,W$)|0,m0=m0+Math.imul(w,l)|0,a0=a0+Math.imul(w,W$)|0,t0=t0+Math.imul(B,E$)|0,m0=m0+Math.imul(B,u)|0,m0=m0+Math.imul(U$,E$)|0,a0=a0+Math.imul(U$,u)|0,t0=t0+Math.imul(G$,n)|0,m0=m0+Math.imul(G$,D$)|0,m0=m0+Math.imul(x,n)|0,a0=a0+Math.imul(x,D$)|0,t0=t0+Math.imul(_,C$)|0,m0=m0+Math.imul(_,t)|0,m0=m0+Math.imul(Z$,C$)|0,a0=a0+Math.imul(Z$,t)|0,t0=t0+Math.imul(Q$,m)|0,m0=m0+Math.imul(Q$,R$)|0,m0=m0+Math.imul(g,m)|0,a0=a0+Math.imul(g,R$)|0,t0=t0+Math.imul(j,P$)|0,m0=m0+Math.imul(j,O)|0,m0=m0+Math.imul($$,P$)|0,a0=a0+Math.imul($$,O)|0,t0=t0+Math.imul(e0,e)|0,m0=m0+Math.imul(e0,M$)|0,m0=m0+Math.imul(r0,e)|0,a0=a0+Math.imul(r0,M$)|0;var x$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(x$>>>26)|0,x$&=67108863,t0=Math.imul(O$,A$),m0=Math.imul(O$,b),m0=m0+Math.imul(c,A$)|0,a0=Math.imul(c,b),t0=t0+Math.imul(p,l)|0,m0=m0+Math.imul(p,W$)|0,m0=m0+Math.imul(I$,l)|0,a0=a0+Math.imul(I$,W$)|0,t0=t0+Math.imul(X$,E$)|0,m0=m0+Math.imul(X$,u)|0,m0=m0+Math.imul(w,E$)|0,a0=a0+Math.imul(w,u)|0,t0=t0+Math.imul(B,n)|0,m0=m0+Math.imul(B,D$)|0,m0=m0+Math.imul(U$,n)|0,a0=a0+Math.imul(U$,D$)|0,t0=t0+Math.imul(G$,C$)|0,m0=m0+Math.imul(G$,t)|0,m0=m0+Math.imul(x,C$)|0,a0=a0+Math.imul(x,t)|0,t0=t0+Math.imul(_,m)|0,m0=m0+Math.imul(_,R$)|0,m0=m0+Math.imul(Z$,m)|0,a0=a0+Math.imul(Z$,R$)|0,t0=t0+Math.imul(Q$,P$)|0,m0=m0+Math.imul(Q$,O)|0,m0=m0+Math.imul(g,P$)|0,a0=a0+Math.imul(g,O)|0,t0=t0+Math.imul(j,e)|0,m0=m0+Math.imul(j,M$)|0,m0=m0+Math.imul($$,e)|0,a0=a0+Math.imul($$,M$)|0,t0=t0+Math.imul(e0,S$)|0,m0=m0+Math.imul(e0,F)|0,m0=m0+Math.imul(r0,S$)|0,a0=a0+Math.imul(r0,F)|0;var Q0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,t0=Math.imul(h,A$),m0=Math.imul(h,b),m0=m0+Math.imul(F$,A$)|0,a0=Math.imul(F$,b),t0=t0+Math.imul(O$,l)|0,m0=m0+Math.imul(O$,W$)|0,m0=m0+Math.imul(c,l)|0,a0=a0+Math.imul(c,W$)|0,t0=t0+Math.imul(p,E$)|0,m0=m0+Math.imul(p,u)|0,m0=m0+Math.imul(I$,E$)|0,a0=a0+Math.imul(I$,u)|0,t0=t0+Math.imul(X$,n)|0,m0=m0+Math.imul(X$,D$)|0,m0=m0+Math.imul(w,n)|0,a0=a0+Math.imul(w,D$)|0,t0=t0+Math.imul(B,C$)|0,m0=m0+Math.imul(B,t)|0,m0=m0+Math.imul(U$,C$)|0,a0=a0+Math.imul(U$,t)|0,t0=t0+Math.imul(G$,m)|0,m0=m0+Math.imul(G$,R$)|0,m0=m0+Math.imul(x,m)|0,a0=a0+Math.imul(x,R$)|0,t0=t0+Math.imul(_,P$)|0,m0=m0+Math.imul(_,O)|0,m0=m0+Math.imul(Z$,P$)|0,a0=a0+Math.imul(Z$,O)|0,t0=t0+Math.imul(Q$,e)|0,m0=m0+Math.imul(Q$,M$)|0,m0=m0+Math.imul(g,e)|0,a0=a0+Math.imul(g,M$)|0,t0=t0+Math.imul(j,S$)|0,m0=m0+Math.imul(j,F)|0,m0=m0+Math.imul($$,S$)|0,a0=a0+Math.imul($$,F)|0,t0=t0+Math.imul(e0,r)|0,m0=m0+Math.imul(e0,q$)|0,m0=m0+Math.imul(r0,r)|0,a0=a0+Math.imul(r0,q$)|0;var B$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(B$>>>26)|0,B$&=67108863,t0=Math.imul(h,l),m0=Math.imul(h,W$),m0=m0+Math.imul(F$,l)|0,a0=Math.imul(F$,W$),t0=t0+Math.imul(O$,E$)|0,m0=m0+Math.imul(O$,u)|0,m0=m0+Math.imul(c,E$)|0,a0=a0+Math.imul(c,u)|0,t0=t0+Math.imul(p,n)|0,m0=m0+Math.imul(p,D$)|0,m0=m0+Math.imul(I$,n)|0,a0=a0+Math.imul(I$,D$)|0,t0=t0+Math.imul(X$,C$)|0,m0=m0+Math.imul(X$,t)|0,m0=m0+Math.imul(w,C$)|0,a0=a0+Math.imul(w,t)|0,t0=t0+Math.imul(B,m)|0,m0=m0+Math.imul(B,R$)|0,m0=m0+Math.imul(U$,m)|0,a0=a0+Math.imul(U$,R$)|0,t0=t0+Math.imul(G$,P$)|0,m0=m0+Math.imul(G$,O)|0,m0=m0+Math.imul(x,P$)|0,a0=a0+Math.imul(x,O)|0,t0=t0+Math.imul(_,e)|0,m0=m0+Math.imul(_,M$)|0,m0=m0+Math.imul(Z$,e)|0,a0=a0+Math.imul(Z$,M$)|0,t0=t0+Math.imul(Q$,S$)|0,m0=m0+Math.imul(Q$,F)|0,m0=m0+Math.imul(g,S$)|0,a0=a0+Math.imul(g,F)|0,t0=t0+Math.imul(j,r)|0,m0=m0+Math.imul(j,q$)|0,m0=m0+Math.imul($$,r)|0,a0=a0+Math.imul($$,q$)|0;var Y0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,t0=Math.imul(h,E$),m0=Math.imul(h,u),m0=m0+Math.imul(F$,E$)|0,a0=Math.imul(F$,u),t0=t0+Math.imul(O$,n)|0,m0=m0+Math.imul(O$,D$)|0,m0=m0+Math.imul(c,n)|0,a0=a0+Math.imul(c,D$)|0,t0=t0+Math.imul(p,C$)|0,m0=m0+Math.imul(p,t)|0,m0=m0+Math.imul(I$,C$)|0,a0=a0+Math.imul(I$,t)|0,t0=t0+Math.imul(X$,m)|0,m0=m0+Math.imul(X$,R$)|0,m0=m0+Math.imul(w,m)|0,a0=a0+Math.imul(w,R$)|0,t0=t0+Math.imul(B,P$)|0,m0=m0+Math.imul(B,O)|0,m0=m0+Math.imul(U$,P$)|0,a0=a0+Math.imul(U$,O)|0,t0=t0+Math.imul(G$,e)|0,m0=m0+Math.imul(G$,M$)|0,m0=m0+Math.imul(x,e)|0,a0=a0+Math.imul(x,M$)|0,t0=t0+Math.imul(_,S$)|0,m0=m0+Math.imul(_,F)|0,m0=m0+Math.imul(Z$,S$)|0,a0=a0+Math.imul(Z$,F)|0,t0=t0+Math.imul(Q$,r)|0,m0=m0+Math.imul(Q$,q$)|0,m0=m0+Math.imul(g,r)|0,a0=a0+Math.imul(g,q$)|0;var y$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(y$>>>26)|0,y$&=67108863,t0=Math.imul(h,n),m0=Math.imul(h,D$),m0=m0+Math.imul(F$,n)|0,a0=Math.imul(F$,D$),t0=t0+Math.imul(O$,C$)|0,m0=m0+Math.imul(O$,t)|0,m0=m0+Math.imul(c,C$)|0,a0=a0+Math.imul(c,t)|0,t0=t0+Math.imul(p,m)|0,m0=m0+Math.imul(p,R$)|0,m0=m0+Math.imul(I$,m)|0,a0=a0+Math.imul(I$,R$)|0,t0=t0+Math.imul(X$,P$)|0,m0=m0+Math.imul(X$,O)|0,m0=m0+Math.imul(w,P$)|0,a0=a0+Math.imul(w,O)|0,t0=t0+Math.imul(B,e)|0,m0=m0+Math.imul(B,M$)|0,m0=m0+Math.imul(U$,e)|0,a0=a0+Math.imul(U$,M$)|0,t0=t0+Math.imul(G$,S$)|0,m0=m0+Math.imul(G$,F)|0,m0=m0+Math.imul(x,S$)|0,a0=a0+Math.imul(x,F)|0,t0=t0+Math.imul(_,r)|0,m0=m0+Math.imul(_,q$)|0,m0=m0+Math.imul(Z$,r)|0,a0=a0+Math.imul(Z$,q$)|0;var Z0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,t0=Math.imul(h,C$),m0=Math.imul(h,t),m0=m0+Math.imul(F$,C$)|0,a0=Math.imul(F$,t),t0=t0+Math.imul(O$,m)|0,m0=m0+Math.imul(O$,R$)|0,m0=m0+Math.imul(c,m)|0,a0=a0+Math.imul(c,R$)|0,t0=t0+Math.imul(p,P$)|0,m0=m0+Math.imul(p,O)|0,m0=m0+Math.imul(I$,P$)|0,a0=a0+Math.imul(I$,O)|0,t0=t0+Math.imul(X$,e)|0,m0=m0+Math.imul(X$,M$)|0,m0=m0+Math.imul(w,e)|0,a0=a0+Math.imul(w,M$)|0,t0=t0+Math.imul(B,S$)|0,m0=m0+Math.imul(B,F)|0,m0=m0+Math.imul(U$,S$)|0,a0=a0+Math.imul(U$,F)|0,t0=t0+Math.imul(G$,r)|0,m0=m0+Math.imul(G$,q$)|0,m0=m0+Math.imul(x,r)|0,a0=a0+Math.imul(x,q$)|0;var w$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(w$>>>26)|0,w$&=67108863,t0=Math.imul(h,m),m0=Math.imul(h,R$),m0=m0+Math.imul(F$,m)|0,a0=Math.imul(F$,R$),t0=t0+Math.imul(O$,P$)|0,m0=m0+Math.imul(O$,O)|0,m0=m0+Math.imul(c,P$)|0,a0=a0+Math.imul(c,O)|0,t0=t0+Math.imul(p,e)|0,m0=m0+Math.imul(p,M$)|0,m0=m0+Math.imul(I$,e)|0,a0=a0+Math.imul(I$,M$)|0,t0=t0+Math.imul(X$,S$)|0,m0=m0+Math.imul(X$,F)|0,m0=m0+Math.imul(w,S$)|0,a0=a0+Math.imul(w,F)|0,t0=t0+Math.imul(B,r)|0,m0=m0+Math.imul(B,q$)|0,m0=m0+Math.imul(U$,r)|0,a0=a0+Math.imul(U$,q$)|0;var G0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(G0>>>26)|0,G0&=67108863,t0=Math.imul(h,P$),m0=Math.imul(h,O),m0=m0+Math.imul(F$,P$)|0,a0=Math.imul(F$,O),t0=t0+Math.imul(O$,e)|0,m0=m0+Math.imul(O$,M$)|0,m0=m0+Math.imul(c,e)|0,a0=a0+Math.imul(c,M$)|0,t0=t0+Math.imul(p,S$)|0,m0=m0+Math.imul(p,F)|0,m0=m0+Math.imul(I$,S$)|0,a0=a0+Math.imul(I$,F)|0,t0=t0+Math.imul(X$,r)|0,m0=m0+Math.imul(X$,q$)|0,m0=m0+Math.imul(w,r)|0,a0=a0+Math.imul(w,q$)|0;var p$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(p$>>>26)|0,p$&=67108863,t0=Math.imul(h,e),m0=Math.imul(h,M$),m0=m0+Math.imul(F$,e)|0,a0=Math.imul(F$,M$),t0=t0+Math.imul(O$,S$)|0,m0=m0+Math.imul(O$,F)|0,m0=m0+Math.imul(c,S$)|0,a0=a0+Math.imul(c,F)|0,t0=t0+Math.imul(p,r)|0,m0=m0+Math.imul(p,q$)|0,m0=m0+Math.imul(I$,r)|0,a0=a0+Math.imul(I$,q$)|0;var V0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(V0>>>26)|0,V0&=67108863,t0=Math.imul(h,S$),m0=Math.imul(h,F),m0=m0+Math.imul(F$,S$)|0,a0=Math.imul(F$,F),t0=t0+Math.imul(O$,r)|0,m0=m0+Math.imul(O$,q$)|0,m0=m0+Math.imul(c,r)|0,a0=a0+Math.imul(c,q$)|0;var f$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(f$>>>26)|0,f$&=67108863,t0=Math.imul(h,r),m0=Math.imul(h,q$),m0=m0+Math.imul(F$,r)|0,a0=Math.imul(F$,q$);var U0=(I+t0|0)+((m0&8191)<<13)|0;return I=(a0+(m0>>>13)|0)+(U0>>>26)|0,U0&=67108863,s0[0]=i,s0[1]=j$,s0[2]=k$,s0[3]=g$,s0[4]=_$,s0[5]=N$,s0[6]=$0,s0[7]=x$,s0[8]=Q0,s0[9]=B$,s0[10]=Y0,s0[11]=y$,s0[12]=Z0,s0[13]=w$,s0[14]=G0,s0[15]=p$,s0[16]=V0,s0[17]=f$,s0[18]=U0,I!==0&&(s0[19]=I,S.length++),S};Math.imul||(D=f0);function c0(M,u0,S){S.negative=u0.negative^M.negative,S.length=M.length+u0.length;for(var n0=0,v=0,s0=0;s0>>26)|0,v+=I>>>26,I&=67108863}S.words[s0]=t0,n0=I,I=v}return n0!==0?S.words[s0]=n0:S.length--,S._strip()}function C(M,u0,S){return c0(M,u0,S)}Z.prototype.mulTo=function(M,u0){var S,n0=this.length+M.length;return this.length===10&&M.length===10?S=D(this,M,u0):n0<63?S=f0(this,M,u0):n0<1024?S=c0(this,M,u0):S=C(this,M,u0),S};function h0(M,u0){this.x=M,this.y=u0}h0.prototype.makeRBT=function(M){for(var u0=new Array(M),S=Z.prototype._countBits(M)-1,n0=0;n0>=1;return n0},h0.prototype.permute=function(M,u0,S,n0,v,s0){for(var I=0;I>>1)v++;return 1<>>13,S[2*s0+1]=v&8191,v=v>>>13;for(s0=2*u0;s0>=26,S+=v/67108864|0,S+=s0>>>26,this.words[n0]=s0&67108863}return S!==0&&(this.words[n0]=S,this.length++),u0?this.ineg():this},Z.prototype.muln=function(M){return this.clone().imuln(M)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(M){var u0=T(M);if(u0.length===0)return new Z(1);for(var S=this,n0=0;n0=0);var u0=M%26,S=(M-u0)/26,n0=67108863>>>26-u0<<26-u0,v;if(u0!==0){var s0=0;for(v=0;v>>26-u0}s0&&(this.words[v]=s0,this.length++)}if(S!==0){for(v=this.length-1;v>=0;v--)this.words[v+S]=this.words[v];for(v=0;v=0);var n0;u0?n0=(u0-u0%26)/26:n0=0;var v=M%26,s0=Math.min((M-v)/26,this.length),I=67108863^67108863>>>v<s0)for(this.length-=s0,m0=0;m0=0&&(a0!==0||m0>=n0);m0--){var q=this.words[m0]|0;this.words[m0]=a0<<26-v|q>>>v,a0=q&I}return t0&&a0!==0&&(t0.words[t0.length++]=a0),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},Z.prototype.ishrn=function(M,u0,S){return Y(this.negative===0),this.iushrn(M,u0,S)},Z.prototype.shln=function(M){return this.clone().ishln(M)},Z.prototype.ushln=function(M){return this.clone().iushln(M)},Z.prototype.shrn=function(M){return this.clone().ishrn(M)},Z.prototype.ushrn=function(M){return this.clone().iushrn(M)},Z.prototype.testn=function(M){Y(typeof M=="number"&&M>=0);var u0=M%26,S=(M-u0)/26,n0=1<=0);var u0=M%26,S=(M-u0)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=S)return this;if(u0!==0&&S++,this.length=Math.min(S,this.length),u0!==0){var n0=67108863^67108863>>>u0<=67108864;u0++)this.words[u0]-=67108864,u0===this.length-1?this.words[u0+1]=1:this.words[u0+1]++;return this.length=Math.max(this.length,u0+1),this},Z.prototype.isubn=function(M){if(Y(typeof M=="number"),Y(M<67108864),M<0)return this.iaddn(-M);if(this.negative!==0)return this.negative=0,this.iaddn(M),this.negative=1,this;if(this.words[0]-=M,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u0=0;u0>26)-(t0/67108864|0),this.words[v+S]=s0&67108863}for(;v>26,this.words[v+S]=s0&67108863;if(I===0)return this._strip();for(Y(I===-1),I=0,v=0;v>26,this.words[v]=s0&67108863;return this.negative=1,this._strip()},Z.prototype._wordDiv=function(M,u0){var S=this.length-M.length,n0=this.clone(),v=M,s0=v.words[v.length-1]|0,I=this._countBits(s0);S=26-I,S!==0&&(v=v.ushln(S),n0.iushln(S),s0=v.words[v.length-1]|0);var t0=n0.length-v.length,m0;if(u0!=="mod"){m0=new Z(null),m0.length=t0+1,m0.words=new Array(m0.length);for(var a0=0;a0=0;e0--){var r0=(n0.words[v.length+e0]|0)*67108864+(n0.words[v.length+e0-1]|0);for(r0=Math.min(r0/s0|0,67108863),n0._ishlnsubmul(v,r0,e0);n0.negative!==0;)r0--,n0.negative=0,n0._ishlnsubmul(v,1,e0),n0.isZero()||(n0.negative^=1);m0&&(m0.words[e0]=r0)}return m0&&m0._strip(),n0._strip(),u0!=="div"&&S!==0&&n0.iushrn(S),{div:m0||null,mod:n0}},Z.prototype.divmod=function(M,u0,S){if(Y(!M.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var n0,v,s0;return this.negative!==0&&M.negative===0?(s0=this.neg().divmod(M,u0),u0!=="mod"&&(n0=s0.div.neg()),u0!=="div"&&(v=s0.mod.neg(),S&&v.negative!==0&&v.iadd(M)),{div:n0,mod:v}):this.negative===0&&M.negative!==0?(s0=this.divmod(M.neg(),u0),u0!=="mod"&&(n0=s0.div.neg()),{div:n0,mod:s0.mod}):(this.negative&M.negative)!==0?(s0=this.neg().divmod(M.neg(),u0),u0!=="div"&&(v=s0.mod.neg(),S&&v.negative!==0&&v.isub(M)),{div:s0.div,mod:v}):M.length>this.length||this.cmp(M)<0?{div:new Z(0),mod:this}:M.length===1?u0==="div"?{div:this.divn(M.words[0]),mod:null}:u0==="mod"?{div:null,mod:new Z(this.modrn(M.words[0]))}:{div:this.divn(M.words[0]),mod:new Z(this.modrn(M.words[0]))}:this._wordDiv(M,u0)},Z.prototype.div=function(M){return this.divmod(M,"div",!1).div},Z.prototype.mod=function(M){return this.divmod(M,"mod",!1).mod},Z.prototype.umod=function(M){return this.divmod(M,"mod",!0).mod},Z.prototype.divRound=function(M){var u0=this.divmod(M);if(u0.mod.isZero())return u0.div;var S=u0.div.negative!==0?u0.mod.isub(M):u0.mod,n0=M.ushrn(1),v=M.andln(1),s0=S.cmp(n0);return s0<0||v===1&&s0===0?u0.div:u0.div.negative!==0?u0.div.isubn(1):u0.div.iaddn(1)},Z.prototype.modrn=function(M){var u0=M<0;u0&&(M=-M),Y(M<=67108863);for(var S=(1<<26)%M,n0=0,v=this.length-1;v>=0;v--)n0=(S*n0+(this.words[v]|0))%M;return u0?-n0:n0},Z.prototype.modn=function(M){return this.modrn(M)},Z.prototype.idivn=function(M){var u0=M<0;u0&&(M=-M),Y(M<=67108863);for(var S=0,n0=this.length-1;n0>=0;n0--){var v=(this.words[n0]|0)+S*67108864;this.words[n0]=v/M|0,S=v%M}return this._strip(),u0?this.ineg():this},Z.prototype.divn=function(M){return this.clone().idivn(M)},Z.prototype.egcd=function(M){Y(M.negative===0),Y(!M.isZero());var u0=this,S=M.clone();u0.negative!==0?u0=u0.umod(M):u0=u0.clone();for(var n0=new Z(1),v=new Z(0),s0=new Z(0),I=new Z(1),t0=0;u0.isEven()&&S.isEven();)u0.iushrn(1),S.iushrn(1),++t0;for(var m0=S.clone(),a0=u0.clone();!u0.isZero();){for(var q=0,e0=1;(u0.words[0]&e0)===0&&q<26;++q,e0<<=1);if(q>0)for(u0.iushrn(q);q-- >0;)(n0.isOdd()||v.isOdd())&&(n0.iadd(m0),v.isub(a0)),n0.iushrn(1),v.iushrn(1);for(var r0=0,i0=1;(S.words[0]&i0)===0&&r0<26;++r0,i0<<=1);if(r0>0)for(S.iushrn(r0);r0-- >0;)(s0.isOdd()||I.isOdd())&&(s0.iadd(m0),I.isub(a0)),s0.iushrn(1),I.iushrn(1);u0.cmp(S)>=0?(u0.isub(S),n0.isub(s0),v.isub(I)):(S.isub(u0),s0.isub(n0),I.isub(v))}return{a:s0,b:I,gcd:S.iushln(t0)}},Z.prototype._invmp=function(M){Y(M.negative===0),Y(!M.isZero());var u0=this,S=M.clone();u0.negative!==0?u0=u0.umod(M):u0=u0.clone();for(var n0=new Z(1),v=new Z(0),s0=S.clone();u0.cmpn(1)>0&&S.cmpn(1)>0;){for(var I=0,t0=1;(u0.words[0]&t0)===0&&I<26;++I,t0<<=1);if(I>0)for(u0.iushrn(I);I-- >0;)n0.isOdd()&&n0.iadd(s0),n0.iushrn(1);for(var m0=0,a0=1;(S.words[0]&a0)===0&&m0<26;++m0,a0<<=1);if(m0>0)for(S.iushrn(m0);m0-- >0;)v.isOdd()&&v.iadd(s0),v.iushrn(1);u0.cmp(S)>=0?(u0.isub(S),n0.isub(v)):(S.isub(u0),v.isub(n0))}var q;return u0.cmpn(1)===0?q=n0:q=v,q.cmpn(0)<0&&q.iadd(M),q},Z.prototype.gcd=function(M){if(this.isZero())return M.abs();if(M.isZero())return this.abs();var u0=this.clone(),S=M.clone();u0.negative=0,S.negative=0;for(var n0=0;u0.isEven()&&S.isEven();n0++)u0.iushrn(1),S.iushrn(1);do{for(;u0.isEven();)u0.iushrn(1);for(;S.isEven();)S.iushrn(1);var v=u0.cmp(S);if(v<0){var s0=u0;u0=S,S=s0}else if(v===0||S.cmpn(1)===0)break;u0.isub(S)}while(!0);return S.iushln(n0)},Z.prototype.invm=function(M){return this.egcd(M).a.umod(M)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(M){return this.words[0]&M},Z.prototype.bincn=function(M){Y(typeof M=="number");var u0=M%26,S=(M-u0)/26,n0=1<>>26,I&=67108863,this.words[s0]=I}return v!==0&&(this.words[s0]=v,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(M){var u0=M<0;if(this.negative!==0&&!u0)return-1;if(this.negative===0&&u0)return 1;this._strip();var S;if(this.length>1)S=1;else{u0&&(M=-M),Y(M<=67108863,"Number is too big");var n0=this.words[0]|0;S=n0===M?0:n0M.length)return 1;if(this.length=0;S--){var n0=this.words[S]|0,v=M.words[S]|0;if(n0!==v){n0v&&(u0=1);break}}return u0},Z.prototype.gtn=function(M){return this.cmpn(M)===1},Z.prototype.gt=function(M){return this.cmp(M)===1},Z.prototype.gten=function(M){return this.cmpn(M)>=0},Z.prototype.gte=function(M){return this.cmp(M)>=0},Z.prototype.ltn=function(M){return this.cmpn(M)===-1},Z.prototype.lt=function(M){return this.cmp(M)===-1},Z.prototype.lten=function(M){return this.cmpn(M)<=0},Z.prototype.lte=function(M){return this.cmp(M)<=0},Z.prototype.eqn=function(M){return this.cmpn(M)===0},Z.prototype.eq=function(M){return this.cmp(M)===0},Z.red=function(M){return new z(M)},Z.prototype.toRed=function(M){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),M.convertTo(this)._forceRed(M)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(M){return this.red=M,this},Z.prototype.forceRed=function(M){return Y(!this.red,"Already a number in reduction context"),this._forceRed(M)},Z.prototype.redAdd=function(M){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,M)},Z.prototype.redIAdd=function(M){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,M)},Z.prototype.redSub=function(M){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,M)},Z.prototype.redISub=function(M){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,M)},Z.prototype.redShl=function(M){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,M)},Z.prototype.redMul=function(M){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,M),this.red.mul(this,M)},Z.prototype.redIMul=function(M){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,M),this.red.imul(this,M)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(M){return Y(this.red&&!M.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,M)};var L={k256:null,p224:null,p192:null,p25519:null};function d0(M,u0){this.name=M,this.p=new Z(u0,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}d0.prototype._tmp=function(){var M=new Z(null);return M.words=new Array(Math.ceil(this.n/13)),M},d0.prototype.ireduce=function(M){var u0=M,S;do this.split(u0,this.tmp),u0=this.imulK(u0),u0=u0.iadd(this.tmp),S=u0.bitLength();while(S>this.n);var n0=S0?u0.isub(this.p):u0.strip!==void 0?u0.strip():u0._strip(),u0},d0.prototype.split=function(M,u0){M.iushrn(this.n,0,u0)},d0.prototype.imulK=function(M){return M.imul(this.k)};function R(){d0.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(R,d0),R.prototype.split=function(M,u0){for(var S=4194303,n0=Math.min(M.length,9),v=0;v>>22,s0=I}s0>>>=22,M.words[v-10]=s0,s0===0&&M.length>10?M.length-=10:M.length-=9},R.prototype.imulK=function(M){M.words[M.length]=0,M.words[M.length+1]=0,M.length+=2;for(var u0=0,S=0;S>>=26,M.words[S]=v,u0=n0}return u0!==0&&(M.words[M.length++]=u0),M},Z._prime=function(M){if(L[M])return L[M];var u0;if(M==="k256")u0=new R;else if(M==="p224")u0=new b0;else if(M==="p192")u0=new P;else if(M==="p25519")u0=new l0;else throw new Error("Unknown prime "+M);return L[M]=u0,u0};function z(M){if(typeof M=="string"){var u0=Z._prime(M);this.m=u0.p,this.prime=u0}else Y(M.gtn(1),"modulus must be greater than 1"),this.m=M,this.prime=null}z.prototype._verify1=function(M){Y(M.negative===0,"red works only with positives"),Y(M.red,"red works only with red numbers")},z.prototype._verify2=function(M,u0){Y((M.negative|u0.negative)===0,"red works only with positives"),Y(M.red&&M.red===u0.red,"red works only with red numbers")},z.prototype.imod=function(M){return this.prime?this.prime.ireduce(M)._forceRed(this):(H(M,M.umod(this.m)._forceRed(this)),M)},z.prototype.neg=function(M){return M.isZero()?M.clone():this.m.sub(M)._forceRed(this)},z.prototype.add=function(M,u0){this._verify2(M,u0);var S=M.add(u0);return S.cmp(this.m)>=0&&S.isub(this.m),S._forceRed(this)},z.prototype.iadd=function(M,u0){this._verify2(M,u0);var S=M.iadd(u0);return S.cmp(this.m)>=0&&S.isub(this.m),S},z.prototype.sub=function(M,u0){this._verify2(M,u0);var S=M.sub(u0);return S.cmpn(0)<0&&S.iadd(this.m),S._forceRed(this)},z.prototype.isub=function(M,u0){this._verify2(M,u0);var S=M.isub(u0);return S.cmpn(0)<0&&S.iadd(this.m),S},z.prototype.shl=function(M,u0){return this._verify1(M),this.imod(M.ushln(u0))},z.prototype.imul=function(M,u0){return this._verify2(M,u0),this.imod(M.imul(u0))},z.prototype.mul=function(M,u0){return this._verify2(M,u0),this.imod(M.mul(u0))},z.prototype.isqr=function(M){return this.imul(M,M.clone())},z.prototype.sqr=function(M){return this.mul(M,M)},z.prototype.sqrt=function(M){if(M.isZero())return M.clone();var u0=this.m.andln(3);if(Y(u0%2===1),u0===3){var S=this.m.add(new Z(1)).iushrn(2);return this.pow(M,S)}for(var n0=this.m.subn(1),v=0;!n0.isZero()&&n0.andln(1)===0;)v++,n0.iushrn(1);Y(!n0.isZero());var s0=new Z(1).toRed(this),I=s0.redNeg(),t0=this.m.subn(1).iushrn(1),m0=this.m.bitLength();for(m0=new Z(2*m0*m0).toRed(this);this.pow(m0,t0).cmp(I)!==0;)m0.redIAdd(I);for(var a0=this.pow(m0,n0),q=this.pow(M,n0.addn(1).iushrn(1)),e0=this.pow(M,n0),r0=v;e0.cmp(s0)!==0;){for(var i0=e0,j=0;i0.cmp(s0)!==0;j++)i0=i0.redSqr();Y(j=0;v--){for(var a0=u0.words[v],q=m0-1;q>=0;q--){var e0=a0>>q&1;if(s0!==n0[0]&&(s0=this.sqr(s0)),e0===0&&I===0){t0=0;continue}I<<=1,I|=e0,t0++,!(t0!==S&&(v!==0||q!==0))&&(s0=this.mul(s0,n0[I]),t0=0,I=0)}m0=26}return s0},z.prototype.convertTo=function(M){var u0=M.umod(this.m);return u0===M?u0.clone():u0},z.prototype.convertFrom=function(M){var u0=M.clone();return u0.red=null,u0},Z.mont=function(M){return new o0(M)};function o0(M){z.call(this,M),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(o0,z),o0.prototype.convertTo=function(M){return this.imod(M.ushln(this.shift))},o0.prototype.convertFrom=function(M){var u0=this.imod(M.mul(this.rinv));return u0.red=null,u0},o0.prototype.imul=function(M,u0){if(M.isZero()||u0.isZero())return M.words[0]=0,M.length=1,M;var S=M.imul(u0),n0=S.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=S.isub(n0).iushrn(this.shift),s0=v;return v.cmp(this.m)>=0?s0=v.isub(this.m):v.cmpn(0)<0&&(s0=v.iadd(this.m)),s0._forceRed(this)},o0.prototype.mul=function(M,u0){if(M.isZero()||u0.isZero())return new Z(0)._forceRed(this);var S=M.mul(u0),n0=S.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=S.isub(n0).iushrn(this.shift),s0=v;return v.cmp(this.m)>=0?s0=v.isub(this.m):v.cmpn(0)<0&&(s0=v.iadd(this.m)),s0._forceRed(this)},o0.prototype.invm=function(M){var u0=this.imod(M._invmp(this.m).mul(this.r2));return u0._forceRed(this)}})(typeof K>"u"||K,X)}}),hQ=$Q({"node_modules/browserify-rsa/index.js"(X,K){var x0=cQ(),G=ZQ();function Y(Q){var U=$(Q),V=U.toRed(x0.mont(Q.modulus)).redPow(new x0(Q.publicExponent)).fromRed();return{blinder:V,unblinder:U.invm(Q.modulus)}}function $(Q){var U=Q.modulus.byteLength(),V;do V=new x0(G(U));while(V.cmp(Q.modulus)>=0||!V.umod(Q.prime1)||!V.umod(Q.prime2));return V}function Z(Q,U){var V=Y(U),B0=U.modulus.byteLength(),H=new x0(Q).mul(V.blinder).umod(U.modulus),y0=H.toRed(x0.mont(U.prime1)),W=H.toRed(x0.mont(U.prime2)),w0=U.coefficient,E=U.prime1,p0=U.prime2,T=y0.redPow(U.exponent1).fromRed(),f0=W.redPow(U.exponent2).fromRed(),D=T.isub(f0).imul(w0).umod(E).imul(p0);return f0.iadd(D).imul(V.unblinder).umod(U.modulus).toArrayLike(c$,"be",B0)}Z.getr=$,K.exports=Z}}),dQ=$Q({"node_modules/elliptic/package.json"(X,K){K.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"(X,K){(function(x0,G){function Y(l0,z){if(!l0)throw new Error(z||"Assertion failed")}function $(l0,z){l0.super_=z;var o0=function(){};o0.prototype=z.prototype,l0.prototype=new o0,l0.prototype.constructor=l0}function Z(l0,z,o0){if(Z.isBN(l0))return l0;this.negative=0,this.words=null,this.length=0,this.red=null,l0!==null&&((z==="le"||z==="be")&&(o0=z,z=10),this._init(l0||0,z||10,o0||"be"))}typeof x0=="object"?x0.exports=Z:G.BN=Z,Z.BN=Z,Z.wordSize=26;var Q=c$;Z.isBN=function(l0){return l0 instanceof Z?!0:l0!==null&&typeof l0=="object"&&l0.constructor.wordSize===Z.wordSize&&Array.isArray(l0.words)},Z.max=function(l0,z){return l0.cmp(z)>0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),lQ=$Q({"node_modules/minimalistic-crypto-utils/lib/utils.js"(X){var K=X;function x0($,Z){if(Array.isArray($))return $.slice();if(!$)return[];var Q=[];if(typeof $!="string"){for(var U=0;U<$.length;U++)Q[U]=$[U]|0;return Q}if(Z==="hex"){$=$.replace(/[^a-z0-9]+/gi,""),$.length%2!==0&&($="0"+$);for(var U=0;U<$.length;U+=2)Q.push(parseInt($[U]+$[U+1],16))}else for(var U=0;U<$.length;U++){var V=$.charCodeAt(U),B0=V>>8,H=V&255;B0?Q.push(B0,H):Q.push(H)}return Q}K.toArray=x0;function G($){return $.length===1?"0"+$:$}K.zero2=G;function Y($){for(var Z="",Q=0;Q<$.length;Q++)Z+=G($[Q].toString(16));return Z}K.toHex=Y,K.encode=function($,Z){return Z==="hex"?Y($):$}}}),oQ=$Q({"node_modules/elliptic/lib/elliptic/utils.js"(X){var K=X,x0=bQ(),G=N0(),Y=lQ();K.assert=G,K.toArray=Y.toArray,K.zero2=Y.zero2,K.toHex=Y.toHex,K.encode=Y.encode;function $(B0,H,y0){var W=new Array(Math.max(B0.bitLength(),y0)+1);W.fill(0);for(var w0=1<(w0>>1)-1?T=(w0>>1)-f0:T=f0,E.isubn(T)):T=0,W[p0]=T,E.iushrn(1)}return W}K.getNAF=$;function Z(B0,H){var y0=[[],[]];B0=B0.clone(),H=H.clone();for(var W=0,w0=0,E;B0.cmpn(-W)>0||H.cmpn(-w0)>0;){var p0=B0.andln(3)+W&3,T=H.andln(3)+w0&3;p0===3&&(p0=-1),T===3&&(T=-1);var f0;(p0&1)===0?f0=0:(E=B0.andln(7)+W&7,(E===3||E===5)&&T===2?f0=-p0:f0=p0),y0[0].push(f0);var D;(T&1)===0?D=0:(E=H.andln(7)+w0&7,(E===3||E===5)&&p0===2?D=-T:D=T),y0[1].push(D),2*W===f0+1&&(W=1-W),2*w0===D+1&&(w0=1-w0),B0.iushrn(1),H.iushrn(1)}return y0}K.getJSF=Z;function Q(B0,H,y0){var W="_"+H;B0.prototype[H]=function(){return this[W]!==void 0?this[W]:this[W]=y0.call(this)}}K.cachedProperty=Q;function U(B0){return typeof B0=="string"?K.toArray(B0,"hex"):B0}K.parseBytes=U;function V(B0){return new x0(B0,"hex","le")}K.intFromLE=V}}),uQ=$Q({"node_modules/elliptic/lib/elliptic/curve/base.js"(X,K){var x0=bQ(),G=oQ(),Y=G.getNAF,$=G.getJSF,Z=G.assert;function Q(V,B0){this.type=V,this.p=new x0(B0.p,16),this.red=B0.prime?x0.red(B0.prime):x0.mont(this.p),this.zero=new x0(0).toRed(this.red),this.one=new x0(1).toRed(this.red),this.two=new x0(2).toRed(this.red),this.n=B0.n&&new x0(B0.n,16),this.g=B0.g&&this.pointFromJSON(B0.g,B0.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 H=this.n&&this.p.div(this.n);!H||H.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}K.exports=Q,Q.prototype.point=function(){throw new Error("Not implemented")},Q.prototype.validate=function(){throw new Error("Not implemented")},Q.prototype._fixedNafMul=function(V,B0){Z(V.precomputed);var H=V._getDoubles(),y0=Y(B0,1,this._bitLength),W=(1<=E;T--)p0=(p0<<1)+y0[T];w0.push(p0)}for(var f0=this.jpoint(null,null,null),D=this.jpoint(null,null,null),c0=W;c0>0;c0--){for(E=0;E=0;p0--){for(var T=0;p0>=0&&w0[p0]===0;p0--)T++;if(p0>=0&&T++,E=E.dblp(T),p0<0)break;var f0=w0[p0];Z(f0!==0),V.type==="affine"?f0>0?E=E.mixedAdd(W[f0-1>>1]):E=E.mixedAdd(W[-f0-1>>1].neg()):f0>0?E=E.add(W[f0-1>>1]):E=E.add(W[-f0-1>>1].neg())}return V.type==="affine"?E.toP():E},Q.prototype._wnafMulAdd=function(V,B0,H,y0,W){var w0=this._wnafT1,E=this._wnafT2,p0=this._wnafT3,T=0,f0,D,c0;for(f0=0;f0=1;f0-=2){var h0=f0-1,L=f0;if(w0[h0]!==1||w0[L]!==1){p0[h0]=Y(H[h0],w0[h0],this._bitLength),p0[L]=Y(H[L],w0[L],this._bitLength),T=Math.max(p0[h0].length,T),T=Math.max(p0[L].length,T);continue}var d0=[B0[h0],null,null,B0[L]];B0[h0].y.cmp(B0[L].y)===0?(d0[1]=B0[h0].add(B0[L]),d0[2]=B0[h0].toJ().mixedAdd(B0[L].neg())):B0[h0].y.cmp(B0[L].y.redNeg())===0?(d0[1]=B0[h0].toJ().mixedAdd(B0[L]),d0[2]=B0[h0].add(B0[L].neg())):(d0[1]=B0[h0].toJ().mixedAdd(B0[L]),d0[2]=B0[h0].toJ().mixedAdd(B0[L].neg()));var R=[-3,-1,-5,-7,0,7,5,1,3],b0=$(H[h0],H[L]);for(T=Math.max(b0[0].length,T),p0[h0]=new Array(T),p0[L]=new Array(T),D=0;D=0;f0--){for(var M=0;f0>=0;){var u0=!0;for(D=0;D=0&&M++,z=z.dblp(M),f0<0)break;for(D=0;D0?c0=E[D][S-1>>1]:S<0&&(c0=E[D][-S-1>>1].neg()),c0.type==="affine"?z=z.mixedAdd(c0):z=z.add(c0))}}for(f0=0;f0=Math.ceil((V.bitLength()+1)/B0.step):!1},U.prototype._getDoubles=function(V,B0){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var H=[this],y0=this,W=0;W=0&&(h0=f0,L=D),c0.negative&&(c0=c0.neg(),C=C.neg()),h0.negative&&(h0=h0.neg(),L=L.neg()),[{a:c0,b:C},{a:h0,b:L}]},Q.prototype._endoSplit=function(B0){var H=this.endo.basis,y0=H[0],W=H[1],w0=W.b.mul(B0).divRound(this.n),E=y0.b.neg().mul(B0).divRound(this.n),p0=w0.mul(y0.a),T=E.mul(W.a),f0=w0.mul(y0.b),D=E.mul(W.b),c0=B0.sub(p0).sub(T),C=f0.add(D).neg();return{k1:c0,k2:C}},Q.prototype.pointFromX=function(B0,H){B0=new G(B0,16),B0.red||(B0=B0.toRed(this.red));var y0=B0.redSqr().redMul(B0).redIAdd(B0.redMul(this.a)).redIAdd(this.b),W=y0.redSqrt();if(W.redSqr().redSub(y0).cmp(this.zero)!==0)throw new Error("invalid point");var w0=W.fromRed().isOdd();return(H&&!w0||!H&&w0)&&(W=W.redNeg()),this.point(B0,W)},Q.prototype.validate=function(B0){if(B0.inf)return!0;var{x:H,y:y0}=B0,W=this.a.redMul(H),w0=H.redSqr().redMul(H).redIAdd(W).redIAdd(this.b);return y0.redSqr().redISub(w0).cmpn(0)===0},Q.prototype._endoWnafMulAdd=function(B0,H,y0){for(var W=this._endoWnafT1,w0=this._endoWnafT2,E=0;E":""},U.prototype.isInfinity=function(){return this.inf},U.prototype.add=function(B0){if(this.inf)return B0;if(B0.inf)return this;if(this.eq(B0))return this.dbl();if(this.neg().eq(B0))return this.curve.point(null,null);if(this.x.cmp(B0.x)===0)return this.curve.point(null,null);var H=this.y.redSub(B0.y);H.cmpn(0)!==0&&(H=H.redMul(this.x.redSub(B0.x).redInvm()));var y0=H.redSqr().redISub(this.x).redISub(B0.x),W=H.redMul(this.x.redSub(y0)).redISub(this.y);return this.curve.point(y0,W)},U.prototype.dbl=function(){if(this.inf)return this;var B0=this.y.redAdd(this.y);if(B0.cmpn(0)===0)return this.curve.point(null,null);var H=this.curve.a,y0=this.x.redSqr(),W=B0.redInvm(),w0=y0.redAdd(y0).redIAdd(y0).redIAdd(H).redMul(W),E=w0.redSqr().redISub(this.x.redAdd(this.x)),p0=w0.redMul(this.x.redSub(E)).redISub(this.y);return this.curve.point(E,p0)},U.prototype.getX=function(){return this.x.fromRed()},U.prototype.getY=function(){return this.y.fromRed()},U.prototype.mul=function(B0){return B0=new G(B0,16),this.isInfinity()?this:this._hasDoubles(B0)?this.curve._fixedNafMul(this,B0):this.curve.endo?this.curve._endoWnafMulAdd([this],[B0]):this.curve._wnafMul(this,B0)},U.prototype.mulAdd=function(B0,H,y0){var W=[this,H],w0=[B0,y0];return this.curve.endo?this.curve._endoWnafMulAdd(W,w0):this.curve._wnafMulAdd(1,W,w0,2)},U.prototype.jmulAdd=function(B0,H,y0){var W=[this,H],w0=[B0,y0];return this.curve.endo?this.curve._endoWnafMulAdd(W,w0,!0):this.curve._wnafMulAdd(1,W,w0,2,!0)},U.prototype.eq=function(B0){return this===B0||this.inf===B0.inf&&(this.inf||this.x.cmp(B0.x)===0&&this.y.cmp(B0.y)===0)},U.prototype.neg=function(B0){if(this.inf)return this;var H=this.curve.point(this.x,this.y.redNeg());if(B0&&this.precomputed){var y0=this.precomputed,W=function(w0){return w0.neg()};H.precomputed={naf:y0.naf&&{wnd:y0.naf.wnd,points:y0.naf.points.map(W)},doubles:y0.doubles&&{step:y0.doubles.step,points:y0.doubles.points.map(W)}}}return H},U.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var B0=this.curve.jpoint(this.x,this.y,this.curve.one);return B0};function V(B0,H,y0,W){$.BasePoint.call(this,B0,"jacobian"),H===null&&y0===null&&W===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new G(0)):(this.x=new G(H,16),this.y=new G(y0,16),this.z=new G(W,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}Y(V,$.BasePoint),Q.prototype.jpoint=function(B0,H,y0){return new V(this,B0,H,y0)},V.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var B0=this.z.redInvm(),H=B0.redSqr(),y0=this.x.redMul(H),W=this.y.redMul(H).redMul(B0);return this.curve.point(y0,W)},V.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},V.prototype.add=function(B0){if(this.isInfinity())return B0;if(B0.isInfinity())return this;var H=B0.z.redSqr(),y0=this.z.redSqr(),W=this.x.redMul(H),w0=B0.x.redMul(y0),E=this.y.redMul(H.redMul(B0.z)),p0=B0.y.redMul(y0.redMul(this.z)),T=W.redSub(w0),f0=E.redSub(p0);if(T.cmpn(0)===0)return f0.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var D=T.redSqr(),c0=D.redMul(T),C=W.redMul(D),h0=f0.redSqr().redIAdd(c0).redISub(C).redISub(C),L=f0.redMul(C.redISub(h0)).redISub(E.redMul(c0)),d0=this.z.redMul(B0.z).redMul(T);return this.curve.jpoint(h0,L,d0)},V.prototype.mixedAdd=function(B0){if(this.isInfinity())return B0.toJ();if(B0.isInfinity())return this;var H=this.z.redSqr(),y0=this.x,W=B0.x.redMul(H),w0=this.y,E=B0.y.redMul(H).redMul(this.z),p0=y0.redSub(W),T=w0.redSub(E);if(p0.cmpn(0)===0)return T.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var f0=p0.redSqr(),D=f0.redMul(p0),c0=y0.redMul(f0),C=T.redSqr().redIAdd(D).redISub(c0).redISub(c0),h0=T.redMul(c0.redISub(C)).redISub(w0.redMul(D)),L=this.z.redMul(p0);return this.curve.jpoint(C,h0,L)},V.prototype.dblp=function(B0){if(B0===0)return this;if(this.isInfinity())return this;if(!B0)return this.dbl();var H;if(this.curve.zeroA||this.curve.threeA){var y0=this;for(H=0;H=0)return!1;if(y0.redIAdd(w0),this.x.cmp(y0)===0)return!0}},V.prototype.inspect=function(){return this.isInfinity()?"":""},V.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),sQ=$Q({"node_modules/elliptic/lib/elliptic/curve/mont.js"(X,K){var x0=bQ(),G=X0(),Y=uQ(),$=oQ();function Z(U){Y.call(this,"mont",U),this.a=new x0(U.a,16).toRed(this.red),this.b=new x0(U.b,16).toRed(this.red),this.i4=new x0(4).toRed(this.red).redInvm(),this.two=new x0(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}G(Z,Y),K.exports=Z,Z.prototype.validate=function(U){var V=U.normalize().x,B0=V.redSqr(),H=B0.redMul(V).redAdd(B0.redMul(this.a)).redAdd(V),y0=H.redSqrt();return y0.redSqr().cmp(H)===0};function Q(U,V,B0){Y.BasePoint.call(this,U,"projective"),V===null&&B0===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new x0(V,16),this.z=new x0(B0,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}G(Q,Y.BasePoint),Z.prototype.decodePoint=function(U,V){return this.point($.toArray(U,V),1)},Z.prototype.point=function(U,V){return new Q(this,U,V)},Z.prototype.pointFromJSON=function(U){return Q.fromJSON(this,U)},Q.prototype.precompute=function(){},Q.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Q.fromJSON=function(U,V){return new Q(U,V[0],V[1]||U.one)},Q.prototype.inspect=function(){return this.isInfinity()?"":""},Q.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Q.prototype.dbl=function(){var U=this.x.redAdd(this.z),V=U.redSqr(),B0=this.x.redSub(this.z),H=B0.redSqr(),y0=V.redSub(H),W=V.redMul(H),w0=y0.redMul(H.redAdd(this.curve.a24.redMul(y0)));return this.curve.point(W,w0)},Q.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Q.prototype.diffAdd=function(U,V){var B0=this.x.redAdd(this.z),H=this.x.redSub(this.z),y0=U.x.redAdd(U.z),W=U.x.redSub(U.z),w0=W.redMul(B0),E=y0.redMul(H),p0=V.z.redMul(w0.redAdd(E).redSqr()),T=V.x.redMul(w0.redISub(E).redSqr());return this.curve.point(p0,T)},Q.prototype.mul=function(U){for(var V=U.clone(),B0=this,H=this.curve.point(null,null),y0=this,W=[];V.cmpn(0)!==0;V.iushrn(1))W.push(V.andln(1));for(var w0=W.length-1;w0>=0;w0--)W[w0]===0?(B0=B0.diffAdd(H,y0),H=H.dbl()):(H=B0.diffAdd(H,y0),B0=B0.dbl());return H},Q.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Q.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Q.prototype.eq=function(U){return this.getX().cmp(U.getX())===0},Q.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Q.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),tQ=$Q({"node_modules/elliptic/lib/elliptic/curve/edwards.js"(X,K){var x0=oQ(),G=bQ(),Y=X0(),$=uQ(),Z=x0.assert;function Q(V){this.twisted=(V.a|0)!==1,this.mOneA=this.twisted&&(V.a|0)===-1,this.extended=this.mOneA,$.call(this,"edwards",V),this.a=new G(V.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new G(V.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new G(V.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Z(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(V.c|0)===1}Y(Q,$),K.exports=Q,Q.prototype._mulA=function(V){return this.mOneA?V.redNeg():this.a.redMul(V)},Q.prototype._mulC=function(V){return this.oneC?V:this.c.redMul(V)},Q.prototype.jpoint=function(V,B0,H,y0){return this.point(V,B0,H,y0)},Q.prototype.pointFromX=function(V,B0){V=new G(V,16),V.red||(V=V.toRed(this.red));var H=V.redSqr(),y0=this.c2.redSub(this.a.redMul(H)),W=this.one.redSub(this.c2.redMul(this.d).redMul(H)),w0=y0.redMul(W.redInvm()),E=w0.redSqrt();if(E.redSqr().redSub(w0).cmp(this.zero)!==0)throw new Error("invalid point");var p0=E.fromRed().isOdd();return(B0&&!p0||!B0&&p0)&&(E=E.redNeg()),this.point(V,E)},Q.prototype.pointFromY=function(V,B0){V=new G(V,16),V.red||(V=V.toRed(this.red));var H=V.redSqr(),y0=H.redSub(this.c2),W=H.redMul(this.d).redMul(this.c2).redSub(this.a),w0=y0.redMul(W.redInvm());if(w0.cmp(this.zero)===0){if(B0)throw new Error("invalid point");return this.point(this.zero,V)}var E=w0.redSqrt();if(E.redSqr().redSub(w0).cmp(this.zero)!==0)throw new Error("invalid point");return E.fromRed().isOdd()!==B0&&(E=E.redNeg()),this.point(E,V)},Q.prototype.validate=function(V){if(V.isInfinity())return!0;V.normalize();var B0=V.x.redSqr(),H=V.y.redSqr(),y0=B0.redMul(this.a).redAdd(H),W=this.c2.redMul(this.one.redAdd(this.d.redMul(B0).redMul(H)));return y0.cmp(W)===0};function U(V,B0,H,y0,W){$.BasePoint.call(this,V,"projective"),B0===null&&H===null&&y0===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 G(B0,16),this.y=new G(H,16),this.z=y0?new G(y0,16):this.curve.one,this.t=W&&new G(W,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()))))}Y(U,$.BasePoint),Q.prototype.pointFromJSON=function(V){return U.fromJSON(this,V)},Q.prototype.point=function(V,B0,H,y0){return new U(this,V,B0,H,y0)},U.fromJSON=function(V,B0){return new U(V,B0[0],B0[1],B0[2])},U.prototype.inspect=function(){return this.isInfinity()?"":""},U.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},U.prototype._extDbl=function(){var V=this.x.redSqr(),B0=this.y.redSqr(),H=this.z.redSqr();H=H.redIAdd(H);var y0=this.curve._mulA(V),W=this.x.redAdd(this.y).redSqr().redISub(V).redISub(B0),w0=y0.redAdd(B0),E=w0.redSub(H),p0=y0.redSub(B0),T=W.redMul(E),f0=w0.redMul(p0),D=W.redMul(p0),c0=E.redMul(w0);return this.curve.point(T,f0,c0,D)},U.prototype._projDbl=function(){var V=this.x.redAdd(this.y).redSqr(),B0=this.x.redSqr(),H=this.y.redSqr(),y0,W,w0,E,p0,T;if(this.curve.twisted){E=this.curve._mulA(B0);var f0=E.redAdd(H);this.zOne?(y0=V.redSub(B0).redSub(H).redMul(f0.redSub(this.curve.two)),W=f0.redMul(E.redSub(H)),w0=f0.redSqr().redSub(f0).redSub(f0)):(p0=this.z.redSqr(),T=f0.redSub(p0).redISub(p0),y0=V.redSub(B0).redISub(H).redMul(T),W=f0.redMul(E.redSub(H)),w0=f0.redMul(T))}else E=B0.redAdd(H),p0=this.curve._mulC(this.z).redSqr(),T=E.redSub(p0).redSub(p0),y0=this.curve._mulC(V.redISub(E)).redMul(T),W=this.curve._mulC(E).redMul(B0.redISub(H)),w0=E.redMul(T);return this.curve.point(y0,W,w0)},U.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},U.prototype._extAdd=function(V){var B0=this.y.redSub(this.x).redMul(V.y.redSub(V.x)),H=this.y.redAdd(this.x).redMul(V.y.redAdd(V.x)),y0=this.t.redMul(this.curve.dd).redMul(V.t),W=this.z.redMul(V.z.redAdd(V.z)),w0=H.redSub(B0),E=W.redSub(y0),p0=W.redAdd(y0),T=H.redAdd(B0),f0=w0.redMul(E),D=p0.redMul(T),c0=w0.redMul(T),C=E.redMul(p0);return this.curve.point(f0,D,C,c0)},U.prototype._projAdd=function(V){var B0=this.z.redMul(V.z),H=B0.redSqr(),y0=this.x.redMul(V.x),W=this.y.redMul(V.y),w0=this.curve.d.redMul(y0).redMul(W),E=H.redSub(w0),p0=H.redAdd(w0),T=this.x.redAdd(this.y).redMul(V.x.redAdd(V.y)).redISub(y0).redISub(W),f0=B0.redMul(E).redMul(T),D,c0;return this.curve.twisted?(D=B0.redMul(p0).redMul(W.redSub(this.curve._mulA(y0))),c0=E.redMul(p0)):(D=B0.redMul(p0).redMul(W.redSub(y0)),c0=this.curve._mulC(E).redMul(p0)),this.curve.point(f0,D,c0)},U.prototype.add=function(V){return this.isInfinity()?V:V.isInfinity()?this:this.curve.extended?this._extAdd(V):this._projAdd(V)},U.prototype.mul=function(V){return this._hasDoubles(V)?this.curve._fixedNafMul(this,V):this.curve._wnafMul(this,V)},U.prototype.mulAdd=function(V,B0,H){return this.curve._wnafMulAdd(1,[this,B0],[V,H],2,!1)},U.prototype.jmulAdd=function(V,B0,H){return this.curve._wnafMulAdd(1,[this,B0],[V,H],2,!0)},U.prototype.normalize=function(){if(this.zOne)return this;var V=this.z.redInvm();return this.x=this.x.redMul(V),this.y=this.y.redMul(V),this.t&&(this.t=this.t.redMul(V)),this.z=this.curve.one,this.zOne=!0,this},U.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},U.prototype.getX=function(){return this.normalize(),this.x.fromRed()},U.prototype.getY=function(){return this.normalize(),this.y.fromRed()},U.prototype.eq=function(V){return this===V||this.getX().cmp(V.getX())===0&&this.getY().cmp(V.getY())===0},U.prototype.eqXToP=function(V){var B0=V.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(B0)===0)return!0;for(var H=V.clone(),y0=this.curve.redN.redMul(this.z);;){if(H.iadd(this.curve.n),H.cmp(this.curve.p)>=0)return!1;if(B0.redIAdd(y0),this.x.cmp(B0)===0)return!0}},U.prototype.toP=U.prototype.normalize,U.prototype.mixedAdd=U.prototype.add}}),mQ=$Q({"node_modules/elliptic/lib/elliptic/curve/index.js"(X){var K=X;K.base=uQ(),K.short=nQ(),K.mont=sQ(),K.edwards=tQ()}}),aQ=$Q({"node_modules/hash.js/lib/hash/utils.js"(X){var K=N0(),x0=X0();X.inherits=x0;function G(z,o0){return(z.charCodeAt(o0)&64512)!==55296||o0<0||o0+1>=z.length?!1:(z.charCodeAt(o0+1)&64512)===56320}function Y(z,o0){if(Array.isArray(z))return z.slice();if(!z)return[];var M=[];if(typeof z=="string")if(o0){if(o0==="hex")for(z=z.replace(/[^a-z0-9]+/gi,""),z.length%2!==0&&(z="0"+z),S=0;S>6|192,M[u0++]=n0&63|128):G(z,S)?(n0=65536+((n0&1023)<<10)+(z.charCodeAt(++S)&1023),M[u0++]=n0>>18|240,M[u0++]=n0>>12&63|128,M[u0++]=n0>>6&63|128,M[u0++]=n0&63|128):(M[u0++]=n0>>12|224,M[u0++]=n0>>6&63|128,M[u0++]=n0&63|128)}else for(S=0;S>>24|z>>>8&65280|z<<8&16711680|(z&255)<<24;return o0>>>0}X.htonl=Z;function Q(z,o0){for(var M="",u0=0;u0>>0}return n0}X.join32=B0;function H(z,o0){for(var M=new Array(z.length*4),u0=0,S=0;u0>>24,M[S+1]=n0>>>16&255,M[S+2]=n0>>>8&255,M[S+3]=n0&255):(M[S+3]=n0>>>24,M[S+2]=n0>>>16&255,M[S+1]=n0>>>8&255,M[S]=n0&255)}return M}X.split32=H;function y0(z,o0){return z>>>o0|z<<32-o0}X.rotr32=y0;function W(z,o0){return z<>>32-o0}X.rotl32=W;function w0(z,o0){return z+o0>>>0}X.sum32=w0;function E(z,o0,M){return z+o0+M>>>0}X.sum32_3=E;function p0(z,o0,M,u0){return z+o0+M+u0>>>0}X.sum32_4=p0;function T(z,o0,M,u0,S){return z+o0+M+u0+S>>>0}X.sum32_5=T;function f0(z,o0,M,u0){var S=z[o0],n0=z[o0+1],v=u0+n0>>>0,s0=(v>>0,z[o0+1]=v}X.sum64=f0;function D(z,o0,M,u0){var S=o0+u0>>>0,n0=(S>>0}X.sum64_hi=D;function c0(z,o0,M,u0){var S=o0+u0;return S>>>0}X.sum64_lo=c0;function C(z,o0,M,u0,S,n0,v,s0){var I=0,t0=o0;t0=t0+u0>>>0,I+=t0>>0,I+=t0>>0,I+=t0>>0}X.sum64_4_hi=C;function h0(z,o0,M,u0,S,n0,v,s0){var I=o0+u0+n0+s0;return I>>>0}X.sum64_4_lo=h0;function L(z,o0,M,u0,S,n0,v,s0,I,t0){var m0=0,a0=o0;a0=a0+u0>>>0,m0+=a0>>0,m0+=a0>>0,m0+=a0>>0,m0+=a0>>0}X.sum64_5_hi=L;function d0(z,o0,M,u0,S,n0,v,s0,I,t0){var m0=o0+u0+n0+s0+t0;return m0>>>0}X.sum64_5_lo=d0;function R(z,o0,M){var u0=o0<<32-M|z>>>M;return u0>>>0}X.rotr64_hi=R;function b0(z,o0,M){var u0=z<<32-M|o0>>>M;return u0>>>0}X.rotr64_lo=b0;function P(z,o0,M){return z>>>M}X.shr64_hi=P;function l0(z,o0,M){var u0=z<<32-M|o0>>>M;return u0>>>0}X.shr64_lo=l0}}),eQ=$Q({"node_modules/hash.js/lib/hash/common.js"(X){var K=aQ(),x0=N0();function G(){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}X.BlockHash=G,G.prototype.update=function(Y,$){if(Y=K.toArray(Y,$),this.pending?this.pending=this.pending.concat(Y):this.pending=Y,this.pendingTotal+=Y.length,this.pending.length>=this._delta8){Y=this.pending;var Z=Y.length%this._delta8;this.pending=Y.slice(Y.length-Z,Y.length),this.pending.length===0&&(this.pending=null),Y=K.join32(Y,0,Y.length-Z,this.endian);for(var Q=0;Q>>24&255,Q[U++]=Y>>>16&255,Q[U++]=Y>>>8&255,Q[U++]=Y&255}else for(Q[U++]=Y&255,Q[U++]=Y>>>8&255,Q[U++]=Y>>>16&255,Q[U++]=Y>>>24&255,Q[U++]=0,Q[U++]=0,Q[U++]=0,Q[U++]=0,V=8;V>>3}X.g0_256=V;function B0(H){return x0(H,17)^x0(H,19)^H>>>10}X.g1_256=B0}}),iQ=$Q({"node_modules/hash.js/lib/hash/sha/1.js"(X,K){var x0=aQ(),G=eQ(),Y=rQ(),$=x0.rotl32,Z=x0.sum32,Q=x0.sum32_5,U=Y.ft_1,V=G.BlockHash,B0=[1518500249,1859775393,2400959708,3395469782];function H(){if(!(this instanceof H))return new H;V.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}x0.inherits(H,V),K.exports=H,H.blockSize=512,H.outSize=160,H.hmacStrength=80,H.padLength=64,H.prototype._update=function(y0,W){for(var w0=this.W,E=0;E<16;E++)w0[E]=y0[W+E];for(;Ethis.blockSize&&($=new this.Hash().update($).digest()),G($.length<=this.blockSize);for(var Z=$.length;Z=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(Q,U,V)}K.exports=$,$.prototype._init=function(Z,Q,U){var V=Z.concat(Q).concat(U);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var B0=0;B0=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(Z.concat(U||[])),this._reseed=1},$.prototype.generate=function(Z,Q,U,V){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof Q!="string"&&(V=U,U=Q,Q=null),U&&(U=G.toArray(U,V||"hex"),this._update(U));for(var B0=[];B0.length"}}}),FY=$Q({"node_modules/elliptic/lib/elliptic/ec/signature.js"(X,K){var x0=bQ(),G=oQ(),Y=G.assert;function $(B0,H){if(B0 instanceof $)return B0;this._importDER(B0,H)||(Y(B0.r&&B0.s,"Signature without r or s"),this.r=new x0(B0.r,16),this.s=new x0(B0.s,16),B0.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=B0.recoveryParam)}K.exports=$;function Z(){this.place=0}function Q(B0,H){var y0=B0[H.place++];if(!(y0&128))return y0;var W=y0&15;if(W===0||W>4)return!1;for(var w0=0,E=0,p0=H.place;E>>=0;return w0<=127?!1:(H.place=p0,w0)}function U(B0){for(var H=0,y0=B0.length-1;!B0[H]&&!(B0[H+1]&128)&&H>>3);for(B0.push(y0|128);--y0;)B0.push(H>>>(y0<<3)&255);B0.push(H)}$.prototype.toDER=function(B0){var H=this.r.toArray(),y0=this.s.toArray();for(H[0]&128&&(H=[0].concat(H)),y0[0]&128&&(y0=[0].concat(y0)),H=U(H),y0=U(y0);!y0[0]&&!(y0[1]&128);)y0=y0.slice(1);var W=[2];V(W,H.length),W=W.concat(H),W.push(2),V(W,y0.length);var w0=W.concat(y0),E=[48];return V(E,w0.length),E=E.concat(w0),G.encode(E,B0)}}}),AY=$Q({"node_modules/elliptic/lib/elliptic/ec/index.js"(X,K){var x0=bQ(),G=OY(),Y=oQ(),$=IY(),Z=xQ(),Q=Y.assert,U=JY(),V=FY();function B0(H){if(!(this instanceof B0))return new B0(H);typeof H=="string"&&(Q(Object.prototype.hasOwnProperty.call($,H),"Unknown curve "+H),H=$[H]),H instanceof $.PresetCurve&&(H={curve:H}),this.curve=H.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=H.curve.g,this.g.precompute(H.curve.n.bitLength()+1),this.hash=H.hash||H.curve.hash}K.exports=B0,B0.prototype.keyPair=function(H){return new U(this,H)},B0.prototype.keyFromPrivate=function(H,y0){return U.fromPrivate(this,H,y0)},B0.prototype.keyFromPublic=function(H,y0){return U.fromPublic(this,H,y0)},B0.prototype.genKeyPair=function(H){H||(H={});for(var y0=new G({hash:this.hash,pers:H.pers,persEnc:H.persEnc||"utf8",entropy:H.entropy||Z(this.hash.hmacStrength),entropyEnc:H.entropy&&H.entropyEnc||"utf8",nonce:this.n.toArray()}),W=this.n.byteLength(),w0=this.n.sub(new x0(2));;){var E=new x0(y0.generate(W));if(!(E.cmp(w0)>0))return E.iaddn(1),this.keyFromPrivate(E)}},B0.prototype._truncateToN=function(H,y0){var W=H.byteLength()*8-this.n.bitLength();return W>0&&(H=H.ushrn(W)),!y0&&H.cmp(this.n)>=0?H.sub(this.n):H},B0.prototype.sign=function(H,y0,W,w0){typeof W=="object"&&(w0=W,W=null),w0||(w0={}),y0=this.keyFromPrivate(y0,W),H=this._truncateToN(new x0(H,16));for(var E=this.n.byteLength(),p0=y0.getPrivate().toArray("be",E),T=H.toArray("be",E),f0=new G({hash:this.hash,entropy:p0,nonce:T,pers:w0.pers,persEnc:w0.persEnc||"utf8"}),D=this.n.sub(new x0(1)),c0=0;;c0++){var C=w0.k?w0.k(c0):new x0(f0.generate(this.n.byteLength()));if(C=this._truncateToN(C,!0),!(C.cmpn(1)<=0||C.cmp(D)>=0)){var h0=this.g.mul(C);if(!h0.isInfinity()){var L=h0.getX(),d0=L.umod(this.n);if(d0.cmpn(0)!==0){var R=C.invm(this.n).mul(d0.mul(y0.getPrivate()).iadd(H));if(R=R.umod(this.n),R.cmpn(0)!==0){var b0=(h0.getY().isOdd()?1:0)|(L.cmp(d0)!==0?2:0);return w0.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),b0^=1),new V({r:d0,s:R,recoveryParam:b0})}}}}}},B0.prototype.verify=function(H,y0,W,w0){H=this._truncateToN(new x0(H,16)),W=this.keyFromPublic(W,w0),y0=new V(y0,"hex");var{r:E,s:p0}=y0;if(E.cmpn(1)<0||E.cmp(this.n)>=0||p0.cmpn(1)<0||p0.cmp(this.n)>=0)return!1;var T=p0.invm(this.n),f0=T.mul(H).umod(this.n),D=T.mul(E).umod(this.n),c0;return this.curve._maxwellTrick?(c0=this.g.jmulAdd(f0,W.getPublic(),D),c0.isInfinity()?!1:c0.eqXToP(E)):(c0=this.g.mulAdd(f0,W.getPublic(),D),c0.isInfinity()?!1:c0.getX().umod(this.n).cmp(E)===0)},B0.prototype.recoverPubKey=function(H,y0,W,w0){Q((3&W)===W,"The recovery param is more than two bits"),y0=new V(y0,w0);var E=this.n,p0=new x0(H),T=y0.r,f0=y0.s,D=W&1,c0=W>>1;if(T.cmp(this.curve.p.umod(this.curve.n))>=0&&c0)throw new Error("Unable to find sencond key candinate");c0?T=this.curve.pointFromX(T.add(this.curve.n),D):T=this.curve.pointFromX(T,D);var C=y0.r.invm(E),h0=E.sub(p0).mul(C).umod(E),L=f0.mul(C).umod(E);return this.g.mulAdd(h0,T,L)},B0.prototype.getKeyRecoveryParam=function(H,y0,W,w0){if(y0=new V(y0,w0),y0.recoveryParam!==null)return y0.recoveryParam;for(var E=0;E<4;E++){var p0;try{p0=this.recoverPubKey(H,y0,E)}catch{continue}if(p0.eq(W))return E}throw new Error("Unable to find valid recovery factor")}}}),HY=$Q({"node_modules/elliptic/lib/elliptic/eddsa/key.js"(X,K){var x0=oQ(),G=x0.assert,Y=x0.parseBytes,$=x0.cachedProperty;function Z(Q,U){this.eddsa=Q,this._secret=Y(U.secret),Q.isPoint(U.pub)?this._pub=U.pub:this._pubBytes=Y(U.pub)}Z.fromPublic=function(Q,U){return U instanceof Z?U:new Z(Q,{pub:U})},Z.fromSecret=function(Q,U){return U instanceof Z?U:new Z(Q,{secret:U})},Z.prototype.secret=function(){return this._secret},$(Z,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),$(Z,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),$(Z,"privBytes",function(){var Q=this.eddsa,U=this.hash(),V=Q.encodingLength-1,B0=U.slice(0,Q.encodingLength);return B0[0]&=248,B0[V]&=127,B0[V]|=64,B0}),$(Z,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),$(Z,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),$(Z,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Z.prototype.sign=function(Q){return G(this._secret,"KeyPair can only verify"),this.eddsa.sign(Q,this)},Z.prototype.verify=function(Q,U){return this.eddsa.verify(Q,U,this)},Z.prototype.getSecret=function(Q){return G(this._secret,"KeyPair is public only"),x0.encode(this.secret(),Q)},Z.prototype.getPublic=function(Q){return x0.encode(this.pubBytes(),Q)},K.exports=Z}}),WY=$Q({"node_modules/elliptic/lib/elliptic/eddsa/signature.js"(X,K){var x0=bQ(),G=oQ(),Y=G.assert,$=G.cachedProperty,Z=G.parseBytes;function Q(U,V){this.eddsa=U,typeof V!="object"&&(V=Z(V)),Array.isArray(V)&&(V={R:V.slice(0,U.encodingLength),S:V.slice(U.encodingLength)}),Y(V.R&&V.S,"Signature without R or S"),U.isPoint(V.R)&&(this._R=V.R),V.S instanceof x0&&(this._S=V.S),this._Rencoded=Array.isArray(V.R)?V.R:V.Rencoded,this._Sencoded=Array.isArray(V.S)?V.S:V.Sencoded}$(Q,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),$(Q,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),$(Q,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),$(Q,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Q.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Q.prototype.toHex=function(){return G.encode(this.toBytes(),"hex").toUpperCase()},K.exports=Q}}),EY=$Q({"node_modules/elliptic/lib/elliptic/eddsa/index.js"(X,K){var x0=XY(),G=IY(),Y=oQ(),$=Y.assert,Z=Y.parseBytes,Q=HY(),U=WY();function V(B0){if($(B0==="ed25519","only tested with ed25519 so far"),!(this instanceof V))return new V(B0);B0=G[B0].curve,this.curve=B0,this.g=B0.g,this.g.precompute(B0.n.bitLength()+1),this.pointClass=B0.point().constructor,this.encodingLength=Math.ceil(B0.n.bitLength()/8),this.hash=x0.sha512}K.exports=V,V.prototype.sign=function(B0,H){B0=Z(B0);var y0=this.keyFromSecret(H),W=this.hashInt(y0.messagePrefix(),B0),w0=this.g.mul(W),E=this.encodePoint(w0),p0=this.hashInt(E,y0.pubBytes(),B0).mul(y0.priv()),T=W.add(p0).umod(this.curve.n);return this.makeSignature({R:w0,S:T,Rencoded:E})},V.prototype.verify=function(B0,H,y0){B0=Z(B0),H=this.makeSignature(H);var W=this.keyFromPublic(y0),w0=this.hashInt(H.Rencoded(),W.pubBytes(),B0),E=this.g.mul(H.S()),p0=H.R().add(W.pub().mul(w0));return p0.eq(E)},V.prototype.hashInt=function(){for(var B0=this.hash(),H=0;H0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),CY=$Q({"node_modules/safer-buffer/safer.js"(X,K){var x0=e$,G=c$,Y={},$;for($ in x0)!x0.hasOwnProperty($)||$==="SlowBuffer"||$==="Buffer"||(Y[$]=x0[$]);var Z=Y.Buffer={};for($ in G)!G.hasOwnProperty($)||$==="allocUnsafe"||$==="allocUnsafeSlow"||(Z[$]=G[$]);if(Y.Buffer.prototype=G.prototype,(!Z.from||Z.from===Uint8Array.from)&&(Z.from=function(Q,U,V){if(typeof Q=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof Q);if(Q&&typeof Q.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Q);return G(Q,U,V)}),Z.alloc||(Z.alloc=function(Q,U,V){if(typeof Q!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof Q);if(Q<0||Q>=2*(1<<30))throw new RangeError('The value "'+Q+'" is invalid for option "size"');var B0=G(Q);return!U||U.length===0?B0.fill(0):typeof V=="string"?B0.fill(U,V):B0.fill(U),B0}),!Y.kStringMaxLength)try{Y.kStringMaxLength=r$}catch{}Y.constants||(Y.constants={MAX_LENGTH:Y.kMaxLength},Y.kStringMaxLength&&(Y.constants.MAX_STRING_LENGTH=Y.kStringMaxLength)),K.exports=Y}}),LY=$Q({"node_modules/asn1.js/lib/asn1/base/reporter.js"(X){var K=X0();function x0(Y){this._reporterState={obj:null,path:[],options:Y||{},errors:[]}}X.Reporter=x0,x0.prototype.isError=function(Y){return Y instanceof G},x0.prototype.save=function(){let Y=this._reporterState;return{obj:Y.obj,pathLen:Y.path.length}},x0.prototype.restore=function(Y){let $=this._reporterState;$.obj=Y.obj,$.path=$.path.slice(0,Y.pathLen)},x0.prototype.enterKey=function(Y){return this._reporterState.path.push(Y)},x0.prototype.exitKey=function(Y){let $=this._reporterState;$.path=$.path.slice(0,Y-1)},x0.prototype.leaveKey=function(Y,$,Z){let Q=this._reporterState;this.exitKey(Y),Q.obj!==null&&(Q.obj[$]=Z)},x0.prototype.path=function(){return this._reporterState.path.join("/")},x0.prototype.enterObject=function(){let Y=this._reporterState,$=Y.obj;return Y.obj={},$},x0.prototype.leaveObject=function(Y){let $=this._reporterState,Z=$.obj;return $.obj=Y,Z},x0.prototype.error=function(Y){let $,Z=this._reporterState,Q=Y instanceof G;if(Q?$=Y:$=new G(Z.path.map(function(U){return"["+JSON.stringify(U)+"]"}).join(""),Y.message||Y,Y.stack),!Z.options.partial)throw $;return Q||Z.errors.push($),$},x0.prototype.wrapResult=function(Y){let $=this._reporterState;return $.options.partial?{result:this.isError(Y)?null:Y,errors:$.errors}:Y};function G(Y,$){this.path=Y,this.rethrow($)}K(G,Error),G.prototype.rethrow=function(Y){if(this.message=Y+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,G),!this.stack)try{throw new Error(this.message)}catch($){this.stack=$.stack}return this}}}),l$=$Q({"node_modules/asn1.js/lib/asn1/base/buffer.js"(X){var K=X0(),x0=LY().Reporter,G=CY().Buffer;function Y(Z,Q){if(x0.call(this,Q),!G.isBuffer(Z)){this.error("Input not Buffer");return}this.base=Z,this.offset=0,this.length=Z.length}K(Y,x0),X.DecoderBuffer=Y,Y.isDecoderBuffer=function(Z){return Z instanceof Y?!0:typeof Z=="object"&&G.isBuffer(Z.base)&&Z.constructor.name==="DecoderBuffer"&&typeof Z.offset=="number"&&typeof Z.length=="number"&&typeof Z.save=="function"&&typeof Z.restore=="function"&&typeof Z.isEmpty=="function"&&typeof Z.readUInt8=="function"&&typeof Z.skip=="function"&&typeof Z.raw=="function"},Y.prototype.save=function(){return{offset:this.offset,reporter:x0.prototype.save.call(this)}},Y.prototype.restore=function(Z){let Q=new Y(this.base);return Q.offset=Z.offset,Q.length=this.offset,this.offset=Z.offset,x0.prototype.restore.call(this,Z.reporter),Q},Y.prototype.isEmpty=function(){return this.offset===this.length},Y.prototype.readUInt8=function(Z){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(Z||"DecoderBuffer overrun")},Y.prototype.skip=function(Z,Q){if(!(this.offset+Z<=this.length))return this.error(Q||"DecoderBuffer overrun");let U=new Y(this.base);return U._reporterState=this._reporterState,U.offset=this.offset,U.length=this.offset+Z,this.offset+=Z,U},Y.prototype.raw=function(Z){return this.base.slice(Z?Z.offset:this.offset,this.length)};function $(Z,Q){if(Array.isArray(Z))this.length=0,this.value=Z.map(function(U){return $.isEncoderBuffer(U)||(U=new $(U,Q)),this.length+=U.length,U},this);else if(typeof Z=="number"){if(!(0<=Z&&Z<=255))return Q.error("non-byte EncoderBuffer value");this.value=Z,this.length=1}else if(typeof Z=="string")this.value=Z,this.length=G.byteLength(Z);else if(G.isBuffer(Z))this.value=Z,this.length=Z.length;else return Q.error("Unsupported type: "+typeof Z)}X.EncoderBuffer=$,$.isEncoderBuffer=function(Z){return Z instanceof $?!0:typeof Z=="object"&&Z.constructor.name==="EncoderBuffer"&&typeof Z.length=="number"&&typeof Z.join=="function"},$.prototype.join=function(Z,Q){return Z||(Z=G.alloc(this.length)),Q||(Q=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(U){U.join(Z,Q),Q+=U.length}):(typeof this.value=="number"?Z[Q]=this.value:typeof this.value=="string"?Z.write(this.value,Q):G.isBuffer(this.value)&&this.value.copy(Z,Q),Q+=this.length)),Z}}}),RY=$Q({"node_modules/asn1.js/lib/asn1/base/node.js"(X,K){var x0=LY().Reporter,G=l$().EncoderBuffer,Y=l$().DecoderBuffer,$=N0(),Z=["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"],Q=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(Z),U=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function V(H,y0,W){let w0={};this._baseState=w0,w0.name=W,w0.enc=H,w0.parent=y0||null,w0.children=null,w0.tag=null,w0.args=null,w0.reverseArgs=null,w0.choice=null,w0.optional=!1,w0.any=!1,w0.obj=!1,w0.use=null,w0.useDecoder=null,w0.key=null,w0.default=null,w0.explicit=null,w0.implicit=null,w0.contains=null,w0.parent||(w0.children=[],this._wrap())}K.exports=V;var B0=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];V.prototype.clone=function(){let H=this._baseState,y0={};B0.forEach(function(w0){y0[w0]=H[w0]});let W=new this.constructor(y0.parent);return W._baseState=y0,W},V.prototype._wrap=function(){let H=this._baseState;Q.forEach(function(y0){this[y0]=function(){let W=new this.constructor(this);return H.children.push(W),W[y0].apply(W,arguments)}},this)},V.prototype._init=function(H){let y0=this._baseState;$(y0.parent===null),H.call(this),y0.children=y0.children.filter(function(W){return W._baseState.parent===this},this),$.equal(y0.children.length,1,"Root node can have only one child")},V.prototype._useArgs=function(H){let y0=this._baseState,W=H.filter(function(w0){return w0 instanceof this.constructor},this);H=H.filter(function(w0){return!(w0 instanceof this.constructor)},this),W.length!==0&&($(y0.children===null),y0.children=W,W.forEach(function(w0){w0._baseState.parent=this},this)),H.length!==0&&($(y0.args===null),y0.args=H,y0.reverseArgs=H.map(function(w0){if(typeof w0!="object"||w0.constructor!==Object)return w0;let E={};return Object.keys(w0).forEach(function(p0){p0==(p0|0)&&(p0|=0);let T=w0[p0];E[T]=p0}),E}))},U.forEach(function(H){V.prototype[H]=function(){let y0=this._baseState;throw new Error(H+" not implemented for encoding: "+y0.enc)}}),Z.forEach(function(H){V.prototype[H]=function(){let y0=this._baseState,W=Array.prototype.slice.call(arguments);return $(y0.tag===null),y0.tag=H,this._useArgs(W),this}}),V.prototype.use=function(H){$(H);let y0=this._baseState;return $(y0.use===null),y0.use=H,this},V.prototype.optional=function(){let H=this._baseState;return H.optional=!0,this},V.prototype.def=function(H){let y0=this._baseState;return $(y0.default===null),y0.default=H,y0.optional=!0,this},V.prototype.explicit=function(H){let y0=this._baseState;return $(y0.explicit===null&&y0.implicit===null),y0.explicit=H,this},V.prototype.implicit=function(H){let y0=this._baseState;return $(y0.explicit===null&&y0.implicit===null),y0.implicit=H,this},V.prototype.obj=function(){let H=this._baseState,y0=Array.prototype.slice.call(arguments);return H.obj=!0,y0.length!==0&&this._useArgs(y0),this},V.prototype.key=function(H){let y0=this._baseState;return $(y0.key===null),y0.key=H,this},V.prototype.any=function(){let H=this._baseState;return H.any=!0,this},V.prototype.choice=function(H){let y0=this._baseState;return $(y0.choice===null),y0.choice=H,this._useArgs(Object.keys(H).map(function(W){return H[W]})),this},V.prototype.contains=function(H){let y0=this._baseState;return $(y0.use===null),y0.contains=H,this},V.prototype._decode=function(H,y0){let W=this._baseState;if(W.parent===null)return H.wrapResult(W.children[0]._decode(H,y0));let w0=W.default,E=!0,p0=null;if(W.key!==null&&(p0=H.enterKey(W.key)),W.optional){let f0=null;if(W.explicit!==null?f0=W.explicit:W.implicit!==null?f0=W.implicit:W.tag!==null&&(f0=W.tag),f0===null&&!W.any){let D=H.save();try{W.choice===null?this._decodeGeneric(W.tag,H,y0):this._decodeChoice(H,y0),E=!0}catch{E=!1}H.restore(D)}else if(E=this._peekTag(H,f0,W.any),H.isError(E))return E}let T;if(W.obj&&E&&(T=H.enterObject()),E){if(W.explicit!==null){let D=this._decodeTag(H,W.explicit);if(H.isError(D))return D;H=D}let f0=H.offset;if(W.use===null&&W.choice===null){let D;W.any&&(D=H.save());let c0=this._decodeTag(H,W.implicit!==null?W.implicit:W.tag,W.any);if(H.isError(c0))return c0;W.any?w0=H.raw(D):H=c0}if(y0&&y0.track&&W.tag!==null&&y0.track(H.path(),f0,H.length,"tagged"),y0&&y0.track&&W.tag!==null&&y0.track(H.path(),H.offset,H.length,"content"),W.any||(W.choice===null?w0=this._decodeGeneric(W.tag,H,y0):w0=this._decodeChoice(H,y0)),H.isError(w0))return w0;if(!W.any&&W.choice===null&&W.children!==null&&W.children.forEach(function(D){D._decode(H,y0)}),W.contains&&(W.tag==="octstr"||W.tag==="bitstr")){let D=new Y(w0);w0=this._getUse(W.contains,H._reporterState.obj)._decode(D,y0)}}return W.obj&&E&&(w0=H.leaveObject(T)),W.key!==null&&(w0!==null||E===!0)?H.leaveKey(p0,W.key,w0):p0!==null&&H.exitKey(p0),w0},V.prototype._decodeGeneric=function(H,y0,W){let w0=this._baseState;return H==="seq"||H==="set"?null:H==="seqof"||H==="setof"?this._decodeList(y0,H,w0.args[0],W):/str$/.test(H)?this._decodeStr(y0,H,W):H==="objid"&&w0.args?this._decodeObjid(y0,w0.args[0],w0.args[1],W):H==="objid"?this._decodeObjid(y0,null,null,W):H==="gentime"||H==="utctime"?this._decodeTime(y0,H,W):H==="null_"?this._decodeNull(y0,W):H==="bool"?this._decodeBool(y0,W):H==="objDesc"?this._decodeStr(y0,H,W):H==="int"||H==="enum"?this._decodeInt(y0,w0.args&&w0.args[0],W):w0.use!==null?this._getUse(w0.use,y0._reporterState.obj)._decode(y0,W):y0.error("unknown tag: "+H)},V.prototype._getUse=function(H,y0){let W=this._baseState;return W.useDecoder=this._use(H,y0),$(W.useDecoder._baseState.parent===null),W.useDecoder=W.useDecoder._baseState.children[0],W.implicit!==W.useDecoder._baseState.implicit&&(W.useDecoder=W.useDecoder.clone(),W.useDecoder._baseState.implicit=W.implicit),W.useDecoder},V.prototype._decodeChoice=function(H,y0){let W=this._baseState,w0=null,E=!1;return Object.keys(W.choice).some(function(p0){let T=H.save(),f0=W.choice[p0];try{let D=f0._decode(H,y0);if(H.isError(D))return!1;w0={type:p0,value:D},E=!0}catch{return H.restore(T),!1}return!0},this),E?w0:H.error("Choice not matched")},V.prototype._createEncoderBuffer=function(H){return new G(H,this.reporter)},V.prototype._encode=function(H,y0,W){let w0=this._baseState;if(w0.default!==null&&w0.default===H)return;let E=this._encodeValue(H,y0,W);if(E!==void 0&&!this._skipDefault(E,y0,W))return E},V.prototype._encodeValue=function(H,y0,W){let w0=this._baseState;if(w0.parent===null)return w0.children[0]._encode(H,y0||new x0);let E=null;if(this.reporter=y0,w0.optional&&H===void 0)if(w0.default!==null)H=w0.default;else return;let p0=null,T=!1;if(w0.any)E=this._createEncoderBuffer(H);else if(w0.choice)E=this._encodeChoice(H,y0);else if(w0.contains)p0=this._getUse(w0.contains,W)._encode(H,y0),T=!0;else if(w0.children)p0=w0.children.map(function(f0){if(f0._baseState.tag==="null_")return f0._encode(null,y0,H);if(f0._baseState.key===null)return y0.error("Child should have a key");let D=y0.enterKey(f0._baseState.key);if(typeof H!="object")return y0.error("Child expected, but input is not object");let c0=f0._encode(H[f0._baseState.key],y0,H);return y0.leaveKey(D),c0},this).filter(function(f0){return f0}),p0=this._createEncoderBuffer(p0);else if(w0.tag==="seqof"||w0.tag==="setof"){if(!(w0.args&&w0.args.length===1))return y0.error("Too many args for : "+w0.tag);if(!Array.isArray(H))return y0.error("seqof/setof, but data is not Array");let f0=this.clone();f0._baseState.implicit=null,p0=this._createEncoderBuffer(H.map(function(D){let c0=this._baseState;return this._getUse(c0.args[0],H)._encode(D,y0)},f0))}else w0.use!==null?E=this._getUse(w0.use,W)._encode(H,y0):(p0=this._encodePrimitive(w0.tag,H),T=!0);if(!w0.any&&w0.choice===null){let f0=w0.implicit!==null?w0.implicit:w0.tag,D=w0.implicit===null?"universal":"context";f0===null?w0.use===null&&y0.error("Tag could be omitted only for .use()"):w0.use===null&&(E=this._encodeComposite(f0,T,D,p0))}return w0.explicit!==null&&(E=this._encodeComposite(w0.explicit,!1,"context",E)),E},V.prototype._encodeChoice=function(H,y0){let W=this._baseState,w0=W.choice[H.type];return w0||$(!1,H.type+" not found in "+JSON.stringify(Object.keys(W.choice))),w0._encode(H.value,y0)},V.prototype._encodePrimitive=function(H,y0){let W=this._baseState;if(/str$/.test(H))return this._encodeStr(y0,H);if(H==="objid"&&W.args)return this._encodeObjid(y0,W.reverseArgs[0],W.args[1]);if(H==="objid")return this._encodeObjid(y0,null,null);if(H==="gentime"||H==="utctime")return this._encodeTime(y0,H);if(H==="null_")return this._encodeNull();if(H==="int"||H==="enum")return this._encodeInt(y0,W.args&&W.reverseArgs[0]);if(H==="bool")return this._encodeBool(y0);if(H==="objDesc")return this._encodeStr(y0,H);throw new Error("Unsupported tag: "+H)},V.prototype._isNumstr=function(H){return/^[0-9 ]*$/.test(H)},V.prototype._isPrintstr=function(H){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(H)}}}),PY=$Q({"node_modules/asn1.js/lib/asn1/constants/der.js"(X){function K(x0){let G={};return Object.keys(x0).forEach(function(Y){(Y|0)==Y&&(Y=Y|0);let $=x0[Y];G[$]=Y}),G}X.tagClass={0:"universal",1:"application",2:"context",3:"private"},X.tagClassByName=K(X.tagClass),X.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"},X.tagByName=K(X.tag)}}),zY=$Q({"node_modules/asn1.js/lib/asn1/encoders/der.js"(X,K){var x0=X0(),G=CY().Buffer,Y=RY(),$=PY();function Z(B0){this.enc="der",this.name=B0.name,this.entity=B0,this.tree=new Q,this.tree._init(B0.body)}K.exports=Z,Z.prototype.encode=function(B0,H){return this.tree._encode(B0,H).join()};function Q(B0){Y.call(this,"der",B0)}x0(Q,Y),Q.prototype._encodeComposite=function(B0,H,y0,W){let w0=V(B0,H,y0,this.reporter);if(W.length<128){let T=G.alloc(2);return T[0]=w0,T[1]=W.length,this._createEncoderBuffer([T,W])}let E=1;for(let T=W.length;T>=256;T>>=8)E++;let p0=G.alloc(2+E);p0[0]=w0,p0[1]=128|E;for(let T=1+E,f0=W.length;f0>0;T--,f0>>=8)p0[T]=f0&255;return this._createEncoderBuffer([p0,W])},Q.prototype._encodeStr=function(B0,H){if(H==="bitstr")return this._createEncoderBuffer([B0.unused|0,B0.data]);if(H==="bmpstr"){let y0=G.alloc(B0.length*2);for(let W=0;W=40)return this.reporter.error("Second objid identifier OOB");B0.splice(0,2,B0[0]*40+B0[1])}let W=0;for(let p0=0;p0=128;T>>=7)W++}let w0=G.alloc(W),E=w0.length-1;for(let p0=B0.length-1;p0>=0;p0--){let T=B0[p0];for(w0[E--]=T&127;(T>>=7)>0;)w0[E--]=128|T&127}return this._createEncoderBuffer(w0)};function U(B0){return B0<10?"0"+B0:B0}Q.prototype._encodeTime=function(B0,H){let y0,W=new Date(B0);return H==="gentime"?y0=[U(W.getUTCFullYear()),U(W.getUTCMonth()+1),U(W.getUTCDate()),U(W.getUTCHours()),U(W.getUTCMinutes()),U(W.getUTCSeconds()),"Z"].join(""):H==="utctime"?y0=[U(W.getUTCFullYear()%100),U(W.getUTCMonth()+1),U(W.getUTCDate()),U(W.getUTCHours()),U(W.getUTCMinutes()),U(W.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+H+" time is not supported yet"),this._encodeStr(y0,"octstr")},Q.prototype._encodeNull=function(){return this._createEncoderBuffer("")},Q.prototype._encodeInt=function(B0,H){if(typeof B0=="string"){if(!H)return this.reporter.error("String int or enum given, but no values map");if(!H.hasOwnProperty(B0))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(B0));B0=H[B0]}if(typeof B0!="number"&&!G.isBuffer(B0)){let w0=B0.toArray();!B0.sign&&w0[0]&128&&w0.unshift(0),B0=G.from(w0)}if(G.isBuffer(B0)){let w0=B0.length;B0.length===0&&w0++;let E=G.alloc(w0);return B0.copy(E),B0.length===0&&(E[0]=0),this._createEncoderBuffer(E)}if(B0<128)return this._createEncoderBuffer(B0);if(B0<256)return this._createEncoderBuffer([0,B0]);let y0=1;for(let w0=B0;w0>=256;w0>>=8)y0++;let W=new Array(y0);for(let w0=W.length-1;w0>=0;w0--)W[w0]=B0&255,B0>>=8;return W[0]&128&&W.unshift(0),this._createEncoderBuffer(G.from(W))},Q.prototype._encodeBool=function(B0){return this._createEncoderBuffer(B0?255:0)},Q.prototype._use=function(B0,H){return typeof B0=="function"&&(B0=B0(H)),B0._getEncoder("der").tree},Q.prototype._skipDefault=function(B0,H,y0){let W=this._baseState,w0;if(W.default===null)return!1;let E=B0.join();if(W.defaultBuffer===void 0&&(W.defaultBuffer=this._encodeValue(W.default,H,y0).join()),E.length!==W.defaultBuffer.length)return!1;for(w0=0;w0=31?W.error("Multi-octet tag encoding unsupported"):(H||(w0|=32),w0|=$.tagClassByName[y0||"universal"]<<6,w0)}}}),MY=$Q({"node_modules/asn1.js/lib/asn1/encoders/pem.js"(X,K){var x0=X0(),G=zY();function Y($){G.call(this,$),this.enc="pem"}x0(Y,G),K.exports=Y,Y.prototype.encode=function($,Z){let Q=G.prototype.encode.call(this,$).toString("base64"),U=["-----BEGIN "+Z.label+"-----"];for(let V=0;V>6],E=(W&32)===0;if((W&31)===31){let T=W;for(W=0;(T&128)===128;){if(T=H.readUInt8(y0),H.isError(T))return T;W<<=7,W|=T&127}}else W&=31;let p0=Z.tag[W];return{cls:w0,primitive:E,tag:W,tagStr:p0}}function B0(H,y0,W){let w0=H.readUInt8(W);if(H.isError(w0))return w0;if(!y0&&w0===128)return null;if((w0&128)===0)return w0;let E=w0&127;if(E>4)return H.error("length octect is too long");w0=0;for(let p0=0;p00&&c0.ishrn(C),c0}function E(f0,D){f0=w0(f0,D),f0=f0.mod(D);var c0=x0.from(f0.toArray());if(c0.length=y0)throw new Error("invalid sig")}K.exports=Q}}),dY=$Q({"node_modules/browserify-sign/browser/index.js"(X,K){var x0=YQ().Buffer,G=L0(),Y=X0(),$=cY(),Z=hY(),Q=M0();Object.keys(Q).forEach(function(y0){Q[y0].id=x0.from(Q[y0].id,"hex"),Q[y0.toLowerCase()]=Q[y0]});function U(y0){h$.Writable.call(this);var W=Q[y0];if(!W)throw new Error("Unknown message digest");this._hashType=W.hash,this._hash=G(W.hash),this._tag=W.id,this._signType=W.sign}Y(U,h$.Writable),U.prototype._write=function(y0,W,w0){this._hash.update(y0),w0()},U.prototype.update=function(y0,W){return typeof y0=="string"&&(y0=x0.from(y0,W)),this._hash.update(y0),this},U.prototype.sign=function(y0,W){this.end();var w0=this._hash.digest(),E=$(w0,y0,this._hashType,this._signType,this._tag);return W?E.toString(W):E};function V(y0){h$.Writable.call(this);var W=Q[y0];if(!W)throw new Error("Unknown message digest");this._hash=G(W.hash),this._tag=W.id,this._signType=W.sign}Y(V,h$.Writable),V.prototype._write=function(y0,W,w0){this._hash.update(y0),w0()},V.prototype.update=function(y0,W){return typeof y0=="string"&&(y0=x0.from(y0,W)),this._hash.update(y0),this},V.prototype.verify=function(y0,W,w0){typeof W=="string"&&(W=x0.from(W,w0)),this.end();var E=this._hash.digest();return Z(W,E,y0,this._signType,this._tag)};function B0(y0){return new U(y0)}function H(y0){return new V(y0)}K.exports={Sign:B0,Verify:H,createSign:B0,createVerify:H}}}),bY=$Q({"node_modules/create-ecdh/node_modules/bn.js/lib/bn.js"(X,K){(function(x0,G){function Y(l0,z){if(!l0)throw new Error(z||"Assertion failed")}function $(l0,z){l0.super_=z;var o0=function(){};o0.prototype=z.prototype,l0.prototype=new o0,l0.prototype.constructor=l0}function Z(l0,z,o0){if(Z.isBN(l0))return l0;this.negative=0,this.words=null,this.length=0,this.red=null,l0!==null&&((z==="le"||z==="be")&&(o0=z,z=10),this._init(l0||0,z||10,o0||"be"))}typeof x0=="object"?x0.exports=Z:G.BN=Z,Z.BN=Z,Z.wordSize=26;var Q=c$;Z.isBN=function(l0){return l0 instanceof Z?!0:l0!==null&&typeof l0=="object"&&l0.constructor.wordSize===Z.wordSize&&Array.isArray(l0.words)},Z.max=function(l0,z){return l0.cmp(z)>0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),lY=$Q({"node_modules/create-ecdh/browser.js"(X,K){var x0=TY(),G=bY();K.exports=function(Q){return new $(Q)};var Y={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}};Y.p224=Y.secp224r1,Y.p256=Y.secp256r1=Y.prime256v1,Y.p192=Y.secp192r1=Y.prime192v1,Y.p384=Y.secp384r1,Y.p521=Y.secp521r1;function $(Q){this.curveType=Y[Q],this.curveType||(this.curveType={name:Q}),this.curve=new x0.ec(this.curveType.name),this.keys=void 0}$.prototype.generateKeys=function(Q,U){return this.keys=this.curve.genKeyPair(),this.getPublicKey(Q,U)},$.prototype.computeSecret=function(Q,U,V){U=U||"utf8",c$.isBuffer(Q)||(Q=new c$(Q,U));var B0=this.curve.keyFromPublic(Q).getPublic(),H=B0.mul(this.keys.getPrivate()).getX();return Z(H,V,this.curveType.byteLength)},$.prototype.getPublicKey=function(Q,U){var V=this.keys.getPublic(U==="compressed",!0);return U==="hybrid"&&(V[V.length-1]%2?V[0]=7:V[0]=6),Z(V,Q)},$.prototype.getPrivateKey=function(Q){return Z(this.keys.getPrivate(),Q)},$.prototype.setPublicKey=function(Q,U){return U=U||"utf8",c$.isBuffer(Q)||(Q=new c$(Q,U)),this.keys._importPublic(Q),this},$.prototype.setPrivateKey=function(Q,U){U=U||"utf8",c$.isBuffer(Q)||(Q=new c$(Q,U));var V=new G(Q);return V=V.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(V),this};function Z(Q,U,V){Array.isArray(Q)||(Q=Q.toArray());var B0=new c$(Q);if(V&&B0.length0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),{CryptoHasher:sY}=globalThis.Bun,tY=$Q({"node_modules/public-encrypt/withPublic.js"(X,K){var x0=nY(),G=YQ().Buffer;function Y($,Z){return G.from($.toRed(x0.mont(Z.modulus)).redPow(new x0(Z.publicExponent)).fromRed().toArray())}K.exports=Y}}),mY=$Q({"node_modules/public-encrypt/publicEncrypt.js"(X,K){var x0=pY(),G=ZQ(),Y=L0(),$=oY(),Z=uY(),Q=nY(),U=tY(),V=hQ(),B0=YQ().Buffer;K.exports=function(w0,E,p0){var T;w0.padding?T=w0.padding:p0?T=1:T=4;var f0=x0(w0),D;if(T===4)D=H(f0,E);else if(T===1)D=y0(f0,E,p0);else if(T===3){if(D=new Q(E),D.cmp(f0.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return p0?V(D,f0):U(D,f0)};function H(w0,E){var p0=w0.modulus.byteLength(),T=E.length,f0=Y("sha1").update(B0.alloc(0)).digest(),D=f0.length,c0=2*D;if(T>p0-c0-2)throw new Error("message too long");var C=B0.alloc(p0-T-c0-2),h0=p0-D-1,L=G(D),d0=Z(B0.concat([f0,C,B0.alloc(1,1),E],h0),$(L,h0)),R=Z(L,$(d0,D));return new Q(B0.concat([B0.alloc(1),R,d0],p0))}function y0(w0,E,p0){var T=E.length,f0=w0.modulus.byteLength();if(T>f0-11)throw new Error("message too long");var D;return p0?D=B0.alloc(f0-T-3,255):D=W(f0-T-3),new Q(B0.concat([B0.from([0,p0?1:2]),D,B0.alloc(1),E],f0))}function W(w0){for(var E=B0.allocUnsafe(w0),p0=0,T=G(w0*2),f0=0,D;p0f0||new $(w0).cmp(T.modulus)>=0)throw new Error("decryption error");var D;E?D=U(new $(w0),T):D=Z(w0,T);var c0=V.alloc(f0-D.length);if(D=V.concat([c0,D],f0),p0===4)return B0(T,D);if(p0===1)return H(T,D,E);if(p0===3)return D;throw new Error("unknown padding")};function B0(W,w0){var E=W.modulus.byteLength(),p0=Q("sha1").update(V.alloc(0)).digest(),T=p0.length;if(w0[0]!==0)throw new Error("decryption error");var f0=w0.slice(1,T+1),D=w0.slice(T+1),c0=Y(f0,G(D,T)),C=Y(D,G(c0,E-T-1));if(y0(p0,C.slice(0,T)))throw new Error("decryption error");for(var h0=T;C[h0]===0;)h0++;if(C[h0++]!==1)throw new Error("decryption error");return C.slice(h0)}function H(W,w0,E){for(var p0=w0.slice(0,2),T=2,f0=0;w0[T++]!==0;)if(T>=w0.length){f0++;break}var D=w0.slice(2,T-1);if((p0.toString("hex")!=="0002"&&!E||p0.toString("hex")!=="0001"&&E)&&f0++,D.length<8&&f0++,f0)throw new Error("decryption error");return w0.slice(T)}function y0(W,w0){W=V.from(W),w0=V.from(w0);var E=0,p0=W.length;W.length!==w0.length&&(E++,p0=Math.min(W.length,w0.length));for(var T=-1;++T$||H<0)throw new TypeError("offset must be a uint32");if(H>Y||H>y0)throw new RangeError("offset out of range")}function Q(H,y0,W){if(typeof H!="number"||H!==H)throw new TypeError("size must be a number");if(H>$||H<0)throw new TypeError("size must be a uint32");if(H+y0>W||H>Y)throw new RangeError("buffer too small")}X.randomFill=U,X.randomFillSync=B0;function U(H,y0,W,w0){if(!G.isBuffer(H)&&!(H instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof y0=="function")w0=y0,y0=0,W=H.length;else if(typeof W=="function")w0=W,W=H.length-y0;else if(typeof w0!="function")throw new TypeError('"cb" argument must be a function');return Z(y0,H.length),Q(W,y0,H.length),V(H,y0,W,w0)}function V(H,y0,W,w0){if(w0){x0(W,function(p0,T){if(p0)return w0(p0);T.copy(H,y0),w0(null,H)});return}var E=x0(W);return E.copy(H,y0),H}function B0(H,y0,W){if(typeof y0>"u"&&(y0=0),!G.isBuffer(H)&&!(H instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return Z(y0,H.length),W===void 0&&(W=H.length-y0),Q(W,y0,H.length),V(H,y0,W)}}}),iY=$Q({"node_modules/crypto-browserify/index.js"(X){X.randomBytes=X.rng=X.pseudoRandomBytes=X.prng=ZQ(),X.createHash=L0(),X.Hash=X.createHash.Hash,X.createHmac=X.Hmac=z0();var K=S0(),x0=Object.keys(K),G=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(x0);X.getHashes=function(){return G};var Y=g0();X.pbkdf2=Y.pbkdf2,X.pbkdf2Sync=Y.pbkdf2Sync;var $=gQ();X.Cipher=$.Cipher,X.createCipher=$.createCipher,X.Cipheriv=$.Cipheriv,X.createCipheriv=$.createCipheriv,X.Decipher=$.Decipher,X.createDecipher=$.createDecipher,X.Decipheriv=$.Decipheriv,X.createDecipheriv=$.createDecipheriv,X.getCiphers=$.getCiphers,X.listCiphers=$.listCiphers;var Z=fQ();X.DiffieHellmanGroup=Z.DiffieHellmanGroup,X.createDiffieHellmanGroup=Z.createDiffieHellmanGroup,X.getDiffieHellman=Z.getDiffieHellman,X.createDiffieHellman=Z.createDiffieHellman,X.DiffieHellman=Z.DiffieHellman;var Q=dY();X.createSign=Q.createSign,X.Sign=Q.Sign,X.createVerify=Q.createVerify,X.Verify=Q.Verify,X.createECDH=lY();var U=eY();X.publicEncrypt=U.publicEncrypt,X.privateEncrypt=U.privateEncrypt,X.publicDecrypt=U.publicDecrypt,X.privateDecrypt=U.privateDecrypt,X.getRandomValues=(B0)=>d$.getRandomValues(B0);var V=rY();X.randomFill=V.randomFill,X.randomFillSync=V.randomFillSync,X.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` +`))},X.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},o$="buffer",QZ=(X)=>d$.getRandomValues(X),YZ=()=>d$.randomUUID(),u$="timingSafeEqual"in d$?(X,K)=>{let{byteLength:x0}=X,{byteLength:G}=K;if(typeof x0!="number"||typeof G!="number")throw new TypeError("Input must be an array buffer view");if(x0!==G)throw new RangeError("Input buffers must have the same length");return d$.timingSafeEqual(X,K)}:void 0,ZZ="scryptSync"in d$?(X,K,x0,G)=>{let Y=d$.scryptSync(X,K,x0,G);return o$!=="buffer"?new c$(Y).toString(o$):new c$(Y)}:void 0,GZ="scryptSync"in d$?function(X,K,x0,G,Y){if(typeof G=="function"&&(Y=G,G=void 0),typeof Y!="function"){var $=new TypeError("callback must be a function");throw $.code="ERR_INVALID_CALLBACK",$}try{let Z=d$.scryptSync(X,K,x0,G);process.nextTick(Y,null,o$!=="buffer"?new c$(Z).toString(o$):new c$(Z))}catch(Z){throw Z}}:void 0;u$&&(Object.defineProperty(u$,"name",{value:"::bunternal::"}),Object.defineProperty(GZ,"name",{value:"::bunternal::"}),Object.defineProperty(ZZ,"name",{value:"::bunternal::"}));var n$=d$;QQ($Z,{DEFAULT_ENCODING:()=>o$,getRandomValues:()=>QZ,randomUUID:()=>YZ,scrypt:()=>GZ,scryptSync:()=>ZZ,timingSafeEqual:()=>u$,webcrypto:()=>n$,subtle:()=>n$.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{n$ as webcrypto,u$ 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,o$ as DEFAULT_ENCODING,DZ as Cipheriv,EZ as Cipher}; diff --git a/src/js/out/modules/node/path.js b/src/js/out/modules/node/path.js index f8cc1ec08..4e6003c7d 100644 --- a/src/js/out/modules/node/path.js +++ b/src/js/out/modules/node/path.js @@ -1 +1 @@ -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}; +var H=function(i){var G=f({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 G.default=G,G},f=(i)=>Object.assign(Object.create(null),i),m=H(Bun._Path()),I=H(Bun._Path(!1)),g=H(Bun._Path(!0));m.win32=g;m.posix=I;var{basename:J,dirname:k,extname:K,format:q,isAbsolute:L,join:v,normalize:N,parse:y,relative:O,resolve:C,toNamespacedPath:z,sep:D,delimiter:A,__esModule:E}=m;m[Symbol.for("CommonJS")]=0;m.__esModule=!0;var F=m;export{g as win32,z as toNamespacedPath,D as sep,C as resolve,O as relative,I as posix,y as parse,N as normalize,v as join,L as isAbsolute,q as format,K as extname,k as dirname,A as delimiter,F as default,f as createModule,J as basename,E as __esModule}; diff --git a/src/js/out/modules/node/path.posix.js b/src/js/out/modules/node/path.posix.js index 64e8a62f5..ca08d44b8 100644 --- a/src/js/out/modules/node/path.posix.js +++ b/src/js/out/modules/node/path.posix.js @@ -1 +1 @@ -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}; +var r=function(i){return{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}},k=r(Bun._Path(!1));k[Symbol.for("CommonJS")]=0;var{basename:e,dirname:m,extname:d,format:l,isAbsolute:s,join:c,normalize:f,parse:g,relative:q,resolve:t,toNamespacedPath:v,sep:w,delimiter:x}=k,z=k;export{v as toNamespacedPath,w as sep,t as resolve,q as relative,g as parse,f as normalize,c as join,s as isAbsolute,l as format,d as extname,m as dirname,x as delimiter,z as default,e as basename}; diff --git a/src/js/out/modules/node/stream.consumers.js b/src/js/out/modules/node/stream.consumers.js index 20bbb7de4..8e3592104 100644 --- a/src/js/out/modules/node/stream.consumers.js +++ b/src/js/out/modules/node/stream.consumers.js @@ -1 +1 @@ -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}; +var{Bun:k}=globalThis[Symbol.for("Bun.lazy")]("primordials"),p=k.readableStreamToArrayBuffer,o=k.readableStreamToText,h=(c)=>k.readableStreamToText(c).then(JSON.parse),g=async(c)=>{return new Buffer(await p(c))},i=k.readableStreamToBlob,q={[Symbol.for("CommonJS")]:0,arrayBuffer:p,text:o,json:h,buffer:g,blob:i};export{o as text,h as json,q as default,g as buffer,i as blob,p as arrayBuffer}; diff --git a/src/js/out/modules/node/stream.js b/src/js/out/modules/node/stream.js index f96818bd6..31a1d64c6 100644 --- a/src/js/out/modules/node/stream.js +++ b/src/js/out/modules/node/stream.js @@ -1,2 +1,2 @@ -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}; +import{EventEmitter as CQ} from"bun:events_native";import{StringDecoder as Eq} from"node:string_decoder";var M=function(B){return typeof B==="object"&&B!==null&&B instanceof ReadableStream},F=function(B,Y){if(typeof B!=="boolean")throw new yQ(Y,"boolean",B)};var yQ=function(B,Y,U){return new Error(`The argument '${B}' is invalid. Received '${U}' for type '${Y}'`)},xq=function(B,Y,U){return new Error(`The value '${Y}' is invalid for argument '${B}'. Reason: ${U}`)},P=function(B,Y){var[U,H,X,q,J,Q,Z]=globalThis[Symbol.for("Bun.lazy")](B),K=[!1],oq=function(rq,m,tq,c){if(m>0){const eq=tq.subarray(0,m),d=tq.subarray(m);if(eq.byteLength>0)rq.push(eq);if(c)rq.push(null);return d.byteLength>0?d:void 0}if(c)rq.push(null);return tq},p=function(rq,m,tq,c){if(m.byteLength>0)rq.push(m);if(c)rq.push(null);return tq},sq=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const u=new FinalizationRegistry((rq)=>rq&&J(rq)),aq=512;var b=class rq extends Y{#q;#Q=1;#X=!1;#J=void 0;#H;#K=!1;#Z=!sq;#B;constructor(m,tq={}){super(tq);if(typeof tq.highWaterMark==="number")this.#H=tq.highWaterMark;else this.#H=262144;this.#q=m,this.#X=!1,this.#J=void 0,this.#K=!1,this.#B={},u.register(this,this.#q,this.#B)}_read(m){if(OQ&&Gq("NativeReadable._read",this.__id),this.#K){OQ&&Gq("pendingRead is true",this.__id);return}var tq=this.#q;if(OQ&&Gq("ptr @ NativeReadable._read",tq,this.__id),tq===0){this.push(null);return}if(!this.#X)OQ&&Gq("NativeReadable not constructed yet",this.__id),this.#Y(tq);return this.#V(this.#$(m),tq)}#Y(m){this.#X=!0;const tq=H(m,this.#H);if(OQ&&Gq("NativeReadable internal `start` result",tq,this.__id),typeof tq==="number"&&tq>1)this.#Z=!0,OQ&&Gq("NativeReadable resized",this.__id),this.#H=Math.min(this.#H,tq);if(Z){const c=Z(m);if(OQ&&Gq("NativeReadable drain result",c,this.__id),(c?.byteLength??0)>0)this.push(c)}}#$(m=this.#H){var tq=this.#J;if(OQ&&Gq("chunk @ #getRemainingChunk",tq,this.__id),tq?.byteLength??0aq?m:aq;this.#J=tq=new Buffer(c)}return tq}push(m,tq){return OQ&&Gq("NativeReadable push -- result, encoding",m,tq,this.__id),super.push(...arguments)}#z(m,tq,c){if(OQ&&Gq("result, isClosed @ #handleResult",m,c,this.__id),typeof m==="number"){if(m>=this.#H&&!this.#Z&&!c)this.#H*=2,this.#Z=!0;return oq(this,m,tq,c)}else if(typeof m==="boolean")return this.push(null),tq?.byteLength??0>0?tq:void 0;else if(ArrayBuffer.isView(m)){if(m.byteLength>=this.#H&&!this.#Z&&!c)this.#H*=2,this.#Z=!0,OQ&&Gq("Resized",this.__id);return p(this,m,tq,c)}else throw OQ&&Gq("Unknown result type",m,this.__id),new Error("Invalid result from pull")}#V(m,tq){OQ&&Gq("#internalRead()",this.__id),K[0]=!1;var c=U(tq,m,K);if(Lq(c))return this.#K=!0,c.then((eq)=>{this.#K=!1,OQ&&Gq("pending no longerrrrrrrr (result returned from pull)",this.__id),this.#J=this.#z(eq,m,K[0])},(eq)=>{OQ&&Gq("error from pull",eq,this.__id),errorOrDestroy(this,eq)});else this.#J=this.#z(c,m,K[0])}_destroy(m,tq){var c=this.#q;if(c===0){tq(m);return}if(u.unregister(this.#B),this.#q=0,Q)Q(c,!1);OQ&&Gq("NativeReadable destroyed",this.__id),X(c,m),tq(m)}ref(){var m=this.#q;if(m===0)return;if(this.#Q++===0)Q(m,!0)}unref(){var m=this.#q;if(m===0)return;if(this.#Q--===1)Q(m,!1)}};if(!Q)b.prototype.ref=void 0,b.prototype.unref=void 0;return b},O=function(B,Y){return x[B]||=P(B,Y)},_=function(B,Y,U){if(!(Y&&typeof Y==="object"&&Y instanceof ReadableStream))return;const H=vQ(Y);if(!H){Gq("no native readable stream");return}const{stream:X,data:q}=H;return new(O(q,B))(X,U)},{isPromise:Lq,isCallable:Nq,direct:vQ,Object:Fq}=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 SQ=!!process.env.DEBUG_TRACK_EE,OQ=!!(process.env.DEBUG||process.env.DEBUG_STREAMS||SQ),Gq=OQ?globalThis.__IDS_TO_TRACK?(...B)=>{const Y=B[B.length-1];if(!globalThis.__IDS_TO_TRACK.includes(Y))return;console.log(`ID: ${Y}`,...B.slice(0,-1))}:(...B)=>console.log(...B.slice(0,-1)):()=>{},Iq=Fq.create,gQ=Fq.defineProperty,V=Fq.getOwnPropertyDescriptor,fQ=Fq.getOwnPropertyNames,Tq=Fq.getPrototypeOf,kQ=Fq.prototype.hasOwnProperty,W=Fq.setPrototypeOf,G=(B,Y)=>function U(){return Y||(0,B[fQ(B)[0]])((Y={exports:{}}).exports,Y),Y.exports};var _Q=process.nextTick;var Pq=Array.isArray,DQ=G({"node_modules/readable-stream/lib/ours/primordials.js"(B,Y){Y.exports={ArrayIsArray(U){return Array.isArray(U)},ArrayPrototypeIncludes(U,H){return U.includes(H)},ArrayPrototypeIndexOf(U,H){return U.indexOf(H)},ArrayPrototypeJoin(U,H){return U.join(H)},ArrayPrototypeMap(U,H){return U.map(H)},ArrayPrototypePop(U,H){return U.pop(H)},ArrayPrototypePush(U,H){return U.push(H)},ArrayPrototypeSlice(U,H,X){return U.slice(H,X)},Error,FunctionPrototypeCall(U,H,...X){return U.call(H,...X)},FunctionPrototypeSymbolHasInstance(U,H){return Function.prototype[Symbol.hasInstance].call(U,H)},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(U,H){return Fq.defineProperties(U,H)},ObjectDefineProperty(U,H,X){return Fq.defineProperty(U,H,X)},ObjectGetOwnPropertyDescriptor(U,H){return Fq.getOwnPropertyDescriptor(U,H)},ObjectKeys(U){return Fq.keys(U)},ObjectSetPrototypeOf(U,H){return Fq.setPrototypeOf(U,H)},Promise,PromisePrototypeCatch(U,H){return U.catch(H)},PromisePrototypeThen(U,H,X){return U.then(H,X)},PromiseReject(U){return Promise.reject(U)},ReflectApply:Reflect.apply,RegExpPrototypeTest(U,H){return U.test(H)},SafeSet:Set,String,StringPrototypeSlice(U,H,X){return U.slice(H,X)},StringPrototypeToLowerCase(U){return U.toLowerCase()},StringPrototypeToUpperCase(U){return U.toUpperCase()},StringPrototypeTrim(U){return U.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(U,H,X){return U.set(H,X)},Uint8Array}}}),jq=G({"node_modules/readable-stream/lib/ours/util.js"(B,Y){var U=Fq.getPrototypeOf(async function(){}).constructor,H=typeof Blob!=="undefined"?function q(J){return J instanceof Blob}:function q(J){return!1},X=class extends Error{constructor(q){if(!Array.isArray(q))throw new TypeError(`Expected input to be an Array, got ${typeof q}`);let J="";for(let Q=0;Q{q=Z,J=K}),resolve:q,reject:J}},promisify(q){return new Promise((J,Q)=>{q((Z,...K)=>{if(Z)return Q(Z);return J(...K)})})},debuglog(){return function(){}},format(q,...J){return q.replace(/%([sdifj])/g,function(...[Q,Z]){const K=J.shift();if(Z==="f")return K.toFixed(6);else if(Z==="j")return JSON.stringify(K);else if(Z==="s"&&typeof K==="object")return`${K.constructor!==Fq?K.constructor.name:""} {}`.trim();else return K.toString()})},inspect(q){switch(typeof q){case"string":if(q.includes("'")){if(!q.includes('"'))return`"${q}"`;else if(!q.includes("`")&&!q.includes("${"))return`\`${q}\``}return`'${q}'`;case"number":if(isNaN(q))return"NaN";else if(Fq.is(q,-0))return String(q);return q;case"bigint":return`${String(q)}n`;case"boolean":case"undefined":return String(q);case"object":return"{}"}},types:{isAsyncFunction(q){return q instanceof U},isArrayBufferView(q){return ArrayBuffer.isView(q)}},isBlob:H},Y.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),hQ=G({"node_modules/readable-stream/lib/ours/errors.js"(B,Y){var{format:U,inspect:H,AggregateError:X}=jq(),q=globalThis.AggregateError||X,J=Symbol("kIsNodeError"),Q=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Z=/^([A-Z][a-z0-9]*)+$/,K="__node_internal_",oq={};function p(tq,c){if(!tq)throw new oq.ERR_INTERNAL_ASSERTION(c)}function sq(tq){let c="",eq=tq.length;const d=tq[0]==="-"?1:0;for(;eq>=d+4;eq-=3)c=`_${tq.slice(eq-3,eq)}${c}`;return`${tq.slice(0,eq)}${c}`}function u(tq,c,eq){if(typeof c==="function")return p(c.length<=eq.length,`Code: ${tq}; The provided arguments length (${eq.length}) does not match the required ones (${c.length}).`),c(...eq);const d=(c.match(/%[dfijoOs]/g)||[]).length;if(p(d===eq.length,`Code: ${tq}; The provided arguments length (${eq.length}) does not match the required ones (${d}).`),eq.length===0)return c;return U(c,...eq)}function aq(tq,c,eq){if(!eq)eq=Error;class d extends eq{constructor(...qQ){super(u(tq,c,qQ))}toString(){return`${this.name} [${tq}]: ${this.message}`}}Fq.defineProperties(d.prototype,{name:{value:eq.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${tq}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),d.prototype.code=tq,d.prototype[J]=!0,oq[tq]=d}function b(tq){const c=K+tq.name;return Fq.defineProperty(tq,"name",{value:c}),tq}function rq(tq,c){if(tq&&c&&tq!==c){if(Array.isArray(c.errors))return c.errors.push(tq),c;const eq=new q([c,tq],c.message);return eq.code=c.code,eq}return tq||c}var m=class extends Error{constructor(tq="The operation was aborted",c=void 0){if(c!==void 0&&typeof c!=="object")throw new oq.ERR_INVALID_ARG_TYPE("options","Object",c);super(tq,c);this.code="ABORT_ERR",this.name="AbortError"}};aq("ERR_ASSERTION","%s",Error),aq("ERR_INVALID_ARG_TYPE",(tq,c,eq)=>{if(p(typeof tq==="string","'name' must be a string"),!Array.isArray(c))c=[c];let d="The ";if(tq.endsWith(" argument"))d+=`${tq} `;else d+=`"${tq}" ${tq.includes(".")?"property":"argument"} `;d+="must be ";const qQ=[],l=[],QQ=[];for(let XQ of c)if(p(typeof XQ==="string","All expected entries have to be of type string"),Q.includes(XQ))qQ.push(XQ.toLowerCase());else if(Z.test(XQ))l.push(XQ);else p(XQ!=="object",'The value "object" should be written as "Object"'),QQ.push(XQ);if(l.length>0){const XQ=qQ.indexOf("object");if(XQ!==-1)qQ.splice(qQ,XQ,1),l.push("Object")}if(qQ.length>0){switch(qQ.length){case 1:d+=`of type ${qQ[0]}`;break;case 2:d+=`one of type ${qQ[0]} or ${qQ[1]}`;break;default:{const XQ=qQ.pop();d+=`one of type ${qQ.join(", ")}, or ${XQ}`}}if(l.length>0||QQ.length>0)d+=" or "}if(l.length>0){switch(l.length){case 1:d+=`an instance of ${l[0]}`;break;case 2:d+=`an instance of ${l[0]} or ${l[1]}`;break;default:{const XQ=l.pop();d+=`an instance of ${l.join(", ")}, or ${XQ}`}}if(QQ.length>0)d+=" or "}switch(QQ.length){case 0:break;case 1:if(QQ[0].toLowerCase()!==QQ[0])d+="an ";d+=`${QQ[0]}`;break;case 2:d+=`one of ${QQ[0]} or ${QQ[1]}`;break;default:{const XQ=QQ.pop();d+=`one of ${QQ.join(", ")}, or ${XQ}`}}if(eq==null)d+=`. Received ${eq}`;else if(typeof eq==="function"&&eq.name)d+=`. Received function ${eq.name}`;else if(typeof eq==="object"){var i;if((i=eq.constructor)!==null&&i!==void 0&&i.name)d+=`. Received an instance of ${eq.constructor.name}`;else{const XQ=H(eq,{depth:-1});d+=`. Received ${XQ}`}}else{let XQ=H(eq,{colors:!1});if(XQ.length>25)XQ=`${XQ.slice(0,25)}...`;d+=`. Received type ${typeof eq} (${XQ})`}return d},TypeError),aq("ERR_INVALID_ARG_VALUE",(tq,c,eq="is invalid")=>{let d=H(c);if(d.length>128)d=d.slice(0,128)+"...";return`The ${tq.includes(".")?"property":"argument"} '${tq}' ${eq}. Received ${d}`},TypeError),aq("ERR_INVALID_RETURN_VALUE",(tq,c,eq)=>{var d;const qQ=eq!==null&&eq!==void 0&&(d=eq.constructor)!==null&&d!==void 0&&d.name?`instance of ${eq.constructor.name}`:`type ${typeof eq}`;return`Expected ${tq} to be returned from the "${c}" function but got ${qQ}.`},TypeError),aq("ERR_MISSING_ARGS",(...tq)=>{p(tq.length>0,"At least one arg needs to be specified");let c;const eq=tq.length;switch(tq=(Array.isArray(tq)?tq:[tq]).map((d)=>`"${d}"`).join(" or "),eq){case 1:c+=`The ${tq[0]} argument`;break;case 2:c+=`The ${tq[0]} and ${tq[1]} arguments`;break;default:{const d=tq.pop();c+=`The ${tq.join(", ")}, and ${d} arguments`}break}return`${c} must be specified`},TypeError),aq("ERR_OUT_OF_RANGE",(tq,c,eq)=>{p(c,'Missing "range" argument');let d;if(Number.isInteger(eq)&&Math.abs(eq)>4294967296)d=sq(String(eq));else if(typeof eq==="bigint"){if(d=String(eq),eq>2n**32n||eq<-(2n**32n))d=sq(d);d+="n"}else d=H(eq);return`The value of "${tq}" is out of range. It must be ${c}. Received ${d}`},RangeError),aq("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),aq("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),aq("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),aq("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),aq("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),aq("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),aq("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),aq("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),aq("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),aq("ERR_STREAM_WRITE_AFTER_END","write after end",Error),aq("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),Y.exports={AbortError:m,aggregateTwoErrors:b(rq),hideStackFrames:b,codes:oq}}}),L=G({"node_modules/readable-stream/lib/internal/validators.js"(B,Y){var{ArrayIsArray:U,ArrayPrototypeIncludes:H,ArrayPrototypeJoin:X,ArrayPrototypeMap:q,NumberIsInteger:J,NumberMAX_SAFE_INTEGER:Q,NumberMIN_SAFE_INTEGER:Z,NumberParseInt:K,RegExpPrototypeTest:oq,String:p,StringPrototypeToUpperCase:sq,StringPrototypeTrim:u}=DQ(),{hideStackFrames:aq,codes:{ERR_SOCKET_BAD_PORT:b,ERR_INVALID_ARG_TYPE:rq,ERR_INVALID_ARG_VALUE:m,ERR_OUT_OF_RANGE:tq,ERR_UNKNOWN_SIGNAL:c}}=hQ(),{normalizeEncoding:eq}=jq(),{isAsyncFunction:d,isArrayBufferView:qQ}=jq().types,l={};function QQ(UQ){return UQ===(UQ|0)}function i(UQ){return UQ===UQ>>>0}var XQ=/^[0-7]+$/,n="must be a 32-bit unsigned integer or an octal string";function JQ(UQ,Qq,WQ){if(typeof UQ==="undefined")UQ=WQ;if(typeof UQ==="string"){if(!oq(XQ,UQ))throw new m(Qq,UQ,n);UQ=K(UQ,8)}return HQ(UQ,Qq,0,4294967295),UQ}var o=aq((UQ,Qq,WQ=Z,Xq=Q)=>{if(typeof UQ!=="number")throw new rq(Qq,"number",UQ);if(!J(UQ))throw new tq(Qq,"an integer",UQ);if(UQXq)throw new tq(Qq,`>= ${WQ} && <= ${Xq}`,UQ)}),HQ=aq((UQ,Qq,WQ=-2147483648,Xq=2147483647)=>{if(typeof UQ!=="number")throw new rq(Qq,"number",UQ);if(!QQ(UQ)){if(!J(UQ))throw new tq(Qq,"an integer",UQ);throw new tq(Qq,`>= ${WQ} && <= ${Xq}`,UQ)}if(UQXq)throw new tq(Qq,`>= ${WQ} && <= ${Xq}`,UQ)}),s=aq((UQ,Qq,WQ)=>{if(typeof UQ!=="number")throw new rq(Qq,"number",UQ);if(!i(UQ)){if(!J(UQ))throw new tq(Qq,"an integer",UQ);throw new tq(Qq,`>= ${WQ?1:0} && < 4294967296`,UQ)}if(WQ&&UQ===0)throw new tq(Qq,">= 1 && < 4294967296",UQ)});function KQ(UQ,Qq){if(typeof UQ!=="string")throw new rq(Qq,"string",UQ)}function a(UQ,Qq){if(typeof UQ!=="number")throw new rq(Qq,"number",UQ)}var ZQ=aq((UQ,Qq,WQ)=>{if(!H(WQ,UQ)){const GQ="must be one of: "+X(q(WQ,(Jq)=>typeof Jq==="string"?`'${Jq}'`:p(Jq)),", ");throw new m(Qq,UQ,GQ)}});function r(UQ,Qq){if(typeof UQ!=="boolean")throw new rq(Qq,"boolean",UQ)}var BQ=aq((UQ,Qq,WQ)=>{const Xq=WQ==null,GQ=Xq?!1:WQ.allowArray,Jq=Xq?!1:WQ.allowFunction;if(!(Xq?!1:WQ.nullable)&&UQ===null||!GQ&&U(UQ)||typeof UQ!=="object"&&(!Jq||typeof UQ!=="function"))throw new rq(Qq,"Object",UQ)}),$=aq((UQ,Qq,WQ=0)=>{if(!U(UQ))throw new rq(Qq,"Array",UQ);if(UQ.length{if(!qQ(UQ))throw new rq(Qq,["Buffer","TypedArray","DataView"],UQ)});function $Q(UQ,Qq){const WQ=eq(Qq),Xq=UQ.length;if(WQ==="hex"&&Xq%2!==0)throw new m("encoding",Qq,`is invalid for data of length ${Xq}`)}function t(UQ,Qq="Port",WQ=!0){if(typeof UQ!=="number"&&typeof UQ!=="string"||typeof UQ==="string"&&u(UQ).length===0||+UQ!==+UQ>>>0||UQ>65535||UQ===0&&!WQ)throw new b(Qq,UQ,WQ);return UQ|0}var zQ=aq((UQ,Qq)=>{if(UQ!==void 0&&(UQ===null||typeof UQ!=="object"||!("aborted"in UQ)))throw new rq(Qq,"AbortSignal",UQ)}),e=aq((UQ,Qq)=>{if(typeof UQ!=="function")throw new rq(Qq,"Function",UQ)}),VQ=aq((UQ,Qq)=>{if(typeof UQ!=="function"||d(UQ))throw new rq(Qq,"Function",UQ)}),qq=aq((UQ,Qq)=>{if(UQ!==void 0)throw new rq(Qq,"undefined",UQ)});Y.exports={isInt32:QQ,isUint32:i,parseFileMode:JQ,validateArray:$,validateBoolean:r,validateBuffer:z,validateEncoding:$Q,validateFunction:e,validateInt32:HQ,validateInteger:o,validateNumber:a,validateObject:BQ,validateOneOf:ZQ,validatePlainFunction:VQ,validatePort:t,validateSignalName:YQ,validateString:KQ,validateUint32:s,validateUndefined:qq,validateAbortSignal:zQ}}}),j=G({"node_modules/readable-stream/lib/internal/streams/utils.js"(B,Y){var{Symbol:U,SymbolAsyncIterator:H,SymbolIterator:X}=DQ(),q=U("kDestroyed"),J=U("kIsErrored"),Q=U("kIsReadable"),Z=U("kIsDisturbed");function K(s,KQ=!1){var a;return!!(s&&typeof s.pipe==="function"&&typeof s.on==="function"&&(!KQ||typeof s.pause==="function"&&typeof s.resume==="function")&&(!s._writableState||((a=s._readableState)===null||a===void 0?void 0:a.readable)!==!1)&&(!s._writableState||s._readableState))}function oq(s){var KQ;return!!(s&&typeof s.write==="function"&&typeof s.on==="function"&&(!s._readableState||((KQ=s._writableState)===null||KQ===void 0?void 0:KQ.writable)!==!1))}function p(s){return!!(s&&typeof s.pipe==="function"&&s._readableState&&typeof s.on==="function"&&typeof s.write==="function")}function sq(s){return s&&(s._readableState||s._writableState||typeof s.write==="function"&&typeof s.on==="function"||typeof s.pipe==="function"&&typeof s.on==="function")}function u(s,KQ){if(s==null)return!1;if(KQ===!0)return typeof s[H]==="function";if(KQ===!1)return typeof s[X]==="function";return typeof s[H]==="function"||typeof s[X]==="function"}function aq(s){if(!sq(s))return null;const{_writableState:KQ,_readableState:a}=s,ZQ=KQ||a;return!!(s.destroyed||s[q]||ZQ!==null&&ZQ!==void 0&&ZQ.destroyed)}function b(s){if(!oq(s))return null;if(s.writableEnded===!0)return!0;const KQ=s._writableState;if(KQ!==null&&KQ!==void 0&&KQ.errored)return!1;if(typeof(KQ===null||KQ===void 0?void 0:KQ.ended)!=="boolean")return null;return KQ.ended}function rq(s,KQ){if(!oq(s))return null;if(s.writableFinished===!0)return!0;const a=s._writableState;if(a!==null&&a!==void 0&&a.errored)return!1;if(typeof(a===null||a===void 0?void 0:a.finished)!=="boolean")return null;return!!(a.finished||KQ===!1&&a.ended===!0&&a.length===0)}function m(s){if(!K(s))return null;if(s.readableEnded===!0)return!0;const KQ=s._readableState;if(!KQ||KQ.errored)return!1;if(typeof(KQ===null||KQ===void 0?void 0:KQ.ended)!=="boolean")return null;return KQ.ended}function tq(s,KQ){if(!K(s))return null;const a=s._readableState;if(a!==null&&a!==void 0&&a.errored)return!1;if(typeof(a===null||a===void 0?void 0:a.endEmitted)!=="boolean")return null;return!!(a.endEmitted||KQ===!1&&a.ended===!0&&a.length===0)}function c(s){if(s&&s[Q]!=null)return s[Q];if(typeof(s===null||s===void 0?void 0:s.readable)!=="boolean")return null;if(aq(s))return!1;return K(s)&&s.readable&&!tq(s)}function eq(s){if(typeof(s===null||s===void 0?void 0:s.writable)!=="boolean")return null;if(aq(s))return!1;return oq(s)&&s.writable&&!b(s)}function d(s,KQ){if(!sq(s))return null;if(aq(s))return!0;if((KQ===null||KQ===void 0?void 0:KQ.readable)!==!1&&c(s))return!1;if((KQ===null||KQ===void 0?void 0:KQ.writable)!==!1&&eq(s))return!1;return!0}function qQ(s){var KQ,a;if(!sq(s))return null;if(s.writableErrored)return s.writableErrored;return(KQ=(a=s._writableState)===null||a===void 0?void 0:a.errored)!==null&&KQ!==void 0?KQ:null}function l(s){var KQ,a;if(!sq(s))return null;if(s.readableErrored)return s.readableErrored;return(KQ=(a=s._readableState)===null||a===void 0?void 0:a.errored)!==null&&KQ!==void 0?KQ:null}function QQ(s){if(!sq(s))return null;if(typeof s.closed==="boolean")return s.closed;const{_writableState:KQ,_readableState:a}=s;if(typeof(KQ===null||KQ===void 0?void 0:KQ.closed)==="boolean"||typeof(a===null||a===void 0?void 0:a.closed)==="boolean")return(KQ===null||KQ===void 0?void 0:KQ.closed)||(a===null||a===void 0?void 0:a.closed);if(typeof s._closed==="boolean"&&i(s))return s._closed;return null}function i(s){return typeof s._closed==="boolean"&&typeof s._defaultKeepAlive==="boolean"&&typeof s._removedConnection==="boolean"&&typeof s._removedContLen==="boolean"}function XQ(s){return typeof s._sent100==="boolean"&&i(s)}function n(s){var KQ;return typeof s._consuming==="boolean"&&typeof s._dumped==="boolean"&&((KQ=s.req)===null||KQ===void 0?void 0:KQ.upgradeOrConnect)===void 0}function JQ(s){if(!sq(s))return null;const{_writableState:KQ,_readableState:a}=s,ZQ=KQ||a;return!ZQ&&XQ(s)||!!(ZQ&&ZQ.autoDestroy&&ZQ.emitClose&&ZQ.closed===!1)}function o(s){var KQ;return!!(s&&((KQ=s[Z])!==null&&KQ!==void 0?KQ:s.readableDidRead||s.readableAborted))}function HQ(s){var KQ,a,ZQ,r,BQ,$,YQ,z,$Q,t;return!!(s&&((KQ=(a=(ZQ=(r=(BQ=($=s[J])!==null&&$!==void 0?$:s.readableErrored)!==null&&BQ!==void 0?BQ:s.writableErrored)!==null&&r!==void 0?r:(YQ=s._readableState)===null||YQ===void 0?void 0:YQ.errorEmitted)!==null&&ZQ!==void 0?ZQ:(z=s._writableState)===null||z===void 0?void 0:z.errorEmitted)!==null&&a!==void 0?a:($Q=s._readableState)===null||$Q===void 0?void 0:$Q.errored)!==null&&KQ!==void 0?KQ:(t=s._writableState)===null||t===void 0?void 0:t.errored))}Y.exports={kDestroyed:q,isDisturbed:o,kIsDisturbed:Z,isErrored:HQ,kIsErrored:J,isReadable:c,kIsReadable:Q,isClosed:QQ,isDestroyed:aq,isDuplexNodeStream:p,isFinished:d,isIterable:u,isReadableNodeStream:K,isReadableEnded:m,isReadableFinished:tq,isReadableErrored:l,isNodeStream:sq,isWritable:eq,isWritableNodeStream:oq,isWritableEnded:b,isWritableFinished:rq,isWritableErrored:qQ,isServerRequest:n,isServerResponse:XQ,willEmitClose:JQ}}}),N=G({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(B,Y){var{AbortError:U,codes:H}=hQ(),{ERR_INVALID_ARG_TYPE:X,ERR_STREAM_PREMATURE_CLOSE:q}=H,{once:J}=jq(),{validateAbortSignal:Q,validateFunction:Z,validateObject:K}=L(),{Promise:oq}=DQ(),{isClosed:p,isReadable:sq,isReadableNodeStream:u,isReadableFinished:aq,isReadableErrored:b,isWritable:rq,isWritableNodeStream:m,isWritableFinished:tq,isWritableErrored:c,isNodeStream:eq,willEmitClose:d}=j();function qQ(XQ){return XQ.setHeader&&typeof XQ.abort==="function"}var l=()=>{};function QQ(XQ,n,JQ){var o,HQ;if(arguments.length===2)JQ=n,n={};else if(n==null)n={};else K(n,"options");Z(JQ,"callback"),Q(n.signal,"options.signal"),JQ=J(JQ);const s=(o=n.readable)!==null&&o!==void 0?o:u(XQ),KQ=(HQ=n.writable)!==null&&HQ!==void 0?HQ:m(XQ);if(!eq(XQ))throw new X("stream","Stream",XQ);const{_writableState:a,_readableState:ZQ}=XQ,r=()=>{if(!XQ.writable)YQ()};let BQ=d(XQ)&&u(XQ)===s&&m(XQ)===KQ,$=tq(XQ,!1);const YQ=()=>{if($=!0,XQ.destroyed)BQ=!1;if(BQ&&(!XQ.readable||s))return;if(!s||z)JQ.call(XQ)};let z=aq(XQ,!1);const $Q=()=>{if(z=!0,XQ.destroyed)BQ=!1;if(BQ&&(!XQ.writable||KQ))return;if(!KQ||$)JQ.call(XQ)},t=(UQ)=>{JQ.call(XQ,UQ)};let zQ=p(XQ);const e=()=>{zQ=!0;const UQ=c(XQ)||b(XQ);if(UQ&&typeof UQ!=="boolean")return JQ.call(XQ,UQ);if(s&&!z&&u(XQ,!0)){if(!aq(XQ,!1))return JQ.call(XQ,new q)}if(KQ&&!$){if(!tq(XQ,!1))return JQ.call(XQ,new q)}JQ.call(XQ)},VQ=()=>{XQ.req.on("finish",YQ)};if(qQ(XQ)){if(XQ.on("complete",YQ),!BQ)XQ.on("abort",e);if(XQ.req)VQ();else XQ.on("request",VQ)}else if(KQ&&!a)XQ.on("end",r),XQ.on("close",r);if(!BQ&&typeof XQ.aborted==="boolean")XQ.on("aborted",e);if(XQ.on("end",$Q),XQ.on("finish",YQ),n.error!==!1)XQ.on("error",t);if(XQ.on("close",e),zQ)_Q(e);else if(a!==null&&a!==void 0&&a.errorEmitted||ZQ!==null&&ZQ!==void 0&&ZQ.errorEmitted){if(!BQ)_Q(e)}else if(!s&&(!BQ||sq(XQ))&&($||rq(XQ)===!1))_Q(e);else if(!KQ&&(!BQ||rq(XQ))&&(z||sq(XQ)===!1))_Q(e);else if(ZQ&&XQ.req&&XQ.aborted)_Q(e);const qq=()=>{if(JQ=l,XQ.removeListener("aborted",e),XQ.removeListener("complete",YQ),XQ.removeListener("abort",e),XQ.removeListener("request",VQ),XQ.req)XQ.req.removeListener("finish",YQ);XQ.removeListener("end",r),XQ.removeListener("close",r),XQ.removeListener("finish",YQ),XQ.removeListener("end",$Q),XQ.removeListener("error",t),XQ.removeListener("close",e)};if(n.signal&&!zQ){const UQ=()=>{const Qq=JQ;qq(),Qq.call(XQ,new U(void 0,{cause:n.signal.reason}))};if(n.signal.aborted)_Q(UQ);else{const Qq=JQ;JQ=J((...WQ)=>{n.signal.removeEventListener("abort",UQ),Qq.apply(XQ,WQ)}),n.signal.addEventListener("abort",UQ)}}return qq}function i(XQ,n){return new oq((JQ,o)=>{QQ(XQ,n,(HQ)=>{if(HQ)o(HQ);else JQ()})})}Y.exports=QQ,Y.exports.finished=i}}),A=G({"node_modules/readable-stream/lib/internal/streams/operators.js"(B,Y){var{codes:{ERR_INVALID_ARG_TYPE:U,ERR_MISSING_ARGS:H,ERR_OUT_OF_RANGE:X},AbortError:q}=hQ(),{validateAbortSignal:J,validateInteger:Q,validateObject:Z}=L(),K=DQ().Symbol("kWeak"),{finished:oq}=N(),{ArrayPrototypePush:p,MathFloor:sq,Number:u,NumberIsNaN:aq,Promise:b,PromiseReject:rq,PromisePrototypeCatch:m,Symbol:tq}=DQ(),c=tq("kEmpty"),eq=tq("kEof");function d(r,BQ){if(typeof r!=="function")throw new U("fn",["Function","AsyncFunction"],r);if(BQ!=null)Z(BQ,"options");if((BQ===null||BQ===void 0?void 0:BQ.signal)!=null)J(BQ.signal,"options.signal");let $=1;if((BQ===null||BQ===void 0?void 0:BQ.concurrency)!=null)$=sq(BQ.concurrency);return Q($,"concurrency",1),async function*YQ(){var z,$Q;const t=new AbortController,zQ=this,e=[],VQ=t.signal,qq={signal:VQ},UQ=()=>t.abort();if(BQ!==null&&BQ!==void 0&&(z=BQ.signal)!==null&&z!==void 0&&z.aborted)UQ();BQ===null||BQ===void 0||($Q=BQ.signal)===null||$Q===void 0||$Q.addEventListener("abort",UQ);let Qq,WQ,Xq=!1;function GQ(){Xq=!0}async function Jq(){try{for await(let FQ of zQ){var MQ;if(Xq)return;if(VQ.aborted)throw new q;try{FQ=r(FQ,qq)}catch(Kq){FQ=rq(Kq)}if(FQ===c)continue;if(typeof((MQ=FQ)===null||MQ===void 0?void 0:MQ.catch)==="function")FQ.catch(GQ);if(e.push(FQ),Qq)Qq(),Qq=null;if(!Xq&&e.length&&e.length>=$)await new b((Kq)=>{WQ=Kq})}e.push(eq)}catch(FQ){const Kq=rq(FQ);m(Kq,GQ),e.push(Kq)}finally{var Hq;if(Xq=!0,Qq)Qq(),Qq=null;BQ===null||BQ===void 0||(Hq=BQ.signal)===null||Hq===void 0||Hq.removeEventListener("abort",UQ)}}Jq();try{while(!0){while(e.length>0){const MQ=await e[0];if(MQ===eq)return;if(VQ.aborted)throw new q;if(MQ!==c)yield MQ;if(e.shift(),WQ)WQ(),WQ=null}await new b((MQ)=>{Qq=MQ})}}finally{if(t.abort(),Xq=!0,WQ)WQ(),WQ=null}}.call(this)}function qQ(r=void 0){if(r!=null)Z(r,"options");if((r===null||r===void 0?void 0:r.signal)!=null)J(r.signal,"options.signal");return async function*BQ(){let $=0;for await(let z of this){var YQ;if(r!==null&&r!==void 0&&(YQ=r.signal)!==null&&YQ!==void 0&&YQ.aborted)throw new q({cause:r.signal.reason});yield[$++,z]}}.call(this)}async function l(r,BQ=void 0){for await(let $ of n.call(this,r,BQ))return!0;return!1}async function QQ(r,BQ=void 0){if(typeof r!=="function")throw new U("fn",["Function","AsyncFunction"],r);return!await l.call(this,async(...$)=>{return!await r(...$)},BQ)}async function i(r,BQ){for await(let $ of n.call(this,r,BQ))return $;return}async function XQ(r,BQ){if(typeof r!=="function")throw new U("fn",["Function","AsyncFunction"],r);async function $(YQ,z){return await r(YQ,z),c}for await(let YQ of d.call(this,$,BQ));}function n(r,BQ){if(typeof r!=="function")throw new U("fn",["Function","AsyncFunction"],r);async function $(YQ,z){if(await r(YQ,z))return YQ;return c}return d.call(this,$,BQ)}var JQ=class extends H{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function o(r,BQ,$){var YQ;if(typeof r!=="function")throw new U("reducer",["Function","AsyncFunction"],r);if($!=null)Z($,"options");if(($===null||$===void 0?void 0:$.signal)!=null)J($.signal,"options.signal");let z=arguments.length>1;if($!==null&&$!==void 0&&(YQ=$.signal)!==null&&YQ!==void 0&&YQ.aborted){const VQ=new q(void 0,{cause:$.signal.reason});throw this.once("error",()=>{}),await oq(this.destroy(VQ)),VQ}const $Q=new AbortController,t=$Q.signal;if($!==null&&$!==void 0&&$.signal){const VQ={once:!0,[K]:this};$.signal.addEventListener("abort",()=>$Q.abort(),VQ)}let zQ=!1;try{for await(let VQ of this){var e;if(zQ=!0,$!==null&&$!==void 0&&(e=$.signal)!==null&&e!==void 0&&e.aborted)throw new q;if(!z)BQ=VQ,z=!0;else BQ=await r(BQ,VQ,{signal:t})}if(!zQ&&!z)throw new JQ}finally{$Q.abort()}return BQ}async function HQ(r){if(r!=null)Z(r,"options");if((r===null||r===void 0?void 0:r.signal)!=null)J(r.signal,"options.signal");const BQ=[];for await(let YQ of this){var $;if(r!==null&&r!==void 0&&($=r.signal)!==null&&$!==void 0&&$.aborted)throw new q(void 0,{cause:r.signal.reason});p(BQ,YQ)}return BQ}function s(r,BQ){const $=d.call(this,r,BQ);return async function*YQ(){for await(let z of $)yield*z}.call(this)}function KQ(r){if(r=u(r),aq(r))return 0;if(r<0)throw new X("number",">= 0",r);return r}function a(r,BQ=void 0){if(BQ!=null)Z(BQ,"options");if((BQ===null||BQ===void 0?void 0:BQ.signal)!=null)J(BQ.signal,"options.signal");return r=KQ(r),async function*$(){var YQ;if(BQ!==null&&BQ!==void 0&&(YQ=BQ.signal)!==null&&YQ!==void 0&&YQ.aborted)throw new q;for await(let $Q of this){var z;if(BQ!==null&&BQ!==void 0&&(z=BQ.signal)!==null&&z!==void 0&&z.aborted)throw new q;if(r--<=0)yield $Q}}.call(this)}function ZQ(r,BQ=void 0){if(BQ!=null)Z(BQ,"options");if((BQ===null||BQ===void 0?void 0:BQ.signal)!=null)J(BQ.signal,"options.signal");return r=KQ(r),async function*$(){var YQ;if(BQ!==null&&BQ!==void 0&&(YQ=BQ.signal)!==null&&YQ!==void 0&&YQ.aborted)throw new q;for await(let $Q of this){var z;if(BQ!==null&&BQ!==void 0&&(z=BQ.signal)!==null&&z!==void 0&&z.aborted)throw new q;if(r-- >0)yield $Q;else return}}.call(this)}Y.exports.streamReturningOperators={asIndexedPairs:qQ,drop:a,filter:n,flatMap:s,map:d,take:ZQ},Y.exports.promiseReturningOperators={every:QQ,forEach:XQ,reduce:o,toArray:HQ,some:l,find:i}}}),Oq=G({"node_modules/readable-stream/lib/internal/streams/destroy.js"(B,Y){var{aggregateTwoErrors:U,codes:{ERR_MULTIPLE_CALLBACK:H},AbortError:X}=hQ(),{Symbol:q}=DQ(),{kDestroyed:J,isDestroyed:Q,isFinished:Z,isServerRequest:K}=j(),oq="#kDestroy",p="#kConstruct";function sq(n,JQ,o){if(n){if(n.stack,JQ&&!JQ.errored)JQ.errored=n;if(o&&!o.errored)o.errored=n}}function u(n,JQ){const o=this._readableState,HQ=this._writableState,s=HQ||o;if(HQ&&HQ.destroyed||o&&o.destroyed){if(typeof JQ==="function")JQ();return this}if(sq(n,HQ,o),HQ)HQ.destroyed=!0;if(o)o.destroyed=!0;if(!s.constructed)this.once(oq,(KQ)=>{aq(this,U(KQ,n),JQ)});else aq(this,n,JQ);return this}function aq(n,JQ,o){let HQ=!1;function s(KQ){if(HQ)return;HQ=!0;const{_readableState:a,_writableState:ZQ}=n;if(sq(KQ,ZQ,a),ZQ)ZQ.closed=!0;if(a)a.closed=!0;if(typeof o==="function")o(KQ);if(KQ)_Q(b,n,KQ);else _Q(rq,n)}try{n._destroy(JQ||null,s)}catch(KQ){s(KQ)}}function b(n,JQ){m(n,JQ),rq(n)}function rq(n){const{_readableState:JQ,_writableState:o}=n;if(o)o.closeEmitted=!0;if(JQ)JQ.closeEmitted=!0;if(o&&o.emitClose||JQ&&JQ.emitClose)n.emit("close")}function m(n,JQ){const o=n?._readableState,HQ=n?._writableState;if(HQ?.errorEmitted||o?.errorEmitted)return;if(HQ)HQ.errorEmitted=!0;if(o)o.errorEmitted=!0;n?.emit?.("error",JQ)}function tq(){const n=this._readableState,JQ=this._writableState;if(n)n.constructed=!0,n.closed=!1,n.closeEmitted=!1,n.destroyed=!1,n.errored=null,n.errorEmitted=!1,n.reading=!1,n.ended=n.readable===!1,n.endEmitted=n.readable===!1;if(JQ)JQ.constructed=!0,JQ.destroyed=!1,JQ.closed=!1,JQ.closeEmitted=!1,JQ.errored=null,JQ.errorEmitted=!1,JQ.finalCalled=!1,JQ.prefinished=!1,JQ.ended=JQ.writable===!1,JQ.ending=JQ.writable===!1,JQ.finished=JQ.writable===!1}function c(n,JQ,o){const HQ=n?._readableState,s=n?._writableState;if(s&&s.destroyed||HQ&&HQ.destroyed)return this;if(HQ&&HQ.autoDestroy||s&&s.autoDestroy)n.destroy(JQ);else if(JQ){if(Error.captureStackTrace(JQ),s&&!s.errored)s.errored=JQ;if(HQ&&!HQ.errored)HQ.errored=JQ;if(o)_Q(m,n,JQ);else m(n,JQ)}}function eq(n,JQ){if(typeof n._construct!=="function")return;const{_readableState:o,_writableState:HQ}=n;if(o)o.constructed=!1;if(HQ)HQ.constructed=!1;if(n.once(p,JQ),n.listenerCount(p)>1)return;_Q(d,n)}function d(n){let JQ=!1;function o(HQ){if(JQ){c(n,HQ!==null&&HQ!==void 0?HQ:new H);return}JQ=!0;const{_readableState:s,_writableState:KQ}=n,a=KQ||s;if(s)s.constructed=!0;if(KQ)KQ.constructed=!0;if(a.destroyed)n.emit(oq,HQ);else if(HQ)c(n,HQ,!0);else _Q(qQ,n)}try{n._construct(o)}catch(HQ){o(HQ)}}function qQ(n){n.emit(p)}function l(n){return n&&n.setHeader&&typeof n.abort==="function"}function QQ(n){n.emit("close")}function i(n,JQ){n.emit("error",JQ),_Q(QQ,n)}function XQ(n,JQ){if(!n||Q(n))return;if(!JQ&&!Z(n))JQ=new X;if(K(n))n.socket=null,n.destroy(JQ);else if(l(n))n.abort();else if(l(n.req))n.req.abort();else if(typeof n.destroy==="function")n.destroy(JQ);else if(typeof n.close==="function")n.close();else if(JQ)_Q(i,n);else _Q(QQ,n);if(!n.destroyed)n[J]=!0}Y.exports={construct:eq,destroyer:XQ,destroy:u,undestroy:tq,errorOrDestroy:c}}}),pQ=G({"node_modules/readable-stream/lib/internal/streams/legacy.js"(B,Y){var{ArrayIsArray:U,ObjectSetPrototypeOf:H}=DQ();function X(J){if(!(this instanceof X))return new X(J);CQ.call(this,J)}H(X.prototype,CQ.prototype),H(X,CQ),X.prototype.pipe=function(J,Q){const Z=this;function K(rq){if(J.writable&&J.write(rq)===!1&&Z.pause)Z.pause()}Z.on("data",K);function oq(){if(Z.readable&&Z.resume)Z.resume()}if(J.on("drain",oq),!J._isStdio&&(!Q||Q.end!==!1))Z.on("end",sq),Z.on("close",u);let p=!1;function sq(){if(p)return;p=!0,J.end()}function u(){if(p)return;if(p=!0,typeof J.destroy==="function")J.destroy()}function aq(rq){if(b(),CQ.listenerCount(this,"error")===0)this.emit("error",rq)}q(Z,"error",aq),q(J,"error",aq);function b(){Z.removeListener("data",K),J.removeListener("drain",oq),Z.removeListener("end",sq),Z.removeListener("close",u),Z.removeListener("error",aq),J.removeListener("error",aq),Z.removeListener("end",b),Z.removeListener("close",b),J.removeListener("close",b)}return Z.on("end",b),Z.on("close",b),J.on("close",b),J.emit("pipe",Z),J};function q(J,Q,Z){if(typeof J.prependListener==="function")return J.prependListener(Q,Z);if(!J._events||!J._events[Q])J.on(Q,Z);else if(U(J._events[Q]))J._events[Q].unshift(Z);else J._events[Q]=[Z,J._events[Q]]}Y.exports={Stream:X,prependListener:q}}}),_q=G({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(B,Y){var{AbortError:U,codes:H}=hQ(),X=N(),{ERR_INVALID_ARG_TYPE:q}=H,J=(Z,K)=>{if(typeof Z!=="object"||!("aborted"in Z))throw new q(K,"AbortSignal",Z)};function Q(Z){return!!(Z&&typeof Z.pipe==="function")}Y.exports.addAbortSignal=function Z(K,oq){if(J(K,"signal"),!Q(oq))throw new q("stream","stream.Stream",oq);return Y.exports.addAbortSignalNoValidate(K,oq)},Y.exports.addAbortSignalNoValidate=function(Z,K){if(typeof Z!=="object"||!("aborted"in Z))return K;const oq=()=>{K.destroy(new U(void 0,{cause:Z.reason}))};if(Z.aborted)oq();else Z.addEventListener("abort",oq),X(K,()=>Z.removeEventListener("abort",oq));return K}}}),uQ=G({"node_modules/readable-stream/lib/internal/streams/state.js"(B,Y){var{MathFloor:U,NumberIsInteger:H}=DQ(),{ERR_INVALID_ARG_VALUE:X}=hQ().codes;function q(Z,K,oq){return Z.highWaterMark!=null?Z.highWaterMark:K?Z[oq]:null}function J(Z){return Z?16:16384}function Q(Z,K,oq,p){const sq=q(K,p,oq);if(sq!=null){if(!H(sq)||sq<0){const u=p?`options.${oq}`:"options.highWaterMark";throw new X(u,sq)}return U(sq)}return J(Z.objectMode)}Y.exports={getHighWaterMark:Q,getDefaultHighWaterMark:J}}}),Cq=G({"node_modules/readable-stream/lib/internal/streams/from.js"(B,Y){var{PromisePrototypeThen:U,SymbolAsyncIterator:H,SymbolIterator:X}=DQ(),{ERR_INVALID_ARG_TYPE:q,ERR_STREAM_NULL_VALUES:J}=hQ().codes;function Q(Z,K,oq){let p;if(typeof K==="string"||K instanceof Buffer)return new Z({objectMode:!0,...oq,read(){this.push(K),this.push(null)}});let sq;if(K&&K[H])sq=!0,p=K[H]();else if(K&&K[X])sq=!1,p=K[X]();else throw new q("iterable",["Iterable"],K);const u=new Z({objectMode:!0,highWaterMark:1,...oq});let aq=!1;u._read=function(){if(!aq)aq=!0,rq()},u._destroy=function(m,tq){U(b(m),()=>_Q(tq,m),(c)=>_Q(tq,c||m))};async function b(m){const tq=m!==void 0&&m!==null,c=typeof p.throw==="function";if(tq&&c){const{value:eq,done:d}=await p.throw(m);if(await eq,d)return}if(typeof p.return==="function"){const{value:eq}=await p.return();await eq}}async function rq(){for(;;){try{const{value:m,done:tq}=sq?await p.next():p.next();if(tq)u.push(null);else{const c=m&&typeof m.then==="function"?await m:m;if(c===null)throw aq=!1,new J;else if(u.push(c))continue;else aq=!1}}catch(m){u.destroy(m)}break}}return u}Y.exports=Q}}),bQ,Dq,mQ=G({"node_modules/readable-stream/lib/internal/streams/readable.js"(B,Y){var{ArrayPrototypeIndexOf:U,NumberIsInteger:H,NumberIsNaN:X,NumberParseInt:q,ObjectDefineProperties:J,ObjectKeys:Q,ObjectSetPrototypeOf:Z,Promise:K,SafeSet:oq,SymbolAsyncIterator:p,Symbol:sq}=DQ(),u=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{Stream:aq,prependListener:b}=pQ();function rq(FQ){if(!(this instanceof rq))return new rq(FQ);const Kq=this instanceof wQ();if(this._readableState=new u(FQ,this,Kq),FQ){const{read:LQ,destroy:Zq,construct:jQ,signal:Bq}=FQ;if(typeof LQ==="function")this._read=LQ;if(typeof Zq==="function")this._destroy=Zq;if(typeof jQ==="function")this._construct=jQ;if(Bq&&!Kq)c(Bq,this)}aq.call(this,FQ),n.construct(this,()=>{if(this._readableState.needReadable)i(this,this._readableState)})}Z(rq.prototype,aq.prototype),Z(rq,aq),rq.prototype.on=function(FQ,Kq){const LQ=aq.prototype.on.call(this,FQ,Kq),Zq=this._readableState;if(FQ==="data")if(Zq.readableListening=this.listenerCount("readable")>0,Zq.flowing!==!1)OQ&&Gq("in flowing mode!",this.__id),this.resume();else OQ&&Gq("in readable mode!",this.__id);else if(FQ==="readable"){if(OQ&&Gq("readable listener added!",this.__id),!Zq.endEmitted&&!Zq.readableListening){if(Zq.readableListening=Zq.needReadable=!0,Zq.flowing=!1,Zq.emittedReadable=!1,OQ&&Gq("on readable - state.length, reading, emittedReadable",Zq.length,Zq.reading,Zq.emittedReadable,this.__id),Zq.length)XQ(this,Zq);else if(!Zq.reading)_Q(qq,this)}else if(Zq.endEmitted)OQ&&Gq("end already emitted...",this.__id)}return LQ};class m extends rq{#q;#Q;#X;#J;constructor(FQ,Kq){const{objectMode:LQ,highWaterMark:Zq,encoding:jQ,signal:Bq}=FQ;super({objectMode:LQ,highWaterMark:Zq,encoding:jQ,signal:Bq});this.#X=[],this.#q=void 0,this.#J=Kq,this.#Q=!1}#H(){var FQ=this.#X,Kq=0,LQ=FQ.length;for(;Kq0)this.#X=[];return!1}#K(FQ){FQ.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){OQ&&Gq("ReadableFromWeb _read()",this.__id);var FQ=this.#J,Kq=this.#q;if(FQ)Kq=this.#q=FQ.getReader(),this.#J=void 0;else if(this.#H())return;var LQ;try{do{var Zq=!1,jQ;const Bq=Kq.readMany();if(Lq(Bq)){if({done:Zq,value:jQ}=await Bq,this.#Q){this.#X.push(...jQ);return}}else({done:Zq,value:jQ}=Bq);if(Zq){this.#K(Kq);return}if(!this.push(jQ[0])){this.#X=jQ.slice(1);return}for(let NQ=1,Yq=jQ.length;NQ{this.#Q=!0,Kq(FQ)});return}try{Kq(FQ)}catch(Zq){globalThis.reportError(Zq)}}}Dq=m;function tq(FQ,Kq={}){if(!M(FQ))throw new o("readableStream","ReadableStream",FQ);ZQ(Kq,"options");const{highWaterMark:LQ,encoding:Zq,objectMode:jQ=!1,signal:Bq}=Kq;if(Zq!==void 0&&!Buffer.isEncoding(Zq))throw new xq(Zq,"options.encoding");return F(jQ,"options.objectMode"),_(rq,FQ,Kq)||new m({highWaterMark:LQ,encoding:Zq,objectMode:jQ,signal:Bq},FQ)}Y.exports=rq,bQ=tq;var{addAbortSignal:c}=_q(),eq=N();const{maybeReadMore:d,resume:qQ,emitReadable:l,onEofChunk:QQ}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function i(FQ,Kq){process.nextTick(d,FQ,Kq)}function XQ(FQ,Kq){OQ&&Gq("NativeReadable - emitReadable",FQ.__id),l(FQ,Kq)}var n=Oq(),{aggregateTwoErrors:JQ,codes:{ERR_INVALID_ARG_TYPE:o,ERR_METHOD_NOT_IMPLEMENTED:HQ,ERR_OUT_OF_RANGE:s,ERR_STREAM_PUSH_AFTER_EOF:KQ,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:a}}=hQ(),{validateObject:ZQ}=L(),r=Cq(),BQ=()=>{},{errorOrDestroy:$}=n;rq.prototype.destroy=n.destroy,rq.prototype._undestroy=n.undestroy,rq.prototype._destroy=function(FQ,Kq){Kq(FQ)},rq.prototype[CQ.captureRejectionSymbol]=function(FQ){this.destroy(FQ)},rq.prototype.push=function(FQ,Kq){return YQ(this,FQ,Kq,!1)},rq.prototype.unshift=function(FQ,Kq){return YQ(this,FQ,Kq,!0)};function YQ(FQ,Kq,LQ,Zq){OQ&&Gq("readableAddChunk",Kq,FQ.__id);const jQ=FQ._readableState;let Bq;if(!jQ.objectMode){if(typeof Kq==="string"){if(LQ=LQ||jQ.defaultEncoding,jQ.encoding!==LQ)if(Zq&&jQ.encoding)Kq=Buffer.from(Kq,LQ).toString(jQ.encoding);else Kq=Buffer.from(Kq,LQ),LQ=""}else if(Kq instanceof Buffer)LQ="";else if(aq._isUint8Array(Kq)){if(Zq||!jQ.decoder)Kq=aq._uint8ArrayToBuffer(Kq);LQ=""}else if(Kq!=null)Bq=new o("chunk",["string","Buffer","Uint8Array"],Kq)}if(Bq)$(FQ,Bq);else if(Kq===null)jQ.reading=!1,QQ(FQ,jQ);else if(jQ.objectMode||Kq&&Kq.length>0)if(Zq)if(jQ.endEmitted)$(FQ,new a);else if(jQ.destroyed||jQ.errored)return!1;else z(FQ,jQ,Kq,!0);else if(jQ.ended)$(FQ,new KQ);else if(jQ.destroyed||jQ.errored)return!1;else if(jQ.reading=!1,jQ.decoder&&!LQ)if(Kq=jQ.decoder.write(Kq),jQ.objectMode||Kq.length!==0)z(FQ,jQ,Kq,!1);else i(FQ,jQ);else z(FQ,jQ,Kq,!1);else if(!Zq)jQ.reading=!1,i(FQ,jQ);return!jQ.ended&&(jQ.length0){if(Kq.multiAwaitDrain)Kq.awaitDrainWriters.clear();else Kq.awaitDrainWriters=null;Kq.dataEmitted=!0,FQ.emit("data",LQ)}else{if(Kq.length+=Kq.objectMode?1:LQ.length,Zq)Kq.buffer.unshift(LQ);else Kq.buffer.push(LQ);if(OQ&&Gq("needReadable @ addChunk",Kq.needReadable,FQ.__id),Kq.needReadable)XQ(FQ,Kq)}i(FQ,Kq)}rq.prototype.isPaused=function(){const FQ=this._readableState;return FQ.paused===!0||FQ.flowing===!1},rq.prototype.setEncoding=function(FQ){const Kq=new Eq(FQ);this._readableState.decoder=Kq,this._readableState.encoding=this._readableState.decoder.encoding;const LQ=this._readableState.buffer;let Zq="";for(let jQ=LQ.length;jQ>0;jQ--)Zq+=Kq.write(LQ.shift());if(Zq!=="")LQ.push(Zq);return this._readableState.length=Zq.length,this};var $Q=1073741824;function t(FQ){if(FQ>$Q)throw new s("size","<= 1GiB",FQ);else FQ--,FQ|=FQ>>>1,FQ|=FQ>>>2,FQ|=FQ>>>4,FQ|=FQ>>>8,FQ|=FQ>>>16,FQ++;return FQ}function zQ(FQ,Kq){if(FQ<=0||Kq.length===0&&Kq.ended)return 0;if(Kq.objectMode)return 1;if(X(FQ)){if(Kq.flowing&&Kq.length)return Kq.buffer.first().length;return Kq.length}if(FQ<=Kq.length)return FQ;return Kq.ended?Kq.length:0}rq.prototype.read=function(FQ){if(OQ&&Gq("read - n =",FQ,this.__id),!H(FQ))FQ=q(FQ,10);const Kq=this._readableState,LQ=FQ;if(FQ>Kq.highWaterMark)Kq.highWaterMark=t(FQ);if(FQ!==0)Kq.emittedReadable=!1;if(FQ===0&&Kq.needReadable&&((Kq.highWaterMark!==0?Kq.length>=Kq.highWaterMark:Kq.length>0)||Kq.ended)){if(OQ&&Gq("read: emitReadable or endReadable",Kq.length,Kq.ended,this.__id),Kq.length===0&&Kq.ended)Xq(this);else XQ(this,Kq);return null}if(FQ=zQ(FQ,Kq),FQ===0&&Kq.ended){if(OQ&&Gq("read: calling endReadable if length 0 -- length, state.ended",Kq.length,Kq.ended,this.__id),Kq.length===0)Xq(this);return null}let Zq=Kq.needReadable;if(OQ&&Gq("need readable",Zq,this.__id),Kq.length===0||Kq.length-FQ0)Bq=WQ(FQ,Kq);else Bq=null;if(OQ&&Gq("ret @ read",Bq,this.__id),Bq===null)Kq.needReadable=Kq.length<=Kq.highWaterMark,OQ&&Gq("state.length while ret = null",Kq.length,this.__id),FQ=0;else if(Kq.length-=FQ,Kq.multiAwaitDrain)Kq.awaitDrainWriters.clear();else Kq.awaitDrainWriters=null;if(Kq.length===0){if(!Kq.ended)Kq.needReadable=!0;if(LQ!==FQ&&Kq.ended)Xq(this)}if(Bq!==null&&!Kq.errorEmitted&&!Kq.closeEmitted)Kq.dataEmitted=!0,this.emit("data",Bq);return Bq},rq.prototype._read=function(FQ){throw new HQ("_read()")},rq.prototype.pipe=function(FQ,Kq){const LQ=this,Zq=this._readableState;if(Zq.pipes.length===1){if(!Zq.multiAwaitDrain)Zq.multiAwaitDrain=!0,Zq.awaitDrainWriters=new oq(Zq.awaitDrainWriters?[Zq.awaitDrainWriters]:[])}Zq.pipes.push(FQ),OQ&&Gq("pipe count=%d opts=%j",Zq.pipes.length,Kq,LQ.__id);const Bq=(!Kq||Kq.end!==!1)&&FQ!==process.stdout&&FQ!==process.stderr?Yq:PQ;if(Zq.endEmitted)_Q(Bq);else LQ.once("end",Bq);FQ.on("unpipe",NQ);function NQ(Wq,xQ){if(OQ&&Gq("onunpipe",LQ.__id),Wq===LQ){if(xQ&&xQ.hasUnpiped===!1)xQ.hasUnpiped=!0,EQ()}}function Yq(){OQ&&Gq("onend",LQ.__id),FQ.end()}let AQ,$q=!1;function EQ(){if(OQ&&Gq("cleanup",LQ.__id),FQ.removeListener("close",TQ),FQ.removeListener("finish",Uq),AQ)FQ.removeListener("drain",AQ);if(FQ.removeListener("error",Vq),FQ.removeListener("unpipe",NQ),LQ.removeListener("end",Yq),LQ.removeListener("end",PQ),LQ.removeListener("data",IQ),$q=!0,AQ&&Zq.awaitDrainWriters&&(!FQ._writableState||FQ._writableState.needDrain))AQ()}function zq(){if(!$q){if(Zq.pipes.length===1&&Zq.pipes[0]===FQ)OQ&&Gq("false write response, pause",0,LQ.__id),Zq.awaitDrainWriters=FQ,Zq.multiAwaitDrain=!1;else if(Zq.pipes.length>1&&Zq.pipes.includes(FQ))OQ&&Gq("false write response, pause",Zq.awaitDrainWriters.size,LQ.__id),Zq.awaitDrainWriters.add(FQ);LQ.pause()}if(!AQ)AQ=e(LQ,FQ),FQ.on("drain",AQ)}LQ.on("data",IQ);function IQ(Wq){OQ&&Gq("ondata",LQ.__id);const xQ=FQ.write(Wq);if(OQ&&Gq("dest.write",xQ,LQ.__id),xQ===!1)zq()}function Vq(Wq){if(Gq("onerror",Wq),PQ(),FQ.removeListener("error",Vq),FQ.listenerCount("error")===0){const xQ=FQ._writableState||FQ._readableState;if(xQ&&!xQ.errorEmitted)$(FQ,Wq);else FQ.emit("error",Wq)}}b(FQ,"error",Vq);function TQ(){FQ.removeListener("finish",Uq),PQ()}FQ.once("close",TQ);function Uq(){Gq("onfinish"),FQ.removeListener("close",TQ),PQ()}FQ.once("finish",Uq);function PQ(){Gq("unpipe"),LQ.unpipe(FQ)}if(FQ.emit("pipe",LQ),FQ.writableNeedDrain===!0){if(Zq.flowing)zq()}else if(!Zq.flowing)Gq("pipe resume"),LQ.resume();return FQ};function e(FQ,Kq){return function LQ(){const Zq=FQ._readableState;if(Zq.awaitDrainWriters===Kq)Gq("pipeOnDrain",1),Zq.awaitDrainWriters=null;else if(Zq.multiAwaitDrain)Gq("pipeOnDrain",Zq.awaitDrainWriters.size),Zq.awaitDrainWriters.delete(Kq);if((!Zq.awaitDrainWriters||Zq.awaitDrainWriters.size===0)&&FQ.listenerCount("data"))FQ.resume()}}rq.prototype.unpipe=function(FQ){const Kq=this._readableState,LQ={hasUnpiped:!1};if(Kq.pipes.length===0)return this;if(!FQ){const jQ=Kq.pipes;Kq.pipes=[],this.pause();for(let Bq=0;Bq0,Kq.resumeScheduled&&Kq.paused===!1)Kq.flowing=!0;else if(FQ.listenerCount("data")>0)FQ.resume();else if(!Kq.readableListening)Kq.flowing=null}function qq(FQ){OQ&&Gq("on readable nextTick, calling read(0)",FQ.__id),FQ.read(0)}rq.prototype.resume=function(){const FQ=this._readableState;if(!FQ.flowing)OQ&&Gq("resume",this.__id),FQ.flowing=!FQ.readableListening,qQ(this,FQ);return FQ.paused=!1,this},rq.prototype.pause=function(){if(OQ&&Gq("call pause flowing=%j",this._readableState.flowing,this.__id),this._readableState.flowing!==!1)OQ&&Gq("pause",this.__id),this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},rq.prototype.wrap=function(FQ){let Kq=!1;FQ.on("data",(Zq)=>{if(!this.push(Zq)&&FQ.pause)Kq=!0,FQ.pause()}),FQ.on("end",()=>{this.push(null)}),FQ.on("error",(Zq)=>{$(this,Zq)}),FQ.on("close",()=>{this.destroy()}),FQ.on("destroy",()=>{this.destroy()}),this._read=()=>{if(Kq&&FQ.resume)Kq=!1,FQ.resume()};const LQ=Q(FQ);for(let Zq=1;Zq{jQ=NQ?JQ(jQ,NQ):null,LQ(),LQ=BQ});try{while(!0){const NQ=FQ.destroyed?null:FQ.read();if(NQ!==null)yield NQ;else if(jQ)throw jQ;else if(jQ===null)return;else await new K(Zq)}}catch(NQ){throw jQ=JQ(jQ,NQ),jQ}finally{if((jQ||(Kq===null||Kq===void 0?void 0:Kq.destroyOnReturn)!==!1)&&(jQ===void 0||FQ._readableState.autoDestroy))n.destroyer(FQ,null);else FQ.off("readable",Zq),Bq()}}J(rq.prototype,{readable:{get(){const FQ=this._readableState;return!!FQ&&FQ.readable!==!1&&!FQ.destroyed&&!FQ.errorEmitted&&!FQ.endEmitted},set(FQ){if(this._readableState)this._readableState.readable=!!FQ}},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(FQ){if(this._readableState)this._readableState.flowing=FQ}},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(FQ){if(!this._readableState)return;this._readableState.destroyed=FQ}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),rq._fromList=WQ;function WQ(FQ,Kq){if(Kq.length===0)return null;let LQ;if(Kq.objectMode)LQ=Kq.buffer.shift();else if(!FQ||FQ>=Kq.length){if(Kq.decoder)LQ=Kq.buffer.join("");else if(Kq.buffer.length===1)LQ=Kq.buffer.first();else LQ=Kq.buffer.concat(Kq.length);Kq.buffer.clear()}else LQ=Kq.buffer.consume(FQ,Kq.decoder);return LQ}function Xq(FQ){const Kq=FQ._readableState;if(OQ&&Gq("endEmitted @ endReadable",Kq.endEmitted,FQ.__id),!Kq.endEmitted)Kq.ended=!0,_Q(GQ,Kq,FQ)}function GQ(FQ,Kq){if(OQ&&Gq("endReadableNT -- endEmitted, state.length",FQ.endEmitted,FQ.length,Kq.__id),!FQ.errored&&!FQ.closeEmitted&&!FQ.endEmitted&&FQ.length===0){if(FQ.endEmitted=!0,Kq.emit("end"),OQ&&Gq("end emitted @ endReadableNT",Kq.__id),Kq.writable&&Kq.allowHalfOpen===!1)_Q(Jq,Kq);else if(FQ.autoDestroy){const LQ=Kq._writableState;if(!LQ||LQ.autoDestroy&&(LQ.finished||LQ.writable===!1))Kq.destroy()}}}function Jq(FQ){if(FQ.writable&&!FQ.writableEnded&&!FQ.destroyed)FQ.end()}rq.from=function(FQ,Kq){return r(rq,FQ,Kq)};var MQ={newStreamReadableFromReadableStream:tq};function Hq(){if(MQ===void 0)MQ={};return MQ}rq.fromWeb=function(FQ,Kq){return Hq().newStreamReadableFromReadableStream(FQ,Kq)},rq.toWeb=function(FQ){return Hq().newReadableStreamFromStreamReadable(FQ)},rq.wrap=function(FQ,Kq){var LQ,Zq;return new rq({objectMode:(LQ=(Zq=FQ.readableObjectMode)!==null&&Zq!==void 0?Zq:FQ.objectMode)!==null&&LQ!==void 0?LQ:!0,...Kq,destroy(jQ,Bq){n.destroyer(FQ,jQ),Bq(jQ)}}).wrap(FQ)}}}),wq=G({"node_modules/readable-stream/lib/internal/streams/writable.js"(B,Y){var{ArrayPrototypeSlice:U,Error:H,FunctionPrototypeSymbolHasInstance:X,ObjectDefineProperty:q,ObjectDefineProperties:J,ObjectSetPrototypeOf:Q,StringPrototypeToLowerCase:Z,Symbol:K,SymbolHasInstance:oq}=DQ(),p=pQ().Stream,sq=Oq(),{addAbortSignal:u}=_q(),{getHighWaterMark:aq,getDefaultHighWaterMark:b}=uQ(),{ERR_INVALID_ARG_TYPE:rq,ERR_METHOD_NOT_IMPLEMENTED:m,ERR_MULTIPLE_CALLBACK:tq,ERR_STREAM_CANNOT_PIPE:c,ERR_STREAM_DESTROYED:eq,ERR_STREAM_ALREADY_FINISHED:d,ERR_STREAM_NULL_VALUES:qQ,ERR_STREAM_WRITE_AFTER_END:l,ERR_UNKNOWN_ENCODING:QQ}=hQ().codes,{errorOrDestroy:i}=sq;function XQ(WQ={}){const Xq=this instanceof wQ();if(!Xq&&!X(XQ,this))return new XQ(WQ);if(this._writableState=new o(WQ,this,Xq),WQ){if(typeof WQ.write==="function")this._write=WQ.write;if(typeof WQ.writev==="function")this._writev=WQ.writev;if(typeof WQ.destroy==="function")this._destroy=WQ.destroy;if(typeof WQ.final==="function")this._final=WQ.final;if(typeof WQ.construct==="function")this._construct=WQ.construct;if(WQ.signal)u(WQ.signal,this)}p.call(this,WQ),sq.construct(this,()=>{const GQ=this._writableState;if(!GQ.writing)z(this,GQ);e(this,GQ)})}Q(XQ.prototype,p.prototype),Q(XQ,p),Y.exports=XQ;function n(){}var JQ=K("kOnFinished");function o(WQ,Xq,GQ){if(typeof GQ!=="boolean")GQ=Xq instanceof wQ();if(this.objectMode=!!(WQ&&WQ.objectMode),GQ)this.objectMode=this.objectMode||!!(WQ&&WQ.writableObjectMode);this.highWaterMark=WQ?aq(this,WQ,"writableHighWaterMark",GQ):b(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const Jq=!!(WQ&&WQ.decodeStrings===!1);this.decodeStrings=!Jq,this.defaultEncoding=WQ&&WQ.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=r.bind(void 0,Xq),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,HQ(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!WQ||WQ.emitClose!==!1,this.autoDestroy=!WQ||WQ.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[JQ]=[]}function HQ(WQ){WQ.buffered=[],WQ.bufferedIndex=0,WQ.allBuffers=!0,WQ.allNoop=!0}o.prototype.getBuffer=function WQ(){return U(this.buffered,this.bufferedIndex)},q(o.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),q(XQ,oq,{value:function(WQ){if(X(this,WQ))return!0;if(this!==XQ)return!1;return WQ&&WQ._writableState instanceof o}}),XQ.prototype.pipe=function(){i(this,new c)};function s(WQ,Xq,GQ,Jq){const MQ=WQ._writableState;if(typeof GQ==="function")Jq=GQ,GQ=MQ.defaultEncoding;else{if(!GQ)GQ=MQ.defaultEncoding;else if(GQ!=="buffer"&&!Buffer.isEncoding(GQ))throw new QQ(GQ);if(typeof Jq!=="function")Jq=n}if(Xq===null)throw new qQ;else if(!MQ.objectMode)if(typeof Xq==="string"){if(MQ.decodeStrings!==!1)Xq=Buffer.from(Xq,GQ),GQ="buffer"}else if(Xq instanceof Buffer)GQ="buffer";else if(p._isUint8Array(Xq))Xq=p._uint8ArrayToBuffer(Xq),GQ="buffer";else throw new rq("chunk",["string","Buffer","Uint8Array"],Xq);let Hq;if(MQ.ending)Hq=new l;else if(MQ.destroyed)Hq=new eq("write");if(Hq)return _Q(Jq,Hq),i(WQ,Hq,!0),Hq;return MQ.pendingcb++,KQ(WQ,MQ,Xq,GQ,Jq)}XQ.prototype.write=function(WQ,Xq,GQ){return s(this,WQ,Xq,GQ)===!0},XQ.prototype.cork=function(){this._writableState.corked++},XQ.prototype.uncork=function(){const WQ=this._writableState;if(WQ.corked){if(WQ.corked--,!WQ.writing)z(this,WQ)}},XQ.prototype.setDefaultEncoding=function WQ(Xq){if(typeof Xq==="string")Xq=Z(Xq);if(!Buffer.isEncoding(Xq))throw new QQ(Xq);return this._writableState.defaultEncoding=Xq,this};function KQ(WQ,Xq,GQ,Jq,MQ){const Hq=Xq.objectMode?1:GQ.length;Xq.length+=Hq;const FQ=Xq.lengthGQ.bufferedIndex)z(WQ,GQ);if(Jq)if(GQ.afterWriteTickInfo!==null&&GQ.afterWriteTickInfo.cb===MQ)GQ.afterWriteTickInfo.count++;else GQ.afterWriteTickInfo={count:1,cb:MQ,stream:WQ,state:GQ},_Q(BQ,GQ.afterWriteTickInfo);else $(WQ,GQ,1,MQ)}}function BQ({stream:WQ,state:Xq,count:GQ,cb:Jq}){return Xq.afterWriteTickInfo=null,$(WQ,Xq,GQ,Jq)}function $(WQ,Xq,GQ,Jq){if(!Xq.ending&&!WQ.destroyed&&Xq.length===0&&Xq.needDrain)Xq.needDrain=!1,WQ.emit("drain");while(GQ-- >0)Xq.pendingcb--,Jq();if(Xq.destroyed)YQ(Xq);e(WQ,Xq)}function YQ(WQ){if(WQ.writing)return;for(let MQ=WQ.bufferedIndex;MQ1&&WQ._writev){Xq.pendingcb-=Hq-1;const Kq=Xq.allNoop?n:(Zq)=>{for(let jQ=FQ;jQ256)GQ.splice(0,FQ),Xq.bufferedIndex=0;else Xq.bufferedIndex=FQ}Xq.bufferProcessing=!1}XQ.prototype._write=function(WQ,Xq,GQ){if(this._writev)this._writev([{chunk:WQ,encoding:Xq}],GQ);else throw new m("_write()")},XQ.prototype._writev=null,XQ.prototype.end=function(WQ,Xq,GQ,Jq=!1){const MQ=this._writableState;if(OQ&&Gq("end",MQ,this.__id),typeof WQ==="function")GQ=WQ,WQ=null,Xq=null;else if(typeof Xq==="function")GQ=Xq,Xq=null;let Hq;if(WQ!==null&&WQ!==void 0){let FQ;if(!Jq)FQ=s(this,WQ,Xq);else FQ=this.write(WQ,Xq);if(FQ instanceof H)Hq=FQ}if(MQ.corked)MQ.corked=1,this.uncork();if(Hq)this.emit("error",Hq);else if(!MQ.errored&&!MQ.ending)MQ.ending=!0,e(this,MQ,!0),MQ.ended=!0;else if(MQ.finished)Hq=new d("end");else if(MQ.destroyed)Hq=new eq("end");if(typeof GQ==="function")if(Hq||MQ.finished)_Q(GQ,Hq);else MQ[JQ].push(GQ);return this};function $Q(WQ,Xq){var GQ=WQ.ending&&!WQ.destroyed&&WQ.constructed&&WQ.length===0&&!WQ.errored&&WQ.buffered.length===0&&!WQ.finished&&!WQ.writing&&!WQ.errorEmitted&&!WQ.closeEmitted;return Gq("needFinish",GQ,Xq),GQ}function t(WQ,Xq){let GQ=!1;function Jq(MQ){if(GQ){i(WQ,MQ!==null&&MQ!==void 0?MQ:tq());return}if(GQ=!0,Xq.pendingcb--,MQ){const Hq=Xq[JQ].splice(0);for(let FQ=0;FQ{if($Q(MQ))VQ(Jq,MQ);else MQ.pendingcb--},WQ,Xq);else if($Q(Xq))Xq.pendingcb++,VQ(WQ,Xq)}}function VQ(WQ,Xq){Xq.pendingcb--,Xq.finished=!0;const GQ=Xq[JQ].splice(0);for(let Jq=0;Jq{if(ZQ!=null)throw new sq("nully","body",ZQ)},(ZQ)=>{u(KQ,ZQ)});return KQ=new eq({objectMode:!0,readable:!1,write:JQ,final(ZQ){o(async()=>{try{await a,_Q(ZQ,null)}catch(r){_Q(ZQ,r)}})},destroy:HQ})}throw new sq("Iterable, AsyncIterable or AsyncFunction",i,n)}if(tq(QQ))return l(QQ.arrayBuffer());if(X(QQ))return m(eq,QQ,{objectMode:!0,writable:!1});if(typeof(QQ===null||QQ===void 0?void 0:QQ.writable)==="object"||typeof(QQ===null||QQ===void 0?void 0:QQ.readable)==="object"){const n=QQ!==null&&QQ!==void 0&&QQ.readable?J(QQ===null||QQ===void 0?void 0:QQ.readable)?QQ===null||QQ===void 0?void 0:QQ.readable:l(QQ.readable):void 0,JQ=QQ!==null&&QQ!==void 0&&QQ.writable?Q(QQ===null||QQ===void 0?void 0:QQ.writable)?QQ===null||QQ===void 0?void 0:QQ.writable:l(QQ.writable):void 0;return qQ({readable:n,writable:JQ})}const XQ=QQ===null||QQ===void 0?void 0:QQ.then;if(typeof XQ==="function"){let n;return c(XQ,QQ,(JQ)=>{if(JQ!=null)n.push(JQ);n.push(null)},(JQ)=>{u(n,JQ)}),n=new eq({objectMode:!0,writable:!1,read(){}})}throw new p(i,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],QQ)};function d(l){let{promise:QQ,resolve:i}=rq();const XQ=new AbortController,n=XQ.signal;return{value:l(async function*(){while(!0){const o=QQ;QQ=null;const{chunk:HQ,done:s,cb:KQ}=await o;if(_Q(KQ),s)return;if(n.aborted)throw new oq(void 0,{cause:n.reason});({promise:QQ,resolve:i}=rq()),yield HQ}}(),{signal:n}),write(o,HQ,s){const KQ=i;i=null,KQ({chunk:o,done:!1,cb:s})},final(o){const HQ=i;i=null,HQ({done:!0,cb:o})},destroy(o,HQ){XQ.abort(),HQ(o)}}}function qQ(l){const QQ=l.readable&&typeof l.readable.read!=="function"?b.wrap(l.readable):l.readable,i=l.writable;let XQ=!!U(QQ),n=!!H(i),JQ,o,HQ,s,KQ;function a(ZQ){const r=s;if(s=null,r)r(ZQ);else if(ZQ)KQ.destroy(ZQ);else if(!XQ&&!n)KQ.destroy()}if(KQ=new eq({readableObjectMode:!!(QQ!==null&&QQ!==void 0&&QQ.readableObjectMode),writableObjectMode:!!(i!==null&&i!==void 0&&i.writableObjectMode),readable:XQ,writable:n}),n)K(i,(ZQ)=>{if(n=!1,ZQ)u(QQ,ZQ);a(ZQ)}),KQ._write=function(ZQ,r,BQ){if(i.write(ZQ,r))BQ();else JQ=BQ},KQ._final=function(ZQ){i.end(),o=ZQ},i.on("drain",function(){if(JQ){const ZQ=JQ;JQ=null,ZQ()}}),i.on("finish",function(){if(o){const ZQ=o;o=null,ZQ()}});if(XQ)K(QQ,(ZQ)=>{if(XQ=!1,ZQ)u(QQ,ZQ);a(ZQ)}),QQ.on("readable",function(){if(HQ){const ZQ=HQ;HQ=null,ZQ()}}),QQ.on("end",function(){KQ.push(null)}),KQ._read=function(){while(!0){const ZQ=QQ.read();if(ZQ===null){HQ=KQ._read;return}if(!KQ.push(ZQ))return}};return KQ._destroy=function(ZQ,r){if(!ZQ&&s!==null)ZQ=new oq;if(HQ=null,JQ=null,o=null,s===null)r(ZQ);else s=r,u(i,ZQ),u(QQ,ZQ)},KQ}}}),wQ=G({"node_modules/readable-stream/lib/internal/streams/duplex.js"(B,Y){var{ObjectDefineProperties:U,ObjectGetOwnPropertyDescriptor:H,ObjectKeys:X,ObjectSetPrototypeOf:q}=DQ(),J=mQ();function Q(sq){if(!(this instanceof Q))return new Q(sq);if(J.call(this,sq),Mq.call(this,sq),sq){if(this.allowHalfOpen=sq.allowHalfOpen!==!1,sq.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(sq.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}Y.exports=Q,q(Q.prototype,J.prototype),q(Q,J);for(var Z in Mq.prototype)if(!Q.prototype[Z])Q.prototype[Z]=Mq.prototype[Z];U(Q.prototype,{writable:H(Mq.prototype,"writable"),writableHighWaterMark:H(Mq.prototype,"writableHighWaterMark"),writableObjectMode:H(Mq.prototype,"writableObjectMode"),writableBuffer:H(Mq.prototype,"writableBuffer"),writableLength:H(Mq.prototype,"writableLength"),writableFinished:H(Mq.prototype,"writableFinished"),writableCorked:H(Mq.prototype,"writableCorked"),writableEnded:H(Mq.prototype,"writableEnded"),writableNeedDrain:H(Mq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(sq){if(this._readableState&&this._writableState)this._readableState.destroyed=sq,this._writableState.destroyed=sq}}});var K;function oq(){if(K===void 0)K={};return K}Q.fromWeb=function(sq,u){return oq().newStreamDuplexFromReadableWritablePair(sq,u)},Q.toWeb=function(sq){return oq().newReadableWritablePairFromDuplex(sq)};var p;Q.from=function(sq){if(!p)p=cQ();return p(sq,"body")}}}),vq=G({"node_modules/readable-stream/lib/internal/streams/transform.js"(B,Y){var{ObjectSetPrototypeOf:U,Symbol:H}=DQ(),{ERR_METHOD_NOT_IMPLEMENTED:X}=hQ().codes,q=wQ();function J(oq){if(!(this instanceof J))return new J(oq);if(q.call(this,oq),this._readableState.sync=!1,this[Q]=null,oq){if(typeof oq.transform==="function")this._transform=oq.transform;if(typeof oq.flush==="function")this._flush=oq.flush}this.on("prefinish",K.bind(this))}U(J.prototype,q.prototype),U(J,q),Y.exports=J;var Q=H("kCallback");function Z(oq){if(typeof this._flush==="function"&&!this.destroyed)this._flush((p,sq)=>{if(p){if(oq)oq(p);else this.destroy(p);return}if(sq!=null)this.push(sq);if(this.push(null),oq)oq()});else if(this.push(null),oq)oq()}function K(){if(this._final!==Z)Z.call(this)}J.prototype._final=Z,J.prototype._transform=function(oq,p,sq){throw new X("_transform()")},J.prototype._write=function(oq,p,sq){const u=this._readableState,aq=this._writableState,b=u.length;this._transform(oq,p,(rq,m)=>{if(rq){sq(rq);return}if(m!=null)this.push(m);if(aq.ended||b===u.length||u.length{ZQ=!0});const r=q(s,{readable:KQ,writable:a},(BQ)=>{ZQ=!BQ});return{destroy:(BQ)=>{if(ZQ)return;ZQ=!0,Q.destroyer(s,BQ||new u("pipe"))},cleanup:r}}function QQ(s){return b(s[s.length-1],"streams[stream.length - 1]"),s.pop()}function i(s){if(m(s))return s;else if(c(s))return XQ(s);throw new oq("val",["Readable","Iterable","AsyncIterable"],s)}async function*XQ(s){if(!qQ)qQ=mQ();yield*qQ.prototype[X].call(s)}async function n(s,KQ,a,{end:ZQ}){let r,BQ=null;const $=($Q)=>{if($Q)r=$Q;if(BQ){const t=BQ;BQ=null,t()}},YQ=()=>new H(($Q,t)=>{if(r)t(r);else BQ=()=>{if(r)t(r);else $Q()}});KQ.on("drain",$);const z=q(KQ,{readable:!1},$);try{if(KQ.writableNeedDrain)await YQ();for await(let $Q of s)if(!KQ.write($Q))await YQ();if(ZQ)KQ.end();await YQ(),a()}catch($Q){a(r!==$Q?K(r,$Q):$Q)}finally{z(),KQ.off("drain",$)}}function JQ(...s){return o(s,J(QQ(s)))}function o(s,KQ,a){if(s.length===1&&U(s[0]))s=s[0];if(s.length<2)throw new sq("streams");const ZQ=new AbortController,r=ZQ.signal,BQ=a===null||a===void 0?void 0:a.signal,$=[];rq(BQ,"options.signal");function YQ(){VQ(new aq)}BQ===null||BQ===void 0||BQ.addEventListener("abort",YQ);let z,$Q;const t=[];let zQ=0;function e(Qq){VQ(Qq,--zQ===0)}function VQ(Qq,WQ){if(Qq&&(!z||z.code==="ERR_STREAM_PREMATURE_CLOSE"))z=Qq;if(!z&&!WQ)return;while(t.length)t.shift()(z);if(BQ===null||BQ===void 0||BQ.removeEventListener("abort",YQ),ZQ.abort(),WQ){if(!z)$.forEach((Xq)=>Xq());_Q(KQ,z,$Q)}}let qq;for(let Qq=0;Qq0,Jq=Xq||(a===null||a===void 0?void 0:a.end)!==!1,MQ=Qq===s.length-1;if(eq(WQ)){let Hq=function(FQ){if(FQ&&FQ.name!=="AbortError"&&FQ.code!=="ERR_STREAM_PREMATURE_CLOSE")e(FQ)};if(Jq){const{destroy:FQ,cleanup:Kq}=l(WQ,Xq,GQ);if(t.push(FQ),tq(WQ)&&MQ)$.push(Kq)}if(WQ.on("error",Hq),tq(WQ)&&MQ)$.push(()=>{WQ.removeListener("error",Hq)})}if(Qq===0)if(typeof WQ==="function"){if(qq=WQ({signal:r}),!m(qq))throw new p("Iterable, AsyncIterable or Stream","source",qq)}else if(m(WQ)||c(WQ))qq=WQ;else qq=Z.from(WQ);else if(typeof WQ==="function")if(qq=i(qq),qq=WQ(qq,{signal:r}),Xq){if(!m(qq,!0))throw new p("AsyncIterable",`transform[${Qq-1}]`,qq)}else{var UQ;if(!d)d=dQ();const Hq=new d({objectMode:!0}),FQ=(UQ=qq)===null||UQ===void 0?void 0:UQ.then;if(typeof FQ==="function")zQ++,FQ.call(qq,(Zq)=>{if($Q=Zq,Zq!=null)Hq.write(Zq);if(Jq)Hq.end();_Q(e)},(Zq)=>{Hq.destroy(Zq),_Q(e,Zq)});else if(m(qq,!0))zQ++,n(qq,Hq,e,{end:Jq});else throw new p("AsyncIterable or Promise","destination",qq);qq=Hq;const{destroy:Kq,cleanup:LQ}=l(qq,!1,!0);if(t.push(Kq),MQ)$.push(LQ)}else if(eq(WQ)){if(c(qq)){zQ+=2;const Hq=HQ(qq,WQ,e,{end:Jq});if(tq(WQ)&&MQ)$.push(Hq)}else if(m(qq))zQ++,n(qq,WQ,e,{end:Jq});else throw new oq("val",["Readable","Iterable","AsyncIterable"],qq);qq=WQ}else qq=Z.from(WQ)}if(r!==null&&r!==void 0&&r.aborted||BQ!==null&&BQ!==void 0&&BQ.aborted)_Q(YQ);return qq}function HQ(s,KQ,a,{end:ZQ}){if(s.pipe(KQ,{end:ZQ}),ZQ)s.once("end",()=>KQ.end());else a();return q(s,{readable:!0,writable:!1},(r)=>{const BQ=s._readableState;if(r&&r.code==="ERR_STREAM_PREMATURE_CLOSE"&&BQ&&BQ.ended&&!BQ.errored&&!BQ.errorEmitted)s.once("end",a).once("error",a);else a(r)}),q(KQ,{readable:!1,writable:!0},a)}Y.exports={pipelineImpl:o,pipeline:JQ}}}),lQ=G({"node_modules/readable-stream/lib/internal/streams/compose.js"(B,Y){var{pipeline:U}=Rq(),H=wQ(),{destroyer:X}=Oq(),{isNodeStream:q,isReadable:J,isWritable:Q}=j(),{AbortError:Z,codes:{ERR_INVALID_ARG_VALUE:K,ERR_MISSING_ARGS:oq}}=hQ();Y.exports=function p(...sq){if(sq.length===0)throw new oq("streams");if(sq.length===1)return H.from(sq[0]);const u=[...sq];if(typeof sq[0]==="function")sq[0]=H.from(sq[0]);if(typeof sq[sq.length-1]==="function"){const QQ=sq.length-1;sq[QQ]=H.from(sq[QQ])}for(let QQ=0;QQ0&&!Q(sq[QQ]))throw new K(`streams[${QQ}]`,u[QQ],"must be writable")}let aq,b,rq,m,tq;function c(QQ){const i=m;if(m=null,i)i(QQ);else if(QQ)tq.destroy(QQ);else if(!l&&!qQ)tq.destroy()}const eq=sq[0],d=U(sq,c),qQ=!!Q(eq),l=!!J(d);if(tq=new H({writableObjectMode:!!(eq!==null&&eq!==void 0&&eq.writableObjectMode),readableObjectMode:!!(d!==null&&d!==void 0&&d.writableObjectMode),writable:qQ,readable:l}),qQ)tq._write=function(QQ,i,XQ){if(eq.write(QQ,i))XQ();else aq=XQ},tq._final=function(QQ){eq.end(),b=QQ},eq.on("drain",function(){if(aq){const QQ=aq;aq=null,QQ()}}),d.on("finish",function(){if(b){const QQ=b;b=null,QQ()}});if(l)d.on("readable",function(){if(rq){const QQ=rq;rq=null,QQ()}}),d.on("end",function(){tq.push(null)}),tq._read=function(){while(!0){const QQ=d.read();if(QQ===null){rq=tq._read;return}if(!tq.push(QQ))return}};return tq._destroy=function(QQ,i){if(!QQ&&m!==null)QQ=new Z;if(rq=null,aq=null,b=null,m===null)i(QQ);else m=i,X(d,QQ)},tq}}}),E=G({"node_modules/readable-stream/lib/stream/promises.js"(B,Y){var{ArrayPrototypePop:U,Promise:H}=DQ(),{isIterable:X,isNodeStream:q}=j(),{pipelineImpl:J}=Rq(),{finished:Q}=N();function Z(...K){return new H((oq,p)=>{let sq,u;const aq=K[K.length-1];if(aq&&typeof aq==="object"&&!q(aq)&&!X(aq)){const b=U(K);sq=b.signal,u=b.end}J(K,(b,rq)=>{if(b)p(b);else oq(rq)},{signal:sq,end:u})})}Y.exports={finished:Q,pipeline:Z}}}),I=G({"node_modules/readable-stream/lib/stream.js"(B,Y){var{ObjectDefineProperty:U,ObjectKeys:H,ReflectApply:X}=DQ(),{promisify:{custom:q}}=jq(),{streamReturningOperators:J,promiseReturningOperators:Q}=A(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:Z}}=hQ(),K=lQ(),{pipeline:oq}=Rq(),{destroyer:p}=Oq(),sq=N(),u=E(),aq=j(),b=Y.exports=pQ().Stream;b.isDisturbed=aq.isDisturbed,b.isErrored=aq.isErrored,b.isWritable=aq.isWritable,b.isReadable=aq.isReadable,b.Readable=mQ();for(let m of H(J)){let tq=function(...eq){if(new.target)throw Z();return b.Readable.from(X(c,this,eq))};const c=J[m];U(tq,"name",{value:c.name}),U(tq,"length",{value:c.length}),U(b.Readable.prototype,m,{value:tq,enumerable:!1,configurable:!0,writable:!0})}for(let m of H(Q)){let tq=function(...eq){if(new.target)throw Z();return X(c,this,eq)};const c=Q[m];U(tq,"name",{value:c.name}),U(tq,"length",{value:c.length}),U(b.Readable.prototype,m,{value:tq,enumerable:!1,configurable:!0,writable:!0})}b.Writable=wq(),b.Duplex=wQ(),b.Transform=vq(),b.PassThrough=dQ(),b.pipeline=oq;var{addAbortSignal:rq}=_q();b.addAbortSignal=rq,b.finished=sq,b.destroy=p,b.compose=K,U(b,"promises",{configurable:!0,enumerable:!0,get(){return u}}),U(oq,q,{enumerable:!0,get(){return u.pipeline}}),U(sq,q,{enumerable:!0,get(){return u.finished}}),b.Stream=b,b._isUint8Array=function m(tq){return tq instanceof Uint8Array},b._uint8ArrayToBuffer=function m(tq){return new Buffer(tq.buffer,tq.byteOffset,tq.byteLength)}}}),T=G({"node_modules/readable-stream/lib/ours/index.js"(B,Y){const U=I(),H=E(),X=U.Readable.destroy;Y.exports=U,Y.exports._uint8ArrayToBuffer=U._uint8ArrayToBuffer,Y.exports._isUint8Array=U._isUint8Array,Y.exports.isDisturbed=U.isDisturbed,Y.exports.isErrored=U.isErrored,Y.exports.isWritable=U.isWritable,Y.exports.isReadable=U.isReadable,Y.exports.Readable=U.Readable,Y.exports.Writable=U.Writable,Y.exports.Duplex=U.Duplex,Y.exports.Transform=U.Transform,Y.exports.PassThrough=U.PassThrough,Y.exports.addAbortSignal=U.addAbortSignal,Y.exports.finished=U.finished,Y.exports.destroy=U.destroy,Y.exports.destroy=X,Y.exports.pipeline=U.pipeline,Y.exports.compose=U.compose,Y.exports._getNativeReadableStreamPrototype=O,Y.exports.NativeWritable=bq,Fq.defineProperty(U,"promises",{configurable:!0,enumerable:!0,get(){return H}}),Y.exports.Stream=U.Stream,Y.exports.default=Y.exports}}),x={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Mq=wq(),bq=class B extends Mq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(Y,U={}){super(U);this._construct=this.#J,this._destroy=this.#K,this._final=this.#Z,this.#q=Y}#J(Y){this._writableState.constructed=!0,this.constructed=!0,Y()}#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(Y,U,H,X=this.#X){if(!X)return this.#X=!1,super.write(Y,U,H);if(!this.#Q)this.#H();var q=this.#Q,J=q.write(Y);if(Lq(J))return J.then(()=>{this.emit("drain"),q.flush(!0)}),!1;if(q.flush(!0),H)H(null,Y.byteLength);return!0}end(Y,U,H,X=this.#X){return super.end(Y,U,H,X)}#K(Y,U){if(this._writableState.destroyed=!0,U)U(Y)}#Z(Y){if(this.#Q)this.#Q.end();if(Y)Y()}ref(){if(!this.#Q)this.#H();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},C=T();C[Symbol.for("CommonJS")]=0;C[Symbol.for("::bunternal::")]={_ReadableFromWeb:bQ,_ReadableFromWebForUndici:Dq};var nq=C,D=C._uint8ArrayToBuffer,w=C._isUint8Array,v=C.isDisturbed,R=C.isErrored,S=C.isWritable,g=C.isReadable,f=C.Readable,Mq=C.Writable,k=C.Duplex,y=C.Transform,h=C.PassThrough,Sq=C.addAbortSignal,gq=C.finished,fq=C.destroy,kq=C.pipeline,yq=C.compose,hq=C.Stream,pq=C["eos"]=N,uq=C._getNativeReadableStreamPrototype,bq=C.NativeWritable,mq=hq.promises;export{mq as promises,kq as pipeline,S as isWritable,g as isReadable,R as isErrored,v as isDisturbed,gq as finished,pq as eos,fq as destroy,nq as default,yq as compose,Sq as addAbortSignal,D as _uint8ArrayToBuffer,w as _isUint8Array,uq as _getNativeReadableStreamPrototype,Mq as Writable,y as Transform,hq as Stream,f as Readable,h as PassThrough,bq as NativeWritable,k as Duplex}; diff --git a/src/js/out/modules/node/util.js b/src/js/out/modules/node/util.js index b0881147c..8fbdc2d6c 100644 --- a/src/js/out/modules/node/util.js +++ b/src/js/out/modules/node/util.js @@ -44,21 +44,23 @@ var isFunction = function(value) { }, deprecate = function(fn, msg, code) { if (process.noDeprecation === !0) return fn; - 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; + var warned = !1; + function deprecated() { + if (!warned) { + 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); + warned = !0; + } + return fn.apply(this, arguments); + } + return deprecated; }, debuglog = function(set) { if (set = set.toUpperCase(), !debugs[set]) if (debugEnvRegex.test(set)) { diff --git a/test/js/bun/resolve/import-meta.test.js b/test/js/bun/resolve/import-meta.test.js index 7d385148b..d6d145520 100644 --- a/test/js/bun/resolve/import-meta.test.js +++ b/test/js/bun/resolve/import-meta.test.js @@ -25,9 +25,14 @@ it("import.meta.main", () => { it("import.meta.resolveSync", () => { expect(import.meta.resolveSync("./" + import.meta.file, import.meta.path)).toBe(path); +}); + +it("Module.createRequire", () => { const require = Module.createRequire(import.meta.path); expect(require.resolve(import.meta.path)).toBe(path); expect(require.resolve("./" + import.meta.file)).toBe(path); + const { resolve } = require; + expect(resolve("./" + import.meta.file)).toBe(path); // check it works with URL objects expect(Module.createRequire(new URL(import.meta.url)).resolve(import.meta.path)).toBe(import.meta.path); @@ -68,8 +73,11 @@ it("import.meta.require (json)", () => { }); it("const f = require;require(json)", () => { + function capture(f) { + return f.length; + } const f = require; - console.log(f); + capture(f); expect(f("./require-json.json").hello).toBe(sync.hello); }); @@ -107,7 +115,6 @@ it("Module.createRequire(file://url).resolve(file://url)", () => { const createdRequire = Module.createRequire(import.meta.url); const result1 = createdRequire.resolve("./require-json.json"); const result2 = createdRequire.resolve("file://./require-json.json"); - expect(result1).toBe(expected); expect(result2).toBe(expected); }); -- cgit v1.2.3 From ec3ed67bc9ad8cbb0e59234564d57265d5423fce Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Mon, 26 Jun 2023 08:12:37 -0700 Subject: implement `_nodeModulePaths` and `require.main.paths` (#3411) * tests in progress * add `require.main.paths`, add every dir up to root * remove imports --- src/bun.js/bindings/CommonJSModuleRecord.cpp | 31 +++++++++ src/bun.js/bindings/CommonJSModuleRecord.h | 1 + src/bun.js/modules/NodeModuleModule.cpp | 15 ++-- src/resolver/resolver.zig | 95 ++++++++++++++++++++++++++ test/js/node/module/node-module-module.test.js | 19 ++++++ 5 files changed, 150 insertions(+), 11 deletions(-) diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index 8d4fe0a1e..3615db774 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -295,6 +295,35 @@ JSC_DEFINE_CUSTOM_SETTER(setterPath, return true; } +extern "C" EncodedJSValue Resolver__propForRequireMainPaths(JSGlobalObject*); + +JSC_DEFINE_CUSTOM_GETTER(getterPaths, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (UNLIKELY(!thisObject)) { + return JSValue::encode(jsUndefined()); + } + + if (!thisObject->m_paths) { + JSValue paths = JSValue::decode(Resolver__propForRequireMainPaths(globalObject)); + thisObject->m_paths.set(globalObject->vm(), thisObject, paths); + } + + return JSValue::encode(thisObject->m_paths.get()); +} + +JSC_DEFINE_CUSTOM_SETTER(setterPaths, + (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue value, JSC::PropertyName propertyName)) +{ + JSCommonJSModule* thisObject = jsDynamicCast(JSValue::decode(thisValue)); + if (!thisObject) + return false; + + thisObject->m_paths.set(globalObject->vm(), thisObject, JSValue::decode(value)); + return true; +} + JSC_DEFINE_CUSTOM_SETTER(setterFilename, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName propertyName)) @@ -340,6 +369,7 @@ static const struct HashTableValue JSCommonJSModulePrototypeTableValues[] = { { "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 } }, + { "paths"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, getterPaths, setterPaths } }, }; class JSCommonJSModulePrototype final : public JSC::JSNonFinalObject { @@ -675,6 +705,7 @@ void JSCommonJSModule::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(thisObject->sourceCode); visitor.append(thisObject->m_filename); visitor.append(thisObject->m_dirname); + visitor.append(thisObject->m_paths); } DEFINE_VISIT_CHILDREN(JSCommonJSModule); diff --git a/src/bun.js/bindings/CommonJSModuleRecord.h b/src/bun.js/bindings/CommonJSModuleRecord.h index 48f14b39c..a96ab5f75 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.h +++ b/src/bun.js/bindings/CommonJSModuleRecord.h @@ -24,6 +24,7 @@ public: mutable JSC::WriteBarrier m_id; mutable JSC::WriteBarrier m_filename; mutable JSC::WriteBarrier m_dirname; + mutable JSC::WriteBarrier m_paths; mutable JSC::WriteBarrier sourceCode; static void destroy(JSC::JSCell*); diff --git a/src/bun.js/modules/NodeModuleModule.cpp b/src/bun.js/modules/NodeModuleModule.cpp index 8b278ddd8..34d45698f 100644 --- a/src/bun.js/modules/NodeModuleModule.cpp +++ b/src/bun.js/modules/NodeModuleModule.cpp @@ -26,15 +26,8 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModuleCreateRequire, scope, JSValue::encode(Zig::ImportMetaObject::createRequireFunction( vm, globalObject, val))); } -JSC_DEFINE_HOST_FUNCTION(jsFunctionNodeModulePaths, - (JSC::JSGlobalObject * globalObject, - JSC::CallFrame *callFrame)) { - return JSC::JSValue::encode(JSC::JSArray::create( - globalObject->vm(), - globalObject->arrayStructureForIndexingTypeDuringAllocation( - ArrayWithContiguous), - 0)); -} +extern "C" EncodedJSValue Resolver__nodeModulePathsForJS(JSGlobalObject *, + CallFrame *); JSC_DEFINE_HOST_FUNCTION(jsFunctionFindSourceMap, (JSGlobalObject * globalObject, @@ -114,7 +107,7 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, vm, globalObject, 1, String("createRequire"_s), jsFunctionNodeModuleCreateRequire, ImplementationVisibility::Public)); exportValues.append(JSFunction::create(vm, globalObject, 1, String("paths"_s), - jsFunctionNodeModulePaths, + Resolver__nodeModulePathsForJS, ImplementationVisibility::Public)); exportValues.append(JSFunction::create( vm, globalObject, 1, String("findSourceMap"_s), jsFunctionFindSourceMap, @@ -143,7 +136,7 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, exportNames.append(JSC::Identifier::fromString(vm, "_nodeModulePaths"_s)); exportValues.append(JSFunction::create( vm, globalObject, 0, String("_nodeModulePaths"_s), - jsFunctionNodeModulePaths, ImplementationVisibility::Public)); + Resolver__nodeModulePathsForJS, ImplementationVisibility::Public)); exportNames.append(JSC::Identifier::fromString(vm, "_cache"_s)); exportValues.append( diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 14bc358d0..40b106f3a 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -94,6 +94,7 @@ const bufs = struct { threadlocal var remap_path_trailing_slash: [bun.MAX_PATH_BYTES]u8 = undefined; threadlocal var path_in_global_disk_cache: [bun.MAX_PATH_BYTES]u8 = undefined; threadlocal var abs_to_rel: [bun.MAX_PATH_BYTES]u8 = undefined; + threadlocal var node_modules_paths_buf: [bun.MAX_PATH_BYTES]u8 = undefined; pub inline fn bufs(comptime field: std.meta.DeclEnum(@This())) *@TypeOf(@field(@This(), @tagName(field))) { return &@field(@This(), @tagName(field)); @@ -3107,6 +3108,93 @@ pub const Resolver = struct { }; } + pub export fn Resolver__nodeModulePathsForJS(globalThis: *bun.JSC.JSGlobalObject, callframe: *bun.JSC.CallFrame) callconv(.C) bun.JSC.JSValue { + bun.JSC.markBinding(@src()); + const argument: bun.JSC.JSValue = callframe.argument(0); + + if (argument.isEmpty() or !argument.isString()) { + globalThis.throwInvalidArgumentType("nodeModulePaths", "path", "string"); + return .zero; + } + + const in_str = argument.toBunString(globalThis); + var r = &globalThis.bunVM().bundler.resolver; + return nodeModulePathsJSValue(r, in_str, globalThis); + } + + pub export fn Resolver__propForRequireMainPaths(globalThis: *bun.JSC.JSGlobalObject) callconv(.C) bun.JSC.JSValue { + bun.JSC.markBinding(@src()); + + const in_str = bun.String.create("."); + var r = &globalThis.bunVM().bundler.resolver; + return nodeModulePathsJSValue(r, in_str, globalThis); + } + + pub fn nodeModulePathsJSValue( + r: *ThisResolver, + in_str: bun.String, + globalObject: *bun.JSC.JSGlobalObject, + ) bun.JSC.JSValue { + var list = std.ArrayList(bun.String).init(bun.default_allocator); + defer list.deinit(); + + const sliced = in_str.toUTF8(bun.default_allocator); + defer sliced.deinit(); + + const str = brk: { + if (std.fs.path.isAbsolute(sliced.slice())) break :brk sliced.slice(); + var dir_path_buf = bufs(.node_modules_paths_buf); + break :brk r.fs.joinBuf(&[_]string{ r.fs.top_level_dir, sliced.slice() }, dir_path_buf); + }; + var arena = std.heap.ArenaAllocator.init(bun.default_allocator); + defer arena.deinit(); + var stack_fallback_allocator = std.heap.stackFallback(1024, arena.allocator()); + + if (r.readDirInfo(strings.withoutTrailingSlash(str)) catch null) |result| { + var dir_info = result; + + while (true) { + const path_without_trailing_slash = strings.withoutTrailingSlash(dir_info.abs_path); + const path_parts = brk: { + if (path_without_trailing_slash.len == 1 and path_without_trailing_slash[0] == '/') { + break :brk [2]string{ "", "/node_modules" }; + } + + break :brk [2]string{ path_without_trailing_slash, "/node_modules" }; + }; + list.append( + bun.String.create( + bun.strings.concat(stack_fallback_allocator.get(), &path_parts) catch unreachable, + ), + ) catch unreachable; + dir_info = (r.readDirInfo(std.fs.path.dirname(path_without_trailing_slash) orelse break) catch null) orelse break; + } + } else { + // does not exist + const full_path = std.fs.path.resolve(r.allocator, &[1][]const u8{str}) catch unreachable; + var path = full_path; + while (true) { + const path_without_trailing_slash = strings.withoutTrailingSlash(path); + + list.append( + bun.String.create( + bun.strings.concat( + stack_fallback_allocator.get(), + &[_]string{ + path_without_trailing_slash, + "/node_modules", + }, + ) catch unreachable, + ), + ) catch unreachable; + + path = path[0 .. strings.lastIndexOfChar(path, '/') orelse break]; + } + } + + return bun.String.toJSArray(globalObject, list.items); + } + pub fn loadAsIndex(r: *ThisResolver, dir_info: *DirInfo, extension_order: []const string) ?MatchResult { var rfs = &r.fs.fs; // Try the "index" file with extensions @@ -3892,3 +3980,10 @@ pub const GlobalCache = enum { }; } }; + +comptime { + if (!bun.JSC.is_bindgen) { + _ = Resolver.Resolver__nodeModulePathsForJS; + _ = Resolver.Resolver__propForRequireMainPaths; + } +} diff --git a/test/js/node/module/node-module-module.test.js b/test/js/node/module/node-module-module.test.js index 549b5e085..3ced63da1 100644 --- a/test/js/node/module/node-module-module.test.js +++ b/test/js/node/module/node-module-module.test.js @@ -1,5 +1,24 @@ import { expect, test } from "bun:test"; +import { _nodeModulePaths } from "module"; test("module.globalPaths exists", () => { expect(Array.isArray(require("module").globalPaths)).toBe(true); }); + +test("_nodeModulePaths() works", () => { + expect(() => { + _nodeModulePaths(); + }).toThrow(); + expect(_nodeModulePaths(".").length).toBeGreaterThan(0); + expect(_nodeModulePaths(".").pop()).toBe("/node_modules"); + expect(_nodeModulePaths("")).toEqual(_nodeModulePaths(".")); + expect(_nodeModulePaths("/")).toEqual(["/node_modules"]); + expect(_nodeModulePaths("/a/b/c/d")).toEqual([ + "/a/b/c/d/node_modules", + "/a/b/c/node_modules", + "/a/b/node_modules", + "/a/node_modules", + "/node_modules", + ]); + expect(_nodeModulePaths("/a/b/../d")).toEqual(["/a/d/node_modules", "/a/node_modules", "/node_modules"]); +}); -- cgit v1.2.3 From 318879d1741035a01fc383821aea7a5ae972b40e Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 26 Jun 2023 21:55:26 +0300 Subject: [install] support trustedDependencies (#3288) * [install] support trustedDependencies closes #2073 * use `strings.indexOfChar()` * use hashes instead of strings * utilise `inline else` --- src/install/bin.zig | 2 +- src/install/extract_tarball.zig | 137 +++++++---------- src/install/install.zig | 284 ++++++++++++++++++----------------- src/install/integrity.zig | 2 +- src/install/lockfile.zig | 77 +++++++--- src/install/npm.zig | 8 +- src/install/repository.zig | 2 +- src/logger.zig | 15 +- test/cli/install/bun-install.test.ts | 74 ++++++++- 9 files changed, 342 insertions(+), 259 deletions(-) diff --git a/src/install/bin.zig b/src/install/bin.zig index b0e988269..f8117c1e8 100644 --- a/src/install/bin.zig +++ b/src/install/bin.zig @@ -281,7 +281,7 @@ pub const Bin = extern struct { if (name[0] != '@') return name; var name_ = name; name_ = name[1..]; - return name_[(std.mem.indexOfScalar(u8, name_, '/') orelse return name) + 1 ..]; + return name_[(strings.indexOfChar(name_, '/') orelse return name) + 1 ..]; } fn setPermissions(folder: std.os.fd_t, target: [:0]const u8) void { diff --git a/src/install/extract_tarball.zig b/src/install/extract_tarball.zig index 0e5f8e188..3be00853f 100644 --- a/src/install/extract_tarball.zig +++ b/src/install/extract_tarball.zig @@ -157,13 +157,14 @@ fn extract(this: *const ExtractTarball, tgz_bytes: []const u8) !Install.ExtractD var tmpdir = this.temp_dir; var tmpname_buf: [256]u8 = undefined; const name = this.name.slice(); - - var basename = this.name.slice(); - if (basename[0] == '@') { - if (std.mem.indexOfScalar(u8, basename, '/')) |i| { - basename = basename[i + 1 ..]; + const basename = brk: { + if (name[0] == '@') { + if (strings.indexOfChar(name, '/')) |i| { + break :brk name[i + 1 ..]; + } } - } + break :brk name; + }; var resolved: string = ""; var tmpname = try FileSystem.instance.tmpname(basename[0..@min(basename.len, 32)], &tmpname_buf, tgz_bytes.len); @@ -216,8 +217,8 @@ fn extract(this: *const ExtractTarball, tgz_bytes: []const u8) !Install.ExtractD }; var dirname_reader = DirnameReader{ .outdirname = &resolved }; - _ = if (PackageManager.verbose_install) - try Archive.extractToDir( + switch (PackageManager.verbose_install) { + inline else => |log| _ = try Archive.extractToDir( zlib_pool.data.list.items, extract_destination, null, @@ -226,20 +227,9 @@ fn extract(this: *const ExtractTarball, tgz_bytes: []const u8) !Install.ExtractD // for GitHub tarballs, the root dir is always -- 1, true, - true, - ) - else - try Archive.extractToDir( - zlib_pool.data.list.items, - extract_destination, - null, - *DirnameReader, - &dirname_reader, - // for GitHub tarballs, the root dir is always -- - 1, - true, - false, - ); + log, + ), + } // This tag is used to know which version of the package was // installed from GitHub. package.json version becomes sort of @@ -252,31 +242,18 @@ fn extract(this: *const ExtractTarball, tgz_bytes: []const u8) !Install.ExtractD }; } }, - else => { - _ = if (PackageManager.verbose_install) - try Archive.extractToDir( - zlib_pool.data.list.items, - extract_destination, - null, - void, - {}, - // for npm packages, the root dir is always "package" - 1, - true, - true, - ) - else - try Archive.extractToDir( - zlib_pool.data.list.items, - extract_destination, - null, - void, - {}, - // for npm packages, the root dir is always "package" - 1, - true, - false, - ); + else => switch (PackageManager.verbose_install) { + inline else => |log| _ = try Archive.extractToDir( + zlib_pool.data.list.items, + extract_destination, + null, + void, + {}, + // for npm packages, the root dir is always "package" + 1, + true, + log, + ), }, } @@ -343,7 +320,7 @@ fn extract(this: *const ExtractTarball, tgz_bytes: []const u8) !Install.ExtractD }; // create an index storing each version of a package installed - if (std.mem.indexOfScalar(u8, basename, '/') == null) create_index: { + if (strings.indexOfChar(basename, '/') == null) create_index: { var index_dir = cache_dir.makeOpenPathIterable(name, .{}) catch break :create_index; defer index_dir.close(); index_dir.dir.symLink( @@ -361,39 +338,39 @@ fn extract(this: *const ExtractTarball, tgz_bytes: []const u8) !Install.ExtractD var json_path: []u8 = ""; var json_buf: []u8 = ""; var json_len: usize = 0; - switch (this.resolution.tag) { - .github, .local_tarball, .remote_tarball => { - const json_file = final_dir.openFileZ("package.json", .{ .mode = .read_only }) catch |err| { - this.package_manager.log.addErrorFmt( - null, - logger.Loc.Empty, - this.package_manager.allocator, - "\"package.json\" for \"{s}\" failed to open: {s}", - .{ name, @errorName(err) }, - ) catch unreachable; - return error.InstallFailed; - }; - defer json_file.close(); - const json_stat = try json_file.stat(); - json_buf = try this.package_manager.allocator.alloc(u8, json_stat.size + 64); - json_len = try json_file.preadAll(json_buf, 0); + if (switch (this.resolution.tag) { + // TODO remove extracted files not matching any globs under "files" + .github, .local_tarball, .remote_tarball => true, + else => this.package_manager.lockfile.trusted_dependencies.contains(@truncate(u32, Semver.String.Builder.stringHash(name))), + }) { + const json_file = final_dir.openFileZ("package.json", .{ .mode = .read_only }) catch |err| { + this.package_manager.log.addErrorFmt( + null, + logger.Loc.Empty, + this.package_manager.allocator, + "\"package.json\" for \"{s}\" failed to open: {s}", + .{ name, @errorName(err) }, + ) catch unreachable; + return error.InstallFailed; + }; + defer json_file.close(); + const json_stat = try json_file.stat(); + json_buf = try this.package_manager.allocator.alloc(u8, json_stat.size + 64); + json_len = try json_file.preadAll(json_buf, 0); - json_path = bun.getFdPath( - json_file.handle, - &json_path_buf, - ) catch |err| { - this.package_manager.log.addErrorFmt( - null, - logger.Loc.Empty, - this.package_manager.allocator, - "\"package.json\" for \"{s}\" failed to resolve: {s}", - .{ name, @errorName(err) }, - ) catch unreachable; - return error.InstallFailed; - }; - // TODO remove extracted files not matching any globs under "files" - }, - else => {}, + json_path = bun.getFdPath( + json_file.handle, + &json_path_buf, + ) catch |err| { + this.package_manager.log.addErrorFmt( + null, + logger.Loc.Empty, + this.package_manager.allocator, + "\"package.json\" for \"{s}\" failed to resolve: {s}", + .{ name, @errorName(err) }, + ) catch unreachable; + return error.InstallFailed; + }; } const ret_json_path = try FileSystem.instance.dirname_store.append(@TypeOf(json_path), json_path); diff --git a/src/install/install.zig b/src/install/install.zig index 81e2a7bb8..22068bbf3 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -166,8 +166,8 @@ pub const ExternalStringList = ExternalSlice(ExternalString); pub const VersionSlice = ExternalSlice(Semver.Version); pub const ExternalStringMap = extern struct { - name: ExternalStringList = ExternalStringList{}, - value: ExternalStringList = ExternalStringList{}, + name: ExternalStringList = .{}, + value: ExternalStringList = .{}, }; pub const PackageNameHash = u64; @@ -467,7 +467,7 @@ pub const Features = struct { is_main: bool = false, optional_dependencies: bool = false, peer_dependencies: bool = true, - scripts: bool = false, + trusted_dependencies: bool = false, workspaces: bool = false, check_for_duplicate_dependencies: bool = false, @@ -487,7 +487,7 @@ pub const Features = struct { .dev_dependencies = true, .is_main = true, .optional_dependencies = true, - .scripts = true, + .trusted_dependencies = true, .workspaces = true, }; @@ -499,7 +499,7 @@ pub const Features = struct { pub const workspace = Features{ .dev_dependencies = true, .optional_dependencies = true, - .scripts = true, + .trusted_dependencies = true, }; pub const link = Features{ @@ -3546,7 +3546,34 @@ pub const PackageManager = struct { return package; }, - else => {}, + else => if (data.json_len > 0) { + const package_json_source = logger.Source.initPathString( + data.json_path, + data.json_buf[0..data.json_len], + ); + initializeStore(); + const json = json_parser.ParseJSONUTF8( + &package_json_source, + manager.log, + manager.allocator, + ) catch |err| { + if (comptime log_level != .silent) { + const string_buf = manager.lockfile.buffers.string_bytes.items; + Output.prettyErrorln("error: expected package.json in {any} to be a JSON file: {s}\n", .{ + resolution.fmtURL(&manager.options, string_buf), + @errorName(err), + }); + } + Global.crash(); + }; + var builder = manager.lockfile.stringBuilder(); + Lockfile.Package.Scripts.parseCount(manager.allocator, &builder, json); + builder.allocate() catch unreachable; + if (comptime Environment.allow_assert) std.debug.assert(package_id.* != invalid_package_id); + var scripts = manager.lockfile.packages.items(.scripts)[package_id.*]; + scripts.parseAlloc(manager.allocator, &builder, json); + scripts.filled = true; + }, } return null; @@ -3910,10 +3937,10 @@ pub const PackageManager = struct { var task: Task = task_; if (task.log.msgs.items.len > 0) { - if (Output.enable_ansi_colors) { - try task.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true); - } else { - try task.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + try task.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), enable_ansi_colors); + }, } } @@ -5308,36 +5335,31 @@ pub const PackageManager = struct { // When using bun, we only do staleness checks once per day ) -| std.time.s_per_day; - manager.lockfile = brk: { + if (root_dir.entries.hasComptimeQuery("bun.lockb")) { var buf: [bun.MAX_PATH_BYTES]u8 = undefined; + var parts = [_]string{ + "./bun.lockb", + }; + var lockfile_path = Path.joinAbsStringBuf( + Fs.FileSystem.instance.top_level_dir, + &buf, + &parts, + .auto, + ); + buf[lockfile_path.len] = 0; + var lockfile_path_z = buf[0..lockfile_path.len :0]; - if (root_dir.entries.hasComptimeQuery("bun.lockb")) { - var parts = [_]string{ - "./bun.lockb", - }; - var lockfile_path = Path.joinAbsStringBuf( - Fs.FileSystem.instance.top_level_dir, - &buf, - &parts, - .auto, - ); - buf[lockfile_path.len] = 0; - var lockfile_path_z = buf[0..lockfile_path.len :0]; - - const result = manager.lockfile.loadFromDisk( - allocator, - log, - lockfile_path_z, - ); - - if (result == .ok) { - break :brk result.ok; - } + switch (manager.lockfile.loadFromDisk( + allocator, + log, + lockfile_path_z, + )) { + .ok => |lockfile| manager.lockfile = lockfile, + else => try manager.lockfile.initEmpty(allocator), } - + } else { try manager.lockfile.initEmpty(allocator); - break :brk manager.lockfile; - }; + } return manager; } @@ -5448,7 +5470,7 @@ pub const PackageManager = struct { // create scope if specified if (name[0] == '@') { - if (std.mem.indexOfScalar(u8, name, '/')) |i| { + if (strings.indexOfChar(name, '/')) |i| { node_modules.dir.makeDir(name[0..i]) catch |err| brk: { if (err == error.PathAlreadyExists) break :brk; if (manager.options.log_level != .silent) @@ -5513,11 +5535,7 @@ pub const PackageManager = struct { } else { // bun link lodash switch (manager.options.log_level) { - .default => try updatePackageJSONAndInstallWithManager(ctx, manager, .link, .default), - .verbose => try updatePackageJSONAndInstallWithManager(ctx, manager, .link, .verbose), - .silent => try updatePackageJSONAndInstallWithManager(ctx, manager, .link, .silent), - .default_no_progress => try updatePackageJSONAndInstallWithManager(ctx, manager, .link, .default_no_progress), - .verbose_no_progress => try updatePackageJSONAndInstallWithManager(ctx, manager, .link, .verbose_no_progress), + inline else => |log_level| try updatePackageJSONAndInstallWithManager(ctx, manager, .link, log_level), } } } @@ -6019,11 +6037,7 @@ pub const PackageManager = struct { } switch (manager.options.log_level) { - .default => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .default), - .verbose => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .verbose), - .silent => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .silent), - .default_no_progress => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .default_no_progress), - .verbose_no_progress => try updatePackageJSONAndInstallWithManager(ctx, manager, op, .verbose_no_progress), + inline else => |log_level| try updatePackageJSONAndInstallWithManager(ctx, manager, op, log_level), } } @@ -6153,13 +6167,12 @@ pub const PackageManager = struct { ) !void { if (ctx.log.errors > 0) { if (comptime log_level != .silent) { - if (Output.enable_ansi_colors) { - ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {}; - } else { - ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {}; + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), enable_ansi_colors) catch {}; + }, } } - Global.crash(); } @@ -6183,10 +6196,10 @@ pub const PackageManager = struct { initializeStore(); var current_package_json = json_parser.ParseJSONUTF8(&package_json_source, ctx.log, manager.allocator) catch |err| { - if (Output.enable_ansi_colors) { - ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {}; - } else { - ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {}; + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), enable_ansi_colors) catch {}; + }, } if (err == error.ParserError and ctx.log.errors > 0) { @@ -6313,7 +6326,7 @@ pub const PackageManager = struct { // haha unless defer if (auto_free) bun.default_allocator.free(old_ast_nodes); - try installWithManager(ctx, manager, new_package_json_source, log_level); + try manager.installWithManager(ctx, new_package_json_source, log_level); if (op == .update or op == .add or op == .link) { for (manager.package_json_updates) |update| { @@ -6435,11 +6448,7 @@ pub const PackageManager = struct { }; try switch (manager.options.log_level) { - .default => installWithManager(ctx, manager, package_json_contents, .default), - .verbose => installWithManager(ctx, manager, package_json_contents, .verbose), - .silent => installWithManager(ctx, manager, package_json_contents, .silent), - .default_no_progress => installWithManager(ctx, manager, package_json_contents, .default_no_progress), - .verbose_no_progress => installWithManager(ctx, manager, package_json_contents, .verbose_no_progress), + inline else => |log_level| manager.installWithManager(ctx, package_json_contents, log_level), }; } @@ -6593,10 +6602,10 @@ pub const PackageManager = struct { const args = .{ name, @errorName(err) }; if (comptime log_level.showProgress()) { - if (Output.enable_ansi_colors) { - this.progress.log(comptime Output.prettyFmt(fmt, true), args); - } else { - this.progress.log(comptime Output.prettyFmt(fmt, false), args); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + this.progress.log(comptime Output.prettyFmt(fmt, enable_ansi_colors), args); + }, } } else { Output.prettyErrorln(fmt, args); @@ -6699,10 +6708,10 @@ pub const PackageManager = struct { const args = .{ alias, @errorName(err) }; if (comptime log_level.showProgress()) { - if (Output.enable_ansi_colors) { - this.progress.log(comptime Output.prettyFmt(fmt, true), args); - } else { - this.progress.log(comptime Output.prettyFmt(fmt, false), args); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + this.progress.log(comptime Output.prettyFmt(fmt, enable_ansi_colors), args); + }, } } else { Output.prettyErrorln(fmt, args); @@ -6718,61 +6727,56 @@ pub const PackageManager = struct { } } - var scripts = this.lockfile.packages.items(.scripts)[package_id]; - if (scripts.hasAny()) { - var path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; - const path_str = Path.joinAbsString( - bun.getFdPath(this.node_modules_folder.dir.fd, &path_buf) catch unreachable, - &[_]string{destination_dir_subpath}, - .posix, - ); + if (resolution.tag == .workspace or this.lockfile.trusted_dependencies.contains(@truncate(u32, String.Builder.stringHash(name)))) { + var scripts = this.lockfile.packages.items(.scripts)[package_id]; + if (scripts.hasAny()) { + var path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + const path_str = Path.joinAbsString( + bun.getFdPath(this.node_modules_folder.dir.fd, &path_buf) catch unreachable, + &[_]string{destination_dir_subpath}, + .posix, + ); - scripts.enqueue(this.lockfile, buf, path_str); - } else if (!scripts.filled and switch (resolution.tag) { - .folder => Features.folder.scripts, - .npm => Features.npm.scripts, - .git, .github, .gitlab, .local_tarball, .remote_tarball => Features.tarball.scripts, - .symlink => Features.link.scripts, - .workspace => Features.workspace.scripts, - else => false, - }) { - var path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; - const path_str = Path.joinAbsString( - bun.getFdPath(this.node_modules_folder.dir.fd, &path_buf) catch unreachable, - &[_]string{destination_dir_subpath}, - .posix, - ); + scripts.enqueue(this.lockfile, buf, path_str); + } else if (!scripts.filled) { + var path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + const path_str = Path.joinAbsString( + bun.getFdPath(this.node_modules_folder.dir.fd, &path_buf) catch unreachable, + &[_]string{destination_dir_subpath}, + .posix, + ); - scripts.enqueueFromPackageJSON( - this.manager.log, - this.lockfile, - this.node_modules_folder.dir, - destination_dir_subpath, - path_str, - ) catch |err| { - if (comptime log_level != .silent) { - const fmt = "\nerror: failed to parse life-cycle scripts for {s}: {s}\n"; - const args = .{ name, @errorName(err) }; - - if (comptime log_level.showProgress()) { - if (Output.enable_ansi_colors) { - this.progress.log(comptime Output.prettyFmt(fmt, true), args); + scripts.enqueueFromPackageJSON( + this.manager.log, + this.lockfile, + this.node_modules_folder.dir, + destination_dir_subpath, + path_str, + ) catch |err| { + if (comptime log_level != .silent) { + const fmt = "\nerror: failed to parse life-cycle scripts for {s}: {s}\n"; + const args = .{ name, @errorName(err) }; + + if (comptime log_level.showProgress()) { + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + this.progress.log(comptime Output.prettyFmt(fmt, enable_ansi_colors), args); + }, + } } else { - this.progress.log(comptime Output.prettyFmt(fmt, false), args); + Output.prettyErrorln(fmt, args); } - } else { - Output.prettyErrorln(fmt, args); } - } - if (this.manager.options.enable.fail_early) { - Global.exit(1); - } + if (this.manager.options.enable.fail_early) { + Global.exit(1); + } - Output.flush(); - this.summary.fail += 1; - return; - }; + Output.flush(); + this.summary.fail += 1; + return; + }; + } } }, .fail => |cause| { @@ -7241,10 +7245,10 @@ pub const PackageManager = struct { const args = .{ name, @errorName(err) }; if (comptime log_level.showProgress()) { - if (Output.enable_ansi_colors) { - this.progress.log(comptime Output.prettyFmt(fmt, true), args); - } else { - this.progress.log(comptime Output.prettyFmt(fmt, false), args); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + this.progress.log(comptime Output.prettyFmt(fmt, enable_ansi_colors), args); + }, } } else { Output.prettyErrorln(fmt, args); @@ -7262,10 +7266,10 @@ pub const PackageManager = struct { const args = .{lockfile.str(&names[package_id])}; if (comptime log_level.showProgress()) { - if (Output.enable_ansi_colors) { - this.progress.log(comptime Output.prettyFmt(fmt, true), args); - } else { - this.progress.log(comptime Output.prettyFmt(fmt, false), args); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + this.progress.log(comptime Output.prettyFmt(fmt, enable_ansi_colors), args); + }, } } else { Output.prettyErrorln(fmt, args); @@ -7312,8 +7316,8 @@ pub const PackageManager = struct { } fn installWithManager( - ctx: Command.Context, manager: *PackageManager, + ctx: Command.Context, package_json_contents: string, comptime log_level: Options.LogLevel, ) !void { @@ -7326,7 +7330,7 @@ pub const PackageManager = struct { manager.options.lockfile_path, ) else - Lockfile.LoadFromDiskResult{ .not_found = {} }; + .{ .not_found = {} }; var root = Lockfile.Package{}; var needs_new_lockfile = load_lockfile_result != .ok or (load_lockfile_result.ok.buffers.dependencies.items.len == 0 and manager.package_json_updates.len > 0); // this defaults to false @@ -7360,10 +7364,10 @@ pub const PackageManager = struct { } if (ctx.log.errors > 0) { - if (Output.enable_ansi_colors) { - try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true); - } else { - try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), enable_ansi_colors); + }, } } Output.flush(); @@ -7567,10 +7571,10 @@ pub const PackageManager = struct { } } - if (Output.enable_ansi_colors) { - try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true); - } else { - try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + try manager.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), enable_ansi_colors); + }, } if (manager.log.hasErrors()) Global.crash(); @@ -7731,10 +7735,10 @@ pub const PackageManager = struct { .successfully_installed = install_summary.successfully_installed, }; - if (Output.enable_ansi_colors) { - try Lockfile.Printer.Tree.print(&printer, Output.WriterType, Output.writer(), true); - } else { - try Lockfile.Printer.Tree.print(&printer, Output.WriterType, Output.writer(), false); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + try Lockfile.Printer.Tree.print(&printer, Output.WriterType, Output.writer(), enable_ansi_colors); + }, } if (!did_meta_hash_change) { diff --git a/src/install/integrity.zig b/src/install/integrity.zig index 19e55c223..4634c2dfd 100644 --- a/src/install/integrity.zig +++ b/src/install/integrity.zig @@ -117,7 +117,7 @@ pub const Integrity = extern struct { pub fn parse(buf: []const u8) Tag { const Matcher = strings.ExactSizeMatcher(8); - const i = std.mem.indexOfScalar(u8, buf[0..@min(buf.len, 7)], '-') orelse return Tag.unknown; + const i = strings.indexOfChar(buf[0..@min(buf.len, 7)], '-') orelse return Tag.unknown; return switch (Matcher.match(buf[0..i])) { Matcher.case("sha1") => Tag.sha1, diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index b17691853..a51d2b2ee 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -85,6 +85,7 @@ const PackageJSON = @import("../resolver/package_json.zig").PackageJSON; const MetaHash = [std.crypto.hash.sha2.Sha512256.digest_length]u8; const zero_hash = std.mem.zeroes(MetaHash); const NameHashMap = std.ArrayHashMapUnmanaged(u32, String, ArrayIdentityContext, false); +const NameHashSet = std.ArrayHashMapUnmanaged(u32, void, ArrayIdentityContext, false); // Serialized data /// The version of the lockfile format, intended to prevent data corruption for format changes. @@ -103,6 +104,7 @@ allocator: Allocator, scratch: Scratch = .{}, scripts: Scripts = .{}, +trusted_dependencies: NameHashSet = .{}, workspace_paths: NameHashMap = .{}, const Stream = std.io.FixedBufferStream([]u8); @@ -113,15 +115,15 @@ pub const Scripts = struct { cwd: string, script: string, }; - const StringArrayList = std.ArrayListUnmanaged(Entry); + const Entries = std.ArrayListUnmanaged(Entry); const RunCommand = @import("../cli/run_command.zig").RunCommand; - preinstall: StringArrayList = .{}, - install: StringArrayList = .{}, - postinstall: StringArrayList = .{}, - preprepare: StringArrayList = .{}, - prepare: StringArrayList = .{}, - postprepare: StringArrayList = .{}, + preinstall: Entries = .{}, + install: Entries = .{}, + postinstall: Entries = .{}, + preprepare: Entries = .{}, + prepare: Entries = .{}, + postprepare: Entries = .{}, pub fn hasAny(this: *Scripts) bool { inline for (Package.Scripts.Hooks) |hook| { @@ -195,6 +197,7 @@ pub fn loadFromBytes(this: *Lockfile, buf: []u8, allocator: Allocator, log: *log this.format = FormatVersion.current; this.scripts = .{}; + this.trusted_dependencies = .{}; this.workspace_paths = .{}; Lockfile.Serializer.load(this, &stream, allocator, log) catch |err| { @@ -633,6 +636,7 @@ pub fn clean(old: *Lockfile, updates: []PackageManager.UpdateRequest) !*Lockfile } pub fn cleanWithLogger(old: *Lockfile, updates: []PackageManager.UpdateRequest, log: *logger.Log) !*Lockfile { + const old_trusted_dependencies = old.trusted_dependencies; const old_scripts = old.scripts; // We will only shrink the number of packages here. // never grow @@ -738,6 +742,7 @@ pub fn cleanWithLogger(old: *Lockfile, updates: []PackageManager.UpdateRequest, } } } + new.trusted_dependencies = old_trusted_dependencies; new.scripts = old_scripts; return new; } @@ -909,10 +914,10 @@ pub const Printer = struct { }), } if (log.errors > 0) { - if (Output.enable_ansi_colors) { - try log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true); - } else { - try log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false); + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + try log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), enable_ansi_colors); + }, } } Global.crash(); @@ -1493,6 +1498,7 @@ pub fn initEmpty(this: *Lockfile, allocator: Allocator) !void { .allocator = allocator, .scratch = Scratch.init(allocator), .scripts = .{}, + .trusted_dependencies = .{}, .workspace_paths = .{}, }; } @@ -2438,12 +2444,11 @@ pub const Package = extern struct { initializeStore(); const json = json_parser.ParseJSONUTF8(&source, log, allocator) catch |err| { - if (Output.enable_ansi_colors) { - log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {}; - } else { - log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), false) catch {}; + switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| { + log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), enable_ansi_colors) catch {}; + }, } - Output.prettyErrorln("{s} parsing package.json in \"{s}\"", .{ @errorName(err), source.path.prettyDir() }); Global.crash(); }; @@ -2956,9 +2961,7 @@ pub const Package = extern struct { } } - if (comptime features.scripts) { - Package.Scripts.parseCount(allocator, &string_builder, json); - } + Package.Scripts.parseCount(allocator, &string_builder, json); if (comptime ResolverContext != void) { resolver.count(*Lockfile.StringBuilder, &string_builder, json); @@ -3113,6 +3116,37 @@ pub const Package = extern struct { } } + if (comptime features.trusted_dependencies) { + if (json.asProperty("trustedDependencies")) |q| { + switch (q.expr.data) { + .e_array => |arr| { + try lockfile.trusted_dependencies.ensureUnusedCapacity(allocator, arr.items.len); + for (arr.slice()) |item| { + const name = item.asString(allocator) orelse { + log.addErrorFmt(&source, q.loc, allocator, + \\trustedDependencies expects an array of strings, e.g. + \\"trustedDependencies": [ + \\ "package_name" + \\] + , .{}) catch {}; + return error.InvalidPackageJSON; + }; + lockfile.trusted_dependencies.putAssumeCapacity(@truncate(u32, String.Builder.stringHash(name)), {}); + } + }, + else => { + log.addErrorFmt(&source, q.loc, allocator, + \\trustedDependencies expects an array of strings, e.g. + \\"trustedDependencies": [ + \\ "package_name" + \\] + , .{}) catch {}; + return error.InvalidPackageJSON; + }, + } + } + } + try string_builder.allocate(); try lockfile.buffers.dependencies.ensureUnusedCapacity(lockfile.allocator, total_dependencies_count); try lockfile.buffers.resolutions.ensureUnusedCapacity(lockfile.allocator, total_dependencies_count); @@ -3233,9 +3267,7 @@ pub const Package = extern struct { } } - if (comptime features.scripts) { - package.scripts.parseAlloc(allocator, &string_builder, json); - } + package.scripts.parseAlloc(allocator, &string_builder, json); package.scripts.filled = true; // It is allowed for duplicate dependencies to exist in optionalDependencies and regular dependencies @@ -3511,6 +3543,7 @@ pub fn deinit(this: *Lockfile) void { this.packages.deinit(this.allocator); this.string_pool.deinit(); this.scripts.deinit(this.allocator); + this.trusted_dependencies.deinit(this.allocator); this.workspace_paths.deinit(this.allocator); } diff --git a/src/install/npm.zig b/src/install/npm.zig index 074041056..6edb6dcb4 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -80,14 +80,14 @@ pub const Registry = struct { url.path = pathname; } - while (std.mem.lastIndexOfScalar(u8, pathname, ':')) |colon| { + while (strings.lastIndexOfChar(pathname, ':')) |colon| { var segment = pathname[colon + 1 ..]; pathname = pathname[0..colon]; if (pathname.len > 1 and pathname[pathname.len - 1] == '/') { pathname = pathname[0 .. pathname.len - 1]; } - const eql_i = std.mem.indexOfScalar(u8, segment, '=') orelse continue; + const eql_i = strings.indexOfChar(segment, '=') orelse continue; var value = segment[eql_i + 1 ..]; segment = segment[0..eql_i]; @@ -847,11 +847,11 @@ pub const PackageManifest = struct { for (versions) |prop| { const version_name = prop.key.?.asString(allocator) orelse continue; - if (std.mem.indexOfScalar(u8, version_name, '-') != null) { + if (strings.indexOfChar(version_name, '-') != null) { pre_versions_len += 1; extern_string_count += 1; } else { - extern_string_count += @as(usize, @intFromBool(std.mem.indexOfScalar(u8, version_name, '+') != null)); + extern_string_count += @as(usize, @intFromBool(strings.indexOfChar(version_name, '+') != null)); release_versions_len += 1; } diff --git a/src/install/repository.zig b/src/install/repository.zig index c4b68d9be..6546481e9 100644 --- a/src/install/repository.zig +++ b/src/install/repository.zig @@ -94,7 +94,7 @@ pub const Repository = extern struct { if (!formatter.repository.resolved.isEmpty()) { try writer.writeAll("#"); var resolved = formatter.repository.resolved.slice(formatter.buf); - if (std.mem.lastIndexOfScalar(u8, resolved, '-')) |i| { + if (strings.lastIndexOfChar(resolved, '-')) |i| { resolved = resolved[i + 1 ..]; } try writer.writeAll(resolved); diff --git a/src/logger.zig b/src/logger.zig index 621e643b5..3279e9fd5 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -860,10 +860,9 @@ pub const Log = struct { } inline fn allocPrint(allocator: std.mem.Allocator, comptime fmt: string, args: anytype) !string { - return if (Output.enable_ansi_colors) - try std.fmt.allocPrint(allocator, Output.prettyFmt(fmt, true), args) - else - try std.fmt.allocPrint(allocator, Output.prettyFmt(fmt, false), args); + return try switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| std.fmt.allocPrint(allocator, Output.prettyFmt(fmt, enable_ansi_colors), args), + }; } inline fn _addResolveErrorWithLevel( @@ -1174,11 +1173,9 @@ pub const Log = struct { } pub fn printForLogLevel(self: *Log, to: anytype) !void { - if (Output.enable_ansi_colors) { - return self.printForLogLevelWithEnableAnsiColors(to, true); - } else { - return self.printForLogLevelWithEnableAnsiColors(to, false); - } + return switch (Output.enable_ansi_colors) { + inline else => |enable_ansi_colors| self.printForLogLevelWithEnableAnsiColors(to, enable_ansi_colors), + }; } pub fn printForLogLevelWithEnableAnsiColors(self: *Log, to: anytype, comptime enable_ansi_colors: bool) !void { diff --git a/test/cli/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts index 6baee23a9..595e7bcdd 100644 --- a/test/cli/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -1,7 +1,7 @@ import { file, listen, Socket, spawn } from "bun"; import { afterAll, afterEach, beforeAll, beforeEach, expect, it } from "bun:test"; import { bunExe, bunEnv as env } from "harness"; -import { access, mkdir, readlink, rm, writeFile } from "fs/promises"; +import { access, mkdir, readlink, realpath, rm, writeFile } from "fs/promises"; import { join } from "path"; import { dummyAfterAll, @@ -4473,3 +4473,75 @@ cache = false expect(await file(join(package_dir, "package.json")).text()).toEqual(foo_package); expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([]); }, 20000); + +it("should handle trustedDependencies", async () => { + const scripts = { + preinstall: `${bunExe()} echo.js preinstall`, + install: `${bunExe()} echo.js install`, + postinstall: `${bunExe()} echo.js postinstall`, + preprepare: `${bunExe()} echo.js preprepare`, + prepare: `${bunExe()} echo.js prepare`, + postprepare: `${bunExe()} echo.js postprepare`, + }; + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ + name: "foo", + version: "0.1.0", + dependencies: { + bar: "file:./bar", + moo: "file:./moo", + }, + trustedDependencies: ["moo"], + }), + ); + await mkdir(join(package_dir, "bar")); + const bar_package = JSON.stringify({ + name: "bar", + version: "0.2.0", + scripts, + }); + await writeFile(join(package_dir, "bar", "package.json"), bar_package); + await writeFile(join(package_dir, "bar", "echo.js"), "console.log(`bar|${process.argv[2]}|${import.meta.dir}`);"); + await mkdir(join(package_dir, "moo")); + const moo_package = JSON.stringify({ + name: "moo", + version: "0.3.0", + scripts, + }); + await writeFile(join(package_dir, "moo", "package.json"), moo_package); + await writeFile(join(package_dir, "moo", "echo.js"), "console.log(`moo|${process.argv[2]}|${import.meta.dir}`);"); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "install"], + cwd: package_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toContain("Saved lockfile"); + expect(stdout).toBeDefined(); + const out = await new Response(stdout).text(); + const moo_dir = await realpath(join(package_dir, "node_modules", "moo")); + expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ + `moo|preinstall|${moo_dir}`, + " + bar@bar", + " + moo@moo", + `moo|install|${moo_dir}`, + `moo|postinstall|${moo_dir}`, + `moo|preprepare|${moo_dir}`, + `moo|prepare|${moo_dir}`, + `moo|postprepare|${moo_dir}`, + "", + " 2 packages installed", + ]); + expect(await exited).toBe(0); + expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "bar", "moo"]); + expect(await readdirSorted(join(package_dir, "node_modules", "bar"))).toEqual(["echo.js", "package.json"]); + expect(await file(join(package_dir, "node_modules", "bar", "package.json")).text()).toEqual(bar_package); + expect(await readdirSorted(join(package_dir, "node_modules", "moo"))).toEqual(["echo.js", "package.json"]); + expect(await file(join(package_dir, "node_modules", "moo", "package.json")).text()).toEqual(moo_package); + await access(join(package_dir, "bun.lockb")); +}); -- cgit v1.2.3 From 50e872fc761db50ae2804f780ea9cd655600a7e2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 26 Jun 2023 11:56:53 -0700 Subject: Implement writev & readv (#3419) * [node:fs] Implement `writev` and `readv` * writev & readv tests * cast to const type * woops * cast --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/node/node_fs.zig | 235 +++++++++++++++++++++++++++++++++ src/bun.js/node/node_fs_binding.zig | 8 +- src/bun.js/node/syscall.zig | 152 +++++++++++++++++++++ src/bun.js/node/types.zig | 44 ++++++ src/io/io_darwin.zig | 4 + src/js/node/fs.js | 41 +++++- src/js/node/fs.promises.ts | 34 ++++- src/js/out/modules/node/fs.js | 38 +++++- src/js/out/modules/node/fs.promises.js | 2 +- test/js/node/fs/fs.test.ts | 65 +++++++++ 10 files changed, 611 insertions(+), 12 deletions(-) diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 13d785e97..fa33a575b 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -135,6 +135,154 @@ pub const Arguments = struct { } }; + pub const Writev = struct { + fd: FileDescriptor, + buffers: JSC.Node.VectorArrayBuffer, + position: ?u52 = 0, + + pub fn deinit(_: *const @This()) void {} + + pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Writev { + const fd_value = arguments.nextEat() orelse { + if (exception.* == null) { + JSC.throwInvalidArguments( + "file descriptor is required", + .{}, + ctx, + exception, + ); + } + return null; + }; + + const fd = JSC.Node.fileDescriptorFromJS(ctx, fd_value, exception) orelse { + if (exception.* == null) { + JSC.throwInvalidArguments( + "file descriptor must be a number", + .{}, + ctx, + exception, + ); + } + return null; + }; + + const buffers = JSC.Node.VectorArrayBuffer.fromJS( + ctx, + arguments.protectEatNext() orelse { + JSC.throwInvalidArguments("Expected an ArrayBufferView[]", .{}, ctx, exception); + return null; + }, + exception, + arguments.arena.allocator(), + ) orelse { + if (exception.* == null) { + JSC.throwInvalidArguments( + "buffers must be an array of TypedArray", + .{}, + ctx, + exception, + ); + } + return null; + }; + + var position: ?u52 = null; + + if (arguments.nextEat()) |pos_value| { + if (!pos_value.isUndefinedOrNull()) { + if (pos_value.isNumber()) { + position = pos_value.to(u52); + } else { + JSC.throwInvalidArguments( + "position must be a number", + .{}, + ctx, + exception, + ); + return null; + } + } + } + + return Writev{ .fd = fd, .buffers = buffers, .position = position }; + } + }; + + pub const Readv = struct { + fd: FileDescriptor, + buffers: JSC.Node.VectorArrayBuffer, + position: ?u52 = 0, + + pub fn deinit(_: *const @This()) void {} + + pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Readv { + const fd_value = arguments.nextEat() orelse { + if (exception.* == null) { + JSC.throwInvalidArguments( + "file descriptor is required", + .{}, + ctx, + exception, + ); + } + return null; + }; + + const fd = JSC.Node.fileDescriptorFromJS(ctx, fd_value, exception) orelse { + if (exception.* == null) { + JSC.throwInvalidArguments( + "file descriptor must be a number", + .{}, + ctx, + exception, + ); + } + return null; + }; + + const buffers = JSC.Node.VectorArrayBuffer.fromJS( + ctx, + arguments.protectEatNext() orelse { + JSC.throwInvalidArguments("Expected an ArrayBufferView[]", .{}, ctx, exception); + return null; + }, + exception, + arguments.arena.allocator(), + ) orelse { + if (exception.* == null) { + JSC.throwInvalidArguments( + "buffers must be an array of TypedArray", + .{}, + ctx, + exception, + ); + } + return null; + }; + + var position: ?u52 = null; + + if (arguments.nextEat()) |pos_value| { + if (!pos_value.isUndefinedOrNull()) { + if (pos_value.isNumber()) { + position = pos_value.to(u52); + } else { + JSC.throwInvalidArguments( + "position must be a number", + .{}, + ctx, + exception, + ); + return null; + } + } + } + + return Readv{ .fd = fd, .buffers = buffers, .position = position }; + } + }; + pub const FTruncate = struct { fd: FileDescriptor, len: ?JSC.WebCore.Blob.SizeType = null, @@ -2372,6 +2520,7 @@ const Return = struct { pub const Mkdtemp = JSC.ZigString; pub const Open = FileDescriptor; pub const WriteFile = void; + pub const Readv = Read; pub const Read = struct { bytes_read: u52, @@ -2480,6 +2629,8 @@ const Return = struct { pub const Chown = void; pub const Lutimes = void; + + pub const Writev = Write; }; /// Bun's implementation of the Node.js "fs" module @@ -3256,6 +3407,14 @@ pub const NodeFS = struct { ); } + pub fn readv(this: *NodeFS, args: Arguments.Readv, comptime flavor: Flavor) Maybe(Return.Read) { + return if (args.position != null) _preadv(this, args, flavor) else _readv(this, args, flavor); + } + + pub fn writev(this: *NodeFS, args: Arguments.Writev, comptime flavor: Flavor) Maybe(Return.Write) { + return if (args.position != null) _pwritev(this, args, flavor) else _writev(this, args, flavor); + } + pub fn write(this: *NodeFS, args: Arguments.Write, comptime flavor: Flavor) Maybe(Return.Write) { return if (args.position != null) _pwrite(this, args, flavor) else _write(this, args, flavor); } @@ -3307,6 +3466,82 @@ pub const NodeFS = struct { return Maybe(Return.Write).todo; } + fn _preadv(_: *NodeFS, args: Arguments.Readv, comptime flavor: Flavor) Maybe(Return.Readv) { + const position = args.position.?; + + switch (comptime flavor) { + .sync => { + return switch (Syscall.preadv(args.fd, args.buffers.buffers.items, position)) { + .err => |err| .{ + .err = err, + }, + .result => |amt| .{ .result = .{ + .bytes_read = @truncate(u52, amt), + } }, + }; + }, + else => {}, + } + + return Maybe(Return.Write).todo; + } + + fn _readv(_: *NodeFS, args: Arguments.Readv, comptime flavor: Flavor) Maybe(Return.Readv) { + switch (comptime flavor) { + .sync => { + return switch (Syscall.readv(args.fd, args.buffers.buffers.items)) { + .err => |err| .{ + .err = err, + }, + .result => |amt| .{ .result = .{ + .bytes_read = @truncate(u52, amt), + } }, + }; + }, + else => {}, + } + + return Maybe(Return.Write).todo; + } + + fn _pwritev(_: *NodeFS, args: Arguments.Writev, comptime flavor: Flavor) Maybe(Return.Write) { + const position = args.position.?; + + switch (comptime flavor) { + .sync => { + return switch (Syscall.pwritev(args.fd, args.buffers.buffers.items, position)) { + .err => |err| .{ + .err = err, + }, + .result => |amt| .{ .result = .{ + .bytes_written = @truncate(u52, amt), + } }, + }; + }, + else => {}, + } + + return Maybe(Return.Write).todo; + } + + fn _writev(_: *NodeFS, args: Arguments.Writev, comptime flavor: Flavor) Maybe(Return.Write) { + switch (comptime flavor) { + .sync => { + return switch (Syscall.writev(args.fd, args.buffers.buffers.items)) { + .err => |err| .{ + .err = err, + }, + .result => |amt| .{ .result = .{ + .bytes_written = @truncate(u52, amt), + } }, + }; + }, + else => {}, + } + + return Maybe(Return.Write).todo; + } + pub fn readdir(this: *NodeFS, args: Arguments.Readdir, comptime flavor: Flavor) Maybe(Return.Readdir) { return switch (args.encoding) { .buffer => _readdir( diff --git a/src/bun.js/node/node_fs_binding.zig b/src/bun.js/node/node_fs_binding.zig index f178f0355..a4cc62cd3 100644 --- a/src/bun.js/node/node_fs_binding.zig +++ b/src/bun.js/node/node_fs_binding.zig @@ -229,6 +229,10 @@ pub const NodeJSFS = struct { pub const lutimesSync = callSync(.lutimes); pub const rmSync = callSync(.rm); pub const rmdirSync = callSync(.rmdir); + pub const writev = call(.writev); + pub const writevSync = callSync(.writev); + pub const readv = call(.readv); + pub const readvSync = callSync(.readv); pub const fdatasyncSync = callSync(.fdatasync); pub const fdatasync = call(.fdatasync); @@ -247,8 +251,4 @@ pub const NodeJSFS = struct { const notimpl = fdatasync; pub const opendir = notimpl; pub const opendirSync = notimpl; - pub const readv = notimpl; - pub const readvSync = notimpl; - pub const writev = notimpl; - pub const writevSync = notimpl; }; diff --git a/src/bun.js/node/syscall.zig b/src/bun.js/node/syscall.zig index 77bd5b13d..48c5b1305 100644 --- a/src/bun.js/node/syscall.zig +++ b/src/bun.js/node/syscall.zig @@ -106,6 +106,10 @@ pub const Tag = enum(u8) { waitpid, posix_spawn, getaddrinfo, + writev, + pwritev, + readv, + preadv, pub var strings = std.EnumMap(Tag, JSC.C.JSStringRef).initFull(null); }; const PathString = @import("root").bun.PathString; @@ -302,6 +306,154 @@ pub fn write(fd: os.fd_t, bytes: []const u8) Maybe(usize) { } } +fn veclen(buffers: anytype) usize { + var len: usize = 0; + for (buffers) |buffer| { + len += buffer.iov_len; + } + return len; +} + +pub fn writev(fd: os.fd_t, buffers: []std.os.iovec) Maybe(usize) { + if (comptime Environment.isMac) { + const rc = writev_sym(fd, @ptrCast([*]std.os.iovec_const, buffers.ptr), @intCast(i32, buffers.len)); + if (comptime Environment.allow_assert) + log("writev({d}, {d}) = {d}", .{ fd, veclen(buffers), rc }); + + if (Maybe(usize).errnoSysFd(rc, .writev, fd)) |err| { + return err; + } + + return Maybe(usize){ .result = @intCast(usize, rc) }; + } else { + while (true) { + const rc = writev_sym(fd, @ptrCast([*]std.os.iovec_const, buffers.ptr), buffers.len); + if (comptime Environment.allow_assert) + log("writev({d}, {d}) = {d}", .{ fd, veclen(buffers), rc }); + + if (Maybe(usize).errnoSysFd(rc, .writev, fd)) |err| { + if (err.getErrno() == .INTR) continue; + return err; + } + + return Maybe(usize){ .result = @intCast(usize, rc) }; + } + unreachable; + } +} + +pub fn pwritev(fd: os.fd_t, buffers: []std.os.iovec, position: isize) Maybe(usize) { + if (comptime Environment.isMac) { + const rc = pwritev_sym(fd, @ptrCast([*]std.os.iovec_const, buffers.ptr), @intCast(i32, buffers.len), position); + if (comptime Environment.allow_assert) + log("pwritev({d}, {d}) = {d}", .{ fd, veclen(buffers), rc }); + + if (Maybe(usize).errnoSysFd(rc, .pwritev, fd)) |err| { + return err; + } + + return Maybe(usize){ .result = @intCast(usize, rc) }; + } else { + while (true) { + const rc = pwritev_sym(fd, @ptrCast([*]std.os.iovec_const, buffers.ptr), buffers.len, position); + if (comptime Environment.allow_assert) + log("pwritev({d}, {d}) = {d}", .{ fd, veclen(buffers), rc }); + + if (Maybe(usize).errnoSysFd(rc, .pwritev, fd)) |err| { + if (err.getErrno() == .INTR) continue; + return err; + } + + return Maybe(usize){ .result = @intCast(usize, rc) }; + } + unreachable; + } +} + +pub fn readv(fd: os.fd_t, buffers: []std.os.iovec) Maybe(usize) { + if (comptime Environment.isMac) { + const rc = readv_sym(fd, buffers.ptr, @intCast(i32, buffers.len)); + if (comptime Environment.allow_assert) + log("readv({d}, {d}) = {d}", .{ fd, veclen(buffers), rc }); + + if (Maybe(usize).errnoSysFd(rc, .readv, fd)) |err| { + return err; + } + + return Maybe(usize){ .result = @intCast(usize, rc) }; + } else { + while (true) { + const rc = readv_sym(fd, buffers.ptr, buffers.len); + if (comptime Environment.allow_assert) + log("readv({d}, {d}) = {d}", .{ fd, veclen(buffers), rc }); + + if (Maybe(usize).errnoSysFd(rc, .readv, fd)) |err| { + if (err.getErrno() == .INTR) continue; + return err; + } + + return Maybe(usize){ .result = @intCast(usize, rc) }; + } + unreachable; + } +} + +pub fn preadv(fd: os.fd_t, buffers: []std.os.iovec, position: isize) Maybe(usize) { + if (comptime Environment.isMac) { + const rc = preadv_sym(fd, buffers.ptr, @intCast(i32, buffers.len), position); + if (comptime Environment.allow_assert) + log("preadv({d}, {d}) = {d}", .{ fd, veclen(buffers), rc }); + + if (Maybe(usize).errnoSysFd(rc, .preadv, fd)) |err| { + return err; + } + + return Maybe(usize){ .result = @intCast(usize, rc) }; + } else { + while (true) { + const rc = preadv_sym(fd, buffers.ptr, buffers.len, position); + if (comptime Environment.allow_assert) + log("preadv({d}, {d}) = {d}", .{ fd, veclen(buffers), rc }); + + if (Maybe(usize).errnoSysFd(rc, .preadv, fd)) |err| { + if (err.getErrno() == .INTR) continue; + return err; + } + + return Maybe(usize){ .result = @intCast(usize, rc) }; + } + unreachable; + } +} + +const preadv_sym = if (builtin.os.tag == .linux and builtin.link_libc) + std.os.linux.preadv +else if (builtin.os.tag.isDarwin()) + system.@"preadv$NOCANCEL" +else + system.preadv; + +const readv_sym = if (builtin.os.tag == .linux and builtin.link_libc) + std.os.linux.readv +else if (builtin.os.tag.isDarwin()) + system.@"readv$NOCANCEL" +else + system.readv; + +const pwritev_sym = if (builtin.os.tag == .linux and builtin.link_libc) + std.os.linux.pwritev +else if (builtin.os.tag.isDarwin()) + system.@"pwritev$NOCANCEL" +else + system.pwritev; + +const writev_sym = if (builtin.os.tag == .linux and builtin.link_libc) + std.os.linux.writev +else if (builtin.os.tag.isDarwin()) + system.@"writev$NOCANCEL" +else + system.writev; + const pread_sym = if (builtin.os.tag == .linux and builtin.link_libc) sys.pread64 else if (builtin.os.tag.isDarwin()) diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index 659ac31bb..b01eca8e0 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -813,6 +813,50 @@ pub const Valid = struct { } }; +pub const VectorArrayBuffer = struct { + value: JSC.JSValue, + buffers: std.ArrayList(std.os.iovec), + + pub fn toJS(this: VectorArrayBuffer, _: *JSC.JSGlobalObject) JSC.JSValue { + return this.value; + } + + pub fn fromJS(globalObject: *JSC.JSGlobalObject, val: JSC.JSValue, exception: JSC.C.ExceptionRef, allocator: std.mem.Allocator) ?VectorArrayBuffer { + if (!val.jsType().isArrayLike()) { + JSC.throwInvalidArguments("Expected ArrayBufferView[]", .{}, globalObject, exception); + return null; + } + + var bufferlist = std.ArrayList(std.os.iovec).init(allocator); + var i: usize = 0; + const len = val.getLength(globalObject); + bufferlist.ensureTotalCapacityPrecise(len) catch @panic("Failed to allocate memory for ArrayBuffer[]"); + + while (i < len) { + const element = val.getIndex(globalObject, @truncate(u32, i)); + + if (!element.isCell()) { + JSC.throwInvalidArguments("Expected ArrayBufferView[]", .{}, globalObject, exception); + return null; + } + + const array_buffer = element.asArrayBuffer(globalObject) orelse { + JSC.throwInvalidArguments("Expected ArrayBufferView[]", .{}, globalObject, exception); + return null; + }; + + var buf = array_buffer.byteSlice(); + bufferlist.append(std.os.iovec{ + .iov_base = buf.ptr, + .iov_len = buf.len, + }) catch @panic("Failed to allocate memory for ArrayBuffer[]"); + i += 1; + } + + return VectorArrayBuffer{ .value = val, .buffers = bufferlist }; + } +}; + pub const ArgumentsSlice = struct { remaining: []const JSC.JSValue, vm: *JSC.VirtualMachine, diff --git a/src/io/io_darwin.zig b/src/io/io_darwin.zig index 8045cbdf6..9ebc6f4d6 100644 --- a/src/io/io_darwin.zig +++ b/src/io/io_darwin.zig @@ -274,7 +274,11 @@ pub const darwin = struct { pub extern "c" fn @"openat$NOCANCEL"(fd: c.fd_t, path: [*:0]const u8, oflag: c_uint, ...) c_int; pub extern "c" fn @"read$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize; pub extern "c" fn @"pread$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize; + pub extern "c" fn @"preadv$NOCANCEL"(fd: c.fd_t, uf: [*]std.os.iovec, count: i32, offset: c.off_t) isize; + pub extern "c" fn @"readv$NOCANCEL"(fd: c.fd_t, uf: [*]std.os.iovec, count: i32) isize; pub extern "c" fn @"write$NOCANCEL"(fd: c.fd_t, buf: [*]const u8, nbyte: usize) isize; + pub extern "c" fn @"writev$NOCANCEL"(fd: c.fd_t, buf: [*]std.os.iovec_const, count: i32) isize; + pub extern "c" fn @"pwritev$NOCANCEL"(fd: c.fd_t, buf: [*]std.os.iovec_const, count: i32, offset: c.off_t) isize; }; pub const OpenError = error{ /// In WASI, this error may occur when the file descriptor does diff --git a/src/js/node/fs.js b/src/js/node/fs.js index 8d9f0d235..072102c35 100644 --- a/src/js/node/fs.js +++ b/src/js/node/fs.js @@ -5,9 +5,8 @@ import { EventEmitter } from "node:events"; // Hardcoded module "node:fs" var { direct, isPromise, isCallable } = globalThis[Symbol.for("Bun.lazy")]("primordials"); -export { default as promises } from "node:fs/promises"; import promises from "node:fs/promises"; - +export { default as promises } from "node:fs/promises"; import * as Stream from "node:stream"; var fs = Bun.fs(); @@ -213,6 +212,40 @@ export var access = function access(...args) { lutimesSync = fs.lutimesSync.bind(fs), rmSync = fs.rmSync.bind(fs), rmdirSync = fs.rmdirSync.bind(fs), + writev = (fd, buffers, position, callback) => { + if (typeof position === "function") { + callback = position; + position = null; + } + + queueMicrotask(() => { + try { + var written = fs.writevSync(fd, buffers, position); + } catch (e) { + callback(e); + } + + callback(null, written, buffers); + }); + }, + writevSync = fs.writevSync.bind(fs), + readv = (fd, buffers, position, callback) => { + if (typeof position === "function") { + callback = position; + position = null; + } + + queueMicrotask(() => { + try { + var written = fs.readvSync(fd, buffers, position); + } catch (e) { + callback(e); + } + + callback(null, written, buffers); + }); + }, + readvSync = fs.readvSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch(path, options, listener) { @@ -1069,6 +1102,10 @@ export default { ReadStream, watch, FSWatcher, + writev, + writevSync, + readv, + readvSync, [Symbol.for("::bunternal::")]: { ReadStreamClass, WriteStreamClass, diff --git a/src/js/node/fs.promises.ts b/src/js/node/fs.promises.ts index 7df446ccb..12278ef53 100644 --- a/src/js/node/fs.promises.ts +++ b/src/js/node/fs.promises.ts @@ -123,7 +123,37 @@ export var access = promisify(fs.accessSync), utimes = promisify(fs.utimesSync), lutimes = promisify(fs.lutimesSync), rm = promisify(fs.rmSync), - rmdir = promisify(fs.rmdirSync); + rmdir = promisify(fs.rmdirSync), + writev = (fd, buffers, position) => { + return new Promise((resolve, reject) => { + try { + var bytesWritten = fs.writevSync(fd, buffers, position); + } catch (err) { + reject(err); + return; + } + + resolve({ + bytesWritten, + buffers, + }); + }); + }, + readv = (fd, buffers, position) => { + return new Promise((resolve, reject) => { + try { + var bytesRead = fs.readvSync(fd, buffers, position); + } catch (err) { + reject(err); + return; + } + + resolve({ + bytesRead, + buffers, + }); + }); + }; export default { access, @@ -163,6 +193,8 @@ export default { rm, rmdir, watch, + writev, + readv, constants, [Symbol.for("CommonJS")]: 0, }; diff --git a/src/js/out/modules/node/fs.js b/src/js/out/modules/node/fs.js index 6c8269d59..b7457f104 100644 --- a/src/js/out/modules/node/fs.js +++ b/src/js/out/modules/node/fs.js @@ -1,6 +1,6 @@ import {EventEmitter} from "node:events"; -import {default as default2} from "node:fs/promises"; import promises2 from "node:fs/promises"; +import {default as default2} from "node:fs/promises"; import * as Stream from "node:stream"; var callbackify = function(fsFunction, args) { try { @@ -133,7 +133,29 @@ var access = function access2(...args) { callbackify(fs.utimesSync, args); }, lutimes = function lutimes2(...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) { +}, 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), writev = (fd, buffers, position, callback) => { + if (typeof position === "function") + callback = position, position = null; + queueMicrotask(() => { + try { + var written = fs.writevSync(fd, buffers, position); + } catch (e) { + callback(e); + } + callback(null, written, buffers); + }); +}, writevSync = fs.writevSync.bind(fs), readv = (fd, buffers, position, callback) => { + if (typeof position === "function") + callback = position, position = null; + queueMicrotask(() => { + try { + var written = fs.readvSync(fd, buffers, position); + } catch (e) { + callback(e); + } + callback(null, written, buffers); + }); +}, readvSync = fs.readvSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch2(path, options, listener) { return new FSWatcher(path, options, listener); }, 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, @@ -366,8 +388,8 @@ WriteStream = function(InternalWriteStream) { return WriteStreamClass = InternalWriteStream, Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, { value: "WritesStream", enumerable: !1 - }), Object.defineProperty(function WriteStream(options) { - return new InternalWriteStream(options); + }), Object.defineProperty(function WriteStream(path, options) { + return new InternalWriteStream(path, options); }, Symbol.hasInstance, { value(instance) { return instance instanceof InternalWriteStream; @@ -642,12 +664,18 @@ var fs_default = { ReadStream, watch, FSWatcher, + writev, + writevSync, + readv, + readvSync, [Symbol.for("::bunternal::")]: { ReadStreamClass, WriteStreamClass } }; export { + writevSync, + writev, writeSync, writeFileSync, writeFile, @@ -671,6 +699,8 @@ export { rename, realpathSync, realpath, + readvSync, + readv, readlinkSync, readlink, readdirSync, diff --git a/src/js/out/modules/node/fs.promises.js b/src/js/out/modules/node/fs.promises.js index ef3330771..549ba0c9c 100644 --- a/src/js/out/modules/node/fs.promises.js +++ b/src/js/out/modules/node/fs.promises.js @@ -1 +1 @@ -function H(S,C={}){const J=[];if(S instanceof URL)throw new TypeError("Watch URLs are not supported yet");else if(Buffer.isBuffer(S))S=S.toString();else if(typeof S!=="string")throw new TypeError("Expected path to be a string or Buffer");let b=null;if(typeof C==="string")C={encoding:C};return D.watch(S,C||{},(q,z)=>{if(J.push({eventType:q,filename:z}),b){const A=b;b=null,A()}}),{async*[Symbol.asyncIterator](){let q=!1;while(!q){while(J.length){let z=J.shift();if(z.eventType==="close"){q=!0;break}if(z.eventType==="error")throw q=!0,z.filename;yield z}await new Promise((z)=>b=z)}}}}var D=Bun.fs(),B="::bunternal::",G={[B]:(S)=>{var C={[B]:function(J,b,q){var z;try{z=S.apply(D,q),q=void 0}catch(A){q=void 0,b(A);return}J(z)}}[B];return async function(...J){return await new Promise((b,q)=>{process.nextTick(C,b,q,J)})}}}[B],I=G(D.accessSync),K=G(D.appendFileSync),L=G(D.closeSync),M=G(D.copyFileSync),N=G(D.existsSync),O=G(D.chownSync),P=G(D.chmodSync),Q=G(D.fchmodSync),U=G(D.fchownSync),V=G(D.fstatSync),W=G(D.fsyncSync),X=G(D.ftruncateSync),Y=G(D.futimesSync),Z=G(D.lchmodSync),_=G(D.lchownSync),$=G(D.linkSync),T=G(D.lstatSync),E=G(D.mkdirSync),j=G(D.mkdtempSync),R=G(D.openSync),k=G(D.readSync),x=G(D.writeSync),F=G(D.readdirSync),u=G(D.readFileSync),w=G(D.writeFileSync),g=G(D.readlinkSync),h=G(D.realpathSync),d=G(D.renameSync),c=G(D.statSync),v=G(D.symlinkSync),a=G(D.truncateSync),y=G(D.unlinkSync),l=G(D.utimesSync),t=G(D.lutimesSync),p=G(D.rmSync),n=G(D.rmdirSync),m={access:I,appendFile:K,close:L,copyFile:M,exists:N,chown:O,chmod:P,fchmod:Q,fchown:U,fstat:V,fsync:W,ftruncate:X,futimes:Y,lchmod:Z,lchown:_,link:$,lstat:T,mkdir:E,mkdtemp:j,open:R,read:k,write:x,readdir:F,readFile:u,writeFile:w,readlink:g,realpath:h,rename:d,stat:c,symlink:v,truncate:a,unlink:y,utimes:l,lutimes:t,rm:p,rmdir:n,watch:H,constants,[Symbol.for("CommonJS")]:0};export{w as writeFile,x as write,H as watch,l as utimes,y as unlink,a as truncate,v as symlink,c as stat,n as rmdir,p as rm,d as rename,h as realpath,g as readlink,F as readdir,u as readFile,k as read,R as open,j as mkdtemp,E as mkdir,t as lutimes,T as lstat,$ as link,_ as lchown,Z as lchmod,Y as futimes,X as ftruncate,W as fsync,V as fstat,U as fchown,Q as fchmod,N as exists,m as default,M as copyFile,L as close,O as chown,P as chmod,K as appendFile,I as access}; +function J(S,q={}){const z=[];if(S instanceof URL)throw new TypeError("Watch URLs are not supported yet");else if(Buffer.isBuffer(S))S=S.toString();else if(typeof S!=="string")throw new TypeError("Expected path to be a string or Buffer");let A=null;if(typeof q==="string")q={encoding:q};return H.watch(S,q||{},(B,C)=>{if(z.push({eventType:B,filename:C}),A){const D=A;A=null,D()}}),{async*[Symbol.asyncIterator](){let B=!1;while(!B){while(z.length){let C=z.shift();if(C.eventType==="close"){B=!0;break}if(C.eventType==="error")throw B=!0,C.filename;yield C}await new Promise((C)=>A=C)}}}}var H=Bun.fs(),G="::bunternal::",I={[G]:(S)=>{var q={[G]:function(z,A,B){var C;try{C=S.apply(H,B),B=void 0}catch(D){B=void 0,A(D);return}z(C)}}[G];return async function(...z){return await new Promise((A,B)=>{process.nextTick(q,A,B,z)})}}}[G],K=I(H.accessSync),L=I(H.appendFileSync),M=I(H.closeSync),N=I(H.copyFileSync),O=I(H.existsSync),P=I(H.chownSync),Q=I(H.chmodSync),U=I(H.fchmodSync),V=I(H.fchownSync),X=I(H.fstatSync),Y=I(H.fsyncSync),Z=I(H.ftruncateSync),_=I(H.futimesSync),$=I(H.lchmodSync),T=I(H.lchownSync),W=I(H.linkSync),k=I(H.lstatSync),E=I(H.mkdirSync),x=I(H.mkdtempSync),F=I(H.openSync),R=I(H.readSync),g=I(H.writeSync),h=I(H.readdirSync),j=I(H.readFileSync),w=I(H.writeFileSync),b=I(H.readlinkSync),u=I(H.realpathSync),d=I(H.renameSync),c=I(H.statSync),v=I(H.symlinkSync),a=I(H.truncateSync),y=I(H.unlinkSync),l=I(H.utimesSync),p=I(H.lutimesSync),m=I(H.rmSync),n=I(H.rmdirSync),t=(S,q,z)=>{return new Promise((A,B)=>{try{var C=H.writevSync(S,q,z)}catch(D){B(D);return}A({bytesWritten:C,buffers:q})})},o=(S,q,z)=>{return new Promise((A,B)=>{try{var C=H.readvSync(S,q,z)}catch(D){B(D);return}A({bytesRead:C,buffers:q})})},r={access:K,appendFile:L,close:M,copyFile:N,exists:O,chown:P,chmod:Q,fchmod:U,fchown:V,fstat:X,fsync:Y,ftruncate:Z,futimes:_,lchmod:$,lchown:T,link:W,lstat:k,mkdir:E,mkdtemp:x,open:F,read:R,write:g,readdir:h,readFile:j,writeFile:w,readlink:b,realpath:u,rename:d,stat:c,symlink:v,truncate:a,unlink:y,utimes:l,lutimes:p,rm:m,rmdir:n,watch:J,writev:t,readv:o,constants,[Symbol.for("CommonJS")]:0};export{t as writev,w as writeFile,g as write,J as watch,l as utimes,y as unlink,a as truncate,v as symlink,c as stat,n as rmdir,m as rm,d as rename,u as realpath,o as readv,b as readlink,h as readdir,j as readFile,R as read,F as open,x as mkdtemp,E as mkdir,p as lutimes,k as lstat,W as link,T as lchown,$ as lchmod,_ as futimes,Z as ftruncate,Y as fsync,X as fstat,V as fchown,U as fchmod,O as exists,r as default,N as copyFile,M as close,P as chown,Q as chmod,L as appendFile,K as access}; diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index 0353968fe..272522fc0 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -29,6 +29,8 @@ import fs, { realpathSync, readlinkSync, symlinkSync, + writevSync, + readvSync, } from "node:fs"; import _promises from "node:fs/promises"; @@ -301,6 +303,69 @@ describe("readSync", () => { }); }); +it("writevSync", () => { + var fd = openSync(`${tmpdir()}/writevSync.txt`, "w"); + fs.ftruncateSync(fd, 0); + const buffers = [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]), new Uint8Array([7, 8, 9])]; + const result = writevSync(fd, buffers); + expect(result).toBe(9); + closeSync(fd); + + fd = openSync(`${tmpdir()}/writevSync.txt`, "r"); + const buf = new Uint8Array(9); + readSync(fd, buf, 0, 9, 0); + expect(buf).toEqual(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9])); +}); + +it("pwritevSync", () => { + var fd = openSync(`${tmpdir()}/pwritevSync.txt`, "w"); + fs.ftruncateSync(fd, 0); + writeSync(fd, "lalalala", 0); + const buffers = [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]), new Uint8Array([7, 8, 9])]; + const result = writevSync(fd, buffers, "lalalala".length); + expect(result).toBe(9); + closeSync(fd); + + const out = readFileSync(`${tmpdir()}/pwritevSync.txt`); + expect(out.slice(0, "lalalala".length).toString()).toBe("lalalala"); + expect(out.slice("lalalala".length)).toEqual(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9])); +}); + +it("readvSync", () => { + var fd = openSync(`${tmpdir()}/readv.txt`, "w"); + fs.ftruncateSync(fd, 0); + + const buf = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]); + writeSync(fd, buf, 0, 9, 0); + closeSync(fd); + + var fd = openSync(`${tmpdir()}/readv.txt`, "r"); + const buffers = [new Uint8Array(3), new Uint8Array(3), new Uint8Array(3)]; + const result = readvSync(fd, buffers); + expect(result).toBe(9); + expect(buffers[0]).toEqual(new Uint8Array([1, 2, 3])); + expect(buffers[1]).toEqual(new Uint8Array([4, 5, 6])); + expect(buffers[2]).toEqual(new Uint8Array([7, 8, 9])); + closeSync(fd); +}); + +it("preadv", () => { + var fd = openSync(`${tmpdir()}/preadv.txt`, "w"); + fs.ftruncateSync(fd, 0); + + const buf = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); + writeSync(fd, buf, 0, buf.byteLength, 0); + closeSync(fd); + + var fd = openSync(`${tmpdir()}/preadv.txt`, "r"); + const buffers = [new Uint8Array(3), new Uint8Array(3), new Uint8Array(3)]; + const result = readvSync(fd, buffers, 3); + expect(result).toBe(9); + expect(buffers[0]).toEqual(new Uint8Array([4, 5, 6])); + expect(buffers[1]).toEqual(new Uint8Array([7, 8, 9])); + expect(buffers[2]).toEqual(new Uint8Array([10, 11, 12])); +}); + describe("writeSync", () => { it("works with a position set to 0", () => { const fd = openSync(import.meta.dir + "/writeFileSync.txt", "w+"); -- cgit v1.2.3 From 6d01e6e367fd518884883ce8194c3c7322043639 Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Mon, 26 Jun 2023 12:09:05 -0700 Subject: test moved to `node-module-module.test.js` --- test/js/bun/resolve/import-meta.test.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/js/bun/resolve/import-meta.test.js b/test/js/bun/resolve/import-meta.test.js index d6d145520..2d79c531e 100644 --- a/test/js/bun/resolve/import-meta.test.js +++ b/test/js/bun/resolve/import-meta.test.js @@ -90,12 +90,6 @@ it("Module.createRequire().resolve", () => { expect(result).toBe(expected); }); -// this is stubbed out -it("Module._nodeModulePaths()", () => { - const expected = Module._nodeModulePaths(); - expect(!!expected).toBe(true); -}); - // this isn't used in bun but exists anyway // we just want it to not be undefined it("Module._cache", () => { -- cgit v1.2.3 From a732999da578ca92a1d9e633036225a32e77529d Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 26 Jun 2023 12:49:20 -0700 Subject: Runtime support for `__esModule` annotations (#3393) * Runtime support for `__esModule` annotations * Ignore `__esModule` annotation when `"type": "module"` is set --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/CommonJSModuleRecord.cpp | 113 +++++++++++++++++++-- src/bun.js/bindings/CommonJSModuleRecord.h | 1 + src/bun.js/bindings/exports.zig | 7 +- src/bun.js/bindings/headers-handwritten.h | 1 + src/bun.js/module_loader.zig | 21 ++++ src/js/builtins/BunBuiltinNames.h | 7 +- test/js/bun/resolve/esModule-annotation.test.js | 68 +++++++++++++ .../export-esModule-annotation-empty.cjs | 1 + .../export-esModule-annotation-no-default.cjs | 1 + .../export-esModule-annotation.cjs | 2 + .../export-esModule-no-annotation.cjs | 1 + test/js/bun/resolve/with-type-module/package.json | 4 + .../export-esModule-annotation-empty.cjs | 1 + .../export-esModule-annotation-no-default.cjs | 1 + .../export-esModule-annotation.cjs | 2 + .../export-esModule-no-annotation.cjs | 1 + .../bun/resolve/without-type-module/package.json | 4 + 17 files changed, 221 insertions(+), 15 deletions(-) create mode 100644 test/js/bun/resolve/esModule-annotation.test.js create mode 100644 test/js/bun/resolve/with-type-module/export-esModule-annotation-empty.cjs create mode 100644 test/js/bun/resolve/with-type-module/export-esModule-annotation-no-default.cjs create mode 100644 test/js/bun/resolve/with-type-module/export-esModule-annotation.cjs create mode 100644 test/js/bun/resolve/with-type-module/export-esModule-no-annotation.cjs create mode 100644 test/js/bun/resolve/with-type-module/package.json create mode 100644 test/js/bun/resolve/without-type-module/export-esModule-annotation-empty.cjs create mode 100644 test/js/bun/resolve/without-type-module/export-esModule-annotation-no-default.cjs create mode 100644 test/js/bun/resolve/without-type-module/export-esModule-annotation.cjs create mode 100644 test/js/bun/resolve/without-type-module/export-esModule-no-annotation.cjs create mode 100644 test/js/bun/resolve/without-type-module/package.json diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index 3615db774..c7dac89c2 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -586,13 +586,41 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject, 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)); + // Bun's intepretation of the "__esModule" annotation: + // + // - If a "default" export does not exist OR the __esModule annotation is not present, then we + // set the default export to the exports object + // + // - If a "default" export also exists, then we set the default export + // to the value of it (matching Babel behavior) + // + // https://stackoverflow.com/questions/50943704/whats-the-purpose-of-object-definepropertyexports-esmodule-value-0 + // https://github.com/nodejs/node/issues/40891 + // https://github.com/evanw/bundler-esm-cjs-tests + // https://github.com/evanw/esbuild/issues/1591 + // https://github.com/oven-sh/bun/issues/3383 + // + // Note that this interpretation is slightly different + // + // - We do not ignore when "type": "module" or when the file + // extension is ".mjs". Build tools determine that based on the + // caller's behavior, but in a JS runtime, there is only one ModuleNamespaceObject. + // + // It would be possible to match the behavior at runtime, but + // it would need further engine changes which do not match the ES Module spec + // + // - We ignore the value of the annotation. We only look for the + // existence of the value being set. This is for performance reasons, but also + // this annotation is meant for tooling and the only usages of setting + // it to something that does NOT evaluate to "true" I could find were in + // unit tests of build tools. Happy to revisit this if users file an issue. + bool needsToAssignDefault = true; + if (result.isObject()) { auto* exports = asObject(result); @@ -601,21 +629,78 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject, exportNames.reserveCapacity(size + 2); exportValues.ensureCapacity(size + 2); - if (canPerformFastEnumeration(structure)) { + auto catchScope = DECLARE_CATCH_SCOPE(vm); + + Identifier esModuleMarker = builtinNames(vm).__esModulePublicName(); + bool hasESModuleMarker = !this->ignoreESModuleAnnotation && exports->hasProperty(globalObject, esModuleMarker); + if (catchScope.exception()) { + catchScope.clearException(); + } + + if (hasESModuleMarker) { + if (canPerformFastEnumeration(structure)) { + exports->structure()->forEachProperty(vm, [&](const PropertyTableEntry& entry) -> bool { + auto key = entry.key(); + if (key->isSymbol() || entry.attributes() & PropertyAttribute::DontEnum || key == esModuleMarker) + return true; + + needsToAssignDefault = needsToAssignDefault && key != vm.propertyNames->defaultKeyword; + + JSValue value = exports->getDirect(entry.offset()); + exportNames.append(Identifier::fromUid(vm, key)); + exportValues.append(value); + return true; + }); + } else { + 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 == esModuleMarker || property.isPrivateName() || property.isSymbol())) + continue; + + // ignore constructor + if (property == vm.propertyNames->constructor) + continue; + + JSC::PropertySlot slot(exports, PropertySlot::InternalMethodType::Get); + if (!exports->getPropertySlot(globalObject, property, slot)) + continue; + + exportNames.append(property); + + 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); + + needsToAssignDefault = needsToAssignDefault && property != vm.propertyNames->defaultKeyword; + } + } + + } else 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) + if (key->isSymbol() || entry.attributes() & PropertyAttribute::DontEnum || key == vm.propertyNames->defaultKeyword) return true; - exportNames.append(Identifier::fromUid(vm, key)); - JSValue value = exports->getDirect(entry.offset()); + exportNames.append(Identifier::fromUid(vm, key)); 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()) { @@ -624,11 +709,11 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject, } for (auto property : properties) { - if (UNLIKELY(property.isEmpty() || property.isNull() || property.isPrivateName() || property.isSymbol())) + if (UNLIKELY(property.isEmpty() || property.isNull() || property == vm.propertyNames->defaultKeyword || property.isPrivateName() || property.isSymbol())) continue; // ignore constructor - if (property == vm.propertyNames->constructor || property == vm.propertyNames->defaultKeyword) + if (property == vm.propertyNames->constructor) continue; JSC::PropertySlot slot(exports, PropertySlot::InternalMethodType::Get); @@ -650,6 +735,11 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject, } } } + + if (needsToAssignDefault) { + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(result); + } } JSValue JSCommonJSModule::exportsObject() @@ -759,6 +849,7 @@ bool JSCommonJSModule::evaluate( { auto& vm = globalObject->vm(); auto sourceProvider = Zig::SourceProvider::create(jsCast(globalObject), source, JSC::SourceProviderSourceType::Program); + this->ignoreESModuleAnnotation = source.tag == ResolvedSourceTagPackageJSONTypeModule; JSC::SourceCode rawInputSource( WTFMove(sourceProvider)); @@ -766,6 +857,7 @@ bool JSCommonJSModule::evaluate( return true; this->sourceCode.set(vm, this, JSC::JSSourceCode::create(vm, WTFMove(rawInputSource))); + WTF::NakedPtr exception; evaluateCommonJSModuleOnce(vm, globalObject, this, this->m_dirname.get(), this->m_filename.get(), exception); @@ -796,6 +888,7 @@ std::optional createCommonJSModule( JSValue entry = globalObject->requireMap()->get(globalObject, specifierValue); auto sourceProvider = Zig::SourceProvider::create(jsCast(globalObject), source, JSC::SourceProviderSourceType::Program); + bool ignoreESModuleAnnotation = source.tag == ResolvedSourceTagPackageJSONTypeModule; SourceOrigin sourceOrigin = sourceProvider->sourceOrigin(); if (entry) { @@ -827,6 +920,8 @@ std::optional createCommonJSModule( globalObject->requireMap()->set(globalObject, requireMapKey, moduleObject); } + moduleObject->ignoreESModuleAnnotation = ignoreESModuleAnnotation; + return JSC::SourceCode( JSC::SyntheticSourceProvider::create( [](JSC::JSGlobalObject* lexicalGlobalObject, diff --git a/src/bun.js/bindings/CommonJSModuleRecord.h b/src/bun.js/bindings/CommonJSModuleRecord.h index a96ab5f75..15792f9da 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.h +++ b/src/bun.js/bindings/CommonJSModuleRecord.h @@ -26,6 +26,7 @@ public: mutable JSC::WriteBarrier m_dirname; mutable JSC::WriteBarrier m_paths; mutable JSC::WriteBarrier sourceCode; + bool ignoreESModuleAnnotation { false }; static void destroy(JSC::JSCell*); ~JSCommonJSModule(); diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index f77b57216..213291e7b 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -216,9 +216,10 @@ pub const ResolvedSource = extern struct { pub const Tag = enum(u64) { javascript = 0, - wasm = 1, - object = 2, - file = 3, + package_json_type_module = 1, + wasm = 2, + object = 3, + file = 4, @"node:buffer" = 1024, @"node:process" = 1025, diff --git a/src/bun.js/bindings/headers-handwritten.h b/src/bun.js/bindings/headers-handwritten.h index 57940550f..db1e38d3e 100644 --- a/src/bun.js/bindings/headers-handwritten.h +++ b/src/bun.js/bindings/headers-handwritten.h @@ -72,6 +72,7 @@ typedef struct ResolvedSource { void* allocator; uint64_t tag; } ResolvedSource; +static const uint64_t ResolvedSourceTagPackageJSONTypeModule = 1; typedef union ErrorableResolvedSourceResult { ResolvedSource value; ZigErrorType err; diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index 5838d8a49..b25bb4b10 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -1225,6 +1225,25 @@ pub const ModuleLoader = struct { return resolved_source; } + // Pass along package.json type "module" if set. + const tag = brk: { + if (parse_result.ast.exports_kind == .cjs and parse_result.source.path.isFile()) { + var actual_package_json: *PackageJSON = package_json orelse brk2: { + // this should already be cached virtually always so it's fine to do this + var dir_info = (jsc_vm.bundler.resolver.readDirInfo(parse_result.source.path.name.dir) catch null) orelse + break :brk .javascript; + + break :brk2 dir_info.package_json orelse dir_info.enclosing_package_json; + } orelse break :brk .javascript; + + if (actual_package_json.module_type == .esm) { + break :brk ResolvedSource.Tag.package_json_type_module; + } + } + + break :brk ResolvedSource.Tag.javascript; + }; + return .{ .allocator = null, .source_code = bun.String.createLatin1(printer.ctx.getWritten()), @@ -1245,6 +1264,8 @@ pub const ModuleLoader = struct { // having JSC own the memory causes crashes .hash = 0, + + .tag = tag, }; }, // provideFetch() should be called diff --git a/src/js/builtins/BunBuiltinNames.h b/src/js/builtins/BunBuiltinNames.h index af9291918..1897f939e 100644 --- a/src/js/builtins/BunBuiltinNames.h +++ b/src/js/builtins/BunBuiltinNames.h @@ -37,6 +37,7 @@ using namespace JSC; macro(WritableStream) \ macro(WritableStreamDefaultController) \ macro(WritableStreamDefaultWriter) \ + macro(__esModule) \ macro(_events) \ macro(abortAlgorithm) \ macro(abortSteps) \ @@ -59,11 +60,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) \ @@ -94,6 +95,7 @@ using namespace JSC; macro(end) \ macro(errno) \ macro(errorSteps) \ + macro(evaluateCommonJSModule) \ macro(execArgv) \ macro(exports) \ macro(extname) \ @@ -137,7 +139,6 @@ using namespace JSC; macro(lazyLoad) \ macro(lazyStreamPrototypeMap) \ macro(loadCJS2ESM) \ - macro(evaluateCommonJSModule) \ macro(localStreams) \ macro(main) \ macro(makeDOMException) \ diff --git a/test/js/bun/resolve/esModule-annotation.test.js b/test/js/bun/resolve/esModule-annotation.test.js new file mode 100644 index 000000000..33c84be5d --- /dev/null +++ b/test/js/bun/resolve/esModule-annotation.test.js @@ -0,0 +1,68 @@ +import { test, expect, describe } from "bun:test"; +import * as WithTypeModuleExportEsModuleAnnotationMissingDefault from "./with-type-module/export-esModule-annotation-empty.cjs"; +import * as WithTypeModuleExportEsModuleAnnotationNoDefault from "./with-type-module/export-esModule-annotation-no-default.cjs"; +import * as WithTypeModuleExportEsModuleAnnotation from "./with-type-module/export-esModule-annotation.cjs"; +import * as WithTypeModuleExportEsModuleNoAnnotation from "./with-type-module/export-esModule-no-annotation.cjs"; +import * as WithoutTypeModuleExportEsModuleAnnotationMissingDefault from "./without-type-module/export-esModule-annotation-empty.cjs"; +import * as WithoutTypeModuleExportEsModuleAnnotationNoDefault from "./without-type-module/export-esModule-annotation-no-default.cjs"; +import * as WithoutTypeModuleExportEsModuleAnnotation from "./without-type-module/export-esModule-annotation.cjs"; +import * as WithoutTypeModuleExportEsModuleNoAnnotation from "./without-type-module/export-esModule-no-annotation.cjs"; + +describe('without type: "module"', () => { + test("module.exports = {}", () => { + expect(WithoutTypeModuleExportEsModuleAnnotationMissingDefault.default).toEqual({}); + expect(WithoutTypeModuleExportEsModuleAnnotationMissingDefault.__esModule).toBeUndefined(); + }); + + test("exports.__esModule = true", () => { + expect(WithoutTypeModuleExportEsModuleAnnotationNoDefault.default).toEqual({ + __esModule: true, + }); + + // The module namespace object will not have the __esModule property. + expect(WithoutTypeModuleExportEsModuleAnnotationNoDefault).not.toHaveProperty("__esModule"); + }); + + test("exports.default = true; exports.__esModule = true;", () => { + expect(WithoutTypeModuleExportEsModuleAnnotation.default).toBeTrue(); + expect(WithoutTypeModuleExportEsModuleAnnotation.__esModule).toBeUndefined(); + }); + + test("exports.default = true;", () => { + expect(WithoutTypeModuleExportEsModuleNoAnnotation.default).toEqual({ + default: true, + }); + expect(WithoutTypeModuleExportEsModuleAnnotation.__esModule).toBeUndefined(); + }); +}); + +describe('with type: "module"', () => { + test("module.exports = {}", () => { + expect(WithTypeModuleExportEsModuleAnnotationMissingDefault.default).toEqual({}); + expect(WithTypeModuleExportEsModuleAnnotationMissingDefault.__esModule).toBeUndefined(); + }); + + test("exports.__esModule = true", () => { + expect(WithTypeModuleExportEsModuleAnnotationNoDefault.default).toEqual({ + __esModule: true, + }); + + // The module namespace object WILL have the __esModule property. + expect(WithTypeModuleExportEsModuleAnnotationNoDefault).toHaveProperty("__esModule"); + }); + + test("exports.default = true; exports.__esModule = true;", () => { + expect(WithTypeModuleExportEsModuleAnnotation.default).toEqual({ + default: true, + __esModule: true, + }); + expect(WithTypeModuleExportEsModuleAnnotation.__esModule).toBeTrue(); + }); + + test("exports.default = true;", () => { + expect(WithTypeModuleExportEsModuleNoAnnotation.default).toEqual({ + default: true, + }); + expect(WithTypeModuleExportEsModuleAnnotation.__esModule).toBeTrue(); + }); +}); diff --git a/test/js/bun/resolve/with-type-module/export-esModule-annotation-empty.cjs b/test/js/bun/resolve/with-type-module/export-esModule-annotation-empty.cjs new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/test/js/bun/resolve/with-type-module/export-esModule-annotation-empty.cjs @@ -0,0 +1 @@ +module.exports = {}; diff --git a/test/js/bun/resolve/with-type-module/export-esModule-annotation-no-default.cjs b/test/js/bun/resolve/with-type-module/export-esModule-annotation-no-default.cjs new file mode 100644 index 000000000..32b83d4a5 --- /dev/null +++ b/test/js/bun/resolve/with-type-module/export-esModule-annotation-no-default.cjs @@ -0,0 +1 @@ +exports.__esModule = true; diff --git a/test/js/bun/resolve/with-type-module/export-esModule-annotation.cjs b/test/js/bun/resolve/with-type-module/export-esModule-annotation.cjs new file mode 100644 index 000000000..bc0625a0c --- /dev/null +++ b/test/js/bun/resolve/with-type-module/export-esModule-annotation.cjs @@ -0,0 +1,2 @@ +exports.default = true; +exports.__esModule = true; diff --git a/test/js/bun/resolve/with-type-module/export-esModule-no-annotation.cjs b/test/js/bun/resolve/with-type-module/export-esModule-no-annotation.cjs new file mode 100644 index 000000000..a4b65815f --- /dev/null +++ b/test/js/bun/resolve/with-type-module/export-esModule-no-annotation.cjs @@ -0,0 +1 @@ +exports.default = true; diff --git a/test/js/bun/resolve/with-type-module/package.json b/test/js/bun/resolve/with-type-module/package.json new file mode 100644 index 000000000..f1863a426 --- /dev/null +++ b/test/js/bun/resolve/with-type-module/package.json @@ -0,0 +1,4 @@ +{ + "name": "with-type-module", + "type": "module" +} diff --git a/test/js/bun/resolve/without-type-module/export-esModule-annotation-empty.cjs b/test/js/bun/resolve/without-type-module/export-esModule-annotation-empty.cjs new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/test/js/bun/resolve/without-type-module/export-esModule-annotation-empty.cjs @@ -0,0 +1 @@ +module.exports = {}; diff --git a/test/js/bun/resolve/without-type-module/export-esModule-annotation-no-default.cjs b/test/js/bun/resolve/without-type-module/export-esModule-annotation-no-default.cjs new file mode 100644 index 000000000..32b83d4a5 --- /dev/null +++ b/test/js/bun/resolve/without-type-module/export-esModule-annotation-no-default.cjs @@ -0,0 +1 @@ +exports.__esModule = true; diff --git a/test/js/bun/resolve/without-type-module/export-esModule-annotation.cjs b/test/js/bun/resolve/without-type-module/export-esModule-annotation.cjs new file mode 100644 index 000000000..bc0625a0c --- /dev/null +++ b/test/js/bun/resolve/without-type-module/export-esModule-annotation.cjs @@ -0,0 +1,2 @@ +exports.default = true; +exports.__esModule = true; diff --git a/test/js/bun/resolve/without-type-module/export-esModule-no-annotation.cjs b/test/js/bun/resolve/without-type-module/export-esModule-no-annotation.cjs new file mode 100644 index 000000000..a4b65815f --- /dev/null +++ b/test/js/bun/resolve/without-type-module/export-esModule-no-annotation.cjs @@ -0,0 +1 @@ +exports.default = true; diff --git a/test/js/bun/resolve/without-type-module/package.json b/test/js/bun/resolve/without-type-module/package.json new file mode 100644 index 000000000..5b290db1c --- /dev/null +++ b/test/js/bun/resolve/without-type-module/package.json @@ -0,0 +1,4 @@ +{ + "name": "without-type-module", + "type": "commonjs" +} -- cgit v1.2.3 From 16598555f137112a3df2da5d8f2ee8edb496484f Mon Sep 17 00:00:00 2001 From: Silas Rech Date: Tue, 27 Jun 2023 00:35:48 +0200 Subject: `.randomInt()` support (#3357) * Add initial .randomInt() fallback * Add basic .randomInt() test * Attempt creating a native implementation * Switch to JSC.wrapWithHasContainer * Switch to .jsNumberFromUint64(), it seems like using just .jsNumber() causes the number to overflow in some cases * Regenerate out folder after rebasing --- bench/snippets/crypto.mjs | 4 ++++ src/bun.js/bindings/JSSinkLookupTable.h | 2 +- src/bun.js/bindings/bindings.zig | 1 + src/bun.js/webcore.zig | 20 ++++++++++++++++++++ src/js/node/crypto.js | 2 ++ src/js/out/modules/node/crypto.js | 8 ++++---- test/js/node/crypto/node-crypto.test.js | 21 +++++++++++++++++++++ 7 files changed, 53 insertions(+), 5 deletions(-) diff --git a/bench/snippets/crypto.mjs b/bench/snippets/crypto.mjs index b0b992a0f..e8e6f2f8a 100644 --- a/bench/snippets/crypto.mjs +++ b/bench/snippets/crypto.mjs @@ -22,4 +22,8 @@ bench("crypto.randomUUID()", () => { return crypto.randomUUID()[2]; }); +bench("crypto.randomInt()", () => { + return crypto.randomInt(); +}); + await run(); diff --git a/src/bun.js/bindings/JSSinkLookupTable.h b/src/bun.js/bindings/JSSinkLookupTable.h index e4ed81629..f8518bc5e 100644 --- a/src/bun.js/bindings/JSSinkLookupTable.h +++ b/src/bun.js/bindings/JSSinkLookupTable.h @@ -1,4 +1,4 @@ -// Automatically generated from src/bun.js/bindings/JSSink.cpp using /home/cirospaciari/Repos/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! +// Automatically generated from src/bun.js/bindings/JSSink.cpp using /Users/silas/Workspace/opensource/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 00833c71d..2b800ab8b 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -5568,6 +5568,7 @@ pub const __DOMCall__reader_u64 = @import("../api/bun.zig").FFI.Reader.Class.fun pub const __DOMCall__reader_intptr = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.intptr; pub const __Crypto_getRandomValues = @import("../webcore.zig").Crypto.Class.functionDefinitions.getRandomValues; pub const __Crypto_randomUUID = @import("../webcore.zig").Crypto.Class.functionDefinitions.randomUUID; +pub const __Crypto_randomInt = @import("../webcore.zig").Crypto.Class.functionDefinitions.randomInt; pub const __Crypto_timingSafeEqual = @import("../webcore.zig").Crypto.Class.functionDefinitions.timingSafeEqual; pub const DOMCalls = .{ @import("../api/bun.zig").FFI, diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig index a5009e09e..fd69b0262 100644 --- a/src/bun.js/webcore.zig +++ b/src/bun.js/webcore.zig @@ -10,6 +10,7 @@ const std = @import("std"); const bun = @import("root").bun; const string = bun.string; pub const AbortSignal = @import("./bindings/bindings.zig").AbortSignal; +pub const JSValue = @import("./bindings/bindings.zig").JSValue; pub const Lifetime = enum { clone, @@ -374,6 +375,7 @@ pub const Crypto = struct { .getRandomValues = JSC.DOMCall("Crypto", @This(), "getRandomValues", JSC.JSValue, JSC.DOMEffect.top), .randomUUID = JSC.DOMCall("Crypto", @This(), "randomUUID", *JSC.JSString, JSC.DOMEffect.top), .timingSafeEqual = JSC.DOMCall("Crypto", @This(), "timingSafeEqual", JSC.JSValue, JSC.DOMEffect.top), + .randomInt = .{ .rfn = &JSC.wrapWithHasContainer(Crypto, "randomInt", false, false, false) }, .scryptSync = .{ .rfn = &JSC.wrapWithHasContainer(Crypto, "scryptSync", false, false, false) }, }, .{}, @@ -698,6 +700,24 @@ pub const Crypto = struct { return JSC.ZigString.init(&out).toValueGC(globalThis); } + pub fn randomInt(globalThis: *JSC.JSGlobalObject, min_value: ?JSValue, max_value: ?JSValue) JSValue { + _ = globalThis; + + var at_least: u52 = 0; + var at_most: u52 = std.math.maxInt(u52); + + if (min_value) |min| { + if (max_value) |max| { + if (min.isNumber()) at_least = min.to(u52); + if (max.isNumber()) at_most = max.to(u52); + } else { + if (min.isNumber()) at_most = min.to(u52); + } + } + + return JSValue.jsNumberFromUint64(std.crypto.random.intRangeAtMost(u52, at_least, at_most)); + } + pub fn randomUUIDWithoutTypeChecks( globalThis: *JSC.JSGlobalObject, _: *anyopaque, diff --git a/src/js/node/crypto.js b/src/js/node/crypto.js index 3791bdcd9..c6968bbd5 100644 --- a/src/js/node/crypto.js +++ b/src/js/node/crypto.js @@ -23752,6 +23752,7 @@ var crypto_exports = { var DEFAULT_ENCODING = "buffer", getRandomValues = array => crypto.getRandomValues(array), randomUUID = () => crypto.randomUUID(), + randomInt = (...args) => crypto.randomInt(...args), timingSafeEqual = "timingSafeEqual" in crypto ? (a, b) => { @@ -23806,6 +23807,7 @@ __export(crypto_exports, { DEFAULT_ENCODING: () => DEFAULT_ENCODING, getRandomValues: () => getRandomValues, randomUUID: () => randomUUID, + randomInt: () => randomInt, scrypt: () => scrypt, scryptSync: () => scryptSync, timingSafeEqual: () => timingSafeEqual, diff --git a/src/js/out/modules/node/crypto.js b/src/js/out/modules/node/crypto.js index 85d647a59..9db837693 100644 --- a/src/js/out/modules/node/crypto.js +++ b/src/js/out/modules/node/crypto.js @@ -1,4 +1,4 @@ -import{StringDecoder as a$} from"node:string_decoder";import*as e$ from"node:buffer";import*as h$ from"node:stream";var s$=Object.defineProperty;var t$=Object.getOwnPropertyNames;var r$=536870888,c$=globalThis.Buffer,d$=globalThis.crypto,i$=d$;var $Q=(X,K)=>function(){return K||(0,X[t$(X)[0]])((K={exports:{}}).exports,K),K.exports},QQ=(X,K)=>{for(var x0 in K)s$(X,x0,{get:K[x0],enumerable:!0})};var YQ=$Q({"node_modules/safe-buffer/index.js"(X,K){var x0=e$,G=x0.Buffer;function Y(Z,Q){for(var U in Z)Q[U]=Z[U]}G.from&&G.alloc&&G.allocUnsafe&&G.allocUnsafeSlow?K.exports=x0:(Y(x0,X),X.Buffer=$);function $(Z,Q,U){return G(Z,Q,U)}$.prototype=Object.create(G.prototype),Y(G,$),$.from=function(Z,Q,U){if(typeof Z=="number")throw new TypeError("Argument must not be a number");return G(Z,Q,U)},$.alloc=function(Z,Q,U){if(typeof Z!="number")throw new TypeError("Argument must be a number");var V=G(Z);return Q!==void 0?typeof U=="string"?V.fill(Q,U):V.fill(Q):V.fill(0),V},$.allocUnsafe=function(Z){if(typeof Z!="number")throw new TypeError("Argument must be a number");return G(Z)},$.allocUnsafeSlow=function(Z){if(typeof Z!="number")throw new TypeError("Argument must be a number");return x0.SlowBuffer(Z)}}}),ZQ=$Q({"node_modules/randombytes/browser.js"(X,K){var x0=65536,G=4294967295;function Y(){throw new Error(`Secure random number generation is not supported by this browser. -Use Chrome, Firefox or Internet Explorer 11`)}var $=YQ().Buffer,Z=i$;Z&&Z.getRandomValues?K.exports=Q:K.exports=Y;function Q(U,V){if(U>G)throw new RangeError("requested too many random bytes");var B0=$.allocUnsafe(U);if(U>0)if(U>x0)for(var H=0;H=this._blockSize;){for(var B0=this._blockOffset;B00;++H)this._length[H]+=y0,y0=this._length[H]/4294967296|0,y0>0&&(this._length[H]-=4294967296*y0);return this},$.prototype._update=function(){throw new Error("_update is not implemented")},$.prototype.digest=function(Z){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var Q=this._digest();Z!==void 0&&(Q=Q.toString(Z)),this._block.fill(0),this._blockOffset=0;for(var U=0;U<4;++U)this._length[U]=0;return Q},$.prototype._digest=function(){throw new Error("_digest is not implemented")},K.exports=$}}),I0=$Q({"node_modules/md5.js/index.js"(X,K){var x0=X0(),G=K0(),Y=YQ().Buffer,$=new Array(16);function Z(){G.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}x0(Z,G),Z.prototype._update=function(){for(var y0=$,W=0;W<16;++W)y0[W]=this._block.readInt32LE(W*4);var w0=this._a,E=this._b,p0=this._c,T=this._d;w0=U(w0,E,p0,T,y0[0],3614090360,7),T=U(T,w0,E,p0,y0[1],3905402710,12),p0=U(p0,T,w0,E,y0[2],606105819,17),E=U(E,p0,T,w0,y0[3],3250441966,22),w0=U(w0,E,p0,T,y0[4],4118548399,7),T=U(T,w0,E,p0,y0[5],1200080426,12),p0=U(p0,T,w0,E,y0[6],2821735955,17),E=U(E,p0,T,w0,y0[7],4249261313,22),w0=U(w0,E,p0,T,y0[8],1770035416,7),T=U(T,w0,E,p0,y0[9],2336552879,12),p0=U(p0,T,w0,E,y0[10],4294925233,17),E=U(E,p0,T,w0,y0[11],2304563134,22),w0=U(w0,E,p0,T,y0[12],1804603682,7),T=U(T,w0,E,p0,y0[13],4254626195,12),p0=U(p0,T,w0,E,y0[14],2792965006,17),E=U(E,p0,T,w0,y0[15],1236535329,22),w0=V(w0,E,p0,T,y0[1],4129170786,5),T=V(T,w0,E,p0,y0[6],3225465664,9),p0=V(p0,T,w0,E,y0[11],643717713,14),E=V(E,p0,T,w0,y0[0],3921069994,20),w0=V(w0,E,p0,T,y0[5],3593408605,5),T=V(T,w0,E,p0,y0[10],38016083,9),p0=V(p0,T,w0,E,y0[15],3634488961,14),E=V(E,p0,T,w0,y0[4],3889429448,20),w0=V(w0,E,p0,T,y0[9],568446438,5),T=V(T,w0,E,p0,y0[14],3275163606,9),p0=V(p0,T,w0,E,y0[3],4107603335,14),E=V(E,p0,T,w0,y0[8],1163531501,20),w0=V(w0,E,p0,T,y0[13],2850285829,5),T=V(T,w0,E,p0,y0[2],4243563512,9),p0=V(p0,T,w0,E,y0[7],1735328473,14),E=V(E,p0,T,w0,y0[12],2368359562,20),w0=B0(w0,E,p0,T,y0[5],4294588738,4),T=B0(T,w0,E,p0,y0[8],2272392833,11),p0=B0(p0,T,w0,E,y0[11],1839030562,16),E=B0(E,p0,T,w0,y0[14],4259657740,23),w0=B0(w0,E,p0,T,y0[1],2763975236,4),T=B0(T,w0,E,p0,y0[4],1272893353,11),p0=B0(p0,T,w0,E,y0[7],4139469664,16),E=B0(E,p0,T,w0,y0[10],3200236656,23),w0=B0(w0,E,p0,T,y0[13],681279174,4),T=B0(T,w0,E,p0,y0[0],3936430074,11),p0=B0(p0,T,w0,E,y0[3],3572445317,16),E=B0(E,p0,T,w0,y0[6],76029189,23),w0=B0(w0,E,p0,T,y0[9],3654602809,4),T=B0(T,w0,E,p0,y0[12],3873151461,11),p0=B0(p0,T,w0,E,y0[15],530742520,16),E=B0(E,p0,T,w0,y0[2],3299628645,23),w0=H(w0,E,p0,T,y0[0],4096336452,6),T=H(T,w0,E,p0,y0[7],1126891415,10),p0=H(p0,T,w0,E,y0[14],2878612391,15),E=H(E,p0,T,w0,y0[5],4237533241,21),w0=H(w0,E,p0,T,y0[12],1700485571,6),T=H(T,w0,E,p0,y0[3],2399980690,10),p0=H(p0,T,w0,E,y0[10],4293915773,15),E=H(E,p0,T,w0,y0[1],2240044497,21),w0=H(w0,E,p0,T,y0[8],1873313359,6),T=H(T,w0,E,p0,y0[15],4264355552,10),p0=H(p0,T,w0,E,y0[6],2734768916,15),E=H(E,p0,T,w0,y0[13],1309151649,21),w0=H(w0,E,p0,T,y0[4],4149444226,6),T=H(T,w0,E,p0,y0[11],3174756917,10),p0=H(p0,T,w0,E,y0[2],718787259,15),E=H(E,p0,T,w0,y0[9],3951481745,21),this._a=this._a+w0|0,this._b=this._b+E|0,this._c=this._c+p0|0,this._d=this._d+T|0},Z.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 y0=Y.allocUnsafe(16);return y0.writeInt32LE(this._a,0),y0.writeInt32LE(this._b,4),y0.writeInt32LE(this._c,8),y0.writeInt32LE(this._d,12),y0};function Q(y0,W){return y0<>>32-W}function U(y0,W,w0,E,p0,T,f0){return Q(y0+(W&w0|~W&E)+p0+T|0,f0)+W|0}function V(y0,W,w0,E,p0,T,f0){return Q(y0+(W&E|w0&~E)+p0+T|0,f0)+W|0}function B0(y0,W,w0,E,p0,T,f0){return Q(y0+(W^w0^E)+p0+T|0,f0)+W|0}function H(y0,W,w0,E,p0,T,f0){return Q(y0+(w0^(W|~E))+p0+T|0,f0)+W|0}K.exports=Z}}),O0=$Q({"node_modules/ripemd160/index.js"(X,K){var x0=c$,G=X0(),Y=K0(),$=new Array(16),Z=[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],Q=[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],U=[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],V=[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],B0=[0,1518500249,1859775393,2400959708,2840853838],H=[1352829926,1548603684,1836072691,2053994217,0];function y0(){Y.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}G(y0,Y),y0.prototype._update=function(){for(var D=$,c0=0;c0<16;++c0)D[c0]=this._block.readInt32LE(c0*4);for(var C=this._a|0,h0=this._b|0,L=this._c|0,d0=this._d|0,R=this._e|0,b0=this._a|0,P=this._b|0,l0=this._c|0,z=this._d|0,o0=this._e|0,M=0;M<80;M+=1){var u0,S;M<16?(u0=w0(C,h0,L,d0,R,D[Z[M]],B0[0],U[M]),S=f0(b0,P,l0,z,o0,D[Q[M]],H[0],V[M])):M<32?(u0=E(C,h0,L,d0,R,D[Z[M]],B0[1],U[M]),S=T(b0,P,l0,z,o0,D[Q[M]],H[1],V[M])):M<48?(u0=p0(C,h0,L,d0,R,D[Z[M]],B0[2],U[M]),S=p0(b0,P,l0,z,o0,D[Q[M]],H[2],V[M])):M<64?(u0=T(C,h0,L,d0,R,D[Z[M]],B0[3],U[M]),S=E(b0,P,l0,z,o0,D[Q[M]],H[3],V[M])):(u0=f0(C,h0,L,d0,R,D[Z[M]],B0[4],U[M]),S=w0(b0,P,l0,z,o0,D[Q[M]],H[4],V[M])),C=R,R=d0,d0=W(L,10),L=h0,h0=u0,b0=o0,o0=z,z=W(l0,10),l0=P,P=S}var n0=this._b+L+z|0;this._b=this._c+d0+o0|0,this._c=this._d+R+b0|0,this._d=this._e+C+P|0,this._e=this._a+h0+l0|0,this._a=n0},y0.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=x0.alloc?x0.alloc(20):new x0(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 W(D,c0){return D<>>32-c0}function w0(D,c0,C,h0,L,d0,R,b0){return W(D+(c0^C^h0)+d0+R|0,b0)+L|0}function E(D,c0,C,h0,L,d0,R,b0){return W(D+(c0&C|~c0&h0)+d0+R|0,b0)+L|0}function p0(D,c0,C,h0,L,d0,R,b0){return W(D+((c0|~C)^h0)+d0+R|0,b0)+L|0}function T(D,c0,C,h0,L,d0,R,b0){return W(D+(c0&h0|C&~h0)+d0+R|0,b0)+L|0}function f0(D,c0,C,h0,L,d0,R,b0){return W(D+(c0^(C|~h0))+d0+R|0,b0)+L|0}K.exports=y0}}),J0=$Q({"node_modules/sha.js/hash.js"(X,K){var x0=YQ().Buffer;function G(Y,$){this._block=x0.alloc(Y),this._finalSize=$,this._blockSize=Y,this._len=0}G.prototype.update=function(Y,$){typeof Y=="string"&&($=$||"utf8",Y=x0.from(Y,$));for(var Z=this._block,Q=this._blockSize,U=Y.length,V=this._len,B0=0;B0=this._finalSize&&(this._update(this._block),this._block.fill(0));var Z=this._len*8;if(Z<=4294967295)this._block.writeUInt32BE(Z,this._blockSize-4);else{var Q=(Z&4294967295)>>>0,U=(Z-Q)/4294967296;this._block.writeUInt32BE(U,this._blockSize-8),this._block.writeUInt32BE(Q,this._blockSize-4)}this._update(this._block);var V=this._hash();return Y?V.toString(Y):V},G.prototype._update=function(){throw new Error("_update must be implemented by subclass")},K.exports=G}}),F0=$Q({"node_modules/sha.js/sha.js"(X,K){var x0=X0(),G=J0(),Y=YQ().Buffer,$=[1518500249,1859775393,-1894007588,-899497514],Z=new Array(80);function Q(){this.init(),this._w=Z,G.call(this,64,56)}x0(Q,G),Q.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function U(H){return H<<5|H>>>27}function V(H){return H<<30|H>>>2}function B0(H,y0,W,w0){return H===0?y0&W|~y0&w0:H===2?y0&W|y0&w0|W&w0:y0^W^w0}Q.prototype._update=function(H){for(var y0=this._w,W=this._a|0,w0=this._b|0,E=this._c|0,p0=this._d|0,T=this._e|0,f0=0;f0<16;++f0)y0[f0]=H.readInt32BE(f0*4);for(;f0<80;++f0)y0[f0]=y0[f0-3]^y0[f0-8]^y0[f0-14]^y0[f0-16];for(var D=0;D<80;++D){var c0=~~(D/20),C=U(W)+B0(c0,w0,E,p0)+T+y0[D]+$[c0]|0;T=p0,p0=E,E=V(w0),w0=W,W=C}this._a=W+this._a|0,this._b=w0+this._b|0,this._c=E+this._c|0,this._d=p0+this._d|0,this._e=T+this._e|0},Q.prototype._hash=function(){var H=Y.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},K.exports=Q}}),A0=$Q({"node_modules/sha.js/sha1.js"(X,K){var x0=X0(),G=J0(),Y=YQ().Buffer,$=[1518500249,1859775393,-1894007588,-899497514],Z=new Array(80);function Q(){this.init(),this._w=Z,G.call(this,64,56)}x0(Q,G),Q.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function U(y0){return y0<<1|y0>>>31}function V(y0){return y0<<5|y0>>>27}function B0(y0){return y0<<30|y0>>>2}function H(y0,W,w0,E){return y0===0?W&w0|~W&E:y0===2?W&w0|W&E|w0&E:W^w0^E}Q.prototype._update=function(y0){for(var W=this._w,w0=this._a|0,E=this._b|0,p0=this._c|0,T=this._d|0,f0=this._e|0,D=0;D<16;++D)W[D]=y0.readInt32BE(D*4);for(;D<80;++D)W[D]=U(W[D-3]^W[D-8]^W[D-14]^W[D-16]);for(var c0=0;c0<80;++c0){var C=~~(c0/20),h0=V(w0)+H(C,E,p0,T)+f0+W[c0]+$[C]|0;f0=T,T=p0,p0=B0(E),E=w0,w0=h0}this._a=w0+this._a|0,this._b=E+this._b|0,this._c=p0+this._c|0,this._d=T+this._d|0,this._e=f0+this._e|0},Q.prototype._hash=function(){var y0=Y.allocUnsafe(20);return y0.writeInt32BE(this._a|0,0),y0.writeInt32BE(this._b|0,4),y0.writeInt32BE(this._c|0,8),y0.writeInt32BE(this._d|0,12),y0.writeInt32BE(this._e|0,16),y0},K.exports=Q}}),H0=$Q({"node_modules/sha.js/sha256.js"(X,K){var x0=X0(),G=J0(),Y=YQ().Buffer,$=[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],Z=new Array(64);function Q(){this.init(),this._w=Z,G.call(this,64,56)}x0(Q,G),Q.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 U(w0,E,p0){return p0^w0&(E^p0)}function V(w0,E,p0){return w0&E|p0&(w0|E)}function B0(w0){return(w0>>>2|w0<<30)^(w0>>>13|w0<<19)^(w0>>>22|w0<<10)}function H(w0){return(w0>>>6|w0<<26)^(w0>>>11|w0<<21)^(w0>>>25|w0<<7)}function y0(w0){return(w0>>>7|w0<<25)^(w0>>>18|w0<<14)^w0>>>3}function W(w0){return(w0>>>17|w0<<15)^(w0>>>19|w0<<13)^w0>>>10}Q.prototype._update=function(w0){for(var E=this._w,p0=this._a|0,T=this._b|0,f0=this._c|0,D=this._d|0,c0=this._e|0,C=this._f|0,h0=this._g|0,L=this._h|0,d0=0;d0<16;++d0)E[d0]=w0.readInt32BE(d0*4);for(;d0<64;++d0)E[d0]=W(E[d0-2])+E[d0-7]+y0(E[d0-15])+E[d0-16]|0;for(var R=0;R<64;++R){var b0=L+H(c0)+U(c0,C,h0)+$[R]+E[R]|0,P=B0(p0)+V(p0,T,f0)|0;L=h0,h0=C,C=c0,c0=D+b0|0,D=f0,f0=T,T=p0,p0=b0+P|0}this._a=p0+this._a|0,this._b=T+this._b|0,this._c=f0+this._c|0,this._d=D+this._d|0,this._e=c0+this._e|0,this._f=C+this._f|0,this._g=h0+this._g|0,this._h=L+this._h|0},Q.prototype._hash=function(){var w0=Y.allocUnsafe(32);return w0.writeInt32BE(this._a,0),w0.writeInt32BE(this._b,4),w0.writeInt32BE(this._c,8),w0.writeInt32BE(this._d,12),w0.writeInt32BE(this._e,16),w0.writeInt32BE(this._f,20),w0.writeInt32BE(this._g,24),w0.writeInt32BE(this._h,28),w0},K.exports=Q}}),W0=$Q({"node_modules/sha.js/sha224.js"(X,K){var x0=X0(),G=H0(),Y=J0(),$=YQ().Buffer,Z=new Array(64);function Q(){this.init(),this._w=Z,Y.call(this,64,56)}x0(Q,G),Q.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},Q.prototype._hash=function(){var U=$.allocUnsafe(28);return U.writeInt32BE(this._a,0),U.writeInt32BE(this._b,4),U.writeInt32BE(this._c,8),U.writeInt32BE(this._d,12),U.writeInt32BE(this._e,16),U.writeInt32BE(this._f,20),U.writeInt32BE(this._g,24),U},K.exports=Q}}),E0=$Q({"node_modules/sha.js/sha512.js"(X,K){var x0=X0(),G=J0(),Y=YQ().Buffer,$=[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],Z=new Array(160);function Q(){this.init(),this._w=Z,G.call(this,128,112)}x0(Q,G),Q.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 U(T,f0,D){return D^T&(f0^D)}function V(T,f0,D){return T&f0|D&(T|f0)}function B0(T,f0){return(T>>>28|f0<<4)^(f0>>>2|T<<30)^(f0>>>7|T<<25)}function H(T,f0){return(T>>>14|f0<<18)^(T>>>18|f0<<14)^(f0>>>9|T<<23)}function y0(T,f0){return(T>>>1|f0<<31)^(T>>>8|f0<<24)^T>>>7}function W(T,f0){return(T>>>1|f0<<31)^(T>>>8|f0<<24)^(T>>>7|f0<<25)}function w0(T,f0){return(T>>>19|f0<<13)^(f0>>>29|T<<3)^T>>>6}function E(T,f0){return(T>>>19|f0<<13)^(f0>>>29|T<<3)^(T>>>6|f0<<26)}function p0(T,f0){return T>>>0>>0?1:0}Q.prototype._update=function(T){for(var f0=this._w,D=this._ah|0,c0=this._bh|0,C=this._ch|0,h0=this._dh|0,L=this._eh|0,d0=this._fh|0,R=this._gh|0,b0=this._hh|0,P=this._al|0,l0=this._bl|0,z=this._cl|0,o0=this._dl|0,M=this._el|0,u0=this._fl|0,S=this._gl|0,n0=this._hl|0,v=0;v<32;v+=2)f0[v]=T.readInt32BE(v*4),f0[v+1]=T.readInt32BE(v*4+4);for(;v<160;v+=2){var s0=f0[v-30],I=f0[v-30+1],t0=y0(s0,I),m0=W(I,s0);s0=f0[v-4],I=f0[v-4+1];var a0=w0(s0,I),q=E(I,s0),e0=f0[v-14],r0=f0[v-14+1],i0=f0[v-32],j=f0[v-32+1],$$=m0+r0|0,k=t0+e0+p0($$,m0)|0;$$=$$+q|0,k=k+a0+p0($$,q)|0,$$=$$+j|0,k=k+i0+p0($$,j)|0,f0[v]=k,f0[v+1]=$$}for(var Q$=0;Q$<160;Q$+=2){k=f0[Q$],$$=f0[Q$+1];var g=V(D,c0,C),Y$=V(P,l0,z),_=B0(D,P),Z$=B0(P,D),N=H(L,M),G$=H(M,L),x=$[Q$],V$=$[Q$+1],B=U(L,d0,R),U$=U(M,u0,S),y=n0+G$|0,X$=b0+N+p0(y,n0)|0;y=y+U$|0,X$=X$+B+p0(y,U$)|0,y=y+V$|0,X$=X$+x+p0(y,V$)|0,y=y+$$|0,X$=X$+k+p0(y,$$)|0;var w=Z$+Y$|0,K$=_+g+p0(w,Z$)|0;b0=R,n0=S,R=d0,S=u0,d0=L,u0=M,M=o0+y|0,L=h0+X$+p0(M,o0)|0,h0=C,o0=z,C=c0,z=l0,c0=D,l0=P,P=y+w|0,D=X$+K$+p0(P,y)|0}this._al=this._al+P|0,this._bl=this._bl+l0|0,this._cl=this._cl+z|0,this._dl=this._dl+o0|0,this._el=this._el+M|0,this._fl=this._fl+u0|0,this._gl=this._gl+S|0,this._hl=this._hl+n0|0,this._ah=this._ah+D+p0(this._al,P)|0,this._bh=this._bh+c0+p0(this._bl,l0)|0,this._ch=this._ch+C+p0(this._cl,z)|0,this._dh=this._dh+h0+p0(this._dl,o0)|0,this._eh=this._eh+L+p0(this._el,M)|0,this._fh=this._fh+d0+p0(this._fl,u0)|0,this._gh=this._gh+R+p0(this._gl,S)|0,this._hh=this._hh+b0+p0(this._hl,n0)|0},Q.prototype._hash=function(){var T=Y.allocUnsafe(64);function f0(D,c0,C){T.writeInt32BE(D,C),T.writeInt32BE(c0,C+4)}return f0(this._ah,this._al,0),f0(this._bh,this._bl,8),f0(this._ch,this._cl,16),f0(this._dh,this._dl,24),f0(this._eh,this._el,32),f0(this._fh,this._fl,40),f0(this._gh,this._gl,48),f0(this._hh,this._hl,56),T},K.exports=Q}}),T0=$Q({"node_modules/sha.js/sha384.js"(X,K){var x0=X0(),G=E0(),Y=J0(),$=YQ().Buffer,Z=new Array(160);function Q(){this.init(),this._w=Z,Y.call(this,128,112)}x0(Q,G),Q.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},Q.prototype._hash=function(){var U=$.allocUnsafe(48);function V(B0,H,y0){U.writeInt32BE(B0,y0),U.writeInt32BE(H,y0+4)}return V(this._ah,this._al,0),V(this._bh,this._bl,8),V(this._ch,this._cl,16),V(this._dh,this._dl,24),V(this._eh,this._el,32),V(this._fh,this._fl,40),U},K.exports=Q}}),D0=$Q({"node_modules/sha.js/index.js"(x0,K){var x0=K.exports=function(G){G=G.toLowerCase();var Y=x0[G];if(!Y)throw new Error(G+" is not supported (we accept pull requests)");return new Y};x0.sha=F0(),x0.sha1=A0(),x0.sha224=W0(),x0.sha256=H0(),x0.sha384=T0(),x0.sha512=E0()}}),C0=$Q({"node_modules/cipher-base/index.js"(X,K){var x0=YQ().Buffer,G=X0();function Y($){h$.Transform.call(this),this.hashMode=typeof $=="string",this.hashMode?this[$]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}G(Y,h$.Transform),Y.prototype.update=function($,Z,Q){typeof $=="string"&&($=x0.from($,Z));var U=this._update($);return this.hashMode?this:(Q&&(U=this._toString(U,Q)),U)},Y.prototype.setAutoPadding=function(){},Y.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},Y.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},Y.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},Y.prototype._transform=function($,Z,Q){var U;try{this.hashMode?this._update($):this.push(this._update($))}catch(V){U=V}finally{Q(U)}},Y.prototype._flush=function($){var Z;try{this.push(this.__final())}catch(Q){Z=Q}$(Z)},Y.prototype._finalOrDigest=function($){var Z=this.__final()||x0.alloc(0);return $&&(Z=this._toString(Z,$,!0)),Z},Y.prototype._toString=function($,Z,Q){if(this._decoder||(this._decoder=new a$(Z),this._encoding=Z),this._encoding!==Z)throw new Error("can't switch encodings");var U=this._decoder.write($);return Q&&(U+=this._decoder.end()),U},K.exports=Y}}),L0=$Q({"node_modules/create-hash/browser.js"(X,K){const x0=function $(Z,Q){this._options=Q,this._hasher=new sY(Z,Q),this._finalized=!1};x0.prototype=Object.create(h$.Transform.prototype),x0.prototype.update=function $(Z,Q){return this._checkFinalized(),this._hasher.update(Z,Q),this},x0.prototype.digest=function $(Z,Q){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(Z,Q)},x0.prototype._checkFinalized=function $(){if(this._finalized){var Z=new Error("Digest already called");throw Z.code="ERR_CRYPTO_HASH_FINALIZED",Z}},x0.prototype.copy=function $(){const Z=Object.create(x0.prototype);return Z._options=this._options,Z._hasher=this._hasher.copy(),Z._finalized=this._finalized,Z};const G={__proto__:h$.Transform.prototype,...x0.prototype,_transform($,Z,Q){this.update($,Z),Q&&Q()},_flush($){this.push(this.digest()),$()}},Y=["_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 $ of Y)Object.defineProperty(x0.prototype,$,{get(){return Object.setPrototypeOf(this,G),h$.Transform.call(this,this._options),this[$]},enumerable:!1,configurable:!0});K.exports=function $(Z){return new x0(Z)},K.exports.createHash=K.exports,K.exports.Hash=x0}}),R0=$Q({"node_modules/create-hmac/legacy.js"(X,K){var x0=X0(),G=YQ().Buffer,Y=C0(),$=G.alloc(128),Z=64;function Q(U,V){Y.call(this,"digest"),typeof V=="string"&&(V=G.from(V)),this._alg=U,this._key=V,V.length>Z?V=U(V):V.lengthW){var w0=H==="rmd160"?new Q:U(H);y0=w0.update(y0).digest()}else y0.lengthx0||Y!==Y)throw new TypeError("Bad key length")}}}),q0=$Q({"node_modules/pbkdf2/lib/default-encoding.js"(X,K){var x0;global.process&&global.process.browser?x0="utf-8":global.process&&global.process.version?(G=parseInt(process.version.split(".")[0].slice(1),10),x0=G>=6?"utf-8":"binary"):x0="utf-8";var G;K.exports=x0}}),j0=$Q({"node_modules/pbkdf2/lib/to-buffer.js"(X,K){var x0=YQ().Buffer;K.exports=function(G,Y,$){if(x0.isBuffer(G))return G;if(typeof G=="string")return x0.from(G,Y);if(ArrayBuffer.isView(G))return x0.from(G.buffer);throw new TypeError($+" must be a string, a Buffer, a typed array or a DataView")}}}),k0=$Q({"node_modules/pbkdf2/lib/sync-browser.js"(X,K){var x0=P0(),G=O0(),Y=D0(),$=YQ().Buffer,Z=v0(),Q=q0(),U=j0(),V=$.alloc(128),B0={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function H(w0,E,p0){var T=y0(w0),f0=w0==="sha512"||w0==="sha384"?128:64;E.length>f0?E=T(E):E.length>>0},X.writeUInt32BE=function(Y,$,Z){Y[0+Z]=$>>>24,Y[1+Z]=$>>>16&255,Y[2+Z]=$>>>8&255,Y[3+Z]=$&255},X.ip=function(Y,$,Z,Q){for(var U=0,V=0,B0=6;B0>=0;B0-=2){for(var H=0;H<=24;H+=8)U<<=1,U|=$>>>H+B0&1;for(var H=0;H<=24;H+=8)U<<=1,U|=Y>>>H+B0&1}for(var B0=6;B0>=0;B0-=2){for(var H=1;H<=25;H+=8)V<<=1,V|=$>>>H+B0&1;for(var H=1;H<=25;H+=8)V<<=1,V|=Y>>>H+B0&1}Z[Q+0]=U>>>0,Z[Q+1]=V>>>0},X.rip=function(Y,$,Z,Q){for(var U=0,V=0,B0=0;B0<4;B0++)for(var H=24;H>=0;H-=8)U<<=1,U|=$>>>H+B0&1,U<<=1,U|=Y>>>H+B0&1;for(var B0=4;B0<8;B0++)for(var H=24;H>=0;H-=8)V<<=1,V|=$>>>H+B0&1,V<<=1,V|=Y>>>H+B0&1;Z[Q+0]=U>>>0,Z[Q+1]=V>>>0},X.pc1=function(Y,$,Z,Q){for(var U=0,V=0,B0=7;B0>=5;B0--){for(var H=0;H<=24;H+=8)U<<=1,U|=$>>H+B0&1;for(var H=0;H<=24;H+=8)U<<=1,U|=Y>>H+B0&1}for(var H=0;H<=24;H+=8)U<<=1,U|=$>>H+B0&1;for(var B0=1;B0<=3;B0++){for(var H=0;H<=24;H+=8)V<<=1,V|=$>>H+B0&1;for(var H=0;H<=24;H+=8)V<<=1,V|=Y>>H+B0&1}for(var H=0;H<=24;H+=8)V<<=1,V|=Y>>H+B0&1;Z[Q+0]=U>>>0,Z[Q+1]=V>>>0},X.r28shl=function(Y,$){return Y<<$&268435455|Y>>>28-$};var K=[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];X.pc2=function(Y,$,Z,Q){for(var U=0,V=0,B0=K.length>>>1,H=0;H>>K[H]&1;for(var H=B0;H>>K[H]&1;Z[Q+0]=U>>>0,Z[Q+1]=V>>>0},X.expand=function(Y,$,Z){var Q=0,U=0;Q=(Y&1)<<5|Y>>>27;for(var V=23;V>=15;V-=4)Q<<=6,Q|=Y>>>V&63;for(var V=11;V>=3;V-=4)U|=Y>>>V&63,U<<=6;U|=(Y&31)<<1|Y>>>31,$[Z+0]=Q>>>0,$[Z+1]=U>>>0};var x0=[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];X.substitute=function(Y,$){for(var Z=0,Q=0;Q<4;Q++){var U=Y>>>18-Q*6&63,V=x0[Q*64+U];Z<<=4,Z|=V}for(var Q=0;Q<4;Q++){var U=$>>>18-Q*6&63,V=x0[256+Q*64+U];Z<<=4,Z|=V}return Z>>>0};var G=[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];X.permute=function(Y){for(var $=0,Z=0;Z>>G[Z]&1;return $>>>0},X.padSplit=function(Y,$,Z){for(var Q=Y.toString(2);Q.length<$;)Q="0"+Q;for(var U=[],V=0;V<$;V+=Z)U.push(Q.slice(V,V+Z));return U.join(" ")}}}),N0=$Q({"node_modules/minimalistic-assert/index.js"(X,K){K.exports=x0;function x0(G,Y){if(!G)throw new Error(Y||"Assertion failed")}x0.equal=function(G,Y,$){if(G!=Y)throw new Error($||"Assertion failed: "+G+" != "+Y)}}}),VQ=$Q({"node_modules/des.js/lib/des/cipher.js"(X,K){var x0=N0();function G(Y){this.options=Y,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}K.exports=G,G.prototype._init=function(){},G.prototype.update=function(Y){return Y.length===0?[]:this.type==="decrypt"?this._updateDecrypt(Y):this._updateEncrypt(Y)},G.prototype._buffer=function(Y,$){for(var Z=Math.min(this.buffer.length-this.bufferOff,Y.length-$),Q=0;Q0;Q--)$+=this._buffer(Y,$),Z+=this._flushBuffer(U,Z);return $+=this._buffer(Y,$),U},G.prototype.final=function(Y){var $;Y&&($=this.update(Y));var Z;return this.type==="encrypt"?Z=this._finalEncrypt():Z=this._finalDecrypt(),$?$.concat(Z):Z},G.prototype._pad=function(Y,$){if($===0)return!1;for(;$>>1];H=Y.r28shl(H,w0),y0=Y.r28shl(y0,w0),Y.pc2(H,y0,V.keys,W)}},Q.prototype._update=function(V,B0,H,y0){var W=this._desState,w0=Y.readUInt32BE(V,B0),E=Y.readUInt32BE(V,B0+4);Y.ip(w0,E,W.tmp,0),w0=W.tmp[0],E=W.tmp[1],this.type==="encrypt"?this._encrypt(W,w0,E,W.tmp,0):this._decrypt(W,w0,E,W.tmp,0),w0=W.tmp[0],E=W.tmp[1],Y.writeUInt32BE(H,w0,y0),Y.writeUInt32BE(H,E,y0+4)},Q.prototype._pad=function(V,B0){for(var H=V.length-B0,y0=B0;y0>>0,w0=C}Y.rip(E,w0,y0,W)},Q.prototype._decrypt=function(V,B0,H,y0,W){for(var w0=H,E=B0,p0=V.keys.length-2;p0>=0;p0-=2){var T=V.keys[p0],f0=V.keys[p0+1];Y.expand(w0,V.tmp,0),T^=V.tmp[0],f0^=V.tmp[1];var D=Y.substitute(T,f0),c0=Y.permute(D),C=w0;w0=(E^c0)>>>0,E=C}Y.rip(w0,E,y0,W)}}}),XQ=$Q({"node_modules/des.js/lib/des/cbc.js"(X){var K=N0(),x0=X0(),G={};function Y(Z){K.equal(Z.length,8,"Invalid IV length"),this.iv=new Array(8);for(var Q=0;Q>U%8,Y._prev=G(Y._prev,Z?H:y0);return B0}function G(Y,$){var Z=Y.length,Q=-1,U=K.allocUnsafe(Y.length);for(Y=K.concat([Y,K.from([$])]);++Q>7;return U}X.encrypt=function(Y,$,Z){for(var Q=$.length,U=K.allocUnsafe(Q),V=-1;++V>>24]^E[D>>>16&255]^p0[c0>>>8&255]^T[C&255]^B0[b0++],L=w0[D>>>24]^E[c0>>>16&255]^p0[C>>>8&255]^T[f0&255]^B0[b0++],d0=w0[c0>>>24]^E[C>>>16&255]^p0[f0>>>8&255]^T[D&255]^B0[b0++],R=w0[C>>>24]^E[f0>>>16&255]^p0[D>>>8&255]^T[c0&255]^B0[b0++],f0=h0,D=L,c0=d0,C=R;return h0=(y0[f0>>>24]<<24|y0[D>>>16&255]<<16|y0[c0>>>8&255]<<8|y0[C&255])^B0[b0++],L=(y0[D>>>24]<<24|y0[c0>>>16&255]<<16|y0[C>>>8&255]<<8|y0[f0&255])^B0[b0++],d0=(y0[c0>>>24]<<24|y0[C>>>16&255]<<16|y0[f0>>>8&255]<<8|y0[D&255])^B0[b0++],R=(y0[C>>>24]<<24|y0[f0>>>16&255]<<16|y0[D>>>8&255]<<8|y0[c0&255])^B0[b0++],h0=h0>>>0,L=L>>>0,d0=d0>>>0,R=R>>>0,[h0,L,d0,R]}var Z=[0,1,2,4,8,16,32,64,128,27,54],Q=function(){for(var V=new Array(256),B0=0;B0<256;B0++)B0<128?V[B0]=B0<<1:V[B0]=B0<<1^283;for(var H=[],y0=[],W=[[],[],[],[]],w0=[[],[],[],[]],E=0,p0=0,T=0;T<256;++T){var f0=p0^p0<<1^p0<<2^p0<<3^p0<<4;f0=f0>>>8^f0&255^99,H[E]=f0,y0[f0]=E;var D=V[E],c0=V[D],C=V[c0],h0=V[f0]*257^f0*16843008;W[0][E]=h0<<24|h0>>>8,W[1][E]=h0<<16|h0>>>16,W[2][E]=h0<<8|h0>>>24,W[3][E]=h0,h0=C*16843009^c0*65537^D*257^E*16843008,w0[0][f0]=h0<<24|h0>>>8,w0[1][f0]=h0<<16|h0>>>16,w0[2][f0]=h0<<8|h0>>>24,w0[3][f0]=h0,E===0?E=p0=1:(E=D^V[V[V[C^D]]],p0^=V[V[p0]])}return{SBOX:H,INV_SBOX:y0,SUB_MIX:W,INV_SUB_MIX:w0}}();function U(V){this._key=G(V),this._reset()}U.blockSize=16,U.keySize=32,U.prototype.blockSize=U.blockSize,U.prototype.keySize=U.keySize,U.prototype._reset=function(){for(var V=this._key,B0=V.length,H=B0+6,y0=(H+1)*4,W=[],w0=0;w0>>24,E=Q.SBOX[E>>>24]<<24|Q.SBOX[E>>>16&255]<<16|Q.SBOX[E>>>8&255]<<8|Q.SBOX[E&255],E^=Z[w0/B0|0]<<24):B0>6&&w0%B0===4&&(E=Q.SBOX[E>>>24]<<24|Q.SBOX[E>>>16&255]<<16|Q.SBOX[E>>>8&255]<<8|Q.SBOX[E&255]),W[w0]=W[w0-B0]^E}for(var p0=[],T=0;T>>24]]^Q.INV_SUB_MIX[1][Q.SBOX[D>>>16&255]]^Q.INV_SUB_MIX[2][Q.SBOX[D>>>8&255]]^Q.INV_SUB_MIX[3][Q.SBOX[D&255]]}this._nRounds=H,this._keySchedule=W,this._invKeySchedule=p0},U.prototype.encryptBlockRaw=function(V){return V=G(V),$(V,this._keySchedule,Q.SUB_MIX,Q.SBOX,this._nRounds)},U.prototype.encryptBlock=function(V){var B0=this.encryptBlockRaw(V),H=x0.allocUnsafe(16);return H.writeUInt32BE(B0[0],0),H.writeUInt32BE(B0[1],4),H.writeUInt32BE(B0[2],8),H.writeUInt32BE(B0[3],12),H},U.prototype.decryptBlock=function(V){V=G(V);var B0=V[1];V[1]=V[3],V[3]=B0;var H=$(V,this._invKeySchedule,Q.INV_SUB_MIX,Q.INV_SBOX,this._nRounds),y0=x0.allocUnsafe(16);return y0.writeUInt32BE(H[0],0),y0.writeUInt32BE(H[3],4),y0.writeUInt32BE(H[2],8),y0.writeUInt32BE(H[1],12),y0},U.prototype.scrub=function(){Y(this._keySchedule),Y(this._invKeySchedule),Y(this._key)},K.exports.AES=U}}),PQ=$Q({"node_modules/browserify-aes/ghash.js"(X,K){var x0=YQ().Buffer,G=x0.alloc(16,0);function Y(Q){return[Q.readUInt32BE(0),Q.readUInt32BE(4),Q.readUInt32BE(8),Q.readUInt32BE(12)]}function $(Q){var U=x0.allocUnsafe(16);return U.writeUInt32BE(Q[0]>>>0,0),U.writeUInt32BE(Q[1]>>>0,4),U.writeUInt32BE(Q[2]>>>0,8),U.writeUInt32BE(Q[3]>>>0,12),U}function Z(Q){this.h=Q,this.state=x0.alloc(16,0),this.cache=x0.allocUnsafe(0)}Z.prototype.ghash=function(Q){for(var U=-1;++U0;V--)Q[V]=Q[V]>>>1|(Q[V-1]&1)<<31;Q[0]=Q[0]>>>1,H&&(Q[0]=Q[0]^225<<24)}this.state=$(U)},Z.prototype.update=function(Q){this.cache=x0.concat([this.cache,Q]);for(var U;this.cache.length>=16;)U=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(U)},Z.prototype.final=function(Q,U){return this.cache.length&&this.ghash(x0.concat([this.cache,G],16)),this.ghash($([0,Q,0,U])),this.state},K.exports=Z}}),zQ=$Q({"node_modules/browserify-aes/authCipher.js"(X,K){var x0=RQ(),G=YQ().Buffer,Y=C0(),$=X0(),Z=PQ(),Q=FQ(),U=DQ();function V(y0,W){var w0=0;y0.length!==W.length&&w0++;for(var E=Math.min(y0.length,W.length),p0=0;p00||U>0;){var W=new G;W.update(y0),W.update($),Z&&W.update(Z),y0=W.digest();var w0=0;if(V>0){var E=B0.length-V;w0=Math.min(V,y0.length),y0.copy(B0,E,0,w0),V-=w0}if(w00){var p0=H.length-U,T=Math.min(U,y0.length-w0);y0.copy(H,p0,w0,w0+T),U-=T}}return y0.fill(0),{key:B0,iv:H}}K.exports=Y}}),vQ=$Q({"node_modules/browserify-aes/encrypter.js"(X){var K=LQ(),x0=zQ(),G=YQ().Buffer,Y=MQ(),$=C0(),Z=RQ(),Q=SQ(),U=X0();function V(w0,E,p0){$.call(this),this._cache=new H,this._cipher=new Z.AES(E),this._prev=G.from(p0),this._mode=w0,this._autopadding=!0}U(V,$),V.prototype._update=function(w0){this._cache.add(w0);for(var E,p0,T=[];E=this._cache.get();)p0=this._mode.encrypt(this,E),T.push(p0);return G.concat(T)};var B0=G.alloc(16,16);V.prototype._final=function(){var w0=this._cache.flush();if(this._autopadding)return w0=this._mode.encrypt(this,w0),this._cipher.scrub(),w0;if(!w0.equals(B0))throw this._cipher.scrub(),new Error("data not multiple of block length")},V.prototype.setAutoPadding=function(w0){return this._autopadding=!!w0,this};function H(){this.cache=G.allocUnsafe(0)}H.prototype.add=function(w0){this.cache=G.concat([this.cache,w0])},H.prototype.get=function(){if(this.cache.length>15){var w0=this.cache.slice(0,16);return this.cache=this.cache.slice(16),w0}return null},H.prototype.flush=function(){for(var w0=16-this.cache.length,E=G.allocUnsafe(w0),p0=-1;++p016)return E=this.cache.slice(0,16),this.cache=this.cache.slice(16),E}else if(this.cache.length>=16)return E=this.cache.slice(0,16),this.cache=this.cache.slice(16),E;return null},B0.prototype.flush=function(){if(this.cache.length)return this.cache};function H(w0){var E=w0[15];if(E<1||E>16)throw new Error("unable to decrypt data");for(var p0=-1;++p00?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),_Q=$Q({"node_modules/miller-rabin/node_modules/bn.js/lib/bn.js"(X,K){(function(x0,G){function Y(l0,z){if(!l0)throw new Error(z||"Assertion failed")}function $(l0,z){l0.super_=z;var o0=function(){};o0.prototype=z.prototype,l0.prototype=new o0,l0.prototype.constructor=l0}function Z(l0,z,o0){if(Z.isBN(l0))return l0;this.negative=0,this.words=null,this.length=0,this.red=null,l0!==null&&((z==="le"||z==="be")&&(o0=z,z=10),this._init(l0||0,z||10,o0||"be"))}typeof x0=="object"?x0.exports=Z:G.BN=Z,Z.BN=Z,Z.wordSize=26;var Q=c$;Z.isBN=function(l0){return l0 instanceof Z?!0:l0!==null&&typeof l0=="object"&&l0.constructor.wordSize===Z.wordSize&&Array.isArray(l0.words)},Z.max=function(l0,z){return l0.cmp(z)>0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),NQ=$Q({"(disabled):node_modules/crypto-browserify/index.js"(){}}),xQ=$Q({"node_modules/brorand/index.js"(X,K){var x0;K.exports=function(Y){return x0||(x0=new G(null)),x0.generate(Y)};function G(Y){this.rand=Y}K.exports.Rand=G,G.prototype.generate=function(Y){return this._rand(Y)},G.prototype._rand=function(Y){var $=new c$(Y);return d$.getRandomValues($),$}}}),BQ=$Q({"node_modules/miller-rabin/lib/mr.js"(X,K){var x0=_Q(),G=xQ();function Y($){this.rand=$||new G.Rand}K.exports=Y,Y.create=function($){return new Y($)},Y.prototype._randbelow=function($){var Z=$.bitLength(),Q=Math.ceil(Z/8);do var U=new x0(this.rand.generate(Q));while(U.cmp($)>=0);return U},Y.prototype._randrange=function($,Z){var Q=Z.sub($);return $.add(this._randbelow(Q))},Y.prototype.test=function($,Z,Q){var U=$.bitLength(),V=x0.mont($),B0=new x0(1).toRed(V);Z||(Z=Math.max(1,U/48|0));for(var H=$.subn(1),y0=0;!H.testn(y0);y0++);for(var W=$.shrn(y0),w0=H.toRed(V),E=!0;Z>0;Z--){var p0=this._randrange(new x0(2),H);Q&&Q(p0);var T=p0.toRed(V).redPow(W);if(!(T.cmp(B0)===0||T.cmp(w0)===0)){for(var f0=1;f00;Z--){var w0=this._randrange(new x0(2),B0),E=$.gcd(w0);if(E.cmpn(1)!==0)return E;var p0=w0.toRed(U).redPow(y0);if(!(p0.cmp(V)===0||p0.cmp(W)===0)){for(var T=1;TL;)R.ishrn(1);if(R.isEven()&&R.iadd(Q),R.testn(1)||R.iadd(U),d0.cmp(U)){if(!d0.cmp(V))for(;R.mod(y0).cmp(W);)R.iadd(p0)}else for(;R.mod(Y).cmp(E);)R.iadd(p0);if(b0=R.shrn(1),c0(b0)&&c0(R)&&C(b0)&&C(R)&&Z.test(b0)&&Z.test(R))return R}}}}),wQ=$Q({"node_modules/diffie-hellman/lib/primes.json"(X,K){K.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"(X,K){var x0=A(),G=BQ(),Y=new G,$=new x0(24),Z=new x0(11),Q=new x0(10),U=new x0(3),V=new x0(7),B0=yQ(),H=ZQ();K.exports=p0;function y0(f0,D){return D=D||"utf8",c$.isBuffer(f0)||(f0=new c$(f0,D)),this._pub=new x0(f0),this}function W(f0,D){return D=D||"utf8",c$.isBuffer(f0)||(f0=new c$(f0,D)),this._priv=new x0(f0),this}var w0={};function E(f0,D){var c0=D.toString("hex"),C=[c0,f0.toString(16)].join("_");if(C in w0)return w0[C];var h0=0;if(f0.isEven()||!B0.simpleSieve||!B0.fermatTest(f0)||!Y.test(f0))return h0+=1,c0==="02"||c0==="05"?h0+=8:h0+=4,w0[C]=h0,h0;Y.test(f0.shrn(1))||(h0+=2);var L;switch(c0){case"02":f0.mod($).cmp(Z)&&(h0+=8);break;case"05":L=f0.mod(Q),L.cmp(U)&&L.cmp(V)&&(h0+=8);break;default:h0+=4}return w0[C]=h0,h0}function p0(f0,D,c0){this.setGenerator(D),this.__prime=new x0(f0),this._prime=x0.mont(this.__prime),this._primeLen=f0.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,c0?(this.setPublicKey=y0,this.setPrivateKey=W):this._primeCode=8}Object.defineProperty(p0.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=E(this.__prime,this.__gen)),this._primeCode}}),p0.prototype.generateKeys=function(){return this._priv||(this._priv=new x0(H(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},p0.prototype.computeSecret=function(f0){f0=new x0(f0),f0=f0.toRed(this._prime);var D=f0.redPow(this._priv).fromRed(),c0=new c$(D.toArray()),C=this.getPrime();if(c0.length0?M:u0},Z.min=function(M,u0){return M.cmp(u0)<0?M:u0},Z.prototype._init=function(M,u0,S){if(typeof M=="number")return this._initNumber(M,u0,S);if(typeof M=="object")return this._initArray(M,u0,S);u0==="hex"&&(u0=16),Y(u0===(u0|0)&&u0>=2&&u0<=36),M=M.toString().replace(/\s+/g,"");var n0=0;M[0]==="-"&&(n0++,this.negative=1),n0=0;n0-=3)s0=M[n0]|M[n0-1]<<8|M[n0-2]<<16,this.words[v]|=s0<>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);else if(S==="le")for(n0=0,v=0;n0>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);return this._strip()};function U(M,u0){var S=M.charCodeAt(u0);if(S>=48&&S<=57)return S-48;if(S>=65&&S<=70)return S-55;if(S>=97&&S<=102)return S-87;Y(!1,"Invalid character in "+M)}function V(M,u0,S){var n0=U(M,S);return S-1>=u0&&(n0|=U(M,S-1)<<4),n0}Z.prototype._parseHex=function(M,u0,S){this.length=Math.ceil((M.length-u0)/6),this.words=new Array(this.length);for(var n0=0;n0=u0;n0-=2)I=V(M,u0,n0)<=18?(v-=18,s0+=1,this.words[s0]|=I>>>26):v+=8;else{var t0=M.length-u0;for(n0=t0%2===0?u0+1:u0;n0=18?(v-=18,s0+=1,this.words[s0]|=I>>>26):v+=8}this._strip()};function B0(M,u0,S,n0){for(var v=0,s0=0,I=Math.min(M.length,S),t0=u0;t0=49?s0=m0-49+10:m0>=17?s0=m0-17+10:s0=m0,Y(m0>=0&&s01&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{Z.prototype[Symbol.for("nodejs.util.inspect.custom")]=y0}catch{Z.prototype.inspect=y0}else Z.prototype.inspect=y0;function y0(){return(this.red?""}var W=["","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"],w0=[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],E=[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];Z.prototype.toString=function(M,u0){M=M||10,u0=u0|0||1;var S;if(M===16||M==="hex"){S="";for(var n0=0,v=0,s0=0;s0>>24-n0&16777215,n0+=2,n0>=26&&(n0-=26,s0--),v!==0||s0!==this.length-1?S=W[6-t0.length]+t0+S:S=t0+S}for(v!==0&&(S=v.toString(16)+S);S.length%u0!==0;)S="0"+S;return this.negative!==0&&(S="-"+S),S}if(M===(M|0)&&M>=2&&M<=36){var m0=w0[M],a0=E[M];S="";var q=this.clone();for(q.negative=0;!q.isZero();){var e0=q.modrn(a0).toString(M);q=q.idivn(a0),q.isZero()?S=e0+S:S=W[m0-e0.length]+e0+S}for(this.isZero()&&(S="0"+S);S.length%u0!==0;)S="0"+S;return this.negative!==0&&(S="-"+S),S}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var M=this.words[0];return this.length===2?M+=this.words[1]*67108864:this.length===3&&this.words[2]===1?M+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-M:M},Z.prototype.toJSON=function(){return this.toString(16,2)},Q&&(Z.prototype.toBuffer=function(M,u0){return this.toArrayLike(Q,M,u0)}),Z.prototype.toArray=function(M,u0){return this.toArrayLike(Array,M,u0)};var p0=function(M,u0){return M.allocUnsafe?M.allocUnsafe(u0):new M(u0)};Z.prototype.toArrayLike=function(M,u0,S){this._strip();var n0=this.byteLength(),v=S||Math.max(1,n0);Y(n0<=v,"byte array longer than desired length"),Y(v>0,"Requested array length <= 0");var s0=p0(M,v),I=u0==="le"?"LE":"BE";return this["_toArrayLike"+I](s0,n0),s0},Z.prototype._toArrayLikeLE=function(M,u0){for(var S=0,n0=0,v=0,s0=0;v>8&255),S>16&255),s0===6?(S>24&255),n0=0,s0=0):(n0=I>>>24,s0+=2)}if(S=0&&(M[S--]=I>>8&255),S>=0&&(M[S--]=I>>16&255),s0===6?(S>=0&&(M[S--]=I>>24&255),n0=0,s0=0):(n0=I>>>24,s0+=2)}if(S>=0)for(M[S--]=n0;S>=0;)M[S--]=0},Math.clz32?Z.prototype._countBits=function(M){return 32-Math.clz32(M)}:Z.prototype._countBits=function(M){var u0=M,S=0;return u0>=4096&&(S+=13,u0>>>=13),u0>=64&&(S+=7,u0>>>=7),u0>=8&&(S+=4,u0>>>=4),u0>=2&&(S+=2,u0>>>=2),S+u0},Z.prototype._zeroBits=function(M){if(M===0)return 26;var u0=M,S=0;return(u0&8191)===0&&(S+=13,u0>>>=13),(u0&127)===0&&(S+=7,u0>>>=7),(u0&15)===0&&(S+=4,u0>>>=4),(u0&3)===0&&(S+=2,u0>>>=2),(u0&1)===0&&S++,S},Z.prototype.bitLength=function(){var M=this.words[this.length-1],u0=this._countBits(M);return(this.length-1)*26+u0};function T(M){for(var u0=new Array(M.bitLength()),S=0;S>>v&1}return u0}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var M=0,u0=0;u0M.length?this.clone().ior(M):M.clone().ior(this)},Z.prototype.uor=function(M){return this.length>M.length?this.clone().iuor(M):M.clone().iuor(this)},Z.prototype.iuand=function(M){var u0;this.length>M.length?u0=M:u0=this;for(var S=0;SM.length?this.clone().iand(M):M.clone().iand(this)},Z.prototype.uand=function(M){return this.length>M.length?this.clone().iuand(M):M.clone().iuand(this)},Z.prototype.iuxor=function(M){var u0,S;this.length>M.length?(u0=this,S=M):(u0=M,S=this);for(var n0=0;n0M.length?this.clone().ixor(M):M.clone().ixor(this)},Z.prototype.uxor=function(M){return this.length>M.length?this.clone().iuxor(M):M.clone().iuxor(this)},Z.prototype.inotn=function(M){Y(typeof M=="number"&&M>=0);var u0=Math.ceil(M/26)|0,S=M%26;this._expand(u0),S>0&&u0--;for(var n0=0;n00&&(this.words[n0]=~this.words[n0]&67108863>>26-S),this._strip()},Z.prototype.notn=function(M){return this.clone().inotn(M)},Z.prototype.setn=function(M,u0){Y(typeof M=="number"&&M>=0);var S=M/26|0,n0=M%26;return this._expand(S+1),u0?this.words[S]=this.words[S]|1<M.length?(S=this,n0=M):(S=M,n0=this);for(var v=0,s0=0;s0>>26;for(;v!==0&&s0>>26;if(this.length=S.length,v!==0)this.words[this.length]=v,this.length++;else if(S!==this)for(;s0M.length?this.clone().iadd(M):M.clone().iadd(this)},Z.prototype.isub=function(M){if(M.negative!==0){M.negative=0;var u0=this.iadd(M);return M.negative=1,u0._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(M),this.negative=1,this._normSign();var S=this.cmp(M);if(S===0)return this.negative=0,this.length=1,this.words[0]=0,this;var n0,v;S>0?(n0=this,v=M):(n0=M,v=this);for(var s0=0,I=0;I>26,this.words[I]=u0&67108863;for(;s0!==0&&I>26,this.words[I]=u0&67108863;if(s0===0&&I>>26,e0=m0&67108863,r0=Math.min(a0,u0.length-1),i0=Math.max(0,a0-M.length+1);i0<=r0;i0++){var j=a0-i0|0;v=M.words[j]|0,s0=u0.words[i0]|0,I=v*s0+e0,q+=I/67108864|0,e0=I&67108863}S.words[a0]=e0|0,m0=q|0}return m0!==0?S.words[a0]=m0|0:S.length--,S._strip()}var D=function(M,u0,S){var n0=M.words,v=u0.words,s0=S.words,I=0,t0,m0,a0,q=n0[0]|0,e0=q&8191,r0=q>>>13,i0=n0[1]|0,j=i0&8191,$$=i0>>>13,k=n0[2]|0,Q$=k&8191,g=k>>>13,Y$=n0[3]|0,_=Y$&8191,Z$=Y$>>>13,N=n0[4]|0,G$=N&8191,x=N>>>13,V$=n0[5]|0,B=V$&8191,U$=V$>>>13,y=n0[6]|0,X$=y&8191,w=y>>>13,K$=n0[7]|0,p=K$&8191,I$=K$>>>13,f=n0[8]|0,O$=f&8191,c=f>>>13,J$=n0[9]|0,h=J$&8191,F$=J$>>>13,d=v[0]|0,A$=d&8191,b=d>>>13,H$=v[1]|0,l=H$&8191,W$=H$>>>13,o=v[2]|0,E$=o&8191,u=o>>>13,T$=v[3]|0,n=T$&8191,D$=T$>>>13,s=v[4]|0,C$=s&8191,t=s>>>13,L$=v[5]|0,m=L$&8191,R$=L$>>>13,a=v[6]|0,P$=a&8191,O=a>>>13,z$=v[7]|0,e=z$&8191,M$=z$>>>13,J=v[8]|0,S$=J&8191,F=J>>>13,v$=v[9]|0,r=v$&8191,q$=v$>>>13;S.negative=M.negative^u0.negative,S.length=19,t0=Math.imul(e0,A$),m0=Math.imul(e0,b),m0=m0+Math.imul(r0,A$)|0,a0=Math.imul(r0,b);var i=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(i>>>26)|0,i&=67108863,t0=Math.imul(j,A$),m0=Math.imul(j,b),m0=m0+Math.imul($$,A$)|0,a0=Math.imul($$,b),t0=t0+Math.imul(e0,l)|0,m0=m0+Math.imul(e0,W$)|0,m0=m0+Math.imul(r0,l)|0,a0=a0+Math.imul(r0,W$)|0;var j$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(j$>>>26)|0,j$&=67108863,t0=Math.imul(Q$,A$),m0=Math.imul(Q$,b),m0=m0+Math.imul(g,A$)|0,a0=Math.imul(g,b),t0=t0+Math.imul(j,l)|0,m0=m0+Math.imul(j,W$)|0,m0=m0+Math.imul($$,l)|0,a0=a0+Math.imul($$,W$)|0,t0=t0+Math.imul(e0,E$)|0,m0=m0+Math.imul(e0,u)|0,m0=m0+Math.imul(r0,E$)|0,a0=a0+Math.imul(r0,u)|0;var k$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(k$>>>26)|0,k$&=67108863,t0=Math.imul(_,A$),m0=Math.imul(_,b),m0=m0+Math.imul(Z$,A$)|0,a0=Math.imul(Z$,b),t0=t0+Math.imul(Q$,l)|0,m0=m0+Math.imul(Q$,W$)|0,m0=m0+Math.imul(g,l)|0,a0=a0+Math.imul(g,W$)|0,t0=t0+Math.imul(j,E$)|0,m0=m0+Math.imul(j,u)|0,m0=m0+Math.imul($$,E$)|0,a0=a0+Math.imul($$,u)|0,t0=t0+Math.imul(e0,n)|0,m0=m0+Math.imul(e0,D$)|0,m0=m0+Math.imul(r0,n)|0,a0=a0+Math.imul(r0,D$)|0;var g$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(g$>>>26)|0,g$&=67108863,t0=Math.imul(G$,A$),m0=Math.imul(G$,b),m0=m0+Math.imul(x,A$)|0,a0=Math.imul(x,b),t0=t0+Math.imul(_,l)|0,m0=m0+Math.imul(_,W$)|0,m0=m0+Math.imul(Z$,l)|0,a0=a0+Math.imul(Z$,W$)|0,t0=t0+Math.imul(Q$,E$)|0,m0=m0+Math.imul(Q$,u)|0,m0=m0+Math.imul(g,E$)|0,a0=a0+Math.imul(g,u)|0,t0=t0+Math.imul(j,n)|0,m0=m0+Math.imul(j,D$)|0,m0=m0+Math.imul($$,n)|0,a0=a0+Math.imul($$,D$)|0,t0=t0+Math.imul(e0,C$)|0,m0=m0+Math.imul(e0,t)|0,m0=m0+Math.imul(r0,C$)|0,a0=a0+Math.imul(r0,t)|0;var _$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(_$>>>26)|0,_$&=67108863,t0=Math.imul(B,A$),m0=Math.imul(B,b),m0=m0+Math.imul(U$,A$)|0,a0=Math.imul(U$,b),t0=t0+Math.imul(G$,l)|0,m0=m0+Math.imul(G$,W$)|0,m0=m0+Math.imul(x,l)|0,a0=a0+Math.imul(x,W$)|0,t0=t0+Math.imul(_,E$)|0,m0=m0+Math.imul(_,u)|0,m0=m0+Math.imul(Z$,E$)|0,a0=a0+Math.imul(Z$,u)|0,t0=t0+Math.imul(Q$,n)|0,m0=m0+Math.imul(Q$,D$)|0,m0=m0+Math.imul(g,n)|0,a0=a0+Math.imul(g,D$)|0,t0=t0+Math.imul(j,C$)|0,m0=m0+Math.imul(j,t)|0,m0=m0+Math.imul($$,C$)|0,a0=a0+Math.imul($$,t)|0,t0=t0+Math.imul(e0,m)|0,m0=m0+Math.imul(e0,R$)|0,m0=m0+Math.imul(r0,m)|0,a0=a0+Math.imul(r0,R$)|0;var N$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(N$>>>26)|0,N$&=67108863,t0=Math.imul(X$,A$),m0=Math.imul(X$,b),m0=m0+Math.imul(w,A$)|0,a0=Math.imul(w,b),t0=t0+Math.imul(B,l)|0,m0=m0+Math.imul(B,W$)|0,m0=m0+Math.imul(U$,l)|0,a0=a0+Math.imul(U$,W$)|0,t0=t0+Math.imul(G$,E$)|0,m0=m0+Math.imul(G$,u)|0,m0=m0+Math.imul(x,E$)|0,a0=a0+Math.imul(x,u)|0,t0=t0+Math.imul(_,n)|0,m0=m0+Math.imul(_,D$)|0,m0=m0+Math.imul(Z$,n)|0,a0=a0+Math.imul(Z$,D$)|0,t0=t0+Math.imul(Q$,C$)|0,m0=m0+Math.imul(Q$,t)|0,m0=m0+Math.imul(g,C$)|0,a0=a0+Math.imul(g,t)|0,t0=t0+Math.imul(j,m)|0,m0=m0+Math.imul(j,R$)|0,m0=m0+Math.imul($$,m)|0,a0=a0+Math.imul($$,R$)|0,t0=t0+Math.imul(e0,P$)|0,m0=m0+Math.imul(e0,O)|0,m0=m0+Math.imul(r0,P$)|0,a0=a0+Math.imul(r0,O)|0;var $0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+($0>>>26)|0,$0&=67108863,t0=Math.imul(p,A$),m0=Math.imul(p,b),m0=m0+Math.imul(I$,A$)|0,a0=Math.imul(I$,b),t0=t0+Math.imul(X$,l)|0,m0=m0+Math.imul(X$,W$)|0,m0=m0+Math.imul(w,l)|0,a0=a0+Math.imul(w,W$)|0,t0=t0+Math.imul(B,E$)|0,m0=m0+Math.imul(B,u)|0,m0=m0+Math.imul(U$,E$)|0,a0=a0+Math.imul(U$,u)|0,t0=t0+Math.imul(G$,n)|0,m0=m0+Math.imul(G$,D$)|0,m0=m0+Math.imul(x,n)|0,a0=a0+Math.imul(x,D$)|0,t0=t0+Math.imul(_,C$)|0,m0=m0+Math.imul(_,t)|0,m0=m0+Math.imul(Z$,C$)|0,a0=a0+Math.imul(Z$,t)|0,t0=t0+Math.imul(Q$,m)|0,m0=m0+Math.imul(Q$,R$)|0,m0=m0+Math.imul(g,m)|0,a0=a0+Math.imul(g,R$)|0,t0=t0+Math.imul(j,P$)|0,m0=m0+Math.imul(j,O)|0,m0=m0+Math.imul($$,P$)|0,a0=a0+Math.imul($$,O)|0,t0=t0+Math.imul(e0,e)|0,m0=m0+Math.imul(e0,M$)|0,m0=m0+Math.imul(r0,e)|0,a0=a0+Math.imul(r0,M$)|0;var x$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(x$>>>26)|0,x$&=67108863,t0=Math.imul(O$,A$),m0=Math.imul(O$,b),m0=m0+Math.imul(c,A$)|0,a0=Math.imul(c,b),t0=t0+Math.imul(p,l)|0,m0=m0+Math.imul(p,W$)|0,m0=m0+Math.imul(I$,l)|0,a0=a0+Math.imul(I$,W$)|0,t0=t0+Math.imul(X$,E$)|0,m0=m0+Math.imul(X$,u)|0,m0=m0+Math.imul(w,E$)|0,a0=a0+Math.imul(w,u)|0,t0=t0+Math.imul(B,n)|0,m0=m0+Math.imul(B,D$)|0,m0=m0+Math.imul(U$,n)|0,a0=a0+Math.imul(U$,D$)|0,t0=t0+Math.imul(G$,C$)|0,m0=m0+Math.imul(G$,t)|0,m0=m0+Math.imul(x,C$)|0,a0=a0+Math.imul(x,t)|0,t0=t0+Math.imul(_,m)|0,m0=m0+Math.imul(_,R$)|0,m0=m0+Math.imul(Z$,m)|0,a0=a0+Math.imul(Z$,R$)|0,t0=t0+Math.imul(Q$,P$)|0,m0=m0+Math.imul(Q$,O)|0,m0=m0+Math.imul(g,P$)|0,a0=a0+Math.imul(g,O)|0,t0=t0+Math.imul(j,e)|0,m0=m0+Math.imul(j,M$)|0,m0=m0+Math.imul($$,e)|0,a0=a0+Math.imul($$,M$)|0,t0=t0+Math.imul(e0,S$)|0,m0=m0+Math.imul(e0,F)|0,m0=m0+Math.imul(r0,S$)|0,a0=a0+Math.imul(r0,F)|0;var Q0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,t0=Math.imul(h,A$),m0=Math.imul(h,b),m0=m0+Math.imul(F$,A$)|0,a0=Math.imul(F$,b),t0=t0+Math.imul(O$,l)|0,m0=m0+Math.imul(O$,W$)|0,m0=m0+Math.imul(c,l)|0,a0=a0+Math.imul(c,W$)|0,t0=t0+Math.imul(p,E$)|0,m0=m0+Math.imul(p,u)|0,m0=m0+Math.imul(I$,E$)|0,a0=a0+Math.imul(I$,u)|0,t0=t0+Math.imul(X$,n)|0,m0=m0+Math.imul(X$,D$)|0,m0=m0+Math.imul(w,n)|0,a0=a0+Math.imul(w,D$)|0,t0=t0+Math.imul(B,C$)|0,m0=m0+Math.imul(B,t)|0,m0=m0+Math.imul(U$,C$)|0,a0=a0+Math.imul(U$,t)|0,t0=t0+Math.imul(G$,m)|0,m0=m0+Math.imul(G$,R$)|0,m0=m0+Math.imul(x,m)|0,a0=a0+Math.imul(x,R$)|0,t0=t0+Math.imul(_,P$)|0,m0=m0+Math.imul(_,O)|0,m0=m0+Math.imul(Z$,P$)|0,a0=a0+Math.imul(Z$,O)|0,t0=t0+Math.imul(Q$,e)|0,m0=m0+Math.imul(Q$,M$)|0,m0=m0+Math.imul(g,e)|0,a0=a0+Math.imul(g,M$)|0,t0=t0+Math.imul(j,S$)|0,m0=m0+Math.imul(j,F)|0,m0=m0+Math.imul($$,S$)|0,a0=a0+Math.imul($$,F)|0,t0=t0+Math.imul(e0,r)|0,m0=m0+Math.imul(e0,q$)|0,m0=m0+Math.imul(r0,r)|0,a0=a0+Math.imul(r0,q$)|0;var B$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(B$>>>26)|0,B$&=67108863,t0=Math.imul(h,l),m0=Math.imul(h,W$),m0=m0+Math.imul(F$,l)|0,a0=Math.imul(F$,W$),t0=t0+Math.imul(O$,E$)|0,m0=m0+Math.imul(O$,u)|0,m0=m0+Math.imul(c,E$)|0,a0=a0+Math.imul(c,u)|0,t0=t0+Math.imul(p,n)|0,m0=m0+Math.imul(p,D$)|0,m0=m0+Math.imul(I$,n)|0,a0=a0+Math.imul(I$,D$)|0,t0=t0+Math.imul(X$,C$)|0,m0=m0+Math.imul(X$,t)|0,m0=m0+Math.imul(w,C$)|0,a0=a0+Math.imul(w,t)|0,t0=t0+Math.imul(B,m)|0,m0=m0+Math.imul(B,R$)|0,m0=m0+Math.imul(U$,m)|0,a0=a0+Math.imul(U$,R$)|0,t0=t0+Math.imul(G$,P$)|0,m0=m0+Math.imul(G$,O)|0,m0=m0+Math.imul(x,P$)|0,a0=a0+Math.imul(x,O)|0,t0=t0+Math.imul(_,e)|0,m0=m0+Math.imul(_,M$)|0,m0=m0+Math.imul(Z$,e)|0,a0=a0+Math.imul(Z$,M$)|0,t0=t0+Math.imul(Q$,S$)|0,m0=m0+Math.imul(Q$,F)|0,m0=m0+Math.imul(g,S$)|0,a0=a0+Math.imul(g,F)|0,t0=t0+Math.imul(j,r)|0,m0=m0+Math.imul(j,q$)|0,m0=m0+Math.imul($$,r)|0,a0=a0+Math.imul($$,q$)|0;var Y0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,t0=Math.imul(h,E$),m0=Math.imul(h,u),m0=m0+Math.imul(F$,E$)|0,a0=Math.imul(F$,u),t0=t0+Math.imul(O$,n)|0,m0=m0+Math.imul(O$,D$)|0,m0=m0+Math.imul(c,n)|0,a0=a0+Math.imul(c,D$)|0,t0=t0+Math.imul(p,C$)|0,m0=m0+Math.imul(p,t)|0,m0=m0+Math.imul(I$,C$)|0,a0=a0+Math.imul(I$,t)|0,t0=t0+Math.imul(X$,m)|0,m0=m0+Math.imul(X$,R$)|0,m0=m0+Math.imul(w,m)|0,a0=a0+Math.imul(w,R$)|0,t0=t0+Math.imul(B,P$)|0,m0=m0+Math.imul(B,O)|0,m0=m0+Math.imul(U$,P$)|0,a0=a0+Math.imul(U$,O)|0,t0=t0+Math.imul(G$,e)|0,m0=m0+Math.imul(G$,M$)|0,m0=m0+Math.imul(x,e)|0,a0=a0+Math.imul(x,M$)|0,t0=t0+Math.imul(_,S$)|0,m0=m0+Math.imul(_,F)|0,m0=m0+Math.imul(Z$,S$)|0,a0=a0+Math.imul(Z$,F)|0,t0=t0+Math.imul(Q$,r)|0,m0=m0+Math.imul(Q$,q$)|0,m0=m0+Math.imul(g,r)|0,a0=a0+Math.imul(g,q$)|0;var y$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(y$>>>26)|0,y$&=67108863,t0=Math.imul(h,n),m0=Math.imul(h,D$),m0=m0+Math.imul(F$,n)|0,a0=Math.imul(F$,D$),t0=t0+Math.imul(O$,C$)|0,m0=m0+Math.imul(O$,t)|0,m0=m0+Math.imul(c,C$)|0,a0=a0+Math.imul(c,t)|0,t0=t0+Math.imul(p,m)|0,m0=m0+Math.imul(p,R$)|0,m0=m0+Math.imul(I$,m)|0,a0=a0+Math.imul(I$,R$)|0,t0=t0+Math.imul(X$,P$)|0,m0=m0+Math.imul(X$,O)|0,m0=m0+Math.imul(w,P$)|0,a0=a0+Math.imul(w,O)|0,t0=t0+Math.imul(B,e)|0,m0=m0+Math.imul(B,M$)|0,m0=m0+Math.imul(U$,e)|0,a0=a0+Math.imul(U$,M$)|0,t0=t0+Math.imul(G$,S$)|0,m0=m0+Math.imul(G$,F)|0,m0=m0+Math.imul(x,S$)|0,a0=a0+Math.imul(x,F)|0,t0=t0+Math.imul(_,r)|0,m0=m0+Math.imul(_,q$)|0,m0=m0+Math.imul(Z$,r)|0,a0=a0+Math.imul(Z$,q$)|0;var Z0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,t0=Math.imul(h,C$),m0=Math.imul(h,t),m0=m0+Math.imul(F$,C$)|0,a0=Math.imul(F$,t),t0=t0+Math.imul(O$,m)|0,m0=m0+Math.imul(O$,R$)|0,m0=m0+Math.imul(c,m)|0,a0=a0+Math.imul(c,R$)|0,t0=t0+Math.imul(p,P$)|0,m0=m0+Math.imul(p,O)|0,m0=m0+Math.imul(I$,P$)|0,a0=a0+Math.imul(I$,O)|0,t0=t0+Math.imul(X$,e)|0,m0=m0+Math.imul(X$,M$)|0,m0=m0+Math.imul(w,e)|0,a0=a0+Math.imul(w,M$)|0,t0=t0+Math.imul(B,S$)|0,m0=m0+Math.imul(B,F)|0,m0=m0+Math.imul(U$,S$)|0,a0=a0+Math.imul(U$,F)|0,t0=t0+Math.imul(G$,r)|0,m0=m0+Math.imul(G$,q$)|0,m0=m0+Math.imul(x,r)|0,a0=a0+Math.imul(x,q$)|0;var w$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(w$>>>26)|0,w$&=67108863,t0=Math.imul(h,m),m0=Math.imul(h,R$),m0=m0+Math.imul(F$,m)|0,a0=Math.imul(F$,R$),t0=t0+Math.imul(O$,P$)|0,m0=m0+Math.imul(O$,O)|0,m0=m0+Math.imul(c,P$)|0,a0=a0+Math.imul(c,O)|0,t0=t0+Math.imul(p,e)|0,m0=m0+Math.imul(p,M$)|0,m0=m0+Math.imul(I$,e)|0,a0=a0+Math.imul(I$,M$)|0,t0=t0+Math.imul(X$,S$)|0,m0=m0+Math.imul(X$,F)|0,m0=m0+Math.imul(w,S$)|0,a0=a0+Math.imul(w,F)|0,t0=t0+Math.imul(B,r)|0,m0=m0+Math.imul(B,q$)|0,m0=m0+Math.imul(U$,r)|0,a0=a0+Math.imul(U$,q$)|0;var G0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(G0>>>26)|0,G0&=67108863,t0=Math.imul(h,P$),m0=Math.imul(h,O),m0=m0+Math.imul(F$,P$)|0,a0=Math.imul(F$,O),t0=t0+Math.imul(O$,e)|0,m0=m0+Math.imul(O$,M$)|0,m0=m0+Math.imul(c,e)|0,a0=a0+Math.imul(c,M$)|0,t0=t0+Math.imul(p,S$)|0,m0=m0+Math.imul(p,F)|0,m0=m0+Math.imul(I$,S$)|0,a0=a0+Math.imul(I$,F)|0,t0=t0+Math.imul(X$,r)|0,m0=m0+Math.imul(X$,q$)|0,m0=m0+Math.imul(w,r)|0,a0=a0+Math.imul(w,q$)|0;var p$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(p$>>>26)|0,p$&=67108863,t0=Math.imul(h,e),m0=Math.imul(h,M$),m0=m0+Math.imul(F$,e)|0,a0=Math.imul(F$,M$),t0=t0+Math.imul(O$,S$)|0,m0=m0+Math.imul(O$,F)|0,m0=m0+Math.imul(c,S$)|0,a0=a0+Math.imul(c,F)|0,t0=t0+Math.imul(p,r)|0,m0=m0+Math.imul(p,q$)|0,m0=m0+Math.imul(I$,r)|0,a0=a0+Math.imul(I$,q$)|0;var V0=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(V0>>>26)|0,V0&=67108863,t0=Math.imul(h,S$),m0=Math.imul(h,F),m0=m0+Math.imul(F$,S$)|0,a0=Math.imul(F$,F),t0=t0+Math.imul(O$,r)|0,m0=m0+Math.imul(O$,q$)|0,m0=m0+Math.imul(c,r)|0,a0=a0+Math.imul(c,q$)|0;var f$=(I+t0|0)+((m0&8191)<<13)|0;I=(a0+(m0>>>13)|0)+(f$>>>26)|0,f$&=67108863,t0=Math.imul(h,r),m0=Math.imul(h,q$),m0=m0+Math.imul(F$,r)|0,a0=Math.imul(F$,q$);var U0=(I+t0|0)+((m0&8191)<<13)|0;return I=(a0+(m0>>>13)|0)+(U0>>>26)|0,U0&=67108863,s0[0]=i,s0[1]=j$,s0[2]=k$,s0[3]=g$,s0[4]=_$,s0[5]=N$,s0[6]=$0,s0[7]=x$,s0[8]=Q0,s0[9]=B$,s0[10]=Y0,s0[11]=y$,s0[12]=Z0,s0[13]=w$,s0[14]=G0,s0[15]=p$,s0[16]=V0,s0[17]=f$,s0[18]=U0,I!==0&&(s0[19]=I,S.length++),S};Math.imul||(D=f0);function c0(M,u0,S){S.negative=u0.negative^M.negative,S.length=M.length+u0.length;for(var n0=0,v=0,s0=0;s0>>26)|0,v+=I>>>26,I&=67108863}S.words[s0]=t0,n0=I,I=v}return n0!==0?S.words[s0]=n0:S.length--,S._strip()}function C(M,u0,S){return c0(M,u0,S)}Z.prototype.mulTo=function(M,u0){var S,n0=this.length+M.length;return this.length===10&&M.length===10?S=D(this,M,u0):n0<63?S=f0(this,M,u0):n0<1024?S=c0(this,M,u0):S=C(this,M,u0),S};function h0(M,u0){this.x=M,this.y=u0}h0.prototype.makeRBT=function(M){for(var u0=new Array(M),S=Z.prototype._countBits(M)-1,n0=0;n0>=1;return n0},h0.prototype.permute=function(M,u0,S,n0,v,s0){for(var I=0;I>>1)v++;return 1<>>13,S[2*s0+1]=v&8191,v=v>>>13;for(s0=2*u0;s0>=26,S+=v/67108864|0,S+=s0>>>26,this.words[n0]=s0&67108863}return S!==0&&(this.words[n0]=S,this.length++),u0?this.ineg():this},Z.prototype.muln=function(M){return this.clone().imuln(M)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(M){var u0=T(M);if(u0.length===0)return new Z(1);for(var S=this,n0=0;n0=0);var u0=M%26,S=(M-u0)/26,n0=67108863>>>26-u0<<26-u0,v;if(u0!==0){var s0=0;for(v=0;v>>26-u0}s0&&(this.words[v]=s0,this.length++)}if(S!==0){for(v=this.length-1;v>=0;v--)this.words[v+S]=this.words[v];for(v=0;v=0);var n0;u0?n0=(u0-u0%26)/26:n0=0;var v=M%26,s0=Math.min((M-v)/26,this.length),I=67108863^67108863>>>v<s0)for(this.length-=s0,m0=0;m0=0&&(a0!==0||m0>=n0);m0--){var q=this.words[m0]|0;this.words[m0]=a0<<26-v|q>>>v,a0=q&I}return t0&&a0!==0&&(t0.words[t0.length++]=a0),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},Z.prototype.ishrn=function(M,u0,S){return Y(this.negative===0),this.iushrn(M,u0,S)},Z.prototype.shln=function(M){return this.clone().ishln(M)},Z.prototype.ushln=function(M){return this.clone().iushln(M)},Z.prototype.shrn=function(M){return this.clone().ishrn(M)},Z.prototype.ushrn=function(M){return this.clone().iushrn(M)},Z.prototype.testn=function(M){Y(typeof M=="number"&&M>=0);var u0=M%26,S=(M-u0)/26,n0=1<=0);var u0=M%26,S=(M-u0)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=S)return this;if(u0!==0&&S++,this.length=Math.min(S,this.length),u0!==0){var n0=67108863^67108863>>>u0<=67108864;u0++)this.words[u0]-=67108864,u0===this.length-1?this.words[u0+1]=1:this.words[u0+1]++;return this.length=Math.max(this.length,u0+1),this},Z.prototype.isubn=function(M){if(Y(typeof M=="number"),Y(M<67108864),M<0)return this.iaddn(-M);if(this.negative!==0)return this.negative=0,this.iaddn(M),this.negative=1,this;if(this.words[0]-=M,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u0=0;u0>26)-(t0/67108864|0),this.words[v+S]=s0&67108863}for(;v>26,this.words[v+S]=s0&67108863;if(I===0)return this._strip();for(Y(I===-1),I=0,v=0;v>26,this.words[v]=s0&67108863;return this.negative=1,this._strip()},Z.prototype._wordDiv=function(M,u0){var S=this.length-M.length,n0=this.clone(),v=M,s0=v.words[v.length-1]|0,I=this._countBits(s0);S=26-I,S!==0&&(v=v.ushln(S),n0.iushln(S),s0=v.words[v.length-1]|0);var t0=n0.length-v.length,m0;if(u0!=="mod"){m0=new Z(null),m0.length=t0+1,m0.words=new Array(m0.length);for(var a0=0;a0=0;e0--){var r0=(n0.words[v.length+e0]|0)*67108864+(n0.words[v.length+e0-1]|0);for(r0=Math.min(r0/s0|0,67108863),n0._ishlnsubmul(v,r0,e0);n0.negative!==0;)r0--,n0.negative=0,n0._ishlnsubmul(v,1,e0),n0.isZero()||(n0.negative^=1);m0&&(m0.words[e0]=r0)}return m0&&m0._strip(),n0._strip(),u0!=="div"&&S!==0&&n0.iushrn(S),{div:m0||null,mod:n0}},Z.prototype.divmod=function(M,u0,S){if(Y(!M.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var n0,v,s0;return this.negative!==0&&M.negative===0?(s0=this.neg().divmod(M,u0),u0!=="mod"&&(n0=s0.div.neg()),u0!=="div"&&(v=s0.mod.neg(),S&&v.negative!==0&&v.iadd(M)),{div:n0,mod:v}):this.negative===0&&M.negative!==0?(s0=this.divmod(M.neg(),u0),u0!=="mod"&&(n0=s0.div.neg()),{div:n0,mod:s0.mod}):(this.negative&M.negative)!==0?(s0=this.neg().divmod(M.neg(),u0),u0!=="div"&&(v=s0.mod.neg(),S&&v.negative!==0&&v.isub(M)),{div:s0.div,mod:v}):M.length>this.length||this.cmp(M)<0?{div:new Z(0),mod:this}:M.length===1?u0==="div"?{div:this.divn(M.words[0]),mod:null}:u0==="mod"?{div:null,mod:new Z(this.modrn(M.words[0]))}:{div:this.divn(M.words[0]),mod:new Z(this.modrn(M.words[0]))}:this._wordDiv(M,u0)},Z.prototype.div=function(M){return this.divmod(M,"div",!1).div},Z.prototype.mod=function(M){return this.divmod(M,"mod",!1).mod},Z.prototype.umod=function(M){return this.divmod(M,"mod",!0).mod},Z.prototype.divRound=function(M){var u0=this.divmod(M);if(u0.mod.isZero())return u0.div;var S=u0.div.negative!==0?u0.mod.isub(M):u0.mod,n0=M.ushrn(1),v=M.andln(1),s0=S.cmp(n0);return s0<0||v===1&&s0===0?u0.div:u0.div.negative!==0?u0.div.isubn(1):u0.div.iaddn(1)},Z.prototype.modrn=function(M){var u0=M<0;u0&&(M=-M),Y(M<=67108863);for(var S=(1<<26)%M,n0=0,v=this.length-1;v>=0;v--)n0=(S*n0+(this.words[v]|0))%M;return u0?-n0:n0},Z.prototype.modn=function(M){return this.modrn(M)},Z.prototype.idivn=function(M){var u0=M<0;u0&&(M=-M),Y(M<=67108863);for(var S=0,n0=this.length-1;n0>=0;n0--){var v=(this.words[n0]|0)+S*67108864;this.words[n0]=v/M|0,S=v%M}return this._strip(),u0?this.ineg():this},Z.prototype.divn=function(M){return this.clone().idivn(M)},Z.prototype.egcd=function(M){Y(M.negative===0),Y(!M.isZero());var u0=this,S=M.clone();u0.negative!==0?u0=u0.umod(M):u0=u0.clone();for(var n0=new Z(1),v=new Z(0),s0=new Z(0),I=new Z(1),t0=0;u0.isEven()&&S.isEven();)u0.iushrn(1),S.iushrn(1),++t0;for(var m0=S.clone(),a0=u0.clone();!u0.isZero();){for(var q=0,e0=1;(u0.words[0]&e0)===0&&q<26;++q,e0<<=1);if(q>0)for(u0.iushrn(q);q-- >0;)(n0.isOdd()||v.isOdd())&&(n0.iadd(m0),v.isub(a0)),n0.iushrn(1),v.iushrn(1);for(var r0=0,i0=1;(S.words[0]&i0)===0&&r0<26;++r0,i0<<=1);if(r0>0)for(S.iushrn(r0);r0-- >0;)(s0.isOdd()||I.isOdd())&&(s0.iadd(m0),I.isub(a0)),s0.iushrn(1),I.iushrn(1);u0.cmp(S)>=0?(u0.isub(S),n0.isub(s0),v.isub(I)):(S.isub(u0),s0.isub(n0),I.isub(v))}return{a:s0,b:I,gcd:S.iushln(t0)}},Z.prototype._invmp=function(M){Y(M.negative===0),Y(!M.isZero());var u0=this,S=M.clone();u0.negative!==0?u0=u0.umod(M):u0=u0.clone();for(var n0=new Z(1),v=new Z(0),s0=S.clone();u0.cmpn(1)>0&&S.cmpn(1)>0;){for(var I=0,t0=1;(u0.words[0]&t0)===0&&I<26;++I,t0<<=1);if(I>0)for(u0.iushrn(I);I-- >0;)n0.isOdd()&&n0.iadd(s0),n0.iushrn(1);for(var m0=0,a0=1;(S.words[0]&a0)===0&&m0<26;++m0,a0<<=1);if(m0>0)for(S.iushrn(m0);m0-- >0;)v.isOdd()&&v.iadd(s0),v.iushrn(1);u0.cmp(S)>=0?(u0.isub(S),n0.isub(v)):(S.isub(u0),v.isub(n0))}var q;return u0.cmpn(1)===0?q=n0:q=v,q.cmpn(0)<0&&q.iadd(M),q},Z.prototype.gcd=function(M){if(this.isZero())return M.abs();if(M.isZero())return this.abs();var u0=this.clone(),S=M.clone();u0.negative=0,S.negative=0;for(var n0=0;u0.isEven()&&S.isEven();n0++)u0.iushrn(1),S.iushrn(1);do{for(;u0.isEven();)u0.iushrn(1);for(;S.isEven();)S.iushrn(1);var v=u0.cmp(S);if(v<0){var s0=u0;u0=S,S=s0}else if(v===0||S.cmpn(1)===0)break;u0.isub(S)}while(!0);return S.iushln(n0)},Z.prototype.invm=function(M){return this.egcd(M).a.umod(M)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(M){return this.words[0]&M},Z.prototype.bincn=function(M){Y(typeof M=="number");var u0=M%26,S=(M-u0)/26,n0=1<>>26,I&=67108863,this.words[s0]=I}return v!==0&&(this.words[s0]=v,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(M){var u0=M<0;if(this.negative!==0&&!u0)return-1;if(this.negative===0&&u0)return 1;this._strip();var S;if(this.length>1)S=1;else{u0&&(M=-M),Y(M<=67108863,"Number is too big");var n0=this.words[0]|0;S=n0===M?0:n0M.length)return 1;if(this.length=0;S--){var n0=this.words[S]|0,v=M.words[S]|0;if(n0!==v){n0v&&(u0=1);break}}return u0},Z.prototype.gtn=function(M){return this.cmpn(M)===1},Z.prototype.gt=function(M){return this.cmp(M)===1},Z.prototype.gten=function(M){return this.cmpn(M)>=0},Z.prototype.gte=function(M){return this.cmp(M)>=0},Z.prototype.ltn=function(M){return this.cmpn(M)===-1},Z.prototype.lt=function(M){return this.cmp(M)===-1},Z.prototype.lten=function(M){return this.cmpn(M)<=0},Z.prototype.lte=function(M){return this.cmp(M)<=0},Z.prototype.eqn=function(M){return this.cmpn(M)===0},Z.prototype.eq=function(M){return this.cmp(M)===0},Z.red=function(M){return new z(M)},Z.prototype.toRed=function(M){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),M.convertTo(this)._forceRed(M)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(M){return this.red=M,this},Z.prototype.forceRed=function(M){return Y(!this.red,"Already a number in reduction context"),this._forceRed(M)},Z.prototype.redAdd=function(M){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,M)},Z.prototype.redIAdd=function(M){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,M)},Z.prototype.redSub=function(M){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,M)},Z.prototype.redISub=function(M){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,M)},Z.prototype.redShl=function(M){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,M)},Z.prototype.redMul=function(M){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,M),this.red.mul(this,M)},Z.prototype.redIMul=function(M){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,M),this.red.imul(this,M)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(M){return Y(this.red&&!M.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,M)};var L={k256:null,p224:null,p192:null,p25519:null};function d0(M,u0){this.name=M,this.p=new Z(u0,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}d0.prototype._tmp=function(){var M=new Z(null);return M.words=new Array(Math.ceil(this.n/13)),M},d0.prototype.ireduce=function(M){var u0=M,S;do this.split(u0,this.tmp),u0=this.imulK(u0),u0=u0.iadd(this.tmp),S=u0.bitLength();while(S>this.n);var n0=S0?u0.isub(this.p):u0.strip!==void 0?u0.strip():u0._strip(),u0},d0.prototype.split=function(M,u0){M.iushrn(this.n,0,u0)},d0.prototype.imulK=function(M){return M.imul(this.k)};function R(){d0.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(R,d0),R.prototype.split=function(M,u0){for(var S=4194303,n0=Math.min(M.length,9),v=0;v>>22,s0=I}s0>>>=22,M.words[v-10]=s0,s0===0&&M.length>10?M.length-=10:M.length-=9},R.prototype.imulK=function(M){M.words[M.length]=0,M.words[M.length+1]=0,M.length+=2;for(var u0=0,S=0;S>>=26,M.words[S]=v,u0=n0}return u0!==0&&(M.words[M.length++]=u0),M},Z._prime=function(M){if(L[M])return L[M];var u0;if(M==="k256")u0=new R;else if(M==="p224")u0=new b0;else if(M==="p192")u0=new P;else if(M==="p25519")u0=new l0;else throw new Error("Unknown prime "+M);return L[M]=u0,u0};function z(M){if(typeof M=="string"){var u0=Z._prime(M);this.m=u0.p,this.prime=u0}else Y(M.gtn(1),"modulus must be greater than 1"),this.m=M,this.prime=null}z.prototype._verify1=function(M){Y(M.negative===0,"red works only with positives"),Y(M.red,"red works only with red numbers")},z.prototype._verify2=function(M,u0){Y((M.negative|u0.negative)===0,"red works only with positives"),Y(M.red&&M.red===u0.red,"red works only with red numbers")},z.prototype.imod=function(M){return this.prime?this.prime.ireduce(M)._forceRed(this):(H(M,M.umod(this.m)._forceRed(this)),M)},z.prototype.neg=function(M){return M.isZero()?M.clone():this.m.sub(M)._forceRed(this)},z.prototype.add=function(M,u0){this._verify2(M,u0);var S=M.add(u0);return S.cmp(this.m)>=0&&S.isub(this.m),S._forceRed(this)},z.prototype.iadd=function(M,u0){this._verify2(M,u0);var S=M.iadd(u0);return S.cmp(this.m)>=0&&S.isub(this.m),S},z.prototype.sub=function(M,u0){this._verify2(M,u0);var S=M.sub(u0);return S.cmpn(0)<0&&S.iadd(this.m),S._forceRed(this)},z.prototype.isub=function(M,u0){this._verify2(M,u0);var S=M.isub(u0);return S.cmpn(0)<0&&S.iadd(this.m),S},z.prototype.shl=function(M,u0){return this._verify1(M),this.imod(M.ushln(u0))},z.prototype.imul=function(M,u0){return this._verify2(M,u0),this.imod(M.imul(u0))},z.prototype.mul=function(M,u0){return this._verify2(M,u0),this.imod(M.mul(u0))},z.prototype.isqr=function(M){return this.imul(M,M.clone())},z.prototype.sqr=function(M){return this.mul(M,M)},z.prototype.sqrt=function(M){if(M.isZero())return M.clone();var u0=this.m.andln(3);if(Y(u0%2===1),u0===3){var S=this.m.add(new Z(1)).iushrn(2);return this.pow(M,S)}for(var n0=this.m.subn(1),v=0;!n0.isZero()&&n0.andln(1)===0;)v++,n0.iushrn(1);Y(!n0.isZero());var s0=new Z(1).toRed(this),I=s0.redNeg(),t0=this.m.subn(1).iushrn(1),m0=this.m.bitLength();for(m0=new Z(2*m0*m0).toRed(this);this.pow(m0,t0).cmp(I)!==0;)m0.redIAdd(I);for(var a0=this.pow(m0,n0),q=this.pow(M,n0.addn(1).iushrn(1)),e0=this.pow(M,n0),r0=v;e0.cmp(s0)!==0;){for(var i0=e0,j=0;i0.cmp(s0)!==0;j++)i0=i0.redSqr();Y(j=0;v--){for(var a0=u0.words[v],q=m0-1;q>=0;q--){var e0=a0>>q&1;if(s0!==n0[0]&&(s0=this.sqr(s0)),e0===0&&I===0){t0=0;continue}I<<=1,I|=e0,t0++,!(t0!==S&&(v!==0||q!==0))&&(s0=this.mul(s0,n0[I]),t0=0,I=0)}m0=26}return s0},z.prototype.convertTo=function(M){var u0=M.umod(this.m);return u0===M?u0.clone():u0},z.prototype.convertFrom=function(M){var u0=M.clone();return u0.red=null,u0},Z.mont=function(M){return new o0(M)};function o0(M){z.call(this,M),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(o0,z),o0.prototype.convertTo=function(M){return this.imod(M.ushln(this.shift))},o0.prototype.convertFrom=function(M){var u0=this.imod(M.mul(this.rinv));return u0.red=null,u0},o0.prototype.imul=function(M,u0){if(M.isZero()||u0.isZero())return M.words[0]=0,M.length=1,M;var S=M.imul(u0),n0=S.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=S.isub(n0).iushrn(this.shift),s0=v;return v.cmp(this.m)>=0?s0=v.isub(this.m):v.cmpn(0)<0&&(s0=v.iadd(this.m)),s0._forceRed(this)},o0.prototype.mul=function(M,u0){if(M.isZero()||u0.isZero())return new Z(0)._forceRed(this);var S=M.mul(u0),n0=S.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=S.isub(n0).iushrn(this.shift),s0=v;return v.cmp(this.m)>=0?s0=v.isub(this.m):v.cmpn(0)<0&&(s0=v.iadd(this.m)),s0._forceRed(this)},o0.prototype.invm=function(M){var u0=this.imod(M._invmp(this.m).mul(this.r2));return u0._forceRed(this)}})(typeof K>"u"||K,X)}}),hQ=$Q({"node_modules/browserify-rsa/index.js"(X,K){var x0=cQ(),G=ZQ();function Y(Q){var U=$(Q),V=U.toRed(x0.mont(Q.modulus)).redPow(new x0(Q.publicExponent)).fromRed();return{blinder:V,unblinder:U.invm(Q.modulus)}}function $(Q){var U=Q.modulus.byteLength(),V;do V=new x0(G(U));while(V.cmp(Q.modulus)>=0||!V.umod(Q.prime1)||!V.umod(Q.prime2));return V}function Z(Q,U){var V=Y(U),B0=U.modulus.byteLength(),H=new x0(Q).mul(V.blinder).umod(U.modulus),y0=H.toRed(x0.mont(U.prime1)),W=H.toRed(x0.mont(U.prime2)),w0=U.coefficient,E=U.prime1,p0=U.prime2,T=y0.redPow(U.exponent1).fromRed(),f0=W.redPow(U.exponent2).fromRed(),D=T.isub(f0).imul(w0).umod(E).imul(p0);return f0.iadd(D).imul(V.unblinder).umod(U.modulus).toArrayLike(c$,"be",B0)}Z.getr=$,K.exports=Z}}),dQ=$Q({"node_modules/elliptic/package.json"(X,K){K.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"(X,K){(function(x0,G){function Y(l0,z){if(!l0)throw new Error(z||"Assertion failed")}function $(l0,z){l0.super_=z;var o0=function(){};o0.prototype=z.prototype,l0.prototype=new o0,l0.prototype.constructor=l0}function Z(l0,z,o0){if(Z.isBN(l0))return l0;this.negative=0,this.words=null,this.length=0,this.red=null,l0!==null&&((z==="le"||z==="be")&&(o0=z,z=10),this._init(l0||0,z||10,o0||"be"))}typeof x0=="object"?x0.exports=Z:G.BN=Z,Z.BN=Z,Z.wordSize=26;var Q=c$;Z.isBN=function(l0){return l0 instanceof Z?!0:l0!==null&&typeof l0=="object"&&l0.constructor.wordSize===Z.wordSize&&Array.isArray(l0.words)},Z.max=function(l0,z){return l0.cmp(z)>0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),lQ=$Q({"node_modules/minimalistic-crypto-utils/lib/utils.js"(X){var K=X;function x0($,Z){if(Array.isArray($))return $.slice();if(!$)return[];var Q=[];if(typeof $!="string"){for(var U=0;U<$.length;U++)Q[U]=$[U]|0;return Q}if(Z==="hex"){$=$.replace(/[^a-z0-9]+/gi,""),$.length%2!==0&&($="0"+$);for(var U=0;U<$.length;U+=2)Q.push(parseInt($[U]+$[U+1],16))}else for(var U=0;U<$.length;U++){var V=$.charCodeAt(U),B0=V>>8,H=V&255;B0?Q.push(B0,H):Q.push(H)}return Q}K.toArray=x0;function G($){return $.length===1?"0"+$:$}K.zero2=G;function Y($){for(var Z="",Q=0;Q<$.length;Q++)Z+=G($[Q].toString(16));return Z}K.toHex=Y,K.encode=function($,Z){return Z==="hex"?Y($):$}}}),oQ=$Q({"node_modules/elliptic/lib/elliptic/utils.js"(X){var K=X,x0=bQ(),G=N0(),Y=lQ();K.assert=G,K.toArray=Y.toArray,K.zero2=Y.zero2,K.toHex=Y.toHex,K.encode=Y.encode;function $(B0,H,y0){var W=new Array(Math.max(B0.bitLength(),y0)+1);W.fill(0);for(var w0=1<(w0>>1)-1?T=(w0>>1)-f0:T=f0,E.isubn(T)):T=0,W[p0]=T,E.iushrn(1)}return W}K.getNAF=$;function Z(B0,H){var y0=[[],[]];B0=B0.clone(),H=H.clone();for(var W=0,w0=0,E;B0.cmpn(-W)>0||H.cmpn(-w0)>0;){var p0=B0.andln(3)+W&3,T=H.andln(3)+w0&3;p0===3&&(p0=-1),T===3&&(T=-1);var f0;(p0&1)===0?f0=0:(E=B0.andln(7)+W&7,(E===3||E===5)&&T===2?f0=-p0:f0=p0),y0[0].push(f0);var D;(T&1)===0?D=0:(E=H.andln(7)+w0&7,(E===3||E===5)&&p0===2?D=-T:D=T),y0[1].push(D),2*W===f0+1&&(W=1-W),2*w0===D+1&&(w0=1-w0),B0.iushrn(1),H.iushrn(1)}return y0}K.getJSF=Z;function Q(B0,H,y0){var W="_"+H;B0.prototype[H]=function(){return this[W]!==void 0?this[W]:this[W]=y0.call(this)}}K.cachedProperty=Q;function U(B0){return typeof B0=="string"?K.toArray(B0,"hex"):B0}K.parseBytes=U;function V(B0){return new x0(B0,"hex","le")}K.intFromLE=V}}),uQ=$Q({"node_modules/elliptic/lib/elliptic/curve/base.js"(X,K){var x0=bQ(),G=oQ(),Y=G.getNAF,$=G.getJSF,Z=G.assert;function Q(V,B0){this.type=V,this.p=new x0(B0.p,16),this.red=B0.prime?x0.red(B0.prime):x0.mont(this.p),this.zero=new x0(0).toRed(this.red),this.one=new x0(1).toRed(this.red),this.two=new x0(2).toRed(this.red),this.n=B0.n&&new x0(B0.n,16),this.g=B0.g&&this.pointFromJSON(B0.g,B0.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 H=this.n&&this.p.div(this.n);!H||H.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}K.exports=Q,Q.prototype.point=function(){throw new Error("Not implemented")},Q.prototype.validate=function(){throw new Error("Not implemented")},Q.prototype._fixedNafMul=function(V,B0){Z(V.precomputed);var H=V._getDoubles(),y0=Y(B0,1,this._bitLength),W=(1<=E;T--)p0=(p0<<1)+y0[T];w0.push(p0)}for(var f0=this.jpoint(null,null,null),D=this.jpoint(null,null,null),c0=W;c0>0;c0--){for(E=0;E=0;p0--){for(var T=0;p0>=0&&w0[p0]===0;p0--)T++;if(p0>=0&&T++,E=E.dblp(T),p0<0)break;var f0=w0[p0];Z(f0!==0),V.type==="affine"?f0>0?E=E.mixedAdd(W[f0-1>>1]):E=E.mixedAdd(W[-f0-1>>1].neg()):f0>0?E=E.add(W[f0-1>>1]):E=E.add(W[-f0-1>>1].neg())}return V.type==="affine"?E.toP():E},Q.prototype._wnafMulAdd=function(V,B0,H,y0,W){var w0=this._wnafT1,E=this._wnafT2,p0=this._wnafT3,T=0,f0,D,c0;for(f0=0;f0=1;f0-=2){var h0=f0-1,L=f0;if(w0[h0]!==1||w0[L]!==1){p0[h0]=Y(H[h0],w0[h0],this._bitLength),p0[L]=Y(H[L],w0[L],this._bitLength),T=Math.max(p0[h0].length,T),T=Math.max(p0[L].length,T);continue}var d0=[B0[h0],null,null,B0[L]];B0[h0].y.cmp(B0[L].y)===0?(d0[1]=B0[h0].add(B0[L]),d0[2]=B0[h0].toJ().mixedAdd(B0[L].neg())):B0[h0].y.cmp(B0[L].y.redNeg())===0?(d0[1]=B0[h0].toJ().mixedAdd(B0[L]),d0[2]=B0[h0].add(B0[L].neg())):(d0[1]=B0[h0].toJ().mixedAdd(B0[L]),d0[2]=B0[h0].toJ().mixedAdd(B0[L].neg()));var R=[-3,-1,-5,-7,0,7,5,1,3],b0=$(H[h0],H[L]);for(T=Math.max(b0[0].length,T),p0[h0]=new Array(T),p0[L]=new Array(T),D=0;D=0;f0--){for(var M=0;f0>=0;){var u0=!0;for(D=0;D=0&&M++,z=z.dblp(M),f0<0)break;for(D=0;D0?c0=E[D][S-1>>1]:S<0&&(c0=E[D][-S-1>>1].neg()),c0.type==="affine"?z=z.mixedAdd(c0):z=z.add(c0))}}for(f0=0;f0=Math.ceil((V.bitLength()+1)/B0.step):!1},U.prototype._getDoubles=function(V,B0){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var H=[this],y0=this,W=0;W=0&&(h0=f0,L=D),c0.negative&&(c0=c0.neg(),C=C.neg()),h0.negative&&(h0=h0.neg(),L=L.neg()),[{a:c0,b:C},{a:h0,b:L}]},Q.prototype._endoSplit=function(B0){var H=this.endo.basis,y0=H[0],W=H[1],w0=W.b.mul(B0).divRound(this.n),E=y0.b.neg().mul(B0).divRound(this.n),p0=w0.mul(y0.a),T=E.mul(W.a),f0=w0.mul(y0.b),D=E.mul(W.b),c0=B0.sub(p0).sub(T),C=f0.add(D).neg();return{k1:c0,k2:C}},Q.prototype.pointFromX=function(B0,H){B0=new G(B0,16),B0.red||(B0=B0.toRed(this.red));var y0=B0.redSqr().redMul(B0).redIAdd(B0.redMul(this.a)).redIAdd(this.b),W=y0.redSqrt();if(W.redSqr().redSub(y0).cmp(this.zero)!==0)throw new Error("invalid point");var w0=W.fromRed().isOdd();return(H&&!w0||!H&&w0)&&(W=W.redNeg()),this.point(B0,W)},Q.prototype.validate=function(B0){if(B0.inf)return!0;var{x:H,y:y0}=B0,W=this.a.redMul(H),w0=H.redSqr().redMul(H).redIAdd(W).redIAdd(this.b);return y0.redSqr().redISub(w0).cmpn(0)===0},Q.prototype._endoWnafMulAdd=function(B0,H,y0){for(var W=this._endoWnafT1,w0=this._endoWnafT2,E=0;E":""},U.prototype.isInfinity=function(){return this.inf},U.prototype.add=function(B0){if(this.inf)return B0;if(B0.inf)return this;if(this.eq(B0))return this.dbl();if(this.neg().eq(B0))return this.curve.point(null,null);if(this.x.cmp(B0.x)===0)return this.curve.point(null,null);var H=this.y.redSub(B0.y);H.cmpn(0)!==0&&(H=H.redMul(this.x.redSub(B0.x).redInvm()));var y0=H.redSqr().redISub(this.x).redISub(B0.x),W=H.redMul(this.x.redSub(y0)).redISub(this.y);return this.curve.point(y0,W)},U.prototype.dbl=function(){if(this.inf)return this;var B0=this.y.redAdd(this.y);if(B0.cmpn(0)===0)return this.curve.point(null,null);var H=this.curve.a,y0=this.x.redSqr(),W=B0.redInvm(),w0=y0.redAdd(y0).redIAdd(y0).redIAdd(H).redMul(W),E=w0.redSqr().redISub(this.x.redAdd(this.x)),p0=w0.redMul(this.x.redSub(E)).redISub(this.y);return this.curve.point(E,p0)},U.prototype.getX=function(){return this.x.fromRed()},U.prototype.getY=function(){return this.y.fromRed()},U.prototype.mul=function(B0){return B0=new G(B0,16),this.isInfinity()?this:this._hasDoubles(B0)?this.curve._fixedNafMul(this,B0):this.curve.endo?this.curve._endoWnafMulAdd([this],[B0]):this.curve._wnafMul(this,B0)},U.prototype.mulAdd=function(B0,H,y0){var W=[this,H],w0=[B0,y0];return this.curve.endo?this.curve._endoWnafMulAdd(W,w0):this.curve._wnafMulAdd(1,W,w0,2)},U.prototype.jmulAdd=function(B0,H,y0){var W=[this,H],w0=[B0,y0];return this.curve.endo?this.curve._endoWnafMulAdd(W,w0,!0):this.curve._wnafMulAdd(1,W,w0,2,!0)},U.prototype.eq=function(B0){return this===B0||this.inf===B0.inf&&(this.inf||this.x.cmp(B0.x)===0&&this.y.cmp(B0.y)===0)},U.prototype.neg=function(B0){if(this.inf)return this;var H=this.curve.point(this.x,this.y.redNeg());if(B0&&this.precomputed){var y0=this.precomputed,W=function(w0){return w0.neg()};H.precomputed={naf:y0.naf&&{wnd:y0.naf.wnd,points:y0.naf.points.map(W)},doubles:y0.doubles&&{step:y0.doubles.step,points:y0.doubles.points.map(W)}}}return H},U.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var B0=this.curve.jpoint(this.x,this.y,this.curve.one);return B0};function V(B0,H,y0,W){$.BasePoint.call(this,B0,"jacobian"),H===null&&y0===null&&W===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new G(0)):(this.x=new G(H,16),this.y=new G(y0,16),this.z=new G(W,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}Y(V,$.BasePoint),Q.prototype.jpoint=function(B0,H,y0){return new V(this,B0,H,y0)},V.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var B0=this.z.redInvm(),H=B0.redSqr(),y0=this.x.redMul(H),W=this.y.redMul(H).redMul(B0);return this.curve.point(y0,W)},V.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},V.prototype.add=function(B0){if(this.isInfinity())return B0;if(B0.isInfinity())return this;var H=B0.z.redSqr(),y0=this.z.redSqr(),W=this.x.redMul(H),w0=B0.x.redMul(y0),E=this.y.redMul(H.redMul(B0.z)),p0=B0.y.redMul(y0.redMul(this.z)),T=W.redSub(w0),f0=E.redSub(p0);if(T.cmpn(0)===0)return f0.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var D=T.redSqr(),c0=D.redMul(T),C=W.redMul(D),h0=f0.redSqr().redIAdd(c0).redISub(C).redISub(C),L=f0.redMul(C.redISub(h0)).redISub(E.redMul(c0)),d0=this.z.redMul(B0.z).redMul(T);return this.curve.jpoint(h0,L,d0)},V.prototype.mixedAdd=function(B0){if(this.isInfinity())return B0.toJ();if(B0.isInfinity())return this;var H=this.z.redSqr(),y0=this.x,W=B0.x.redMul(H),w0=this.y,E=B0.y.redMul(H).redMul(this.z),p0=y0.redSub(W),T=w0.redSub(E);if(p0.cmpn(0)===0)return T.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var f0=p0.redSqr(),D=f0.redMul(p0),c0=y0.redMul(f0),C=T.redSqr().redIAdd(D).redISub(c0).redISub(c0),h0=T.redMul(c0.redISub(C)).redISub(w0.redMul(D)),L=this.z.redMul(p0);return this.curve.jpoint(C,h0,L)},V.prototype.dblp=function(B0){if(B0===0)return this;if(this.isInfinity())return this;if(!B0)return this.dbl();var H;if(this.curve.zeroA||this.curve.threeA){var y0=this;for(H=0;H=0)return!1;if(y0.redIAdd(w0),this.x.cmp(y0)===0)return!0}},V.prototype.inspect=function(){return this.isInfinity()?"":""},V.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),sQ=$Q({"node_modules/elliptic/lib/elliptic/curve/mont.js"(X,K){var x0=bQ(),G=X0(),Y=uQ(),$=oQ();function Z(U){Y.call(this,"mont",U),this.a=new x0(U.a,16).toRed(this.red),this.b=new x0(U.b,16).toRed(this.red),this.i4=new x0(4).toRed(this.red).redInvm(),this.two=new x0(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}G(Z,Y),K.exports=Z,Z.prototype.validate=function(U){var V=U.normalize().x,B0=V.redSqr(),H=B0.redMul(V).redAdd(B0.redMul(this.a)).redAdd(V),y0=H.redSqrt();return y0.redSqr().cmp(H)===0};function Q(U,V,B0){Y.BasePoint.call(this,U,"projective"),V===null&&B0===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new x0(V,16),this.z=new x0(B0,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}G(Q,Y.BasePoint),Z.prototype.decodePoint=function(U,V){return this.point($.toArray(U,V),1)},Z.prototype.point=function(U,V){return new Q(this,U,V)},Z.prototype.pointFromJSON=function(U){return Q.fromJSON(this,U)},Q.prototype.precompute=function(){},Q.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Q.fromJSON=function(U,V){return new Q(U,V[0],V[1]||U.one)},Q.prototype.inspect=function(){return this.isInfinity()?"":""},Q.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Q.prototype.dbl=function(){var U=this.x.redAdd(this.z),V=U.redSqr(),B0=this.x.redSub(this.z),H=B0.redSqr(),y0=V.redSub(H),W=V.redMul(H),w0=y0.redMul(H.redAdd(this.curve.a24.redMul(y0)));return this.curve.point(W,w0)},Q.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Q.prototype.diffAdd=function(U,V){var B0=this.x.redAdd(this.z),H=this.x.redSub(this.z),y0=U.x.redAdd(U.z),W=U.x.redSub(U.z),w0=W.redMul(B0),E=y0.redMul(H),p0=V.z.redMul(w0.redAdd(E).redSqr()),T=V.x.redMul(w0.redISub(E).redSqr());return this.curve.point(p0,T)},Q.prototype.mul=function(U){for(var V=U.clone(),B0=this,H=this.curve.point(null,null),y0=this,W=[];V.cmpn(0)!==0;V.iushrn(1))W.push(V.andln(1));for(var w0=W.length-1;w0>=0;w0--)W[w0]===0?(B0=B0.diffAdd(H,y0),H=H.dbl()):(H=B0.diffAdd(H,y0),B0=B0.dbl());return H},Q.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Q.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Q.prototype.eq=function(U){return this.getX().cmp(U.getX())===0},Q.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Q.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),tQ=$Q({"node_modules/elliptic/lib/elliptic/curve/edwards.js"(X,K){var x0=oQ(),G=bQ(),Y=X0(),$=uQ(),Z=x0.assert;function Q(V){this.twisted=(V.a|0)!==1,this.mOneA=this.twisted&&(V.a|0)===-1,this.extended=this.mOneA,$.call(this,"edwards",V),this.a=new G(V.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new G(V.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new G(V.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Z(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(V.c|0)===1}Y(Q,$),K.exports=Q,Q.prototype._mulA=function(V){return this.mOneA?V.redNeg():this.a.redMul(V)},Q.prototype._mulC=function(V){return this.oneC?V:this.c.redMul(V)},Q.prototype.jpoint=function(V,B0,H,y0){return this.point(V,B0,H,y0)},Q.prototype.pointFromX=function(V,B0){V=new G(V,16),V.red||(V=V.toRed(this.red));var H=V.redSqr(),y0=this.c2.redSub(this.a.redMul(H)),W=this.one.redSub(this.c2.redMul(this.d).redMul(H)),w0=y0.redMul(W.redInvm()),E=w0.redSqrt();if(E.redSqr().redSub(w0).cmp(this.zero)!==0)throw new Error("invalid point");var p0=E.fromRed().isOdd();return(B0&&!p0||!B0&&p0)&&(E=E.redNeg()),this.point(V,E)},Q.prototype.pointFromY=function(V,B0){V=new G(V,16),V.red||(V=V.toRed(this.red));var H=V.redSqr(),y0=H.redSub(this.c2),W=H.redMul(this.d).redMul(this.c2).redSub(this.a),w0=y0.redMul(W.redInvm());if(w0.cmp(this.zero)===0){if(B0)throw new Error("invalid point");return this.point(this.zero,V)}var E=w0.redSqrt();if(E.redSqr().redSub(w0).cmp(this.zero)!==0)throw new Error("invalid point");return E.fromRed().isOdd()!==B0&&(E=E.redNeg()),this.point(E,V)},Q.prototype.validate=function(V){if(V.isInfinity())return!0;V.normalize();var B0=V.x.redSqr(),H=V.y.redSqr(),y0=B0.redMul(this.a).redAdd(H),W=this.c2.redMul(this.one.redAdd(this.d.redMul(B0).redMul(H)));return y0.cmp(W)===0};function U(V,B0,H,y0,W){$.BasePoint.call(this,V,"projective"),B0===null&&H===null&&y0===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 G(B0,16),this.y=new G(H,16),this.z=y0?new G(y0,16):this.curve.one,this.t=W&&new G(W,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()))))}Y(U,$.BasePoint),Q.prototype.pointFromJSON=function(V){return U.fromJSON(this,V)},Q.prototype.point=function(V,B0,H,y0){return new U(this,V,B0,H,y0)},U.fromJSON=function(V,B0){return new U(V,B0[0],B0[1],B0[2])},U.prototype.inspect=function(){return this.isInfinity()?"":""},U.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},U.prototype._extDbl=function(){var V=this.x.redSqr(),B0=this.y.redSqr(),H=this.z.redSqr();H=H.redIAdd(H);var y0=this.curve._mulA(V),W=this.x.redAdd(this.y).redSqr().redISub(V).redISub(B0),w0=y0.redAdd(B0),E=w0.redSub(H),p0=y0.redSub(B0),T=W.redMul(E),f0=w0.redMul(p0),D=W.redMul(p0),c0=E.redMul(w0);return this.curve.point(T,f0,c0,D)},U.prototype._projDbl=function(){var V=this.x.redAdd(this.y).redSqr(),B0=this.x.redSqr(),H=this.y.redSqr(),y0,W,w0,E,p0,T;if(this.curve.twisted){E=this.curve._mulA(B0);var f0=E.redAdd(H);this.zOne?(y0=V.redSub(B0).redSub(H).redMul(f0.redSub(this.curve.two)),W=f0.redMul(E.redSub(H)),w0=f0.redSqr().redSub(f0).redSub(f0)):(p0=this.z.redSqr(),T=f0.redSub(p0).redISub(p0),y0=V.redSub(B0).redISub(H).redMul(T),W=f0.redMul(E.redSub(H)),w0=f0.redMul(T))}else E=B0.redAdd(H),p0=this.curve._mulC(this.z).redSqr(),T=E.redSub(p0).redSub(p0),y0=this.curve._mulC(V.redISub(E)).redMul(T),W=this.curve._mulC(E).redMul(B0.redISub(H)),w0=E.redMul(T);return this.curve.point(y0,W,w0)},U.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},U.prototype._extAdd=function(V){var B0=this.y.redSub(this.x).redMul(V.y.redSub(V.x)),H=this.y.redAdd(this.x).redMul(V.y.redAdd(V.x)),y0=this.t.redMul(this.curve.dd).redMul(V.t),W=this.z.redMul(V.z.redAdd(V.z)),w0=H.redSub(B0),E=W.redSub(y0),p0=W.redAdd(y0),T=H.redAdd(B0),f0=w0.redMul(E),D=p0.redMul(T),c0=w0.redMul(T),C=E.redMul(p0);return this.curve.point(f0,D,C,c0)},U.prototype._projAdd=function(V){var B0=this.z.redMul(V.z),H=B0.redSqr(),y0=this.x.redMul(V.x),W=this.y.redMul(V.y),w0=this.curve.d.redMul(y0).redMul(W),E=H.redSub(w0),p0=H.redAdd(w0),T=this.x.redAdd(this.y).redMul(V.x.redAdd(V.y)).redISub(y0).redISub(W),f0=B0.redMul(E).redMul(T),D,c0;return this.curve.twisted?(D=B0.redMul(p0).redMul(W.redSub(this.curve._mulA(y0))),c0=E.redMul(p0)):(D=B0.redMul(p0).redMul(W.redSub(y0)),c0=this.curve._mulC(E).redMul(p0)),this.curve.point(f0,D,c0)},U.prototype.add=function(V){return this.isInfinity()?V:V.isInfinity()?this:this.curve.extended?this._extAdd(V):this._projAdd(V)},U.prototype.mul=function(V){return this._hasDoubles(V)?this.curve._fixedNafMul(this,V):this.curve._wnafMul(this,V)},U.prototype.mulAdd=function(V,B0,H){return this.curve._wnafMulAdd(1,[this,B0],[V,H],2,!1)},U.prototype.jmulAdd=function(V,B0,H){return this.curve._wnafMulAdd(1,[this,B0],[V,H],2,!0)},U.prototype.normalize=function(){if(this.zOne)return this;var V=this.z.redInvm();return this.x=this.x.redMul(V),this.y=this.y.redMul(V),this.t&&(this.t=this.t.redMul(V)),this.z=this.curve.one,this.zOne=!0,this},U.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},U.prototype.getX=function(){return this.normalize(),this.x.fromRed()},U.prototype.getY=function(){return this.normalize(),this.y.fromRed()},U.prototype.eq=function(V){return this===V||this.getX().cmp(V.getX())===0&&this.getY().cmp(V.getY())===0},U.prototype.eqXToP=function(V){var B0=V.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(B0)===0)return!0;for(var H=V.clone(),y0=this.curve.redN.redMul(this.z);;){if(H.iadd(this.curve.n),H.cmp(this.curve.p)>=0)return!1;if(B0.redIAdd(y0),this.x.cmp(B0)===0)return!0}},U.prototype.toP=U.prototype.normalize,U.prototype.mixedAdd=U.prototype.add}}),mQ=$Q({"node_modules/elliptic/lib/elliptic/curve/index.js"(X){var K=X;K.base=uQ(),K.short=nQ(),K.mont=sQ(),K.edwards=tQ()}}),aQ=$Q({"node_modules/hash.js/lib/hash/utils.js"(X){var K=N0(),x0=X0();X.inherits=x0;function G(z,o0){return(z.charCodeAt(o0)&64512)!==55296||o0<0||o0+1>=z.length?!1:(z.charCodeAt(o0+1)&64512)===56320}function Y(z,o0){if(Array.isArray(z))return z.slice();if(!z)return[];var M=[];if(typeof z=="string")if(o0){if(o0==="hex")for(z=z.replace(/[^a-z0-9]+/gi,""),z.length%2!==0&&(z="0"+z),S=0;S>6|192,M[u0++]=n0&63|128):G(z,S)?(n0=65536+((n0&1023)<<10)+(z.charCodeAt(++S)&1023),M[u0++]=n0>>18|240,M[u0++]=n0>>12&63|128,M[u0++]=n0>>6&63|128,M[u0++]=n0&63|128):(M[u0++]=n0>>12|224,M[u0++]=n0>>6&63|128,M[u0++]=n0&63|128)}else for(S=0;S>>24|z>>>8&65280|z<<8&16711680|(z&255)<<24;return o0>>>0}X.htonl=Z;function Q(z,o0){for(var M="",u0=0;u0>>0}return n0}X.join32=B0;function H(z,o0){for(var M=new Array(z.length*4),u0=0,S=0;u0>>24,M[S+1]=n0>>>16&255,M[S+2]=n0>>>8&255,M[S+3]=n0&255):(M[S+3]=n0>>>24,M[S+2]=n0>>>16&255,M[S+1]=n0>>>8&255,M[S]=n0&255)}return M}X.split32=H;function y0(z,o0){return z>>>o0|z<<32-o0}X.rotr32=y0;function W(z,o0){return z<>>32-o0}X.rotl32=W;function w0(z,o0){return z+o0>>>0}X.sum32=w0;function E(z,o0,M){return z+o0+M>>>0}X.sum32_3=E;function p0(z,o0,M,u0){return z+o0+M+u0>>>0}X.sum32_4=p0;function T(z,o0,M,u0,S){return z+o0+M+u0+S>>>0}X.sum32_5=T;function f0(z,o0,M,u0){var S=z[o0],n0=z[o0+1],v=u0+n0>>>0,s0=(v>>0,z[o0+1]=v}X.sum64=f0;function D(z,o0,M,u0){var S=o0+u0>>>0,n0=(S>>0}X.sum64_hi=D;function c0(z,o0,M,u0){var S=o0+u0;return S>>>0}X.sum64_lo=c0;function C(z,o0,M,u0,S,n0,v,s0){var I=0,t0=o0;t0=t0+u0>>>0,I+=t0>>0,I+=t0>>0,I+=t0>>0}X.sum64_4_hi=C;function h0(z,o0,M,u0,S,n0,v,s0){var I=o0+u0+n0+s0;return I>>>0}X.sum64_4_lo=h0;function L(z,o0,M,u0,S,n0,v,s0,I,t0){var m0=0,a0=o0;a0=a0+u0>>>0,m0+=a0>>0,m0+=a0>>0,m0+=a0>>0,m0+=a0>>0}X.sum64_5_hi=L;function d0(z,o0,M,u0,S,n0,v,s0,I,t0){var m0=o0+u0+n0+s0+t0;return m0>>>0}X.sum64_5_lo=d0;function R(z,o0,M){var u0=o0<<32-M|z>>>M;return u0>>>0}X.rotr64_hi=R;function b0(z,o0,M){var u0=z<<32-M|o0>>>M;return u0>>>0}X.rotr64_lo=b0;function P(z,o0,M){return z>>>M}X.shr64_hi=P;function l0(z,o0,M){var u0=z<<32-M|o0>>>M;return u0>>>0}X.shr64_lo=l0}}),eQ=$Q({"node_modules/hash.js/lib/hash/common.js"(X){var K=aQ(),x0=N0();function G(){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}X.BlockHash=G,G.prototype.update=function(Y,$){if(Y=K.toArray(Y,$),this.pending?this.pending=this.pending.concat(Y):this.pending=Y,this.pendingTotal+=Y.length,this.pending.length>=this._delta8){Y=this.pending;var Z=Y.length%this._delta8;this.pending=Y.slice(Y.length-Z,Y.length),this.pending.length===0&&(this.pending=null),Y=K.join32(Y,0,Y.length-Z,this.endian);for(var Q=0;Q>>24&255,Q[U++]=Y>>>16&255,Q[U++]=Y>>>8&255,Q[U++]=Y&255}else for(Q[U++]=Y&255,Q[U++]=Y>>>8&255,Q[U++]=Y>>>16&255,Q[U++]=Y>>>24&255,Q[U++]=0,Q[U++]=0,Q[U++]=0,Q[U++]=0,V=8;V>>3}X.g0_256=V;function B0(H){return x0(H,17)^x0(H,19)^H>>>10}X.g1_256=B0}}),iQ=$Q({"node_modules/hash.js/lib/hash/sha/1.js"(X,K){var x0=aQ(),G=eQ(),Y=rQ(),$=x0.rotl32,Z=x0.sum32,Q=x0.sum32_5,U=Y.ft_1,V=G.BlockHash,B0=[1518500249,1859775393,2400959708,3395469782];function H(){if(!(this instanceof H))return new H;V.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}x0.inherits(H,V),K.exports=H,H.blockSize=512,H.outSize=160,H.hmacStrength=80,H.padLength=64,H.prototype._update=function(y0,W){for(var w0=this.W,E=0;E<16;E++)w0[E]=y0[W+E];for(;Ethis.blockSize&&($=new this.Hash().update($).digest()),G($.length<=this.blockSize);for(var Z=$.length;Z=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(Q,U,V)}K.exports=$,$.prototype._init=function(Z,Q,U){var V=Z.concat(Q).concat(U);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var B0=0;B0=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(Z.concat(U||[])),this._reseed=1},$.prototype.generate=function(Z,Q,U,V){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof Q!="string"&&(V=U,U=Q,Q=null),U&&(U=G.toArray(U,V||"hex"),this._update(U));for(var B0=[];B0.length"}}}),FY=$Q({"node_modules/elliptic/lib/elliptic/ec/signature.js"(X,K){var x0=bQ(),G=oQ(),Y=G.assert;function $(B0,H){if(B0 instanceof $)return B0;this._importDER(B0,H)||(Y(B0.r&&B0.s,"Signature without r or s"),this.r=new x0(B0.r,16),this.s=new x0(B0.s,16),B0.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=B0.recoveryParam)}K.exports=$;function Z(){this.place=0}function Q(B0,H){var y0=B0[H.place++];if(!(y0&128))return y0;var W=y0&15;if(W===0||W>4)return!1;for(var w0=0,E=0,p0=H.place;E>>=0;return w0<=127?!1:(H.place=p0,w0)}function U(B0){for(var H=0,y0=B0.length-1;!B0[H]&&!(B0[H+1]&128)&&H>>3);for(B0.push(y0|128);--y0;)B0.push(H>>>(y0<<3)&255);B0.push(H)}$.prototype.toDER=function(B0){var H=this.r.toArray(),y0=this.s.toArray();for(H[0]&128&&(H=[0].concat(H)),y0[0]&128&&(y0=[0].concat(y0)),H=U(H),y0=U(y0);!y0[0]&&!(y0[1]&128);)y0=y0.slice(1);var W=[2];V(W,H.length),W=W.concat(H),W.push(2),V(W,y0.length);var w0=W.concat(y0),E=[48];return V(E,w0.length),E=E.concat(w0),G.encode(E,B0)}}}),AY=$Q({"node_modules/elliptic/lib/elliptic/ec/index.js"(X,K){var x0=bQ(),G=OY(),Y=oQ(),$=IY(),Z=xQ(),Q=Y.assert,U=JY(),V=FY();function B0(H){if(!(this instanceof B0))return new B0(H);typeof H=="string"&&(Q(Object.prototype.hasOwnProperty.call($,H),"Unknown curve "+H),H=$[H]),H instanceof $.PresetCurve&&(H={curve:H}),this.curve=H.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=H.curve.g,this.g.precompute(H.curve.n.bitLength()+1),this.hash=H.hash||H.curve.hash}K.exports=B0,B0.prototype.keyPair=function(H){return new U(this,H)},B0.prototype.keyFromPrivate=function(H,y0){return U.fromPrivate(this,H,y0)},B0.prototype.keyFromPublic=function(H,y0){return U.fromPublic(this,H,y0)},B0.prototype.genKeyPair=function(H){H||(H={});for(var y0=new G({hash:this.hash,pers:H.pers,persEnc:H.persEnc||"utf8",entropy:H.entropy||Z(this.hash.hmacStrength),entropyEnc:H.entropy&&H.entropyEnc||"utf8",nonce:this.n.toArray()}),W=this.n.byteLength(),w0=this.n.sub(new x0(2));;){var E=new x0(y0.generate(W));if(!(E.cmp(w0)>0))return E.iaddn(1),this.keyFromPrivate(E)}},B0.prototype._truncateToN=function(H,y0){var W=H.byteLength()*8-this.n.bitLength();return W>0&&(H=H.ushrn(W)),!y0&&H.cmp(this.n)>=0?H.sub(this.n):H},B0.prototype.sign=function(H,y0,W,w0){typeof W=="object"&&(w0=W,W=null),w0||(w0={}),y0=this.keyFromPrivate(y0,W),H=this._truncateToN(new x0(H,16));for(var E=this.n.byteLength(),p0=y0.getPrivate().toArray("be",E),T=H.toArray("be",E),f0=new G({hash:this.hash,entropy:p0,nonce:T,pers:w0.pers,persEnc:w0.persEnc||"utf8"}),D=this.n.sub(new x0(1)),c0=0;;c0++){var C=w0.k?w0.k(c0):new x0(f0.generate(this.n.byteLength()));if(C=this._truncateToN(C,!0),!(C.cmpn(1)<=0||C.cmp(D)>=0)){var h0=this.g.mul(C);if(!h0.isInfinity()){var L=h0.getX(),d0=L.umod(this.n);if(d0.cmpn(0)!==0){var R=C.invm(this.n).mul(d0.mul(y0.getPrivate()).iadd(H));if(R=R.umod(this.n),R.cmpn(0)!==0){var b0=(h0.getY().isOdd()?1:0)|(L.cmp(d0)!==0?2:0);return w0.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),b0^=1),new V({r:d0,s:R,recoveryParam:b0})}}}}}},B0.prototype.verify=function(H,y0,W,w0){H=this._truncateToN(new x0(H,16)),W=this.keyFromPublic(W,w0),y0=new V(y0,"hex");var{r:E,s:p0}=y0;if(E.cmpn(1)<0||E.cmp(this.n)>=0||p0.cmpn(1)<0||p0.cmp(this.n)>=0)return!1;var T=p0.invm(this.n),f0=T.mul(H).umod(this.n),D=T.mul(E).umod(this.n),c0;return this.curve._maxwellTrick?(c0=this.g.jmulAdd(f0,W.getPublic(),D),c0.isInfinity()?!1:c0.eqXToP(E)):(c0=this.g.mulAdd(f0,W.getPublic(),D),c0.isInfinity()?!1:c0.getX().umod(this.n).cmp(E)===0)},B0.prototype.recoverPubKey=function(H,y0,W,w0){Q((3&W)===W,"The recovery param is more than two bits"),y0=new V(y0,w0);var E=this.n,p0=new x0(H),T=y0.r,f0=y0.s,D=W&1,c0=W>>1;if(T.cmp(this.curve.p.umod(this.curve.n))>=0&&c0)throw new Error("Unable to find sencond key candinate");c0?T=this.curve.pointFromX(T.add(this.curve.n),D):T=this.curve.pointFromX(T,D);var C=y0.r.invm(E),h0=E.sub(p0).mul(C).umod(E),L=f0.mul(C).umod(E);return this.g.mulAdd(h0,T,L)},B0.prototype.getKeyRecoveryParam=function(H,y0,W,w0){if(y0=new V(y0,w0),y0.recoveryParam!==null)return y0.recoveryParam;for(var E=0;E<4;E++){var p0;try{p0=this.recoverPubKey(H,y0,E)}catch{continue}if(p0.eq(W))return E}throw new Error("Unable to find valid recovery factor")}}}),HY=$Q({"node_modules/elliptic/lib/elliptic/eddsa/key.js"(X,K){var x0=oQ(),G=x0.assert,Y=x0.parseBytes,$=x0.cachedProperty;function Z(Q,U){this.eddsa=Q,this._secret=Y(U.secret),Q.isPoint(U.pub)?this._pub=U.pub:this._pubBytes=Y(U.pub)}Z.fromPublic=function(Q,U){return U instanceof Z?U:new Z(Q,{pub:U})},Z.fromSecret=function(Q,U){return U instanceof Z?U:new Z(Q,{secret:U})},Z.prototype.secret=function(){return this._secret},$(Z,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),$(Z,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),$(Z,"privBytes",function(){var Q=this.eddsa,U=this.hash(),V=Q.encodingLength-1,B0=U.slice(0,Q.encodingLength);return B0[0]&=248,B0[V]&=127,B0[V]|=64,B0}),$(Z,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),$(Z,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),$(Z,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Z.prototype.sign=function(Q){return G(this._secret,"KeyPair can only verify"),this.eddsa.sign(Q,this)},Z.prototype.verify=function(Q,U){return this.eddsa.verify(Q,U,this)},Z.prototype.getSecret=function(Q){return G(this._secret,"KeyPair is public only"),x0.encode(this.secret(),Q)},Z.prototype.getPublic=function(Q){return x0.encode(this.pubBytes(),Q)},K.exports=Z}}),WY=$Q({"node_modules/elliptic/lib/elliptic/eddsa/signature.js"(X,K){var x0=bQ(),G=oQ(),Y=G.assert,$=G.cachedProperty,Z=G.parseBytes;function Q(U,V){this.eddsa=U,typeof V!="object"&&(V=Z(V)),Array.isArray(V)&&(V={R:V.slice(0,U.encodingLength),S:V.slice(U.encodingLength)}),Y(V.R&&V.S,"Signature without R or S"),U.isPoint(V.R)&&(this._R=V.R),V.S instanceof x0&&(this._S=V.S),this._Rencoded=Array.isArray(V.R)?V.R:V.Rencoded,this._Sencoded=Array.isArray(V.S)?V.S:V.Sencoded}$(Q,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),$(Q,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),$(Q,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),$(Q,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Q.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Q.prototype.toHex=function(){return G.encode(this.toBytes(),"hex").toUpperCase()},K.exports=Q}}),EY=$Q({"node_modules/elliptic/lib/elliptic/eddsa/index.js"(X,K){var x0=XY(),G=IY(),Y=oQ(),$=Y.assert,Z=Y.parseBytes,Q=HY(),U=WY();function V(B0){if($(B0==="ed25519","only tested with ed25519 so far"),!(this instanceof V))return new V(B0);B0=G[B0].curve,this.curve=B0,this.g=B0.g,this.g.precompute(B0.n.bitLength()+1),this.pointClass=B0.point().constructor,this.encodingLength=Math.ceil(B0.n.bitLength()/8),this.hash=x0.sha512}K.exports=V,V.prototype.sign=function(B0,H){B0=Z(B0);var y0=this.keyFromSecret(H),W=this.hashInt(y0.messagePrefix(),B0),w0=this.g.mul(W),E=this.encodePoint(w0),p0=this.hashInt(E,y0.pubBytes(),B0).mul(y0.priv()),T=W.add(p0).umod(this.curve.n);return this.makeSignature({R:w0,S:T,Rencoded:E})},V.prototype.verify=function(B0,H,y0){B0=Z(B0),H=this.makeSignature(H);var W=this.keyFromPublic(y0),w0=this.hashInt(H.Rencoded(),W.pubBytes(),B0),E=this.g.mul(H.S()),p0=H.R().add(W.pub().mul(w0));return p0.eq(E)},V.prototype.hashInt=function(){for(var B0=this.hash(),H=0;H0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),CY=$Q({"node_modules/safer-buffer/safer.js"(X,K){var x0=e$,G=c$,Y={},$;for($ in x0)!x0.hasOwnProperty($)||$==="SlowBuffer"||$==="Buffer"||(Y[$]=x0[$]);var Z=Y.Buffer={};for($ in G)!G.hasOwnProperty($)||$==="allocUnsafe"||$==="allocUnsafeSlow"||(Z[$]=G[$]);if(Y.Buffer.prototype=G.prototype,(!Z.from||Z.from===Uint8Array.from)&&(Z.from=function(Q,U,V){if(typeof Q=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof Q);if(Q&&typeof Q.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Q);return G(Q,U,V)}),Z.alloc||(Z.alloc=function(Q,U,V){if(typeof Q!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof Q);if(Q<0||Q>=2*(1<<30))throw new RangeError('The value "'+Q+'" is invalid for option "size"');var B0=G(Q);return!U||U.length===0?B0.fill(0):typeof V=="string"?B0.fill(U,V):B0.fill(U),B0}),!Y.kStringMaxLength)try{Y.kStringMaxLength=r$}catch{}Y.constants||(Y.constants={MAX_LENGTH:Y.kMaxLength},Y.kStringMaxLength&&(Y.constants.MAX_STRING_LENGTH=Y.kStringMaxLength)),K.exports=Y}}),LY=$Q({"node_modules/asn1.js/lib/asn1/base/reporter.js"(X){var K=X0();function x0(Y){this._reporterState={obj:null,path:[],options:Y||{},errors:[]}}X.Reporter=x0,x0.prototype.isError=function(Y){return Y instanceof G},x0.prototype.save=function(){let Y=this._reporterState;return{obj:Y.obj,pathLen:Y.path.length}},x0.prototype.restore=function(Y){let $=this._reporterState;$.obj=Y.obj,$.path=$.path.slice(0,Y.pathLen)},x0.prototype.enterKey=function(Y){return this._reporterState.path.push(Y)},x0.prototype.exitKey=function(Y){let $=this._reporterState;$.path=$.path.slice(0,Y-1)},x0.prototype.leaveKey=function(Y,$,Z){let Q=this._reporterState;this.exitKey(Y),Q.obj!==null&&(Q.obj[$]=Z)},x0.prototype.path=function(){return this._reporterState.path.join("/")},x0.prototype.enterObject=function(){let Y=this._reporterState,$=Y.obj;return Y.obj={},$},x0.prototype.leaveObject=function(Y){let $=this._reporterState,Z=$.obj;return $.obj=Y,Z},x0.prototype.error=function(Y){let $,Z=this._reporterState,Q=Y instanceof G;if(Q?$=Y:$=new G(Z.path.map(function(U){return"["+JSON.stringify(U)+"]"}).join(""),Y.message||Y,Y.stack),!Z.options.partial)throw $;return Q||Z.errors.push($),$},x0.prototype.wrapResult=function(Y){let $=this._reporterState;return $.options.partial?{result:this.isError(Y)?null:Y,errors:$.errors}:Y};function G(Y,$){this.path=Y,this.rethrow($)}K(G,Error),G.prototype.rethrow=function(Y){if(this.message=Y+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,G),!this.stack)try{throw new Error(this.message)}catch($){this.stack=$.stack}return this}}}),l$=$Q({"node_modules/asn1.js/lib/asn1/base/buffer.js"(X){var K=X0(),x0=LY().Reporter,G=CY().Buffer;function Y(Z,Q){if(x0.call(this,Q),!G.isBuffer(Z)){this.error("Input not Buffer");return}this.base=Z,this.offset=0,this.length=Z.length}K(Y,x0),X.DecoderBuffer=Y,Y.isDecoderBuffer=function(Z){return Z instanceof Y?!0:typeof Z=="object"&&G.isBuffer(Z.base)&&Z.constructor.name==="DecoderBuffer"&&typeof Z.offset=="number"&&typeof Z.length=="number"&&typeof Z.save=="function"&&typeof Z.restore=="function"&&typeof Z.isEmpty=="function"&&typeof Z.readUInt8=="function"&&typeof Z.skip=="function"&&typeof Z.raw=="function"},Y.prototype.save=function(){return{offset:this.offset,reporter:x0.prototype.save.call(this)}},Y.prototype.restore=function(Z){let Q=new Y(this.base);return Q.offset=Z.offset,Q.length=this.offset,this.offset=Z.offset,x0.prototype.restore.call(this,Z.reporter),Q},Y.prototype.isEmpty=function(){return this.offset===this.length},Y.prototype.readUInt8=function(Z){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(Z||"DecoderBuffer overrun")},Y.prototype.skip=function(Z,Q){if(!(this.offset+Z<=this.length))return this.error(Q||"DecoderBuffer overrun");let U=new Y(this.base);return U._reporterState=this._reporterState,U.offset=this.offset,U.length=this.offset+Z,this.offset+=Z,U},Y.prototype.raw=function(Z){return this.base.slice(Z?Z.offset:this.offset,this.length)};function $(Z,Q){if(Array.isArray(Z))this.length=0,this.value=Z.map(function(U){return $.isEncoderBuffer(U)||(U=new $(U,Q)),this.length+=U.length,U},this);else if(typeof Z=="number"){if(!(0<=Z&&Z<=255))return Q.error("non-byte EncoderBuffer value");this.value=Z,this.length=1}else if(typeof Z=="string")this.value=Z,this.length=G.byteLength(Z);else if(G.isBuffer(Z))this.value=Z,this.length=Z.length;else return Q.error("Unsupported type: "+typeof Z)}X.EncoderBuffer=$,$.isEncoderBuffer=function(Z){return Z instanceof $?!0:typeof Z=="object"&&Z.constructor.name==="EncoderBuffer"&&typeof Z.length=="number"&&typeof Z.join=="function"},$.prototype.join=function(Z,Q){return Z||(Z=G.alloc(this.length)),Q||(Q=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(U){U.join(Z,Q),Q+=U.length}):(typeof this.value=="number"?Z[Q]=this.value:typeof this.value=="string"?Z.write(this.value,Q):G.isBuffer(this.value)&&this.value.copy(Z,Q),Q+=this.length)),Z}}}),RY=$Q({"node_modules/asn1.js/lib/asn1/base/node.js"(X,K){var x0=LY().Reporter,G=l$().EncoderBuffer,Y=l$().DecoderBuffer,$=N0(),Z=["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"],Q=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(Z),U=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function V(H,y0,W){let w0={};this._baseState=w0,w0.name=W,w0.enc=H,w0.parent=y0||null,w0.children=null,w0.tag=null,w0.args=null,w0.reverseArgs=null,w0.choice=null,w0.optional=!1,w0.any=!1,w0.obj=!1,w0.use=null,w0.useDecoder=null,w0.key=null,w0.default=null,w0.explicit=null,w0.implicit=null,w0.contains=null,w0.parent||(w0.children=[],this._wrap())}K.exports=V;var B0=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];V.prototype.clone=function(){let H=this._baseState,y0={};B0.forEach(function(w0){y0[w0]=H[w0]});let W=new this.constructor(y0.parent);return W._baseState=y0,W},V.prototype._wrap=function(){let H=this._baseState;Q.forEach(function(y0){this[y0]=function(){let W=new this.constructor(this);return H.children.push(W),W[y0].apply(W,arguments)}},this)},V.prototype._init=function(H){let y0=this._baseState;$(y0.parent===null),H.call(this),y0.children=y0.children.filter(function(W){return W._baseState.parent===this},this),$.equal(y0.children.length,1,"Root node can have only one child")},V.prototype._useArgs=function(H){let y0=this._baseState,W=H.filter(function(w0){return w0 instanceof this.constructor},this);H=H.filter(function(w0){return!(w0 instanceof this.constructor)},this),W.length!==0&&($(y0.children===null),y0.children=W,W.forEach(function(w0){w0._baseState.parent=this},this)),H.length!==0&&($(y0.args===null),y0.args=H,y0.reverseArgs=H.map(function(w0){if(typeof w0!="object"||w0.constructor!==Object)return w0;let E={};return Object.keys(w0).forEach(function(p0){p0==(p0|0)&&(p0|=0);let T=w0[p0];E[T]=p0}),E}))},U.forEach(function(H){V.prototype[H]=function(){let y0=this._baseState;throw new Error(H+" not implemented for encoding: "+y0.enc)}}),Z.forEach(function(H){V.prototype[H]=function(){let y0=this._baseState,W=Array.prototype.slice.call(arguments);return $(y0.tag===null),y0.tag=H,this._useArgs(W),this}}),V.prototype.use=function(H){$(H);let y0=this._baseState;return $(y0.use===null),y0.use=H,this},V.prototype.optional=function(){let H=this._baseState;return H.optional=!0,this},V.prototype.def=function(H){let y0=this._baseState;return $(y0.default===null),y0.default=H,y0.optional=!0,this},V.prototype.explicit=function(H){let y0=this._baseState;return $(y0.explicit===null&&y0.implicit===null),y0.explicit=H,this},V.prototype.implicit=function(H){let y0=this._baseState;return $(y0.explicit===null&&y0.implicit===null),y0.implicit=H,this},V.prototype.obj=function(){let H=this._baseState,y0=Array.prototype.slice.call(arguments);return H.obj=!0,y0.length!==0&&this._useArgs(y0),this},V.prototype.key=function(H){let y0=this._baseState;return $(y0.key===null),y0.key=H,this},V.prototype.any=function(){let H=this._baseState;return H.any=!0,this},V.prototype.choice=function(H){let y0=this._baseState;return $(y0.choice===null),y0.choice=H,this._useArgs(Object.keys(H).map(function(W){return H[W]})),this},V.prototype.contains=function(H){let y0=this._baseState;return $(y0.use===null),y0.contains=H,this},V.prototype._decode=function(H,y0){let W=this._baseState;if(W.parent===null)return H.wrapResult(W.children[0]._decode(H,y0));let w0=W.default,E=!0,p0=null;if(W.key!==null&&(p0=H.enterKey(W.key)),W.optional){let f0=null;if(W.explicit!==null?f0=W.explicit:W.implicit!==null?f0=W.implicit:W.tag!==null&&(f0=W.tag),f0===null&&!W.any){let D=H.save();try{W.choice===null?this._decodeGeneric(W.tag,H,y0):this._decodeChoice(H,y0),E=!0}catch{E=!1}H.restore(D)}else if(E=this._peekTag(H,f0,W.any),H.isError(E))return E}let T;if(W.obj&&E&&(T=H.enterObject()),E){if(W.explicit!==null){let D=this._decodeTag(H,W.explicit);if(H.isError(D))return D;H=D}let f0=H.offset;if(W.use===null&&W.choice===null){let D;W.any&&(D=H.save());let c0=this._decodeTag(H,W.implicit!==null?W.implicit:W.tag,W.any);if(H.isError(c0))return c0;W.any?w0=H.raw(D):H=c0}if(y0&&y0.track&&W.tag!==null&&y0.track(H.path(),f0,H.length,"tagged"),y0&&y0.track&&W.tag!==null&&y0.track(H.path(),H.offset,H.length,"content"),W.any||(W.choice===null?w0=this._decodeGeneric(W.tag,H,y0):w0=this._decodeChoice(H,y0)),H.isError(w0))return w0;if(!W.any&&W.choice===null&&W.children!==null&&W.children.forEach(function(D){D._decode(H,y0)}),W.contains&&(W.tag==="octstr"||W.tag==="bitstr")){let D=new Y(w0);w0=this._getUse(W.contains,H._reporterState.obj)._decode(D,y0)}}return W.obj&&E&&(w0=H.leaveObject(T)),W.key!==null&&(w0!==null||E===!0)?H.leaveKey(p0,W.key,w0):p0!==null&&H.exitKey(p0),w0},V.prototype._decodeGeneric=function(H,y0,W){let w0=this._baseState;return H==="seq"||H==="set"?null:H==="seqof"||H==="setof"?this._decodeList(y0,H,w0.args[0],W):/str$/.test(H)?this._decodeStr(y0,H,W):H==="objid"&&w0.args?this._decodeObjid(y0,w0.args[0],w0.args[1],W):H==="objid"?this._decodeObjid(y0,null,null,W):H==="gentime"||H==="utctime"?this._decodeTime(y0,H,W):H==="null_"?this._decodeNull(y0,W):H==="bool"?this._decodeBool(y0,W):H==="objDesc"?this._decodeStr(y0,H,W):H==="int"||H==="enum"?this._decodeInt(y0,w0.args&&w0.args[0],W):w0.use!==null?this._getUse(w0.use,y0._reporterState.obj)._decode(y0,W):y0.error("unknown tag: "+H)},V.prototype._getUse=function(H,y0){let W=this._baseState;return W.useDecoder=this._use(H,y0),$(W.useDecoder._baseState.parent===null),W.useDecoder=W.useDecoder._baseState.children[0],W.implicit!==W.useDecoder._baseState.implicit&&(W.useDecoder=W.useDecoder.clone(),W.useDecoder._baseState.implicit=W.implicit),W.useDecoder},V.prototype._decodeChoice=function(H,y0){let W=this._baseState,w0=null,E=!1;return Object.keys(W.choice).some(function(p0){let T=H.save(),f0=W.choice[p0];try{let D=f0._decode(H,y0);if(H.isError(D))return!1;w0={type:p0,value:D},E=!0}catch{return H.restore(T),!1}return!0},this),E?w0:H.error("Choice not matched")},V.prototype._createEncoderBuffer=function(H){return new G(H,this.reporter)},V.prototype._encode=function(H,y0,W){let w0=this._baseState;if(w0.default!==null&&w0.default===H)return;let E=this._encodeValue(H,y0,W);if(E!==void 0&&!this._skipDefault(E,y0,W))return E},V.prototype._encodeValue=function(H,y0,W){let w0=this._baseState;if(w0.parent===null)return w0.children[0]._encode(H,y0||new x0);let E=null;if(this.reporter=y0,w0.optional&&H===void 0)if(w0.default!==null)H=w0.default;else return;let p0=null,T=!1;if(w0.any)E=this._createEncoderBuffer(H);else if(w0.choice)E=this._encodeChoice(H,y0);else if(w0.contains)p0=this._getUse(w0.contains,W)._encode(H,y0),T=!0;else if(w0.children)p0=w0.children.map(function(f0){if(f0._baseState.tag==="null_")return f0._encode(null,y0,H);if(f0._baseState.key===null)return y0.error("Child should have a key");let D=y0.enterKey(f0._baseState.key);if(typeof H!="object")return y0.error("Child expected, but input is not object");let c0=f0._encode(H[f0._baseState.key],y0,H);return y0.leaveKey(D),c0},this).filter(function(f0){return f0}),p0=this._createEncoderBuffer(p0);else if(w0.tag==="seqof"||w0.tag==="setof"){if(!(w0.args&&w0.args.length===1))return y0.error("Too many args for : "+w0.tag);if(!Array.isArray(H))return y0.error("seqof/setof, but data is not Array");let f0=this.clone();f0._baseState.implicit=null,p0=this._createEncoderBuffer(H.map(function(D){let c0=this._baseState;return this._getUse(c0.args[0],H)._encode(D,y0)},f0))}else w0.use!==null?E=this._getUse(w0.use,W)._encode(H,y0):(p0=this._encodePrimitive(w0.tag,H),T=!0);if(!w0.any&&w0.choice===null){let f0=w0.implicit!==null?w0.implicit:w0.tag,D=w0.implicit===null?"universal":"context";f0===null?w0.use===null&&y0.error("Tag could be omitted only for .use()"):w0.use===null&&(E=this._encodeComposite(f0,T,D,p0))}return w0.explicit!==null&&(E=this._encodeComposite(w0.explicit,!1,"context",E)),E},V.prototype._encodeChoice=function(H,y0){let W=this._baseState,w0=W.choice[H.type];return w0||$(!1,H.type+" not found in "+JSON.stringify(Object.keys(W.choice))),w0._encode(H.value,y0)},V.prototype._encodePrimitive=function(H,y0){let W=this._baseState;if(/str$/.test(H))return this._encodeStr(y0,H);if(H==="objid"&&W.args)return this._encodeObjid(y0,W.reverseArgs[0],W.args[1]);if(H==="objid")return this._encodeObjid(y0,null,null);if(H==="gentime"||H==="utctime")return this._encodeTime(y0,H);if(H==="null_")return this._encodeNull();if(H==="int"||H==="enum")return this._encodeInt(y0,W.args&&W.reverseArgs[0]);if(H==="bool")return this._encodeBool(y0);if(H==="objDesc")return this._encodeStr(y0,H);throw new Error("Unsupported tag: "+H)},V.prototype._isNumstr=function(H){return/^[0-9 ]*$/.test(H)},V.prototype._isPrintstr=function(H){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(H)}}}),PY=$Q({"node_modules/asn1.js/lib/asn1/constants/der.js"(X){function K(x0){let G={};return Object.keys(x0).forEach(function(Y){(Y|0)==Y&&(Y=Y|0);let $=x0[Y];G[$]=Y}),G}X.tagClass={0:"universal",1:"application",2:"context",3:"private"},X.tagClassByName=K(X.tagClass),X.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"},X.tagByName=K(X.tag)}}),zY=$Q({"node_modules/asn1.js/lib/asn1/encoders/der.js"(X,K){var x0=X0(),G=CY().Buffer,Y=RY(),$=PY();function Z(B0){this.enc="der",this.name=B0.name,this.entity=B0,this.tree=new Q,this.tree._init(B0.body)}K.exports=Z,Z.prototype.encode=function(B0,H){return this.tree._encode(B0,H).join()};function Q(B0){Y.call(this,"der",B0)}x0(Q,Y),Q.prototype._encodeComposite=function(B0,H,y0,W){let w0=V(B0,H,y0,this.reporter);if(W.length<128){let T=G.alloc(2);return T[0]=w0,T[1]=W.length,this._createEncoderBuffer([T,W])}let E=1;for(let T=W.length;T>=256;T>>=8)E++;let p0=G.alloc(2+E);p0[0]=w0,p0[1]=128|E;for(let T=1+E,f0=W.length;f0>0;T--,f0>>=8)p0[T]=f0&255;return this._createEncoderBuffer([p0,W])},Q.prototype._encodeStr=function(B0,H){if(H==="bitstr")return this._createEncoderBuffer([B0.unused|0,B0.data]);if(H==="bmpstr"){let y0=G.alloc(B0.length*2);for(let W=0;W=40)return this.reporter.error("Second objid identifier OOB");B0.splice(0,2,B0[0]*40+B0[1])}let W=0;for(let p0=0;p0=128;T>>=7)W++}let w0=G.alloc(W),E=w0.length-1;for(let p0=B0.length-1;p0>=0;p0--){let T=B0[p0];for(w0[E--]=T&127;(T>>=7)>0;)w0[E--]=128|T&127}return this._createEncoderBuffer(w0)};function U(B0){return B0<10?"0"+B0:B0}Q.prototype._encodeTime=function(B0,H){let y0,W=new Date(B0);return H==="gentime"?y0=[U(W.getUTCFullYear()),U(W.getUTCMonth()+1),U(W.getUTCDate()),U(W.getUTCHours()),U(W.getUTCMinutes()),U(W.getUTCSeconds()),"Z"].join(""):H==="utctime"?y0=[U(W.getUTCFullYear()%100),U(W.getUTCMonth()+1),U(W.getUTCDate()),U(W.getUTCHours()),U(W.getUTCMinutes()),U(W.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+H+" time is not supported yet"),this._encodeStr(y0,"octstr")},Q.prototype._encodeNull=function(){return this._createEncoderBuffer("")},Q.prototype._encodeInt=function(B0,H){if(typeof B0=="string"){if(!H)return this.reporter.error("String int or enum given, but no values map");if(!H.hasOwnProperty(B0))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(B0));B0=H[B0]}if(typeof B0!="number"&&!G.isBuffer(B0)){let w0=B0.toArray();!B0.sign&&w0[0]&128&&w0.unshift(0),B0=G.from(w0)}if(G.isBuffer(B0)){let w0=B0.length;B0.length===0&&w0++;let E=G.alloc(w0);return B0.copy(E),B0.length===0&&(E[0]=0),this._createEncoderBuffer(E)}if(B0<128)return this._createEncoderBuffer(B0);if(B0<256)return this._createEncoderBuffer([0,B0]);let y0=1;for(let w0=B0;w0>=256;w0>>=8)y0++;let W=new Array(y0);for(let w0=W.length-1;w0>=0;w0--)W[w0]=B0&255,B0>>=8;return W[0]&128&&W.unshift(0),this._createEncoderBuffer(G.from(W))},Q.prototype._encodeBool=function(B0){return this._createEncoderBuffer(B0?255:0)},Q.prototype._use=function(B0,H){return typeof B0=="function"&&(B0=B0(H)),B0._getEncoder("der").tree},Q.prototype._skipDefault=function(B0,H,y0){let W=this._baseState,w0;if(W.default===null)return!1;let E=B0.join();if(W.defaultBuffer===void 0&&(W.defaultBuffer=this._encodeValue(W.default,H,y0).join()),E.length!==W.defaultBuffer.length)return!1;for(w0=0;w0=31?W.error("Multi-octet tag encoding unsupported"):(H||(w0|=32),w0|=$.tagClassByName[y0||"universal"]<<6,w0)}}}),MY=$Q({"node_modules/asn1.js/lib/asn1/encoders/pem.js"(X,K){var x0=X0(),G=zY();function Y($){G.call(this,$),this.enc="pem"}x0(Y,G),K.exports=Y,Y.prototype.encode=function($,Z){let Q=G.prototype.encode.call(this,$).toString("base64"),U=["-----BEGIN "+Z.label+"-----"];for(let V=0;V>6],E=(W&32)===0;if((W&31)===31){let T=W;for(W=0;(T&128)===128;){if(T=H.readUInt8(y0),H.isError(T))return T;W<<=7,W|=T&127}}else W&=31;let p0=Z.tag[W];return{cls:w0,primitive:E,tag:W,tagStr:p0}}function B0(H,y0,W){let w0=H.readUInt8(W);if(H.isError(w0))return w0;if(!y0&&w0===128)return null;if((w0&128)===0)return w0;let E=w0&127;if(E>4)return H.error("length octect is too long");w0=0;for(let p0=0;p00&&c0.ishrn(C),c0}function E(f0,D){f0=w0(f0,D),f0=f0.mod(D);var c0=x0.from(f0.toArray());if(c0.length=y0)throw new Error("invalid sig")}K.exports=Q}}),dY=$Q({"node_modules/browserify-sign/browser/index.js"(X,K){var x0=YQ().Buffer,G=L0(),Y=X0(),$=cY(),Z=hY(),Q=M0();Object.keys(Q).forEach(function(y0){Q[y0].id=x0.from(Q[y0].id,"hex"),Q[y0.toLowerCase()]=Q[y0]});function U(y0){h$.Writable.call(this);var W=Q[y0];if(!W)throw new Error("Unknown message digest");this._hashType=W.hash,this._hash=G(W.hash),this._tag=W.id,this._signType=W.sign}Y(U,h$.Writable),U.prototype._write=function(y0,W,w0){this._hash.update(y0),w0()},U.prototype.update=function(y0,W){return typeof y0=="string"&&(y0=x0.from(y0,W)),this._hash.update(y0),this},U.prototype.sign=function(y0,W){this.end();var w0=this._hash.digest(),E=$(w0,y0,this._hashType,this._signType,this._tag);return W?E.toString(W):E};function V(y0){h$.Writable.call(this);var W=Q[y0];if(!W)throw new Error("Unknown message digest");this._hash=G(W.hash),this._tag=W.id,this._signType=W.sign}Y(V,h$.Writable),V.prototype._write=function(y0,W,w0){this._hash.update(y0),w0()},V.prototype.update=function(y0,W){return typeof y0=="string"&&(y0=x0.from(y0,W)),this._hash.update(y0),this},V.prototype.verify=function(y0,W,w0){typeof W=="string"&&(W=x0.from(W,w0)),this.end();var E=this._hash.digest();return Z(W,E,y0,this._signType,this._tag)};function B0(y0){return new U(y0)}function H(y0){return new V(y0)}K.exports={Sign:B0,Verify:H,createSign:B0,createVerify:H}}}),bY=$Q({"node_modules/create-ecdh/node_modules/bn.js/lib/bn.js"(X,K){(function(x0,G){function Y(l0,z){if(!l0)throw new Error(z||"Assertion failed")}function $(l0,z){l0.super_=z;var o0=function(){};o0.prototype=z.prototype,l0.prototype=new o0,l0.prototype.constructor=l0}function Z(l0,z,o0){if(Z.isBN(l0))return l0;this.negative=0,this.words=null,this.length=0,this.red=null,l0!==null&&((z==="le"||z==="be")&&(o0=z,z=10),this._init(l0||0,z||10,o0||"be"))}typeof x0=="object"?x0.exports=Z:G.BN=Z,Z.BN=Z,Z.wordSize=26;var Q=c$;Z.isBN=function(l0){return l0 instanceof Z?!0:l0!==null&&typeof l0=="object"&&l0.constructor.wordSize===Z.wordSize&&Array.isArray(l0.words)},Z.max=function(l0,z){return l0.cmp(z)>0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),lY=$Q({"node_modules/create-ecdh/browser.js"(X,K){var x0=TY(),G=bY();K.exports=function(Q){return new $(Q)};var Y={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}};Y.p224=Y.secp224r1,Y.p256=Y.secp256r1=Y.prime256v1,Y.p192=Y.secp192r1=Y.prime192v1,Y.p384=Y.secp384r1,Y.p521=Y.secp521r1;function $(Q){this.curveType=Y[Q],this.curveType||(this.curveType={name:Q}),this.curve=new x0.ec(this.curveType.name),this.keys=void 0}$.prototype.generateKeys=function(Q,U){return this.keys=this.curve.genKeyPair(),this.getPublicKey(Q,U)},$.prototype.computeSecret=function(Q,U,V){U=U||"utf8",c$.isBuffer(Q)||(Q=new c$(Q,U));var B0=this.curve.keyFromPublic(Q).getPublic(),H=B0.mul(this.keys.getPrivate()).getX();return Z(H,V,this.curveType.byteLength)},$.prototype.getPublicKey=function(Q,U){var V=this.keys.getPublic(U==="compressed",!0);return U==="hybrid"&&(V[V.length-1]%2?V[0]=7:V[0]=6),Z(V,Q)},$.prototype.getPrivateKey=function(Q){return Z(this.keys.getPrivate(),Q)},$.prototype.setPublicKey=function(Q,U){return U=U||"utf8",c$.isBuffer(Q)||(Q=new c$(Q,U)),this.keys._importPublic(Q),this},$.prototype.setPrivateKey=function(Q,U){U=U||"utf8",c$.isBuffer(Q)||(Q=new c$(Q,U));var V=new G(Q);return V=V.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(V),this};function Z(Q,U,V){Array.isArray(Q)||(Q=Q.toArray());var B0=new c$(Q);if(V&&B0.length0?l0:z},Z.min=function(l0,z){return l0.cmp(z)<0?l0:z},Z.prototype._init=function(l0,z,o0){if(typeof l0=="number")return this._initNumber(l0,z,o0);if(typeof l0=="object")return this._initArray(l0,z,o0);z==="hex"&&(z=16),Y(z===(z|0)&&z>=2&&z<=36),l0=l0.toString().replace(/\s+/g,"");var M=0;l0[0]==="-"&&(M++,this.negative=1),M=0;M-=3)S=l0[M]|l0[M-1]<<8|l0[M-2]<<16,this.words[u0]|=S<>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);else if(o0==="le")for(M=0,u0=0;M>>26-n0&67108863,n0+=24,n0>=26&&(n0-=26,u0++);return this.strip()};function U(l0,z){var o0=l0.charCodeAt(z);return o0>=65&&o0<=70?o0-55:o0>=97&&o0<=102?o0-87:o0-48&15}function V(l0,z,o0){var M=U(l0,o0);return o0-1>=z&&(M|=U(l0,o0-1)<<4),M}Z.prototype._parseHex=function(l0,z,o0){this.length=Math.ceil((l0.length-z)/6),this.words=new Array(this.length);for(var M=0;M=z;M-=2)n0=V(l0,z,M)<=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8;else{var v=l0.length-z;for(M=v%2===0?z+1:z;M=18?(u0-=18,S+=1,this.words[S]|=n0>>>26):u0+=8}this.strip()};function B0(l0,z,o0,M){for(var u0=0,S=Math.min(l0.length,o0),n0=z;n0=49?u0+=v-49+10:v>=17?u0+=v-17+10:u0+=v}return u0}Z.prototype._parseBase=function(l0,z,o0){this.words=[0],this.length=1;for(var M=0,u0=1;u0<=67108863;u0*=z)M++;M--,u0=u0/z|0;for(var S=l0.length-o0,n0=S%M,v=Math.min(S,S-n0)+o0,s0=0,I=o0;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},Z.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},Z.prototype.inspect=function(){return(this.red?""};var H=["","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"],y0=[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];Z.prototype.toString=function(l0,z){l0=l0||10,z=z|0||1;var o0;if(l0===16||l0==="hex"){o0="";for(var M=0,u0=0,S=0;S>>24-M&16777215,u0!==0||S!==this.length-1?o0=H[6-v.length]+v+o0:o0=v+o0,M+=2,M>=26&&(M-=26,S--)}for(u0!==0&&(o0=u0.toString(16)+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}if(l0===(l0|0)&&l0>=2&&l0<=36){var s0=y0[l0],I=W[l0];o0="";var t0=this.clone();for(t0.negative=0;!t0.isZero();){var m0=t0.modn(I).toString(l0);t0=t0.idivn(I),t0.isZero()?o0=m0+o0:o0=H[s0-m0.length]+m0+o0}for(this.isZero()&&(o0="0"+o0);o0.length%z!==0;)o0="0"+o0;return this.negative!==0&&(o0="-"+o0),o0}Y(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var l0=this.words[0];return this.length===2?l0+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l0+=4503599627370496+this.words[1]*67108864:this.length>2&&Y(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l0:l0},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(l0,z){return Y(typeof Q<"u"),this.toArrayLike(Q,l0,z)},Z.prototype.toArray=function(l0,z){return this.toArrayLike(Array,l0,z)},Z.prototype.toArrayLike=function(l0,z,o0){var M=this.byteLength(),u0=o0||Math.max(1,M);Y(M<=u0,"byte array longer than desired length"),Y(u0>0,"Requested array length <= 0"),this.strip();var S=z==="le",n0=new l0(u0),v,s0,I=this.clone();if(S){for(s0=0;!I.isZero();s0++)v=I.andln(255),I.iushrn(8),n0[s0]=v;for(;s0=4096&&(o0+=13,z>>>=13),z>=64&&(o0+=7,z>>>=7),z>=8&&(o0+=4,z>>>=4),z>=2&&(o0+=2,z>>>=2),o0+z},Z.prototype._zeroBits=function(l0){if(l0===0)return 26;var z=l0,o0=0;return(z&8191)===0&&(o0+=13,z>>>=13),(z&127)===0&&(o0+=7,z>>>=7),(z&15)===0&&(o0+=4,z>>>=4),(z&3)===0&&(o0+=2,z>>>=2),(z&1)===0&&o0++,o0},Z.prototype.bitLength=function(){var l0=this.words[this.length-1],z=this._countBits(l0);return(this.length-1)*26+z};function w0(l0){for(var z=new Array(l0.bitLength()),o0=0;o0>>u0}return z}Z.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l0=0,z=0;zl0.length?this.clone().ior(l0):l0.clone().ior(this)},Z.prototype.uor=function(l0){return this.length>l0.length?this.clone().iuor(l0):l0.clone().iuor(this)},Z.prototype.iuand=function(l0){var z;this.length>l0.length?z=l0:z=this;for(var o0=0;o0l0.length?this.clone().iand(l0):l0.clone().iand(this)},Z.prototype.uand=function(l0){return this.length>l0.length?this.clone().iuand(l0):l0.clone().iuand(this)},Z.prototype.iuxor=function(l0){var z,o0;this.length>l0.length?(z=this,o0=l0):(z=l0,o0=this);for(var M=0;Ml0.length?this.clone().ixor(l0):l0.clone().ixor(this)},Z.prototype.uxor=function(l0){return this.length>l0.length?this.clone().iuxor(l0):l0.clone().iuxor(this)},Z.prototype.inotn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=Math.ceil(l0/26)|0,o0=l0%26;this._expand(z),o0>0&&z--;for(var M=0;M0&&(this.words[M]=~this.words[M]&67108863>>26-o0),this.strip()},Z.prototype.notn=function(l0){return this.clone().inotn(l0)},Z.prototype.setn=function(l0,z){Y(typeof l0=="number"&&l0>=0);var o0=l0/26|0,M=l0%26;return this._expand(o0+1),z?this.words[o0]=this.words[o0]|1<l0.length?(o0=this,M=l0):(o0=l0,M=this);for(var u0=0,S=0;S>>26;for(;u0!==0&&S>>26;if(this.length=o0.length,u0!==0)this.words[this.length]=u0,this.length++;else if(o0!==this)for(;Sl0.length?this.clone().iadd(l0):l0.clone().iadd(this)},Z.prototype.isub=function(l0){if(l0.negative!==0){l0.negative=0;var z=this.iadd(l0);return l0.negative=1,z._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l0),this.negative=1,this._normSign();var o0=this.cmp(l0);if(o0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var M,u0;o0>0?(M=this,u0=l0):(M=l0,u0=this);for(var S=0,n0=0;n0>26,this.words[n0]=z&67108863;for(;S!==0&&n0>26,this.words[n0]=z&67108863;if(S===0&&n0>>26,m0=s0&67108863,a0=Math.min(I,z.length-1),q=Math.max(0,I-l0.length+1);q<=a0;q++){var e0=I-q|0;u0=l0.words[e0]|0,S=z.words[q]|0,n0=u0*S+m0,t0+=n0/67108864|0,m0=n0&67108863}o0.words[I]=m0|0,s0=t0|0}return s0!==0?o0.words[I]=s0|0:o0.length--,o0.strip()}var p0=function(l0,z,o0){var M=l0.words,u0=z.words,S=o0.words,n0=0,v,s0,I,t0=M[0]|0,m0=t0&8191,a0=t0>>>13,q=M[1]|0,e0=q&8191,r0=q>>>13,i0=M[2]|0,j=i0&8191,$$=i0>>>13,k=M[3]|0,Q$=k&8191,g=k>>>13,Y$=M[4]|0,_=Y$&8191,Z$=Y$>>>13,N=M[5]|0,G$=N&8191,x=N>>>13,V$=M[6]|0,B=V$&8191,U$=V$>>>13,y=M[7]|0,X$=y&8191,w=y>>>13,K$=M[8]|0,p=K$&8191,I$=K$>>>13,f=M[9]|0,O$=f&8191,c=f>>>13,J$=u0[0]|0,h=J$&8191,F$=J$>>>13,d=u0[1]|0,A$=d&8191,b=d>>>13,H$=u0[2]|0,l=H$&8191,W$=H$>>>13,o=u0[3]|0,E$=o&8191,u=o>>>13,T$=u0[4]|0,n=T$&8191,D$=T$>>>13,s=u0[5]|0,C$=s&8191,t=s>>>13,L$=u0[6]|0,m=L$&8191,R$=L$>>>13,a=u0[7]|0,P$=a&8191,O=a>>>13,z$=u0[8]|0,e=z$&8191,M$=z$>>>13,J=u0[9]|0,S$=J&8191,F=J>>>13;o0.negative=l0.negative^z.negative,o0.length=19,v=Math.imul(m0,h),s0=Math.imul(m0,F$),s0=s0+Math.imul(a0,h)|0,I=Math.imul(a0,F$);var v$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(v$>>>26)|0,v$&=67108863,v=Math.imul(e0,h),s0=Math.imul(e0,F$),s0=s0+Math.imul(r0,h)|0,I=Math.imul(r0,F$),v=v+Math.imul(m0,A$)|0,s0=s0+Math.imul(m0,b)|0,s0=s0+Math.imul(a0,A$)|0,I=I+Math.imul(a0,b)|0;var r=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(r>>>26)|0,r&=67108863,v=Math.imul(j,h),s0=Math.imul(j,F$),s0=s0+Math.imul($$,h)|0,I=Math.imul($$,F$),v=v+Math.imul(e0,A$)|0,s0=s0+Math.imul(e0,b)|0,s0=s0+Math.imul(r0,A$)|0,I=I+Math.imul(r0,b)|0,v=v+Math.imul(m0,l)|0,s0=s0+Math.imul(m0,W$)|0,s0=s0+Math.imul(a0,l)|0,I=I+Math.imul(a0,W$)|0;var q$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(q$>>>26)|0,q$&=67108863,v=Math.imul(Q$,h),s0=Math.imul(Q$,F$),s0=s0+Math.imul(g,h)|0,I=Math.imul(g,F$),v=v+Math.imul(j,A$)|0,s0=s0+Math.imul(j,b)|0,s0=s0+Math.imul($$,A$)|0,I=I+Math.imul($$,b)|0,v=v+Math.imul(e0,l)|0,s0=s0+Math.imul(e0,W$)|0,s0=s0+Math.imul(r0,l)|0,I=I+Math.imul(r0,W$)|0,v=v+Math.imul(m0,E$)|0,s0=s0+Math.imul(m0,u)|0,s0=s0+Math.imul(a0,E$)|0,I=I+Math.imul(a0,u)|0;var i=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(i>>>26)|0,i&=67108863,v=Math.imul(_,h),s0=Math.imul(_,F$),s0=s0+Math.imul(Z$,h)|0,I=Math.imul(Z$,F$),v=v+Math.imul(Q$,A$)|0,s0=s0+Math.imul(Q$,b)|0,s0=s0+Math.imul(g,A$)|0,I=I+Math.imul(g,b)|0,v=v+Math.imul(j,l)|0,s0=s0+Math.imul(j,W$)|0,s0=s0+Math.imul($$,l)|0,I=I+Math.imul($$,W$)|0,v=v+Math.imul(e0,E$)|0,s0=s0+Math.imul(e0,u)|0,s0=s0+Math.imul(r0,E$)|0,I=I+Math.imul(r0,u)|0,v=v+Math.imul(m0,n)|0,s0=s0+Math.imul(m0,D$)|0,s0=s0+Math.imul(a0,n)|0,I=I+Math.imul(a0,D$)|0;var j$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(j$>>>26)|0,j$&=67108863,v=Math.imul(G$,h),s0=Math.imul(G$,F$),s0=s0+Math.imul(x,h)|0,I=Math.imul(x,F$),v=v+Math.imul(_,A$)|0,s0=s0+Math.imul(_,b)|0,s0=s0+Math.imul(Z$,A$)|0,I=I+Math.imul(Z$,b)|0,v=v+Math.imul(Q$,l)|0,s0=s0+Math.imul(Q$,W$)|0,s0=s0+Math.imul(g,l)|0,I=I+Math.imul(g,W$)|0,v=v+Math.imul(j,E$)|0,s0=s0+Math.imul(j,u)|0,s0=s0+Math.imul($$,E$)|0,I=I+Math.imul($$,u)|0,v=v+Math.imul(e0,n)|0,s0=s0+Math.imul(e0,D$)|0,s0=s0+Math.imul(r0,n)|0,I=I+Math.imul(r0,D$)|0,v=v+Math.imul(m0,C$)|0,s0=s0+Math.imul(m0,t)|0,s0=s0+Math.imul(a0,C$)|0,I=I+Math.imul(a0,t)|0;var k$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(k$>>>26)|0,k$&=67108863,v=Math.imul(B,h),s0=Math.imul(B,F$),s0=s0+Math.imul(U$,h)|0,I=Math.imul(U$,F$),v=v+Math.imul(G$,A$)|0,s0=s0+Math.imul(G$,b)|0,s0=s0+Math.imul(x,A$)|0,I=I+Math.imul(x,b)|0,v=v+Math.imul(_,l)|0,s0=s0+Math.imul(_,W$)|0,s0=s0+Math.imul(Z$,l)|0,I=I+Math.imul(Z$,W$)|0,v=v+Math.imul(Q$,E$)|0,s0=s0+Math.imul(Q$,u)|0,s0=s0+Math.imul(g,E$)|0,I=I+Math.imul(g,u)|0,v=v+Math.imul(j,n)|0,s0=s0+Math.imul(j,D$)|0,s0=s0+Math.imul($$,n)|0,I=I+Math.imul($$,D$)|0,v=v+Math.imul(e0,C$)|0,s0=s0+Math.imul(e0,t)|0,s0=s0+Math.imul(r0,C$)|0,I=I+Math.imul(r0,t)|0,v=v+Math.imul(m0,m)|0,s0=s0+Math.imul(m0,R$)|0,s0=s0+Math.imul(a0,m)|0,I=I+Math.imul(a0,R$)|0;var g$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(g$>>>26)|0,g$&=67108863,v=Math.imul(X$,h),s0=Math.imul(X$,F$),s0=s0+Math.imul(w,h)|0,I=Math.imul(w,F$),v=v+Math.imul(B,A$)|0,s0=s0+Math.imul(B,b)|0,s0=s0+Math.imul(U$,A$)|0,I=I+Math.imul(U$,b)|0,v=v+Math.imul(G$,l)|0,s0=s0+Math.imul(G$,W$)|0,s0=s0+Math.imul(x,l)|0,I=I+Math.imul(x,W$)|0,v=v+Math.imul(_,E$)|0,s0=s0+Math.imul(_,u)|0,s0=s0+Math.imul(Z$,E$)|0,I=I+Math.imul(Z$,u)|0,v=v+Math.imul(Q$,n)|0,s0=s0+Math.imul(Q$,D$)|0,s0=s0+Math.imul(g,n)|0,I=I+Math.imul(g,D$)|0,v=v+Math.imul(j,C$)|0,s0=s0+Math.imul(j,t)|0,s0=s0+Math.imul($$,C$)|0,I=I+Math.imul($$,t)|0,v=v+Math.imul(e0,m)|0,s0=s0+Math.imul(e0,R$)|0,s0=s0+Math.imul(r0,m)|0,I=I+Math.imul(r0,R$)|0,v=v+Math.imul(m0,P$)|0,s0=s0+Math.imul(m0,O)|0,s0=s0+Math.imul(a0,P$)|0,I=I+Math.imul(a0,O)|0;var _$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(_$>>>26)|0,_$&=67108863,v=Math.imul(p,h),s0=Math.imul(p,F$),s0=s0+Math.imul(I$,h)|0,I=Math.imul(I$,F$),v=v+Math.imul(X$,A$)|0,s0=s0+Math.imul(X$,b)|0,s0=s0+Math.imul(w,A$)|0,I=I+Math.imul(w,b)|0,v=v+Math.imul(B,l)|0,s0=s0+Math.imul(B,W$)|0,s0=s0+Math.imul(U$,l)|0,I=I+Math.imul(U$,W$)|0,v=v+Math.imul(G$,E$)|0,s0=s0+Math.imul(G$,u)|0,s0=s0+Math.imul(x,E$)|0,I=I+Math.imul(x,u)|0,v=v+Math.imul(_,n)|0,s0=s0+Math.imul(_,D$)|0,s0=s0+Math.imul(Z$,n)|0,I=I+Math.imul(Z$,D$)|0,v=v+Math.imul(Q$,C$)|0,s0=s0+Math.imul(Q$,t)|0,s0=s0+Math.imul(g,C$)|0,I=I+Math.imul(g,t)|0,v=v+Math.imul(j,m)|0,s0=s0+Math.imul(j,R$)|0,s0=s0+Math.imul($$,m)|0,I=I+Math.imul($$,R$)|0,v=v+Math.imul(e0,P$)|0,s0=s0+Math.imul(e0,O)|0,s0=s0+Math.imul(r0,P$)|0,I=I+Math.imul(r0,O)|0,v=v+Math.imul(m0,e)|0,s0=s0+Math.imul(m0,M$)|0,s0=s0+Math.imul(a0,e)|0,I=I+Math.imul(a0,M$)|0;var N$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(N$>>>26)|0,N$&=67108863,v=Math.imul(O$,h),s0=Math.imul(O$,F$),s0=s0+Math.imul(c,h)|0,I=Math.imul(c,F$),v=v+Math.imul(p,A$)|0,s0=s0+Math.imul(p,b)|0,s0=s0+Math.imul(I$,A$)|0,I=I+Math.imul(I$,b)|0,v=v+Math.imul(X$,l)|0,s0=s0+Math.imul(X$,W$)|0,s0=s0+Math.imul(w,l)|0,I=I+Math.imul(w,W$)|0,v=v+Math.imul(B,E$)|0,s0=s0+Math.imul(B,u)|0,s0=s0+Math.imul(U$,E$)|0,I=I+Math.imul(U$,u)|0,v=v+Math.imul(G$,n)|0,s0=s0+Math.imul(G$,D$)|0,s0=s0+Math.imul(x,n)|0,I=I+Math.imul(x,D$)|0,v=v+Math.imul(_,C$)|0,s0=s0+Math.imul(_,t)|0,s0=s0+Math.imul(Z$,C$)|0,I=I+Math.imul(Z$,t)|0,v=v+Math.imul(Q$,m)|0,s0=s0+Math.imul(Q$,R$)|0,s0=s0+Math.imul(g,m)|0,I=I+Math.imul(g,R$)|0,v=v+Math.imul(j,P$)|0,s0=s0+Math.imul(j,O)|0,s0=s0+Math.imul($$,P$)|0,I=I+Math.imul($$,O)|0,v=v+Math.imul(e0,e)|0,s0=s0+Math.imul(e0,M$)|0,s0=s0+Math.imul(r0,e)|0,I=I+Math.imul(r0,M$)|0,v=v+Math.imul(m0,S$)|0,s0=s0+Math.imul(m0,F)|0,s0=s0+Math.imul(a0,S$)|0,I=I+Math.imul(a0,F)|0;var $0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+($0>>>26)|0,$0&=67108863,v=Math.imul(O$,A$),s0=Math.imul(O$,b),s0=s0+Math.imul(c,A$)|0,I=Math.imul(c,b),v=v+Math.imul(p,l)|0,s0=s0+Math.imul(p,W$)|0,s0=s0+Math.imul(I$,l)|0,I=I+Math.imul(I$,W$)|0,v=v+Math.imul(X$,E$)|0,s0=s0+Math.imul(X$,u)|0,s0=s0+Math.imul(w,E$)|0,I=I+Math.imul(w,u)|0,v=v+Math.imul(B,n)|0,s0=s0+Math.imul(B,D$)|0,s0=s0+Math.imul(U$,n)|0,I=I+Math.imul(U$,D$)|0,v=v+Math.imul(G$,C$)|0,s0=s0+Math.imul(G$,t)|0,s0=s0+Math.imul(x,C$)|0,I=I+Math.imul(x,t)|0,v=v+Math.imul(_,m)|0,s0=s0+Math.imul(_,R$)|0,s0=s0+Math.imul(Z$,m)|0,I=I+Math.imul(Z$,R$)|0,v=v+Math.imul(Q$,P$)|0,s0=s0+Math.imul(Q$,O)|0,s0=s0+Math.imul(g,P$)|0,I=I+Math.imul(g,O)|0,v=v+Math.imul(j,e)|0,s0=s0+Math.imul(j,M$)|0,s0=s0+Math.imul($$,e)|0,I=I+Math.imul($$,M$)|0,v=v+Math.imul(e0,S$)|0,s0=s0+Math.imul(e0,F)|0,s0=s0+Math.imul(r0,S$)|0,I=I+Math.imul(r0,F)|0;var x$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(x$>>>26)|0,x$&=67108863,v=Math.imul(O$,l),s0=Math.imul(O$,W$),s0=s0+Math.imul(c,l)|0,I=Math.imul(c,W$),v=v+Math.imul(p,E$)|0,s0=s0+Math.imul(p,u)|0,s0=s0+Math.imul(I$,E$)|0,I=I+Math.imul(I$,u)|0,v=v+Math.imul(X$,n)|0,s0=s0+Math.imul(X$,D$)|0,s0=s0+Math.imul(w,n)|0,I=I+Math.imul(w,D$)|0,v=v+Math.imul(B,C$)|0,s0=s0+Math.imul(B,t)|0,s0=s0+Math.imul(U$,C$)|0,I=I+Math.imul(U$,t)|0,v=v+Math.imul(G$,m)|0,s0=s0+Math.imul(G$,R$)|0,s0=s0+Math.imul(x,m)|0,I=I+Math.imul(x,R$)|0,v=v+Math.imul(_,P$)|0,s0=s0+Math.imul(_,O)|0,s0=s0+Math.imul(Z$,P$)|0,I=I+Math.imul(Z$,O)|0,v=v+Math.imul(Q$,e)|0,s0=s0+Math.imul(Q$,M$)|0,s0=s0+Math.imul(g,e)|0,I=I+Math.imul(g,M$)|0,v=v+Math.imul(j,S$)|0,s0=s0+Math.imul(j,F)|0,s0=s0+Math.imul($$,S$)|0,I=I+Math.imul($$,F)|0;var Q0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,v=Math.imul(O$,E$),s0=Math.imul(O$,u),s0=s0+Math.imul(c,E$)|0,I=Math.imul(c,u),v=v+Math.imul(p,n)|0,s0=s0+Math.imul(p,D$)|0,s0=s0+Math.imul(I$,n)|0,I=I+Math.imul(I$,D$)|0,v=v+Math.imul(X$,C$)|0,s0=s0+Math.imul(X$,t)|0,s0=s0+Math.imul(w,C$)|0,I=I+Math.imul(w,t)|0,v=v+Math.imul(B,m)|0,s0=s0+Math.imul(B,R$)|0,s0=s0+Math.imul(U$,m)|0,I=I+Math.imul(U$,R$)|0,v=v+Math.imul(G$,P$)|0,s0=s0+Math.imul(G$,O)|0,s0=s0+Math.imul(x,P$)|0,I=I+Math.imul(x,O)|0,v=v+Math.imul(_,e)|0,s0=s0+Math.imul(_,M$)|0,s0=s0+Math.imul(Z$,e)|0,I=I+Math.imul(Z$,M$)|0,v=v+Math.imul(Q$,S$)|0,s0=s0+Math.imul(Q$,F)|0,s0=s0+Math.imul(g,S$)|0,I=I+Math.imul(g,F)|0;var B$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(B$>>>26)|0,B$&=67108863,v=Math.imul(O$,n),s0=Math.imul(O$,D$),s0=s0+Math.imul(c,n)|0,I=Math.imul(c,D$),v=v+Math.imul(p,C$)|0,s0=s0+Math.imul(p,t)|0,s0=s0+Math.imul(I$,C$)|0,I=I+Math.imul(I$,t)|0,v=v+Math.imul(X$,m)|0,s0=s0+Math.imul(X$,R$)|0,s0=s0+Math.imul(w,m)|0,I=I+Math.imul(w,R$)|0,v=v+Math.imul(B,P$)|0,s0=s0+Math.imul(B,O)|0,s0=s0+Math.imul(U$,P$)|0,I=I+Math.imul(U$,O)|0,v=v+Math.imul(G$,e)|0,s0=s0+Math.imul(G$,M$)|0,s0=s0+Math.imul(x,e)|0,I=I+Math.imul(x,M$)|0,v=v+Math.imul(_,S$)|0,s0=s0+Math.imul(_,F)|0,s0=s0+Math.imul(Z$,S$)|0,I=I+Math.imul(Z$,F)|0;var Y0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Y0>>>26)|0,Y0&=67108863,v=Math.imul(O$,C$),s0=Math.imul(O$,t),s0=s0+Math.imul(c,C$)|0,I=Math.imul(c,t),v=v+Math.imul(p,m)|0,s0=s0+Math.imul(p,R$)|0,s0=s0+Math.imul(I$,m)|0,I=I+Math.imul(I$,R$)|0,v=v+Math.imul(X$,P$)|0,s0=s0+Math.imul(X$,O)|0,s0=s0+Math.imul(w,P$)|0,I=I+Math.imul(w,O)|0,v=v+Math.imul(B,e)|0,s0=s0+Math.imul(B,M$)|0,s0=s0+Math.imul(U$,e)|0,I=I+Math.imul(U$,M$)|0,v=v+Math.imul(G$,S$)|0,s0=s0+Math.imul(G$,F)|0,s0=s0+Math.imul(x,S$)|0,I=I+Math.imul(x,F)|0;var y$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(y$>>>26)|0,y$&=67108863,v=Math.imul(O$,m),s0=Math.imul(O$,R$),s0=s0+Math.imul(c,m)|0,I=Math.imul(c,R$),v=v+Math.imul(p,P$)|0,s0=s0+Math.imul(p,O)|0,s0=s0+Math.imul(I$,P$)|0,I=I+Math.imul(I$,O)|0,v=v+Math.imul(X$,e)|0,s0=s0+Math.imul(X$,M$)|0,s0=s0+Math.imul(w,e)|0,I=I+Math.imul(w,M$)|0,v=v+Math.imul(B,S$)|0,s0=s0+Math.imul(B,F)|0,s0=s0+Math.imul(U$,S$)|0,I=I+Math.imul(U$,F)|0;var Z0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(Z0>>>26)|0,Z0&=67108863,v=Math.imul(O$,P$),s0=Math.imul(O$,O),s0=s0+Math.imul(c,P$)|0,I=Math.imul(c,O),v=v+Math.imul(p,e)|0,s0=s0+Math.imul(p,M$)|0,s0=s0+Math.imul(I$,e)|0,I=I+Math.imul(I$,M$)|0,v=v+Math.imul(X$,S$)|0,s0=s0+Math.imul(X$,F)|0,s0=s0+Math.imul(w,S$)|0,I=I+Math.imul(w,F)|0;var w$=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(w$>>>26)|0,w$&=67108863,v=Math.imul(O$,e),s0=Math.imul(O$,M$),s0=s0+Math.imul(c,e)|0,I=Math.imul(c,M$),v=v+Math.imul(p,S$)|0,s0=s0+Math.imul(p,F)|0,s0=s0+Math.imul(I$,S$)|0,I=I+Math.imul(I$,F)|0;var G0=(n0+v|0)+((s0&8191)<<13)|0;n0=(I+(s0>>>13)|0)+(G0>>>26)|0,G0&=67108863,v=Math.imul(O$,S$),s0=Math.imul(O$,F),s0=s0+Math.imul(c,S$)|0,I=Math.imul(c,F);var p$=(n0+v|0)+((s0&8191)<<13)|0;return n0=(I+(s0>>>13)|0)+(p$>>>26)|0,p$&=67108863,S[0]=v$,S[1]=r,S[2]=q$,S[3]=i,S[4]=j$,S[5]=k$,S[6]=g$,S[7]=_$,S[8]=N$,S[9]=$0,S[10]=x$,S[11]=Q0,S[12]=B$,S[13]=Y0,S[14]=y$,S[15]=Z0,S[16]=w$,S[17]=G0,S[18]=p$,n0!==0&&(S[19]=n0,o0.length++),o0};Math.imul||(p0=E);function T(l0,z,o0){o0.negative=z.negative^l0.negative,o0.length=l0.length+z.length;for(var M=0,u0=0,S=0;S>>26)|0,u0+=n0>>>26,n0&=67108863}o0.words[S]=v,M=n0,n0=u0}return M!==0?o0.words[S]=M:o0.length--,o0.strip()}function f0(l0,z,o0){var M=new D;return M.mulp(l0,z,o0)}Z.prototype.mulTo=function(l0,z){var o0,M=this.length+l0.length;return this.length===10&&l0.length===10?o0=p0(this,l0,z):M<63?o0=E(this,l0,z):M<1024?o0=T(this,l0,z):o0=f0(this,l0,z),o0};function D(l0,z){this.x=l0,this.y=z}D.prototype.makeRBT=function(l0){for(var z=new Array(l0),o0=Z.prototype._countBits(l0)-1,M=0;M>=1;return M},D.prototype.permute=function(l0,z,o0,M,u0,S){for(var n0=0;n0>>1)u0++;return 1<>>13,o0[2*S+1]=u0&8191,u0=u0>>>13;for(S=2*z;S>=26,z+=M/67108864|0,z+=u0>>>26,this.words[o0]=u0&67108863}return z!==0&&(this.words[o0]=z,this.length++),this},Z.prototype.muln=function(l0){return this.clone().imuln(l0)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(l0){var z=w0(l0);if(z.length===0)return new Z(1);for(var o0=this,M=0;M=0);var z=l0%26,o0=(l0-z)/26,M=67108863>>>26-z<<26-z,u0;if(z!==0){var S=0;for(u0=0;u0>>26-z}S&&(this.words[u0]=S,this.length++)}if(o0!==0){for(u0=this.length-1;u0>=0;u0--)this.words[u0+o0]=this.words[u0];for(u0=0;u0=0);var M;z?M=(z-z%26)/26:M=0;var u0=l0%26,S=Math.min((l0-u0)/26,this.length),n0=67108863^67108863>>>u0<S)for(this.length-=S,s0=0;s0=0&&(I!==0||s0>=M);s0--){var t0=this.words[s0]|0;this.words[s0]=I<<26-u0|t0>>>u0,I=t0&n0}return v&&I!==0&&(v.words[v.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},Z.prototype.ishrn=function(l0,z,o0){return Y(this.negative===0),this.iushrn(l0,z,o0)},Z.prototype.shln=function(l0){return this.clone().ishln(l0)},Z.prototype.ushln=function(l0){return this.clone().iushln(l0)},Z.prototype.shrn=function(l0){return this.clone().ishrn(l0)},Z.prototype.ushrn=function(l0){return this.clone().iushrn(l0)},Z.prototype.testn=function(l0){Y(typeof l0=="number"&&l0>=0);var z=l0%26,o0=(l0-z)/26,M=1<=0);var z=l0%26,o0=(l0-z)/26;if(Y(this.negative===0,"imaskn works only with positive numbers"),this.length<=o0)return this;if(z!==0&&o0++,this.length=Math.min(o0,this.length),z!==0){var M=67108863^67108863>>>z<=67108864;z++)this.words[z]-=67108864,z===this.length-1?this.words[z+1]=1:this.words[z+1]++;return this.length=Math.max(this.length,z+1),this},Z.prototype.isubn=function(l0){if(Y(typeof l0=="number"),Y(l0<67108864),l0<0)return this.iaddn(-l0);if(this.negative!==0)return this.negative=0,this.iaddn(l0),this.negative=1,this;if(this.words[0]-=l0,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var z=0;z>26)-(v/67108864|0),this.words[u0+o0]=S&67108863}for(;u0>26,this.words[u0+o0]=S&67108863;if(n0===0)return this.strip();for(Y(n0===-1),n0=0,u0=0;u0>26,this.words[u0]=S&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(l0,z){var o0=this.length-l0.length,M=this.clone(),u0=l0,S=u0.words[u0.length-1]|0,n0=this._countBits(S);o0=26-n0,o0!==0&&(u0=u0.ushln(o0),M.iushln(o0),S=u0.words[u0.length-1]|0);var v=M.length-u0.length,s0;if(z!=="mod"){s0=new Z(null),s0.length=v+1,s0.words=new Array(s0.length);for(var I=0;I=0;m0--){var a0=(M.words[u0.length+m0]|0)*67108864+(M.words[u0.length+m0-1]|0);for(a0=Math.min(a0/S|0,67108863),M._ishlnsubmul(u0,a0,m0);M.negative!==0;)a0--,M.negative=0,M._ishlnsubmul(u0,1,m0),M.isZero()||(M.negative^=1);s0&&(s0.words[m0]=a0)}return s0&&s0.strip(),M.strip(),z!=="div"&&o0!==0&&M.iushrn(o0),{div:s0||null,mod:M}},Z.prototype.divmod=function(l0,z,o0){if(Y(!l0.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var M,u0,S;return this.negative!==0&&l0.negative===0?(S=this.neg().divmod(l0,z),z!=="mod"&&(M=S.div.neg()),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.iadd(l0)),{div:M,mod:u0}):this.negative===0&&l0.negative!==0?(S=this.divmod(l0.neg(),z),z!=="mod"&&(M=S.div.neg()),{div:M,mod:S.mod}):(this.negative&l0.negative)!==0?(S=this.neg().divmod(l0.neg(),z),z!=="div"&&(u0=S.mod.neg(),o0&&u0.negative!==0&&u0.isub(l0)),{div:S.div,mod:u0}):l0.length>this.length||this.cmp(l0)<0?{div:new Z(0),mod:this}:l0.length===1?z==="div"?{div:this.divn(l0.words[0]),mod:null}:z==="mod"?{div:null,mod:new Z(this.modn(l0.words[0]))}:{div:this.divn(l0.words[0]),mod:new Z(this.modn(l0.words[0]))}:this._wordDiv(l0,z)},Z.prototype.div=function(l0){return this.divmod(l0,"div",!1).div},Z.prototype.mod=function(l0){return this.divmod(l0,"mod",!1).mod},Z.prototype.umod=function(l0){return this.divmod(l0,"mod",!0).mod},Z.prototype.divRound=function(l0){var z=this.divmod(l0);if(z.mod.isZero())return z.div;var o0=z.div.negative!==0?z.mod.isub(l0):z.mod,M=l0.ushrn(1),u0=l0.andln(1),S=o0.cmp(M);return S<0||u0===1&&S===0?z.div:z.div.negative!==0?z.div.isubn(1):z.div.iaddn(1)},Z.prototype.modn=function(l0){Y(l0<=67108863);for(var z=(1<<26)%l0,o0=0,M=this.length-1;M>=0;M--)o0=(z*o0+(this.words[M]|0))%l0;return o0},Z.prototype.idivn=function(l0){Y(l0<=67108863);for(var z=0,o0=this.length-1;o0>=0;o0--){var M=(this.words[o0]|0)+z*67108864;this.words[o0]=M/l0|0,z=M%l0}return this.strip()},Z.prototype.divn=function(l0){return this.clone().idivn(l0)},Z.prototype.egcd=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=new Z(0),n0=new Z(1),v=0;z.isEven()&&o0.isEven();)z.iushrn(1),o0.iushrn(1),++v;for(var s0=o0.clone(),I=z.clone();!z.isZero();){for(var t0=0,m0=1;(z.words[0]&m0)===0&&t0<26;++t0,m0<<=1);if(t0>0)for(z.iushrn(t0);t0-- >0;)(M.isOdd()||u0.isOdd())&&(M.iadd(s0),u0.isub(I)),M.iushrn(1),u0.iushrn(1);for(var a0=0,q=1;(o0.words[0]&q)===0&&a0<26;++a0,q<<=1);if(a0>0)for(o0.iushrn(a0);a0-- >0;)(S.isOdd()||n0.isOdd())&&(S.iadd(s0),n0.isub(I)),S.iushrn(1),n0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(S),u0.isub(n0)):(o0.isub(z),S.isub(M),n0.isub(u0))}return{a:S,b:n0,gcd:o0.iushln(v)}},Z.prototype._invmp=function(l0){Y(l0.negative===0),Y(!l0.isZero());var z=this,o0=l0.clone();z.negative!==0?z=z.umod(l0):z=z.clone();for(var M=new Z(1),u0=new Z(0),S=o0.clone();z.cmpn(1)>0&&o0.cmpn(1)>0;){for(var n0=0,v=1;(z.words[0]&v)===0&&n0<26;++n0,v<<=1);if(n0>0)for(z.iushrn(n0);n0-- >0;)M.isOdd()&&M.iadd(S),M.iushrn(1);for(var s0=0,I=1;(o0.words[0]&I)===0&&s0<26;++s0,I<<=1);if(s0>0)for(o0.iushrn(s0);s0-- >0;)u0.isOdd()&&u0.iadd(S),u0.iushrn(1);z.cmp(o0)>=0?(z.isub(o0),M.isub(u0)):(o0.isub(z),u0.isub(M))}var t0;return z.cmpn(1)===0?t0=M:t0=u0,t0.cmpn(0)<0&&t0.iadd(l0),t0},Z.prototype.gcd=function(l0){if(this.isZero())return l0.abs();if(l0.isZero())return this.abs();var z=this.clone(),o0=l0.clone();z.negative=0,o0.negative=0;for(var M=0;z.isEven()&&o0.isEven();M++)z.iushrn(1),o0.iushrn(1);do{for(;z.isEven();)z.iushrn(1);for(;o0.isEven();)o0.iushrn(1);var u0=z.cmp(o0);if(u0<0){var S=z;z=o0,o0=S}else if(u0===0||o0.cmpn(1)===0)break;z.isub(o0)}while(!0);return o0.iushln(M)},Z.prototype.invm=function(l0){return this.egcd(l0).a.umod(l0)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(l0){return this.words[0]&l0},Z.prototype.bincn=function(l0){Y(typeof l0=="number");var z=l0%26,o0=(l0-z)/26,M=1<>>26,n0&=67108863,this.words[S]=n0}return u0!==0&&(this.words[S]=u0,this.length++),this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(l0){var z=l0<0;if(this.negative!==0&&!z)return-1;if(this.negative===0&&z)return 1;this.strip();var o0;if(this.length>1)o0=1;else{z&&(l0=-l0),Y(l0<=67108863,"Number is too big");var M=this.words[0]|0;o0=M===l0?0:Ml0.length)return 1;if(this.length=0;o0--){var M=this.words[o0]|0,u0=l0.words[o0]|0;if(M!==u0){Mu0&&(z=1);break}}return z},Z.prototype.gtn=function(l0){return this.cmpn(l0)===1},Z.prototype.gt=function(l0){return this.cmp(l0)===1},Z.prototype.gten=function(l0){return this.cmpn(l0)>=0},Z.prototype.gte=function(l0){return this.cmp(l0)>=0},Z.prototype.ltn=function(l0){return this.cmpn(l0)===-1},Z.prototype.lt=function(l0){return this.cmp(l0)===-1},Z.prototype.lten=function(l0){return this.cmpn(l0)<=0},Z.prototype.lte=function(l0){return this.cmp(l0)<=0},Z.prototype.eqn=function(l0){return this.cmpn(l0)===0},Z.prototype.eq=function(l0){return this.cmp(l0)===0},Z.red=function(l0){return new b0(l0)},Z.prototype.toRed=function(l0){return Y(!this.red,"Already a number in reduction context"),Y(this.negative===0,"red works only with positives"),l0.convertTo(this)._forceRed(l0)},Z.prototype.fromRed=function(){return Y(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(l0){return this.red=l0,this},Z.prototype.forceRed=function(l0){return Y(!this.red,"Already a number in reduction context"),this._forceRed(l0)},Z.prototype.redAdd=function(l0){return Y(this.red,"redAdd works only with red numbers"),this.red.add(this,l0)},Z.prototype.redIAdd=function(l0){return Y(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l0)},Z.prototype.redSub=function(l0){return Y(this.red,"redSub works only with red numbers"),this.red.sub(this,l0)},Z.prototype.redISub=function(l0){return Y(this.red,"redISub works only with red numbers"),this.red.isub(this,l0)},Z.prototype.redShl=function(l0){return Y(this.red,"redShl works only with red numbers"),this.red.shl(this,l0)},Z.prototype.redMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.mul(this,l0)},Z.prototype.redIMul=function(l0){return Y(this.red,"redMul works only with red numbers"),this.red._verify2(this,l0),this.red.imul(this,l0)},Z.prototype.redSqr=function(){return Y(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return Y(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return Y(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return Y(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return Y(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(l0){return Y(this.red&&!l0.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l0)};var c0={k256:null,p224:null,p192:null,p25519:null};function C(l0,z){this.name=l0,this.p=new Z(z,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var l0=new Z(null);return l0.words=new Array(Math.ceil(this.n/13)),l0},C.prototype.ireduce=function(l0){var z=l0,o0;do this.split(z,this.tmp),z=this.imulK(z),z=z.iadd(this.tmp),o0=z.bitLength();while(o0>this.n);var M=o00?z.isub(this.p):z.strip!==void 0?z.strip():z._strip(),z},C.prototype.split=function(l0,z){l0.iushrn(this.n,0,z)},C.prototype.imulK=function(l0){return l0.imul(this.k)};function h0(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}$(h0,C),h0.prototype.split=function(l0,z){for(var o0=4194303,M=Math.min(l0.length,9),u0=0;u0>>22,S=n0}S>>>=22,l0.words[u0-10]=S,S===0&&l0.length>10?l0.length-=10:l0.length-=9},h0.prototype.imulK=function(l0){l0.words[l0.length]=0,l0.words[l0.length+1]=0,l0.length+=2;for(var z=0,o0=0;o0>>=26,l0.words[o0]=u0,z=M}return z!==0&&(l0.words[l0.length++]=z),l0},Z._prime=function(l0){if(c0[l0])return c0[l0];var z;if(l0==="k256")z=new h0;else if(l0==="p224")z=new L;else if(l0==="p192")z=new d0;else if(l0==="p25519")z=new R;else throw new Error("Unknown prime "+l0);return c0[l0]=z,z};function b0(l0){if(typeof l0=="string"){var z=Z._prime(l0);this.m=z.p,this.prime=z}else Y(l0.gtn(1),"modulus must be greater than 1"),this.m=l0,this.prime=null}b0.prototype._verify1=function(l0){Y(l0.negative===0,"red works only with positives"),Y(l0.red,"red works only with red numbers")},b0.prototype._verify2=function(l0,z){Y((l0.negative|z.negative)===0,"red works only with positives"),Y(l0.red&&l0.red===z.red,"red works only with red numbers")},b0.prototype.imod=function(l0){return this.prime?this.prime.ireduce(l0)._forceRed(this):l0.umod(this.m)._forceRed(this)},b0.prototype.neg=function(l0){return l0.isZero()?l0.clone():this.m.sub(l0)._forceRed(this)},b0.prototype.add=function(l0,z){this._verify2(l0,z);var o0=l0.add(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0._forceRed(this)},b0.prototype.iadd=function(l0,z){this._verify2(l0,z);var o0=l0.iadd(z);return o0.cmp(this.m)>=0&&o0.isub(this.m),o0},b0.prototype.sub=function(l0,z){this._verify2(l0,z);var o0=l0.sub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0._forceRed(this)},b0.prototype.isub=function(l0,z){this._verify2(l0,z);var o0=l0.isub(z);return o0.cmpn(0)<0&&o0.iadd(this.m),o0},b0.prototype.shl=function(l0,z){return this._verify1(l0),this.imod(l0.ushln(z))},b0.prototype.imul=function(l0,z){return this._verify2(l0,z),this.imod(l0.imul(z))},b0.prototype.mul=function(l0,z){return this._verify2(l0,z),this.imod(l0.mul(z))},b0.prototype.isqr=function(l0){return this.imul(l0,l0.clone())},b0.prototype.sqr=function(l0){return this.mul(l0,l0)},b0.prototype.sqrt=function(l0){if(l0.isZero())return l0.clone();var z=this.m.andln(3);if(Y(z%2===1),z===3){var o0=this.m.add(new Z(1)).iushrn(2);return this.pow(l0,o0)}for(var M=this.m.subn(1),u0=0;!M.isZero()&&M.andln(1)===0;)u0++,M.iushrn(1);Y(!M.isZero());var S=new Z(1).toRed(this),n0=S.redNeg(),v=this.m.subn(1).iushrn(1),s0=this.m.bitLength();for(s0=new Z(2*s0*s0).toRed(this);this.pow(s0,v).cmp(n0)!==0;)s0.redIAdd(n0);for(var I=this.pow(s0,M),t0=this.pow(l0,M.addn(1).iushrn(1)),m0=this.pow(l0,M),a0=u0;m0.cmp(S)!==0;){for(var q=m0,e0=0;q.cmp(S)!==0;e0++)q=q.redSqr();Y(e0=0;u0--){for(var I=z.words[u0],t0=s0-1;t0>=0;t0--){var m0=I>>t0&1;if(S!==M[0]&&(S=this.sqr(S)),m0===0&&n0===0){v=0;continue}n0<<=1,n0|=m0,v++,!(v!==o0&&(u0!==0||t0!==0))&&(S=this.mul(S,M[n0]),v=0,n0=0)}s0=26}return S},b0.prototype.convertTo=function(l0){var z=l0.umod(this.m);return z===l0?z.clone():z},b0.prototype.convertFrom=function(l0){var z=l0.clone();return z.red=null,z},Z.mont=function(l0){return new P(l0)};function P(l0){b0.call(this,l0),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new Z(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)}$(P,b0),P.prototype.convertTo=function(l0){return this.imod(l0.ushln(this.shift))},P.prototype.convertFrom=function(l0){var z=this.imod(l0.mul(this.rinv));return z.red=null,z},P.prototype.imul=function(l0,z){if(l0.isZero()||z.isZero())return l0.words[0]=0,l0.length=1,l0;var o0=l0.imul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.mul=function(l0,z){if(l0.isZero()||z.isZero())return new Z(0)._forceRed(this);var o0=l0.mul(z),M=o0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u0=o0.isub(M).iushrn(this.shift),S=u0;return u0.cmp(this.m)>=0?S=u0.isub(this.m):u0.cmpn(0)<0&&(S=u0.iadd(this.m)),S._forceRed(this)},P.prototype.invm=function(l0){var z=this.imod(l0._invmp(this.m).mul(this.r2));return z._forceRed(this)}})(typeof K>"u"||K,X)}}),{CryptoHasher:sY}=globalThis.Bun,tY=$Q({"node_modules/public-encrypt/withPublic.js"(X,K){var x0=nY(),G=YQ().Buffer;function Y($,Z){return G.from($.toRed(x0.mont(Z.modulus)).redPow(new x0(Z.publicExponent)).fromRed().toArray())}K.exports=Y}}),mY=$Q({"node_modules/public-encrypt/publicEncrypt.js"(X,K){var x0=pY(),G=ZQ(),Y=L0(),$=oY(),Z=uY(),Q=nY(),U=tY(),V=hQ(),B0=YQ().Buffer;K.exports=function(w0,E,p0){var T;w0.padding?T=w0.padding:p0?T=1:T=4;var f0=x0(w0),D;if(T===4)D=H(f0,E);else if(T===1)D=y0(f0,E,p0);else if(T===3){if(D=new Q(E),D.cmp(f0.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return p0?V(D,f0):U(D,f0)};function H(w0,E){var p0=w0.modulus.byteLength(),T=E.length,f0=Y("sha1").update(B0.alloc(0)).digest(),D=f0.length,c0=2*D;if(T>p0-c0-2)throw new Error("message too long");var C=B0.alloc(p0-T-c0-2),h0=p0-D-1,L=G(D),d0=Z(B0.concat([f0,C,B0.alloc(1,1),E],h0),$(L,h0)),R=Z(L,$(d0,D));return new Q(B0.concat([B0.alloc(1),R,d0],p0))}function y0(w0,E,p0){var T=E.length,f0=w0.modulus.byteLength();if(T>f0-11)throw new Error("message too long");var D;return p0?D=B0.alloc(f0-T-3,255):D=W(f0-T-3),new Q(B0.concat([B0.from([0,p0?1:2]),D,B0.alloc(1),E],f0))}function W(w0){for(var E=B0.allocUnsafe(w0),p0=0,T=G(w0*2),f0=0,D;p0f0||new $(w0).cmp(T.modulus)>=0)throw new Error("decryption error");var D;E?D=U(new $(w0),T):D=Z(w0,T);var c0=V.alloc(f0-D.length);if(D=V.concat([c0,D],f0),p0===4)return B0(T,D);if(p0===1)return H(T,D,E);if(p0===3)return D;throw new Error("unknown padding")};function B0(W,w0){var E=W.modulus.byteLength(),p0=Q("sha1").update(V.alloc(0)).digest(),T=p0.length;if(w0[0]!==0)throw new Error("decryption error");var f0=w0.slice(1,T+1),D=w0.slice(T+1),c0=Y(f0,G(D,T)),C=Y(D,G(c0,E-T-1));if(y0(p0,C.slice(0,T)))throw new Error("decryption error");for(var h0=T;C[h0]===0;)h0++;if(C[h0++]!==1)throw new Error("decryption error");return C.slice(h0)}function H(W,w0,E){for(var p0=w0.slice(0,2),T=2,f0=0;w0[T++]!==0;)if(T>=w0.length){f0++;break}var D=w0.slice(2,T-1);if((p0.toString("hex")!=="0002"&&!E||p0.toString("hex")!=="0001"&&E)&&f0++,D.length<8&&f0++,f0)throw new Error("decryption error");return w0.slice(T)}function y0(W,w0){W=V.from(W),w0=V.from(w0);var E=0,p0=W.length;W.length!==w0.length&&(E++,p0=Math.min(W.length,w0.length));for(var T=-1;++T$||H<0)throw new TypeError("offset must be a uint32");if(H>Y||H>y0)throw new RangeError("offset out of range")}function Q(H,y0,W){if(typeof H!="number"||H!==H)throw new TypeError("size must be a number");if(H>$||H<0)throw new TypeError("size must be a uint32");if(H+y0>W||H>Y)throw new RangeError("buffer too small")}X.randomFill=U,X.randomFillSync=B0;function U(H,y0,W,w0){if(!G.isBuffer(H)&&!(H instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof y0=="function")w0=y0,y0=0,W=H.length;else if(typeof W=="function")w0=W,W=H.length-y0;else if(typeof w0!="function")throw new TypeError('"cb" argument must be a function');return Z(y0,H.length),Q(W,y0,H.length),V(H,y0,W,w0)}function V(H,y0,W,w0){if(w0){x0(W,function(p0,T){if(p0)return w0(p0);T.copy(H,y0),w0(null,H)});return}var E=x0(W);return E.copy(H,y0),H}function B0(H,y0,W){if(typeof y0>"u"&&(y0=0),!G.isBuffer(H)&&!(H instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return Z(y0,H.length),W===void 0&&(W=H.length-y0),Q(W,y0,H.length),V(H,y0,W)}}}),iY=$Q({"node_modules/crypto-browserify/index.js"(X){X.randomBytes=X.rng=X.pseudoRandomBytes=X.prng=ZQ(),X.createHash=L0(),X.Hash=X.createHash.Hash,X.createHmac=X.Hmac=z0();var K=S0(),x0=Object.keys(K),G=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(x0);X.getHashes=function(){return G};var Y=g0();X.pbkdf2=Y.pbkdf2,X.pbkdf2Sync=Y.pbkdf2Sync;var $=gQ();X.Cipher=$.Cipher,X.createCipher=$.createCipher,X.Cipheriv=$.Cipheriv,X.createCipheriv=$.createCipheriv,X.Decipher=$.Decipher,X.createDecipher=$.createDecipher,X.Decipheriv=$.Decipheriv,X.createDecipheriv=$.createDecipheriv,X.getCiphers=$.getCiphers,X.listCiphers=$.listCiphers;var Z=fQ();X.DiffieHellmanGroup=Z.DiffieHellmanGroup,X.createDiffieHellmanGroup=Z.createDiffieHellmanGroup,X.getDiffieHellman=Z.getDiffieHellman,X.createDiffieHellman=Z.createDiffieHellman,X.DiffieHellman=Z.DiffieHellman;var Q=dY();X.createSign=Q.createSign,X.Sign=Q.Sign,X.createVerify=Q.createVerify,X.Verify=Q.Verify,X.createECDH=lY();var U=eY();X.publicEncrypt=U.publicEncrypt,X.privateEncrypt=U.privateEncrypt,X.publicDecrypt=U.publicDecrypt,X.privateDecrypt=U.privateDecrypt,X.getRandomValues=(B0)=>d$.getRandomValues(B0);var V=rY();X.randomFill=V.randomFill,X.randomFillSync=V.randomFillSync,X.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` -`))},X.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},o$="buffer",QZ=(X)=>d$.getRandomValues(X),YZ=()=>d$.randomUUID(),u$="timingSafeEqual"in d$?(X,K)=>{let{byteLength:x0}=X,{byteLength:G}=K;if(typeof x0!="number"||typeof G!="number")throw new TypeError("Input must be an array buffer view");if(x0!==G)throw new RangeError("Input buffers must have the same length");return d$.timingSafeEqual(X,K)}:void 0,ZZ="scryptSync"in d$?(X,K,x0,G)=>{let Y=d$.scryptSync(X,K,x0,G);return o$!=="buffer"?new c$(Y).toString(o$):new c$(Y)}:void 0,GZ="scryptSync"in d$?function(X,K,x0,G,Y){if(typeof G=="function"&&(Y=G,G=void 0),typeof Y!="function"){var $=new TypeError("callback must be a function");throw $.code="ERR_INVALID_CALLBACK",$}try{let Z=d$.scryptSync(X,K,x0,G);process.nextTick(Y,null,o$!=="buffer"?new c$(Z).toString(o$):new c$(Z))}catch(Z){throw Z}}:void 0;u$&&(Object.defineProperty(u$,"name",{value:"::bunternal::"}),Object.defineProperty(GZ,"name",{value:"::bunternal::"}),Object.defineProperty(ZZ,"name",{value:"::bunternal::"}));var n$=d$;QQ($Z,{DEFAULT_ENCODING:()=>o$,getRandomValues:()=>QZ,randomUUID:()=>YZ,scrypt:()=>GZ,scryptSync:()=>ZZ,timingSafeEqual:()=>u$,webcrypto:()=>n$,subtle:()=>n$.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{n$ as webcrypto,u$ 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,o$ as DEFAULT_ENCODING,DZ as Cipheriv,EZ 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(),ZZ=(...$)=>H$.randomInt(...$),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,GZ="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,VZ="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(VZ,"name",{value:"::bunternal::"}),Object.defineProperty(GZ,"name",{value:"::bunternal::"}));var C$=H$;j$($Z,{DEFAULT_ENCODING:()=>T$,getRandomValues:()=>QZ,randomUUID:()=>YZ,randomInt:()=>ZZ,scrypt:()=>VZ,scryptSync:()=>GZ,timingSafeEqual:()=>D$,webcrypto:()=>C$,subtle:()=>C$.subtle});var{randomBytes:UZ,rng:XZ,pseudoRandomBytes:KZ,prng:IZ,Hash:OZ,createHash:JZ,createHmac:FZ,Hmac:AZ,getHashes:HZ,pbkdf2:WZ,pbkdf2Sync:EZ,Cipher:TZ,createCipher:DZ,Cipheriv:CZ,createCipheriv:LZ,Decipher:RZ,createDecipher:PZ,Decipheriv:zZ,createDecipheriv:MZ,getCiphers:SZ,listCiphers:vZ,DiffieHellmanGroup:qZ,createDiffieHellmanGroup:jZ,getDiffieHellman:kZ,createDiffieHellman:gZ,DiffieHellman:_Z,createSign:NZ,Sign:xZ,createVerify:BZ,Verify:yZ,createECDH:wZ,publicEncrypt:pZ,privateEncrypt:fZ,publicDecrypt:cZ,privateDecrypt:hZ,randomFill:dZ,randomFillSync:bZ,createCredentials:lZ,constants:oZ}=$Z;var nZ=$Z;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{C$ as webcrypto,D$ as timingSafeEqual,GZ as scryptSync,VZ as scrypt,XZ as rng,YZ as randomUUID,bZ as randomFillSync,dZ as randomFill,UZ as randomBytes,pZ as publicEncrypt,cZ as publicDecrypt,KZ as pseudoRandomBytes,IZ as prng,fZ as privateEncrypt,hZ as privateDecrypt,EZ as pbkdf2Sync,WZ as pbkdf2,vZ as listCiphers,QZ as getRandomValues,HZ as getHashes,kZ as getDiffieHellman,SZ as getCiphers,nZ as default,BZ as createVerify,NZ as createSign,FZ as createHmac,JZ as createHash,wZ as createECDH,jZ as createDiffieHellmanGroup,gZ as createDiffieHellman,MZ as createDecipheriv,PZ as createDecipher,lZ as createCredentials,LZ as createCipheriv,DZ as createCipher,oZ as constants,yZ as Verify,xZ as Sign,AZ as Hmac,OZ as Hash,qZ as DiffieHellmanGroup,_Z as DiffieHellman,zZ as Decipheriv,RZ as Decipher,T$ as DEFAULT_ENCODING,CZ as Cipheriv,TZ as Cipher}; diff --git a/test/js/node/crypto/node-crypto.test.js b/test/js/node/crypto/node-crypto.test.js index 9e0e7f396..5a68540cf 100644 --- a/test/js/node/crypto/node-crypto.test.js +++ b/test/js/node/crypto/node-crypto.test.js @@ -8,6 +8,27 @@ it("crypto.randomBytes should return a Buffer", () => { expect(Buffer.isBuffer(crypto.randomBytes(1))).toBe(true); }); +it("crypto.randomInt should return a number", () => { + const result = crypto.randomInt(0, 10); + expect(typeof result).toBe("number"); + expect(result).toBeGreaterThanOrEqual(0); + expect(result).toBeLessThanOrEqual(10); +}); + +it("crypto.randomInt with no arguments", () => { + const result = crypto.randomInt(); + expect(typeof result).toBe("number"); + expect(result).toBeGreaterThanOrEqual(0); + expect(result).toBeLessThanOrEqual(Number.MAX_SAFE_INTEGER); +}); + +it("crypto.randomInt with one argument", () => { + const result = crypto.randomInt(100); + expect(typeof result).toBe("number"); + expect(result).toBeGreaterThanOrEqual(0); + expect(result).toBeLessThanOrEqual(100); +}); + // https://github.com/oven-sh/bun/issues/1839 describe("createHash", () => { it("update & digest", () => { -- cgit v1.2.3 From a5100ad380f099907d4b3a9bec696f481b8e7821 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 26 Jun 2023 15:49:14 -0700 Subject: Fix .rejects --- src/bun.js/test/expect.zig | 21 +++++++-------------- test/js/bun/test/expect.test.js | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/bun.js/test/expect.zig b/src/bun.js/test/expect.zig index 90fcb2a73..e0833f8ed 100644 --- a/src/bun.js/test/expect.zig +++ b/src/bun.js/test/expect.zig @@ -73,32 +73,25 @@ pub const Expect = struct { } pub fn getResolves(this: *Expect, thisValue: JSValue, globalThis: *JSGlobalObject) callconv(.C) JSValue { - switch (this.flags.promise) { + this.flags.promise = switch (this.flags.promise) { + .resolves, .none => .resolves, .rejects => { globalThis.throw("Cannot chain .resolves() after .rejects()", .{}); return .zero; }, - .resolves => {}, - .none => { - this.flags.promise = .resolves; - }, - } + }; + return thisValue; } pub fn getRejects(this: *Expect, thisValue: JSValue, globalThis: *JSGlobalObject) callconv(.C) JSValue { - switch (this.flags.promise) { - .rejects => { - this.flags.promise = .rejects; - }, + this.flags.promise = switch (this.flags.promise) { + .none, .rejects => .rejects, .resolves => { globalThis.throw("Cannot chain .rejects() after .resolves()", .{}); return .zero; }, - .none => { - this.flags.promise = .resolves; - }, - } + }; return thisValue; } diff --git a/test/js/bun/test/expect.test.js b/test/js/bun/test/expect.test.js index d42ec2219..e7195d6f8 100644 --- a/test/js/bun/test/expect.test.js +++ b/test/js/bun/test/expect.test.js @@ -6,6 +6,28 @@ var { isBun, test, describe, expect, jest, vi, mock, bunTest, spyOn } = require("./test-interop.js")(); describe("expect()", () => { + test("rejects", async () => { + await expect(Promise.reject(1)).rejects.toBe(1); + + // Different task + await expect( + new Promise((_, reject) => { + setTimeout(() => reject(1), 0); + }), + ).rejects.toBe(1); + }); + + test("resolves", async () => { + await expect(Promise.resolve(1)).resolves.toBe(1); + + // Different task + await expect( + new Promise(resolve => { + setTimeout(() => resolve(1), 0); + }), + ).resolves.toBe(1); + }); + test("can call without an argument", () => { expect().toBe(undefined); }); -- cgit v1.2.3 From 28f27f733b3db072944156694301651b09b7696b Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 26 Jun 2023 15:51:57 -0700 Subject: [bun install] Implement `--exact` flag (#3409) * [bun install] Implement `--exact` flag * Rename to --save-exact * Rename --exact to --save-exact * Update bun-add.test.ts * We're going with --exact as the flag name --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/api/schema.d.ts | 1 + src/api/schema.js | 10 ++++++++ src/api/schema.peechy | 1 + src/api/schema.zig | 10 ++++++++ src/bunfig.zig | 8 ++++++ src/install/install.zig | 53 +++++++++++++++++++++++++++++++++----- src/install/lockfile.zig | 32 +++++++++++++++++------ test/cli/install/bun-add.test.ts | 55 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 155 insertions(+), 15 deletions(-) diff --git a/src/api/schema.d.ts b/src/api/schema.d.ts index ac6183878..2a86340ad 100644 --- a/src/api/schema.d.ts +++ b/src/api/schema.d.ts @@ -710,6 +710,7 @@ export interface BunInstall { global_dir?: string; global_bin_dir?: string; frozen_lockfile?: boolean; + exact?: boolean; } export interface ClientServerModule { diff --git a/src/api/schema.js b/src/api/schema.js index 270eb9a62..f1e68031e 100644 --- a/src/api/schema.js +++ b/src/api/schema.js @@ -3048,6 +3048,10 @@ function decodeBunInstall(bb) { result["frozen_lockfile"] = !!bb.readByte(); break; + case 20: + result["exact"] = !!bb.readByte(); + break; + default: throw new Error("Attempted to parse invalid message"); } @@ -3174,6 +3178,12 @@ function encodeBunInstall(message, bb) { bb.writeByte(19); bb.writeByte(value); } + + var value = message["exact"]; + if (value != null) { + bb.writeByte(20); + bb.writeByte(value); + } bb.writeByte(0); } diff --git a/src/api/schema.peechy b/src/api/schema.peechy index 6d28381c4..a172606f7 100644 --- a/src/api/schema.peechy +++ b/src/api/schema.peechy @@ -591,6 +591,7 @@ message BunInstall { string global_dir = 17; string global_bin_dir = 18; bool frozen_lockfile = 19; + bool exact = 20; } struct ClientServerModule { diff --git a/src/api/schema.zig b/src/api/schema.zig index 2de80d42c..ec8efa9f6 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -2904,6 +2904,9 @@ pub const Api = struct { /// frozen_lockfile frozen_lockfile: ?bool = null, + /// exact + exact: ?bool = null, + pub fn decode(reader: anytype) anyerror!BunInstall { var this = std.mem.zeroes(BunInstall); @@ -2970,6 +2973,9 @@ pub const Api = struct { 19 => { this.frozen_lockfile = try reader.readValue(bool); }, + 20 => { + this.exact = try reader.readValue(bool); + }, else => { return error.InvalidMessage; }, @@ -3055,6 +3061,10 @@ pub const Api = struct { try writer.writeFieldID(19); try writer.writeInt(@as(u8, @intFromBool(frozen_lockfile))); } + if (this.exact) |exact| { + try writer.writeFieldID(20); + try writer.writeInt(@as(u8, @intFromBool(exact))); + } try writer.endMessage(); } }; diff --git a/src/bunfig.zig b/src/bunfig.zig index 597fb0985..1244f52b8 100644 --- a/src/bunfig.zig +++ b/src/bunfig.zig @@ -259,6 +259,14 @@ pub const Bunfig = struct { } } + if (json.get("exact")) |exact_install_expr| { + try this.expect(exact_install_expr, .e_boolean); + + if (exact_install_expr.asBool().?) { + install.exact = true; + } + } + if (json.get("prefer")) |prefer_expr| { try this.expect(prefer_expr, .e_string); diff --git a/src/install/install.zig b/src/install/install.zig index 22068bbf3..9465c4897 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -4461,6 +4461,10 @@ pub const PackageManager = struct { this.remote_package_features.peer_dependencies = save; } + if (bun_install.exact) |exact| { + this.enable.exact_versions = exact; + } + if (bun_install.production) |production| { if (production) { this.local_package_features.dev_dependencies = false; @@ -4569,6 +4573,10 @@ pub const PackageManager = struct { this.scope.url = URL.parse(cli.registry); } + if (cli.exact) { + this.enable.exact_versions = true; + } + if (cli.token.len > 0) { this.scope.token = cli.token; } @@ -4755,6 +4763,8 @@ pub const PackageManager = struct { force_save_lockfile: bool = false, force_install: bool = false, + + exact_versions: bool = false, }; }; @@ -4802,6 +4812,7 @@ pub const PackageManager = struct { updates: []UpdateRequest, current_package_json: *JSAst.Expr, dependency_list: string, + exact_versions: bool, ) !void { const G = JSAst.G; @@ -4989,9 +5000,14 @@ pub const PackageManager = struct { if (update.e_string) |e_string| { e_string.data = switch (update.resolution.tag) { .npm => if (update.version.tag == .dist_tag and update.version.literal.isEmpty()) - std.fmt.allocPrint(allocator, "^{}", .{ - update.resolution.value.npm.version.fmt(update.version_buf), - }) catch unreachable + switch (exact_versions) { + false => std.fmt.allocPrint(allocator, "^{}", .{ + update.resolution.value.npm.version.fmt(update.version_buf), + }) catch unreachable, + true => std.fmt.allocPrint(allocator, "{}", .{ + update.resolution.value.npm.version.fmt(update.version_buf), + }) catch unreachable, + } else null, .uninitialized => switch (update.version.tag) { @@ -5709,6 +5725,7 @@ pub const PackageManager = struct { const add_params = install_params_ ++ [_]ParamType{ clap.parseParam("-d, --development Add dependency to \"devDependencies\"") catch unreachable, clap.parseParam("--optional Add dependency to \"optionalDependencies\"") catch unreachable, + clap.parseParam("--exact Add the exact version instead of the ^range") catch unreachable, clap.parseParam(" ... \"name\" or \"name@version\" of packages to install") catch unreachable, }; @@ -5759,6 +5776,8 @@ pub const PackageManager = struct { no_optional: bool = false, omit: Omit = Omit{}, + exact: bool = false, + const Omit = struct { dev: bool = false, optional: bool = true, @@ -5837,6 +5856,7 @@ pub const PackageManager = struct { if (comptime subcommand == .add) { cli.development = args.flag("--development"); cli.optional = args.flag("--optional"); + cli.exact = args.flag("--exact"); } // for (args.options("--omit")) |omit| { @@ -6293,7 +6313,13 @@ pub const PackageManager = struct { manager.to_remove = updates; }, .link, .add, .update => { - try PackageJSONEditor.edit(ctx.allocator, updates, ¤t_package_json, dependency_list); + try PackageJSONEditor.edit( + ctx.allocator, + updates, + ¤t_package_json, + dependency_list, + manager.options.enable.exact_versions, + ); manager.package_json_updates = updates; }, else => {}, @@ -6346,7 +6372,13 @@ pub const PackageManager = struct { return; }; - try PackageJSONEditor.edit(ctx.allocator, updates, ¤t_package_json, dependency_list); + try PackageJSONEditor.edit( + ctx.allocator, + updates, + ¤t_package_json, + dependency_list, + manager.options.enable.exact_versions, + ); var buffer_writer_two = try JSPrinter.BufferWriter.init(ctx.allocator); try buffer_writer_two.buffer.list.ensureTotalCapacity(ctx.allocator, new_package_json_source.len + 1); buffer_writer_two.append_newline = @@ -7031,7 +7063,10 @@ pub const PackageManager = struct { ) !PackageInstall.Summary { var lockfile = lockfile_; if (!this.options.local_package_features.dev_dependencies) { - lockfile = try lockfile.maybeCloneFilteringRootPackages(this.options.local_package_features); + lockfile = try lockfile.maybeCloneFilteringRootPackages( + this.options.local_package_features, + this.options.enable.exact_versions, + ); } var root_node: *Progress.Node = undefined; @@ -7582,7 +7617,11 @@ pub const PackageManager = struct { const needs_clean_lockfile = had_any_diffs or needs_new_lockfile or manager.package_json_updates.len > 0; var did_meta_hash_change = needs_clean_lockfile; if (needs_clean_lockfile) { - manager.lockfile = try manager.lockfile.cleanWithLogger(manager.package_json_updates, manager.log); + manager.lockfile = try manager.lockfile.cleanWithLogger( + manager.package_json_updates, + manager.log, + manager.options.enable.exact_versions, + ); } if (manager.lockfile.packages.len > 0) { diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index a51d2b2ee..7d21860ef 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -538,6 +538,7 @@ pub const Tree = struct { pub fn maybeCloneFilteringRootPackages( old: *Lockfile, features: Features, + exact_versions: bool, ) !*Lockfile { const old_root_dependenices_list = old.packages.items(.dependencies)[0]; var old_root_resolutions = old.packages.items(.resolutions)[0]; @@ -555,10 +556,10 @@ pub fn maybeCloneFilteringRootPackages( if (!any_changes) return old; - return try old.clean(&.{}); + return try old.clean(&.{}, exact_versions); } -fn preprocessUpdateRequests(old: *Lockfile, updates: []PackageManager.UpdateRequest) !void { +fn preprocessUpdateRequests(old: *Lockfile, updates: []PackageManager.UpdateRequest, exact_versions: bool) !void { const root_deps_list: Lockfile.DependencySlice = old.packages.items(.dependencies)[0]; if (@as(usize, root_deps_list.off) < old.buffers.dependencies.items.len) { var string_builder = old.stringBuilder(); @@ -575,7 +576,10 @@ fn preprocessUpdateRequests(old: *Lockfile, updates: []PackageManager.UpdateRequ if (dep.name_hash == String.Builder.stringHash(update.name)) { if (old_resolution > old.packages.len) continue; const res = resolutions_of_yore[old_resolution]; - const len = std.fmt.count("^{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)}); + const len = switch (exact_versions) { + false => std.fmt.count("^{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)}), + true => std.fmt.count("{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)}), + }; if (len >= String.max_inline_len) { string_builder.cap += len; } @@ -603,7 +607,10 @@ fn preprocessUpdateRequests(old: *Lockfile, updates: []PackageManager.UpdateRequ if (dep.name_hash == String.Builder.stringHash(update.name)) { if (old_resolution > old.packages.len) continue; const res = resolutions_of_yore[old_resolution]; - var buf = std.fmt.bufPrint(&temp_buf, "^{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)}) catch break; + var buf = switch (exact_versions) { + false => std.fmt.bufPrint(&temp_buf, "^{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)}) catch break, + true => std.fmt.bufPrint(&temp_buf, "{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)}) catch break, + }; const external_version = string_builder.append(ExternalString, buf); const sliced = external_version.value.sliced(old.buffers.string_bytes.items); dep.version = Dependency.parse( @@ -622,7 +629,11 @@ fn preprocessUpdateRequests(old: *Lockfile, updates: []PackageManager.UpdateRequ } } } -pub fn clean(old: *Lockfile, updates: []PackageManager.UpdateRequest) !*Lockfile { +pub fn clean( + old: *Lockfile, + updates: []PackageManager.UpdateRequest, + exact_versions: bool, +) !*Lockfile { // This is wasteful, but we rarely log anything so it's fine. var log = logger.Log.init(bun.default_allocator); defer { @@ -632,17 +643,22 @@ pub fn clean(old: *Lockfile, updates: []PackageManager.UpdateRequest) !*Lockfile log.deinit(); } - return old.cleanWithLogger(updates, &log); + return old.cleanWithLogger(updates, &log, exact_versions); } -pub fn cleanWithLogger(old: *Lockfile, updates: []PackageManager.UpdateRequest, log: *logger.Log) !*Lockfile { +pub fn cleanWithLogger( + old: *Lockfile, + updates: []PackageManager.UpdateRequest, + log: *logger.Log, + exact_versions: bool, +) !*Lockfile { const old_trusted_dependencies = old.trusted_dependencies; const old_scripts = old.scripts; // We will only shrink the number of packages here. // never grow if (updates.len > 0) { - try old.preprocessUpdateRequests(updates); + try old.preprocessUpdateRequests(updates, exact_versions); } // Deduplication works like this diff --git a/test/cli/install/bun-add.test.ts b/test/cli/install/bun-add.test.ts index 79804f0e0..9dd38c8cd 100644 --- a/test/cli/install/bun-add.test.ts +++ b/test/cli/install/bun-add.test.ts @@ -303,6 +303,61 @@ it("should add dependency with capital letters", async () => { await access(join(package_dir, "bun.lockb")); }); +it("should add exact version", async () => { + const urls: string[] = []; + setHandler(dummyRegistry(urls)); + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ + name: "foo", + version: "0.0.1", + }), + ); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "add", "--exact", "BaR"], + cwd: package_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toContain("Saved lockfile"); + expect(stdout).toBeDefined(); + const out = await new Response(stdout).text(); + expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ + "", + " installed BaR@0.0.2", + "", + "", + " 1 packages installed", + ]); + expect(await exited).toBe(0); + expect(urls.sort()).toEqual([`${root_url}/BaR`, `${root_url}/BaR-0.0.2.tgz`]); + expect(requested).toBe(2); + expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "BaR"]); + expect(await readdirSorted(join(package_dir, "node_modules", "BaR"))).toEqual(["package.json"]); + expect(await file(join(package_dir, "node_modules", "BaR", "package.json")).json()).toEqual({ + name: "bar", + version: "0.0.2", + }); + expect(await file(join(package_dir, "package.json")).text()).toEqual( + JSON.stringify( + { + name: "foo", + version: "0.0.1", + dependencies: { + BaR: "0.0.2", + }, + }, + null, + 2, + ), + ); + await access(join(package_dir, "bun.lockb")); +}); + it("should add dependency with specified semver", async () => { const urls: string[] = []; setHandler( -- cgit v1.2.3 From 7a0b1656c735ea634a7e27cb6f73254cc4411a91 Mon Sep 17 00:00:00 2001 From: Peter Weinberg Date: Mon, 26 Jun 2023 21:25:33 -0400 Subject: docs: add troubleshooting section to installation page (#3389) * docs: add troubleshooting section to installation page * Add note for unzip * Update msg in install.sh --------- Co-authored-by: Colin McDonnell --- docs/installation.md | 12 ++++++------ src/cli/install.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 06ca2b34d..9fce0b511 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -3,17 +3,17 @@ Bun ships as a single executable that can be installed a few different ways. {% callout %} **Windows users** — Bun does not currently provide a native Windows build. We're working on this; progress can be tracked at [this issue](https://github.com/oven-sh/bun/issues/43). In the meantime, use one of the installation methods below for Windows Subsystem for Linux. -**Linux users** — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. +**Linux users** — The `unzip` package is required to install Bun. Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. {% /callout %} {% codetabs %} -```bash#Native -$ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL +```bash#NPM +$ npm install -g bun # the last `npm` command you'll ever need ``` -```bash#npm -$ npm install -g bun # the last `npm` command you'll ever need +```bash#Native +$ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL ``` ```bash#Homebrew @@ -26,7 +26,7 @@ $ docker pull oven/bun $ docker run --rm --init --ulimit memlock=-1:-1 oven/bun ``` -```bash#proto +```bash#Proto $ proto install bun ``` diff --git a/src/cli/install.sh b/src/cli/install.sh index ffb70b6cb..782e8592e 100644 --- a/src/cli/install.sh +++ b/src/cli/install.sh @@ -50,7 +50,7 @@ success() { } command -v unzip >/dev/null || - error 'unzip is required to install bun (see: https://bun.sh/docs/installation)' + error 'unzip is required to install bun' if [[ $# -gt 2 ]]; then error 'Too many arguments, only 2 are allowed. The first can be a specific tag of bun to install. (e.g. "bun-v0.1.4") The second can be a build variant of bun to install. (e.g. "debug-info")' -- cgit v1.2.3 From 1ed1723a2f2891ebaf5101c0251f49a16ad3e3a1 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:00:55 -0700 Subject: Update bundle_v2.zig (#3420) --- src/bundler/bundle_v2.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 231a4bde8..aa7c40599 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -1617,8 +1617,8 @@ pub const BundleV2 = struct { bundler.resolver.generation = generation; bundler.options.code_splitting = config.code_splitting; - try bundler.configureDefines(); bundler.configureLinker(); + try bundler.configureDefines(); bundler.resolver.opts = bundler.options; -- cgit v1.2.3 From 1e6a41b5cfb405c8550969688a51aa702c5cec1a Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 26 Jun 2023 16:08:46 -0700 Subject: change the text from "error" to "warn" --- src/bun.js/bindings/Process.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index a369faee2..6320deaf1 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -560,26 +560,28 @@ JSC_DEFINE_HOST_FUNCTION(Process_emitWarning, (JSGlobalObject * lexicalGlobalObj auto* process = jsCast(globalObject->processObject()); - auto getError = [&]() -> JSValue { + JSObject* errorInstance = ([&]() -> JSObject* { JSValue arg0 = callFrame->uncheckedArgument(0); if (!arg0.isEmpty() && arg0.isCell() && arg0.asCell()->type() == ErrorInstanceType) { - return arg0; + return arg0.getObject(); } WTF::String str = arg0.toWTFString(globalObject); return createError(globalObject, str); - }; + })(); + + errorInstance->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, String("warn"_s)), JSC::PropertyAttribute::DontEnum | 0); auto ident = Identifier::fromString(vm, "warning"_s); if (process->wrapped().hasEventListeners(ident)) { JSC::MarkedArgumentBuffer args; - args.append(getError()); + args.append(errorInstance); process->wrapped().emit(ident, args); return JSValue::encode(jsUndefined()); } - auto jsArgs = JSValue::encode(getError()); + auto jsArgs = JSValue::encode(errorInstance); Zig__ConsoleClient__messageWithTypeAndLevel(reinterpret_cast(globalObject->consoleClient().get())->m_client, static_cast(MessageType::Log), static_cast(MessageLevel::Warning), globalObject, &jsArgs, 1); return JSValue::encode(jsUndefined()); -- cgit v1.2.3 From f839cf1ce309959f168066e51edc2e8b0038728e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:07:00 -0700 Subject: Update crypto.mjs --- bench/snippets/crypto.mjs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bench/snippets/crypto.mjs b/bench/snippets/crypto.mjs index e8e6f2f8a..484a4295d 100644 --- a/bench/snippets/crypto.mjs +++ b/bench/snippets/crypto.mjs @@ -1,12 +1,6 @@ // so it can run in environments without node module resolution import { bench, run } from "../node_modules/mitata/src/cli.mjs"; - -var crypto = globalThis.crypto; - -if (!crypto) { - crypto = await import("node:crypto"); -} - +import crypto from "node:crypto"; var foo = new Uint8Array(65536); bench("crypto.getRandomValues(65536)", () => { crypto.getRandomValues(foo); @@ -23,7 +17,7 @@ bench("crypto.randomUUID()", () => { }); bench("crypto.randomInt()", () => { - return crypto.randomInt(); + return crypto.randomInt(0, 100); }); await run(); -- cgit v1.2.3 From 4be15cff026eed36762b955003ce805a59d8f6a7 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:07:25 -0700 Subject: Tweak the ramSize setting because /= 1024 is causing CI to fail on arm64 when there's only 8 GB of ram --- src/bun.js/bindings/ZigGlobalObject.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 38d5fb1d6..b27e0aafc 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -280,7 +280,13 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c // crypto.createHash("sha1") 985.26 ns/iter (956.7 ns … 1.12 µs) 1 µs 1.12 µs 1.12 µs // Peak memory usage: 56 MB size_t ramSize = WTF::ramSize(); - ramSize /= 1024; + + // We originally went with a hardcoded /= 1024 here + // But if you don't have much memory, that becomes a problem. + // Instead, we do 65% + double ramSizeDouble = static_cast(ramSize); + ramSizeDouble *= 0.65; + ramSize = static_cast(ramSizeDouble); if (ramSize > 0) { JSC::Options::forceRAMSize() = ramSize; -- cgit v1.2.3 From 4e4cae0fc308c448fb73d59228fb30bd994453ed Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:16:59 -0700 Subject: webpack test and add empty `prototype` prop to module (#3421) --- src/bun.js/modules/NodeModuleModule.cpp | 9 ++++++--- test/js/third_party/webpack/package.json | 7 +++++++ test/js/third_party/webpack/test.js | 11 +++++++++++ test/js/third_party/webpack/webpack.test.ts | 27 +++++++++++++++++++++++++++ test/js/third_party/webpack/world.js | 3 +++ test/package.json | 4 +++- 6 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 test/js/third_party/webpack/package.json create mode 100644 test/js/third_party/webpack/test.js create mode 100644 test/js/third_party/webpack/webpack.test.ts create mode 100644 test/js/third_party/webpack/world.js diff --git a/src/bun.js/modules/NodeModuleModule.cpp b/src/bun.js/modules/NodeModuleModule.cpp index 34d45698f..88e08a3ac 100644 --- a/src/bun.js/modules/NodeModuleModule.cpp +++ b/src/bun.js/modules/NodeModuleModule.cpp @@ -142,10 +142,10 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, exportValues.append( jsCast(globalObject)->lazyRequireCacheObject()); - exportNames.append(JSC::Identifier::fromString(vm, "builtinModules"_s)); + exportNames.append(JSC::Identifier::fromString(vm, "prototype"_s)); + exportValues.append(constructEmptyObject(globalObject)); - exportNames.append(JSC::Identifier::fromString(vm, "globalPaths"_s)); - exportValues.append(JSC::constructEmptyArray(globalObject, 0)); + exportNames.append(JSC::Identifier::fromString(vm, "builtinModules"_s)); JSC::JSArray *builtinModules = JSC::JSArray::create( vm, @@ -167,5 +167,8 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, builtinModules->putDirectIndex(globalObject, 6, JSC::jsString(vm, String("bun:sqlite"_s))); exportValues.append(builtinModules); + + exportNames.append(JSC::Identifier::fromString(vm, "globalPaths"_s)); + exportValues.append(JSC::constructEmptyArray(globalObject, 0)); } } // namespace Zig diff --git a/test/js/third_party/webpack/package.json b/test/js/third_party/webpack/package.json new file mode 100644 index 000000000..fb08bfdc5 --- /dev/null +++ b/test/js/third_party/webpack/package.json @@ -0,0 +1,7 @@ +{ + "name": "webpack-test", + "version": "2.0.0", + "dependencies": { + "webpack": "5.88.0" + } +} \ No newline at end of file diff --git a/test/js/third_party/webpack/test.js b/test/js/third_party/webpack/test.js new file mode 100644 index 000000000..bfd3e80a1 --- /dev/null +++ b/test/js/third_party/webpack/test.js @@ -0,0 +1,11 @@ +import { world } from "./world.js"; + +function component() { + const element = document.createElement("div"); + + element.innerHTML = "hello " + world(); + + return element; +} + +document.body.appendChild(component()); diff --git a/test/js/third_party/webpack/webpack.test.ts b/test/js/third_party/webpack/webpack.test.ts new file mode 100644 index 000000000..ffc8195c6 --- /dev/null +++ b/test/js/third_party/webpack/webpack.test.ts @@ -0,0 +1,27 @@ +import { bunExe, bunEnv } from "harness"; +import { existsSync, rmdirSync } from "fs"; +import { join } from "path"; + +afterEach(() => { + rmdirSync(join(import.meta.dir, "dist"), { recursive: true }); +}); + +test("webpack works", () => { + Bun.spawnSync({ + cmd: [bunExe(), "-b", "webpack", "--entry", "./test.js", "-o", "./dist/test1/main.js"], + cwd: import.meta.dir, + env: bunEnv, + }); + + expect(existsSync(join(import.meta.dir, "dist", "test1/main.js"))).toBe(true); +}); + +test("webpack --watch works", async () => { + Bun.spawnSync({ + cmd: ["timeout", "3", bunExe(), "-b", "webpack", "--entry", "./test.js", "-o", "./dist/test2/main.js", "--watch"], + cwd: import.meta.dir, + env: bunEnv, + }); + + expect(existsSync(join(import.meta.dir, "dist", "test2/main.js"))).toBe(true); +}); diff --git a/test/js/third_party/webpack/world.js b/test/js/third_party/webpack/world.js new file mode 100644 index 000000000..3fa21bf67 --- /dev/null +++ b/test/js/third_party/webpack/world.js @@ -0,0 +1,3 @@ +export function world() { + return "world"; +} diff --git a/test/package.json b/test/package.json index b9aa55ae2..d4246ea43 100644 --- a/test/package.json +++ b/test/package.json @@ -23,7 +23,9 @@ "svelte": "^3.55.1", "typescript": "^5.0.2", "undici": "^5.20.0", - "vitest": "^0.32.2" + "vitest": "^0.32.2", + "webpack": "5.88.0", + "webpack-cli": "4.7.2" }, "private": true, "scripts": { -- cgit v1.2.3 From ecb0bd39b6f7a0a69f0b92ddedc0af5d0e88e945 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Mon, 26 Jun 2023 22:27:12 -0400 Subject: fix #3412 (#3422) --- src/bun.js/bindings/JSMockFunction.cpp | 12 ++++++++---- test/js/bun/test/mock-fn.test.js | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/bun.js/bindings/JSMockFunction.cpp b/src/bun.js/bindings/JSMockFunction.cpp index fbfcf0c9e..33922c2b7 100644 --- a/src/bun.js/bindings/JSMockFunction.cpp +++ b/src/bun.js/bindings/JSMockFunction.cpp @@ -569,15 +569,19 @@ extern "C" EncodedJSValue JSMock__jsSpyOn(JSC::JSGlobalObject* lexicalGlobalObje // easymode: regular property or missing property if (!hasValue || slot.isValue()) { + JSValue value = jsUndefined(); + if (hasValue) { + value = slot.getValue(globalObject, propertyKey); + if (jsDynamicCast(value)) { + return JSValue::encode(value); + } + } + auto* mock = JSMockFunction::create(vm, globalObject, globalObject->mockModule.mockFunctionStructure.getInitializedOnMainThread(globalObject), CallbackKind::GetterSetter); mock->spyTarget = JSC::Weak(object, &weakValueHandleOwner(), nullptr); mock->spyIdentifier = propertyKey.isSymbol() ? Identifier::fromUid(vm, propertyKey.uid()) : Identifier::fromString(vm, propertyKey.publicName()); mock->spyAttributes = hasValue ? slot.attributes() : 0; unsigned attributes = 0; - JSValue value = jsUndefined(); - - if (hasValue) - value = slot.getValue(globalObject, propertyKey); if (hasValue && ((slot.attributes() & PropertyAttribute::Function) != 0 || (value.isCell() && value.isCallable()))) { if (hasValue) diff --git a/test/js/bun/test/mock-fn.test.js b/test/js/bun/test/mock-fn.test.js index 8504e3d70..ef3c4b7d3 100644 --- a/test/js/bun/test/mock-fn.test.js +++ b/test/js/bun/test/mock-fn.test.js @@ -603,5 +603,19 @@ describe("spyOn", () => { }); } + test("spyOn twice works", () => { + var obj = { + original() { + return 42; + }, + }; + const _original = obj.original; + const fn = spyOn(obj, "original"); + const fn2 = spyOn(obj, "original"); + expect(fn).toBe(obj.original); + expect(fn2).toBe(fn); + expect(fn).not.toBe(_original); + }); + // spyOn does not work with getters/setters yet. }); -- cgit v1.2.3 From c96f3b303b07312d320f3f07299aac0f93d4640f Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 26 Jun 2023 20:37:09 -0700 Subject: Fix default export of `"module"` module --- src/bun.js/modules/NodeModuleModule.cpp | 102 ++++++++++++++----------- test/js/node/module/node-module-module.test.js | 5 ++ 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/src/bun.js/modules/NodeModuleModule.cpp b/src/bun.js/modules/NodeModuleModule.cpp index 88e08a3ac..10853ae32 100644 --- a/src/bun.js/modules/NodeModuleModule.cpp +++ b/src/bun.js/modules/NodeModuleModule.cpp @@ -103,49 +103,53 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, JSC::MarkedArgumentBuffer &exportValues) { JSC::VM &vm = globalObject->vm(); - exportValues.append(JSFunction::create( - vm, globalObject, 1, String("createRequire"_s), - jsFunctionNodeModuleCreateRequire, ImplementationVisibility::Public)); - exportValues.append(JSFunction::create(vm, globalObject, 1, String("paths"_s), - Resolver__nodeModulePathsForJS, - ImplementationVisibility::Public)); - exportValues.append(JSFunction::create( - vm, globalObject, 1, String("findSourceMap"_s), jsFunctionFindSourceMap, - ImplementationVisibility::Public)); - exportValues.append(JSFunction::create( - vm, globalObject, 0, String("syncBuiltinExports"_s), - jsFunctionSyncBuiltinExports, ImplementationVisibility::Public)); - exportValues.append( - JSFunction::create(vm, globalObject, 1, String("SourceMap"_s), - jsFunctionSourceMap, ImplementationVisibility::Public, - NoIntrinsic, jsFunctionSourceMap, nullptr)); - - exportNames.append(JSC::Identifier::fromString(vm, "createRequire"_s)); - exportNames.append(JSC::Identifier::fromString(vm, "paths"_s)); - exportNames.append(JSC::Identifier::fromString(vm, "findSourceMap"_s)); - exportNames.append(JSC::Identifier::fromString(vm, "syncBuiltinExports"_s)); - exportNames.append(JSC::Identifier::fromString(vm, "SourceMap"_s)); - - // note: this is not technically correct - // it doesn't set process.mainModule - exportNames.append(JSC::Identifier::fromString(vm, "_resolveFileName"_s)); - exportValues.append(JSFunction::create( - vm, globalObject, 3, String("_resolveFileName"_s), - jsFunctionResolveFileName, ImplementationVisibility::Public)); - - exportNames.append(JSC::Identifier::fromString(vm, "_nodeModulePaths"_s)); - exportValues.append(JSFunction::create( - vm, globalObject, 0, String("_nodeModulePaths"_s), - Resolver__nodeModulePathsForJS, ImplementationVisibility::Public)); - - exportNames.append(JSC::Identifier::fromString(vm, "_cache"_s)); - exportValues.append( - jsCast(globalObject)->lazyRequireCacheObject()); - - exportNames.append(JSC::Identifier::fromString(vm, "prototype"_s)); - exportValues.append(constructEmptyObject(globalObject)); - - exportNames.append(JSC::Identifier::fromString(vm, "builtinModules"_s)); + JSObject *defaultObject = JSC::constructEmptyObject( + vm, globalObject->nullPrototypeObjectStructure()); + auto append = [&](Identifier name, JSValue value) { + defaultObject->putDirect(vm, name, value); + exportNames.append(name); + exportValues.append(value); + }; + + append(Identifier::fromString(vm, "createRequire"_s), + JSFunction::create(vm, globalObject, 1, String("createRequire"_s), + jsFunctionNodeModuleCreateRequire, + ImplementationVisibility::Public)); + + append(Identifier::fromString(vm, "paths"_s), + JSFunction::create(vm, globalObject, 1, String("paths"_s), + Resolver__nodeModulePathsForJS, + ImplementationVisibility::Public)); + + append(Identifier::fromString(vm, "findSourceMap"_s), + JSFunction::create(vm, globalObject, 1, String("findSourceMap"_s), + jsFunctionFindSourceMap, + ImplementationVisibility::Public)); + append(Identifier::fromString(vm, "syncBuiltinExports"_s), + JSFunction::create(vm, globalObject, 0, String("syncBuiltinExports"_s), + jsFunctionSyncBuiltinExports, + ImplementationVisibility::Public)); + append(Identifier::fromString(vm, "SourceMap"_s), + JSFunction::create(vm, globalObject, 1, String("SourceMap"_s), + jsFunctionSourceMap, + ImplementationVisibility::Public, NoIntrinsic, + jsFunctionSourceMap, nullptr)); + + append(JSC::Identifier::fromString(vm, "_resolveFileName"_s), + JSFunction::create(vm, globalObject, 3, String("_resolveFileName"_s), + jsFunctionResolveFileName, + ImplementationVisibility::Public)); + + append(JSC::Identifier::fromString(vm, "_nodeModulePaths"_s), + JSFunction::create(vm, globalObject, 0, String("_nodeModulePaths"_s), + Resolver__nodeModulePathsForJS, + ImplementationVisibility::Public)); + + append(JSC::Identifier::fromString(vm, "_cache"_s), + jsCast(globalObject)->lazyRequireCacheObject()); + + append(JSC::Identifier::fromString(vm, "globalPaths"_s), + JSC::constructEmptyArray(globalObject, nullptr, 0)); JSC::JSArray *builtinModules = JSC::JSArray::create( vm, @@ -166,9 +170,15 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, JSC::jsString(vm, String("bun:ffi"_s))); builtinModules->putDirectIndex(globalObject, 6, JSC::jsString(vm, String("bun:sqlite"_s))); - exportValues.append(builtinModules); - exportNames.append(JSC::Identifier::fromString(vm, "globalPaths"_s)); - exportValues.append(JSC::constructEmptyArray(globalObject, 0)); + append(JSC::Identifier::fromString(vm, "builtinModules"_s), builtinModules); + + defaultObject->putDirect(vm, + JSC::PropertyName(Identifier::fromUid( + vm.symbolRegistry().symbolForKey("CommonJS"_s))), + jsNumber(0), 0); + + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(defaultObject); } } // namespace Zig diff --git a/test/js/node/module/node-module-module.test.js b/test/js/node/module/node-module-module.test.js index 3ced63da1..434bac829 100644 --- a/test/js/node/module/node-module-module.test.js +++ b/test/js/node/module/node-module-module.test.js @@ -1,10 +1,15 @@ import { expect, test } from "bun:test"; import { _nodeModulePaths } from "module"; +import Module from "module"; test("module.globalPaths exists", () => { expect(Array.isArray(require("module").globalPaths)).toBe(true); }); +test("Module exists", () => { + expect(Module).toBeDefined(); +}); + test("_nodeModulePaths() works", () => { expect(() => { _nodeModulePaths(); -- cgit v1.2.3 From b305309e64900cc720e859eb4bc7123bc24668cb Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 27 Jun 2023 14:05:59 +0300 Subject: minor build diffs (#3427) --- src/js/out/modules/node/assert.js | 84 ++++++++++++++-------------- src/js/out/modules/node/fs.promises.js | 2 +- src/js/out/modules/node/path.js | 2 +- src/js/out/modules/node/path.posix.js | 2 +- src/js/out/modules/node/stream.consumers.js | 2 +- src/js/out/modules/node/stream.js | 4 +- test/bun.lockb | Bin 95035 -> 140423 bytes 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/js/out/modules/node/assert.js b/src/js/out/modules/node/assert.js index bdaa04547..dbcaf0a02 100644 --- a/src/js/out/modules/node/assert.js +++ b/src/js/out/modules/node/assert.js @@ -1,53 +1,53 @@ -import U1 from"node:util";var w1=function(){throw new Error("CallTracker is not supported yet")},{Bun:K1}=globalThis[Symbol.for("Bun.lazy")]("primordials"),X1=K1.deepEquals,Y1=(b1,Z)=>function(){return Z||(0,b1[Object.keys(b1)[0]])((Z={exports:{}}).exports,Z),Z.exports},B1=Y1({"assert/build/internal/errors.js"(b1,Z){function J(T){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?J=function(w){return typeof w}:J=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},J(T)}function z(T,w){if(!(T instanceof w))throw new TypeError("Cannot call a class as a function")}function X(T,w){return w&&(J(w)==="object"||typeof w=="function")?w:U(T)}function U(T){if(T===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return T}function $(T){return $=Object.setPrototypeOf?Object.getPrototypeOf:function(w){return w.__proto__||Object.getPrototypeOf(w)},$(T)}function K(T,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");T.prototype=Object.create(w&&w.prototype,{constructor:{value:T,writable:!0,configurable:!0}}),w&&W(T,w)}function W(T,w){return W=Object.setPrototypeOf||function(O,F){return O.__proto__=F,O},W(T,w)}var Y={},B,V;function D(T,w,O){O||(O=Error);function F(I,P,A){return typeof w=="string"?w:w(I,P,A)}var N=function(I){K(P,I);function P(A,S,j){var R;return z(this,P),R=X(this,$(P).call(this,F(A,S,j))),R.code=T,R}return P}(O);Y[T]=N}function M(T,w){if(Array.isArray(T)){var O=T.length;return T=T.map(function(F){return String(F)}),O>2?"one of ".concat(w," ").concat(T.slice(0,O-1).join(", "),", or ")+T[O-1]:O===2?"one of ".concat(w," ").concat(T[0]," or ").concat(T[1]):"of ".concat(w," ").concat(T[0])}else return"of ".concat(w," ").concat(String(T))}function q(T,w,O){return T.substr(!O||O<0?0:+O,w.length)===w}function v(T,w,O){return(O===void 0||O>T.length)&&(O=T.length),T.substring(O-w.length,O)===w}function G(T,w,O){return typeof O!="number"&&(O=0),O+w.length>T.length?!1:T.indexOf(w,O)!==-1}D("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),D("ERR_INVALID_ARG_TYPE",function(T,w,O){B===void 0&&(B=$1()),B(typeof T=="string","'name' must be a string");var F;typeof w=="string"&&q(w,"not ")?(F="must not be",w=w.replace(/^not /,"")):F="must be";var N;if(v(T," argument"))N="The ".concat(T," ").concat(F," ").concat(M(w,"type"));else{var I=G(T,".")?"property":"argument";N='The "'.concat(T,'" ').concat(I," ").concat(F," ").concat(M(w,"type"))}return N+=". Received type ".concat(J(O)),N},TypeError),D("ERR_INVALID_ARG_VALUE",function(T,w){var O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid",F=V.inspect(w);return F.length>128&&(F="".concat(F.slice(0,128),"...")),"The argument '".concat(T,"' ").concat(O,". Received ").concat(F)},TypeError,RangeError),D("ERR_INVALID_RETURN_VALUE",function(T,w,O){var F;return O&&O.constructor&&O.constructor.name?F="instance of ".concat(O.constructor.name):F="type ".concat(J(O)),"Expected ".concat(T,' to be returned from the "').concat(w,'"')+" function but got ".concat(F,".")},TypeError),D("ERR_MISSING_ARGS",function(){for(var T=arguments.length,w=new Array(T),O=0;O0,"At least one arg needs to be specified");var F="The ",N=w.length;switch(w=w.map(function(I){return'"'.concat(I,'"')}),N){case 1:F+="".concat(w[0]," argument");break;case 2:F+="".concat(w[0]," and ").concat(w[1]," arguments");break;default:F+=w.slice(0,N-1).join(", "),F+=", and ".concat(w[N-1]," arguments");break}return"".concat(F," must be specified")},TypeError),Z.exports.codes=Y}}),G1=Y1({"assert/build/internal/assert/assertion_error.js"(b1,Z){function J(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 I="",P="",A="",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(m){k[m]=b[m]}),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 m="",x="",y=0,g="",d=!1,_=C(b),u=_.split(` -`),n=C(h).split(` -`),i=0,p="";if(k==="strictEqual"&&G(b)==="object"&&G(h)==="object"&&b!==null&&h!==null&&(k="strictEqualObject"),u.length===1&&n.length===1&&u[0]!==n[0]){var l=u[0].length+n[0].length;if(l<=R){if((G(b)!=="object"||b===null)&&(G(h)!=="object"||h===null)&&(b!==0||h!==0))return"".concat(j[k],` +import J from"node:util";var f1=function(){throw new Error("CallTracker is not supported yet")},{Bun:j1}=globalThis[Symbol.for("Bun.lazy")]("primordials"),O=j1.deepEquals,N=(X,_)=>function(){return _||(0,X[Object.keys(X)[0]])((_={exports:{}}).exports,_),_.exports},z=N({"assert/build/internal/errors.js"(X,_){function u(H1){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(Q1){return typeof Q1}:u=function(Q1){return Q1&&typeof Symbol=="function"&&Q1.constructor===Symbol&&Q1!==Symbol.prototype?"symbol":typeof Q1},u(H1)}function n(H1,Q1){if(!(H1 instanceof Q1))throw new TypeError("Cannot call a class as a function")}function i(H1,Q1){return Q1&&(u(Q1)==="object"||typeof Q1=="function")?Q1:U(H1)}function U(H1){if(H1===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return H1}function p(H1){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(Q1){return Q1.__proto__||Object.getPrototypeOf(Q1)},p(H1)}function l(H1,Q1){if(typeof Q1!="function"&&Q1!==null)throw new TypeError("Super expression must either be null or a function");H1.prototype=Object.create(Q1&&Q1.prototype,{constructor:{value:H1,writable:!0,configurable:!0}}),Q1&&c(H1,Q1)}function c(H1,Q1){return c=Object.setPrototypeOf||function(Z1,W){return Z1.__proto__=W,Z1},c(H1,Q1)}var o={},$,a;function t(H1,Q1,Z1){Z1||(Z1=Error);function W(z1,X1,U1){return typeof Q1=="string"?Q1:Q1(z1,X1,U1)}var J1=function(z1){l(X1,z1);function X1(U1,Y,$1){var K1;return n(this,X1),K1=i(this,p(X1).call(this,W(U1,Y,$1))),K1.code=H1,K1}return X1}(Z1);o[H1]=J1}function r(H1,Q1){if(Array.isArray(H1)){var Z1=H1.length;return H1=H1.map(function(W){return String(W)}),Z1>2?"one of ".concat(Q1," ").concat(H1.slice(0,Z1-1).join(", "),", or ")+H1[Z1-1]:Z1===2?"one of ".concat(Q1," ").concat(H1[0]," or ").concat(H1[1]):"of ".concat(Q1," ").concat(H1[0])}else return"of ".concat(Q1," ").concat(String(H1))}function s(H1,Q1,Z1){return H1.substr(!Z1||Z1<0?0:+Z1,Q1.length)===Q1}function K(H1,Q1,Z1){return(Z1===void 0||Z1>H1.length)&&(Z1=H1.length),H1.substring(Z1-Q1.length,Z1)===Q1}function e(H1,Q1,Z1){return typeof Z1!="number"&&(Z1=0),Z1+Q1.length>H1.length?!1:H1.indexOf(Q1,Z1)!==-1}t("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),t("ERR_INVALID_ARG_TYPE",function(H1,Q1,Z1){$===void 0&&($=F()),$(typeof H1=="string","'name' must be a string");var W;typeof Q1=="string"&&s(Q1,"not ")?(W="must not be",Q1=Q1.replace(/^not /,"")):W="must be";var J1;if(K(H1," argument"))J1="The ".concat(H1," ").concat(W," ").concat(r(Q1,"type"));else{var z1=e(H1,".")?"property":"argument";J1='The "'.concat(H1,'" ').concat(z1," ").concat(W," ").concat(r(Q1,"type"))}return J1+=". Received type ".concat(u(Z1)),J1},TypeError),t("ERR_INVALID_ARG_VALUE",function(H1,Q1){var Z1=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid",W=a.inspect(Q1);return W.length>128&&(W="".concat(W.slice(0,128),"...")),"The argument '".concat(H1,"' ").concat(Z1,". Received ").concat(W)},TypeError,RangeError),t("ERR_INVALID_RETURN_VALUE",function(H1,Q1,Z1){var W;return Z1&&Z1.constructor&&Z1.constructor.name?W="instance of ".concat(Z1.constructor.name):W="type ".concat(u(Z1)),"Expected ".concat(H1,' to be returned from the "').concat(Q1,'"')+" function but got ".concat(W,".")},TypeError),t("ERR_MISSING_ARGS",function(){for(var H1=arguments.length,Q1=new Array(H1),Z1=0;Z10,"At least one arg needs to be specified");var W="The ",J1=Q1.length;switch(Q1=Q1.map(function(z1){return'"'.concat(z1,'"')}),J1){case 1:W+="".concat(Q1[0]," argument");break;case 2:W+="".concat(Q1[0]," and ").concat(Q1[1]," arguments");break;default:W+=Q1.slice(0,J1-1).join(", "),W+=", and ".concat(Q1[J1-1]," arguments");break}return"".concat(W," must be specified")},TypeError),_.exports.codes=o}}),I=N({"assert/build/internal/assert/assertion_error.js"(X,_){function u(V1){for(var D1=1;D1V1.length)&&(M1=V1.length),V1.substring(M1-D1.length,M1)===D1}function J1(V1,D1){if(D1=Math.floor(D1),V1.length==0||D1==0)return"";var M1=V1.length*D1;for(D1=Math.floor(Math.log(D1)/Math.log(2));D1;)V1+=V1,D1--;return V1+=V1.substring(0,M1-V1.length),V1}var z1="",X1="",U1="",Y="",$1={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:"},K1=10;function W1(V1){var D1=Object.keys(V1),M1=Object.create(Object.getPrototypeOf(V1));return D1.forEach(function(V){M1[V]=V1[V]}),Object.defineProperty(M1,"message",{value:V1.message}),M1}function Y1(V1){return H1(V1,{compact:!1,customInspect:!1,depth:1000,maxArrayLength:Infinity,showHidden:!1,breakLength:Infinity,showProxy:!1,sorted:!0,getters:!0})}function B(V1,D1,M1){var V="",q1="",v1=0,G1="",T1=!1,D=Y1(V1),w1=D.split(` +`),O1=Y1(D1).split(` +`),M=0,H="";if(M1==="strictEqual"&&e(V1)==="object"&&e(D1)==="object"&&V1!==null&&D1!==null&&(M1="strictEqualObject"),w1.length===1&&O1.length===1&&w1[0]!==O1[0]){var q=w1[0].length+O1[0].length;if(q<=K1){if((e(V1)!=="object"||V1===null)&&(e(D1)!=="object"||D1===null)&&(V1!==0||D1!==0))return"".concat($1[M1],` -`)+"".concat(u[0]," !== ").concat(n[0],` -`)}else if(k!=="strictEqualObject"){var c=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(l2&&(p=` - `.concat(N(" ",i),"^"),i=0)}}}for(var o=u[u.length-1],a=n[n.length-1];o===a&&(i++<2?g=` - `.concat(o).concat(g):m=o,u.pop(),n.pop(),!(u.length===0||n.length===0));)o=u[u.length-1],a=n[n.length-1];var t=Math.max(u.length,n.length);if(t===0){var r=_.split(` -`);if(r.length>30)for(r[26]="".concat(I,"...").concat(S);r.length>27;)r.pop();return"".concat(j.notIdentical,` +`)+"".concat(w1[0]," !== ").concat(O1[0],` +`)}else if(M1!=="strictEqualObject"){var F1=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(q2&&(H=` + `.concat(J1(" ",M),"^"),M=0)}}}for(var N1=w1[w1.length-1],v=O1[O1.length-1];N1===v&&(M++<2?G1=` + `.concat(N1).concat(G1):V=N1,w1.pop(),O1.pop(),!(w1.length===0||O1.length===0));)N1=w1[w1.length-1],v=O1[O1.length-1];var Q=Math.max(w1.length,O1.length);if(Q===0){var G=D.split(` +`);if(G.length>30)for(G[26]="".concat(z1,"...").concat(Y);G.length>27;)G.pop();return"".concat($1.notIdentical,` -`).concat(r.join(` +`).concat(G.join(` `),` -`)}i>3&&(g=` -`.concat(I,"...").concat(S).concat(g),d=!0),m!==""&&(g=` - `.concat(m).concat(g),m="");var s=0,e=j[k]+` -`.concat(P,"+ actual").concat(S," ").concat(A,"- expected").concat(S),H1=" ".concat(I,"...").concat(S," Lines skipped");for(i=0;i1&&i>2&&(Q1>4?(x+=` -`.concat(I,"...").concat(S),d=!0):Q1>3&&(x+=` - `.concat(n[i-2]),s++),x+=` - `.concat(n[i-1]),s++),y=i,m+=` -`.concat(A,"-").concat(S," ").concat(n[i]),s++;else if(n.length1&&i>2&&(Q1>4?(x+=` -`.concat(I,"...").concat(S),d=!0):Q1>3&&(x+=` - `.concat(u[i-2]),s++),x+=` - `.concat(u[i-1]),s++),y=i,x+=` -`.concat(P,"+").concat(S," ").concat(u[i]),s++;else{var Z1=n[i],J1=u[i],z1=J1!==Z1&&(!F(J1,",")||J1.slice(0,-1)!==Z1);z1&&F(Z1,",")&&Z1.slice(0,-1)===J1&&(z1=!1,J1+=","),z1?(Q1>1&&i>2&&(Q1>4?(x+=` -`.concat(I,"...").concat(S),d=!0):Q1>3&&(x+=` - `.concat(u[i-2]),s++),x+=` - `.concat(u[i-1]),s++),y=i,x+=` -`.concat(P,"+").concat(S," ").concat(J1),m+=` -`.concat(A,"-").concat(S," ").concat(Z1),s+=2):(x+=m,m="",(Q1===1||i===0)&&(x+=` - `.concat(J1),s++))}if(s>20&&i30)for(i[26]="".concat(I,"...").concat(S);i.length>27;)i.pop();i.length===1?m=K(this,v(h).call(this,"".concat(n," ").concat(i[0]))):m=K(this,v(h).call(this,"".concat(n,` +`)}M>3&&(G1=` +`.concat(z1,"...").concat(Y).concat(G1),T1=!0),V!==""&&(G1=` + `.concat(V).concat(G1),V="");var I1=0,P1=$1[M1]+` +`.concat(X1,"+ actual").concat(Y," ").concat(U1,"- expected").concat(Y),T=" ".concat(z1,"...").concat(Y," Lines skipped");for(M=0;M1&&M>2&&(Z>4?(q1+=` +`.concat(z1,"...").concat(Y),T1=!0):Z>3&&(q1+=` + `.concat(O1[M-2]),I1++),q1+=` + `.concat(O1[M-1]),I1++),v1=M,V+=` +`.concat(U1,"-").concat(Y," ").concat(O1[M]),I1++;else if(O1.length1&&M>2&&(Z>4?(q1+=` +`.concat(z1,"...").concat(Y),T1=!0):Z>3&&(q1+=` + `.concat(w1[M-2]),I1++),q1+=` + `.concat(w1[M-1]),I1++),v1=M,q1+=` +`.concat(X1,"+").concat(Y," ").concat(w1[M]),I1++;else{var w=O1[M],A1=w1[M],S1=A1!==w&&(!W(A1,",")||A1.slice(0,-1)!==w);S1&&W(w,",")&&w.slice(0,-1)===A1&&(S1=!1,A1+=","),S1?(Z>1&&M>2&&(Z>4?(q1+=` +`.concat(z1,"...").concat(Y),T1=!0):Z>3&&(q1+=` + `.concat(w1[M-2]),I1++),q1+=` + `.concat(w1[M-1]),I1++),v1=M,q1+=` +`.concat(X1,"+").concat(Y," ").concat(A1),V+=` +`.concat(U1,"-").concat(Y," ").concat(w),I1+=2):(q1+=V,V="",(Z===1||M===0)&&(q1+=` + `.concat(A1),I1++))}if(I1>20&&M30)for(M[26]="".concat(z1,"...").concat(Y);M.length>27;)M.pop();M.length===1?V=l(this,K(D1).call(this,"".concat(O1," ").concat(M[0]))):V=l(this,K(D1).call(this,"".concat(O1,` -`).concat(i.join(` +`).concat(M.join(` `),` -`)))}else{var p=C(d),l="",c=j[y];y==="notDeepEqual"||y==="notEqual"?(p="".concat(j[y],` +`)))}else{var H=Y1(T1),q="",F1=$1[v1];v1==="notDeepEqual"||v1==="notEqual"?(H="".concat($1[v1],` -`).concat(p),p.length>1024&&(p="".concat(p.slice(0,1021),"..."))):(l="".concat(C(_)),p.length>512&&(p="".concat(p.slice(0,509),"...")),l.length>512&&(l="".concat(l.slice(0,509),"...")),y==="deepEqual"||y==="equal"?p="".concat(c,` +`).concat(H),H.length>1024&&(H="".concat(H.slice(0,1021),"..."))):(q="".concat(Y1(D)),H.length>512&&(H="".concat(H.slice(0,509),"...")),q.length>512&&(q="".concat(q.slice(0,509),"...")),v1==="deepEqual"||v1==="equal"?H="".concat(F1,` -`).concat(p,` +`).concat(H,` should equal -`):l=" ".concat(y," ").concat(l)),m=K(this,v(h).call(this,"".concat(p).concat(l)))}return Error.stackTraceLimit=u,m.generatedMessage=!x,Object.defineProperty(W(m),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),m.code="ERR_ASSERTION",m.actual=d,m.expected=_,m.operator=y,Error.captureStackTrace&&Error.captureStackTrace(W(m),g),m.stack,m.name="AssertionError",K(m)}return $(h,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:T.custom,value:function(k,m){return T(this,J({},m,{customInspect:!1,depth:0}))}}]),h}(B(Error));Z.exports=L}}),$1=Y1({"assert/build/assert.js"(b1,Z){function J(y){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?J=function(g){return typeof g}:J=function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},J(y)}function z(y,g){if(!(y instanceof g))throw new TypeError("Cannot call a class as a function")}var X=B1(),U=X.codes,$=U.ERR_AMBIGUOUS_ARGUMENT,K=U.ERR_INVALID_ARG_TYPE,W=U.ERR_INVALID_ARG_VALUE,Y=U.ERR_INVALID_RETURN_VALUE,B=U.ERR_MISSING_ARGS,V=G1(),D=U1,M=D.inspect,q=U1.types,v=q.isPromise,G=q.isRegExp,T=Object.assign,w=Object.is,O=new Map,F=!1,N=Z.exports=j,I={};function P(y){throw y.message instanceof Error?y.message:new V(y)}function A(y,g,d,_,u){var n=arguments.length,i;if(n===0)i="Failed";else if(n===1)d=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")}n===2&&(_="!=")}if(d instanceof Error)throw d;var l={actual:y,expected:g,operator:_===void 0?"fail":_,stackStartFn:u||A};d!==void 0&&(l.message=d);var c=new V(l);throw i&&(c.message=i,c.generatedMessage=!0),c}N.fail=A,N.AssertionError=V;function S(y,g,d,_){if(!d){var u=!1;if(g===0)u=!0,_="No value argument passed to `assert.ok()`";else if(_ instanceof Error)throw _;var n=new V({actual:d,expected:!0,message:_,operator:"==",stackStartFn:y});throw n.generatedMessage=u,n}}function j(){for(var y=arguments.length,g=new Array(y),d=0;d1?d-1:0),u=1;u1?d-1:0),u=1;u1?d-1:0),u=1;u1?d-1:0),u=1;u1?T1-1:0),w1=1;w11?T1-1:0),w1=1;w11?T1-1:0),w1=1;w11?T1-1:0),w1=1;w1{if(z.push({eventType:B,filename:C}),A){const D=A;A=null,D()}}),{async*[Symbol.asyncIterator](){let B=!1;while(!B){while(z.length){let C=z.shift();if(C.eventType==="close"){B=!0;break}if(C.eventType==="error")throw B=!0,C.filename;yield C}await new Promise((C)=>A=C)}}}}var H=Bun.fs(),G="::bunternal::",I={[G]:(S)=>{var q={[G]:function(z,A,B){var C;try{C=S.apply(H,B),B=void 0}catch(D){B=void 0,A(D);return}z(C)}}[G];return async function(...z){return await new Promise((A,B)=>{process.nextTick(q,A,B,z)})}}}[G],K=I(H.accessSync),L=I(H.appendFileSync),M=I(H.closeSync),N=I(H.copyFileSync),O=I(H.existsSync),P=I(H.chownSync),Q=I(H.chmodSync),U=I(H.fchmodSync),V=I(H.fchownSync),X=I(H.fstatSync),Y=I(H.fsyncSync),Z=I(H.ftruncateSync),_=I(H.futimesSync),$=I(H.lchmodSync),T=I(H.lchownSync),W=I(H.linkSync),k=I(H.lstatSync),E=I(H.mkdirSync),x=I(H.mkdtempSync),F=I(H.openSync),R=I(H.readSync),g=I(H.writeSync),h=I(H.readdirSync),j=I(H.readFileSync),w=I(H.writeFileSync),b=I(H.readlinkSync),u=I(H.realpathSync),d=I(H.renameSync),c=I(H.statSync),v=I(H.symlinkSync),a=I(H.truncateSync),y=I(H.unlinkSync),l=I(H.utimesSync),p=I(H.lutimesSync),m=I(H.rmSync),n=I(H.rmdirSync),t=(S,q,z)=>{return new Promise((A,B)=>{try{var C=H.writevSync(S,q,z)}catch(D){B(D);return}A({bytesWritten:C,buffers:q})})},o=(S,q,z)=>{return new Promise((A,B)=>{try{var C=H.readvSync(S,q,z)}catch(D){B(D);return}A({bytesRead:C,buffers:q})})},r={access:K,appendFile:L,close:M,copyFile:N,exists:O,chown:P,chmod:Q,fchmod:U,fchown:V,fstat:X,fsync:Y,ftruncate:Z,futimes:_,lchmod:$,lchown:T,link:W,lstat:k,mkdir:E,mkdtemp:x,open:F,read:R,write:g,readdir:h,readFile:j,writeFile:w,readlink:b,realpath:u,rename:d,stat:c,symlink:v,truncate:a,unlink:y,utimes:l,lutimes:p,rm:m,rmdir:n,watch:J,writev:t,readv:o,constants,[Symbol.for("CommonJS")]:0};export{t as writev,w as writeFile,g as write,J as watch,l as utimes,y as unlink,a as truncate,v as symlink,c as stat,n as rmdir,m as rm,d as rename,u as realpath,o as readv,b as readlink,h as readdir,j as readFile,R as read,F as open,x as mkdtemp,E as mkdir,p as lutimes,k as lstat,W as link,T as lchown,$ as lchmod,_ as futimes,Z as ftruncate,Y as fsync,X as fstat,V as fchown,U as fchmod,O as exists,r as default,N as copyFile,M as close,P as chown,Q as chmod,L as appendFile,K as access}; +function z(i,S={}){const L=[];if(i instanceof URL)throw new TypeError("Watch URLs are not supported yet");else if(Buffer.isBuffer(i))i=i.toString();else if(typeof i!=="string")throw new TypeError("Expected path to be a string or Buffer");let n=null;if(typeof S==="string")S={encoding:S};return V.watch(i,S||{},(r,a)=>{if(L.push({eventType:r,filename:a}),n){const E=n;n=null,E()}}),{async*[Symbol.asyncIterator](){let r=!1;while(!r){while(L.length){let a=L.shift();if(a.eventType==="close"){r=!0;break}if(a.eventType==="error")throw r=!0,a.filename;yield a}await new Promise((a)=>n=a)}}}}var V=Bun.fs(),_="::bunternal::",q={[_]:(i)=>{var S={[_]:function(L,n,r){var a;try{a=i.apply(V,r),r=void 0}catch(E){r=void 0,n(E);return}L(a)}}[_];return async function(...L){return await new Promise((n,r)=>{process.nextTick(S,n,r,L)})}}}[_],k=q(V.accessSync),X=q(V.appendFileSync),l=q(V.closeSync),b=q(V.copyFileSync),R=q(V.existsSync),h=q(V.chownSync),j=q(V.chmodSync),N=q(V.fchmodSync),A=q(V.fchownSync),B=q(V.fstatSync),d=q(V.fsyncSync),P=q(V.ftruncateSync),p=q(V.futimesSync),O=q(V.lchmodSync),o=q(V.lchownSync),K=q(V.linkSync),Z=q(V.lstatSync),C=q(V.mkdirSync),D=q(V.mkdtempSync),y=q(V.openSync),c=q(V.readSync),G=q(V.writeSync),U=q(V.readdirSync),m=q(V.readFileSync),Q=q(V.writeFileSync),H=q(V.readlinkSync),v=q(V.realpathSync),x=q(V.renameSync),F=q(V.statSync),$=q(V.symlinkSync),W=q(V.truncateSync),w=q(V.unlinkSync),t=q(V.utimesSync),Y=q(V.lutimesSync),g=q(V.rmSync),T=q(V.rmdirSync),I=(i,S,L)=>{return new Promise((n,r)=>{try{var a=V.writevSync(i,S,L)}catch(E){r(E);return}n({bytesWritten:a,buffers:S})})},J=(i,S,L)=>{return new Promise((n,r)=>{try{var a=V.readvSync(i,S,L)}catch(E){r(E);return}n({bytesRead:a,buffers:S})})},M={access:k,appendFile:X,close:l,copyFile:b,exists:R,chown:h,chmod:j,fchmod:N,fchown:A,fstat:B,fsync:d,ftruncate:P,futimes:p,lchmod:O,lchown:o,link:K,lstat:Z,mkdir:C,mkdtemp:D,open:y,read:c,write:G,readdir:U,readFile:m,writeFile:Q,readlink:H,realpath:v,rename:x,stat:F,symlink:$,truncate:W,unlink:w,utimes:t,lutimes:Y,rm:g,rmdir:T,watch:z,writev:I,readv:J,constants,[Symbol.for("CommonJS")]:0};export{I as writev,Q as writeFile,G as write,z as watch,t as utimes,w as unlink,W as truncate,$ as symlink,F as stat,T as rmdir,g as rm,x as rename,v as realpath,J as readv,H as readlink,U as readdir,m as readFile,c as read,y as open,D as mkdtemp,C as mkdir,Y as lutimes,Z as lstat,K as link,o as lchown,O as lchmod,p as futimes,P as ftruncate,d as fsync,B as fstat,A as fchown,N as fchmod,R as exists,M as default,b as copyFile,l as close,h as chown,j as chmod,X as appendFile,k as access}; diff --git a/src/js/out/modules/node/path.js b/src/js/out/modules/node/path.js index 4e6003c7d..f8cc1ec08 100644 --- a/src/js/out/modules/node/path.js +++ b/src/js/out/modules/node/path.js @@ -1 +1 @@ -var H=function(i){var G=f({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 G.default=G,G},f=(i)=>Object.assign(Object.create(null),i),m=H(Bun._Path()),I=H(Bun._Path(!1)),g=H(Bun._Path(!0));m.win32=g;m.posix=I;var{basename:J,dirname:k,extname:K,format:q,isAbsolute:L,join:v,normalize:N,parse:y,relative:O,resolve:C,toNamespacedPath:z,sep:D,delimiter:A,__esModule:E}=m;m[Symbol.for("CommonJS")]=0;m.__esModule=!0;var F=m;export{g as win32,z as toNamespacedPath,D as sep,C as resolve,O as relative,I as posix,y as parse,N as normalize,v as join,L as isAbsolute,q as format,K as extname,k as dirname,A as delimiter,F as default,f as createModule,J as basename,E 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 ca08d44b8..64e8a62f5 100644 --- a/src/js/out/modules/node/path.posix.js +++ b/src/js/out/modules/node/path.posix.js @@ -1 +1 @@ -var r=function(i){return{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}},k=r(Bun._Path(!1));k[Symbol.for("CommonJS")]=0;var{basename:e,dirname:m,extname:d,format:l,isAbsolute:s,join:c,normalize:f,parse:g,relative:q,resolve:t,toNamespacedPath:v,sep:w,delimiter:x}=k,z=k;export{v as toNamespacedPath,w as sep,t as resolve,q as relative,g as parse,f as normalize,c as join,s as isAbsolute,l as format,d as extname,m as dirname,x as delimiter,z as default,e 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/stream.consumers.js b/src/js/out/modules/node/stream.consumers.js index 8e3592104..20bbb7de4 100644 --- a/src/js/out/modules/node/stream.consumers.js +++ b/src/js/out/modules/node/stream.consumers.js @@ -1 +1 @@ -var{Bun:k}=globalThis[Symbol.for("Bun.lazy")]("primordials"),p=k.readableStreamToArrayBuffer,o=k.readableStreamToText,h=(c)=>k.readableStreamToText(c).then(JSON.parse),g=async(c)=>{return new Buffer(await p(c))},i=k.readableStreamToBlob,q={[Symbol.for("CommonJS")]:0,arrayBuffer:p,text:o,json:h,buffer:g,blob:i};export{o as text,h as json,q as default,g as buffer,i as blob,p 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 31a1d64c6..f96818bd6 100644 --- a/src/js/out/modules/node/stream.js +++ b/src/js/out/modules/node/stream.js @@ -1,2 +1,2 @@ -import{EventEmitter as CQ} from"bun:events_native";import{StringDecoder as Eq} from"node:string_decoder";var M=function(B){return typeof B==="object"&&B!==null&&B instanceof ReadableStream},F=function(B,Y){if(typeof B!=="boolean")throw new yQ(Y,"boolean",B)};var yQ=function(B,Y,U){return new Error(`The argument '${B}' is invalid. Received '${U}' for type '${Y}'`)},xq=function(B,Y,U){return new Error(`The value '${Y}' is invalid for argument '${B}'. Reason: ${U}`)},P=function(B,Y){var[U,H,X,q,J,Q,Z]=globalThis[Symbol.for("Bun.lazy")](B),K=[!1],oq=function(rq,m,tq,c){if(m>0){const eq=tq.subarray(0,m),d=tq.subarray(m);if(eq.byteLength>0)rq.push(eq);if(c)rq.push(null);return d.byteLength>0?d:void 0}if(c)rq.push(null);return tq},p=function(rq,m,tq,c){if(m.byteLength>0)rq.push(m);if(c)rq.push(null);return tq},sq=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const u=new FinalizationRegistry((rq)=>rq&&J(rq)),aq=512;var b=class rq extends Y{#q;#Q=1;#X=!1;#J=void 0;#H;#K=!1;#Z=!sq;#B;constructor(m,tq={}){super(tq);if(typeof tq.highWaterMark==="number")this.#H=tq.highWaterMark;else this.#H=262144;this.#q=m,this.#X=!1,this.#J=void 0,this.#K=!1,this.#B={},u.register(this,this.#q,this.#B)}_read(m){if(OQ&&Gq("NativeReadable._read",this.__id),this.#K){OQ&&Gq("pendingRead is true",this.__id);return}var tq=this.#q;if(OQ&&Gq("ptr @ NativeReadable._read",tq,this.__id),tq===0){this.push(null);return}if(!this.#X)OQ&&Gq("NativeReadable not constructed yet",this.__id),this.#Y(tq);return this.#V(this.#$(m),tq)}#Y(m){this.#X=!0;const tq=H(m,this.#H);if(OQ&&Gq("NativeReadable internal `start` result",tq,this.__id),typeof tq==="number"&&tq>1)this.#Z=!0,OQ&&Gq("NativeReadable resized",this.__id),this.#H=Math.min(this.#H,tq);if(Z){const c=Z(m);if(OQ&&Gq("NativeReadable drain result",c,this.__id),(c?.byteLength??0)>0)this.push(c)}}#$(m=this.#H){var tq=this.#J;if(OQ&&Gq("chunk @ #getRemainingChunk",tq,this.__id),tq?.byteLength??0aq?m:aq;this.#J=tq=new Buffer(c)}return tq}push(m,tq){return OQ&&Gq("NativeReadable push -- result, encoding",m,tq,this.__id),super.push(...arguments)}#z(m,tq,c){if(OQ&&Gq("result, isClosed @ #handleResult",m,c,this.__id),typeof m==="number"){if(m>=this.#H&&!this.#Z&&!c)this.#H*=2,this.#Z=!0;return oq(this,m,tq,c)}else if(typeof m==="boolean")return this.push(null),tq?.byteLength??0>0?tq:void 0;else if(ArrayBuffer.isView(m)){if(m.byteLength>=this.#H&&!this.#Z&&!c)this.#H*=2,this.#Z=!0,OQ&&Gq("Resized",this.__id);return p(this,m,tq,c)}else throw OQ&&Gq("Unknown result type",m,this.__id),new Error("Invalid result from pull")}#V(m,tq){OQ&&Gq("#internalRead()",this.__id),K[0]=!1;var c=U(tq,m,K);if(Lq(c))return this.#K=!0,c.then((eq)=>{this.#K=!1,OQ&&Gq("pending no longerrrrrrrr (result returned from pull)",this.__id),this.#J=this.#z(eq,m,K[0])},(eq)=>{OQ&&Gq("error from pull",eq,this.__id),errorOrDestroy(this,eq)});else this.#J=this.#z(c,m,K[0])}_destroy(m,tq){var c=this.#q;if(c===0){tq(m);return}if(u.unregister(this.#B),this.#q=0,Q)Q(c,!1);OQ&&Gq("NativeReadable destroyed",this.__id),X(c,m),tq(m)}ref(){var m=this.#q;if(m===0)return;if(this.#Q++===0)Q(m,!0)}unref(){var m=this.#q;if(m===0)return;if(this.#Q--===1)Q(m,!1)}};if(!Q)b.prototype.ref=void 0,b.prototype.unref=void 0;return b},O=function(B,Y){return x[B]||=P(B,Y)},_=function(B,Y,U){if(!(Y&&typeof Y==="object"&&Y instanceof ReadableStream))return;const H=vQ(Y);if(!H){Gq("no native readable stream");return}const{stream:X,data:q}=H;return new(O(q,B))(X,U)},{isPromise:Lq,isCallable:Nq,direct:vQ,Object:Fq}=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 SQ=!!process.env.DEBUG_TRACK_EE,OQ=!!(process.env.DEBUG||process.env.DEBUG_STREAMS||SQ),Gq=OQ?globalThis.__IDS_TO_TRACK?(...B)=>{const Y=B[B.length-1];if(!globalThis.__IDS_TO_TRACK.includes(Y))return;console.log(`ID: ${Y}`,...B.slice(0,-1))}:(...B)=>console.log(...B.slice(0,-1)):()=>{},Iq=Fq.create,gQ=Fq.defineProperty,V=Fq.getOwnPropertyDescriptor,fQ=Fq.getOwnPropertyNames,Tq=Fq.getPrototypeOf,kQ=Fq.prototype.hasOwnProperty,W=Fq.setPrototypeOf,G=(B,Y)=>function U(){return Y||(0,B[fQ(B)[0]])((Y={exports:{}}).exports,Y),Y.exports};var _Q=process.nextTick;var Pq=Array.isArray,DQ=G({"node_modules/readable-stream/lib/ours/primordials.js"(B,Y){Y.exports={ArrayIsArray(U){return Array.isArray(U)},ArrayPrototypeIncludes(U,H){return U.includes(H)},ArrayPrototypeIndexOf(U,H){return U.indexOf(H)},ArrayPrototypeJoin(U,H){return U.join(H)},ArrayPrototypeMap(U,H){return U.map(H)},ArrayPrototypePop(U,H){return U.pop(H)},ArrayPrototypePush(U,H){return U.push(H)},ArrayPrototypeSlice(U,H,X){return U.slice(H,X)},Error,FunctionPrototypeCall(U,H,...X){return U.call(H,...X)},FunctionPrototypeSymbolHasInstance(U,H){return Function.prototype[Symbol.hasInstance].call(U,H)},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(U,H){return Fq.defineProperties(U,H)},ObjectDefineProperty(U,H,X){return Fq.defineProperty(U,H,X)},ObjectGetOwnPropertyDescriptor(U,H){return Fq.getOwnPropertyDescriptor(U,H)},ObjectKeys(U){return Fq.keys(U)},ObjectSetPrototypeOf(U,H){return Fq.setPrototypeOf(U,H)},Promise,PromisePrototypeCatch(U,H){return U.catch(H)},PromisePrototypeThen(U,H,X){return U.then(H,X)},PromiseReject(U){return Promise.reject(U)},ReflectApply:Reflect.apply,RegExpPrototypeTest(U,H){return U.test(H)},SafeSet:Set,String,StringPrototypeSlice(U,H,X){return U.slice(H,X)},StringPrototypeToLowerCase(U){return U.toLowerCase()},StringPrototypeToUpperCase(U){return U.toUpperCase()},StringPrototypeTrim(U){return U.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(U,H,X){return U.set(H,X)},Uint8Array}}}),jq=G({"node_modules/readable-stream/lib/ours/util.js"(B,Y){var U=Fq.getPrototypeOf(async function(){}).constructor,H=typeof Blob!=="undefined"?function q(J){return J instanceof Blob}:function q(J){return!1},X=class extends Error{constructor(q){if(!Array.isArray(q))throw new TypeError(`Expected input to be an Array, got ${typeof q}`);let J="";for(let Q=0;Q{q=Z,J=K}),resolve:q,reject:J}},promisify(q){return new Promise((J,Q)=>{q((Z,...K)=>{if(Z)return Q(Z);return J(...K)})})},debuglog(){return function(){}},format(q,...J){return q.replace(/%([sdifj])/g,function(...[Q,Z]){const K=J.shift();if(Z==="f")return K.toFixed(6);else if(Z==="j")return JSON.stringify(K);else if(Z==="s"&&typeof K==="object")return`${K.constructor!==Fq?K.constructor.name:""} {}`.trim();else return K.toString()})},inspect(q){switch(typeof q){case"string":if(q.includes("'")){if(!q.includes('"'))return`"${q}"`;else if(!q.includes("`")&&!q.includes("${"))return`\`${q}\``}return`'${q}'`;case"number":if(isNaN(q))return"NaN";else if(Fq.is(q,-0))return String(q);return q;case"bigint":return`${String(q)}n`;case"boolean":case"undefined":return String(q);case"object":return"{}"}},types:{isAsyncFunction(q){return q instanceof U},isArrayBufferView(q){return ArrayBuffer.isView(q)}},isBlob:H},Y.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),hQ=G({"node_modules/readable-stream/lib/ours/errors.js"(B,Y){var{format:U,inspect:H,AggregateError:X}=jq(),q=globalThis.AggregateError||X,J=Symbol("kIsNodeError"),Q=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Z=/^([A-Z][a-z0-9]*)+$/,K="__node_internal_",oq={};function p(tq,c){if(!tq)throw new oq.ERR_INTERNAL_ASSERTION(c)}function sq(tq){let c="",eq=tq.length;const d=tq[0]==="-"?1:0;for(;eq>=d+4;eq-=3)c=`_${tq.slice(eq-3,eq)}${c}`;return`${tq.slice(0,eq)}${c}`}function u(tq,c,eq){if(typeof c==="function")return p(c.length<=eq.length,`Code: ${tq}; The provided arguments length (${eq.length}) does not match the required ones (${c.length}).`),c(...eq);const d=(c.match(/%[dfijoOs]/g)||[]).length;if(p(d===eq.length,`Code: ${tq}; The provided arguments length (${eq.length}) does not match the required ones (${d}).`),eq.length===0)return c;return U(c,...eq)}function aq(tq,c,eq){if(!eq)eq=Error;class d extends eq{constructor(...qQ){super(u(tq,c,qQ))}toString(){return`${this.name} [${tq}]: ${this.message}`}}Fq.defineProperties(d.prototype,{name:{value:eq.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${tq}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),d.prototype.code=tq,d.prototype[J]=!0,oq[tq]=d}function b(tq){const c=K+tq.name;return Fq.defineProperty(tq,"name",{value:c}),tq}function rq(tq,c){if(tq&&c&&tq!==c){if(Array.isArray(c.errors))return c.errors.push(tq),c;const eq=new q([c,tq],c.message);return eq.code=c.code,eq}return tq||c}var m=class extends Error{constructor(tq="The operation was aborted",c=void 0){if(c!==void 0&&typeof c!=="object")throw new oq.ERR_INVALID_ARG_TYPE("options","Object",c);super(tq,c);this.code="ABORT_ERR",this.name="AbortError"}};aq("ERR_ASSERTION","%s",Error),aq("ERR_INVALID_ARG_TYPE",(tq,c,eq)=>{if(p(typeof tq==="string","'name' must be a string"),!Array.isArray(c))c=[c];let d="The ";if(tq.endsWith(" argument"))d+=`${tq} `;else d+=`"${tq}" ${tq.includes(".")?"property":"argument"} `;d+="must be ";const qQ=[],l=[],QQ=[];for(let XQ of c)if(p(typeof XQ==="string","All expected entries have to be of type string"),Q.includes(XQ))qQ.push(XQ.toLowerCase());else if(Z.test(XQ))l.push(XQ);else p(XQ!=="object",'The value "object" should be written as "Object"'),QQ.push(XQ);if(l.length>0){const XQ=qQ.indexOf("object");if(XQ!==-1)qQ.splice(qQ,XQ,1),l.push("Object")}if(qQ.length>0){switch(qQ.length){case 1:d+=`of type ${qQ[0]}`;break;case 2:d+=`one of type ${qQ[0]} or ${qQ[1]}`;break;default:{const XQ=qQ.pop();d+=`one of type ${qQ.join(", ")}, or ${XQ}`}}if(l.length>0||QQ.length>0)d+=" or "}if(l.length>0){switch(l.length){case 1:d+=`an instance of ${l[0]}`;break;case 2:d+=`an instance of ${l[0]} or ${l[1]}`;break;default:{const XQ=l.pop();d+=`an instance of ${l.join(", ")}, or ${XQ}`}}if(QQ.length>0)d+=" or "}switch(QQ.length){case 0:break;case 1:if(QQ[0].toLowerCase()!==QQ[0])d+="an ";d+=`${QQ[0]}`;break;case 2:d+=`one of ${QQ[0]} or ${QQ[1]}`;break;default:{const XQ=QQ.pop();d+=`one of ${QQ.join(", ")}, or ${XQ}`}}if(eq==null)d+=`. Received ${eq}`;else if(typeof eq==="function"&&eq.name)d+=`. Received function ${eq.name}`;else if(typeof eq==="object"){var i;if((i=eq.constructor)!==null&&i!==void 0&&i.name)d+=`. Received an instance of ${eq.constructor.name}`;else{const XQ=H(eq,{depth:-1});d+=`. Received ${XQ}`}}else{let XQ=H(eq,{colors:!1});if(XQ.length>25)XQ=`${XQ.slice(0,25)}...`;d+=`. Received type ${typeof eq} (${XQ})`}return d},TypeError),aq("ERR_INVALID_ARG_VALUE",(tq,c,eq="is invalid")=>{let d=H(c);if(d.length>128)d=d.slice(0,128)+"...";return`The ${tq.includes(".")?"property":"argument"} '${tq}' ${eq}. Received ${d}`},TypeError),aq("ERR_INVALID_RETURN_VALUE",(tq,c,eq)=>{var d;const qQ=eq!==null&&eq!==void 0&&(d=eq.constructor)!==null&&d!==void 0&&d.name?`instance of ${eq.constructor.name}`:`type ${typeof eq}`;return`Expected ${tq} to be returned from the "${c}" function but got ${qQ}.`},TypeError),aq("ERR_MISSING_ARGS",(...tq)=>{p(tq.length>0,"At least one arg needs to be specified");let c;const eq=tq.length;switch(tq=(Array.isArray(tq)?tq:[tq]).map((d)=>`"${d}"`).join(" or "),eq){case 1:c+=`The ${tq[0]} argument`;break;case 2:c+=`The ${tq[0]} and ${tq[1]} arguments`;break;default:{const d=tq.pop();c+=`The ${tq.join(", ")}, and ${d} arguments`}break}return`${c} must be specified`},TypeError),aq("ERR_OUT_OF_RANGE",(tq,c,eq)=>{p(c,'Missing "range" argument');let d;if(Number.isInteger(eq)&&Math.abs(eq)>4294967296)d=sq(String(eq));else if(typeof eq==="bigint"){if(d=String(eq),eq>2n**32n||eq<-(2n**32n))d=sq(d);d+="n"}else d=H(eq);return`The value of "${tq}" is out of range. It must be ${c}. Received ${d}`},RangeError),aq("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),aq("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),aq("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),aq("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),aq("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),aq("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),aq("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),aq("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),aq("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),aq("ERR_STREAM_WRITE_AFTER_END","write after end",Error),aq("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),Y.exports={AbortError:m,aggregateTwoErrors:b(rq),hideStackFrames:b,codes:oq}}}),L=G({"node_modules/readable-stream/lib/internal/validators.js"(B,Y){var{ArrayIsArray:U,ArrayPrototypeIncludes:H,ArrayPrototypeJoin:X,ArrayPrototypeMap:q,NumberIsInteger:J,NumberMAX_SAFE_INTEGER:Q,NumberMIN_SAFE_INTEGER:Z,NumberParseInt:K,RegExpPrototypeTest:oq,String:p,StringPrototypeToUpperCase:sq,StringPrototypeTrim:u}=DQ(),{hideStackFrames:aq,codes:{ERR_SOCKET_BAD_PORT:b,ERR_INVALID_ARG_TYPE:rq,ERR_INVALID_ARG_VALUE:m,ERR_OUT_OF_RANGE:tq,ERR_UNKNOWN_SIGNAL:c}}=hQ(),{normalizeEncoding:eq}=jq(),{isAsyncFunction:d,isArrayBufferView:qQ}=jq().types,l={};function QQ(UQ){return UQ===(UQ|0)}function i(UQ){return UQ===UQ>>>0}var XQ=/^[0-7]+$/,n="must be a 32-bit unsigned integer or an octal string";function JQ(UQ,Qq,WQ){if(typeof UQ==="undefined")UQ=WQ;if(typeof UQ==="string"){if(!oq(XQ,UQ))throw new m(Qq,UQ,n);UQ=K(UQ,8)}return HQ(UQ,Qq,0,4294967295),UQ}var o=aq((UQ,Qq,WQ=Z,Xq=Q)=>{if(typeof UQ!=="number")throw new rq(Qq,"number",UQ);if(!J(UQ))throw new tq(Qq,"an integer",UQ);if(UQXq)throw new tq(Qq,`>= ${WQ} && <= ${Xq}`,UQ)}),HQ=aq((UQ,Qq,WQ=-2147483648,Xq=2147483647)=>{if(typeof UQ!=="number")throw new rq(Qq,"number",UQ);if(!QQ(UQ)){if(!J(UQ))throw new tq(Qq,"an integer",UQ);throw new tq(Qq,`>= ${WQ} && <= ${Xq}`,UQ)}if(UQXq)throw new tq(Qq,`>= ${WQ} && <= ${Xq}`,UQ)}),s=aq((UQ,Qq,WQ)=>{if(typeof UQ!=="number")throw new rq(Qq,"number",UQ);if(!i(UQ)){if(!J(UQ))throw new tq(Qq,"an integer",UQ);throw new tq(Qq,`>= ${WQ?1:0} && < 4294967296`,UQ)}if(WQ&&UQ===0)throw new tq(Qq,">= 1 && < 4294967296",UQ)});function KQ(UQ,Qq){if(typeof UQ!=="string")throw new rq(Qq,"string",UQ)}function a(UQ,Qq){if(typeof UQ!=="number")throw new rq(Qq,"number",UQ)}var ZQ=aq((UQ,Qq,WQ)=>{if(!H(WQ,UQ)){const GQ="must be one of: "+X(q(WQ,(Jq)=>typeof Jq==="string"?`'${Jq}'`:p(Jq)),", ");throw new m(Qq,UQ,GQ)}});function r(UQ,Qq){if(typeof UQ!=="boolean")throw new rq(Qq,"boolean",UQ)}var BQ=aq((UQ,Qq,WQ)=>{const Xq=WQ==null,GQ=Xq?!1:WQ.allowArray,Jq=Xq?!1:WQ.allowFunction;if(!(Xq?!1:WQ.nullable)&&UQ===null||!GQ&&U(UQ)||typeof UQ!=="object"&&(!Jq||typeof UQ!=="function"))throw new rq(Qq,"Object",UQ)}),$=aq((UQ,Qq,WQ=0)=>{if(!U(UQ))throw new rq(Qq,"Array",UQ);if(UQ.length{if(!qQ(UQ))throw new rq(Qq,["Buffer","TypedArray","DataView"],UQ)});function $Q(UQ,Qq){const WQ=eq(Qq),Xq=UQ.length;if(WQ==="hex"&&Xq%2!==0)throw new m("encoding",Qq,`is invalid for data of length ${Xq}`)}function t(UQ,Qq="Port",WQ=!0){if(typeof UQ!=="number"&&typeof UQ!=="string"||typeof UQ==="string"&&u(UQ).length===0||+UQ!==+UQ>>>0||UQ>65535||UQ===0&&!WQ)throw new b(Qq,UQ,WQ);return UQ|0}var zQ=aq((UQ,Qq)=>{if(UQ!==void 0&&(UQ===null||typeof UQ!=="object"||!("aborted"in UQ)))throw new rq(Qq,"AbortSignal",UQ)}),e=aq((UQ,Qq)=>{if(typeof UQ!=="function")throw new rq(Qq,"Function",UQ)}),VQ=aq((UQ,Qq)=>{if(typeof UQ!=="function"||d(UQ))throw new rq(Qq,"Function",UQ)}),qq=aq((UQ,Qq)=>{if(UQ!==void 0)throw new rq(Qq,"undefined",UQ)});Y.exports={isInt32:QQ,isUint32:i,parseFileMode:JQ,validateArray:$,validateBoolean:r,validateBuffer:z,validateEncoding:$Q,validateFunction:e,validateInt32:HQ,validateInteger:o,validateNumber:a,validateObject:BQ,validateOneOf:ZQ,validatePlainFunction:VQ,validatePort:t,validateSignalName:YQ,validateString:KQ,validateUint32:s,validateUndefined:qq,validateAbortSignal:zQ}}}),j=G({"node_modules/readable-stream/lib/internal/streams/utils.js"(B,Y){var{Symbol:U,SymbolAsyncIterator:H,SymbolIterator:X}=DQ(),q=U("kDestroyed"),J=U("kIsErrored"),Q=U("kIsReadable"),Z=U("kIsDisturbed");function K(s,KQ=!1){var a;return!!(s&&typeof s.pipe==="function"&&typeof s.on==="function"&&(!KQ||typeof s.pause==="function"&&typeof s.resume==="function")&&(!s._writableState||((a=s._readableState)===null||a===void 0?void 0:a.readable)!==!1)&&(!s._writableState||s._readableState))}function oq(s){var KQ;return!!(s&&typeof s.write==="function"&&typeof s.on==="function"&&(!s._readableState||((KQ=s._writableState)===null||KQ===void 0?void 0:KQ.writable)!==!1))}function p(s){return!!(s&&typeof s.pipe==="function"&&s._readableState&&typeof s.on==="function"&&typeof s.write==="function")}function sq(s){return s&&(s._readableState||s._writableState||typeof s.write==="function"&&typeof s.on==="function"||typeof s.pipe==="function"&&typeof s.on==="function")}function u(s,KQ){if(s==null)return!1;if(KQ===!0)return typeof s[H]==="function";if(KQ===!1)return typeof s[X]==="function";return typeof s[H]==="function"||typeof s[X]==="function"}function aq(s){if(!sq(s))return null;const{_writableState:KQ,_readableState:a}=s,ZQ=KQ||a;return!!(s.destroyed||s[q]||ZQ!==null&&ZQ!==void 0&&ZQ.destroyed)}function b(s){if(!oq(s))return null;if(s.writableEnded===!0)return!0;const KQ=s._writableState;if(KQ!==null&&KQ!==void 0&&KQ.errored)return!1;if(typeof(KQ===null||KQ===void 0?void 0:KQ.ended)!=="boolean")return null;return KQ.ended}function rq(s,KQ){if(!oq(s))return null;if(s.writableFinished===!0)return!0;const a=s._writableState;if(a!==null&&a!==void 0&&a.errored)return!1;if(typeof(a===null||a===void 0?void 0:a.finished)!=="boolean")return null;return!!(a.finished||KQ===!1&&a.ended===!0&&a.length===0)}function m(s){if(!K(s))return null;if(s.readableEnded===!0)return!0;const KQ=s._readableState;if(!KQ||KQ.errored)return!1;if(typeof(KQ===null||KQ===void 0?void 0:KQ.ended)!=="boolean")return null;return KQ.ended}function tq(s,KQ){if(!K(s))return null;const a=s._readableState;if(a!==null&&a!==void 0&&a.errored)return!1;if(typeof(a===null||a===void 0?void 0:a.endEmitted)!=="boolean")return null;return!!(a.endEmitted||KQ===!1&&a.ended===!0&&a.length===0)}function c(s){if(s&&s[Q]!=null)return s[Q];if(typeof(s===null||s===void 0?void 0:s.readable)!=="boolean")return null;if(aq(s))return!1;return K(s)&&s.readable&&!tq(s)}function eq(s){if(typeof(s===null||s===void 0?void 0:s.writable)!=="boolean")return null;if(aq(s))return!1;return oq(s)&&s.writable&&!b(s)}function d(s,KQ){if(!sq(s))return null;if(aq(s))return!0;if((KQ===null||KQ===void 0?void 0:KQ.readable)!==!1&&c(s))return!1;if((KQ===null||KQ===void 0?void 0:KQ.writable)!==!1&&eq(s))return!1;return!0}function qQ(s){var KQ,a;if(!sq(s))return null;if(s.writableErrored)return s.writableErrored;return(KQ=(a=s._writableState)===null||a===void 0?void 0:a.errored)!==null&&KQ!==void 0?KQ:null}function l(s){var KQ,a;if(!sq(s))return null;if(s.readableErrored)return s.readableErrored;return(KQ=(a=s._readableState)===null||a===void 0?void 0:a.errored)!==null&&KQ!==void 0?KQ:null}function QQ(s){if(!sq(s))return null;if(typeof s.closed==="boolean")return s.closed;const{_writableState:KQ,_readableState:a}=s;if(typeof(KQ===null||KQ===void 0?void 0:KQ.closed)==="boolean"||typeof(a===null||a===void 0?void 0:a.closed)==="boolean")return(KQ===null||KQ===void 0?void 0:KQ.closed)||(a===null||a===void 0?void 0:a.closed);if(typeof s._closed==="boolean"&&i(s))return s._closed;return null}function i(s){return typeof s._closed==="boolean"&&typeof s._defaultKeepAlive==="boolean"&&typeof s._removedConnection==="boolean"&&typeof s._removedContLen==="boolean"}function XQ(s){return typeof s._sent100==="boolean"&&i(s)}function n(s){var KQ;return typeof s._consuming==="boolean"&&typeof s._dumped==="boolean"&&((KQ=s.req)===null||KQ===void 0?void 0:KQ.upgradeOrConnect)===void 0}function JQ(s){if(!sq(s))return null;const{_writableState:KQ,_readableState:a}=s,ZQ=KQ||a;return!ZQ&&XQ(s)||!!(ZQ&&ZQ.autoDestroy&&ZQ.emitClose&&ZQ.closed===!1)}function o(s){var KQ;return!!(s&&((KQ=s[Z])!==null&&KQ!==void 0?KQ:s.readableDidRead||s.readableAborted))}function HQ(s){var KQ,a,ZQ,r,BQ,$,YQ,z,$Q,t;return!!(s&&((KQ=(a=(ZQ=(r=(BQ=($=s[J])!==null&&$!==void 0?$:s.readableErrored)!==null&&BQ!==void 0?BQ:s.writableErrored)!==null&&r!==void 0?r:(YQ=s._readableState)===null||YQ===void 0?void 0:YQ.errorEmitted)!==null&&ZQ!==void 0?ZQ:(z=s._writableState)===null||z===void 0?void 0:z.errorEmitted)!==null&&a!==void 0?a:($Q=s._readableState)===null||$Q===void 0?void 0:$Q.errored)!==null&&KQ!==void 0?KQ:(t=s._writableState)===null||t===void 0?void 0:t.errored))}Y.exports={kDestroyed:q,isDisturbed:o,kIsDisturbed:Z,isErrored:HQ,kIsErrored:J,isReadable:c,kIsReadable:Q,isClosed:QQ,isDestroyed:aq,isDuplexNodeStream:p,isFinished:d,isIterable:u,isReadableNodeStream:K,isReadableEnded:m,isReadableFinished:tq,isReadableErrored:l,isNodeStream:sq,isWritable:eq,isWritableNodeStream:oq,isWritableEnded:b,isWritableFinished:rq,isWritableErrored:qQ,isServerRequest:n,isServerResponse:XQ,willEmitClose:JQ}}}),N=G({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(B,Y){var{AbortError:U,codes:H}=hQ(),{ERR_INVALID_ARG_TYPE:X,ERR_STREAM_PREMATURE_CLOSE:q}=H,{once:J}=jq(),{validateAbortSignal:Q,validateFunction:Z,validateObject:K}=L(),{Promise:oq}=DQ(),{isClosed:p,isReadable:sq,isReadableNodeStream:u,isReadableFinished:aq,isReadableErrored:b,isWritable:rq,isWritableNodeStream:m,isWritableFinished:tq,isWritableErrored:c,isNodeStream:eq,willEmitClose:d}=j();function qQ(XQ){return XQ.setHeader&&typeof XQ.abort==="function"}var l=()=>{};function QQ(XQ,n,JQ){var o,HQ;if(arguments.length===2)JQ=n,n={};else if(n==null)n={};else K(n,"options");Z(JQ,"callback"),Q(n.signal,"options.signal"),JQ=J(JQ);const s=(o=n.readable)!==null&&o!==void 0?o:u(XQ),KQ=(HQ=n.writable)!==null&&HQ!==void 0?HQ:m(XQ);if(!eq(XQ))throw new X("stream","Stream",XQ);const{_writableState:a,_readableState:ZQ}=XQ,r=()=>{if(!XQ.writable)YQ()};let BQ=d(XQ)&&u(XQ)===s&&m(XQ)===KQ,$=tq(XQ,!1);const YQ=()=>{if($=!0,XQ.destroyed)BQ=!1;if(BQ&&(!XQ.readable||s))return;if(!s||z)JQ.call(XQ)};let z=aq(XQ,!1);const $Q=()=>{if(z=!0,XQ.destroyed)BQ=!1;if(BQ&&(!XQ.writable||KQ))return;if(!KQ||$)JQ.call(XQ)},t=(UQ)=>{JQ.call(XQ,UQ)};let zQ=p(XQ);const e=()=>{zQ=!0;const UQ=c(XQ)||b(XQ);if(UQ&&typeof UQ!=="boolean")return JQ.call(XQ,UQ);if(s&&!z&&u(XQ,!0)){if(!aq(XQ,!1))return JQ.call(XQ,new q)}if(KQ&&!$){if(!tq(XQ,!1))return JQ.call(XQ,new q)}JQ.call(XQ)},VQ=()=>{XQ.req.on("finish",YQ)};if(qQ(XQ)){if(XQ.on("complete",YQ),!BQ)XQ.on("abort",e);if(XQ.req)VQ();else XQ.on("request",VQ)}else if(KQ&&!a)XQ.on("end",r),XQ.on("close",r);if(!BQ&&typeof XQ.aborted==="boolean")XQ.on("aborted",e);if(XQ.on("end",$Q),XQ.on("finish",YQ),n.error!==!1)XQ.on("error",t);if(XQ.on("close",e),zQ)_Q(e);else if(a!==null&&a!==void 0&&a.errorEmitted||ZQ!==null&&ZQ!==void 0&&ZQ.errorEmitted){if(!BQ)_Q(e)}else if(!s&&(!BQ||sq(XQ))&&($||rq(XQ)===!1))_Q(e);else if(!KQ&&(!BQ||rq(XQ))&&(z||sq(XQ)===!1))_Q(e);else if(ZQ&&XQ.req&&XQ.aborted)_Q(e);const qq=()=>{if(JQ=l,XQ.removeListener("aborted",e),XQ.removeListener("complete",YQ),XQ.removeListener("abort",e),XQ.removeListener("request",VQ),XQ.req)XQ.req.removeListener("finish",YQ);XQ.removeListener("end",r),XQ.removeListener("close",r),XQ.removeListener("finish",YQ),XQ.removeListener("end",$Q),XQ.removeListener("error",t),XQ.removeListener("close",e)};if(n.signal&&!zQ){const UQ=()=>{const Qq=JQ;qq(),Qq.call(XQ,new U(void 0,{cause:n.signal.reason}))};if(n.signal.aborted)_Q(UQ);else{const Qq=JQ;JQ=J((...WQ)=>{n.signal.removeEventListener("abort",UQ),Qq.apply(XQ,WQ)}),n.signal.addEventListener("abort",UQ)}}return qq}function i(XQ,n){return new oq((JQ,o)=>{QQ(XQ,n,(HQ)=>{if(HQ)o(HQ);else JQ()})})}Y.exports=QQ,Y.exports.finished=i}}),A=G({"node_modules/readable-stream/lib/internal/streams/operators.js"(B,Y){var{codes:{ERR_INVALID_ARG_TYPE:U,ERR_MISSING_ARGS:H,ERR_OUT_OF_RANGE:X},AbortError:q}=hQ(),{validateAbortSignal:J,validateInteger:Q,validateObject:Z}=L(),K=DQ().Symbol("kWeak"),{finished:oq}=N(),{ArrayPrototypePush:p,MathFloor:sq,Number:u,NumberIsNaN:aq,Promise:b,PromiseReject:rq,PromisePrototypeCatch:m,Symbol:tq}=DQ(),c=tq("kEmpty"),eq=tq("kEof");function d(r,BQ){if(typeof r!=="function")throw new U("fn",["Function","AsyncFunction"],r);if(BQ!=null)Z(BQ,"options");if((BQ===null||BQ===void 0?void 0:BQ.signal)!=null)J(BQ.signal,"options.signal");let $=1;if((BQ===null||BQ===void 0?void 0:BQ.concurrency)!=null)$=sq(BQ.concurrency);return Q($,"concurrency",1),async function*YQ(){var z,$Q;const t=new AbortController,zQ=this,e=[],VQ=t.signal,qq={signal:VQ},UQ=()=>t.abort();if(BQ!==null&&BQ!==void 0&&(z=BQ.signal)!==null&&z!==void 0&&z.aborted)UQ();BQ===null||BQ===void 0||($Q=BQ.signal)===null||$Q===void 0||$Q.addEventListener("abort",UQ);let Qq,WQ,Xq=!1;function GQ(){Xq=!0}async function Jq(){try{for await(let FQ of zQ){var MQ;if(Xq)return;if(VQ.aborted)throw new q;try{FQ=r(FQ,qq)}catch(Kq){FQ=rq(Kq)}if(FQ===c)continue;if(typeof((MQ=FQ)===null||MQ===void 0?void 0:MQ.catch)==="function")FQ.catch(GQ);if(e.push(FQ),Qq)Qq(),Qq=null;if(!Xq&&e.length&&e.length>=$)await new b((Kq)=>{WQ=Kq})}e.push(eq)}catch(FQ){const Kq=rq(FQ);m(Kq,GQ),e.push(Kq)}finally{var Hq;if(Xq=!0,Qq)Qq(),Qq=null;BQ===null||BQ===void 0||(Hq=BQ.signal)===null||Hq===void 0||Hq.removeEventListener("abort",UQ)}}Jq();try{while(!0){while(e.length>0){const MQ=await e[0];if(MQ===eq)return;if(VQ.aborted)throw new q;if(MQ!==c)yield MQ;if(e.shift(),WQ)WQ(),WQ=null}await new b((MQ)=>{Qq=MQ})}}finally{if(t.abort(),Xq=!0,WQ)WQ(),WQ=null}}.call(this)}function qQ(r=void 0){if(r!=null)Z(r,"options");if((r===null||r===void 0?void 0:r.signal)!=null)J(r.signal,"options.signal");return async function*BQ(){let $=0;for await(let z of this){var YQ;if(r!==null&&r!==void 0&&(YQ=r.signal)!==null&&YQ!==void 0&&YQ.aborted)throw new q({cause:r.signal.reason});yield[$++,z]}}.call(this)}async function l(r,BQ=void 0){for await(let $ of n.call(this,r,BQ))return!0;return!1}async function QQ(r,BQ=void 0){if(typeof r!=="function")throw new U("fn",["Function","AsyncFunction"],r);return!await l.call(this,async(...$)=>{return!await r(...$)},BQ)}async function i(r,BQ){for await(let $ of n.call(this,r,BQ))return $;return}async function XQ(r,BQ){if(typeof r!=="function")throw new U("fn",["Function","AsyncFunction"],r);async function $(YQ,z){return await r(YQ,z),c}for await(let YQ of d.call(this,$,BQ));}function n(r,BQ){if(typeof r!=="function")throw new U("fn",["Function","AsyncFunction"],r);async function $(YQ,z){if(await r(YQ,z))return YQ;return c}return d.call(this,$,BQ)}var JQ=class extends H{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function o(r,BQ,$){var YQ;if(typeof r!=="function")throw new U("reducer",["Function","AsyncFunction"],r);if($!=null)Z($,"options");if(($===null||$===void 0?void 0:$.signal)!=null)J($.signal,"options.signal");let z=arguments.length>1;if($!==null&&$!==void 0&&(YQ=$.signal)!==null&&YQ!==void 0&&YQ.aborted){const VQ=new q(void 0,{cause:$.signal.reason});throw this.once("error",()=>{}),await oq(this.destroy(VQ)),VQ}const $Q=new AbortController,t=$Q.signal;if($!==null&&$!==void 0&&$.signal){const VQ={once:!0,[K]:this};$.signal.addEventListener("abort",()=>$Q.abort(),VQ)}let zQ=!1;try{for await(let VQ of this){var e;if(zQ=!0,$!==null&&$!==void 0&&(e=$.signal)!==null&&e!==void 0&&e.aborted)throw new q;if(!z)BQ=VQ,z=!0;else BQ=await r(BQ,VQ,{signal:t})}if(!zQ&&!z)throw new JQ}finally{$Q.abort()}return BQ}async function HQ(r){if(r!=null)Z(r,"options");if((r===null||r===void 0?void 0:r.signal)!=null)J(r.signal,"options.signal");const BQ=[];for await(let YQ of this){var $;if(r!==null&&r!==void 0&&($=r.signal)!==null&&$!==void 0&&$.aborted)throw new q(void 0,{cause:r.signal.reason});p(BQ,YQ)}return BQ}function s(r,BQ){const $=d.call(this,r,BQ);return async function*YQ(){for await(let z of $)yield*z}.call(this)}function KQ(r){if(r=u(r),aq(r))return 0;if(r<0)throw new X("number",">= 0",r);return r}function a(r,BQ=void 0){if(BQ!=null)Z(BQ,"options");if((BQ===null||BQ===void 0?void 0:BQ.signal)!=null)J(BQ.signal,"options.signal");return r=KQ(r),async function*$(){var YQ;if(BQ!==null&&BQ!==void 0&&(YQ=BQ.signal)!==null&&YQ!==void 0&&YQ.aborted)throw new q;for await(let $Q of this){var z;if(BQ!==null&&BQ!==void 0&&(z=BQ.signal)!==null&&z!==void 0&&z.aborted)throw new q;if(r--<=0)yield $Q}}.call(this)}function ZQ(r,BQ=void 0){if(BQ!=null)Z(BQ,"options");if((BQ===null||BQ===void 0?void 0:BQ.signal)!=null)J(BQ.signal,"options.signal");return r=KQ(r),async function*$(){var YQ;if(BQ!==null&&BQ!==void 0&&(YQ=BQ.signal)!==null&&YQ!==void 0&&YQ.aborted)throw new q;for await(let $Q of this){var z;if(BQ!==null&&BQ!==void 0&&(z=BQ.signal)!==null&&z!==void 0&&z.aborted)throw new q;if(r-- >0)yield $Q;else return}}.call(this)}Y.exports.streamReturningOperators={asIndexedPairs:qQ,drop:a,filter:n,flatMap:s,map:d,take:ZQ},Y.exports.promiseReturningOperators={every:QQ,forEach:XQ,reduce:o,toArray:HQ,some:l,find:i}}}),Oq=G({"node_modules/readable-stream/lib/internal/streams/destroy.js"(B,Y){var{aggregateTwoErrors:U,codes:{ERR_MULTIPLE_CALLBACK:H},AbortError:X}=hQ(),{Symbol:q}=DQ(),{kDestroyed:J,isDestroyed:Q,isFinished:Z,isServerRequest:K}=j(),oq="#kDestroy",p="#kConstruct";function sq(n,JQ,o){if(n){if(n.stack,JQ&&!JQ.errored)JQ.errored=n;if(o&&!o.errored)o.errored=n}}function u(n,JQ){const o=this._readableState,HQ=this._writableState,s=HQ||o;if(HQ&&HQ.destroyed||o&&o.destroyed){if(typeof JQ==="function")JQ();return this}if(sq(n,HQ,o),HQ)HQ.destroyed=!0;if(o)o.destroyed=!0;if(!s.constructed)this.once(oq,(KQ)=>{aq(this,U(KQ,n),JQ)});else aq(this,n,JQ);return this}function aq(n,JQ,o){let HQ=!1;function s(KQ){if(HQ)return;HQ=!0;const{_readableState:a,_writableState:ZQ}=n;if(sq(KQ,ZQ,a),ZQ)ZQ.closed=!0;if(a)a.closed=!0;if(typeof o==="function")o(KQ);if(KQ)_Q(b,n,KQ);else _Q(rq,n)}try{n._destroy(JQ||null,s)}catch(KQ){s(KQ)}}function b(n,JQ){m(n,JQ),rq(n)}function rq(n){const{_readableState:JQ,_writableState:o}=n;if(o)o.closeEmitted=!0;if(JQ)JQ.closeEmitted=!0;if(o&&o.emitClose||JQ&&JQ.emitClose)n.emit("close")}function m(n,JQ){const o=n?._readableState,HQ=n?._writableState;if(HQ?.errorEmitted||o?.errorEmitted)return;if(HQ)HQ.errorEmitted=!0;if(o)o.errorEmitted=!0;n?.emit?.("error",JQ)}function tq(){const n=this._readableState,JQ=this._writableState;if(n)n.constructed=!0,n.closed=!1,n.closeEmitted=!1,n.destroyed=!1,n.errored=null,n.errorEmitted=!1,n.reading=!1,n.ended=n.readable===!1,n.endEmitted=n.readable===!1;if(JQ)JQ.constructed=!0,JQ.destroyed=!1,JQ.closed=!1,JQ.closeEmitted=!1,JQ.errored=null,JQ.errorEmitted=!1,JQ.finalCalled=!1,JQ.prefinished=!1,JQ.ended=JQ.writable===!1,JQ.ending=JQ.writable===!1,JQ.finished=JQ.writable===!1}function c(n,JQ,o){const HQ=n?._readableState,s=n?._writableState;if(s&&s.destroyed||HQ&&HQ.destroyed)return this;if(HQ&&HQ.autoDestroy||s&&s.autoDestroy)n.destroy(JQ);else if(JQ){if(Error.captureStackTrace(JQ),s&&!s.errored)s.errored=JQ;if(HQ&&!HQ.errored)HQ.errored=JQ;if(o)_Q(m,n,JQ);else m(n,JQ)}}function eq(n,JQ){if(typeof n._construct!=="function")return;const{_readableState:o,_writableState:HQ}=n;if(o)o.constructed=!1;if(HQ)HQ.constructed=!1;if(n.once(p,JQ),n.listenerCount(p)>1)return;_Q(d,n)}function d(n){let JQ=!1;function o(HQ){if(JQ){c(n,HQ!==null&&HQ!==void 0?HQ:new H);return}JQ=!0;const{_readableState:s,_writableState:KQ}=n,a=KQ||s;if(s)s.constructed=!0;if(KQ)KQ.constructed=!0;if(a.destroyed)n.emit(oq,HQ);else if(HQ)c(n,HQ,!0);else _Q(qQ,n)}try{n._construct(o)}catch(HQ){o(HQ)}}function qQ(n){n.emit(p)}function l(n){return n&&n.setHeader&&typeof n.abort==="function"}function QQ(n){n.emit("close")}function i(n,JQ){n.emit("error",JQ),_Q(QQ,n)}function XQ(n,JQ){if(!n||Q(n))return;if(!JQ&&!Z(n))JQ=new X;if(K(n))n.socket=null,n.destroy(JQ);else if(l(n))n.abort();else if(l(n.req))n.req.abort();else if(typeof n.destroy==="function")n.destroy(JQ);else if(typeof n.close==="function")n.close();else if(JQ)_Q(i,n);else _Q(QQ,n);if(!n.destroyed)n[J]=!0}Y.exports={construct:eq,destroyer:XQ,destroy:u,undestroy:tq,errorOrDestroy:c}}}),pQ=G({"node_modules/readable-stream/lib/internal/streams/legacy.js"(B,Y){var{ArrayIsArray:U,ObjectSetPrototypeOf:H}=DQ();function X(J){if(!(this instanceof X))return new X(J);CQ.call(this,J)}H(X.prototype,CQ.prototype),H(X,CQ),X.prototype.pipe=function(J,Q){const Z=this;function K(rq){if(J.writable&&J.write(rq)===!1&&Z.pause)Z.pause()}Z.on("data",K);function oq(){if(Z.readable&&Z.resume)Z.resume()}if(J.on("drain",oq),!J._isStdio&&(!Q||Q.end!==!1))Z.on("end",sq),Z.on("close",u);let p=!1;function sq(){if(p)return;p=!0,J.end()}function u(){if(p)return;if(p=!0,typeof J.destroy==="function")J.destroy()}function aq(rq){if(b(),CQ.listenerCount(this,"error")===0)this.emit("error",rq)}q(Z,"error",aq),q(J,"error",aq);function b(){Z.removeListener("data",K),J.removeListener("drain",oq),Z.removeListener("end",sq),Z.removeListener("close",u),Z.removeListener("error",aq),J.removeListener("error",aq),Z.removeListener("end",b),Z.removeListener("close",b),J.removeListener("close",b)}return Z.on("end",b),Z.on("close",b),J.on("close",b),J.emit("pipe",Z),J};function q(J,Q,Z){if(typeof J.prependListener==="function")return J.prependListener(Q,Z);if(!J._events||!J._events[Q])J.on(Q,Z);else if(U(J._events[Q]))J._events[Q].unshift(Z);else J._events[Q]=[Z,J._events[Q]]}Y.exports={Stream:X,prependListener:q}}}),_q=G({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(B,Y){var{AbortError:U,codes:H}=hQ(),X=N(),{ERR_INVALID_ARG_TYPE:q}=H,J=(Z,K)=>{if(typeof Z!=="object"||!("aborted"in Z))throw new q(K,"AbortSignal",Z)};function Q(Z){return!!(Z&&typeof Z.pipe==="function")}Y.exports.addAbortSignal=function Z(K,oq){if(J(K,"signal"),!Q(oq))throw new q("stream","stream.Stream",oq);return Y.exports.addAbortSignalNoValidate(K,oq)},Y.exports.addAbortSignalNoValidate=function(Z,K){if(typeof Z!=="object"||!("aborted"in Z))return K;const oq=()=>{K.destroy(new U(void 0,{cause:Z.reason}))};if(Z.aborted)oq();else Z.addEventListener("abort",oq),X(K,()=>Z.removeEventListener("abort",oq));return K}}}),uQ=G({"node_modules/readable-stream/lib/internal/streams/state.js"(B,Y){var{MathFloor:U,NumberIsInteger:H}=DQ(),{ERR_INVALID_ARG_VALUE:X}=hQ().codes;function q(Z,K,oq){return Z.highWaterMark!=null?Z.highWaterMark:K?Z[oq]:null}function J(Z){return Z?16:16384}function Q(Z,K,oq,p){const sq=q(K,p,oq);if(sq!=null){if(!H(sq)||sq<0){const u=p?`options.${oq}`:"options.highWaterMark";throw new X(u,sq)}return U(sq)}return J(Z.objectMode)}Y.exports={getHighWaterMark:Q,getDefaultHighWaterMark:J}}}),Cq=G({"node_modules/readable-stream/lib/internal/streams/from.js"(B,Y){var{PromisePrototypeThen:U,SymbolAsyncIterator:H,SymbolIterator:X}=DQ(),{ERR_INVALID_ARG_TYPE:q,ERR_STREAM_NULL_VALUES:J}=hQ().codes;function Q(Z,K,oq){let p;if(typeof K==="string"||K instanceof Buffer)return new Z({objectMode:!0,...oq,read(){this.push(K),this.push(null)}});let sq;if(K&&K[H])sq=!0,p=K[H]();else if(K&&K[X])sq=!1,p=K[X]();else throw new q("iterable",["Iterable"],K);const u=new Z({objectMode:!0,highWaterMark:1,...oq});let aq=!1;u._read=function(){if(!aq)aq=!0,rq()},u._destroy=function(m,tq){U(b(m),()=>_Q(tq,m),(c)=>_Q(tq,c||m))};async function b(m){const tq=m!==void 0&&m!==null,c=typeof p.throw==="function";if(tq&&c){const{value:eq,done:d}=await p.throw(m);if(await eq,d)return}if(typeof p.return==="function"){const{value:eq}=await p.return();await eq}}async function rq(){for(;;){try{const{value:m,done:tq}=sq?await p.next():p.next();if(tq)u.push(null);else{const c=m&&typeof m.then==="function"?await m:m;if(c===null)throw aq=!1,new J;else if(u.push(c))continue;else aq=!1}}catch(m){u.destroy(m)}break}}return u}Y.exports=Q}}),bQ,Dq,mQ=G({"node_modules/readable-stream/lib/internal/streams/readable.js"(B,Y){var{ArrayPrototypeIndexOf:U,NumberIsInteger:H,NumberIsNaN:X,NumberParseInt:q,ObjectDefineProperties:J,ObjectKeys:Q,ObjectSetPrototypeOf:Z,Promise:K,SafeSet:oq,SymbolAsyncIterator:p,Symbol:sq}=DQ(),u=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{Stream:aq,prependListener:b}=pQ();function rq(FQ){if(!(this instanceof rq))return new rq(FQ);const Kq=this instanceof wQ();if(this._readableState=new u(FQ,this,Kq),FQ){const{read:LQ,destroy:Zq,construct:jQ,signal:Bq}=FQ;if(typeof LQ==="function")this._read=LQ;if(typeof Zq==="function")this._destroy=Zq;if(typeof jQ==="function")this._construct=jQ;if(Bq&&!Kq)c(Bq,this)}aq.call(this,FQ),n.construct(this,()=>{if(this._readableState.needReadable)i(this,this._readableState)})}Z(rq.prototype,aq.prototype),Z(rq,aq),rq.prototype.on=function(FQ,Kq){const LQ=aq.prototype.on.call(this,FQ,Kq),Zq=this._readableState;if(FQ==="data")if(Zq.readableListening=this.listenerCount("readable")>0,Zq.flowing!==!1)OQ&&Gq("in flowing mode!",this.__id),this.resume();else OQ&&Gq("in readable mode!",this.__id);else if(FQ==="readable"){if(OQ&&Gq("readable listener added!",this.__id),!Zq.endEmitted&&!Zq.readableListening){if(Zq.readableListening=Zq.needReadable=!0,Zq.flowing=!1,Zq.emittedReadable=!1,OQ&&Gq("on readable - state.length, reading, emittedReadable",Zq.length,Zq.reading,Zq.emittedReadable,this.__id),Zq.length)XQ(this,Zq);else if(!Zq.reading)_Q(qq,this)}else if(Zq.endEmitted)OQ&&Gq("end already emitted...",this.__id)}return LQ};class m extends rq{#q;#Q;#X;#J;constructor(FQ,Kq){const{objectMode:LQ,highWaterMark:Zq,encoding:jQ,signal:Bq}=FQ;super({objectMode:LQ,highWaterMark:Zq,encoding:jQ,signal:Bq});this.#X=[],this.#q=void 0,this.#J=Kq,this.#Q=!1}#H(){var FQ=this.#X,Kq=0,LQ=FQ.length;for(;Kq0)this.#X=[];return!1}#K(FQ){FQ.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){OQ&&Gq("ReadableFromWeb _read()",this.__id);var FQ=this.#J,Kq=this.#q;if(FQ)Kq=this.#q=FQ.getReader(),this.#J=void 0;else if(this.#H())return;var LQ;try{do{var Zq=!1,jQ;const Bq=Kq.readMany();if(Lq(Bq)){if({done:Zq,value:jQ}=await Bq,this.#Q){this.#X.push(...jQ);return}}else({done:Zq,value:jQ}=Bq);if(Zq){this.#K(Kq);return}if(!this.push(jQ[0])){this.#X=jQ.slice(1);return}for(let NQ=1,Yq=jQ.length;NQ{this.#Q=!0,Kq(FQ)});return}try{Kq(FQ)}catch(Zq){globalThis.reportError(Zq)}}}Dq=m;function tq(FQ,Kq={}){if(!M(FQ))throw new o("readableStream","ReadableStream",FQ);ZQ(Kq,"options");const{highWaterMark:LQ,encoding:Zq,objectMode:jQ=!1,signal:Bq}=Kq;if(Zq!==void 0&&!Buffer.isEncoding(Zq))throw new xq(Zq,"options.encoding");return F(jQ,"options.objectMode"),_(rq,FQ,Kq)||new m({highWaterMark:LQ,encoding:Zq,objectMode:jQ,signal:Bq},FQ)}Y.exports=rq,bQ=tq;var{addAbortSignal:c}=_q(),eq=N();const{maybeReadMore:d,resume:qQ,emitReadable:l,onEofChunk:QQ}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function i(FQ,Kq){process.nextTick(d,FQ,Kq)}function XQ(FQ,Kq){OQ&&Gq("NativeReadable - emitReadable",FQ.__id),l(FQ,Kq)}var n=Oq(),{aggregateTwoErrors:JQ,codes:{ERR_INVALID_ARG_TYPE:o,ERR_METHOD_NOT_IMPLEMENTED:HQ,ERR_OUT_OF_RANGE:s,ERR_STREAM_PUSH_AFTER_EOF:KQ,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:a}}=hQ(),{validateObject:ZQ}=L(),r=Cq(),BQ=()=>{},{errorOrDestroy:$}=n;rq.prototype.destroy=n.destroy,rq.prototype._undestroy=n.undestroy,rq.prototype._destroy=function(FQ,Kq){Kq(FQ)},rq.prototype[CQ.captureRejectionSymbol]=function(FQ){this.destroy(FQ)},rq.prototype.push=function(FQ,Kq){return YQ(this,FQ,Kq,!1)},rq.prototype.unshift=function(FQ,Kq){return YQ(this,FQ,Kq,!0)};function YQ(FQ,Kq,LQ,Zq){OQ&&Gq("readableAddChunk",Kq,FQ.__id);const jQ=FQ._readableState;let Bq;if(!jQ.objectMode){if(typeof Kq==="string"){if(LQ=LQ||jQ.defaultEncoding,jQ.encoding!==LQ)if(Zq&&jQ.encoding)Kq=Buffer.from(Kq,LQ).toString(jQ.encoding);else Kq=Buffer.from(Kq,LQ),LQ=""}else if(Kq instanceof Buffer)LQ="";else if(aq._isUint8Array(Kq)){if(Zq||!jQ.decoder)Kq=aq._uint8ArrayToBuffer(Kq);LQ=""}else if(Kq!=null)Bq=new o("chunk",["string","Buffer","Uint8Array"],Kq)}if(Bq)$(FQ,Bq);else if(Kq===null)jQ.reading=!1,QQ(FQ,jQ);else if(jQ.objectMode||Kq&&Kq.length>0)if(Zq)if(jQ.endEmitted)$(FQ,new a);else if(jQ.destroyed||jQ.errored)return!1;else z(FQ,jQ,Kq,!0);else if(jQ.ended)$(FQ,new KQ);else if(jQ.destroyed||jQ.errored)return!1;else if(jQ.reading=!1,jQ.decoder&&!LQ)if(Kq=jQ.decoder.write(Kq),jQ.objectMode||Kq.length!==0)z(FQ,jQ,Kq,!1);else i(FQ,jQ);else z(FQ,jQ,Kq,!1);else if(!Zq)jQ.reading=!1,i(FQ,jQ);return!jQ.ended&&(jQ.length0){if(Kq.multiAwaitDrain)Kq.awaitDrainWriters.clear();else Kq.awaitDrainWriters=null;Kq.dataEmitted=!0,FQ.emit("data",LQ)}else{if(Kq.length+=Kq.objectMode?1:LQ.length,Zq)Kq.buffer.unshift(LQ);else Kq.buffer.push(LQ);if(OQ&&Gq("needReadable @ addChunk",Kq.needReadable,FQ.__id),Kq.needReadable)XQ(FQ,Kq)}i(FQ,Kq)}rq.prototype.isPaused=function(){const FQ=this._readableState;return FQ.paused===!0||FQ.flowing===!1},rq.prototype.setEncoding=function(FQ){const Kq=new Eq(FQ);this._readableState.decoder=Kq,this._readableState.encoding=this._readableState.decoder.encoding;const LQ=this._readableState.buffer;let Zq="";for(let jQ=LQ.length;jQ>0;jQ--)Zq+=Kq.write(LQ.shift());if(Zq!=="")LQ.push(Zq);return this._readableState.length=Zq.length,this};var $Q=1073741824;function t(FQ){if(FQ>$Q)throw new s("size","<= 1GiB",FQ);else FQ--,FQ|=FQ>>>1,FQ|=FQ>>>2,FQ|=FQ>>>4,FQ|=FQ>>>8,FQ|=FQ>>>16,FQ++;return FQ}function zQ(FQ,Kq){if(FQ<=0||Kq.length===0&&Kq.ended)return 0;if(Kq.objectMode)return 1;if(X(FQ)){if(Kq.flowing&&Kq.length)return Kq.buffer.first().length;return Kq.length}if(FQ<=Kq.length)return FQ;return Kq.ended?Kq.length:0}rq.prototype.read=function(FQ){if(OQ&&Gq("read - n =",FQ,this.__id),!H(FQ))FQ=q(FQ,10);const Kq=this._readableState,LQ=FQ;if(FQ>Kq.highWaterMark)Kq.highWaterMark=t(FQ);if(FQ!==0)Kq.emittedReadable=!1;if(FQ===0&&Kq.needReadable&&((Kq.highWaterMark!==0?Kq.length>=Kq.highWaterMark:Kq.length>0)||Kq.ended)){if(OQ&&Gq("read: emitReadable or endReadable",Kq.length,Kq.ended,this.__id),Kq.length===0&&Kq.ended)Xq(this);else XQ(this,Kq);return null}if(FQ=zQ(FQ,Kq),FQ===0&&Kq.ended){if(OQ&&Gq("read: calling endReadable if length 0 -- length, state.ended",Kq.length,Kq.ended,this.__id),Kq.length===0)Xq(this);return null}let Zq=Kq.needReadable;if(OQ&&Gq("need readable",Zq,this.__id),Kq.length===0||Kq.length-FQ0)Bq=WQ(FQ,Kq);else Bq=null;if(OQ&&Gq("ret @ read",Bq,this.__id),Bq===null)Kq.needReadable=Kq.length<=Kq.highWaterMark,OQ&&Gq("state.length while ret = null",Kq.length,this.__id),FQ=0;else if(Kq.length-=FQ,Kq.multiAwaitDrain)Kq.awaitDrainWriters.clear();else Kq.awaitDrainWriters=null;if(Kq.length===0){if(!Kq.ended)Kq.needReadable=!0;if(LQ!==FQ&&Kq.ended)Xq(this)}if(Bq!==null&&!Kq.errorEmitted&&!Kq.closeEmitted)Kq.dataEmitted=!0,this.emit("data",Bq);return Bq},rq.prototype._read=function(FQ){throw new HQ("_read()")},rq.prototype.pipe=function(FQ,Kq){const LQ=this,Zq=this._readableState;if(Zq.pipes.length===1){if(!Zq.multiAwaitDrain)Zq.multiAwaitDrain=!0,Zq.awaitDrainWriters=new oq(Zq.awaitDrainWriters?[Zq.awaitDrainWriters]:[])}Zq.pipes.push(FQ),OQ&&Gq("pipe count=%d opts=%j",Zq.pipes.length,Kq,LQ.__id);const Bq=(!Kq||Kq.end!==!1)&&FQ!==process.stdout&&FQ!==process.stderr?Yq:PQ;if(Zq.endEmitted)_Q(Bq);else LQ.once("end",Bq);FQ.on("unpipe",NQ);function NQ(Wq,xQ){if(OQ&&Gq("onunpipe",LQ.__id),Wq===LQ){if(xQ&&xQ.hasUnpiped===!1)xQ.hasUnpiped=!0,EQ()}}function Yq(){OQ&&Gq("onend",LQ.__id),FQ.end()}let AQ,$q=!1;function EQ(){if(OQ&&Gq("cleanup",LQ.__id),FQ.removeListener("close",TQ),FQ.removeListener("finish",Uq),AQ)FQ.removeListener("drain",AQ);if(FQ.removeListener("error",Vq),FQ.removeListener("unpipe",NQ),LQ.removeListener("end",Yq),LQ.removeListener("end",PQ),LQ.removeListener("data",IQ),$q=!0,AQ&&Zq.awaitDrainWriters&&(!FQ._writableState||FQ._writableState.needDrain))AQ()}function zq(){if(!$q){if(Zq.pipes.length===1&&Zq.pipes[0]===FQ)OQ&&Gq("false write response, pause",0,LQ.__id),Zq.awaitDrainWriters=FQ,Zq.multiAwaitDrain=!1;else if(Zq.pipes.length>1&&Zq.pipes.includes(FQ))OQ&&Gq("false write response, pause",Zq.awaitDrainWriters.size,LQ.__id),Zq.awaitDrainWriters.add(FQ);LQ.pause()}if(!AQ)AQ=e(LQ,FQ),FQ.on("drain",AQ)}LQ.on("data",IQ);function IQ(Wq){OQ&&Gq("ondata",LQ.__id);const xQ=FQ.write(Wq);if(OQ&&Gq("dest.write",xQ,LQ.__id),xQ===!1)zq()}function Vq(Wq){if(Gq("onerror",Wq),PQ(),FQ.removeListener("error",Vq),FQ.listenerCount("error")===0){const xQ=FQ._writableState||FQ._readableState;if(xQ&&!xQ.errorEmitted)$(FQ,Wq);else FQ.emit("error",Wq)}}b(FQ,"error",Vq);function TQ(){FQ.removeListener("finish",Uq),PQ()}FQ.once("close",TQ);function Uq(){Gq("onfinish"),FQ.removeListener("close",TQ),PQ()}FQ.once("finish",Uq);function PQ(){Gq("unpipe"),LQ.unpipe(FQ)}if(FQ.emit("pipe",LQ),FQ.writableNeedDrain===!0){if(Zq.flowing)zq()}else if(!Zq.flowing)Gq("pipe resume"),LQ.resume();return FQ};function e(FQ,Kq){return function LQ(){const Zq=FQ._readableState;if(Zq.awaitDrainWriters===Kq)Gq("pipeOnDrain",1),Zq.awaitDrainWriters=null;else if(Zq.multiAwaitDrain)Gq("pipeOnDrain",Zq.awaitDrainWriters.size),Zq.awaitDrainWriters.delete(Kq);if((!Zq.awaitDrainWriters||Zq.awaitDrainWriters.size===0)&&FQ.listenerCount("data"))FQ.resume()}}rq.prototype.unpipe=function(FQ){const Kq=this._readableState,LQ={hasUnpiped:!1};if(Kq.pipes.length===0)return this;if(!FQ){const jQ=Kq.pipes;Kq.pipes=[],this.pause();for(let Bq=0;Bq0,Kq.resumeScheduled&&Kq.paused===!1)Kq.flowing=!0;else if(FQ.listenerCount("data")>0)FQ.resume();else if(!Kq.readableListening)Kq.flowing=null}function qq(FQ){OQ&&Gq("on readable nextTick, calling read(0)",FQ.__id),FQ.read(0)}rq.prototype.resume=function(){const FQ=this._readableState;if(!FQ.flowing)OQ&&Gq("resume",this.__id),FQ.flowing=!FQ.readableListening,qQ(this,FQ);return FQ.paused=!1,this},rq.prototype.pause=function(){if(OQ&&Gq("call pause flowing=%j",this._readableState.flowing,this.__id),this._readableState.flowing!==!1)OQ&&Gq("pause",this.__id),this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},rq.prototype.wrap=function(FQ){let Kq=!1;FQ.on("data",(Zq)=>{if(!this.push(Zq)&&FQ.pause)Kq=!0,FQ.pause()}),FQ.on("end",()=>{this.push(null)}),FQ.on("error",(Zq)=>{$(this,Zq)}),FQ.on("close",()=>{this.destroy()}),FQ.on("destroy",()=>{this.destroy()}),this._read=()=>{if(Kq&&FQ.resume)Kq=!1,FQ.resume()};const LQ=Q(FQ);for(let Zq=1;Zq{jQ=NQ?JQ(jQ,NQ):null,LQ(),LQ=BQ});try{while(!0){const NQ=FQ.destroyed?null:FQ.read();if(NQ!==null)yield NQ;else if(jQ)throw jQ;else if(jQ===null)return;else await new K(Zq)}}catch(NQ){throw jQ=JQ(jQ,NQ),jQ}finally{if((jQ||(Kq===null||Kq===void 0?void 0:Kq.destroyOnReturn)!==!1)&&(jQ===void 0||FQ._readableState.autoDestroy))n.destroyer(FQ,null);else FQ.off("readable",Zq),Bq()}}J(rq.prototype,{readable:{get(){const FQ=this._readableState;return!!FQ&&FQ.readable!==!1&&!FQ.destroyed&&!FQ.errorEmitted&&!FQ.endEmitted},set(FQ){if(this._readableState)this._readableState.readable=!!FQ}},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(FQ){if(this._readableState)this._readableState.flowing=FQ}},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(FQ){if(!this._readableState)return;this._readableState.destroyed=FQ}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),rq._fromList=WQ;function WQ(FQ,Kq){if(Kq.length===0)return null;let LQ;if(Kq.objectMode)LQ=Kq.buffer.shift();else if(!FQ||FQ>=Kq.length){if(Kq.decoder)LQ=Kq.buffer.join("");else if(Kq.buffer.length===1)LQ=Kq.buffer.first();else LQ=Kq.buffer.concat(Kq.length);Kq.buffer.clear()}else LQ=Kq.buffer.consume(FQ,Kq.decoder);return LQ}function Xq(FQ){const Kq=FQ._readableState;if(OQ&&Gq("endEmitted @ endReadable",Kq.endEmitted,FQ.__id),!Kq.endEmitted)Kq.ended=!0,_Q(GQ,Kq,FQ)}function GQ(FQ,Kq){if(OQ&&Gq("endReadableNT -- endEmitted, state.length",FQ.endEmitted,FQ.length,Kq.__id),!FQ.errored&&!FQ.closeEmitted&&!FQ.endEmitted&&FQ.length===0){if(FQ.endEmitted=!0,Kq.emit("end"),OQ&&Gq("end emitted @ endReadableNT",Kq.__id),Kq.writable&&Kq.allowHalfOpen===!1)_Q(Jq,Kq);else if(FQ.autoDestroy){const LQ=Kq._writableState;if(!LQ||LQ.autoDestroy&&(LQ.finished||LQ.writable===!1))Kq.destroy()}}}function Jq(FQ){if(FQ.writable&&!FQ.writableEnded&&!FQ.destroyed)FQ.end()}rq.from=function(FQ,Kq){return r(rq,FQ,Kq)};var MQ={newStreamReadableFromReadableStream:tq};function Hq(){if(MQ===void 0)MQ={};return MQ}rq.fromWeb=function(FQ,Kq){return Hq().newStreamReadableFromReadableStream(FQ,Kq)},rq.toWeb=function(FQ){return Hq().newReadableStreamFromStreamReadable(FQ)},rq.wrap=function(FQ,Kq){var LQ,Zq;return new rq({objectMode:(LQ=(Zq=FQ.readableObjectMode)!==null&&Zq!==void 0?Zq:FQ.objectMode)!==null&&LQ!==void 0?LQ:!0,...Kq,destroy(jQ,Bq){n.destroyer(FQ,jQ),Bq(jQ)}}).wrap(FQ)}}}),wq=G({"node_modules/readable-stream/lib/internal/streams/writable.js"(B,Y){var{ArrayPrototypeSlice:U,Error:H,FunctionPrototypeSymbolHasInstance:X,ObjectDefineProperty:q,ObjectDefineProperties:J,ObjectSetPrototypeOf:Q,StringPrototypeToLowerCase:Z,Symbol:K,SymbolHasInstance:oq}=DQ(),p=pQ().Stream,sq=Oq(),{addAbortSignal:u}=_q(),{getHighWaterMark:aq,getDefaultHighWaterMark:b}=uQ(),{ERR_INVALID_ARG_TYPE:rq,ERR_METHOD_NOT_IMPLEMENTED:m,ERR_MULTIPLE_CALLBACK:tq,ERR_STREAM_CANNOT_PIPE:c,ERR_STREAM_DESTROYED:eq,ERR_STREAM_ALREADY_FINISHED:d,ERR_STREAM_NULL_VALUES:qQ,ERR_STREAM_WRITE_AFTER_END:l,ERR_UNKNOWN_ENCODING:QQ}=hQ().codes,{errorOrDestroy:i}=sq;function XQ(WQ={}){const Xq=this instanceof wQ();if(!Xq&&!X(XQ,this))return new XQ(WQ);if(this._writableState=new o(WQ,this,Xq),WQ){if(typeof WQ.write==="function")this._write=WQ.write;if(typeof WQ.writev==="function")this._writev=WQ.writev;if(typeof WQ.destroy==="function")this._destroy=WQ.destroy;if(typeof WQ.final==="function")this._final=WQ.final;if(typeof WQ.construct==="function")this._construct=WQ.construct;if(WQ.signal)u(WQ.signal,this)}p.call(this,WQ),sq.construct(this,()=>{const GQ=this._writableState;if(!GQ.writing)z(this,GQ);e(this,GQ)})}Q(XQ.prototype,p.prototype),Q(XQ,p),Y.exports=XQ;function n(){}var JQ=K("kOnFinished");function o(WQ,Xq,GQ){if(typeof GQ!=="boolean")GQ=Xq instanceof wQ();if(this.objectMode=!!(WQ&&WQ.objectMode),GQ)this.objectMode=this.objectMode||!!(WQ&&WQ.writableObjectMode);this.highWaterMark=WQ?aq(this,WQ,"writableHighWaterMark",GQ):b(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const Jq=!!(WQ&&WQ.decodeStrings===!1);this.decodeStrings=!Jq,this.defaultEncoding=WQ&&WQ.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=r.bind(void 0,Xq),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,HQ(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!WQ||WQ.emitClose!==!1,this.autoDestroy=!WQ||WQ.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[JQ]=[]}function HQ(WQ){WQ.buffered=[],WQ.bufferedIndex=0,WQ.allBuffers=!0,WQ.allNoop=!0}o.prototype.getBuffer=function WQ(){return U(this.buffered,this.bufferedIndex)},q(o.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),q(XQ,oq,{value:function(WQ){if(X(this,WQ))return!0;if(this!==XQ)return!1;return WQ&&WQ._writableState instanceof o}}),XQ.prototype.pipe=function(){i(this,new c)};function s(WQ,Xq,GQ,Jq){const MQ=WQ._writableState;if(typeof GQ==="function")Jq=GQ,GQ=MQ.defaultEncoding;else{if(!GQ)GQ=MQ.defaultEncoding;else if(GQ!=="buffer"&&!Buffer.isEncoding(GQ))throw new QQ(GQ);if(typeof Jq!=="function")Jq=n}if(Xq===null)throw new qQ;else if(!MQ.objectMode)if(typeof Xq==="string"){if(MQ.decodeStrings!==!1)Xq=Buffer.from(Xq,GQ),GQ="buffer"}else if(Xq instanceof Buffer)GQ="buffer";else if(p._isUint8Array(Xq))Xq=p._uint8ArrayToBuffer(Xq),GQ="buffer";else throw new rq("chunk",["string","Buffer","Uint8Array"],Xq);let Hq;if(MQ.ending)Hq=new l;else if(MQ.destroyed)Hq=new eq("write");if(Hq)return _Q(Jq,Hq),i(WQ,Hq,!0),Hq;return MQ.pendingcb++,KQ(WQ,MQ,Xq,GQ,Jq)}XQ.prototype.write=function(WQ,Xq,GQ){return s(this,WQ,Xq,GQ)===!0},XQ.prototype.cork=function(){this._writableState.corked++},XQ.prototype.uncork=function(){const WQ=this._writableState;if(WQ.corked){if(WQ.corked--,!WQ.writing)z(this,WQ)}},XQ.prototype.setDefaultEncoding=function WQ(Xq){if(typeof Xq==="string")Xq=Z(Xq);if(!Buffer.isEncoding(Xq))throw new QQ(Xq);return this._writableState.defaultEncoding=Xq,this};function KQ(WQ,Xq,GQ,Jq,MQ){const Hq=Xq.objectMode?1:GQ.length;Xq.length+=Hq;const FQ=Xq.lengthGQ.bufferedIndex)z(WQ,GQ);if(Jq)if(GQ.afterWriteTickInfo!==null&&GQ.afterWriteTickInfo.cb===MQ)GQ.afterWriteTickInfo.count++;else GQ.afterWriteTickInfo={count:1,cb:MQ,stream:WQ,state:GQ},_Q(BQ,GQ.afterWriteTickInfo);else $(WQ,GQ,1,MQ)}}function BQ({stream:WQ,state:Xq,count:GQ,cb:Jq}){return Xq.afterWriteTickInfo=null,$(WQ,Xq,GQ,Jq)}function $(WQ,Xq,GQ,Jq){if(!Xq.ending&&!WQ.destroyed&&Xq.length===0&&Xq.needDrain)Xq.needDrain=!1,WQ.emit("drain");while(GQ-- >0)Xq.pendingcb--,Jq();if(Xq.destroyed)YQ(Xq);e(WQ,Xq)}function YQ(WQ){if(WQ.writing)return;for(let MQ=WQ.bufferedIndex;MQ1&&WQ._writev){Xq.pendingcb-=Hq-1;const Kq=Xq.allNoop?n:(Zq)=>{for(let jQ=FQ;jQ256)GQ.splice(0,FQ),Xq.bufferedIndex=0;else Xq.bufferedIndex=FQ}Xq.bufferProcessing=!1}XQ.prototype._write=function(WQ,Xq,GQ){if(this._writev)this._writev([{chunk:WQ,encoding:Xq}],GQ);else throw new m("_write()")},XQ.prototype._writev=null,XQ.prototype.end=function(WQ,Xq,GQ,Jq=!1){const MQ=this._writableState;if(OQ&&Gq("end",MQ,this.__id),typeof WQ==="function")GQ=WQ,WQ=null,Xq=null;else if(typeof Xq==="function")GQ=Xq,Xq=null;let Hq;if(WQ!==null&&WQ!==void 0){let FQ;if(!Jq)FQ=s(this,WQ,Xq);else FQ=this.write(WQ,Xq);if(FQ instanceof H)Hq=FQ}if(MQ.corked)MQ.corked=1,this.uncork();if(Hq)this.emit("error",Hq);else if(!MQ.errored&&!MQ.ending)MQ.ending=!0,e(this,MQ,!0),MQ.ended=!0;else if(MQ.finished)Hq=new d("end");else if(MQ.destroyed)Hq=new eq("end");if(typeof GQ==="function")if(Hq||MQ.finished)_Q(GQ,Hq);else MQ[JQ].push(GQ);return this};function $Q(WQ,Xq){var GQ=WQ.ending&&!WQ.destroyed&&WQ.constructed&&WQ.length===0&&!WQ.errored&&WQ.buffered.length===0&&!WQ.finished&&!WQ.writing&&!WQ.errorEmitted&&!WQ.closeEmitted;return Gq("needFinish",GQ,Xq),GQ}function t(WQ,Xq){let GQ=!1;function Jq(MQ){if(GQ){i(WQ,MQ!==null&&MQ!==void 0?MQ:tq());return}if(GQ=!0,Xq.pendingcb--,MQ){const Hq=Xq[JQ].splice(0);for(let FQ=0;FQ{if($Q(MQ))VQ(Jq,MQ);else MQ.pendingcb--},WQ,Xq);else if($Q(Xq))Xq.pendingcb++,VQ(WQ,Xq)}}function VQ(WQ,Xq){Xq.pendingcb--,Xq.finished=!0;const GQ=Xq[JQ].splice(0);for(let Jq=0;Jq{if(ZQ!=null)throw new sq("nully","body",ZQ)},(ZQ)=>{u(KQ,ZQ)});return KQ=new eq({objectMode:!0,readable:!1,write:JQ,final(ZQ){o(async()=>{try{await a,_Q(ZQ,null)}catch(r){_Q(ZQ,r)}})},destroy:HQ})}throw new sq("Iterable, AsyncIterable or AsyncFunction",i,n)}if(tq(QQ))return l(QQ.arrayBuffer());if(X(QQ))return m(eq,QQ,{objectMode:!0,writable:!1});if(typeof(QQ===null||QQ===void 0?void 0:QQ.writable)==="object"||typeof(QQ===null||QQ===void 0?void 0:QQ.readable)==="object"){const n=QQ!==null&&QQ!==void 0&&QQ.readable?J(QQ===null||QQ===void 0?void 0:QQ.readable)?QQ===null||QQ===void 0?void 0:QQ.readable:l(QQ.readable):void 0,JQ=QQ!==null&&QQ!==void 0&&QQ.writable?Q(QQ===null||QQ===void 0?void 0:QQ.writable)?QQ===null||QQ===void 0?void 0:QQ.writable:l(QQ.writable):void 0;return qQ({readable:n,writable:JQ})}const XQ=QQ===null||QQ===void 0?void 0:QQ.then;if(typeof XQ==="function"){let n;return c(XQ,QQ,(JQ)=>{if(JQ!=null)n.push(JQ);n.push(null)},(JQ)=>{u(n,JQ)}),n=new eq({objectMode:!0,writable:!1,read(){}})}throw new p(i,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],QQ)};function d(l){let{promise:QQ,resolve:i}=rq();const XQ=new AbortController,n=XQ.signal;return{value:l(async function*(){while(!0){const o=QQ;QQ=null;const{chunk:HQ,done:s,cb:KQ}=await o;if(_Q(KQ),s)return;if(n.aborted)throw new oq(void 0,{cause:n.reason});({promise:QQ,resolve:i}=rq()),yield HQ}}(),{signal:n}),write(o,HQ,s){const KQ=i;i=null,KQ({chunk:o,done:!1,cb:s})},final(o){const HQ=i;i=null,HQ({done:!0,cb:o})},destroy(o,HQ){XQ.abort(),HQ(o)}}}function qQ(l){const QQ=l.readable&&typeof l.readable.read!=="function"?b.wrap(l.readable):l.readable,i=l.writable;let XQ=!!U(QQ),n=!!H(i),JQ,o,HQ,s,KQ;function a(ZQ){const r=s;if(s=null,r)r(ZQ);else if(ZQ)KQ.destroy(ZQ);else if(!XQ&&!n)KQ.destroy()}if(KQ=new eq({readableObjectMode:!!(QQ!==null&&QQ!==void 0&&QQ.readableObjectMode),writableObjectMode:!!(i!==null&&i!==void 0&&i.writableObjectMode),readable:XQ,writable:n}),n)K(i,(ZQ)=>{if(n=!1,ZQ)u(QQ,ZQ);a(ZQ)}),KQ._write=function(ZQ,r,BQ){if(i.write(ZQ,r))BQ();else JQ=BQ},KQ._final=function(ZQ){i.end(),o=ZQ},i.on("drain",function(){if(JQ){const ZQ=JQ;JQ=null,ZQ()}}),i.on("finish",function(){if(o){const ZQ=o;o=null,ZQ()}});if(XQ)K(QQ,(ZQ)=>{if(XQ=!1,ZQ)u(QQ,ZQ);a(ZQ)}),QQ.on("readable",function(){if(HQ){const ZQ=HQ;HQ=null,ZQ()}}),QQ.on("end",function(){KQ.push(null)}),KQ._read=function(){while(!0){const ZQ=QQ.read();if(ZQ===null){HQ=KQ._read;return}if(!KQ.push(ZQ))return}};return KQ._destroy=function(ZQ,r){if(!ZQ&&s!==null)ZQ=new oq;if(HQ=null,JQ=null,o=null,s===null)r(ZQ);else s=r,u(i,ZQ),u(QQ,ZQ)},KQ}}}),wQ=G({"node_modules/readable-stream/lib/internal/streams/duplex.js"(B,Y){var{ObjectDefineProperties:U,ObjectGetOwnPropertyDescriptor:H,ObjectKeys:X,ObjectSetPrototypeOf:q}=DQ(),J=mQ();function Q(sq){if(!(this instanceof Q))return new Q(sq);if(J.call(this,sq),Mq.call(this,sq),sq){if(this.allowHalfOpen=sq.allowHalfOpen!==!1,sq.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(sq.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}Y.exports=Q,q(Q.prototype,J.prototype),q(Q,J);for(var Z in Mq.prototype)if(!Q.prototype[Z])Q.prototype[Z]=Mq.prototype[Z];U(Q.prototype,{writable:H(Mq.prototype,"writable"),writableHighWaterMark:H(Mq.prototype,"writableHighWaterMark"),writableObjectMode:H(Mq.prototype,"writableObjectMode"),writableBuffer:H(Mq.prototype,"writableBuffer"),writableLength:H(Mq.prototype,"writableLength"),writableFinished:H(Mq.prototype,"writableFinished"),writableCorked:H(Mq.prototype,"writableCorked"),writableEnded:H(Mq.prototype,"writableEnded"),writableNeedDrain:H(Mq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(sq){if(this._readableState&&this._writableState)this._readableState.destroyed=sq,this._writableState.destroyed=sq}}});var K;function oq(){if(K===void 0)K={};return K}Q.fromWeb=function(sq,u){return oq().newStreamDuplexFromReadableWritablePair(sq,u)},Q.toWeb=function(sq){return oq().newReadableWritablePairFromDuplex(sq)};var p;Q.from=function(sq){if(!p)p=cQ();return p(sq,"body")}}}),vq=G({"node_modules/readable-stream/lib/internal/streams/transform.js"(B,Y){var{ObjectSetPrototypeOf:U,Symbol:H}=DQ(),{ERR_METHOD_NOT_IMPLEMENTED:X}=hQ().codes,q=wQ();function J(oq){if(!(this instanceof J))return new J(oq);if(q.call(this,oq),this._readableState.sync=!1,this[Q]=null,oq){if(typeof oq.transform==="function")this._transform=oq.transform;if(typeof oq.flush==="function")this._flush=oq.flush}this.on("prefinish",K.bind(this))}U(J.prototype,q.prototype),U(J,q),Y.exports=J;var Q=H("kCallback");function Z(oq){if(typeof this._flush==="function"&&!this.destroyed)this._flush((p,sq)=>{if(p){if(oq)oq(p);else this.destroy(p);return}if(sq!=null)this.push(sq);if(this.push(null),oq)oq()});else if(this.push(null),oq)oq()}function K(){if(this._final!==Z)Z.call(this)}J.prototype._final=Z,J.prototype._transform=function(oq,p,sq){throw new X("_transform()")},J.prototype._write=function(oq,p,sq){const u=this._readableState,aq=this._writableState,b=u.length;this._transform(oq,p,(rq,m)=>{if(rq){sq(rq);return}if(m!=null)this.push(m);if(aq.ended||b===u.length||u.length{ZQ=!0});const r=q(s,{readable:KQ,writable:a},(BQ)=>{ZQ=!BQ});return{destroy:(BQ)=>{if(ZQ)return;ZQ=!0,Q.destroyer(s,BQ||new u("pipe"))},cleanup:r}}function QQ(s){return b(s[s.length-1],"streams[stream.length - 1]"),s.pop()}function i(s){if(m(s))return s;else if(c(s))return XQ(s);throw new oq("val",["Readable","Iterable","AsyncIterable"],s)}async function*XQ(s){if(!qQ)qQ=mQ();yield*qQ.prototype[X].call(s)}async function n(s,KQ,a,{end:ZQ}){let r,BQ=null;const $=($Q)=>{if($Q)r=$Q;if(BQ){const t=BQ;BQ=null,t()}},YQ=()=>new H(($Q,t)=>{if(r)t(r);else BQ=()=>{if(r)t(r);else $Q()}});KQ.on("drain",$);const z=q(KQ,{readable:!1},$);try{if(KQ.writableNeedDrain)await YQ();for await(let $Q of s)if(!KQ.write($Q))await YQ();if(ZQ)KQ.end();await YQ(),a()}catch($Q){a(r!==$Q?K(r,$Q):$Q)}finally{z(),KQ.off("drain",$)}}function JQ(...s){return o(s,J(QQ(s)))}function o(s,KQ,a){if(s.length===1&&U(s[0]))s=s[0];if(s.length<2)throw new sq("streams");const ZQ=new AbortController,r=ZQ.signal,BQ=a===null||a===void 0?void 0:a.signal,$=[];rq(BQ,"options.signal");function YQ(){VQ(new aq)}BQ===null||BQ===void 0||BQ.addEventListener("abort",YQ);let z,$Q;const t=[];let zQ=0;function e(Qq){VQ(Qq,--zQ===0)}function VQ(Qq,WQ){if(Qq&&(!z||z.code==="ERR_STREAM_PREMATURE_CLOSE"))z=Qq;if(!z&&!WQ)return;while(t.length)t.shift()(z);if(BQ===null||BQ===void 0||BQ.removeEventListener("abort",YQ),ZQ.abort(),WQ){if(!z)$.forEach((Xq)=>Xq());_Q(KQ,z,$Q)}}let qq;for(let Qq=0;Qq0,Jq=Xq||(a===null||a===void 0?void 0:a.end)!==!1,MQ=Qq===s.length-1;if(eq(WQ)){let Hq=function(FQ){if(FQ&&FQ.name!=="AbortError"&&FQ.code!=="ERR_STREAM_PREMATURE_CLOSE")e(FQ)};if(Jq){const{destroy:FQ,cleanup:Kq}=l(WQ,Xq,GQ);if(t.push(FQ),tq(WQ)&&MQ)$.push(Kq)}if(WQ.on("error",Hq),tq(WQ)&&MQ)$.push(()=>{WQ.removeListener("error",Hq)})}if(Qq===0)if(typeof WQ==="function"){if(qq=WQ({signal:r}),!m(qq))throw new p("Iterable, AsyncIterable or Stream","source",qq)}else if(m(WQ)||c(WQ))qq=WQ;else qq=Z.from(WQ);else if(typeof WQ==="function")if(qq=i(qq),qq=WQ(qq,{signal:r}),Xq){if(!m(qq,!0))throw new p("AsyncIterable",`transform[${Qq-1}]`,qq)}else{var UQ;if(!d)d=dQ();const Hq=new d({objectMode:!0}),FQ=(UQ=qq)===null||UQ===void 0?void 0:UQ.then;if(typeof FQ==="function")zQ++,FQ.call(qq,(Zq)=>{if($Q=Zq,Zq!=null)Hq.write(Zq);if(Jq)Hq.end();_Q(e)},(Zq)=>{Hq.destroy(Zq),_Q(e,Zq)});else if(m(qq,!0))zQ++,n(qq,Hq,e,{end:Jq});else throw new p("AsyncIterable or Promise","destination",qq);qq=Hq;const{destroy:Kq,cleanup:LQ}=l(qq,!1,!0);if(t.push(Kq),MQ)$.push(LQ)}else if(eq(WQ)){if(c(qq)){zQ+=2;const Hq=HQ(qq,WQ,e,{end:Jq});if(tq(WQ)&&MQ)$.push(Hq)}else if(m(qq))zQ++,n(qq,WQ,e,{end:Jq});else throw new oq("val",["Readable","Iterable","AsyncIterable"],qq);qq=WQ}else qq=Z.from(WQ)}if(r!==null&&r!==void 0&&r.aborted||BQ!==null&&BQ!==void 0&&BQ.aborted)_Q(YQ);return qq}function HQ(s,KQ,a,{end:ZQ}){if(s.pipe(KQ,{end:ZQ}),ZQ)s.once("end",()=>KQ.end());else a();return q(s,{readable:!0,writable:!1},(r)=>{const BQ=s._readableState;if(r&&r.code==="ERR_STREAM_PREMATURE_CLOSE"&&BQ&&BQ.ended&&!BQ.errored&&!BQ.errorEmitted)s.once("end",a).once("error",a);else a(r)}),q(KQ,{readable:!1,writable:!0},a)}Y.exports={pipelineImpl:o,pipeline:JQ}}}),lQ=G({"node_modules/readable-stream/lib/internal/streams/compose.js"(B,Y){var{pipeline:U}=Rq(),H=wQ(),{destroyer:X}=Oq(),{isNodeStream:q,isReadable:J,isWritable:Q}=j(),{AbortError:Z,codes:{ERR_INVALID_ARG_VALUE:K,ERR_MISSING_ARGS:oq}}=hQ();Y.exports=function p(...sq){if(sq.length===0)throw new oq("streams");if(sq.length===1)return H.from(sq[0]);const u=[...sq];if(typeof sq[0]==="function")sq[0]=H.from(sq[0]);if(typeof sq[sq.length-1]==="function"){const QQ=sq.length-1;sq[QQ]=H.from(sq[QQ])}for(let QQ=0;QQ0&&!Q(sq[QQ]))throw new K(`streams[${QQ}]`,u[QQ],"must be writable")}let aq,b,rq,m,tq;function c(QQ){const i=m;if(m=null,i)i(QQ);else if(QQ)tq.destroy(QQ);else if(!l&&!qQ)tq.destroy()}const eq=sq[0],d=U(sq,c),qQ=!!Q(eq),l=!!J(d);if(tq=new H({writableObjectMode:!!(eq!==null&&eq!==void 0&&eq.writableObjectMode),readableObjectMode:!!(d!==null&&d!==void 0&&d.writableObjectMode),writable:qQ,readable:l}),qQ)tq._write=function(QQ,i,XQ){if(eq.write(QQ,i))XQ();else aq=XQ},tq._final=function(QQ){eq.end(),b=QQ},eq.on("drain",function(){if(aq){const QQ=aq;aq=null,QQ()}}),d.on("finish",function(){if(b){const QQ=b;b=null,QQ()}});if(l)d.on("readable",function(){if(rq){const QQ=rq;rq=null,QQ()}}),d.on("end",function(){tq.push(null)}),tq._read=function(){while(!0){const QQ=d.read();if(QQ===null){rq=tq._read;return}if(!tq.push(QQ))return}};return tq._destroy=function(QQ,i){if(!QQ&&m!==null)QQ=new Z;if(rq=null,aq=null,b=null,m===null)i(QQ);else m=i,X(d,QQ)},tq}}}),E=G({"node_modules/readable-stream/lib/stream/promises.js"(B,Y){var{ArrayPrototypePop:U,Promise:H}=DQ(),{isIterable:X,isNodeStream:q}=j(),{pipelineImpl:J}=Rq(),{finished:Q}=N();function Z(...K){return new H((oq,p)=>{let sq,u;const aq=K[K.length-1];if(aq&&typeof aq==="object"&&!q(aq)&&!X(aq)){const b=U(K);sq=b.signal,u=b.end}J(K,(b,rq)=>{if(b)p(b);else oq(rq)},{signal:sq,end:u})})}Y.exports={finished:Q,pipeline:Z}}}),I=G({"node_modules/readable-stream/lib/stream.js"(B,Y){var{ObjectDefineProperty:U,ObjectKeys:H,ReflectApply:X}=DQ(),{promisify:{custom:q}}=jq(),{streamReturningOperators:J,promiseReturningOperators:Q}=A(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:Z}}=hQ(),K=lQ(),{pipeline:oq}=Rq(),{destroyer:p}=Oq(),sq=N(),u=E(),aq=j(),b=Y.exports=pQ().Stream;b.isDisturbed=aq.isDisturbed,b.isErrored=aq.isErrored,b.isWritable=aq.isWritable,b.isReadable=aq.isReadable,b.Readable=mQ();for(let m of H(J)){let tq=function(...eq){if(new.target)throw Z();return b.Readable.from(X(c,this,eq))};const c=J[m];U(tq,"name",{value:c.name}),U(tq,"length",{value:c.length}),U(b.Readable.prototype,m,{value:tq,enumerable:!1,configurable:!0,writable:!0})}for(let m of H(Q)){let tq=function(...eq){if(new.target)throw Z();return X(c,this,eq)};const c=Q[m];U(tq,"name",{value:c.name}),U(tq,"length",{value:c.length}),U(b.Readable.prototype,m,{value:tq,enumerable:!1,configurable:!0,writable:!0})}b.Writable=wq(),b.Duplex=wQ(),b.Transform=vq(),b.PassThrough=dQ(),b.pipeline=oq;var{addAbortSignal:rq}=_q();b.addAbortSignal=rq,b.finished=sq,b.destroy=p,b.compose=K,U(b,"promises",{configurable:!0,enumerable:!0,get(){return u}}),U(oq,q,{enumerable:!0,get(){return u.pipeline}}),U(sq,q,{enumerable:!0,get(){return u.finished}}),b.Stream=b,b._isUint8Array=function m(tq){return tq instanceof Uint8Array},b._uint8ArrayToBuffer=function m(tq){return new Buffer(tq.buffer,tq.byteOffset,tq.byteLength)}}}),T=G({"node_modules/readable-stream/lib/ours/index.js"(B,Y){const U=I(),H=E(),X=U.Readable.destroy;Y.exports=U,Y.exports._uint8ArrayToBuffer=U._uint8ArrayToBuffer,Y.exports._isUint8Array=U._isUint8Array,Y.exports.isDisturbed=U.isDisturbed,Y.exports.isErrored=U.isErrored,Y.exports.isWritable=U.isWritable,Y.exports.isReadable=U.isReadable,Y.exports.Readable=U.Readable,Y.exports.Writable=U.Writable,Y.exports.Duplex=U.Duplex,Y.exports.Transform=U.Transform,Y.exports.PassThrough=U.PassThrough,Y.exports.addAbortSignal=U.addAbortSignal,Y.exports.finished=U.finished,Y.exports.destroy=U.destroy,Y.exports.destroy=X,Y.exports.pipeline=U.pipeline,Y.exports.compose=U.compose,Y.exports._getNativeReadableStreamPrototype=O,Y.exports.NativeWritable=bq,Fq.defineProperty(U,"promises",{configurable:!0,enumerable:!0,get(){return H}}),Y.exports.Stream=U.Stream,Y.exports.default=Y.exports}}),x={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Mq=wq(),bq=class B extends Mq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(Y,U={}){super(U);this._construct=this.#J,this._destroy=this.#K,this._final=this.#Z,this.#q=Y}#J(Y){this._writableState.constructed=!0,this.constructed=!0,Y()}#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(Y,U,H,X=this.#X){if(!X)return this.#X=!1,super.write(Y,U,H);if(!this.#Q)this.#H();var q=this.#Q,J=q.write(Y);if(Lq(J))return J.then(()=>{this.emit("drain"),q.flush(!0)}),!1;if(q.flush(!0),H)H(null,Y.byteLength);return!0}end(Y,U,H,X=this.#X){return super.end(Y,U,H,X)}#K(Y,U){if(this._writableState.destroyed=!0,U)U(Y)}#Z(Y){if(this.#Q)this.#Q.end();if(Y)Y()}ref(){if(!this.#Q)this.#H();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},C=T();C[Symbol.for("CommonJS")]=0;C[Symbol.for("::bunternal::")]={_ReadableFromWeb:bQ,_ReadableFromWebForUndici:Dq};var nq=C,D=C._uint8ArrayToBuffer,w=C._isUint8Array,v=C.isDisturbed,R=C.isErrored,S=C.isWritable,g=C.isReadable,f=C.Readable,Mq=C.Writable,k=C.Duplex,y=C.Transform,h=C.PassThrough,Sq=C.addAbortSignal,gq=C.finished,fq=C.destroy,kq=C.pipeline,yq=C.compose,hq=C.Stream,pq=C["eos"]=N,uq=C._getNativeReadableStreamPrototype,bq=C.NativeWritable,mq=hq.promises;export{mq as promises,kq as pipeline,S as isWritable,g as isReadable,R as isErrored,v as isDisturbed,gq as finished,pq as eos,fq as destroy,nq as default,yq as compose,Sq as addAbortSignal,D as _uint8ArrayToBuffer,w as _isUint8Array,uq as _getNativeReadableStreamPrototype,Mq as Writable,y as Transform,hq as Stream,f as Readable,h as PassThrough,bq as NativeWritable,k 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/test/bun.lockb b/test/bun.lockb index 528415ddd..f8ea8e4c6 100755 Binary files a/test/bun.lockb and b/test/bun.lockb differ -- cgit v1.2.3 From e77f593b76e4ac8343106af9cc1161cfd573d234 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 27 Jun 2023 08:14:34 -0700 Subject: Update build-id --- src/build-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build-id b/src/build-id index f599e28b8..b4de39476 100644 --- a/src/build-id +++ b/src/build-id @@ -1 +1 @@ -10 +11 -- cgit v1.2.3 From d220d9ee5ab7d45c5480ad9a278807eb434f4276 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 27 Jun 2023 08:21:04 -0700 Subject: Update NodeModuleModule.cpp --- src/bun.js/modules/NodeModuleModule.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bun.js/modules/NodeModuleModule.cpp b/src/bun.js/modules/NodeModuleModule.cpp index 10853ae32..3019ea95c 100644 --- a/src/bun.js/modules/NodeModuleModule.cpp +++ b/src/bun.js/modules/NodeModuleModule.cpp @@ -135,8 +135,8 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, ImplementationVisibility::Public, NoIntrinsic, jsFunctionSourceMap, nullptr)); - append(JSC::Identifier::fromString(vm, "_resolveFileName"_s), - JSFunction::create(vm, globalObject, 3, String("_resolveFileName"_s), + append(JSC::Identifier::fromString(vm, "_resolveFilename"_s), + JSFunction::create(vm, globalObject, 3, String("_resolveFilename"_s), jsFunctionResolveFileName, ImplementationVisibility::Public)); @@ -151,6 +151,9 @@ void generateNodeModuleModule(JSC::JSGlobalObject *globalObject, append(JSC::Identifier::fromString(vm, "globalPaths"_s), JSC::constructEmptyArray(globalObject, nullptr, 0)); + append(JSC::Identifier::fromString(vm, "prototype"_s), + JSC::constructEmptyObject(globalObject)); + JSC::JSArray *builtinModules = JSC::JSArray::create( vm, globalObject->arrayStructureForIndexingTypeDuringAllocation( -- cgit v1.2.3 From 1c46d887286350ca102708c7fb8ae090ad88bf31 Mon Sep 17 00:00:00 2001 From: Ai Hoshino Date: Tue, 27 Jun 2023 23:23:25 +0800 Subject: Fix `node:util.callbackify` (#3428) * remove the incorrect parameters Close: https://github.com/oven-sh/bun/issues/3424 * fix error code * add callbackify tests * fix function type * ensure `done` is called when error occurred --- src/js/node/util.js | 5 +- test/js/node/util/util-callbackify.test.js | 323 +++++++++++++++++++++++++++++ 2 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 test/js/node/util/util-callbackify.test.js diff --git a/src/js/node/util.js b/src/js/node/util.js index 346f88ffb..8f20a4bc1 100644 --- a/src/js/node/util.js +++ b/src/js/node/util.js @@ -518,6 +518,7 @@ function callbackifyOnRejected(reason, cb) { if (!reason) { var newReason = new Error("Promise was rejected with a falsy value"); newReason.reason = reason; + newReason.code = "ERR_FALSY_VALUE_REJECTION"; reason = newReason; } return cb(reason); @@ -538,10 +539,10 @@ function callbackify(original) { }; original.apply(this, args).then( function (ret) { - process.nextTick(cb, null, null, ret); + process.nextTick(cb, null, ret); }, function (rej) { - process.nextTick(callbackifyOnRejected, null, rej, cb); + process.nextTick(callbackifyOnRejected, rej, cb); }, ); } diff --git a/test/js/node/util/util-callbackify.test.js b/test/js/node/util/util-callbackify.test.js new file mode 100644 index 000000000..38c20f5c0 --- /dev/null +++ b/test/js/node/util/util-callbackify.test.js @@ -0,0 +1,323 @@ +import { callbackify } from "util"; +import { createTest } from "node-harness"; + +const { describe, expect, it, createCallCheckCtx } = createTest(import.meta.path); + +const values = [ + "hello world", + null, + undefined, + false, + 0, + {}, + { key: "value" }, + Symbol("I am a symbol"), + function ok() {}, + ["array", "with", 4, "values"], + new Error("boo"), +]; + +describe("util.callbackify", () => { + describe("rejection reason", () => { + for (const value of values) { + it(`callback is async function, value is ${String(value)}`, done => { + const { mustCall } = createCallCheckCtx(done); + async function asyncFn() { + return Promise.reject(value); + } + + const cbAsyncFn = callbackify(asyncFn); + cbAsyncFn( + mustCall((err, ret) => { + try { + expect(ret).toBeUndefined(); + if (err instanceof Error) { + if ("reason" in err) { + expect(!value).toBeTrue(); + expect(err.code).toStrictEqual("ERR_FALSY_VALUE_REJECTION"); + expect(err.reason).toStrictEqual(value); + } else { + expect(String(value)).toEndWith(err.message); + } + } else { + expect(err).toStrictEqual(value); + } + + done(); + } catch (error) { + done(error); + } + }), + ); + }); + + it(`callback is promise, value is ${String(value)}`, done => { + const { mustCall } = createCallCheckCtx(done); + function promiseFn() { + return Promise.reject(value); + } + const obj = {}; + Object.defineProperty(promiseFn, "name", { + value: obj, + writable: false, + enumerable: false, + configurable: true, + }); + + const cbPromiseFn = callbackify(promiseFn); + try { + expect(promiseFn.name).toStrictEqual(obj); + } catch (error) { + done(error); + } + + cbPromiseFn( + mustCall((err, ret) => { + try { + expect(ret).toBeUndefined(); + if (err instanceof Error) { + if ("reason" in err) { + expect(!value).toBeTrue(); + expect(err.code).toStrictEqual("ERR_FALSY_VALUE_REJECTION"); + expect(err.reason).toStrictEqual(value); + } else { + expect(String(value)).toEndWith(err.message); + } + } else { + expect(err).toStrictEqual(value); + } + + done(); + } catch (error) { + done(error); + } + }), + ); + }); + + it(`callback is thenable, value is ${String(value)}`, done => { + const { mustCall } = createCallCheckCtx(done); + function thenableFn() { + return { + then(onRes, onRej) { + onRej(value); + }, + }; + } + + const cbThenableFn = callbackify(thenableFn); + cbThenableFn( + mustCall((err, ret) => { + try { + expect(ret).toBeUndefined(); + if (err instanceof Error) { + if ("reason" in err) { + expect(!value).toBeTrue(); + expect(err.code).toStrictEqual("ERR_FALSY_VALUE_REJECTION"); + expect(err.reason).toStrictEqual(value); + } else { + expect(String(value)).toEndWith(err.message); + } + } else { + expect(err).toStrictEqual(value); + } + + done(); + } catch (error) { + done(error); + } + }), + ); + }); + } + }); + + describe("return value", () => { + for (const value of values) { + it(`callback is async function, value is ${String(value)}`, done => { + const { mustSucceed } = createCallCheckCtx(done); + async function asyncFn() { + return value; + } + + const cbAsyncFn = callbackify(asyncFn); + cbAsyncFn( + mustSucceed(ret => { + try { + expect(ret).toStrictEqual(value); + expect(ret).toStrictEqual(value); + + done(); + } catch (error) { + done(error); + } + }), + ); + }); + + it(`callback is promise, value is ${String(value)}`, done => { + const { mustSucceed } = createCallCheckCtx(done); + function promiseFn() { + return Promise.resolve(value); + } + + const cbPromiseFn = callbackify(promiseFn); + cbPromiseFn( + mustSucceed(ret => { + try { + expect(ret).toStrictEqual(value); + done(); + } catch (error) { + done(error); + } + }), + ); + }); + + it(`callback is thenable, value is ${String(value)}`, done => { + const { mustSucceed } = createCallCheckCtx(done); + function thenableFn() { + return { + then(onRes, onRej) { + onRes(value); + }, + }; + } + + const cbThenableFn = callbackify(thenableFn); + cbThenableFn( + mustSucceed(ret => { + try { + expect(ret).toStrictEqual(value); + done(); + } catch (error) { + done(error); + } + }), + ); + }); + } + }); + + describe("arguments", () => { + for (const value of values) { + it(`callback is async function, value is ${String(value)}`, done => { + const { mustSucceed } = createCallCheckCtx(done); + async function asyncFn(arg) { + try { + expect(arg).toStrictEqual(value); + } catch (error) { + done(error); + } + return arg; + } + + const cbAsyncFn = callbackify(asyncFn); + cbAsyncFn( + value, + mustSucceed(ret => { + try { + expect(ret).toStrictEqual(value); + done(); + } catch (error) { + done(error); + } + }), + ); + }); + + it(`callback is promise, value is ${String(value)}`, done => { + const { mustSucceed } = createCallCheckCtx(done); + function promiseFn(arg) { + try { + expect(arg).toStrictEqual(value); + } catch (error) { + done(error); + } + + return Promise.resolve(arg); + } + const obj = {}; + Object.defineProperty(promiseFn, "length", { + value: obj, + writable: false, + enumerable: false, + configurable: true, + }); + const cbPromiseFn = callbackify(promiseFn); + try { + expect(promiseFn.length).toStrictEqual(obj); + } catch (error) { + done(error); + } + + cbPromiseFn( + value, + mustSucceed(ret => { + try { + expect(ret).toStrictEqual(value); + done(); + } catch (error) { + done(error); + } + }), + ); + }); + } + }); + + describe("this binding", () => { + const value = "hello world"; + it("callback is sync function", done => { + // TODO: + // const { mustSucceed } = createCallCheckCtx(done); + const iAmThis = { + fn(arg) { + try { + expect(this).toStrictEqual(iAmThis); + } catch (error) { + done(error); + } + return Promise.resolve(arg); + }, + }; + + iAmThis.cbFn = callbackify(iAmThis.fn); + iAmThis.cbFn(value, function (rej, ret) { + try { + expect(ret).toStrictEqual(value); + expect(this).toStrictEqual(iAmThis); + + done(); + } catch (error) { + done(error); + } + }); + }); + + it("callback is async function", done => { + const iAmThis = { + async fn(arg) { + try { + expect(this).toStrictEqual(iAmThis); + } catch (error) { + done(error); + } + return Promise.resolve(arg); + }, + }; + + iAmThis.cbFn = callbackify(iAmThis.fn); + iAmThis.cbFn(value, function (rej, ret) { + try { + expect(ret).toStrictEqual(value); + expect(this).toStrictEqual(iAmThis); + + done(); + } catch (error) { + done(error); + } + }); + }); + }); +}); -- cgit v1.2.3 From 2eb885c1d8140106b9e292234456cc1482a5a5e1 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 27 Jun 2023 08:24:35 -0700 Subject: Regenerate --- src/js/out/modules/node/util.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/out/modules/node/util.js b/src/js/out/modules/node/util.js index 8fbdc2d6c..48b22871f 100644 --- a/src/js/out/modules/node/util.js +++ b/src/js/out/modules/node/util.js @@ -270,7 +270,7 @@ var isFunction = function(value) { }, callbackifyOnRejected = function(reason, cb) { if (!reason) { var newReason = new Error("Promise was rejected with a falsy value"); - newReason.reason = reason, reason = newReason; + newReason.reason = reason, newReason.code = "ERR_FALSY_VALUE_REJECTION", reason = newReason; } return cb(reason); }, callbackify = function(original) { @@ -284,9 +284,9 @@ var isFunction = function(value) { return maybeCb.apply(self, arguments); }; original.apply(this, args).then(function(ret) { - process.nextTick(cb, null, null, ret); + process.nextTick(cb, null, ret); }, function(rej) { - process.nextTick(callbackifyOnRejected, null, rej, cb); + process.nextTick(callbackifyOnRejected, rej, cb); }); } return Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)), Object.defineProperties(callbackified, getOwnPropertyDescriptors(original)), callbackified; -- cgit v1.2.3 From 3ec6c9e4fb03a374bb5a1d856bf804483246589c Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Tue, 27 Jun 2023 09:10:43 -0700 Subject: Fix docker tag on release --- .github/workflows/bun-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bun-release.yml b/.github/workflows/bun-release.yml index e39c5cda3..1b2c49e81 100644 --- a/.github/workflows/bun-release.yml +++ b/.github/workflows/bun-release.yml @@ -156,8 +156,8 @@ jobs: with: images: oven/bun tags: | - type=match,pattern=(bun-v)?(\d.\d.\d),group=2,value=${{ env.TAG }} - type=match,pattern=(bun-v)?(\d.\d),group=2,value=${{ env.TAG }} + type=match,pattern=(bun-v)?(\d+.\d+.\d+),group=2,value=${{ env.TAG }} + type=match,pattern=(bun-v)?(\d+.\d+),group=2,value=${{ env.TAG }} - id: login name: Login to Docker uses: docker/login-action@v2 -- cgit v1.2.3 From 5376b5b5d6054b487cd2a3fae1a725b48d5c079a Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:29:22 -0700 Subject: Add builtin exports list --- test/exports/bun-exports.bun-v0.6.11.json | 8598 +++++++++++++++++ test/exports/generate-exports.mjs | 211 + test/exports/node-exports.bun-v0.6.11.json | 8559 +++++++++++++++++ test/exports/node-exports.node-v20.1.0.json | 12843 ++++++++++++++++++++++++++ 4 files changed, 30211 insertions(+) create mode 100644 test/exports/bun-exports.bun-v0.6.11.json create mode 100644 test/exports/generate-exports.mjs create mode 100644 test/exports/node-exports.bun-v0.6.11.json create mode 100644 test/exports/node-exports.node-v20.1.0.json diff --git a/test/exports/bun-exports.bun-v0.6.11.json b/test/exports/bun-exports.bun-v0.6.11.json new file mode 100644 index 000000000..8e2cb23d2 --- /dev/null +++ b/test/exports/bun-exports.bun-v0.6.11.json @@ -0,0 +1,8598 @@ +{ + "import": { + "buffer": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "default": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "bun:events_native": { + "EventEmitter": { + "EventEmitter": { + "EventEmitter": "function", + "captureRejectionSymbol": "symbol", + "defaultMaxListeners": "number", + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function" + }, + "captureRejectionSymbol": "symbol", + "defaultMaxListeners": "number", + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function" + }, + "captureRejectionSymbol": "symbol", + "default": { + "EventEmitter": { + "EventEmitter": "function", + "captureRejectionSymbol": "symbol", + "defaultMaxListeners": "number", + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function" + }, + "captureRejectionSymbol": "symbol", + "defaultMaxListeners": "number", + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function" + }, + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function" + }, + "bun:ffi": { + "CFunction": "function", + "CString": "function", + "FFIType": { + "0": "number", + "1": "number", + "2": "number", + "3": "number", + "4": "number", + "5": "number", + "6": "number", + "7": "number", + "8": "number", + "9": "number", + "10": "number", + "11": "number", + "12": "number", + "13": "number", + "14": "number", + "15": "number", + "16": "number", + "17": "number", + "bool": "number", + "c_int": "number", + "c_uint": "number", + "callback": "number", + "char*": "number", + "char": "number", + "cstring": "number", + "double": "number", + "f32": "number", + "f64": "number", + "float": "number", + "fn": "number", + "function": "number", + "i16": "number", + "i32": "number", + "i64": "number", + "i64_fast": "number", + "i8": "number", + "int": "number", + "int16_t": "number", + "int32_t": "number", + "int64_t": "number", + "int8_t": "number", + "isize": "number", + "pointer": "number", + "ptr": "number", + "u16": "number", + "u32": "number", + "u64": "number", + "u64_fast": "number", + "u8": "number", + "uint16_t": "number", + "uint32_t": "number", + "uint64_t": "number", + "uint8_t": "number", + "usize": "number", + "void*": "number", + "void": "number" + }, + "JSCallback": "function", + "dlopen": "function", + "linkSymbols": "function", + "native": { + "callback": "function", + "dlopen": "function" + }, + "ptr": "function", + "read": { + "f32": "function", + "f64": "function", + "i16": "function", + "i32": "function", + "i64": "function", + "i8": "function", + "intptr": "function", + "ptr": "function", + "u16": "function", + "u32": "function", + "u64": "function", + "u8": "function" + }, + "suffix": "string", + "toArrayBuffer": "function", + "toBuffer": "function", + "viewSource": "function" + }, + "bun:jsc": { + "callerSourceOrigin": "function", + "default": { + "callerSourceOrigin": "function", + "describe": "function", + "describeArray": "function", + "drainMicrotasks": "function", + "edenGC": "function", + "fullGC": "function", + "gcAndSweep": "function", + "generateHeapSnapshotForDebugging": "function", + "getProtectedObjects": "function", + "getRandomSeed": "function", + "heapSize": "function", + "heapStats": "function", + "isRope": "function", + "memoryUsage": "function", + "noFTL": "function", + "noInline": "function", + "noOSRExitFuzzing": "function", + "numberOfDFGCompiles": "function", + "optimizeNextInvocation": "function", + "profile": "function", + "releaseWeakRefs": "function", + "reoptimizationRetryCount": "function", + "samplingProfilerStackTraces": "function", + "setRandomSeed": "function", + "setTimeZone": "function", + "startRemoteDebugger": "function", + "startSamplingProfiler": "function", + "totalCompileTime": "function" + }, + "describe": "function", + "describeArray": "function", + "drainMicrotasks": "function", + "edenGC": "function", + "fullGC": "function", + "gcAndSweep": "function", + "generateHeapSnapshotForDebugging": "function", + "getProtectedObjects": "function", + "getRandomSeed": "function", + "heapSize": "function", + "heapStats": "function", + "isRope": "function", + "jscDescribe": "function", + "jscDescribeArray": "function", + "memoryUsage": "function", + "noFTL": "function", + "noInline": "function", + "noOSRExitFuzzing": "function", + "numberOfDFGCompiles": "function", + "optimizeNextInvocation": "function", + "profile": "function", + "releaseWeakRefs": "function", + "reoptimizationRetryCount": "function", + "samplingProfilerStackTraces": "function", + "setRandomSeed": "function", + "setTimeZone": "function", + "setTimezone": "function", + "startRemoteDebugger": "function", + "startSamplingProfiler": "function", + "totalCompileTime": "function" + }, + "bun:main": {}, + "bun:sqlite": { + "Database": { + "MAX_QUERY_CACHE_SIZE": "number" + }, + "Statement": "function", + "constants": { + "SQLITE_OPEN_AUTOPROXY": "number", + "SQLITE_OPEN_CREATE": "number", + "SQLITE_OPEN_DELETEONCLOSE": "number", + "SQLITE_OPEN_EXCLUSIVE": "number", + "SQLITE_OPEN_EXRESCODE": "number", + "SQLITE_OPEN_FULLMUTEX": "number", + "SQLITE_OPEN_MAIN_DB": "number", + "SQLITE_OPEN_MAIN_JOURNAL": "number", + "SQLITE_OPEN_MEMORY": "number", + "SQLITE_OPEN_NOFOLLOW": "number", + "SQLITE_OPEN_NOMUTEX": "number", + "SQLITE_OPEN_PRIVATECACHE": "number", + "SQLITE_OPEN_READONLY": "number", + "SQLITE_OPEN_READWRITE": "number", + "SQLITE_OPEN_SHAREDCACHE": "number", + "SQLITE_OPEN_SUBJOURNAL": "number", + "SQLITE_OPEN_SUPER_JOURNAL": "number", + "SQLITE_OPEN_TEMP_DB": "number", + "SQLITE_OPEN_TEMP_JOURNAL": "number", + "SQLITE_OPEN_TRANSIENT_DB": "number", + "SQLITE_OPEN_URI": "number", + "SQLITE_OPEN_WAL": "number", + "SQLITE_PREPARE_NORMALIZE": "number", + "SQLITE_PREPARE_NO_VTAB": "number", + "SQLITE_PREPARE_PERSISTENT": "number" + }, + "default": { + "MAX_QUERY_CACHE_SIZE": "number" + }, + "native": "undefined" + }, + "detect-libc": { + "GLIBC": "string", + "MUSL": "string", + "family": "function", + "familySync": "function", + "isNonGlibcLinux": "function", + "isNonGlibcLinuxSync": "function", + "version": "function", + "versionAsync": "function" + }, + "node:assert": { + "AssertionError": "function", + "assert": "undefined", + "deepEqual": "function", + "deepStrictEqual": "function", + "default": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:assert/strict": { + "AssertionError": "function", + "CallTracker": "undefined", + "deepEqual": "function", + "deepStrictEqual": "function", + "default": { + "AssertionError": "function", + "CallTracker": "undefined", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "undefined", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strictEqual": "function", + "throws": "function" + }, + "doesNotMatch": "undefined", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:async_hooks": { + "AsyncLocalStorage": "function", + "AsyncResource": { + "allowedRunInAsyncScope": "object" + }, + "asyncWrapProviders": { + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FIXEDSIZEBLOBCOPY": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "default": { + "AsyncLocalStorage": "function", + "AsyncResource": { + "allowedRunInAsyncScope": "object" + }, + "asyncWrapProviders": { + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FIXEDSIZEBLOBCOPY": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "node:buffer": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "default": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "node:child_process": { + "ChildProcess": "function", + "default": { + "ChildProcess": "function", + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "node:cluster": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "Worker": "function", + "cluster": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "schedulingPolicy": "number", + "settings": "object", + "workers": "object" + }, + "default": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "schedulingPolicy": "number", + "settings": "object", + "workers": "object" + }, + "isMaster": "boolean", + "isPrimary": "boolean", + "isWorker": "boolean", + "schedulingPolicy": "number" + }, + "node:crypto": { + "Cipher": "function", + "Cipheriv": "function", + "DEFAULT_ENCODING": "string", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "Hash": "function", + "Hmac": "function", + "Sign": "function", + "Verify": "function", + "constants": { + "ALPN_ENABLED": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "NPN_ENABLED": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number" + }, + "createCipher": "function", + "createCipheriv": "function", + "createCredentials": "function", + "createDecipher": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": { + "Hash": "function", + "createHash": { + "Hash": "function", + "createHash": "function" + } + }, + "createHmac": "function", + "createSign": "function", + "createVerify": "function", + "default": { + "Cipher": "function", + "Cipheriv": "function", + "DEFAULT_ENCODING": "string", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "Hash": "function", + "Hmac": "function", + "Sign": "function", + "Verify": "function", + "constants": { + "ALPN_ENABLED": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "NPN_ENABLED": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number" + }, + "createCipher": "function", + "createCipheriv": "function", + "createCredentials": "function", + "createDecipher": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": { + "Hash": "function", + "createHash": "function" + }, + "createHmac": "function", + "createSign": "function", + "createVerify": "function", + "getCiphers": "function", + "getDiffieHellman": "function", + "getHashes": "function", + "getRandomValues": "function", + "listCiphers": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "prng": "function", + "pseudoRandomBytes": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomInt": "function", + "randomUUID": "function", + "rng": "function", + "scrypt": "function", + "scryptSync": "function", + "subtle": "object", + "timingSafeEqual": "function", + "webcrypto": { + "getRandomValues": "function", + "randomUUID": "function", + "subtle": "object", + "timingSafeEqual": "function" + } + }, + "getCiphers": "function", + "getDiffieHellman": "function", + "getHashes": "function", + "getRandomValues": "function", + "listCiphers": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "prng": "function", + "pseudoRandomBytes": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomUUID": "function", + "rng": "function", + "scrypt": "function", + "scryptSync": "function", + "timingSafeEqual": "function", + "webcrypto": { + "getRandomValues": "function", + "randomUUID": "function", + "subtle": "object", + "timingSafeEqual": "function" + } + }, + "node:dgram": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function", + "default": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function" + } + }, + "node:diagnostics_channel": { + "Channel": "function", + "channel": "function", + "default": { + "Channel": "function", + "channel": "function", + "hasSubscribers": "function", + "subscribe": "function", + "unsubscribe": "function" + }, + "hasSubscribers": "function", + "subscribe": "function", + "unsubscribe": "function" + }, + "node:dns": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "default": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "lookup": "function", + "lookupService": "function", + "promises": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "lookup": "function", + "lookupService": "function", + "promises": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "node:dns/promises": { + "Resolver": "function", + "default": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "undefined", + "setServers": "undefined" + }, + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "undefined", + "setServers": "undefined" + }, + "node:events": { + "EventEmitter": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "captureRejectionSymbol": "symbol", + "default": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "node:fs": { + "Dirent": "function", + "ReadStream": "function", + "Stats": "function", + "WriteStream": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "default": { + "Dirent": "function", + "FSWatcher": "function", + "ReadStream": "function", + "Stats": "function", + "WriteStream": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": "object", + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": "function" + }, + "realpathSync": { + "native": "function" + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": { + "native": "function" + } + }, + "realpathSync": { + "native": { + "native": "function" + } + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "node:fs/promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "default": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "node:http": { + "Agent": "function", + "ClientRequest": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "OutgoingMessage": "function", + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "default": { + "Agent": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function" + }, + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "request": "function" + }, + "node:http2": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "default": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "node:https": { + "Agent": "function", + "ClientRequest": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "OutgoingMessage": "function", + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "default": { + "Agent": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function" + }, + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "request": "function" + }, + "node:inspector": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": { + "console": "object" + }, + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "default": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "object", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:module": { + "SourceMap": "function", + "_cache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs": { + "exports": "object" + }, + "bun:events_native": { + "exports": "function" + }, + "bun:ffi": { + "exports": "object" + }, + "bun:jsc": { + "exports": "object" + }, + "bun:main": { + "exports": "object" + }, + "bun:sqlite": { + "exports": "object" + }, + "detect-libc": { + "exports": "object" + }, + "node:assert": { + "exports": "function" + }, + "node:assert/strict": { + "exports": "object" + }, + "node:async_hooks": { + "exports": "object" + }, + "node:buffer": { + "exports": "object" + }, + "node:child_process": { + "exports": "object" + }, + "node:cluster": { + "exports": "object" + }, + "node:crypto": { + "exports": "object" + }, + "node:dgram": { + "exports": "object" + }, + "node:diagnostics_channel": { + "exports": "object" + }, + "node:dns": { + "exports": "object" + }, + "node:dns/promises": { + "exports": "object" + }, + "node:events": { + "exports": "function" + }, + "node:fs": { + "exports": "object" + }, + "node:fs/promises": { + "exports": "object" + }, + "node:http": { + "exports": "object" + }, + "node:http2": { + "exports": "object" + }, + "node:https": { + "exports": "object" + }, + "node:inspector": { + "exports": "object" + }, + "node:module": { + "exports": "object" + }, + "node:os": { + "exports": "object" + }, + "node:process": { + "exports": "object" + }, + "node:stream": { + "exports": "function" + }, + "node:string_decoder": { + "exports": "object" + }, + "node:util": { + "exports": "object" + }, + "node:util/types": { + "exports": "object" + } + }, + "_nodeModulePaths": "function", + "_resolveFilename": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string" + }, + "createRequire": "function", + "default": { + "SourceMap": "function", + "_cache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs": "object", + "bun:events_native": "object", + "bun:ffi": "object", + "bun:jsc": "object", + "bun:main": "object", + "bun:sqlite": "object", + "detect-libc": "object", + "node:assert": "object", + "node:assert/strict": "object", + "node:async_hooks": "object", + "node:buffer": "object", + "node:child_process": "object", + "node:cluster": "object", + "node:crypto": "object", + "node:dgram": "object", + "node:diagnostics_channel": "object", + "node:dns": "object", + "node:dns/promises": "object", + "node:events": "object", + "node:fs": "object", + "node:fs/promises": "object", + "node:http": "object", + "node:http2": "object", + "node:https": "object", + "node:inspector": "object", + "node:module": "object", + "node:os": "object", + "node:process": "object", + "node:stream": "object", + "node:string_decoder": "object", + "node:util": "object", + "node:util/types": "object" + }, + "_nodeModulePaths": "function", + "_resolveFilename": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string" + }, + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": "object", + "paths": "function", + "prototype": "object", + "syncBuiltinExports": "function" + }, + "findSourceMap": "function", + "globalPaths": "object", + "paths": "function", + "prototype": "object", + "syncBuiltinExports": "function" + }, + "node:net": { + "Server": "function", + "Socket": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "default": { + "Server": "function", + "Socket": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function" + }, + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function" + }, + "node:os": { + "EOL": "string", + "arch": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": { + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number" + }, + "errno": { + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EXDEV": "number" + }, + "priority": { + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number" + }, + "signals": { + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPOLL": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number" + } + }, + "cpus": "function", + "default": { + "EOL": "string", + "arch": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": "object", + "errno": "object", + "priority": "object", + "signals": "object" + }, + "cpus": "function", + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "node:path": { + "__esModule": "undefined", + "basename": "function", + "createModule": "function", + "default": { + "__esModule": "boolean", + "basename": "function", + "default": { + "__esModule": "boolean", + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + } + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "basename": "function", + "default": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "basename": "function", + "default": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + } + }, + "node:path/posix": { + "basename": "function", + "default": { + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "node:path/win32": { + "basename": "function", + "default": { + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "node:perf_hooks": { + "PerformanceEntry": "function", + "PerformanceNodeTiming": "function", + "PerformanceObserver": "function", + "default": { + "PerformanceEntry": "function", + "PerformanceNodeTiming": "function", + "performance": { + "now": "function", + "timeOrigin": "number" + } + }, + "performance": { + "now": "function", + "timeOrigin": "number" + } + }, + "node:process": { + "abort": "function", + "addListener": "function", + "arch": "string", + "argv": { + "0": "string", + "1": "string", + "2": "string" + }, + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": { + "v8_enable_i8n_support": "number" + } + }, + "cwd": "function", + "default": { + "abort": "function", + "arch": "string", + "argv": { + "0": "string", + "1": "string", + "2": "string" + }, + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": "object" + }, + "cwd": "function", + "dlopen": "function", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "hrtime": { + "bigint": "function" + }, + "isBun": "number", + "nextTick": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "release": { + "headersUrl": "string", + "libUrl": "string", + "lts": "boolean", + "name": "string", + "sourceUrl": "string" + }, + "revision": "string", + "stderr": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "stdin": { + "_readableState": "object", + "_writableState": "object", + "allowHalfOpen": "boolean" + }, + "stdout": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "ares": "string", + "boringssl": "string", + "bun": "string", + "libarchive": "string", + "lolhtml": "string", + "mimalloc": "string", + "modules": "string", + "napi": "string", + "node": "string", + "picohttpparser": "string", + "tinycc": "string", + "usockets": "string", + "uv": "string", + "uwebsockets": "string", + "v8": "string", + "webkit": "string", + "zig": "string", + "zlib": "string" + } + }, + "dlopen": "function", + "emit": "function", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "eventNames": "function", + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "getMaxListeners": "function", + "hrtime": { + "bigint": "function" + }, + "isBun": "number", + "listenerCount": "function", + "listeners": "function", + "nextTick": "function", + "off": "function", + "on": "function", + "once": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "prepend": "function", + "prependOnce": "function", + "rawListeners": "function", + "release": { + "headersUrl": "string", + "libUrl": "string", + "lts": "boolean", + "name": "string", + "sourceUrl": "string" + }, + "removeAllListeners": "function", + "removeListener": "function", + "revision": "string", + "setMaxListeners": "function", + "stderr": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "stdin": { + "_readableState": "object", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "allowHalfOpen": "boolean" + }, + "stdout": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "ares": "string", + "boringssl": "string", + "bun": "string", + "libarchive": "string", + "lolhtml": "string", + "mimalloc": "string", + "modules": "string", + "napi": "string", + "node": "string", + "picohttpparser": "string", + "tinycc": "string", + "usockets": "string", + "uv": "string", + "uwebsockets": "string", + "v8": "string", + "webkit": "string", + "zig": "string", + "zlib": "string" + } + }, + "node:readline": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "default": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:readline/promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function", + "default": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:repl": { + "REPLServer": "function", + "REPL_MODE_SLOPPY": "number", + "REPL_MODE_STRICT": "number", + "Recoverable": "function", + "default": { + "_domain": "undefined", + "_initialPrompt": "string", + "allowBlockingCompletions": "boolean", + "breakEvalOnSigint": "boolean", + "completer": "function", + "context": { + "AbortController": "function", + "AbortSignal": "function", + "Blob": "function", + "Buffer": "function", + "BuildError": "function", + "BuildMessage": "function", + "Bun": "function", + "ByteLengthQueuingStrategy": "function", + "CloseEvent": "function", + "CountQueuingStrategy": "function", + "Crypto": "function", + "CryptoKey": "function", + "CustomEvent": "function", + "DOMException": "function", + "ErrorEvent": "function", + "Event": "function", + "EventSource": "function", + "EventTarget": "function", + "FormData": "function", + "HTMLRewriter": "object", + "Headers": "function", + "MessageEvent": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "Request": "function", + "ResolveError": "function", + "ResolveMessage": "function", + "Response": "function", + "SubtleCrypto": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "URL": "function", + "URLSearchParams": "function", + "WebSocket": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "__IDS_TO_TRACK": "object", + "addEventListener": "function", + "alert": "function", + "atob": "function", + "btoa": "function", + "bunJSX": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "confirm": "function", + "crypto": "function", + "fetch": "function", + "navigator": "object", + "performance": "object", + "process": "object", + "prompt": "function", + "queueMicrotask": "function", + "reportError": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "crlfDelay": "number", + "cursor": "number", + "escapeCodeTimeout": "number", + "eval": "function", + "history": "object", + "historyIndex": "number", + "historySize": "number", + "input": "object", + "isCompletionEnabled": "boolean", + "last": "undefined", + "line": "string", + "lines": "object", + "output": "object", + "removeHistoryDuplicates": "boolean", + "tabSize": "number", + "terminal": "boolean", + "underscoreAssigned": "boolean", + "useColors": "boolean", + "useGlobal": "boolean" + }, + "repl": { + "_domain": "undefined", + "_initialPrompt": "string", + "allowBlockingCompletions": "boolean", + "breakEvalOnSigint": "boolean", + "completer": "function", + "context": { + "AbortController": "function", + "AbortSignal": "function", + "Blob": "function", + "Buffer": "function", + "BuildError": "function", + "BuildMessage": "function", + "Bun": "function", + "ByteLengthQueuingStrategy": "function", + "CloseEvent": "function", + "CountQueuingStrategy": "function", + "Crypto": "function", + "CryptoKey": "function", + "CustomEvent": "function", + "DOMException": "function", + "ErrorEvent": "function", + "Event": "function", + "EventSource": "function", + "EventTarget": "function", + "FormData": "function", + "HTMLRewriter": "object", + "Headers": "function", + "MessageEvent": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "Request": "function", + "ResolveError": "function", + "ResolveMessage": "function", + "Response": "function", + "SubtleCrypto": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "URL": "function", + "URLSearchParams": "function", + "WebSocket": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "__IDS_TO_TRACK": "object", + "addEventListener": "function", + "alert": "function", + "atob": "function", + "btoa": "function", + "bunJSX": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "confirm": "function", + "crypto": "function", + "fetch": "function", + "navigator": "object", + "performance": "object", + "process": "object", + "prompt": "function", + "queueMicrotask": "function", + "reportError": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "crlfDelay": "number", + "cursor": "number", + "escapeCodeTimeout": "number", + "eval": "function", + "history": "object", + "historyIndex": "number", + "historySize": "number", + "input": "object", + "isCompletionEnabled": "boolean", + "last": "undefined", + "line": "string", + "lines": "object", + "output": "object", + "removeHistoryDuplicates": "boolean", + "tabSize": "number", + "terminal": "boolean", + "underscoreAssigned": "boolean", + "useColors": "boolean", + "useGlobal": "boolean" + }, + "start": "function" + }, + "node:stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "node:stream/consumers": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "default": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "json": "function", + "text": "function" + }, + "json": "function", + "text": "function" + }, + "node:stream/promises": { + "default": { + "finished": "function", + "pipeline": "function" + }, + "finished": "function", + "pipeline": "function" + }, + "node:stream/web": { + "ByteLengthQueuingStrategy": "function", + "CountQueuingStrategy": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "default": { + "ByteLengthQueuingStrategy": "function", + "CountQueuingStrategy": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function" + } + }, + "node:string_decoder": { + "StringDecoder": "function", + "default": { + "StringDecoder": "function" + } + }, + "node:timers": { + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "default": { + "clearInterval": "function", + "clearTimeout": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:timers/promises": { + "default": { + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:tls": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "function", + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createConnection": "function", + "createSecureContext": "function", + "createServer": "function", + "default": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "function", + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createConnection": "function", + "createSecureContext": "function", + "createServer": "function", + "getCiphers": "function", + "getCurves": "function", + "parseCertString": "function" + }, + "getCiphers": "function", + "getCurves": "function", + "parseCertString": "function" + }, + "node:trace_events": { + "createTracing": "function", + "default": { + "createTracing": "function", + "getEnabledCategories": "function" + }, + "getEnabledCategories": "function" + }, + "node:tty": { + "ReadStream": "function", + "WriteStream": "function", + "default": { + "ReadStream": "function", + "WriteStream": "function", + "isatty": "function" + }, + "isatty": "function" + }, + "node:url": { + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "default": { + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "node:util": { + "TextDecoder": "function", + "TextEncoder": "function", + "callbackify": "function", + "debuglog": "function", + "default": { + "TextDecoder": "function", + "TextEncoder": "function", + "_extend": "function", + "callbackify": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": "object", + "styles": "object" + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "default": "object", + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": { + "black": "object", + "blue": "object", + "bold": "object", + "cyan": "object", + "green": "object", + "grey": "object", + "inverse": "object", + "italic": "object", + "magenta": "object", + "red": "object", + "underline": "object", + "white": "object", + "yellow": "object" + }, + "styles": { + "boolean": "string", + "date": "string", + "null": "string", + "number": "string", + "regexp": "string", + "special": "string", + "string": "string", + "undefined": "string" + } + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "node:util/types": { + "default": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "node:v8": { + "DefaultDeserializer": "function", + "DefaultSerializer": "function", + "Deserializer": "function", + "GCProfiler": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "default": { + "Deserializer": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "node:vm": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "default": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "node:zlib": { + "Deflate": { + "super_": { + "super_": "function" + } + }, + "DeflateRaw": { + "super_": { + "super_": "function" + } + }, + "Gunzip": { + "super_": { + "super_": "function" + } + }, + "Gzip": { + "super_": { + "super_": "function" + } + }, + "Inflate": { + "super_": { + "super_": "function" + } + }, + "InflateRaw": { + "super_": { + "super_": "function" + } + }, + "Unzip": { + "super_": { + "super_": "function" + } + }, + "constants": { + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number" + }, + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "default": { + "Deflate": { + "super_": "function" + }, + "DeflateRaw": { + "super_": "function" + }, + "Gunzip": { + "super_": "function" + }, + "Gzip": { + "super_": "function" + }, + "Inflate": { + "super_": "function" + }, + "InflateRaw": { + "super_": "function" + }, + "Unzip": { + "super_": "function" + }, + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_CHUNK": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_LEVEL": "number", + "Z_DEFAULT_MEMLEVEL": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFAULT_WINDOWBITS": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_MAX_CHUNK": "number", + "Z_MAX_LEVEL": "number", + "Z_MAX_MEMLEVEL": "number", + "Z_MAX_WINDOWBITS": "number", + "Z_MIN_CHUNK": "number", + "Z_MIN_LEVEL": "number", + "Z_MIN_MEMLEVEL": "number", + "Z_MIN_WINDOWBITS": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number", + "Zlib": "function", + "codes": { + "0": "string", + "1": "string", + "2": "string", + "-1": "string", + "-2": "string", + "-3": "string", + "-5": "string", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_ERRNO": "number", + "Z_MEM_ERROR": "undefined", + "Z_NEED_DICT": "number", + "Z_OK": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_VERSION_ERROR": "undefined", + "undefined": "string" + }, + "constants": { + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number" + }, + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + }, + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + } + }, + "require": { + "buffer": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "bun:events_native": { + "EventEmitter": { + "EventEmitter": { + "EventEmitter": "function", + "captureRejectionSymbol": "symbol", + "defaultMaxListeners": "number", + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function" + }, + "captureRejectionSymbol": "symbol", + "defaultMaxListeners": "number", + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function" + }, + "captureRejectionSymbol": "symbol", + "defaultMaxListeners": "number", + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function" + }, + "bun:ffi": { + "CFunction": "function", + "CString": "function", + "FFIType": { + "0": "number", + "1": "number", + "2": "number", + "3": "number", + "4": "number", + "5": "number", + "6": "number", + "7": "number", + "8": "number", + "9": "number", + "10": "number", + "11": "number", + "12": "number", + "13": "number", + "14": "number", + "15": "number", + "16": "number", + "17": "number", + "bool": "number", + "c_int": "number", + "c_uint": "number", + "callback": "number", + "char*": "number", + "char": "number", + "cstring": "number", + "double": "number", + "f32": "number", + "f64": "number", + "float": "number", + "fn": "number", + "function": "number", + "i16": "number", + "i32": "number", + "i64": "number", + "i64_fast": "number", + "i8": "number", + "int": "number", + "int16_t": "number", + "int32_t": "number", + "int64_t": "number", + "int8_t": "number", + "isize": "number", + "pointer": "number", + "ptr": "number", + "u16": "number", + "u32": "number", + "u64": "number", + "u64_fast": "number", + "u8": "number", + "uint16_t": "number", + "uint32_t": "number", + "uint64_t": "number", + "uint8_t": "number", + "usize": "number", + "void*": "number", + "void": "number" + }, + "JSCallback": "function", + "dlopen": "function", + "linkSymbols": "function", + "native": { + "callback": "function", + "dlopen": "function" + }, + "ptr": "function", + "read": { + "f32": "function", + "f64": "function", + "i16": "function", + "i32": "function", + "i64": "function", + "i8": "function", + "intptr": "function", + "ptr": "function", + "u16": "function", + "u32": "function", + "u64": "function", + "u8": "function" + }, + "suffix": "string", + "toArrayBuffer": "function", + "toBuffer": "function", + "viewSource": "function" + }, + "bun:jsc": { + "callerSourceOrigin": "function", + "default": { + "callerSourceOrigin": "function", + "describe": "function", + "describeArray": "function", + "drainMicrotasks": "function", + "edenGC": "function", + "fullGC": "function", + "gcAndSweep": "function", + "generateHeapSnapshotForDebugging": "function", + "getProtectedObjects": "function", + "getRandomSeed": "function", + "heapSize": "function", + "heapStats": "function", + "isRope": "function", + "memoryUsage": "function", + "noFTL": "function", + "noInline": "function", + "noOSRExitFuzzing": "function", + "numberOfDFGCompiles": "function", + "optimizeNextInvocation": "function", + "profile": "function", + "releaseWeakRefs": "function", + "reoptimizationRetryCount": "function", + "samplingProfilerStackTraces": "function", + "setRandomSeed": "function", + "setTimeZone": "function", + "startRemoteDebugger": "function", + "startSamplingProfiler": "function", + "totalCompileTime": "function" + }, + "describe": "function", + "describeArray": "function", + "drainMicrotasks": "function", + "edenGC": "function", + "fullGC": "function", + "gcAndSweep": "function", + "generateHeapSnapshotForDebugging": "function", + "getProtectedObjects": "function", + "getRandomSeed": "function", + "heapSize": "function", + "heapStats": "function", + "isRope": "function", + "jscDescribe": "function", + "jscDescribeArray": "function", + "memoryUsage": "function", + "noFTL": "function", + "noInline": "function", + "noOSRExitFuzzing": "function", + "numberOfDFGCompiles": "function", + "optimizeNextInvocation": "function", + "profile": "function", + "releaseWeakRefs": "function", + "reoptimizationRetryCount": "function", + "samplingProfilerStackTraces": "function", + "setRandomSeed": "function", + "setTimeZone": "function", + "setTimezone": "function", + "startRemoteDebugger": "function", + "startSamplingProfiler": "function", + "totalCompileTime": "function" + }, + "bun:main": {}, + "bun:sqlite": { + "Database": { + "MAX_QUERY_CACHE_SIZE": "number" + }, + "Statement": "function", + "constants": { + "SQLITE_OPEN_AUTOPROXY": "number", + "SQLITE_OPEN_CREATE": "number", + "SQLITE_OPEN_DELETEONCLOSE": "number", + "SQLITE_OPEN_EXCLUSIVE": "number", + "SQLITE_OPEN_EXRESCODE": "number", + "SQLITE_OPEN_FULLMUTEX": "number", + "SQLITE_OPEN_MAIN_DB": "number", + "SQLITE_OPEN_MAIN_JOURNAL": "number", + "SQLITE_OPEN_MEMORY": "number", + "SQLITE_OPEN_NOFOLLOW": "number", + "SQLITE_OPEN_NOMUTEX": "number", + "SQLITE_OPEN_PRIVATECACHE": "number", + "SQLITE_OPEN_READONLY": "number", + "SQLITE_OPEN_READWRITE": "number", + "SQLITE_OPEN_SHAREDCACHE": "number", + "SQLITE_OPEN_SUBJOURNAL": "number", + "SQLITE_OPEN_SUPER_JOURNAL": "number", + "SQLITE_OPEN_TEMP_DB": "number", + "SQLITE_OPEN_TEMP_JOURNAL": "number", + "SQLITE_OPEN_TRANSIENT_DB": "number", + "SQLITE_OPEN_URI": "number", + "SQLITE_OPEN_WAL": "number", + "SQLITE_PREPARE_NORMALIZE": "number", + "SQLITE_PREPARE_NO_VTAB": "number", + "SQLITE_PREPARE_PERSISTENT": "number" + }, + "default": { + "MAX_QUERY_CACHE_SIZE": "number" + }, + "native": "undefined" + }, + "detect-libc": { + "GLIBC": "string", + "MUSL": "string", + "family": "function", + "familySync": "function", + "isNonGlibcLinux": "function", + "isNonGlibcLinuxSync": "function", + "version": "function", + "versionAsync": "function" + }, + "node:assert": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:assert/strict": { + "AssertionError": "function", + "CallTracker": "undefined", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "undefined", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strictEqual": "function", + "throws": "function" + }, + "node:async_hooks": { + "AsyncLocalStorage": "function", + "AsyncResource": { + "allowedRunInAsyncScope": "object" + }, + "asyncWrapProviders": { + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FIXEDSIZEBLOBCOPY": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "node:buffer": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "node:child_process": { + "ChildProcess": "function", + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "node:cluster": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "schedulingPolicy": "number", + "settings": "object", + "workers": "object" + }, + "node:crypto": { + "Cipher": "function", + "Cipheriv": "function", + "DEFAULT_ENCODING": "string", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "Hash": "function", + "Hmac": "function", + "Sign": "function", + "Verify": "function", + "constants": { + "ALPN_ENABLED": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "NPN_ENABLED": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number" + }, + "createCipher": "function", + "createCipheriv": "function", + "createCredentials": "function", + "createDecipher": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": { + "Hash": "function", + "createHash": { + "Hash": "function", + "createHash": "function" + } + }, + "createHmac": "function", + "createSign": "function", + "createVerify": "function", + "getCiphers": "function", + "getDiffieHellman": "function", + "getHashes": "function", + "getRandomValues": "function", + "listCiphers": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "prng": "function", + "pseudoRandomBytes": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomInt": "function", + "randomUUID": "function", + "rng": "function", + "scrypt": "function", + "scryptSync": "function", + "subtle": "object", + "timingSafeEqual": "function", + "webcrypto": { + "getRandomValues": "function", + "randomUUID": "function", + "subtle": "object", + "timingSafeEqual": "function" + } + }, + "node:dgram": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function" + }, + "node:diagnostics_channel": { + "Channel": "function", + "channel": "function", + "hasSubscribers": "function", + "subscribe": "function", + "unsubscribe": "function" + }, + "node:dns": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "lookup": "function", + "lookupService": "function", + "promises": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "node:dns/promises": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "undefined", + "setServers": "undefined" + }, + "node:events": { + "EventEmitter": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "node:fs": { + "Dirent": "function", + "FSWatcher": "function", + "ReadStream": "function", + "Stats": "function", + "WriteStream": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": { + "native": "function" + } + }, + "realpathSync": { + "native": { + "native": "function" + } + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "node:fs/promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "node:http": { + "Agent": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function" + }, + "node:http2": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "node:https": { + "Agent": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function" + }, + "node:inspector": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": { + "console": "object" + }, + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:module": { + "SourceMap": "function", + "_cache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs": { + "exports": "object" + }, + "bun:events_native": { + "exports": "function" + }, + "bun:ffi": { + "exports": "object" + }, + "bun:jsc": { + "exports": "object" + }, + "bun:main": { + "exports": "object" + }, + "bun:sqlite": { + "exports": "object" + }, + "detect-libc": { + "exports": "object" + }, + "node:assert": { + "exports": "function" + }, + "node:assert/strict": { + "exports": "object" + }, + "node:async_hooks": { + "exports": "object" + }, + "node:buffer": { + "exports": "object" + }, + "node:child_process": { + "exports": "object" + }, + "node:cluster": { + "exports": "object" + }, + "node:crypto": { + "exports": "object" + }, + "node:dgram": { + "exports": "object" + }, + "node:diagnostics_channel": { + "exports": "object" + }, + "node:dns": { + "exports": "object" + }, + "node:dns/promises": { + "exports": "object" + }, + "node:events": { + "exports": "function" + }, + "node:fs": { + "exports": "object" + }, + "node:fs/promises": { + "exports": "object" + }, + "node:http": { + "exports": "object" + }, + "node:http2": { + "exports": "object" + }, + "node:https": { + "exports": "object" + }, + "node:inspector": { + "exports": "object" + }, + "node:module": { + "exports": "object" + }, + "node:os": { + "exports": "object" + }, + "node:process": { + "exports": "object" + }, + "node:stream": { + "exports": "function" + }, + "node:string_decoder": { + "exports": "object" + }, + "node:util": { + "exports": "object" + }, + "node:util/types": { + "exports": "object" + } + }, + "_nodeModulePaths": "function", + "_resolveFilename": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string" + }, + "createRequire": "function", + "default": { + "SourceMap": "function", + "_cache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs": "object", + "bun:events_native": "object", + "bun:ffi": "object", + "bun:jsc": "object", + "bun:main": "object", + "bun:sqlite": "object", + "detect-libc": "object", + "node:assert": "object", + "node:assert/strict": "object", + "node:async_hooks": "object", + "node:buffer": "object", + "node:child_process": "object", + "node:cluster": "object", + "node:crypto": "object", + "node:dgram": "object", + "node:diagnostics_channel": "object", + "node:dns": "object", + "node:dns/promises": "object", + "node:events": "object", + "node:fs": "object", + "node:fs/promises": "object", + "node:http": "object", + "node:http2": "object", + "node:https": "object", + "node:inspector": "object", + "node:module": "object", + "node:os": "object", + "node:process": "object", + "node:stream": "object", + "node:string_decoder": "object", + "node:util": "object", + "node:util/types": "object" + }, + "_nodeModulePaths": "function", + "_resolveFilename": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string" + }, + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": "object", + "paths": "function", + "prototype": "object", + "syncBuiltinExports": "function" + }, + "findSourceMap": "function", + "globalPaths": "object", + "paths": "function", + "prototype": "object", + "syncBuiltinExports": "function" + }, + "node:net": { + "Server": "function", + "Socket": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function" + }, + "node:os": { + "EOL": "string", + "arch": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": { + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number" + }, + "errno": { + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EXDEV": "number" + }, + "priority": { + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number" + }, + "signals": { + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPOLL": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number" + } + }, + "cpus": "function", + "default": { + "EOL": "string", + "arch": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": "object", + "errno": "object", + "priority": "object", + "signals": "object" + }, + "cpus": "function", + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "node:path": { + "__esModule": "boolean", + "basename": "function", + "default": { + "__esModule": "boolean", + "basename": "function", + "default": { + "__esModule": "boolean", + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + } + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "basename": "function", + "default": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "basename": "function", + "default": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + } + }, + "node:path/posix": { + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "node:path/win32": { + "basename": "function", + "default": { + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "node:perf_hooks": { + "PerformanceEntry": "function", + "PerformanceNodeTiming": "function", + "performance": { + "now": "function", + "timeOrigin": "number" + } + }, + "node:process": { + "abort": "function", + "addListener": "function", + "arch": "string", + "argv": { + "0": "string", + "1": "string", + "2": "string" + }, + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": { + "v8_enable_i8n_support": "number" + } + }, + "cwd": "function", + "default": { + "abort": "function", + "arch": "string", + "argv": { + "0": "string", + "1": "string", + "2": "string" + }, + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": "object" + }, + "cwd": "function", + "dlopen": "function", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "hrtime": { + "bigint": "function" + }, + "isBun": "number", + "nextTick": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "release": { + "headersUrl": "string", + "libUrl": "string", + "lts": "boolean", + "name": "string", + "sourceUrl": "string" + }, + "revision": "string", + "stderr": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "stdin": { + "_readableState": "object", + "_writableState": "object", + "allowHalfOpen": "boolean" + }, + "stdout": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "ares": "string", + "boringssl": "string", + "bun": "string", + "libarchive": "string", + "lolhtml": "string", + "mimalloc": "string", + "modules": "string", + "napi": "string", + "node": "string", + "picohttpparser": "string", + "tinycc": "string", + "usockets": "string", + "uv": "string", + "uwebsockets": "string", + "v8": "string", + "webkit": "string", + "zig": "string", + "zlib": "string" + } + }, + "dlopen": "function", + "emit": "function", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "eventNames": "function", + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "getMaxListeners": "function", + "hrtime": { + "bigint": "function" + }, + "isBun": "number", + "listenerCount": "function", + "listeners": "function", + "nextTick": "function", + "off": "function", + "on": "function", + "once": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "prepend": "function", + "prependOnce": "function", + "rawListeners": "function", + "release": { + "headersUrl": "string", + "libUrl": "string", + "lts": "boolean", + "name": "string", + "sourceUrl": "string" + }, + "removeAllListeners": "function", + "removeListener": "function", + "revision": "string", + "setMaxListeners": "function", + "stderr": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "stdin": { + "_readableState": "object", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "allowHalfOpen": "boolean" + }, + "stdout": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "ares": "string", + "boringssl": "string", + "bun": "string", + "libarchive": "string", + "lolhtml": "string", + "mimalloc": "string", + "modules": "string", + "napi": "string", + "node": "string", + "picohttpparser": "string", + "tinycc": "string", + "usockets": "string", + "uv": "string", + "uwebsockets": "string", + "v8": "string", + "webkit": "string", + "zig": "string", + "zlib": "string" + } + }, + "node:readline": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:readline/promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + }, + "node:repl": { + "_domain": "undefined", + "_initialPrompt": "string", + "allowBlockingCompletions": "boolean", + "breakEvalOnSigint": "boolean", + "completer": "function", + "context": { + "AbortController": "function", + "AbortSignal": { + "abort": "function", + "timeout": "function", + "whenSignalAborted": "function" + }, + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "BuildError": "function", + "BuildMessage": "function", + "Bun": { + "ArrayBufferSink": "function", + "concatArrayBuffers": "function", + "deepEquals": "function", + "deepMatch": "function", + "dns": "object", + "env": "object", + "escapeHTML": "function", + "fetch": "function", + "fileURLToPath": "function", + "nanoseconds": "function", + "password": "object", + "pathToFileURL": "function", + "peek": "function", + "plugin": "function", + "readableStreamToArray": "function", + "readableStreamToArrayBuffer": "function", + "readableStreamToBlob": "function", + "readableStreamToJSON": "function", + "readableStreamToText": "function", + "revision": "string", + "sleep": "function", + "stringHashCode": "function", + "version": "string" + }, + "ByteLengthQueuingStrategy": "function", + "CloseEvent": "function", + "CountQueuingStrategy": "function", + "Crypto": "function", + "CryptoKey": "function", + "CustomEvent": "function", + "DOMException": { + "ABORT_ERR": "number", + "DATA_CLONE_ERR": "number", + "DOMSTRING_SIZE_ERR": "number", + "HIERARCHY_REQUEST_ERR": "number", + "INDEX_SIZE_ERR": "number", + "INUSE_ATTRIBUTE_ERR": "number", + "INVALID_ACCESS_ERR": "number", + "INVALID_CHARACTER_ERR": "number", + "INVALID_MODIFICATION_ERR": "number", + "INVALID_NODE_TYPE_ERR": "number", + "INVALID_STATE_ERR": "number", + "NAMESPACE_ERR": "number", + "NETWORK_ERR": "number", + "NOT_FOUND_ERR": "number", + "NOT_SUPPORTED_ERR": "number", + "NO_DATA_ALLOWED_ERR": "number", + "NO_MODIFICATION_ALLOWED_ERR": "number", + "QUOTA_EXCEEDED_ERR": "number", + "SECURITY_ERR": "number", + "SYNTAX_ERR": "number", + "TIMEOUT_ERR": "number", + "TYPE_MISMATCH_ERR": "number", + "URL_MISMATCH_ERR": "number", + "VALIDATION_ERR": "number", + "WRONG_DOCUMENT_ERR": "number" + }, + "ErrorEvent": "function", + "Event": { + "AT_TARGET": "number", + "BUBBLING_PHASE": "number", + "CAPTURING_PHASE": "number", + "NONE": "number" + }, + "EventSource": "function", + "EventTarget": "function", + "FormData": "function", + "HTMLRewriter": "object", + "Headers": "function", + "MessageEvent": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "Request": "function", + "ResolveError": "function", + "ResolveMessage": "function", + "Response": { + "error": "function", + "json": "function", + "redirect": "function" + }, + "SubtleCrypto": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "WebSocket": { + "CLOSED": "number", + "CLOSING": "number", + "CONNECTING": "number", + "OPEN": "number" + }, + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "__IDS_TO_TRACK": "object", + "addEventListener": "function", + "alert": "function", + "atob": "function", + "btoa": "function", + "bunJSX": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "confirm": "function", + "crypto": { + "getRandomValues": "function", + "randomUUID": "function", + "subtle": "object", + "timingSafeEqual": "function" + }, + "fetch": "function", + "navigator": { + "hardwareConcurrency": "number", + "userAgent": "string" + }, + "performance": { + "now": "function", + "timeOrigin": "number" + }, + "process": { + "abort": "function", + "arch": "string", + "argv": "object", + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": "object", + "cwd": "function", + "dlopen": "function", + "emitWarning": "function", + "env": "object", + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "hrtime": "function", + "isBun": "number", + "nextTick": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "release": "object", + "revision": "string", + "stderr": "object", + "stdin": "object", + "stdout": "object", + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": "object" + }, + "prompt": "function", + "queueMicrotask": "function", + "reportError": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "crlfDelay": "number", + "cursor": "number", + "escapeCodeTimeout": "number", + "eval": "function", + "history": "object", + "historyIndex": "number", + "historySize": "number", + "input": "object", + "isCompletionEnabled": "boolean", + "last": "undefined", + "line": "string", + "lines": "object", + "output": "object", + "removeHistoryDuplicates": "boolean", + "tabSize": "number", + "terminal": "boolean", + "underscoreAssigned": "boolean", + "useColors": "boolean", + "useGlobal": "boolean" + }, + "node:stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "node:stream/consumers": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "json": "function", + "text": "function" + }, + "node:stream/promises": { + "finished": "function", + "pipeline": "function" + }, + "node:stream/web": { + "ByteLengthQueuingStrategy": "function", + "CountQueuingStrategy": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function" + }, + "node:string_decoder": { + "StringDecoder": "function", + "default": { + "StringDecoder": "function" + } + }, + "node:timers": { + "clearInterval": "function", + "clearTimeout": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:timers/promises": { + "default": { + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:tls": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "function", + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createConnection": "function", + "createSecureContext": "function", + "createServer": "function", + "getCiphers": "function", + "getCurves": "function", + "parseCertString": "function" + }, + "node:trace_events": { + "createTracing": "function", + "getEnabledCategories": "function" + }, + "node:tty": { + "ReadStream": "function", + "WriteStream": "function", + "isatty": "function" + }, + "node:url": { + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "default": { + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "node:util": { + "TextDecoder": "function", + "TextEncoder": "function", + "callbackify": "function", + "debuglog": "function", + "default": { + "TextDecoder": "function", + "TextEncoder": "function", + "_extend": "function", + "callbackify": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": "object", + "styles": "object" + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "default": "object", + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": { + "black": "object", + "blue": "object", + "bold": "object", + "cyan": "object", + "green": "object", + "grey": "object", + "inverse": "object", + "italic": "object", + "magenta": "object", + "red": "object", + "underline": "object", + "white": "object", + "yellow": "object" + }, + "styles": { + "boolean": "string", + "date": "string", + "null": "string", + "number": "string", + "regexp": "string", + "special": "string", + "string": "string", + "undefined": "string" + } + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "node:util/types": { + "default": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "node:v8": { + "Deserializer": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "node:vm": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "node:zlib": { + "Deflate": { + "super_": { + "super_": "function" + } + }, + "DeflateRaw": { + "super_": { + "super_": "function" + } + }, + "Gunzip": { + "super_": { + "super_": "function" + } + }, + "Gzip": { + "super_": { + "super_": "function" + } + }, + "Inflate": { + "super_": { + "super_": "function" + } + }, + "InflateRaw": { + "super_": { + "super_": "function" + } + }, + "Unzip": { + "super_": { + "super_": "function" + } + }, + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_CHUNK": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_LEVEL": "number", + "Z_DEFAULT_MEMLEVEL": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFAULT_WINDOWBITS": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_MAX_CHUNK": "number", + "Z_MAX_LEVEL": "number", + "Z_MAX_MEMLEVEL": "number", + "Z_MAX_WINDOWBITS": "number", + "Z_MIN_CHUNK": "number", + "Z_MIN_LEVEL": "number", + "Z_MIN_MEMLEVEL": "number", + "Z_MIN_WINDOWBITS": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number", + "Zlib": "function", + "codes": { + "0": "string", + "1": "string", + "2": "string", + "-1": "string", + "-2": "string", + "-3": "string", + "-5": "string", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_ERRNO": "number", + "Z_MEM_ERROR": "undefined", + "Z_NEED_DICT": "number", + "Z_OK": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_VERSION_ERROR": "undefined", + "undefined": "string" + }, + "constants": { + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number" + }, + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + } + }, + "runtime": "bun", + "version": "0.6.11", + "errors": { + "node:wasi": { + "name": "ReferenceError", + "message": "Can't find variable: constants" + } + } +} \ No newline at end of file diff --git a/test/exports/generate-exports.mjs b/test/exports/generate-exports.mjs new file mode 100644 index 000000000..04565ac15 --- /dev/null +++ b/test/exports/generate-exports.mjs @@ -0,0 +1,211 @@ +// This generates a list of all the shapes of all builtin modules and their typeof values. +// +// To run: +// +// bun generate-exports.mjs > node-exports.bun-${version}.json +// bun generate-exports.mjs bun > bun-exports.bun-${version}.json +// node generate-exports.mjs > node-exports.node-$(node --version).json +// +import { createRequire } from "node:module"; +import process from "node:process"; + +const nodeBuiltins = [ + "_http_agent", + "_http_client", + "_http_common", + "_http_incoming", + "_http_outgoing", + "_http_server", + "_stream_duplex", + "_stream_passthrough", + "_stream_readable", + "_stream_transform", + "_stream_wrap", + "_stream_writable", + "_tls_common", + "_tls_wrap", + "assert", + "assert/strict", + "async_hooks", + "buffer", + "child_process", + "cluster", + "console", + "constants", + "crypto", + "dgram", + "diagnostics_channel", + "dns", + "dns/promises", + "domain", + "events", + "fs", + "fs/promises", + "http", + "http2", + "https", + "inspector", + "inspector/promises", + "module", + "net", + "os", + "path", + "path/posix", + "path/win32", + "perf_hooks", + "process", + "punycode", + "querystring", + "readline", + "readline/promises", + "repl", + "stream", + "stream/consumers", + "stream/promises", + "stream/web", + "string_decoder", + "sys", + "test/reporters", + "timers", + "timers/promises", + "tls", + "trace_events", + "tty", + "url", + "util", + "util/types", + "v8", + "vm", + "wasi", + "worker_threads", + "zlib", +] + .map(a => "node:" + a) + .sort(); + +const bunBuiltins = [ + "buffer", + "bun:ffi", + "bun:jsc", + "bun:main", + "bun:sqlite", + "bun:events_native", + "detect-libc", + "node:assert", + "node:assert/strict", + "node:async_hooks", + "node:buffer", + "node:child_process", + "node:cluster", + "node:crypto", + "node:dgram", + "node:diagnostics_channel", + "node:dns", + "node:dns/promises", + "node:events", + "node:fs", + "node:fs/promises", + "node:http", + "node:http2", + "node:https", + "node:inspector", + "node:module", + "node:net", + "node:os", + "node:path", + "node:path/posix", + "node:path/win32", + "node:perf_hooks", + "node:process", + "node:readline", + "node:readline/promises", + "node:repl", + "node:stream", + "node:stream/consumers", + "node:stream/promises", + "node:stream/web", + "node:string_decoder", + "node:timers", + "node:timers/promises", + "node:tls", + "node:trace_events", + "node:tty", + "node:url", + "node:util", + "node:util/types", + "node:v8", + "node:vm", + "node:wasi", + "node:zlib", +].sort(); + +const require = createRequire(import.meta.url); + +const imported = {}; +const required = {}; +const errors = {}; + +function resolveNested([key, v], stop) { + let nested; + if ((v && typeof v === "object") || typeof v === "function") { + const entries = Object.fromEntries( + Object.entries(v) + .map(([ak, av]) => { + var display = typeof av; + + if (av && (typeof av === "function" || typeof av === "object")) { + const list = Object.fromEntries( + Object.entries(av) + .map(([ak2, av2]) => [ak2, typeof av2]) + .sort(), + ); + + for (let key in list) { + display = list; + break; + } + } + + return [ak, display]; + }) + .sort(), + ); + + for (let key in entries) { + nested = entries; + break; + } + } + + return [key, nested || typeof v]; +} + +async function processBuiltins(builtins) { + for (const builtin of builtins) { + try { + imported[builtin] = Object.fromEntries( + Object.entries(await import(builtin)) + .map(resolveNested) + .sort(), + ); + required[builtin] = Object.fromEntries(Object.entries(require(builtin)).map(resolveNested).sort()); + } catch ({ name, message }) { + errors[builtin] = { name, message }; + } + } +} + +process.stdout.write( + JSON.stringify( + { + builtins: await processBuiltins(process.argv.at(-1) === "bun" ? bunBuiltins : nodeBuiltins), + import: imported, + require: required, + runtime: typeof Bun !== "undefined" ? "bun" : "node", + version: typeof Bun !== "undefined" ? Bun.version : process.version, + errors, + }, + null, + 2, + ), +); diff --git a/test/exports/node-exports.bun-v0.6.11.json b/test/exports/node-exports.bun-v0.6.11.json new file mode 100644 index 000000000..91422fa97 --- /dev/null +++ b/test/exports/node-exports.bun-v0.6.11.json @@ -0,0 +1,8559 @@ +{ + "import": { + "node:assert": { + "AssertionError": "function", + "assert": "undefined", + "deepEqual": "function", + "deepStrictEqual": "function", + "default": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:assert/strict": { + "AssertionError": "function", + "CallTracker": "undefined", + "deepEqual": "function", + "deepStrictEqual": "function", + "default": { + "AssertionError": "function", + "CallTracker": "undefined", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "undefined", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strictEqual": "function", + "throws": "function" + }, + "doesNotMatch": "undefined", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:async_hooks": { + "AsyncLocalStorage": "function", + "AsyncResource": { + "allowedRunInAsyncScope": "object" + }, + "asyncWrapProviders": { + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FIXEDSIZEBLOBCOPY": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "default": { + "AsyncLocalStorage": "function", + "AsyncResource": { + "allowedRunInAsyncScope": "object" + }, + "asyncWrapProviders": { + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FIXEDSIZEBLOBCOPY": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "node:buffer": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "default": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "node:child_process": { + "ChildProcess": "function", + "default": { + "ChildProcess": "function", + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "node:cluster": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "Worker": "function", + "cluster": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "schedulingPolicy": "number", + "settings": "object", + "workers": "object" + }, + "default": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "schedulingPolicy": "number", + "settings": "object", + "workers": "object" + }, + "isMaster": "boolean", + "isPrimary": "boolean", + "isWorker": "boolean", + "schedulingPolicy": "number" + }, + "node:console": { + "default": { + "assert": "function", + "clear": "function", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + } + }, + "node:constants": {}, + "node:crypto": { + "Cipher": "function", + "Cipheriv": "function", + "DEFAULT_ENCODING": "string", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "Hash": "function", + "Hmac": "function", + "Sign": "function", + "Verify": "function", + "constants": { + "ALPN_ENABLED": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "NPN_ENABLED": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number" + }, + "createCipher": "function", + "createCipheriv": "function", + "createCredentials": "function", + "createDecipher": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": { + "Hash": "function", + "createHash": { + "Hash": "function", + "createHash": "function" + } + }, + "createHmac": "function", + "createSign": "function", + "createVerify": "function", + "default": { + "Cipher": "function", + "Cipheriv": "function", + "DEFAULT_ENCODING": "string", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "Hash": "function", + "Hmac": "function", + "Sign": "function", + "Verify": "function", + "constants": { + "ALPN_ENABLED": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "NPN_ENABLED": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number" + }, + "createCipher": "function", + "createCipheriv": "function", + "createCredentials": "function", + "createDecipher": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": { + "Hash": "function", + "createHash": "function" + }, + "createHmac": "function", + "createSign": "function", + "createVerify": "function", + "getCiphers": "function", + "getDiffieHellman": "function", + "getHashes": "function", + "getRandomValues": "function", + "listCiphers": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "prng": "function", + "pseudoRandomBytes": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomInt": "function", + "randomUUID": "function", + "rng": "function", + "scrypt": "function", + "scryptSync": "function", + "subtle": "object", + "timingSafeEqual": "function", + "webcrypto": { + "getRandomValues": "function", + "randomUUID": "function", + "subtle": "object", + "timingSafeEqual": "function" + } + }, + "getCiphers": "function", + "getDiffieHellman": "function", + "getHashes": "function", + "getRandomValues": "function", + "listCiphers": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "prng": "function", + "pseudoRandomBytes": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomUUID": "function", + "rng": "function", + "scrypt": "function", + "scryptSync": "function", + "timingSafeEqual": "function", + "webcrypto": { + "getRandomValues": "function", + "randomUUID": "function", + "subtle": "object", + "timingSafeEqual": "function" + } + }, + "node:dgram": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function", + "default": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function" + } + }, + "node:diagnostics_channel": { + "Channel": "function", + "channel": "function", + "default": { + "Channel": "function", + "channel": "function", + "hasSubscribers": "function", + "subscribe": "function", + "unsubscribe": "function" + }, + "hasSubscribers": "function", + "subscribe": "function", + "unsubscribe": "function" + }, + "node:dns": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "default": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "lookup": "function", + "lookupService": "function", + "promises": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "lookup": "function", + "lookupService": "function", + "promises": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "node:dns/promises": { + "Resolver": "function", + "default": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "undefined", + "setServers": "undefined" + }, + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "undefined", + "setServers": "undefined" + }, + "node:domain": { + "create": "function", + "createDomain": "function", + "default": { + "create": "function", + "createDomain": "function" + } + }, + "node:events": { + "EventEmitter": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "captureRejectionSymbol": "symbol", + "default": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "getEventListeners": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "node:fs": { + "Dirent": "function", + "ReadStream": "function", + "Stats": "function", + "WriteStream": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "default": { + "Dirent": "function", + "FSWatcher": "function", + "ReadStream": "function", + "Stats": "function", + "WriteStream": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": "object", + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": "function" + }, + "realpathSync": { + "native": "function" + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": { + "native": "function" + } + }, + "realpathSync": { + "native": { + "native": "function" + } + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "node:fs/promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "default": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "node:http": { + "Agent": "function", + "ClientRequest": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "OutgoingMessage": "function", + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "default": { + "Agent": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function" + }, + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "request": "function" + }, + "node:http2": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "default": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "node:https": { + "Agent": "function", + "ClientRequest": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "OutgoingMessage": "function", + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "default": { + "Agent": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function" + }, + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "request": "function" + }, + "node:inspector": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": { + "console": "object" + }, + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "default": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "object", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:inspector/promises": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": { + "console": "object" + }, + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "default": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "object", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:module": { + "SourceMap": "function", + "_cache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs": { + "exports": "object" + }, + "/bun-vfs/node_modules/console/index.js": { + "exports": "object" + }, + "/bun-vfs/node_modules/constants/index.js": { + "exports": "object" + }, + "/bun-vfs/node_modules/domain/index.js": { + "exports": "object" + }, + "bun:events_native": { + "exports": "object" + }, + "bun:jsc": { + "exports": "object" + }, + "bun:main": { + "exports": "object" + }, + "node:assert": { + "exports": "function" + }, + "node:assert/strict": { + "exports": "object" + }, + "node:async_hooks": { + "exports": "object" + }, + "node:buffer": { + "exports": "object" + }, + "node:child_process": { + "exports": "object" + }, + "node:cluster": { + "exports": "object" + }, + "node:crypto": { + "exports": "object" + }, + "node:dgram": { + "exports": "object" + }, + "node:diagnostics_channel": { + "exports": "object" + }, + "node:dns": { + "exports": "object" + }, + "node:dns/promises": { + "exports": "object" + }, + "node:events": { + "exports": "function" + }, + "node:fs": { + "exports": "object" + }, + "node:fs/promises": { + "exports": "object" + }, + "node:http": { + "exports": "object" + }, + "node:http2": { + "exports": "object" + }, + "node:https": { + "exports": "object" + }, + "node:inspector": { + "exports": "object" + }, + "node:module": { + "exports": "object" + }, + "node:os": { + "exports": "object" + }, + "node:process": { + "exports": "object" + }, + "node:stream": { + "exports": "function" + }, + "node:string_decoder": { + "exports": "object" + }, + "node:util": { + "exports": "object" + }, + "node:util/types": { + "exports": "object" + } + }, + "_nodeModulePaths": "function", + "_resolveFilename": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string" + }, + "createRequire": "function", + "default": { + "SourceMap": "function", + "_cache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs": "object", + "/bun-vfs/node_modules/console/index.js": "object", + "/bun-vfs/node_modules/constants/index.js": "object", + "/bun-vfs/node_modules/domain/index.js": "object", + "bun:events_native": "object", + "bun:jsc": "object", + "bun:main": "object", + "node:assert": "object", + "node:assert/strict": "object", + "node:async_hooks": "object", + "node:buffer": "object", + "node:child_process": "object", + "node:cluster": "object", + "node:crypto": "object", + "node:dgram": "object", + "node:diagnostics_channel": "object", + "node:dns": "object", + "node:dns/promises": "object", + "node:events": "object", + "node:fs": "object", + "node:fs/promises": "object", + "node:http": "object", + "node:http2": "object", + "node:https": "object", + "node:inspector": "object", + "node:module": "object", + "node:os": "object", + "node:process": "object", + "node:stream": "object", + "node:string_decoder": "object", + "node:util": "object", + "node:util/types": "object" + }, + "_nodeModulePaths": "function", + "_resolveFilename": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string" + }, + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": "object", + "paths": "function", + "prototype": "object", + "syncBuiltinExports": "function" + }, + "findSourceMap": "function", + "globalPaths": "object", + "paths": "function", + "prototype": "object", + "syncBuiltinExports": "function" + }, + "node:net": { + "Server": "function", + "Socket": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "default": { + "Server": "function", + "Socket": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function" + }, + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function" + }, + "node:os": { + "EOL": "string", + "arch": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": { + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number" + }, + "errno": { + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EXDEV": "number" + }, + "priority": { + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number" + }, + "signals": { + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPOLL": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number" + } + }, + "cpus": "function", + "default": { + "EOL": "string", + "arch": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": "object", + "errno": "object", + "priority": "object", + "signals": "object" + }, + "cpus": "function", + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "node:path": { + "__esModule": "undefined", + "basename": "function", + "createModule": "function", + "default": { + "__esModule": "boolean", + "basename": "function", + "default": { + "__esModule": "boolean", + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + } + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "basename": "function", + "default": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "basename": "function", + "default": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + } + }, + "node:path/posix": { + "basename": "function", + "default": { + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "node:path/win32": { + "basename": "function", + "default": { + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "node:perf_hooks": { + "PerformanceEntry": "function", + "PerformanceNodeTiming": "function", + "PerformanceObserver": "function", + "default": { + "PerformanceEntry": "function", + "PerformanceNodeTiming": "function", + "performance": { + "now": "function", + "timeOrigin": "number" + } + }, + "performance": { + "now": "function", + "timeOrigin": "number" + } + }, + "node:process": { + "abort": "function", + "addListener": "function", + "arch": "string", + "argv": { + "0": "string", + "1": "string" + }, + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": { + "v8_enable_i8n_support": "number" + } + }, + "cwd": "function", + "default": { + "abort": "function", + "arch": "string", + "argv": { + "0": "string", + "1": "string" + }, + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": "object" + }, + "cwd": "function", + "dlopen": "function", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "hrtime": { + "bigint": "function" + }, + "isBun": "number", + "nextTick": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "release": { + "headersUrl": "string", + "libUrl": "string", + "lts": "boolean", + "name": "string", + "sourceUrl": "string" + }, + "revision": "string", + "stderr": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "stdin": { + "_readableState": "object", + "_writableState": "object", + "allowHalfOpen": "boolean" + }, + "stdout": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "ares": "string", + "boringssl": "string", + "bun": "string", + "libarchive": "string", + "lolhtml": "string", + "mimalloc": "string", + "modules": "string", + "napi": "string", + "node": "string", + "picohttpparser": "string", + "tinycc": "string", + "usockets": "string", + "uv": "string", + "uwebsockets": "string", + "v8": "string", + "webkit": "string", + "zig": "string", + "zlib": "string" + } + }, + "dlopen": "function", + "emit": "function", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "eventNames": "function", + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "getMaxListeners": "function", + "hrtime": { + "bigint": "function" + }, + "isBun": "number", + "listenerCount": "function", + "listeners": "function", + "nextTick": "function", + "off": "function", + "on": "function", + "once": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "prepend": "function", + "prependOnce": "function", + "rawListeners": "function", + "release": { + "headersUrl": "string", + "libUrl": "string", + "lts": "boolean", + "name": "string", + "sourceUrl": "string" + }, + "removeAllListeners": "function", + "removeListener": "function", + "revision": "string", + "setMaxListeners": "function", + "stderr": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "stdin": { + "_readableState": "object", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "allowHalfOpen": "boolean" + }, + "stdout": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "ares": "string", + "boringssl": "string", + "bun": "string", + "libarchive": "string", + "lolhtml": "string", + "mimalloc": "string", + "modules": "string", + "napi": "string", + "node": "string", + "picohttpparser": "string", + "tinycc": "string", + "usockets": "string", + "uv": "string", + "uwebsockets": "string", + "v8": "string", + "webkit": "string", + "zig": "string", + "zlib": "string" + } + }, + "node:punycode": { + "decode": "function", + "encode": "function", + "toASCII": "function", + "toUnicode": "function", + "ucs2decode": "function", + "ucs2encode": "function" + }, + "node:querystring": { + "decode": "function", + "default": { + "decode": "function", + "encode": "function", + "escape": "function", + "parse": "function", + "stringify": "function", + "unescape": "function", + "unescapeBuffer": "function" + }, + "encode": "function", + "escape": "function", + "parse": "function", + "stringify": "function", + "unescape": "function", + "unescapeBuffer": "function" + }, + "node:readline": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "default": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:readline/promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function", + "default": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:repl": { + "REPLServer": "function", + "REPL_MODE_SLOPPY": "number", + "REPL_MODE_STRICT": "number", + "Recoverable": "function", + "default": { + "_domain": "undefined", + "_initialPrompt": "string", + "allowBlockingCompletions": "boolean", + "breakEvalOnSigint": "boolean", + "completer": "function", + "context": { + "AbortController": "function", + "AbortSignal": "function", + "Blob": "function", + "Buffer": "function", + "BuildError": "function", + "BuildMessage": "function", + "Bun": "function", + "ByteLengthQueuingStrategy": "function", + "CloseEvent": "function", + "CountQueuingStrategy": "function", + "Crypto": "function", + "CryptoKey": "function", + "CustomEvent": "function", + "DOMException": "function", + "ErrorEvent": "function", + "Event": "function", + "EventSource": "function", + "EventTarget": "function", + "FormData": "function", + "HTMLRewriter": "object", + "Headers": "function", + "MessageEvent": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "Request": "function", + "ResolveError": "function", + "ResolveMessage": "function", + "Response": "function", + "SubtleCrypto": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "URL": "function", + "URLSearchParams": "function", + "WebSocket": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "__IDS_TO_TRACK": "object", + "addEventListener": "function", + "alert": "function", + "atob": "function", + "btoa": "function", + "bunJSX": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "confirm": "function", + "crypto": "function", + "fetch": "function", + "navigator": "object", + "performance": "object", + "process": "object", + "prompt": "function", + "queueMicrotask": "function", + "reportError": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "crlfDelay": "number", + "cursor": "number", + "escapeCodeTimeout": "number", + "eval": "function", + "history": "object", + "historyIndex": "number", + "historySize": "number", + "input": "object", + "isCompletionEnabled": "boolean", + "last": "undefined", + "line": "string", + "lines": "object", + "output": "object", + "removeHistoryDuplicates": "boolean", + "tabSize": "number", + "terminal": "boolean", + "underscoreAssigned": "boolean", + "useColors": "boolean", + "useGlobal": "boolean" + }, + "repl": { + "_domain": "undefined", + "_initialPrompt": "string", + "allowBlockingCompletions": "boolean", + "breakEvalOnSigint": "boolean", + "completer": "function", + "context": { + "AbortController": "function", + "AbortSignal": "function", + "Blob": "function", + "Buffer": "function", + "BuildError": "function", + "BuildMessage": "function", + "Bun": "function", + "ByteLengthQueuingStrategy": "function", + "CloseEvent": "function", + "CountQueuingStrategy": "function", + "Crypto": "function", + "CryptoKey": "function", + "CustomEvent": "function", + "DOMException": "function", + "ErrorEvent": "function", + "Event": "function", + "EventSource": "function", + "EventTarget": "function", + "FormData": "function", + "HTMLRewriter": "object", + "Headers": "function", + "MessageEvent": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "Request": "function", + "ResolveError": "function", + "ResolveMessage": "function", + "Response": "function", + "SubtleCrypto": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "URL": "function", + "URLSearchParams": "function", + "WebSocket": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "__IDS_TO_TRACK": "object", + "addEventListener": "function", + "alert": "function", + "atob": "function", + "btoa": "function", + "bunJSX": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "confirm": "function", + "crypto": "function", + "fetch": "function", + "navigator": "object", + "performance": "object", + "process": "object", + "prompt": "function", + "queueMicrotask": "function", + "reportError": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "crlfDelay": "number", + "cursor": "number", + "escapeCodeTimeout": "number", + "eval": "function", + "history": "object", + "historyIndex": "number", + "historySize": "number", + "input": "object", + "isCompletionEnabled": "boolean", + "last": "undefined", + "line": "string", + "lines": "object", + "output": "object", + "removeHistoryDuplicates": "boolean", + "tabSize": "number", + "terminal": "boolean", + "underscoreAssigned": "boolean", + "useColors": "boolean", + "useGlobal": "boolean" + }, + "start": "function" + }, + "node:stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "node:stream/consumers": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "default": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "json": "function", + "text": "function" + }, + "json": "function", + "text": "function" + }, + "node:stream/promises": { + "default": { + "finished": "function", + "pipeline": "function" + }, + "finished": "function", + "pipeline": "function" + }, + "node:stream/web": { + "ByteLengthQueuingStrategy": "function", + "CountQueuingStrategy": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "default": { + "ByteLengthQueuingStrategy": "function", + "CountQueuingStrategy": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function" + } + }, + "node:string_decoder": { + "StringDecoder": "function", + "default": { + "StringDecoder": "function" + } + }, + "node:sys": { + "default": { + "_extend": "function", + "callbackify": "function", + "debuglog": "function", + "default": { + "_extend": "function", + "callbackify": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": "function", + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": "function", + "types": "object" + }, + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": "object", + "styles": "object" + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isDataView": "function", + "isDate": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isMap": "function", + "isMapIterator": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function", + "isWebAssemblyCompiledModule": "function" + } + } + }, + "node:timers": { + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "default": { + "clearInterval": "function", + "clearTimeout": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:timers/promises": { + "default": { + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:tls": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "function", + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createConnection": "function", + "createSecureContext": "function", + "createServer": "function", + "default": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "function", + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createConnection": "function", + "createSecureContext": "function", + "createServer": "function", + "getCiphers": "function", + "getCurves": "function", + "parseCertString": "function" + }, + "getCiphers": "function", + "getCurves": "function", + "parseCertString": "function" + }, + "node:trace_events": { + "createTracing": "function", + "default": { + "createTracing": "function", + "getEnabledCategories": "function" + }, + "getEnabledCategories": "function" + }, + "node:tty": { + "ReadStream": "function", + "WriteStream": "function", + "default": { + "ReadStream": "function", + "WriteStream": "function", + "isatty": "function" + }, + "isatty": "function" + }, + "node:url": { + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "default": { + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "node:util": { + "TextDecoder": "function", + "TextEncoder": "function", + "callbackify": "function", + "debuglog": "function", + "default": { + "TextDecoder": "function", + "TextEncoder": "function", + "_extend": "function", + "callbackify": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": "object", + "styles": "object" + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "default": "object", + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": { + "black": "object", + "blue": "object", + "bold": "object", + "cyan": "object", + "green": "object", + "grey": "object", + "inverse": "object", + "italic": "object", + "magenta": "object", + "red": "object", + "underline": "object", + "white": "object", + "yellow": "object" + }, + "styles": { + "boolean": "string", + "date": "string", + "null": "string", + "number": "string", + "regexp": "string", + "special": "string", + "string": "string", + "undefined": "string" + } + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "node:util/types": { + "default": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "node:v8": { + "DefaultDeserializer": "function", + "DefaultSerializer": "function", + "Deserializer": "function", + "GCProfiler": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "default": { + "Deserializer": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "node:vm": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "default": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "node:worker_threads": { + "default": "undefined" + }, + "node:zlib": { + "Deflate": { + "super_": { + "super_": "function" + } + }, + "DeflateRaw": { + "super_": { + "super_": "function" + } + }, + "Gunzip": { + "super_": { + "super_": "function" + } + }, + "Gzip": { + "super_": { + "super_": "function" + } + }, + "Inflate": { + "super_": { + "super_": "function" + } + }, + "InflateRaw": { + "super_": { + "super_": "function" + } + }, + "Unzip": { + "super_": { + "super_": "function" + } + }, + "constants": { + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number" + }, + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "default": { + "Deflate": { + "super_": "function" + }, + "DeflateRaw": { + "super_": "function" + }, + "Gunzip": { + "super_": "function" + }, + "Gzip": { + "super_": "function" + }, + "Inflate": { + "super_": "function" + }, + "InflateRaw": { + "super_": "function" + }, + "Unzip": { + "super_": "function" + }, + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_CHUNK": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_LEVEL": "number", + "Z_DEFAULT_MEMLEVEL": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFAULT_WINDOWBITS": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_MAX_CHUNK": "number", + "Z_MAX_LEVEL": "number", + "Z_MAX_MEMLEVEL": "number", + "Z_MAX_WINDOWBITS": "number", + "Z_MIN_CHUNK": "number", + "Z_MIN_LEVEL": "number", + "Z_MIN_MEMLEVEL": "number", + "Z_MIN_WINDOWBITS": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number", + "Zlib": "function", + "codes": { + "0": "string", + "1": "string", + "2": "string", + "-1": "string", + "-2": "string", + "-3": "string", + "-5": "string", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_ERRNO": "number", + "Z_MEM_ERROR": "undefined", + "Z_NEED_DICT": "number", + "Z_OK": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_VERSION_ERROR": "undefined", + "undefined": "string" + }, + "constants": { + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number" + }, + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + }, + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + } + }, + "require": { + "node:assert": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:assert/strict": { + "AssertionError": "function", + "CallTracker": "undefined", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "undefined", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strictEqual": "function", + "throws": "function" + }, + "node:async_hooks": { + "AsyncLocalStorage": "function", + "AsyncResource": { + "allowedRunInAsyncScope": "object" + }, + "asyncWrapProviders": { + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FIXEDSIZEBLOBCOPY": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "node:buffer": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "undefined", + "transcode": "undefined" + }, + "node:child_process": { + "ChildProcess": "function", + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "node:cluster": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "schedulingPolicy": "number", + "settings": "object", + "workers": "object" + }, + "node:console": { + "default": { + "assert": "function", + "clear": "function", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + } + }, + "node:constants": {}, + "node:crypto": { + "Cipher": "function", + "Cipheriv": "function", + "DEFAULT_ENCODING": "string", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "Hash": "function", + "Hmac": "function", + "Sign": "function", + "Verify": "function", + "constants": { + "ALPN_ENABLED": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "NPN_ENABLED": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number" + }, + "createCipher": "function", + "createCipheriv": "function", + "createCredentials": "function", + "createDecipher": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": { + "Hash": "function", + "createHash": { + "Hash": "function", + "createHash": "function" + } + }, + "createHmac": "function", + "createSign": "function", + "createVerify": "function", + "getCiphers": "function", + "getDiffieHellman": "function", + "getHashes": "function", + "getRandomValues": "function", + "listCiphers": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "prng": "function", + "pseudoRandomBytes": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomInt": "function", + "randomUUID": "function", + "rng": "function", + "scrypt": "function", + "scryptSync": "function", + "subtle": "object", + "timingSafeEqual": "function", + "webcrypto": { + "getRandomValues": "function", + "randomUUID": "function", + "subtle": "object", + "timingSafeEqual": "function" + } + }, + "node:dgram": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function" + }, + "node:diagnostics_channel": { + "Channel": "function", + "channel": "function", + "hasSubscribers": "function", + "subscribe": "function", + "unsubscribe": "function" + }, + "node:dns": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "lookup": "function", + "lookupService": "function", + "promises": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "node:dns/promises": { + "Resolver": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "undefined", + "setServers": "undefined" + }, + "node:domain": { + "create": "function", + "createDomain": "function", + "default": { + "create": "function", + "createDomain": "function" + } + }, + "node:events": { + "EventEmitter": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "node:fs": { + "Dirent": "function", + "FSWatcher": "function", + "ReadStream": "function", + "Stats": "function", + "WriteStream": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": { + "native": "function" + } + }, + "realpathSync": { + "native": { + "native": "function" + } + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "node:fs/promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "close": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOATIME": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_FS_O_FILEMAP": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "exists": "function", + "fchmod": "function", + "fchown": "function", + "fstat": "function", + "fsync": "function", + "ftruncate": "function", + "futimes": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "read": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "readv": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "write": "function", + "writeFile": "function", + "writev": "function" + }, + "node:http": { + "Agent": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function" + }, + "node:http2": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "node:https": { + "Agent": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function" + }, + "node:inspector": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": { + "console": "object" + }, + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:inspector/promises": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": { + "console": "object" + }, + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "record": "function", + "recordEnd": "function", + "screenshot": "function", + "table": "function", + "takeHeapSnapshot": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function", + "write": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:module": { + "SourceMap": "function", + "_cache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs": { + "exports": "object" + }, + "/bun-vfs/node_modules/console/index.js": { + "exports": "object" + }, + "/bun-vfs/node_modules/constants/index.js": { + "exports": "object" + }, + "/bun-vfs/node_modules/domain/index.js": { + "exports": "object" + }, + "bun:events_native": { + "exports": "object" + }, + "bun:jsc": { + "exports": "object" + }, + "bun:main": { + "exports": "object" + }, + "node:assert": { + "exports": "function" + }, + "node:assert/strict": { + "exports": "object" + }, + "node:async_hooks": { + "exports": "object" + }, + "node:buffer": { + "exports": "object" + }, + "node:child_process": { + "exports": "object" + }, + "node:cluster": { + "exports": "object" + }, + "node:crypto": { + "exports": "object" + }, + "node:dgram": { + "exports": "object" + }, + "node:diagnostics_channel": { + "exports": "object" + }, + "node:dns": { + "exports": "object" + }, + "node:dns/promises": { + "exports": "object" + }, + "node:events": { + "exports": "function" + }, + "node:fs": { + "exports": "object" + }, + "node:fs/promises": { + "exports": "object" + }, + "node:http": { + "exports": "object" + }, + "node:http2": { + "exports": "object" + }, + "node:https": { + "exports": "object" + }, + "node:inspector": { + "exports": "object" + }, + "node:module": { + "exports": "object" + }, + "node:os": { + "exports": "object" + }, + "node:process": { + "exports": "object" + }, + "node:stream": { + "exports": "function" + }, + "node:string_decoder": { + "exports": "object" + }, + "node:util": { + "exports": "object" + }, + "node:util/types": { + "exports": "object" + } + }, + "_nodeModulePaths": "function", + "_resolveFilename": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string" + }, + "createRequire": "function", + "default": { + "SourceMap": "function", + "_cache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs": "object", + "/bun-vfs/node_modules/console/index.js": "object", + "/bun-vfs/node_modules/constants/index.js": "object", + "/bun-vfs/node_modules/domain/index.js": "object", + "bun:events_native": "object", + "bun:jsc": "object", + "bun:main": "object", + "node:assert": "object", + "node:assert/strict": "object", + "node:async_hooks": "object", + "node:buffer": "object", + "node:child_process": "object", + "node:cluster": "object", + "node:crypto": "object", + "node:dgram": "object", + "node:diagnostics_channel": "object", + "node:dns": "object", + "node:dns/promises": "object", + "node:events": "object", + "node:fs": "object", + "node:fs/promises": "object", + "node:http": "object", + "node:http2": "object", + "node:https": "object", + "node:inspector": "object", + "node:module": "object", + "node:os": "object", + "node:process": "object", + "node:stream": "object", + "node:string_decoder": "object", + "node:util": "object", + "node:util/types": "object" + }, + "_nodeModulePaths": "function", + "_resolveFilename": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string" + }, + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": "object", + "paths": "function", + "prototype": "object", + "syncBuiltinExports": "function" + }, + "findSourceMap": "function", + "globalPaths": "object", + "paths": "function", + "prototype": "object", + "syncBuiltinExports": "function" + }, + "node:net": { + "Server": "function", + "Socket": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function" + }, + "node:os": { + "EOL": "string", + "arch": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": { + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number" + }, + "errno": { + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EXDEV": "number" + }, + "priority": { + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number" + }, + "signals": { + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPOLL": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number" + } + }, + "cpus": "function", + "default": { + "EOL": "string", + "arch": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": "object", + "errno": "object", + "priority": "object", + "signals": "object" + }, + "cpus": "function", + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "node:path": { + "__esModule": "boolean", + "basename": "function", + "default": { + "__esModule": "boolean", + "basename": "function", + "default": { + "__esModule": "boolean", + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + } + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "basename": "function", + "default": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "basename": "function", + "default": { + "basename": "function", + "default": "object", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + } + }, + "node:path/posix": { + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "node:path/win32": { + "basename": "function", + "default": { + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function" + }, + "node:perf_hooks": { + "PerformanceEntry": "function", + "PerformanceNodeTiming": "function", + "performance": { + "now": "function", + "timeOrigin": "number" + } + }, + "node:process": { + "abort": "function", + "addListener": "function", + "arch": "string", + "argv": { + "0": "string", + "1": "string" + }, + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": { + "v8_enable_i8n_support": "number" + } + }, + "cwd": "function", + "default": { + "abort": "function", + "arch": "string", + "argv": { + "0": "string", + "1": "string" + }, + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": "object" + }, + "cwd": "function", + "dlopen": "function", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "hrtime": { + "bigint": "function" + }, + "isBun": "number", + "nextTick": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "release": { + "headersUrl": "string", + "libUrl": "string", + "lts": "boolean", + "name": "string", + "sourceUrl": "string" + }, + "revision": "string", + "stderr": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "stdin": { + "_readableState": "object", + "_writableState": "object", + "allowHalfOpen": "boolean" + }, + "stdout": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "ares": "string", + "boringssl": "string", + "bun": "string", + "libarchive": "string", + "lolhtml": "string", + "mimalloc": "string", + "modules": "string", + "napi": "string", + "node": "string", + "picohttpparser": "string", + "tinycc": "string", + "usockets": "string", + "uv": "string", + "uwebsockets": "string", + "v8": "string", + "webkit": "string", + "zig": "string", + "zlib": "string" + } + }, + "dlopen": "function", + "emit": "function", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "eventNames": "function", + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "getMaxListeners": "function", + "hrtime": { + "bigint": "function" + }, + "isBun": "number", + "listenerCount": "function", + "listeners": "function", + "nextTick": "function", + "off": "function", + "on": "function", + "once": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "prepend": "function", + "prependOnce": "function", + "rawListeners": "function", + "release": { + "headersUrl": "string", + "libUrl": "string", + "lts": "boolean", + "name": "string", + "sourceUrl": "string" + }, + "removeAllListeners": "function", + "removeListener": "function", + "revision": "string", + "setMaxListeners": "function", + "stderr": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "stdin": { + "_readableState": "object", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "allowHalfOpen": "boolean" + }, + "stdout": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "bytesWritten": "number" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "ares": "string", + "boringssl": "string", + "bun": "string", + "libarchive": "string", + "lolhtml": "string", + "mimalloc": "string", + "modules": "string", + "napi": "string", + "node": "string", + "picohttpparser": "string", + "tinycc": "string", + "usockets": "string", + "uv": "string", + "uwebsockets": "string", + "v8": "string", + "webkit": "string", + "zig": "string", + "zlib": "string" + } + }, + "node:punycode": { + "decode": "function", + "encode": "function", + "toASCII": "function", + "toUnicode": "function", + "ucs2decode": "function", + "ucs2encode": "function" + }, + "node:querystring": { + "decode": "function", + "default": { + "decode": "function", + "encode": "function", + "escape": "function", + "parse": "function", + "stringify": "function", + "unescape": "function", + "unescapeBuffer": "function" + }, + "encode": "function", + "escape": "function", + "parse": "function", + "stringify": "function", + "unescape": "function", + "unescapeBuffer": "function" + }, + "node:readline": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:readline/promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + }, + "node:repl": { + "_domain": "undefined", + "_initialPrompt": "string", + "allowBlockingCompletions": "boolean", + "breakEvalOnSigint": "boolean", + "completer": "function", + "context": { + "AbortController": "function", + "AbortSignal": { + "abort": "function", + "timeout": "function", + "whenSignalAborted": "function" + }, + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "toBuffer": "function" + }, + "BuildError": "function", + "BuildMessage": "function", + "Bun": { + "ArrayBufferSink": "function", + "concatArrayBuffers": "function", + "deepEquals": "function", + "deepMatch": "function", + "dns": "object", + "env": "object", + "escapeHTML": "function", + "fetch": "function", + "fileURLToPath": "function", + "nanoseconds": "function", + "password": "object", + "pathToFileURL": "function", + "peek": "function", + "plugin": "function", + "readableStreamToArray": "function", + "readableStreamToArrayBuffer": "function", + "readableStreamToBlob": "function", + "readableStreamToJSON": "function", + "readableStreamToText": "function", + "revision": "string", + "sleep": "function", + "stringHashCode": "function", + "version": "string" + }, + "ByteLengthQueuingStrategy": "function", + "CloseEvent": "function", + "CountQueuingStrategy": "function", + "Crypto": "function", + "CryptoKey": "function", + "CustomEvent": "function", + "DOMException": { + "ABORT_ERR": "number", + "DATA_CLONE_ERR": "number", + "DOMSTRING_SIZE_ERR": "number", + "HIERARCHY_REQUEST_ERR": "number", + "INDEX_SIZE_ERR": "number", + "INUSE_ATTRIBUTE_ERR": "number", + "INVALID_ACCESS_ERR": "number", + "INVALID_CHARACTER_ERR": "number", + "INVALID_MODIFICATION_ERR": "number", + "INVALID_NODE_TYPE_ERR": "number", + "INVALID_STATE_ERR": "number", + "NAMESPACE_ERR": "number", + "NETWORK_ERR": "number", + "NOT_FOUND_ERR": "number", + "NOT_SUPPORTED_ERR": "number", + "NO_DATA_ALLOWED_ERR": "number", + "NO_MODIFICATION_ALLOWED_ERR": "number", + "QUOTA_EXCEEDED_ERR": "number", + "SECURITY_ERR": "number", + "SYNTAX_ERR": "number", + "TIMEOUT_ERR": "number", + "TYPE_MISMATCH_ERR": "number", + "URL_MISMATCH_ERR": "number", + "VALIDATION_ERR": "number", + "WRONG_DOCUMENT_ERR": "number" + }, + "ErrorEvent": "function", + "Event": { + "AT_TARGET": "number", + "BUBBLING_PHASE": "number", + "CAPTURING_PHASE": "number", + "NONE": "number" + }, + "EventSource": "function", + "EventTarget": "function", + "FormData": "function", + "HTMLRewriter": "object", + "Headers": "function", + "MessageEvent": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "Request": "function", + "ResolveError": "function", + "ResolveMessage": "function", + "Response": { + "error": "function", + "json": "function", + "redirect": "function" + }, + "SubtleCrypto": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "WebSocket": { + "CLOSED": "number", + "CLOSING": "number", + "CONNECTING": "number", + "OPEN": "number" + }, + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "__IDS_TO_TRACK": "object", + "addEventListener": "function", + "alert": "function", + "atob": "function", + "btoa": "function", + "bunJSX": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "confirm": "function", + "crypto": { + "getRandomValues": "function", + "randomUUID": "function", + "subtle": "object", + "timingSafeEqual": "function" + }, + "fetch": "function", + "navigator": { + "hardwareConcurrency": "number", + "userAgent": "string" + }, + "performance": { + "now": "function", + "timeOrigin": "number" + }, + "process": { + "abort": "function", + "arch": "string", + "argv": "object", + "argv0": "string", + "binding": "function", + "browser": "number", + "chdir": "function", + "config": "object", + "cwd": "function", + "dlopen": "function", + "emitWarning": "function", + "env": "object", + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "number", + "hrtime": "function", + "isBun": "number", + "nextTick": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "release": "object", + "revision": "string", + "stderr": "object", + "stdin": "object", + "stdout": "object", + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": "object" + }, + "prompt": "function", + "queueMicrotask": "function", + "reportError": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "crlfDelay": "number", + "cursor": "number", + "escapeCodeTimeout": "number", + "eval": "function", + "history": "object", + "historyIndex": "number", + "historySize": "number", + "input": "object", + "isCompletionEnabled": "boolean", + "last": "undefined", + "line": "string", + "lines": "object", + "output": "object", + "removeHistoryDuplicates": "boolean", + "tabSize": "number", + "terminal": "boolean", + "underscoreAssigned": "boolean", + "useColors": "boolean", + "useGlobal": "boolean" + }, + "node:stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "NativeWritable": "function", + "PassThrough": "function", + "Readable": { + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "Transform": "function", + "Writable": { + "fromWeb": "function", + "toWeb": "function" + }, + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": "function", + "NativeWritable": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_getNativeReadableStreamPrototype": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": "function", + "destroy": "function", + "eos": "function", + "finished": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object" + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "destroy": "function", + "eos": "function", + "finished": { + "finished": "function" + }, + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + } + }, + "node:stream/consumers": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "json": "function", + "text": "function" + }, + "node:stream/promises": { + "finished": "function", + "pipeline": "function" + }, + "node:stream/web": { + "ByteLengthQueuingStrategy": "function", + "CountQueuingStrategy": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function" + }, + "node:string_decoder": { + "StringDecoder": "function", + "default": { + "StringDecoder": "function" + } + }, + "node:sys": { + "default": { + "_extend": "function", + "callbackify": "function", + "debuglog": "function", + "default": { + "_extend": "function", + "callbackify": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": "function", + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": "function", + "types": "object" + }, + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": "object", + "styles": "object" + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isDataView": "function", + "isDate": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isMap": "function", + "isMapIterator": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function", + "isWebAssemblyCompiledModule": "function" + } + } + }, + "node:timers": { + "clearInterval": "function", + "clearTimeout": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:timers/promises": { + "default": { + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:tls": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "function", + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createConnection": "function", + "createSecureContext": "function", + "createServer": "function", + "getCiphers": "function", + "getCurves": "function", + "parseCertString": "function" + }, + "node:trace_events": { + "createTracing": "function", + "getEnabledCategories": "function" + }, + "node:tty": { + "ReadStream": "function", + "WriteStream": "function", + "isatty": "function" + }, + "node:url": { + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "default": { + "URL": { + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "node:util": { + "TextDecoder": "function", + "TextEncoder": "function", + "callbackify": "function", + "debuglog": "function", + "default": { + "TextDecoder": "function", + "TextEncoder": "function", + "_extend": "function", + "callbackify": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": "object", + "styles": "object" + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "default": "object", + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "deprecate": "function", + "format": "function", + "inherits": "function", + "inspect": { + "colors": { + "black": "object", + "blue": "object", + "bold": "object", + "cyan": "object", + "green": "object", + "grey": "object", + "inverse": "object", + "italic": "object", + "magenta": "object", + "red": "object", + "underline": "object", + "white": "object", + "yellow": "object" + }, + "styles": { + "boolean": "string", + "date": "string", + "null": "string", + "number": "string", + "regexp": "string", + "special": "string", + "string": "string", + "undefined": "string" + } + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "promisify": { + "custom": "symbol" + }, + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "node:util/types": { + "default": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "node:v8": { + "Deserializer": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "node:vm": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "node:worker_threads": { + "default": "undefined" + }, + "node:zlib": { + "Deflate": { + "super_": { + "super_": "function" + } + }, + "DeflateRaw": { + "super_": { + "super_": "function" + } + }, + "Gunzip": { + "super_": { + "super_": "function" + } + }, + "Gzip": { + "super_": { + "super_": "function" + } + }, + "Inflate": { + "super_": { + "super_": "function" + } + }, + "InflateRaw": { + "super_": { + "super_": "function" + } + }, + "Unzip": { + "super_": { + "super_": "function" + } + }, + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_CHUNK": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_LEVEL": "number", + "Z_DEFAULT_MEMLEVEL": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFAULT_WINDOWBITS": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_MAX_CHUNK": "number", + "Z_MAX_LEVEL": "number", + "Z_MAX_MEMLEVEL": "number", + "Z_MAX_WINDOWBITS": "number", + "Z_MIN_CHUNK": "number", + "Z_MIN_LEVEL": "number", + "Z_MIN_MEMLEVEL": "number", + "Z_MIN_WINDOWBITS": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number", + "Zlib": "function", + "codes": { + "0": "string", + "1": "string", + "2": "string", + "-1": "string", + "-2": "string", + "-3": "string", + "-5": "string", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_ERRNO": "number", + "Z_MEM_ERROR": "undefined", + "Z_NEED_DICT": "number", + "Z_OK": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_VERSION_ERROR": "undefined", + "undefined": "string" + }, + "constants": { + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BINARY": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFLATED": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_TEXT": "number", + "Z_TREES": "number", + "Z_UNKNOWN": "number" + }, + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + } + }, + "runtime": "bun", + "version": "0.6.11", + "errors": { + "node:_http_agent": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_http_agent\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_http_client": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_http_client\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_http_common": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_http_common\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_http_incoming": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_http_incoming\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_http_outgoing": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_http_outgoing\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_http_server": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_http_server\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_stream_duplex": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_stream_duplex\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_stream_passthrough": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_stream_passthrough\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_stream_readable": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_stream_readable\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_stream_transform": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_stream_transform\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_stream_wrap": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_stream_wrap\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_stream_writable": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_stream_writable\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_tls_common": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_tls_common\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:_tls_wrap": { + "name": "ResolveMessage", + "message": "Cannot find package \"node:_tls_wrap\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:test/reporters": { + "name": "ResolveMessage", + "message": "Cannot find module \"node:test/reporters\" from \"/Users/jarred/Code/bun/test/exports/generate-exports.mjs\"" + }, + "node:wasi": { + "name": "ReferenceError", + "message": "Can't find variable: constants" + } + } +} \ No newline at end of file diff --git a/test/exports/node-exports.node-v20.1.0.json b/test/exports/node-exports.node-v20.1.0.json new file mode 100644 index 000000000..0ffc90856 --- /dev/null +++ b/test/exports/node-exports.node-v20.1.0.json @@ -0,0 +1,12843 @@ +{ + "import": { + "node:_http_agent": { + "Agent": { + "defaultMaxSockets": "number" + }, + "default": { + "Agent": { + "defaultMaxSockets": "number" + }, + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": "object", + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + } + }, + "globalAgent": { + "_events": { + "free": "function", + "newListener": "function" + }, + "_eventsCount": "number", + "_maxListeners": "undefined", + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": { + "keepAlive": "boolean", + "noDelay": "boolean", + "path": "object", + "scheduling": "string", + "timeout": "number" + }, + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + } + }, + "node:_http_client": { + "ClientRequest": "function", + "default": { + "ClientRequest": "function" + } + }, + "node:_http_common": { + "CRLF": "string", + "HTTPParser": { + "REQUEST": "number", + "RESPONSE": "number", + "kLenientAll": "number", + "kLenientChunkedLength": "number", + "kLenientHeaders": "number", + "kLenientKeepAlive": "number", + "kLenientNone": "number", + "kOnBody": "number", + "kOnExecute": "number", + "kOnHeaders": "number", + "kOnHeadersComplete": "number", + "kOnMessageBegin": "number", + "kOnMessageComplete": "number", + "kOnTimeout": "number" + }, + "_checkInvalidHeaderChar": "function", + "_checkIsHttpToken": "function", + "chunkExpression": "object", + "continueExpression": "object", + "default": { + "CRLF": "string", + "HTTPParser": { + "REQUEST": "number", + "RESPONSE": "number", + "kLenientAll": "number", + "kLenientChunkedLength": "number", + "kLenientHeaders": "number", + "kLenientKeepAlive": "number", + "kLenientNone": "number", + "kOnBody": "number", + "kOnExecute": "number", + "kOnHeaders": "number", + "kOnHeadersComplete": "number", + "kOnMessageBegin": "number", + "kOnMessageComplete": "number", + "kOnTimeout": "number" + }, + "_checkInvalidHeaderChar": "function", + "_checkIsHttpToken": "function", + "chunkExpression": "object", + "continueExpression": "object", + "freeParser": "function", + "isLenient": "function", + "kIncomingMessage": "symbol", + "methods": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "parsers": { + "ctor": "function", + "list": "object", + "max": "number", + "name": "string" + }, + "prepareError": "function" + }, + "freeParser": "function", + "isLenient": "function", + "kIncomingMessage": "symbol", + "methods": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "parsers": { + "ctor": "function", + "list": "object", + "max": "number", + "name": "string" + }, + "prepareError": "function" + }, + "node:_http_incoming": { + "IncomingMessage": "function", + "default": { + "IncomingMessage": "function", + "readStart": "function", + "readStop": "function" + }, + "readStart": "function", + "readStop": "function" + }, + "node:_http_outgoing": { + "OutgoingMessage": "function", + "default": { + "OutgoingMessage": "function", + "kHighWaterMark": "symbol", + "kUniqueHeaders": "symbol", + "parseUniqueHeadersOption": "function", + "validateHeaderName": "function", + "validateHeaderValue": "function" + }, + "kHighWaterMark": "symbol", + "kUniqueHeaders": "symbol", + "parseUniqueHeadersOption": "function", + "validateHeaderName": "function", + "validateHeaderValue": "function" + }, + "node:_http_server": { + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "_connectionListener": "function", + "default": { + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "_connectionListener": "function", + "kServerResponse": "symbol", + "setupConnectionsTracking": "function", + "storeHTTPOptions": "function" + }, + "kServerResponse": "symbol", + "setupConnectionsTracking": "function", + "storeHTTPOptions": "function" + }, + "node:_stream_duplex": { + "default": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "node:_stream_passthrough": { + "default": "function" + }, + "node:_stream_readable": { + "ReadableState": "function", + "_fromList": "function", + "default": { + "ReadableState": "function", + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "node:_stream_transform": { + "default": "function" + }, + "node:_stream_wrap": { + "default": "function" + }, + "node:_stream_writable": { + "WritableState": "function", + "default": { + "WritableState": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "fromWeb": "function", + "toWeb": "function" + }, + "node:_tls_common": { + "SecureContext": "function", + "createSecureContext": "function", + "default": { + "SecureContext": "function", + "createSecureContext": "function", + "translatePeerCertificate": "function" + }, + "translatePeerCertificate": "function" + }, + "node:_tls_wrap": { + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "createServer": "function", + "default": { + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "createServer": "function" + } + }, + "node:assert": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "default": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:assert/strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "default": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:async_hooks": { + "AsyncLocalStorage": "function", + "AsyncResource": "function", + "asyncWrapProviders": { + "BLOBREADER": "number", + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "QUIC_LOGSTREAM": "number", + "QUIC_PACKET": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "default": { + "AsyncLocalStorage": "function", + "AsyncResource": "function", + "asyncWrapProviders": { + "BLOBREADER": "number", + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "QUIC_LOGSTREAM": "number", + "QUIC_PACKET": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "node:buffer": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "copyBytesFrom": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "of": "function", + "poolSize": "number" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "default": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "copyBytesFrom": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "of": "function", + "poolSize": "number" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "isAscii": "function", + "isUtf8": "function", + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "function", + "transcode": "function" + }, + "isAscii": "function", + "isUtf8": "function", + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "function", + "transcode": "function" + }, + "node:child_process": { + "ChildProcess": "function", + "_forkChild": "function", + "default": { + "ChildProcess": "function", + "_forkChild": "function", + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "node:cluster": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "Worker": "function", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "default": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "Worker": "function", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "disconnect": "function", + "fork": "function", + "isMaster": "boolean", + "isPrimary": "boolean", + "isWorker": "boolean", + "schedulingPolicy": "number", + "settings": "object", + "setupMaster": "function", + "setupPrimary": "function", + "workers": "object" + }, + "disconnect": "function", + "fork": "function", + "isMaster": "boolean", + "isPrimary": "boolean", + "isWorker": "boolean", + "schedulingPolicy": "number", + "settings": "object", + "setupMaster": "function", + "setupPrimary": "function", + "workers": "object" + }, + "node:console": { + "Console": "function", + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "createTask": "function", + "debug": "function", + "default": { + "Console": "function", + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "createTask": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "node:constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENGINE_METHOD_ALL": "number", + "ENGINE_METHOD_CIPHERS": "number", + "ENGINE_METHOD_DH": "number", + "ENGINE_METHOD_DIGESTS": "number", + "ENGINE_METHOD_DSA": "number", + "ENGINE_METHOD_EC": "number", + "ENGINE_METHOD_NONE": "number", + "ENGINE_METHOD_PKEY_ASN1_METHS": "number", + "ENGINE_METHOD_PKEY_METHS": "number", + "ENGINE_METHOD_RAND": "number", + "ENGINE_METHOD_RSA": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTSUP": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EWOULDBLOCK": "number", + "EXDEV": "number", + "F_OK": "number", + "OPENSSL_VERSION_NUMBER": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_PSS_SALTLEN_AUTO": "number", + "RSA_PSS_SALTLEN_DIGEST": "number", + "RSA_PSS_SALTLEN_MAX_SIGN": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number", + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number", + "R_OK": "number", + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number", + "SSL_OP_ALL": "number", + "SSL_OP_ALLOW_NO_DHE_KEX": "number", + "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": "number", + "SSL_OP_CIPHER_SERVER_PREFERENCE": "number", + "SSL_OP_CISCO_ANYCONNECT": "number", + "SSL_OP_COOKIE_EXCHANGE": "number", + "SSL_OP_CRYPTOPRO_TLSEXT_BUG": "number", + "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": "number", + "SSL_OP_LEGACY_SERVER_CONNECT": "number", + "SSL_OP_NO_COMPRESSION": "number", + "SSL_OP_NO_ENCRYPT_THEN_MAC": "number", + "SSL_OP_NO_QUERY_MTU": "number", + "SSL_OP_NO_RENEGOTIATION": "number", + "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": "number", + "SSL_OP_NO_SSLv2": "number", + "SSL_OP_NO_SSLv3": "number", + "SSL_OP_NO_TICKET": "number", + "SSL_OP_NO_TLSv1": "number", + "SSL_OP_NO_TLSv1_1": "number", + "SSL_OP_NO_TLSv1_2": "number", + "SSL_OP_NO_TLSv1_3": "number", + "SSL_OP_PRIORITIZE_CHACHA": "number", + "SSL_OP_TLS_ROLLBACK_BUG": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "TLS1_1_VERSION": "number", + "TLS1_2_VERSION": "number", + "TLS1_3_VERSION": "number", + "TLS1_VERSION": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number", + "default": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENGINE_METHOD_ALL": "number", + "ENGINE_METHOD_CIPHERS": "number", + "ENGINE_METHOD_DH": "number", + "ENGINE_METHOD_DIGESTS": "number", + "ENGINE_METHOD_DSA": "number", + "ENGINE_METHOD_EC": "number", + "ENGINE_METHOD_NONE": "number", + "ENGINE_METHOD_PKEY_ASN1_METHS": "number", + "ENGINE_METHOD_PKEY_METHS": "number", + "ENGINE_METHOD_RAND": "number", + "ENGINE_METHOD_RSA": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTSUP": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EWOULDBLOCK": "number", + "EXDEV": "number", + "F_OK": "number", + "OPENSSL_VERSION_NUMBER": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_PSS_SALTLEN_AUTO": "number", + "RSA_PSS_SALTLEN_DIGEST": "number", + "RSA_PSS_SALTLEN_MAX_SIGN": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number", + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number", + "R_OK": "number", + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number", + "SSL_OP_ALL": "number", + "SSL_OP_ALLOW_NO_DHE_KEX": "number", + "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": "number", + "SSL_OP_CIPHER_SERVER_PREFERENCE": "number", + "SSL_OP_CISCO_ANYCONNECT": "number", + "SSL_OP_COOKIE_EXCHANGE": "number", + "SSL_OP_CRYPTOPRO_TLSEXT_BUG": "number", + "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": "number", + "SSL_OP_LEGACY_SERVER_CONNECT": "number", + "SSL_OP_NO_COMPRESSION": "number", + "SSL_OP_NO_ENCRYPT_THEN_MAC": "number", + "SSL_OP_NO_QUERY_MTU": "number", + "SSL_OP_NO_RENEGOTIATION": "number", + "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": "number", + "SSL_OP_NO_SSLv2": "number", + "SSL_OP_NO_SSLv3": "number", + "SSL_OP_NO_TICKET": "number", + "SSL_OP_NO_TLSv1": "number", + "SSL_OP_NO_TLSv1_1": "number", + "SSL_OP_NO_TLSv1_2": "number", + "SSL_OP_NO_TLSv1_3": "number", + "SSL_OP_PRIORITIZE_CHACHA": "number", + "SSL_OP_TLS_ROLLBACK_BUG": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "TLS1_1_VERSION": "number", + "TLS1_2_VERSION": "number", + "TLS1_3_VERSION": "number", + "TLS1_VERSION": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number", + "defaultCipherList": "string", + "defaultCoreCipherList": "string" + }, + "defaultCipherList": "string", + "defaultCoreCipherList": "string" + }, + "node:crypto": { + "Certificate": { + "exportChallenge": "function", + "exportPublicKey": "function", + "verifySpkac": "function" + }, + "Cipher": "function", + "Cipheriv": "function", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "ECDH": { + "convertKey": "function" + }, + "Hash": "function", + "Hmac": "function", + "KeyObject": "function", + "Sign": "function", + "Verify": "function", + "X509Certificate": "function", + "checkPrime": "function", + "checkPrimeSync": "function", + "constants": { + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "ENGINE_METHOD_ALL": "number", + "ENGINE_METHOD_CIPHERS": "number", + "ENGINE_METHOD_DH": "number", + "ENGINE_METHOD_DIGESTS": "number", + "ENGINE_METHOD_DSA": "number", + "ENGINE_METHOD_EC": "number", + "ENGINE_METHOD_NONE": "number", + "ENGINE_METHOD_PKEY_ASN1_METHS": "number", + "ENGINE_METHOD_PKEY_METHS": "number", + "ENGINE_METHOD_RAND": "number", + "ENGINE_METHOD_RSA": "number", + "OPENSSL_VERSION_NUMBER": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_PSS_SALTLEN_AUTO": "number", + "RSA_PSS_SALTLEN_DIGEST": "number", + "RSA_PSS_SALTLEN_MAX_SIGN": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number", + "SSL_OP_ALL": "number", + "SSL_OP_ALLOW_NO_DHE_KEX": "number", + "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": "number", + "SSL_OP_CIPHER_SERVER_PREFERENCE": "number", + "SSL_OP_CISCO_ANYCONNECT": "number", + "SSL_OP_COOKIE_EXCHANGE": "number", + "SSL_OP_CRYPTOPRO_TLSEXT_BUG": "number", + "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": "number", + "SSL_OP_LEGACY_SERVER_CONNECT": "number", + "SSL_OP_NO_COMPRESSION": "number", + "SSL_OP_NO_ENCRYPT_THEN_MAC": "number", + "SSL_OP_NO_QUERY_MTU": "number", + "SSL_OP_NO_RENEGOTIATION": "number", + "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": "number", + "SSL_OP_NO_SSLv2": "number", + "SSL_OP_NO_SSLv3": "number", + "SSL_OP_NO_TICKET": "number", + "SSL_OP_NO_TLSv1": "number", + "SSL_OP_NO_TLSv1_1": "number", + "SSL_OP_NO_TLSv1_2": "number", + "SSL_OP_NO_TLSv1_3": "number", + "SSL_OP_PRIORITIZE_CHACHA": "number", + "SSL_OP_TLS_ROLLBACK_BUG": "number", + "TLS1_1_VERSION": "number", + "TLS1_2_VERSION": "number", + "TLS1_3_VERSION": "number", + "TLS1_VERSION": "number", + "defaultCipherList": "string", + "defaultCoreCipherList": "string" + }, + "createCipheriv": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": "function", + "createHmac": "function", + "createPrivateKey": "function", + "createPublicKey": "function", + "createSecretKey": "function", + "createSign": "function", + "createVerify": "function", + "default": { + "Certificate": { + "exportChallenge": "function", + "exportPublicKey": "function", + "verifySpkac": "function" + }, + "Cipher": "function", + "Cipheriv": "function", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "ECDH": { + "convertKey": "function" + }, + "Hash": "function", + "Hmac": "function", + "KeyObject": "function", + "Sign": "function", + "Verify": "function", + "X509Certificate": "function", + "checkPrime": "function", + "checkPrimeSync": "function", + "constants": { + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "ENGINE_METHOD_ALL": "number", + "ENGINE_METHOD_CIPHERS": "number", + "ENGINE_METHOD_DH": "number", + "ENGINE_METHOD_DIGESTS": "number", + "ENGINE_METHOD_DSA": "number", + "ENGINE_METHOD_EC": "number", + "ENGINE_METHOD_NONE": "number", + "ENGINE_METHOD_PKEY_ASN1_METHS": "number", + "ENGINE_METHOD_PKEY_METHS": "number", + "ENGINE_METHOD_RAND": "number", + "ENGINE_METHOD_RSA": "number", + "OPENSSL_VERSION_NUMBER": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_PSS_SALTLEN_AUTO": "number", + "RSA_PSS_SALTLEN_DIGEST": "number", + "RSA_PSS_SALTLEN_MAX_SIGN": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number", + "SSL_OP_ALL": "number", + "SSL_OP_ALLOW_NO_DHE_KEX": "number", + "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": "number", + "SSL_OP_CIPHER_SERVER_PREFERENCE": "number", + "SSL_OP_CISCO_ANYCONNECT": "number", + "SSL_OP_COOKIE_EXCHANGE": "number", + "SSL_OP_CRYPTOPRO_TLSEXT_BUG": "number", + "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": "number", + "SSL_OP_LEGACY_SERVER_CONNECT": "number", + "SSL_OP_NO_COMPRESSION": "number", + "SSL_OP_NO_ENCRYPT_THEN_MAC": "number", + "SSL_OP_NO_QUERY_MTU": "number", + "SSL_OP_NO_RENEGOTIATION": "number", + "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": "number", + "SSL_OP_NO_SSLv2": "number", + "SSL_OP_NO_SSLv3": "number", + "SSL_OP_NO_TICKET": "number", + "SSL_OP_NO_TLSv1": "number", + "SSL_OP_NO_TLSv1_1": "number", + "SSL_OP_NO_TLSv1_2": "number", + "SSL_OP_NO_TLSv1_3": "number", + "SSL_OP_PRIORITIZE_CHACHA": "number", + "SSL_OP_TLS_ROLLBACK_BUG": "number", + "TLS1_1_VERSION": "number", + "TLS1_2_VERSION": "number", + "TLS1_3_VERSION": "number", + "TLS1_VERSION": "number", + "defaultCipherList": "string", + "defaultCoreCipherList": "string" + }, + "createCipheriv": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": "function", + "createHmac": "function", + "createPrivateKey": "function", + "createPublicKey": "function", + "createSecretKey": "function", + "createSign": "function", + "createVerify": "function", + "diffieHellman": "function", + "generateKey": "function", + "generateKeyPair": "function", + "generateKeyPairSync": "function", + "generateKeySync": "function", + "generatePrime": "function", + "generatePrimeSync": "function", + "getCipherInfo": "function", + "getCiphers": "function", + "getCurves": "function", + "getDiffieHellman": "function", + "getFips": "function", + "getHashes": "function", + "getRandomValues": "function", + "hkdf": "function", + "hkdfSync": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomInt": "function", + "randomUUID": "function", + "scrypt": "function", + "scryptSync": "function", + "secureHeapUsed": "function", + "setEngine": "function", + "setFips": "function", + "sign": "function", + "subtle": "object", + "timingSafeEqual": "function", + "verify": "function", + "webcrypto": "object" + }, + "diffieHellman": "function", + "generateKey": "function", + "generateKeyPair": "function", + "generateKeyPairSync": "function", + "generateKeySync": "function", + "generatePrime": "function", + "generatePrimeSync": "function", + "getCipherInfo": "function", + "getCiphers": "function", + "getCurves": "function", + "getDiffieHellman": "function", + "getFips": "function", + "getHashes": "function", + "getRandomValues": "function", + "hkdf": "function", + "hkdfSync": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomInt": "function", + "randomUUID": "function", + "scrypt": "function", + "scryptSync": "function", + "secureHeapUsed": "function", + "setEngine": "function", + "setFips": "function", + "sign": "function", + "subtle": "object", + "timingSafeEqual": "function", + "verify": "function", + "webcrypto": "object" + }, + "node:dgram": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function", + "default": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function" + } + }, + "node:diagnostics_channel": { + "Channel": "function", + "channel": "function", + "default": { + "Channel": "function", + "channel": "function", + "hasSubscribers": "function", + "subscribe": "function", + "tracingChannel": "function", + "unsubscribe": "function" + }, + "hasSubscribers": "function", + "subscribe": "function", + "tracingChannel": "function", + "unsubscribe": "function" + }, + "node:dns": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "default": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "promises": { + "ADDRGETNETWORKPARAMS": "string", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "promises": { + "ADDRGETNETWORKPARAMS": "string", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "node:dns/promises": { + "ADDRGETNETWORKPARAMS": "string", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "default": { + "ADDRGETNETWORKPARAMS": "string", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "node:domain": { + "Domain": "function", + "_stack": "object", + "active": "object", + "create": "function", + "createDomain": "function", + "default": { + "Domain": "function", + "_stack": "object", + "active": "object", + "create": "function", + "createDomain": "function" + } + }, + "node:events": { + "EventEmitter": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "getMaxListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "getMaxListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "default": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "getMaxListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "getMaxListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "getMaxListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "node:fs": { + "Dir": "function", + "Dirent": "function", + "F_OK": "number", + "FileReadStream": "function", + "FileWriteStream": "function", + "R_OK": "number", + "ReadStream": "function", + "Stats": "function", + "W_OK": "number", + "WriteStream": "function", + "X_OK": "number", + "_toUnixTimestamp": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "cp": "function", + "cpSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "default": { + "Dir": "function", + "Dirent": "function", + "F_OK": "number", + "FileReadStream": "function", + "FileWriteStream": "function", + "R_OK": "number", + "ReadStream": "function", + "Stats": "function", + "W_OK": "number", + "WriteStream": "function", + "X_OK": "number", + "_toUnixTimestamp": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "cp": "function", + "cpSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fdatasync": "function", + "fdatasyncSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openAsBlob": "function", + "openSync": "function", + "opendir": "function", + "opendirSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "constants": "object", + "copyFile": "function", + "cp": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "opendir": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "statfs": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "writeFile": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": "function" + }, + "realpathSync": { + "native": "function" + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "statfs": "function", + "statfsSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "unwatchFile": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "watchFile": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fdatasync": "function", + "fdatasyncSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openAsBlob": "function", + "openSync": "function", + "opendir": "function", + "opendirSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "cp": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "opendir": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "statfs": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "writeFile": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": "function" + }, + "realpathSync": { + "native": "function" + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "statfs": "function", + "statfsSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "unwatchFile": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "watchFile": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "node:fs/promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "cp": "function", + "default": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "cp": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "opendir": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "statfs": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "writeFile": "function" + }, + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "opendir": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "statfs": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "writeFile": "function" + }, + "node:http": { + "Agent": { + "defaultMaxSockets": "number" + }, + "ClientRequest": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "OutgoingMessage": "function", + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "_connectionListener": "function", + "createServer": "function", + "default": { + "Agent": { + "defaultMaxSockets": "number" + }, + "ClientRequest": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "OutgoingMessage": "function", + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "_connectionListener": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": "object", + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function", + "validateHeaderName": "function", + "validateHeaderValue": "function" + }, + "get": "function", + "globalAgent": { + "_events": { + "free": "function", + "newListener": "function" + }, + "_eventsCount": "number", + "_maxListeners": "undefined", + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": { + "keepAlive": "boolean", + "noDelay": "boolean", + "path": "object", + "scheduling": "string", + "timeout": "number" + }, + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function", + "validateHeaderName": "function", + "validateHeaderValue": "function" + }, + "node:http2": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "default": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "node:https": { + "Agent": "function", + "Server": "function", + "createServer": "function", + "default": { + "Agent": "function", + "Server": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "_sessionCache": "object", + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxCachedSessions": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": "object", + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + }, + "request": "function" + }, + "get": "function", + "globalAgent": { + "_events": { + "free": "function", + "newListener": "function" + }, + "_eventsCount": "number", + "_maxListeners": "undefined", + "_sessionCache": { + "list": "object", + "map": "object" + }, + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxCachedSessions": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": { + "keepAlive": "boolean", + "noDelay": "boolean", + "path": "object", + "scheduling": "string", + "timeout": "number" + }, + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + }, + "request": "function" + }, + "node:inspector": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "default": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:inspector/promises": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "default": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:module": { + "Module": { + "Module": { + "Module": "function", + "SourceMap": "function", + "_cache": "object", + "_debug": "function", + "_extensions": "object", + "_findPath": "function", + "_initPaths": "function", + "_load": "function", + "_nodeModulePaths": "function", + "_pathCache": "object", + "_preloadModules": "function", + "_resolveFilename": "function", + "_resolveLookupPaths": "function", + "builtinModules": "object", + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": "object", + "isBuiltin": "function", + "runMain": "function", + "syncBuiltinESMExports": "function" + }, + "SourceMap": "function", + "_cache": "object", + "_debug": "function", + "_extensions": { + ".js": "function", + ".json": "function", + ".node": "function" + }, + "_findPath": "function", + "_initPaths": "function", + "_load": "function", + "_nodeModulePaths": "function", + "_pathCache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs\u0000": "string" + }, + "_preloadModules": "function", + "_resolveFilename": "function", + "_resolveLookupPaths": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string" + }, + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": { + "0": "string", + "1": "string", + "2": "string" + }, + "isBuiltin": "function", + "runMain": "function", + "syncBuiltinESMExports": "function" + }, + "SourceMap": "function", + "_cache": "object", + "_debug": "function", + "_extensions": { + ".js": "function", + ".json": "function", + ".node": "function" + }, + "_findPath": "function", + "_initPaths": "function", + "_load": "function", + "_nodeModulePaths": "function", + "_pathCache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs\u0000": "string" + }, + "_preloadModules": "function", + "_resolveFilename": "function", + "_resolveLookupPaths": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string" + }, + "createRequire": "function", + "default": { + "Module": { + "Module": "function", + "SourceMap": "function", + "_cache": "object", + "_debug": "function", + "_extensions": "object", + "_findPath": "function", + "_initPaths": "function", + "_load": "function", + "_nodeModulePaths": "function", + "_pathCache": "object", + "_preloadModules": "function", + "_resolveFilename": "function", + "_resolveLookupPaths": "function", + "builtinModules": "object", + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": "object", + "isBuiltin": "function", + "runMain": "function", + "syncBuiltinESMExports": "function" + }, + "SourceMap": "function", + "_cache": "object", + "_debug": "function", + "_extensions": { + ".js": "function", + ".json": "function", + ".node": "function" + }, + "_findPath": "function", + "_initPaths": "function", + "_load": "function", + "_nodeModulePaths": "function", + "_pathCache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs\u0000": "string" + }, + "_preloadModules": "function", + "_resolveFilename": "function", + "_resolveLookupPaths": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string" + }, + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": { + "0": "string", + "1": "string", + "2": "string" + }, + "isBuiltin": "function", + "runMain": "function", + "syncBuiltinESMExports": "function" + }, + "findSourceMap": "function", + "globalPaths": { + "0": "string", + "1": "string", + "2": "string" + }, + "isBuiltin": "function", + "runMain": "function", + "syncBuiltinESMExports": "function" + }, + "node:net": { + "BlockList": "function", + "Server": "function", + "Socket": "function", + "SocketAddress": "function", + "Stream": "function", + "_createServerHandle": "function", + "_normalizeArgs": "function", + "_setSimultaneousAccepts": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "default": { + "BlockList": "function", + "Server": "function", + "Socket": "function", + "SocketAddress": "function", + "Stream": "function", + "_createServerHandle": "function", + "_normalizeArgs": "function", + "_setSimultaneousAccepts": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "getDefaultAutoSelectFamily": "function", + "getDefaultAutoSelectFamilyAttemptTimeout": "function", + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function", + "setDefaultAutoSelectFamily": "function", + "setDefaultAutoSelectFamilyAttemptTimeout": "function" + }, + "getDefaultAutoSelectFamily": "function", + "getDefaultAutoSelectFamilyAttemptTimeout": "function", + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function", + "setDefaultAutoSelectFamily": "function", + "setDefaultAutoSelectFamilyAttemptTimeout": "function" + }, + "node:os": { + "EOL": "string", + "arch": "function", + "availableParallelism": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": { + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number" + }, + "errno": { + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTSUP": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EWOULDBLOCK": "number", + "EXDEV": "number" + }, + "priority": { + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number" + }, + "signals": { + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number" + } + }, + "cpus": "function", + "default": { + "EOL": "string", + "arch": "function", + "availableParallelism": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": "object", + "errno": "object", + "priority": "object", + "signals": "object" + }, + "cpus": "function", + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "node:path": { + "_makeLong": "function", + "basename": "function", + "default": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + } + }, + "node:path/posix": { + "_makeLong": "function", + "basename": "function", + "default": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + } + }, + "node:path/win32": { + "_makeLong": "function", + "basename": "function", + "default": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + } + }, + "node:perf_hooks": { + "Performance": "function", + "PerformanceEntry": "function", + "PerformanceMark": "function", + "PerformanceMeasure": "function", + "PerformanceObserver": "function", + "PerformanceObserverEntryList": "function", + "PerformanceResourceTiming": "function", + "constants": { + "NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE": "number", + "NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY": "number", + "NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED": "number", + "NODE_PERFORMANCE_GC_FLAGS_FORCED": "number", + "NODE_PERFORMANCE_GC_FLAGS_NO": "number", + "NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE": "number", + "NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING": "number", + "NODE_PERFORMANCE_GC_INCREMENTAL": "number", + "NODE_PERFORMANCE_GC_MAJOR": "number", + "NODE_PERFORMANCE_GC_MINOR": "number", + "NODE_PERFORMANCE_GC_WEAKCB": "number" + }, + "createHistogram": "function", + "default": { + "Performance": "function", + "PerformanceEntry": "function", + "PerformanceMark": "function", + "PerformanceMeasure": "function", + "PerformanceObserver": "function", + "PerformanceObserverEntryList": "function", + "PerformanceResourceTiming": "function", + "constants": { + "NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE": "number", + "NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY": "number", + "NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED": "number", + "NODE_PERFORMANCE_GC_FLAGS_FORCED": "number", + "NODE_PERFORMANCE_GC_FLAGS_NO": "number", + "NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE": "number", + "NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING": "number", + "NODE_PERFORMANCE_GC_INCREMENTAL": "number", + "NODE_PERFORMANCE_GC_MAJOR": "number", + "NODE_PERFORMANCE_GC_MINOR": "number", + "NODE_PERFORMANCE_GC_WEAKCB": "number" + }, + "createHistogram": "function", + "monitorEventLoopDelay": "function", + "performance": "object" + }, + "monitorEventLoopDelay": "function", + "performance": "object" + }, + "node:process": { + "_debugEnd": "function", + "_debugProcess": "function", + "_events": { + "SIGWINCH": "function", + "exit": "function", + "newListener": { + "0": "function", + "1": "function" + }, + "removeListener": { + "0": "function", + "1": "function" + }, + "warning": "function" + }, + "_eventsCount": "number", + "_exiting": "boolean", + "_fatalException": "function", + "_getActiveHandles": "function", + "_getActiveRequests": "function", + "_kill": "function", + "_linkedBinding": "function", + "_maxListeners": "undefined", + "_preload_modules": "object", + "_rawDebug": "function", + "_startProfilerIdleNotifier": "function", + "_stopProfilerIdleNotifier": "function", + "_tickCallback": "function", + "abort": "function", + "allowedNodeEnvironmentFlags": "object", + "arch": "string", + "argv": { + "0": "string", + "1": "string" + }, + "argv0": "string", + "assert": "function", + "binding": "function", + "chdir": "function", + "config": { + "target_defaults": { + "cflags": "object", + "default_configuration": "string", + "defines": "object", + "include_dirs": "object", + "libraries": "object" + }, + "variables": { + "arm_fpu": "string", + "asan": "number", + "coverage": "boolean", + "dcheck_always_on": "number", + "debug_nghttp2": "boolean", + "debug_node": "boolean", + "enable_lto": "boolean", + "enable_pgo_generate": "boolean", + "enable_pgo_use": "boolean", + "error_on_warn": "boolean", + "force_dynamic_crt": "number", + "host_arch": "string", + "icu_gyp_path": "string", + "icu_small": "boolean", + "icu_ver_major": "string", + "is_debug": "number", + "libdir": "string", + "llvm_version": "string", + "napi_build_version": "string", + "node_builtin_shareable_builtins": "object", + "node_byteorder": "string", + "node_debug_lib": "boolean", + "node_enable_d8": "boolean", + "node_enable_v8_vtunejit": "boolean", + "node_fipsinstall": "boolean", + "node_install_corepack": "boolean", + "node_install_npm": "boolean", + "node_library_files": "object", + "node_module_version": "number", + "node_no_browser_globals": "boolean", + "node_prefix": "string", + "node_release_urlbase": "string", + "node_shared": "boolean", + "node_shared_brotli": "boolean", + "node_shared_cares": "boolean", + "node_shared_http_parser": "boolean", + "node_shared_libuv": "boolean", + "node_shared_nghttp2": "boolean", + "node_shared_nghttp3": "boolean", + "node_shared_ngtcp2": "boolean", + "node_shared_openssl": "boolean", + "node_shared_zlib": "boolean", + "node_tag": "string", + "node_target_type": "string", + "node_use_bundled_v8": "boolean", + "node_use_node_code_cache": "boolean", + "node_use_node_snapshot": "boolean", + "node_use_openssl": "boolean", + "node_use_v8_platform": "boolean", + "node_with_ltcg": "boolean", + "node_without_node_options": "boolean", + "openssl_is_fips": "boolean", + "openssl_quic": "boolean", + "ossfuzz": "boolean", + "shlib_suffix": "string", + "single_executable_application": "boolean", + "target_arch": "string", + "v8_enable_31bit_smis_on_64bit_arch": "number", + "v8_enable_gdbjit": "number", + "v8_enable_hugepage": "number", + "v8_enable_i18n_support": "number", + "v8_enable_inspector": "number", + "v8_enable_javascript_promise_hooks": "number", + "v8_enable_lite_mode": "number", + "v8_enable_object_print": "number", + "v8_enable_pointer_compression": "number", + "v8_enable_shared_ro_heap": "number", + "v8_enable_webassembly": "number", + "v8_no_strict_aliasing": "number", + "v8_optimized_debug": "number", + "v8_promise_internal_field_count": "number", + "v8_random_seed": "number", + "v8_trace_maps": "number", + "v8_use_siphash": "number", + "want_separate_host_toolset": "number" + } + }, + "constrainedMemory": "function", + "cpuUsage": "function", + "cwd": "function", + "debugPort": "number", + "default": { + "_debugEnd": "function", + "_debugProcess": "function", + "_events": { + "SIGWINCH": "function", + "exit": "function", + "newListener": "object", + "removeListener": "object", + "warning": "function" + }, + "_eventsCount": "number", + "_exiting": "boolean", + "_fatalException": "function", + "_getActiveHandles": "function", + "_getActiveRequests": "function", + "_kill": "function", + "_linkedBinding": "function", + "_maxListeners": "undefined", + "_preload_modules": "object", + "_rawDebug": "function", + "_startProfilerIdleNotifier": "function", + "_stopProfilerIdleNotifier": "function", + "_tickCallback": "function", + "abort": "function", + "allowedNodeEnvironmentFlags": "object", + "arch": "string", + "argv": { + "0": "string", + "1": "string" + }, + "argv0": "string", + "assert": "function", + "binding": "function", + "chdir": "function", + "config": { + "target_defaults": "object", + "variables": "object" + }, + "constrainedMemory": "function", + "cpuUsage": "function", + "cwd": "function", + "debugPort": "number", + "dlopen": "function", + "domain": "object", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "undefined", + "features": { + "cached_builtins": "boolean", + "debug": "boolean", + "inspector": "boolean", + "ipv6": "boolean", + "tls": "boolean", + "tls_alpn": "boolean", + "tls_ocsp": "boolean", + "tls_sni": "boolean", + "uv": "boolean" + }, + "getActiveResourcesInfo": "function", + "getegid": "function", + "geteuid": "function", + "getgid": "function", + "getgroups": "function", + "getuid": "function", + "hasUncaughtExceptionCaptureCallback": "function", + "hrtime": { + "bigint": "function" + }, + "initgroups": "function", + "kill": "function", + "memoryUsage": { + "rss": "function" + }, + "moduleLoadList": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string", + "69": "string", + "70": "string", + "71": "string", + "72": "string", + "73": "string", + "74": "string", + "75": "string", + "76": "string", + "77": "string", + "78": "string", + "79": "string", + "80": "string", + "81": "string", + "82": "string", + "83": "string", + "84": "string", + "85": "string", + "86": "string", + "87": "string", + "88": "string", + "89": "string", + "90": "string", + "91": "string", + "92": "string", + "93": "string", + "94": "string", + "95": "string", + "96": "string", + "97": "string", + "98": "string", + "99": "string", + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "104": "string", + "105": "string", + "106": "string", + "107": "string", + "108": "string", + "109": "string", + "110": "string", + "111": "string", + "112": "string", + "113": "string", + "114": "string", + "115": "string", + "116": "string", + "117": "string", + "118": "string", + "119": "string", + "120": "string", + "121": "string", + "122": "string", + "123": "string", + "124": "string", + "125": "string", + "126": "string", + "127": "string", + "128": "string", + "129": "string", + "130": "string", + "131": "string", + "132": "string", + "133": "string", + "134": "string", + "135": "string", + "136": "string", + "137": "string", + "138": "string", + "139": "string", + "140": "string", + "141": "string", + "142": "string", + "143": "string", + "144": "string", + "145": "string", + "146": "string", + "147": "string", + "148": "string", + "149": "string", + "150": "string", + "151": "string", + "152": "string", + "153": "string", + "154": "string", + "155": "string", + "156": "string", + "157": "string", + "158": "string", + "159": "string", + "160": "string", + "161": "string", + "162": "string", + "163": "string", + "164": "string", + "165": "string", + "166": "string", + "167": "string", + "168": "string", + "169": "string", + "170": "string", + "171": "string", + "172": "string", + "173": "string", + "174": "string", + "175": "string", + "176": "string", + "177": "string", + "178": "string", + "179": "string", + "180": "string", + "181": "string", + "182": "string", + "183": "string", + "184": "string", + "185": "string", + "186": "string", + "187": "string", + "188": "string", + "189": "string", + "190": "string", + "191": "string", + "192": "string", + "193": "string", + "194": "string", + "195": "string", + "196": "string", + "197": "string", + "198": "string", + "199": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "209": "string", + "210": "string", + "211": "string", + "212": "string", + "213": "string", + "214": "string", + "215": "string", + "216": "string", + "217": "string", + "218": "string", + "219": "string", + "220": "string", + "221": "string", + "222": "string", + "223": "string", + "224": "string", + "225": "string", + "226": "string", + "227": "string", + "228": "string", + "229": "string", + "230": "string", + "231": "string", + "232": "string", + "233": "string", + "234": "string", + "235": "string", + "236": "string", + "237": "string", + "238": "string", + "239": "string", + "240": "string", + "241": "string", + "242": "string", + "243": "string", + "244": "string", + "245": "string", + "246": "string", + "247": "string", + "248": "string", + "249": "string", + "250": "string", + "251": "string", + "252": "string" + }, + "nextTick": "function", + "openStdin": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "reallyExit": "function", + "release": { + "headersUrl": "string", + "name": "string", + "sourceUrl": "string" + }, + "report": { + "compact": "boolean", + "directory": "string", + "filename": "string", + "getReport": "function", + "reportOnFatalError": "boolean", + "reportOnSignal": "boolean", + "reportOnUncaughtException": "boolean", + "signal": "string", + "writeReport": "function" + }, + "resourceUsage": "function", + "setSourceMapsEnabled": "function", + "setUncaughtExceptionCaptureCallback": "function", + "setegid": "function", + "seteuid": "function", + "setgid": "function", + "setgroups": "function", + "setuid": "function", + "stderr": { + "_closeAfterHandlingError": "boolean", + "_destroy": "function", + "_events": "object", + "_eventsCount": "number", + "_hadError": "boolean", + "_host": "object", + "_isStdio": "boolean", + "_maxListeners": "undefined", + "_parent": "object", + "_pendingData": "object", + "_pendingEncoding": "string", + "_readableState": "object", + "_server": "object", + "_sockname": "object", + "_type": "string", + "_writableState": "object", + "allowHalfOpen": "boolean", + "columns": "number", + "connecting": "boolean", + "destroySoon": "function", + "fd": "number", + "rows": "number", + "server": "object" + }, + "stdin": { + "_closeAfterHandlingError": "boolean", + "_events": "object", + "_eventsCount": "number", + "_hadError": "boolean", + "_host": "object", + "_maxListeners": "undefined", + "_parent": "object", + "_pendingData": "object", + "_pendingEncoding": "string", + "_readableState": "object", + "_server": "object", + "_sockname": "object", + "_writableState": "object", + "allowHalfOpen": "boolean", + "connecting": "boolean", + "fd": "number", + "isRaw": "boolean", + "isTTY": "boolean", + "server": "object" + }, + "stdout": { + "_destroy": "function", + "_events": "object", + "_eventsCount": "number", + "_isStdio": "boolean", + "_maxListeners": "undefined", + "_type": "string", + "_writableState": "object", + "autoClose": "boolean", + "destroySoon": "function", + "fd": "number", + "readable": "boolean" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "acorn": "string", + "ada": "string", + "ares": "string", + "brotli": "string", + "cldr": "string", + "icu": "string", + "llhttp": "string", + "modules": "string", + "napi": "string", + "nghttp2": "string", + "node": "string", + "openssl": "string", + "simdutf": "string", + "tz": "string", + "undici": "string", + "unicode": "string", + "uv": "string", + "uvwasi": "string", + "v8": "string", + "zlib": "string" + } + }, + "dlopen": "function", + "domain": "object", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "undefined", + "features": { + "cached_builtins": "boolean", + "debug": "boolean", + "inspector": "boolean", + "ipv6": "boolean", + "tls": "boolean", + "tls_alpn": "boolean", + "tls_ocsp": "boolean", + "tls_sni": "boolean", + "uv": "boolean" + }, + "getActiveResourcesInfo": "function", + "getegid": "function", + "geteuid": "function", + "getgid": "function", + "getgroups": "function", + "getuid": "function", + "hasUncaughtExceptionCaptureCallback": "function", + "hrtime": { + "bigint": "function" + }, + "initgroups": "function", + "kill": "function", + "memoryUsage": { + "rss": "function" + }, + "moduleLoadList": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string", + "69": "string", + "70": "string", + "71": "string", + "72": "string", + "73": "string", + "74": "string", + "75": "string", + "76": "string", + "77": "string", + "78": "string", + "79": "string", + "80": "string", + "81": "string", + "82": "string", + "83": "string", + "84": "string", + "85": "string", + "86": "string", + "87": "string", + "88": "string", + "89": "string", + "90": "string", + "91": "string", + "92": "string", + "93": "string", + "94": "string", + "95": "string", + "96": "string", + "97": "string", + "98": "string", + "99": "string", + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "104": "string", + "105": "string", + "106": "string", + "107": "string", + "108": "string", + "109": "string", + "110": "string", + "111": "string", + "112": "string", + "113": "string", + "114": "string", + "115": "string", + "116": "string", + "117": "string", + "118": "string", + "119": "string", + "120": "string", + "121": "string", + "122": "string", + "123": "string", + "124": "string", + "125": "string", + "126": "string", + "127": "string", + "128": "string", + "129": "string", + "130": "string", + "131": "string", + "132": "string", + "133": "string", + "134": "string", + "135": "string", + "136": "string", + "137": "string", + "138": "string", + "139": "string", + "140": "string", + "141": "string", + "142": "string", + "143": "string", + "144": "string", + "145": "string", + "146": "string", + "147": "string", + "148": "string", + "149": "string", + "150": "string", + "151": "string", + "152": "string", + "153": "string", + "154": "string", + "155": "string", + "156": "string", + "157": "string", + "158": "string", + "159": "string", + "160": "string", + "161": "string", + "162": "string", + "163": "string", + "164": "string", + "165": "string", + "166": "string", + "167": "string", + "168": "string", + "169": "string", + "170": "string", + "171": "string", + "172": "string", + "173": "string", + "174": "string", + "175": "string", + "176": "string", + "177": "string", + "178": "string", + "179": "string", + "180": "string", + "181": "string", + "182": "string", + "183": "string", + "184": "string", + "185": "string", + "186": "string", + "187": "string", + "188": "string", + "189": "string", + "190": "string", + "191": "string", + "192": "string", + "193": "string", + "194": "string", + "195": "string", + "196": "string", + "197": "string", + "198": "string", + "199": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "209": "string", + "210": "string", + "211": "string", + "212": "string", + "213": "string", + "214": "string", + "215": "string", + "216": "string", + "217": "string", + "218": "string", + "219": "string", + "220": "string", + "221": "string", + "222": "string", + "223": "string", + "224": "string", + "225": "string", + "226": "string", + "227": "string", + "228": "string", + "229": "string", + "230": "string", + "231": "string", + "232": "string", + "233": "string", + "234": "string", + "235": "string", + "236": "string", + "237": "string", + "238": "string", + "239": "string", + "240": "string", + "241": "string", + "242": "string", + "243": "string", + "244": "string", + "245": "string", + "246": "string", + "247": "string", + "248": "string", + "249": "string", + "250": "string", + "251": "string", + "252": "string" + }, + "nextTick": "function", + "openStdin": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "reallyExit": "function", + "release": { + "headersUrl": "string", + "name": "string", + "sourceUrl": "string" + }, + "report": { + "compact": "boolean", + "directory": "string", + "filename": "string", + "getReport": "function", + "reportOnFatalError": "boolean", + "reportOnSignal": "boolean", + "reportOnUncaughtException": "boolean", + "signal": "string", + "writeReport": "function" + }, + "resourceUsage": "function", + "setSourceMapsEnabled": "function", + "setUncaughtExceptionCaptureCallback": "function", + "setegid": "function", + "seteuid": "function", + "setgid": "function", + "setgroups": "function", + "setuid": "function", + "stderr": { + "_closeAfterHandlingError": "boolean", + "_destroy": "function", + "_events": { + "end": "function" + }, + "_eventsCount": "number", + "_hadError": "boolean", + "_host": "object", + "_isStdio": "boolean", + "_maxListeners": "undefined", + "_parent": "object", + "_pendingData": "object", + "_pendingEncoding": "string", + "_readableState": { + "autoDestroy": "boolean", + "awaitDrainWriters": "object", + "buffer": "object", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "dataEmitted": "boolean", + "decoder": "object", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "emittedReadable": "boolean", + "encoding": "object", + "endEmitted": "boolean", + "ended": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "flowing": "object", + "highWaterMark": "number", + "length": "number", + "multiAwaitDrain": "boolean", + "needReadable": "boolean", + "objectMode": "boolean", + "pipes": "object", + "readableListening": "boolean", + "reading": "boolean", + "readingMore": "boolean", + "resumeScheduled": "boolean", + "sync": "boolean" + }, + "_server": "object", + "_sockname": "object", + "_type": "string", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "allowHalfOpen": "boolean", + "columns": "number", + "connecting": "boolean", + "destroySoon": "function", + "fd": "number", + "rows": "number", + "server": "object" + }, + "stdin": { + "_closeAfterHandlingError": "boolean", + "_events": { + "end": "function", + "pause": "function" + }, + "_eventsCount": "number", + "_hadError": "boolean", + "_host": "object", + "_maxListeners": "undefined", + "_parent": "object", + "_pendingData": "object", + "_pendingEncoding": "string", + "_readableState": { + "autoDestroy": "boolean", + "awaitDrainWriters": "object", + "buffer": "object", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "dataEmitted": "boolean", + "decoder": "object", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "emittedReadable": "boolean", + "encoding": "object", + "endEmitted": "boolean", + "ended": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "flowing": "object", + "highWaterMark": "number", + "length": "number", + "multiAwaitDrain": "boolean", + "needReadable": "boolean", + "objectMode": "boolean", + "pipes": "object", + "readableListening": "boolean", + "reading": "boolean", + "readingMore": "boolean", + "resumeScheduled": "boolean", + "sync": "boolean" + }, + "_server": "object", + "_sockname": "object", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "allowHalfOpen": "boolean", + "connecting": "boolean", + "fd": "number", + "isRaw": "boolean", + "isTTY": "boolean", + "server": "object" + }, + "stdout": { + "_destroy": "function", + "_events": "object", + "_eventsCount": "number", + "_isStdio": "boolean", + "_maxListeners": "undefined", + "_type": "string", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "autoClose": "boolean", + "destroySoon": "function", + "fd": "number", + "readable": "boolean" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "acorn": "string", + "ada": "string", + "ares": "string", + "brotli": "string", + "cldr": "string", + "icu": "string", + "llhttp": "string", + "modules": "string", + "napi": "string", + "nghttp2": "string", + "node": "string", + "openssl": "string", + "simdutf": "string", + "tz": "string", + "undici": "string", + "unicode": "string", + "uv": "string", + "uvwasi": "string", + "v8": "string", + "zlib": "string" + } + }, + "node:punycode": { + "decode": "function", + "default": { + "decode": "function", + "encode": "function", + "toASCII": "function", + "toUnicode": "function", + "ucs2": { + "decode": "function", + "encode": "function" + }, + "version": "string" + }, + "encode": "function", + "toASCII": "function", + "toUnicode": "function", + "ucs2": { + "decode": "function", + "encode": "function" + }, + "version": "string" + }, + "node:querystring": { + "decode": "function", + "default": { + "decode": "function", + "encode": "function", + "escape": "function", + "parse": "function", + "stringify": "function", + "unescape": "function", + "unescapeBuffer": "function" + }, + "encode": "function", + "escape": "function", + "parse": "function", + "stringify": "function", + "unescape": "function", + "unescapeBuffer": "function" + }, + "node:readline": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "default": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:readline/promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function", + "default": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:repl": { + "REPLServer": "function", + "REPL_MODE_SLOPPY": "symbol", + "REPL_MODE_STRICT": "symbol", + "Recoverable": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string" + }, + "default": { + "REPLServer": "function", + "REPL_MODE_SLOPPY": "symbol", + "REPL_MODE_STRICT": "symbol", + "Recoverable": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string" + }, + "start": "function", + "writer": { + "options": "object" + } + }, + "start": "function", + "writer": { + "options": { + "breakLength": "number", + "colors": "boolean", + "compact": "number", + "customInspect": "boolean", + "depth": "number", + "getters": "boolean", + "maxArrayLength": "number", + "maxStringLength": "number", + "numericSeparator": "boolean", + "showHidden": "boolean", + "showProxy": "boolean", + "sorted": "boolean" + } + } + }, + "node:stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "PassThrough": "function", + "Readable": { + "ReadableState": "function", + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "PassThrough": "function", + "Readable": { + "ReadableState": "function", + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "destroy": "function", + "finished": "function", + "getDefaultHighWaterMark": "function", + "isDestroyed": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object", + "setDefaultHighWaterMark": "function" + }, + "Transform": "function", + "Writable": { + "WritableState": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "destroy": "function", + "finished": { + "finished": "function" + }, + "getDefaultHighWaterMark": "function", + "isDestroyed": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + }, + "setDefaultHighWaterMark": "function" + }, + "Transform": "function", + "Writable": { + "WritableState": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "default": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "PassThrough": "function", + "Readable": { + "ReadableState": "function", + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "destroy": "function", + "finished": "function", + "getDefaultHighWaterMark": "function", + "isDestroyed": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object", + "setDefaultHighWaterMark": "function" + }, + "Transform": "function", + "Writable": { + "WritableState": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "destroy": "function", + "finished": { + "finished": "function" + }, + "getDefaultHighWaterMark": "function", + "isDestroyed": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + }, + "setDefaultHighWaterMark": "function" + }, + "destroy": "function", + "finished": { + "finished": "function" + }, + "getDefaultHighWaterMark": "function", + "isDestroyed": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + }, + "setDefaultHighWaterMark": "function" + }, + "node:stream/consumers": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "default": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "json": "function", + "text": "function" + }, + "json": "function", + "text": "function" + }, + "node:stream/promises": { + "default": { + "finished": "function", + "pipeline": "function" + }, + "finished": "function", + "pipeline": "function" + }, + "node:stream/web": { + "ByteLengthQueuingStrategy": "function", + "CompressionStream": "function", + "CountQueuingStrategy": "function", + "DecompressionStream": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TextDecoderStream": "function", + "TextEncoderStream": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function", + "default": { + "ByteLengthQueuingStrategy": "function", + "CompressionStream": "function", + "CountQueuingStrategy": "function", + "DecompressionStream": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TextDecoderStream": "function", + "TextEncoderStream": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function" + } + }, + "node:string_decoder": { + "StringDecoder": "function", + "default": { + "StringDecoder": "function" + } + }, + "node:sys": { + "MIMEParams": "function", + "MIMEType": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "_errnoException": "function", + "_exceptionWithHostPort": "function", + "_extend": "function", + "aborted": "function", + "callbackify": "function", + "debug": "function", + "debuglog": "function", + "default": { + "MIMEParams": "function", + "MIMEType": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "_errnoException": "function", + "_exceptionWithHostPort": "function", + "_extend": "function", + "aborted": "function", + "callbackify": "function", + "debug": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "formatWithOptions": "function", + "getSystemErrorMap": "function", + "getSystemErrorName": "function", + "inherits": "function", + "inspect": { + "colors": "object", + "custom": "symbol", + "styles": "object" + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "parseArgs": "function", + "promisify": { + "custom": "symbol" + }, + "stripVTControlCharacters": "function", + "toUSVString": "function", + "transferableAbortController": "function", + "transferableAbortSignal": "function", + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "deprecate": "function", + "format": "function", + "formatWithOptions": "function", + "getSystemErrorMap": "function", + "getSystemErrorName": "function", + "inherits": "function", + "inspect": { + "colors": { + "bgBlack": "object", + "bgBlue": "object", + "bgBlueBright": "object", + "bgCyan": "object", + "bgCyanBright": "object", + "bgGray": "object", + "bgGreen": "object", + "bgGreenBright": "object", + "bgMagenta": "object", + "bgMagentaBright": "object", + "bgRed": "object", + "bgRedBright": "object", + "bgWhite": "object", + "bgWhiteBright": "object", + "bgYellow": "object", + "bgYellowBright": "object", + "black": "object", + "blink": "object", + "blue": "object", + "blueBright": "object", + "bold": "object", + "cyan": "object", + "cyanBright": "object", + "dim": "object", + "doubleunderline": "object", + "framed": "object", + "gray": "object", + "green": "object", + "greenBright": "object", + "hidden": "object", + "inverse": "object", + "italic": "object", + "magenta": "object", + "magentaBright": "object", + "overlined": "object", + "red": "object", + "redBright": "object", + "reset": "object", + "strikethrough": "object", + "underline": "object", + "white": "object", + "whiteBright": "object", + "yellow": "object", + "yellowBright": "object" + }, + "custom": "symbol", + "styles": { + "bigint": "string", + "boolean": "string", + "date": "string", + "module": "string", + "null": "string", + "number": "string", + "regexp": "string", + "special": "string", + "string": "string", + "symbol": "string", + "undefined": "string" + } + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "parseArgs": "function", + "promisify": { + "custom": "symbol" + }, + "stripVTControlCharacters": "function", + "toUSVString": "function", + "transferableAbortController": "function", + "transferableAbortSignal": "function", + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "node:test/reporters": { + "default": { + "dot": "function", + "spec": "function", + "tap": "function" + }, + "dot": "function", + "spec": "function", + "tap": "function" + }, + "node:timers": { + "_unrefActive": "function", + "active": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "default": { + "_unrefActive": "function", + "active": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "enroll": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function", + "unenroll": "function" + }, + "enroll": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function", + "unenroll": "function" + }, + "node:timers/promises": { + "default": { + "scheduler": "object", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "scheduler": "object", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:tls": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "undefined", + "Server": "function", + "TLSSocket": "function", + "checkServerIdentity": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createSecureContext": "undefined", + "createSecurePair": "function", + "createServer": "function", + "default": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "undefined", + "Server": "function", + "TLSSocket": "function", + "checkServerIdentity": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createSecureContext": "undefined", + "createSecurePair": "function", + "createServer": "function", + "getCiphers": "function", + "rootCertificates": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string", + "69": "string", + "70": "string", + "71": "string", + "72": "string", + "73": "string", + "74": "string", + "75": "string", + "76": "string", + "77": "string", + "78": "string", + "79": "string", + "80": "string", + "81": "string", + "82": "string", + "83": "string", + "84": "string", + "85": "string", + "86": "string", + "87": "string", + "88": "string", + "89": "string", + "90": "string", + "91": "string", + "92": "string", + "93": "string", + "94": "string", + "95": "string", + "96": "string", + "97": "string", + "98": "string", + "99": "string", + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "104": "string", + "105": "string", + "106": "string", + "107": "string", + "108": "string", + "109": "string", + "110": "string", + "111": "string", + "112": "string", + "113": "string", + "114": "string", + "115": "string", + "116": "string", + "117": "string", + "118": "string", + "119": "string", + "120": "string", + "121": "string", + "122": "string", + "123": "string", + "124": "string", + "125": "string", + "126": "string", + "127": "string", + "128": "string", + "129": "string", + "130": "string", + "131": "string", + "132": "string", + "133": "string", + "134": "string", + "135": "string", + "136": "string" + } + }, + "getCiphers": "function", + "rootCertificates": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string", + "69": "string", + "70": "string", + "71": "string", + "72": "string", + "73": "string", + "74": "string", + "75": "string", + "76": "string", + "77": "string", + "78": "string", + "79": "string", + "80": "string", + "81": "string", + "82": "string", + "83": "string", + "84": "string", + "85": "string", + "86": "string", + "87": "string", + "88": "string", + "89": "string", + "90": "string", + "91": "string", + "92": "string", + "93": "string", + "94": "string", + "95": "string", + "96": "string", + "97": "string", + "98": "string", + "99": "string", + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "104": "string", + "105": "string", + "106": "string", + "107": "string", + "108": "string", + "109": "string", + "110": "string", + "111": "string", + "112": "string", + "113": "string", + "114": "string", + "115": "string", + "116": "string", + "117": "string", + "118": "string", + "119": "string", + "120": "string", + "121": "string", + "122": "string", + "123": "string", + "124": "string", + "125": "string", + "126": "string", + "127": "string", + "128": "string", + "129": "string", + "130": "string", + "131": "string", + "132": "string", + "133": "string", + "134": "string", + "135": "string", + "136": "string" + } + }, + "node:trace_events": { + "createTracing": "function", + "default": { + "createTracing": "function", + "getEnabledCategories": "function" + }, + "getEnabledCategories": "function" + }, + "node:tty": { + "ReadStream": "function", + "WriteStream": "function", + "default": { + "ReadStream": "function", + "WriteStream": "function", + "isatty": "function" + }, + "isatty": "function" + }, + "node:url": { + "URL": { + "canParse": "function", + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "default": { + "URL": { + "canParse": "function", + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "domainToASCII": "function", + "domainToUnicode": "function", + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "domainToASCII": "function", + "domainToUnicode": "function", + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "node:util": { + "MIMEParams": "function", + "MIMEType": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "_errnoException": "function", + "_exceptionWithHostPort": "function", + "_extend": "function", + "aborted": "function", + "callbackify": "function", + "debug": "function", + "debuglog": "function", + "default": { + "MIMEParams": "function", + "MIMEType": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "_errnoException": "function", + "_exceptionWithHostPort": "function", + "_extend": "function", + "aborted": "function", + "callbackify": "function", + "debug": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "formatWithOptions": "function", + "getSystemErrorMap": "function", + "getSystemErrorName": "function", + "inherits": "function", + "inspect": { + "colors": "object", + "custom": "symbol", + "styles": "object" + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "parseArgs": "function", + "promisify": { + "custom": "symbol" + }, + "stripVTControlCharacters": "function", + "toUSVString": "function", + "transferableAbortController": "function", + "transferableAbortSignal": "function", + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "deprecate": "function", + "format": "function", + "formatWithOptions": "function", + "getSystemErrorMap": "function", + "getSystemErrorName": "function", + "inherits": "function", + "inspect": { + "colors": { + "bgBlack": "object", + "bgBlue": "object", + "bgBlueBright": "object", + "bgCyan": "object", + "bgCyanBright": "object", + "bgGray": "object", + "bgGreen": "object", + "bgGreenBright": "object", + "bgMagenta": "object", + "bgMagentaBright": "object", + "bgRed": "object", + "bgRedBright": "object", + "bgWhite": "object", + "bgWhiteBright": "object", + "bgYellow": "object", + "bgYellowBright": "object", + "black": "object", + "blink": "object", + "blue": "object", + "blueBright": "object", + "bold": "object", + "cyan": "object", + "cyanBright": "object", + "dim": "object", + "doubleunderline": "object", + "framed": "object", + "gray": "object", + "green": "object", + "greenBright": "object", + "hidden": "object", + "inverse": "object", + "italic": "object", + "magenta": "object", + "magentaBright": "object", + "overlined": "object", + "red": "object", + "redBright": "object", + "reset": "object", + "strikethrough": "object", + "underline": "object", + "white": "object", + "whiteBright": "object", + "yellow": "object", + "yellowBright": "object" + }, + "custom": "symbol", + "styles": { + "bigint": "string", + "boolean": "string", + "date": "string", + "module": "string", + "null": "string", + "number": "string", + "regexp": "string", + "special": "string", + "string": "string", + "symbol": "string", + "undefined": "string" + } + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "parseArgs": "function", + "promisify": { + "custom": "symbol" + }, + "stripVTControlCharacters": "function", + "toUSVString": "function", + "transferableAbortController": "function", + "transferableAbortSignal": "function", + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "node:util/types": { + "default": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "node:v8": { + "DefaultDeserializer": "function", + "DefaultSerializer": "function", + "Deserializer": "function", + "GCProfiler": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "default": { + "DefaultDeserializer": "function", + "DefaultSerializer": "function", + "Deserializer": "function", + "GCProfiler": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "node:vm": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "createScript": "function", + "default": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "createScript": "function", + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "node:wasi": { + "WASI": "function", + "default": { + "WASI": "function" + } + }, + "node:worker_threads": { + "BroadcastChannel": "function", + "MessageChannel": "function", + "MessagePort": "function", + "SHARE_ENV": "symbol", + "Worker": "function", + "default": { + "BroadcastChannel": "function", + "MessageChannel": "function", + "MessagePort": "function", + "SHARE_ENV": "symbol", + "Worker": "function", + "getEnvironmentData": "function", + "isMainThread": "boolean", + "markAsUntransferable": "function", + "moveMessagePortToContext": "function", + "parentPort": "object", + "receiveMessageOnPort": "function", + "resourceLimits": "object", + "setEnvironmentData": "function", + "threadId": "number", + "workerData": "object" + }, + "getEnvironmentData": "function", + "isMainThread": "boolean", + "markAsUntransferable": "function", + "moveMessagePortToContext": "function", + "parentPort": "object", + "receiveMessageOnPort": "function", + "resourceLimits": "object", + "setEnvironmentData": "function", + "threadId": "number", + "workerData": "object" + }, + "node:zlib": { + "BrotliCompress": "function", + "BrotliDecompress": "function", + "Deflate": "function", + "DeflateRaw": "function", + "Gunzip": "function", + "Gzip": "function", + "Inflate": "function", + "InflateRaw": "function", + "Unzip": "function", + "brotliCompress": "function", + "brotliCompressSync": "function", + "brotliDecompress": "function", + "brotliDecompressSync": "function", + "codes": { + "0": "string", + "1": "string", + "2": "string", + "-1": "string", + "-2": "string", + "-3": "string", + "-4": "string", + "-5": "string", + "-6": "string", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_ERRNO": "number", + "Z_MEM_ERROR": "number", + "Z_NEED_DICT": "number", + "Z_OK": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_VERSION_ERROR": "number" + }, + "constants": { + "BROTLI_DECODE": "number", + "BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES": "number", + "BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP": "number", + "BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES": "number", + "BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1": "number", + "BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2": "number", + "BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS": "number", + "BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET": "number", + "BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1": "number", + "BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2": "number", + "BROTLI_DECODER_ERROR_FORMAT_CL_SPACE": "number", + "BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT": "number", + "BROTLI_DECODER_ERROR_FORMAT_DICTIONARY": "number", + "BROTLI_DECODER_ERROR_FORMAT_DISTANCE": "number", + "BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE": "number", + "BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE": "number", + "BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE": "number", + "BROTLI_DECODER_ERROR_FORMAT_PADDING_1": "number", + "BROTLI_DECODER_ERROR_FORMAT_PADDING_2": "number", + "BROTLI_DECODER_ERROR_FORMAT_RESERVED": "number", + "BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET": "number", + "BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME": "number", + "BROTLI_DECODER_ERROR_FORMAT_TRANSFORM": "number", + "BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS": "number", + "BROTLI_DECODER_ERROR_INVALID_ARGUMENTS": "number", + "BROTLI_DECODER_ERROR_UNREACHABLE": "number", + "BROTLI_DECODER_NEEDS_MORE_INPUT": "number", + "BROTLI_DECODER_NEEDS_MORE_OUTPUT": "number", + "BROTLI_DECODER_NO_ERROR": "number", + "BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION": "number", + "BROTLI_DECODER_PARAM_LARGE_WINDOW": "number", + "BROTLI_DECODER_RESULT_ERROR": "number", + "BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT": "number", + "BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT": "number", + "BROTLI_DECODER_RESULT_SUCCESS": "number", + "BROTLI_DECODER_SUCCESS": "number", + "BROTLI_DEFAULT_MODE": "number", + "BROTLI_DEFAULT_QUALITY": "number", + "BROTLI_DEFAULT_WINDOW": "number", + "BROTLI_ENCODE": "number", + "BROTLI_LARGE_MAX_WINDOW_BITS": "number", + "BROTLI_MAX_INPUT_BLOCK_BITS": "number", + "BROTLI_MAX_QUALITY": "number", + "BROTLI_MAX_WINDOW_BITS": "number", + "BROTLI_MIN_INPUT_BLOCK_BITS": "number", + "BROTLI_MIN_QUALITY": "number", + "BROTLI_MIN_WINDOW_BITS": "number", + "BROTLI_MODE_FONT": "number", + "BROTLI_MODE_GENERIC": "number", + "BROTLI_MODE_TEXT": "number", + "BROTLI_OPERATION_EMIT_METADATA": "number", + "BROTLI_OPERATION_FINISH": "number", + "BROTLI_OPERATION_FLUSH": "number", + "BROTLI_OPERATION_PROCESS": "number", + "BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING": "number", + "BROTLI_PARAM_LARGE_WINDOW": "number", + "BROTLI_PARAM_LGBLOCK": "number", + "BROTLI_PARAM_LGWIN": "number", + "BROTLI_PARAM_MODE": "number", + "BROTLI_PARAM_NDIRECT": "number", + "BROTLI_PARAM_NPOSTFIX": "number", + "BROTLI_PARAM_QUALITY": "number", + "BROTLI_PARAM_SIZE_HINT": "number", + "DEFLATE": "number", + "DEFLATERAW": "number", + "GUNZIP": "number", + "GZIP": "number", + "INFLATE": "number", + "INFLATERAW": "number", + "UNZIP": "number", + "ZLIB_VERNUM": "number", + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_CHUNK": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_LEVEL": "number", + "Z_DEFAULT_MEMLEVEL": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFAULT_WINDOWBITS": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_MAX_CHUNK": "number", + "Z_MAX_LEVEL": "number", + "Z_MAX_MEMLEVEL": "number", + "Z_MAX_WINDOWBITS": "number", + "Z_MEM_ERROR": "number", + "Z_MIN_CHUNK": "number", + "Z_MIN_LEVEL": "number", + "Z_MIN_MEMLEVEL": "number", + "Z_MIN_WINDOWBITS": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_VERSION_ERROR": "number" + }, + "createBrotliCompress": "function", + "createBrotliDecompress": "function", + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "default": { + "BrotliCompress": "function", + "BrotliDecompress": "function", + "Deflate": "function", + "DeflateRaw": "function", + "Gunzip": "function", + "Gzip": "function", + "Inflate": "function", + "InflateRaw": "function", + "Unzip": "function", + "brotliCompress": "function", + "brotliCompressSync": "function", + "brotliDecompress": "function", + "brotliDecompressSync": "function", + "codes": { + "0": "string", + "1": "string", + "2": "string", + "-1": "string", + "-2": "string", + "-3": "string", + "-4": "string", + "-5": "string", + "-6": "string", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_ERRNO": "number", + "Z_MEM_ERROR": "number", + "Z_NEED_DICT": "number", + "Z_OK": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_VERSION_ERROR": "number" + }, + "constants": { + "BROTLI_DECODE": "number", + "BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES": "number", + "BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP": "number", + "BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES": "number", + "BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1": "number", + "BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2": "number", + "BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS": "number", + "BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET": "number", + "BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1": "number", + "BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2": "number", + "BROTLI_DECODER_ERROR_FORMAT_CL_SPACE": "number", + "BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT": "number", + "BROTLI_DECODER_ERROR_FORMAT_DICTIONARY": "number", + "BROTLI_DECODER_ERROR_FORMAT_DISTANCE": "number", + "BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE": "number", + "BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE": "number", + "BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE": "number", + "BROTLI_DECODER_ERROR_FORMAT_PADDING_1": "number", + "BROTLI_DECODER_ERROR_FORMAT_PADDING_2": "number", + "BROTLI_DECODER_ERROR_FORMAT_RESERVED": "number", + "BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET": "number", + "BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME": "number", + "BROTLI_DECODER_ERROR_FORMAT_TRANSFORM": "number", + "BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS": "number", + "BROTLI_DECODER_ERROR_INVALID_ARGUMENTS": "number", + "BROTLI_DECODER_ERROR_UNREACHABLE": "number", + "BROTLI_DECODER_NEEDS_MORE_INPUT": "number", + "BROTLI_DECODER_NEEDS_MORE_OUTPUT": "number", + "BROTLI_DECODER_NO_ERROR": "number", + "BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION": "number", + "BROTLI_DECODER_PARAM_LARGE_WINDOW": "number", + "BROTLI_DECODER_RESULT_ERROR": "number", + "BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT": "number", + "BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT": "number", + "BROTLI_DECODER_RESULT_SUCCESS": "number", + "BROTLI_DECODER_SUCCESS": "number", + "BROTLI_DEFAULT_MODE": "number", + "BROTLI_DEFAULT_QUALITY": "number", + "BROTLI_DEFAULT_WINDOW": "number", + "BROTLI_ENCODE": "number", + "BROTLI_LARGE_MAX_WINDOW_BITS": "number", + "BROTLI_MAX_INPUT_BLOCK_BITS": "number", + "BROTLI_MAX_QUALITY": "number", + "BROTLI_MAX_WINDOW_BITS": "number", + "BROTLI_MIN_INPUT_BLOCK_BITS": "number", + "BROTLI_MIN_QUALITY": "number", + "BROTLI_MIN_WINDOW_BITS": "number", + "BROTLI_MODE_FONT": "number", + "BROTLI_MODE_GENERIC": "number", + "BROTLI_MODE_TEXT": "number", + "BROTLI_OPERATION_EMIT_METADATA": "number", + "BROTLI_OPERATION_FINISH": "number", + "BROTLI_OPERATION_FLUSH": "number", + "BROTLI_OPERATION_PROCESS": "number", + "BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING": "number", + "BROTLI_PARAM_LARGE_WINDOW": "number", + "BROTLI_PARAM_LGBLOCK": "number", + "BROTLI_PARAM_LGWIN": "number", + "BROTLI_PARAM_MODE": "number", + "BROTLI_PARAM_NDIRECT": "number", + "BROTLI_PARAM_NPOSTFIX": "number", + "BROTLI_PARAM_QUALITY": "number", + "BROTLI_PARAM_SIZE_HINT": "number", + "DEFLATE": "number", + "DEFLATERAW": "number", + "GUNZIP": "number", + "GZIP": "number", + "INFLATE": "number", + "INFLATERAW": "number", + "UNZIP": "number", + "ZLIB_VERNUM": "number", + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_CHUNK": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_LEVEL": "number", + "Z_DEFAULT_MEMLEVEL": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFAULT_WINDOWBITS": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_MAX_CHUNK": "number", + "Z_MAX_LEVEL": "number", + "Z_MAX_MEMLEVEL": "number", + "Z_MAX_WINDOWBITS": "number", + "Z_MEM_ERROR": "number", + "Z_MIN_CHUNK": "number", + "Z_MIN_LEVEL": "number", + "Z_MIN_MEMLEVEL": "number", + "Z_MIN_WINDOWBITS": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_VERSION_ERROR": "number" + }, + "createBrotliCompress": "function", + "createBrotliDecompress": "function", + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + }, + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + } + }, + "require": { + "node:_http_agent": { + "Agent": { + "defaultMaxSockets": "number" + }, + "globalAgent": { + "_events": { + "free": "function", + "newListener": "function" + }, + "_eventsCount": "number", + "_maxListeners": "undefined", + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": { + "keepAlive": "boolean", + "noDelay": "boolean", + "path": "object", + "scheduling": "string", + "timeout": "number" + }, + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + } + }, + "node:_http_client": { + "ClientRequest": "function" + }, + "node:_http_common": { + "CRLF": "string", + "HTTPParser": { + "REQUEST": "number", + "RESPONSE": "number", + "kLenientAll": "number", + "kLenientChunkedLength": "number", + "kLenientHeaders": "number", + "kLenientKeepAlive": "number", + "kLenientNone": "number", + "kOnBody": "number", + "kOnExecute": "number", + "kOnHeaders": "number", + "kOnHeadersComplete": "number", + "kOnMessageBegin": "number", + "kOnMessageComplete": "number", + "kOnTimeout": "number" + }, + "_checkInvalidHeaderChar": "function", + "_checkIsHttpToken": "function", + "chunkExpression": "object", + "continueExpression": "object", + "freeParser": "function", + "isLenient": "function", + "kIncomingMessage": "symbol", + "methods": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "parsers": { + "ctor": "function", + "list": "object", + "max": "number", + "name": "string" + }, + "prepareError": "function" + }, + "node:_http_incoming": { + "IncomingMessage": "function", + "readStart": "function", + "readStop": "function" + }, + "node:_http_outgoing": { + "OutgoingMessage": "function", + "kHighWaterMark": "symbol", + "kUniqueHeaders": "symbol", + "parseUniqueHeadersOption": "function", + "validateHeaderName": "function", + "validateHeaderValue": "function" + }, + "node:_http_server": { + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "_connectionListener": "function", + "kServerResponse": "symbol", + "setupConnectionsTracking": "function", + "storeHTTPOptions": "function" + }, + "node:_stream_duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "node:_stream_passthrough": {}, + "node:_stream_readable": { + "ReadableState": "function", + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "node:_stream_transform": {}, + "node:_stream_wrap": {}, + "node:_stream_writable": { + "WritableState": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "node:_tls_common": { + "SecureContext": "function", + "createSecureContext": "function", + "translatePeerCertificate": "function" + }, + "node:_tls_wrap": { + "Server": "function", + "TLSSocket": "function", + "connect": "function", + "createServer": "function" + }, + "node:assert": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:assert/strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "rejects": "function", + "strict": { + "AssertionError": "function", + "CallTracker": "function", + "deepEqual": "function", + "deepStrictEqual": "function", + "doesNotMatch": "function", + "doesNotReject": "function", + "doesNotThrow": "function", + "equal": "function", + "fail": "function", + "ifError": "function", + "match": "function", + "notDeepEqual": "function", + "notDeepStrictEqual": "function", + "notEqual": "function", + "notStrictEqual": "function", + "ok": "function", + "rejects": "function", + "strict": "function", + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "strictEqual": "function", + "throws": "function" + }, + "node:async_hooks": { + "AsyncLocalStorage": "function", + "AsyncResource": "function", + "asyncWrapProviders": { + "BLOBREADER": "number", + "CHECKPRIMEREQUEST": "number", + "CIPHERREQUEST": "number", + "DERIVEBITSREQUEST": "number", + "DIRHANDLE": "number", + "DNSCHANNEL": "number", + "ELDHISTOGRAM": "number", + "FILEHANDLE": "number", + "FILEHANDLECLOSEREQ": "number", + "FSEVENTWRAP": "number", + "FSREQCALLBACK": "number", + "FSREQPROMISE": "number", + "GETADDRINFOREQWRAP": "number", + "GETNAMEINFOREQWRAP": "number", + "HASHREQUEST": "number", + "HEAPSNAPSHOT": "number", + "HTTP2PING": "number", + "HTTP2SESSION": "number", + "HTTP2SETTINGS": "number", + "HTTP2STREAM": "number", + "HTTPCLIENTREQUEST": "number", + "HTTPINCOMINGMESSAGE": "number", + "INSPECTORJSBINDING": "number", + "JSSTREAM": "number", + "JSUDPWRAP": "number", + "KEYEXPORTREQUEST": "number", + "KEYGENREQUEST": "number", + "KEYPAIRGENREQUEST": "number", + "MESSAGEPORT": "number", + "NONE": "number", + "PBKDF2REQUEST": "number", + "PIPECONNECTWRAP": "number", + "PIPESERVERWRAP": "number", + "PIPEWRAP": "number", + "PROCESSWRAP": "number", + "PROMISE": "number", + "QUERYWRAP": "number", + "QUIC_LOGSTREAM": "number", + "QUIC_PACKET": "number", + "RANDOMBYTESREQUEST": "number", + "RANDOMPRIMEREQUEST": "number", + "SCRYPTREQUEST": "number", + "SHUTDOWNWRAP": "number", + "SIGINTWATCHDOG": "number", + "SIGNALWRAP": "number", + "SIGNREQUEST": "number", + "STATWATCHER": "number", + "STREAMPIPE": "number", + "TCPCONNECTWRAP": "number", + "TCPSERVERWRAP": "number", + "TCPWRAP": "number", + "TLSWRAP": "number", + "TTYWRAP": "number", + "UDPSENDWRAP": "number", + "UDPWRAP": "number", + "VERIFYREQUEST": "number", + "WORKER": "number", + "WORKERHEAPSNAPSHOT": "number", + "WRITEWRAP": "number", + "ZLIB": "number" + }, + "createHook": "function", + "executionAsyncId": "function", + "executionAsyncResource": "function", + "triggerAsyncId": "function" + }, + "node:buffer": { + "Blob": "function", + "Buffer": { + "alloc": "function", + "allocUnsafe": "function", + "allocUnsafeSlow": "function", + "byteLength": "function", + "compare": "function", + "concat": "function", + "copyBytesFrom": "function", + "from": "function", + "isBuffer": "function", + "isEncoding": "function", + "of": "function", + "poolSize": "number" + }, + "File": "function", + "INSPECT_MAX_BYTES": "number", + "SlowBuffer": "function", + "atob": "function", + "btoa": "function", + "constants": { + "MAX_LENGTH": "number", + "MAX_STRING_LENGTH": "number" + }, + "isAscii": "function", + "isUtf8": "function", + "kMaxLength": "number", + "kStringMaxLength": "number", + "resolveObjectURL": "function", + "transcode": "function" + }, + "node:child_process": { + "ChildProcess": "function", + "_forkChild": "function", + "exec": "function", + "execFile": "function", + "execFileSync": "function", + "execSync": "function", + "fork": "function", + "spawn": "function", + "spawnSync": "function" + }, + "node:cluster": { + "SCHED_NONE": "number", + "SCHED_RR": "number", + "Worker": "function", + "_events": "object", + "_eventsCount": "number", + "_maxListeners": "undefined", + "disconnect": "function", + "fork": "function", + "isMaster": "boolean", + "isPrimary": "boolean", + "isWorker": "boolean", + "schedulingPolicy": "number", + "settings": "object", + "setupMaster": "function", + "setupPrimary": "function", + "workers": "object" + }, + "node:console": { + "Console": "function", + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "createTask": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "node:constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENGINE_METHOD_ALL": "number", + "ENGINE_METHOD_CIPHERS": "number", + "ENGINE_METHOD_DH": "number", + "ENGINE_METHOD_DIGESTS": "number", + "ENGINE_METHOD_DSA": "number", + "ENGINE_METHOD_EC": "number", + "ENGINE_METHOD_NONE": "number", + "ENGINE_METHOD_PKEY_ASN1_METHS": "number", + "ENGINE_METHOD_PKEY_METHS": "number", + "ENGINE_METHOD_RAND": "number", + "ENGINE_METHOD_RSA": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTSUP": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EWOULDBLOCK": "number", + "EXDEV": "number", + "F_OK": "number", + "OPENSSL_VERSION_NUMBER": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_PSS_SALTLEN_AUTO": "number", + "RSA_PSS_SALTLEN_DIGEST": "number", + "RSA_PSS_SALTLEN_MAX_SIGN": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number", + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number", + "R_OK": "number", + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number", + "SSL_OP_ALL": "number", + "SSL_OP_ALLOW_NO_DHE_KEX": "number", + "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": "number", + "SSL_OP_CIPHER_SERVER_PREFERENCE": "number", + "SSL_OP_CISCO_ANYCONNECT": "number", + "SSL_OP_COOKIE_EXCHANGE": "number", + "SSL_OP_CRYPTOPRO_TLSEXT_BUG": "number", + "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": "number", + "SSL_OP_LEGACY_SERVER_CONNECT": "number", + "SSL_OP_NO_COMPRESSION": "number", + "SSL_OP_NO_ENCRYPT_THEN_MAC": "number", + "SSL_OP_NO_QUERY_MTU": "number", + "SSL_OP_NO_RENEGOTIATION": "number", + "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": "number", + "SSL_OP_NO_SSLv2": "number", + "SSL_OP_NO_SSLv3": "number", + "SSL_OP_NO_TICKET": "number", + "SSL_OP_NO_TLSv1": "number", + "SSL_OP_NO_TLSv1_1": "number", + "SSL_OP_NO_TLSv1_2": "number", + "SSL_OP_NO_TLSv1_3": "number", + "SSL_OP_PRIORITIZE_CHACHA": "number", + "SSL_OP_TLS_ROLLBACK_BUG": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "TLS1_1_VERSION": "number", + "TLS1_2_VERSION": "number", + "TLS1_3_VERSION": "number", + "TLS1_VERSION": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number", + "defaultCipherList": "string", + "defaultCoreCipherList": "string" + }, + "node:crypto": { + "Certificate": { + "exportChallenge": "function", + "exportPublicKey": "function", + "verifySpkac": "function" + }, + "Cipher": "function", + "Cipheriv": "function", + "Decipher": "function", + "Decipheriv": "function", + "DiffieHellman": "function", + "DiffieHellmanGroup": "function", + "ECDH": { + "convertKey": "function" + }, + "Hash": "function", + "Hmac": "function", + "KeyObject": "function", + "Sign": "function", + "Verify": "function", + "X509Certificate": "function", + "checkPrime": "function", + "checkPrimeSync": "function", + "constants": { + "DH_CHECK_P_NOT_PRIME": "number", + "DH_CHECK_P_NOT_SAFE_PRIME": "number", + "DH_NOT_SUITABLE_GENERATOR": "number", + "DH_UNABLE_TO_CHECK_GENERATOR": "number", + "ENGINE_METHOD_ALL": "number", + "ENGINE_METHOD_CIPHERS": "number", + "ENGINE_METHOD_DH": "number", + "ENGINE_METHOD_DIGESTS": "number", + "ENGINE_METHOD_DSA": "number", + "ENGINE_METHOD_EC": "number", + "ENGINE_METHOD_NONE": "number", + "ENGINE_METHOD_PKEY_ASN1_METHS": "number", + "ENGINE_METHOD_PKEY_METHS": "number", + "ENGINE_METHOD_RAND": "number", + "ENGINE_METHOD_RSA": "number", + "OPENSSL_VERSION_NUMBER": "number", + "POINT_CONVERSION_COMPRESSED": "number", + "POINT_CONVERSION_HYBRID": "number", + "POINT_CONVERSION_UNCOMPRESSED": "number", + "RSA_NO_PADDING": "number", + "RSA_PKCS1_OAEP_PADDING": "number", + "RSA_PKCS1_PADDING": "number", + "RSA_PKCS1_PSS_PADDING": "number", + "RSA_PSS_SALTLEN_AUTO": "number", + "RSA_PSS_SALTLEN_DIGEST": "number", + "RSA_PSS_SALTLEN_MAX_SIGN": "number", + "RSA_SSLV23_PADDING": "number", + "RSA_X931_PADDING": "number", + "SSL_OP_ALL": "number", + "SSL_OP_ALLOW_NO_DHE_KEX": "number", + "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": "number", + "SSL_OP_CIPHER_SERVER_PREFERENCE": "number", + "SSL_OP_CISCO_ANYCONNECT": "number", + "SSL_OP_COOKIE_EXCHANGE": "number", + "SSL_OP_CRYPTOPRO_TLSEXT_BUG": "number", + "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": "number", + "SSL_OP_LEGACY_SERVER_CONNECT": "number", + "SSL_OP_NO_COMPRESSION": "number", + "SSL_OP_NO_ENCRYPT_THEN_MAC": "number", + "SSL_OP_NO_QUERY_MTU": "number", + "SSL_OP_NO_RENEGOTIATION": "number", + "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": "number", + "SSL_OP_NO_SSLv2": "number", + "SSL_OP_NO_SSLv3": "number", + "SSL_OP_NO_TICKET": "number", + "SSL_OP_NO_TLSv1": "number", + "SSL_OP_NO_TLSv1_1": "number", + "SSL_OP_NO_TLSv1_2": "number", + "SSL_OP_NO_TLSv1_3": "number", + "SSL_OP_PRIORITIZE_CHACHA": "number", + "SSL_OP_TLS_ROLLBACK_BUG": "number", + "TLS1_1_VERSION": "number", + "TLS1_2_VERSION": "number", + "TLS1_3_VERSION": "number", + "TLS1_VERSION": "number", + "defaultCipherList": "string", + "defaultCoreCipherList": "string" + }, + "createCipheriv": "function", + "createDecipheriv": "function", + "createDiffieHellman": "function", + "createDiffieHellmanGroup": "function", + "createECDH": "function", + "createHash": "function", + "createHmac": "function", + "createPrivateKey": "function", + "createPublicKey": "function", + "createSecretKey": "function", + "createSign": "function", + "createVerify": "function", + "diffieHellman": "function", + "generateKey": "function", + "generateKeyPair": "function", + "generateKeyPairSync": "function", + "generateKeySync": "function", + "generatePrime": "function", + "generatePrimeSync": "function", + "getCipherInfo": "function", + "getCiphers": "function", + "getCurves": "function", + "getDiffieHellman": "function", + "getFips": "function", + "getHashes": "function", + "getRandomValues": "function", + "hkdf": "function", + "hkdfSync": "function", + "pbkdf2": "function", + "pbkdf2Sync": "function", + "privateDecrypt": "function", + "privateEncrypt": "function", + "publicDecrypt": "function", + "publicEncrypt": "function", + "randomBytes": "function", + "randomFill": "function", + "randomFillSync": "function", + "randomInt": "function", + "randomUUID": "function", + "scrypt": "function", + "scryptSync": "function", + "secureHeapUsed": "function", + "setEngine": "function", + "setFips": "function", + "sign": "function", + "subtle": "object", + "timingSafeEqual": "function", + "verify": "function", + "webcrypto": "object" + }, + "node:dgram": { + "Socket": "function", + "_createSocketHandle": "function", + "createSocket": "function" + }, + "node:diagnostics_channel": { + "Channel": "function", + "channel": "function", + "hasSubscribers": "function", + "subscribe": "function", + "tracingChannel": "function", + "unsubscribe": "function" + }, + "node:dns": { + "ADDRCONFIG": "number", + "ADDRGETNETWORKPARAMS": "string", + "ALL": "number", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "V4MAPPED": "number", + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "promises": { + "ADDRGETNETWORKPARAMS": "string", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "node:dns/promises": { + "ADDRGETNETWORKPARAMS": "string", + "BADFAMILY": "string", + "BADFLAGS": "string", + "BADHINTS": "string", + "BADNAME": "string", + "BADQUERY": "string", + "BADRESP": "string", + "BADSTR": "string", + "CANCELLED": "string", + "CONNREFUSED": "string", + "DESTRUCTION": "string", + "EOF": "string", + "FILE": "string", + "FORMERR": "string", + "LOADIPHLPAPI": "string", + "NODATA": "string", + "NOMEM": "string", + "NONAME": "string", + "NOTFOUND": "string", + "NOTIMP": "string", + "NOTINITIALIZED": "string", + "REFUSED": "string", + "Resolver": "function", + "SERVFAIL": "string", + "TIMEOUT": "string", + "getDefaultResultOrder": "function", + "getServers": "function", + "lookup": "function", + "lookupService": "function", + "resolve": "function", + "resolve4": "function", + "resolve6": "function", + "resolveAny": "function", + "resolveCaa": "function", + "resolveCname": "function", + "resolveMx": "function", + "resolveNaptr": "function", + "resolveNs": "function", + "resolvePtr": "function", + "resolveSoa": "function", + "resolveSrv": "function", + "resolveTxt": "function", + "reverse": "function", + "setDefaultResultOrder": "function", + "setServers": "function" + }, + "node:domain": { + "Domain": "function", + "_stack": "object", + "active": "object", + "create": "function", + "createDomain": "function" + }, + "node:events": { + "EventEmitter": { + "EventEmitter": { + "EventEmitter": "function", + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "getMaxListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "getMaxListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "EventEmitterAsyncResource": "function", + "captureRejectionSymbol": "symbol", + "captureRejections": "boolean", + "defaultMaxListeners": "number", + "errorMonitor": "symbol", + "getEventListeners": "function", + "getMaxListeners": "function", + "init": "function", + "listenerCount": "function", + "on": "function", + "once": "function", + "setMaxListeners": "function", + "usingDomains": "boolean" + }, + "node:fs": { + "Dir": "function", + "Dirent": "function", + "F_OK": "number", + "FileReadStream": "function", + "FileWriteStream": "function", + "R_OK": "number", + "ReadStream": "function", + "Stats": "function", + "W_OK": "number", + "WriteStream": "function", + "X_OK": "number", + "_toUnixTimestamp": "function", + "access": "function", + "accessSync": "function", + "appendFile": "function", + "appendFileSync": "function", + "chmod": "function", + "chmodSync": "function", + "chown": "function", + "chownSync": "function", + "close": "function", + "closeSync": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "copyFileSync": "function", + "cp": "function", + "cpSync": "function", + "createReadStream": "function", + "createWriteStream": "function", + "exists": "function", + "existsSync": "function", + "fchmod": "function", + "fchmodSync": "function", + "fchown": "function", + "fchownSync": "function", + "fdatasync": "function", + "fdatasyncSync": "function", + "fstat": "function", + "fstatSync": "function", + "fsync": "function", + "fsyncSync": "function", + "ftruncate": "function", + "ftruncateSync": "function", + "futimes": "function", + "futimesSync": "function", + "lchmod": "function", + "lchmodSync": "function", + "lchown": "function", + "lchownSync": "function", + "link": "function", + "linkSync": "function", + "lstat": "function", + "lstatSync": "function", + "lutimes": "function", + "lutimesSync": "function", + "mkdir": "function", + "mkdirSync": "function", + "mkdtemp": "function", + "mkdtempSync": "function", + "open": "function", + "openAsBlob": "function", + "openSync": "function", + "opendir": "function", + "opendirSync": "function", + "promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "cp": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "opendir": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "statfs": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "writeFile": "function" + }, + "read": "function", + "readFile": "function", + "readFileSync": "function", + "readSync": "function", + "readdir": "function", + "readdirSync": "function", + "readlink": "function", + "readlinkSync": "function", + "readv": "function", + "readvSync": "function", + "realpath": { + "native": "function" + }, + "realpathSync": { + "native": "function" + }, + "rename": "function", + "renameSync": "function", + "rm": "function", + "rmSync": "function", + "rmdir": "function", + "rmdirSync": "function", + "stat": "function", + "statSync": "function", + "statfs": "function", + "statfsSync": "function", + "symlink": "function", + "symlinkSync": "function", + "truncate": "function", + "truncateSync": "function", + "unlink": "function", + "unlinkSync": "function", + "unwatchFile": "function", + "utimes": "function", + "utimesSync": "function", + "watch": "function", + "watchFile": "function", + "write": "function", + "writeFile": "function", + "writeFileSync": "function", + "writeSync": "function", + "writev": "function", + "writevSync": "function" + }, + "node:fs/promises": { + "access": "function", + "appendFile": "function", + "chmod": "function", + "chown": "function", + "constants": { + "COPYFILE_EXCL": "number", + "COPYFILE_FICLONE": "number", + "COPYFILE_FICLONE_FORCE": "number", + "F_OK": "number", + "O_APPEND": "number", + "O_CREAT": "number", + "O_DIRECTORY": "number", + "O_DSYNC": "number", + "O_EXCL": "number", + "O_NOCTTY": "number", + "O_NOFOLLOW": "number", + "O_NONBLOCK": "number", + "O_RDONLY": "number", + "O_RDWR": "number", + "O_SYMLINK": "number", + "O_SYNC": "number", + "O_TRUNC": "number", + "O_WRONLY": "number", + "R_OK": "number", + "S_IFBLK": "number", + "S_IFCHR": "number", + "S_IFDIR": "number", + "S_IFIFO": "number", + "S_IFLNK": "number", + "S_IFMT": "number", + "S_IFREG": "number", + "S_IFSOCK": "number", + "S_IRGRP": "number", + "S_IROTH": "number", + "S_IRUSR": "number", + "S_IRWXG": "number", + "S_IRWXO": "number", + "S_IRWXU": "number", + "S_IWGRP": "number", + "S_IWOTH": "number", + "S_IWUSR": "number", + "S_IXGRP": "number", + "S_IXOTH": "number", + "S_IXUSR": "number", + "UV_DIRENT_BLOCK": "number", + "UV_DIRENT_CHAR": "number", + "UV_DIRENT_DIR": "number", + "UV_DIRENT_FIFO": "number", + "UV_DIRENT_FILE": "number", + "UV_DIRENT_LINK": "number", + "UV_DIRENT_SOCKET": "number", + "UV_DIRENT_UNKNOWN": "number", + "UV_FS_COPYFILE_EXCL": "number", + "UV_FS_COPYFILE_FICLONE": "number", + "UV_FS_COPYFILE_FICLONE_FORCE": "number", + "UV_FS_O_FILEMAP": "number", + "UV_FS_SYMLINK_DIR": "number", + "UV_FS_SYMLINK_JUNCTION": "number", + "W_OK": "number", + "X_OK": "number" + }, + "copyFile": "function", + "cp": "function", + "lchmod": "function", + "lchown": "function", + "link": "function", + "lstat": "function", + "lutimes": "function", + "mkdir": "function", + "mkdtemp": "function", + "open": "function", + "opendir": "function", + "readFile": "function", + "readdir": "function", + "readlink": "function", + "realpath": "function", + "rename": "function", + "rm": "function", + "rmdir": "function", + "stat": "function", + "statfs": "function", + "symlink": "function", + "truncate": "function", + "unlink": "function", + "utimes": "function", + "watch": "function", + "writeFile": "function" + }, + "node:http": { + "Agent": { + "defaultMaxSockets": "number" + }, + "ClientRequest": "function", + "IncomingMessage": "function", + "METHODS": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string" + }, + "OutgoingMessage": "function", + "STATUS_CODES": { + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "226": "string", + "300": "string", + "301": "string", + "302": "string", + "303": "string", + "304": "string", + "305": "string", + "307": "string", + "308": "string", + "400": "string", + "401": "string", + "402": "string", + "403": "string", + "404": "string", + "405": "string", + "406": "string", + "407": "string", + "408": "string", + "409": "string", + "410": "string", + "411": "string", + "412": "string", + "413": "string", + "414": "string", + "415": "string", + "416": "string", + "417": "string", + "418": "string", + "421": "string", + "422": "string", + "423": "string", + "424": "string", + "425": "string", + "426": "string", + "428": "string", + "429": "string", + "431": "string", + "451": "string", + "500": "string", + "501": "string", + "502": "string", + "503": "string", + "504": "string", + "505": "string", + "506": "string", + "507": "string", + "508": "string", + "509": "string", + "510": "string", + "511": "string" + }, + "Server": "function", + "ServerResponse": "function", + "_connectionListener": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": { + "free": "function", + "newListener": "function" + }, + "_eventsCount": "number", + "_maxListeners": "undefined", + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": { + "keepAlive": "boolean", + "noDelay": "boolean", + "path": "object", + "scheduling": "string", + "timeout": "number" + }, + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + }, + "maxHeaderSize": "number", + "request": "function", + "setMaxIdleHTTPParsers": "function", + "validateHeaderName": "function", + "validateHeaderValue": "function" + }, + "node:http2": { + "Http2ServerRequest": "function", + "Http2ServerResponse": "function", + "connect": "function", + "constants": { + "DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "DEFAULT_SETTINGS_ENABLE_PUSH": "number", + "DEFAULT_SETTINGS_HEADER_TABLE_SIZE": "number", + "DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "DEFAULT_SETTINGS_MAX_FRAME_SIZE": "number", + "DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "HTTP2_HEADER_ACCEPT": "string", + "HTTP2_HEADER_ACCEPT_CHARSET": "string", + "HTTP2_HEADER_ACCEPT_ENCODING": "string", + "HTTP2_HEADER_ACCEPT_LANGUAGE": "string", + "HTTP2_HEADER_ACCEPT_RANGES": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS": "string", + "HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD": "string", + "HTTP2_HEADER_AGE": "string", + "HTTP2_HEADER_ALLOW": "string", + "HTTP2_HEADER_ALT_SVC": "string", + "HTTP2_HEADER_AUTHORITY": "string", + "HTTP2_HEADER_AUTHORIZATION": "string", + "HTTP2_HEADER_CACHE_CONTROL": "string", + "HTTP2_HEADER_CONNECTION": "string", + "HTTP2_HEADER_CONTENT_DISPOSITION": "string", + "HTTP2_HEADER_CONTENT_ENCODING": "string", + "HTTP2_HEADER_CONTENT_LANGUAGE": "string", + "HTTP2_HEADER_CONTENT_LENGTH": "string", + "HTTP2_HEADER_CONTENT_LOCATION": "string", + "HTTP2_HEADER_CONTENT_MD5": "string", + "HTTP2_HEADER_CONTENT_RANGE": "string", + "HTTP2_HEADER_CONTENT_SECURITY_POLICY": "string", + "HTTP2_HEADER_CONTENT_TYPE": "string", + "HTTP2_HEADER_COOKIE": "string", + "HTTP2_HEADER_DATE": "string", + "HTTP2_HEADER_DNT": "string", + "HTTP2_HEADER_EARLY_DATA": "string", + "HTTP2_HEADER_ETAG": "string", + "HTTP2_HEADER_EXPECT": "string", + "HTTP2_HEADER_EXPECT_CT": "string", + "HTTP2_HEADER_EXPIRES": "string", + "HTTP2_HEADER_FORWARDED": "string", + "HTTP2_HEADER_FROM": "string", + "HTTP2_HEADER_HOST": "string", + "HTTP2_HEADER_HTTP2_SETTINGS": "string", + "HTTP2_HEADER_IF_MATCH": "string", + "HTTP2_HEADER_IF_MODIFIED_SINCE": "string", + "HTTP2_HEADER_IF_NONE_MATCH": "string", + "HTTP2_HEADER_IF_RANGE": "string", + "HTTP2_HEADER_IF_UNMODIFIED_SINCE": "string", + "HTTP2_HEADER_KEEP_ALIVE": "string", + "HTTP2_HEADER_LAST_MODIFIED": "string", + "HTTP2_HEADER_LINK": "string", + "HTTP2_HEADER_LOCATION": "string", + "HTTP2_HEADER_MAX_FORWARDS": "string", + "HTTP2_HEADER_METHOD": "string", + "HTTP2_HEADER_ORIGIN": "string", + "HTTP2_HEADER_PATH": "string", + "HTTP2_HEADER_PREFER": "string", + "HTTP2_HEADER_PRIORITY": "string", + "HTTP2_HEADER_PROTOCOL": "string", + "HTTP2_HEADER_PROXY_AUTHENTICATE": "string", + "HTTP2_HEADER_PROXY_AUTHORIZATION": "string", + "HTTP2_HEADER_PROXY_CONNECTION": "string", + "HTTP2_HEADER_PURPOSE": "string", + "HTTP2_HEADER_RANGE": "string", + "HTTP2_HEADER_REFERER": "string", + "HTTP2_HEADER_REFRESH": "string", + "HTTP2_HEADER_RETRY_AFTER": "string", + "HTTP2_HEADER_SCHEME": "string", + "HTTP2_HEADER_SERVER": "string", + "HTTP2_HEADER_SET_COOKIE": "string", + "HTTP2_HEADER_STATUS": "string", + "HTTP2_HEADER_STRICT_TRANSPORT_SECURITY": "string", + "HTTP2_HEADER_TE": "string", + "HTTP2_HEADER_TIMING_ALLOW_ORIGIN": "string", + "HTTP2_HEADER_TK": "string", + "HTTP2_HEADER_TRAILER": "string", + "HTTP2_HEADER_TRANSFER_ENCODING": "string", + "HTTP2_HEADER_UPGRADE": "string", + "HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS": "string", + "HTTP2_HEADER_USER_AGENT": "string", + "HTTP2_HEADER_VARY": "string", + "HTTP2_HEADER_VIA": "string", + "HTTP2_HEADER_WARNING": "string", + "HTTP2_HEADER_WWW_AUTHENTICATE": "string", + "HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS": "string", + "HTTP2_HEADER_X_FORWARDED_FOR": "string", + "HTTP2_HEADER_X_FRAME_OPTIONS": "string", + "HTTP2_HEADER_X_XSS_PROTECTION": "string", + "HTTP2_METHOD_ACL": "string", + "HTTP2_METHOD_BASELINE_CONTROL": "string", + "HTTP2_METHOD_BIND": "string", + "HTTP2_METHOD_CHECKIN": "string", + "HTTP2_METHOD_CHECKOUT": "string", + "HTTP2_METHOD_CONNECT": "string", + "HTTP2_METHOD_COPY": "string", + "HTTP2_METHOD_DELETE": "string", + "HTTP2_METHOD_GET": "string", + "HTTP2_METHOD_HEAD": "string", + "HTTP2_METHOD_LABEL": "string", + "HTTP2_METHOD_LINK": "string", + "HTTP2_METHOD_LOCK": "string", + "HTTP2_METHOD_MERGE": "string", + "HTTP2_METHOD_MKACTIVITY": "string", + "HTTP2_METHOD_MKCALENDAR": "string", + "HTTP2_METHOD_MKCOL": "string", + "HTTP2_METHOD_MKREDIRECTREF": "string", + "HTTP2_METHOD_MKWORKSPACE": "string", + "HTTP2_METHOD_MOVE": "string", + "HTTP2_METHOD_OPTIONS": "string", + "HTTP2_METHOD_ORDERPATCH": "string", + "HTTP2_METHOD_PATCH": "string", + "HTTP2_METHOD_POST": "string", + "HTTP2_METHOD_PRI": "string", + "HTTP2_METHOD_PROPFIND": "string", + "HTTP2_METHOD_PROPPATCH": "string", + "HTTP2_METHOD_PUT": "string", + "HTTP2_METHOD_REBIND": "string", + "HTTP2_METHOD_REPORT": "string", + "HTTP2_METHOD_SEARCH": "string", + "HTTP2_METHOD_TRACE": "string", + "HTTP2_METHOD_UNBIND": "string", + "HTTP2_METHOD_UNCHECKOUT": "string", + "HTTP2_METHOD_UNLINK": "string", + "HTTP2_METHOD_UNLOCK": "string", + "HTTP2_METHOD_UPDATE": "string", + "HTTP2_METHOD_UPDATEREDIRECTREF": "string", + "HTTP2_METHOD_VERSION_CONTROL": "string", + "HTTP_STATUS_ACCEPTED": "number", + "HTTP_STATUS_ALREADY_REPORTED": "number", + "HTTP_STATUS_BAD_GATEWAY": "number", + "HTTP_STATUS_BAD_REQUEST": "number", + "HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED": "number", + "HTTP_STATUS_CONFLICT": "number", + "HTTP_STATUS_CONTINUE": "number", + "HTTP_STATUS_CREATED": "number", + "HTTP_STATUS_EARLY_HINTS": "number", + "HTTP_STATUS_EXPECTATION_FAILED": "number", + "HTTP_STATUS_FAILED_DEPENDENCY": "number", + "HTTP_STATUS_FORBIDDEN": "number", + "HTTP_STATUS_FOUND": "number", + "HTTP_STATUS_GATEWAY_TIMEOUT": "number", + "HTTP_STATUS_GONE": "number", + "HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED": "number", + "HTTP_STATUS_IM_USED": "number", + "HTTP_STATUS_INSUFFICIENT_STORAGE": "number", + "HTTP_STATUS_INTERNAL_SERVER_ERROR": "number", + "HTTP_STATUS_LENGTH_REQUIRED": "number", + "HTTP_STATUS_LOCKED": "number", + "HTTP_STATUS_LOOP_DETECTED": "number", + "HTTP_STATUS_METHOD_NOT_ALLOWED": "number", + "HTTP_STATUS_MISDIRECTED_REQUEST": "number", + "HTTP_STATUS_MOVED_PERMANENTLY": "number", + "HTTP_STATUS_MULTIPLE_CHOICES": "number", + "HTTP_STATUS_MULTI_STATUS": "number", + "HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION": "number", + "HTTP_STATUS_NOT_ACCEPTABLE": "number", + "HTTP_STATUS_NOT_EXTENDED": "number", + "HTTP_STATUS_NOT_FOUND": "number", + "HTTP_STATUS_NOT_IMPLEMENTED": "number", + "HTTP_STATUS_NOT_MODIFIED": "number", + "HTTP_STATUS_NO_CONTENT": "number", + "HTTP_STATUS_OK": "number", + "HTTP_STATUS_PARTIAL_CONTENT": "number", + "HTTP_STATUS_PAYLOAD_TOO_LARGE": "number", + "HTTP_STATUS_PAYMENT_REQUIRED": "number", + "HTTP_STATUS_PERMANENT_REDIRECT": "number", + "HTTP_STATUS_PRECONDITION_FAILED": "number", + "HTTP_STATUS_PRECONDITION_REQUIRED": "number", + "HTTP_STATUS_PROCESSING": "number", + "HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED": "number", + "HTTP_STATUS_RANGE_NOT_SATISFIABLE": "number", + "HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE": "number", + "HTTP_STATUS_REQUEST_TIMEOUT": "number", + "HTTP_STATUS_RESET_CONTENT": "number", + "HTTP_STATUS_SEE_OTHER": "number", + "HTTP_STATUS_SERVICE_UNAVAILABLE": "number", + "HTTP_STATUS_SWITCHING_PROTOCOLS": "number", + "HTTP_STATUS_TEAPOT": "number", + "HTTP_STATUS_TEMPORARY_REDIRECT": "number", + "HTTP_STATUS_TOO_EARLY": "number", + "HTTP_STATUS_TOO_MANY_REQUESTS": "number", + "HTTP_STATUS_UNAUTHORIZED": "number", + "HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS": "number", + "HTTP_STATUS_UNPROCESSABLE_ENTITY": "number", + "HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE": "number", + "HTTP_STATUS_UPGRADE_REQUIRED": "number", + "HTTP_STATUS_URI_TOO_LONG": "number", + "HTTP_STATUS_USE_PROXY": "number", + "HTTP_STATUS_VARIANT_ALSO_NEGOTIATES": "number", + "MAX_INITIAL_WINDOW_SIZE": "number", + "MAX_MAX_FRAME_SIZE": "number", + "MIN_MAX_FRAME_SIZE": "number", + "NGHTTP2_CANCEL": "number", + "NGHTTP2_COMPRESSION_ERROR": "number", + "NGHTTP2_CONNECT_ERROR": "number", + "NGHTTP2_DEFAULT_WEIGHT": "number", + "NGHTTP2_ENHANCE_YOUR_CALM": "number", + "NGHTTP2_ERR_FRAME_SIZE_ERROR": "number", + "NGHTTP2_FLAG_ACK": "number", + "NGHTTP2_FLAG_END_HEADERS": "number", + "NGHTTP2_FLAG_END_STREAM": "number", + "NGHTTP2_FLAG_NONE": "number", + "NGHTTP2_FLAG_PADDED": "number", + "NGHTTP2_FLAG_PRIORITY": "number", + "NGHTTP2_FLOW_CONTROL_ERROR": "number", + "NGHTTP2_FRAME_SIZE_ERROR": "number", + "NGHTTP2_HTTP_1_1_REQUIRED": "number", + "NGHTTP2_INADEQUATE_SECURITY": "number", + "NGHTTP2_INTERNAL_ERROR": "number", + "NGHTTP2_NO_ERROR": "number", + "NGHTTP2_PROTOCOL_ERROR": "number", + "NGHTTP2_REFUSED_STREAM": "number", + "NGHTTP2_SESSION_CLIENT": "number", + "NGHTTP2_SESSION_SERVER": "number", + "NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL": "number", + "NGHTTP2_SETTINGS_ENABLE_PUSH": "number", + "NGHTTP2_SETTINGS_HEADER_TABLE_SIZE": "number", + "NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS": "number", + "NGHTTP2_SETTINGS_MAX_FRAME_SIZE": "number", + "NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE": "number", + "NGHTTP2_SETTINGS_TIMEOUT": "number", + "NGHTTP2_STREAM_CLOSED": "number", + "NGHTTP2_STREAM_STATE_CLOSED": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE": "number", + "NGHTTP2_STREAM_STATE_IDLE": "number", + "NGHTTP2_STREAM_STATE_OPEN": "number", + "NGHTTP2_STREAM_STATE_RESERVED_LOCAL": "number", + "NGHTTP2_STREAM_STATE_RESERVED_REMOTE": "number", + "PADDING_STRATEGY_ALIGNED": "number", + "PADDING_STRATEGY_CALLBACK": "number", + "PADDING_STRATEGY_MAX": "number", + "PADDING_STRATEGY_NONE": "number" + }, + "createSecureServer": "function", + "createServer": "function", + "getDefaultSettings": "function", + "getPackedSettings": "function", + "getUnpackedSettings": "function", + "sensitiveHeaders": "symbol" + }, + "node:https": { + "Agent": "function", + "Server": "function", + "createServer": "function", + "get": "function", + "globalAgent": { + "_events": { + "free": "function", + "newListener": "function" + }, + "_eventsCount": "number", + "_maxListeners": "undefined", + "_sessionCache": { + "list": "object", + "map": "object" + }, + "defaultPort": "number", + "freeSockets": "object", + "keepAlive": "boolean", + "keepAliveMsecs": "number", + "maxCachedSessions": "number", + "maxFreeSockets": "number", + "maxSockets": "number", + "maxTotalSockets": "number", + "options": { + "keepAlive": "boolean", + "noDelay": "boolean", + "path": "object", + "scheduling": "string", + "timeout": "number" + }, + "protocol": "string", + "requests": "object", + "scheduling": "string", + "sockets": "object", + "totalSocketCount": "number" + }, + "request": "function" + }, + "node:inspector": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:inspector/promises": { + "Session": "function", + "close": "function", + "console": { + "assert": "function", + "clear": "function", + "context": "function", + "count": "function", + "countReset": "function", + "debug": "function", + "dir": "function", + "dirxml": "function", + "error": "function", + "group": "function", + "groupCollapsed": "function", + "groupEnd": "function", + "info": "function", + "log": "function", + "profile": "function", + "profileEnd": "function", + "table": "function", + "time": "function", + "timeEnd": "function", + "timeLog": "function", + "timeStamp": "function", + "trace": "function", + "warn": "function" + }, + "open": "function", + "url": "function", + "waitForDebugger": "function" + }, + "node:module": { + "Module": { + "Module": { + "Module": "function", + "SourceMap": "function", + "_cache": "object", + "_debug": "function", + "_extensions": "object", + "_findPath": "function", + "_initPaths": "function", + "_load": "function", + "_nodeModulePaths": "function", + "_pathCache": "object", + "_preloadModules": "function", + "_resolveFilename": "function", + "_resolveLookupPaths": "function", + "builtinModules": "object", + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": "object", + "isBuiltin": "function", + "runMain": "function", + "syncBuiltinESMExports": "function" + }, + "SourceMap": "function", + "_cache": "object", + "_debug": "function", + "_extensions": { + ".js": "function", + ".json": "function", + ".node": "function" + }, + "_findPath": "function", + "_initPaths": "function", + "_load": "function", + "_nodeModulePaths": "function", + "_pathCache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs\u0000": "string" + }, + "_preloadModules": "function", + "_resolveFilename": "function", + "_resolveLookupPaths": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string" + }, + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": { + "0": "string", + "1": "string", + "2": "string" + }, + "isBuiltin": "function", + "runMain": "function", + "syncBuiltinESMExports": "function" + }, + "SourceMap": "function", + "_cache": "object", + "_debug": "function", + "_extensions": { + ".js": "function", + ".json": "function", + ".node": "function" + }, + "_findPath": "function", + "_initPaths": "function", + "_load": "function", + "_nodeModulePaths": "function", + "_pathCache": { + "/Users/jarred/Code/bun/test/exports/generate-exports.mjs\u0000": "string" + }, + "_preloadModules": "function", + "_resolveFilename": "function", + "_resolveLookupPaths": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string" + }, + "createRequire": "function", + "findSourceMap": "function", + "globalPaths": { + "0": "string", + "1": "string", + "2": "string" + }, + "isBuiltin": "function", + "runMain": "function", + "syncBuiltinESMExports": "function" + }, + "node:net": { + "BlockList": "function", + "Server": "function", + "Socket": "function", + "SocketAddress": "function", + "Stream": "function", + "_createServerHandle": "function", + "_normalizeArgs": "function", + "_setSimultaneousAccepts": "function", + "connect": "function", + "createConnection": "function", + "createServer": "function", + "getDefaultAutoSelectFamily": "function", + "getDefaultAutoSelectFamilyAttemptTimeout": "function", + "isIP": "function", + "isIPv4": "function", + "isIPv6": "function", + "setDefaultAutoSelectFamily": "function", + "setDefaultAutoSelectFamilyAttemptTimeout": "function" + }, + "node:os": { + "EOL": "string", + "arch": "function", + "availableParallelism": "function", + "constants": { + "UV_UDP_REUSEADDR": "number", + "dlopen": { + "RTLD_GLOBAL": "number", + "RTLD_LAZY": "number", + "RTLD_LOCAL": "number", + "RTLD_NOW": "number" + }, + "errno": { + "E2BIG": "number", + "EACCES": "number", + "EADDRINUSE": "number", + "EADDRNOTAVAIL": "number", + "EAFNOSUPPORT": "number", + "EAGAIN": "number", + "EALREADY": "number", + "EBADF": "number", + "EBADMSG": "number", + "EBUSY": "number", + "ECANCELED": "number", + "ECHILD": "number", + "ECONNABORTED": "number", + "ECONNREFUSED": "number", + "ECONNRESET": "number", + "EDEADLK": "number", + "EDESTADDRREQ": "number", + "EDOM": "number", + "EDQUOT": "number", + "EEXIST": "number", + "EFAULT": "number", + "EFBIG": "number", + "EHOSTUNREACH": "number", + "EIDRM": "number", + "EILSEQ": "number", + "EINPROGRESS": "number", + "EINTR": "number", + "EINVAL": "number", + "EIO": "number", + "EISCONN": "number", + "EISDIR": "number", + "ELOOP": "number", + "EMFILE": "number", + "EMLINK": "number", + "EMSGSIZE": "number", + "EMULTIHOP": "number", + "ENAMETOOLONG": "number", + "ENETDOWN": "number", + "ENETRESET": "number", + "ENETUNREACH": "number", + "ENFILE": "number", + "ENOBUFS": "number", + "ENODATA": "number", + "ENODEV": "number", + "ENOENT": "number", + "ENOEXEC": "number", + "ENOLCK": "number", + "ENOLINK": "number", + "ENOMEM": "number", + "ENOMSG": "number", + "ENOPROTOOPT": "number", + "ENOSPC": "number", + "ENOSR": "number", + "ENOSTR": "number", + "ENOSYS": "number", + "ENOTCONN": "number", + "ENOTDIR": "number", + "ENOTEMPTY": "number", + "ENOTSOCK": "number", + "ENOTSUP": "number", + "ENOTTY": "number", + "ENXIO": "number", + "EOPNOTSUPP": "number", + "EOVERFLOW": "number", + "EPERM": "number", + "EPIPE": "number", + "EPROTO": "number", + "EPROTONOSUPPORT": "number", + "EPROTOTYPE": "number", + "ERANGE": "number", + "EROFS": "number", + "ESPIPE": "number", + "ESRCH": "number", + "ESTALE": "number", + "ETIME": "number", + "ETIMEDOUT": "number", + "ETXTBSY": "number", + "EWOULDBLOCK": "number", + "EXDEV": "number" + }, + "priority": { + "PRIORITY_ABOVE_NORMAL": "number", + "PRIORITY_BELOW_NORMAL": "number", + "PRIORITY_HIGH": "number", + "PRIORITY_HIGHEST": "number", + "PRIORITY_LOW": "number", + "PRIORITY_NORMAL": "number" + }, + "signals": { + "SIGABRT": "number", + "SIGALRM": "number", + "SIGBUS": "number", + "SIGCHLD": "number", + "SIGCONT": "number", + "SIGFPE": "number", + "SIGHUP": "number", + "SIGILL": "number", + "SIGINFO": "number", + "SIGINT": "number", + "SIGIO": "number", + "SIGIOT": "number", + "SIGKILL": "number", + "SIGPIPE": "number", + "SIGPROF": "number", + "SIGQUIT": "number", + "SIGSEGV": "number", + "SIGSTOP": "number", + "SIGSYS": "number", + "SIGTERM": "number", + "SIGTRAP": "number", + "SIGTSTP": "number", + "SIGTTIN": "number", + "SIGTTOU": "number", + "SIGURG": "number", + "SIGUSR1": "number", + "SIGUSR2": "number", + "SIGVTALRM": "number", + "SIGWINCH": "number", + "SIGXCPU": "number", + "SIGXFSZ": "number" + } + }, + "cpus": "function", + "devNull": "string", + "endianness": "function", + "freemem": "function", + "getPriority": "function", + "homedir": "function", + "hostname": "function", + "loadavg": "function", + "machine": "function", + "networkInterfaces": "function", + "platform": "function", + "release": "function", + "setPriority": "function", + "tmpdir": "function", + "totalmem": "function", + "type": "function", + "uptime": "function", + "userInfo": "function", + "version": "function" + }, + "node:path": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + } + }, + "node:path/posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + } + }, + "node:path/win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + }, + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": { + "_makeLong": "function", + "basename": "function", + "delimiter": "string", + "dirname": "function", + "extname": "function", + "format": "function", + "isAbsolute": "function", + "join": "function", + "normalize": "function", + "parse": "function", + "posix": "object", + "relative": "function", + "resolve": "function", + "sep": "string", + "toNamespacedPath": "function", + "win32": "object" + } + } + }, + "node:perf_hooks": { + "Performance": "function", + "PerformanceEntry": "function", + "PerformanceMark": "function", + "PerformanceMeasure": "function", + "PerformanceObserver": "function", + "PerformanceObserverEntryList": "function", + "PerformanceResourceTiming": "function", + "constants": { + "NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE": "number", + "NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY": "number", + "NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED": "number", + "NODE_PERFORMANCE_GC_FLAGS_FORCED": "number", + "NODE_PERFORMANCE_GC_FLAGS_NO": "number", + "NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE": "number", + "NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING": "number", + "NODE_PERFORMANCE_GC_INCREMENTAL": "number", + "NODE_PERFORMANCE_GC_MAJOR": "number", + "NODE_PERFORMANCE_GC_MINOR": "number", + "NODE_PERFORMANCE_GC_WEAKCB": "number" + }, + "createHistogram": "function", + "monitorEventLoopDelay": "function", + "performance": "object" + }, + "node:process": { + "_debugEnd": "function", + "_debugProcess": "function", + "_events": { + "SIGWINCH": "function", + "exit": "function", + "newListener": { + "0": "function", + "1": "function" + }, + "removeListener": { + "0": "function", + "1": "function" + }, + "warning": "function" + }, + "_eventsCount": "number", + "_exiting": "boolean", + "_fatalException": "function", + "_getActiveHandles": "function", + "_getActiveRequests": "function", + "_kill": "function", + "_linkedBinding": "function", + "_maxListeners": "undefined", + "_preload_modules": "object", + "_rawDebug": "function", + "_startProfilerIdleNotifier": "function", + "_stopProfilerIdleNotifier": "function", + "_tickCallback": "function", + "abort": "function", + "allowedNodeEnvironmentFlags": "object", + "arch": "string", + "argv": { + "0": "string", + "1": "string" + }, + "argv0": "string", + "assert": "function", + "binding": "function", + "chdir": "function", + "config": { + "target_defaults": { + "cflags": "object", + "default_configuration": "string", + "defines": "object", + "include_dirs": "object", + "libraries": "object" + }, + "variables": { + "arm_fpu": "string", + "asan": "number", + "coverage": "boolean", + "dcheck_always_on": "number", + "debug_nghttp2": "boolean", + "debug_node": "boolean", + "enable_lto": "boolean", + "enable_pgo_generate": "boolean", + "enable_pgo_use": "boolean", + "error_on_warn": "boolean", + "force_dynamic_crt": "number", + "host_arch": "string", + "icu_gyp_path": "string", + "icu_small": "boolean", + "icu_ver_major": "string", + "is_debug": "number", + "libdir": "string", + "llvm_version": "string", + "napi_build_version": "string", + "node_builtin_shareable_builtins": "object", + "node_byteorder": "string", + "node_debug_lib": "boolean", + "node_enable_d8": "boolean", + "node_enable_v8_vtunejit": "boolean", + "node_fipsinstall": "boolean", + "node_install_corepack": "boolean", + "node_install_npm": "boolean", + "node_library_files": "object", + "node_module_version": "number", + "node_no_browser_globals": "boolean", + "node_prefix": "string", + "node_release_urlbase": "string", + "node_shared": "boolean", + "node_shared_brotli": "boolean", + "node_shared_cares": "boolean", + "node_shared_http_parser": "boolean", + "node_shared_libuv": "boolean", + "node_shared_nghttp2": "boolean", + "node_shared_nghttp3": "boolean", + "node_shared_ngtcp2": "boolean", + "node_shared_openssl": "boolean", + "node_shared_zlib": "boolean", + "node_tag": "string", + "node_target_type": "string", + "node_use_bundled_v8": "boolean", + "node_use_node_code_cache": "boolean", + "node_use_node_snapshot": "boolean", + "node_use_openssl": "boolean", + "node_use_v8_platform": "boolean", + "node_with_ltcg": "boolean", + "node_without_node_options": "boolean", + "openssl_is_fips": "boolean", + "openssl_quic": "boolean", + "ossfuzz": "boolean", + "shlib_suffix": "string", + "single_executable_application": "boolean", + "target_arch": "string", + "v8_enable_31bit_smis_on_64bit_arch": "number", + "v8_enable_gdbjit": "number", + "v8_enable_hugepage": "number", + "v8_enable_i18n_support": "number", + "v8_enable_inspector": "number", + "v8_enable_javascript_promise_hooks": "number", + "v8_enable_lite_mode": "number", + "v8_enable_object_print": "number", + "v8_enable_pointer_compression": "number", + "v8_enable_shared_ro_heap": "number", + "v8_enable_webassembly": "number", + "v8_no_strict_aliasing": "number", + "v8_optimized_debug": "number", + "v8_promise_internal_field_count": "number", + "v8_random_seed": "number", + "v8_trace_maps": "number", + "v8_use_siphash": "number", + "want_separate_host_toolset": "number" + } + }, + "constrainedMemory": "function", + "cpuUsage": "function", + "cwd": "function", + "debugPort": "number", + "dlopen": "function", + "domain": "object", + "emitWarning": "function", + "env": { + "ALACRITTY_LOG": "string", + "ALACRITTY_SOCKET": "string", + "BUN_INSTALL": "string", + "CC": "string", + "CODESIGN_IDENTITY": "string", + "COLORTERM": "string", + "COMMAND_MODE": "string", + "CXX": "string", + "HOME": "string", + "LC_ALL": "string", + "LLVM_PREFIX": "string", + "LOGNAME": "string", + "LS_COLORS": "string", + "PATH": "string", + "PWD": "string", + "SDKROOT": "string", + "SHELL": "string", + "SHLVL": "string", + "SSH_AUTH_SOCK": "string", + "STARSHIP_SESSION_KEY": "string", + "STARSHIP_SHELL": "string", + "TERM": "string", + "TMPDIR": "string", + "USER": "string", + "VOLTA_HOME": "string", + "XPC_FLAGS": "string", + "XPC_SERVICE_NAME": "string", + "__CFBundleIdentifier": "string", + "__CF_USER_TEXT_ENCODING": "string" + }, + "execArgv": "object", + "execPath": "string", + "exit": "function", + "exitCode": "undefined", + "features": { + "cached_builtins": "boolean", + "debug": "boolean", + "inspector": "boolean", + "ipv6": "boolean", + "tls": "boolean", + "tls_alpn": "boolean", + "tls_ocsp": "boolean", + "tls_sni": "boolean", + "uv": "boolean" + }, + "getActiveResourcesInfo": "function", + "getegid": "function", + "geteuid": "function", + "getgid": "function", + "getgroups": "function", + "getuid": "function", + "hasUncaughtExceptionCaptureCallback": "function", + "hrtime": { + "bigint": "function" + }, + "initgroups": "function", + "kill": "function", + "memoryUsage": { + "rss": "function" + }, + "moduleLoadList": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string", + "69": "string", + "70": "string", + "71": "string", + "72": "string", + "73": "string", + "74": "string", + "75": "string", + "76": "string", + "77": "string", + "78": "string", + "79": "string", + "80": "string", + "81": "string", + "82": "string", + "83": "string", + "84": "string", + "85": "string", + "86": "string", + "87": "string", + "88": "string", + "89": "string", + "90": "string", + "91": "string", + "92": "string", + "93": "string", + "94": "string", + "95": "string", + "96": "string", + "97": "string", + "98": "string", + "99": "string", + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "104": "string", + "105": "string", + "106": "string", + "107": "string", + "108": "string", + "109": "string", + "110": "string", + "111": "string", + "112": "string", + "113": "string", + "114": "string", + "115": "string", + "116": "string", + "117": "string", + "118": "string", + "119": "string", + "120": "string", + "121": "string", + "122": "string", + "123": "string", + "124": "string", + "125": "string", + "126": "string", + "127": "string", + "128": "string", + "129": "string", + "130": "string", + "131": "string", + "132": "string", + "133": "string", + "134": "string", + "135": "string", + "136": "string", + "137": "string", + "138": "string", + "139": "string", + "140": "string", + "141": "string", + "142": "string", + "143": "string", + "144": "string", + "145": "string", + "146": "string", + "147": "string", + "148": "string", + "149": "string", + "150": "string", + "151": "string", + "152": "string", + "153": "string", + "154": "string", + "155": "string", + "156": "string", + "157": "string", + "158": "string", + "159": "string", + "160": "string", + "161": "string", + "162": "string", + "163": "string", + "164": "string", + "165": "string", + "166": "string", + "167": "string", + "168": "string", + "169": "string", + "170": "string", + "171": "string", + "172": "string", + "173": "string", + "174": "string", + "175": "string", + "176": "string", + "177": "string", + "178": "string", + "179": "string", + "180": "string", + "181": "string", + "182": "string", + "183": "string", + "184": "string", + "185": "string", + "186": "string", + "187": "string", + "188": "string", + "189": "string", + "190": "string", + "191": "string", + "192": "string", + "193": "string", + "194": "string", + "195": "string", + "196": "string", + "197": "string", + "198": "string", + "199": "string", + "200": "string", + "201": "string", + "202": "string", + "203": "string", + "204": "string", + "205": "string", + "206": "string", + "207": "string", + "208": "string", + "209": "string", + "210": "string", + "211": "string", + "212": "string", + "213": "string", + "214": "string", + "215": "string", + "216": "string", + "217": "string", + "218": "string", + "219": "string", + "220": "string", + "221": "string", + "222": "string", + "223": "string", + "224": "string", + "225": "string", + "226": "string", + "227": "string", + "228": "string", + "229": "string", + "230": "string", + "231": "string", + "232": "string", + "233": "string", + "234": "string", + "235": "string", + "236": "string", + "237": "string", + "238": "string", + "239": "string", + "240": "string", + "241": "string", + "242": "string", + "243": "string", + "244": "string", + "245": "string", + "246": "string", + "247": "string", + "248": "string", + "249": "string", + "250": "string", + "251": "string", + "252": "string" + }, + "nextTick": "function", + "openStdin": "function", + "pid": "number", + "platform": "string", + "ppid": "number", + "reallyExit": "function", + "release": { + "headersUrl": "string", + "name": "string", + "sourceUrl": "string" + }, + "report": { + "compact": "boolean", + "directory": "string", + "filename": "string", + "getReport": "function", + "reportOnFatalError": "boolean", + "reportOnSignal": "boolean", + "reportOnUncaughtException": "boolean", + "signal": "string", + "writeReport": "function" + }, + "resourceUsage": "function", + "setSourceMapsEnabled": "function", + "setUncaughtExceptionCaptureCallback": "function", + "setegid": "function", + "seteuid": "function", + "setgid": "function", + "setgroups": "function", + "setuid": "function", + "stderr": { + "_closeAfterHandlingError": "boolean", + "_destroy": "function", + "_events": { + "end": "function" + }, + "_eventsCount": "number", + "_hadError": "boolean", + "_host": "object", + "_isStdio": "boolean", + "_maxListeners": "undefined", + "_parent": "object", + "_pendingData": "object", + "_pendingEncoding": "string", + "_readableState": { + "autoDestroy": "boolean", + "awaitDrainWriters": "object", + "buffer": "object", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "dataEmitted": "boolean", + "decoder": "object", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "emittedReadable": "boolean", + "encoding": "object", + "endEmitted": "boolean", + "ended": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "flowing": "object", + "highWaterMark": "number", + "length": "number", + "multiAwaitDrain": "boolean", + "needReadable": "boolean", + "objectMode": "boolean", + "pipes": "object", + "readableListening": "boolean", + "reading": "boolean", + "readingMore": "boolean", + "resumeScheduled": "boolean", + "sync": "boolean" + }, + "_server": "object", + "_sockname": "object", + "_type": "string", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "allowHalfOpen": "boolean", + "columns": "number", + "connecting": "boolean", + "destroySoon": "function", + "fd": "number", + "rows": "number", + "server": "object" + }, + "stdin": { + "_closeAfterHandlingError": "boolean", + "_events": { + "end": "function", + "pause": "function" + }, + "_eventsCount": "number", + "_hadError": "boolean", + "_host": "object", + "_maxListeners": "undefined", + "_parent": "object", + "_pendingData": "object", + "_pendingEncoding": "string", + "_readableState": { + "autoDestroy": "boolean", + "awaitDrainWriters": "object", + "buffer": "object", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "dataEmitted": "boolean", + "decoder": "object", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "emittedReadable": "boolean", + "encoding": "object", + "endEmitted": "boolean", + "ended": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "flowing": "object", + "highWaterMark": "number", + "length": "number", + "multiAwaitDrain": "boolean", + "needReadable": "boolean", + "objectMode": "boolean", + "pipes": "object", + "readableListening": "boolean", + "reading": "boolean", + "readingMore": "boolean", + "resumeScheduled": "boolean", + "sync": "boolean" + }, + "_server": "object", + "_sockname": "object", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "allowHalfOpen": "boolean", + "connecting": "boolean", + "fd": "number", + "isRaw": "boolean", + "isTTY": "boolean", + "server": "object" + }, + "stdout": { + "_destroy": "function", + "_events": "object", + "_eventsCount": "number", + "_isStdio": "boolean", + "_maxListeners": "undefined", + "_type": "string", + "_writableState": { + "afterWriteTickInfo": "object", + "allBuffers": "boolean", + "allNoop": "boolean", + "autoDestroy": "boolean", + "bufferProcessing": "boolean", + "buffered": "object", + "bufferedIndex": "number", + "closeEmitted": "boolean", + "closed": "boolean", + "constructed": "boolean", + "corked": "number", + "decodeStrings": "boolean", + "defaultEncoding": "string", + "destroyed": "boolean", + "emitClose": "boolean", + "ended": "boolean", + "ending": "boolean", + "errorEmitted": "boolean", + "errored": "object", + "finalCalled": "boolean", + "finished": "boolean", + "highWaterMark": "number", + "length": "number", + "needDrain": "boolean", + "objectMode": "boolean", + "onwrite": "function", + "pendingcb": "number", + "prefinished": "boolean", + "sync": "boolean", + "writecb": "object", + "writelen": "number", + "writing": "boolean" + }, + "autoClose": "boolean", + "destroySoon": "function", + "fd": "number", + "readable": "boolean" + }, + "title": "string", + "umask": "function", + "uptime": "function", + "version": "string", + "versions": { + "acorn": "string", + "ada": "string", + "ares": "string", + "brotli": "string", + "cldr": "string", + "icu": "string", + "llhttp": "string", + "modules": "string", + "napi": "string", + "nghttp2": "string", + "node": "string", + "openssl": "string", + "simdutf": "string", + "tz": "string", + "undici": "string", + "unicode": "string", + "uv": "string", + "uvwasi": "string", + "v8": "string", + "zlib": "string" + } + }, + "node:punycode": { + "decode": "function", + "encode": "function", + "toASCII": "function", + "toUnicode": "function", + "ucs2": { + "decode": "function", + "encode": "function" + }, + "version": "string" + }, + "node:querystring": { + "decode": "function", + "encode": "function", + "escape": "function", + "parse": "function", + "stringify": "function", + "unescape": "function", + "unescapeBuffer": "function" + }, + "node:readline": { + "Interface": "function", + "clearLine": "function", + "clearScreenDown": "function", + "createInterface": "function", + "cursorTo": "function", + "emitKeypressEvents": "function", + "moveCursor": "function", + "promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + } + }, + "node:readline/promises": { + "Interface": "function", + "Readline": "function", + "createInterface": "function" + }, + "node:repl": { + "REPLServer": "function", + "REPL_MODE_SLOPPY": "symbol", + "REPL_MODE_STRICT": "symbol", + "Recoverable": "function", + "builtinModules": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string" + }, + "start": "function", + "writer": { + "options": { + "breakLength": "number", + "colors": "boolean", + "compact": "number", + "customInspect": "boolean", + "depth": "number", + "getters": "boolean", + "maxArrayLength": "number", + "maxStringLength": "number", + "numericSeparator": "boolean", + "showHidden": "boolean", + "showProxy": "boolean", + "sorted": "boolean" + } + } + }, + "node:stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "PassThrough": "function", + "Readable": { + "ReadableState": "function", + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": { + "from": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "PassThrough": "function", + "Readable": { + "ReadableState": "function", + "_fromList": "function", + "from": "function", + "fromWeb": "function", + "toWeb": "function", + "wrap": "function" + }, + "Stream": { + "Duplex": "function", + "PassThrough": "function", + "Readable": "function", + "Stream": "function", + "Transform": "function", + "Writable": "function", + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "destroy": "function", + "finished": "function", + "getDefaultHighWaterMark": "function", + "isDestroyed": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": "object", + "setDefaultHighWaterMark": "function" + }, + "Transform": "function", + "Writable": { + "WritableState": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "destroy": "function", + "finished": { + "finished": "function" + }, + "getDefaultHighWaterMark": "function", + "isDestroyed": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + }, + "setDefaultHighWaterMark": "function" + }, + "Transform": "function", + "Writable": { + "WritableState": "function", + "fromWeb": "function", + "toWeb": "function" + }, + "_isUint8Array": "function", + "_uint8ArrayToBuffer": "function", + "addAbortSignal": "function", + "compose": "function", + "destroy": "function", + "finished": { + "finished": "function" + }, + "getDefaultHighWaterMark": "function", + "isDestroyed": "function", + "isDisturbed": "function", + "isErrored": "function", + "isReadable": "function", + "isWritable": "function", + "pipeline": "function", + "promises": { + "finished": "function", + "pipeline": "function" + }, + "setDefaultHighWaterMark": "function" + }, + "node:stream/consumers": { + "arrayBuffer": "function", + "blob": "function", + "buffer": "function", + "json": "function", + "text": "function" + }, + "node:stream/promises": { + "finished": "function", + "pipeline": "function" + }, + "node:stream/web": { + "ByteLengthQueuingStrategy": "function", + "CompressionStream": "function", + "CountQueuingStrategy": "function", + "DecompressionStream": "function", + "ReadableByteStreamController": "function", + "ReadableStream": "function", + "ReadableStreamBYOBReader": "function", + "ReadableStreamBYOBRequest": "function", + "ReadableStreamDefaultController": "function", + "ReadableStreamDefaultReader": "function", + "TextDecoderStream": "function", + "TextEncoderStream": "function", + "TransformStream": "function", + "TransformStreamDefaultController": "function", + "WritableStream": "function", + "WritableStreamDefaultController": "function", + "WritableStreamDefaultWriter": "function" + }, + "node:string_decoder": { + "StringDecoder": "function" + }, + "node:sys": { + "MIMEParams": "function", + "MIMEType": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "_errnoException": "function", + "_exceptionWithHostPort": "function", + "_extend": "function", + "aborted": "function", + "callbackify": "function", + "debug": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "formatWithOptions": "function", + "getSystemErrorMap": "function", + "getSystemErrorName": "function", + "inherits": "function", + "inspect": { + "colors": { + "bgBlack": "object", + "bgBlue": "object", + "bgBlueBright": "object", + "bgCyan": "object", + "bgCyanBright": "object", + "bgGray": "object", + "bgGreen": "object", + "bgGreenBright": "object", + "bgMagenta": "object", + "bgMagentaBright": "object", + "bgRed": "object", + "bgRedBright": "object", + "bgWhite": "object", + "bgWhiteBright": "object", + "bgYellow": "object", + "bgYellowBright": "object", + "black": "object", + "blink": "object", + "blue": "object", + "blueBright": "object", + "bold": "object", + "cyan": "object", + "cyanBright": "object", + "dim": "object", + "doubleunderline": "object", + "framed": "object", + "gray": "object", + "green": "object", + "greenBright": "object", + "hidden": "object", + "inverse": "object", + "italic": "object", + "magenta": "object", + "magentaBright": "object", + "overlined": "object", + "red": "object", + "redBright": "object", + "reset": "object", + "strikethrough": "object", + "underline": "object", + "white": "object", + "whiteBright": "object", + "yellow": "object", + "yellowBright": "object" + }, + "custom": "symbol", + "styles": { + "bigint": "string", + "boolean": "string", + "date": "string", + "module": "string", + "null": "string", + "number": "string", + "regexp": "string", + "special": "string", + "string": "string", + "symbol": "string", + "undefined": "string" + } + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "parseArgs": "function", + "promisify": { + "custom": "symbol" + }, + "stripVTControlCharacters": "function", + "toUSVString": "function", + "transferableAbortController": "function", + "transferableAbortSignal": "function", + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "node:test/reporters": { + "dot": "function", + "spec": "function", + "tap": "function" + }, + "node:timers": { + "_unrefActive": "function", + "active": "function", + "clearImmediate": "function", + "clearInterval": "function", + "clearTimeout": "function", + "enroll": "function", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function", + "unenroll": "function" + }, + "node:timers/promises": { + "scheduler": "object", + "setImmediate": "function", + "setInterval": "function", + "setTimeout": "function" + }, + "node:tls": { + "CLIENT_RENEG_LIMIT": "number", + "CLIENT_RENEG_WINDOW": "number", + "DEFAULT_CIPHERS": "string", + "DEFAULT_ECDH_CURVE": "string", + "DEFAULT_MAX_VERSION": "string", + "DEFAULT_MIN_VERSION": "string", + "SecureContext": "undefined", + "Server": "function", + "TLSSocket": "function", + "checkServerIdentity": "function", + "connect": "function", + "convertALPNProtocols": "function", + "createSecureContext": "undefined", + "createSecurePair": "function", + "createServer": "function", + "getCiphers": "function", + "rootCertificates": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string", + "6": "string", + "7": "string", + "8": "string", + "9": "string", + "10": "string", + "11": "string", + "12": "string", + "13": "string", + "14": "string", + "15": "string", + "16": "string", + "17": "string", + "18": "string", + "19": "string", + "20": "string", + "21": "string", + "22": "string", + "23": "string", + "24": "string", + "25": "string", + "26": "string", + "27": "string", + "28": "string", + "29": "string", + "30": "string", + "31": "string", + "32": "string", + "33": "string", + "34": "string", + "35": "string", + "36": "string", + "37": "string", + "38": "string", + "39": "string", + "40": "string", + "41": "string", + "42": "string", + "43": "string", + "44": "string", + "45": "string", + "46": "string", + "47": "string", + "48": "string", + "49": "string", + "50": "string", + "51": "string", + "52": "string", + "53": "string", + "54": "string", + "55": "string", + "56": "string", + "57": "string", + "58": "string", + "59": "string", + "60": "string", + "61": "string", + "62": "string", + "63": "string", + "64": "string", + "65": "string", + "66": "string", + "67": "string", + "68": "string", + "69": "string", + "70": "string", + "71": "string", + "72": "string", + "73": "string", + "74": "string", + "75": "string", + "76": "string", + "77": "string", + "78": "string", + "79": "string", + "80": "string", + "81": "string", + "82": "string", + "83": "string", + "84": "string", + "85": "string", + "86": "string", + "87": "string", + "88": "string", + "89": "string", + "90": "string", + "91": "string", + "92": "string", + "93": "string", + "94": "string", + "95": "string", + "96": "string", + "97": "string", + "98": "string", + "99": "string", + "100": "string", + "101": "string", + "102": "string", + "103": "string", + "104": "string", + "105": "string", + "106": "string", + "107": "string", + "108": "string", + "109": "string", + "110": "string", + "111": "string", + "112": "string", + "113": "string", + "114": "string", + "115": "string", + "116": "string", + "117": "string", + "118": "string", + "119": "string", + "120": "string", + "121": "string", + "122": "string", + "123": "string", + "124": "string", + "125": "string", + "126": "string", + "127": "string", + "128": "string", + "129": "string", + "130": "string", + "131": "string", + "132": "string", + "133": "string", + "134": "string", + "135": "string", + "136": "string" + } + }, + "node:trace_events": { + "createTracing": "function", + "getEnabledCategories": "function" + }, + "node:tty": { + "ReadStream": "function", + "WriteStream": "function", + "isatty": "function" + }, + "node:url": { + "URL": { + "canParse": "function", + "createObjectURL": "function", + "revokeObjectURL": "function" + }, + "URLSearchParams": "function", + "Url": "function", + "domainToASCII": "function", + "domainToUnicode": "function", + "fileURLToPath": "function", + "format": "function", + "parse": "function", + "pathToFileURL": "function", + "resolve": "function", + "resolveObject": "function", + "urlToHttpOptions": "function" + }, + "node:util": { + "MIMEParams": "function", + "MIMEType": "function", + "TextDecoder": "function", + "TextEncoder": "function", + "_errnoException": "function", + "_exceptionWithHostPort": "function", + "_extend": "function", + "aborted": "function", + "callbackify": "function", + "debug": "function", + "debuglog": "function", + "deprecate": "function", + "format": "function", + "formatWithOptions": "function", + "getSystemErrorMap": "function", + "getSystemErrorName": "function", + "inherits": "function", + "inspect": { + "colors": { + "bgBlack": "object", + "bgBlue": "object", + "bgBlueBright": "object", + "bgCyan": "object", + "bgCyanBright": "object", + "bgGray": "object", + "bgGreen": "object", + "bgGreenBright": "object", + "bgMagenta": "object", + "bgMagentaBright": "object", + "bgRed": "object", + "bgRedBright": "object", + "bgWhite": "object", + "bgWhiteBright": "object", + "bgYellow": "object", + "bgYellowBright": "object", + "black": "object", + "blink": "object", + "blue": "object", + "blueBright": "object", + "bold": "object", + "cyan": "object", + "cyanBright": "object", + "dim": "object", + "doubleunderline": "object", + "framed": "object", + "gray": "object", + "green": "object", + "greenBright": "object", + "hidden": "object", + "inverse": "object", + "italic": "object", + "magenta": "object", + "magentaBright": "object", + "overlined": "object", + "red": "object", + "redBright": "object", + "reset": "object", + "strikethrough": "object", + "underline": "object", + "white": "object", + "whiteBright": "object", + "yellow": "object", + "yellowBright": "object" + }, + "custom": "symbol", + "styles": { + "bigint": "string", + "boolean": "string", + "date": "string", + "module": "string", + "null": "string", + "number": "string", + "regexp": "string", + "special": "string", + "string": "string", + "symbol": "string", + "undefined": "string" + } + }, + "isArray": "function", + "isBoolean": "function", + "isBuffer": "function", + "isDate": "function", + "isDeepStrictEqual": "function", + "isError": "function", + "isFunction": "function", + "isNull": "function", + "isNullOrUndefined": "function", + "isNumber": "function", + "isObject": "function", + "isPrimitive": "function", + "isRegExp": "function", + "isString": "function", + "isSymbol": "function", + "isUndefined": "function", + "log": "function", + "parseArgs": "function", + "promisify": { + "custom": "symbol" + }, + "stripVTControlCharacters": "function", + "toUSVString": "function", + "transferableAbortController": "function", + "transferableAbortSignal": "function", + "types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + } + }, + "node:util/types": { + "isAnyArrayBuffer": "function", + "isArgumentsObject": "function", + "isArrayBuffer": "function", + "isArrayBufferView": "function", + "isAsyncFunction": "function", + "isBigInt64Array": "function", + "isBigIntObject": "function", + "isBigUint64Array": "function", + "isBooleanObject": "function", + "isBoxedPrimitive": "function", + "isCryptoKey": "function", + "isDataView": "function", + "isDate": "function", + "isExternal": "function", + "isFloat32Array": "function", + "isFloat64Array": "function", + "isGeneratorFunction": "function", + "isGeneratorObject": "function", + "isInt16Array": "function", + "isInt32Array": "function", + "isInt8Array": "function", + "isKeyObject": "function", + "isMap": "function", + "isMapIterator": "function", + "isModuleNamespaceObject": "function", + "isNativeError": "function", + "isNumberObject": "function", + "isPromise": "function", + "isProxy": "function", + "isRegExp": "function", + "isSet": "function", + "isSetIterator": "function", + "isSharedArrayBuffer": "function", + "isStringObject": "function", + "isSymbolObject": "function", + "isTypedArray": "function", + "isUint16Array": "function", + "isUint32Array": "function", + "isUint8Array": "function", + "isUint8ClampedArray": "function", + "isWeakMap": "function", + "isWeakSet": "function" + }, + "node:v8": { + "DefaultDeserializer": "function", + "DefaultSerializer": "function", + "Deserializer": "function", + "GCProfiler": "function", + "Serializer": "function", + "cachedDataVersionTag": "function", + "deserialize": "function", + "getHeapCodeStatistics": "function", + "getHeapSnapshot": "function", + "getHeapSpaceStatistics": "function", + "getHeapStatistics": "function", + "promiseHooks": { + "createHook": "function", + "onAfter": "function", + "onBefore": "function", + "onInit": "function", + "onSettled": "function" + }, + "serialize": "function", + "setFlagsFromString": "function", + "setHeapSnapshotNearHeapLimit": "function", + "startupSnapshot": { + "addDeserializeCallback": "function", + "addSerializeCallback": "function", + "isBuildingSnapshot": "function", + "setDeserializeMainFunction": "function" + }, + "stopCoverage": "function", + "takeCoverage": "function", + "writeHeapSnapshot": "function" + }, + "node:vm": { + "Script": "function", + "compileFunction": "function", + "createContext": "function", + "createScript": "function", + "isContext": "function", + "measureMemory": "function", + "runInContext": "function", + "runInNewContext": "function", + "runInThisContext": "function" + }, + "node:wasi": { + "WASI": "function" + }, + "node:worker_threads": { + "BroadcastChannel": "function", + "MessageChannel": "function", + "MessagePort": "function", + "SHARE_ENV": "symbol", + "Worker": "function", + "getEnvironmentData": "function", + "isMainThread": "boolean", + "markAsUntransferable": "function", + "moveMessagePortToContext": "function", + "parentPort": "object", + "receiveMessageOnPort": "function", + "resourceLimits": "object", + "setEnvironmentData": "function", + "threadId": "number", + "workerData": "object" + }, + "node:zlib": { + "BrotliCompress": "function", + "BrotliDecompress": "function", + "Deflate": "function", + "DeflateRaw": "function", + "Gunzip": "function", + "Gzip": "function", + "Inflate": "function", + "InflateRaw": "function", + "Unzip": "function", + "brotliCompress": "function", + "brotliCompressSync": "function", + "brotliDecompress": "function", + "brotliDecompressSync": "function", + "codes": { + "0": "string", + "1": "string", + "2": "string", + "-1": "string", + "-2": "string", + "-3": "string", + "-4": "string", + "-5": "string", + "-6": "string", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_ERRNO": "number", + "Z_MEM_ERROR": "number", + "Z_NEED_DICT": "number", + "Z_OK": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_VERSION_ERROR": "number" + }, + "constants": { + "BROTLI_DECODE": "number", + "BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES": "number", + "BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP": "number", + "BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES": "number", + "BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1": "number", + "BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2": "number", + "BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS": "number", + "BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET": "number", + "BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1": "number", + "BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2": "number", + "BROTLI_DECODER_ERROR_FORMAT_CL_SPACE": "number", + "BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT": "number", + "BROTLI_DECODER_ERROR_FORMAT_DICTIONARY": "number", + "BROTLI_DECODER_ERROR_FORMAT_DISTANCE": "number", + "BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE": "number", + "BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE": "number", + "BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE": "number", + "BROTLI_DECODER_ERROR_FORMAT_PADDING_1": "number", + "BROTLI_DECODER_ERROR_FORMAT_PADDING_2": "number", + "BROTLI_DECODER_ERROR_FORMAT_RESERVED": "number", + "BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET": "number", + "BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME": "number", + "BROTLI_DECODER_ERROR_FORMAT_TRANSFORM": "number", + "BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS": "number", + "BROTLI_DECODER_ERROR_INVALID_ARGUMENTS": "number", + "BROTLI_DECODER_ERROR_UNREACHABLE": "number", + "BROTLI_DECODER_NEEDS_MORE_INPUT": "number", + "BROTLI_DECODER_NEEDS_MORE_OUTPUT": "number", + "BROTLI_DECODER_NO_ERROR": "number", + "BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION": "number", + "BROTLI_DECODER_PARAM_LARGE_WINDOW": "number", + "BROTLI_DECODER_RESULT_ERROR": "number", + "BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT": "number", + "BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT": "number", + "BROTLI_DECODER_RESULT_SUCCESS": "number", + "BROTLI_DECODER_SUCCESS": "number", + "BROTLI_DEFAULT_MODE": "number", + "BROTLI_DEFAULT_QUALITY": "number", + "BROTLI_DEFAULT_WINDOW": "number", + "BROTLI_ENCODE": "number", + "BROTLI_LARGE_MAX_WINDOW_BITS": "number", + "BROTLI_MAX_INPUT_BLOCK_BITS": "number", + "BROTLI_MAX_QUALITY": "number", + "BROTLI_MAX_WINDOW_BITS": "number", + "BROTLI_MIN_INPUT_BLOCK_BITS": "number", + "BROTLI_MIN_QUALITY": "number", + "BROTLI_MIN_WINDOW_BITS": "number", + "BROTLI_MODE_FONT": "number", + "BROTLI_MODE_GENERIC": "number", + "BROTLI_MODE_TEXT": "number", + "BROTLI_OPERATION_EMIT_METADATA": "number", + "BROTLI_OPERATION_FINISH": "number", + "BROTLI_OPERATION_FLUSH": "number", + "BROTLI_OPERATION_PROCESS": "number", + "BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING": "number", + "BROTLI_PARAM_LARGE_WINDOW": "number", + "BROTLI_PARAM_LGBLOCK": "number", + "BROTLI_PARAM_LGWIN": "number", + "BROTLI_PARAM_MODE": "number", + "BROTLI_PARAM_NDIRECT": "number", + "BROTLI_PARAM_NPOSTFIX": "number", + "BROTLI_PARAM_QUALITY": "number", + "BROTLI_PARAM_SIZE_HINT": "number", + "DEFLATE": "number", + "DEFLATERAW": "number", + "GUNZIP": "number", + "GZIP": "number", + "INFLATE": "number", + "INFLATERAW": "number", + "UNZIP": "number", + "ZLIB_VERNUM": "number", + "Z_BEST_COMPRESSION": "number", + "Z_BEST_SPEED": "number", + "Z_BLOCK": "number", + "Z_BUF_ERROR": "number", + "Z_DATA_ERROR": "number", + "Z_DEFAULT_CHUNK": "number", + "Z_DEFAULT_COMPRESSION": "number", + "Z_DEFAULT_LEVEL": "number", + "Z_DEFAULT_MEMLEVEL": "number", + "Z_DEFAULT_STRATEGY": "number", + "Z_DEFAULT_WINDOWBITS": "number", + "Z_ERRNO": "number", + "Z_FILTERED": "number", + "Z_FINISH": "number", + "Z_FIXED": "number", + "Z_FULL_FLUSH": "number", + "Z_HUFFMAN_ONLY": "number", + "Z_MAX_CHUNK": "number", + "Z_MAX_LEVEL": "number", + "Z_MAX_MEMLEVEL": "number", + "Z_MAX_WINDOWBITS": "number", + "Z_MEM_ERROR": "number", + "Z_MIN_CHUNK": "number", + "Z_MIN_LEVEL": "number", + "Z_MIN_MEMLEVEL": "number", + "Z_MIN_WINDOWBITS": "number", + "Z_NEED_DICT": "number", + "Z_NO_COMPRESSION": "number", + "Z_NO_FLUSH": "number", + "Z_OK": "number", + "Z_PARTIAL_FLUSH": "number", + "Z_RLE": "number", + "Z_STREAM_END": "number", + "Z_STREAM_ERROR": "number", + "Z_SYNC_FLUSH": "number", + "Z_VERSION_ERROR": "number" + }, + "createBrotliCompress": "function", + "createBrotliDecompress": "function", + "createDeflate": "function", + "createDeflateRaw": "function", + "createGunzip": "function", + "createGzip": "function", + "createInflate": "function", + "createInflateRaw": "function", + "createUnzip": "function", + "deflate": "function", + "deflateRaw": "function", + "deflateRawSync": "function", + "deflateSync": "function", + "gunzip": "function", + "gunzipSync": "function", + "gzip": "function", + "gzipSync": "function", + "inflate": "function", + "inflateRaw": "function", + "inflateRawSync": "function", + "inflateSync": "function", + "unzip": "function", + "unzipSync": "function" + } + }, + "runtime": "node", + "version": "v20.1.0", + "errors": {} +} \ No newline at end of file -- cgit v1.2.3 From 7ba4ae11c966e72757a479d594f333fbe6162d0e Mon Sep 17 00:00:00 2001 From: Revenity Date: Wed, 28 Jun 2023 02:37:57 +0700 Subject: Update Stric page in Ecosystem (#3399) --- docs/ecosystem/stric.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/ecosystem/stric.md b/docs/ecosystem/stric.md index b6b93725c..5f2787d75 100644 --- a/docs/ecosystem/stric.md +++ b/docs/ecosystem/stric.md @@ -1,20 +1,20 @@ [Stric](https://github.com/bunsvr) is a minimalist, fast web framework for Bun. ```ts#index.ts -import { App } from "@stricjs/core"; +import { Router } from '@stricjs/router'; // Export the fetch handler and serve with Bun -export default new App() - // Return "Hi!" on every request - .use(() => new Response("Hi!")); +export default new Router() + // Return 'Hi' on every request + .get('/', () => new Response('Hi')); ``` -Stric provides support for [ArrowJS](https://www.arrow-js.com), a library for building reactive interfaces in **native** JavaScript. +Stric provides support for [ArrowJS](https://www.arrow-js.com), a library for building reactive interfaces. {% codetabs %} ```ts#src/App.ts -import { html } from "@stricjs/arrow/utils"; +import { html } from '@stricjs/arrow/utils'; // Code inside this function can use web APIs export function render() { @@ -23,10 +23,10 @@ export function render() { }; // Set the path to handle -export const path = "/"; +export const path = '/'; ``` ```ts#index.ts -import { PageRouter } from "@stricjs/arrow"; +import { PageRouter } from '@stricjs/arrow'; // Create a page router, build and serve directly new PageRouter().serve(); -- cgit v1.2.3 From c78aa5a60fa9c9b1cf31fb3766ffe51e9aba4f6e Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Tue, 27 Jun 2023 13:23:01 -0700 Subject: fix macros --- src/js_ast.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js_ast.zig b/src/js_ast.zig index bd06ca6dc..bcd140495 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -10052,7 +10052,7 @@ pub const Macro = struct { } }; - return CallData.callWrapper(.{ + return CallData.callWrapper(CallArgs{ macro, log, allocator, -- cgit v1.2.3 From 4f34d48029772676b6c0ea6656b0aac74ac3b39f Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 27 Jun 2023 13:42:25 -0700 Subject: getIfPropertyExists is safer than getDirect (#3391) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/JSReadableState.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/bun.js/bindings/JSReadableState.cpp b/src/bun.js/bindings/JSReadableState.cpp index d09e30d44..2137e65d5 100644 --- a/src/bun.js/bindings/JSReadableState.cpp +++ b/src/bun.js/bindings/JSReadableState.cpp @@ -26,7 +26,7 @@ int64_t getHighWaterMark(JSC::VM& vm, JSC::JSGlobalObject* globalObject, bool is auto* clientData = WebCore::clientData(vm); if (JSValue highWaterMarkVal = options->getIfPropertyExists(globalObject, clientData->builtinNames().highWaterMarkPublicName())) { if (isDuplex && (highWaterMarkVal.isUndefined() || highWaterMarkVal.isNull())) { - highWaterMarkVal = options->getDirect(vm, JSC::Identifier::fromString(vm, "readableObjectMode"_s)); + highWaterMarkVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "readableObjectMode"_s)); } if (!highWaterMarkVal.isUndefinedOrNull()) { @@ -42,9 +42,9 @@ void JSReadableState::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObj Base::finishCreation(vm); if (options != nullptr) { - JSC::JSValue objectModeVal = options->getDirect(vm, JSC::Identifier::fromString(vm, "objectMode"_s)); + JSC::JSValue objectModeVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "objectMode"_s)); if (isDuplex && !objectModeVal) { - objectModeVal = options->getDirect(vm, JSC::Identifier::fromString(vm, "readableObjectMode"_s)); + objectModeVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "readableObjectMode"_s)); } if (objectModeVal && objectModeVal.toBoolean(globalObject)) setBool(JSReadableState::Mask::objectMode, true); @@ -65,11 +65,11 @@ void JSReadableState::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObj m_pipes.set(vm, this, JSC::constructEmptyArray(globalObject, nullptr, 0)); if (options != nullptr) { - JSC::JSValue emitCloseVal = options->getDirect(vm, JSC::Identifier::fromString(vm, "emitClose"_s)); + JSC::JSValue emitCloseVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "emitClose"_s)); if (!emitCloseVal.isBoolean() || emitCloseVal.toBoolean(globalObject)) setBool(JSReadableState::Mask::emitClose, true); // Has it been destroyed. - JSC::JSValue autoDestroyVal = options->getDirect(vm, JSC::Identifier::fromString(vm, "autoDestroy"_s)); + JSC::JSValue autoDestroyVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "autoDestroy"_s)); if (!autoDestroyVal.isBoolean() || autoDestroyVal.toBoolean(globalObject)) setBool(JSReadableState::Mask::autoDestroy, true); } @@ -90,26 +90,25 @@ void JSReadableState::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObj } m_awaitDrainWriters.set(vm, this, JSC::jsNull()); + JSValue decodeValue = JSC::jsNull(); + JSValue encodingValue = JSC::jsNull(); - if (options == nullptr) { - m_decoder.set(vm, this, JSC::jsNull()); - m_encoding.set(vm, this, JSC::jsNull()); - } else { - JSC::JSValue encodingVal = options->getDirect(vm, JSC::Identifier::fromString(vm, "encoding"_s)); + if (options != nullptr) { + JSC::JSValue encodingVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "encoding"_s)); if (encodingVal && encodingVal.isString()) { auto constructor = reinterpret_cast(globalObject)->JSStringDecoder(); auto constructData = JSC::getConstructData(constructor); MarkedArgumentBuffer args; args.append(encodingVal); JSObject* decoder = JSC::construct(globalObject, constructor, constructData, args); - m_decoder.set(vm, this, decoder); - m_encoding.set(vm, this, encodingVal); - } else { - m_decoder.set(vm, this, JSC::jsNull()); - m_encoding.set(vm, this, JSC::jsNull()); + decodeValue = decoder; + encodingValue = encodingVal; } } + m_decoder.set(vm, this, decodeValue); + m_encoding.set(vm, this, encodingValue); + // ReadableState.constructed is set to false during construction when a _construct method is implemented // this is here so that the ReadableState behavior tracks the behavior in node, and that calling Readable.read // will work when we return early from construct because there is no Readable._construct implemented @@ -403,10 +402,12 @@ JSC::EncodedJSValue JSReadableStateConstructor::construct(JSC::JSGlobalObject* l return JSValue::encode(jsUndefined()); } isDuplex = isDuplexVal.toBoolean(lexicalGlobalObject); + RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); JSObject* options = nullptr; - if (optionsVal.toBoolean(lexicalGlobalObject) && optionsVal.isObject()) { + if (optionsVal && optionsVal.isObject()) { options = optionsVal.toObject(lexicalGlobalObject); } + RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); JSReadableState* stringDecoder = JSReadableState::create( vm, lexicalGlobalObject, reinterpret_cast(lexicalGlobalObject)->JSReadableStateStructure(), isDuplex, options); -- cgit v1.2.3 From 28d7507a5da07591395c4b66b091ac6b5e3655a0 Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Tue, 27 Jun 2023 14:55:13 -0700 Subject: add todo comment --- src/js_ast.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js_ast.zig b/src/js_ast.zig index bcd140495..9ec14e158 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -10052,6 +10052,8 @@ pub const Macro = struct { } }; + // TODO: can change back to `return CallData.callWrapper(.{` + // when https://github.com/ziglang/zig/issues/16242 is fixed return CallData.callWrapper(CallArgs{ macro, log, -- cgit v1.2.3 From 940c9a8185cb0c27e03e804b7bdd01cf5a91ec3e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 27 Jun 2023 16:16:35 -0700 Subject: Fix some checks --- src/bun.js/bindings/JSReadableState.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bun.js/bindings/JSReadableState.cpp b/src/bun.js/bindings/JSReadableState.cpp index 2137e65d5..8a4ee746b 100644 --- a/src/bun.js/bindings/JSReadableState.cpp +++ b/src/bun.js/bindings/JSReadableState.cpp @@ -29,7 +29,7 @@ int64_t getHighWaterMark(JSC::VM& vm, JSC::JSGlobalObject* globalObject, bool is highWaterMarkVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "readableObjectMode"_s)); } - if (!highWaterMarkVal.isUndefinedOrNull()) { + if (highWaterMarkVal && !highWaterMarkVal.isUndefinedOrNull()) { return highWaterMarkVal.toInt32(globalObject); } } @@ -66,11 +66,11 @@ void JSReadableState::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObj if (options != nullptr) { JSC::JSValue emitCloseVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "emitClose"_s)); - if (!emitCloseVal.isBoolean() || emitCloseVal.toBoolean(globalObject)) + if (!emitCloseVal || emitCloseVal.toBoolean(globalObject)) setBool(JSReadableState::Mask::emitClose, true); // Has it been destroyed. JSC::JSValue autoDestroyVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "autoDestroy"_s)); - if (!autoDestroyVal.isBoolean() || autoDestroyVal.toBoolean(globalObject)) + if (!autoDestroyVal || autoDestroyVal.toBoolean(globalObject)) setBool(JSReadableState::Mask::autoDestroy, true); } -- cgit v1.2.3 From f81d084f5cef287d7fb94798219c2c0d95cb4a4f Mon Sep 17 00:00:00 2001 From: Benjamin Ryan Date: Tue, 27 Jun 2023 19:27:06 -0500 Subject: [bun:sqlite] enable FTS5 on linux build (#3431) * [bun:sqlite] enable FTS5 on linux build * prettier --- Makefile | 2 +- test/js/bun/sqlite/sqlite.test.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 18e229903..b023dc53c 100644 --- a/Makefile +++ b/Makefile @@ -1694,7 +1694,7 @@ sizegen: # Linux uses bundled SQLite3 ifeq ($(OS_NAME),linux) sqlite: - $(CC) $(EMIT_LLVM_FOR_RELEASE) $(CFLAGS) $(INCLUDE_DIRS) -DSQLITE_ENABLE_COLUMN_METADATA= -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_JSON1=1 $(SRC_DIR)/sqlite/sqlite3.c -c -o $(SQLITE_OBJECT) + $(CC) $(EMIT_LLVM_FOR_RELEASE) $(CFLAGS) $(INCLUDE_DIRS) -DSQLITE_ENABLE_COLUMN_METADATA= -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 $(SRC_DIR)/sqlite/sqlite3.c -c -o $(SQLITE_OBJECT) endif picohttp: diff --git a/test/js/bun/sqlite/sqlite.test.js b/test/js/bun/sqlite/sqlite.test.js index faa7d5015..e4725cac2 100644 --- a/test/js/bun/sqlite/sqlite.test.js +++ b/test/js/bun/sqlite/sqlite.test.js @@ -513,6 +513,24 @@ it("latin1 supplement chars", () => { expect(db.query("SELECT * FROM foo WHERE id > 9999").values()).toEqual([]); }); +it("supports FTS5", () => { + const db = new Database(); + db.run("CREATE VIRTUAL TABLE movies USING fts5(title, tokenize='trigram')"); + const insert = db.prepare("INSERT INTO movies VALUES ($title)"); + const insertMovies = db.transaction(movies => { + for (const movie of movies) insert.run(movie); + }); + insertMovies([ + { $title: "The Shawshank Redemption" }, + { $title: "WarGames" }, + { $title: "Interstellar" }, + { $title: "Se7en" }, + { $title: "City of God" }, + { $title: "Spirited Away" }, + ]); + expect(db.query("SELECT * FROM movies('game')").all()).toEqual([{ title: "WarGames" }]); +}); + describe("Database.run", () => { it("should not throw error `not an error` when provided query containing only whitespace", () => { const db = Database.open(":memory:"); -- cgit v1.2.3 From 09994d6067a2df1095a29619ecdbb56ae10b0974 Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Tue, 27 Jun 2023 17:34:31 -0700 Subject: add `__esModule` --- src/js/builtins/Module.ts | 6 +- src/js/out/WebCoreJSBuiltins.cpp | 230 +++++++++++++++++++-------------------- 2 files changed, 119 insertions(+), 117 deletions(-) diff --git a/src/js/builtins/Module.ts b/src/js/builtins/Module.ts index 7ef108258..6a0b70a37 100644 --- a/src/js/builtins/Module.ts +++ b/src/js/builtins/Module.ts @@ -44,7 +44,9 @@ export function require(this: Module, id: string) { const mod = esm.module; const namespace = Loader.getModuleNamespaceObject(mod); const exports = - namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0 ? namespace.default : namespace; + namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0 + ? namespace.default + : Object.create(namespace, { __esModule: { value: true } }); $requireMap.$set(id, $createCommonJSModule(id, exports, true)); return exports; } @@ -81,7 +83,7 @@ export function require(this: Module, id: string) { // if they choose a module namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0 ? namespace.default - : namespace); + : Object.create(namespace, { __esModule: { value: true } })); } } diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index d1250f0b9..d5c0e4d1b 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -108,7 +108,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeCons const JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateWritableStreamCodeLength = 278; static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (u,p,d,N,_,f){\"use strict\";@assert(typeof _===\"number\"&&!@isNaN(_)&&_>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,p,d,N,_,f),@createWritableStreamFromInternal(j)})\n"; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (d,_,u,N,f,p){\"use strict\";@assert(typeof f===\"number\"&&!@isNaN(f)&&f>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,d,_,u,N,f,p),@createWritableStreamFromInternal(j)})\n"; // createInternalWritableStreamFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -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 (f,w){\"use strict\";const o={};if(f===@undefined)f={};if(w===@undefined)w={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const C=@extractSizeAlgorithm(w),E=@extractHighWaterMark(w,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(o,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(o,f,_,E,C),o})\n"; +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"; // 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,h){\"use strict\";if(@isWritableStreamLocked(h))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(n,\"stream\",h),@putByIdDirectPrivate(h,\"writer\",n);const v=@newPromiseCapability(@Promise),B=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"readyPromise\",v),@putByIdDirectPrivate(n,\"closedPromise\",B);const _=@getByIdDirectPrivate(h,\"state\");if(_===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(h)||!@getByIdDirectPrivate(h,\"backpressure\"))v.@resolve.@call()}else if(_===\"erroring\")v.@reject.@call(@undefined,@getByIdDirectPrivate(h,\"storedError\")),@markPromiseAsHandled(v.@promise);else if(_===\"closed\")v.@resolve.@call(),B.@resolve.@call();else{@assert(_===\"errored\");const g=@getByIdDirectPrivate(h,\"storedError\");v.@reject.@call(@undefined,g),@markPromiseAsHandled(v.@promise),B.@reject.@call(@undefined,g),@markPromiseAsHandled(B.@promise)}})\n"; +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"; // 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 f=@getByIdDirectPrivate(c,\"state\");if(f===\"closed\"||f===\"errored\")return @Promise.@resolve();const B=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(B!==@undefined)return B.promise.@promise;@assert(f===\"writable\"||f===\"erroring\");let j=!1;if(f===\"erroring\")j=!0,h=@undefined;const _=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:_,reason:h,wasAlreadyErroring:j}),!j)@writableStreamStartErroring(c,h);return _.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (c,B){\"use strict\";const h=@getByIdDirectPrivate(c,\"state\");if(h===\"closed\"||h===\"errored\")return @Promise.@resolve();const _=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(_!==@undefined)return _.promise.@promise;@assert(h===\"writable\"||h===\"erroring\");let f=!1;if(h===\"erroring\")f=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:f}),!f)@writableStreamStartErroring(c,B);return j.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = 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\"),i=@getByIdDirectPrivate(_,\"writeRequests\");for(var A=i.shift();A;A=i.shift())A.@reject.@call(@undefined,h);@putByIdDirectPrivate(_,\"writeRequests\",@createFIFO());const B=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(B===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}if(@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined),B.wasAlreadyErroring){B.promise.@reject.@call(@undefined,h),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}@getByIdDirectPrivate(p,\"abortSteps\").@call(@undefined,B.reason).@then(()=>{B.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)},(I)=>{B.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; +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 I=A.shift();I;I=A.shift())I.@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(_)},(B)=>{i.promise.@reject.@call(@undefined,B),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const c=@getByIdDirectPrivate(d,\"writer\");if(c!==@undefined)@getByIdDirectPrivate(c,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -220,7 +220,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength = 488; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,c){\"use strict\";const n=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(n!==@undefined),n.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const d=@getByIdDirectPrivate(_,\"state\");@assert(d===\"writable\"||d===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,c)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,c){\"use strict\";const d=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(d!==@undefined),d.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(_,\"state\");@assert(n===\"writable\"||n===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,c)})\n"; // writableStreamFinishInFlightWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -260,7 +260,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWrite const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength = 240; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (d){\"use strict\";const c=@getByIdDirectPrivate(d,\"writeRequests\");@assert(@getByIdDirectPrivate(d,\"inFlightWriteRequest\")===@undefined),@assert(c.isNotEmpty());const h=c.shift();@putByIdDirectPrivate(d,\"inFlightWriteRequest\",h)})\n"; +const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"writeRequests\");@assert(@getByIdDirectPrivate(c,\"inFlightWriteRequest\")===@undefined),@assert(d.isNotEmpty());const h=d.shift();@putByIdDirectPrivate(c,\"inFlightWriteRequest\",h)})\n"; // writableStreamRejectCloseAndClosedPromiseIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -268,7 +268,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAnd const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 516; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (h){\"use strict\";@assert(@getByIdDirectPrivate(h,\"state\")===\"errored\");const i=@getByIdDirectPrivate(h,\"storedError\"),n=@getByIdDirectPrivate(h,\"closeRequest\");if(n!==@undefined)@assert(@getByIdDirectPrivate(h,\"inFlightCloseRequest\")===@undefined),n.@reject.@call(@undefined,i),@putByIdDirectPrivate(h,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(h,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,i),@markPromiseAsHandled(b.@promise)}})\n"; +const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const h=@getByIdDirectPrivate(i,\"storedError\"),n=@getByIdDirectPrivate(i,\"closeRequest\");if(n!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),n.@reject.@call(@undefined,h),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(i,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,h),@markPromiseAsHandled(b.@promise)}})\n"; // writableStreamStartErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -276,7 +276,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamStartErroringC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamStartErroringCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamStartErroringCodeLength = 544; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamStartErroringCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamStartErroringCode = "(function (i,_){\"use strict\";@assert(@getByIdDirectPrivate(i,\"storedError\")===@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\");const h=@getByIdDirectPrivate(i,\"controller\");@assert(h!==@undefined),@putByIdDirectPrivate(i,\"state\",\"erroring\"),@putByIdDirectPrivate(i,\"storedError\",_);const d=@getByIdDirectPrivate(i,\"writer\");if(d!==@undefined)@writableStreamDefaultWriterEnsureReadyPromiseRejected(d,_);if(!@writableStreamHasOperationMarkedInFlight(i)&&@getByIdDirectPrivate(h,\"started\")===1)@writableStreamFinishErroring(i)})\n"; +const char* const s_writableStreamInternalsWritableStreamStartErroringCode = "(function (i,_){\"use strict\";@assert(@getByIdDirectPrivate(i,\"storedError\")===@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\");const d=@getByIdDirectPrivate(i,\"controller\");@assert(d!==@undefined),@putByIdDirectPrivate(i,\"state\",\"erroring\"),@putByIdDirectPrivate(i,\"storedError\",_);const h=@getByIdDirectPrivate(i,\"writer\");if(h!==@undefined)@writableStreamDefaultWriterEnsureReadyPromiseRejected(h,_);if(!@writableStreamHasOperationMarkedInFlight(i)&&@getByIdDirectPrivate(d,\"started\")===1)@writableStreamFinishErroring(i)})\n"; // writableStreamUpdateBackpressure const JSC::ConstructAbility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -324,7 +324,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 327; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (c,n){\"use strict\";let g=@getByIdDirectPrivate(c,\"readyPromise\"),h=g.@promise;if((@getPromiseInternalField(h,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)g=@newPromiseCapability(@Promise),h=g.@promise,@putByIdDirectPrivate(c,\"readyPromise\",g);g.@reject.@call(@undefined,n),@markPromiseAsHandled(h)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (c,g){\"use strict\";let h=@getByIdDirectPrivate(c,\"readyPromise\"),n=h.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),n=h.@promise,@putByIdDirectPrivate(c,\"readyPromise\",h);h.@reject.@call(@undefined,g),@markPromiseAsHandled(n)})\n"; // writableStreamDefaultWriterGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = 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 (d,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const _=@getByIdDirectPrivate(P,\"controller\");@assert(_!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(_,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const W=@getByIdDirectPrivate(P,\"state\");if(W===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||W===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||W===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(W===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(W===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(_,g,b),f})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (d,P){\"use strict\";const g=@getByIdDirectPrivate(d,\"stream\");@assert(g!==@undefined);const W=@getByIdDirectPrivate(g,\"controller\");@assert(W!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(W,P);if(g!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const _=@getByIdDirectPrivate(g,\"state\");if(_===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(g,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(g)||_===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(g)||_===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(_===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(g,\"storedError\"));@assert(_===\"writable\");const f=@writableStreamAddWriteRequest(g);return @writableStreamDefaultControllerWrite(W,P,b),f})\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 (_,U,d,f,B,j,v,q){\"use strict\";@assert(@isWritableStream(_)),@assert(@getByIdDirectPrivate(_,\"controller\")===@undefined),@putByIdDirectPrivate(U,\"stream\",_),@putByIdDirectPrivate(_,\"controller\",U),@resetQueue(@getByIdDirectPrivate(U,\"queue\")),@putByIdDirectPrivate(U,\"started\",-1),@putByIdDirectPrivate(U,\"startAlgorithm\",d),@putByIdDirectPrivate(U,\"strategySizeAlgorithm\",q),@putByIdDirectPrivate(U,\"strategyHWM\",v),@putByIdDirectPrivate(U,\"writeAlgorithm\",f),@putByIdDirectPrivate(U,\"closeAlgorithm\",B),@putByIdDirectPrivate(U,\"abortAlgorithm\",j);const P=@writableStreamDefaultControllerGetBackpressure(U);@writableStreamUpdateBackpressure(_,P),@writableStreamDefaultControllerStart(U)})\n"; +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"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -364,7 +364,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 647; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (p){\"use strict\";if(@getByIdDirectPrivate(p,\"started\")!==-1)return;@putByIdDirectPrivate(p,\"started\",0);const i=@getByIdDirectPrivate(p,\"startAlgorithm\");@putByIdDirectPrivate(p,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(p,\"stream\");return @Promise.@resolve(i.@call()).@then(()=>{const _=@getByIdDirectPrivate(d,\"state\");@assert(_===\"writable\"||_===\"erroring\"),@putByIdDirectPrivate(p,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(p)},(_)=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(p,\"started\",1),@writableStreamDealWithRejection(d,_)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const _=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(_.@call()).@then(()=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(d,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,u)})})\n"; // setUpWritableStreamDefaultControllerFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 573; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (P,j,B,v,f){\"use strict\";const _=new @WritableStreamDefaultController;let C=()=>{},p=()=>{return @Promise.@resolve()},E=()=>{return @Promise.@resolve()},q=()=>{return @Promise.@resolve()};if(\"start\"in B){const F=B[\"start\"];C=()=>@promiseInvokeOrNoopMethodNoCatch(j,F,[_])}if(\"write\"in B){const F=B[\"write\"];p=(x)=>@promiseInvokeOrNoopMethod(j,F,[x,_])}if(\"close\"in B){const F=B[\"close\"];E=()=>@promiseInvokeOrNoopMethod(j,F,[])}if(\"abort\"in B){const F=B[\"abort\"];q=(x)=>@promiseInvokeOrNoopMethod(j,F,[x])}@setUpWritableStreamDefaultController(P,_,C,p,E,q,v,f)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (P,f,v,j,E){\"use strict\";const p=new @WritableStreamDefaultController;let B=()=>{},q=()=>{return @Promise.@resolve()},_=()=>{return @Promise.@resolve()},F=()=>{return @Promise.@resolve()};if(\"start\"in v){const C=v[\"start\"];B=()=>@promiseInvokeOrNoopMethodNoCatch(f,C,[p])}if(\"write\"in v){const C=v[\"write\"];q=(x)=>@promiseInvokeOrNoopMethod(f,C,[x,p])}if(\"close\"in v){const C=v[\"close\"];_=()=>@promiseInvokeOrNoopMethod(f,C,[])}if(\"abort\"in v){const C=v[\"abort\"];F=(x)=>@promiseInvokeOrNoopMethod(f,C,[x])}@setUpWritableStreamDefaultController(P,p,B,q,_,F,j,E)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -380,7 +380,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength = 582; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (_){\"use strict\";const i=@getByIdDirectPrivate(_,\"stream\");if(@getByIdDirectPrivate(_,\"started\")!==1)return;if(@assert(i!==@undefined),@getByIdDirectPrivate(i,\"inFlightWriteRequest\")!==@undefined)return;const d=@getByIdDirectPrivate(i,\"state\");if(@assert(d!==\"closed\"||d!==\"errored\"),d===\"erroring\"){@writableStreamFinishErroring(i);return}const f=@getByIdDirectPrivate(_,\"queue\");if(f.content\?.isEmpty()\?\?!1)return;const h=@peekQueueValue(f);if(h===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(_);else @writableStreamDefaultControllerProcessWrite(_,h)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"stream\");if(@getByIdDirectPrivate(_,\"started\")!==1)return;if(@assert(d!==@undefined),@getByIdDirectPrivate(d,\"inFlightWriteRequest\")!==@undefined)return;const f=@getByIdDirectPrivate(d,\"state\");if(@assert(f!==\"closed\"||f!==\"errored\"),f===\"erroring\"){@writableStreamFinishErroring(d);return}const h=@getByIdDirectPrivate(_,\"queue\");if(h.content\?.isEmpty()\?\?!1)return;const i=@peekQueueValue(h);if(i===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(_);else @writableStreamDefaultControllerProcessWrite(_,i)})\n"; // isCloseSentinel const JSC::ConstructAbility s_writableStreamInternalsIsCloseSentinelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -428,7 +428,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength = 89; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode = "(function (d){\"use strict\";return @writableStreamDefaultControllerGetDesiredSize(d)<=0})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode = "(function (e){\"use strict\";return @writableStreamDefaultControllerGetDesiredSize(e)<=0})\n"; // writableStreamDefaultControllerGetChunkSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -436,7 +436,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength = 181; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode = "(function (a,d){\"use strict\";try{return @getByIdDirectPrivate(a,\"strategySizeAlgorithm\").@call(@undefined,d)}catch(i){return @writableStreamDefaultControllerErrorIfNeeded(a,i),1}})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode = "(function (a,i){\"use strict\";try{return @getByIdDirectPrivate(a,\"strategySizeAlgorithm\").@call(@undefined,i)}catch(d){return @writableStreamDefaultControllerErrorIfNeeded(a,d),1}})\n"; // writableStreamDefaultControllerGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructAbility = 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,q){\"use strict\";const d=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(d),@getByIdDirectPrivate(i,\"writeAlgorithm\").@call(@undefined,q).@then(()=>{@writableStreamFinishInFlightWrite(d);const M=@getByIdDirectPrivate(d,\"state\");if(@assert(M===\"writable\"||M===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),!@writableStreamCloseQueuedOrInFlight(d)&&M===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(i);@writableStreamUpdateBackpressure(d,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(M)=>{if(@getByIdDirectPrivate(d,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(i);@writableStreamFinishInFlightWriteWithError(d,M)})})\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 (d,D,y){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),D,y);const B=@getByIdDirectPrivate(d,\"stream\"),_=@getByIdDirectPrivate(B,\"state\");if(!@writableStreamCloseQueuedOrInFlight(B)&&_===\"writable\"){const I=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(B,I)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)}catch(B){@writableStreamDefaultControllerErrorIfNeeded(d,B)}})\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 (I,G,v,_,E,B,D){\"use strict\";if(_===@undefined)_=1;if(E===@undefined)E=()=>1;if(B===@undefined)B=0;if(D===@undefined)D=()=>1;@assert(_>=0),@assert(B>=0);const q={};@putByIdDirectPrivate(q,\"TransformStream\",!0);const F=new @TransformStream(q),j=@newPromiseCapability(@Promise);@initializeTransformStream(F,j.@promise,_,E,B,D);const x=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(F,x,G,v),I().@then(()=>{j.@resolve.@call()},(c)=>{j.@reject.@call(@undefined,c)}),F})\n"; +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"; // 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,E,j,F,f){\"use strict\";const G=()=>{return T},q=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(B,N)},I=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(B,N)},v=()=>{return @transformStreamDefaultSinkCloseAlgorithm(B)},J=@createWritableStream(G,q,v,I,E,j),x=()=>{return @transformStreamDefaultSourcePullAlgorithm(B)},K=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(B,N),@Promise.@resolve()},C={};@putByIdDirectPrivate(C,\"start\",G),@putByIdDirectPrivate(C,\"pull\",x),@putByIdDirectPrivate(C,\"cancel\",K);const L={};@putByIdDirectPrivate(L,\"size\",f),@putByIdDirectPrivate(L,\"highWaterMark\",F);const D=new @ReadableStream(C,L);@putByIdDirectPrivate(B,\"writable\",J),@putByIdDirectPrivate(B,\"internalWritable\",@getInternalWritableStream(J)),@putByIdDirectPrivate(B,\"readable\",D),@putByIdDirectPrivate(B,\"backpressure\",@undefined),@putByIdDirectPrivate(B,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(B,!0),@putByIdDirectPrivate(B,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (T,j,v,C,D,E){\"use strict\";const F=()=>{return j},G=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(T,N)},I=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(T,N)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(T)},f=@createWritableStream(F,G,J,I,v,C),B=()=>{return @transformStreamDefaultSourcePullAlgorithm(T)},q=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(T,N),@Promise.@resolve()},x={};@putByIdDirectPrivate(x,\"start\",F),@putByIdDirectPrivate(x,\"pull\",B),@putByIdDirectPrivate(x,\"cancel\",q);const K={};@putByIdDirectPrivate(K,\"size\",E),@putByIdDirectPrivate(K,\"highWaterMark\",D);const L=new @ReadableStream(x,K);@putByIdDirectPrivate(T,\"writable\",f),@putByIdDirectPrivate(T,\"internalWritable\",@getInternalWritableStream(f)),@putByIdDirectPrivate(T,\"readable\",L),@putByIdDirectPrivate(T,\"backpressure\",@undefined),@putByIdDirectPrivate(T,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(T,!0),@putByIdDirectPrivate(T,\"controller\",@undefined)})\n"; // transformStreamError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -518,7 +518,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeCon const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorCodeLength = 222; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (_,i){\"use strict\";const n=@getByIdDirectPrivate(_,\"readable\"),f=@getByIdDirectPrivate(n,\"readableStreamController\");@readableStreamDefaultControllerError(f,i),@transformStreamErrorWritableAndUnblockWrite(_,i)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (f,i){\"use strict\";const n=@getByIdDirectPrivate(f,\"readable\"),_=@getByIdDirectPrivate(n,\"readableStreamController\");@readableStreamDefaultControllerError(_,i),@transformStreamErrorWritableAndUnblockWrite(f,i)})\n"; // transformStreamErrorWritableAndUnblockWrite const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -526,7 +526,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritabl const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength = 339; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (n,_){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(n,\"controller\"));const o=@getByIdDirectPrivate(n,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(o,\"controller\"),_),@getByIdDirectPrivate(n,\"backpressure\"))@transformStreamSetBackpressure(n,!1)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (_,n){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(_,\"controller\"));const o=@getByIdDirectPrivate(_,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(o,\"controller\"),n),@getByIdDirectPrivate(_,\"backpressure\"))@transformStreamSetBackpressure(_,!1)})\n"; // transformStreamSetBackpressure const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility = 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,b,_,P){\"use strict\";@assert(@isTransformStream(d)),@assert(@getByIdDirectPrivate(d,\"controller\")===@undefined),@putByIdDirectPrivate(b,\"stream\",d),@putByIdDirectPrivate(d,\"controller\",b),@putByIdDirectPrivate(b,\"transformAlgorithm\",_),@putByIdDirectPrivate(b,\"flushAlgorithm\",P)})\n"; +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"; // setUpTransformStreamDefaultControllerFromTransformer const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 449; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,j,d){\"use strict\";const q=new @TransformStreamDefaultController;let p=(b)=>{try{@transformStreamDefaultControllerEnqueue(q,b)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},v=()=>{return @Promise.@resolve()};if(\"transform\"in d)p=(b)=>{return @promiseInvokeOrNoopMethod(j,d[\"transform\"],[b,q])};if(\"flush\"in d)v=()=>{return @promiseInvokeOrNoopMethod(j,d[\"flush\"],[q])};@setUpTransformStreamDefaultController(_,q,p,v)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (d,p,v){\"use strict\";const b=new @TransformStreamDefaultController;let q=(j)=>{try{@transformStreamDefaultControllerEnqueue(b,j)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},_=()=>{return @Promise.@resolve()};if(\"transform\"in v)q=(j)=>{return @promiseInvokeOrNoopMethod(p,v[\"transform\"],[j,b])};if(\"flush\"in v)_=()=>{return @promiseInvokeOrNoopMethod(p,v[\"flush\"],[b])};@setUpTransformStreamDefaultController(d,b,q,_)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = 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 (W,i){\"use strict\";const f=@getByIdDirectPrivate(W,\"stream\"),_=@getByIdDirectPrivate(f,\"readable\"),j=@getByIdDirectPrivate(_,\"readableStreamController\");if(@assert(j!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(j))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(j,i)}catch(S){throw @transformStreamErrorWritableAndUnblockWrite(f,S),@getByIdDirectPrivate(_,\"storedError\")}const g=!@readableStreamDefaultControllerShouldCallPull(j);if(g!==@getByIdDirectPrivate(f,\"backpressure\"))@assert(g),@transformStreamSetBackpressure(f,!0)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (_,S){\"use strict\";const W=@getByIdDirectPrivate(_,\"stream\"),f=@getByIdDirectPrivate(W,\"readable\"),g=@getByIdDirectPrivate(f,\"readableStreamController\");if(@assert(g!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(g))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(g,S)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(W,j),@getByIdDirectPrivate(f,\"storedError\")}const i=!@readableStreamDefaultControllerShouldCallPull(g);if(i!==@getByIdDirectPrivate(W,\"backpressure\"))@assert(i),@transformStreamSetBackpressure(W,!0)})\n"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,g){\"use strict\";const d=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,g).@then(()=>{d.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),d.@reject.@call(@undefined,j)}),d.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -590,7 +590,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 367; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const f=@getByIdDirectPrivate(i,\"stream\"),k=@getByIdDirectPrivate(f,\"readable\"),u=@getByIdDirectPrivate(k,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(u))@readableStreamDefaultControllerClose(u);const _=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(f,_)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\"),f=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(f,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(_,u)})\n"; // transformStreamDefaultSinkWriteAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = 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 (u){\"use strict\";const j=@getByIdDirectPrivate(u,\"readable\"),f=@getByIdDirectPrivate(u,\"controller\"),I=@getByIdDirectPrivate(j,\"readableStreamController\"),q=@getByIdDirectPrivate(f,\"flushAlgorithm\");@assert(q!==@undefined);const _=@getByIdDirectPrivate(f,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(f);const k=@newPromiseCapability(@Promise);return _.@then(()=>{if(@getByIdDirectPrivate(j,\"state\")===@streamErrored){k.@reject.@call(@undefined,@getByIdDirectPrivate(j,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(I))@readableStreamDefaultControllerClose(I);k.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(f,\"stream\"),v),k.@reject.@call(@undefined,@getByIdDirectPrivate(j,\"storedError\"))}),k.@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; @@ -640,7 +640,7 @@ const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsBindingCodeLength = 473; static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsBindingCode = "(function (I){\"use strict\";if(I!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var d=globalThis.Symbol.for(\"process.bindings.constants\"),r=globalThis[d];if(!r){const{constants:l}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");r={fs:l,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[d]=r}return r})\n"; +const char* const s_processObjectInternalsBindingCode = "(function (l){\"use strict\";if(l!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var r=globalThis.Symbol.for(\"process.bindings.constants\"),I=globalThis[r];if(!I){const{constants:d}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");I={fs:d,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[r]=I}return I})\n"; // getStdioWriteStream const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (U,G){\"use strict\";var H={path:\"node:process\",require:G},J=(L)=>H.require(L);function K(L){var{Duplex:Q,eos:M,destroy:j}=J(\"node:stream\"),N=class Y extends Q{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=J(\"node:tty\").isatty(L)}get fd(){return L}constructor(O){super({readable:!0,writable:!0});this.#G=`/dev/fd/${O}`}#N(O){const z=this.#H;if(this.#H=null,z)z(O);else if(O)this.destroy(O);else if(!this.#j&&!this.#z)this.destroy()}_destroy(O,z){if(!O&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};O=new P}if(this.#J=null,this.#K=null,this.#H===null)z(O);else{if(this.#H=z,this.#$)j(this.#$,O);if(this.#B)j(this.#B,O)}}_write(O,z,P){if(!this.#$){var{createWriteStream:A}=J(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),M(T,(x)=>{if(this.#z=!1,x)j(T,x);this.#N(x)})}if(T.write(O,z))P();else this.#J=P}_final(O){this.#$&&this.#$.end(),this.#K=O}#O(){var{createReadStream:O}=J(\"node:fs\"),z=this.#B=O(this.#G);return z.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),z.on(\"end\",()=>{this.push(null)}),M(z,(P)=>{if(this.#j=!1,P)j(z,P);this.#N(P)}),z}_read(){var O=this.#B;if(!O)O=this.#O();while(!0){const z=O.read();if(z===null||!this.push(z))return}}};return new N(L)}var{EventEmitter:V}=J(\"node:events\");function X(L){if(!L)return!0;var Q=L.toLowerCase();return Q===\"utf8\"||Q===\"utf-8\"||Q===\"buffer\"||Q===\"binary\"}var Z,B=class L extends V{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(Q){if(this.#B||!X(Q))return this.#J(),this.#B.setDefaultEncoding(Q)}#G(){switch(this.#$){case 1:{var Q=@Bun.stdout.writer({highWaterMark:0});return Q.unref(),Q}case 2:{var Q=@Bun.stderr.writer({highWaterMark:0});return Q.unref(),Q}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(Q){super();this.#$=Q}get fd(){return this.#$}get isTTY(){return this.#z\?\?=J(\"node:tty\").isatty(this.#$)}cursorTo(Q,M,j){return(Z\?\?=J(\"readline\")).cursorTo(this,Q,M,j)}moveCursor(Q,M,j){return(Z\?\?=J(\"readline\")).moveCursor(this,Q,M,j)}clearLine(Q,M){return(Z\?\?=J(\"readline\")).clearLine(this,Q,M)}clearScreenDown(Q){return(Z\?\?=J(\"readline\")).clearScreenDown(this,Q)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(Q,M){if(Q===\"close\"||Q===\"finish\")return this.#J(),this.#B.on(Q,M);if(Q===\"drain\")return super.on(\"drain\",M);if(Q===\"error\")return super.on(\"error\",M);return super.on(Q,M)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(Q){return this.#J(),this.#B.pipe(Q)}unpipe(Q){return this.#J(),this.#B.unpipe(Q)}#J(){if(this.#B)return;this.#B=K(this.#$);const Q=this.eventNames();for(let M of Q)this.#B.on(M,(...j)=>{this.emit(M,...j)})}#K(Q){var M=this.#H();const j=M.write(Q);this.bytesWritten+=j;const N=M.flush(!1);return!!(j||N)}#L(Q,M){if(!X(M))return this.#J(),this.#B.write(Q,M);return this.#K(Q)}#M(Q,M){if(M)this.emit(\"error\",M);try{Q(M\?M:null)}catch(j){this.emit(\"error\",j)}}#N(Q,M,j){if(!X(M))return this.#J(),this.#B.write(Q,M,j);var N=this.#H();const Y=N.write(Q),O=N.flush(!0);if(O\?.then)return O.then(()=>{this.#M(j),this.emit(\"drain\")},(z)=>this.#M(j,z)),!1;return queueMicrotask(()=>{this.#M(j)}),!!(Y||O)}write(Q,M,j){const N=this._write(Q,M,j);if(N)this.emit(\"drain\");return N}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(Q,M,j){var N=this.#B;if(N)return N.write(Q,M,j);switch(arguments.length){case 0:{var Y=new Error(\"Invalid arguments\");throw Y.code=\"ERR_INVALID_ARG_TYPE\",Y}case 1:return this.#K(Q);case 2:if(typeof M===\"function\")return this.#N(Q,\"\",M);else if(typeof M===\"string\")return this.#L(Q,M);default:{if(typeof M!==\"undefined\"&&typeof M!==\"string\"||typeof j!==\"undefined\"&&typeof j!==\"function\"){var Y=new Error(\"Invalid arguments\");throw Y.code=\"ERR_INVALID_ARG_TYPE\",Y}if(typeof j===\"undefined\")return this.#L(Q,M);return this.#N(Q,M,j)}}}destroy(){return this}end(){return this}};return new B(U)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (A,M){\"use strict\";var Q={path:\"node:process\",require:M},N=(Z)=>Q.require(Z);function O(Z){var{Duplex:T,eos:x,destroy:Y}=N(\"node:stream\"),G=class j extends T{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=N(\"node:tty\").isatty(Z)}get fd(){return Z}constructor(V){super({readable:!0,writable:!0});this.#G=`/dev/fd/${V}`}#N(V){const L=this.#H;if(this.#H=null,L)L(V);else if(V)this.destroy(V);else if(!this.#j&&!this.#z)this.destroy()}_destroy(V,L){if(!V&&this.#H!==null){var X=class J extends Error{code;name;constructor(H=\"The operation was aborted\",P=void 0){if(P!==void 0&&typeof P!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(P,null,2)}`);super(H,P);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};V=new X}if(this.#J=null,this.#K=null,this.#H===null)L(V);else{if(this.#H=L,this.#$)Y(this.#$,V);if(this.#B)Y(this.#B,V)}}_write(V,L,X){if(!this.#$){var{createWriteStream:J}=N(\"node:fs\"),H=this.#$=J(this.#G);H.on(\"finish\",()=>{if(this.#K){const P=this.#K;this.#K=null,P()}}),H.on(\"drain\",()=>{if(this.#J){const P=this.#J;this.#J=null,P()}}),x(H,(P)=>{if(this.#z=!1,P)Y(H,P);this.#N(P)})}if(H.write(V,L))X();else this.#J=X}_final(V){this.#$&&this.#$.end(),this.#K=V}#O(){var{createReadStream:V}=N(\"node:fs\"),L=this.#B=V(this.#G);return L.on(\"readable\",()=>{if(this.#L){const X=this.#L;this.#L=null,X()}else this.read()}),L.on(\"end\",()=>{this.push(null)}),x(L,(X)=>{if(this.#j=!1,X)Y(L,X);this.#N(X)}),L}_read(){var V=this.#B;if(!V)V=this.#O();while(!0){const L=V.read();if(L===null||!this.push(L))return}}};return new G(Z)}var{EventEmitter:z}=N(\"node:events\");function B(Z){if(!Z)return!0;var T=Z.toLowerCase();return T===\"utf8\"||T===\"utf-8\"||T===\"buffer\"||T===\"binary\"}var U,K=class Z extends z{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(T){if(this.#B||!B(T))return this.#J(),this.#B.setDefaultEncoding(T)}#G(){switch(this.#$){case 1:{var T=@Bun.stdout.writer({highWaterMark:0});return T.unref(),T}case 2:{var T=@Bun.stderr.writer({highWaterMark:0});return T.unref(),T}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(T){super();this.#$=T}get fd(){return this.#$}get isTTY(){return this.#z\?\?=N(\"node:tty\").isatty(this.#$)}cursorTo(T,x,Y){return(U\?\?=N(\"readline\")).cursorTo(this,T,x,Y)}moveCursor(T,x,Y){return(U\?\?=N(\"readline\")).moveCursor(this,T,x,Y)}clearLine(T,x){return(U\?\?=N(\"readline\")).clearLine(this,T,x)}clearScreenDown(T){return(U\?\?=N(\"readline\")).clearScreenDown(this,T)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(T,x){if(T===\"close\"||T===\"finish\")return this.#J(),this.#B.on(T,x);if(T===\"drain\")return super.on(\"drain\",x);if(T===\"error\")return super.on(\"error\",x);return super.on(T,x)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(T){return this.#J(),this.#B.pipe(T)}unpipe(T){return this.#J(),this.#B.unpipe(T)}#J(){if(this.#B)return;this.#B=O(this.#$);const T=this.eventNames();for(let x of T)this.#B.on(x,(...Y)=>{this.emit(x,...Y)})}#K(T){var x=this.#H();const Y=x.write(T);this.bytesWritten+=Y;const G=x.flush(!1);return!!(Y||G)}#L(T,x){if(!B(x))return this.#J(),this.#B.write(T,x);return this.#K(T)}#M(T,x){if(x)this.emit(\"error\",x);try{T(x\?x:null)}catch(Y){this.emit(\"error\",Y)}}#N(T,x,Y){if(!B(x))return this.#J(),this.#B.write(T,x,Y);var G=this.#H();const j=G.write(T),V=G.flush(!0);if(V\?.then)return V.then(()=>{this.#M(Y),this.emit(\"drain\")},(L)=>this.#M(Y,L)),!1;return queueMicrotask(()=>{this.#M(Y)}),!!(j||V)}write(T,x,Y){const G=this._write(T,x,Y);if(G)this.emit(\"drain\");return G}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(T,x,Y){var G=this.#B;if(G)return G.write(T,x,Y);switch(arguments.length){case 0:{var j=new Error(\"Invalid arguments\");throw j.code=\"ERR_INVALID_ARG_TYPE\",j}case 1:return this.#K(T);case 2:if(typeof x===\"function\")return this.#N(T,\"\",x);else if(typeof x===\"string\")return this.#L(T,x);default:{if(typeof x!==\"undefined\"&&typeof x!==\"string\"||typeof Y!==\"undefined\"&&typeof Y!==\"function\"){var j=new Error(\"Invalid arguments\");throw j.code=\"ERR_INVALID_ARG_TYPE\",j}if(typeof Y===\"undefined\")return this.#L(T,x);return this.#N(T,x,Y)}}}destroy(){return this}end(){return this}};return new K(A)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = 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,j,H){\"use strict\";var I={path:\"node:process\",require:j},J=(N)=>I.require(N),{Duplex:K,eos:z,destroy:L}=J(\"node:stream\"),M=class N extends K{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return J(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(P){const Q=this.#J;if(this.#J=null,Q)Q(P);else if(P)this.destroy(P);else if(!this.#z&&!this.#H)this.destroy()}_destroy(P,Q){if(!P&&this.#J!==null){var G=class T extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};P=new G}if(this.#J===null)Q(P);else if(this.#J=Q,this.#j)L(this.#j,P)}setRawMode(P){}on(P,Q){if(P===\"readable\")this.ref(),this.#G=!0;return super.on(P,Q)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#Y\?\?=H.stdin.stream().getReader(),this.#$\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#$)clearInterval(this.#$),this.#$=null}async#M(){try{var P,Q;const G=this.#Y.readMany();if(!G\?.then)({done:P,value:Q}=G);else({done:P,value:Q}=await G);if(!P){this.push(Q[0]);const T=Q.length;for(let U=1;U{if(this.#I){const G=this.#I;this.#I=null,G()}}),Q.on(\"drain\",()=>{if(this.#K){const G=this.#K;this.#K=null,G()}}),z(Q,(G)=>{if(this.#H=!1,G)L(Q,G);this.#L(G)}),Q}_write(P,Q,G){var T=this.#j;if(!T)T=this.#N();if(T.write(P,Q))G();else this.#K=G}_final(P){this.#j.end(),this.#I=(...Q)=>P(...Q)}};return new M})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (H,Y,z){\"use strict\";var L={path:\"node:process\",require:Y},I=(T)=>L.require(T),{Duplex:M,eos:N,destroy:P}=I(\"node:stream\"),Q=class T extends M{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return I(\"tty\").isatty(H)}get fd(){return H}constructor(){super({readable:!0,writable:!0})}#L(U){const V=this.#J;if(this.#J=null,V)V(U);else if(U)this.destroy(U);else if(!this.#z&&!this.#H)this.destroy()}_destroy(U,V){if(!U&&this.#J!==null){var j=class G extends Error{constructor(J=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(J,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};U=new j}if(this.#J===null)V(U);else if(this.#J=V,this.#j)P(this.#j,U)}setRawMode(U){}on(U,V){if(U===\"readable\")this.ref(),this.#G=!0;return super.on(U,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 U,V;const j=this.#Y.readMany();if(!j\?.then)({done:U,value:V}=j);else({done:U,value:V}=await j);if(!U){this.push(V[0]);const G=V.length;for(let J=1;J{if(this.#I){const j=this.#I;this.#I=null,j()}}),V.on(\"drain\",()=>{if(this.#K){const j=this.#K;this.#K=null,j()}}),N(V,(j)=>{if(this.#H=!1,j)P(V,j);this.#L(j)}),V}_write(U,V,j){var G=this.#j;if(!G)G=this.#N();if(G.write(U,V))j();else this.#K=j}_final(U){this.#j.end(),this.#I=(...V)=>U(...V)}};return new Q})\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 _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let x=arguments[1],u=arguments[2];if(_===@undefined)_=null;if(u===@undefined)u={};if(x===@undefined)x={};let B={};if(_!==null){if(\"start\"in _){if(B[\"start\"]=_[\"start\"],typeof B[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(B[\"transform\"]=_[\"transform\"],typeof B[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(B[\"flush\"]=_[\"flush\"],typeof B[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const F=@extractHighWaterMark(u,0),j=@extractSizeAlgorithm(u),I=@extractHighWaterMark(x,1),q=@extractSizeAlgorithm(x),E=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,E.@promise,I,q,F,j),@setUpTransformStreamDefaultControllerFromTransformer(this,_,B),(\"start\"in B)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,B[\"start\"],[G]))().@then(()=>{E.@resolve.@call()},(v)=>{E.@reject.@call(@undefined,v)})}else E.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let x=arguments[1],E=arguments[2];if(_===@undefined)_=null;if(E===@undefined)E={};if(x===@undefined)x={};let F={};if(_!==null){if(\"start\"in _){if(F[\"start\"]=_[\"start\"],typeof F[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(F[\"transform\"]=_[\"transform\"],typeof F[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(F[\"flush\"]=_[\"flush\"],typeof F[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const G=@extractHighWaterMark(E,0),I=@extractSizeAlgorithm(E),B=@extractHighWaterMark(x,1),u=@extractSizeAlgorithm(x),J=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,J.@promise,B,u,G,I),@setUpTransformStreamDefaultControllerFromTransformer(this,_,F),(\"start\"in F)){const j=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,F[\"start\"],[j]))().@then(()=>{J.@resolve.@call()},(v)=>{J.@reject.@call(@undefined,v)})}else J.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -714,9 +714,9 @@ const char* const s_moduleMainCode = "(function (){\"use strict\";return @requir 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 = 927; +const int s_moduleRequireCodeLength = 1005; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (l){\"use strict\";const M=@requireMap.@get(l)||@requireMap.@get(l=@resolveSync(l,this.path,!1));if(M)return @evaluateCommonJSModule(M),M.exports;if(l.endsWith(\".json\")||l.endsWith(\".toml\")||l.endsWith(\".node\"))return @internalRequire(l);let y=@Loader.registry.@get(l);if(y\?.evaluated&&(y.state\?\?0)>=@ModuleReady){const _=y.module,S=@Loader.getModuleNamespaceObject(_),t=S\?.[@commonJSSymbol]===0||S\?.default\?.[@commonJSSymbol]===0\?S.default:S;return @requireMap.@set(l,@createCommonJSModule(l,t,!0)),t}const h=@createCommonJSModule(l,{},!1);@requireMap.@set(l,h);var L=this.@require(l,h);if(L===-1){try{L=@requireESM(l)}catch(_){throw @requireMap.@delete(l),_}if(y=@Loader.registry.@get(l),y\?.evaluated&&(y.state\?\?0)>=@ModuleReady){const _=@Loader.getModuleNamespaceObject(y.module);return h.exports=_\?.[@commonJSSymbol]===0||_\?.default\?.[@commonJSSymbol]===0\?_.default:_}}return @evaluateCommonJSModule(h),h.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const t=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(t)return @evaluateCommonJSModule(t),t.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let M=@Loader.registry.@get(_);if(M\?.evaluated&&(M.state\?\?0)>=@ModuleReady){const l=M.module,y=@Loader.getModuleNamespaceObject(l),L=y\?.[@commonJSSymbol]===0||y\?.default\?.[@commonJSSymbol]===0\?y.default:Object.create(y,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,L,!0)),L}const f=@createCommonJSModule(_,{},!1);@requireMap.@set(_,f);var h=this.@require(_,f);if(h===-1){try{h=@requireESM(_)}catch(l){throw @requireMap.@delete(_),l}if(M=@Loader.registry.@get(_),M\?.evaluated&&(M.state\?\?0)>=@ModuleReady){const l=@Loader.getModuleNamespaceObject(M.module);return f.exports=l\?.[@commonJSSymbol]===0||l\?.default\?.[@commonJSSymbol]===0\?l.default:Object.create(l,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(f),f.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return u.getInt8(d);case 2:return u.getInt16(d,!0);case 3:{const _=u.getUint16(d,!0)+u.getUint8(d+2)*65536;return _|(_&8388608)*510}case 4:return u.getInt32(d,!0);case 5:{const _=u.getUint8(d+4);return(_|(_&128)*33554430)*4294967296+u.getUint32(d,!0)}case 6:{const _=u.getUint16(d+4,!0);return(_|(_&32768)*131070)*4294967296+u.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,_){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:return r.getInt8(d);case 2:return r.getInt16(d,!0);case 3:{const u=r.getUint16(d,!0)+r.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return r.getInt32(d,!0);case 5:{const u=r.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+r.getUint32(d,!0)}case 6:{const u=r.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+r.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1006,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 (d,j,r){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:{c.setInt8(j,d);break}case 2:{c.setInt16(j,d,!0);break}case 3:{c.setUint16(j,d&65535,!0),c.setInt8(j+2,Math.floor(d*0.0000152587890625));break}case 4:{c.setInt32(j,d,!0);break}case 5:{c.setUint32(j,d|0,!0),c.setInt8(j+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{c.setUint32(j,d|0,!0),c.setInt16(j+4,Math.floor(d*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; @@ -1022,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,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"; +const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (d,E,c){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{r.setUint8(E,d);break}case 2:{r.setUint16(E,d,!0);break}case 3:{r.setUint16(E,d&65535,!0),r.setUint8(E+2,Math.floor(d*0.0000152587890625));break}case 4:{r.setUint32(E,d,!0);break}case 5:{r.setUint32(E,d|0,!0),r.setUint8(E+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{r.setUint32(E,d|0,!0),r.setUint16(E+4,Math.floor(d*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return E+c})\n"; // writeUIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1030,7 +1030,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntBECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (r,p,_){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{d.setUint8(p,r);break}case 2:{d.setUint16(p,r,!1);break}case 3:{d.setUint16(p+1,r&65535,!1),d.setUint8(p,Math.floor(r*0.0000152587890625));break}case 4:{d.setUint32(p,r,!1);break}case 5:{d.setUint32(p+1,r|0,!1),d.setUint8(p,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(p+2,r|0,!1),d.setUint16(p,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return p+_})\n"; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (d,r,p){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:{_.setUint8(r,d);break}case 2:{_.setUint16(r,d,!1);break}case 3:{_.setUint16(r+1,d&65535,!1),_.setUint8(r,Math.floor(d*0.0000152587890625));break}case 4:{_.setUint32(r,d,!1);break}case 5:{_.setUint32(r+1,d|0,!1),_.setUint8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{_.setUint32(r+2,d|0,!1),_.setUint16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+p})\n"; // writeFloatLE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1126,7 +1126,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeLatin1WriteCodeLength = 67; static const JSC::Intrinsic s_jsBufferPrototypeLatin1WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"latin1\")})\n"; +const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"latin1\")})\n"; // asciiWrite const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1142,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,r,d){\"use strict\";return this.write(a,r,d,\"base64\")})\n"; +const char* const s_jsBufferPrototypeBase64WriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64\")})\n"; // base64urlWrite const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1150,7 +1150,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlWriteCodeLength = 70; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"base64url\")})\n"; +const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64url\")})\n"; // hexWrite const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (c,w){\"use strict\";var{buffer:m,byteOffset:x,byteLength:z}=this;function p(k,v){if(k=@trunc(k),k===0||@isNaN(k))return 0;else if(k<0)return k+=v,k>0\?k:0;else return ki\?q-i:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (i,k){\"use strict\";var{buffer:m,byteOffset:q,byteLength:c}=this;function w(z,v){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=v,z>0\?z:0;else return zp\?x-p:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1280,7 +1280,7 @@ const JSC::ConstructorKind s_readableByteStreamControllerInitializeReadableByteS const JSC::ImplementationVisibility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength = 253; static const JSC::Intrinsic s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode = "(function (f,p,l){\"use strict\";if(arguments.length!==4&&arguments[3]!==@isReadableStream)@throwTypeError(\"ReadableByteStreamController constructor should not be called directly\");return @privateInitializeReadableByteStreamController.@call(this,f,p,l)})\n"; +const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode = "(function (f,l,p){\"use strict\";if(arguments.length!==4&&arguments[3]!==@isReadableStream)@throwTypeError(\"ReadableByteStreamController constructor should not be called directly\");return @privateInitializeReadableByteStreamController.@call(this,f,l,p)})\n"; // enqueue const JSC::ConstructAbility s_readableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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*A(){var m=@Bun.stdin.stream().getReader(),D=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),F,G=@Bun.indexOfLine;try{while(!0){var q,H,J;const K=m.readMany();if(@isPromise(K))({done:q,value:H}=await K);else({done:q,value:H}=K);if(q){if(J)yield D.decode(J);return}var w;for(let _ of H){if(w=_,J)w=@Buffer.concat([J,_]),J=null;var L=0,M=G(w,L);while(M!==-1)yield D.decode(w.subarray(L,M)),L=M+1,M=G(w,L);J=w.subarray(L)}}}catch(K){F=K}finally{if(m.releaseLock(),F)throw F}},z=globalThis.Symbol.asyncIterator;return this[z]=j,j()})\n"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const j=async function*z(){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 q=0,A=H(_,q);while(A!==-1)yield F.decode(_.subarray(q,A)),q=A+1,A=H(_,q);w=_.subarray(q)}}}catch(L){G=L}finally{if(D.releaseLock(),G)throw G}},m=globalThis.Symbol.asyncIterator;return this[m]=j,j()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (a){\"use strict\";var d=@getByIdDirectPrivate(this,\"writer\");if(!d){var _=@toLength(a\?.length\?\?0);d=@Bun.stdout.writer({highWaterMark:_>65536\?_:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var b=d.write(a);const f=@argumentCount();for(var c=1;c65536\?_:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var b=d.write(a);const c=@argumentCount();for(var f=1;f{},(g)=>{y.error(g)});function h(){@readableStreamDefaultReaderRead(c).@then(function(g){if(g.done){y.close();return}try{y.enqueue(g.value)}catch(S){y.error(\"ReadableStream chunk enqueueing in the sink failed\");return}h()},function(g){y.error(g)})}h()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (_,c){\"use strict\";@assert(@isReadableStream(_));const g=new @ReadableStreamDefaultReader(_);@getByIdDirectPrivate(g,\"closedPromiseCapability\").@promise.@then(()=>{},(y)=>{c.error(y)});function h(){@readableStreamDefaultReaderRead(g).@then(function(y){if(y.done){c.close();return}try{c.enqueue(y.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}h()},function(y){c.error(y)})}h()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1404,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 (f,b,j,q,v,w,x){\"use strict\";const B=new @ReadableStreamDefaultController(f,b,j,q,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(b,w,[B]),D=(_)=>@promiseInvokeOrNoopMethod(b,x,[_]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",D),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(f,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (_,w,f,x,b,B,j){\"use strict\";const C=new @ReadableStreamDefaultController(_,w,f,x,@isReadableStream),q=()=>@promiseInvokeOrNoopMethod(w,B,[C]),D=(v)=>@promiseInvokeOrNoopMethod(w,j,[v]);@putByIdDirectPrivate(C,\"pullAlgorithm\",q),@putByIdDirectPrivate(C,\"cancelAlgorithm\",D),@putByIdDirectPrivate(C,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(C,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(_,\"readableStreamController\",C),@readableStreamDefaultControllerStart(C)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const C=v.type,b=@toString(C);if(b===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(b===\"direct\"){var A=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,A)}else if(C===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (v,w,A){\"use strict\";const C=w.type,b=@toString(C);if(b===\"bytes\"){if(A.highWaterMark===@undefined)A.highWaterMark=0;if(A.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(v,\"readableStreamController\",new @ReadableByteStreamController(v,w,A.highWaterMark,@isReadableStream))}else if(b===\"direct\"){var f=A\?.highWaterMark;@initializeArrayBufferStream.@call(v,w,f)}else if(C===@undefined){if(A.highWaterMark===@undefined)A.highWaterMark=1;@setupReadableStreamDefaultController(v,w,A.size,A.highWaterMark,w.start,w.pull,w.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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 (D,I,E,T,k,J){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(I)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(I)),@assert(J===@undefined||@isAbortSignal(J)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:D,destination:I,preventAbort:T,preventCancel:k,preventClose:E,signal:J};if(_.reader=@acquireReadableStreamDefaultReader(D),_.writer=@acquireWritableStreamDefaultWriter(I),@putByIdDirectPrivate(D,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),J!==@undefined){const q=(w)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const z=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,w):@Promise.@resolve(),F=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,w):@Promise.@resolve();let G=@newPromiseCapability(@Promise),H=!0,K=()=>{if(H){H=!1;return}G.@resolve.@call()},f=(L)=>{G.@reject.@call(@undefined,L)};return z.@then(K,f),F.@then(K,f),G.@promise},w)};if(@whenSignalAborted(J,q))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (D,E,k,w,x,z){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(E)),@assert(z===@undefined||@isAbortSignal(z)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let B={source:D,destination:E,preventAbort:w,preventCancel:x,preventClose:k,signal:z};if(B.reader=@acquireReadableStreamDefaultReader(D),B.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(D,\"disturbed\",!0),B.finalized=!1,B.shuttingDown=!1,B.promiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability.@resolve.@call(),B.pendingWritePromise=@Promise.@resolve(),z!==@undefined){const F=(G)=>{if(B.finalized)return;@pipeToShutdownWithAction(B,()=>{const _=!B.preventAbort&&@getByIdDirectPrivate(B.destination,\"state\")===\"writable\"\?@writableStreamAbort(B.destination,G):@Promise.@resolve(),T=!B.preventCancel&&@getByIdDirectPrivate(B.source,\"state\")===@streamReadable\?@readableStreamCancel(B.source,G):@Promise.@resolve();let q=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}q.@resolve.@call()},K=(L)=>{q.@reject.@call(@undefined,L)};return _.@then(J,K),T.@then(J,K),q.@promise},G)};if(@whenSignalAborted(z,F))return B.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(B),@pipeToErrorsMustBePropagatedBackward(B),@pipeToClosingMustBePropagatedForward(B),@pipeToClosingMustBePropagatedBackward(B),@pipeToLoop(B),B.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1436,7 +1436,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToLoopCodeConstructorKin const JSC::ImplementationVisibility s_readableStreamInternalsPipeToLoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToLoopCodeLength = 110; static const JSC::Intrinsic s_readableStreamInternalsPipeToLoopCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToLoopCode = "(function (c){\"use strict\";if(c.shuttingDown)return;@pipeToDoReadWrite(c).@then((d)=>{if(d)@pipeToLoop(c)})})\n"; +const char* const s_readableStreamInternalsPipeToLoopCode = "(function (d){\"use strict\";if(d.shuttingDown)return;@pipeToDoReadWrite(d).@then((c)=>{if(c)@pipeToLoop(d)})})\n"; // pipeToDoReadWrite const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1452,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 d=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,b),b);return}@pipeToShutdown(_,b)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){d();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,d)})\n"; +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"; // pipeToErrorsMustBePropagatedBackward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1476,7 +1476,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagate const JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength = 324; static const JSC::Intrinsic s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode = "(function (k){\"use strict\";if(!@writableStreamCloseQueuedOrInFlight(k.destination)&&@getByIdDirectPrivate(k.destination,\"state\")!==\"closed\")return;const m=@makeTypeError(\"closing is propagated backward\");if(!k.preventCancel){@pipeToShutdownWithAction(k,()=>@readableStreamCancel(k.source,m),m);return}@pipeToShutdown(k,m)})\n"; +const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode = "(function (m){\"use strict\";if(!@writableStreamCloseQueuedOrInFlight(m.destination)&&@getByIdDirectPrivate(m.destination,\"state\")!==\"closed\")return;const k=@makeTypeError(\"closing is propagated backward\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,k),k);return}@pipeToShutdown(m,k)})\n"; // pipeToShutdownWithAction const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownWithActionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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 (_,g){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const b=arguments.length>2,d=arguments[2],m=()=>{g().@then(()=>{if(b)@pipeToFinalize(_,d);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(m,m)},(h)=>@pipeToFinalize(_,h));return}m()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (m,d){\"use strict\";if(m.shuttingDown)return;m.shuttingDown=!0;const h=arguments.length>2,g=arguments[2],j=()=>{d().@then(()=>{if(h)@pipeToFinalize(m,g);else @pipeToFinalize(m)},(b)=>{@pipeToFinalize(m,b)})};if(@getByIdDirectPrivate(m.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(m.destination)){m.pendingReadPromiseCapability.@promise.@then(()=>{m.pendingWritePromise.@then(j,j)},(_)=>@pipeToFinalize(m,_));return}j()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (i,q){\"use strict\";@assert(@isReadableStream(i)),@assert(typeof q===\"boolean\");var k=@getByIdDirectPrivate(i,\"start\");if(k)@putByIdDirectPrivate(i,\"start\",@undefined),k();const _=new @ReadableStreamDefaultReader(i),v={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};v.cancelPromiseCapability=@newPromiseCapability(@Promise);const w=@readableStreamTeePullFunction(v,_,q),f={};@putByIdDirectPrivate(f,\"pull\",w),@putByIdDirectPrivate(f,\"cancel\",@readableStreamTeeBranch1CancelFunction(v,i));const j={};@putByIdDirectPrivate(j,\"pull\",w),@putByIdDirectPrivate(j,\"cancel\",@readableStreamTeeBranch2CancelFunction(v,i));const g=new @ReadableStream(f),x=new @ReadableStream(j);return @getByIdDirectPrivate(_,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(v.closedOrErrored)return;if(@readableStreamDefaultControllerError(g.@readableStreamController,y),@readableStreamDefaultControllerError(x.@readableStreamController,y),v.closedOrErrored=!0,!v.canceled1||!v.canceled2)v.cancelPromiseCapability.@resolve.@call()}),v.branch1=g,v.branch2=x,[g,x]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (i,_){\"use strict\";@assert(@isReadableStream(i)),@assert(typeof _===\"boolean\");var q=@getByIdDirectPrivate(i,\"start\");if(q)@putByIdDirectPrivate(i,\"start\",@undefined),q();const f=new @ReadableStreamDefaultReader(i),v={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};v.cancelPromiseCapability=@newPromiseCapability(@Promise);const g=@readableStreamTeePullFunction(v,f,_),w={};@putByIdDirectPrivate(w,\"pull\",g),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch1CancelFunction(v,i));const j={};@putByIdDirectPrivate(j,\"pull\",g),@putByIdDirectPrivate(j,\"cancel\",@readableStreamTeeBranch2CancelFunction(v,i));const x=new @ReadableStream(w),k=new @ReadableStream(j);return @getByIdDirectPrivate(f,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(v.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,y),@readableStreamDefaultControllerError(k.@readableStreamController,y),v.closedOrErrored=!0,!v.canceled1||!v.canceled2)v.cancelPromiseCapability.@resolve.@call()}),v.branch1=x,v.branch2=k,[x,k]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,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 (m,_,f){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(_),function(i){if(@assert(@isObject(i)),@assert(typeof i.done===\"boolean\"),i.done&&!m.closedOrErrored){if(!m.canceled1)@readableStreamDefaultControllerClose(m.branch1.@readableStreamController);if(!m.canceled2)@readableStreamDefaultControllerClose(m.branch2.@readableStreamController);if(m.closedOrErrored=!0,!m.canceled1||!m.canceled2)m.cancelPromiseCapability.@resolve.@call()}if(m.closedOrErrored)return;if(!m.canceled1)@readableStreamDefaultControllerEnqueue(m.branch1.@readableStreamController,i.value);if(!m.canceled2)@readableStreamDefaultControllerEnqueue(m.branch2.@readableStreamController,f\?@structuredCloneForStream(i.value):i.value)})}})\n"; +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"; // readableStreamTeeBranch1CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,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,v,w){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function x(f,A){if(A&&w\?.cancel){try{var B=w.cancel(A);@markPromiseAsHandled(B)}catch(q){}w=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),A)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",A);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!w.pull){x();return}if(!@isCallable(w.pull)){x(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",v);const _=@getByIdDirectPrivate(j,\"highWaterMark\");v.start({highWaterMark:!_||_<64\?64:_}),@startDirectStream.@call(v,j,w.pull,x),@putByIdDirectPrivate(j,\"reader\",{});var z=w.pull(v);if(v=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; +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"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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,q,f){\"use strict\";var x=!1,B=!1;try{var z=c.getReader(),F=z.readMany();if(F&&@isPromise(F))F=await F;if(F.done)return x=!0,q.end();var G=F.value.length;const _=@getByIdDirectPrivate(c,\"highWaterMark\");if(f)@startDirectStream.@call(q,c,@undefined,()=>!B&&@markPromiseAsHandled(c.cancel()));q.start({highWaterMark:_||0});for(var I=0,H=F.value,P=F.value.length;I!I&&@markPromiseAsHandled(_.cancel()));H.start({highWaterMark:D||0});for(var q=0,x=P.value,z=P.value.length;q{var B=@createFulfilledPromise({value:C,done:!1});return C=@undefined,@readableStreamClose(v),v=@undefined,B}}else if(this._pendingRead){var S=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(S,{value:@undefined,done:!0})}@readableStreamClose(v)})\n"; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (v){\"use strict\";var b=this.@controlledReadableStream;if(!b||@getByIdDirectPrivate(b,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=v;return}if(@putByIdDirectPrivate(b,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,v)}catch(j){}var y;try{y=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(j){if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(B,j)}@readableStreamError(b,j);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var S=@getByIdDirectPrivate(b,\"reader\");if(S&&@isReadableStreamDefaultReader(S)){var c=this._pendingRead;if(c&&@isPromise(c)&&y\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(c,{value:y,done:!1}),@readableStreamClose(b);return}}if(y\?.byteLength){var C=@getByIdDirectPrivate(S,\"readRequests\");if(C\?.isNotEmpty()){@readableStreamFulfillReadRequest(b,y,!1),@readableStreamClose(b);return}@putByIdDirectPrivate(b,\"state\",@streamReadable),this.@pull=()=>{var j=@createFulfilledPromise({value:y,done:!1});return y=@undefined,@readableStreamClose(b),b=@undefined,j}}else if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(B,{value:@undefined,done:!0})}@readableStreamClose(b)})\n"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,b=@getByIdDirectPrivate(c,\"reader\");if(!b||!@isReadableStreamDefaultReader(b))return;var i=this._pendingRead;if(this._pendingRead=@undefined,i&&@isPromise(i)){var j=this.@sink.flush();if(j\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(i,{value:j,done:!1});else this._pendingRead=i}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var j=this.@sink.flush();if(j\?.byteLength)@readableStreamFulfillReadRequest(c,j,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var i=this._pendingRead;if(this._pendingRead=@undefined,i&&@isPromise(i)){var b=this.@sink.flush();if(b\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(i,{value:b,done:!1});else this._pendingRead=i}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var b=this.@sink.flush();if(b\?.byteLength)@readableStreamFulfillReadRequest(c,b,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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 (q){\"use strict\";var j,v=[],w=!1,x=!1,z=\"\",A=@toLength(0),C=@newPromiseCapability(@Promise),E=!1;return j={start(){},write(F){if(typeof F===\"string\"){var G=@toLength(F.length);if(G>0)z+=F,w=!0,A+=G;return G}if(!F||!(@ArrayBuffer.@isView(F)||F instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const _=@toLength(F.byteLength);if(_>0)if(x=!0,z.length>0)@arrayPush(v,z,F),z=\"\";else @arrayPush(v,F);return A+=_,_},flush(){return 0},end(){if(E)return\"\";return j.fulfill()},fulfill(){E=!0;const F=j.finishInternal();return @fulfillPromise(C.@promise,F),F},finishInternal(){if(!w&&!x)return\"\";if(w&&!x)return z;if(x&&!w)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(v));var F=new @Bun.ArrayBufferSink;F.start({highWaterMark:A,asUint8Array:!0});for(let G of v)F.write(G);if(v.length=0,z.length>0)F.write(z),z=\"\";return new globalThis.TextDecoder().decode(F.end())},close(){try{if(!E)E=!0,j.fulfill()}catch(F){}}},[j,C]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (v){\"use strict\";var w,x=[],z=!1,_=!1,C=\"\",q=@toLength(0),E=@newPromiseCapability(@Promise),F=!1;return w={start(){},write(G){if(typeof G===\"string\"){var A=@toLength(G.length);if(A>0)C+=G,z=!0,q+=A;return A}if(!G||!(@ArrayBuffer.@isView(G)||G instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const j=@toLength(G.byteLength);if(j>0)if(_=!0,C.length>0)@arrayPush(x,C,G),C=\"\";else @arrayPush(x,G);return q+=j,j},flush(){return 0},end(){if(F)return\"\";return w.fulfill()},fulfill(){F=!0;const G=w.finishInternal();return @fulfillPromise(E.@promise,G),G},finishInternal(){if(!z&&!_)return\"\";if(z&&!_)return C;if(_&&!z)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(x));var G=new @Bun.ArrayBufferSink;G.start({highWaterMark:q,asUint8Array:!0});for(let A of x)G.write(A);if(x.length=0,C.length>0)G.write(C),C=\"\";return new globalThis.TextDecoder().decode(G.end())},close(){try{if(!F)F=!0,w.fulfill()}catch(G){}}},[w,E]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[b,p]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),p})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,p){\"use strict\";var[m,b]=@createTextStream(p),f={@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\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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 (_,d){\"use strict\";var j=[],m=@newPromiseCapability(@Promise),t=!1;function b(){return t=!0,m.@resolve.@call(@undefined,j),j}var q={start(){},write(p){return @arrayPush(j,p),p.byteLength||p.length},flush(){return 0},end(){if(t)return[];return b()},close(){if(!t)b()}},v={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:q,close:@onCloseDirectStream,write:q.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",v),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),m})\n"; +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"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1668,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 w=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},b=new @Bun.ArrayBufferSink;b.start(w);var D={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write.bind(b),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",D),@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; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,_){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",_);const c=@getByIdDirectPrivate(i,\"reader\");if(!c)return;if(@isReadableStreamDefaultReader(c)){const h=@getByIdDirectPrivate(c,\"readRequests\");@putByIdDirectPrivate(c,\"readRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,_)}else{@assert(@isReadableStreamBYOBReader(c));const h=@getByIdDirectPrivate(c,\"readIntoRequests\");@putByIdDirectPrivate(c,\"readIntoRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,_)}@getByIdDirectPrivate(c,\"closedPromiseCapability\").@reject.@call(@undefined,_);const f=@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(f)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const v=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(v)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1684,7 +1684,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength = 477; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode = "(function (h){\"use strict\";const v=@getByIdDirectPrivate(h,\"controlledReadableStream\");if(!@readableStreamDefaultControllerCanCloseOrEnqueue(h))return!1;if(@getByIdDirectPrivate(h,\"started\")!==1)return!1;if((!@isReadableStreamLocked(v)||!@getByIdDirectPrivate(@getByIdDirectPrivate(v,\"reader\"),\"readRequests\")\?.isNotEmpty())&&@readableStreamDefaultControllerGetDesiredSize(h)<=0)return!1;const i=@readableStreamDefaultControllerGetDesiredSize(h);return @assert(i!==null),i>0})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode = "(function (h){\"use strict\";const i=@getByIdDirectPrivate(h,\"controlledReadableStream\");if(!@readableStreamDefaultControllerCanCloseOrEnqueue(h))return!1;if(@getByIdDirectPrivate(h,\"started\")!==1)return!1;if((!@isReadableStreamLocked(i)||!@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\")\?.isNotEmpty())&&@readableStreamDefaultControllerGetDesiredSize(h)<=0)return!1;const v=@readableStreamDefaultControllerGetDesiredSize(h);return @assert(v!==null),v>0})\n"; // readableStreamDefaultControllerCallPullIfNeeded const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1708,7 +1708,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 283; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const g=@getByIdDirectPrivate(i,\"controlledReadableStream\"),d=@getByIdDirectPrivate(g,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\"),g=@getByIdDirectPrivate(d,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; // readableStreamReaderGenericCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1716,7 +1716,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 133; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,i){\"use strict\";const h=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!h),@readableStreamCancel(h,i)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,h){\"use strict\";const i=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,h)})\n"; // readableStreamCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (d,h){\"use strict\";@putByIdDirectPrivate(d,\"disturbed\",!0);const p=@getByIdDirectPrivate(d,\"state\");if(p===@streamClosed)return @Promise.@resolve();if(p===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));@readableStreamClose(d);var u=@getByIdDirectPrivate(d,\"readableStreamController\"),_=u.@cancel;if(_)return _(u,h).@then(function(){});var i=u.close;if(i)return @Promise.@resolve(u.close(h));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (_,d){\"use strict\";@putByIdDirectPrivate(_,\"disturbed\",!0);const h=@getByIdDirectPrivate(_,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));@readableStreamClose(_);var p=@getByIdDirectPrivate(_,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,d).@then(function(){});var i=p.close;if(i)return @Promise.@resolve(p.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1740,7 +1740,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 519; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (f){\"use strict\";var a=@getByIdDirectPrivate(f,\"queue\");if(a.content.isNotEmpty()){const _=@dequeueValue(a);if(@getByIdDirectPrivate(f,\"closeRequested\")&&a.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(f,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(f);return @createFulfilledPromise({value:_,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(f,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(f),d})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const f=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:f,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),d})\n"; // readableStreamDefaultControllerClose const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var i=d.shift();i;i=d.shift())@fulfillPromise(i,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1764,7 +1764,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadReq const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 157; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (p,y,i){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(p,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:y,done:i})})\n"; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,p,y){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:p,done:y})})\n"; // readableStreamDefaultControllerEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let D=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)D=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,D)}catch(D){throw @readableStreamDefaultControllerError(_,D),D}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const y=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!y);const n=@getByIdDirectPrivate(y,\"state\");if(@putByIdDirectPrivate(y,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(y,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(y,\"readableStreamController\").@pull(@getByIdDirectPrivate(y,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1788,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; @@ -1820,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 (f,b){\"use strict\";var D=@getByIdDirectPrivate(f,\"bunNativeType\"),E=@getByIdDirectPrivate(f,\"bunNativePtr\"),y=@lazyStreamPrototypeMap.@get(D);if(y===@undefined){let p=function(U){var{c:z,v:A}=this;this.c=@undefined,this.v=@undefined,J(U,z,A)},X=function(U){try{U.close()}catch(z){globalThis.reportError(z)}},P=function(U,z,A,Y){Y[0]=!1;var Q;try{Q=j(U,A,Y)}catch(Z){return z.error(Z)}return J(Q,z,A)};var O=p,W=X,N=P,[j,F,_,G,B,m,H]=@lazyLoad(D),I=[!1],J;J=function U(z,A,Y){if(z&&@isPromise(z))return z.then(p.bind({c:A,v:Y}),(Q)=>A.error(Q));else if(typeof z===\"number\")if(Y&&Y.byteLength===z&&Y.buffer===A.byobRequest\?.view\?.buffer)A.byobRequest.respondWithNewView(Y);else A.byobRequest.respond(z);else if(z.constructor===@Uint8Array)A.enqueue(z);if(I[0]||z===!1)@enqueueJob(X,A),I[0]=!1};const x=B\?new FinalizationRegistry(B):null;y=class U{constructor(z,A,Y){if(this.#f=z,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=A,Y!==@undefined)this.start=(Q)=>{Q.enqueue(Y)};if(x)x.register(this,z,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=F;#j(z){var A=this.#f;if(!A){z.close();return}P(A,z,z.byobRequest.view,I)}#m(z){var A=this.#f;x&&x.unregister(this.#b),m&&m(A,!1),_(A,z)}static deinit=B;static drain=H},@lazyStreamPrototypeMap.@set(D,y)}const K=y.startSync(E,b);var q;const{drain:L,deinit:M}=y;if(L)q=L(E);if(K===0){if(B&&E&&@enqueueJob(B,E),(q\?.byteLength\?\?0)>0)return{start(p){p.enqueue(q),p.close()},type:\"bytes\"};return{start(p){p.close()},type:\"bytes\"}}return new y(E,K,q)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (B,m){\"use strict\";var y=@getByIdDirectPrivate(B,\"bunNativeType\"),q=@getByIdDirectPrivate(B,\"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=D(Y,_,p)}catch(A){return Z.error(A)}return K(z,Z,_)};var P=U,Q=W,O=X,[D,E,F,b,G,H,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=G\?new FinalizationRegistry(G):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=E;#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),H&&H(_,!1),F(_,Z)}static deinit=G;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(G&&q&&@enqueueJob(G,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; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var _=f.getReader(),b=_.readMany();async function g(j){if(j.done)return[];var p=j.value||[];while(!0){var q=await _.read();if(q.done)break;p=p.concat(q.value)}return p}if(b&&@isPromise(b))return b.@then(g);return g(b)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var b=f.getReader(),_=b.readMany();async function g(j){if(j.done)return[];var p=j.value||[];while(!0){var q=await b.read();if(q.done)break;p=p.concat(q.value)}return p}if(_&&@isPromise(_))return _.@then(g);return g(_)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1836,7 +1836,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 214; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (_){\"use strict\";const[i,d]=@createTextStream(@getByIdDirectPrivate(_,\"highWaterMark\")),h=@readStreamIntoSink(_,i,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (i){\"use strict\";const[_,h]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),d=@readStreamIntoSink(i,_,!1);if(d&&@isPromise(d))return @Promise.@resolve(d).@then(h.@promise);return h.@promise})\n"; // readableStreamToArrayBufferDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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 (q,v){\"use strict\";var w=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(q,\"underlyingSource\",@undefined);var D=@getByIdDirectPrivate(q,\"highWaterMark\");w.start(D\?{highWaterMark:D}:{});var x=@newPromiseCapability(@Promise),F=!1,z=v.pull,A=v.close,B={start(){},close(C){if(!F){if(F=!0,A)A();@fulfillPromise(x.@promise,w.end())}},end(){if(!F){if(F=!0,A)A();@fulfillPromise(x.@promise,w.end())}},flush(){return 0},write:w.write.bind(w)},G=!1;try{const C=z(B);if(C&&@isObject(C)&&@isPromise(C))return async function(O,j,_){while(!F)await _(O);return await j}(B,promise,z);return x.@promise}catch(C){return G=!0,@readableStreamError(q,C),@Promise.@reject(C)}finally{if(!G&&q)@readableStreamClose(q);B=A=w=z=q=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,_){\"use strict\";var q=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var x=@getByIdDirectPrivate(O,\"highWaterMark\");q.start(x\?{highWaterMark:x}:{});var v=@newPromiseCapability(@Promise),z=!1,A=_.pull,B=_.close,C={start(){},close(F){if(!z){if(z=!0,B)B();@fulfillPromise(v.@promise,q.end())}},end(){if(!z){if(z=!0,B)B();@fulfillPromise(v.@promise,q.end())}},flush(){return 0},write:q.write.bind(q)},D=!1;try{const F=A(C);if(F&&@isObject(F)&&@isPromise(F))return async function(G,j,w){while(!z)await w(G);return await j}(C,promise,A);return v.@promise}catch(F){return D=!0,@readableStreamError(O,F),@Promise.@reject(F)}finally{if(!D&&O)@readableStreamClose(O);C=B=q=A=O=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var _=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var k=await _.read();if(k.done)break}try{_.releaseLock()}catch(p){}return _=@undefined,f=@undefined,j.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var k=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(_){}return k=@undefined,f=@undefined,j.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,f){\"use strict\";const k=@initializeArrayStream.@call(_,f,@undefined);f=@undefined;var q=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var j=await q.read();if(j.done)break}try{q.releaseLock()}catch(p){}return q=@undefined,@Promise.@resolve(k.@promise)}catch(p){throw p}finally{_=@undefined,q=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,_){\"use strict\";const j=@initializeArrayStream.@call(f,_,@undefined);_=@undefined;var k=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(q){}return k=@undefined,@Promise.@resolve(j.@promise)}catch(q){throw q}finally{f=@undefined,k=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (F){\"use strict\";var i=globalThis.Symbol.asyncIterator,z=async function*q(D,w){var j=D.getReader(),x;try{while(!0){var k,g;const G=j.readMany();if(@isPromise(G))({done:k,value:g}=await G);else({done:k,value:g}=G);if(k)return;yield*g}}catch(G){x=G}finally{if(j.releaseLock(),!w)D.cancel(x);if(x)throw x}},h=function q(){return z(this,!1)},B=function q({preventCancel:D=!1}={preventCancel:!1}){return z(this,D)};return @Object.@defineProperty(F,i,{value:h}),@Object.@defineProperty(F,\"values\",{value:B}),F})\n"; +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"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1986,7 +1986,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const u=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(u){const f=u.@call(n,\"string\");if(typeof f===\"string\")switch(@argumentCount()){case 1:return new @Buffer(f);case 2:return new @Buffer(f,@argument(1));default:return new @Buffer(f,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2020,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 _=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!_)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const S=@getByIdDirectPrivate(_,\"state\");if(@putByIdDirectPrivate(_,\"disturbed\",!0),S===@streamClosed)return{value:[],size:0,done:!0};else if(S===@streamErrored)throw @getByIdDirectPrivate(_,\"storedError\");var H=@getByIdDirectPrivate(_,\"readableStreamController\"),U=@getByIdDirectPrivate(H,\"queue\");if(!U)return H.@pull(H).@then(function({done:w,value:k}){return w\?{done:!0,value:[],size:0}:{value:[k],size:1,done:!1}});const d=U.content;var x=U.size,W=d.toArray(!1),J=W.length;if(J>0){var B=@newArrayWithSize(J);if(@isReadableByteStreamController(H)){{const w=W[0];if(!(@ArrayBuffer.@isView(w)||w instanceof @ArrayBuffer))@putByValDirect(B,0,new @Uint8Array(w.buffer,w.byteOffset,w.byteLength));else @putByValDirect(B,0,w)}for(var C=1;C{if(w.done)return{value:[],size:0,done:!0};var k=@getByIdDirectPrivate(_,\"readableStreamController\"),N=@getByIdDirectPrivate(k,\"queue\"),K=[w.value].concat(N.content.toArray(!1)),A=K.length;if(@isReadableByteStreamController(k))for(var G=0;G0){var _=@newArrayWithSize(F);if(@isReadableByteStreamController(w)){{const H=E[0];if(!(@ArrayBuffer.@isView(H)||H instanceof @ArrayBuffer))@putByValDirect(_,0,new @Uint8Array(H.buffer,H.byteOffset,H.byteLength));else @putByValDirect(_,0,H)}for(var j=1;j{if(H.done)return{value:[],size:0,done:!0};var I=@getByIdDirectPrivate(x,\"readableStreamController\"),J=@getByIdDirectPrivate(I,\"queue\"),K=[H.value].concat(J.content.toArray(!1)),d=K.length;if(@isReadableByteStreamController(I))for(var N=0;N0}shift(){var{_head:F,_tail:x,_list:g,_capacityMask:A}=this;if(F===x)return @undefined;var B=g[F];if(@putByValDirect(g,F,@undefined),F=this._head=F+1&A,F<2&&x>1e4&&x<=g.length>>>2)this._shrinkArray();return B}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(F){var x=this._tail;if(@putByValDirect(this._list,x,F),this._tail=x+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(F){var x=this._list,g=@toLength(x.length);if(F||this._head>this._tail){var A=@toLength(this._head),B=@toLength(this._tail),k=@toLength(g-A+B),z=@newArrayWithSize(k),G=0;for(var w=A;w>>=1,this._capacityMask>>>=1}}return new E})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var g=@Array.prototype.slice;class w{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:A,_list:b,_capacityMask:E}=this;if(z===A)return @undefined;var x=b[z];if(@putByValDirect(b,z,@undefined),z=this._head=z+1&E,z<2&&A>1e4&&A<=b.length>>>2)this._shrinkArray();return x}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(z){var A=this._tail;if(@putByValDirect(this._list,A,z),this._tail=A+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(z){var A=this._list,b=@toLength(A.length);if(z||this._head>this._tail){var E=@toLength(this._head),x=@toLength(this._tail),F=@toLength(b-E+x),G=@newArrayWithSize(F),k=0;for(var B=E;B>>=1,this._capacityMask>>>=1}}return new w})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2224,7 +2224,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (D){\"use strict\";var J=@Loader,z=@createFIFO(),B=D;while(B){var F=J.registry.@get(B);if((F\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(B),F=J.registry.@get(B);var G=@getPromiseInternalField(F.fetch,@promiseFieldReactionsOrResult),H=J.parseModule(B,G),I=F.module;if(H&&@isPromise(H)){var L=@getPromiseInternalField(H,@promiseFieldReactionsOrResult),_=@getPromiseInternalField(H,@promiseFieldFlags),w=_&@promiseStateMask;if(w===@promiseStatePending||L&&@isPromise(L))@throwTypeError(`require() async module \"${B}\" is unsupported. use \"await import()\" instead.`);else if(w===@promiseStateRejected){if(!L\?.message)@throwTypeError(`${L+\"\"\?L:\"An error occurred\"} occurred while parsing module \\\"${B}\\\"`);throw L}F.module=I=L}else if(H&&!I)F.module=I=H;@setStateToMax(F,@ModuleLink);var Q=I.dependenciesMap,x=J.requestedModules(I),T=@newArrayWithSize(x.length);for(var U=0,V=x.length;U=@ModuleLink)B=z.shift()}var Z=J.linkAndEvaluateModule(D,@undefined);if(Z&&@isPromise(Z))@throwTypeError(`require() async module \\\"${D}\\\" is unsupported. use \"await import()\" instead.`);return J.registry.@get(D)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (D){\"use strict\";var H=@Loader,_=@createFIFO(),I=D;while(I){var w=H.registry.@get(I);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(I),w=H.registry.@get(I);var L=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),J=H.parseModule(I,L),Q=w.module;if(J&&@isPromise(J)){var T=@getPromiseInternalField(J,@promiseFieldReactionsOrResult),x=@getPromiseInternalField(J,@promiseFieldFlags),U=x&@promiseStateMask;if(U===@promiseStatePending||T&&@isPromise(T))@throwTypeError(`require() async module \"${I}\" is unsupported. use \"await import()\" instead.`);else if(U===@promiseStateRejected){if(!T\?.message)@throwTypeError(`${T+\"\"\?T:\"An error occurred\"} occurred while parsing module \\\"${I}\\\"`);throw T}w.module=Q=T}else if(J&&!Q)w.module=Q=J;@setStateToMax(w,@ModuleLink);var V=Q.dependenciesMap,W=H.requestedModules(Q),X=@newArrayWithSize(W.length);for(var Y=0,Z=W.length;Y=@ModuleLink)I=_.shift()}var G=H.linkAndEvaluateModule(D,@undefined);if(G&&@isPromise(G))@throwTypeError(`require() async module \\\"${D}\\\" is unsupported. use \"await import()\" instead.`);return H.registry.@get(D)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var _=@Loader.registry.@get(a);if(!_||!_.evaluated)_=@loadCJS2ESM(a);if(!_||!_.evaluated||!_.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var c=@Loader.getModuleNamespaceObject(_.module);if(c[@commonJSSymbol]===0)return;return c})\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; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (k){\"use strict\";var n=@requireMap.@get(k);const j=k.substring(k.length-5);if(n)return n.exports;if(j===\".json\"){var _=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=JSON.parse(_.readFileSync(k,\"utf8\"));return @requireMap.@set(k,@createCommonJSModule(k,q,!0)),q}else if(j===\".node\"){const v=@createCommonJSModule(k,{},!0);return process.dlopen(v,k),@requireMap.@set(k,v),v.exports}else if(j===\".toml\"){var _=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=@Bun.TOML.parse(_.readFileSync(k,\"utf8\"));return @requireMap.@set(k,@createCommonJSModule(k,q,!0)),q}else{var q=@requireESM(k);const g=@requireMap.@get(k);if(g)return g.exports;var b=q\?.default;if(b\?.[@commonJSSymbol]===0)q=b;return @requireMap.@set(k,@createCommonJSModule(k,q,!0)),q}})\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 n=@createCommonJSModule(b,{},!0);return process.dlopen(n,b),@requireMap.@set(b,n),n.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 v=@requireMap.@get(b);if(v)return v.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; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,f={};return new Proxy(f,{get(h,t){const u=@requireMap.@get(t);if(u)return u;const L=@Loader.registry.@get(t);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(t,c,!0);return @requireMap.@set(t,g),g}return f[t]},set(h,t,u){return @requireMap.@set(t,u),!0},has(h,t){return @requireMap.@has(t)||@Loader.registry.@has(t)},deleteProperty(h,t){return _.@delete(t),@requireMap.@delete(t),@Loader.registry.@delete(t),!0},ownKeys(h){var t=[...@requireMap.@keys()];const u=[...@Loader.registry.@keys()];for(let L of u)if(!t.includes(L))@arrayPush(t,L);return t},getPrototypeOf(h){return null},getOwnPropertyDescriptor(h,t){if(@requireMap.@has(t)||@Loader.registry.@has(t))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,h={};return new Proxy(h,{get(u,f){const L=@requireMap.@get(f);if(L)return L;const t=@Loader.registry.@get(f);if(t\?.evaluated){const b=@Loader.getModuleNamespaceObject(t.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(f,c,!0);return @requireMap.@set(f,g),g}return h[f]},set(u,f,L){return @requireMap.@set(f,L),!0},has(u,f){return @requireMap.@has(f)||@Loader.registry.@has(f)},deleteProperty(u,f){return _.@delete(f),@requireMap.@delete(f),@Loader.registry.@delete(f),!0},ownKeys(u){var f=[...@requireMap.@keys()];const L=[...@Loader.registry.@keys()];for(let t of L)if(!f.includes(t))@arrayPush(f,t);return f},getPrototypeOf(u){return null},getOwnPropertyDescriptor(u,f){if(@requireMap.@has(f)||@Loader.registry.@has(f))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2432,7 +2432,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const m=_.type===\"direct\",v=!!_.@lazy,B=m||v;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!B){const I=@getByIdDirectPrivate(f,\"size\"),b=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,I,b!==@undefined\?b:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(m)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(B){const I=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,I);if(b)@createReadableStreamController(this,b,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,b=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!b){const _=@getByIdDirectPrivate(m,\"size\"),I=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",I),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,I!==@undefined\?I:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(b){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const I=@lazyLoadStream(this,_);if(I)@createReadableStreamController(this,I,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2456,7 +2456,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2480,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,w,H){\"use strict\";const F=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var k=globalThis[F];if(!k)k=globalThis[F]=[];var q=k[w];if(q===@undefined){var[_,x,I,A,J,B]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](w);q=class D{handleError;handleClosed;processResult;constructor(L,G){this.#_=G,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,A(L),B(L)}_handleError(L){if(this.#$)return;this.#$=!0;var G=this.#_;this.#_=0,x(G,L),B(G)}#_;#$=!1;#F;_handleReadMany({value:L,done:G,size:N}){if(G){this.handleClosed();return}if(this.#$)return;I(this.#_,L,G,N)}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 N=@getPromiseInternalField(L,@promiseFieldReactionsOrResult);if(N)L=N}}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 K=w+1;if(k.length{@putByIdDirectPrivate(R,\"started\",1),@assert(!@getByIdDirectPrivate(R,\"pulling\")),@assert(!@getByIdDirectPrivate(R,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(R)},(d)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(R,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (v,b,f){\"use strict\";if(!@isReadableStream(v))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(v,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",v),@putByIdDirectPrivate(this,\"underlyingByteSource\",b),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let p=@toNumber(f);if(@isNaN(p)||p<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",p);let d=b.autoAllocateChunkSize;if(d!==@undefined){if(d=@toNumber(d),d<=0||d===@Infinity||d===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",d),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const _=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(_,\"underlyingByteSource\"),\"start\",[_]).@then(()=>{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(_)},(R)=>{if(@getByIdDirectPrivate(v,\"state\")===@streamReadable)@readableByteStreamControllerError(_,R)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2676,7 +2676,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var p=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=p.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,_){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=u.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[_])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2708,7 +2708,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 272; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\"),u=@getByIdDirectPrivate(d,\"state\");if(u===@streamErrored)return null;if(u===@streamClosed)return 0;return @getByIdDirectPrivate(_,\"strategyHWM\")-@getByIdDirectPrivate(_,\"queue\").size})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const _=@getByIdDirectPrivate(u,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; // readableStreamHasBYOBReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2740,7 +2740,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (h){\"use strict\";const R=@getByIdDirectPrivate(h,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(R)),@getByIdDirectPrivate(h,\"queue\").content\?.isNotEmpty()){const d=@getByIdDirectPrivate(h,\"queue\").content.shift();@getByIdDirectPrivate(h,\"queue\").size-=d.byteLength,@readableByteStreamControllerHandleQueueDrain(h);let _;try{_=new @Uint8Array(d.buffer,d.byteOffset,d.byteLength)}catch(P){return @Promise.@reject(P)}return @createFulfilledPromise({value:_,done:!1})}if(@getByIdDirectPrivate(h,\"autoAllocateChunkSize\")!==@undefined){let d;try{d=@createUninitializedArrayBuffer(@getByIdDirectPrivate(h,\"autoAllocateChunkSize\"))}catch(P){return @Promise.@reject(P)}const _={buffer:d,byteOffset:0,byteLength:@getByIdDirectPrivate(h,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(h,\"pendingPullIntos\").push(_)}const F=@readableStreamAddReadRequest(R);return @readableByteStreamControllerCallPullIfNeeded(h),F})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(d)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const F=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=F.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let P;try{P=new @Uint8Array(F.buffer,F.byteOffset,F.byteLength)}catch(R){return @Promise.@reject(R)}return @createFulfilledPromise({value:P,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let F;try{F=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(R){return @Promise.@reject(R)}const P={buffer:F,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(P)}const h=@readableStreamAddReadRequest(d);return @readableByteStreamControllerCallPullIfNeeded(_),h})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 619; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const b=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(b,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const P=@getByIdDirectPrivate(b,\"reader\");if(P&&(@getByIdDirectPrivate(P,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(P,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(b)&&@getByIdDirectPrivate(@getByIdDirectPrivate(b,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const P=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(P,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const b=@getByIdDirectPrivate(P,\"reader\");if(b&&(@getByIdDirectPrivate(b,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(b,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(P)&&@getByIdDirectPrivate(@getByIdDirectPrivate(P,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; // readableByteStreamControllerCallPullIfNeeded const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2812,7 +2812,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength = 464; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,_){\"use strict\";let u=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),k=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){if(_!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,u)}else @assert(@getByIdDirectPrivate(k,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,_,u)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,u){\"use strict\";let _=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),k=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){if(u!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,_)}else @assert(@getByIdDirectPrivate(k,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,u,_)})\n"; // readableByteStreamControllerRespondInReadableState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2820,7 +2820,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,R,_){\"use strict\";if(_.bytesFilled+R>_.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"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2836,7 +2836,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength = 472; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode = "(function (d){\"use strict\";@assert(!@getByIdDirectPrivate(d,\"closeRequested\"));while(@getByIdDirectPrivate(d,\"pendingPullIntos\").isNotEmpty()){if(@getByIdDirectPrivate(d,\"queue\").size===0)return;let a=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek();if(@readableByteStreamControllerFillDescriptorFromQueue(d,a))@readableByteStreamControllerShiftPendingDescriptor(d),@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(d,\"controlledReadableStream\"),a)}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode = "(function (a){\"use strict\";@assert(!@getByIdDirectPrivate(a,\"closeRequested\"));while(@getByIdDirectPrivate(a,\"pendingPullIntos\").isNotEmpty()){if(@getByIdDirectPrivate(a,\"queue\").size===0)return;let d=@getByIdDirectPrivate(a,\"pendingPullIntos\").peek();if(@readableByteStreamControllerFillDescriptorFromQueue(a,d))@readableByteStreamControllerShiftPendingDescriptor(a),@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(a,\"controlledReadableStream\"),d)}})\n"; // readableByteStreamControllerFillDescriptorFromQueue const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2844,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 (_,k){\"use strict\";const v=k.bytesFilled-k.bytesFilled%k.elementSize,G=@getByIdDirectPrivate(_,\"queue\").sizev)q=H-k.bytesFilled,J=!0;while(q>0){let j=@getByIdDirectPrivate(_,\"queue\").content.peek();const z=q0),@assert(k.bytesFilledw)q=G-v.bytesFilled,H=!0;while(q>0){let J=@getByIdDirectPrivate(j,\"queue\").content.peek();const k=q0),@assert(v.bytesFilled0){if(@readableByteStreamControllerFillDescriptorFromQueue(_,A)){const k=@readableByteStreamControllerConvertDescriptor(A);return @readableByteStreamControllerHandleQueueDrain(_),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(_,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(_,k),@Promise.@reject(k)}}A.buffer=@transferBufferToCurrentRealm(A.buffer),@getByIdDirectPrivate(_,\"pendingPullIntos\").push(A);const R=@readableStreamAddReadIntoRequest(b);return @readableByteStreamControllerCallPullIfNeeded(_),R})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (b,A){\"use strict\";const N=@getByIdDirectPrivate(b,\"controlledReadableStream\");let E=1;if(A.BYTES_PER_ELEMENT!==@undefined)E=A.BYTES_PER_ELEMENT;const d=A.constructor,R={buffer:A.buffer,byteOffset:A.byteOffset,byteLength:A.byteLength,bytesFilled:0,elementSize:E,ctor:d,readerType:\"byob\"};var _=@getByIdDirectPrivate(b,\"pendingPullIntos\");if(_\?.isNotEmpty())return R.buffer=@transferBufferToCurrentRealm(R.buffer),_.push(R),@readableStreamAddReadIntoRequest(N);if(@getByIdDirectPrivate(N,\"state\")===@streamClosed){const k=new d(R.buffer,R.byteOffset,0);return @createFulfilledPromise({value:k,done:!0})}if(@getByIdDirectPrivate(b,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,R)){const k=@readableByteStreamControllerConvertDescriptor(R);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}R.buffer=@transferBufferToCurrentRealm(R.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(R);const L=@readableStreamAddReadIntoRequest(N);return @readableByteStreamControllerCallPullIfNeeded(b),L})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2952,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 A extends EventTarget{#Z;#K;#W;#L;#M;#j=!1;#$=null;#O=\"\";#B=\"\";#z=\"\";#Q=!0;#X=0;#F=0;#H=0;#U=null;static#G(U){U.#Y()}static#J(U,B){const V=U.data,F=V.#z\?`Last-Event-ID: ${V.#z}\\r\\n`:\"\",j=`GET ${B.pathname}${B.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${F}\\r\\n`,G=U.write(j);if(G!==j.length)V.#B=j.substring(G)}static#V(U,B,V){for(;;){if(V>=B.length)return;let F=-1,j=B.indexOf(\"\\r\\n\",V);const G=j+2;if(j>0)if(U.#X===0){const Y=parseInt(B.substring(V,j),16);if(Y===0){U.#K=2,U.#$\?.end();return}F=G+Y}else F=B.length;else{if(U.#O.length===0){U.#O+=B.substring(V);return}F=B.length}let W=B.substring(G,F);V=F+2;let J=0,X=W.indexOf(\"\\n\\n\");if(X==-1){U.#O+=B.substring(G);return}if(U.#O.length)U.#O+=W,W=U.#O,U.#O=\"\";let K=!0;while(K){const Y=W.substring(J,X);let L,Z=\"\",M,w=0,O=-1;for(;;){let Q=Y.indexOf(\"\\n\",w);if(Q===-1){if(w>=Y.length)break;Q=Y.length}const H=Y.substring(w,Q);if(H.startsWith(\"data:\"))if(Z.length)Z+=`\\n${H.substring(5).trim()}`;else Z=H.substring(5).trim();else if(H.startsWith(\"event:\"))L=H.substring(6).trim();else if(H.startsWith(\"id:\"))M=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(O=parseInt(H.substring(6).trim(),10),@isNaN(O))O=-1}w=Q+1}if(U.#z=M||\"\",O>=0)U.#H=O;if(Z||M||L)U.dispatchEvent(new MessageEvent(L||\"message\",{data:Z||\"\",origin:U.#Z.origin,source:U,lastEventId:M}));if(W.length===X+2){K=!1;break}const z=W.indexOf(\"\\n\\n\",X+1);if(z===-1)break;J=X,X=z}}}static#A={open(U){const B=U.data;if(B.#$=U,!B.#j)A.#J(U,B.#Z)},handshake(U,B,V){const F=U.data;if(B)A.#J(U,F.#Z);else F.#K=2,F.dispatchEvent(new ErrorEvent(\"error\",{error:V})),U.end()},data(U,B){const V=U.data;switch(V.#K){case 0:{let F=B.toString();const j=F.indexOf(\"\\r\\n\\r\\n\");if(j===-1){V.#O+=F;return}if(V.#O.length)V.#O+=F,F=V.#O,V.#O=\"\";const G=F.substring(0,j),W=G.indexOf(\"\\r\\n\");if(W===-1){V.#K=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),U.end();return}const J=G.substring(0,W);if(J!==\"HTTP/1.1 200 OK\"){V.#K=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(J)})),U.end();return}let X=W+1,K=!1,Y=-1;for(;;){let Z=G.indexOf(\"\\r\\n\",X);if(Z===-1){if(X>=G.length){if(!K)V.#K=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),U.end();return}Z=G.length}const M=G.substring(X+1,Z),w=M.indexOf(\":\"),O=M.substring(0,w),z=O.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(X=Z+1,z)if(M.endsWith(\" text/event-stream\"))K=!0;else{V.#K=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),U.end();return}else if(O.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(Y=parseInt(M.substring(w+1).trim(),10),@isNaN(Y)||Y<=0){V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),U.end();return}if(K)break}else if(O.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(M.substring(w+1).trim()!==\"chunked\"){V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),U.end();return}if(Y=0,K)break}}V.#X=Y,V.#K=1,V.dispatchEvent(new Event(\"open\"));const L=F.substring(j+4);if(A.#V(V,L,0),V.#X>0){if(V.#F+=L.length,V.#F>=V.#X)V.#K=2,U.end()}return}case 1:if(A.#V(V,B.toString(),2),V.#X>0){if(V.#F+=B.byteLength,V.#F>=V.#X)V.#K=2,U.end()}return;default:break}},drain(U){const B=U.data;if(B.#K===0){const V=B.#O;if(V.length){const F=U.write(V);if(F!==V.length)U.data.#B=V.substring(F);else U.data.#B=\"\"}}},close:A.#w,end(U){A.#w(U).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(U){A.#w(U).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#w(U){const B=U.data;if(B.#$=null,B.#F=0,B.#K=2,B.#Q){if(B.#U)clearTimeout(B.#U);B.#U=setTimeout(A.#G,B.#H,B)}return B}constructor(U,B=@undefined){super();const V=new URL(U);this.#j=V.protocol===\"https:\",this.#Z=V,this.#K=2,process.nextTick(A.#G,this)}ref(){this.#U\?.ref(),this.#$\?.ref()}unref(){this.#U\?.unref(),this.#$\?.unref()}#Y(){if(this.#K!==2)return;const U=this.#Z,B=this.#j;this.#K=0,@Bun.connect({data:this,socket:A.#A,hostname:U.hostname,port:parseInt(U.port||(B\?\"443\":\"80\"),10),tls:B\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((V)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:V})),this.#Q){if(this.#U)this.#U.unref\?.();this.#U=setTimeout(A.#G,1000,this)}})}get url(){return this.#Z.href}get readyState(){return this.#K}close(){this.#Q=!1,this.#K=2,this.#$\?.unref(),this.#$\?.end()}get onopen(){return this.#M}get onerror(){return this.#W}get onmessage(){return this.#L}set onopen(U){if(this.#M)super.removeEventListener(\"close\",this.#M);super.addEventListener(\"open\",U),this.#M=U}set onerror(U){if(this.#W)super.removeEventListener(\"error\",this.#W);super.addEventListener(\"error\",U),this.#W=U}set onmessage(U){if(this.#L)super.removeEventListener(\"message\",this.#L);super.addEventListener(\"message\",U),this.#L=U}}return Object.defineProperty(A.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(A.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(A.prototype,\"CLOSED\",{enumerable:!0,value:2}),A[Symbol.for(\"CommonJS\")]=0,A})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class F 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(L){L.#H()}static#X(L,j){const A=L.data,G=A.#L\?`Last-Event-ID: ${A.#L}\\r\\n`:\"\",J=`GET ${j.pathname}${j.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${G}\\r\\n`,M=L.write(J);if(M!==J.length)A.#K=J.substring(M)}static#Y(L,j,A){for(;;){if(A>=j.length)return;let G=-1,J=j.indexOf(\"\\r\\n\",A);const M=J+2;if(J>0)if(L.#O===0){const W=parseInt(j.substring(A,J),16);if(W===0){L.#j=2,L.#G\?.end();return}G=M+W}else G=j.length;else{if(L.#J.length===0){L.#J+=j.substring(A);return}G=j.length}let O=j.substring(M,G);A=G+2;let Q=0,U=O.indexOf(\"\\n\\n\");if(U==-1){L.#J+=j.substring(M);return}if(L.#J.length)L.#J+=O,O=L.#J,L.#J=\"\";let V=!0;while(V){const W=O.substring(Q,U);let X,w=\"\",B,Y=0,K=-1;for(;;){let z=W.indexOf(\"\\n\",Y);if(z===-1){if(Y>=W.length)break;z=W.length}const H=W.substring(Y,z);if(H.startsWith(\"data:\"))if(w.length)w+=`\\n${H.substring(5).trim()}`;else w=H.substring(5).trim();else if(H.startsWith(\"event:\"))X=H.substring(6).trim();else if(H.startsWith(\"id:\"))B=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(K=parseInt(H.substring(6).trim(),10),@isNaN(K))K=-1}Y=z+1}if(L.#L=B||\"\",K>=0)L.#U=K;if(w||B||X)L.dispatchEvent(new MessageEvent(X||\"message\",{data:w||\"\",origin:L.#$.origin,source:L,lastEventId:B}));if(O.length===U+2){V=!1;break}const Z=O.indexOf(\"\\n\\n\",U+1);if(Z===-1)break;Q=U,U=Z}}}static#Z={open(L){const j=L.data;if(j.#G=L,!j.#F)F.#X(L,j.#$)},handshake(L,j,A){const G=L.data;if(j)F.#X(L,G.#$);else G.#j=2,G.dispatchEvent(new ErrorEvent(\"error\",{error:A})),L.end()},data(L,j){const A=L.data;switch(A.#j){case 0:{let G=j.toString();const J=G.indexOf(\"\\r\\n\\r\\n\");if(J===-1){A.#J+=G;return}if(A.#J.length)A.#J+=G,G=A.#J,A.#J=\"\";const M=G.substring(0,J),O=M.indexOf(\"\\r\\n\");if(O===-1){A.#j=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),L.end();return}const Q=M.substring(0,O);if(Q!==\"HTTP/1.1 200 OK\"){A.#j=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Q)})),L.end();return}let U=O+1,V=!1,W=-1;for(;;){let w=M.indexOf(\"\\r\\n\",U);if(w===-1){if(U>=M.length){if(!V)A.#j=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),L.end();return}w=M.length}const B=M.substring(U+1,w),Y=B.indexOf(\":\"),K=B.substring(0,Y),Z=K.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(U=w+1,Z)if(B.endsWith(\" text/event-stream\"))V=!0;else{A.#j=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),L.end();return}else if(K.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(W=parseInt(B.substring(Y+1).trim(),10),@isNaN(W)||W<=0){A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),L.end();return}if(V)break}else if(K.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(B.substring(Y+1).trim()!==\"chunked\"){A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),L.end();return}if(W=0,V)break}}A.#O=W,A.#j=1,A.dispatchEvent(new Event(\"open\"));const X=G.substring(J+4);if(F.#Y(A,X,0),A.#O>0){if(A.#Q+=X.length,A.#Q>=A.#O)A.#j=2,L.end()}return}case 1:if(F.#Y(A,j.toString(),2),A.#O>0){if(A.#Q+=j.byteLength,A.#Q>=A.#O)A.#j=2,L.end()}return;default:break}},drain(L){const j=L.data;if(j.#j===0){const A=j.#J;if(A.length){const G=L.write(A);if(G!==A.length)L.data.#K=A.substring(G);else L.data.#K=\"\"}}},close:F.#z,end(L){F.#z(L).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(L){F.#z(L).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(L){const j=L.data;if(j.#G=null,j.#Q=0,j.#j=2,j.#M){if(j.#V)clearTimeout(j.#V);j.#V=setTimeout(F.#W,j.#U,j)}return j}constructor(L,j=@undefined){super();const A=new URL(L);this.#F=A.protocol===\"https:\",this.#$=A,this.#j=2,process.nextTick(F.#W,this)}ref(){this.#V\?.ref(),this.#G\?.ref()}unref(){this.#V\?.unref(),this.#G\?.unref()}#H(){if(this.#j!==2)return;const L=this.#$,j=this.#F;this.#j=0,@Bun.connect({data:this,socket:F.#Z,hostname:L.hostname,port:parseInt(L.port||(j\?\"443\":\"80\"),10),tls:j\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((A)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:A})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(F.#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(L){if(this.#B)super.removeEventListener(\"close\",this.#B);super.addEventListener(\"open\",L),this.#B=L}set onerror(L){if(this.#w)super.removeEventListener(\"error\",this.#w);super.addEventListener(\"error\",L),this.#w=L}set onmessage(L){if(this.#A)super.removeEventListener(\"message\",this.#A);super.addEventListener(\"message\",L),this.#A=L}}return Object.defineProperty(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ -- cgit v1.2.3 From f670c0fc1866352b846f092e4f0741b51f59ec1a Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Tue, 27 Jun 2023 18:23:56 -0700 Subject: don't overwrite `__esModule` --- src/js/builtins/Module.ts | 4 + src/js/out/WebCoreJSBuiltins.cpp | 158 +++++++++++++++++++-------------------- 2 files changed, 83 insertions(+), 79 deletions(-) diff --git a/src/js/builtins/Module.ts b/src/js/builtins/Module.ts index 6a0b70a37..0b5fcafe8 100644 --- a/src/js/builtins/Module.ts +++ b/src/js/builtins/Module.ts @@ -46,6 +46,8 @@ export function require(this: Module, id: string) { const exports = namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0 ? namespace.default + : namespace.__esModule + ? namespace : Object.create(namespace, { __esModule: { value: true } }); $requireMap.$set(id, $createCommonJSModule(id, exports, true)); return exports; @@ -83,6 +85,8 @@ export function require(this: Module, id: string) { // if they choose a module namespace?.[$commonJSSymbol] === 0 || namespace?.default?.[$commonJSSymbol] === 0 ? namespace.default + : namespace.__esModule + ? namespace : Object.create(namespace, { __esModule: { value: true } })); } } diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index d5c0e4d1b..f90125c70 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,g,j,q){\"use strict\";const v={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},w=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][q];var x=(async(y,z,B,C)=>{var F=this.onLoad.@get(B);if(!F)return this.onLoadAsync(y,null,null),null;for(let[K,Q]of F)if(K.test(z)){var G=Q({path:z,namespace:B,loader:C});while(G&&@isPromise(G)&&(@getPromiseInternalField(G,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)G=@getPromiseInternalField(G,@promiseFieldReactionsOrResult);if(G&&@isPromise(G))G=await G;if(!G||!@isObject(G))continue;var{contents:H,loader:J=C}=G;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=v[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(y,H,T),null}return this.onLoadAsync(y,null,null),null})(b,g,j,w);while(x&&@isPromise(x)&&(@getPromiseInternalField(x,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)x=@getPromiseInternalField(x,@promiseFieldReactionsOrResult);if(x&&@isPromise(x))x.then(()=>{},(y)=>{this.addError(b,y,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,q,v,w){\"use strict\";const x={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},y=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][w];var g=(async(z,B,C,F)=>{var G=this.onLoad.@get(C);if(!G)return this.onLoadAsync(z,null,null),null;for(let[K,Q]of G)if(K.test(B)){var j=Q({path:B,namespace:C,loader:F});while(j&&@isPromise(j)&&(@getPromiseInternalField(j,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)j=@getPromiseInternalField(j,@promiseFieldReactionsOrResult);if(j&&@isPromise(j))j=await j;if(!j||!@isObject(j))continue;var{contents:H,loader:J=F}=j;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=x[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(z,H,T),null}return this.onLoadAsync(z,null,null),null})(b,q,v,y);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(z)=>{this.addError(b,z,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -108,7 +108,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeCons const JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateWritableStreamCodeLength = 278; static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (d,_,u,N,f,p){\"use strict\";@assert(typeof f===\"number\"&&!@isNaN(f)&&f>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,d,_,u,N,f,p),@createWritableStreamFromInternal(j)})\n"; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (u,d,p,N,_,f){\"use strict\";@assert(typeof _===\"number\"&&!@isNaN(_)&&_>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,d,p,N,_,f),@createWritableStreamFromInternal(j)})\n"; // createInternalWritableStreamFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -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 w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; // initializeWritableStreamSlots const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = 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,B){\"use strict\";const h=@getByIdDirectPrivate(c,\"state\");if(h===\"closed\"||h===\"errored\")return @Promise.@resolve();const _=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(_!==@undefined)return _.promise.@promise;@assert(h===\"writable\"||h===\"erroring\");let f=!1;if(h===\"erroring\")f=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:f}),!f)@writableStreamStartErroring(c,B);return j.@promise})\n"; +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"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -180,7 +180,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAddWriteReques const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAddWriteRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength = 227; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAddWriteRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode = "(function (c){\"use strict\";@assert(@isWritableStreamLocked(c)),@assert(@getByIdDirectPrivate(c,\"state\")===\"writable\");const d=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(c,\"writeRequests\").push(d),d.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode = "(function (d){\"use strict\";@assert(@isWritableStreamLocked(d)),@assert(@getByIdDirectPrivate(d,\"state\")===\"writable\");const h=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(d,\"writeRequests\").push(h),h.@promise})\n"; // writableStreamCloseQueuedOrInFlight const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructAbility = 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 I=A.shift();I;I=A.shift())I.@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(_)},(B)=>{i.promise.@reject.@call(@undefined,B),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const p=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(p,\"errorSteps\").@call();const h=@getByIdDirectPrivate(i,\"storedError\"),A=@getByIdDirectPrivate(i,\"writeRequests\");for(var B=A.shift();B;B=A.shift())B.@reject.@call(@undefined,h);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const I=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(I===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),I.wasAlreadyErroring){I.promise.@reject.@call(@undefined,h),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(p,\"abortSteps\").@call(@undefined,I.reason).@then(()=>{I.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(_)=>{I.promise.@reject.@call(@undefined,_),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -268,7 +268,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAnd const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 516; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const h=@getByIdDirectPrivate(i,\"storedError\"),n=@getByIdDirectPrivate(i,\"closeRequest\");if(n!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),n.@reject.@call(@undefined,h),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(i,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,h),@markPromiseAsHandled(b.@promise)}})\n"; +const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const n=@getByIdDirectPrivate(i,\"storedError\"),h=@getByIdDirectPrivate(i,\"closeRequest\");if(h!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),h.@reject.@call(@undefined,n),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(i,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,n),@markPromiseAsHandled(b.@promise)}})\n"; // writableStreamStartErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility = 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 (d,P){\"use strict\";const g=@getByIdDirectPrivate(d,\"stream\");@assert(g!==@undefined);const W=@getByIdDirectPrivate(g,\"controller\");@assert(W!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(W,P);if(g!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const _=@getByIdDirectPrivate(g,\"state\");if(_===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(g,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(g)||_===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(g)||_===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(_===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(g,\"storedError\"));@assert(_===\"writable\");const f=@writableStreamAddWriteRequest(g);return @writableStreamDefaultControllerWrite(W,P,b),f})\n"; +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 f=@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 b=@writableStreamAddWriteRequest(W);return @writableStreamDefaultControllerWrite(_,P,f),b})\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 (_,d,B,v,P,U,f,j){\"use strict\";@assert(@isWritableStream(_)),@assert(@getByIdDirectPrivate(_,\"controller\")===@undefined),@putByIdDirectPrivate(d,\"stream\",_),@putByIdDirectPrivate(_,\"controller\",d),@resetQueue(@getByIdDirectPrivate(d,\"queue\")),@putByIdDirectPrivate(d,\"started\",-1),@putByIdDirectPrivate(d,\"startAlgorithm\",B),@putByIdDirectPrivate(d,\"strategySizeAlgorithm\",j),@putByIdDirectPrivate(d,\"strategyHWM\",f),@putByIdDirectPrivate(d,\"writeAlgorithm\",v),@putByIdDirectPrivate(d,\"closeAlgorithm\",P),@putByIdDirectPrivate(d,\"abortAlgorithm\",U);const q=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(_,q),@writableStreamDefaultControllerStart(d)})\n"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 573; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (P,f,v,j,E){\"use strict\";const p=new @WritableStreamDefaultController;let B=()=>{},q=()=>{return @Promise.@resolve()},_=()=>{return @Promise.@resolve()},F=()=>{return @Promise.@resolve()};if(\"start\"in v){const C=v[\"start\"];B=()=>@promiseInvokeOrNoopMethodNoCatch(f,C,[p])}if(\"write\"in v){const C=v[\"write\"];q=(x)=>@promiseInvokeOrNoopMethod(f,C,[x,p])}if(\"close\"in v){const C=v[\"close\"];_=()=>@promiseInvokeOrNoopMethod(f,C,[])}if(\"abort\"in v){const C=v[\"abort\"];F=(x)=>@promiseInvokeOrNoopMethod(f,C,[x])}@setUpWritableStreamDefaultController(P,p,B,q,_,F,j,E)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,P,_,j,p){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},f=()=>{return @Promise.@resolve()};if(\"start\"in _){const E=_[\"start\"];x=()=>@promiseInvokeOrNoopMethodNoCatch(P,E,[q])}if(\"write\"in _){const E=_[\"write\"];B=(F)=>@promiseInvokeOrNoopMethod(P,E,[F,q])}if(\"close\"in _){const E=_[\"close\"];C=()=>@promiseInvokeOrNoopMethod(P,E,[])}if(\"abort\"in _){const E=_[\"abort\"];f=(F)=>@promiseInvokeOrNoopMethod(P,E,[F])}@setUpWritableStreamDefaultController(v,q,x,B,C,f,j,p)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = 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 (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"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = "(function (i,d){\"use strict\";const q=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(q),@getByIdDirectPrivate(i,\"writeAlgorithm\").@call(@undefined,d).@then(()=>{@writableStreamFinishInFlightWrite(q);const v=@getByIdDirectPrivate(q,\"state\");if(@assert(v===\"writable\"||v===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),!@writableStreamCloseQueuedOrInFlight(q)&&v===\"writable\"){const M=@writableStreamDefaultControllerGetBackpressure(i);@writableStreamUpdateBackpressure(q,M)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(v)=>{if(@getByIdDirectPrivate(q,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(i);@writableStreamFinishInFlightWriteWithError(q,v)})})\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 (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"; +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"; #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,B,D,c,F,j){\"use strict\";if(D===@undefined)D=1;if(c===@undefined)c=()=>1;if(F===@undefined)F=0;if(j===@undefined)j=()=>1;@assert(D>=0),@assert(F>=0);const G={};@putByIdDirectPrivate(G,\"TransformStream\",!0);const I=new @TransformStream(G),v=@newPromiseCapability(@Promise);@initializeTransformStream(I,v.@promise,D,c,F,j);const E=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(I,E,x,B),q().@then(()=>{v.@resolve.@call()},(_)=>{v.@reject.@call(@undefined,_)}),I})\n"; // initializeTransformStream const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 449; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (d,p,v){\"use strict\";const b=new @TransformStreamDefaultController;let q=(j)=>{try{@transformStreamDefaultControllerEnqueue(b,j)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},_=()=>{return @Promise.@resolve()};if(\"transform\"in v)q=(j)=>{return @promiseInvokeOrNoopMethod(p,v[\"transform\"],[j,b])};if(\"flush\"in v)_=()=>{return @promiseInvokeOrNoopMethod(p,v[\"flush\"],[b])};@setUpTransformStreamDefaultController(d,b,q,_)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,p,v){\"use strict\";const b=new @TransformStreamDefaultController;let q=(d)=>{try{@transformStreamDefaultControllerEnqueue(b,d)}catch(j){return @Promise.@reject(j)}return @Promise.@resolve()},w=()=>{return @Promise.@resolve()};if(\"transform\"in v)q=(d)=>{return @promiseInvokeOrNoopMethod(p,v[\"transform\"],[d,b])};if(\"flush\"in v)w=()=>{return @promiseInvokeOrNoopMethod(p,v[\"flush\"],[b])};@setUpTransformStreamDefaultController(_,b,q,w)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = 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 (H,Y,z){\"use strict\";var L={path:\"node:process\",require:Y},I=(T)=>L.require(T),{Duplex:M,eos:N,destroy:P}=I(\"node:stream\"),Q=class T extends M{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return I(\"tty\").isatty(H)}get fd(){return H}constructor(){super({readable:!0,writable:!0})}#L(U){const V=this.#J;if(this.#J=null,V)V(U);else if(U)this.destroy(U);else if(!this.#z&&!this.#H)this.destroy()}_destroy(U,V){if(!U&&this.#J!==null){var j=class G extends Error{constructor(J=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(J,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};U=new j}if(this.#J===null)V(U);else if(this.#J=V,this.#j)P(this.#j,U)}setRawMode(U){}on(U,V){if(U===\"readable\")this.ref(),this.#G=!0;return super.on(U,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 U,V;const j=this.#Y.readMany();if(!j\?.then)({done:U,value:V}=j);else({done:U,value:V}=await j);if(!U){this.push(V[0]);const G=V.length;for(let J=1;J{if(this.#I){const j=this.#I;this.#I=null,j()}}),V.on(\"drain\",()=>{if(this.#K){const j=this.#K;this.#K=null,j()}}),N(V,(j)=>{if(this.#H=!1,j)P(V,j);this.#L(j)}),V}_write(U,V,j){var G=this.#j;if(!G)G=this.#N();if(G.write(U,V))j();else this.#K=j}_final(U){this.#j.end(),this.#I=(...V)=>U(...V)}};return new Q})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (Y,j,z){\"use strict\";var G={path:\"node:process\",require:j},H=(M)=>G.require(M),{Duplex:I,eos:J,destroy:K}=H(\"node:stream\"),L=class M extends I{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return H(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(N){const P=this.#J;if(this.#J=null,P)P(N);else if(N)this.destroy(N);else if(!this.#z&&!this.#H)this.destroy()}_destroy(N,P){if(!N&&this.#J!==null){var Q=class T extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new Q}if(this.#J===null)P(N);else if(this.#J=P,this.#j)K(this.#j,N)}setRawMode(N){}on(N,P){if(N===\"readable\")this.ref(),this.#G=!0;return super.on(N,P)}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 N,P;const Q=this.#Y.readMany();if(!Q\?.then)({done:N,value:P}=Q);else({done:N,value:P}=await Q);if(!N){this.push(P[0]);const T=P.length;for(let U=1;U{if(this.#I){const Q=this.#I;this.#I=null,Q()}}),P.on(\"drain\",()=>{if(this.#K){const Q=this.#K;this.#K=null,Q()}}),J(P,(Q)=>{if(this.#H=!1,Q)K(P,Q);this.#L(Q)}),P}_write(N,P,Q){var T=this.#j;if(!T)T=this.#N();if(T.write(N,P))Q();else this.#K=Q}_final(N){this.#j.end(),this.#I=(...P)=>N(...P)}};return new L})\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 _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let x=arguments[1],E=arguments[2];if(_===@undefined)_=null;if(E===@undefined)E={};if(x===@undefined)x={};let F={};if(_!==null){if(\"start\"in _){if(F[\"start\"]=_[\"start\"],typeof F[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(F[\"transform\"]=_[\"transform\"],typeof F[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(F[\"flush\"]=_[\"flush\"],typeof F[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const G=@extractHighWaterMark(E,0),I=@extractSizeAlgorithm(E),B=@extractHighWaterMark(x,1),u=@extractSizeAlgorithm(x),J=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,J.@promise,B,u,G,I),@setUpTransformStreamDefaultControllerFromTransformer(this,_,F),(\"start\"in F)){const j=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,F[\"start\"],[j]))().@then(()=>{J.@resolve.@call()},(v)=>{J.@reject.@call(@undefined,v)})}else J.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let j=arguments[0];if(@isObject(j)&&@getByIdDirectPrivate(j,\"TransformStream\"))return this;let q=arguments[1],v=arguments[2];if(j===@undefined)j=null;if(v===@undefined)v={};if(q===@undefined)q={};let x={};if(j!==null){if(\"start\"in j){if(x[\"start\"]=j[\"start\"],typeof x[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in j){if(x[\"transform\"]=j[\"transform\"],typeof x[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in j){if(x[\"flush\"]=j[\"flush\"],typeof x[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in j)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in j)@throwRangeError(\"TransformStream transformer has a writableType\")}const B=@extractHighWaterMark(v,0),E=@extractSizeAlgorithm(v),F=@extractHighWaterMark(q,1),G=@extractSizeAlgorithm(q),I=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,I.@promise,F,G,B,E),@setUpTransformStreamDefaultControllerFromTransformer(this,j,x),(\"start\"in x)){const J=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(j,x[\"start\"],[J]))().@then(()=>{I.@resolve.@call()},(u)=>{I.@reject.@call(@undefined,u)})}else I.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -714,9 +714,9 @@ const char* const s_moduleMainCode = "(function (){\"use strict\";return @requir 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 = 1005; +const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (_){\"use strict\";const t=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(t)return @evaluateCommonJSModule(t),t.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let M=@Loader.registry.@get(_);if(M\?.evaluated&&(M.state\?\?0)>=@ModuleReady){const l=M.module,y=@Loader.getModuleNamespaceObject(l),L=y\?.[@commonJSSymbol]===0||y\?.default\?.[@commonJSSymbol]===0\?y.default:Object.create(y,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,L,!0)),L}const f=@createCommonJSModule(_,{},!1);@requireMap.@set(_,f);var h=this.@require(_,f);if(h===-1){try{h=@requireESM(_)}catch(l){throw @requireMap.@delete(_),l}if(M=@Loader.registry.@get(_),M\?.evaluated&&(M.state\?\?0)>=@ModuleReady){const l=@Loader.getModuleNamespaceObject(M.module);return f.exports=l\?.[@commonJSSymbol]===0||l\?.default\?.[@commonJSSymbol]===0\?l.default:Object.create(l,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(f),f.exports})\n"; +const char* const s_moduleRequireCode = "(function (M){\"use strict\";const L=@requireMap.@get(M)||@requireMap.@get(M=@resolveSync(M,this.path,!1));if(L)return @evaluateCommonJSModule(L),L.exports;if(M.endsWith(\".json\")||M.endsWith(\".toml\")||M.endsWith(\".node\"))return @internalRequire(M);let b=@Loader.registry.@get(M);if(b\?.evaluated&&(b.state\?\?0)>=@ModuleReady){const h=b.module,f=@Loader.getModuleNamespaceObject(h),r=f\?.[@commonJSSymbol]===0||f\?.default\?.[@commonJSSymbol]===0\?f.default:f.__esModule\?f:Object.create(f,{__esModule:{value:!0}});return @requireMap.@set(M,@createCommonJSModule(M,r,!0)),r}const _=@createCommonJSModule(M,{},!1);@requireMap.@set(M,_);var S=this.@require(M,_);if(S===-1){try{S=@requireESM(M)}catch(h){throw @requireMap.@delete(M),h}if(b=@Loader.registry.@get(M),b\?.evaluated&&(b.state\?\?0)>=@ModuleReady){const h=@Loader.getModuleNamespaceObject(b.module);return _.exports=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(_),_.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,_){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:return r.getInt8(d);case 2:return r.getInt16(d,!0);case 3:{const u=r.getUint16(d,!0)+r.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return r.getInt32(d,!0);case 5:{const u=r.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+r.getUint32(d,!0)}case 6:{const u=r.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+r.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -846,7 +846,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntLECodeLength = 445; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,d){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return r.getUint8(a);case 2:return r.getUint16(a,!0);case 3:return r.getUint16(a,!0)+r.getUint8(a+2)*65536;case 4:return r.getUint32(a,!0);case 5:return r.getUint8(a+4)*4294967296+r.getUint32(a,!0);case 6:return r.getUint16(a+4,!0)*4294967296+r.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,r){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return d.getUint8(a);case 2:return d.getUint16(a,!0);case 3:return d.getUint16(a,!0)+d.getUint8(a+2)*65536;case 4:return d.getUint32(a,!0);case 5:return d.getUint8(a+4)*4294967296+d.getUint32(a,!0);case 6:return d.getUint16(a+4,!0)*4294967296+d.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1014,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 (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"; +const char* const s_jsBufferPrototypeWriteIntBECode = "(function (r,c,E){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(E){case 1:{d.setInt8(c,r);break}case 2:{d.setInt16(c,r,!1);break}case 3:{d.setUint16(c+1,r&65535,!1),d.setInt8(c,Math.floor(r*0.0000152587890625));break}case 4:{d.setInt32(c,r,!1);break}case 5:{d.setUint32(c+1,r|0,!1),d.setInt8(c,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(c+2,r|0,!1),d.setInt16(c,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return c+E})\n"; // writeUIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1022,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,E,c){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{r.setUint8(E,d);break}case 2:{r.setUint16(E,d,!0);break}case 3:{r.setUint16(E,d&65535,!0),r.setUint8(E+2,Math.floor(d*0.0000152587890625));break}case 4:{r.setUint32(E,d,!0);break}case 5:{r.setUint32(E,d|0,!0),r.setUint8(E+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{r.setUint32(E,d|0,!0),r.setUint16(E+4,Math.floor(d*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return E+c})\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; @@ -1150,7 +1150,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlWriteCodeLength = 70; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64url\")})\n"; +const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"base64url\")})\n"; // hexWrite const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (i,k){\"use strict\";var{buffer:m,byteOffset:q,byteLength:c}=this;function w(z,v){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=v,z>0\?z:0;else return zp\?x-p:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (c,p){\"use strict\";var{buffer:i,byteOffset:k,byteLength:m}=this;function q(x,z){if(x=@trunc(x),x===0||@isNaN(x))return 0;else if(x<0)return x+=z,x>0\?x:0;else return xv\?w-v:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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*z(){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 q=0,A=H(_,q);while(A!==-1)yield F.decode(_.subarray(q,A)),q=A+1,A=H(_,q);w=_.subarray(q)}}}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; @@ -1364,7 +1364,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericI const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength = 585; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericInitializeCode = "(function (i,_){\"use strict\";if(@putByIdDirectPrivate(i,\"ownerReadableStream\",_),@putByIdDirectPrivate(_,\"reader\",i),@getByIdDirectPrivate(_,\"state\")===@streamReadable)@putByIdDirectPrivate(i,\"closedPromiseCapability\",@newPromiseCapability(@Promise));else if(@getByIdDirectPrivate(_,\"state\")===@streamClosed)@putByIdDirectPrivate(i,\"closedPromiseCapability\",{@promise:@Promise.@resolve()});else @assert(@getByIdDirectPrivate(_,\"state\")===@streamErrored),@putByIdDirectPrivate(i,\"closedPromiseCapability\",{@promise:@newHandledRejectedPromise(@getByIdDirectPrivate(_,\"storedError\"))})})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericInitializeCode = "(function (_,i){\"use strict\";if(@putByIdDirectPrivate(_,\"ownerReadableStream\",i),@putByIdDirectPrivate(i,\"reader\",_),@getByIdDirectPrivate(i,\"state\")===@streamReadable)@putByIdDirectPrivate(_,\"closedPromiseCapability\",@newPromiseCapability(@Promise));else if(@getByIdDirectPrivate(i,\"state\")===@streamClosed)@putByIdDirectPrivate(_,\"closedPromiseCapability\",{@promise:@Promise.@resolve()});else @assert(@getByIdDirectPrivate(i,\"state\")===@streamErrored),@putByIdDirectPrivate(_,\"closedPromiseCapability\",{@promise:@newHandledRejectedPromise(@getByIdDirectPrivate(i,\"storedError\"))})})\n"; // privateInitializeReadableStreamDefaultController const JSC::ConstructAbility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1388,7 +1388,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamPipeToCodeLength = 427; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (_,c){\"use strict\";@assert(@isReadableStream(_));const g=new @ReadableStreamDefaultReader(_);@getByIdDirectPrivate(g,\"closedPromiseCapability\").@promise.@then(()=>{},(y)=>{c.error(y)});function h(){@readableStreamDefaultReaderRead(g).@then(function(y){if(y.done){c.close();return}try{c.enqueue(y.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}h()},function(y){c.error(y)})}h()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (c,g){\"use strict\";@assert(@isReadableStream(c));const h=new @ReadableStreamDefaultReader(c);@getByIdDirectPrivate(h,\"closedPromiseCapability\").@promise.@then(()=>{},(S)=>{g.error(S)});function y(){@readableStreamDefaultReaderRead(h).@then(function(S){if(S.done){g.close();return}try{g.enqueue(S.value)}catch(_){g.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(S){g.error(S)})}y()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1404,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,x,b,B,j){\"use strict\";const C=new @ReadableStreamDefaultController(_,w,f,x,@isReadableStream),q=()=>@promiseInvokeOrNoopMethod(w,B,[C]),D=(v)=>@promiseInvokeOrNoopMethod(w,j,[v]);@putByIdDirectPrivate(C,\"pullAlgorithm\",q),@putByIdDirectPrivate(C,\"cancelAlgorithm\",D),@putByIdDirectPrivate(C,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(C,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(_,\"readableStreamController\",C),@readableStreamDefaultControllerStart(C)})\n"; +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"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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 (D,E,k,w,x,z){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(E)),@assert(z===@undefined||@isAbortSignal(z)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let B={source:D,destination:E,preventAbort:w,preventCancel:x,preventClose:k,signal:z};if(B.reader=@acquireReadableStreamDefaultReader(D),B.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(D,\"disturbed\",!0),B.finalized=!1,B.shuttingDown=!1,B.promiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability.@resolve.@call(),B.pendingWritePromise=@Promise.@resolve(),z!==@undefined){const F=(G)=>{if(B.finalized)return;@pipeToShutdownWithAction(B,()=>{const _=!B.preventAbort&&@getByIdDirectPrivate(B.destination,\"state\")===\"writable\"\?@writableStreamAbort(B.destination,G):@Promise.@resolve(),T=!B.preventCancel&&@getByIdDirectPrivate(B.source,\"state\")===@streamReadable\?@readableStreamCancel(B.source,G):@Promise.@resolve();let q=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}q.@resolve.@call()},K=(L)=>{q.@reject.@call(@undefined,L)};return _.@then(J,K),T.@then(J,K),q.@promise},G)};if(@whenSignalAborted(z,F))return B.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(B),@pipeToErrorsMustBePropagatedBackward(B),@pipeToClosingMustBePropagatedForward(B),@pipeToClosingMustBePropagatedBackward(B),@pipeToLoop(B),B.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (D,x,_,z,f,B){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(x)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(x)),@assert(B===@undefined||@isAbortSignal(B)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let E={source:D,destination:x,preventAbort:z,preventCancel:f,preventClose:_,signal:B};if(E.reader=@acquireReadableStreamDefaultReader(D),E.writer=@acquireWritableStreamDefaultWriter(x),@putByIdDirectPrivate(D,\"disturbed\",!0),E.finalized=!1,E.shuttingDown=!1,E.promiseCapability=@newPromiseCapability(@Promise),E.pendingReadPromiseCapability=@newPromiseCapability(@Promise),E.pendingReadPromiseCapability.@resolve.@call(),E.pendingWritePromise=@Promise.@resolve(),B!==@undefined){const F=(G)=>{if(E.finalized)return;@pipeToShutdownWithAction(E,()=>{const H=!E.preventAbort&&@getByIdDirectPrivate(E.destination,\"state\")===\"writable\"\?@writableStreamAbort(E.destination,G):@Promise.@resolve(),k=!E.preventCancel&&@getByIdDirectPrivate(E.source,\"state\")===@streamReadable\?@readableStreamCancel(E.source,G):@Promise.@resolve();let J=@newPromiseCapability(@Promise),K=!0,L=()=>{if(K){K=!1;return}J.@resolve.@call()},q=(w)=>{J.@reject.@call(@undefined,w)};return H.@then(L,q),k.@then(L,q),J.@promise},G)};if(@whenSignalAborted(B,F))return E.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(E),@pipeToErrorsMustBePropagatedBackward(E),@pipeToClosingMustBePropagatedForward(E),@pipeToClosingMustBePropagatedBackward(E),@pipeToLoop(E),E.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1436,7 +1436,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToLoopCodeConstructorKin const JSC::ImplementationVisibility s_readableStreamInternalsPipeToLoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToLoopCodeLength = 110; static const JSC::Intrinsic s_readableStreamInternalsPipeToLoopCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToLoopCode = "(function (d){\"use strict\";if(d.shuttingDown)return;@pipeToDoReadWrite(d).@then((c)=>{if(c)@pipeToLoop(d)})})\n"; +const char* const s_readableStreamInternalsPipeToLoopCode = "(function (c){\"use strict\";if(c.shuttingDown)return;@pipeToDoReadWrite(c).@then((d)=>{if(d)@pipeToLoop(c)})})\n"; // pipeToDoReadWrite const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1444,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; @@ -1476,7 +1476,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagate const JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength = 324; static const JSC::Intrinsic s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode = "(function (m){\"use strict\";if(!@writableStreamCloseQueuedOrInFlight(m.destination)&&@getByIdDirectPrivate(m.destination,\"state\")!==\"closed\")return;const k=@makeTypeError(\"closing is propagated backward\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,k),k);return}@pipeToShutdown(m,k)})\n"; +const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode = "(function (k){\"use strict\";if(!@writableStreamCloseQueuedOrInFlight(k.destination)&&@getByIdDirectPrivate(k.destination,\"state\")!==\"closed\")return;const m=@makeTypeError(\"closing is propagated backward\");if(!k.preventCancel){@pipeToShutdownWithAction(k,()=>@readableStreamCancel(k.source,m),m);return}@pipeToShutdown(k,m)})\n"; // pipeToShutdownWithAction const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownWithActionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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,d){\"use strict\";if(m.shuttingDown)return;m.shuttingDown=!0;const h=arguments.length>2,g=arguments[2],j=()=>{d().@then(()=>{if(h)@pipeToFinalize(m,g);else @pipeToFinalize(m)},(b)=>{@pipeToFinalize(m,b)})};if(@getByIdDirectPrivate(m.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(m.destination)){m.pendingReadPromiseCapability.@promise.@then(()=>{m.pendingWritePromise.@then(j,j)},(_)=>@pipeToFinalize(m,_));return}j()})\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; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (i,_){\"use strict\";@assert(@isReadableStream(i)),@assert(typeof _===\"boolean\");var q=@getByIdDirectPrivate(i,\"start\");if(q)@putByIdDirectPrivate(i,\"start\",@undefined),q();const f=new @ReadableStreamDefaultReader(i),v={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};v.cancelPromiseCapability=@newPromiseCapability(@Promise);const g=@readableStreamTeePullFunction(v,f,_),w={};@putByIdDirectPrivate(w,\"pull\",g),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch1CancelFunction(v,i));const j={};@putByIdDirectPrivate(j,\"pull\",g),@putByIdDirectPrivate(j,\"cancel\",@readableStreamTeeBranch2CancelFunction(v,i));const x=new @ReadableStream(w),k=new @ReadableStream(j);return @getByIdDirectPrivate(f,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(v.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,y),@readableStreamDefaultControllerError(k.@readableStreamController,y),v.closedOrErrored=!0,!v.canceled1||!v.canceled2)v.cancelPromiseCapability.@resolve.@call()}),v.branch1=x,v.branch2=k,[x,k]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (f,k){\"use strict\";@assert(@isReadableStream(f)),@assert(typeof k===\"boolean\");var i=@getByIdDirectPrivate(f,\"start\");if(i)@putByIdDirectPrivate(f,\"start\",@undefined),i();const q=new @ReadableStreamDefaultReader(f),_={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};_.cancelPromiseCapability=@newPromiseCapability(@Promise);const v=@readableStreamTeePullFunction(_,q,k),g={};@putByIdDirectPrivate(g,\"pull\",v),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch1CancelFunction(_,f));const w={};@putByIdDirectPrivate(w,\"pull\",v),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(_,f));const x=new @ReadableStream(g),j=new @ReadableStream(w);return @getByIdDirectPrivate(q,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(_.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,y),@readableStreamDefaultControllerError(j.@readableStreamController,y),_.closedOrErrored=!0,!_.canceled1||!_.canceled2)_.cancelPromiseCapability.@resolve.@call()}),_.branch1=x,_.branch2=j,[x,j]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,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; @@ -1564,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 (j,v,w){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function x(f,A){if(A&&w\?.cancel){try{var B=w.cancel(A);@markPromiseAsHandled(B)}catch(q){}w=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),A)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",A);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!w.pull){x();return}if(!@isCallable(w.pull)){x(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",v);const _=@getByIdDirectPrivate(j,\"highWaterMark\");v.start({highWaterMark:!_||_<64\?64:_}),@startDirectStream.@call(v,j,w.pull,x),@putByIdDirectPrivate(j,\"reader\",{});var z=w.pull(v);if(v=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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 (_,H,c){\"use strict\";var f=!1,I=!1;try{var G=_.getReader(),P=G.readMany();if(P&&@isPromise(P))P=await P;if(P.done)return f=!0,H.end();var J=P.value.length;const D=@getByIdDirectPrivate(_,\"highWaterMark\");if(c)@startDirectStream.@call(H,_,@undefined,()=>!I&&@markPromiseAsHandled(_.cancel()));H.start({highWaterMark:D||0});for(var q=0,x=P.value,z=P.value.length;q!z&&@markPromiseAsHandled(_.cancel()));E.start({highWaterMark:q||0});for(var H=0,I=F.value,J=F.value.length;H{var j=@createFulfilledPromise({value:y,done:!1});return y=@undefined,@readableStreamClose(b),b=@undefined,j}}else if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(B,{value:@undefined,done:!0})}@readableStreamClose(b)})\n"; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (v){\"use strict\";var y=this.@controlledReadableStream;if(!y||@getByIdDirectPrivate(y,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=v;return}if(@putByIdDirectPrivate(y,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,v)}catch(C){}var S;try{S=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(C){if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(B,C)}@readableStreamError(y,C);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var j=@getByIdDirectPrivate(y,\"reader\");if(j&&@isReadableStreamDefaultReader(j)){var c=this._pendingRead;if(c&&@isPromise(c)&&S\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(c,{value:S,done:!1}),@readableStreamClose(y);return}}if(S\?.byteLength){var b=@getByIdDirectPrivate(j,\"readRequests\");if(b\?.isNotEmpty()){@readableStreamFulfillReadRequest(y,S,!1),@readableStreamClose(y);return}@putByIdDirectPrivate(y,\"state\",@streamReadable),this.@pull=()=>{var C=@createFulfilledPromise({value:S,done:!1});return S=@undefined,@readableStreamClose(y),y=@undefined,C}}else if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(B,{value:@undefined,done:!0})}@readableStreamClose(y)})\n"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var i=this._pendingRead;if(this._pendingRead=@undefined,i&&@isPromise(i)){var b=this.@sink.flush();if(b\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(i,{value:b,done:!1});else this._pendingRead=i}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var b=this.@sink.flush();if(b\?.byteLength)@readableStreamFulfillReadRequest(c,b,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var i=this.@sink.flush();if(i\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:i,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var i=this.@sink.flush();if(i\?.byteLength)@readableStreamFulfillReadRequest(c,i,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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 w,x=[],z=!1,_=!1,C=\"\",q=@toLength(0),E=@newPromiseCapability(@Promise),F=!1;return w={start(){},write(G){if(typeof G===\"string\"){var A=@toLength(G.length);if(A>0)C+=G,z=!0,q+=A;return A}if(!G||!(@ArrayBuffer.@isView(G)||G instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const j=@toLength(G.byteLength);if(j>0)if(_=!0,C.length>0)@arrayPush(x,C,G),C=\"\";else @arrayPush(x,G);return q+=j,j},flush(){return 0},end(){if(F)return\"\";return w.fulfill()},fulfill(){F=!0;const G=w.finishInternal();return @fulfillPromise(E.@promise,G),G},finishInternal(){if(!z&&!_)return\"\";if(z&&!_)return C;if(_&&!z)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(x));var G=new @Bun.ArrayBufferSink;G.start({highWaterMark:q,asUint8Array:!0});for(let A of x)G.write(A);if(x.length=0,C.length>0)G.write(C),C=\"\";return new globalThis.TextDecoder().decode(G.end())},close(){try{if(!F)F=!0,w.fulfill()}catch(G){}}},[w,E]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (v){\"use strict\";var x,z=[],A=!1,j=!1,E=\"\",q=@toLength(0),F=@newPromiseCapability(@Promise),G=!1;return x={start(){},write(w){if(typeof w===\"string\"){var C=@toLength(w.length);if(C>0)E+=w,A=!0,q+=C;return C}if(!w||!(@ArrayBuffer.@isView(w)||w instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const _=@toLength(w.byteLength);if(_>0)if(j=!0,E.length>0)@arrayPush(z,E,w),E=\"\";else @arrayPush(z,w);return q+=_,_},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(!A&&!j)return\"\";if(A&&!j)return E;if(j&&!A)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(z));var w=new @Bun.ArrayBufferSink;w.start({highWaterMark:q,asUint8Array:!0});for(let C of z)w.write(C);if(z.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"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,p){\"use strict\";var[m,b]=@createTextStream(p),f={@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\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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 (_,j){\"use strict\";var t=[],p=@newPromiseCapability(@Promise),b=!1;function d(){return b=!0,p.@resolve.@call(@undefined,t),t}var m={start(){},write(v){return @arrayPush(t,v),v.byteLength||v.length},flush(){return 0},end(){if(b)return[];return d()},close(){if(!b)d()}},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),p})\n"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1668,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 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"; +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"; // readableStreamError const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const v=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(v)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (_,i){\"use strict\";@assert(@isReadableStream(_)),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamErrored),@putByIdDirectPrivate(_,\"storedError\",i);const c=@getByIdDirectPrivate(_,\"reader\");if(!c)return;if(@isReadableStreamDefaultReader(c)){const h=@getByIdDirectPrivate(c,\"readRequests\");@putByIdDirectPrivate(c,\"readRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,i)}else{@assert(@isReadableStreamBYOBReader(c));const h=@getByIdDirectPrivate(c,\"readIntoRequests\");@putByIdDirectPrivate(c,\"readIntoRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,i)}@getByIdDirectPrivate(c,\"closedPromiseCapability\").@reject.@call(@undefined,i);const f=@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(f)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const y=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!y);const n=@getByIdDirectPrivate(y,\"state\");if(@putByIdDirectPrivate(y,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(y,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(y,\"readableStreamController\").@pull(@getByIdDirectPrivate(y,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1788,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 (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"; +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"; // isReadableStreamDisturbed const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,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 (B,m){\"use strict\";var y=@getByIdDirectPrivate(B,\"bunNativeType\"),q=@getByIdDirectPrivate(B,\"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=D(Y,_,p)}catch(A){return Z.error(A)}return K(z,Z,_)};var P=U,Q=W,O=X,[D,E,F,b,G,H,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=G\?new FinalizationRegistry(G):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=E;#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),H&&H(_,!1),F(_,Z)}static deinit=G;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(G&&q&&@enqueueJob(G,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"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (Q,G){\"use strict\";var N=@getByIdDirectPrivate(Q,\"bunNativeType\"),H=@getByIdDirectPrivate(Q,\"bunNativePtr\"),I=@lazyStreamPrototypeMap.@get(N);if(I===@undefined){let m=function(D){var{c:p,v:z}=this;this.c=@undefined,this.v=@undefined,X(D,p,z)},M=function(D){try{D.close()}catch(p){globalThis.reportError(p)}},_=function(D,p,z,A){A[0]=!1;var E;try{E=f(D,z,A)}catch(F){return p.error(F)}return X(E,p,z)};var j=m,P=M,q=_,[f,b,J,x,K,O,U]=@lazyLoad(N),W=[!1],X;X=function D(p,z,A){if(p&&@isPromise(p))return p.then(m.bind({c:z,v:A}),(E)=>z.error(E));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(W[0]||p===!1)@enqueueJob(M,z),W[0]=!1};const B=K\?new FinalizationRegistry(K):null;I=class D{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=(E)=>{E.enqueue(A)};if(B)B.register(this,p,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=b;#j(p){var z=this.#f;if(!z){p.close();return}_(z,p,p.byobRequest.view,W)}#m(p){var z=this.#f;B&&B.unregister(this.#b),O&&O(z,!1),J(z,p)}static deinit=K;static drain=U},@lazyStreamPrototypeMap.@set(N,I)}const Y=I.startSync(H,G);var Z;const{drain:y,deinit:L}=I;if(y)Z=y(H);if(Y===0){if(K&&H&&@enqueueJob(K,H),(Z\?.byteLength\?\?0)>0)return{start(m){m.enqueue(Z),m.close()},type:\"bytes\"};return{start(m){m.close()},type:\"bytes\"}}return new I(H,Y,Z)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var b=f.getReader(),_=b.readMany();async function g(j){if(j.done)return[];var p=j.value||[];while(!0){var q=await b.read();if(q.done)break;p=p.concat(q.value)}return p}if(_&&@isPromise(_))return _.@then(g);return g(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var b=f.getReader(),g=b.readMany();async function j(p){if(p.done)return[];var q=p.value||[];while(!0){var _=await b.read();if(_.done)break;q=q.concat(_.value)}return q}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1836,7 +1836,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 214; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (i){\"use strict\";const[_,h]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),d=@readStreamIntoSink(i,_,!1);if(d&&@isPromise(d))return @Promise.@resolve(d).@then(h.@promise);return h.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (i){\"use strict\";const[_,d]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),h=@readStreamIntoSink(i,_,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; // readableStreamToArrayBufferDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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 (O,_){\"use strict\";var q=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var x=@getByIdDirectPrivate(O,\"highWaterMark\");q.start(x\?{highWaterMark:x}:{});var v=@newPromiseCapability(@Promise),z=!1,A=_.pull,B=_.close,C={start(){},close(F){if(!z){if(z=!0,B)B();@fulfillPromise(v.@promise,q.end())}},end(){if(!z){if(z=!0,B)B();@fulfillPromise(v.@promise,q.end())}},flush(){return 0},write:q.write.bind(q)},D=!1;try{const F=A(C);if(F&&@isObject(F)&&@isPromise(F))return async function(G,j,w){while(!z)await w(G);return await j}(C,promise,A);return v.@promise}catch(F){return D=!0,@readableStreamError(O,F),@Promise.@reject(F)}finally{if(!D&&O)@readableStreamClose(O);C=B=q=A=O=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (j,w){\"use strict\";var _=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(j,\"underlyingSource\",@undefined);var x=@getByIdDirectPrivate(j,\"highWaterMark\");_.start(x\?{highWaterMark:x}:{});var O=@newPromiseCapability(@Promise),z=!1,q=w.pull,A=w.close,B={start(){},close(C){if(!z){if(z=!0,A)A();@fulfillPromise(O.@promise,_.end())}},end(){if(!z){if(z=!0,A)A();@fulfillPromise(O.@promise,_.end())}},flush(){return 0},write:_.write.bind(_)},v=!1;try{const C=q(B);if(C&&@isObject(C)&&@isPromise(C))return async function(D,F,G){while(!z)await G(D);return await F}(B,promise,q);return O.@promise}catch(C){return v=!0,@readableStreamError(j,C),@Promise.@reject(C)}finally{if(!v&&j)@readableStreamClose(j);B=A=_=q=j=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,_){\"use strict\";const j=@initializeArrayStream.@call(f,_,@undefined);_=@undefined;var k=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(q){}return k=@undefined,@Promise.@resolve(j.@promise)}catch(q){throw q}finally{f=@undefined,k=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,j){\"use strict\";const k=@initializeArrayStream.@call(_,j,@undefined);j=@undefined;var p=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var q=await p.read();if(q.done)break}try{p.releaseLock()}catch(f){}return p=@undefined,@Promise.@resolve(k.@promise)}catch(f){throw f}finally{_=@undefined,p=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (g){\"use strict\";var h=globalThis.Symbol.asyncIterator,j=async function*z(x,B){var D=x.getReader(),F;try{while(!0){var G,k;const i=D.readMany();if(@isPromise(i))({done:G,value:k}=await i);else({done:G,value:k}=i);if(G)return;yield*k}}catch(i){F=i}finally{if(D.releaseLock(),!B)x.cancel(F);if(F)throw F}},w=function z(){return j(this,!1)},q=function z({preventCancel:x=!1}={preventCancel:!1}){return j(this,x)};return @Object.@defineProperty(g,h,{value:w}),@Object.@defineProperty(g,\"values\",{value:q}),g})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1986,7 +1986,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const u=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(u){const f=u.@call(n,\"string\");if(typeof f===\"string\")switch(@argumentCount()){case 1:return new @Buffer(f);case 2:return new @Buffer(f,@argument(1));default:return new @Buffer(f,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2020,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 x=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!x)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const B=@getByIdDirectPrivate(x,\"state\");if(@putByIdDirectPrivate(x,\"disturbed\",!0),B===@streamClosed)return{value:[],size:0,done:!0};else if(B===@streamErrored)throw @getByIdDirectPrivate(x,\"storedError\");var w=@getByIdDirectPrivate(x,\"readableStreamController\"),A=@getByIdDirectPrivate(w,\"queue\");if(!A)return w.@pull(w).@then(function({done:H,value:I}){return H\?{done:!0,value:[],size:0}:{value:[I],size:1,done:!1}});const D=A.content;var C=A.size,E=D.toArray(!1),F=E.length;if(F>0){var _=@newArrayWithSize(F);if(@isReadableByteStreamController(w)){{const H=E[0];if(!(@ArrayBuffer.@isView(H)||H instanceof @ArrayBuffer))@putByValDirect(_,0,new @Uint8Array(H.buffer,H.byteOffset,H.byteLength));else @putByValDirect(_,0,H)}for(var j=1;j{if(H.done)return{value:[],size:0,done:!0};var I=@getByIdDirectPrivate(x,\"readableStreamController\"),J=@getByIdDirectPrivate(I,\"queue\"),K=[H.value].concat(J.content.toArray(!1)),d=K.length;if(@isReadableByteStreamController(I))for(var N=0;N0){var K=@newArrayWithSize(J);if(@isReadableByteStreamController(H)){{const Q=D[0];if(!(@ArrayBuffer.@isView(Q)||Q instanceof @ArrayBuffer))@putByValDirect(K,0,new @Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength));else @putByValDirect(K,0,Q)}for(var d=1;d{if(Q.done)return{value:[],size:0,done:!0};var B=@getByIdDirectPrivate(I,\"readableStreamController\"),k=@getByIdDirectPrivate(B,\"queue\"),S=[Q.value].concat(k.content.toArray(!1)),T=S.length;if(@isReadableByteStreamController(B))for(var w=0;w0}shift(){var{_head:z,_tail:A,_list:b,_capacityMask:E}=this;if(z===A)return @undefined;var x=b[z];if(@putByValDirect(b,z,@undefined),z=this._head=z+1&E,z<2&&A>1e4&&A<=b.length>>>2)this._shrinkArray();return x}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(z){var A=this._tail;if(@putByValDirect(this._list,A,z),this._tail=A+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(z){var A=this._list,b=@toLength(A.length);if(z||this._head>this._tail){var E=@toLength(this._head),x=@toLength(this._tail),F=@toLength(b-E+x),G=@newArrayWithSize(F),k=0;for(var B=E;B>>=1,this._capacityMask>>>=1}}return new w})\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; @@ -2174,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; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -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 n=@createCommonJSModule(b,{},!0);return process.dlopen(n,b),@requireMap.@set(b,n),n.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 v=@requireMap.@get(b);if(v)return v.exports;var _=q\?.default;if(_\?.[@commonJSSymbol]===0)q=_;return @requireMap.@set(b,@createCommonJSModule(b,q,!0)),q}})\n"; +const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var b=@requireMap.@get(_);const g=_.substring(_.length-5);if(b)return b.exports;if(g===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),k=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,k,!0)),k}else if(g===\".node\"){const q=@createCommonJSModule(_,{},!0);return process.dlopen(q,_),@requireMap.@set(_,q),q.exports}else if(g===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),k=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,k,!0)),k}else{var k=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var n=k\?.default;if(n\?.[@commonJSSymbol]===0)k=n;return @requireMap.@set(_,@createCommonJSModule(_,k,!0)),k}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,h={};return new Proxy(h,{get(u,f){const L=@requireMap.@get(f);if(L)return L;const t=@Loader.registry.@get(f);if(t\?.evaluated){const b=@Loader.getModuleNamespaceObject(t.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(f,c,!0);return @requireMap.@set(f,g),g}return h[f]},set(u,f,L){return @requireMap.@set(f,L),!0},has(u,f){return @requireMap.@has(f)||@Loader.registry.@has(f)},deleteProperty(u,f){return _.@delete(f),@requireMap.@delete(f),@Loader.registry.@delete(f),!0},ownKeys(u){var f=[...@requireMap.@keys()];const L=[...@Loader.registry.@keys()];for(let t of L)if(!f.includes(t))@arrayPush(f,t);return f},getPrototypeOf(u){return null},getOwnPropertyDescriptor(u,f){if(@requireMap.@has(f)||@Loader.registry.@has(f))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,t={};return new Proxy(t,{get(L,f){const h=@requireMap.@get(f);if(h)return h;const u=@Loader.registry.@get(f);if(u\?.evaluated){const b=@Loader.getModuleNamespaceObject(u.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(f,c,!0);return @requireMap.@set(f,g),g}return t[f]},set(L,f,h){return @requireMap.@set(f,h),!0},has(L,f){return @requireMap.@has(f)||@Loader.registry.@has(f)},deleteProperty(L,f){return _.@delete(f),@requireMap.@delete(f),@Loader.registry.@delete(f),!0},ownKeys(L){var f=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let u of h)if(!f.includes(u))@arrayPush(f,u);return f},getPrototypeOf(L){return null},getOwnPropertyDescriptor(L,f){if(@requireMap.@has(f)||@Loader.registry.@has(f))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2432,7 +2432,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,b=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!b){const _=@getByIdDirectPrivate(m,\"size\"),I=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",I),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,I!==@undefined\?I:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(b){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const I=@lazyLoadStream(this,_);if(I)@createReadableStreamController(this,I,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const m=_.type===\"direct\",v=!!_.@lazy,B=m||v;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!B){const I=@getByIdDirectPrivate(f,\"size\"),b=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,I,b!==@undefined\?b:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(m)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(B){const I=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,I);if(b)@createReadableStreamController(this,b,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2480,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 (_,w,x){\"use strict\";const A=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var H=globalThis[A];if(!H)H=globalThis[A]=[];var G=H[w];if(G===@undefined){var[I,J,K,F,L,N]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](w);G=class B{handleError;handleClosed;processResult;constructor(D,k){this.#_=k,this.#F=D,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),D.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var D=this.#_;this.#_=0,F(D),N(D)}_handleError(D){if(this.#$)return;this.#$=!0;var k=this.#_;this.#_=0,J(k,D),N(k)}#_;#$=!1;#F;_handleReadMany({value:D,done:k,size:q}){if(k){this.handleClosed();return}if(this.#$)return;K(this.#_,D,k,q)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(D){if(D&&@isPromise(D)){if(@getPromiseInternalField(D,@promiseFieldFlags)&@promiseStateFulfilled){const q=@getPromiseInternalField(D,@promiseFieldReactionsOrResult);if(q)D=q}}if(D&&@isPromise(D))return D.then(this.processResult,this.handleError),null;if(D.done)return this.handleClosed(),0;else if(D.value)return D.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const j=w+1;if(H.length{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(_)},(R)=>{if(@getByIdDirectPrivate(v,\"state\")===@streamReadable)@readableByteStreamControllerError(_,R)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (_,p,v){\"use strict\";if(!@isReadableStream(_))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(_,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",_),@putByIdDirectPrivate(this,\"underlyingByteSource\",p),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let f=@toNumber(v);if(@isNaN(f)||f<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",f);let R=p.autoAllocateChunkSize;if(R!==@undefined){if(R=@toNumber(R),R<=0||R===@Infinity||R===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",R),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const d=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(d,\"underlyingByteSource\"),\"start\",[d]).@then(()=>{@putByIdDirectPrivate(d,\"started\",1),@assert(!@getByIdDirectPrivate(d,\"pulling\")),@assert(!@getByIdDirectPrivate(d,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(d)},(b)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(d,b)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2676,7 +2676,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,_){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=u.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[_])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2684,7 +2684,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength = 316; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode = "(function (_,a){\"use strict\";@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"controlledReadableStream\"),\"state\")===@streamReadable),@readableByteStreamControllerClearPendingPullIntos(_),@putByIdDirectPrivate(_,\"queue\",@newQueue()),@readableStreamError(@getByIdDirectPrivate(_,\"controlledReadableStream\"),a)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode = "(function (a,_){\"use strict\";@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"state\")===@streamReadable),@readableByteStreamControllerClearPendingPullIntos(a),@putByIdDirectPrivate(a,\"queue\",@newQueue()),@readableStreamError(@getByIdDirectPrivate(a,\"controlledReadableStream\"),_)})\n"; // readableByteStreamControllerClose const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2708,7 +2708,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 272; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const _=@getByIdDirectPrivate(u,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const d=@getByIdDirectPrivate(u,\"controlledReadableStream\"),_=@getByIdDirectPrivate(d,\"state\");if(_===@streamErrored)return null;if(_===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; // readableStreamHasBYOBReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2740,7 +2740,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(d)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const F=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=F.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let P;try{P=new @Uint8Array(F.buffer,F.byteOffset,F.byteLength)}catch(R){return @Promise.@reject(R)}return @createFulfilledPromise({value:P,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let F;try{F=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(R){return @Promise.@reject(R)}const P={buffer:F,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(P)}const h=@readableStreamAddReadRequest(d);return @readableByteStreamControllerCallPullIfNeeded(_),h})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (d){\"use strict\";const h=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(h)),@getByIdDirectPrivate(d,\"queue\").content\?.isNotEmpty()){const P=@getByIdDirectPrivate(d,\"queue\").content.shift();@getByIdDirectPrivate(d,\"queue\").size-=P.byteLength,@readableByteStreamControllerHandleQueueDrain(d);let R;try{R=new @Uint8Array(P.buffer,P.byteOffset,P.byteLength)}catch(_){return @Promise.@reject(_)}return @createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(d,\"autoAllocateChunkSize\")!==@undefined){let P;try{P=@createUninitializedArrayBuffer(@getByIdDirectPrivate(d,\"autoAllocateChunkSize\"))}catch(_){return @Promise.@reject(_)}const R={buffer:P,byteOffset:0,byteLength:@getByIdDirectPrivate(d,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(d,\"pendingPullIntos\").push(R)}const F=@readableStreamAddReadRequest(h);return @readableByteStreamControllerCallPullIfNeeded(d),F})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 619; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const P=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(P,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const b=@getByIdDirectPrivate(P,\"reader\");if(b&&(@getByIdDirectPrivate(b,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(b,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(P)&&@getByIdDirectPrivate(@getByIdDirectPrivate(P,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const b=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(b,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const P=@getByIdDirectPrivate(b,\"reader\");if(P&&(@getByIdDirectPrivate(P,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(P,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(b)&&@getByIdDirectPrivate(@getByIdDirectPrivate(b,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; // readableByteStreamControllerCallPullIfNeeded const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2788,7 +2788,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,d,p){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:d,byteLength:p}),@getByIdDirectPrivate(_,\"queue\").size+=p})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,p,d){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:p,byteLength:d}),@getByIdDirectPrivate(_,\"queue\").size+=d})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2836,7 +2836,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength = 472; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode = "(function (a){\"use strict\";@assert(!@getByIdDirectPrivate(a,\"closeRequested\"));while(@getByIdDirectPrivate(a,\"pendingPullIntos\").isNotEmpty()){if(@getByIdDirectPrivate(a,\"queue\").size===0)return;let d=@getByIdDirectPrivate(a,\"pendingPullIntos\").peek();if(@readableByteStreamControllerFillDescriptorFromQueue(a,d))@readableByteStreamControllerShiftPendingDescriptor(a),@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(a,\"controlledReadableStream\"),d)}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode = "(function (d){\"use strict\";@assert(!@getByIdDirectPrivate(d,\"closeRequested\"));while(@getByIdDirectPrivate(d,\"pendingPullIntos\").isNotEmpty()){if(@getByIdDirectPrivate(d,\"queue\").size===0)return;let a=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek();if(@readableByteStreamControllerFillDescriptorFromQueue(d,a))@readableByteStreamControllerShiftPendingDescriptor(d),@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(d,\"controlledReadableStream\"),a)}})\n"; // readableByteStreamControllerFillDescriptorFromQueue const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2844,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 (j,v){\"use strict\";const w=v.bytesFilled-v.bytesFilled%v.elementSize,z=@getByIdDirectPrivate(j,\"queue\").sizew)q=G-v.bytesFilled,H=!0;while(q>0){let J=@getByIdDirectPrivate(j,\"queue\").content.peek();const k=q0),@assert(v.bytesFilledq)E=w-z.bytesFilled,G=!0;while(E>0){let H=@getByIdDirectPrivate(_,\"queue\").content.peek();const k=E0),@assert(z.bytesFilled0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,R)){const k=@readableByteStreamControllerConvertDescriptor(R);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}R.buffer=@transferBufferToCurrentRealm(R.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(R);const L=@readableStreamAddReadIntoRequest(N);return @readableByteStreamControllerCallPullIfNeeded(b),L})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (b,d){\"use strict\";const A=@getByIdDirectPrivate(b,\"controlledReadableStream\");let k=1;if(d.BYTES_PER_ELEMENT!==@undefined)k=d.BYTES_PER_ELEMENT;const E=d.constructor,L={buffer:d.buffer,byteOffset:d.byteOffset,byteLength:d.byteLength,bytesFilled:0,elementSize:k,ctor:E,readerType:\"byob\"};var _=@getByIdDirectPrivate(b,\"pendingPullIntos\");if(_\?.isNotEmpty())return L.buffer=@transferBufferToCurrentRealm(L.buffer),_.push(L),@readableStreamAddReadIntoRequest(A);if(@getByIdDirectPrivate(A,\"state\")===@streamClosed){const R=new E(L.buffer,L.byteOffset,0);return @createFulfilledPromise({value:R,done:!0})}if(@getByIdDirectPrivate(b,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,L)){const R=@readableByteStreamControllerConvertDescriptor(L);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const R=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,R),@Promise.@reject(R)}}L.buffer=@transferBufferToCurrentRealm(L.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(L);const N=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(b),N})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2952,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 F 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(L){L.#H()}static#X(L,j){const A=L.data,G=A.#L\?`Last-Event-ID: ${A.#L}\\r\\n`:\"\",J=`GET ${j.pathname}${j.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${G}\\r\\n`,M=L.write(J);if(M!==J.length)A.#K=J.substring(M)}static#Y(L,j,A){for(;;){if(A>=j.length)return;let G=-1,J=j.indexOf(\"\\r\\n\",A);const M=J+2;if(J>0)if(L.#O===0){const W=parseInt(j.substring(A,J),16);if(W===0){L.#j=2,L.#G\?.end();return}G=M+W}else G=j.length;else{if(L.#J.length===0){L.#J+=j.substring(A);return}G=j.length}let O=j.substring(M,G);A=G+2;let Q=0,U=O.indexOf(\"\\n\\n\");if(U==-1){L.#J+=j.substring(M);return}if(L.#J.length)L.#J+=O,O=L.#J,L.#J=\"\";let V=!0;while(V){const W=O.substring(Q,U);let X,w=\"\",B,Y=0,K=-1;for(;;){let z=W.indexOf(\"\\n\",Y);if(z===-1){if(Y>=W.length)break;z=W.length}const H=W.substring(Y,z);if(H.startsWith(\"data:\"))if(w.length)w+=`\\n${H.substring(5).trim()}`;else w=H.substring(5).trim();else if(H.startsWith(\"event:\"))X=H.substring(6).trim();else if(H.startsWith(\"id:\"))B=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(K=parseInt(H.substring(6).trim(),10),@isNaN(K))K=-1}Y=z+1}if(L.#L=B||\"\",K>=0)L.#U=K;if(w||B||X)L.dispatchEvent(new MessageEvent(X||\"message\",{data:w||\"\",origin:L.#$.origin,source:L,lastEventId:B}));if(O.length===U+2){V=!1;break}const Z=O.indexOf(\"\\n\\n\",U+1);if(Z===-1)break;Q=U,U=Z}}}static#Z={open(L){const j=L.data;if(j.#G=L,!j.#F)F.#X(L,j.#$)},handshake(L,j,A){const G=L.data;if(j)F.#X(L,G.#$);else G.#j=2,G.dispatchEvent(new ErrorEvent(\"error\",{error:A})),L.end()},data(L,j){const A=L.data;switch(A.#j){case 0:{let G=j.toString();const J=G.indexOf(\"\\r\\n\\r\\n\");if(J===-1){A.#J+=G;return}if(A.#J.length)A.#J+=G,G=A.#J,A.#J=\"\";const M=G.substring(0,J),O=M.indexOf(\"\\r\\n\");if(O===-1){A.#j=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),L.end();return}const Q=M.substring(0,O);if(Q!==\"HTTP/1.1 200 OK\"){A.#j=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Q)})),L.end();return}let U=O+1,V=!1,W=-1;for(;;){let w=M.indexOf(\"\\r\\n\",U);if(w===-1){if(U>=M.length){if(!V)A.#j=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),L.end();return}w=M.length}const B=M.substring(U+1,w),Y=B.indexOf(\":\"),K=B.substring(0,Y),Z=K.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(U=w+1,Z)if(B.endsWith(\" text/event-stream\"))V=!0;else{A.#j=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),L.end();return}else if(K.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(W=parseInt(B.substring(Y+1).trim(),10),@isNaN(W)||W<=0){A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),L.end();return}if(V)break}else if(K.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(B.substring(Y+1).trim()!==\"chunked\"){A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),L.end();return}if(W=0,V)break}}A.#O=W,A.#j=1,A.dispatchEvent(new Event(\"open\"));const X=G.substring(J+4);if(F.#Y(A,X,0),A.#O>0){if(A.#Q+=X.length,A.#Q>=A.#O)A.#j=2,L.end()}return}case 1:if(F.#Y(A,j.toString(),2),A.#O>0){if(A.#Q+=j.byteLength,A.#Q>=A.#O)A.#j=2,L.end()}return;default:break}},drain(L){const j=L.data;if(j.#j===0){const A=j.#J;if(A.length){const G=L.write(A);if(G!==A.length)L.data.#K=A.substring(G);else L.data.#K=\"\"}}},close:F.#z,end(L){F.#z(L).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(L){F.#z(L).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(L){const j=L.data;if(j.#G=null,j.#Q=0,j.#j=2,j.#M){if(j.#V)clearTimeout(j.#V);j.#V=setTimeout(F.#W,j.#U,j)}return j}constructor(L,j=@undefined){super();const A=new URL(L);this.#F=A.protocol===\"https:\",this.#$=A,this.#j=2,process.nextTick(F.#W,this)}ref(){this.#V\?.ref(),this.#G\?.ref()}unref(){this.#V\?.unref(),this.#G\?.unref()}#H(){if(this.#j!==2)return;const L=this.#$,j=this.#F;this.#j=0,@Bun.connect({data:this,socket:F.#Z,hostname:L.hostname,port:parseInt(L.port||(j\?\"443\":\"80\"),10),tls:j\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((A)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:A})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(F.#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(L){if(this.#B)super.removeEventListener(\"close\",this.#B);super.addEventListener(\"open\",L),this.#B=L}set onerror(L){if(this.#w)super.removeEventListener(\"error\",this.#w);super.addEventListener(\"error\",L),this.#w=L}set onmessage(L){if(this.#A)super.removeEventListener(\"message\",this.#A);super.addEventListener(\"message\",L),this.#A=L}}return Object.defineProperty(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class j extends EventTarget{#Q;#B;#F;#G;#J;#U=!1;#V=null;#W=\"\";#M=\"\";#$=\"\";#j=!0;#X=0;#Y=0;#Z=0;#O=null;static#K(V){V.#A()}static#w(V,w){const A=V.data,L=A.#$\?`Last-Event-ID: ${A.#$}\\r\\n`:\"\",U=`GET ${w.pathname}${w.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${L}\\r\\n`,W=V.write(U);if(W!==U.length)A.#M=U.substring(W)}static#L(V,w,A){for(;;){if(A>=w.length)return;let L=-1,U=w.indexOf(\"\\r\\n\",A);const W=U+2;if(U>0)if(V.#X===0){const z=parseInt(w.substring(A,U),16);if(z===0){V.#B=2,V.#V\?.end();return}L=W+z}else L=w.length;else{if(V.#W.length===0){V.#W+=w.substring(A);return}L=w.length}let X=w.substring(W,L);A=L+2;let Y=0,B=X.indexOf(\"\\n\\n\");if(B==-1){V.#W+=w.substring(W);return}if(V.#W.length)V.#W+=X,X=V.#W,V.#W=\"\";let Z=!0;while(Z){const z=X.substring(Y,B);let F,M=\"\",O,G=0,J=-1;for(;;){let K=z.indexOf(\"\\n\",G);if(K===-1){if(G>=z.length)break;K=z.length}const Q=z.substring(G,K);if(Q.startsWith(\"data:\"))if(M.length)M+=`\\n${Q.substring(5).trim()}`;else M=Q.substring(5).trim();else if(Q.startsWith(\"event:\"))F=Q.substring(6).trim();else if(Q.startsWith(\"id:\"))O=Q.substring(3).trim();else if(Q.startsWith(\"retry:\")){if(J=parseInt(Q.substring(6).trim(),10),@isNaN(J))J=-1}G=K+1}if(V.#$=O||\"\",J>=0)V.#Z=J;if(M||O||F)V.dispatchEvent(new MessageEvent(F||\"message\",{data:M||\"\",origin:V.#Q.origin,source:V,lastEventId:O}));if(X.length===B+2){Z=!1;break}const H=X.indexOf(\"\\n\\n\",B+1);if(H===-1)break;Y=B,B=H}}}static#z={open(V){const w=V.data;if(w.#V=V,!w.#U)j.#w(V,w.#Q)},handshake(V,w,A){const L=V.data;if(w)j.#w(V,L.#Q);else L.#B=2,L.dispatchEvent(new ErrorEvent(\"error\",{error:A})),V.end()},data(V,w){const A=V.data;switch(A.#B){case 0:{let L=w.toString();const U=L.indexOf(\"\\r\\n\\r\\n\");if(U===-1){A.#W+=L;return}if(A.#W.length)A.#W+=L,L=A.#W,A.#W=\"\";const W=L.substring(0,U),X=W.indexOf(\"\\r\\n\");if(X===-1){A.#B=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),V.end();return}const Y=W.substring(0,X);if(Y!==\"HTTP/1.1 200 OK\"){A.#B=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Y)})),V.end();return}let B=X+1,Z=!1,z=-1;for(;;){let M=W.indexOf(\"\\r\\n\",B);if(M===-1){if(B>=W.length){if(!Z)A.#B=2,A.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}M=W.length}const O=W.substring(B+1,M),G=O.indexOf(\":\"),J=O.substring(0,G),H=J.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(B=M+1,H)if(O.endsWith(\" text/event-stream\"))Z=!0;else{A.#B=2,A.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(J.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(z=parseInt(O.substring(G+1).trim(),10),@isNaN(z)||z<=0){A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),V.end();return}if(Z)break}else if(J.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(O.substring(G+1).trim()!==\"chunked\"){A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),V.end();return}if(z=0,Z)break}}A.#X=z,A.#B=1,A.dispatchEvent(new Event(\"open\"));const F=L.substring(U+4);if(j.#L(A,F,0),A.#X>0){if(A.#Y+=F.length,A.#Y>=A.#X)A.#B=2,V.end()}return}case 1:if(j.#L(A,w.toString(),2),A.#X>0){if(A.#Y+=w.byteLength,A.#Y>=A.#X)A.#B=2,V.end()}return;default:break}},drain(V){const w=V.data;if(w.#B===0){const A=w.#W;if(A.length){const L=V.write(A);if(L!==A.length)V.data.#M=A.substring(L);else V.data.#M=\"\"}}},close:j.#H,end(V){j.#H(V).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(V){j.#H(V).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#H(V){const w=V.data;if(w.#V=null,w.#Y=0,w.#B=2,w.#j){if(w.#O)clearTimeout(w.#O);w.#O=setTimeout(j.#K,w.#Z,w)}return w}constructor(V,w=@undefined){super();const A=new URL(V);this.#U=A.protocol===\"https:\",this.#Q=A,this.#B=2,process.nextTick(j.#K,this)}ref(){this.#O\?.ref(),this.#V\?.ref()}unref(){this.#O\?.unref(),this.#V\?.unref()}#A(){if(this.#B!==2)return;const V=this.#Q,w=this.#U;this.#B=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((A)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:A})),this.#j){if(this.#O)this.#O.unref\?.();this.#O=setTimeout(j.#K,1000,this)}})}get url(){return this.#Q.href}get readyState(){return this.#B}close(){this.#j=!1,this.#B=2,this.#V\?.unref(),this.#V\?.end()}get onopen(){return this.#J}get onerror(){return this.#F}get onmessage(){return this.#G}set onopen(V){if(this.#J)super.removeEventListener(\"close\",this.#J);super.addEventListener(\"open\",V),this.#J=V}set onerror(V){if(this.#F)super.removeEventListener(\"error\",this.#F);super.addEventListener(\"error\",V),this.#F=V}set onmessage(V){if(this.#G)super.removeEventListener(\"message\",this.#G);super.addEventListener(\"message\",V),this.#G=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"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ -- cgit v1.2.3 From 0de5bb22af427dcad57731d7063f8678b13265e2 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 28 Jun 2023 11:20:59 +0300 Subject: [install] workaround run-time module loading issue (#3432) --- src/bun.js/module_loader.zig | 6 --- src/install/install.zig | 40 ++++++++++++++--- src/resolver/resolver.zig | 27 ++++++----- test/cli/install/bun-run.test.ts | 96 ++++++++++++++++++++++++++++++++++++++++ test/cli/install/bunx.test.ts | 80 +-------------------------------- 5 files changed, 143 insertions(+), 106 deletions(-) create mode 100644 test/cli/install/bun-run.test.ts diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index b25bb4b10..6fd4fef99 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -271,14 +271,8 @@ pub const ModuleLoader = struct { pub fn onPoll(this: *Queue) void { debug("onPoll", .{}); - var pm = this.vm().packageManager(); - this.runTasks(); - _ = pm.scheduleTasks(); - this.runTasks(); - this.pollModules(); - _ = pm.flushDependencyQueue(); } pub fn runTasks(this: *Queue) void { diff --git a/src/install/install.zig b/src/install/install.zig index 9465c4897..87f931291 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -1718,9 +1718,8 @@ pub const PackageManager = struct { } pub fn wake(this: *PackageManager) void { - if (this.onWake.context != null) { - this.onWake.getHandler()(this.onWake.context.?, this); - return; + if (this.onWake.context) |ctx| { + this.onWake.getHandler()(ctx, this); } _ = this.wait_count.fetchAdd(1, .Monotonic); @@ -1791,12 +1790,37 @@ pub const PackageManager = struct { return .{ .failure = err }; }; - const resolution_id = this.lockfile.buffers.resolutions.items[index]; + const resolution_id = switch (this.lockfile.buffers.resolutions.items[index]) { + invalid_package_id => brk: { + this.drainDependencyList(); + + switch (this.options.log_level) { + inline else => |log_level| { + if (log_level.showProgress()) this.startProgressBarIfNone(); + while (this.pending_tasks > 0) : (this.sleep()) { + this.runTasks( + void, + {}, + .{ + .onExtract = {}, + .onResolve = {}, + .onPackageManifestError = {}, + .onPackageDownloadError = {}, + }, + log_level, + ) catch |err| { + return .{ .failure = err }; + }; + } + }, + } - // check if we managed to synchronously resolve the dependency - if (resolution_id == invalid_package_id) return .{ .pending = index }; + break :brk this.lockfile.buffers.resolutions.items[index]; + }, + // we managed to synchronously resolve the dependency + else => |pkg_id| pkg_id, + }; - this.drainDependencyList(); return .{ .resolution = .{ .resolution = this.lockfile.packages.items(.resolution)[resolution_id], @@ -5310,6 +5334,8 @@ pub const PackageManager = struct { manager.progress.supports_ansi_escape_codes = Output.enable_ansi_colors_stderr; manager.root_progress_node = manager.progress.start("", 0); manager.root_download_node = manager.root_progress_node.start(ProgressStrings.download(), 0); + } else { + manager.options.log_level = .default_no_progress; } if (!manager.options.enable.cache) { diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 40b106f3a..d9f4dc887 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -534,20 +534,19 @@ pub const Resolver = struct { dir_cache: *DirInfo.HashMap, pub fn getPackageManager(this: *Resolver) *PackageManager { - if (this.package_manager != null) { - return this.package_manager.?; - } - bun.HTTPThead.init() catch unreachable; - this.package_manager = PackageManager.initWithRuntime( - this.log, - this.opts.install, - this.allocator, - .{}, - this.env_loader.?, - ) catch @panic("Failed to initialize package manager"); - this.package_manager.?.onWake = this.onWakePackageManager; - - return this.package_manager.?; + return this.package_manager orelse brk: { + bun.HTTPThead.init() catch unreachable; + const pm = PackageManager.initWithRuntime( + this.log, + this.opts.install, + this.allocator, + .{}, + this.env_loader.?, + ) catch @panic("Failed to initialize package manager"); + pm.onWake = this.onWakePackageManager; + this.package_manager = pm; + break :brk pm; + }; } pub inline fn usePackageManager(self: *const ThisResolver) bool { diff --git a/test/cli/install/bun-run.test.ts b/test/cli/install/bun-run.test.ts new file mode 100644 index 000000000..fecbfc3d5 --- /dev/null +++ b/test/cli/install/bun-run.test.ts @@ -0,0 +1,96 @@ +import { file, spawn } from "bun"; +import { afterEach, beforeEach, expect, it } from "bun:test"; +import { bunExe, bunEnv as env } from "harness"; +import { mkdtemp, realpath, rm, writeFile } from "fs/promises"; +import { tmpdir } from "os"; +import { join } from "path"; +import { readdirSorted } from "./dummy.registry"; + +let run_dir: string; + +beforeEach(async () => { + run_dir = await realpath(await mkdtemp(join(tmpdir(), "bun-run.test"))); +}); +afterEach(async () => { + await rm(run_dir, { force: true, recursive: true }); +}); + +it("should download dependency to run local file", async () => { + await writeFile( + join(run_dir, "test.js"), + ` + const { minify } = require("uglify-js@3.17.4"); + + console.log(minify("print(6 * 7)").code); + `, + ); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "test.js"], + cwd: run_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env: { + ...env, + BUN_INSTALL_CACHE_DIR: join(run_dir, ".cache"), + }, + }); + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toBe(""); + expect(stdout).toBeDefined(); + const out = await new Response(stdout).text(); + expect(out.split(/\r?\n/)).toEqual(["print(42);", ""]); + expect(await exited).toBe(0); + expect(await readdirSorted(run_dir)).toEqual([".cache", "test.js"]); +}); + +it("should download dependencies to run local file", async () => { + await writeFile( + join(run_dir, "test.js"), + ` + import { file } from "bun"; + import decompress from "decompress@4.2.1"; + + const buffer = await file("${join(import.meta.dir, "baz-0.0.3.tgz")}").arrayBuffer(); + for (const entry of await decompress(Buffer.from(buffer))) { + console.log(\`\${entry.type}: \${entry.path}\`); + } + `, + ); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "test.js"], + cwd: run_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env: { + ...env, + BUN_INSTALL_CACHE_DIR: join(run_dir, ".cache"), + }, + }); + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toBe(""); + expect(await readdirSorted(run_dir)).toEqual([".cache", "test.js"]); + expect(await readdirSorted(join(run_dir, ".cache"))).toContain("decompress"); + expect(await readdirSorted(join(run_dir, ".cache", "decompress"))).toEqual(["4.2.1"]); + expect(await readdirSorted(join(run_dir, ".cache", "decompress", "4.2.1"))).toEqual([ + "index.js", + "license", + "package.json", + "readme.md", + ]); + expect(await file(join(run_dir, ".cache", "decompress", "4.2.1", "index.js")).text()).toContain( + "\nmodule.exports = ", + ); + expect(stdout).toBeDefined(); + const out = await new Response(stdout).text(); + expect(out.split(/\r?\n/)).toEqual([ + "directory: package/", + "file: package/index.js", + "file: package/package.json", + "", + ]); + expect(await exited).toBe(0); +}); diff --git a/test/cli/install/bunx.test.ts b/test/cli/install/bunx.test.ts index 3605f5b6b..70d7aac29 100644 --- a/test/cli/install/bunx.test.ts +++ b/test/cli/install/bunx.test.ts @@ -1,4 +1,4 @@ -import { file, spawn } from "bun"; +import { spawn } from "bun"; import { afterEach, beforeEach, expect, it } from "bun:test"; import { bunExe, bunEnv as env } from "harness"; import { mkdtemp, realpath, rm, writeFile } from "fs/promises"; @@ -109,84 +109,6 @@ it("should work for @scoped packages", async () => { expect(await cached.exited).toBe(0); }); -it("should download dependency to run local file", async () => { - await writeFile( - join(x_dir, "test.js"), - ` -const { minify } = require("uglify-js@3.17.4"); - -console.log(minify("print(6 * 7)").code); -`, - ); - const { stdout, stderr, exited } = spawn({ - cmd: [bunExe(), "test.js"], - cwd: x_dir, - stdout: null, - stdin: "pipe", - stderr: "pipe", - env: { - ...env, - BUN_INSTALL_CACHE_DIR: join(x_dir, ".cache"), - }, - }); - expect(stderr).toBeDefined(); - const err = await new Response(stderr).text(); - expect(err).toBe(""); - expect(stdout).toBeDefined(); - const out = await new Response(stdout).text(); - expect(out.split(/\r?\n/)).toEqual(["print(42);", ""]); - expect(await exited).toBe(0); - expect(await readdirSorted(x_dir)).toEqual([".cache", "test.js"]); -}); - -it("should download dependencies to run local file", async () => { - await writeFile( - join(x_dir, "test.js"), - ` -import { file } from "bun"; -import decompress from "decompress@4.2.1"; - -const buffer = await file("${join(import.meta.dir, "baz-0.0.3.tgz")}").arrayBuffer(); -for (const entry of await decompress(Buffer.from(buffer))) { - console.log(\`\${entry.type}: \${entry.path}\`); -} -`, - ); - const { stdout, stderr, exited } = spawn({ - cmd: [bunExe(), "test.js"], - cwd: x_dir, - stdout: null, - stdin: "pipe", - stderr: "pipe", - env: { - ...env, - BUN_INSTALL_CACHE_DIR: join(x_dir, ".cache"), - }, - }); - expect(stderr).toBeDefined(); - const err = await new Response(stderr).text(); - expect(err).toBe(""); - expect(await readdirSorted(x_dir)).toEqual([".cache", "test.js"]); - expect(await readdirSorted(join(x_dir, ".cache"))).toContain("decompress"); - expect(await readdirSorted(join(x_dir, ".cache", "decompress"))).toEqual(["4.2.1"]); - expect(await readdirSorted(join(x_dir, ".cache", "decompress", "4.2.1"))).toEqual([ - "index.js", - "license", - "package.json", - "readme.md", - ]); - expect(await file(join(x_dir, ".cache", "decompress", "4.2.1", "index.js")).text()).toContain("\nmodule.exports = "); - expect(stdout).toBeDefined(); - const out = await new Response(stdout).text(); - expect(out.split(/\r?\n/)).toEqual([ - "directory: package/", - "file: package/index.js", - "file: package/package.json", - "", - ]); - expect(await exited).toBe(0); -}); - it("should execute from current working directory", async () => { await writeFile( join(x_dir, "test.js"), -- cgit v1.2.3 From e6e3d9e368919a8433243099d4ce8af01ad08bd9 Mon Sep 17 00:00:00 2001 From: Silas Rech Date: Wed, 28 Jun 2023 20:27:02 +0200 Subject: Fix .randomInt() export (#3438) --- src/js/node/crypto.js | 2 +- src/js/out/modules/node/crypto.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/node/crypto.js b/src/js/node/crypto.js index c6968bbd5..e75182429 100644 --- a/src/js/node/crypto.js +++ b/src/js/node/crypto.js @@ -23856,6 +23856,6 @@ export const { createCredentials, constants, } = crypto_exports; -export { DEFAULT_ENCODING, getRandomValues, randomUUID, scrypt, scryptSync, timingSafeEqual, webcrypto }; +export { DEFAULT_ENCODING, getRandomValues, randomUUID, randomInt, scrypt, scryptSync, timingSafeEqual, webcrypto }; export default crypto_exports; /*! safe-buffer. MIT License. Feross Aboukhadijeh */ diff --git a/src/js/out/modules/node/crypto.js b/src/js/out/modules/node/crypto.js index 9db837693..ed1935be8 100644 --- a/src/js/out/modules/node/crypto.js +++ b/src/js/out/modules/node/crypto.js @@ -1,4 +1,4 @@ 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(),ZZ=(...$)=>H$.randomInt(...$),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,GZ="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,VZ="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(VZ,"name",{value:"::bunternal::"}),Object.defineProperty(GZ,"name",{value:"::bunternal::"}));var C$=H$;j$($Z,{DEFAULT_ENCODING:()=>T$,getRandomValues:()=>QZ,randomUUID:()=>YZ,randomInt:()=>ZZ,scrypt:()=>VZ,scryptSync:()=>GZ,timingSafeEqual:()=>D$,webcrypto:()=>C$,subtle:()=>C$.subtle});var{randomBytes:UZ,rng:XZ,pseudoRandomBytes:KZ,prng:IZ,Hash:OZ,createHash:JZ,createHmac:FZ,Hmac:AZ,getHashes:HZ,pbkdf2:WZ,pbkdf2Sync:EZ,Cipher:TZ,createCipher:DZ,Cipheriv:CZ,createCipheriv:LZ,Decipher:RZ,createDecipher:PZ,Decipheriv:zZ,createDecipheriv:MZ,getCiphers:SZ,listCiphers:vZ,DiffieHellmanGroup:qZ,createDiffieHellmanGroup:jZ,getDiffieHellman:kZ,createDiffieHellman:gZ,DiffieHellman:_Z,createSign:NZ,Sign:xZ,createVerify:BZ,Verify:yZ,createECDH:wZ,publicEncrypt:pZ,privateEncrypt:fZ,publicDecrypt:cZ,privateDecrypt:hZ,randomFill:dZ,randomFillSync:bZ,createCredentials:lZ,constants:oZ}=$Z;var nZ=$Z;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{C$ as webcrypto,D$ as timingSafeEqual,GZ as scryptSync,VZ as scrypt,XZ as rng,YZ as randomUUID,bZ as randomFillSync,dZ as randomFill,UZ as randomBytes,pZ as publicEncrypt,cZ as publicDecrypt,KZ as pseudoRandomBytes,IZ as prng,fZ as privateEncrypt,hZ as privateDecrypt,EZ as pbkdf2Sync,WZ as pbkdf2,vZ as listCiphers,QZ as getRandomValues,HZ as getHashes,kZ as getDiffieHellman,SZ as getCiphers,nZ as default,BZ as createVerify,NZ as createSign,FZ as createHmac,JZ as createHash,wZ as createECDH,jZ as createDiffieHellmanGroup,gZ as createDiffieHellman,MZ as createDecipheriv,PZ as createDecipher,lZ as createCredentials,LZ as createCipheriv,DZ as createCipher,oZ as constants,yZ as Verify,xZ as Sign,AZ as Hmac,OZ as Hash,qZ as DiffieHellmanGroup,_Z as DiffieHellman,zZ as Decipheriv,RZ as Decipher,T$ as DEFAULT_ENCODING,CZ as Cipheriv,TZ as Cipher}; +`))},$.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(),ZZ=(...$)=>H$.randomInt(...$),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,GZ="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,VZ="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(VZ,"name",{value:"::bunternal::"}),Object.defineProperty(GZ,"name",{value:"::bunternal::"}));var C$=H$;j$($Z,{DEFAULT_ENCODING:()=>T$,getRandomValues:()=>QZ,randomUUID:()=>YZ,randomInt:()=>ZZ,scrypt:()=>VZ,scryptSync:()=>GZ,timingSafeEqual:()=>D$,webcrypto:()=>C$,subtle:()=>C$.subtle});var{randomBytes:UZ,rng:XZ,pseudoRandomBytes:KZ,prng:IZ,Hash:OZ,createHash:JZ,createHmac:FZ,Hmac:AZ,getHashes:HZ,pbkdf2:WZ,pbkdf2Sync:EZ,Cipher:TZ,createCipher:DZ,Cipheriv:CZ,createCipheriv:LZ,Decipher:RZ,createDecipher:PZ,Decipheriv:zZ,createDecipheriv:MZ,getCiphers:SZ,listCiphers:vZ,DiffieHellmanGroup:qZ,createDiffieHellmanGroup:jZ,getDiffieHellman:kZ,createDiffieHellman:gZ,DiffieHellman:_Z,createSign:NZ,Sign:xZ,createVerify:BZ,Verify:yZ,createECDH:wZ,publicEncrypt:pZ,privateEncrypt:fZ,publicDecrypt:cZ,privateDecrypt:hZ,randomFill:dZ,randomFillSync:bZ,createCredentials:lZ,constants:oZ}=$Z;var nZ=$Z;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{C$ as webcrypto,D$ as timingSafeEqual,GZ as scryptSync,VZ as scrypt,XZ as rng,YZ as randomUUID,ZZ as randomInt,bZ as randomFillSync,dZ as randomFill,UZ as randomBytes,pZ as publicEncrypt,cZ as publicDecrypt,KZ as pseudoRandomBytes,IZ as prng,fZ as privateEncrypt,hZ as privateDecrypt,EZ as pbkdf2Sync,WZ as pbkdf2,vZ as listCiphers,QZ as getRandomValues,HZ as getHashes,kZ as getDiffieHellman,SZ as getCiphers,nZ as default,BZ as createVerify,NZ as createSign,FZ as createHmac,JZ as createHash,wZ as createECDH,jZ as createDiffieHellmanGroup,gZ as createDiffieHellman,MZ as createDecipheriv,PZ as createDecipher,lZ as createCredentials,LZ as createCipheriv,DZ as createCipher,oZ as constants,yZ as Verify,xZ as Sign,AZ as Hmac,OZ as Hash,qZ as DiffieHellmanGroup,_Z as DiffieHellman,zZ as Decipheriv,RZ as Decipher,T$ as DEFAULT_ENCODING,CZ as Cipheriv,TZ as Cipher}; -- cgit v1.2.3 From 43752ec3f0fac7ffe790272ba5d0ebbbca02572c Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 28 Jun 2023 11:27:31 -0700 Subject: Fix assertion failure in escapeHTML with UTF-16 text (#3436) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/string_immutable.zig | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 3931648b8..6c4eaa943 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -2488,11 +2488,11 @@ pub fn escapeHTMLForUTF16Input(allocator: std.mem.Allocator, utf16: []const u16) continue :scan_and_allocate_lazily; } - buf = try std.ArrayList(u16).initCapacity(allocator, utf16.len + 6); if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(remaining.ptr + i) >= @intFromPtr(utf16.ptr)); const to_copy = std.mem.sliceAsBytes(utf16)[0 .. @intFromPtr(remaining.ptr + i) - @intFromPtr(utf16.ptr)]; - @memcpy(@ptrCast([*]align(2) u8, buf.items[0..to_copy.len]), to_copy); - buf.items.len = std.mem.bytesAsSlice(u16, to_copy).len; + var to_copy_16 = std.mem.bytesAsSlice(u16, to_copy); + buf = try std.ArrayList(u16).initCapacity(allocator, utf16.len + 6); + try buf.appendSlice(to_copy_16); while (i < ascii_u16_vector_size) { switch (remaining[i]) { @@ -2603,13 +2603,8 @@ pub fn escapeHTMLForUTF16Input(allocator: std.mem.Allocator, utf16: []const u16) if (comptime Environment.allow_assert) std.debug.assert(@intFromPtr(ptr) >= @intFromPtr(utf16.ptr)); const to_copy = std.mem.sliceAsBytes(utf16)[0 .. @intFromPtr(ptr) - @intFromPtr(utf16.ptr)]; - - @memcpy( - @ptrCast([*]align(2) u8, buf.items[0..to_copy.len]), - to_copy, - ); - - buf.items.len = std.mem.bytesAsSlice(u16, to_copy).len; + var to_copy_16 = std.mem.bytesAsSlice(u16, to_copy); + try buf.appendSlice(to_copy_16); any_needs_escape = true; break :scan_and_allocate_lazily; }, -- cgit v1.2.3 From 3d5573921e732c4a63794e5d25f5953d0a40ff0e Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 28 Jun 2023 13:53:09 -0700 Subject: Error.prototype.stack gets sourcemapped stacktraces and introduce Error.appendStackTrace (#3441) * Fix potential crash when reading sourcemapped stack traces * Format & sourcemap Error.prototype.stack * prevent double sourcemapping * Introduce Error.appendStackTrace * Fix source url * hide private stack traces in non-debug builds * fixes #3443 * Bump WebKit * Fix test failure in vm.test * Support new() & add test --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- .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 +- bun.lockb | Bin 72925 -> 72925 bytes package.json | 2 +- src/bun.js/bindings/ZigGlobalObject.cpp | 188 +++++++++++++++++++++++++--- src/bun.js/bindings/bindings.cpp | 28 +++-- src/bun.js/javascript.zig | 22 ++-- test/js/node/v8/capture-stack-trace.test.js | 12 ++ 12 files changed, 241 insertions(+), 67 deletions(-) diff --git a/.github/workflows/bun-linux-aarch64.yml b/.github/workflows/bun-linux-aarch64.yml index 9bee835b7..01714460b 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-1/bun-webkit-linux-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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 8689d488e..798ffaf33 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-1/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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 3040eee43..f281783bd 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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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 dea617b21..b5f79a757 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-1/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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 2f2143ab1..8b30321f0 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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/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-1/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-2/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index b4a76208f..f50ada2d8 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-1 +ARG WEBKIT_TAG=may20-2 ARG ZIG_TAG=jul1 ARG ZIG_VERSION="0.11.0-dev.3737+9eb008717" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" diff --git a/bun.lockb b/bun.lockb index 2c2b03711..e53db751b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 94f9968ea..4fe213747 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-4b3750ddfe644a5bb131d652407653fac528ad51" + "bun-webkit": "0.0.1-8a03cf746abef8a48c932ab25f8821390632f2e2" }, "version": "0.0.0", "prettier": "./.prettierrc.cjs" diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index b27e0aafc..4b4edf097 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -219,7 +219,9 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c JSC::Options::useJITCage() = false; JSC::Options::useShadowRealm() = true; JSC::Options::useResizableArrayBuffer() = true; +#ifdef BUN_DEBUG JSC::Options::showPrivateScriptsInStackTraces() = true; +#endif JSC::Options::useSetMethods() = true; /* @@ -312,6 +314,123 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c } extern "C" void* Bun__getVM(); +extern "C" JSGlobalObject* Bun__getDefaultGlobal(); + +static String computeErrorInfoWithoutPrepareStackTrace(JSC::VM& vm, Vector& stackTrace, unsigned& line, unsigned& column, String& sourceURL, JSObject* errorInstance) +{ + if (!errorInstance) { + return String(); + } + + Zig::GlobalObject* globalObject = jsDynamicCast(errorInstance->globalObject()); + if (!globalObject) { + // Happens in node:vm + globalObject = jsDynamicCast(Bun__getDefaultGlobal()); + } + + WTF::String name = "Error"_s; + WTF::String message; + + if (errorInstance) { + // Note that we are not allowed to allocate memory in here. It's called inside a finalizer. + if (auto* instance = jsDynamicCast(errorInstance)) { + name = instance->sanitizedNameString(globalObject); + message = instance->sanitizedMessageString(globalObject); + } + } + + WTF::StringBuilder sb; + + if (!name.isEmpty()) { + sb.append(name); + sb.append(": "_s); + } + + if (!message.isEmpty()) { + sb.append(message); + } + + if (stackTrace.isEmpty()) { + return sb.toString(); + } + + if ((!message.isEmpty() || !name.isEmpty())) { + sb.append("\n"_s); + } + + size_t framesCount = stackTrace.size(); + ZigStackFrame remappedFrames[framesCount]; + bool hasSet = false; + for (size_t i = 0; i < framesCount; i++) { + StackFrame& frame = stackTrace.at(i); + + sb.append(" at "_s); + + WTF::String functionName = frame.functionName(vm); + + if (auto codeblock = frame.codeBlock()) { + if (codeblock->isConstructor()) { + sb.append("new "_s); + } + + // TODO: async + } + + if (functionName.isEmpty()) { + sb.append(""_s); + } else { + sb.append(functionName); + } + + sb.append(" ("_s); + + if (frame.hasLineAndColumnInfo()) { + unsigned int thisLine = 0; + unsigned int thisColumn = 0; + frame.computeLineAndColumn(thisLine, thisColumn); + remappedFrames[i].position.line = thisLine; + remappedFrames[i].position.column_start = thisColumn; + remappedFrames[i].source_url = Zig::toZigString(frame.sourceURL(vm)); + + // This ensures the lifetime of the sourceURL is accounted for correctly + Bun__remapStackFramePositions(globalObject, remappedFrames + i, 1); + + if (!hasSet) { + hasSet = true; + line = thisLine; + column = thisColumn; + sourceURL = frame.sourceURL(vm); + + if (errorInstance) { + if (remappedFrames[i].remapped) { + errorInstance->putDirect(vm, Identifier::fromString(vm, "originalLine"_s), jsNumber(thisLine), 0); + errorInstance->putDirect(vm, Identifier::fromString(vm, "originalColumn"_s), jsNumber(thisColumn), 0); + } + } + } + + sb.append(frame.sourceURL(vm)); + sb.append(":"_s); + sb.append(remappedFrames[i].position.line); + sb.append(":"_s); + sb.append(remappedFrames[i].position.column_start); + } else { + sb.append("native"_s); + } + sb.append(")"_s); + + if (i != framesCount - 1) { + sb.append("\n"_s); + } + } + + return sb.toString(); +} + +static String computeErrorInfo(JSC::VM& vm, Vector& stackTrace, unsigned& line, unsigned& column, String& sourceURL, JSObject* errorInstance) +{ + return computeErrorInfoWithoutPrepareStackTrace(vm, stackTrace, line, column, sourceURL, errorInstance); +} extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObjectClass, int count, void* console_client) @@ -329,6 +448,9 @@ extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObje Zig::GlobalObject* globalObject = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::JSGlobalObject::create(vm, JSC::JSGlobalObject::createStructure(vm, JSC::jsNull())), JSC::jsNull())); globalObject->setConsole(globalObject); globalObject->isThreadLocalDefaultGlobalObject = true; + globalObject->setStackTraceLimit(DEFAULT_ERROR_STACK_TRACE_LIMIT); // Node.js defaults to 10 + vm.setOnComputeErrorInfo(computeErrorInfo); + if (count > 0) { globalObject->installAPIGlobals(globalObjectClass, count, vm); } @@ -2585,7 +2707,32 @@ JSC::JSValue GlobalObject::formatStackTrace(JSC::VM& vm, JSC::JSGlobalObject* le extern "C" EncodedJSValue JSPasswordObject__create(JSC::JSGlobalObject*, bool); -JSC_DECLARE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace); +JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncAppendStackTrace, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) +{ + GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + JSC::VM& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + JSC::ErrorInstance* source = jsDynamicCast(callFrame->argument(0)); + JSC::ErrorInstance* destination = jsDynamicCast(callFrame->argument(1)); + + if (!source || !destination) { + throwTypeError(lexicalGlobalObject, scope, "First & second argument must be an Error object"_s); + return JSC::JSValue::encode(jsUndefined()); + } + + if (!destination->stackTrace()) { + destination->captureStackTrace(vm, globalObject, 1); + } + + if (source->stackTrace()) { + destination->stackTrace()->appendVector(*source->stackTrace()); + source->stackTrace()->clear(); + } + + return JSC::JSValue::encode(jsUndefined()); +} + JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); @@ -2600,18 +2747,15 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb JSC::JSObject* errorObject = objectArg.asCell()->getObject(); JSC::JSValue caller = callFrame->argument(1); + // We cannot use our ErrorInstance::captureStackTrace() fast path here unfortunately. + // We need to return these CallSite array objects which means we need to create them JSValue errorValue = lexicalGlobalObject->get(lexicalGlobalObject, vm.propertyNames->Error); auto* errorConstructor = jsDynamicCast(errorValue); - - size_t stackTraceLimit = DEFAULT_ERROR_STACK_TRACE_LIMIT; - if (JSC::JSValue stackTraceLimitProp = errorConstructor->getIfPropertyExists(lexicalGlobalObject, vm.propertyNames->stackTraceLimit)) { - if (stackTraceLimitProp.isNumber()) { - stackTraceLimit = std::min(std::max(static_cast(stackTraceLimitProp.toIntegerOrInfinity(lexicalGlobalObject)), 0ul), 2048ul); - if (stackTraceLimit == 0) { - stackTraceLimit = 2048; - } - } + size_t stackTraceLimit = globalObject->stackTraceLimit().value(); + if (stackTraceLimit == 0) { + stackTraceLimit = DEFAULT_ERROR_STACK_TRACE_LIMIT; } + JSCStackTrace stackTrace = JSCStackTrace::captureCurrentJSStackTrace(globalObject, callFrame, stackTraceLimit, caller); // Create an (uninitialized) array for our "call sites" @@ -2672,9 +2816,20 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb errorObject->deleteProperty(lexicalGlobalObject, vm.propertyNames->stack); } if (formattedStackTrace.isUndefinedOrNull()) { - errorObject->putDirect(vm, vm.propertyNames->stack, jsUndefined(), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); - } else { - errorObject->putDirect(vm, vm.propertyNames->stack, formattedStackTrace, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); + formattedStackTrace = JSC::jsUndefined(); + } + + errorObject->putDirect(vm, vm.propertyNames->stack, formattedStackTrace, 0); + + if (!(caller && caller.isObject())) { + if (auto* instance = jsDynamicCast(errorObject)) { + // we make a separate copy of the StackTrace unfortunately so that we + // can later console.log it without losing the info + // + // This is not good. We should remove this in the future as it strictly makes this function + // already slower than necessary. + instance->captureStackTrace(vm, globalObject, 1, false); + } } RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSValue {})); @@ -3118,11 +3273,8 @@ void GlobalObject::finishCreation(VM& vm) RELEASE_ASSERT(classInfo()); JSC::JSObject* errorConstructor = this->errorConstructor(); - errorConstructor->putDirectNativeFunctionWithoutTransition(vm, this, JSC::Identifier::fromString(vm, "captureStackTrace"_s), 2, errorConstructorFuncCaptureStackTrace, ImplementationVisibility::Public, JSC::NoIntrinsic, PropertyAttribute::DontEnum | 0); - - // JSC default is 100 - errorConstructor->putDirect(vm, vm.propertyNames->stackTraceLimit, jsNumber(DEFAULT_ERROR_STACK_TRACE_LIMIT), JSC::PropertyAttribute::DontEnum | 0); - + errorConstructor->putDirectNativeFunction(vm, this, JSC::Identifier::fromString(vm, "captureStackTrace"_s), 2, errorConstructorFuncCaptureStackTrace, ImplementationVisibility::Public, JSC::NoIntrinsic, PropertyAttribute::DontEnum | 0); + errorConstructor->putDirectNativeFunction(vm, this, JSC::Identifier::fromString(vm, "appendStackTrace"_s), 2, errorConstructorFuncAppendStackTrace, ImplementationVisibility::Private, JSC::NoIntrinsic, PropertyAttribute::DontEnum | 0); JSC::JSValue console = this->get(this, JSC::Identifier::fromString(vm, "console"_s)); JSC::JSObject* consoleObject = console.getObject(); consoleObject->putDirectBuiltinFunction(vm, this, vm.propertyNames->asyncIteratorSymbol, consoleObjectAsyncIteratorCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete); diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 3f3d82dc4..68aef29dd 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -3528,12 +3528,13 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, JSC::JSValue val) { JSC::JSObject* obj = JSC::jsDynamicCast(val); + JSC::VM& vm = global->vm(); bool getFromSourceURL = false; if (stackTrace != nullptr && stackTrace->size() > 0) { - populateStackTrace(global->vm(), *stackTrace, &except->stack); + populateStackTrace(vm, *stackTrace, &except->stack); } else if (err->stackTrace() != nullptr && err->stackTrace()->size() > 0) { - populateStackTrace(global->vm(), *err->stackTrace(), &except->stack); + populateStackTrace(vm, *err->stackTrace(), &except->stack); } else { getFromSourceURL = true; } @@ -3546,7 +3547,7 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, } if (except->code == SYNTAX_ERROR_CODE) { except->message = Zig::toZigString(err->sanitizedMessageString(global)); - } else if (JSC::JSValue message = obj->getIfPropertyExists(global, global->vm().propertyNames->message)) { + } else if (JSC::JSValue message = obj->getIfPropertyExists(global, vm.propertyNames->message)) { except->message = Zig::toZigString(message, global); @@ -3556,7 +3557,7 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, except->name = Zig::toZigString(err->sanitizedNameString(global)); except->runtime_type = err->runtimeTypeForCause(); - auto clientData = WebCore::clientData(global->vm()); + auto clientData = WebCore::clientData(vm); if (except->code != SYNTAX_ERROR_CODE) { if (JSC::JSValue syscall = obj->getIfPropertyExists(global, clientData->builtinNames().syscallPublicName())) { @@ -3571,7 +3572,7 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, except->path = Zig::toZigString(path, global); } - if (JSC::JSValue fd = obj->getIfPropertyExists(global, Identifier::fromString(global->vm(), "fd"_s))) { + if (JSC::JSValue fd = obj->getIfPropertyExists(global, Identifier::fromString(vm, "fd"_s))) { if (fd.isAnyInt()) { except->fd = fd.toInt32(global); } @@ -3583,17 +3584,17 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, } if (getFromSourceURL) { - if (JSC::JSValue sourceURL = obj->getIfPropertyExists(global, global->vm().propertyNames->sourceURL)) { + if (JSC::JSValue sourceURL = obj->getIfPropertyExists(global, vm.propertyNames->sourceURL)) { except->stack.frames_ptr[0].source_url = Zig::toZigString(sourceURL, global); - if (JSC::JSValue column = obj->getIfPropertyExists(global, global->vm().propertyNames->column)) { + if (JSC::JSValue column = obj->getIfPropertyExists(global, vm.propertyNames->column)) { except->stack.frames_ptr[0].position.column_start = column.toInt32(global); } - if (JSC::JSValue line = obj->getIfPropertyExists(global, global->vm().propertyNames->line)) { + if (JSC::JSValue line = obj->getIfPropertyExists(global, vm.propertyNames->line)) { except->stack.frames_ptr[0].position.line = line.toInt32(global); - if (JSC::JSValue lineText = obj->getIfPropertyExists(global, JSC::Identifier::fromString(global->vm(), "lineText"_s))) { + 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] = Zig::toZigString(str); @@ -3603,7 +3604,9 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, } } } + except->stack.frames_len = 1; + except->stack.frames_ptr[0].remapped = obj->hasProperty(global, JSC::Identifier::fromString(vm, "originalLine"_s)); } } @@ -3654,7 +3657,12 @@ void exceptionFromString(ZigException* except, JSC::JSValue value, JSC::JSGlobal if (JSC::JSValue line = obj->getIfPropertyExists(global, global->vm().propertyNames->line)) { if (line) { - except->stack.frames_ptr[0].position.line = line.toInt32(global); + // TODO: don't sourcemap it twice + if (auto originalLine = obj->getIfPropertyExists(global, JSC::Identifier::fromString(global->vm(), "originalLine"_s))) { + except->stack.frames_ptr[0].position.line = originalLine.toInt32(global); + } else { + except->stack.frames_ptr[0].position.line = line.toInt32(global); + } except->stack.frames_len = 1; } } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index cb1a50f1d..5c58eff60 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -1981,19 +1981,21 @@ pub const VirtualMachine = struct { } pub fn remapStackFramePositions(this: *VirtualMachine, frames: [*]JSC.ZigStackFrame, frames_count: usize) void { - var i: usize = 0; - while (i < frames_count) : (i += 1) { - if (frames[i].position.isInvalid()) continue; + for (frames[0..frames_count]) |*frame| { + if (frame.position.isInvalid() or frame.remapped) continue; + var sourceURL = frame.source_url.toSlice(bun.default_allocator); + defer sourceURL.deinit(); + if (this.source_mappings.resolveMapping( - frames[i].source_url.slice(), - @max(frames[i].position.line, 0), - @max(frames[i].position.column_start, 0), + sourceURL.slice(), + @max(frame.position.line, 0), + @max(frame.position.column_start, 0), )) |mapping| { - frames[i].position.line = mapping.original.lines; - frames[i].position.column_start = mapping.original.columns; - frames[i].remapped = true; + frame.position.line = mapping.original.lines; + frame.position.column_start = mapping.original.columns; + frame.remapped = true; } else { - frames[i].remapped = true; + frame.remapped = true; } } } diff --git a/test/js/node/v8/capture-stack-trace.test.js b/test/js/node/v8/capture-stack-trace.test.js index d96f91483..cb2624681 100644 --- a/test/js/node/v8/capture-stack-trace.test.js +++ b/test/js/node/v8/capture-stack-trace.test.js @@ -5,6 +5,18 @@ afterEach(() => { Error.prepareStackTrace = origPrepareStackTrace; }); +test("Regular .stack", () => { + var err; + class Foo { + constructor() { + err = new Error("wat"); + } + } + + new Foo(); + expect(err.stack).toMatch(/at new Foo/); +}); + test("capture stack trace", () => { function f1() { f2(); -- cgit v1.2.3 From 42ded7033623feec80afd13ce199752eaf20e438 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 13:55:58 -0700 Subject: [node:http] Stub `_implicitHeader` fn --- src/js/node/http.js | 6 ++++++ src/js/out/modules/node/http.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/js/node/http.js b/src/js/node/http.js index 4fba20881..658e45433 100644 --- a/src/js/node/http.js +++ b/src/js/node/http.js @@ -835,6 +835,9 @@ export class OutgoingMessage extends Writable { #timeoutTimer = null; [kAbortController] = null; + // Express "compress" package uses this + _implicitHeader() {} + // For compat with IncomingRequest get headers() { if (!this.#headers) return kEmptyObject; @@ -977,6 +980,9 @@ export class ServerResponse extends Writable { #deferred = undefined; #finished = false; + // Express "compress" package uses this + _implicitHeader() {} + _write(chunk, encoding, callback) { if (!this.#firstWrite && !this.headersSent) { this.#firstWrite = chunk; diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index e5f96de48..ab0d68e96 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -543,6 +543,8 @@ class OutgoingMessage extends Writable { #fakeSocket; #timeoutTimer = null; [kAbortController] = null; + _implicitHeader() { + } get headers() { if (!this.#headers) return kEmptyObject; @@ -647,6 +649,8 @@ class ServerResponse extends Writable { _removedContLen = !1; #deferred = void 0; #finished = !1; + _implicitHeader() { + } _write(chunk, encoding, callback) { if (!this.#firstWrite && !this.headersSent) { this.#firstWrite = chunk, callback(); -- 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 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 086ca176be5c8dcc30278b97df274f152fcd112e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 16:19:58 -0700 Subject: Make these tests do more --- test/js/bun/util/bun-file-exists.test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/js/bun/util/bun-file-exists.test.js b/test/js/bun/util/bun-file-exists.test.js index da6dce192..cca28e359 100644 --- a/test/js/bun/util/bun-file-exists.test.js +++ b/test/js/bun/util/bun-file-exists.test.js @@ -1,8 +1,20 @@ import { test, expect } from "bun:test"; - +import { join } from "path"; +import { tmpdir } from "os"; +import { write } from "bun"; +import { unlinkSync } from "fs"; 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(); + const temp = join(tmpdir(), "bun-file-exists.test.js"); + try { + unlinkSync(temp); + } catch (e) {} + expect(await Bun.file(temp).exists()).toBeFalse(); + await write(temp, "boop"); + expect(await Bun.file(temp).exists()).toBeTrue(); + unlinkSync(temp); + expect(await Bun.file(temp).exists()).toBeFalse(); }); -- cgit v1.2.3 From 945093ee7e8ad00f89d6216b5e6a136e98c9cd7a Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 16:22:46 -0700 Subject: bump! --- src/build-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build-id b/src/build-id index b4de39476..48082f72f 100644 --- a/src/build-id +++ b/src/build-id @@ -1 +1 @@ -11 +12 -- cgit v1.2.3 From 182e8aa1392af9ba92beccce06f49f8e4593fe5c Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 29 Jun 2023 02:27:15 +0300 Subject: [jest] fix lifecycle hook execution order (#3447) --- src/bun.js/test/jest.zig | 162 +++++++++++++++++++++--------------- test/js/bun/test/jest-hooks.test.ts | 31 +++++++ test/js/bun/test/test-test.test.ts | 6 +- 3 files changed, 130 insertions(+), 69 deletions(-) diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index f43afb1a2..d3bb90747 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -493,8 +493,7 @@ pub const Jest = struct { var filepath = Fs.FileSystem.instance.filename_store.append([]const u8, slice) catch unreachable; var scope = runner_.getOrPutFile(filepath); - DescribeScope.active = scope; - DescribeScope.module = scope; + scope.push(); return Bun__Jest__testModuleObject(ctx).asObjectRef(); } @@ -751,17 +750,16 @@ pub const DescribeScope = struct { } pub fn push(new: *DescribeScope) void { - if (comptime is_bindgen) return undefined; - if (new == DescribeScope.active) return; - - new.parent = DescribeScope.active; + if (comptime is_bindgen) return; + std.debug.assert(DescribeScope.active != new); + if (new.parent) |scope| std.debug.assert(scope == DescribeScope.active); DescribeScope.active = new; } pub fn pop(this: *DescribeScope) void { - if (comptime is_bindgen) return undefined; - if (DescribeScope.active == this) - DescribeScope.active = this.parent orelse DescribeScope.active; + if (comptime is_bindgen) return; + std.debug.assert(DescribeScope.active == this); + DescribeScope.active = this.parent; } pub const LifecycleHook = enum { @@ -771,8 +769,7 @@ pub const DescribeScope = struct { afterAll, }; - pub threadlocal var active: *DescribeScope = undefined; - pub threadlocal var module: *DescribeScope = undefined; + pub threadlocal var active: ?*DescribeScope = null; const CallbackFn = *const fn ( *JSC.JSGlobalObject, @@ -781,21 +778,24 @@ pub const DescribeScope = struct { fn createCallback(comptime hook: LifecycleHook) CallbackFn { return struct { - const this_hook = hook; pub fn run( globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - const arguments_ = callframe.arguments(2); - const arguments = arguments_.ptr[0..arguments_.len]; - if (arguments.len == 0 or !arguments[0].isObject() or !arguments[0].isCallable(globalThis.vm())) { - globalThis.throwInvalidArgumentType(@tagName(this_hook), "callback", "function"); + const arguments = callframe.arguments(2); + if (arguments.len < 1) { + globalThis.throwNotEnoughArguments("callback", 1, arguments.len); return .zero; } - arguments[0].protect(); - const name = comptime @as(string, @tagName(this_hook)); - @field(DescribeScope.active, name).append(getAllocator(globalThis), arguments[0]) catch unreachable; + const cb = arguments.ptr[0]; + if (!cb.isObject() or !cb.isCallable(globalThis.vm())) { + globalThis.throwInvalidArgumentType(@tagName(hook), "callback", "function"); + return .zero; + } + + cb.protect(); + @field(DescribeScope.active.?, @tagName(hook)).append(getAllocator(globalThis), cb) catch unreachable; return JSC.JSValue.jsBoolean(true); } }.run; @@ -829,11 +829,22 @@ pub const DescribeScope = struct { pub const beforeAll = createCallback(.beforeAll); pub const beforeEach = createCallback(.beforeEach); - pub fn execCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) JSValue { - const name = comptime @as(string, @tagName(hook)); - var hooks: []JSC.JSValue = @field(this, name).items; - for (hooks, 0..) |cb, i| { - if (cb.isEmpty()) continue; + pub fn execCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { + var hooks = &@field(this, @tagName(hook)); + defer { + if (comptime hook == .beforeAll or hook == .afterAll) { + hooks.clearAndFree(getAllocator(globalObject)); + } + } + + for (hooks.items) |cb| { + std.debug.assert(cb.isObject()); + std.debug.assert(cb.isCallable(globalObject.vm())); + defer { + if (comptime hook == .beforeAll or hook == .afterAll) { + cb.unprotect(); + } + } const pending_test = Jest.runner.?.pending_test; // forbid `expect()` within hooks @@ -843,20 +854,23 @@ pub const DescribeScope = struct { Jest.runner.?.did_pending_test_fail = false; const vm = VirtualMachine.get(); - var result: JSC.JSValue = if (cb.getLength(globalObject) > 0) brk: { - this.done = false; - const done_func = JSC.NewFunctionWithData( - globalObject, - ZigString.static("done"), - 0, - DescribeScope.onDone, - false, - this, - ); - var result = cb.call(globalObject, &.{done_func}); - vm.waitFor(&this.done); - break :brk result; - } else cb.call(globalObject, &.{}); + var result: JSC.JSValue = switch (cb.getLength(globalObject)) { + 0 => cb.call(globalObject, &.{}), + else => brk: { + this.done = false; + const done_func = JSC.NewFunctionWithData( + globalObject, + ZigString.static("done"), + 0, + DescribeScope.onDone, + false, + this, + ); + var result = cb.call(globalObject, &.{done_func}); + vm.waitFor(&this.done); + break :brk result; + }, + }; if (result.asAnyPromise()) |promise| { if (promise.status(globalObject.vm()) == .Pending) { result.protect(); @@ -870,19 +884,28 @@ pub const DescribeScope = struct { Jest.runner.?.pending_test = pending_test; Jest.runner.?.did_pending_test_fail = orig_did_pending_test_fail; if (result.isAnyError()) return result; - - if (comptime hook == .beforeAll or hook == .afterAll) { - hooks[i] = JSC.JSValue.zero; - } } - return JSValue.zero; + return null; } pub fn runGlobalCallbacks(globalThis: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { // global callbacks - for (@field(Jest.runner.?.global_callbacks, @tagName(hook)).items) |cb| { - if (cb.isEmpty()) continue; + var hooks = &@field(Jest.runner.?.global_callbacks, @tagName(hook)); + defer { + if (comptime hook == .beforeAll or hook == .afterAll) { + hooks.clearAndFree(getAllocator(globalThis)); + } + } + + for (hooks.items) |cb| { + std.debug.assert(cb.isObject()); + std.debug.assert(cb.isCallable(globalThis.vm())); + defer { + if (comptime hook == .beforeAll or hook == .afterAll) { + cb.unprotect(); + } + } const pending_test = Jest.runner.?.pending_test; // forbid `expect()` within hooks @@ -909,28 +932,40 @@ pub const DescribeScope = struct { if (result.isAnyError()) return result; } - if (comptime hook == .beforeAll or hook == .afterAll) { - @field(Jest.runner.?.global_callbacks, @tagName(hook)).items.len = 0; - } - return null; } + fn runBeforeCallbacks(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { + if (this.parent) |scope| { + if (scope.runBeforeCallbacks(globalObject, hook)) |err| { + return err; + } + } + return this.execCallback(globalObject, hook); + } + pub fn runCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) JSValue { + if (comptime hook == .afterAll or hook == .afterEach) { + var parent: ?*DescribeScope = this; + while (parent) |scope| { + if (scope.execCallback(globalObject, hook)) |err| { + return err; + } + parent = scope.parent; + } + } + if (runGlobalCallbacks(globalObject, hook)) |err| { return err; } - var parent = this.parent; - while (parent) |scope| { - const ret = scope.execCallback(globalObject, hook); - if (!ret.isEmpty()) { - return ret; + if (comptime hook == .beforeAll or hook == .beforeEach) { + if (this.runBeforeCallbacks(globalObject, hook)) |err| { + return err; } - parent = scope.parent; } - return this.execCallback(globalObject, hook); + return .zero; } pub fn call(globalThis: *JSGlobalObject, callframe: *CallFrame) callconv(.C) JSValue { @@ -961,11 +996,8 @@ pub const DescribeScope = struct { if (comptime is_bindgen) return undefined; callback.protect(); defer callback.unprotect(); - var original_active = active; - defer active = original_active; - if (this != module) - this.parent = this.parent orelse active; - active = this; + this.push(); + defer this.pop(); if (callback == .zero) { this.runTests(globalObject); @@ -1064,9 +1096,8 @@ pub const DescribeScope = struct { if (!this.isAllSkipped()) { // Run the afterAll callbacks, in reverse order // unless there were no tests for this scope - const afterAll_result = this.execCallback(globalThis, .afterAll); - if (!afterAll_result.isEmpty()) { - globalThis.bunVM().runErrorHandler(afterAll_result, null); + if (this.execCallback(globalThis, .afterAll)) |err| { + globalThis.bunVM().runErrorHandler(err, null); } } @@ -1146,7 +1177,6 @@ pub const TestRunnerTask = struct { // reset the global state for each test // prior to the run - DescribeScope.active = describe; expect.active_test_expectation_counter = .{}; jsc_vm.last_reported_error_for_dedupe = .zero; @@ -1417,7 +1447,7 @@ inline fn createScope( return .zero; } - const parent = DescribeScope.active; + const parent = DescribeScope.active.?; const allocator = getAllocator(globalThis); const label = if (description == .zero) "" diff --git a/test/js/bun/test/jest-hooks.test.ts b/test/js/bun/test/jest-hooks.test.ts index c99dc7759..618cdc4c6 100644 --- a/test/js/bun/test/jest-hooks.test.ts +++ b/test/js/bun/test/jest-hooks.test.ts @@ -1,5 +1,36 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "bun:test"; +let hooks_run: string[] = []; + +beforeAll(() => hooks_run.push("global beforeAll")); +beforeEach(() => hooks_run.push("global beforeEach")); +afterAll(() => hooks_run.push("global afterAll")); +afterEach(() => hooks_run.push("global afterEach")); + +describe("describe scope", () => { + beforeAll(() => hooks_run.push("describe beforeAll")); + beforeEach(() => hooks_run.push("describe beforeEach")); + afterAll(() => hooks_run.push("describe afterAll")); + afterEach(() => hooks_run.push("describe afterEach")); + + it("should run after beforeAll/beforeEach in the correct order", () => { + expect(hooks_run).toEqual(["global beforeAll", "describe beforeAll", "global beforeEach", "describe beforeEach"]); + }); + + it("should run after afterEach/afterAll in the correct order", () => { + expect(hooks_run).toEqual([ + "global beforeAll", + "describe beforeAll", + "global beforeEach", + "describe beforeEach", + "describe afterEach", + "global afterEach", + "global beforeEach", + "describe beforeEach", + ]); + }); +}); + describe("test jest hooks in bun-test", () => { describe("test beforeAll hook", () => { let animal = "tiger"; diff --git a/test/js/bun/test/test-test.test.ts b/test/js/bun/test/test-test.test.ts index 7ecfdef11..5f732bb82 100644 --- a/test/js/bun/test/test-test.test.ts +++ b/test/js/bun/test/test-test.test.ts @@ -540,18 +540,18 @@ beforeEach: #2 beforeEach: TEST-FILE beforeEach: one describe scope -- inside one describe scope -- +afterEach: one describe scope +afterEach: TEST-FILE afterEach: #1 afterEach: #2 -afterEach: TEST-FILE -afterEach: one describe scope afterAll: one describe scope beforeEach: #1 beforeEach: #2 beforeEach: TEST-FILE -- the top-level test -- +afterEach: TEST-FILE afterEach: #1 afterEach: #2 -afterEach: TEST-FILE afterAll: TEST-FILE afterAll: #1 afterAll: #2 -- cgit v1.2.3 From 0cee640199e1102385d639e8e84707d2f3576967 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Wed, 28 Jun 2023 20:45:18 -0400 Subject: export resolve6 from dns/promises (#3450) --- src/js/node/dns.promises.js | 2 ++ test/js/node/dns/dns.node.mjs | 0 test/js/node/dns/node-dns.test.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) delete mode 100644 test/js/node/dns/dns.node.mjs diff --git a/src/js/node/dns.promises.js b/src/js/node/dns.promises.js index 8b1aa4e48..bcc47faee 100644 --- a/src/js/node/dns.promises.js +++ b/src/js/node/dns.promises.js @@ -6,6 +6,7 @@ export const { lookupService, resolve, resolve4, + resolve6, resolveAny, resolveCname, resolveCaa, @@ -27,6 +28,7 @@ export default { lookupService, resolve, resolve4, + resolve6, resolveAny, resolveCname, resolveCaa, diff --git a/test/js/node/dns/dns.node.mjs b/test/js/node/dns/dns.node.mjs deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/js/node/dns/node-dns.test.js b/test/js/node/dns/node-dns.test.js index 5fb8e0739..5de840146 100644 --- a/test/js/node/dns/node-dns.test.js +++ b/test/js/node/dns/node-dns.test.js @@ -1,5 +1,6 @@ import { expect, test } from "bun:test"; import * as dns from "node:dns"; +import * as dns_promises from "node:dns/promises"; // TODO: test("it exists", () => { @@ -18,6 +19,38 @@ test("it exists", () => { expect(dns.resolveNs).toBeDefined(); expect(dns.resolvePtr).toBeDefined(); expect(dns.resolveCname).toBeDefined(); + + expect(dns.promises).toBeDefined(); + expect(dns.promises.lookup).toBeDefined(); + expect(dns.promises.lookupService).toBeDefined(); + expect(dns.promises.resolve).toBeDefined(); + expect(dns.promises.resolve4).toBeDefined(); + expect(dns.promises.resolve6).toBeDefined(); + expect(dns.promises.resolveSrv).toBeDefined(); + expect(dns.promises.resolveTxt).toBeDefined(); + expect(dns.promises.resolveSoa).toBeDefined(); + expect(dns.promises.resolveNaptr).toBeDefined(); + expect(dns.promises.resolveMx).toBeDefined(); + expect(dns.promises.resolveCaa).toBeDefined(); + expect(dns.promises.resolveNs).toBeDefined(); + expect(dns.promises.resolvePtr).toBeDefined(); + expect(dns.promises.resolveCname).toBeDefined(); + + expect(dns_promises).toBeDefined(); + expect(dns_promises.lookup).toBeDefined(); + expect(dns_promises.lookupService).toBeDefined(); + expect(dns_promises.resolve).toBeDefined(); + expect(dns_promises.resolve4).toBeDefined(); + expect(dns_promises.resolve6).toBeDefined(); + expect(dns_promises.resolveSrv).toBeDefined(); + expect(dns_promises.resolveTxt).toBeDefined(); + expect(dns_promises.resolveSoa).toBeDefined(); + expect(dns_promises.resolveNaptr).toBeDefined(); + expect(dns_promises.resolveMx).toBeDefined(); + expect(dns_promises.resolveCaa).toBeDefined(); + expect(dns_promises.resolveNs).toBeDefined(); + expect(dns_promises.resolvePtr).toBeDefined(); + expect(dns_promises.resolveCname).toBeDefined(); }); // //TODO: use a bun.sh SRV for testing -- cgit v1.2.3 From 32d9abcc03bf2c2542574ff9ae1717d933f5d85f Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 19:20:41 -0700 Subject: Fix bad test --- test/js/bun/resolve/import-meta.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/js/bun/resolve/import-meta.test.js b/test/js/bun/resolve/import-meta.test.js index 2d79c531e..e23b44446 100644 --- a/test/js/bun/resolve/import-meta.test.js +++ b/test/js/bun/resolve/import-meta.test.js @@ -97,9 +97,9 @@ it("Module._cache", () => { expect(!!expected).toBe(true); }); -it("Module._resolveFileName()", () => { +it("Module._resolveFilename()", () => { const expected = Bun.resolveSync(import.meta.path, "/"); - const result = Module._resolveFileName(import.meta.path, "/", true); + const result = Module._resolveFilename(import.meta.path, "/", true); expect(result).toBe(expected); }); -- cgit v1.2.3 From 3258bed1c03a7808b9f2e4970012668e984ed390 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Wed, 28 Jun 2023 19:28:53 -0700 Subject: use main field over module for runtime (#3448) * use main field over module for runtime * move flag to `Resolver` * set `prefer_module_field` in `initWithModuleGraph` --- src/bun.js/javascript.zig | 2 + src/resolver/resolver.zig | 9 +- test/bundler/esbuild/default.test.ts | 200 +++++++++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+), 1 deletion(-) diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 5c58eff60..cf6a65841 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -801,6 +801,7 @@ pub const VirtualMachine = struct { vm.bundler.macro_context = null; vm.bundler.resolver.store_fd = false; + vm.bundler.resolver.prefer_module_field = false; vm.bundler.resolver.onWakePackageManager = .{ .context = &vm.modules, @@ -898,6 +899,7 @@ pub const VirtualMachine = struct { vm.bundler.macro_context = null; vm.bundler.resolver.store_fd = store_fd; + vm.bundler.resolver.prefer_module_field = false; vm.bundler.resolver.onWakePackageManager = .{ .context = &vm.modules, diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index d9f4dc887..e1e83ba4f 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -533,6 +533,10 @@ pub const Resolver = struct { // all parent directories dir_cache: *DirInfo.HashMap, + /// This is set to false for the runtime. The runtime should choose "main" + /// over "module" in package.json + prefer_module_field: bool = true, + pub fn getPackageManager(this: *Resolver) *PackageManager { return this.package_manager orelse brk: { bun.HTTPThead.init() catch unreachable; @@ -3408,7 +3412,10 @@ pub const Resolver = struct { // with this same path. The goal of this code is to avoid having // both the "module" file and the "main" file in the bundle at the // same time. - if (kind != ast.ImportKind.require) { + // + // Additionally, if this is for the runtime, use the "main" field. + // If it doesn't exist, the "module" field will be used. + if (r.prefer_module_field and kind != ast.ImportKind.require) { if (r.debug_logs) |*debug| { debug.addNoteFmt("Resolved to \"{s}\" using the \"module\" field in \"{s}\"", .{ auto_main_result.path_pair.primary.text, pkg_json.source.key_path.text }); diff --git a/test/bundler/esbuild/default.test.ts b/test/bundler/esbuild/default.test.ts index 4c4cf87be..20856ecdf 100644 --- a/test/bundler/esbuild/default.test.ts +++ b/test/bundler/esbuild/default.test.ts @@ -6565,4 +6565,204 @@ describe("bundler", () => { api.expectFile("/out.js").not.toContain("data = 123"); }, }); + itBundled("default/BundlerUsesModuleFieldForEsm", { + files: { + "/entry.js": ` + import { foo } from 'foo'; + console.log(foo); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "module": "index.esm.js", + "main": "index.cjs.js" + } + `, + "/node_modules/foo/index.cjs.js": ` + module.exports.foo = "hello index.cjs.js"; + `, + "/node_modules/foo/index.esm.js": ` + export const foo = "hello index.esm.js"; + `, + }, + run: { + stdout: "hello index.esm.js", + }, + }); + itBundled("default/BundlerUsesMainFieldForCjs", { + files: { + "/entry.js": ` + const { foo } = require('foo'); + console.log(foo); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "module": "index.esm.js", + "main": "index.cjs.js" + } + `, + "/node_modules/foo/index.cjs.js": ` + module.exports.foo = "hello index.cjs.js"; + `, + "/node_modules/foo/index.esm.js": ` + export const foo = "hello index.esm.js"; + `, + }, + run: { + stdout: "hello index.cjs.js", + }, + }); + itBundled("default/RuntimeUsesMainFieldForCjs", { + files: { + "/entry.js": ` + const { foo } = require('foo'); + console.log(foo); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "module": "index.esm.js", + "main": "index.cjs.js" + } + `, + "/node_modules/foo/index.cjs.js": ` + module.exports.foo = "hello index.cjs.js"; + `, + "/node_modules/foo/index.esm.js": ` + export const foo = "hello index.esm.js"; + `, + }, + bundling: false, + run: { + stdout: "hello index.cjs.js", + }, + }); + itBundled("default/RuntimeUsesMainFieldForEsm", { + files: { + "/entry.js": ` + import { foo } from 'foo'; + console.log(foo); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "module": "index.esm.js", + "main": "index.cjs.js" + } + `, + "/node_modules/foo/index.cjs.js": ` + module.exports.foo = "hello index.cjs.js"; + `, + "/node_modules/foo/index.esm.js": ` + export const foo = "hello index.esm.js"; + `, + }, + bundling: false, + run: { + stdout: "hello index.cjs.js", + }, + }); + itBundled("default/BundlerUsesModuleFieldIfMainDoesNotExistCjs", { + files: { + "/entry.js": ` + const { foo } = require('foo'); + console.log(foo); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "module": "index.esm.js" + } + `, + "/node_modules/foo/index.cjs.js": ` + module.exports.foo = "hello index.cjs.js"; + `, + "/node_modules/foo/index.esm.js": ` + export const foo = "hello index.esm.js"; + `, + }, + run: { + stdout: "hello index.esm.js", + }, + }); + itBundled("default/BundlerUsesModuleFieldIfMainDoesNotExistEsm", { + files: { + "/entry.js": ` + import { foo } from 'foo'; + console.log(foo); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "module": "index.esm.js" + } + `, + "/node_modules/foo/index.cjs.js": ` + module.exports.foo = "hello index.cjs.js"; + `, + "/node_modules/foo/index.esm.js": ` + export const foo = "hello index.esm.js"; + `, + }, + run: { + stdout: "hello index.esm.js", + }, + }); + itBundled("default/RuntimeUsesModuleFieldIfMainDoesNotExistCjs", { + files: { + "/entry.js": ` + const { foo } = require('foo'); + console.log(foo); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "module": "index.esm.js" + } + `, + "/node_modules/foo/index.cjs.js": ` + module.exports.foo = "hello index.cjs.js"; + `, + "/node_modules/foo/index.esm.js": ` + export const foo = "hello index.esm.js"; + `, + }, + bundling: false, + run: { + stdout: "hello index.esm.js", + }, + }); + itBundled("default/RuntimeUsesModuleFieldIfMainDoesNotExistEsm", { + files: { + "/entry.js": ` + import { foo } from 'foo'; + console.log(foo); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0", + "module": "index.esm.js" + } + `, + "/node_modules/foo/index.cjs.js": ` + module.exports.foo = "hello index.cjs.js"; + `, + "/node_modules/foo/index.esm.js": ` + export const foo = "hello index.esm.js"; + `, + }, + bundling: false, + run: { + stdout: "hello index.esm.js", + }, + }); }); -- cgit v1.2.3 From 68e6fe00a4be7857f474cb3aa80e0d876499e3f8 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 28 Jun 2023 21:11:06 -0700 Subject: Use `bun.String` for `ZigException` (#3451) * Use `bun.String` for `ZigException` * woopsie --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/ZigGlobalObject.cpp | 4 +- src/bun.js/bindings/bindings.cpp | 69 +++++----------- src/bun.js/bindings/exports.zig | 130 ++++++++++++++++++++---------- src/bun.js/bindings/headers-handwritten.h | 16 ++-- src/bun.js/javascript.zig | 72 ++++++++++------- src/bun.js/test/jest.zig | 18 ++--- src/js/out/modules/node/path.js | 2 +- src/js/out/modules/node/stream.web.js | 2 +- src/logger.zig | 4 +- src/string.zig | 24 ++++++ 10 files changed, 198 insertions(+), 143 deletions(-) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 4b4edf097..9ff3ebf93 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -390,7 +390,7 @@ static String computeErrorInfoWithoutPrepareStackTrace(JSC::VM& vm, Vectorline.zeroBasedInt(); remappedFrames[i].position.column_start = sourcePositions->startColumn.zeroBasedInt() + 1; diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 68aef29dd..141215ebe 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -3303,7 +3303,7 @@ bool JSC__JSValue__stringIncludes(JSC__JSValue value, JSC__JSGlobalObject* globa static void populateStackFrameMetadata(JSC::VM& vm, const JSC::StackFrame* stackFrame, ZigStackFrame* frame) { - frame->source_url = Zig::toZigString(stackFrame->sourceURL(vm)); + frame->source_url = Bun::toString(stackFrame->sourceURL(vm)); if (stackFrame->isWasmFrame()) { frame->code_type = ZigStackFrameCodeWasm; @@ -3340,37 +3340,11 @@ static void populateStackFrameMetadata(JSC::VM& vm, const JSC::StackFrame* stack JSC::JSObject* callee = JSC::jsCast(calleeCell); - // Does the code block have a user-defined name property? - JSC::JSValue name = callee->getDirect(vm, vm.propertyNames->name); - if (name && name.isString()) { - auto str = name.toWTFString(m_codeBlock->globalObject()); - frame->function_name = Zig::toZigString(str); - return; - } - - /* For functions (either JSFunction or InternalFunction), fallback to their "native" name - * property. Based on JSC::getCalculatedDisplayName, "inlining" the - * JSFunction::calculatedDisplayName\InternalFunction::calculatedDisplayName calls */ - if (JSC::JSFunction* function = JSC::jsDynamicCast(callee)) { - - WTF::String actualName = function->name(vm); - if (!actualName.isEmpty() || function->isHostOrBuiltinFunction()) { - frame->function_name = Zig::toZigString(actualName); - return; - } - - auto inferred_name = function->jsExecutable()->name(); - frame->function_name = Zig::toZigString(inferred_name.string()); - } - - if (JSC::InternalFunction* function = JSC::jsDynamicCast(callee)) { - // Based on JSC::InternalFunction::calculatedDisplayName, skipping the "displayName" property - frame->function_name = Zig::toZigString(function->name()); - } + frame->function_name = Bun::toString(JSC::getCalculatedDisplayName(vm, callee)); } // Based on // https://github.com/mceSystems/node-jsc/blob/master/deps/jscshim/src/shim/JSCStackTrace.cpp#L298 -static void populateStackFramePosition(const JSC::StackFrame* stackFrame, ZigString* source_lines, +static void populateStackFramePosition(const JSC::StackFrame* stackFrame, BunString* source_lines, int32_t* source_line_numbers, uint8_t source_lines_count, ZigStackFramePosition* position) { @@ -3440,7 +3414,7 @@ static void populateStackFramePosition(const JSC::StackFrame* stackFrame, ZigStr // Most of the time, when you look at a stack trace, you want a couple lines above - source_lines[0] = { &chars[lineStart], lineStop - lineStart }; + source_lines[0] = Bun::toString(sourceString.substring(lineStart, lineStop - lineStart).toStringWithoutCopying()); source_line_numbers[0] = line; if (lineStart > 0) { @@ -3457,8 +3431,7 @@ static void populateStackFramePosition(const JSC::StackFrame* stackFrame, ZigStr } // We are at the beginning of the line - source_lines[source_line_i] = { &chars[byte_offset_in_source_string], - end_of_line_offset - byte_offset_in_source_string + 1 }; + 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_line_numbers[source_line_i] = line - source_line_i; source_line_i++; @@ -3546,30 +3519,30 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, except->code = 8; } if (except->code == SYNTAX_ERROR_CODE) { - except->message = Zig::toZigString(err->sanitizedMessageString(global)); + except->message = Bun::toString(err->sanitizedMessageString(global)); } else if (JSC::JSValue message = obj->getIfPropertyExists(global, vm.propertyNames->message)) { - except->message = Zig::toZigString(message, global); + except->message = Bun::toString(global, message); } else { - except->message = Zig::toZigString(err->sanitizedMessageString(global)); + except->message = Bun::toString(err->sanitizedMessageString(global)); } - except->name = Zig::toZigString(err->sanitizedNameString(global)); + except->name = Bun::toString(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 = Zig::toZigString(syscall, global); + except->syscall = Bun::toString(global, syscall); } if (JSC::JSValue code = obj->getIfPropertyExists(global, clientData->builtinNames().codePublicName())) { - except->code_ = Zig::toZigString(code, global); + except->code_ = Bun::toString(global, code); } if (JSC::JSValue path = obj->getIfPropertyExists(global, clientData->builtinNames().pathPublicName())) { - except->path = Zig::toZigString(path, global); + except->path = Bun::toString(global, path); } if (JSC::JSValue fd = obj->getIfPropertyExists(global, Identifier::fromString(vm, "fd"_s))) { @@ -3585,7 +3558,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 = Zig::toZigString(sourceURL, global); + except->stack.frames_ptr[0].source_url = Bun::toString(global, sourceURL); if (JSC::JSValue column = obj->getIfPropertyExists(global, vm.propertyNames->column)) { except->stack.frames_ptr[0].position.column_start = column.toInt32(global); @@ -3597,7 +3570,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] = Zig::toZigString(str); + except->stack.source_lines_ptr[0] = Bun::toString(str); except->stack.source_lines_numbers[0] = except->stack.frames_ptr[0].position.line; except->stack.source_lines_len = 1; except->remapped = true; @@ -3620,7 +3593,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 = Zig::toZigString(name_str); + except->name = Bun::toString(name_str); if (name_str == "Error"_s) { except->code = JSErrorCodeError; } else if (name_str == "EvalError"_s) { @@ -3642,14 +3615,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 = Zig::toZigString( + except->message = Bun::toString( message.toWTFString(global)); } } if (JSC::JSValue sourceURL = obj->getIfPropertyExists(global, global->vm().propertyNames->sourceURL)) { if (sourceURL) { - except->stack.frames_ptr[0].source_url = Zig::toZigString( + except->stack.frames_ptr[0].source_url = Bun::toString( sourceURL.toWTFString(global)); except->stack.frames_len = 1; } @@ -3678,9 +3651,7 @@ void exceptionFromString(ZigException* except, JSC::JSValue value, JSC::JSGlobal } scope.release(); - auto ref = OpaqueJSString::tryCreate(str); - except->message = ZigString { ref->characters8(), ref->length() }; - ref->ref(); + except->message = Bun::toString(str); } void JSC__VM__releaseWeakRefs(JSC__VM* arg0) @@ -3790,8 +3761,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 = Zig::toZigString("Error"_s); - exception->message = Zig::toZigString("Unknown error"_s); + exception->name = Bun::toString("Error"_s); + exception->message = Bun::toString("Unknown error"_s); return; } diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index 213291e7b..73a26e4be 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -29,6 +29,7 @@ const Backtrace = @import("../../crash_reporter.zig"); const JSPrinter = bun.js_printer; const JSLexer = bun.js_lexer; const typeBaseName = @import("../../meta.zig").typeBaseName; +const String = bun.String; pub const ZigGlobalObject = extern struct { pub const shim = Shimmer("Zig", "GlobalObject", @This()); @@ -438,7 +439,7 @@ pub const Process = extern struct { }; pub const ZigStackTrace = extern struct { - source_lines_ptr: [*c]ZigString, + source_lines_ptr: [*c]bun.String, source_lines_numbers: [*c]i32, source_lines_len: u8, source_lines_to_collect: u8, @@ -456,23 +457,24 @@ pub const ZigStackTrace = extern struct { { var source_lines_iter = this.sourceLineIterator(); - var source_line_len: usize = 0; - var count: usize = 0; - while (source_lines_iter.next()) |source| { - count += 1; - source_line_len += source.text.len; - } + var source_line_len = source_lines_iter.getLength(); - if (count > 0 and source_line_len > 0) { - var source_lines = try allocator.alloc(Api.SourceLine, count); + if (source_line_len > 0) { + var source_lines = try allocator.alloc(Api.SourceLine, @intCast(usize, @max(source_lines_iter.i, 0))); var source_line_buf = try allocator.alloc(u8, source_line_len); source_lines_iter = this.sourceLineIterator(); var remain_buf = source_line_buf[0..]; var i: usize = 0; while (source_lines_iter.next()) |source| { - bun.copy(u8, remain_buf, source.text); - const copied_line = remain_buf[0..source.text.len]; - remain_buf = remain_buf[source.text.len..]; + const text = source.text.slice(); + defer source.text.deinit(); + defer bun.copy( + u8, + remain_buf, + text, + ); + const copied_line = remain_buf[0..text.len]; + remain_buf = remain_buf[text.len..]; source_lines[i] = .{ .text = copied_line, .line = source.line }; i += 1; } @@ -508,9 +510,18 @@ pub const ZigStackTrace = extern struct { pub const SourceLine = struct { line: i32, - text: string, + text: ZigString.Slice, }; + pub fn getLength(this: *SourceLineIterator) usize { + var count: usize = 0; + for (this.trace.source_lines_ptr[0..@intCast(usize, this.i)]) |*line| { + count += line.length(); + } + + return count; + } + pub fn untilLast(this: *SourceLineIterator) ?SourceLine { if (this.i < 1) return null; return this.next(); @@ -522,7 +533,7 @@ pub const ZigStackTrace = extern struct { const source_line = this.trace.source_lines_ptr[@intCast(usize, this.i)]; const result = SourceLine{ .line = this.trace.source_lines_numbers[@intCast(usize, this.i)], - .text = source_line.slice(), + .text = source_line.toUTF8(bun.default_allocator), }; this.i -= 1; return result; @@ -541,21 +552,28 @@ pub const ZigStackTrace = extern struct { }; pub const ZigStackFrame = extern struct { - function_name: ZigString, - source_url: ZigString, + function_name: String, + source_url: String, position: ZigStackFramePosition, code_type: ZigStackFrameCode, /// This informs formatters whether to display as a blob URL or not remapped: bool = false, + pub fn deinit(this: *ZigStackFrame) void { + this.function_name.deref(); + this.source_url.deref(); + } + pub fn toAPI(this: *const ZigStackFrame, root_path: string, origin: ?*const ZigURL, allocator: std.mem.Allocator) !Api.StackFrame { var frame: Api.StackFrame = comptime std.mem.zeroes(Api.StackFrame); - if (this.function_name.len > 0) { - frame.function_name = try allocator.dupe(u8, this.function_name.slice()); + if (!this.function_name.isEmpty()) { + var slicer = this.function_name.toUTF8(allocator); + defer slicer.deinit(); + frame.function_name = (try slicer.clone(allocator)).slice(); } - if (this.source_url.len > 0) { + if (!this.source_url.isEmpty()) { frame.file = try std.fmt.allocPrint(allocator, "{any}", .{this.sourceURLFormatter(root_path, origin, true, false)}); } @@ -576,7 +594,7 @@ pub const ZigStackFrame = extern struct { } pub const SourceURLFormatter = struct { - source_url: ZigString, + source_url: bun.String, position: ZigStackFramePosition, enable_color: bool, origin: ?*const ZigURL, @@ -588,7 +606,9 @@ pub const ZigStackFrame = extern struct { try writer.writeAll(Output.prettyFmt("", true)); } - var source_slice = this.source_url.slice(); + var source_slice_ = this.source_url.toUTF8(bun.default_allocator); + var source_slice = source_slice_.slice(); + defer source_slice_.deinit(); if (!this.remapped) { if (this.origin) |origin| { @@ -647,12 +667,12 @@ pub const ZigStackFrame = extern struct { }; pub const NameFormatter = struct { - function_name: ZigString, + function_name: String, code_type: ZigStackFrameCode, enable_color: bool, pub fn format(this: NameFormatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - const name = this.function_name.slice(); + const name = this.function_name; switch (this.code_type) { .Eval => { @@ -662,26 +682,26 @@ pub const ZigStackFrame = extern struct { // try writer.writeAll("(esm)"); }, .Function => { - if (name.len > 0) { + if (!name.isEmpty()) { if (this.enable_color) { - try std.fmt.format(writer, comptime Output.prettyFmt("{s}", true), .{name}); + try std.fmt.format(writer, comptime Output.prettyFmt("{}", true), .{name}); } else { - try std.fmt.format(writer, "{s}", .{name}); + try std.fmt.format(writer, "{}", .{name}); } } }, .Global => { - if (name.len > 0) { - try std.fmt.format(writer, "globalThis {s}", .{name}); + if (!name.isEmpty()) { + try std.fmt.format(writer, "globalThis {}", .{name}); } else { try writer.writeAll("globalThis"); } }, .Wasm => { - try std.fmt.format(writer, "WASM {s}", .{name}); + try std.fmt.format(writer, "WASM {}", .{name}); }, .Constructor => { - try std.fmt.format(writer, "new {s}", .{name}); + try std.fmt.format(writer, "new {}", .{name}); }, else => {}, } @@ -689,9 +709,9 @@ pub const ZigStackFrame = extern struct { }; pub const Zero: ZigStackFrame = ZigStackFrame{ - .function_name = ZigString{ ._unsafe_ptr_do_not_use = "", .len = 0 }, + .function_name = String.empty, .code_type = ZigStackFrameCode.None, - .source_url = ZigString{ ._unsafe_ptr_do_not_use = "", .len = 0 }, + .source_url = String.empty, .position = ZigStackFramePosition.Invalid, }; @@ -744,14 +764,14 @@ pub const ZigException = extern struct { /// SystemError only errno: c_int = 0, /// SystemError only - syscall: ZigString = ZigString.Empty, + syscall: String = String.empty, /// SystemError only - system_code: ZigString = ZigString.Empty, + system_code: String = String.empty, /// SystemError only - path: ZigString = ZigString.Empty, + path: String = String.empty, - name: ZigString, - message: ZigString, + name: String, + message: String, stack: ZigStackTrace, exception: ?*anyopaque, @@ -760,6 +780,19 @@ pub const ZigException = extern struct { fd: i32 = -1, + pub fn deinit(this: *ZigException) void { + this.syscall.deref(); + this.system_code.deref(); + this.path.deref(); + + this.name.deref(); + this.message.deref(); + + for (this.stack.frames_ptr[0..this.stack.frames_len]) |*frame| { + frame.deinit(); + } + } + pub const shim = Shimmer("Zig", "Exception", @This()); pub const name = "ZigException"; pub const namespace = shim.namespace; @@ -768,7 +801,7 @@ pub const ZigException = extern struct { const frame_count = 32; pub const source_lines_count = 6; source_line_numbers: [source_lines_count]i32, - source_lines: [source_lines_count]ZigString, + source_lines: [source_lines_count]String, frames: [frame_count]ZigStackFrame, loaded: bool, zig_exception: ZigException, @@ -786,8 +819,8 @@ pub const ZigException = extern struct { }, .source_lines = brk: { - var lines: [source_lines_count]ZigString = undefined; - @memset(&lines, ZigString.Empty); + var lines: [source_lines_count]String = undefined; + @memset(&lines, String.empty); break :brk lines; }, .zig_exception = undefined, @@ -798,13 +831,17 @@ pub const ZigException = extern struct { return Holder.Zero; } + pub fn deinit(this: *Holder) void { + this.zigException().deinit(); + } + pub fn zigException(this: *Holder) *ZigException { if (!this.loaded) { this.zig_exception = ZigException{ .code = @enumFromInt(JSErrorCode, 255), .runtime_type = JSRuntimeType.Nothing, - .name = ZigString.Empty, - .message = ZigString.Empty, + .name = String.empty, + .message = String.empty, .exception = null, .stack = ZigStackTrace{ .source_lines_ptr = &this.source_lines, @@ -832,8 +869,13 @@ pub const ZigException = extern struct { root_path: string, origin: ?*const ZigURL, ) !void { - const _name: string = @field(this, "name").slice(); - const message: string = @field(this, "message").slice(); + const name_slice = @field(this, "name").toUTF8(bun.default_allocator); + const message_slice = @field(this, "message").toUTF8(bun.default_allocator); + + const _name = name_slice.slice(); + defer name_slice.deinit(); + const message = message_slice.slice(); + defer message_slice.deinit(); var is_empty = true; var api_exception = Api.JsException{ diff --git a/src/bun.js/bindings/headers-handwritten.h b/src/bun.js/bindings/headers-handwritten.h index db1e38d3e..c7429b633 100644 --- a/src/bun.js/bindings/headers-handwritten.h +++ b/src/bun.js/bindings/headers-handwritten.h @@ -120,15 +120,15 @@ typedef struct ZigStackFramePosition { } ZigStackFramePosition; typedef struct ZigStackFrame { - ZigString function_name; - ZigString source_url; + BunString function_name; + BunString source_url; ZigStackFramePosition position; ZigStackFrameCode code_type; bool remapped; } ZigStackFrame; typedef struct ZigStackTrace { - ZigString* source_lines_ptr; + BunString* source_lines_ptr; int32_t* source_lines_numbers; uint8_t source_lines_len; uint8_t source_lines_to_collect; @@ -140,11 +140,11 @@ typedef struct ZigException { unsigned char code; uint16_t runtime_type; int errno_; - ZigString syscall; - ZigString code_; - ZigString path; - ZigString name; - ZigString message; + BunString syscall; + BunString code_; + BunString path; + BunString name; + BunString message; ZigStackTrace stack; void* exception; bool remapped; diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index cf6a65841..605cc0c25 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -1805,6 +1805,7 @@ pub const VirtualMachine = struct { if (exception) |exception_| { var holder = ZigException.Holder.init(); var zig_exception: *ZigException = holder.zigException(); + defer zig_exception.deinit(); exception_.getStackTrace(&zig_exception.stack); if (zig_exception.stack.frames_len > 0) { if (allow_ansi_color) { @@ -1932,8 +1933,14 @@ pub const VirtualMachine = struct { while (i < stack.len) : (i += 1) { const frame = stack[@intCast(usize, i)]; - const file = frame.source_url.slice(); - const func = frame.function_name.slice(); + const file_slice = frame.source_url.toSlice(bun.default_allocator); + defer file_slice.deinit(); + const func_slice = frame.function_name.toSlice(bun.default_allocator); + defer func_slice.deinit(); + + const file = file_slice.slice(); + const func = func_slice.slice(); + if (file.len == 0 and func.len == 0) continue; const has_name = std.fmt.count("{any}", .{frame.nameFormatter( @@ -1985,7 +1992,7 @@ pub const VirtualMachine = struct { pub fn remapStackFramePositions(this: *VirtualMachine, frames: [*]JSC.ZigStackFrame, frames_count: usize) void { for (frames[0..frames_count]) |*frame| { if (frame.position.isInvalid() or frame.remapped) continue; - var sourceURL = frame.source_url.toSlice(bun.default_allocator); + var sourceURL = frame.source_url.toUTF8(bun.default_allocator); defer sourceURL.deinit(); if (this.source_mappings.resolveMapping( @@ -2049,8 +2056,10 @@ pub const VirtualMachine = struct { if (frames.len == 0) return; var top = &frames[0]; + var top_source_url = top.source_url.toUTF8(bun.default_allocator); + defer top_source_url.deinit(); if (this.source_mappings.resolveMapping( - top.source_url.slice(), + top_source_url.slice(), @max(top.position.line, 0), @max(top.position.column_start, 0), )) |mapping| { @@ -2078,18 +2087,18 @@ pub const VirtualMachine = struct { )) |lines| { var source_lines = exception.stack.source_lines_ptr[0..JSC.ZigException.Holder.source_lines_count]; var source_line_numbers = exception.stack.source_lines_numbers[0..JSC.ZigException.Holder.source_lines_count]; - @memset(source_lines, ZigString.Empty); + @memset(source_lines, String.empty); @memset(source_line_numbers, 0); var lines_ = lines[0..@min(lines.len, source_lines.len)]; for (lines_, 0..) |line, j| { - source_lines[(lines_.len - 1) - j] = ZigString.init(line); + source_lines[(lines_.len - 1) - j] = String.init(line); source_line_numbers[j] = top.position.line - @intCast(i32, j) + 1; } exception.stack.source_lines_len = @intCast(u8, lines_.len); - top.position.column_stop = @intCast(i32, source_lines[lines_.len - 1].len); + top.position.column_stop = @intCast(i32, source_lines[lines_.len - 1].length()); top.position.line_stop = top.position.column_stop; // This expression range is no longer accurate @@ -2101,8 +2110,10 @@ pub const VirtualMachine = struct { if (frames.len > 1) { for (frames[1..]) |*frame| { if (frame.position.isInvalid()) continue; + const source_url = frame.source_url.toUTF8(bun.default_allocator); + defer source_url.deinit(); if (this.source_mappings.resolveMapping( - frame.source_url.slice(), + source_url.slice(), @max(frame.position.line, 0), @max(frame.position.column_start, 0), )) |mapping| { @@ -2117,6 +2128,7 @@ pub const VirtualMachine = struct { pub fn printErrorInstance(this: *VirtualMachine, error_instance: JSValue, exception_list: ?*ExceptionList, comptime Writer: type, writer: Writer, comptime allow_ansi_color: bool, comptime allow_side_effects: bool) !void { var exception_holder = ZigException.Holder.init(); var exception = exception_holder.zigException(); + defer exception_holder.deinit(); this.remapZigException(exception, error_instance, exception_list); this.had_errors = true; @@ -2134,15 +2146,18 @@ pub const VirtualMachine = struct { var source_lines = exception.stack.sourceLineIterator(); var last_pad: u64 = 0; while (source_lines.untilLast()) |source| { + defer source.text.deinit(); + const int_size = std.fmt.count("{d}", .{source.line}); const pad = max_line_number_pad - int_size; last_pad = pad; try writer.writeByteNTimes(' ', pad); + try writer.print( comptime Output.prettyFmt("{d} | {s}\n", allow_ansi_color), .{ source.line, - std.mem.trim(u8, source.text, "\n"), + std.mem.trim(u8, source.text.slice(), "\n"), }, ); } @@ -2158,7 +2173,8 @@ pub const VirtualMachine = struct { const top_frame = if (exception.stack.frames_len > 0) exception.stack.frames()[0] else null; if (top_frame == null or top_frame.?.position.isInvalid()) { defer did_print_name = true; - var text = std.mem.trim(u8, source.text, "\n"); + defer source.text.deinit(); + var text = std.mem.trim(u8, source.text.slice(), "\n"); try writer.print( comptime Output.prettyFmt( @@ -2176,7 +2192,9 @@ pub const VirtualMachine = struct { const int_size = std.fmt.count("{d}", .{source.line}); const pad = max_line_number_pad - int_size; try writer.writeByteNTimes(' ', pad); - var remainder = std.mem.trim(u8, source.text, "\n"); + defer source.text.deinit(); + const text = source.text.slice(); + var remainder = std.mem.trim(u8, text, "\n"); try writer.print( comptime Output.prettyFmt( @@ -2188,7 +2206,7 @@ pub const VirtualMachine = struct { if (!top.position.isInvalid()) { var first_non_whitespace = @intCast(u32, top.position.column_start); - while (first_non_whitespace < source.text.len and source.text[first_non_whitespace] == ' ') { + while (first_non_whitespace < text.len and text[first_non_whitespace] == ' ') { first_non_whitespace += 1; } const indent = @intCast(usize, pad) + " | ".len + first_non_whitespace; @@ -2219,10 +2237,10 @@ pub const VirtualMachine = struct { }; var show = Show{ - .system_code = exception.system_code.len > 0 and !strings.eql(exception.system_code.slice(), name.slice()), - .syscall = exception.syscall.len > 0, + .system_code = !exception.system_code.eql(name) and !exception.system_code.isEmpty(), + .syscall = !exception.syscall.isEmpty(), .errno = exception.errno < 0, - .path = exception.path.len > 0, + .path = !exception.path.isEmpty(), .fd = exception.fd != -1, }; @@ -2262,7 +2280,7 @@ pub const VirtualMachine = struct { } else if (show.errno) { try writer.writeAll(" "); } - try writer.print(comptime Output.prettyFmt(" path: \"{s}\"\n", allow_ansi_color), .{exception.path}); + try writer.print(comptime Output.prettyFmt(" path: \"{}\"\n", allow_ansi_color), .{exception.path}); } if (show.fd) { @@ -2281,12 +2299,12 @@ pub const VirtualMachine = struct { } else if (show.errno) { try writer.writeAll(" "); } - try writer.print(comptime Output.prettyFmt(" code: \"{s}\"\n", allow_ansi_color), .{exception.system_code}); + try writer.print(comptime Output.prettyFmt(" code: \"{}\"\n", allow_ansi_color), .{exception.system_code}); add_extra_line = true; } if (show.syscall) { - try writer.print(comptime Output.prettyFmt(" syscall: \"{s}\"\n", allow_ansi_color), .{exception.syscall}); + try writer.print(comptime Output.prettyFmt(" syscall: \"{}\"\n", allow_ansi_color), .{exception.syscall}); add_extra_line = true; } @@ -2303,22 +2321,22 @@ pub const VirtualMachine = struct { try printStackTrace(@TypeOf(writer), writer, exception.stack, allow_ansi_color); } - fn printErrorNameAndMessage(_: *VirtualMachine, name: ZigString, message: ZigString, comptime Writer: type, writer: Writer, comptime allow_ansi_color: bool) !void { - if (name.len > 0 and message.len > 0) { - const display_name: ZigString = if (!name.is16Bit() and strings.eqlComptime(name.slice(), "Error")) ZigString.init("error") else name; + fn printErrorNameAndMessage(_: *VirtualMachine, name: String, message: String, comptime Writer: type, writer: Writer, comptime allow_ansi_color: bool) !void { + if (!name.isEmpty() and !message.isEmpty()) { + const display_name: String = if (name.eqlComptime("Error")) String.init("error") else name; try writer.print(comptime Output.prettyFmt("{any}: {s}\n", allow_ansi_color), .{ display_name, message, }); - } else if (name.len > 0) { - if (name.is16Bit() or !strings.hasPrefixComptime(name.slice(), "error")) { - try writer.print(comptime Output.prettyFmt("error: {s}\n", allow_ansi_color), .{name}); + } else if (!name.isEmpty()) { + if (!name.hasPrefixComptime("error")) { + try writer.print(comptime Output.prettyFmt("error: {}\n", allow_ansi_color), .{name}); } else { - try writer.print(comptime Output.prettyFmt("{s}\n", allow_ansi_color), .{name}); + try writer.print(comptime Output.prettyFmt("{}\n", allow_ansi_color), .{name}); } - } else if (message.len > 0) { - try writer.print(comptime Output.prettyFmt("error: {s}\n", allow_ansi_color), .{message}); + } else if (!message.isEmpty()) { + try writer.print(comptime Output.prettyFmt("error: {}\n", allow_ansi_color), .{message}); } else { try writer.print(comptime Output.prettyFmt("error\n", allow_ansi_color), .{}); } diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index d3bb90747..5ae2337f9 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -1532,8 +1532,8 @@ inline fn createIfScope( // In Github Actions, emit an annotation that renders the error and location. // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message pub fn printGithubAnnotation(exception: *JSC.ZigException) void { - const name = exception.name; - const message = exception.message; + const name = @field(exception, "name"); + const message = @field(exception, "message"); const frames = exception.stack.frames(); const top_frame = if (frames.len > 0) frames[0] else null; const dir = bun.getenvZ("GITHUB_WORKSPACE") orelse bun.fs.FileSystem.instance.top_level_dir; @@ -1543,7 +1543,7 @@ pub fn printGithubAnnotation(exception: *JSC.ZigException) void { if (top_frame) |frame| { if (!frame.position.isInvalid()) { - const source_url = frame.source_url.toSlice(allocator); + const source_url = frame.source_url.toUTF8(allocator); defer source_url.deinit(); const file = bun.path.relative(dir, source_url.slice()); Output.printError("\n::error file={s},line={d},col={d},title=", .{ @@ -1559,14 +1559,14 @@ pub fn printGithubAnnotation(exception: *JSC.ZigException) void { Output.printError("\n::error title=", .{}); } - if (name.len == 0 or name.eqlComptime("Error")) { + if (name.isEmpty() or name.eqlComptime("Error")) { Output.printError("error", .{}); } else { Output.printError("{s}", .{name.githubAction()}); } - if (message.len > 0) { - const message_slice = message.toSlice(allocator); + if (!message.isEmpty()) { + const message_slice = message.toUTF8(allocator); defer message_slice.deinit(); const msg = message_slice.slice(); @@ -1574,7 +1574,7 @@ pub fn printGithubAnnotation(exception: *JSC.ZigException) void { while (strings.indexOfNewlineOrNonASCIIOrANSI(msg, cursor)) |i| { cursor = i + 1; if (msg[i] == '\n') { - const first_line = ZigString.init(msg[0..i]); + const first_line = bun.String.fromUTF8(msg[0..i]); Output.printError(": {s}::", .{first_line.githubAction()}); break; } @@ -1605,10 +1605,10 @@ pub fn printGithubAnnotation(exception: *JSC.ZigException) void { var i: i16 = 0; while (i < frames.len) : (i += 1) { const frame = frames[@intCast(usize, i)]; - const source_url = frame.source_url.toSlice(allocator); + const source_url = frame.source_url.toUTF8(allocator); defer source_url.deinit(); const file = bun.path.relative(dir, source_url.slice()); - const func = frame.function_name.toSlice(allocator); + const func = frame.function_name.toUTF8(allocator); if (file.len == 0 and func.len == 0) continue; diff --git a/src/js/out/modules/node/path.js b/src/js/out/modules/node/path.js index f8cc1ec08..3a3a75207 100644 --- a/src/js/out/modules/node/path.js +++ b/src/js/out/modules/node/path.js @@ -1 +1 @@ -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}; +var i=function(N){var m=g({basename:N.basename.bind(N),dirname:N.dirname.bind(N),extname:N.extname.bind(N),format:N.format.bind(N),isAbsolute:N.isAbsolute.bind(N),join:N.join.bind(N),normalize:N.normalize.bind(N),parse:N.parse.bind(N),relative:N.relative.bind(N),resolve:N.resolve.bind(N),toNamespacedPath:N.toNamespacedPath.bind(N),sep:N.sep,delimiter:N.delimiter});return m.default=m,m},g=(N)=>Object.assign(Object.create(null),N),f=i(Bun._Path()),J=i(Bun._Path(!1)),k=i(Bun._Path(!0));f.win32=k;f.posix=J;var{basename:q,dirname:v,extname:y,format:z,isAbsolute:A,join:B,normalize:K,parse:C,relative:D,resolve:E,toNamespacedPath:F,sep:G,delimiter:H,__esModule:I}=f;f[Symbol.for("CommonJS")]=0;f.__esModule=!0;var O=f;export{k as win32,F as toNamespacedPath,G as sep,E as resolve,D as relative,J as posix,C as parse,K as normalize,B as join,A as isAbsolute,z as format,y as extname,v as dirname,H as delimiter,O as default,g as createModule,q as basename,I as __esModule}; diff --git a/src/js/out/modules/node/stream.web.js b/src/js/out/modules/node/stream.web.js index bb906418c..f91ee03b4 100644 --- a/src/js/out/modules/node/stream.web.js +++ b/src/js/out/modules/node/stream.web.js @@ -1 +1 @@ -var{ReadableStream:c,ReadableStreamDefaultController:j,WritableStream:k,WritableStreamDefaultController:p,WritableStreamDefaultWriter:v,TransformStream:w,TransformStreamDefaultController:x,ByteLengthQueuingStrategy:z,CountQueuingStrategy:A,ReadableStreamBYOBReader:E,ReadableStreamBYOBRequest:F,ReadableStreamDefaultReader:G}=globalThis,H={ReadableStream:c,ReadableStreamDefaultController:j,WritableStream:k,WritableStreamDefaultController:p,WritableStreamDefaultWriter:v,TransformStream:w,TransformStreamDefaultController:x,ByteLengthQueuingStrategy:z,CountQueuingStrategy:A,ReadableStreamBYOBReader:E,ReadableStreamBYOBRequest:F,ReadableStreamDefaultReader:G,[Symbol.for("CommonJS")]:0};export{H as default,v as WritableStreamDefaultWriter,p as WritableStreamDefaultController,k as WritableStream,x as TransformStreamDefaultController,w as TransformStream,G as ReadableStreamDefaultReader,j as ReadableStreamDefaultController,F as ReadableStreamBYOBRequest,E as ReadableStreamBYOBReader,c as ReadableStream,A as CountQueuingStrategy,z as ByteLengthQueuingStrategy}; +var{ReadableStream:k,ReadableStreamDefaultController:v,WritableStream:w,WritableStreamDefaultController:x,WritableStreamDefaultWriter:z,TransformStream:A,TransformStreamDefaultController:E,ByteLengthQueuingStrategy:F,CountQueuingStrategy:c,ReadableStreamBYOBReader:j,ReadableStreamBYOBRequest:G,ReadableStreamDefaultReader:p}=globalThis,H={ReadableStream:k,ReadableStreamDefaultController:v,WritableStream:w,WritableStreamDefaultController:x,WritableStreamDefaultWriter:z,TransformStream:A,TransformStreamDefaultController:E,ByteLengthQueuingStrategy:F,CountQueuingStrategy:c,ReadableStreamBYOBReader:j,ReadableStreamBYOBRequest:G,ReadableStreamDefaultReader:p,[Symbol.for("CommonJS")]:0};export{H as default,z as WritableStreamDefaultWriter,x as WritableStreamDefaultController,w as WritableStream,E as TransformStreamDefaultController,A as TransformStream,p as ReadableStreamDefaultReader,v as ReadableStreamDefaultController,G as ReadableStreamBYOBRequest,j as ReadableStreamBYOBReader,k as ReadableStream,c as CountQueuingStrategy,F as ByteLengthQueuingStrategy}; diff --git a/src/logger.zig b/src/logger.zig index 3279e9fd5..fc25541de 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -421,12 +421,12 @@ pub const Msg = struct { if (err.toError()) |value| { value.toZigException(globalObject, zig_exception_holder.zigException()); } else { - zig_exception_holder.zig_exception.message = JSC.ZigString.fromUTF8(err.toSlice(globalObject, allocator).slice()); + zig_exception_holder.zig_exception.message = err.toBunString(globalObject); } return Msg{ .data = .{ - .text = zig_exception_holder.zigException().message.toSliceClone(allocator).slice(), + .text = try zig_exception_holder.zigException().message.toOwnedSlice(allocator), .location = Location{ .file = file, }, diff --git a/src/string.zig b/src/string.zig index 54af2ba68..3c0c99ce5 100644 --- a/src/string.zig +++ b/src/string.zig @@ -247,6 +247,26 @@ pub const String = extern struct { extern fn BunString__fromLatin1(bytes: [*]const u8, len: usize) String; extern fn BunString__fromBytes(bytes: [*]const u8, len: usize) String; + pub fn toOwnedSlice(this: String, allocator: std.mem.Allocator) ![]u8 { + switch (this.tag) { + .ZigString => return try this.value.ZigString.toOwnedSlice(allocator), + .WTFStringImpl => { + var utf8_slice = this.value.WTFStringImpl.toUTF8(allocator); + + if (utf8_slice.allocator.get()) |alloc| { + if (isWTFAllocator(alloc)) { + return @constCast((try utf8_slice.clone(allocator)).slice()); + } + } + + return @constCast(utf8_slice.slice()); + }, + .StaticZigString => return try this.value.StaticZigString.toOwnedSlice(allocator), + .Empty => return &[_]u8{}, + else => unreachable, + } + } + pub fn createLatin1(bytes: []const u8) String { JSC.markBinding(@src()); return BunString__fromLatin1(bytes.ptr, bytes.len); @@ -429,6 +449,10 @@ pub const String = extern struct { return .latin1; } + pub fn githubAction(self: String) ZigString.GithubActionFormatter { + return self.toZigString().githubAction(); + } + pub fn byteSlice(this: String) []const u8 { return switch (this.tag) { .ZigString, .StaticZigString => this.value.ZigString.byteSlice(), -- cgit v1.2.3 From 8481f2922f4f6fe07f8b44067fe478cb1ac1706a Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 21:45:16 -0700 Subject: Add GC test for errors --- src/bun.js/WebKit | 2 +- src/bun.js/bindings/ZigGlobalObject.cpp | 8 ++++++-- src/bun.js/javascript.zig | 4 ++-- test/js/bun/util/error-gc-test.test.js | 26 ++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 test/js/bun/util/error-gc-test.test.js diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit index a9e3ab9b8..8a03cf746 160000 --- a/src/bun.js/WebKit +++ b/src/bun.js/WebKit @@ -1 +1 @@ -Subproject commit a9e3ab9b85cf911218e1d51eed8079cd955ec578 +Subproject commit 8a03cf746abef8a48c932ab25f8821390632f2e2 diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 9ff3ebf93..7ba0f0b30 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -390,7 +390,11 @@ static String computeErrorInfoWithoutPrepareStackTrace(JSC::VM& vm, Vector { + for (let i = 0; i < 100; i++) { + var fn = function yo() { + var err = (function innerOne() { + var err = new Error(); + for (let i = 0; i < 1000; i++) { + Bun.inspect(err); + } + Bun.gc(true); + return err; + })(); + err.stack += ""; + }; + + Object.defineProperty(fn, "name", { + value: + "yoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyoyo" + + i, + }); + + fn(); + Bun.gc(true); + } +}); -- cgit v1.2.3 From 8b2c72300c49b1b52ff40c7a927e1d7ddcb4e7a9 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 21:56:26 -0700 Subject: Another test --- test/js/bun/util/error-gc-test.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/js/bun/util/error-gc-test.test.js b/test/js/bun/util/error-gc-test.test.js index 8cef55760..5f9134d4c 100644 --- a/test/js/bun/util/error-gc-test.test.js +++ b/test/js/bun/util/error-gc-test.test.js @@ -1,5 +1,7 @@ import { test, expect } from "bun:test"; +// This test checks that printing stack traces increments and decrements +// reference-counted strings test("error gc test", () => { for (let i = 0; i < 100; i++) { var fn = function yo() { @@ -24,3 +26,10 @@ test("error gc test", () => { Bun.gc(true); } }); + +test("error gc test #2", () => { + for (let i = 0; i < 1000; i++) { + new Error().stack; + Bun.gc(); + } +}); -- cgit v1.2.3 From c6f6db95ffbbf13a68939f7c3de544b1285e8929 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 21:56:45 -0700 Subject: Ref the strings --- src/bun.js/bindings/bindings.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 141215ebe..be3408555 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -3303,7 +3303,11 @@ bool JSC__JSValue__stringIncludes(JSC__JSValue value, JSC__JSGlobalObject* globa static void populateStackFrameMetadata(JSC::VM& vm, const JSC::StackFrame* stackFrame, ZigStackFrame* frame) { - frame->source_url = Bun::toString(stackFrame->sourceURL(vm)); + String str = stackFrame->sourceURL(vm); + if (!str.isEmpty()) + str.impl()->ref(); + + frame->source_url = Bun::toString(str); if (stackFrame->isWasmFrame()) { frame->code_type = ZigStackFrameCodeWasm; @@ -3340,7 +3344,10 @@ static void populateStackFrameMetadata(JSC::VM& vm, const JSC::StackFrame* stack JSC::JSObject* callee = JSC::jsCast(calleeCell); - frame->function_name = Bun::toString(JSC::getCalculatedDisplayName(vm, callee)); + String displayName = JSC::getCalculatedDisplayName(vm, callee); + if (!displayName.isEmpty()) + displayName.impl()->ref(); + frame->function_name = Bun::toString(displayName); } // Based on // https://github.com/mceSystems/node-jsc/blob/master/deps/jscshim/src/shim/JSCStackTrace.cpp#L298 -- cgit v1.2.3 From 8984c819613b52b3cfaf1cd22fc059d0150eedfc Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 21:57:31 -0700 Subject: Prevent integer overflow --- src/bun.js/bindings/bindings.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 2b800ab8b..1c09378a8 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -4608,7 +4608,7 @@ pub const JSValue = enum(JSValueReprInt) { return 0; } - return @intFromFloat(u64, @max(len, 0)); + return @intFromFloat(u64, @max(@min(len, std.math.maxInt(i52)), 0)); } /// This function supports: @@ -4629,7 +4629,7 @@ pub const JSValue = enum(JSValueReprInt) { return null; } - return @intFromFloat(u64, @max(len, 0)); + return @intFromFloat(u64, @max(@min(len, std.math.maxInt(i52)), 0)); } /// Do not use this directly! -- cgit v1.2.3 From 853e3771595fd46bb09641c8dbdab738843a45cd Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 29 Jun 2023 08:30:21 -0700 Subject: Revert "[jest] fix lifecycle hook execution order (#3447)" (#3455) This reverts commit 182e8aa1392af9ba92beccce06f49f8e4593fe5c. --- src/bun.js/test/jest.zig | 162 +++++++++++++++--------------------- test/js/bun/test/jest-hooks.test.ts | 31 ------- test/js/bun/test/test-test.test.ts | 6 +- 3 files changed, 69 insertions(+), 130 deletions(-) diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 5ae2337f9..d53194e00 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -493,7 +493,8 @@ pub const Jest = struct { var filepath = Fs.FileSystem.instance.filename_store.append([]const u8, slice) catch unreachable; var scope = runner_.getOrPutFile(filepath); - scope.push(); + DescribeScope.active = scope; + DescribeScope.module = scope; return Bun__Jest__testModuleObject(ctx).asObjectRef(); } @@ -750,16 +751,17 @@ pub const DescribeScope = struct { } pub fn push(new: *DescribeScope) void { - if (comptime is_bindgen) return; - std.debug.assert(DescribeScope.active != new); - if (new.parent) |scope| std.debug.assert(scope == DescribeScope.active); + if (comptime is_bindgen) return undefined; + if (new == DescribeScope.active) return; + + new.parent = DescribeScope.active; DescribeScope.active = new; } pub fn pop(this: *DescribeScope) void { - if (comptime is_bindgen) return; - std.debug.assert(DescribeScope.active == this); - DescribeScope.active = this.parent; + if (comptime is_bindgen) return undefined; + if (DescribeScope.active == this) + DescribeScope.active = this.parent orelse DescribeScope.active; } pub const LifecycleHook = enum { @@ -769,7 +771,8 @@ pub const DescribeScope = struct { afterAll, }; - pub threadlocal var active: ?*DescribeScope = null; + pub threadlocal var active: *DescribeScope = undefined; + pub threadlocal var module: *DescribeScope = undefined; const CallbackFn = *const fn ( *JSC.JSGlobalObject, @@ -778,24 +781,21 @@ pub const DescribeScope = struct { fn createCallback(comptime hook: LifecycleHook) CallbackFn { return struct { + const this_hook = hook; pub fn run( globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - const arguments = callframe.arguments(2); - if (arguments.len < 1) { - globalThis.throwNotEnoughArguments("callback", 1, arguments.len); + const arguments_ = callframe.arguments(2); + const arguments = arguments_.ptr[0..arguments_.len]; + if (arguments.len == 0 or !arguments[0].isObject() or !arguments[0].isCallable(globalThis.vm())) { + globalThis.throwInvalidArgumentType(@tagName(this_hook), "callback", "function"); return .zero; } - const cb = arguments.ptr[0]; - if (!cb.isObject() or !cb.isCallable(globalThis.vm())) { - globalThis.throwInvalidArgumentType(@tagName(hook), "callback", "function"); - return .zero; - } - - cb.protect(); - @field(DescribeScope.active.?, @tagName(hook)).append(getAllocator(globalThis), cb) catch unreachable; + arguments[0].protect(); + const name = comptime @as(string, @tagName(this_hook)); + @field(DescribeScope.active, name).append(getAllocator(globalThis), arguments[0]) catch unreachable; return JSC.JSValue.jsBoolean(true); } }.run; @@ -829,22 +829,11 @@ pub const DescribeScope = struct { pub const beforeAll = createCallback(.beforeAll); pub const beforeEach = createCallback(.beforeEach); - pub fn execCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { - var hooks = &@field(this, @tagName(hook)); - defer { - if (comptime hook == .beforeAll or hook == .afterAll) { - hooks.clearAndFree(getAllocator(globalObject)); - } - } - - for (hooks.items) |cb| { - std.debug.assert(cb.isObject()); - std.debug.assert(cb.isCallable(globalObject.vm())); - defer { - if (comptime hook == .beforeAll or hook == .afterAll) { - cb.unprotect(); - } - } + pub fn execCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) JSValue { + const name = comptime @as(string, @tagName(hook)); + var hooks: []JSC.JSValue = @field(this, name).items; + for (hooks, 0..) |cb, i| { + if (cb.isEmpty()) continue; const pending_test = Jest.runner.?.pending_test; // forbid `expect()` within hooks @@ -854,23 +843,20 @@ pub const DescribeScope = struct { Jest.runner.?.did_pending_test_fail = false; const vm = VirtualMachine.get(); - var result: JSC.JSValue = switch (cb.getLength(globalObject)) { - 0 => cb.call(globalObject, &.{}), - else => brk: { - this.done = false; - const done_func = JSC.NewFunctionWithData( - globalObject, - ZigString.static("done"), - 0, - DescribeScope.onDone, - false, - this, - ); - var result = cb.call(globalObject, &.{done_func}); - vm.waitFor(&this.done); - break :brk result; - }, - }; + var result: JSC.JSValue = if (cb.getLength(globalObject) > 0) brk: { + this.done = false; + const done_func = JSC.NewFunctionWithData( + globalObject, + ZigString.static("done"), + 0, + DescribeScope.onDone, + false, + this, + ); + var result = cb.call(globalObject, &.{done_func}); + vm.waitFor(&this.done); + break :brk result; + } else cb.call(globalObject, &.{}); if (result.asAnyPromise()) |promise| { if (promise.status(globalObject.vm()) == .Pending) { result.protect(); @@ -884,28 +870,19 @@ pub const DescribeScope = struct { Jest.runner.?.pending_test = pending_test; Jest.runner.?.did_pending_test_fail = orig_did_pending_test_fail; if (result.isAnyError()) return result; + + if (comptime hook == .beforeAll or hook == .afterAll) { + hooks[i] = JSC.JSValue.zero; + } } - return null; + return JSValue.zero; } pub fn runGlobalCallbacks(globalThis: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { // global callbacks - var hooks = &@field(Jest.runner.?.global_callbacks, @tagName(hook)); - defer { - if (comptime hook == .beforeAll or hook == .afterAll) { - hooks.clearAndFree(getAllocator(globalThis)); - } - } - - for (hooks.items) |cb| { - std.debug.assert(cb.isObject()); - std.debug.assert(cb.isCallable(globalThis.vm())); - defer { - if (comptime hook == .beforeAll or hook == .afterAll) { - cb.unprotect(); - } - } + for (@field(Jest.runner.?.global_callbacks, @tagName(hook)).items) |cb| { + if (cb.isEmpty()) continue; const pending_test = Jest.runner.?.pending_test; // forbid `expect()` within hooks @@ -932,40 +909,28 @@ pub const DescribeScope = struct { if (result.isAnyError()) return result; } - return null; - } - - fn runBeforeCallbacks(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { - if (this.parent) |scope| { - if (scope.runBeforeCallbacks(globalObject, hook)) |err| { - return err; - } + if (comptime hook == .beforeAll or hook == .afterAll) { + @field(Jest.runner.?.global_callbacks, @tagName(hook)).items.len = 0; } - return this.execCallback(globalObject, hook); + + return null; } pub fn runCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) JSValue { - if (comptime hook == .afterAll or hook == .afterEach) { - var parent: ?*DescribeScope = this; - while (parent) |scope| { - if (scope.execCallback(globalObject, hook)) |err| { - return err; - } - parent = scope.parent; - } - } - if (runGlobalCallbacks(globalObject, hook)) |err| { return err; } - if (comptime hook == .beforeAll or hook == .beforeEach) { - if (this.runBeforeCallbacks(globalObject, hook)) |err| { - return err; + var parent = this.parent; + while (parent) |scope| { + const ret = scope.execCallback(globalObject, hook); + if (!ret.isEmpty()) { + return ret; } + parent = scope.parent; } - return .zero; + return this.execCallback(globalObject, hook); } pub fn call(globalThis: *JSGlobalObject, callframe: *CallFrame) callconv(.C) JSValue { @@ -996,8 +961,11 @@ pub const DescribeScope = struct { if (comptime is_bindgen) return undefined; callback.protect(); defer callback.unprotect(); - this.push(); - defer this.pop(); + var original_active = active; + defer active = original_active; + if (this != module) + this.parent = this.parent orelse active; + active = this; if (callback == .zero) { this.runTests(globalObject); @@ -1096,8 +1064,9 @@ pub const DescribeScope = struct { if (!this.isAllSkipped()) { // Run the afterAll callbacks, in reverse order // unless there were no tests for this scope - if (this.execCallback(globalThis, .afterAll)) |err| { - globalThis.bunVM().runErrorHandler(err, null); + const afterAll_result = this.execCallback(globalThis, .afterAll); + if (!afterAll_result.isEmpty()) { + globalThis.bunVM().runErrorHandler(afterAll_result, null); } } @@ -1177,6 +1146,7 @@ pub const TestRunnerTask = struct { // reset the global state for each test // prior to the run + DescribeScope.active = describe; expect.active_test_expectation_counter = .{}; jsc_vm.last_reported_error_for_dedupe = .zero; @@ -1447,7 +1417,7 @@ inline fn createScope( return .zero; } - const parent = DescribeScope.active.?; + const parent = DescribeScope.active; const allocator = getAllocator(globalThis); const label = if (description == .zero) "" diff --git a/test/js/bun/test/jest-hooks.test.ts b/test/js/bun/test/jest-hooks.test.ts index 618cdc4c6..c99dc7759 100644 --- a/test/js/bun/test/jest-hooks.test.ts +++ b/test/js/bun/test/jest-hooks.test.ts @@ -1,36 +1,5 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "bun:test"; -let hooks_run: string[] = []; - -beforeAll(() => hooks_run.push("global beforeAll")); -beforeEach(() => hooks_run.push("global beforeEach")); -afterAll(() => hooks_run.push("global afterAll")); -afterEach(() => hooks_run.push("global afterEach")); - -describe("describe scope", () => { - beforeAll(() => hooks_run.push("describe beforeAll")); - beforeEach(() => hooks_run.push("describe beforeEach")); - afterAll(() => hooks_run.push("describe afterAll")); - afterEach(() => hooks_run.push("describe afterEach")); - - it("should run after beforeAll/beforeEach in the correct order", () => { - expect(hooks_run).toEqual(["global beforeAll", "describe beforeAll", "global beforeEach", "describe beforeEach"]); - }); - - it("should run after afterEach/afterAll in the correct order", () => { - expect(hooks_run).toEqual([ - "global beforeAll", - "describe beforeAll", - "global beforeEach", - "describe beforeEach", - "describe afterEach", - "global afterEach", - "global beforeEach", - "describe beforeEach", - ]); - }); -}); - describe("test jest hooks in bun-test", () => { describe("test beforeAll hook", () => { let animal = "tiger"; diff --git a/test/js/bun/test/test-test.test.ts b/test/js/bun/test/test-test.test.ts index 5f732bb82..7ecfdef11 100644 --- a/test/js/bun/test/test-test.test.ts +++ b/test/js/bun/test/test-test.test.ts @@ -540,18 +540,18 @@ beforeEach: #2 beforeEach: TEST-FILE beforeEach: one describe scope -- inside one describe scope -- -afterEach: one describe scope -afterEach: TEST-FILE afterEach: #1 afterEach: #2 +afterEach: TEST-FILE +afterEach: one describe scope afterAll: one describe scope beforeEach: #1 beforeEach: #2 beforeEach: TEST-FILE -- the top-level test -- -afterEach: TEST-FILE afterEach: #1 afterEach: #2 +afterEach: TEST-FILE afterAll: TEST-FILE afterAll: #1 afterAll: #2 -- cgit v1.2.3 From fec0d15c4f20c053c4660ec8ad4da31d689ec895 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Thu, 29 Jun 2023 11:53:44 -0400 Subject: cant believe i missed this (#3453) --- src/node-fallbacks/node-fetch.js | 1 + test/js/node/fs/node-fetch.cjs.test.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 test/js/node/fs/node-fetch.cjs.test.js diff --git a/src/node-fallbacks/node-fetch.js b/src/node-fallbacks/node-fetch.js index a66d8fc7f..f124e6461 100644 --- a/src/node-fallbacks/node-fetch.js +++ b/src/node-fallbacks/node-fetch.js @@ -70,6 +70,7 @@ export default Object.assign(fetch, { fileFrom, fileFromSync, isRedirect, + [Symbol.for("CommonJS")]: 0, }); export { diff --git a/test/js/node/fs/node-fetch.cjs.test.js b/test/js/node/fs/node-fetch.cjs.test.js new file mode 100644 index 000000000..9a6a4b407 --- /dev/null +++ b/test/js/node/fs/node-fetch.cjs.test.js @@ -0,0 +1,13 @@ +const fetch = require("node-fetch"); + +test("require('node-fetch') fetches", async () => { + const server = Bun.serve({ + port: 0, + fetch(req, server) { + server.stop(); + return new Response(); + }, + }); + expect(await fetch("http://" + server.hostname + ":" + server.port)).toBeInstanceOf(Response); + server.stop(true); +}); -- cgit v1.2.3 From 9c66fdc70350fb34102d79e101a2d4a64ba41365 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Thu, 29 Jun 2023 14:51:24 -0700 Subject: [bundler] avoid printing unnecessary declarations (#3456) * skip declarations without values * tests * deoptimize cjs when decls are needed --- src/bundler/bundle_v2.zig | 46 ++++++++++++---------- src/js_parser.zig | 74 ++++++++---------------------------- test/bundler/esbuild/default.test.ts | 71 ++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 79 deletions(-) diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index aa7c40599..b7c5e80c5 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -7950,27 +7950,31 @@ const LinkerContext = struct { } else if (FeatureFlags.unwrap_commonjs_to_esm and s.was_commonjs_export and wrap == .cjs) { std.debug.assert(stmt.data.s_local.decls.len == 1); const decl = stmt.data.s_local.decls.ptr[0]; - stmt = Stmt.alloc( - S.SExpr, - S.SExpr{ - .value = Expr.init( - E.Binary, - E.Binary{ - .op = .bin_assign, - .left = Expr.init( - E.CommonJSExportIdentifier, - E.CommonJSExportIdentifier{ - .ref = decl.binding.data.b_identifier.ref, - }, - decl.binding.loc, - ), - .right = decl.value orelse Expr.init(E.Undefined, E.Undefined{}, Logger.Loc.Empty), - }, - stmt.loc, - ), - }, - stmt.loc, - ); + if (decl.value) |decl_value| { + stmt = Stmt.alloc( + S.SExpr, + S.SExpr{ + .value = Expr.init( + E.Binary, + E.Binary{ + .op = .bin_assign, + .left = Expr.init( + E.CommonJSExportIdentifier, + E.CommonJSExportIdentifier{ + .ref = decl.binding.data.b_identifier.ref, + }, + decl.binding.loc, + ), + .right = decl_value, + }, + stmt.loc, + ), + }, + stmt.loc, + ); + } else { + continue; + } } }, diff --git a/src/js_parser.zig b/src/js_parser.zig index 16560d525..2d84fc0c0 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -3102,70 +3102,28 @@ pub const Parser = struct { var export_refs = p.commonjs_named_exports.values(); var export_names = p.commonjs_named_exports.keys(); - if (!p.commonjs_named_exports_deoptimized) { - - // This is a workaround for packages which have broken ESM checks - // If they never actually assign to exports.foo, only check for it - // and the package specifies type "module" - // and the package uses ESM syntax - // We should just say - // You're ESM and lying about it. - if (p.options.module_type == .esm and p.has_es_module_syntax) { + break_optimize: { + if (!p.commonjs_named_exports_deoptimized) { var needs_decl_count: usize = 0; for (export_refs) |*export_ref| { needs_decl_count += @as(usize, @intFromBool(export_ref.needs_decl)); } - - if (needs_decl_count == export_names.len) { - force_esm = true; + // This is a workaround for packages which have broken ESM checks + // If they never actually assign to exports.foo, only check for it + // and the package specifies type "module" + // and the package uses ESM syntax + // We should just say + // You're ESM and lying about it. + if (p.options.module_type == .esm or p.has_es_module_syntax) { + if (needs_decl_count == export_names.len) { + force_esm = true; + break :break_optimize; + } } - } - - if (!force_esm) { - // We make this safe by doing toCommonJS() at runtime - for (export_refs, export_names) |*export_ref, alias| { - if (export_ref.needs_decl) { - var this_stmts = p.allocator.alloc(Stmt, 2) catch unreachable; - var decls = p.allocator.alloc(Decl, 1) catch unreachable; - const ref = export_ref.loc_ref.ref.?; - decls[0] = .{ - .binding = p.b(B.Identifier{ .ref = ref }, export_ref.loc_ref.loc), - .value = null, - }; - var declared_symbols = DeclaredSymbol.List.initCapacity(p.allocator, 1) catch unreachable; - declared_symbols.appendAssumeCapacity(.{ .ref = ref, .is_top_level = true }); - this_stmts[0] = p.s( - S.Local{ - .kind = .k_var, - .is_export = false, - .was_commonjs_export = true, - .decls = Decl.List.init(decls), - }, - export_ref.loc_ref.loc, - ); - p.module_scope.generated.push(p.allocator, ref) catch unreachable; - var clause_items = p.allocator.alloc(js_ast.ClauseItem, 1) catch unreachable; - clause_items[0] = js_ast.ClauseItem{ - .alias = alias, - .alias_loc = export_ref.loc_ref.loc, - .name = export_ref.loc_ref, - }; - this_stmts[1] = p.s( - S.ExportClause{ - .items = clause_items, - .is_single_line = true, - }, - export_ref.loc_ref.loc, - ); - export_ref.needs_decl = false; - before.append(.{ - .stmts = this_stmts, - .declared_symbols = declared_symbols, - .tag = .commonjs_named_export, - .can_be_removed_if_unused = p.stmtsCanBeRemovedIfUnused(this_stmts), - }) catch unreachable; - } + if (needs_decl_count > 0) { + p.symbols.items[p.exports_ref.innerIndex()].use_count_estimate += @truncate(u32, export_refs.len); + p.deoptimizeCommonJSNamedExports(); } } } diff --git a/test/bundler/esbuild/default.test.ts b/test/bundler/esbuild/default.test.ts index 20856ecdf..ac820848a 100644 --- a/test/bundler/esbuild/default.test.ts +++ b/test/bundler/esbuild/default.test.ts @@ -6765,4 +6765,75 @@ describe("bundler", () => { stdout: "hello index.esm.js", }, }); + itBundled("default/RequireProperlyHandlesNamedExportDeclsInCjsModule", { + files: { + "/entry.js": ` + const { a, b, c, d } = require('foo'); + console.log(a, b, c, d); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0" + } + `, + "/node_modules/foo/index.js": ` + if (!exports.d) { + exports.d = 7; + } + if (exports.hasOwnProperty("d")) { + exports.a = 5; + } + + exports.b; + exports.b = 8; + exports.b = 9; + + var c; + c = 2; + exports.c = c; + `, + }, + run: { + stdout: "5 9 2 7", + }, + onAfterBundle(api) { + const contents = api.readFile("out.js"); + expect(contents).not.toContain("undefined"); + expect(contents).not.toContain("$"); + }, + }); + itBundled("default/EsmImportProperlyHandlesNamedExportDeclsInUnwrappedCjsModule", { + files: { + "/entry.js": ` + import { a, b, c, d } from 'foo'; + console.log(a, b, c, d); + `, + "/node_modules/foo/package.json": ` + { + "name": "foo", + "version": "2.0.0" + } + `, + "/node_modules/foo/index.js": ` + if (!exports.d) { + exports.d = 7; + } + if (exports.hasOwnProperty("d")) { + exports.a = 5; + } + + exports.b; + exports.b = 8; + exports.b = 9; + + var c; + c = 2; + exports.c = c; + `, + }, + run: { + stdout: "5 9 2 7", + }, + }); }); -- cgit v1.2.3 From 7af757d104763a84e0c6d0b36eb0055afe1c40fa Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:47:00 -0700 Subject: add setters for `Agent` properties (#3460) * make `Agent` properties public * back to private, added setters * change properties to public --- src/js/node/http.js | 108 ++++++++----------------------- src/js/out/WebCoreJSBuiltins.cpp | 136 +++++++++++++++++++-------------------- src/js/out/modules/node/http.js | 69 +++++--------------- 3 files changed, 111 insertions(+), 202 deletions(-) diff --git a/src/js/node/http.js b/src/js/node/http.js index 658e45433..fe9730101 100644 --- a/src/js/node/http.js +++ b/src/js/node/http.js @@ -173,20 +173,20 @@ export function createServer(options, callback) { } export class Agent extends EventEmitter { - #defaultPort = 80; - #protocol = "http:"; - #options; - #requests; - #sockets; - #freeSockets; - - #keepAliveMsecs; - #keepAlive; - #maxSockets; - #maxFreeSockets; - #scheduling; - #maxTotalSockets; - #totalSocketCount; + defaultPort = 80; + protocol = "http:"; + options; + requests; + sockets; + freeSockets; + + keepAliveMsecs; + keepAlive; + maxSockets; + maxFreeSockets; + scheduling; + maxTotalSockets; + totalSocketCount; #fakeSocket; @@ -200,75 +200,23 @@ export class Agent extends EventEmitter { constructor(options = kEmptyObject) { super(); - this.#options = options = { ...options, path: null }; + this.options = options = { ...options, path: null }; if (options.noDelay === undefined) options.noDelay = true; // Don't confuse net and make it think that we're connecting to a pipe - this.#requests = kEmptyObject; - this.#sockets = kEmptyObject; - this.#freeSockets = kEmptyObject; - - this.#keepAliveMsecs = options.keepAliveMsecs || 1000; - this.#keepAlive = options.keepAlive || false; - this.#maxSockets = options.maxSockets || Agent.defaultMaxSockets; - this.#maxFreeSockets = options.maxFreeSockets || 256; - this.#scheduling = options.scheduling || "lifo"; - this.#maxTotalSockets = options.maxTotalSockets; - this.#totalSocketCount = 0; - this.#defaultPort = options.defaultPort || 80; - this.#protocol = options.protocol || "http:"; - } - - get defaultPort() { - return this.#defaultPort; - } - - get protocol() { - return this.#protocol; - } - - get requests() { - return this.#requests; - } - - get sockets() { - return this.#sockets; - } - - get freeSockets() { - return this.#freeSockets; - } - - get options() { - return this.#options; - } - - get keepAliveMsecs() { - return this.#keepAliveMsecs; - } - - get keepAlive() { - return this.#keepAlive; - } - - get maxSockets() { - return this.#maxSockets; - } - - get maxFreeSockets() { - return this.#maxFreeSockets; - } - - get scheduling() { - return this.#scheduling; - } - - get maxTotalSockets() { - return this.#maxTotalSockets; - } - - get totalSocketCount() { - return this.#totalSocketCount; + this.requests = kEmptyObject; + this.sockets = kEmptyObject; + this.freeSockets = kEmptyObject; + + this.keepAliveMsecs = options.keepAliveMsecs || 1000; + this.keepAlive = options.keepAlive || false; + this.maxSockets = options.maxSockets || Agent.defaultMaxSockets; + this.maxFreeSockets = options.maxFreeSockets || 256; + this.scheduling = options.scheduling || "lifo"; + this.maxTotalSockets = options.maxTotalSockets; + this.totalSocketCount = 0; + this.defaultPort = options.defaultPort || 80; + this.protocol = options.protocol || "http:"; } createConnection() { diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index f90125c70..f5d39d398 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,q,v,w){\"use strict\";const x={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},y=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][w];var g=(async(z,B,C,F)=>{var G=this.onLoad.@get(C);if(!G)return this.onLoadAsync(z,null,null),null;for(let[K,Q]of G)if(K.test(B)){var j=Q({path:B,namespace:C,loader:F});while(j&&@isPromise(j)&&(@getPromiseInternalField(j,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)j=@getPromiseInternalField(j,@promiseFieldReactionsOrResult);if(j&&@isPromise(j))j=await j;if(!j||!@isObject(j))continue;var{contents:H,loader:J=F}=j;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=x[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(z,H,T),null}return this.onLoadAsync(z,null,null),null})(b,q,v,y);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(z)=>{this.addError(b,z,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (w,G,H,x){\"use strict\";const C={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},b=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][x];var J=(async(K,z,Q,F)=>{var g=this.onLoad.@get(Q);if(!g)return this.onLoadAsync(K,null,null),null;for(let[B,v]of g)if(B.test(z)){var q=v({path:z,namespace:Q,loader:F});while(q&&@isPromise(q)&&(@getPromiseInternalField(q,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)q=@getPromiseInternalField(q,@promiseFieldReactionsOrResult);if(q&&@isPromise(q))q=await q;if(!q||!@isObject(q))continue;var{contents:T,loader:y=F}=q;if(typeof T!==\"string\"&&!@isTypedArrayView(T))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof y!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const j=C[y];if(j===@undefined)@throwTypeError(`Loader ${y} is not supported.`);return this.onLoadAsync(K,T,j),null}return this.onLoadAsync(K,null,null),null})(w,G,H,b);while(J&&@isPromise(J)&&(@getPromiseInternalField(J,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)J=@getPromiseInternalField(J,@promiseFieldReactionsOrResult);if(J&&@isPromise(J))J.then(()=>{},(K)=>{this.addError(w,K,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -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 (f,o){\"use strict\";const w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; +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"; // initializeWritableStreamSlots const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -180,7 +180,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAddWriteReques const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAddWriteRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength = 227; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAddWriteRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode = "(function (d){\"use strict\";@assert(@isWritableStreamLocked(d)),@assert(@getByIdDirectPrivate(d,\"state\")===\"writable\");const h=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(d,\"writeRequests\").push(h),h.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode = "(function (c){\"use strict\";@assert(@isWritableStreamLocked(c)),@assert(@getByIdDirectPrivate(c,\"state\")===\"writable\");const d=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(c,\"writeRequests\").push(d),d.@promise})\n"; // writableStreamCloseQueuedOrInFlight const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructAbility = 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 (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const p=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(p,\"errorSteps\").@call();const h=@getByIdDirectPrivate(i,\"storedError\"),A=@getByIdDirectPrivate(i,\"writeRequests\");for(var B=A.shift();B;B=A.shift())B.@reject.@call(@undefined,h);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const I=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(I===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),I.wasAlreadyErroring){I.promise.@reject.@call(@undefined,h),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(p,\"abortSteps\").@call(@undefined,I.reason).@then(()=>{I.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(_)=>{I.promise.@reject.@call(@undefined,_),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; +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 I=A.shift();I;I=A.shift())I.@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(_)},(B)=>{i.promise.@reject.@call(@undefined,B),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -268,7 +268,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAnd const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 516; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const n=@getByIdDirectPrivate(i,\"storedError\"),h=@getByIdDirectPrivate(i,\"closeRequest\");if(h!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),h.@reject.@call(@undefined,n),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(i,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,n),@markPromiseAsHandled(b.@promise)}})\n"; +const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const h=@getByIdDirectPrivate(i,\"storedError\"),n=@getByIdDirectPrivate(i,\"closeRequest\");if(n!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),n.@reject.@call(@undefined,h),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(i,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,h),@markPromiseAsHandled(b.@promise)}})\n"; // writableStreamStartErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -428,7 +428,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength = 89; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode = "(function (e){\"use strict\";return @writableStreamDefaultControllerGetDesiredSize(e)<=0})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode = "(function (d){\"use strict\";return @writableStreamDefaultControllerGetDesiredSize(d)<=0})\n"; // writableStreamDefaultControllerGetChunkSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructAbility = 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 q=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(q),@getByIdDirectPrivate(i,\"writeAlgorithm\").@call(@undefined,d).@then(()=>{@writableStreamFinishInFlightWrite(q);const v=@getByIdDirectPrivate(q,\"state\");if(@assert(v===\"writable\"||v===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),!@writableStreamCloseQueuedOrInFlight(q)&&v===\"writable\"){const M=@writableStreamDefaultControllerGetBackpressure(i);@writableStreamUpdateBackpressure(q,M)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(v)=>{if(@getByIdDirectPrivate(q,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(i);@writableStreamFinishInFlightWriteWithError(q,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; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 449; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,p,v){\"use strict\";const b=new @TransformStreamDefaultController;let q=(d)=>{try{@transformStreamDefaultControllerEnqueue(b,d)}catch(j){return @Promise.@reject(j)}return @Promise.@resolve()},w=()=>{return @Promise.@resolve()};if(\"transform\"in v)q=(d)=>{return @promiseInvokeOrNoopMethod(p,v[\"transform\"],[d,b])};if(\"flush\"in v)w=()=>{return @promiseInvokeOrNoopMethod(p,v[\"flush\"],[b])};@setUpTransformStreamDefaultController(_,b,q,w)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (d,p,v){\"use strict\";const b=new @TransformStreamDefaultController;let q=(j)=>{try{@transformStreamDefaultControllerEnqueue(b,j)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},_=()=>{return @Promise.@resolve()};if(\"transform\"in v)q=(j)=>{return @promiseInvokeOrNoopMethod(p,v[\"transform\"],[j,b])};if(\"flush\"in v)_=()=>{return @promiseInvokeOrNoopMethod(p,v[\"flush\"],[b])};@setUpTransformStreamDefaultController(d,b,q,_)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = 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){\"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"; +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 q=@getByIdDirectPrivate(f,\"state\");if(q===\"erroring\"){x.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(q===\"writable\"),@transformStreamDefaultControllerPerformTransform(j,v).@then(()=>{x.@resolve()},(z)=>{x.@reject.@call(@undefined,z)})},(q)=>{x.@reject.@call(@undefined,q)}),x.@promise}return @transformStreamDefaultControllerPerformTransform(j,v)})\n"; // transformStreamDefaultSinkAbortAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (A,M){\"use strict\";var Q={path:\"node:process\",require:M},N=(Z)=>Q.require(Z);function O(Z){var{Duplex:T,eos:x,destroy:Y}=N(\"node:stream\"),G=class j extends T{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=N(\"node:tty\").isatty(Z)}get fd(){return Z}constructor(V){super({readable:!0,writable:!0});this.#G=`/dev/fd/${V}`}#N(V){const L=this.#H;if(this.#H=null,L)L(V);else if(V)this.destroy(V);else if(!this.#j&&!this.#z)this.destroy()}_destroy(V,L){if(!V&&this.#H!==null){var X=class J extends Error{code;name;constructor(H=\"The operation was aborted\",P=void 0){if(P!==void 0&&typeof P!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(P,null,2)}`);super(H,P);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};V=new X}if(this.#J=null,this.#K=null,this.#H===null)L(V);else{if(this.#H=L,this.#$)Y(this.#$,V);if(this.#B)Y(this.#B,V)}}_write(V,L,X){if(!this.#$){var{createWriteStream:J}=N(\"node:fs\"),H=this.#$=J(this.#G);H.on(\"finish\",()=>{if(this.#K){const P=this.#K;this.#K=null,P()}}),H.on(\"drain\",()=>{if(this.#J){const P=this.#J;this.#J=null,P()}}),x(H,(P)=>{if(this.#z=!1,P)Y(H,P);this.#N(P)})}if(H.write(V,L))X();else this.#J=X}_final(V){this.#$&&this.#$.end(),this.#K=V}#O(){var{createReadStream:V}=N(\"node:fs\"),L=this.#B=V(this.#G);return L.on(\"readable\",()=>{if(this.#L){const X=this.#L;this.#L=null,X()}else this.read()}),L.on(\"end\",()=>{this.push(null)}),x(L,(X)=>{if(this.#j=!1,X)Y(L,X);this.#N(X)}),L}_read(){var V=this.#B;if(!V)V=this.#O();while(!0){const L=V.read();if(L===null||!this.push(L))return}}};return new G(Z)}var{EventEmitter:z}=N(\"node:events\");function B(Z){if(!Z)return!0;var T=Z.toLowerCase();return T===\"utf8\"||T===\"utf-8\"||T===\"buffer\"||T===\"binary\"}var U,K=class Z extends z{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(T){if(this.#B||!B(T))return this.#J(),this.#B.setDefaultEncoding(T)}#G(){switch(this.#$){case 1:{var T=@Bun.stdout.writer({highWaterMark:0});return T.unref(),T}case 2:{var T=@Bun.stderr.writer({highWaterMark:0});return T.unref(),T}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(T){super();this.#$=T}get fd(){return this.#$}get isTTY(){return this.#z\?\?=N(\"node:tty\").isatty(this.#$)}cursorTo(T,x,Y){return(U\?\?=N(\"readline\")).cursorTo(this,T,x,Y)}moveCursor(T,x,Y){return(U\?\?=N(\"readline\")).moveCursor(this,T,x,Y)}clearLine(T,x){return(U\?\?=N(\"readline\")).clearLine(this,T,x)}clearScreenDown(T){return(U\?\?=N(\"readline\")).clearScreenDown(this,T)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(T,x){if(T===\"close\"||T===\"finish\")return this.#J(),this.#B.on(T,x);if(T===\"drain\")return super.on(\"drain\",x);if(T===\"error\")return super.on(\"error\",x);return super.on(T,x)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(T){return this.#J(),this.#B.pipe(T)}unpipe(T){return this.#J(),this.#B.unpipe(T)}#J(){if(this.#B)return;this.#B=O(this.#$);const T=this.eventNames();for(let x of T)this.#B.on(x,(...Y)=>{this.emit(x,...Y)})}#K(T){var x=this.#H();const Y=x.write(T);this.bytesWritten+=Y;const G=x.flush(!1);return!!(Y||G)}#L(T,x){if(!B(x))return this.#J(),this.#B.write(T,x);return this.#K(T)}#M(T,x){if(x)this.emit(\"error\",x);try{T(x\?x:null)}catch(Y){this.emit(\"error\",Y)}}#N(T,x,Y){if(!B(x))return this.#J(),this.#B.write(T,x,Y);var G=this.#H();const j=G.write(T),V=G.flush(!0);if(V\?.then)return V.then(()=>{this.#M(Y),this.emit(\"drain\")},(L)=>this.#M(Y,L)),!1;return queueMicrotask(()=>{this.#M(Y)}),!!(j||V)}write(T,x,Y){const G=this._write(T,x,Y);if(G)this.emit(\"drain\");return G}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(T,x,Y){var G=this.#B;if(G)return G.write(T,x,Y);switch(arguments.length){case 0:{var j=new Error(\"Invalid arguments\");throw j.code=\"ERR_INVALID_ARG_TYPE\",j}case 1:return this.#K(T);case 2:if(typeof x===\"function\")return this.#N(T,\"\",x);else if(typeof x===\"string\")return this.#L(T,x);default:{if(typeof x!==\"undefined\"&&typeof x!==\"string\"||typeof Y!==\"undefined\"&&typeof Y!==\"function\"){var j=new Error(\"Invalid arguments\");throw j.code=\"ERR_INVALID_ARG_TYPE\",j}if(typeof Y===\"undefined\")return this.#L(T,x);return this.#N(T,x,Y)}}}destroy(){return this}end(){return this}};return new K(A)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (j,z){\"use strict\";var L={path:\"node:process\",require:z},K=(N)=>L.require(N);function G(N){var{Duplex:O,eos:Q,destroy:U}=K(\"node:stream\"),V=class X extends O{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=K(\"node:tty\").isatty(N)}get fd(){return N}constructor(Z){super({readable:!0,writable:!0});this.#G=`/dev/fd/${Z}`}#N(Z){const Y=this.#H;if(this.#H=null,Y)Y(Z);else if(Z)this.destroy(Z);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Z,Y){if(!Z&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Z=new P}if(this.#J=null,this.#K=null,this.#H===null)Y(Z);else{if(this.#H=Y,this.#$)U(this.#$,Z);if(this.#B)U(this.#B,Z)}}_write(Z,Y,P){if(!this.#$){var{createWriteStream:A}=K(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),Q(T,(x)=>{if(this.#z=!1,x)U(T,x);this.#N(x)})}if(T.write(Z,Y))P();else this.#J=P}_final(Z){this.#$&&this.#$.end(),this.#K=Z}#O(){var{createReadStream:Z}=K(\"node:fs\"),Y=this.#B=Z(this.#G);return Y.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),Y.on(\"end\",()=>{this.push(null)}),Q(Y,(P)=>{if(this.#j=!1,P)U(Y,P);this.#N(P)}),Y}_read(){var Z=this.#B;if(!Z)Z=this.#O();while(!0){const Y=Z.read();if(Y===null||!this.push(Y))return}}};return new V(N)}var{EventEmitter:H}=K(\"node:events\");function M(N){if(!N)return!0;var O=N.toLowerCase();return O===\"utf8\"||O===\"utf-8\"||O===\"buffer\"||O===\"binary\"}var J,B=class N extends H{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(O){if(this.#B||!M(O))return this.#J(),this.#B.setDefaultEncoding(O)}#G(){switch(this.#$){case 1:{var O=@Bun.stdout.writer({highWaterMark:0});return O.unref(),O}case 2:{var O=@Bun.stderr.writer({highWaterMark:0});return O.unref(),O}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(O){super();this.#$=O}get fd(){return this.#$}get isTTY(){return this.#z\?\?=K(\"node:tty\").isatty(this.#$)}cursorTo(O,Q,U){return(J\?\?=K(\"readline\")).cursorTo(this,O,Q,U)}moveCursor(O,Q,U){return(J\?\?=K(\"readline\")).moveCursor(this,O,Q,U)}clearLine(O,Q){return(J\?\?=K(\"readline\")).clearLine(this,O,Q)}clearScreenDown(O){return(J\?\?=K(\"readline\")).clearScreenDown(this,O)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(O,Q){if(O===\"close\"||O===\"finish\")return this.#J(),this.#B.on(O,Q);if(O===\"drain\")return super.on(\"drain\",Q);if(O===\"error\")return super.on(\"error\",Q);return super.on(O,Q)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(O){return this.#J(),this.#B.pipe(O)}unpipe(O){return this.#J(),this.#B.unpipe(O)}#J(){if(this.#B)return;this.#B=G(this.#$);const O=this.eventNames();for(let Q of O)this.#B.on(Q,(...U)=>{this.emit(Q,...U)})}#K(O){var Q=this.#H();const U=Q.write(O);this.bytesWritten+=U;const V=Q.flush(!1);return!!(U||V)}#L(O,Q){if(!M(Q))return this.#J(),this.#B.write(O,Q);return this.#K(O)}#M(O,Q){if(Q)this.emit(\"error\",Q);try{O(Q\?Q:null)}catch(U){this.emit(\"error\",U)}}#N(O,Q,U){if(!M(Q))return this.#J(),this.#B.write(O,Q,U);var V=this.#H();const X=V.write(O),Z=V.flush(!0);if(Z\?.then)return Z.then(()=>{this.#M(U),this.emit(\"drain\")},(Y)=>this.#M(U,Y)),!1;return queueMicrotask(()=>{this.#M(U)}),!!(X||Z)}write(O,Q,U){const V=this._write(O,Q,U);if(V)this.emit(\"drain\");return V}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(O,Q,U){var V=this.#B;if(V)return V.write(O,Q,U);switch(arguments.length){case 0:{var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}case 1:return this.#K(O);case 2:if(typeof Q===\"function\")return this.#N(O,\"\",Q);else if(typeof Q===\"string\")return this.#L(O,Q);default:{if(typeof Q!==\"undefined\"&&typeof Q!==\"string\"||typeof U!==\"undefined\"&&typeof U!==\"function\"){var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}if(typeof U===\"undefined\")return this.#L(O,Q);return this.#N(O,Q,U)}}}destroy(){return this}end(){return this}};return new B(j)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = 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,j,z){\"use strict\";var G={path:\"node:process\",require:j},H=(M)=>G.require(M),{Duplex:I,eos:J,destroy:K}=H(\"node:stream\"),L=class M extends I{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return H(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(N){const P=this.#J;if(this.#J=null,P)P(N);else if(N)this.destroy(N);else if(!this.#z&&!this.#H)this.destroy()}_destroy(N,P){if(!N&&this.#J!==null){var Q=class T extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new Q}if(this.#J===null)P(N);else if(this.#J=P,this.#j)K(this.#j,N)}setRawMode(N){}on(N,P){if(N===\"readable\")this.ref(),this.#G=!0;return super.on(N,P)}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 N,P;const Q=this.#Y.readMany();if(!Q\?.then)({done:N,value:P}=Q);else({done:N,value:P}=await Q);if(!N){this.push(P[0]);const T=P.length;for(let U=1;U{if(this.#I){const Q=this.#I;this.#I=null,Q()}}),P.on(\"drain\",()=>{if(this.#K){const Q=this.#K;this.#K=null,Q()}}),J(P,(Q)=>{if(this.#H=!1,Q)K(P,Q);this.#L(Q)}),P}_write(N,P,Q){var T=this.#j;if(!T)T=this.#N();if(T.write(N,P))Q();else this.#K=Q}_final(N){this.#j.end(),this.#I=(...P)=>N(...P)}};return new L})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (z,G,H){\"use strict\";var K={path:\"node:process\",require:G},L=(T)=>K.require(T),{Duplex:M,eos:N,destroy:P}=L(\"node:stream\"),Q=class T extends M{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return L(\"tty\").isatty(z)}get fd(){return z}constructor(){super({readable:!0,writable:!0})}#L(Y){const j=this.#J;if(this.#J=null,j)j(Y);else if(Y)this.destroy(Y);else if(!this.#z&&!this.#H)this.destroy()}_destroy(Y,j){if(!Y&&this.#J!==null){var I=class J extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Y=new I}if(this.#J===null)j(Y);else if(this.#J=j,this.#j)P(this.#j,Y)}setRawMode(Y){}on(Y,j){if(Y===\"readable\")this.ref(),this.#G=!0;return super.on(Y,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#Y\?\?=H.stdin.stream().getReader(),this.#$\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#$)clearInterval(this.#$),this.#$=null}async#M(){try{var Y,j;const I=this.#Y.readMany();if(!I\?.then)({done:Y,value:j}=I);else({done:Y,value:j}=await I);if(!Y){this.push(j[0]);const J=j.length;for(let U=1;U{if(this.#I){const I=this.#I;this.#I=null,I()}}),j.on(\"drain\",()=>{if(this.#K){const I=this.#K;this.#K=null,I()}}),N(j,(I)=>{if(this.#H=!1,I)P(j,I);this.#L(I)}),j}_write(Y,j,I){var J=this.#j;if(!J)J=this.#N();if(J.write(Y,j))I();else this.#K=I}_final(Y){this.#j.end(),this.#I=(...j)=>Y(...j)}};return new Q})\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 j=arguments[0];if(@isObject(j)&&@getByIdDirectPrivate(j,\"TransformStream\"))return this;let q=arguments[1],v=arguments[2];if(j===@undefined)j=null;if(v===@undefined)v={};if(q===@undefined)q={};let x={};if(j!==null){if(\"start\"in j){if(x[\"start\"]=j[\"start\"],typeof x[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in j){if(x[\"transform\"]=j[\"transform\"],typeof x[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in j){if(x[\"flush\"]=j[\"flush\"],typeof x[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in j)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in j)@throwRangeError(\"TransformStream transformer has a writableType\")}const B=@extractHighWaterMark(v,0),E=@extractSizeAlgorithm(v),F=@extractHighWaterMark(q,1),G=@extractSizeAlgorithm(q),I=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,I.@promise,F,G,B,E),@setUpTransformStreamDefaultControllerFromTransformer(this,j,x),(\"start\"in x)){const J=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(j,x[\"start\"],[J]))().@then(()=>{I.@resolve.@call()},(u)=>{I.@reject.@call(@undefined,u)})}else I.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let B=arguments[1],u=arguments[2];if(_===@undefined)_=null;if(u===@undefined)u={};if(B===@undefined)B={};let E={};if(_!==null){if(\"start\"in _){if(E[\"start\"]=_[\"start\"],typeof E[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(E[\"transform\"]=_[\"transform\"],typeof E[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(E[\"flush\"]=_[\"flush\"],typeof E[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const j=@extractHighWaterMark(u,0),F=@extractSizeAlgorithm(u),q=@extractHighWaterMark(B,1),G=@extractSizeAlgorithm(B),v=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,v.@promise,q,G,j,F),@setUpTransformStreamDefaultControllerFromTransformer(this,_,E),(\"start\"in E)){const I=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,E[\"start\"],[I]))().@then(()=>{v.@resolve.@call()},(J)=>{v.@reject.@call(@undefined,J)})}else v.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (M){\"use strict\";const L=@requireMap.@get(M)||@requireMap.@get(M=@resolveSync(M,this.path,!1));if(L)return @evaluateCommonJSModule(L),L.exports;if(M.endsWith(\".json\")||M.endsWith(\".toml\")||M.endsWith(\".node\"))return @internalRequire(M);let b=@Loader.registry.@get(M);if(b\?.evaluated&&(b.state\?\?0)>=@ModuleReady){const h=b.module,f=@Loader.getModuleNamespaceObject(h),r=f\?.[@commonJSSymbol]===0||f\?.default\?.[@commonJSSymbol]===0\?f.default:f.__esModule\?f:Object.create(f,{__esModule:{value:!0}});return @requireMap.@set(M,@createCommonJSModule(M,r,!0)),r}const _=@createCommonJSModule(M,{},!1);@requireMap.@set(M,_);var S=this.@require(M,_);if(S===-1){try{S=@requireESM(M)}catch(h){throw @requireMap.@delete(M),h}if(b=@Loader.registry.@get(M),b\?.evaluated&&(b.state\?\?0)>=@ModuleReady){const h=@Loader.getModuleNamespaceObject(b.module);return _.exports=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(_),_.exports})\n"; +const char* const s_moduleRequireCode = "(function (M){\"use strict\";const S=@requireMap.@get(M)||@requireMap.@get(M=@resolveSync(M,this.path,!1));if(S)return @evaluateCommonJSModule(S),S.exports;if(M.endsWith(\".json\")||M.endsWith(\".toml\")||M.endsWith(\".node\"))return @internalRequire(M);let f=@Loader.registry.@get(M);if(f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const _=f.module,b=@Loader.getModuleNamespaceObject(_),r=b\?.[@commonJSSymbol]===0||b\?.default\?.[@commonJSSymbol]===0\?b.default:b.__esModule\?b:Object.create(b,{__esModule:{value:!0}});return @requireMap.@set(M,@createCommonJSModule(M,r,!0)),r}const L=@createCommonJSModule(M,{},!1);@requireMap.@set(M,L);var h=this.@require(M,L);if(h===-1){try{h=@requireESM(M)}catch(_){throw @requireMap.@delete(M),_}if(f=@Loader.registry.@get(M),f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const _=@Loader.getModuleNamespaceObject(f.module);return L.exports=_\?.[@commonJSSymbol]===0||_\?.default\?.[@commonJSSymbol]===0\?_.default:_.__esModule\?_:Object.create(_,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -846,7 +846,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntLECodeLength = 445; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,r){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return d.getUint8(a);case 2:return d.getUint16(a,!0);case 3:return d.getUint16(a,!0)+d.getUint8(a+2)*65536;case 4:return d.getUint32(a,!0);case 5:return d.getUint8(a+4)*4294967296+d.getUint32(a,!0);case 6:return d.getUint16(a+4,!0)*4294967296+d.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,d){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return r.getUint8(a);case 2:return r.getUint16(a,!0);case 3:return r.getUint16(a,!0)+r.getUint8(a+2)*65536;case 4:return r.getUint32(a,!0);case 5:return r.getUint8(a+4)*4294967296+r.getUint32(a,!0);case 6:return r.getUint16(a+4,!0)*4294967296+r.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1014,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,c,E){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(E){case 1:{d.setInt8(c,r);break}case 2:{d.setInt16(c,r,!1);break}case 3:{d.setUint16(c+1,r&65535,!1),d.setInt8(c,Math.floor(r*0.0000152587890625));break}case 4:{d.setInt32(c,r,!1);break}case 5:{d.setUint32(c+1,r|0,!1),d.setInt8(c,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(c+2,r|0,!1),d.setInt16(c,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return c+E})\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; @@ -1038,7 +1038,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!0),c+4})\n"; // writeFloatBE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1046,7 +1046,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!1),c+4})\n"; // writeDoubleLE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1150,7 +1150,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlWriteCodeLength = 70; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"base64url\")})\n"; +const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64url\")})\n"; // hexWrite const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (c,p){\"use strict\";var{buffer:i,byteOffset:k,byteLength:m}=this;function q(x,z){if(x=@trunc(x),x===0||@isNaN(x))return 0;else if(x<0)return x+=z,x>0\?x:0;else return xv\?w-v:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (p,m){\"use strict\";var{buffer:c,byteOffset:k,byteLength:v}=this;function q(z,i){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=i,z>0\?z:0;else return zw\?x-w:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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 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"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const j=async function*w(){var _=@Bun.stdin.stream().getReader(),B=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),m,D=@Bun.indexOfLine;try{while(!0){var F,q,G;const L=_.readMany();if(@isPromise(L))({done:F,value:q}=await L);else({done:F,value:q}=L);if(F){if(G)yield B.decode(G);return}var H;for(let M of q){if(H=M,G)H=@Buffer.concat([G,M]),G=null;var J=0,K=D(H,J);while(K!==-1)yield B.decode(H.subarray(J,K)),J=K+1,K=D(H,J);G=H.subarray(J)}}}catch(L){m=L}finally{if(_.releaseLock(),m)throw m}},z=globalThis.Symbol.asyncIterator;return this[z]=j,j()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (a){\"use strict\";var d=@getByIdDirectPrivate(this,\"writer\");if(!d){var _=@toLength(a\?.length\?\?0);d=@Bun.stdout.writer({highWaterMark:_>65536\?_:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var b=d.write(a);const c=@argumentCount();for(var f=1;f65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a@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 (_,f,b,v,j,w,B){\"use strict\";const C=new @ReadableStreamDefaultController(_,f,b,v,@isReadableStream),q=()=>@promiseInvokeOrNoopMethod(f,w,[C]),D=(x)=>@promiseInvokeOrNoopMethod(f,B,[x]);@putByIdDirectPrivate(C,\"pullAlgorithm\",q),@putByIdDirectPrivate(C,\"cancelAlgorithm\",D),@putByIdDirectPrivate(C,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(C,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(_,\"readableStreamController\",C),@readableStreamDefaultControllerStart(C)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (v,w,A){\"use strict\";const C=w.type,b=@toString(C);if(b===\"bytes\"){if(A.highWaterMark===@undefined)A.highWaterMark=0;if(A.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(v,\"readableStreamController\",new @ReadableByteStreamController(v,w,A.highWaterMark,@isReadableStream))}else if(b===\"direct\"){var f=A\?.highWaterMark;@initializeArrayBufferStream.@call(v,w,f)}else if(C===@undefined){if(A.highWaterMark===@undefined)A.highWaterMark=1;@setupReadableStreamDefaultController(v,w,A.size,A.highWaterMark,w.start,w.pull,w.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (w,C,A){\"use strict\";const b=C.type,f=@toString(b);if(f===\"bytes\"){if(A.highWaterMark===@undefined)A.highWaterMark=0;if(A.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(w,\"readableStreamController\",new @ReadableByteStreamController(w,C,A.highWaterMark,@isReadableStream))}else if(f===\"direct\"){var v=A\?.highWaterMark;@initializeArrayBufferStream.@call(w,C,v)}else if(b===@undefined){if(A.highWaterMark===@undefined)A.highWaterMark=1;@setupReadableStreamDefaultController(w,C,A.size,A.highWaterMark,C.start,C.pull,C.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1420,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 (B){\"use strict\";if(@getByIdDirectPrivate(B,\"started\")!==-1)return;const a=@getByIdDirectPrivate(B,\"underlyingSource\"),p=a.start;@putByIdDirectPrivate(B,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(a,p,[B]).@then(()=>{@putByIdDirectPrivate(B,\"started\",1),@assert(!@getByIdDirectPrivate(B,\"pulling\")),@assert(!@getByIdDirectPrivate(B,\"pullAgain\")),@readableStreamDefaultControllerCallPullIfNeeded(B)},(m)=>{@readableStreamDefaultControllerError(B,m)})})\n"; // readableStreamPipeToWritableStream const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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 (D,x,_,z,f,B){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(x)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(x)),@assert(B===@undefined||@isAbortSignal(B)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let E={source:D,destination:x,preventAbort:z,preventCancel:f,preventClose:_,signal:B};if(E.reader=@acquireReadableStreamDefaultReader(D),E.writer=@acquireWritableStreamDefaultWriter(x),@putByIdDirectPrivate(D,\"disturbed\",!0),E.finalized=!1,E.shuttingDown=!1,E.promiseCapability=@newPromiseCapability(@Promise),E.pendingReadPromiseCapability=@newPromiseCapability(@Promise),E.pendingReadPromiseCapability.@resolve.@call(),E.pendingWritePromise=@Promise.@resolve(),B!==@undefined){const F=(G)=>{if(E.finalized)return;@pipeToShutdownWithAction(E,()=>{const H=!E.preventAbort&&@getByIdDirectPrivate(E.destination,\"state\")===\"writable\"\?@writableStreamAbort(E.destination,G):@Promise.@resolve(),k=!E.preventCancel&&@getByIdDirectPrivate(E.source,\"state\")===@streamReadable\?@readableStreamCancel(E.source,G):@Promise.@resolve();let J=@newPromiseCapability(@Promise),K=!0,L=()=>{if(K){K=!1;return}J.@resolve.@call()},q=(w)=>{J.@reject.@call(@undefined,w)};return H.@then(L,q),k.@then(L,q),J.@promise},G)};if(@whenSignalAborted(B,F))return E.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(E),@pipeToErrorsMustBePropagatedBackward(E),@pipeToClosingMustBePropagatedForward(E),@pipeToClosingMustBePropagatedBackward(E),@pipeToLoop(E),E.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (D,w,_,x,f,z){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(w)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(w)),@assert(z===@undefined||@isAbortSignal(z)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let E={source:D,destination:w,preventAbort:x,preventCancel:f,preventClose:_,signal:z};if(E.reader=@acquireReadableStreamDefaultReader(D),E.writer=@acquireWritableStreamDefaultWriter(w),@putByIdDirectPrivate(D,\"disturbed\",!0),E.finalized=!1,E.shuttingDown=!1,E.promiseCapability=@newPromiseCapability(@Promise),E.pendingReadPromiseCapability=@newPromiseCapability(@Promise),E.pendingReadPromiseCapability.@resolve.@call(),E.pendingWritePromise=@Promise.@resolve(),z!==@undefined){const B=(F)=>{if(E.finalized)return;@pipeToShutdownWithAction(E,()=>{const G=!E.preventAbort&&@getByIdDirectPrivate(E.destination,\"state\")===\"writable\"\?@writableStreamAbort(E.destination,F):@Promise.@resolve(),I=!E.preventCancel&&@getByIdDirectPrivate(E.source,\"state\")===@streamReadable\?@readableStreamCancel(E.source,F):@Promise.@resolve();let J=@newPromiseCapability(@Promise),K=!0,L=()=>{if(K){K=!1;return}J.@resolve.@call()},k=(q)=>{J.@reject.@call(@undefined,q)};return G.@then(L,k),I.@then(L,k),J.@promise},F)};if(@whenSignalAborted(z,B))return E.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(E),@pipeToErrorsMustBePropagatedBackward(E),@pipeToClosingMustBePropagatedForward(E),@pipeToClosingMustBePropagatedBackward(E),@pipeToLoop(E),E.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1436,7 +1436,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToLoopCodeConstructorKin const JSC::ImplementationVisibility s_readableStreamInternalsPipeToLoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToLoopCodeLength = 110; static const JSC::Intrinsic s_readableStreamInternalsPipeToLoopCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToLoopCode = "(function (c){\"use strict\";if(c.shuttingDown)return;@pipeToDoReadWrite(c).@then((d)=>{if(d)@pipeToLoop(c)})})\n"; +const char* const s_readableStreamInternalsPipeToLoopCode = "(function (d){\"use strict\";if(d.shuttingDown)return;@pipeToDoReadWrite(d).@then((c)=>{if(c)@pipeToLoop(d)})})\n"; // pipeToDoReadWrite const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1444,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 (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"; +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"; // pipeToErrorsMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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){\"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"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (_,m){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const g=arguments.length>2,h=arguments[2],b=()=>{m().@then(()=>{if(g)@pipeToFinalize(_,h);else @pipeToFinalize(_)},(d)=>{@pipeToFinalize(_,d)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(b,b)},(j)=>@pipeToFinalize(_,j));return}b()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1492,7 +1492,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownCodeLength = 411; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const d=arguments.length>1,m=arguments[1],u=()=>{if(d)@pipeToFinalize(_,m);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(I)=>@pipeToFinalize(_,I));return}u()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,u=arguments[1],d=()=>{if(m)@pipeToFinalize(_,u);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(d,d)},(I)=>@pipeToFinalize(_,I));return}d()})\n"; // pipeToFinalize const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (f,k){\"use strict\";@assert(@isReadableStream(f)),@assert(typeof k===\"boolean\");var i=@getByIdDirectPrivate(f,\"start\");if(i)@putByIdDirectPrivate(f,\"start\",@undefined),i();const q=new @ReadableStreamDefaultReader(f),_={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};_.cancelPromiseCapability=@newPromiseCapability(@Promise);const v=@readableStreamTeePullFunction(_,q,k),g={};@putByIdDirectPrivate(g,\"pull\",v),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch1CancelFunction(_,f));const w={};@putByIdDirectPrivate(w,\"pull\",v),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(_,f));const x=new @ReadableStream(g),j=new @ReadableStream(w);return @getByIdDirectPrivate(q,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(_.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,y),@readableStreamDefaultControllerError(j.@readableStreamController,y),_.closedOrErrored=!0,!_.canceled1||!_.canceled2)_.cancelPromiseCapability.@resolve.@call()}),_.branch1=x,_.branch2=j,[x,j]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,f){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof f===\"boolean\");var g=@getByIdDirectPrivate(_,\"start\");if(g)@putByIdDirectPrivate(_,\"start\",@undefined),g();const j=new @ReadableStreamDefaultReader(_),k={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};k.cancelPromiseCapability=@newPromiseCapability(@Promise);const q=@readableStreamTeePullFunction(k,j,f),v={};@putByIdDirectPrivate(v,\"pull\",q),@putByIdDirectPrivate(v,\"cancel\",@readableStreamTeeBranch1CancelFunction(k,_));const w={};@putByIdDirectPrivate(w,\"pull\",q),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(k,_));const x=new @ReadableStream(v),y=new @ReadableStream(w);return @getByIdDirectPrivate(j,\"closedPromiseCapability\").@promise.@then(@undefined,function(i){if(k.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,i),@readableStreamDefaultControllerError(y.@readableStreamController,i),k.closedOrErrored=!0,!k.canceled1||!k.canceled2)k.cancelPromiseCapability.@resolve.@call()}),k.branch1=x,k.branch2=y,[x,y]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,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,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"; +const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = "(function (i,m,_){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(m),function(f){if(@assert(@isObject(f)),@assert(typeof f.done===\"boolean\"),f.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,f.value);if(!i.canceled2)@readableStreamDefaultControllerEnqueue(i.branch2.@readableStreamController,_\?@structuredCloneForStream(f.value):f.value)})}})\n"; // readableStreamTeeBranch1CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1524,7 +1524,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1Canc const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength = 258; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,d){\"use strict\";return function(i){if(c.canceled1=!0,c.reason1=i,c.canceled2)@readableStreamCancel(d,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,i){\"use strict\";return function(d){if(c.canceled1=!0,c.reason1=d,c.canceled2)@readableStreamCancel(i,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; // readableStreamTeeBranch2CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,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,v,w){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function x(f,A){if(A&&w\?.cancel){try{var B=w.cancel(A);@markPromiseAsHandled(B)}catch(q){}w=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),A)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",A);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!w.pull){x();return}if(!@isCallable(w.pull)){x(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",v);const _=@getByIdDirectPrivate(j,\"highWaterMark\");v.start({highWaterMark:!_||_<64\?64:_}),@startDirectStream.@call(v,j,w.pull,x),@putByIdDirectPrivate(j,\"reader\",{});var z=w.pull(v);if(v=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; +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"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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 (_,E,c){\"use strict\";var f=!1,z=!1;try{var D=_.getReader(),F=D.readMany();if(F&&@isPromise(F))F=await F;if(F.done)return f=!0,E.end();var G=F.value.length;const q=@getByIdDirectPrivate(_,\"highWaterMark\");if(c)@startDirectStream.@call(E,_,@undefined,()=>!z&&@markPromiseAsHandled(_.cancel()));E.start({highWaterMark:q||0});for(var H=0,I=F.value,J=F.value.length;H!A&&@markPromiseAsHandled(f.cancel()));I.start({highWaterMark:J||0});for(var F=0,G=D.value,_=D.value.length;F<_;F++)I.write(G[F]);var c=@getByIdDirectPrivate(f,\"state\");if(c===@streamClosed)return z=!0,I.end();while(!0){var{value:P,done:x}=await B.read();if(x)return z=!0,I.end();I.write(P)}}catch(J){A=!0;try{B=@undefined;const K=f.cancel(J);@markPromiseAsHandled(K)}catch(K){}if(I&&!z){z=!0;try{I.close(J)}catch(K){throw new globalThis.AggregateError([J,K])}}throw J}finally{if(B){try{B.releaseLock()}catch(K){}B=@undefined}I=@undefined;var c=@getByIdDirectPrivate(f,\"state\");if(f){var H=@getByIdDirectPrivate(f,\"readableStreamController\");if(H){if(@getByIdDirectPrivate(H,\"underlyingSource\"))@putByIdDirectPrivate(H,\"underlyingSource\",@undefined);if(@getByIdDirectPrivate(H,\"controlledReadableStream\"))@putByIdDirectPrivate(H,\"controlledReadableStream\",@undefined);if(@putByIdDirectPrivate(f,\"readableStreamController\",null),@getByIdDirectPrivate(f,\"underlyingSource\"))@putByIdDirectPrivate(f,\"underlyingSource\",@undefined);H=@undefined}if(!A&&c!==@streamClosed&&c!==@streamErrored)@readableStreamClose(f);f=@undefined}}})\n"; // handleDirectStreamError const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1604,7 +1604,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnPullDirectStreamCodeConstr const JSC::ImplementationVisibility s_readableStreamInternalsOnPullDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnPullDirectStreamCodeLength = 785; static const JSC::Intrinsic s_readableStreamInternalsOnPullDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnPullDirectStreamCode = "(function (g){\"use strict\";var i=g.@controlledReadableStream;if(!i||@getByIdDirectPrivate(i,\"state\")!==@streamReadable)return;if(g._deferClose===-1)return;g._deferClose=-1,g._deferFlush=-1;var y,_;try{var h=g.@underlyingSource.pull(g);if(h&&@isPromise(h)){if(g._handleError===@undefined)g._handleError=@handleDirectStreamErrorReject.bind(g);@Promise.prototype.catch.@call(h,g._handleError)}}catch(b){return @handleDirectStreamErrorReject.@call(g,b)}finally{y=g._deferClose,_=g._deferFlush,g._deferFlush=g._deferClose=0}var j;if(g._pendingRead===@undefined)g._pendingRead=j=@newPromise();else j=@readableStreamAddReadRequest(i);if(y===1){var k=g._deferCloseReason;return g._deferCloseReason=@undefined,@onCloseDirectStream.@call(g,k),j}if(_===1)@onFlushDirectStream.@call(g);return j})\n"; +const char* const s_readableStreamInternalsOnPullDirectStreamCode = "(function (g){\"use strict\";var i=g.@controlledReadableStream;if(!i||@getByIdDirectPrivate(i,\"state\")!==@streamReadable)return;if(g._deferClose===-1)return;g._deferClose=-1,g._deferFlush=-1;var y,_;try{var j=g.@underlyingSource.pull(g);if(j&&@isPromise(j)){if(g._handleError===@undefined)g._handleError=@handleDirectStreamErrorReject.bind(g);@Promise.prototype.catch.@call(j,g._handleError)}}catch(b){return @handleDirectStreamErrorReject.@call(g,b)}finally{y=g._deferClose,_=g._deferFlush,g._deferFlush=g._deferClose=0}var k;if(g._pendingRead===@undefined)g._pendingRead=k=@newPromise();else k=@readableStreamAddReadRequest(i);if(y===1){var h=g._deferCloseReason;return g._deferCloseReason=@undefined,@onCloseDirectStream.@call(g,h),k}if(_===1)@onFlushDirectStream.@call(g);return k})\n"; // noopDoneFunction const JSC::ConstructAbility s_readableStreamInternalsNoopDoneFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1628,7 +1628,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnCloseDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnCloseDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnCloseDirectStreamCodeLength = 1460; static const JSC::Intrinsic s_readableStreamInternalsOnCloseDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (v){\"use strict\";var y=this.@controlledReadableStream;if(!y||@getByIdDirectPrivate(y,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=v;return}if(@putByIdDirectPrivate(y,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,v)}catch(C){}var S;try{S=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(C){if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(B,C)}@readableStreamError(y,C);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var j=@getByIdDirectPrivate(y,\"reader\");if(j&&@isReadableStreamDefaultReader(j)){var c=this._pendingRead;if(c&&@isPromise(c)&&S\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(c,{value:S,done:!1}),@readableStreamClose(y);return}}if(S\?.byteLength){var b=@getByIdDirectPrivate(j,\"readRequests\");if(b\?.isNotEmpty()){@readableStreamFulfillReadRequest(y,S,!1),@readableStreamClose(y);return}@putByIdDirectPrivate(y,\"state\",@streamReadable),this.@pull=()=>{var C=@createFulfilledPromise({value:S,done:!1});return S=@undefined,@readableStreamClose(y),y=@undefined,C}}else if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(B,{value:@undefined,done:!0})}@readableStreamClose(y)})\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; @@ -1644,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,z=[],A=!1,j=!1,E=\"\",q=@toLength(0),F=@newPromiseCapability(@Promise),G=!1;return x={start(){},write(w){if(typeof w===\"string\"){var C=@toLength(w.length);if(C>0)E+=w,A=!0,q+=C;return C}if(!w||!(@ArrayBuffer.@isView(w)||w instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const _=@toLength(w.byteLength);if(_>0)if(j=!0,E.length>0)@arrayPush(z,E,w),E=\"\";else @arrayPush(z,w);return q+=_,_},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(!A&&!j)return\"\";if(A&&!j)return E;if(j&&!A)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(z));var w=new @Bun.ArrayBufferSink;w.start({highWaterMark:q,asUint8Array:!0});for(let C of z)w.write(C);if(z.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 (j){\"use strict\";var x,w=[],z=!1,_=!1,A=\"\",q=@toLength(0),C=@newPromiseCapability(@Promise),E=!1;return x={start(){},write(v){if(typeof v===\"string\"){var F=@toLength(v.length);if(F>0)A+=v,z=!0,q+=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(_=!0,A.length>0)@arrayPush(w,A,v),A=\"\";else @arrayPush(w,v);return q+=G,G},flush(){return 0},end(){if(E)return\"\";return x.fulfill()},fulfill(){E=!0;const v=x.finishInternal();return @fulfillPromise(C.@promise,v),v},finishInternal(){if(!z&&!_)return\"\";if(z&&!_)return A;if(_&&!z)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(w));var v=new @Bun.ArrayBufferSink;v.start({highWaterMark:q,asUint8Array:!0});for(let F of w)v.write(F);if(w.length=0,A.length>0)v.write(A),A=\"\";return new globalThis.TextDecoder().decode(v.end())},close(){try{if(!E)E=!0,x.fulfill()}catch(v){}}},[x,C]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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 (_,j){\"use strict\";var t=[],p=@newPromiseCapability(@Promise),b=!1;function d(){return b=!0,p.@resolve.@call(@undefined,t),t}var m={start(){},write(v){return @arrayPush(t,v),v.byteLength||v.length},flush(){return 0},end(){if(b)return[];return d()},close(){if(!b)d()}},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),p})\n"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (_,b){\"use strict\";var j=[],t=@newPromiseCapability(@Promise),p=!1;function d(){return p=!0,t.@resolve.@call(@undefined,j),j}var m={start(){},write(v){return @arrayPush(j,v),v.byteLength||v.length},flush(){return 0},end(){if(p)return[];return d()},close(){if(!p)d()}},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),t})\n"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1668,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; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (_,i){\"use strict\";@assert(@isReadableStream(_)),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamErrored),@putByIdDirectPrivate(_,\"storedError\",i);const c=@getByIdDirectPrivate(_,\"reader\");if(!c)return;if(@isReadableStreamDefaultReader(c)){const h=@getByIdDirectPrivate(c,\"readRequests\");@putByIdDirectPrivate(c,\"readRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,i)}else{@assert(@isReadableStreamBYOBReader(c));const h=@getByIdDirectPrivate(c,\"readIntoRequests\");@putByIdDirectPrivate(c,\"readIntoRequests\",@createFIFO());for(var n=h.shift();n;n=h.shift())@rejectPromise(n,i)}@getByIdDirectPrivate(c,\"closedPromiseCapability\").@reject.@call(@undefined,i);const f=@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(f)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const v=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(v)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let D=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)D=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,D)}catch(D){throw @readableStreamDefaultControllerError(_,D),D}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var b=f.getReader(),g=b.readMany();async function j(p){if(p.done)return[];var q=p.value||[];while(!0){var _=await b.read();if(_.done)break;q=q.concat(_.value)}return q}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var p=f.getReader(),g=p.readMany();async function b(_){if(_.done)return[];var j=_.value||[];while(!0){var q=await p.read();if(q.done)break;j=j.concat(q.value)}return j}if(g&&@isPromise(g))return g.@then(b);return b(g)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var k=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(_){}return k=@undefined,f=@undefined,j.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,f){\"use strict\";const h=@initializeTextStream.@call(_,f,@undefined);var j=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await j.read();if(k.done)break}try{j.releaseLock()}catch(p){}return j=@undefined,_=@undefined,h.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (g){\"use strict\";var h=globalThis.Symbol.asyncIterator,j=async function*z(x,B){var D=x.getReader(),F;try{while(!0){var G,k;const i=D.readMany();if(@isPromise(i))({done:G,value:k}=await i);else({done:G,value:k}=i);if(G)return;yield*k}}catch(i){F=i}finally{if(D.releaseLock(),!B)x.cancel(F);if(F)throw F}},w=function z(){return j(this,!1)},q=function z({preventCancel:x=!1}={preventCancel:!1}){return j(this,x)};return @Object.@defineProperty(g,h,{value:w}),@Object.@defineProperty(g,\"values\",{value:q}),g})\n"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (k){\"use strict\";var z=globalThis.Symbol.asyncIterator,D=async function*B(G,x){var i=G.getReader(),w;try{while(!0){var q,h;const j=i.readMany();if(@isPromise(j))({done:q,value:h}=await j);else({done:q,value:h}=j);if(q)return;yield*h}}catch(j){w=j}finally{if(i.releaseLock(),!x)G.cancel(w);if(w)throw w}},F=function B(){return D(this,!1)},g=function B({preventCancel:G=!1}={preventCancel:!1}){return D(this,G)};return @Object.@defineProperty(k,z,{value:F}),@Object.@defineProperty(k,\"values\",{value:g}),k})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1894,7 +1894,7 @@ const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeCons const JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 339; static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),u=@getByIdDirectPrivate(_,\"readable\"),i=@getByIdDirectPrivate(u,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(i)})\n"; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),i=@getByIdDirectPrivate(_,\"readable\"),u=@getByIdDirectPrivate(i,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(u)})\n"; // enqueue const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1986,7 +1986,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var f=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(f)){const d=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(d){const u=d.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in f)||@isCallable(f))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(f).buffer)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2020,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 I=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!I)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const E=@getByIdDirectPrivate(I,\"state\");if(@putByIdDirectPrivate(I,\"disturbed\",!0),E===@streamClosed)return{value:[],size:0,done:!0};else if(E===@streamErrored)throw @getByIdDirectPrivate(I,\"storedError\");var H=@getByIdDirectPrivate(I,\"readableStreamController\"),F=@getByIdDirectPrivate(H,\"queue\");if(!F)return H.@pull(H).@then(function({done:Q,value:B}){return Q\?{done:!0,value:[],size:0}:{value:[B],size:1,done:!1}});const G=F.content;var _=F.size,D=G.toArray(!1),J=D.length;if(J>0){var K=@newArrayWithSize(J);if(@isReadableByteStreamController(H)){{const Q=D[0];if(!(@ArrayBuffer.@isView(Q)||Q instanceof @ArrayBuffer))@putByValDirect(K,0,new @Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength));else @putByValDirect(K,0,Q)}for(var d=1;d{if(Q.done)return{value:[],size:0,done:!0};var B=@getByIdDirectPrivate(I,\"readableStreamController\"),k=@getByIdDirectPrivate(B,\"queue\"),S=[Q.value].concat(k.content.toArray(!1)),T=S.length;if(@isReadableByteStreamController(B))for(var w=0;w0){var k=@newArrayWithSize(I);if(@isReadableByteStreamController(H)){{const Q=_[0];if(!(@ArrayBuffer.@isView(Q)||Q instanceof @ArrayBuffer))@putByValDirect(k,0,new @Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength));else @putByValDirect(k,0,Q)}for(var N=1;N{if(Q.done)return{value:[],size:0,done:!0};var w=@getByIdDirectPrivate(T,\"readableStreamController\"),d=@getByIdDirectPrivate(w,\"queue\"),J=[Q.value].concat(d.content.toArray(!1)),x=J.length;if(@isReadableByteStreamController(w))for(var K=0;K0}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"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var b=@Array.prototype.slice;class g{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:w,_tail:x,_list:z,_capacityMask:k}=this;if(w===x)return @undefined;var A=z[w];if(@putByValDirect(z,w,@undefined),w=this._head=w+1&k,w<2&&x>1e4&&x<=z.length>>>2)this._shrinkArray();return A}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(w){var x=this._tail;if(@putByValDirect(this._list,x,w),this._tail=x+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(w){var x=this._list,z=@toLength(x.length);if(w||this._head>this._tail){var k=@toLength(this._head),A=@toLength(this._tail),B=@toLength(z-k+A),E=@newArrayWithSize(B),v=0;for(var F=k;F>>=1,this._capacityMask>>>=1}}return new g})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var b=@requireMap.@get(_);const g=_.substring(_.length-5);if(b)return b.exports;if(g===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),k=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,k,!0)),k}else if(g===\".node\"){const q=@createCommonJSModule(_,{},!0);return process.dlopen(q,_),@requireMap.@set(_,q),q.exports}else if(g===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),k=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,k,!0)),k}else{var k=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var n=k\?.default;if(n\?.[@commonJSSymbol]===0)k=n;return @requireMap.@set(_,@createCommonJSModule(_,k,!0)),k}})\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 n=@createCommonJSModule(b,{},!0);return process.dlopen(n,b),@requireMap.@set(b,n),n.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 v=@requireMap.@get(b);if(v)return v.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; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,t={};return new Proxy(t,{get(L,f){const h=@requireMap.@get(f);if(h)return h;const u=@Loader.registry.@get(f);if(u\?.evaluated){const b=@Loader.getModuleNamespaceObject(u.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(f,c,!0);return @requireMap.@set(f,g),g}return t[f]},set(L,f,h){return @requireMap.@set(f,h),!0},has(L,f){return @requireMap.@has(f)||@Loader.registry.@has(f)},deleteProperty(L,f){return _.@delete(f),@requireMap.@delete(f),@Loader.registry.@delete(f),!0},ownKeys(L){var f=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let u of h)if(!f.includes(u))@arrayPush(f,u);return f},getPrototypeOf(L){return null},getOwnPropertyDescriptor(L,f){if(@requireMap.@has(f)||@Loader.registry.@has(f))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var f=new Map,u={};return new Proxy(u,{get(c,L){const h=@requireMap.@get(L);if(h)return h;const g=@Loader.registry.@get(L);if(g\?.evaluated){const _=@Loader.getModuleNamespaceObject(g.module),b=_[@commonJSSymbol]===0||_.default\?.[@commonJSSymbol]\?_.default:_,t=@createCommonJSModule(L,b,!0);return @requireMap.@set(L,t),t}return u[L]},set(c,L,h){return @requireMap.@set(L,h),!0},has(c,L){return @requireMap.@has(L)||@Loader.registry.@has(L)},deleteProperty(c,L){return f.@delete(L),@requireMap.@delete(L),@Loader.registry.@delete(L),!0},ownKeys(c){var L=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let g of h)if(!L.includes(g))@arrayPush(L,g);return L},getPrototypeOf(c){return null},getOwnPropertyDescriptor(c,L){if(@requireMap.@has(L)||@Loader.registry.@has(L))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2432,7 +2432,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const m=_.type===\"direct\",v=!!_.@lazy,B=m||v;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!B){const I=@getByIdDirectPrivate(f,\"size\"),b=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,I,b!==@undefined\?b:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(m)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(B){const I=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,I);if(b)@createReadableStreamController(this,b,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,B){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(B===@undefined)B={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(B!==@undefined&&!@isObject(B))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const b=f.type===\"direct\",m=!!f.@lazy,v=b||m;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!v){const I=@getByIdDirectPrivate(B,\"size\"),_=@getByIdDirectPrivate(B,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",_),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,I,_!==@undefined\?_:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(b)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,B));else if(v){const I=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const _=@lazyLoadStream(this,I);if(_)@createReadableStreamController(this,_,B)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,B);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2448,7 +2448,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKi const JSC::ImplementationVisibility s_readableStreamReadableStreamToTextCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToTextCodeLength = 171; static const JSC::Intrinsic s_readableStreamReadableStreamToTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToTextCode = "(function (p){\"use strict\";var _=@getByIdDirectPrivate(p,\"underlyingSource\");if(_!==@undefined)return @readableStreamToTextDirect(p,_);return @readableStreamIntoText(p)})\n"; +const char* const s_readableStreamReadableStreamToTextCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToTextDirect(_,p);return @readableStreamIntoText(_)})\n"; // readableStreamToArrayBuffer const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2456,7 +2456,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2480,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 (_,H,F){\"use strict\";const j=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var A=globalThis[j];if(!A)A=globalThis[j]=[];var G=A[H];if(G===@undefined){var[I,J,K,k,L,N]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](H);G=class B{handleError;handleClosed;processResult;constructor(D,w){this.#_=w,this.#F=D,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),D.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var D=this.#_;this.#_=0,k(D),N(D)}_handleError(D){if(this.#$)return;this.#$=!0;var w=this.#_;this.#_=0,J(w,D),N(w)}#_;#$=!1;#F;_handleReadMany({value:D,done:w,size:x}){if(w){this.handleClosed();return}if(this.#$)return;K(this.#_,D,w,x)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(D){if(D&&@isPromise(D)){if(@getPromiseInternalField(D,@promiseFieldFlags)&@promiseStateFulfilled){const x=@getPromiseInternalField(D,@promiseFieldReactionsOrResult);if(x)D=x}}if(D&&@isPromise(D))return D.then(this.processResult,this.handleError),null;if(D.done)return this.handleClosed(),0;else if(D.value)return D.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const q=H+1;if(A.length{@putByIdDirectPrivate(d,\"started\",1),@assert(!@getByIdDirectPrivate(d,\"pulling\")),@assert(!@getByIdDirectPrivate(d,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(d)},(b)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(d,b)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (_,v,b){\"use strict\";if(!@isReadableStream(_))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(_,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",_),@putByIdDirectPrivate(this,\"underlyingByteSource\",v),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let f=@toNumber(b);if(@isNaN(f)||f<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",f);let p=v.autoAllocateChunkSize;if(p!==@undefined){if(p=@toNumber(p),p<=0||p===@Infinity||p===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",p),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const R=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(R,\"underlyingByteSource\"),\"start\",[R]).@then(()=>{@putByIdDirectPrivate(R,\"started\",1),@assert(!@getByIdDirectPrivate(R,\"pulling\")),@assert(!@getByIdDirectPrivate(R,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(R)},(d)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(R,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2684,7 +2684,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength = 316; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode = "(function (a,_){\"use strict\";@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"state\")===@streamReadable),@readableByteStreamControllerClearPendingPullIntos(a),@putByIdDirectPrivate(a,\"queue\",@newQueue()),@readableStreamError(@getByIdDirectPrivate(a,\"controlledReadableStream\"),_)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode = "(function (_,a){\"use strict\";@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"controlledReadableStream\"),\"state\")===@streamReadable),@readableByteStreamControllerClearPendingPullIntos(_),@putByIdDirectPrivate(_,\"queue\",@newQueue()),@readableStreamError(@getByIdDirectPrivate(_,\"controlledReadableStream\"),a)})\n"; // readableByteStreamControllerClose const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2740,7 +2740,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (d){\"use strict\";const h=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(h)),@getByIdDirectPrivate(d,\"queue\").content\?.isNotEmpty()){const P=@getByIdDirectPrivate(d,\"queue\").content.shift();@getByIdDirectPrivate(d,\"queue\").size-=P.byteLength,@readableByteStreamControllerHandleQueueDrain(d);let R;try{R=new @Uint8Array(P.buffer,P.byteOffset,P.byteLength)}catch(_){return @Promise.@reject(_)}return @createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(d,\"autoAllocateChunkSize\")!==@undefined){let P;try{P=@createUninitializedArrayBuffer(@getByIdDirectPrivate(d,\"autoAllocateChunkSize\"))}catch(_){return @Promise.@reject(_)}const R={buffer:P,byteOffset:0,byteLength:@getByIdDirectPrivate(d,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(d,\"pendingPullIntos\").push(R)}const F=@readableStreamAddReadRequest(h);return @readableByteStreamControllerCallPullIfNeeded(d),F})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const P=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(P)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const R=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=R.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let h;try{h=new @Uint8Array(R.buffer,R.byteOffset,R.byteLength)}catch(F){return @Promise.@reject(F)}return @createFulfilledPromise({value:h,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let R;try{R=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(F){return @Promise.@reject(F)}const h={buffer:R,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(h)}const d=@readableStreamAddReadRequest(P);return @readableByteStreamControllerCallPullIfNeeded(_),d})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 619; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const b=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(b,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const P=@getByIdDirectPrivate(b,\"reader\");if(P&&(@getByIdDirectPrivate(P,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(P,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(b)&&@getByIdDirectPrivate(@getByIdDirectPrivate(b,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const P=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(P,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const b=@getByIdDirectPrivate(P,\"reader\");if(b&&(@getByIdDirectPrivate(b,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(b,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(P)&&@getByIdDirectPrivate(@getByIdDirectPrivate(P,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; // readableByteStreamControllerCallPullIfNeeded const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2780,7 +2780,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1076; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,d){\"use strict\";const _=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@getByIdDirectPrivate(_,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(_,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const f=d.constructor===@Uint8Array\?d:new @Uint8Array(d.buffer,d.byteOffset,d.byteLength);@readableStreamFulfillReadRequest(_,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(_)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);break}}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,d){\"use strict\";const f=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(f,\"state\")===@streamReadable),@getByIdDirectPrivate(f,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(f,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(f,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const _=d.constructor===@Uint8Array\?d:new @Uint8Array(d.buffer,d.byteOffset,d.byteLength);@readableStreamFulfillReadRequest(f,_,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(f)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);break}}})\n"; // readableByteStreamControllerEnqueueChunk const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2788,7 +2788,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,p,d){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:p,byteLength:d}),@getByIdDirectPrivate(_,\"queue\").size+=d})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,d,p){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:d,byteLength:p}),@getByIdDirectPrivate(_,\"queue\").size+=p})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2812,7 +2812,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength = 464; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,u){\"use strict\";let _=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),k=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){if(u!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,_)}else @assert(@getByIdDirectPrivate(k,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,u,_)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,u){\"use strict\";let k=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),_=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(_,\"state\")===@streamClosed){if(u!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,k)}else @assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,u,k)})\n"; // readableByteStreamControllerRespondInReadableState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2844,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.bytesFilledk)E=z-j.bytesFilled,G=!0;while(E>0){let H=@getByIdDirectPrivate(q,\"queue\").content.peek();const J=E0),@assert(j.bytesFilled0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,L)){const R=@readableByteStreamControllerConvertDescriptor(L);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const R=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,R),@Promise.@reject(R)}}L.buffer=@transferBufferToCurrentRealm(L.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(L);const N=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(b),N})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (_,A){\"use strict\";const b=@getByIdDirectPrivate(_,\"controlledReadableStream\");let d=1;if(A.BYTES_PER_ELEMENT!==@undefined)d=A.BYTES_PER_ELEMENT;const k=A.constructor,E={buffer:A.buffer,byteOffset:A.byteOffset,byteLength:A.byteLength,bytesFilled:0,elementSize:d,ctor:k,readerType:\"byob\"};var L=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(L\?.isNotEmpty())return E.buffer=@transferBufferToCurrentRealm(E.buffer),L.push(E),@readableStreamAddReadIntoRequest(b);if(@getByIdDirectPrivate(b,\"state\")===@streamClosed){const R=new k(E.buffer,E.byteOffset,0);return @createFulfilledPromise({value:R,done:!0})}if(@getByIdDirectPrivate(_,\"queue\").size>0){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(b);return @readableByteStreamControllerCallPullIfNeeded(_),N})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2952,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{#Q;#B;#F;#G;#J;#U=!1;#V=null;#W=\"\";#M=\"\";#$=\"\";#j=!0;#X=0;#Y=0;#Z=0;#O=null;static#K(V){V.#A()}static#w(V,w){const A=V.data,L=A.#$\?`Last-Event-ID: ${A.#$}\\r\\n`:\"\",U=`GET ${w.pathname}${w.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${L}\\r\\n`,W=V.write(U);if(W!==U.length)A.#M=U.substring(W)}static#L(V,w,A){for(;;){if(A>=w.length)return;let L=-1,U=w.indexOf(\"\\r\\n\",A);const W=U+2;if(U>0)if(V.#X===0){const z=parseInt(w.substring(A,U),16);if(z===0){V.#B=2,V.#V\?.end();return}L=W+z}else L=w.length;else{if(V.#W.length===0){V.#W+=w.substring(A);return}L=w.length}let X=w.substring(W,L);A=L+2;let Y=0,B=X.indexOf(\"\\n\\n\");if(B==-1){V.#W+=w.substring(W);return}if(V.#W.length)V.#W+=X,X=V.#W,V.#W=\"\";let Z=!0;while(Z){const z=X.substring(Y,B);let F,M=\"\",O,G=0,J=-1;for(;;){let K=z.indexOf(\"\\n\",G);if(K===-1){if(G>=z.length)break;K=z.length}const Q=z.substring(G,K);if(Q.startsWith(\"data:\"))if(M.length)M+=`\\n${Q.substring(5).trim()}`;else M=Q.substring(5).trim();else if(Q.startsWith(\"event:\"))F=Q.substring(6).trim();else if(Q.startsWith(\"id:\"))O=Q.substring(3).trim();else if(Q.startsWith(\"retry:\")){if(J=parseInt(Q.substring(6).trim(),10),@isNaN(J))J=-1}G=K+1}if(V.#$=O||\"\",J>=0)V.#Z=J;if(M||O||F)V.dispatchEvent(new MessageEvent(F||\"message\",{data:M||\"\",origin:V.#Q.origin,source:V,lastEventId:O}));if(X.length===B+2){Z=!1;break}const H=X.indexOf(\"\\n\\n\",B+1);if(H===-1)break;Y=B,B=H}}}static#z={open(V){const w=V.data;if(w.#V=V,!w.#U)j.#w(V,w.#Q)},handshake(V,w,A){const L=V.data;if(w)j.#w(V,L.#Q);else L.#B=2,L.dispatchEvent(new ErrorEvent(\"error\",{error:A})),V.end()},data(V,w){const A=V.data;switch(A.#B){case 0:{let L=w.toString();const U=L.indexOf(\"\\r\\n\\r\\n\");if(U===-1){A.#W+=L;return}if(A.#W.length)A.#W+=L,L=A.#W,A.#W=\"\";const W=L.substring(0,U),X=W.indexOf(\"\\r\\n\");if(X===-1){A.#B=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),V.end();return}const Y=W.substring(0,X);if(Y!==\"HTTP/1.1 200 OK\"){A.#B=2,A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Y)})),V.end();return}let B=X+1,Z=!1,z=-1;for(;;){let M=W.indexOf(\"\\r\\n\",B);if(M===-1){if(B>=W.length){if(!Z)A.#B=2,A.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}M=W.length}const O=W.substring(B+1,M),G=O.indexOf(\":\"),J=O.substring(0,G),H=J.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(B=M+1,H)if(O.endsWith(\" text/event-stream\"))Z=!0;else{A.#B=2,A.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(J.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(z=parseInt(O.substring(G+1).trim(),10),@isNaN(z)||z<=0){A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),V.end();return}if(Z)break}else if(J.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(O.substring(G+1).trim()!==\"chunked\"){A.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),V.end();return}if(z=0,Z)break}}A.#X=z,A.#B=1,A.dispatchEvent(new Event(\"open\"));const F=L.substring(U+4);if(j.#L(A,F,0),A.#X>0){if(A.#Y+=F.length,A.#Y>=A.#X)A.#B=2,V.end()}return}case 1:if(j.#L(A,w.toString(),2),A.#X>0){if(A.#Y+=w.byteLength,A.#Y>=A.#X)A.#B=2,V.end()}return;default:break}},drain(V){const w=V.data;if(w.#B===0){const A=w.#W;if(A.length){const L=V.write(A);if(L!==A.length)V.data.#M=A.substring(L);else V.data.#M=\"\"}}},close:j.#H,end(V){j.#H(V).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(V){j.#H(V).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#H(V){const w=V.data;if(w.#V=null,w.#Y=0,w.#B=2,w.#j){if(w.#O)clearTimeout(w.#O);w.#O=setTimeout(j.#K,w.#Z,w)}return w}constructor(V,w=@undefined){super();const A=new URL(V);this.#U=A.protocol===\"https:\",this.#Q=A,this.#B=2,process.nextTick(j.#K,this)}ref(){this.#O\?.ref(),this.#V\?.ref()}unref(){this.#O\?.unref(),this.#V\?.unref()}#A(){if(this.#B!==2)return;const V=this.#Q,w=this.#U;this.#B=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((A)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:A})),this.#j){if(this.#O)this.#O.unref\?.();this.#O=setTimeout(j.#K,1000,this)}})}get url(){return this.#Q.href}get readyState(){return this.#B}close(){this.#j=!1,this.#B=2,this.#V\?.unref(),this.#V\?.end()}get onopen(){return this.#J}get onerror(){return this.#F}get onmessage(){return this.#G}set onopen(V){if(this.#J)super.removeEventListener(\"close\",this.#J);super.addEventListener(\"open\",V),this.#J=V}set onerror(V){if(this.#F)super.removeEventListener(\"error\",this.#F);super.addEventListener(\"error\",V),this.#F=V}set onmessage(V){if(this.#G)super.removeEventListener(\"message\",this.#G);super.addEventListener(\"message\",V),this.#G=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 B 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,Q){const F=W.data,G=F.#L\?`Last-Event-ID: ${F.#L}\\r\\n`:\"\",j=`GET ${Q.pathname}${Q.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${G}\\r\\n`,X=W.write(j);if(X!==j.length)F.#K=j.substring(X)}static#Y(W,Q,F){for(;;){if(F>=Q.length)return;let G=-1,j=Q.indexOf(\"\\r\\n\",F);const X=j+2;if(j>0)if(W.#O===0){const z=parseInt(Q.substring(F,j),16);if(z===0){W.#j=2,W.#G\?.end();return}G=X+z}else G=Q.length;else{if(W.#J.length===0){W.#J+=Q.substring(F);return}G=Q.length}let Y=Q.substring(X,G);F=G+2;let J=0,Z=Y.indexOf(\"\\n\\n\");if(Z==-1){W.#J+=Q.substring(X);return}if(W.#J.length)W.#J+=Y,Y=W.#J,W.#J=\"\";let K=!0;while(K){const z=Y.substring(J,Z);let L,w=\"\",A,H=0,M=-1;for(;;){let U=z.indexOf(\"\\n\",H);if(U===-1){if(H>=z.length)break;U=z.length}const V=z.substring(H,U);if(V.startsWith(\"data:\"))if(w.length)w+=`\\n${V.substring(5).trim()}`;else w=V.substring(5).trim();else if(V.startsWith(\"event:\"))L=V.substring(6).trim();else if(V.startsWith(\"id:\"))A=V.substring(3).trim();else if(V.startsWith(\"retry:\")){if(M=parseInt(V.substring(6).trim(),10),@isNaN(M))M=-1}H=U+1}if(W.#L=A||\"\",M>=0)W.#U=M;if(w||A||L)W.dispatchEvent(new MessageEvent(L||\"message\",{data:w||\"\",origin:W.#$.origin,source:W,lastEventId:A}));if(Y.length===Z+2){K=!1;break}const O=Y.indexOf(\"\\n\\n\",Z+1);if(O===-1)break;J=Z,Z=O}}}static#Z={open(W){const Q=W.data;if(Q.#G=W,!Q.#F)B.#X(W,Q.#$)},handshake(W,Q,F){const G=W.data;if(Q)B.#X(W,G.#$);else G.#j=2,G.dispatchEvent(new ErrorEvent(\"error\",{error:F})),W.end()},data(W,Q){const F=W.data;switch(F.#j){case 0:{let G=Q.toString();const j=G.indexOf(\"\\r\\n\\r\\n\");if(j===-1){F.#J+=G;return}if(F.#J.length)F.#J+=G,G=F.#J,F.#J=\"\";const X=G.substring(0,j),Y=X.indexOf(\"\\r\\n\");if(Y===-1){F.#j=2,F.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),W.end();return}const J=X.substring(0,Y);if(J!==\"HTTP/1.1 200 OK\"){F.#j=2,F.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(J)})),W.end();return}let Z=Y+1,K=!1,z=-1;for(;;){let w=X.indexOf(\"\\r\\n\",Z);if(w===-1){if(Z>=X.length){if(!K)F.#j=2,F.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}w=X.length}const A=X.substring(Z+1,w),H=A.indexOf(\":\"),M=A.substring(0,H),O=M.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(Z=w+1,O)if(A.endsWith(\" text/event-stream\"))K=!0;else{F.#j=2,F.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(M.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(z=parseInt(A.substring(H+1).trim(),10),@isNaN(z)||z<=0){F.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),W.end();return}if(K)break}else if(M.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(A.substring(H+1).trim()!==\"chunked\"){F.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),W.end();return}if(z=0,K)break}}F.#O=z,F.#j=1,F.dispatchEvent(new Event(\"open\"));const L=G.substring(j+4);if(B.#Y(F,L,0),F.#O>0){if(F.#Q+=L.length,F.#Q>=F.#O)F.#j=2,W.end()}return}case 1:if(B.#Y(F,Q.toString(),2),F.#O>0){if(F.#Q+=Q.byteLength,F.#Q>=F.#O)F.#j=2,W.end()}return;default:break}},drain(W){const Q=W.data;if(Q.#j===0){const F=Q.#J;if(F.length){const G=W.write(F);if(G!==F.length)W.data.#K=F.substring(G);else W.data.#K=\"\"}}},close:B.#z,end(W){B.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(W){B.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(W){const Q=W.data;if(Q.#G=null,Q.#Q=0,Q.#j=2,Q.#M){if(Q.#V)clearTimeout(Q.#V);Q.#V=setTimeout(B.#W,Q.#U,Q)}return Q}constructor(W,Q=@undefined){super();const F=new URL(W);this.#F=F.protocol===\"https:\",this.#$=F,this.#j=2,process.nextTick(B.#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.#$,Q=this.#F;this.#j=0,@Bun.connect({data:this,socket:B.#Z,hostname:W.hostname,port:parseInt(W.port||(Q\?\"443\":\"80\"),10),tls:Q\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((F)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:F})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(B.#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(B.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(B.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(B.prototype,\"CLOSED\",{enumerable:!0,value:2}),B[Symbol.for(\"CommonJS\")]=0,B})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index ab0d68e96..0a84f42b7 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -168,19 +168,19 @@ var { URL } = globalThis, { newArrayWithSize, String, Object, Array } = globalTh }; class Agent extends EventEmitter { - #defaultPort = 80; - #protocol = "http:"; - #options; - #requests; - #sockets; - #freeSockets; - #keepAliveMsecs; - #keepAlive; - #maxSockets; - #maxFreeSockets; - #scheduling; - #maxTotalSockets; - #totalSocketCount; + defaultPort = 80; + protocol = "http:"; + options; + requests; + sockets; + freeSockets; + keepAliveMsecs; + keepAlive; + maxSockets; + maxFreeSockets; + scheduling; + maxTotalSockets; + totalSocketCount; #fakeSocket; static get globalAgent() { return _globalAgent ??= new Agent; @@ -190,48 +190,9 @@ class Agent extends EventEmitter { } constructor(options = kEmptyObject) { super(); - if (this.#options = options = { ...options, path: null }, options.noDelay === void 0) + if (this.options = options = { ...options, path: null }, options.noDelay === void 0) options.noDelay = !0; - this.#requests = kEmptyObject, this.#sockets = kEmptyObject, this.#freeSockets = kEmptyObject, this.#keepAliveMsecs = options.keepAliveMsecs || 1000, this.#keepAlive = options.keepAlive || !1, this.#maxSockets = options.maxSockets || Agent.defaultMaxSockets, this.#maxFreeSockets = options.maxFreeSockets || 256, this.#scheduling = options.scheduling || "lifo", this.#maxTotalSockets = options.maxTotalSockets, this.#totalSocketCount = 0, this.#defaultPort = options.defaultPort || 80, this.#protocol = options.protocol || "http:"; - } - get defaultPort() { - return this.#defaultPort; - } - get protocol() { - return this.#protocol; - } - get requests() { - return this.#requests; - } - get sockets() { - return this.#sockets; - } - get freeSockets() { - return this.#freeSockets; - } - get options() { - return this.#options; - } - get keepAliveMsecs() { - return this.#keepAliveMsecs; - } - get keepAlive() { - return this.#keepAlive; - } - get maxSockets() { - return this.#maxSockets; - } - get maxFreeSockets() { - return this.#maxFreeSockets; - } - get scheduling() { - return this.#scheduling; - } - get maxTotalSockets() { - return this.#maxTotalSockets; - } - get totalSocketCount() { - return this.#totalSocketCount; + this.requests = kEmptyObject, this.sockets = kEmptyObject, this.freeSockets = kEmptyObject, this.keepAliveMsecs = options.keepAliveMsecs || 1000, this.keepAlive = options.keepAlive || !1, this.maxSockets = options.maxSockets || Agent.defaultMaxSockets, this.maxFreeSockets = options.maxFreeSockets || 256, this.scheduling = options.scheduling || "lifo", this.maxTotalSockets = options.maxTotalSockets, this.totalSocketCount = 0, this.defaultPort = options.defaultPort || 80, this.protocol = options.protocol || "http:"; } createConnection() { return debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createConnection is a no-op, returns fake socket"), this.#fakeSocket ??= new FakeSocket; -- cgit v1.2.3 From 70a87e11818d36f5922a495e2aed8618b01e9a73 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:36:59 -0700 Subject: Make `node:os` `tmpdir` more consistent with Node.js --- src/bun.js/node/node_os.zig | 28 ++-------------------------- src/js/node/os.js | 23 +++++++++++++++++++++-- src/js/out/modules/node/os.js | 14 ++++++++++++-- test/js/node/os/os.test.js | 5 +++++ 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/bun.js/node/node_os.zig b/src/bun.js/node/node_os.zig index 7f9ea2e28..f71143315 100644 --- a/src/bun.js/node/node_os.zig +++ b/src/bun.js/node/node_os.zig @@ -16,7 +16,7 @@ pub const Os = struct { pub const code = @embedFile("../os.exports.js"); pub fn create(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { - const module = JSC.JSValue.createEmptyObject(globalObject, 20); + const module = JSC.JSValue.createEmptyObject(globalObject, 22); module.put(globalObject, JSC.ZigString.static("arch"), JSC.NewFunction(globalObject, JSC.ZigString.static("arch"), 0, arch, true)); module.put(globalObject, JSC.ZigString.static("cpus"), JSC.NewFunction(globalObject, JSC.ZigString.static("cpus"), 0, cpus, true)); @@ -31,7 +31,6 @@ pub const Os = struct { module.put(globalObject, JSC.ZigString.static("platform"), JSC.NewFunction(globalObject, JSC.ZigString.static("platform"), 0, platform, true)); module.put(globalObject, JSC.ZigString.static("release"), JSC.NewFunction(globalObject, JSC.ZigString.static("release"), 0, release, true)); module.put(globalObject, JSC.ZigString.static("setPriority"), JSC.NewFunction(globalObject, JSC.ZigString.static("setPriority"), 2, setPriority, true)); - module.put(globalObject, JSC.ZigString.static("tmpdir"), JSC.NewFunction(globalObject, JSC.ZigString.static("tmpdir"), 0, tmpdir, true)); module.put(globalObject, JSC.ZigString.static("totalmem"), JSC.NewFunction(globalObject, JSC.ZigString.static("totalmem"), 0, totalmem, true)); module.put(globalObject, JSC.ZigString.static("type"), JSC.NewFunction(globalObject, JSC.ZigString.static("type"), 0, Os.type, true)); module.put(globalObject, JSC.ZigString.static("uptime"), JSC.NewFunction(globalObject, JSC.ZigString.static("uptime"), 0, uptime, true)); @@ -485,7 +484,7 @@ pub const Os = struct { std.os.AF.INET => JSC.ZigString.static("IPv4"), std.os.AF.INET6 => JSC.ZigString.static("IPv6"), else => JSC.ZigString.static("unknown"), - }).toValue(globalThis)); + }).toValueGC(globalThis)); // mac The MAC address of the network interface { @@ -620,29 +619,6 @@ pub const Os = struct { return JSC.JSValue.jsUndefined(); } - pub fn tmpdir(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { - JSC.markBinding(@src()); - - const dir: []const u8 = brk: { - if (comptime Environment.isWindows) { - if (bun.getenvZ("TEMP") orelse bun.getenvZ("TMP")) |tmpdir_| { - break :brk tmpdir_; - } - - if (bun.getenvZ("SYSTEMROOT") orelse bun.getenvZ("WINDIR")) |systemdir_| { - break :brk systemdir_ ++ "\\temp"; - } - } else { - const dir = bun.asByteSlice(bun.getenvZ("TMPDIR") orelse bun.getenvZ("TMP") orelse bun.getenvZ("TEMP") orelse "/tmp"); - break :brk strings.withoutTrailingSlash(dir); - } - - break :brk "unknown"; - }; - - return JSC.ZigString.init(dir).withEncoding().toValueGC(globalThis); - } - pub fn totalmem(_: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue { JSC.markBinding(@src()); diff --git a/src/js/node/os.js b/src/js/node/os.js index 3315708ad..3cd0288bd 100644 --- a/src/js/node/os.js +++ b/src/js/node/os.js @@ -1,4 +1,22 @@ // Hardcoded module "node:os" + +export var tmpdir = function () { + var lazy = Symbol.for("Bun.lazy"); + var primordials = globalThis[lazy]("primordials"); + + var { Bun } = primordials; + var env = Bun.env; + + tmpdir = function () { + var path = env["TMPDIR"] || env["TMP"] || env["TEMP"] || "/tmp"; + const length = path.length; + if (length > 1 && path[length - 1] === "/") path = path.slice(0, -1); + return path; + }; + + return tmpdir(); +}; + function bound(obj) { return { arch: obj.arch.bind(obj), @@ -13,7 +31,9 @@ function bound(obj) { platform: obj.platform.bind(obj), release: obj.release.bind(obj), setPriority: obj.setPriority.bind(obj), - tmpdir: obj.tmpdir.bind(obj), + get tmpdir() { + return tmpdir; + }, totalmem: obj.totalmem.bind(obj), type: obj.type.bind(obj), uptime: obj.uptime.bind(obj), @@ -42,7 +62,6 @@ export var { platform, release, setPriority, - tmpdir, totalmem, type, uptime, diff --git a/src/js/out/modules/node/os.js b/src/js/out/modules/node/os.js index e27464e15..69c112412 100644 --- a/src/js/out/modules/node/os.js +++ b/src/js/out/modules/node/os.js @@ -12,7 +12,9 @@ var bound = function(obj) { platform: obj.platform.bind(obj), release: obj.release.bind(obj), setPriority: obj.setPriority.bind(obj), - tmpdir: obj.tmpdir.bind(obj), + get tmpdir() { + return tmpdir; + }, totalmem: obj.totalmem.bind(obj), type: obj.type.bind(obj), uptime: obj.uptime.bind(obj), @@ -24,6 +26,15 @@ var bound = function(obj) { constants: obj.constants, [Symbol.for("CommonJS")]: 0 }; +}, tmpdir = function() { + var lazy = Symbol.for("Bun.lazy"), primordials = globalThis[lazy]("primordials"), { Bun: Bun2 } = primordials, env = Bun2.env; + return tmpdir = function() { + var path = env["TMPDIR"] || env["TMP"] || env["TEMP"] || "/tmp"; + const length = path.length; + if (length > 1 && path[length - 1] === "/") + path = path.slice(0, -1); + return path; + }, tmpdir(); }, os = bound(Bun._Os()), { arch, cpus, @@ -37,7 +48,6 @@ var bound = function(obj) { platform, release, setPriority, - tmpdir, totalmem, type, uptime, diff --git a/test/js/node/os/os.test.js b/test/js/node/os/os.test.js index d7229b56d..8b4d54bb7 100644 --- a/test/js/node/os/os.test.js +++ b/test/js/node/os/os.test.js @@ -43,11 +43,16 @@ it("tmpdir", () => { expect(os.tmpdir()).toBe(process.env.TEMP || process.env.TMP); expect(os.tmpdir()).toBe(`${process.env.SystemRoot || process.env.windir}\\temp`); } else { + const originalEnv = process.env.TMPDIR; let dir = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp"; if (dir.length > 1 && dir.endsWith("/")) { dir = dir.substring(0, dir.length - 1); } expect(realpathSync(os.tmpdir())).toBe(realpathSync(dir)); + + process.env.TMPDIR = "/boop"; + expect(os.tmpdir()).toBe("/boop"); + process.env.TMPDIR = originalEnv; } }); -- cgit v1.2.3 From 76b9cae25930db8a6293dcff3d3f55948aa896cf Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Thu, 29 Jun 2023 17:19:16 -0700 Subject: handle multiple redirects --- src/bundler/bundle_v2.zig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index b7c5e80c5..814e49a20 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -360,6 +360,8 @@ pub const BundleV2 = struct { redirect_map: PathToSourceIndexMap, dynamic_import_entry_points: *std.AutoArrayHashMap(Index.Int, void), + const MAX_REDIRECTS: usize = 20; + // Find all files reachable from all entry points. This order should be // deterministic given that the entry point order is deterministic, since the // returned order is the postorder of the graph traversal and import record @@ -382,13 +384,20 @@ pub const BundleV2 = struct { if (import_record_list_id.get() < v.all_import_records.len) { var import_records = v.all_import_records[import_record_list_id.get()].slice(); for (import_records) |*import_record| { - const other_source = import_record.source_index; + var other_source = import_record.source_index; if (other_source.isValid()) { - if (getRedirectId(v.redirects[other_source.get()])) |redirect_id| { + var redirect_count: usize = 0; + while (getRedirectId(v.redirects[other_source.get()])) |redirect_id| : (redirect_count += 1) { var other_import_records = v.all_import_records[other_source.get()].slice(); const other_import_record = &other_import_records[redirect_id]; import_record.source_index = other_import_record.source_index; import_record.path = other_import_record.path; + other_source = other_import_record.source_index; + if (redirect_count == MAX_REDIRECTS) { + import_record.path.is_disabled = true; + import_record.source_index = Index.invalid; + break; + } } v.visit(import_record.source_index, check_dynamic_imports and import_record.kind == .dynamic, check_dynamic_imports); -- cgit v1.2.3 From c42a00f9df7423e60a23a1194731ca7c85a7d16f Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 29 Jun 2023 20:14:12 -0700 Subject: Fixes #3462 (#3465) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/js_ast.zig | 8 ++++++++ src/js_parser.zig | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/js_ast.zig b/src/js_ast.zig index 9ec14e158..8ae652bb9 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -2140,6 +2140,14 @@ pub const E = struct { rope_len: u32 = 0, is_utf16: bool = false, + pub fn isIdentifier(this: *String, allocator: std.mem.Allocator) bool { + if (!this.isUTF8()) { + return bun.js_lexer.isIdentifierUTF16(this.slice16()); + } + + return bun.js_lexer.isIdentifier(this.slice(allocator)); + } + pub var class = E.String{ .data = "class" }; pub fn push(this: *String, other: *String) void { std.debug.assert(this.isUTF8()); diff --git a/src/js_parser.zig b/src/js_parser.zig index 2d84fc0c0..5729efa39 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -15900,6 +15900,30 @@ fn NewParser_( const is_call_target = std.meta.activeTag(p.call_target) == .e_index and expr.data.e_index == p.call_target.e_index; const is_delete_target = std.meta.activeTag(p.delete_target) == .e_index and expr.data.e_index == p.delete_target.e_index; + if (p.options.features.minify_syntax) { + if (e_.index.data == .e_string and e_.index.data.e_string.isUTF8() and e_.index.data.e_string.isIdentifier(p.allocator)) { + const dot = p.newExpr( + E.Dot{ + .name = e_.index.data.e_string.slice(p.allocator), + .name_loc = e_.index.loc, + .target = e_.target, + .optional_chain = e_.optional_chain, + }, + expr.loc, + ); + + if (is_call_target) { + p.call_target = dot.data; + } + + if (is_delete_target) { + p.delete_target = dot.data; + } + + return p.visitExprInOut(dot, in); + } + } + const target = p.visitExprInOut(e_.target, ExprIn{ // this is awkward due to a zig compiler bug .has_chain_parent = (e_.optional_chain orelse js_ast.OptionalChain.start) == js_ast.OptionalChain.ccontinue, -- cgit v1.2.3 From b9460087e391c454f323390a42902a3ed024c8bc Mon Sep 17 00:00:00 2001 From: dave caruso Date: Thu, 29 Jun 2023 23:36:18 -0400 Subject: Fixes `node:http` and `node:stream` so `ytdl-core` works. (#3452) * fix crash in readablestate * make node:https request+get actually use https * use a native readablestream in IncomingMessage * tweaks * fix abort crash * emit close by default * remove abort. this isnt a real function * add validate functions, fixup some other requested changes. not done yet * Update WebCoreJSBuiltins.cpp * Update JSReadableState.cpp * Add some missing exports --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- packages/bun-types/bun.d.ts | 6 +- packages/bun-types/globals.d.ts | 9 +- src/bun.js/api/server.zig | 3 +- src/bun.js/bindings/JSReadableState.cpp | 5 +- src/bun.js/webcore/body.zig | 6 +- src/js/builtins/ReadableStreamDefaultReader.ts | 4 +- src/js/builtins/builtins.d.ts | 6 +- src/js/node/events.js | 10 +- src/js/node/http.js | 1795 ----------------------- src/js/node/http.ts | 1810 ++++++++++++++++++++++++ src/js/node/https.js | 3 - src/js/node/https.ts | 65 + src/js/out/WebCoreJSBuiltins.cpp | 150 +- src/js/out/modules/node/assert.js | 84 +- src/js/out/modules/node/dns.promises.js | 3 + src/js/out/modules/node/events.js | 2 + src/js/out/modules/node/fs.promises.js | 2 +- src/js/out/modules/node/http.js | 103 +- src/js/out/modules/node/https.js | 55 +- src/js/private.d.ts | 1 + test/js/node/http/node-http.test.ts | 23 +- 21 files changed, 2163 insertions(+), 1982 deletions(-) delete mode 100644 src/js/node/http.js create mode 100644 src/js/node/http.ts delete mode 100644 src/js/node/https.js create mode 100644 src/js/node/https.ts diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 4c10212f2..86ded9aa0 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -1912,7 +1912,9 @@ declare module "bun" { export interface TLSWebSocketServeOptions extends WebSocketServeOptions, - TLSOptions {} + TLSOptions { + tls?: TLSOptions; + } export interface Errorlike extends Error { code?: string; errno?: number; @@ -2023,6 +2025,8 @@ declare module "bun" { * The values are SSL options objects. */ serverNames?: Record; + + tls?: TLSOptions; } /** diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index a5d011b52..5784f91c2 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -888,6 +888,12 @@ type ReadableStreamController = ReadableStreamDefaultController; type ReadableStreamDefaultReadResult = | ReadableStreamDefaultReadValueResult | ReadableStreamDefaultReadDoneResult; +interface ReadableStreamDefaultReadManyResult { + done: boolean; + /** Number of bytes */ + size: number; + value: T[]; +} type ReadableStreamReader = ReadableStreamDefaultReader; interface RequestInit { @@ -2261,7 +2267,8 @@ declare var ReadableStreamDefaultController: { interface ReadableStreamDefaultReader extends ReadableStreamGenericReader { read(): Promise>; - readMany(): Promise>; + /** Only available in Bun. If there are multiple chunks in the queue, this will return all of them at the same time. */ + readMany(): Promise>; releaseLock(): void; } diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index ebfacdcc9..32c4fd25c 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -1456,12 +1456,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp // the promise is pending if (body.value.Locked.action != .none or body.value.Locked.promise != null) { this.pending_promises_for_abort += 1; - body.value.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis); } else if (body.value.Locked.readable != null) { body.value.Locked.readable.?.abort(this.server.globalThis); - body.value.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis); body.value.Locked.readable = null; } + body.value.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis); } } diff --git a/src/bun.js/bindings/JSReadableState.cpp b/src/bun.js/bindings/JSReadableState.cpp index 8a4ee746b..1f3a36def 100644 --- a/src/bun.js/bindings/JSReadableState.cpp +++ b/src/bun.js/bindings/JSReadableState.cpp @@ -29,7 +29,7 @@ int64_t getHighWaterMark(JSC::VM& vm, JSC::JSGlobalObject* globalObject, bool is highWaterMarkVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "readableObjectMode"_s)); } - if (highWaterMarkVal && !highWaterMarkVal.isUndefinedOrNull()) { + if (highWaterMarkVal && highWaterMarkVal.isNumber()) { return highWaterMarkVal.toInt32(globalObject); } } @@ -72,6 +72,9 @@ void JSReadableState::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObj JSC::JSValue autoDestroyVal = options->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "autoDestroy"_s)); if (!autoDestroyVal || autoDestroyVal.toBoolean(globalObject)) setBool(JSReadableState::Mask::autoDestroy, true); + } else { + setBool(JSReadableState::Mask::emitClose, true); + setBool(JSReadableState::Mask::autoDestroy, true); } // Indicates whether the stream has finished destroying. diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig index df3ba3ce1..028b104b2 100644 --- a/src/bun.js/webcore/body.zig +++ b/src/bun.js/webcore/body.zig @@ -496,8 +496,10 @@ pub const Body = struct { locked.readable.?.value.protect(); return locked.readable.?.value; }, - - else => unreachable, + .Error => { + // TODO: handle error properly + return JSC.WebCore.ReadableStream.empty(globalThis); + }, } } diff --git a/src/js/builtins/ReadableStreamDefaultReader.ts b/src/js/builtins/ReadableStreamDefaultReader.ts index ecd553ed5..70c6df8c3 100644 --- a/src/js/builtins/ReadableStreamDefaultReader.ts +++ b/src/js/builtins/ReadableStreamDefaultReader.ts @@ -43,7 +43,7 @@ export function cancel(this, reason) { return $readableStreamReaderGenericCancel(this, reason); } -export function readMany(this) { +export function readMany(this: ReadableStreamDefaultReader): ReadableStreamDefaultReadManyResult { if (!$isReadableStreamDefaultReader(this)) throw new TypeError("ReadableStreamDefaultReader.readMany() should not be called directly"); @@ -75,7 +75,7 @@ export function readMany(this) { var length = values.length; if (length > 0) { - var outValues = $newArrayWithSize(length); + var outValues = $newArrayWithSize(length); if ($isReadableByteStreamController(controller)) { { const buf = values[0]; diff --git a/src/js/builtins/builtins.d.ts b/src/js/builtins/builtins.d.ts index 449c9c128..2de8d8206 100644 --- a/src/js/builtins/builtins.d.ts +++ b/src/js/builtins/builtins.d.ts @@ -433,9 +433,9 @@ declare interface ArrayBufferConstructor extends ClassWithIntrinsics extends ClassWithIntrinsics> {} declare interface UnderlyingSource { - $lazy: boolean; - $bunNativeType: number; - $bunNativePtr: number; + $lazy?: boolean; + $bunNativeType?: number; + $bunNativePtr?: number; autoAllocateChunkSize?: number; } diff --git a/src/js/node/events.js b/src/js/node/events.js index 4fd16a85b..111fdb524 100644 --- a/src/js/node/events.js +++ b/src/js/node/events.js @@ -463,12 +463,14 @@ const usingDomains = false; Object.assign(EventEmitter, { once, on, getEventListeners, setMaxListeners, listenerCount, EventEmitterAsyncResource }); export { EventEmitter, - once, - on, + captureRejectionSymbol, + kErrorMonitor as errorMonitor, getEventListeners, - setMaxListeners, listenerCount, + on, + once, + setMaxListeners, usingDomains, - captureRejectionSymbol, + EventEmitterAsyncResource, }; export default EventEmitter; diff --git a/src/js/node/http.js b/src/js/node/http.js deleted file mode 100644 index fe9730101..000000000 --- a/src/js/node/http.js +++ /dev/null @@ -1,1795 +0,0 @@ -// Hardcoded module "node:http" -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; -const fetch = Bun.fetch; -const nop = () => {}; - -const __DEBUG__ = process.env.__DEBUG__; -const debug = __DEBUG__ ? (...args) => console.log("node:http", ...args) : nop; - -const kEmptyObject = Object.freeze(Object.create(null)); -const kOutHeaders = Symbol.for("kOutHeaders"); -const kEndCalled = Symbol.for("kEndCalled"); -const kAbortController = Symbol.for("kAbortController"); -const kClearTimeout = Symbol("kClearTimeout"); - -const kCorked = Symbol.for("kCorked"); -const searchParamsSymbol = Symbol.for("query"); // This is the symbol used in Node - -// Primordials -const StringPrototypeSlice = String.prototype.slice; -const StringPrototypeStartsWith = String.prototype.startsWith; -const StringPrototypeToUpperCase = String.prototype.toUpperCase; -const StringPrototypeIncludes = String.prototype.includes; -const StringPrototypeCharCodeAt = String.prototype.charCodeAt; -const StringPrototypeIndexOf = String.prototype.indexOf; -const ArrayIsArray = Array.isArray; -const RegExpPrototypeExec = RegExp.prototype.exec; -const ObjectAssign = Object.assign; -const ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty; - -const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/; -const NODE_HTTP_WARNING = - "WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause."; - -var _globalAgent; -var _defaultHTTPSAgent; -var kInternalRequest = Symbol("kInternalRequest"); -var kInternalSocketData = Symbol.for("::bunternal::"); - -const kEmptyBuffer = Buffer.alloc(0); - -function isValidTLSArray(obj) { - if (typeof obj === "string" || isTypedArray(obj) || obj instanceof ArrayBuffer || obj instanceof Blob) return true; - if (Array.isArray(obj)) { - for (var i = 0; i < obj.length; i++) { - if (typeof obj !== "string" && !isTypedArray(obj) && !(obj instanceof ArrayBuffer) && !(obj instanceof Blob)) - return false; - } - return true; - } -} - -function getHeader(headers, name) { - if (!headers) return; - const result = headers.get(name); - return result == null ? undefined : result; -} - -var FakeSocket = class Socket extends Duplex { - bytesRead = 0; - bytesWritten = 0; - connecting = false; - remoteAddress = null; - localAddress = "127.0.0.1"; - remotePort; - timeout = 0; - - isServer = false; - - address() { - return { - address: this.localAddress, - family: this.localFamily, - port: this.localPort, - }; - } - - get bufferSize() { - return this.writableLength; - } - - connect(port, host, connectListener) { - return this; - } - - _destroy(err, callback) {} - - _final(callback) {} - - get localAddress() { - return "127.0.0.1"; - } - - get localFamily() { - return "IPv4"; - } - - get localPort() { - return 80; - } - - get pending() { - return this.connecting; - } - - _read(size) {} - - get readyState() { - if (this.connecting) return "opening"; - if (this.readable) { - return this.writable ? "open" : "readOnly"; - } else { - return this.writable ? "writeOnly" : "closed"; - } - } - - ref() {} - - get remoteFamily() { - return "IPv4"; - } - - resetAndDestroy() {} - - setKeepAlive(enable = false, initialDelay = 0) {} - - setNoDelay(noDelay = true) { - return this; - } - - setTimeout(timeout, callback) { - return this; - } - - unref() {} - - _write(chunk, encoding, callback) {} -}; - -export function createServer(options, callback) { - return new Server(options, callback); -} - -export class Agent extends EventEmitter { - defaultPort = 80; - protocol = "http:"; - options; - requests; - sockets; - freeSockets; - - keepAliveMsecs; - keepAlive; - maxSockets; - maxFreeSockets; - scheduling; - maxTotalSockets; - totalSocketCount; - - #fakeSocket; - - static get globalAgent() { - return (_globalAgent ??= new Agent()); - } - - static get defaultMaxSockets() { - return Infinity; - } - - constructor(options = kEmptyObject) { - super(); - this.options = options = { ...options, path: null }; - if (options.noDelay === undefined) options.noDelay = true; - - // Don't confuse net and make it think that we're connecting to a pipe - this.requests = kEmptyObject; - this.sockets = kEmptyObject; - this.freeSockets = kEmptyObject; - - this.keepAliveMsecs = options.keepAliveMsecs || 1000; - this.keepAlive = options.keepAlive || false; - this.maxSockets = options.maxSockets || Agent.defaultMaxSockets; - this.maxFreeSockets = options.maxFreeSockets || 256; - this.scheduling = options.scheduling || "lifo"; - this.maxTotalSockets = options.maxTotalSockets; - this.totalSocketCount = 0; - this.defaultPort = options.defaultPort || 80; - this.protocol = options.protocol || "http:"; - } - - createConnection() { - debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createConnection is a no-op, returns fake socket"); - return (this.#fakeSocket ??= new FakeSocket()); - } - - getName(options = kEmptyObject) { - let name = `http:${options.host || "localhost"}:`; - if (options.port) name += options.port; - name += ":"; - if (options.localAddress) name += options.localAddress; - // Pacify parallel/test-http-agent-getname by only appending - // the ':' when options.family is set. - if (options.family === 4 || options.family === 6) name += `:${options.family}`; - if (options.socketPath) name += `:${options.socketPath}`; - return name; - } - - addRequest() { - debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.addRequest is a no-op"); - } - - createSocket(req, options, cb) { - debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createSocket returns fake socket"); - cb(null, (this.#fakeSocket ??= new FakeSocket())); - } - - removeSocket() { - debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.removeSocket is a no-op"); - } - - keepSocketAlive() { - debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.keepSocketAlive is a no-op"); - - return true; - } - - reuseSocket() { - debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.reuseSocket is a no-op"); - } - - destroy() { - debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.destroy is a no-op"); - } -} -function emitListeningNextTick(self, onListen, err, hostname, port) { - if (typeof onListen === "function") { - try { - onListen(err, hostname, port); - } catch (err) { - self.emit("error", err); - } - } - - self.listening = !err; - - if (err) { - self.emit("error", err); - } else { - self.emit("listening", hostname, port); - } -} - -export class Server extends EventEmitter { - #server; - #options; - #tls; - #is_tls = false; - listening = false; - - constructor(options, callback) { - super(); - - if (typeof options === "function") { - callback = options; - options = {}; - } else if (options == null || typeof options === "object") { - options = { ...options }; - this.#tls = null; - let key = options.key; - if (key) { - if (!isValidTLSArray(key)) { - throw new TypeError( - "key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", - ); - } - this.#is_tls = true; - } - let cert = options.cert; - if (cert) { - if (!isValidTLSArray(cert)) { - throw new TypeError( - "cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", - ); - } - this.#is_tls = true; - } - - let ca = options.ca; - if (ca) { - if (!isValidTLSArray(ca)) { - throw new TypeError( - "ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", - ); - } - this.#is_tls = true; - } - let passphrase = options.passphrase; - if (passphrase && typeof passphrase !== "string") { - throw new TypeError("passphrase argument must be an string"); - } - - let serverName = options.servername; - if (serverName && typeof serverName !== "string") { - throw new TypeError("servername argument must be an string"); - } - - let secureOptions = options.secureOptions || 0; - if (secureOptions && typeof secureOptions !== "number") { - throw new TypeError("secureOptions argument must be an number"); - } - - if (this.#is_tls) { - this.#tls = { - serverName, - key: key, - cert: cert, - ca: ca, - passphrase: passphrase, - secureOptions: secureOptions, - }; - } else { - this.#tls = null; - } - } else { - throw new Error("bun-http-polyfill: invalid arguments"); - } - - this.#options = options; - - if (callback) this.on("request", callback); - } - - closeAllConnections() { - const server = this.#server; - if (!server) { - return; - } - this.#server = undefined; - server.stop(true); - this.emit("close"); - } - - closeIdleConnections() { - // not actually implemented - } - - close(optionalCallback) { - const server = this.#server; - if (!server) { - if (typeof optionalCallback === "function") - process.nextTick(optionalCallback, new Error("Server is not running")); - return; - } - this.#server = undefined; - if (typeof optionalCallback === "function") this.once("close", optionalCallback); - server.stop(); - this.emit("close"); - } - - address() { - if (!this.#server) return null; - - const address = this.#server.hostname; - return { - address, - family: isIPv6(address) ? "IPv6" : "IPv4", - port: this.#server.port, - }; - } - - listen(port, host, backlog, onListen) { - const server = this; - if (typeof host === "function") { - onListen = host; - host = undefined; - } - - if (typeof port === "function") { - onListen = port; - } else if (typeof port === "object") { - port?.signal?.addEventListener("abort", () => { - this.close(); - }); - - host = port?.host; - port = port?.port; - - if (typeof port?.callback === "function") onListen = port?.callback; - } - - if (typeof backlog === "function") { - onListen = backlog; - } - - const ResponseClass = this.#options.ServerResponse || ServerResponse; - const RequestClass = this.#options.IncomingMessage || IncomingMessage; - - try { - const tls = this.#tls; - if (tls) { - this.serverName = tls.serverName || host || "localhost"; - } - this.#server = Bun.serve({ - tls, - port, - hostname: host, - // Bindings to be used for WS Server - websocket: { - open(ws) { - ws.data.open(ws); - }, - message(ws, message) { - ws.data.message(ws, message); - }, - close(ws, code, reason) { - ws.data.close(ws, code, reason); - }, - drain(ws) { - ws.data.drain(ws); - }, - }, - fetch(req, _server) { - var pendingResponse; - var pendingError; - var rejectFunction, resolveFunction; - var reject = err => { - if (pendingError) return; - pendingError = err; - if (rejectFunction) rejectFunction(err); - }; - - var reply = function (resp) { - if (pendingResponse) return; - pendingResponse = resp; - if (resolveFunction) resolveFunction(resp); - }; - - const http_req = new RequestClass(req); - const http_res = new ResponseClass({ reply, req: http_req }); - - http_req.once("error", err => reject(err)); - http_res.once("error", err => reject(err)); - - const upgrade = req.headers.get("upgrade"); - if (upgrade) { - const socket = new FakeSocket(); - socket[kInternalSocketData] = [_server, http_res, req]; - server.emit("upgrade", http_req, socket, kEmptyBuffer); - } else { - server.emit("request", http_req, http_res); - } - - if (pendingError) { - throw pendingError; - } - - if (pendingResponse) { - return pendingResponse; - } - - return new Promise((resolve, reject) => { - resolveFunction = resolve; - rejectFunction = reject; - }); - }, - }); - setTimeout(emitListeningNextTick, 1, this, onListen, null, this.#server.hostname, this.#server.port); - } catch (err) { - setTimeout(emitListeningNextTick, 1, this, onListen, err); - } - - return this; - } - setTimeout(msecs, callback) {} -} - -function assignHeaders(object, req) { - var headers = req.headers.toJSON(); - const rawHeaders = newArrayWithSize(req.headers.count * 2); - var i = 0; - for (const key in headers) { - rawHeaders[i++] = key; - rawHeaders[i++] = headers[key]; - } - object.headers = headers; - object.rawHeaders = rawHeaders; -} -function destroyBodyStreamNT(bodyStream) { - bodyStream.destroy(); -} - -var defaultIncomingOpts = { type: "request" }; - -function getDefaultHTTPSAgent() { - return (_defaultHTTPSAgent ??= new Agent({ defaultPort: 443, protocol: "https:" })); -} - -export class IncomingMessage extends Readable { - constructor(req, defaultIncomingOpts) { - const method = req.method; - - super(); - - const url = new URL(req.url); - - var { type = "request", [kInternalRequest]: nodeReq } = defaultIncomingOpts || {}; - - this.#noBody = - type === "request" // TODO: Add logic for checking for body on response - ? "GET" === method || - "HEAD" === method || - "TRACE" === method || - "CONNECT" === method || - "OPTIONS" === method || - (parseInt(req.headers.get("Content-Length") || "") || 0) === 0 - : false; - - this.#req = req; - this.method = method; - this.#type = type; - this.complete = !!this.#noBody; - - this.#bodyStream = null; - const socket = new FakeSocket(); - socket.remoteAddress = url.hostname; - socket.remotePort = url.port; - this.#fakeSocket = socket; - - this.url = url.pathname + url.search; - this.#nodeReq = nodeReq; - assignHeaders(this, req); - } - - headers; - rawHeaders; - _consuming = false; - _dumped = false; - #bodyStream = null; - #fakeSocket = undefined; - #noBody = false; - #aborted = false; - #req; - url; - #type; - #nodeReq; - - get req() { - return this.#nodeReq; - } - - _construct(callback) { - // TODO: streaming - if (this.#type === "response" || this.#noBody) { - callback(); - return; - } - - const contentLength = this.#req.headers.get("content-length"); - const length = contentLength ? parseInt(contentLength, 10) : 0; - if (length === 0) { - this.#noBody = true; - callback(); - return; - } - - callback(); - } - - #closeBodyStream() { - debug("closeBodyStream()"); - var bodyStream = this.#bodyStream; - if (bodyStream == null) return; - this.complete = true; - this.#bodyStream = undefined; - this.push(null); - // process.nextTick(destroyBodyStreamNT, bodyStream); - } - - _read(size) { - if (this.#noBody) { - this.push(null); - this.complete = true; - } else if (this.#bodyStream == null) { - const contentLength = this.#req.headers.get("content-length"); - let remaining = contentLength ? parseInt(contentLength, 10) : 0; - this.#bodyStream = Readable.fromWeb(this.#req.body, { - highWaterMark: Number.isFinite(remaining) ? Math.min(remaining, 16384) : 16384, - }); - - const isBodySizeKnown = remaining > 0 && Number.isSafeInteger(remaining); - - if (isBodySizeKnown) { - this.#bodyStream.on("data", chunk => { - debug("body size known", remaining); - this.push(chunk); - // when we are streaming a known body size, automatically close the stream when we have read enough - remaining -= chunk?.byteLength ?? 0; - if (remaining <= 0) { - this.#closeBodyStream(); - } - }); - } else { - this.#bodyStream.on("data", chunk => { - this.push(chunk); - }); - } - - // this can be closed by the time we get here if enough data was synchronously available - this.#bodyStream && - this.#bodyStream.on("end", () => { - this.#closeBodyStream(); - }); - } else { - // this.#bodyStream.read(size); - } - } - - get aborted() { - return this.#aborted; - } - - abort() { - if (this.#aborted) return; - this.#aborted = true; - - this.#closeBodyStream(); - } - - get connection() { - return this.#fakeSocket; - } - - get statusCode() { - return this.#req.status; - } - - get statusMessage() { - return STATUS_CODES[this.#req.status]; - } - - get httpVersion() { - return "1.1"; - } - - get rawTrailers() { - return []; - } - - get httpVersionMajor() { - return 1; - } - - get httpVersionMinor() { - return 1; - } - - get trailers() { - return kEmptyObject; - } - - get socket() { - return (this.#fakeSocket ??= new FakeSocket()); - } - - set socket(val) { - this.#fakeSocket = val; - } - - setTimeout(msecs, callback) { - throw new Error("not implemented"); - } -} - -function emitErrorNt(msg, err, callback) { - callback(err); - if (typeof msg.emit === "function" && !msg._closed) { - msg.emit("error", err); - } -} - -function onError(self, err, cb) { - process.nextTick(() => emitErrorNt(self, err, cb)); -} - -function write_(msg, chunk, encoding, callback, fromEnd) { - if (typeof callback !== "function") callback = nop; - - let len; - if (chunk === null) { - // throw new ERR_STREAM_NULL_VALUES(); - throw new Error("ERR_STREAM_NULL_VALUES"); - } else if (typeof chunk === "string") { - len = Buffer.byteLength(chunk, encoding); - } else { - throw new Error("Invalid arg type for chunk"); - // throw new ERR_INVALID_ARG_TYPE( - // "chunk", - // ["string", "Buffer", "Uint8Array"], - // chunk, - // ); - } - - let err; - if (msg.finished) { - // err = new ERR_STREAM_WRITE_AFTER_END(); - err = new Error("ERR_STREAM_WRITE_AFTER_END"); - } else if (msg.destroyed) { - // err = new ERR_STREAM_DESTROYED("write"); - err = new Error("ERR_STREAM_DESTROYED"); - } - - if (err) { - if (!msg.destroyed) { - onError(msg, err, callback); - } else { - process.nextTick(callback, err); - } - return false; - } - - if (!msg._header) { - if (fromEnd) { - msg._contentLength = len; - } - // msg._implicitHeader(); - } - - if (!msg._hasBody) { - debug("This type of response MUST NOT have a body. " + "Ignoring write() calls."); - process.nextTick(callback); - return true; - } - - // if (!fromEnd && msg.socket && !msg.socket.writableCorked) { - // msg.socket.cork(); - // process.nextTick(connectionCorkNT, msg.socket); - // } - - return true; -} - -export class OutgoingMessage extends Writable { - #headers; - headersSent = false; - sendDate = true; - req; - - #finished = false; - [kEndCalled] = false; - - #fakeSocket; - #timeoutTimer = null; - [kAbortController] = null; - - // Express "compress" package uses this - _implicitHeader() {} - - // For compat with IncomingRequest - get headers() { - if (!this.#headers) return kEmptyObject; - return this.#headers.toJSON(); - } - - get shouldKeepAlive() { - return true; - } - - get chunkedEncoding() { - return false; - } - - set chunkedEncoding(value) { - // throw new Error('not implemented'); - } - - set shouldKeepAlive(value) { - // throw new Error('not implemented'); - } - - get useChunkedEncodingByDefault() { - return true; - } - - set useChunkedEncodingByDefault(value) { - // throw new Error('not implemented'); - } - - get socket() { - return (this.#fakeSocket ??= new FakeSocket()); - } - - set socket(val) { - this.#fakeSocket = val; - } - - get connection() { - return this.socket; - } - - get finished() { - return this.#finished; - } - - appendHeader(name, value) { - var headers = (this.#headers ??= new Headers()); - headers.append(name, value); - } - - flushHeaders() {} - - getHeader(name) { - return getHeader(this.#headers, name); - } - - getHeaders() { - if (!this.#headers) return kEmptyObject; - return this.#headers.toJSON(); - } - - getHeaderNames() { - var headers = this.#headers; - if (!headers) return []; - return Array.from(headers.keys()); - } - - removeHeader(name) { - if (!this.#headers) return; - this.#headers.delete(name); - } - - setHeader(name, value) { - var headers = (this.#headers ??= new Headers()); - headers.set(name, value); - return this; - } - - hasHeader(name) { - if (!this.#headers) return false; - return this.#headers.has(name); - } - - addTrailers(headers) { - throw new Error("not implemented"); - } - - [kClearTimeout]() { - if (this.#timeoutTimer) { - clearTimeout(this.#timeoutTimer); - this.#timeoutTimer = null; - } - } - - setTimeout(msecs, callback) { - if (this.#timeoutTimer) return this; - if (callback) { - this.on("timeout", callback); - } - - this.#timeoutTimer = setTimeout(async () => { - this.#timeoutTimer = null; - this[kAbortController]?.abort(); - this.emit("timeout"); - }, msecs); - - return this; - } -} - -export class ServerResponse extends Writable { - constructor({ req, reply }) { - super(); - this.req = req; - this._reply = reply; - this.sendDate = true; - this.statusCode = 200; - this.headersSent = false; - this.statusMessage = undefined; - this.#controller = undefined; - this.#firstWrite = undefined; - this._writableState.decodeStrings = false; - this.#deferred = undefined; - } - - req; - _reply; - sendDate; - statusCode; - #headers; - headersSent = false; - statusMessage; - #controller; - #firstWrite; - _sent100 = false; - _defaultKeepAlive = false; - _removedConnection = false; - _removedContLen = false; - #deferred = undefined; - #finished = false; - - // Express "compress" package uses this - _implicitHeader() {} - - _write(chunk, encoding, callback) { - if (!this.#firstWrite && !this.headersSent) { - this.#firstWrite = chunk; - callback(); - return; - } - - this.#ensureReadableStreamController(controller => { - controller.write(chunk); - callback(); - }); - } - - _writev(chunks, callback) { - if (chunks.length === 1 && !this.headersSent && !this.#firstWrite) { - this.#firstWrite = chunks[0].chunk; - callback(); - return; - } - - this.#ensureReadableStreamController(controller => { - for (const chunk of chunks) { - controller.write(chunk.chunk); - } - - callback(); - }); - } - - #ensureReadableStreamController(run) { - var thisController = this.#controller; - if (thisController) return run(thisController); - this.headersSent = true; - var firstWrite = this.#firstWrite; - this.#firstWrite = undefined; - this._reply( - new Response( - new ReadableStream({ - type: "direct", - pull: controller => { - this.#controller = controller; - if (firstWrite) controller.write(firstWrite); - firstWrite = undefined; - run(controller); - if (!this.#finished) { - return new Promise(resolve => { - this.#deferred = resolve; - }); - } - }, - }), - { - headers: this.#headers, - status: this.statusCode, - statusText: this.statusMessage ?? STATUS_CODES[this.statusCode], - }, - ), - ); - } - - _final(callback) { - if (!this.headersSent) { - var data = this.#firstWrite || ""; - this.#firstWrite = undefined; - this.#finished = true; - this._reply( - new Response(data, { - headers: this.#headers, - status: this.statusCode, - statusText: this.statusMessage ?? STATUS_CODES[this.statusCode], - }), - ); - callback && callback(); - return; - } - - this.#finished = true; - this.#ensureReadableStreamController(controller => { - controller.end(); - - callback(); - var deferred = this.#deferred; - if (deferred) { - this.#deferred = undefined; - deferred(); - } - }); - } - - writeProcessing() { - throw new Error("not implemented"); - } - - addTrailers(headers) { - throw new Error("not implemented"); - } - - assignSocket(socket) { - throw new Error("not implemented"); - } - - detachSocket(socket) { - throw new Error("not implemented"); - } - - writeContinue(callback) { - throw new Error("not implemented"); - } - - setTimeout(msecs, callback) { - throw new Error("not implemented"); - } - - get shouldKeepAlive() { - return true; - } - - get chunkedEncoding() { - return false; - } - - set chunkedEncoding(value) { - // throw new Error('not implemented'); - } - - set shouldKeepAlive(value) { - // throw new Error('not implemented'); - } - - get useChunkedEncodingByDefault() { - return true; - } - - set useChunkedEncodingByDefault(value) { - // throw new Error('not implemented'); - } - - appendHeader(name, value) { - var headers = (this.#headers ??= new Headers()); - headers.append(name, value); - } - - flushHeaders() {} - - getHeader(name) { - return getHeader(this.#headers, name); - } - - getHeaders() { - var headers = this.#headers; - if (!headers) return kEmptyObject; - return headers.toJSON(); - } - - getHeaderNames() { - var headers = this.#headers; - if (!headers) return []; - return Array.from(headers.keys()); - } - - removeHeader(name) { - if (!this.#headers) return; - this.#headers.delete(name); - } - - setHeader(name, value) { - var headers = (this.#headers ??= new Headers()); - headers.set(name, value); - return this; - } - - hasHeader(name) { - if (!this.#headers) return false; - return this.#headers.has(name); - } - - writeHead(statusCode, statusMessage, headers) { - _writeHead(statusCode, statusMessage, headers, this); - - return this; - } -} - -export class ClientRequest extends OutgoingMessage { - #timeout; - #res = null; - #upgradeOrConnect = false; - #parser = null; - #maxHeadersCount = null; - #reusedSocket = false; - #host; - #protocol; - #method; - #port; - #useDefaultPort; - #joinDuplicateHeaders; - #maxHeaderSize; - #agent = _globalAgent; - #path; - #socketPath; - - #body = null; - #fetchRequest; - #signal = null; - [kAbortController] = null; - #timeoutTimer = null; - #options; - #finished; - - get path() { - return this.#path; - } - - get port() { - return this.#port; - } - - get method() { - return this.#method; - } - - get host() { - return this.#host; - } - - get protocol() { - return this.#protocol; - } - - _write(chunk, encoding, callback) { - var body = this.#body; - if (!body) { - this.#body = chunk; - callback(); - return; - } - this.#body = body + chunk; - callback(); - } - - _writev(chunks, callback) { - var body = this.#body; - if (!body) { - this.#body = chunks.join(); - callback(); - return; - } - this.#body = body + chunks.join(); - callback(); - } - - _final(callback) { - this.#finished = true; - this[kAbortController] = new AbortController(); - this[kAbortController].signal.addEventListener("abort", () => { - this[kClearTimeout](); - }); - if (this.#signal?.aborted) { - this[kAbortController].abort(); - } - - var method = this.#method, - body = this.#body; - - try { - this.#fetchRequest = fetch( - `${this.#protocol}//${this.#host}${this.#useDefaultPort ? "" : ":" + this.#port}${this.#path}`, - { - method, - headers: this.getHeaders(), - body: body && method !== "GET" && method !== "HEAD" && method !== "OPTIONS" ? body : undefined, - redirect: "manual", - verbose: Boolean(__DEBUG__), - signal: this[kAbortController].signal, - }, - ) - .then(response => { - var res = (this.#res = new IncomingMessage(response, { - type: "response", - [kInternalRequest]: this, - })); - this.emit("response", res); - }) - .catch(err => { - if (__DEBUG__) globalReportError(err); - this.emit("error", err); - }) - .finally(() => { - this.#fetchRequest = null; - this[kClearTimeout](); - }); - } catch (err) { - if (__DEBUG__) globalReportError(err); - this.emit("error", err); - } finally { - callback(); - } - } - - get aborted() { - return this.#signal?.aborted || !!this[kAbortController]?.signal.aborted; - } - - abort() { - if (this.aborted) return; - this[kAbortController].abort(); - // TODO: Close stream if body streaming - } - - constructor(input, options, cb) { - super(); - - if (typeof input === "string") { - const urlStr = input; - try { - var urlObject = new URL(urlStr); - } catch (e) { - throw new TypeError(`Invalid URL: ${urlStr}`); - } - input = urlToHttpOptions(urlObject); - } else if (input && typeof input === "object" && input instanceof URL) { - // url.URL instance - input = urlToHttpOptions(input); - } else { - cb = options; - options = input; - input = null; - } - - if (typeof options === "function") { - cb = options; - options = input || kEmptyObject; - } else { - options = ObjectAssign(input || {}, options); - } - - var defaultAgent = options._defaultAgent || Agent.globalAgent; - - let protocol = options.protocol; - if (!protocol) { - if (options.port === 443) { - protocol = "https:"; - } else { - protocol = defaultAgent.protocol || "http:"; - } - this.#protocol = protocol; - } - - switch (this.#agent?.protocol) { - case undefined: { - break; - } - case "http:": { - if (protocol === "https:") { - defaultAgent = this.#agent = getDefaultHTTPSAgent(); - break; - } - } - case "https:": { - if (protocol === "https") { - defaultAgent = this.#agent = Agent.globalAgent; - break; - } - } - default: { - break; - } - } - - if (options.path) { - const path = String(options.path); - if (RegExpPrototypeExec.call(INVALID_PATH_REGEX, path) !== null) { - debug('Path contains unescaped characters: "%s"', path); - throw new Error("Path contains unescaped characters"); - // throw new ERR_UNESCAPED_CHARACTERS("Request path"); - } - } - - // Since we don't implement Agent, we don't need this - if (protocol !== "http:" && protocol !== "https:" && protocol) { - const expectedProtocol = defaultAgent?.protocol ?? "http:"; - throw new Error(`Protocol mismatch. Expected: ${expectedProtocol}. Got: ${protocol}`); - // throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol); - } - - const defaultPort = protocol === "https:" ? 443 : 80; - - this.#port = options.port || options.defaultPort || this.#agent?.defaultPort || defaultPort; - this.#useDefaultPort = this.#port === defaultPort; - const host = - (this.#host = - options.host = - validateHost(options.hostname, "hostname") || validateHost(options.host, "host") || "localhost"); - - // const setHost = options.setHost === undefined || Boolean(options.setHost); - - this.#socketPath = options.socketPath; - - if (options.timeout !== undefined) this.setTimeout(options.timeout, null); - - const signal = options.signal; - if (signal) { - //We still want to control abort function and timeout so signal call our AbortController - signal.addEventListener("abort", () => { - this[kAbortController]?.abort(); - }); - this.#signal = signal; - } - let method = options.method; - const methodIsString = typeof method === "string"; - if (method !== null && method !== undefined && !methodIsString) { - // throw new ERR_INVALID_ARG_TYPE("options.method", "string", method); - throw new Error("ERR_INVALID_ARG_TYPE: options.method"); - } - - if (methodIsString && method) { - if (!checkIsHttpToken(method)) { - // throw new ERR_INVALID_HTTP_TOKEN("Method", method); - throw new Error("ERR_INVALID_HTTP_TOKEN: Method"); - } - method = this.#method = StringPrototypeToUpperCase.call(method); - } else { - method = this.#method = "GET"; - } - - const _maxHeaderSize = options.maxHeaderSize; - // TODO: Validators - // if (maxHeaderSize !== undefined) - // validateInteger(maxHeaderSize, "maxHeaderSize", 0); - this.#maxHeaderSize = _maxHeaderSize; - - // const insecureHTTPParser = options.insecureHTTPParser; - // if (insecureHTTPParser !== undefined) { - // validateBoolean(insecureHTTPParser, 'options.insecureHTTPParser'); - // } - - // this.insecureHTTPParser = insecureHTTPParser; - var _joinDuplicateHeaders = options.joinDuplicateHeaders; - if (_joinDuplicateHeaders !== undefined) { - // TODO: Validators - // validateBoolean( - // options.joinDuplicateHeaders, - // "options.joinDuplicateHeaders", - // ); - } - - this.#joinDuplicateHeaders = _joinDuplicateHeaders; - - this.#path = options.path || "/"; - if (cb) { - this.once("response", cb); - } - - __DEBUG__ && - debug(`new ClientRequest: ${this.#method} ${this.#protocol}//${this.#host}:${this.#port}${this.#path}`); - - // if ( - // method === "GET" || - // method === "HEAD" || - // method === "DELETE" || - // method === "OPTIONS" || - // method === "TRACE" || - // method === "CONNECT" - // ) { - // this.useChunkedEncodingByDefault = false; - // } else { - // this.useChunkedEncodingByDefault = true; - // } - - this.#finished = false; - this.#res = null; - this.#upgradeOrConnect = false; - this.#parser = null; - this.#maxHeadersCount = null; - this.#reusedSocket = false; - this.#host = host; - this.#protocol = protocol; - this.#timeoutTimer = null; - const headersArray = ArrayIsArray(headers); - if (!headersArray) { - var headers = options.headers; - if (headers) { - for (let key in headers) { - this.setHeader(key, headers[key]); - } - } - - // if (host && !this.getHeader("host") && setHost) { - // let hostHeader = host; - - // // For the Host header, ensure that IPv6 addresses are enclosed - // // in square brackets, as defined by URI formatting - // // https://tools.ietf.org/html/rfc3986#section-3.2.2 - // const posColon = StringPrototypeIndexOf.call(hostHeader, ":"); - // if ( - // posColon !== -1 && - // StringPrototypeIncludes(hostHeader, ":", posColon + 1) && - // StringPrototypeCharCodeAt(hostHeader, 0) !== 91 /* '[' */ - // ) { - // hostHeader = `[${hostHeader}]`; - // } - - // if (port && +port !== defaultPort) { - // hostHeader += ":" + port; - // } - // this.setHeader("Host", hostHeader); - // } - - var auth = options.auth; - if (auth && !this.getHeader("Authorization")) { - this.setHeader("Authorization", "Basic " + Buffer.from(auth).toString("base64")); - } - - // if (this.getHeader("expect")) { - // if (this._header) { - // throw new ERR_HTTP_HEADERS_SENT("render"); - // } - - // this._storeHeader( - // this.method + " " + this.path + " HTTP/1.1\r\n", - // this[kOutHeaders], - // ); - // } - // } else { - // this._storeHeader( - // this.method + " " + this.path + " HTTP/1.1\r\n", - // options.headers, - // ); - } - - // this[kUniqueHeaders] = parseUniqueHeadersOption(options.uniqueHeaders); - - var optsWithoutSignal = options; - if (optsWithoutSignal.signal) { - optsWithoutSignal = ObjectAssign({}, options); - delete optsWithoutSignal.signal; - } - this.#options = optsWithoutSignal; - - var timeout = options.timeout; - if (timeout) { - this.setTimeout(timeout); - } - } - - setSocketKeepAlive(enable = true, initialDelay = 0) { - __DEBUG__ && debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setSocketKeepAlive is a no-op"); - } - - setNoDelay(noDelay = true) { - __DEBUG__ && debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setNoDelay is a no-op"); - } - [kClearTimeout]() { - if (this.#timeoutTimer) { - clearTimeout(this.#timeoutTimer); - this.#timeoutTimer = null; - } - } - - setTimeout(msecs, callback) { - if (this.#timeoutTimer) return this; - if (callback) { - this.on("timeout", callback); - } - - this.#timeoutTimer = setTimeout(async () => { - this.#timeoutTimer = null; - this[kAbortController]?.abort(); - this.emit("timeout"); - }, msecs); - - return this; - } -} - -function urlToHttpOptions(url) { - var { protocol, hostname, hash, search, pathname, href, port, username, password } = url; - return { - protocol, - hostname: - typeof hostname === "string" && StringPrototypeStartsWith.call(hostname, "[") - ? StringPrototypeSlice.call(hostname, 1, -1) - : hostname, - hash, - search, - pathname, - path: `${pathname || ""}${search || ""}`, - href, - port: port ? Number(port) : protocol === "https:" ? 443 : protocol === "http:" ? 80 : undefined, - auth: username || password ? `${decodeURIComponent(username)}:${decodeURIComponent(password)}` : undefined, - }; -} - -function validateHost(host, name) { - if (host !== null && host !== undefined && typeof host !== "string") { - // throw new ERR_INVALID_ARG_TYPE( - // `options.${name}`, - // ["string", "undefined", "null"], - // host, - // ); - throw new Error("Invalid arg type in options"); - } - return host; -} - -const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/; -/** - * Verifies that the given val is a valid HTTP token - * per the rules defined in RFC 7230 - * See https://tools.ietf.org/html/rfc7230#section-3.2.6 - */ -function checkIsHttpToken(val) { - return RegExpPrototypeExec.call(tokenRegExp, val) !== null; -} - -// 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. - -export const METHODS = [ - "ACL", - "BIND", - "CHECKOUT", - "CONNECT", - "COPY", - "DELETE", - "GET", - "HEAD", - "LINK", - "LOCK", - "M-SEARCH", - "MERGE", - "MKACTIVITY", - "MKCALENDAR", - "MKCOL", - "MOVE", - "NOTIFY", - "OPTIONS", - "PATCH", - "POST", - "PROPFIND", - "PROPPATCH", - "PURGE", - "PUT", - "REBIND", - "REPORT", - "SEARCH", - "SOURCE", - "SUBSCRIBE", - "TRACE", - "UNBIND", - "UNLINK", - "UNLOCK", - "UNSUBSCRIBE", -]; - -export const STATUS_CODES = { - 100: "Continue", - 101: "Switching Protocols", - 102: "Processing", - 103: "Early Hints", - 200: "OK", - 201: "Created", - 202: "Accepted", - 203: "Non-Authoritative Information", - 204: "No Content", - 205: "Reset Content", - 206: "Partial Content", - 207: "Multi-Status", - 208: "Already Reported", - 226: "IM Used", - 300: "Multiple Choices", - 301: "Moved Permanently", - 302: "Found", - 303: "See Other", - 304: "Not Modified", - 305: "Use Proxy", - 307: "Temporary Redirect", - 308: "Permanent Redirect", - 400: "Bad Request", - 401: "Unauthorized", - 402: "Payment Required", - 403: "Forbidden", - 404: "Not Found", - 405: "Method Not Allowed", - 406: "Not Acceptable", - 407: "Proxy Authentication Required", - 408: "Request Timeout", - 409: "Conflict", - 410: "Gone", - 411: "Length Required", - 412: "Precondition Failed", - 413: "Payload Too Large", - 414: "URI Too Long", - 415: "Unsupported Media Type", - 416: "Range Not Satisfiable", - 417: "Expectation Failed", - 418: "I'm a Teapot", - 421: "Misdirected Request", - 422: "Unprocessable Entity", - 423: "Locked", - 424: "Failed Dependency", - 425: "Too Early", - 426: "Upgrade Required", - 428: "Precondition Required", - 429: "Too Many Requests", - 431: "Request Header Fields Too Large", - 451: "Unavailable For Legal Reasons", - 500: "Internal Server Error", - 501: "Not Implemented", - 502: "Bad Gateway", - 503: "Service Unavailable", - 504: "Gateway Timeout", - 505: "HTTP Version Not Supported", - 506: "Variant Also Negotiates", - 507: "Insufficient Storage", - 508: "Loop Detected", - 509: "Bandwidth Limit Exceeded", - 510: "Not Extended", - 511: "Network Authentication Required", -}; - -function _normalizeArgs(args) { - let arr; - - if (args.length === 0) { - arr = [{}, null]; - // arr[normalizedArgsSymbol] = true; - return arr; - } - - const arg0 = args[0]; - let options = {}; - if (typeof arg0 === "object" && arg0 !== null) { - // (options[...][, cb]) - options = arg0; - // } else if (isPipeName(arg0)) { - // (path[...][, cb]) - // options.path = arg0; - } else { - // ([port][, host][...][, cb]) - options.port = arg0; - if (args.length > 1 && typeof args[1] === "string") { - options.host = args[1]; - } - } - - const cb = args[args.length - 1]; - if (typeof cb !== "function") arr = [options, null]; - else arr = [options, cb]; - - // arr[normalizedArgsSymbol] = true; - return arr; -} - -function _writeHead(statusCode, reason, obj, response) { - statusCode |= 0; - if (statusCode < 100 || statusCode > 999) { - throw new Error("status code must be between 100 and 999"); - } - - if (typeof reason === "string") { - // writeHead(statusCode, reasonPhrase[, headers]) - response.statusMessage = reason; - } else { - // writeHead(statusCode[, headers]) - if (!response.statusMessage) response.statusMessage = STATUS_CODES[statusCode] || "unknown"; - obj = reason; - } - response.statusCode = statusCode; - - { - // Slow-case: when progressive API and header fields are passed. - let k; - if (Array.isArray(obj)) { - if (obj.length % 2 !== 0) { - throw new Error("raw headers must have an even number of elements"); - } - - for (let n = 0; n < obj.length; n += 2) { - k = obj[n + 0]; - if (k) response.setHeader(k, obj[n + 1]); - } - } else if (obj) { - const keys = Object.keys(obj); - // Retain for(;;) loop for performance reasons - // Refs: https://github.com/nodejs/node/pull/30958 - for (let i = 0; i < keys.length; i++) { - k = keys[i]; - if (k) response.setHeader(k, obj[k]); - } - } - } -} - -/** - * Makes an HTTP request. - * @param {string | URL} url - * @param {HTTPRequestOptions} [options] - * @param {Function} [cb] - * @returns {ClientRequest} - */ -export function request(url, options, cb) { - return new ClientRequest(url, options, cb); -} - -/** - * Makes a `GET` HTTP request. - * @param {string | URL} url - * @param {HTTPRequestOptions} [options] - * @param {Function} [cb] - * @returns {ClientRequest} - */ -export function get(url, options, cb) { - const req = request(url, options, cb); - req.end(); - return req; -} -_globalAgent ??= new Agent(); -var defaultObject = { - Agent, - Server, - METHODS, - STATUS_CODES, - createServer, - ServerResponse, - IncomingMessage, - request, - get, - maxHeaderSize: 16384, - // validateHeaderName, - // validateHeaderValue, - setMaxIdleHTTPParsers(max) { - debug(`${NODE_HTTP_WARNING}\n`, "setMaxIdleHTTPParsers() is a no-op"); - }, - get globalAgent() { - return _globalAgent; - }, - set globalAgent(agent) {}, - [Symbol.for("CommonJS")]: 0, -}; - -export default defaultObject; - -export { _globalAgent as globalAgent }; diff --git a/src/js/node/http.ts b/src/js/node/http.ts new file mode 100644 index 000000000..5f21a791c --- /dev/null +++ b/src/js/node/http.ts @@ -0,0 +1,1810 @@ +// Hardcoded module "node:http" +import { EventEmitter } from "node:events"; +import { Readable, Writable, Duplex } from "node:stream"; +import { isTypedArray } from "util/types"; + +const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/; +/** + * True if val contains an invalid field-vchar + * field-value = *( field-content / obs-fold ) + * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] + * field-vchar = VCHAR / obs-text + */ +function checkInvalidHeaderChar(val: string) { + return RegExpPrototypeExec.call(headerCharRegex, val) !== null; +} + +export const validateHeaderName = (name, label) => { + if (typeof name !== "string" || !name || !checkIsHttpToken(name)) { + // throw new ERR_INVALID_HTTP_TOKEN(label || "Header name", name); + throw new Error("ERR_INVALID_HTTP_TOKEN"); + } +}; + +export const validateHeaderValue = (name, value) => { + if (value === undefined) { + // throw new ERR_HTTP_INVALID_HEADER_VALUE(value, name); + throw new Error("ERR_HTTP_INVALID_HEADER_VALUE"); + } + if (checkInvalidHeaderChar(value)) { + // throw new ERR_INVALID_CHAR("header content", name); + throw new Error("ERR_INVALID_CHAR"); + } +}; + +// 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; +const fetch = Bun.fetch; +const nop = () => {}; + +const __DEBUG__ = process.env.__DEBUG__; +const debug = __DEBUG__ ? (...args) => console.log("node:http", ...args) : nop; + +const kEmptyObject = Object.freeze(Object.create(null)); +const kOutHeaders = Symbol.for("kOutHeaders"); +const kEndCalled = Symbol.for("kEndCalled"); +const kAbortController = Symbol.for("kAbortController"); +const kClearTimeout = Symbol("kClearTimeout"); + +const kCorked = Symbol.for("kCorked"); +const searchParamsSymbol = Symbol.for("query"); // This is the symbol used in Node + +// Primordials +const StringPrototypeSlice = String.prototype.slice; +const StringPrototypeStartsWith = String.prototype.startsWith; +const StringPrototypeToUpperCase = String.prototype.toUpperCase; +const StringPrototypeIncludes = String.prototype.includes; +const StringPrototypeCharCodeAt = String.prototype.charCodeAt; +const StringPrototypeIndexOf = String.prototype.indexOf; +const ArrayIsArray = Array.isArray; +const RegExpPrototypeExec = RegExp.prototype.exec; +const ObjectAssign = Object.assign; +const ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty; + +const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/; +const NODE_HTTP_WARNING = + "WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause."; + +var _defaultHTTPSAgent; +var kInternalRequest = Symbol("kInternalRequest"); +var kInternalSocketData = Symbol.for("::bunternal::"); + +const kEmptyBuffer = Buffer.alloc(0); + +function isValidTLSArray(obj) { + if (typeof obj === "string" || isTypedArray(obj) || obj instanceof ArrayBuffer || obj instanceof Blob) return true; + if (Array.isArray(obj)) { + for (var i = 0; i < obj.length; i++) { + if (typeof obj !== "string" && !isTypedArray(obj) && !(obj instanceof ArrayBuffer) && !(obj instanceof Blob)) + return false; + } + return true; + } +} + +function getHeader(headers, name) { + if (!headers) return; + const result = headers.get(name); + return result == null ? undefined : result; +} + +type FakeSocket = InstanceType; +var FakeSocket = class Socket extends Duplex { + bytesRead = 0; + bytesWritten = 0; + connecting = false; + remoteAddress: string | null = null; + remotePort; + timeout = 0; + + isServer = false; + + address() { + return { + address: this.localAddress, + family: this.localFamily, + port: this.localPort, + }; + } + + get bufferSize() { + return this.writableLength; + } + + connect(port, host, connectListener) { + return this; + } + + _destroy(err, callback) {} + + _final(callback) {} + + get localAddress() { + return "127.0.0.1"; + } + + get localFamily() { + return "IPv4"; + } + + get localPort() { + return 80; + } + + get pending() { + return this.connecting; + } + + _read(size) {} + + get readyState() { + if (this.connecting) return "opening"; + if (this.readable) { + return this.writable ? "open" : "readOnly"; + } else { + return this.writable ? "writeOnly" : "closed"; + } + } + + ref() {} + + get remoteFamily() { + return "IPv4"; + } + + resetAndDestroy() {} + + setKeepAlive(enable = false, initialDelay = 0) {} + + setNoDelay(noDelay = true) { + return this; + } + + setTimeout(timeout, callback) { + return this; + } + + unref() {} + + _write(chunk, encoding, callback) {} +}; + +export function createServer(options, callback) { + return new Server(options, callback); +} + +export class Agent extends EventEmitter { + defaultPort = 80; + protocol = "http:"; + options; + requests; + sockets; + freeSockets; + + keepAliveMsecs; + keepAlive; + maxSockets; + maxFreeSockets; + scheduling; + maxTotalSockets; + totalSocketCount; + + #fakeSocket; + + static get globalAgent() { + return globalAgent; + } + + static get defaultMaxSockets() { + return Infinity; + } + + constructor(options = kEmptyObject) { + super(); + this.options = options = { ...options, path: null }; + if (options.noDelay === undefined) options.noDelay = true; + + // Don't confuse net and make it think that we're connecting to a pipe + this.requests = kEmptyObject; + this.sockets = kEmptyObject; + this.freeSockets = kEmptyObject; + + this.keepAliveMsecs = options.keepAliveMsecs || 1000; + this.keepAlive = options.keepAlive || false; + this.maxSockets = options.maxSockets || Agent.defaultMaxSockets; + this.maxFreeSockets = options.maxFreeSockets || 256; + this.scheduling = options.scheduling || "lifo"; + this.maxTotalSockets = options.maxTotalSockets; + this.totalSocketCount = 0; + this.defaultPort = options.defaultPort || 80; + this.protocol = options.protocol || "http:"; + } + + createConnection() { + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createConnection is a no-op, returns fake socket"); + return (this.#fakeSocket ??= new FakeSocket()); + } + + getName(options = kEmptyObject) { + let name = `http:${options.host || "localhost"}:`; + if (options.port) name += options.port; + name += ":"; + if (options.localAddress) name += options.localAddress; + // Pacify parallel/test-http-agent-getname by only appending + // the ':' when options.family is set. + if (options.family === 4 || options.family === 6) name += `:${options.family}`; + if (options.socketPath) name += `:${options.socketPath}`; + return name; + } + + addRequest() { + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.addRequest is a no-op"); + } + + createSocket(req, options, cb) { + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createSocket returns fake socket"); + cb(null, (this.#fakeSocket ??= new FakeSocket())); + } + + removeSocket() { + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.removeSocket is a no-op"); + } + + keepSocketAlive() { + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.keepSocketAlive is a no-op"); + + return true; + } + + reuseSocket() { + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.reuseSocket is a no-op"); + } + + destroy() { + debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.destroy is a no-op"); + } +} +function emitListeningNextTick(self, onListen, err, hostname, port) { + if (typeof onListen === "function") { + try { + onListen(err, hostname, port); + } catch (err) { + self.emit("error", err); + } + } + + self.listening = !err; + + if (err) { + self.emit("error", err); + } else { + self.emit("listening", hostname, port); + } +} + +export class Server extends EventEmitter { + #server; + #options; + #tls; + #is_tls = false; + listening = false; + serverName; + + constructor(options, callback) { + super(); + + if (typeof options === "function") { + callback = options; + options = {}; + } else if (options == null || typeof options === "object") { + options = { ...options }; + this.#tls = null; + let key = options.key; + if (key) { + if (!isValidTLSArray(key)) { + throw new TypeError( + "key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", + ); + } + this.#is_tls = true; + } + let cert = options.cert; + if (cert) { + if (!isValidTLSArray(cert)) { + throw new TypeError( + "cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", + ); + } + this.#is_tls = true; + } + + let ca = options.ca; + if (ca) { + if (!isValidTLSArray(ca)) { + throw new TypeError( + "ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", + ); + } + this.#is_tls = true; + } + let passphrase = options.passphrase; + if (passphrase && typeof passphrase !== "string") { + throw new TypeError("passphrase argument must be an string"); + } + + let serverName = options.servername; + if (serverName && typeof serverName !== "string") { + throw new TypeError("servername argument must be an string"); + } + + let secureOptions = options.secureOptions || 0; + if (secureOptions && typeof secureOptions !== "number") { + throw new TypeError("secureOptions argument must be an number"); + } + + if (this.#is_tls) { + this.#tls = { + serverName, + key: key, + cert: cert, + ca: ca, + passphrase: passphrase, + secureOptions: secureOptions, + }; + } else { + this.#tls = null; + } + } else { + throw new Error("bun-http-polyfill: invalid arguments"); + } + + this.#options = options; + + if (callback) this.on("request", callback); + } + + closeAllConnections() { + const server = this.#server; + if (!server) { + return; + } + this.#server = undefined; + server.stop(true); + this.emit("close"); + } + + closeIdleConnections() { + // not actually implemented + } + + close(optionalCallback?) { + const server = this.#server; + if (!server) { + if (typeof optionalCallback === "function") + process.nextTick(optionalCallback, new Error("Server is not running")); + return; + } + this.#server = undefined; + if (typeof optionalCallback === "function") this.once("close", optionalCallback); + server.stop(); + this.emit("close"); + } + + address() { + if (!this.#server) return null; + + const address = this.#server.hostname; + return { + address, + family: isIPv6(address) ? "IPv6" : "IPv4", + port: this.#server.port, + }; + } + + listen(port, host, backlog, onListen) { + const server = this; + if (typeof host === "function") { + onListen = host; + host = undefined; + } + + if (typeof port === "function") { + onListen = port; + } else if (typeof port === "object") { + port?.signal?.addEventListener("abort", () => { + this.close(); + }); + + host = port?.host; + port = port?.port; + + if (typeof port?.callback === "function") onListen = port?.callback; + } + + if (typeof backlog === "function") { + onListen = backlog; + } + + const ResponseClass = this.#options.ServerResponse || ServerResponse; + const RequestClass = this.#options.IncomingMessage || IncomingMessage; + + try { + const tls = this.#tls; + if (tls) { + this.serverName = tls.serverName || host || "localhost"; + } + this.#server = Bun.serve({ + tls, + port, + hostname: host, + // Bindings to be used for WS Server + websocket: { + open(ws) { + ws.data.open(ws); + }, + message(ws, message) { + ws.data.message(ws, message); + }, + close(ws, code, reason) { + ws.data.close(ws, code, reason); + }, + drain(ws) { + ws.data.drain(ws); + }, + }, + fetch(req, _server) { + var pendingResponse; + var pendingError; + var rejectFunction, resolveFunction; + var reject = err => { + if (pendingError) return; + pendingError = err; + if (rejectFunction) rejectFunction(err); + }; + + var reply = function (resp) { + if (pendingResponse) return; + pendingResponse = resp; + if (resolveFunction) resolveFunction(resp); + }; + + const http_req = new RequestClass(req); + const http_res = new ResponseClass({ reply, req: http_req }); + + http_req.once("error", err => reject(err)); + http_res.once("error", err => reject(err)); + + const upgrade = req.headers.get("upgrade"); + if (upgrade) { + const socket = new FakeSocket(); + socket[kInternalSocketData] = [_server, http_res, req]; + server.emit("upgrade", http_req, socket, kEmptyBuffer); + } else { + server.emit("request", http_req, http_res); + } + + if (pendingError) { + throw pendingError; + } + + if (pendingResponse) { + return pendingResponse; + } + + return new Promise((resolve, reject) => { + resolveFunction = resolve; + rejectFunction = reject; + }); + }, + }); + setTimeout(emitListeningNextTick, 1, this, onListen, null, this.#server.hostname, this.#server.port); + } catch (err) { + setTimeout(emitListeningNextTick, 1, this, onListen, err); + } + + return this; + } + setTimeout(msecs, callback) {} +} + +function assignHeaders(object, req) { + var headers = req.headers.toJSON(); + const rawHeaders = newArrayWithSize(req.headers.count * 2); + var i = 0; + for (const key in headers) { + rawHeaders[i++] = key; + rawHeaders[i++] = headers[key]; + } + object.headers = headers; + object.rawHeaders = rawHeaders; +} +function destroyBodyStreamNT(bodyStream) { + bodyStream.destroy(); +} + +var defaultIncomingOpts = { type: "request" }; + +function getDefaultHTTPSAgent() { + return (_defaultHTTPSAgent ??= new Agent({ defaultPort: 443, protocol: "https:" })); +} + +export class IncomingMessage extends Readable { + method: string; + complete: boolean; + + constructor(req, defaultIncomingOpts) { + const method = req.method; + + super(); + + const url = new URL(req.url); + + var { type = "request", [kInternalRequest]: nodeReq } = defaultIncomingOpts || {}; + + this.#noBody = + type === "request" // TODO: Add logic for checking for body on response + ? "GET" === method || + "HEAD" === method || + "TRACE" === method || + "CONNECT" === method || + "OPTIONS" === method || + (parseInt(req.headers.get("Content-Length") || "") || 0) === 0 + : false; + + this.#req = req; + this.method = method; + this.#type = type; + this.complete = !!this.#noBody; + + this.#bodyStream = undefined; + const socket = new FakeSocket(); + socket.remoteAddress = url.hostname; + socket.remotePort = url.port; + this.#fakeSocket = socket; + + this.url = url.pathname + url.search; + this.#nodeReq = nodeReq; + assignHeaders(this, req); + } + + headers; + rawHeaders; + _consuming = false; + _dumped = false; + #bodyStream: ReadableStreamDefaultReader | undefined; + #fakeSocket: FakeSocket | undefined; + #noBody = false; + #aborted = false; + #req; + url; + #type; + #nodeReq; + + get req() { + return this.#nodeReq; + } + + _construct(callback) { + // TODO: streaming + if (this.#type === "response" || this.#noBody) { + callback(); + return; + } + + const contentLength = this.#req.headers.get("content-length"); + const length = contentLength ? parseInt(contentLength, 10) : 0; + if (length === 0) { + this.#noBody = true; + callback(); + return; + } + + callback(); + } + + async #consumeStream(reader: ReadableStreamDefaultReader) { + while (true) { + var { done, value } = await reader.readMany(); + if (this.#aborted) return; + if (done) { + this.push(null); + this.destroy(); + break; + } + for (var v of value) { + this.push(v); + } + } + } + + _read(size) { + if (this.#noBody) { + this.push(null); + this.complete = true; + } else if (this.#bodyStream == null) { + const reader = this.#req.body?.getReader() as ReadableStreamDefaultReader; + if (!reader) { + this.push(null); + return; + } + this.#bodyStream = reader; + this.#consumeStream(reader); + } + } + + get aborted() { + return this.#aborted; + } + + #abort() { + if (this.#aborted) return; + this.#aborted = true; + var bodyStream = this.#bodyStream; + if (!bodyStream) return; + bodyStream.cancel(); + this.complete = true; + this.#bodyStream = undefined; + this.push(null); + } + + get connection() { + return this.#fakeSocket; + } + + get statusCode() { + return this.#req.status; + } + + get statusMessage() { + return STATUS_CODES[this.#req.status]; + } + + get httpVersion() { + return "1.1"; + } + + get rawTrailers() { + return []; + } + + get httpVersionMajor() { + return 1; + } + + get httpVersionMinor() { + return 1; + } + + get trailers() { + return kEmptyObject; + } + + get socket() { + return (this.#fakeSocket ??= new FakeSocket()); + } + + set socket(val) { + this.#fakeSocket = val; + } + + setTimeout(msecs, callback) { + throw new Error("not implemented"); + } +} + +function emitErrorNt(msg, err, callback) { + callback(err); + if (typeof msg.emit === "function" && !msg._closed) { + msg.emit("error", err); + } +} + +function onError(self, err, cb) { + process.nextTick(() => emitErrorNt(self, err, cb)); +} + +function write_(msg, chunk, encoding, callback, fromEnd) { + if (typeof callback !== "function") callback = nop; + + let len; + if (chunk === null) { + // throw new ERR_STREAM_NULL_VALUES(); + throw new Error("ERR_STREAM_NULL_VALUES"); + } else if (typeof chunk === "string") { + len = Buffer.byteLength(chunk, encoding); + } else { + throw new Error("Invalid arg type for chunk"); + // throw new ERR_INVALID_ARG_TYPE( + // "chunk", + // ["string", "Buffer", "Uint8Array"], + // chunk, + // ); + } + + let err; + if (msg.finished) { + // err = new ERR_STREAM_WRITE_AFTER_END(); + err = new Error("ERR_STREAM_WRITE_AFTER_END"); + } else if (msg.destroyed) { + // err = new ERR_STREAM_DESTROYED("write"); + err = new Error("ERR_STREAM_DESTROYED"); + } + + if (err) { + if (!msg.destroyed) { + onError(msg, err, callback); + } else { + process.nextTick(callback, err); + } + return false; + } + + if (!msg._header) { + if (fromEnd) { + msg._contentLength = len; + } + // msg._implicitHeader(); + } + + if (!msg._hasBody) { + debug("This type of response MUST NOT have a body. " + "Ignoring write() calls."); + process.nextTick(callback); + return true; + } + + // if (!fromEnd && msg.socket && !msg.socket.writableCorked) { + // msg.socket.cork(); + // process.nextTick(connectionCorkNT, msg.socket); + // } + + return true; +} + +export class OutgoingMessage extends Writable { + #headers; + headersSent = false; + sendDate = true; + req; + + #finished = false; + [kEndCalled] = false; + + #fakeSocket; + #timeoutTimer: Timer | null = null; + [kAbortController]: AbortController | null = null; + + // Express "compress" package uses this + _implicitHeader() {} + + // For compat with IncomingRequest + get headers() { + if (!this.#headers) return kEmptyObject; + return this.#headers.toJSON(); + } + + get shouldKeepAlive() { + return true; + } + + get chunkedEncoding() { + return false; + } + + set chunkedEncoding(value) { + // throw new Error('not implemented'); + } + + set shouldKeepAlive(value) { + // throw new Error('not implemented'); + } + + get useChunkedEncodingByDefault() { + return true; + } + + set useChunkedEncodingByDefault(value) { + // throw new Error('not implemented'); + } + + get socket() { + return (this.#fakeSocket ??= new FakeSocket()); + } + + set socket(val) { + this.#fakeSocket = val; + } + + get connection() { + return this.socket; + } + + get finished() { + return this.#finished; + } + + appendHeader(name, value) { + var headers = (this.#headers ??= new Headers()); + headers.append(name, value); + } + + flushHeaders() {} + + getHeader(name) { + return getHeader(this.#headers, name); + } + + getHeaders() { + if (!this.#headers) return kEmptyObject; + return this.#headers.toJSON(); + } + + getHeaderNames() { + var headers = this.#headers; + if (!headers) return []; + return Array.from(headers.keys()); + } + + removeHeader(name) { + if (!this.#headers) return; + this.#headers.delete(name); + } + + setHeader(name, value) { + var headers = (this.#headers ??= new Headers()); + headers.set(name, value); + return this; + } + + hasHeader(name) { + if (!this.#headers) return false; + return this.#headers.has(name); + } + + addTrailers(headers) { + throw new Error("not implemented"); + } + + [kClearTimeout]() { + if (this.#timeoutTimer) { + clearTimeout(this.#timeoutTimer); + this.#timeoutTimer = null; + } + } + + setTimeout(msecs, callback) { + if (this.#timeoutTimer) return this; + if (callback) { + this.on("timeout", callback); + } + + this.#timeoutTimer = setTimeout(async () => { + this.#timeoutTimer = null; + this[kAbortController]?.abort(); + this.emit("timeout"); + }, msecs); + + return this; + } +} + +export class ServerResponse extends Writable { + declare _writableState: any; + + constructor({ req, reply }) { + super(); + this.req = req; + this._reply = reply; + this.sendDate = true; + this.statusCode = 200; + this.headersSent = false; + this.statusMessage = undefined; + this.#controller = undefined; + this.#firstWrite = undefined; + this._writableState.decodeStrings = false; + this.#deferred = undefined; + } + + req; + _reply; + sendDate; + statusCode; + #headers; + headersSent = false; + statusMessage; + #controller; + #firstWrite; + _sent100 = false; + _defaultKeepAlive = false; + _removedConnection = false; + _removedContLen = false; + #deferred: (() => void) | undefined = undefined; + #finished = false; + + // Express "compress" package uses this + _implicitHeader() {} + + _write(chunk, encoding, callback) { + if (!this.#firstWrite && !this.headersSent) { + this.#firstWrite = chunk; + callback(); + return; + } + + this.#ensureReadableStreamController(controller => { + controller.write(chunk); + callback(); + }); + } + + _writev(chunks, callback) { + if (chunks.length === 1 && !this.headersSent && !this.#firstWrite) { + this.#firstWrite = chunks[0].chunk; + callback(); + return; + } + + this.#ensureReadableStreamController(controller => { + for (const chunk of chunks) { + controller.write(chunk.chunk); + } + + callback(); + }); + } + + #ensureReadableStreamController(run) { + var thisController = this.#controller; + if (thisController) return run(thisController); + this.headersSent = true; + var firstWrite = this.#firstWrite; + this.#firstWrite = undefined; + this._reply( + new Response( + new ReadableStream({ + type: "direct", + pull: controller => { + this.#controller = controller; + if (firstWrite) controller.write(firstWrite); + firstWrite = undefined; + run(controller); + if (!this.#finished) { + return new Promise(resolve => { + this.#deferred = resolve; + }); + } + }, + }), + { + headers: this.#headers, + status: this.statusCode, + statusText: this.statusMessage ?? STATUS_CODES[this.statusCode], + }, + ), + ); + } + + _final(callback) { + if (!this.headersSent) { + var data = this.#firstWrite || ""; + this.#firstWrite = undefined; + this.#finished = true; + this._reply( + new Response(data, { + headers: this.#headers, + status: this.statusCode, + statusText: this.statusMessage ?? STATUS_CODES[this.statusCode], + }), + ); + callback && callback(); + return; + } + + this.#finished = true; + this.#ensureReadableStreamController(controller => { + controller.end(); + + callback(); + var deferred = this.#deferred; + if (deferred) { + this.#deferred = undefined; + deferred(); + } + }); + } + + writeProcessing() { + throw new Error("not implemented"); + } + + addTrailers(headers) { + throw new Error("not implemented"); + } + + assignSocket(socket) { + throw new Error("not implemented"); + } + + detachSocket(socket) { + throw new Error("not implemented"); + } + + writeContinue(callback) { + throw new Error("not implemented"); + } + + setTimeout(msecs, callback) { + throw new Error("not implemented"); + } + + get shouldKeepAlive() { + return true; + } + + get chunkedEncoding() { + return false; + } + + set chunkedEncoding(value) { + // throw new Error('not implemented'); + } + + set shouldKeepAlive(value) { + // throw new Error('not implemented'); + } + + get useChunkedEncodingByDefault() { + return true; + } + + set useChunkedEncodingByDefault(value) { + // throw new Error('not implemented'); + } + + appendHeader(name, value) { + var headers = (this.#headers ??= new Headers()); + headers.append(name, value); + } + + flushHeaders() {} + + getHeader(name) { + return getHeader(this.#headers, name); + } + + getHeaders() { + var headers = this.#headers; + if (!headers) return kEmptyObject; + return headers.toJSON(); + } + + getHeaderNames() { + var headers = this.#headers; + if (!headers) return []; + return Array.from(headers.keys()); + } + + removeHeader(name) { + if (!this.#headers) return; + this.#headers.delete(name); + } + + setHeader(name, value) { + var headers = (this.#headers ??= new Headers()); + headers.set(name, value); + return this; + } + + hasHeader(name) { + if (!this.#headers) return false; + return this.#headers.has(name); + } + + writeHead(statusCode, statusMessage, headers) { + _writeHead(statusCode, statusMessage, headers, this); + + return this; + } +} + +export class ClientRequest extends OutgoingMessage { + #timeout; + #res: IncomingMessage | null = null; + #upgradeOrConnect = false; + #parser = null; + #maxHeadersCount = null; + #reusedSocket = false; + #host; + #protocol; + #method; + #port; + #useDefaultPort; + #joinDuplicateHeaders; + #maxHeaderSize; + #agent = globalAgent; + #path; + #socketPath; + + #body: string | null = null; + #fetchRequest; + #signal: AbortSignal | null = null; + [kAbortController]: AbortController | null = null; + #timeoutTimer: Timer | null = null; + #options; + #finished; + + get path() { + return this.#path; + } + + get port() { + return this.#port; + } + + get method() { + return this.#method; + } + + get host() { + return this.#host; + } + + get protocol() { + return this.#protocol; + } + + _write(chunk, encoding, callback) { + var body = this.#body; + if (!body) { + this.#body = chunk; + callback(); + return; + } + this.#body = body + chunk; + callback(); + } + + _writev(chunks, callback) { + var body = this.#body; + if (!body) { + this.#body = chunks.join(); + callback(); + return; + } + this.#body = body + chunks.join(); + callback(); + } + + _final(callback) { + this.#finished = true; + this[kAbortController] = new AbortController(); + this[kAbortController].signal.addEventListener("abort", () => { + this[kClearTimeout](); + }); + if (this.#signal?.aborted) { + this[kAbortController].abort(); + } + + var method = this.#method, + body = this.#body; + + try { + this.#fetchRequest = fetch( + `${this.#protocol}//${this.#host}${this.#useDefaultPort ? "" : ":" + this.#port}${this.#path}`, + { + method, + headers: this.getHeaders(), + body: body && method !== "GET" && method !== "HEAD" && method !== "OPTIONS" ? body : undefined, + redirect: "manual", + verbose: Boolean(__DEBUG__), + signal: this[kAbortController].signal, + }, + ) + .then(response => { + var res = (this.#res = new IncomingMessage(response, { + type: "response", + [kInternalRequest]: this, + })); + this.emit("response", res); + }) + .catch(err => { + if (__DEBUG__) globalReportError(err); + this.emit("error", err); + }) + .finally(() => { + this.#fetchRequest = null; + this[kClearTimeout](); + }); + } catch (err) { + if (__DEBUG__) globalReportError(err); + this.emit("error", err); + } finally { + callback(); + } + } + + get aborted() { + return this.#signal?.aborted || !!this[kAbortController]?.signal.aborted; + } + + abort() { + if (this.aborted) return; + this[kAbortController]!.abort(); + // TODO: Close stream if body streaming + } + + constructor(input, options, cb) { + super(); + + if (typeof input === "string") { + const urlStr = input; + try { + var urlObject = new URL(urlStr); + } catch (e) { + throw new TypeError(`Invalid URL: ${urlStr}`); + } + input = urlToHttpOptions(urlObject); + } else if (input && typeof input === "object" && input instanceof URL) { + // url.URL instance + input = urlToHttpOptions(input); + } else { + cb = options; + options = input; + input = null; + } + + if (typeof options === "function") { + cb = options; + options = input || kEmptyObject; + } else { + options = ObjectAssign(input || {}, options); + } + + var defaultAgent = options._defaultAgent || Agent.globalAgent; + + let protocol = options.protocol; + if (!protocol) { + if (options.port === 443) { + protocol = "https:"; + } else { + protocol = defaultAgent.protocol || "http:"; + } + } + this.#protocol = protocol; + + switch (this.#agent?.protocol) { + case undefined: { + break; + } + case "http:": { + if (protocol === "https:") { + defaultAgent = this.#agent = getDefaultHTTPSAgent(); + break; + } + } + case "https:": { + if (protocol === "https") { + defaultAgent = this.#agent = Agent.globalAgent; + break; + } + } + default: { + break; + } + } + + if (options.path) { + const path = String(options.path); + if (RegExpPrototypeExec.call(INVALID_PATH_REGEX, path) !== null) { + debug('Path contains unescaped characters: "%s"', path); + throw new Error("Path contains unescaped characters"); + // throw new ERR_UNESCAPED_CHARACTERS("Request path"); + } + } + + // Since we don't implement Agent, we don't need this + if (protocol !== "http:" && protocol !== "https:" && protocol) { + const expectedProtocol = defaultAgent?.protocol ?? "http:"; + throw new Error(`Protocol mismatch. Expected: ${expectedProtocol}. Got: ${protocol}`); + // throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol); + } + + const defaultPort = protocol === "https:" ? 443 : 80; + + this.#port = options.port || options.defaultPort || this.#agent?.defaultPort || defaultPort; + this.#useDefaultPort = this.#port === defaultPort; + const host = + (this.#host = + options.host = + validateHost(options.hostname, "hostname") || validateHost(options.host, "host") || "localhost"); + + // const setHost = options.setHost === undefined || Boolean(options.setHost); + + this.#socketPath = options.socketPath; + + if (options.timeout !== undefined) this.setTimeout(options.timeout, null); + + const signal = options.signal; + if (signal) { + //We still want to control abort function and timeout so signal call our AbortController + signal.addEventListener("abort", () => { + this[kAbortController]?.abort(); + }); + this.#signal = signal; + } + let method = options.method; + const methodIsString = typeof method === "string"; + if (method !== null && method !== undefined && !methodIsString) { + // throw new ERR_INVALID_ARG_TYPE("options.method", "string", method); + throw new Error("ERR_INVALID_ARG_TYPE: options.method"); + } + + if (methodIsString && method) { + if (!checkIsHttpToken(method)) { + // throw new ERR_INVALID_HTTP_TOKEN("Method", method); + throw new Error("ERR_INVALID_HTTP_TOKEN: Method"); + } + method = this.#method = StringPrototypeToUpperCase.call(method); + } else { + method = this.#method = "GET"; + } + + const _maxHeaderSize = options.maxHeaderSize; + // TODO: Validators + // if (maxHeaderSize !== undefined) + // validateInteger(maxHeaderSize, "maxHeaderSize", 0); + this.#maxHeaderSize = _maxHeaderSize; + + // const insecureHTTPParser = options.insecureHTTPParser; + // if (insecureHTTPParser !== undefined) { + // validateBoolean(insecureHTTPParser, 'options.insecureHTTPParser'); + // } + + // this.insecureHTTPParser = insecureHTTPParser; + var _joinDuplicateHeaders = options.joinDuplicateHeaders; + if (_joinDuplicateHeaders !== undefined) { + // TODO: Validators + // validateBoolean( + // options.joinDuplicateHeaders, + // "options.joinDuplicateHeaders", + // ); + } + + this.#joinDuplicateHeaders = _joinDuplicateHeaders; + + this.#path = options.path || "/"; + if (cb) { + this.once("response", cb); + } + + __DEBUG__ && + debug(`new ClientRequest: ${this.#method} ${this.#protocol}//${this.#host}:${this.#port}${this.#path}`); + + // if ( + // method === "GET" || + // method === "HEAD" || + // method === "DELETE" || + // method === "OPTIONS" || + // method === "TRACE" || + // method === "CONNECT" + // ) { + // this.useChunkedEncodingByDefault = false; + // } else { + // this.useChunkedEncodingByDefault = true; + // } + + this.#finished = false; + this.#res = null; + this.#upgradeOrConnect = false; + this.#parser = null; + this.#maxHeadersCount = null; + this.#reusedSocket = false; + this.#host = host; + this.#protocol = protocol; + this.#timeoutTimer = null; + const headersArray = ArrayIsArray(headers); + if (!headersArray) { + var headers = options.headers; + if (headers) { + for (let key in headers) { + this.setHeader(key, headers[key]); + } + } + + // if (host && !this.getHeader("host") && setHost) { + // let hostHeader = host; + + // // For the Host header, ensure that IPv6 addresses are enclosed + // // in square brackets, as defined by URI formatting + // // https://tools.ietf.org/html/rfc3986#section-3.2.2 + // const posColon = StringPrototypeIndexOf.call(hostHeader, ":"); + // if ( + // posColon !== -1 && + // StringPrototypeIncludes(hostHeader, ":", posColon + 1) && + // StringPrototypeCharCodeAt(hostHeader, 0) !== 91 /* '[' */ + // ) { + // hostHeader = `[${hostHeader}]`; + // } + + // if (port && +port !== defaultPort) { + // hostHeader += ":" + port; + // } + // this.setHeader("Host", hostHeader); + // } + + var auth = options.auth; + if (auth && !this.getHeader("Authorization")) { + this.setHeader("Authorization", "Basic " + Buffer.from(auth).toString("base64")); + } + + // if (this.getHeader("expect")) { + // if (this._header) { + // throw new ERR_HTTP_HEADERS_SENT("render"); + // } + + // this._storeHeader( + // this.method + " " + this.path + " HTTP/1.1\r\n", + // this[kOutHeaders], + // ); + // } + // } else { + // this._storeHeader( + // this.method + " " + this.path + " HTTP/1.1\r\n", + // options.headers, + // ); + } + + // this[kUniqueHeaders] = parseUniqueHeadersOption(options.uniqueHeaders); + + var optsWithoutSignal = options; + if (optsWithoutSignal.signal) { + optsWithoutSignal = ObjectAssign({}, options); + delete optsWithoutSignal.signal; + } + this.#options = optsWithoutSignal; + + var timeout = options.timeout; + if (timeout) { + this.setTimeout(timeout); + } + } + + setSocketKeepAlive(enable = true, initialDelay = 0) { + __DEBUG__ && debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setSocketKeepAlive is a no-op"); + } + + setNoDelay(noDelay = true) { + __DEBUG__ && debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setNoDelay is a no-op"); + } + [kClearTimeout]() { + if (this.#timeoutTimer) { + clearTimeout(this.#timeoutTimer); + this.#timeoutTimer = null; + } + } + + setTimeout(msecs, callback?) { + if (this.#timeoutTimer) return this; + if (callback) { + this.on("timeout", callback); + } + + this.#timeoutTimer = setTimeout(async () => { + this.#timeoutTimer = null; + this[kAbortController]?.abort(); + this.emit("timeout"); + }, msecs); + + return this; + } +} + +function urlToHttpOptions(url) { + var { protocol, hostname, hash, search, pathname, href, port, username, password } = url; + return { + protocol, + hostname: + typeof hostname === "string" && StringPrototypeStartsWith.call(hostname, "[") + ? StringPrototypeSlice.call(hostname, 1, -1) + : hostname, + hash, + search, + pathname, + path: `${pathname || ""}${search || ""}`, + href, + port: port ? Number(port) : protocol === "https:" ? 443 : protocol === "http:" ? 80 : undefined, + auth: username || password ? `${decodeURIComponent(username)}:${decodeURIComponent(password)}` : undefined, + }; +} + +function validateHost(host, name) { + if (host !== null && host !== undefined && typeof host !== "string") { + // throw new ERR_INVALID_ARG_TYPE( + // `options.${name}`, + // ["string", "undefined", "null"], + // host, + // ); + throw new Error("Invalid arg type in options"); + } + return host; +} + +const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/; +/** + * Verifies that the given val is a valid HTTP token + * per the rules defined in RFC 7230 + * See https://tools.ietf.org/html/rfc7230#section-3.2.6 + */ +function checkIsHttpToken(val) { + return RegExpPrototypeExec.call(tokenRegExp, val) !== null; +} + +// 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. + +export const METHODS = [ + "ACL", + "BIND", + "CHECKOUT", + "CONNECT", + "COPY", + "DELETE", + "GET", + "HEAD", + "LINK", + "LOCK", + "M-SEARCH", + "MERGE", + "MKACTIVITY", + "MKCALENDAR", + "MKCOL", + "MOVE", + "NOTIFY", + "OPTIONS", + "PATCH", + "POST", + "PROPFIND", + "PROPPATCH", + "PURGE", + "PUT", + "REBIND", + "REPORT", + "SEARCH", + "SOURCE", + "SUBSCRIBE", + "TRACE", + "UNBIND", + "UNLINK", + "UNLOCK", + "UNSUBSCRIBE", +]; + +export const STATUS_CODES = { + 100: "Continue", + 101: "Switching Protocols", + 102: "Processing", + 103: "Early Hints", + 200: "OK", + 201: "Created", + 202: "Accepted", + 203: "Non-Authoritative Information", + 204: "No Content", + 205: "Reset Content", + 206: "Partial Content", + 207: "Multi-Status", + 208: "Already Reported", + 226: "IM Used", + 300: "Multiple Choices", + 301: "Moved Permanently", + 302: "Found", + 303: "See Other", + 304: "Not Modified", + 305: "Use Proxy", + 307: "Temporary Redirect", + 308: "Permanent Redirect", + 400: "Bad Request", + 401: "Unauthorized", + 402: "Payment Required", + 403: "Forbidden", + 404: "Not Found", + 405: "Method Not Allowed", + 406: "Not Acceptable", + 407: "Proxy Authentication Required", + 408: "Request Timeout", + 409: "Conflict", + 410: "Gone", + 411: "Length Required", + 412: "Precondition Failed", + 413: "Payload Too Large", + 414: "URI Too Long", + 415: "Unsupported Media Type", + 416: "Range Not Satisfiable", + 417: "Expectation Failed", + 418: "I'm a Teapot", + 421: "Misdirected Request", + 422: "Unprocessable Entity", + 423: "Locked", + 424: "Failed Dependency", + 425: "Too Early", + 426: "Upgrade Required", + 428: "Precondition Required", + 429: "Too Many Requests", + 431: "Request Header Fields Too Large", + 451: "Unavailable For Legal Reasons", + 500: "Internal Server Error", + 501: "Not Implemented", + 502: "Bad Gateway", + 503: "Service Unavailable", + 504: "Gateway Timeout", + 505: "HTTP Version Not Supported", + 506: "Variant Also Negotiates", + 507: "Insufficient Storage", + 508: "Loop Detected", + 509: "Bandwidth Limit Exceeded", + 510: "Not Extended", + 511: "Network Authentication Required", +}; + +function _normalizeArgs(args) { + let arr; + + if (args.length === 0) { + arr = [{}, null]; + // arr[normalizedArgsSymbol] = true; + return arr; + } + + const arg0 = args[0]; + let options: any = {}; + if (typeof arg0 === "object" && arg0 !== null) { + // (options[...][, cb]) + options = arg0; + // } else if (isPipeName(arg0)) { + // (path[...][, cb]) + // options.path = arg0; + } else { + // ([port][, host][...][, cb]) + options.port = arg0; + if (args.length > 1 && typeof args[1] === "string") { + options.host = args[1]; + } + } + + const cb = args[args.length - 1]; + if (typeof cb !== "function") arr = [options, null]; + else arr = [options, cb]; + + // arr[normalizedArgsSymbol] = true; + return arr; +} + +function _writeHead(statusCode, reason, obj, response) { + statusCode |= 0; + if (statusCode < 100 || statusCode > 999) { + throw new Error("status code must be between 100 and 999"); + } + + if (typeof reason === "string") { + // writeHead(statusCode, reasonPhrase[, headers]) + response.statusMessage = reason; + } else { + // writeHead(statusCode[, headers]) + if (!response.statusMessage) response.statusMessage = STATUS_CODES[statusCode] || "unknown"; + obj = reason; + } + response.statusCode = statusCode; + + { + // Slow-case: when progressive API and header fields are passed. + let k; + if (Array.isArray(obj)) { + if (obj.length % 2 !== 0) { + throw new Error("raw headers must have an even number of elements"); + } + + for (let n = 0; n < obj.length; n += 2) { + k = obj[n + 0]; + if (k) response.setHeader(k, obj[n + 1]); + } + } else if (obj) { + const keys = Object.keys(obj); + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 + for (let i = 0; i < keys.length; i++) { + k = keys[i]; + if (k) response.setHeader(k, obj[k]); + } + } + } +} + +/** + * Makes an HTTP request. + * @param {string | URL} url + * @param {HTTPRequestOptions} [options] + * @param {Function} [cb] + * @returns {ClientRequest} + */ +export function request(url, options, cb) { + return new ClientRequest(url, options, cb); +} + +/** + * Makes a `GET` HTTP request. + * @param {string | URL} url + * @param {HTTPRequestOptions} [options] + * @param {Function} [cb] + * @returns {ClientRequest} + */ +export function get(url, options, cb) { + const req = request(url, options, cb); + req.end(); + return req; +} + +export var globalAgent = new Agent(); +var defaultObject = { + Agent, + Server, + METHODS, + STATUS_CODES, + createServer, + ServerResponse, + IncomingMessage, + request, + get, + maxHeaderSize: 16384, + validateHeaderName, + validateHeaderValue, + setMaxIdleHTTPParsers(max) { + debug(`${NODE_HTTP_WARNING}\n`, "setMaxIdleHTTPParsers() is a no-op"); + }, + globalAgent, + [Symbol.for("CommonJS")]: 0, +}; + +export default defaultObject; diff --git a/src/js/node/https.js b/src/js/node/https.js deleted file mode 100644 index 5bef145ff..000000000 --- a/src/js/node/https.js +++ /dev/null @@ -1,3 +0,0 @@ -// Hardcoded module "node:https" -export * from "node:http"; -export { default as default } from "node:http"; diff --git a/src/js/node/https.ts b/src/js/node/https.ts new file mode 100644 index 000000000..08eb89a01 --- /dev/null +++ b/src/js/node/https.ts @@ -0,0 +1,65 @@ +// Hardcoded module "node:https" +import * as http from "node:http"; + +var { + Agent, + Server, + METHODS, + STATUS_CODES, + createServer, + ServerResponse, + IncomingMessage, + maxHeaderSize, + validateHeaderName, + validateHeaderValue, + globalAgent, +} = http; + +function request(input, options, cb) { + if (input && typeof input === "object" && !(input instanceof URL)) { + input.protocol ??= "https:"; + } else if (typeof options === "object") { + options.protocol ??= "https:"; + } + + return http.request(input, options, cb); +} + +function get(input, options, cb) { + const req = request(input, options, cb); + req.end(); + return req; +} + +var defaultExport = { + Agent, + Server, + METHODS, + STATUS_CODES, + createServer, + ServerResponse, + IncomingMessage, + request, + get, + maxHeaderSize, + validateHeaderName, + validateHeaderValue, + globalAgent, +}; + +export { + Agent, + Server, + METHODS, + STATUS_CODES, + createServer, + ServerResponse, + IncomingMessage, + request, + get, + maxHeaderSize, + validateHeaderName, + validateHeaderValue, + globalAgent, +}; +export default defaultExport; diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index f5d39d398..df64669b5 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (w,G,H,x){\"use strict\";const C={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},b=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][x];var J=(async(K,z,Q,F)=>{var g=this.onLoad.@get(Q);if(!g)return this.onLoadAsync(K,null,null),null;for(let[B,v]of g)if(B.test(z)){var q=v({path:z,namespace:Q,loader:F});while(q&&@isPromise(q)&&(@getPromiseInternalField(q,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)q=@getPromiseInternalField(q,@promiseFieldReactionsOrResult);if(q&&@isPromise(q))q=await q;if(!q||!@isObject(q))continue;var{contents:T,loader:y=F}=q;if(typeof T!==\"string\"&&!@isTypedArrayView(T))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof y!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const j=C[y];if(j===@undefined)@throwTypeError(`Loader ${y} is not supported.`);return this.onLoadAsync(K,T,j),null}return this.onLoadAsync(K,null,null),null})(w,G,H,b);while(J&&@isPromise(J)&&(@getPromiseInternalField(J,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)J=@getPromiseInternalField(J,@promiseFieldReactionsOrResult);if(J&&@isPromise(J))J.then(()=>{},(K)=>{this.addError(w,K,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,g,j,q){\"use strict\";const v={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},w=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][q];var x=(async(y,z,B,C)=>{var F=this.onLoad.@get(B);if(!F)return this.onLoadAsync(y,null,null),null;for(let[K,Q]of F)if(K.test(z)){var G=Q({path:z,namespace:B,loader:C});while(G&&@isPromise(G)&&(@getPromiseInternalField(G,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)G=@getPromiseInternalField(G,@promiseFieldReactionsOrResult);if(G&&@isPromise(G))G=await G;if(!G||!@isObject(G))continue;var{contents:H,loader:J=C}=G;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=v[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(y,H,T),null}return this.onLoadAsync(y,null,null),null})(b,g,j,w);while(x&&@isPromise(x)&&(@getPromiseInternalField(x,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)x=@getPromiseInternalField(x,@promiseFieldReactionsOrResult);if(x&&@isPromise(x))x.then(()=>{},(y)=>{this.addError(b,y,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -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 w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; // initializeWritableStreamSlots const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = 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 (c,B){\"use strict\";const h=@getByIdDirectPrivate(c,\"state\");if(h===\"closed\"||h===\"errored\")return @Promise.@resolve();const _=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(_!==@undefined)return _.promise.@promise;@assert(h===\"writable\"||h===\"erroring\");let f=!1;if(h===\"erroring\")f=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:f}),!f)@writableStreamStartErroring(c,B);return j.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = 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 I=A.shift();I;I=A.shift())I.@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(_)},(B)=>{i.promise.@reject.@call(@undefined,B),@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; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const _=@getByIdDirectPrivate(d,\"state\");if(@assert(_===\"writable\"||_===\"erroring\"),_===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const n=@getByIdDirectPrivate(d,\"writer\");if(n!==@undefined)@getByIdDirectPrivate(n,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = 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 f=@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 b=@writableStreamAddWriteRequest(W);return @writableStreamDefaultControllerWrite(_,P,f),b})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (d,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const W=@getByIdDirectPrivate(P,\"controller\");@assert(W!==@undefined);const _=@writableStreamDefaultControllerGetChunkSize(W,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const b=@getByIdDirectPrivate(P,\"state\");if(b===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(b===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(b===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(W,g,_),f})\n"; // setUpWritableStreamDefaultController const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = 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 (q,x,B,D,c,F,j){\"use strict\";if(D===@undefined)D=1;if(c===@undefined)c=()=>1;if(F===@undefined)F=0;if(j===@undefined)j=()=>1;@assert(D>=0),@assert(F>=0);const G={};@putByIdDirectPrivate(G,\"TransformStream\",!0);const I=new @TransformStream(G),v=@newPromiseCapability(@Promise);@initializeTransformStream(I,v.@promise,D,c,F,j);const E=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(I,E,x,B),q().@then(()=>{v.@resolve.@call()},(_)=>{v.@reject.@call(@undefined,_)}),I})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (_,c,j,q,v,x,B){\"use strict\";if(q===@undefined)q=1;if(v===@undefined)v=()=>1;if(x===@undefined)x=0;if(B===@undefined)B=()=>1;@assert(q>=0),@assert(x>=0);const D={};@putByIdDirectPrivate(D,\"TransformStream\",!0);const E=new @TransformStream(D),F=@newPromiseCapability(@Promise);@initializeTransformStream(E,F.@promise,q,v,x,B);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(E,G,c,j),_().@then(()=>{F.@resolve.@call()},(I)=>{F.@reject.@call(@undefined,I)}),E})\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 (T,j,v,C,D,E){\"use strict\";const F=()=>{return j},G=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(T,N)},I=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(T,N)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(T)},f=@createWritableStream(F,G,J,I,v,C),B=()=>{return @transformStreamDefaultSourcePullAlgorithm(T)},q=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(T,N),@Promise.@resolve()},x={};@putByIdDirectPrivate(x,\"start\",F),@putByIdDirectPrivate(x,\"pull\",B),@putByIdDirectPrivate(x,\"cancel\",q);const K={};@putByIdDirectPrivate(K,\"size\",E),@putByIdDirectPrivate(K,\"highWaterMark\",D);const L=new @ReadableStream(x,K);@putByIdDirectPrivate(T,\"writable\",f),@putByIdDirectPrivate(T,\"internalWritable\",@getInternalWritableStream(f)),@putByIdDirectPrivate(T,\"readable\",L),@putByIdDirectPrivate(T,\"backpressure\",@undefined),@putByIdDirectPrivate(T,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(T,!0),@putByIdDirectPrivate(T,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (f,G,B,T,C,F){\"use strict\";const I=()=>{return G},J=(x)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,x)},K=(x)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,x)},j=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},L=@createWritableStream(I,J,j,K,B,T),N=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},q=(x)=>{return @transformStreamErrorWritableAndUnblockWrite(f,x),@Promise.@resolve()},D={};@putByIdDirectPrivate(D,\"start\",I),@putByIdDirectPrivate(D,\"pull\",N),@putByIdDirectPrivate(D,\"cancel\",q);const E={};@putByIdDirectPrivate(E,\"size\",F),@putByIdDirectPrivate(E,\"highWaterMark\",C);const v=new @ReadableStream(D,E);@putByIdDirectPrivate(f,\"writable\",L),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(L)),@putByIdDirectPrivate(f,\"readable\",v),@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; @@ -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 q=@getByIdDirectPrivate(f,\"state\");if(q===\"erroring\"){x.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(q===\"writable\"),@transformStreamDefaultControllerPerformTransform(j,v).@then(()=>{x.@resolve()},(z)=>{x.@reject.@call(@undefined,z)})},(q)=>{x.@reject.@call(@undefined,q)}),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; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (j,z){\"use strict\";var L={path:\"node:process\",require:z},K=(N)=>L.require(N);function G(N){var{Duplex:O,eos:Q,destroy:U}=K(\"node:stream\"),V=class X extends O{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=K(\"node:tty\").isatty(N)}get fd(){return N}constructor(Z){super({readable:!0,writable:!0});this.#G=`/dev/fd/${Z}`}#N(Z){const Y=this.#H;if(this.#H=null,Y)Y(Z);else if(Z)this.destroy(Z);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Z,Y){if(!Z&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Z=new P}if(this.#J=null,this.#K=null,this.#H===null)Y(Z);else{if(this.#H=Y,this.#$)U(this.#$,Z);if(this.#B)U(this.#B,Z)}}_write(Z,Y,P){if(!this.#$){var{createWriteStream:A}=K(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),Q(T,(x)=>{if(this.#z=!1,x)U(T,x);this.#N(x)})}if(T.write(Z,Y))P();else this.#J=P}_final(Z){this.#$&&this.#$.end(),this.#K=Z}#O(){var{createReadStream:Z}=K(\"node:fs\"),Y=this.#B=Z(this.#G);return Y.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),Y.on(\"end\",()=>{this.push(null)}),Q(Y,(P)=>{if(this.#j=!1,P)U(Y,P);this.#N(P)}),Y}_read(){var Z=this.#B;if(!Z)Z=this.#O();while(!0){const Y=Z.read();if(Y===null||!this.push(Y))return}}};return new V(N)}var{EventEmitter:H}=K(\"node:events\");function M(N){if(!N)return!0;var O=N.toLowerCase();return O===\"utf8\"||O===\"utf-8\"||O===\"buffer\"||O===\"binary\"}var J,B=class N extends H{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(O){if(this.#B||!M(O))return this.#J(),this.#B.setDefaultEncoding(O)}#G(){switch(this.#$){case 1:{var O=@Bun.stdout.writer({highWaterMark:0});return O.unref(),O}case 2:{var O=@Bun.stderr.writer({highWaterMark:0});return O.unref(),O}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(O){super();this.#$=O}get fd(){return this.#$}get isTTY(){return this.#z\?\?=K(\"node:tty\").isatty(this.#$)}cursorTo(O,Q,U){return(J\?\?=K(\"readline\")).cursorTo(this,O,Q,U)}moveCursor(O,Q,U){return(J\?\?=K(\"readline\")).moveCursor(this,O,Q,U)}clearLine(O,Q){return(J\?\?=K(\"readline\")).clearLine(this,O,Q)}clearScreenDown(O){return(J\?\?=K(\"readline\")).clearScreenDown(this,O)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(O,Q){if(O===\"close\"||O===\"finish\")return this.#J(),this.#B.on(O,Q);if(O===\"drain\")return super.on(\"drain\",Q);if(O===\"error\")return super.on(\"error\",Q);return super.on(O,Q)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(O){return this.#J(),this.#B.pipe(O)}unpipe(O){return this.#J(),this.#B.unpipe(O)}#J(){if(this.#B)return;this.#B=G(this.#$);const O=this.eventNames();for(let Q of O)this.#B.on(Q,(...U)=>{this.emit(Q,...U)})}#K(O){var Q=this.#H();const U=Q.write(O);this.bytesWritten+=U;const V=Q.flush(!1);return!!(U||V)}#L(O,Q){if(!M(Q))return this.#J(),this.#B.write(O,Q);return this.#K(O)}#M(O,Q){if(Q)this.emit(\"error\",Q);try{O(Q\?Q:null)}catch(U){this.emit(\"error\",U)}}#N(O,Q,U){if(!M(Q))return this.#J(),this.#B.write(O,Q,U);var V=this.#H();const X=V.write(O),Z=V.flush(!0);if(Z\?.then)return Z.then(()=>{this.#M(U),this.emit(\"drain\")},(Y)=>this.#M(U,Y)),!1;return queueMicrotask(()=>{this.#M(U)}),!!(X||Z)}write(O,Q,U){const V=this._write(O,Q,U);if(V)this.emit(\"drain\");return V}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(O,Q,U){var V=this.#B;if(V)return V.write(O,Q,U);switch(arguments.length){case 0:{var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}case 1:return this.#K(O);case 2:if(typeof Q===\"function\")return this.#N(O,\"\",Q);else if(typeof Q===\"string\")return this.#L(O,Q);default:{if(typeof Q!==\"undefined\"&&typeof Q!==\"string\"||typeof U!==\"undefined\"&&typeof U!==\"function\"){var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}if(typeof U===\"undefined\")return this.#L(O,Q);return this.#N(O,Q,U)}}}destroy(){return this}end(){return this}};return new B(j)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (A,M){\"use strict\";var N={path:\"node:process\",require:M},O=(Z)=>N.require(Z);function Q(Z){var{Duplex:T,eos:x,destroy:Y}=O(\"node:stream\"),j=class H extends T{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=O(\"node:tty\").isatty(Z)}get fd(){return Z}constructor(V){super({readable:!0,writable:!0});this.#G=`/dev/fd/${V}`}#N(V){const L=this.#H;if(this.#H=null,L)L(V);else if(V)this.destroy(V);else if(!this.#j&&!this.#z)this.destroy()}_destroy(V,L){if(!V&&this.#H!==null){var X=class J extends Error{code;name;constructor(z=\"The operation was aborted\",P=void 0){if(P!==void 0&&typeof P!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(P,null,2)}`);super(z,P);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};V=new X}if(this.#J=null,this.#K=null,this.#H===null)L(V);else{if(this.#H=L,this.#$)Y(this.#$,V);if(this.#B)Y(this.#B,V)}}_write(V,L,X){if(!this.#$){var{createWriteStream:J}=O(\"node:fs\"),z=this.#$=J(this.#G);z.on(\"finish\",()=>{if(this.#K){const P=this.#K;this.#K=null,P()}}),z.on(\"drain\",()=>{if(this.#J){const P=this.#J;this.#J=null,P()}}),x(z,(P)=>{if(this.#z=!1,P)Y(z,P);this.#N(P)})}if(z.write(V,L))X();else this.#J=X}_final(V){this.#$&&this.#$.end(),this.#K=V}#O(){var{createReadStream:V}=O(\"node:fs\"),L=this.#B=V(this.#G);return L.on(\"readable\",()=>{if(this.#L){const X=this.#L;this.#L=null,X()}else this.read()}),L.on(\"end\",()=>{this.push(null)}),x(L,(X)=>{if(this.#j=!1,X)Y(L,X);this.#N(X)}),L}_read(){var V=this.#B;if(!V)V=this.#O();while(!0){const L=V.read();if(L===null||!this.push(L))return}}};return new j(Z)}var{EventEmitter:B}=O(\"node:events\");function G(Z){if(!Z)return!0;var T=Z.toLowerCase();return T===\"utf8\"||T===\"utf-8\"||T===\"buffer\"||T===\"binary\"}var U,K=class Z extends B{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(T){if(this.#B||!G(T))return this.#J(),this.#B.setDefaultEncoding(T)}#G(){switch(this.#$){case 1:{var T=@Bun.stdout.writer({highWaterMark:0});return T.unref(),T}case 2:{var T=@Bun.stderr.writer({highWaterMark:0});return T.unref(),T}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(T){super();this.#$=T}get fd(){return this.#$}get isTTY(){return this.#z\?\?=O(\"node:tty\").isatty(this.#$)}cursorTo(T,x,Y){return(U\?\?=O(\"readline\")).cursorTo(this,T,x,Y)}moveCursor(T,x,Y){return(U\?\?=O(\"readline\")).moveCursor(this,T,x,Y)}clearLine(T,x){return(U\?\?=O(\"readline\")).clearLine(this,T,x)}clearScreenDown(T){return(U\?\?=O(\"readline\")).clearScreenDown(this,T)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(T,x){if(T===\"close\"||T===\"finish\")return this.#J(),this.#B.on(T,x);if(T===\"drain\")return super.on(\"drain\",x);if(T===\"error\")return super.on(\"error\",x);return super.on(T,x)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(T){return this.#J(),this.#B.pipe(T)}unpipe(T){return this.#J(),this.#B.unpipe(T)}#J(){if(this.#B)return;this.#B=Q(this.#$);const T=this.eventNames();for(let x of T)this.#B.on(x,(...Y)=>{this.emit(x,...Y)})}#K(T){var x=this.#H();const Y=x.write(T);this.bytesWritten+=Y;const j=x.flush(!1);return!!(Y||j)}#L(T,x){if(!G(x))return this.#J(),this.#B.write(T,x);return this.#K(T)}#M(T,x){if(x)this.emit(\"error\",x);try{T(x\?x:null)}catch(Y){this.emit(\"error\",Y)}}#N(T,x,Y){if(!G(x))return this.#J(),this.#B.write(T,x,Y);var j=this.#H();const H=j.write(T),V=j.flush(!0);if(V\?.then)return V.then(()=>{this.#M(Y),this.emit(\"drain\")},(L)=>this.#M(Y,L)),!1;return queueMicrotask(()=>{this.#M(Y)}),!!(H||V)}write(T,x,Y){const j=this._write(T,x,Y);if(j)this.emit(\"drain\");return j}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(T,x,Y){var j=this.#B;if(j)return j.write(T,x,Y);switch(arguments.length){case 0:{var H=new Error(\"Invalid arguments\");throw H.code=\"ERR_INVALID_ARG_TYPE\",H}case 1:return this.#K(T);case 2:if(typeof x===\"function\")return this.#N(T,\"\",x);else if(typeof x===\"string\")return this.#L(T,x);default:{if(typeof x!==\"undefined\"&&typeof x!==\"string\"||typeof Y!==\"undefined\"&&typeof Y!==\"function\"){var H=new Error(\"Invalid arguments\");throw H.code=\"ERR_INVALID_ARG_TYPE\",H}if(typeof Y===\"undefined\")return this.#L(T,x);return this.#N(T,x,Y)}}}destroy(){return this}end(){return this}};return new K(A)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = 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 (z,G,H){\"use strict\";var K={path:\"node:process\",require:G},L=(T)=>K.require(T),{Duplex:M,eos:N,destroy:P}=L(\"node:stream\"),Q=class T extends M{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return L(\"tty\").isatty(z)}get fd(){return z}constructor(){super({readable:!0,writable:!0})}#L(Y){const j=this.#J;if(this.#J=null,j)j(Y);else if(Y)this.destroy(Y);else if(!this.#z&&!this.#H)this.destroy()}_destroy(Y,j){if(!Y&&this.#J!==null){var I=class J extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Y=new I}if(this.#J===null)j(Y);else if(this.#J=j,this.#j)P(this.#j,Y)}setRawMode(Y){}on(Y,j){if(Y===\"readable\")this.ref(),this.#G=!0;return super.on(Y,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#Y\?\?=H.stdin.stream().getReader(),this.#$\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#$)clearInterval(this.#$),this.#$=null}async#M(){try{var Y,j;const I=this.#Y.readMany();if(!I\?.then)({done:Y,value:j}=I);else({done:Y,value:j}=await I);if(!Y){this.push(j[0]);const J=j.length;for(let U=1;U{if(this.#I){const I=this.#I;this.#I=null,I()}}),j.on(\"drain\",()=>{if(this.#K){const I=this.#K;this.#K=null,I()}}),N(j,(I)=>{if(this.#H=!1,I)P(j,I);this.#L(I)}),j}_write(Y,j,I){var J=this.#j;if(!J)J=this.#N();if(J.write(Y,j))I();else this.#K=I}_final(Y){this.#j.end(),this.#I=(...j)=>Y(...j)}};return new Q})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (Y,j,z){\"use strict\";var G={path:\"node:process\",require:j},H=(M)=>G.require(M),{Duplex:I,eos:J,destroy:K}=H(\"node:stream\"),L=class M extends I{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return H(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(N){const P=this.#J;if(this.#J=null,P)P(N);else if(N)this.destroy(N);else if(!this.#z&&!this.#H)this.destroy()}_destroy(N,P){if(!N&&this.#J!==null){var Q=class T extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new Q}if(this.#J===null)P(N);else if(this.#J=P,this.#j)K(this.#j,N)}setRawMode(N){}on(N,P){if(N===\"readable\")this.ref(),this.#G=!0;return super.on(N,P)}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 N,P;const Q=this.#Y.readMany();if(!Q\?.then)({done:N,value:P}=Q);else({done:N,value:P}=await Q);if(!N){this.push(P[0]);const T=P.length;for(let U=1;U{if(this.#I){const Q=this.#I;this.#I=null,Q()}}),P.on(\"drain\",()=>{if(this.#K){const Q=this.#K;this.#K=null,Q()}}),J(P,(Q)=>{if(this.#H=!1,Q)K(P,Q);this.#L(Q)}),P}_write(N,P,Q){var T=this.#j;if(!T)T=this.#N();if(T.write(N,P))Q();else this.#K=Q}_final(N){this.#j.end(),this.#I=(...P)=>N(...P)}};return new L})\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 _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let B=arguments[1],u=arguments[2];if(_===@undefined)_=null;if(u===@undefined)u={};if(B===@undefined)B={};let E={};if(_!==null){if(\"start\"in _){if(E[\"start\"]=_[\"start\"],typeof E[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(E[\"transform\"]=_[\"transform\"],typeof E[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(E[\"flush\"]=_[\"flush\"],typeof E[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const j=@extractHighWaterMark(u,0),F=@extractSizeAlgorithm(u),q=@extractHighWaterMark(B,1),G=@extractSizeAlgorithm(B),v=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,v.@promise,q,G,j,F),@setUpTransformStreamDefaultControllerFromTransformer(this,_,E),(\"start\"in E)){const I=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,E[\"start\"],[I]))().@then(()=>{v.@resolve.@call()},(J)=>{v.@reject.@call(@undefined,J)})}else v.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let B=arguments[1],u=arguments[2];if(_===@undefined)_=null;if(u===@undefined)u={};if(B===@undefined)B={};let j={};if(_!==null){if(\"start\"in _){if(j[\"start\"]=_[\"start\"],typeof j[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(j[\"transform\"]=_[\"transform\"],typeof j[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(j[\"flush\"]=_[\"flush\"],typeof j[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const v=@extractHighWaterMark(u,0),x=@extractSizeAlgorithm(u),E=@extractHighWaterMark(B,1),F=@extractSizeAlgorithm(B),G=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,G.@promise,E,F,v,x),@setUpTransformStreamDefaultControllerFromTransformer(this,_,j),(\"start\"in j)){const q=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,j[\"start\"],[q]))().@then(()=>{G.@resolve.@call()},(J)=>{G.@reject.@call(@undefined,J)})}else G.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (M){\"use strict\";const S=@requireMap.@get(M)||@requireMap.@get(M=@resolveSync(M,this.path,!1));if(S)return @evaluateCommonJSModule(S),S.exports;if(M.endsWith(\".json\")||M.endsWith(\".toml\")||M.endsWith(\".node\"))return @internalRequire(M);let f=@Loader.registry.@get(M);if(f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const _=f.module,b=@Loader.getModuleNamespaceObject(_),r=b\?.[@commonJSSymbol]===0||b\?.default\?.[@commonJSSymbol]===0\?b.default:b.__esModule\?b:Object.create(b,{__esModule:{value:!0}});return @requireMap.@set(M,@createCommonJSModule(M,r,!0)),r}const L=@createCommonJSModule(M,{},!1);@requireMap.@set(M,L);var h=this.@require(M,L);if(h===-1){try{h=@requireESM(M)}catch(_){throw @requireMap.@delete(M),_}if(f=@Loader.registry.@get(M),f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const _=@Loader.getModuleNamespaceObject(f.module);return L.exports=_\?.[@commonJSSymbol]===0||_\?.default\?.[@commonJSSymbol]===0\?_.default:_.__esModule\?_:Object.create(_,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const S=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(S)return @evaluateCommonJSModule(S),S.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let f=@Loader.registry.@get(_);if(f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const h=f.module,r=@Loader.getModuleNamespaceObject(h),b=r\?.[@commonJSSymbol]===0||r\?.default\?.[@commonJSSymbol]===0\?r.default:r.__esModule\?r:Object.create(r,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}const L=@createCommonJSModule(_,{},!1);@requireMap.@set(_,L);var M=this.@require(_,L);if(M===-1){try{M=@requireESM(_)}catch(h){throw @requireMap.@delete(_),h}if(f=@Loader.registry.@get(_),f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const h=@Loader.getModuleNamespaceObject(f.module);return L.exports=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,_){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:return u.getInt8(d);case 2:return u.getInt16(d,!0);case 3:{const r=u.getUint16(d,!0)+u.getUint8(d+2)*65536;return r|(r&8388608)*510}case 4:return u.getInt32(d,!0);case 5:{const r=u.getUint8(d+4);return(r|(r&128)*33554430)*4294967296+u.getUint32(d,!0)}case 6:{const r=u.getUint16(d+4,!0);return(r|(r&32768)*131070)*4294967296+u.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1038,7 +1038,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!0),c+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!0),d+4})\n"; // writeFloatBE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1046,7 +1046,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!1),c+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!1),d+4})\n"; // writeDoubleLE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1142,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; @@ -1150,7 +1150,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlWriteCodeLength = 70; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64url\")})\n"; +const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (d,a,r){\"use strict\";return this.write(d,a,r,\"base64url\")})\n"; // hexWrite const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (p,m){\"use strict\";var{buffer:c,byteOffset:k,byteLength:v}=this;function q(z,i){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=i,z>0\?z:0;else return zw\?x-w:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (p,q){\"use strict\";var{buffer:m,byteOffset:v,byteLength:c}=this;function w(z,k){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=k,z>0\?z:0;else return zi\?x-i:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,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 l=@getByIdDirectPrivate(this,\"pendingPullIntos\");const m=l.peek();if(m){const a=new @Uint8Array(m.buffer,m.byteOffset+m.bytesFilled,m.byteLength-m.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,a,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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*w(){var _=@Bun.stdin.stream().getReader(),B=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),m,D=@Bun.indexOfLine;try{while(!0){var F,q,G;const L=_.readMany();if(@isPromise(L))({done:F,value:q}=await L);else({done:F,value:q}=L);if(F){if(G)yield B.decode(G);return}var H;for(let M of q){if(H=M,G)H=@Buffer.concat([G,M]),G=null;var J=0,K=D(H,J);while(K!==-1)yield B.decode(H.subarray(J,K)),J=K+1,K=D(H,J);G=H.subarray(J)}}}catch(L){m=L}finally{if(_.releaseLock(),m)throw m}},z=globalThis.Symbol.asyncIterator;return this[z]=j,j()})\n"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const j=async function*z(){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 q=0,A=H(_,q);while(A!==-1)yield F.decode(_.subarray(q,A)),q=A+1,A=H(_,q);w=_.subarray(q)}}}catch(L){G=L}finally{if(D.releaseLock(),G)throw G}},m=globalThis.Symbol.asyncIterator;return this[m]=j,j()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (d){\"use strict\";var _=@getByIdDirectPrivate(this,\"writer\");if(!_){var b=@toLength(d\?.length\?\?0);_=@Bun.stdout.writer({highWaterMark:b>65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a65536\?_:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var b=d.write(a);const c=@argumentCount();for(var f=1;f@promiseInvokeOrNoopMethod(f,w,[C]),D=(x)=>@promiseInvokeOrNoopMethod(f,B,[x]);@putByIdDirectPrivate(C,\"pullAlgorithm\",q),@putByIdDirectPrivate(C,\"cancelAlgorithm\",D),@putByIdDirectPrivate(C,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(C,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(_,\"readableStreamController\",C),@readableStreamDefaultControllerStart(C)})\n"; +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"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (w,C,A){\"use strict\";const b=C.type,f=@toString(b);if(f===\"bytes\"){if(A.highWaterMark===@undefined)A.highWaterMark=0;if(A.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(w,\"readableStreamController\",new @ReadableByteStreamController(w,C,A.highWaterMark,@isReadableStream))}else if(f===\"direct\"){var v=A\?.highWaterMark;@initializeArrayBufferStream.@call(w,C,v)}else if(b===@undefined){if(A.highWaterMark===@undefined)A.highWaterMark=1;@setupReadableStreamDefaultController(w,C,A.size,A.highWaterMark,C.start,C.pull,C.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,b)}else if(A===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1420,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 (B){\"use strict\";if(@getByIdDirectPrivate(B,\"started\")!==-1)return;const a=@getByIdDirectPrivate(B,\"underlyingSource\"),p=a.start;@putByIdDirectPrivate(B,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(a,p,[B]).@then(()=>{@putByIdDirectPrivate(B,\"started\",1),@assert(!@getByIdDirectPrivate(B,\"pulling\")),@assert(!@getByIdDirectPrivate(B,\"pullAgain\")),@readableStreamDefaultControllerCallPullIfNeeded(B)},(m)=>{@readableStreamDefaultControllerError(B,m)})})\n"; +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"; // readableStreamPipeToWritableStream const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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 (D,w,_,x,f,z){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(w)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(w)),@assert(z===@undefined||@isAbortSignal(z)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let E={source:D,destination:w,preventAbort:x,preventCancel:f,preventClose:_,signal:z};if(E.reader=@acquireReadableStreamDefaultReader(D),E.writer=@acquireWritableStreamDefaultWriter(w),@putByIdDirectPrivate(D,\"disturbed\",!0),E.finalized=!1,E.shuttingDown=!1,E.promiseCapability=@newPromiseCapability(@Promise),E.pendingReadPromiseCapability=@newPromiseCapability(@Promise),E.pendingReadPromiseCapability.@resolve.@call(),E.pendingWritePromise=@Promise.@resolve(),z!==@undefined){const B=(F)=>{if(E.finalized)return;@pipeToShutdownWithAction(E,()=>{const G=!E.preventAbort&&@getByIdDirectPrivate(E.destination,\"state\")===\"writable\"\?@writableStreamAbort(E.destination,F):@Promise.@resolve(),I=!E.preventCancel&&@getByIdDirectPrivate(E.source,\"state\")===@streamReadable\?@readableStreamCancel(E.source,F):@Promise.@resolve();let J=@newPromiseCapability(@Promise),K=!0,L=()=>{if(K){K=!1;return}J.@resolve.@call()},k=(q)=>{J.@reject.@call(@undefined,q)};return G.@then(L,k),I.@then(L,k),J.@promise},F)};if(@whenSignalAborted(z,B))return E.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(E),@pipeToErrorsMustBePropagatedBackward(E),@pipeToClosingMustBePropagatedForward(E),@pipeToClosingMustBePropagatedBackward(E),@pipeToLoop(E),E.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (f,q,w,x,F,G){\"use strict\";if(@assert(@isReadableStream(f)),@assert(@isWritableStream(q)),@assert(!@isReadableStreamLocked(f)),@assert(!@isWritableStreamLocked(q)),@assert(G===@undefined||@isAbortSignal(G)),@getByIdDirectPrivate(f,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:f,destination:q,preventAbort:x,preventCancel:F,preventClose:w,signal:G};if(_.reader=@acquireReadableStreamDefaultReader(f),_.writer=@acquireWritableStreamDefaultWriter(q),@putByIdDirectPrivate(f,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),G!==@undefined){const H=(I)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const E=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,I):@Promise.@resolve(),z=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,I):@Promise.@resolve();let B=@newPromiseCapability(@Promise),K=!0,T=()=>{if(K){K=!1;return}B.@resolve.@call()},L=(k)=>{B.@reject.@call(@undefined,k)};return E.@then(T,L),z.@then(T,L),B.@promise},I)};if(@whenSignalAborted(G,H))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const g=arguments.length>2,h=arguments[2],b=()=>{m().@then(()=>{if(g)@pipeToFinalize(_,h);else @pipeToFinalize(_)},(d)=>{@pipeToFinalize(_,d)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(b,b)},(j)=>@pipeToFinalize(_,j));return}b()})\n"; +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],j=()=>{b().@then(()=>{if(d)@pipeToFinalize(m,g);else @pipeToFinalize(m)},(h)=>{@pipeToFinalize(m,h)})};if(@getByIdDirectPrivate(m.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(m.destination)){m.pendingReadPromiseCapability.@promise.@then(()=>{m.pendingWritePromise.@then(j,j)},(_)=>@pipeToFinalize(m,_));return}j()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1492,7 +1492,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownCodeLength = 411; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,u=arguments[1],d=()=>{if(m)@pipeToFinalize(_,u);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(d,d)},(I)=>@pipeToFinalize(_,I));return}d()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const d=arguments.length>1,m=arguments[1],u=()=>{if(d)@pipeToFinalize(_,m);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(I)=>@pipeToFinalize(_,I));return}u()})\n"; // pipeToFinalize const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,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,m,_){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(m),function(f){if(@assert(@isObject(f)),@assert(typeof f.done===\"boolean\"),f.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,f.value);if(!i.canceled2)@readableStreamDefaultControllerEnqueue(i.branch2.@readableStreamController,_\?@structuredCloneForStream(f.value):f.value)})}})\n"; +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"; // readableStreamTeeBranch1CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1524,7 +1524,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1Canc const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength = 258; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,i){\"use strict\";return function(d){if(c.canceled1=!0,c.reason1=d,c.canceled2)@readableStreamCancel(i,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,d){\"use strict\";return function(i){if(c.canceled1=!0,c.reason1=i,c.canceled2)@readableStreamCancel(d,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; // readableStreamTeeBranch2CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,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; @@ -1572,7 +1572,7 @@ const JSC::ConstructorKind s_readableStreamInternalsAssignToStreamCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsAssignToStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamInternalsAssignToStreamCodeLength = 221; static const JSC::Intrinsic s_readableStreamInternalsAssignToStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsAssignToStreamCode = "(function (h,_){\"use strict\";var b=@getByIdDirectPrivate(h,\"underlyingSource\");if(b)try{return @readDirectStream(h,_,b)}catch(f){throw f}finally{b=@undefined,h=@undefined,_=@undefined}return @readStreamIntoSink(h,_,!0)})\n"; +const char* const s_readableStreamInternalsAssignToStreamCode = "(function (_,b){\"use strict\";var f=@getByIdDirectPrivate(_,\"underlyingSource\");if(f)try{return @readDirectStream(_,b,f)}catch(h){throw h}finally{f=@undefined,_=@undefined,b=@undefined}return @readStreamIntoSink(_,b,!0)})\n"; // readStreamIntoSink const JSC::ConstructAbility s_readableStreamInternalsReadStreamIntoSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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 (f,I,q){\"use strict\";var z=!1,A=!1;try{var B=f.getReader(),D=B.readMany();if(D&&@isPromise(D))D=await D;if(D.done)return z=!0,I.end();var E=D.value.length;const J=@getByIdDirectPrivate(f,\"highWaterMark\");if(q)@startDirectStream.@call(I,f,@undefined,()=>!A&&@markPromiseAsHandled(f.cancel()));I.start({highWaterMark:J||0});for(var F=0,G=D.value,_=D.value.length;F<_;F++)I.write(G[F]);var c=@getByIdDirectPrivate(f,\"state\");if(c===@streamClosed)return z=!0,I.end();while(!0){var{value:P,done:x}=await B.read();if(x)return z=!0,I.end();I.write(P)}}catch(J){A=!0;try{B=@undefined;const K=f.cancel(J);@markPromiseAsHandled(K)}catch(K){}if(I&&!z){z=!0;try{I.close(J)}catch(K){throw new globalThis.AggregateError([J,K])}}throw J}finally{if(B){try{B.releaseLock()}catch(K){}B=@undefined}I=@undefined;var c=@getByIdDirectPrivate(f,\"state\");if(f){var H=@getByIdDirectPrivate(f,\"readableStreamController\");if(H){if(@getByIdDirectPrivate(H,\"underlyingSource\"))@putByIdDirectPrivate(H,\"underlyingSource\",@undefined);if(@getByIdDirectPrivate(H,\"controlledReadableStream\"))@putByIdDirectPrivate(H,\"controlledReadableStream\",@undefined);if(@putByIdDirectPrivate(f,\"readableStreamController\",null),@getByIdDirectPrivate(f,\"underlyingSource\"))@putByIdDirectPrivate(f,\"underlyingSource\",@undefined);H=@undefined}if(!A&&c!==@streamClosed&&c!==@streamErrored)@readableStreamClose(f);f=@undefined}}})\n"; +const char* const s_readableStreamInternalsReadStreamIntoSinkCode = "(async function (_,E,c){\"use strict\";var f=!1,B=!1;try{var D=_.getReader(),F=D.readMany();if(F&&@isPromise(F))F=await F;if(F.done)return f=!0,E.end();var G=F.value.length;const q=@getByIdDirectPrivate(_,\"highWaterMark\");if(c)@startDirectStream.@call(E,_,@undefined,()=>!B&&@markPromiseAsHandled(_.cancel()));E.start({highWaterMark:q||0});for(var H=0,I=F.value,J=F.value.length;H{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"; +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 S=@getByIdDirectPrivate(v,\"reader\");if(S&&@isReadableStreamDefaultReader(S)){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 B=@getByIdDirectPrivate(S,\"readRequests\");if(B\?.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; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var i=this.@sink.flush();if(i\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:i,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var i=this.@sink.flush();if(i\?.byteLength)@readableStreamFulfillReadRequest(c,i,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,b=@getByIdDirectPrivate(c,\"reader\");if(!b||!@isReadableStreamDefaultReader(b))return;var i=this._pendingRead;if(this._pendingRead=@undefined,i&&@isPromise(i)){var B=this.@sink.flush();if(B\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(i,{value:B,done:!1});else this._pendingRead=i}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var B=this.@sink.flush();if(B\?.byteLength)@readableStreamFulfillReadRequest(c,B,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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 (j){\"use strict\";var x,w=[],z=!1,_=!1,A=\"\",q=@toLength(0),C=@newPromiseCapability(@Promise),E=!1;return x={start(){},write(v){if(typeof v===\"string\"){var F=@toLength(v.length);if(F>0)A+=v,z=!0,q+=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(_=!0,A.length>0)@arrayPush(w,A,v),A=\"\";else @arrayPush(w,v);return q+=G,G},flush(){return 0},end(){if(E)return\"\";return x.fulfill()},fulfill(){E=!0;const v=x.finishInternal();return @fulfillPromise(C.@promise,v),v},finishInternal(){if(!z&&!_)return\"\";if(z&&!_)return A;if(_&&!z)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(w));var v=new @Bun.ArrayBufferSink;v.start({highWaterMark:q,asUint8Array:!0});for(let F of w)v.write(F);if(w.length=0,A.length>0)v.write(A),A=\"\";return new globalThis.TextDecoder().decode(v.end())},close(){try{if(!E)E=!0,x.fulfill()}catch(v){}}},[x,C]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (_){\"use strict\";var j,q=[],x=!1,v=!1,z=\"\",C=@toLength(0),E=@newPromiseCapability(@Promise),F=!1;return j={start(){},write(G){if(typeof G===\"string\"){var A=@toLength(G.length);if(A>0)z+=G,x=!0,C+=A;return A}if(!G||!(@ArrayBuffer.@isView(G)||G instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const w=@toLength(G.byteLength);if(w>0)if(v=!0,z.length>0)@arrayPush(q,z,G),z=\"\";else @arrayPush(q,G);return C+=w,w},flush(){return 0},end(){if(F)return\"\";return j.fulfill()},fulfill(){F=!0;const G=j.finishInternal();return @fulfillPromise(E.@promise,G),G},finishInternal(){if(!x&&!v)return\"\";if(x&&!v)return z;if(v&&!x)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(q));var G=new @Bun.ArrayBufferSink;G.start({highWaterMark:C,asUint8Array:!0});for(let A of q)G.write(A);if(q.length=0,z.length>0)G.write(z),z=\"\";return new globalThis.TextDecoder().decode(G.end())},close(){try{if(!F)F=!0,j.fulfill()}catch(G){}}},[j,E]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[b,f]=@createTextStream(m),p={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",p),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),f})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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 (_,b){\"use strict\";var j=[],t=@newPromiseCapability(@Promise),p=!1;function d(){return p=!0,t.@resolve.@call(@undefined,j),j}var m={start(){},write(v){return @arrayPush(j,v),v.byteLength||v.length},flush(){return 0},end(){if(p)return[];return d()},close(){if(!p)d()}},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),t})\n"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (p,b){\"use strict\";var d=[],j=@newPromiseCapability(@Promise),_=!1;function m(){return _=!0,j.@resolve.@call(@undefined,d),d}var t={start(){},write(v){return @arrayPush(d,v),v.byteLength||v.length},flush(){return 0},end(){if(_)return[];return m()},close(){if(!_)m()}},q={@underlyingSource:p,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:t,close:@onCloseDirectStream,write:t.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),j})\n"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var i=d.shift();i;i=d.shift())@fulfillPromise(i,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let D=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)D=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,D)}catch(D){throw @readableStreamDefaultControllerError(_,D),D}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const y=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!y);const n=@getByIdDirectPrivate(y,\"state\");if(@putByIdDirectPrivate(y,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(y,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(y,\"readableStreamController\").@pull(@getByIdDirectPrivate(y,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,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 (Q,G){\"use strict\";var N=@getByIdDirectPrivate(Q,\"bunNativeType\"),H=@getByIdDirectPrivate(Q,\"bunNativePtr\"),I=@lazyStreamPrototypeMap.@get(N);if(I===@undefined){let m=function(D){var{c:p,v:z}=this;this.c=@undefined,this.v=@undefined,X(D,p,z)},M=function(D){try{D.close()}catch(p){globalThis.reportError(p)}},_=function(D,p,z,A){A[0]=!1;var E;try{E=f(D,z,A)}catch(F){return p.error(F)}return X(E,p,z)};var j=m,P=M,q=_,[f,b,J,x,K,O,U]=@lazyLoad(N),W=[!1],X;X=function D(p,z,A){if(p&&@isPromise(p))return p.then(m.bind({c:z,v:A}),(E)=>z.error(E));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(W[0]||p===!1)@enqueueJob(M,z),W[0]=!1};const B=K\?new FinalizationRegistry(K):null;I=class D{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=(E)=>{E.enqueue(A)};if(B)B.register(this,p,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=b;#j(p){var z=this.#f;if(!z){p.close();return}_(z,p,p.byobRequest.view,W)}#m(p){var z=this.#f;B&&B.unregister(this.#b),O&&O(z,!1),J(z,p)}static deinit=K;static drain=U},@lazyStreamPrototypeMap.@set(N,I)}const Y=I.startSync(H,G);var Z;const{drain:y,deinit:L}=I;if(y)Z=y(H);if(Y===0){if(K&&H&&@enqueueJob(K,H),(Z\?.byteLength\?\?0)>0)return{start(m){m.enqueue(Z),m.close()},type:\"bytes\"};return{start(m){m.close()},type:\"bytes\"}}return new I(H,Y,Z)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (N,J){\"use strict\";var M=@getByIdDirectPrivate(N,\"bunNativeType\"),K=@getByIdDirectPrivate(N,\"bunNativePtr\"),L=@lazyStreamPrototypeMap.@get(M);if(L===@undefined){let q=function(x){var{c:H,v:z}=this;this.c=@undefined,this.v=@undefined,j(x,H,z)},G=function(x){try{x.close()}catch(H){globalThis.reportError(H)}},_=function(x,H,z,A){A[0]=!1;var y;try{y=b(x,z,A)}catch(I){return H.error(I)}return j(y,H,z)};var Y=q,Z=G,F=_,[b,B,O,P,f,D,Q]=@lazyLoad(M),U=[!1],j;j=function x(H,z,A){if(H&&@isPromise(H))return H.then(q.bind({c:z,v:A}),(y)=>z.error(y));else if(typeof H===\"number\")if(A&&A.byteLength===H&&A.buffer===z.byobRequest\?.view\?.buffer)z.byobRequest.respondWithNewView(A);else z.byobRequest.respond(H);else if(H.constructor===@Uint8Array)z.enqueue(H);if(U[0]||H===!1)@enqueueJob(G,z),U[0]=!1};const p=f\?new FinalizationRegistry(f):null;L=class x{constructor(H,z,A){if(this.#f=H,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=z,A!==@undefined)this.start=(y)=>{y.enqueue(A)};if(p)p.register(this,H,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=B;#j(H){var z=this.#f;if(!z){H.close();return}_(z,H,H.byobRequest.view,U)}#m(H){var z=this.#f;p&&p.unregister(this.#b),D&&D(z,!1),O(z,H)}static deinit=f;static drain=Q},@lazyStreamPrototypeMap.@set(M,L)}const E=L.startSync(K,J);var W;const{drain:X,deinit:m}=L;if(X)W=X(K);if(E===0){if(f&&K&&@enqueueJob(f,K),(W\?.byteLength\?\?0)>0)return{start(q){q.enqueue(W),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new L(K,E,W)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var p=f.getReader(),g=p.readMany();async function b(_){if(_.done)return[];var j=_.value||[];while(!0){var q=await p.read();if(q.done)break;j=j.concat(q.value)}return j}if(g&&@isPromise(g))return g.@then(b);return b(g)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var b=_.getReader(),g=b.readMany();async function j(q){if(q.done)return[];var f=q.value||[];while(!0){var p=await b.read();if(p.done)break;f=f.concat(p.value)}return f}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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,w){\"use strict\";var _=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(j,\"underlyingSource\",@undefined);var x=@getByIdDirectPrivate(j,\"highWaterMark\");_.start(x\?{highWaterMark:x}:{});var O=@newPromiseCapability(@Promise),z=!1,q=w.pull,A=w.close,B={start(){},close(C){if(!z){if(z=!0,A)A();@fulfillPromise(O.@promise,_.end())}},end(){if(!z){if(z=!0,A)A();@fulfillPromise(O.@promise,_.end())}},flush(){return 0},write:_.write.bind(_)},v=!1;try{const C=q(B);if(C&&@isObject(C)&&@isPromise(C))return async function(D,F,G){while(!z)await G(D);return await F}(B,promise,q);return O.@promise}catch(C){return v=!0,@readableStreamError(j,C),@Promise.@reject(C)}finally{if(!v&&j)@readableStreamClose(j);B=A=_=q=j=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,_){\"use strict\";var q=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var x=@getByIdDirectPrivate(O,\"highWaterMark\");q.start(x\?{highWaterMark:x}:{});var v=@newPromiseCapability(@Promise),A=!1,z=_.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=z(C);if(F&&@isObject(F)&&@isPromise(F))return async function(G,j,w){while(!A)await w(G);return await j}(C,promise,z);return v.@promise}catch(F){return D=!0,@readableStreamError(O,F),@Promise.@reject(F)}finally{if(!D&&O)@readableStreamClose(O);C=B=q=z=O=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,f){\"use strict\";const h=@initializeTextStream.@call(_,f,@undefined);var j=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await j.read();if(k.done)break}try{j.releaseLock()}catch(p){}return j=@undefined,_=@undefined,h.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var k=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(_){}return k=@undefined,f=@undefined,j.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,j){\"use strict\";const k=@initializeArrayStream.@call(_,j,@undefined);j=@undefined;var p=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var q=await p.read();if(q.done)break}try{p.releaseLock()}catch(f){}return p=@undefined,@Promise.@resolve(k.@promise)}catch(f){throw f}finally{_=@undefined,p=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,p){\"use strict\";const j=@initializeArrayStream.@call(_,p,@undefined);p=@undefined;var q=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await q.read();if(k.done)break}try{q.releaseLock()}catch(f){}return q=@undefined,@Promise.@resolve(j.@promise)}catch(f){throw f}finally{_=@undefined,q=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (k){\"use strict\";var z=globalThis.Symbol.asyncIterator,D=async function*B(G,x){var i=G.getReader(),w;try{while(!0){var q,h;const j=i.readMany();if(@isPromise(j))({done:q,value:h}=await j);else({done:q,value:h}=j);if(q)return;yield*h}}catch(j){w=j}finally{if(i.releaseLock(),!x)G.cancel(w);if(w)throw w}},F=function B(){return D(this,!1)},g=function B({preventCancel:G=!1}={preventCancel:!1}){return D(this,G)};return @Object.@defineProperty(k,z,{value:F}),@Object.@defineProperty(k,\"values\",{value:g}),k})\n"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (k){\"use strict\";var g=globalThis.Symbol.asyncIterator,i=async function*D(q,F){var w=q.getReader(),G;try{while(!0){var x,h;const z=w.readMany();if(@isPromise(z))({done:x,value:h}=await z);else({done:x,value:h}=z);if(x)return;yield*h}}catch(z){G=z}finally{if(w.releaseLock(),!F)q.cancel(G);if(G)throw G}},B=function D(){return i(this,!1)},j=function D({preventCancel:q=!1}={preventCancel:!1}){return i(this,q)};return @Object.@defineProperty(k,g,{value:B}),@Object.@defineProperty(k,\"values\",{value:j}),k})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1894,7 +1894,7 @@ const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeCons const JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 339; static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),i=@getByIdDirectPrivate(_,\"readable\"),u=@getByIdDirectPrivate(i,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(u)})\n"; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),u=@getByIdDirectPrivate(_,\"readable\"),i=@getByIdDirectPrivate(u,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(i)})\n"; // enqueue const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1986,7 +1986,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var f=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(f)){const d=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(d){const u=d.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in f)||@isCallable(f))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(f).buffer)})\n"; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2020,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 T=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!T)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const C=@getByIdDirectPrivate(T,\"state\");if(@putByIdDirectPrivate(T,\"disturbed\",!0),C===@streamClosed)return{value:[],size:0,done:!0};else if(C===@streamErrored)throw @getByIdDirectPrivate(T,\"storedError\");var H=@getByIdDirectPrivate(T,\"readableStreamController\"),E=@getByIdDirectPrivate(H,\"queue\");if(!E)return H.@pull(H).@then(function({done:Q,value:w}){return Q\?{done:!0,value:[],size:0}:{value:[w],size:1,done:!1}});const F=E.content;var B=E.size,_=F.toArray(!1),I=_.length;if(I>0){var k=@newArrayWithSize(I);if(@isReadableByteStreamController(H)){{const Q=_[0];if(!(@ArrayBuffer.@isView(Q)||Q instanceof @ArrayBuffer))@putByValDirect(k,0,new @Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength));else @putByValDirect(k,0,Q)}for(var N=1;N{if(Q.done)return{value:[],size:0,done:!0};var w=@getByIdDirectPrivate(T,\"readableStreamController\"),d=@getByIdDirectPrivate(w,\"queue\"),J=[Q.value].concat(d.content.toArray(!1)),x=J.length;if(@isReadableByteStreamController(w))for(var K=0;K0){var j=@newArrayWithSize(S);if(@isReadableByteStreamController(J)){{const k=I[0];if(!(@ArrayBuffer.@isView(k)||k instanceof @ArrayBuffer))@putByValDirect(j,0,new @Uint8Array(k.buffer,k.byteOffset,k.byteLength));else @putByValDirect(j,0,k)}for(var _=1;_{if(k.done)return{value:[],size:0,done:!0};var K=@getByIdDirectPrivate(Q,\"readableStreamController\"),N=@getByIdDirectPrivate(K,\"queue\"),O=[k.value].concat(N.content.toArray(!1)),x=O.length;if(@isReadableByteStreamController(K))for(var d=0;d0}shift(){var{_head:w,_tail:x,_list:z,_capacityMask:k}=this;if(w===x)return @undefined;var A=z[w];if(@putByValDirect(z,w,@undefined),w=this._head=w+1&k,w<2&&x>1e4&&x<=z.length>>>2)this._shrinkArray();return A}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(w){var x=this._tail;if(@putByValDirect(this._list,x,w),this._tail=x+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(w){var x=this._list,z=@toLength(x.length);if(w||this._head>this._tail){var k=@toLength(this._head),A=@toLength(this._tail),B=@toLength(z-k+A),E=@newArrayWithSize(B),v=0;for(var F=k;F>>=1,this._capacityMask>>>=1}}return new g})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var b=@Array.prototype.slice;class z{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: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"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var _=@Loader.registry.@get(a);if(!_||!_.evaluated)_=@loadCJS2ESM(a);if(!_||!_.evaluated||!_.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var c=@Loader.getModuleNamespaceObject(_.module);if(c[@commonJSSymbol]===0)return;return c})\n"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var f=new Map,u={};return new Proxy(u,{get(c,L){const h=@requireMap.@get(L);if(h)return h;const g=@Loader.registry.@get(L);if(g\?.evaluated){const _=@Loader.getModuleNamespaceObject(g.module),b=_[@commonJSSymbol]===0||_.default\?.[@commonJSSymbol]\?_.default:_,t=@createCommonJSModule(L,b,!0);return @requireMap.@set(L,t),t}return u[L]},set(c,L,h){return @requireMap.@set(L,h),!0},has(c,L){return @requireMap.@has(L)||@Loader.registry.@has(L)},deleteProperty(c,L){return f.@delete(L),@requireMap.@delete(L),@Loader.registry.@delete(L),!0},ownKeys(c){var L=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let g of h)if(!L.includes(g))@arrayPush(L,g);return L},getPrototypeOf(c){return null},getOwnPropertyDescriptor(c,L){if(@requireMap.@has(L)||@Loader.registry.@has(L))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,f={};return new Proxy(f,{get(h,t){const u=@requireMap.@get(t);if(u)return u;const L=@Loader.registry.@get(t);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(t,c,!0);return @requireMap.@set(t,g),g}return f[t]},set(h,t,u){return @requireMap.@set(t,u),!0},has(h,t){return @requireMap.@has(t)||@Loader.registry.@has(t)},deleteProperty(h,t){return _.@delete(t),@requireMap.@delete(t),@Loader.registry.@delete(t),!0},ownKeys(h){var t=[...@requireMap.@keys()];const u=[...@Loader.registry.@keys()];for(let L of u)if(!t.includes(L))@arrayPush(t,L);return t},getPrototypeOf(h){return null},getOwnPropertyDescriptor(h,t){if(@requireMap.@has(t)||@Loader.registry.@has(t))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2432,7 +2432,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,B){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(B===@undefined)B={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(B!==@undefined&&!@isObject(B))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const b=f.type===\"direct\",m=!!f.@lazy,v=b||m;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!v){const I=@getByIdDirectPrivate(B,\"size\"),_=@getByIdDirectPrivate(B,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",_),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,I,_!==@undefined\?_:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(b)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,B));else if(v){const I=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const _=@lazyLoadStream(this,I);if(_)@createReadableStreamController(this,_,B)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,B);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,b=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!b){const _=@getByIdDirectPrivate(m,\"size\"),I=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",I),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,I!==@undefined\?I:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(b){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const I=@lazyLoadStream(this,_);if(I)@createReadableStreamController(this,I,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2448,7 +2448,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKi const JSC::ImplementationVisibility s_readableStreamReadableStreamToTextCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToTextCodeLength = 171; static const JSC::Intrinsic s_readableStreamReadableStreamToTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToTextCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToTextDirect(_,p);return @readableStreamIntoText(_)})\n"; +const char* const s_readableStreamReadableStreamToTextCode = "(function (p){\"use strict\";var _=@getByIdDirectPrivate(p,\"underlyingSource\");if(_!==@undefined)return @readableStreamToTextDirect(p,_);return @readableStreamIntoText(p)})\n"; // readableStreamToArrayBuffer const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2456,7 +2456,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2480,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 (q,w,x){\"use strict\";const A=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var F=globalThis[A];if(!F)F=globalThis[A]=[];var I=F[w];if(I===@undefined){var[j,J,K,L,G,_]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](w);I=class H{handleError;handleClosed;processResult;constructor(D,N){this.#_=N,this.#F=D,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),D.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var D=this.#_;this.#_=0,L(D),_(D)}_handleError(D){if(this.#$)return;this.#$=!0;var N=this.#_;this.#_=0,J(N,D),_(N)}#_;#$=!1;#F;_handleReadMany({value:D,done:N,size:k}){if(N){this.handleClosed();return}if(this.#$)return;K(this.#_,D,N,k)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(D){if(D&&@isPromise(D)){if(@getPromiseInternalField(D,@promiseFieldFlags)&@promiseStateFulfilled){const k=@getPromiseInternalField(D,@promiseFieldReactionsOrResult);if(k)D=k}}if(D&&@isPromise(D))return D.then(this.processResult,this.handleError),null;if(D.done)return this.handleClosed(),0;else if(D.value)return D.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const B=w+1;if(F.length{@putByIdDirectPrivate(R,\"started\",1),@assert(!@getByIdDirectPrivate(R,\"pulling\")),@assert(!@getByIdDirectPrivate(R,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(R)},(d)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(R,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (v,b,f){\"use strict\";if(!@isReadableStream(v))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(v,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",v),@putByIdDirectPrivate(this,\"underlyingByteSource\",b),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let p=@toNumber(f);if(@isNaN(p)||p<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",p);let d=b.autoAllocateChunkSize;if(d!==@undefined){if(d=@toNumber(d),d<=0||d===@Infinity||d===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",d),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const _=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(_,\"underlyingByteSource\"),\"start\",[_]).@then(()=>{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(_)},(R)=>{if(@getByIdDirectPrivate(v,\"state\")===@streamReadable)@readableByteStreamControllerError(_,R)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2676,7 +2676,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var p=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=p.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2740,7 +2740,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const P=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(P)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const R=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=R.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let h;try{h=new @Uint8Array(R.buffer,R.byteOffset,R.byteLength)}catch(F){return @Promise.@reject(F)}return @createFulfilledPromise({value:h,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let R;try{R=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(F){return @Promise.@reject(F)}const h={buffer:R,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(h)}const d=@readableStreamAddReadRequest(P);return @readableByteStreamControllerCallPullIfNeeded(_),d})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(d)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const R=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=R.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let F;try{F=new @Uint8Array(R.buffer,R.byteOffset,R.byteLength)}catch(P){return @Promise.@reject(P)}return @createFulfilledPromise({value:F,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let R;try{R=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(P){return @Promise.@reject(P)}const F={buffer:R,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(F)}const h=@readableStreamAddReadRequest(d);return @readableByteStreamControllerCallPullIfNeeded(_),h})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2780,7 +2780,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1076; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,d){\"use strict\";const f=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(f,\"state\")===@streamReadable),@getByIdDirectPrivate(f,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(f,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(f,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const _=d.constructor===@Uint8Array\?d:new @Uint8Array(d.buffer,d.byteOffset,d.byteLength);@readableStreamFulfillReadRequest(f,_,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(f)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);break}}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,f){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(d,\"state\")===@streamReadable),@getByIdDirectPrivate(d,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(d,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(d,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(f.buffer),f.byteOffset,f.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const _=f.constructor===@Uint8Array\?f:new @Uint8Array(f.buffer,f.byteOffset,f.byteLength);@readableStreamFulfillReadRequest(d,_,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(f.buffer),f.byteOffset,f.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(d)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(f.buffer),f.byteOffset,f.byteLength);break}}})\n"; // readableByteStreamControllerEnqueueChunk const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2796,7 +2796,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 417; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (u,a){\"use strict\";@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty());let d=@getByIdDirectPrivate(u,\"pendingPullIntos\").peek();if(d.byteOffset+d.bytesFilled!==a.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(d.byteLength!==a.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");d.buffer=a.buffer,@readableByteStreamControllerRespondInternal(u,a.byteLength)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (u,d){\"use strict\";@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty());let a=@getByIdDirectPrivate(u,\"pendingPullIntos\").peek();if(a.byteOffset+a.bytesFilled!==d.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(a.byteLength!==d.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");a.buffer=d.buffer,@readableByteStreamControllerRespondInternal(u,d.byteLength)})\n"; // readableByteStreamControllerRespond const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2812,7 +2812,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength = 464; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,u){\"use strict\";let k=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),_=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(_,\"state\")===@streamClosed){if(u!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,k)}else @assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,u,k)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,u){\"use strict\";let _=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),k=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){if(u!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,_)}else @assert(@getByIdDirectPrivate(k,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,u,_)})\n"; // readableByteStreamControllerRespondInReadableState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2820,7 +2820,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,R,_){\"use strict\";if(_.bytesFilled+R>_.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 (w,h,g){\"use strict\";if(g.bytesFilled+h>g.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===g),@readableByteStreamControllerInvalidateBYOBRequest(w),g.bytesFilled+=h,g.bytesFilled0){const _=g.byteOffset+g.bytesFilled,f=@cloneArrayBuffer(g.buffer,_-R,R);@readableByteStreamControllerEnqueueChunk(w,f,0,f.byteLength)}g.buffer=@transferBufferToCurrentRealm(g.buffer),g.bytesFilled-=R,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),g),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2828,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,_){\"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"; +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"; // readableByteStreamControllerProcessPullDescriptors const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2844,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 (q,j){\"use strict\";const k=j.bytesFilled-j.bytesFilled%j.elementSize,v=@getByIdDirectPrivate(q,\"queue\").sizek)E=z-j.bytesFilled,G=!0;while(E>0){let H=@getByIdDirectPrivate(q,\"queue\").content.peek();const J=E0),@assert(j.bytesFilledj)z=w-_.bytesFilled,E=!0;while(z>0){let G=@getByIdDirectPrivate(q,\"queue\").content.peek();const H=z0),@assert(_.bytesFilled<_.elementSize);return E})\n"; // readableByteStreamControllerShiftPendingDescriptor const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2852,7 +2852,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength = 150; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode = "(function (u){\"use strict\";let _=@getByIdDirectPrivate(u,\"pendingPullIntos\").shift();return @readableByteStreamControllerInvalidateBYOBRequest(u),_})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode = "(function (_){\"use strict\";let u=@getByIdDirectPrivate(_,\"pendingPullIntos\").shift();return @readableByteStreamControllerInvalidateBYOBRequest(_),u})\n"; // readableByteStreamControllerInvalidateBYOBRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2900,7 +2900,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength = 1255; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (_,A){\"use strict\";const b=@getByIdDirectPrivate(_,\"controlledReadableStream\");let d=1;if(A.BYTES_PER_ELEMENT!==@undefined)d=A.BYTES_PER_ELEMENT;const k=A.constructor,E={buffer:A.buffer,byteOffset:A.byteOffset,byteLength:A.byteLength,bytesFilled:0,elementSize:d,ctor:k,readerType:\"byob\"};var L=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(L\?.isNotEmpty())return E.buffer=@transferBufferToCurrentRealm(E.buffer),L.push(E),@readableStreamAddReadIntoRequest(b);if(@getByIdDirectPrivate(b,\"state\")===@streamClosed){const R=new k(E.buffer,E.byteOffset,0);return @createFulfilledPromise({value:R,done:!0})}if(@getByIdDirectPrivate(_,\"queue\").size>0){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(b);return @readableByteStreamControllerCallPullIfNeeded(_),N})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (b,A){\"use strict\";const E=@getByIdDirectPrivate(b,\"controlledReadableStream\");let L=1;if(A.BYTES_PER_ELEMENT!==@undefined)L=A.BYTES_PER_ELEMENT;const d=A.constructor,N={buffer:A.buffer,byteOffset:A.byteOffset,byteLength:A.byteLength,bytesFilled:0,elementSize:L,ctor:d,readerType:\"byob\"};var _=@getByIdDirectPrivate(b,\"pendingPullIntos\");if(_\?.isNotEmpty())return N.buffer=@transferBufferToCurrentRealm(N.buffer),_.push(N),@readableStreamAddReadIntoRequest(E);if(@getByIdDirectPrivate(E,\"state\")===@streamClosed){const k=new d(N.buffer,N.byteOffset,0);return @createFulfilledPromise({value:k,done:!0})}if(@getByIdDirectPrivate(b,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,N)){const k=@readableByteStreamControllerConvertDescriptor(N);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}N.buffer=@transferBufferToCurrentRealm(N.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(N);const R=@readableStreamAddReadIntoRequest(E);return @readableByteStreamControllerCallPullIfNeeded(b),R})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2952,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 B 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,Q){const F=W.data,G=F.#L\?`Last-Event-ID: ${F.#L}\\r\\n`:\"\",j=`GET ${Q.pathname}${Q.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${G}\\r\\n`,X=W.write(j);if(X!==j.length)F.#K=j.substring(X)}static#Y(W,Q,F){for(;;){if(F>=Q.length)return;let G=-1,j=Q.indexOf(\"\\r\\n\",F);const X=j+2;if(j>0)if(W.#O===0){const z=parseInt(Q.substring(F,j),16);if(z===0){W.#j=2,W.#G\?.end();return}G=X+z}else G=Q.length;else{if(W.#J.length===0){W.#J+=Q.substring(F);return}G=Q.length}let Y=Q.substring(X,G);F=G+2;let J=0,Z=Y.indexOf(\"\\n\\n\");if(Z==-1){W.#J+=Q.substring(X);return}if(W.#J.length)W.#J+=Y,Y=W.#J,W.#J=\"\";let K=!0;while(K){const z=Y.substring(J,Z);let L,w=\"\",A,H=0,M=-1;for(;;){let U=z.indexOf(\"\\n\",H);if(U===-1){if(H>=z.length)break;U=z.length}const V=z.substring(H,U);if(V.startsWith(\"data:\"))if(w.length)w+=`\\n${V.substring(5).trim()}`;else w=V.substring(5).trim();else if(V.startsWith(\"event:\"))L=V.substring(6).trim();else if(V.startsWith(\"id:\"))A=V.substring(3).trim();else if(V.startsWith(\"retry:\")){if(M=parseInt(V.substring(6).trim(),10),@isNaN(M))M=-1}H=U+1}if(W.#L=A||\"\",M>=0)W.#U=M;if(w||A||L)W.dispatchEvent(new MessageEvent(L||\"message\",{data:w||\"\",origin:W.#$.origin,source:W,lastEventId:A}));if(Y.length===Z+2){K=!1;break}const O=Y.indexOf(\"\\n\\n\",Z+1);if(O===-1)break;J=Z,Z=O}}}static#Z={open(W){const Q=W.data;if(Q.#G=W,!Q.#F)B.#X(W,Q.#$)},handshake(W,Q,F){const G=W.data;if(Q)B.#X(W,G.#$);else G.#j=2,G.dispatchEvent(new ErrorEvent(\"error\",{error:F})),W.end()},data(W,Q){const F=W.data;switch(F.#j){case 0:{let G=Q.toString();const j=G.indexOf(\"\\r\\n\\r\\n\");if(j===-1){F.#J+=G;return}if(F.#J.length)F.#J+=G,G=F.#J,F.#J=\"\";const X=G.substring(0,j),Y=X.indexOf(\"\\r\\n\");if(Y===-1){F.#j=2,F.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),W.end();return}const J=X.substring(0,Y);if(J!==\"HTTP/1.1 200 OK\"){F.#j=2,F.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(J)})),W.end();return}let Z=Y+1,K=!1,z=-1;for(;;){let w=X.indexOf(\"\\r\\n\",Z);if(w===-1){if(Z>=X.length){if(!K)F.#j=2,F.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}w=X.length}const A=X.substring(Z+1,w),H=A.indexOf(\":\"),M=A.substring(0,H),O=M.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(Z=w+1,O)if(A.endsWith(\" text/event-stream\"))K=!0;else{F.#j=2,F.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(M.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(z=parseInt(A.substring(H+1).trim(),10),@isNaN(z)||z<=0){F.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),W.end();return}if(K)break}else if(M.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(A.substring(H+1).trim()!==\"chunked\"){F.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),W.end();return}if(z=0,K)break}}F.#O=z,F.#j=1,F.dispatchEvent(new Event(\"open\"));const L=G.substring(j+4);if(B.#Y(F,L,0),F.#O>0){if(F.#Q+=L.length,F.#Q>=F.#O)F.#j=2,W.end()}return}case 1:if(B.#Y(F,Q.toString(),2),F.#O>0){if(F.#Q+=Q.byteLength,F.#Q>=F.#O)F.#j=2,W.end()}return;default:break}},drain(W){const Q=W.data;if(Q.#j===0){const F=Q.#J;if(F.length){const G=W.write(F);if(G!==F.length)W.data.#K=F.substring(G);else W.data.#K=\"\"}}},close:B.#z,end(W){B.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(W){B.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(W){const Q=W.data;if(Q.#G=null,Q.#Q=0,Q.#j=2,Q.#M){if(Q.#V)clearTimeout(Q.#V);Q.#V=setTimeout(B.#W,Q.#U,Q)}return Q}constructor(W,Q=@undefined){super();const F=new URL(W);this.#F=F.protocol===\"https:\",this.#$=F,this.#j=2,process.nextTick(B.#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.#$,Q=this.#F;this.#j=0,@Bun.connect({data:this,socket:B.#Z,hostname:W.hostname,port:parseInt(W.port||(Q\?\"443\":\"80\"),10),tls:Q\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((F)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:F})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(B.#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(B.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(B.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(B.prototype,\"CLOSED\",{enumerable:!0,value:2}),B[Symbol.for(\"CommonJS\")]=0,B})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class A 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(Q){Q.#H()}static#X(Q,U){const V=Q.data,B=V.#L\?`Last-Event-ID: ${V.#L}\\r\\n`:\"\",W=`GET ${U.pathname}${U.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${B}\\r\\n`,X=Q.write(W);if(X!==W.length)V.#K=W.substring(X)}static#Y(Q,U,V){for(;;){if(V>=U.length)return;let B=-1,W=U.indexOf(\"\\r\\n\",V);const X=W+2;if(W>0)if(Q.#O===0){const j=parseInt(U.substring(V,W),16);if(j===0){Q.#j=2,Q.#G\?.end();return}B=X+j}else B=U.length;else{if(Q.#J.length===0){Q.#J+=U.substring(V);return}B=U.length}let M=U.substring(X,B);V=B+2;let F=0,Y=M.indexOf(\"\\n\\n\");if(Y==-1){Q.#J+=U.substring(X);return}if(Q.#J.length)Q.#J+=M,M=Q.#J,Q.#J=\"\";let G=!0;while(G){const j=M.substring(F,Y);let J,Z=\"\",O,w=0,K=-1;for(;;){let L=j.indexOf(\"\\n\",w);if(L===-1){if(w>=j.length)break;L=j.length}const H=j.substring(w,L);if(H.startsWith(\"data:\"))if(Z.length)Z+=`\\n${H.substring(5).trim()}`;else Z=H.substring(5).trim();else if(H.startsWith(\"event:\"))J=H.substring(6).trim();else if(H.startsWith(\"id:\"))O=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(K=parseInt(H.substring(6).trim(),10),@isNaN(K))K=-1}w=L+1}if(Q.#L=O||\"\",K>=0)Q.#U=K;if(Z||O||J)Q.dispatchEvent(new MessageEvent(J||\"message\",{data:Z||\"\",origin:Q.#$.origin,source:Q,lastEventId:O}));if(M.length===Y+2){G=!1;break}const z=M.indexOf(\"\\n\\n\",Y+1);if(z===-1)break;F=Y,Y=z}}}static#Z={open(Q){const U=Q.data;if(U.#G=Q,!U.#F)A.#X(Q,U.#$)},handshake(Q,U,V){const B=Q.data;if(U)A.#X(Q,B.#$);else B.#j=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:V})),Q.end()},data(Q,U){const V=Q.data;switch(V.#j){case 0:{let B=U.toString();const W=B.indexOf(\"\\r\\n\\r\\n\");if(W===-1){V.#J+=B;return}if(V.#J.length)V.#J+=B,B=V.#J,V.#J=\"\";const X=B.substring(0,W),M=X.indexOf(\"\\r\\n\");if(M===-1){V.#j=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),Q.end();return}const F=X.substring(0,M);if(F!==\"HTTP/1.1 200 OK\"){V.#j=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(F)})),Q.end();return}let Y=M+1,G=!1,j=-1;for(;;){let Z=X.indexOf(\"\\r\\n\",Y);if(Z===-1){if(Y>=X.length){if(!G)V.#j=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),Q.end();return}Z=X.length}const O=X.substring(Y+1,Z),w=O.indexOf(\":\"),K=O.substring(0,w),z=K.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(Y=Z+1,z)if(O.endsWith(\" text/event-stream\"))G=!0;else{V.#j=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),Q.end();return}else if(K.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(j=parseInt(O.substring(w+1).trim(),10),@isNaN(j)||j<=0){V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),Q.end();return}if(G)break}else if(K.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(O.substring(w+1).trim()!==\"chunked\"){V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),Q.end();return}if(j=0,G)break}}V.#O=j,V.#j=1,V.dispatchEvent(new Event(\"open\"));const J=B.substring(W+4);if(A.#Y(V,J,0),V.#O>0){if(V.#Q+=J.length,V.#Q>=V.#O)V.#j=2,Q.end()}return}case 1:if(A.#Y(V,U.toString(),2),V.#O>0){if(V.#Q+=U.byteLength,V.#Q>=V.#O)V.#j=2,Q.end()}return;default:break}},drain(Q){const U=Q.data;if(U.#j===0){const V=U.#J;if(V.length){const B=Q.write(V);if(B!==V.length)Q.data.#K=V.substring(B);else Q.data.#K=\"\"}}},close:A.#z,end(Q){A.#z(Q).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(Q){A.#z(Q).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(Q){const U=Q.data;if(U.#G=null,U.#Q=0,U.#j=2,U.#M){if(U.#V)clearTimeout(U.#V);U.#V=setTimeout(A.#W,U.#U,U)}return U}constructor(Q,U=@undefined){super();const V=new URL(Q);this.#F=V.protocol===\"https:\",this.#$=V,this.#j=2,process.nextTick(A.#W,this)}ref(){this.#V\?.ref(),this.#G\?.ref()}unref(){this.#V\?.unref(),this.#G\?.unref()}#H(){if(this.#j!==2)return;const Q=this.#$,U=this.#F;this.#j=0,@Bun.connect({data:this,socket:A.#Z,hostname:Q.hostname,port:parseInt(Q.port||(U\?\"443\":\"80\"),10),tls:U\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((V)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:V})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(A.#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(Q){if(this.#B)super.removeEventListener(\"close\",this.#B);super.addEventListener(\"open\",Q),this.#B=Q}set onerror(Q){if(this.#w)super.removeEventListener(\"error\",this.#w);super.addEventListener(\"error\",Q),this.#w=Q}set onmessage(Q){if(this.#A)super.removeEventListener(\"message\",this.#A);super.addEventListener(\"message\",Q),this.#A=Q}}return Object.defineProperty(A.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(A.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(A.prototype,\"CLOSED\",{enumerable:!0,value:2}),A[Symbol.for(\"CommonJS\")]=0,A})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/src/js/out/modules/node/assert.js b/src/js/out/modules/node/assert.js index dbcaf0a02..4086ef8d5 100644 --- a/src/js/out/modules/node/assert.js +++ b/src/js/out/modules/node/assert.js @@ -1,53 +1,53 @@ -import J from"node:util";var f1=function(){throw new Error("CallTracker is not supported yet")},{Bun:j1}=globalThis[Symbol.for("Bun.lazy")]("primordials"),O=j1.deepEquals,N=(X,_)=>function(){return _||(0,X[Object.keys(X)[0]])((_={exports:{}}).exports,_),_.exports},z=N({"assert/build/internal/errors.js"(X,_){function u(H1){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(Q1){return typeof Q1}:u=function(Q1){return Q1&&typeof Symbol=="function"&&Q1.constructor===Symbol&&Q1!==Symbol.prototype?"symbol":typeof Q1},u(H1)}function n(H1,Q1){if(!(H1 instanceof Q1))throw new TypeError("Cannot call a class as a function")}function i(H1,Q1){return Q1&&(u(Q1)==="object"||typeof Q1=="function")?Q1:U(H1)}function U(H1){if(H1===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return H1}function p(H1){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(Q1){return Q1.__proto__||Object.getPrototypeOf(Q1)},p(H1)}function l(H1,Q1){if(typeof Q1!="function"&&Q1!==null)throw new TypeError("Super expression must either be null or a function");H1.prototype=Object.create(Q1&&Q1.prototype,{constructor:{value:H1,writable:!0,configurable:!0}}),Q1&&c(H1,Q1)}function c(H1,Q1){return c=Object.setPrototypeOf||function(Z1,W){return Z1.__proto__=W,Z1},c(H1,Q1)}var o={},$,a;function t(H1,Q1,Z1){Z1||(Z1=Error);function W(z1,X1,U1){return typeof Q1=="string"?Q1:Q1(z1,X1,U1)}var J1=function(z1){l(X1,z1);function X1(U1,Y,$1){var K1;return n(this,X1),K1=i(this,p(X1).call(this,W(U1,Y,$1))),K1.code=H1,K1}return X1}(Z1);o[H1]=J1}function r(H1,Q1){if(Array.isArray(H1)){var Z1=H1.length;return H1=H1.map(function(W){return String(W)}),Z1>2?"one of ".concat(Q1," ").concat(H1.slice(0,Z1-1).join(", "),", or ")+H1[Z1-1]:Z1===2?"one of ".concat(Q1," ").concat(H1[0]," or ").concat(H1[1]):"of ".concat(Q1," ").concat(H1[0])}else return"of ".concat(Q1," ").concat(String(H1))}function s(H1,Q1,Z1){return H1.substr(!Z1||Z1<0?0:+Z1,Q1.length)===Q1}function K(H1,Q1,Z1){return(Z1===void 0||Z1>H1.length)&&(Z1=H1.length),H1.substring(Z1-Q1.length,Z1)===Q1}function e(H1,Q1,Z1){return typeof Z1!="number"&&(Z1=0),Z1+Q1.length>H1.length?!1:H1.indexOf(Q1,Z1)!==-1}t("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),t("ERR_INVALID_ARG_TYPE",function(H1,Q1,Z1){$===void 0&&($=F()),$(typeof H1=="string","'name' must be a string");var W;typeof Q1=="string"&&s(Q1,"not ")?(W="must not be",Q1=Q1.replace(/^not /,"")):W="must be";var J1;if(K(H1," argument"))J1="The ".concat(H1," ").concat(W," ").concat(r(Q1,"type"));else{var z1=e(H1,".")?"property":"argument";J1='The "'.concat(H1,'" ').concat(z1," ").concat(W," ").concat(r(Q1,"type"))}return J1+=". Received type ".concat(u(Z1)),J1},TypeError),t("ERR_INVALID_ARG_VALUE",function(H1,Q1){var Z1=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid",W=a.inspect(Q1);return W.length>128&&(W="".concat(W.slice(0,128),"...")),"The argument '".concat(H1,"' ").concat(Z1,". Received ").concat(W)},TypeError,RangeError),t("ERR_INVALID_RETURN_VALUE",function(H1,Q1,Z1){var W;return Z1&&Z1.constructor&&Z1.constructor.name?W="instance of ".concat(Z1.constructor.name):W="type ".concat(u(Z1)),"Expected ".concat(H1,' to be returned from the "').concat(Q1,'"')+" function but got ".concat(W,".")},TypeError),t("ERR_MISSING_ARGS",function(){for(var H1=arguments.length,Q1=new Array(H1),Z1=0;Z10,"At least one arg needs to be specified");var W="The ",J1=Q1.length;switch(Q1=Q1.map(function(z1){return'"'.concat(z1,'"')}),J1){case 1:W+="".concat(Q1[0]," argument");break;case 2:W+="".concat(Q1[0]," and ").concat(Q1[1]," arguments");break;default:W+=Q1.slice(0,J1-1).join(", "),W+=", and ".concat(Q1[J1-1]," arguments");break}return"".concat(W," must be specified")},TypeError),_.exports.codes=o}}),I=N({"assert/build/internal/assert/assertion_error.js"(X,_){function u(V1){for(var D1=1;D1V1.length)&&(M1=V1.length),V1.substring(M1-D1.length,M1)===D1}function J1(V1,D1){if(D1=Math.floor(D1),V1.length==0||D1==0)return"";var M1=V1.length*D1;for(D1=Math.floor(Math.log(D1)/Math.log(2));D1;)V1+=V1,D1--;return V1+=V1.substring(0,M1-V1.length),V1}var z1="",X1="",U1="",Y="",$1={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:"},K1=10;function W1(V1){var D1=Object.keys(V1),M1=Object.create(Object.getPrototypeOf(V1));return D1.forEach(function(V){M1[V]=V1[V]}),Object.defineProperty(M1,"message",{value:V1.message}),M1}function Y1(V1){return H1(V1,{compact:!1,customInspect:!1,depth:1000,maxArrayLength:Infinity,showHidden:!1,breakLength:Infinity,showProxy:!1,sorted:!0,getters:!0})}function B(V1,D1,M1){var V="",q1="",v1=0,G1="",T1=!1,D=Y1(V1),w1=D.split(` -`),O1=Y1(D1).split(` -`),M=0,H="";if(M1==="strictEqual"&&e(V1)==="object"&&e(D1)==="object"&&V1!==null&&D1!==null&&(M1="strictEqualObject"),w1.length===1&&O1.length===1&&w1[0]!==O1[0]){var q=w1[0].length+O1[0].length;if(q<=K1){if((e(V1)!=="object"||V1===null)&&(e(D1)!=="object"||D1===null)&&(V1!==0||D1!==0))return"".concat($1[M1],` +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(w1[0]," !== ").concat(O1[0],` -`)}else if(M1!=="strictEqualObject"){var F1=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(q2&&(H=` - `.concat(J1(" ",M),"^"),M=0)}}}for(var N1=w1[w1.length-1],v=O1[O1.length-1];N1===v&&(M++<2?G1=` - `.concat(N1).concat(G1):V=N1,w1.pop(),O1.pop(),!(w1.length===0||O1.length===0));)N1=w1[w1.length-1],v=O1[O1.length-1];var Q=Math.max(w1.length,O1.length);if(Q===0){var G=D.split(` -`);if(G.length>30)for(G[26]="".concat(z1,"...").concat(Y);G.length>27;)G.pop();return"".concat($1.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(G.join(` +`).concat(t.join(` `),` -`)}M>3&&(G1=` -`.concat(z1,"...").concat(Y).concat(G1),T1=!0),V!==""&&(G1=` - `.concat(V).concat(G1),V="");var I1=0,P1=$1[M1]+` -`.concat(X1,"+ actual").concat(Y," ").concat(U1,"- expected").concat(Y),T=" ".concat(z1,"...").concat(Y," Lines skipped");for(M=0;M1&&M>2&&(Z>4?(q1+=` -`.concat(z1,"...").concat(Y),T1=!0):Z>3&&(q1+=` - `.concat(O1[M-2]),I1++),q1+=` - `.concat(O1[M-1]),I1++),v1=M,V+=` -`.concat(U1,"-").concat(Y," ").concat(O1[M]),I1++;else if(O1.length1&&M>2&&(Z>4?(q1+=` -`.concat(z1,"...").concat(Y),T1=!0):Z>3&&(q1+=` - `.concat(w1[M-2]),I1++),q1+=` - `.concat(w1[M-1]),I1++),v1=M,q1+=` -`.concat(X1,"+").concat(Y," ").concat(w1[M]),I1++;else{var w=O1[M],A1=w1[M],S1=A1!==w&&(!W(A1,",")||A1.slice(0,-1)!==w);S1&&W(w,",")&&w.slice(0,-1)===A1&&(S1=!1,A1+=","),S1?(Z>1&&M>2&&(Z>4?(q1+=` -`.concat(z1,"...").concat(Y),T1=!0):Z>3&&(q1+=` - `.concat(w1[M-2]),I1++),q1+=` - `.concat(w1[M-1]),I1++),v1=M,q1+=` -`.concat(X1,"+").concat(Y," ").concat(A1),V+=` -`.concat(U1,"-").concat(Y," ").concat(w),I1+=2):(q1+=V,V="",(Z===1||M===0)&&(q1+=` - `.concat(A1),I1++))}if(I1>20&&M30)for(M[26]="".concat(z1,"...").concat(Y);M.length>27;)M.pop();M.length===1?V=l(this,K(D1).call(this,"".concat(O1," ").concat(M[0]))):V=l(this,K(D1).call(this,"".concat(O1,` +`)}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(M.join(` +`).concat(n.join(` `),` -`)))}else{var H=Y1(T1),q="",F1=$1[v1];v1==="notDeepEqual"||v1==="notEqual"?(H="".concat($1[v1],` +`)))}else{var i=f(g),p="",l=S[x];x==="notDeepEqual"||x==="notEqual"?(i="".concat(S[x],` -`).concat(H),H.length>1024&&(H="".concat(H.slice(0,1021),"..."))):(q="".concat(Y1(D)),H.length>512&&(H="".concat(H.slice(0,509),"...")),q.length>512&&(q="".concat(q.slice(0,509),"...")),v1==="deepEqual"||v1==="equal"?H="".concat(F1,` +`).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(H,` +`).concat(i,` should equal -`):q=" ".concat(v1," ").concat(q)),V=l(this,K(D1).call(this,"".concat(H).concat(q)))}return Error.stackTraceLimit=w1,V.generatedMessage=!q1,Object.defineProperty(c(V),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),V.code="ERR_ASSERTION",V.actual=T1,V.expected=D,V.operator=v1,Error.captureStackTrace&&Error.captureStackTrace(c(V),G1),V.stack,V.name="AssertionError",l(V)}return p(D1,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:H1.custom,value:function(M1,V){return H1(this,u({},V,{customInspect:!1,depth:0}))}}]),D1}($(Error));_.exports=B1}}),F=N({"assert/build/assert.js"(X,_){function u(v1){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(G1){return typeof G1}:u=function(G1){return G1&&typeof Symbol=="function"&&G1.constructor===Symbol&&G1!==Symbol.prototype?"symbol":typeof G1},u(v1)}function n(v1,G1){if(!(v1 instanceof G1))throw new TypeError("Cannot call a class as a function")}var i=z(),U=i.codes,p=U.ERR_AMBIGUOUS_ARGUMENT,l=U.ERR_INVALID_ARG_TYPE,c=U.ERR_INVALID_ARG_VALUE,o=U.ERR_INVALID_RETURN_VALUE,$=U.ERR_MISSING_ARGS,a=I(),t=J,r=t.inspect,s=J.types,K=s.isPromise,e=s.isRegExp,H1=Object.assign,Q1=Object.is,Z1=new Map,W=!1,J1=_.exports=$1,z1={};function X1(v1){throw v1.message instanceof Error?v1.message:new a(v1)}function U1(v1,G1,T1,D,w1){var O1=arguments.length,M;if(O1===0)M="Failed";else if(O1===1)T1=v1,v1=void 0;else{if(W===!1){W=!0;var H=process.emitWarning?process.emitWarning:console.warn.bind(console);H("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}O1===2&&(D="!=")}if(T1 instanceof Error)throw T1;var q={actual:v1,expected:G1,operator:D===void 0?"fail":D,stackStartFn:w1||U1};T1!==void 0&&(q.message=T1);var F1=new a(q);throw M&&(F1.message=M,F1.generatedMessage=!0),F1}J1.fail=U1,J1.AssertionError=a;function Y(v1,G1,T1,D){if(!T1){var w1=!1;if(G1===0)w1=!0,D="No value argument passed to `assert.ok()`";else if(D instanceof Error)throw D;var O1=new a({actual:T1,expected:!0,message:D,operator:"==",stackStartFn:v1});throw O1.generatedMessage=w1,O1}}function $1(){for(var v1=arguments.length,G1=new Array(v1),T1=0;T11?T1-1:0),w1=1;w11?T1-1:0),w1=1;w11?T1-1:0),w1=1;w11?T1-1:0),w1=1;w11?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_{if(L.push({eventType:r,filename:a}),n){const E=n;n=null,E()}}),{async*[Symbol.asyncIterator](){let r=!1;while(!r){while(L.length){let a=L.shift();if(a.eventType==="close"){r=!0;break}if(a.eventType==="error")throw r=!0,a.filename;yield a}await new Promise((a)=>n=a)}}}}var V=Bun.fs(),_="::bunternal::",q={[_]:(i)=>{var S={[_]:function(L,n,r){var a;try{a=i.apply(V,r),r=void 0}catch(E){r=void 0,n(E);return}L(a)}}[_];return async function(...L){return await new Promise((n,r)=>{process.nextTick(S,n,r,L)})}}}[_],k=q(V.accessSync),X=q(V.appendFileSync),l=q(V.closeSync),b=q(V.copyFileSync),R=q(V.existsSync),h=q(V.chownSync),j=q(V.chmodSync),N=q(V.fchmodSync),A=q(V.fchownSync),B=q(V.fstatSync),d=q(V.fsyncSync),P=q(V.ftruncateSync),p=q(V.futimesSync),O=q(V.lchmodSync),o=q(V.lchownSync),K=q(V.linkSync),Z=q(V.lstatSync),C=q(V.mkdirSync),D=q(V.mkdtempSync),y=q(V.openSync),c=q(V.readSync),G=q(V.writeSync),U=q(V.readdirSync),m=q(V.readFileSync),Q=q(V.writeFileSync),H=q(V.readlinkSync),v=q(V.realpathSync),x=q(V.renameSync),F=q(V.statSync),$=q(V.symlinkSync),W=q(V.truncateSync),w=q(V.unlinkSync),t=q(V.utimesSync),Y=q(V.lutimesSync),g=q(V.rmSync),T=q(V.rmdirSync),I=(i,S,L)=>{return new Promise((n,r)=>{try{var a=V.writevSync(i,S,L)}catch(E){r(E);return}n({bytesWritten:a,buffers:S})})},J=(i,S,L)=>{return new Promise((n,r)=>{try{var a=V.readvSync(i,S,L)}catch(E){r(E);return}n({bytesRead:a,buffers:S})})},M={access:k,appendFile:X,close:l,copyFile:b,exists:R,chown:h,chmod:j,fchmod:N,fchown:A,fstat:B,fsync:d,ftruncate:P,futimes:p,lchmod:O,lchown:o,link:K,lstat:Z,mkdir:C,mkdtemp:D,open:y,read:c,write:G,readdir:U,readFile:m,writeFile:Q,readlink:H,realpath:v,rename:x,stat:F,symlink:$,truncate:W,unlink:w,utimes:t,lutimes:Y,rm:g,rmdir:T,watch:z,writev:I,readv:J,constants,[Symbol.for("CommonJS")]:0};export{I as writev,Q as writeFile,G as write,z as watch,t as utimes,w as unlink,W as truncate,$ as symlink,F as stat,T as rmdir,g as rm,x as rename,v as realpath,J as readv,H as readlink,U as readdir,m as readFile,c as read,y as open,D as mkdtemp,C as mkdir,Y as lutimes,Z as lstat,K as link,o as lchown,O as lchmod,p as futimes,P as ftruncate,d as fsync,B as fstat,A as fchown,N as fchmod,R as exists,M as default,b as copyFile,l as close,h as chown,j as chmod,X as appendFile,k as access}; +function J(S,q={}){const z=[];if(S instanceof URL)throw new TypeError("Watch URLs are not supported yet");else if(Buffer.isBuffer(S))S=S.toString();else if(typeof S!=="string")throw new TypeError("Expected path to be a string or Buffer");let A=null;if(typeof q==="string")q={encoding:q};return H.watch(S,q||{},(B,C)=>{if(z.push({eventType:B,filename:C}),A){const D=A;A=null,D()}}),{async*[Symbol.asyncIterator](){let B=!1;while(!B){while(z.length){let C=z.shift();if(C.eventType==="close"){B=!0;break}if(C.eventType==="error")throw B=!0,C.filename;yield C}await new Promise((C)=>A=C)}}}}var H=Bun.fs(),G="::bunternal::",I={[G]:(S)=>{var q={[G]:function(z,A,B){var C;try{C=S.apply(H,B),B=void 0}catch(D){B=void 0,A(D);return}z(C)}}[G];return async function(...z){return await new Promise((A,B)=>{process.nextTick(q,A,B,z)})}}}[G],K=I(H.accessSync),L=I(H.appendFileSync),M=I(H.closeSync),N=I(H.copyFileSync),O=I(H.existsSync),P=I(H.chownSync),Q=I(H.chmodSync),U=I(H.fchmodSync),V=I(H.fchownSync),X=I(H.fstatSync),Y=I(H.fsyncSync),Z=I(H.ftruncateSync),_=I(H.futimesSync),$=I(H.lchmodSync),T=I(H.lchownSync),W=I(H.linkSync),k=I(H.lstatSync),E=I(H.mkdirSync),x=I(H.mkdtempSync),F=I(H.openSync),R=I(H.readSync),g=I(H.writeSync),h=I(H.readdirSync),j=I(H.readFileSync),w=I(H.writeFileSync),b=I(H.readlinkSync),u=I(H.realpathSync),d=I(H.renameSync),c=I(H.statSync),v=I(H.symlinkSync),a=I(H.truncateSync),y=I(H.unlinkSync),l=I(H.utimesSync),p=I(H.lutimesSync),m=I(H.rmSync),n=I(H.rmdirSync),t=(S,q,z)=>{return new Promise((A,B)=>{try{var C=H.writevSync(S,q,z)}catch(D){B(D);return}A({bytesWritten:C,buffers:q})})},o=(S,q,z)=>{return new Promise((A,B)=>{try{var C=H.readvSync(S,q,z)}catch(D){B(D);return}A({bytesRead:C,buffers:q})})},r={access:K,appendFile:L,close:M,copyFile:N,exists:O,chown:P,chmod:Q,fchmod:U,fchown:V,fstat:X,fsync:Y,ftruncate:Z,futimes:_,lchmod:$,lchown:T,link:W,lstat:k,mkdir:E,mkdtemp:x,open:F,read:R,write:g,readdir:h,readFile:j,writeFile:w,readlink:b,realpath:u,rename:d,stat:c,symlink:v,truncate:a,unlink:y,utimes:l,lutimes:p,rm:m,rmdir:n,watch:J,writev:t,readv:o,constants,[Symbol.for("CommonJS")]:0};export{t as writev,w as writeFile,g as write,J as watch,l as utimes,y as unlink,a as truncate,v as symlink,c as stat,n as rmdir,m as rm,d as rename,u as realpath,o as readv,b as readlink,h as readdir,j as readFile,R as read,F as open,x as mkdtemp,E as mkdir,p as lutimes,k as lstat,W as link,T as lchown,$ as lchmod,_ as futimes,Z as ftruncate,Y as fsync,X as fstat,V as fchown,U as fchmod,O as exists,r as default,N as copyFile,M as close,P as chown,Q as chmod,L as appendFile,K as access}; diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index 0a84f42b7..955c83642 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -1,7 +1,9 @@ import {EventEmitter} from "node:events"; import {Readable, Writable, Duplex} from "node:stream"; import {isTypedArray} from "node:util/types"; -var isIPv6 = function(input) { +var checkInvalidHeaderChar = function(val) { + return RegExpPrototypeExec.call(headerCharRegex, val) !== null; +}, 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) @@ -97,13 +99,20 @@ function get(url, options, cb) { const req = request(url, options, cb); return req.end(), req; } -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 { +var headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/, validateHeaderName = (name, label) => { + if (typeof name !== "string" || !name || !checkIsHttpToken(name)) + throw new Error("ERR_INVALID_HTTP_TOKEN"); +}, validateHeaderValue = (name, value) => { + if (value === void 0) + throw new Error("ERR_HTTP_INVALID_HEADER_VALUE"); + if (checkInvalidHeaderChar(value)) + throw new Error("ERR_INVALID_CHAR"); +}, { 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.", _defaultHTTPSAgent, kInternalRequest = Symbol("kInternalRequest"), kInternalSocketData = Symbol.for("::bunternal::"), kEmptyBuffer = Buffer.alloc(0), FakeSocket = class Socket extends Duplex { bytesRead = 0; bytesWritten = 0; connecting = !1; remoteAddress = null; - localAddress = "127.0.0.1"; remotePort; timeout = 0; isServer = !1; @@ -183,7 +192,7 @@ class Agent extends EventEmitter { totalSocketCount; #fakeSocket; static get globalAgent() { - return _globalAgent ??= new Agent; + return globalAgent; } static get defaultMaxSockets() { return Infinity; @@ -235,6 +244,7 @@ class Server extends EventEmitter { #tls; #is_tls = !1; listening = !1; + serverName; constructor(options, callback) { super(); if (typeof options === "function") @@ -386,12 +396,14 @@ class Server extends EventEmitter { } } class IncomingMessage extends Readable { + method; + complete; constructor(req, defaultIncomingOpts) { const method = req.method; super(); const url = new URL(req.url); var { type = "request", [kInternalRequest]: nodeReq } = defaultIncomingOpts || {}; - this.#noBody = type === "request" ? method === "GET" || method === "HEAD" || method === "TRACE" || method === "CONNECT" || method === "OPTIONS" || (parseInt(req.headers.get("Content-Length") || "") || 0) === 0 : !1, this.#req = req, this.method = method, this.#type = type, this.complete = !!this.#noBody, this.#bodyStream = null; + this.#noBody = type === "request" ? method === "GET" || method === "HEAD" || method === "TRACE" || method === "CONNECT" || method === "OPTIONS" || (parseInt(req.headers.get("Content-Length") || "") || 0) === 0 : !1, this.#req = req, this.method = method, this.#type = type, this.complete = !!this.#noBody, this.#bodyStream = void 0; const socket = new FakeSocket; socket.remoteAddress = url.hostname, socket.remotePort = url.port, this.#fakeSocket = socket, this.url = url.pathname + url.search, this.#nodeReq = nodeReq, assignHeaders(this, req); } @@ -399,8 +411,8 @@ class IncomingMessage extends Readable { rawHeaders; _consuming = !1; _dumped = !1; - #bodyStream = null; - #fakeSocket = void 0; + #bodyStream; + #fakeSocket; #noBody = !1; #aborted = !1; #req; @@ -422,42 +434,42 @@ class IncomingMessage extends Readable { } callback(); } - #closeBodyStream() { - debug("closeBodyStream()"); - var bodyStream = this.#bodyStream; - if (bodyStream == null) - return; - this.complete = !0, this.#bodyStream = void 0, this.push(null); + async#consumeStream(reader) { + while (!0) { + var { done, value } = await reader.readMany(); + if (this.#aborted) + return; + if (done) { + this.push(null), this.destroy(); + break; + } + for (var v of value) + this.push(v); + } } _read(size) { if (this.#noBody) this.push(null), this.complete = !0; else if (this.#bodyStream == null) { - const contentLength = this.#req.headers.get("content-length"); - let remaining = contentLength ? parseInt(contentLength, 10) : 0; - if (this.#bodyStream = Readable.fromWeb(this.#req.body, { - highWaterMark: Number.isFinite(remaining) ? Math.min(remaining, 16384) : 16384 - }), remaining > 0 && Number.isSafeInteger(remaining)) - this.#bodyStream.on("data", (chunk) => { - if (debug("body size known", remaining), this.push(chunk), remaining -= chunk?.byteLength ?? 0, remaining <= 0) - this.#closeBodyStream(); - }); - else - this.#bodyStream.on("data", (chunk) => { - this.push(chunk); - }); - this.#bodyStream && this.#bodyStream.on("end", () => { - this.#closeBodyStream(); - }); + const reader = this.#req.body?.getReader(); + if (!reader) { + this.push(null); + return; + } + this.#bodyStream = reader, this.#consumeStream(reader); } } get aborted() { return this.#aborted; } - abort() { + #abort() { if (this.#aborted) return; - this.#aborted = !0, this.#closeBodyStream(); + this.#aborted = !0; + var bodyStream = this.#bodyStream; + if (!bodyStream) + return; + bodyStream.cancel(), this.complete = !0, this.#bodyStream = void 0, this.push(null); } get connection() { return this.#fakeSocket; @@ -495,6 +507,9 @@ class IncomingMessage extends Readable { } class OutgoingMessage extends Writable { + constructor() { + super(...arguments); + } #headers; headersSent = !1; sendDate = !0; @@ -758,7 +773,7 @@ class ClientRequest extends OutgoingMessage { #useDefaultPort; #joinDuplicateHeaders; #maxHeaderSize; - #agent = _globalAgent; + #agent = globalAgent; #path; #socketPath; #body = null; @@ -862,14 +877,12 @@ class ClientRequest extends OutgoingMessage { options = ObjectAssign(input || {}, options); var defaultAgent = options._defaultAgent || Agent.globalAgent; let protocol = options.protocol; - if (!protocol) { + if (!protocol) if (options.port === 443) protocol = "https:"; else protocol = defaultAgent.protocol || "http:"; - this.#protocol = protocol; - } - switch (this.#agent?.protocol) { + switch (this.#protocol = protocol, this.#agent?.protocol) { case void 0: break; case "http:": @@ -1055,9 +1068,7 @@ var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, METHODS = [ 509: "Bandwidth Limit Exceeded", 510: "Not Extended", 511: "Network Authentication Required" -}; -_globalAgent ??= new Agent; -var defaultObject = { +}, globalAgent = new Agent, defaultObject = { Agent, Server, METHODS, @@ -1068,19 +1079,19 @@ var defaultObject = { request, get, maxHeaderSize: 16384, + validateHeaderName, + validateHeaderValue, setMaxIdleHTTPParsers(max) { debug(`${NODE_HTTP_WARNING}\n`, "setMaxIdleHTTPParsers() is a no-op"); }, - get globalAgent() { - return _globalAgent; - }, - set globalAgent(agent) { - }, + globalAgent, [Symbol.for("CommonJS")]: 0 }, http_default = defaultObject; export { + validateHeaderValue, + validateHeaderName, request, - _globalAgent as globalAgent, + 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 f6a4e25d0..4fbf284d5 100644 --- a/src/js/out/modules/node/https.js +++ b/src/js/out/modules/node/https.js @@ -1,5 +1,54 @@ -export * from "node:http"; -import {default as default2} from "node:http"; +import * as http from "node:http"; +var request2 = function(input, options, cb) { + if (input && typeof input === "object" && !(input instanceof URL)) + input.protocol ??= "https:"; + else if (typeof options === "object") + options.protocol ??= "https:"; + return http.request(input, options, cb); +}, get = function(input, options, cb) { + const req = request2(input, options, cb); + return req.end(), req; +}, { + Agent, + Server, + METHODS, + STATUS_CODES, + createServer, + ServerResponse, + IncomingMessage, + maxHeaderSize, + validateHeaderName, + validateHeaderValue, + globalAgent +} = http, defaultExport = { + Agent, + Server, + METHODS, + STATUS_CODES, + createServer, + ServerResponse, + IncomingMessage, + request: request2, + get, + maxHeaderSize, + validateHeaderName, + validateHeaderValue, + globalAgent +}; +var https_default = defaultExport; export { - default2 as default + validateHeaderValue, + validateHeaderName, + request2 as request, + maxHeaderSize, + globalAgent, + get, + https_default as default, + createServer, + ServerResponse, + Server, + STATUS_CODES, + METHODS, + IncomingMessage, + Agent }; diff --git a/src/js/private.d.ts b/src/js/private.d.ts index b689c208e..500048dd7 100644 --- a/src/js/private.d.ts +++ b/src/js/private.d.ts @@ -100,6 +100,7 @@ declare module "bun" { var main: string; var tty: Array<{ hasColors: boolean }>; var FFI: any; + var fetch: typeof globalThis.fetch; } declare var Loader: { diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts index b1910a1f7..3e7da9d34 100644 --- a/test/js/node/http/node-http.test.ts +++ b/test/js/node/http/node-http.test.ts @@ -1,5 +1,14 @@ // @ts-nocheck -import { createServer, request, get, Agent, globalAgent, Server } from "node:http"; +import { + createServer, + request, + get, + Agent, + globalAgent, + Server, + validateHeaderName, + validateHeaderValue, +} from "node:http"; import { createTest } from "node-harness"; const { describe, expect, it, beforeAll, afterAll, createDoneDotAll } = createTest(import.meta.path); @@ -624,4 +633,16 @@ describe("node:http", () => { }); }); }); + + test("validateHeaderName", () => { + validateHeaderName("Foo"); + expect(() => validateHeaderName("foo:")).toThrow(); + expect(() => validateHeaderName("foo:bar")).toThrow(); + }); + + test("validateHeaderValue", () => { + validateHeaderValue("Foo", "Bar"); + expect(() => validateHeaderValue("Foo", undefined as any)).toThrow(); + expect(() => validateHeaderValue("Foo", "Bar\r")).toThrow(); + }); }); -- cgit v1.2.3 From 039bbc68ad1f36ee7a734907ef657e90c7f504ac Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 29 Jun 2023 21:24:55 -0700 Subject: Add missing "prependListener" function --- src/bun.js/bindings/webcore/JSEventEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.cpp b/src/bun.js/bindings/webcore/JSEventEmitter.cpp index 995d845cf..1957b404b 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitter.cpp +++ b/src/bun.js/bindings/webcore/JSEventEmitter.cpp @@ -148,7 +148,7 @@ static const HashTableValue JSEventEmitterPrototypeTableValues[] = { { "addListener"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_addListener, 2 } }, { "on"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_addListener, 2 } }, { "once"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_addOnceListener, 2 } }, - { "prepend"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_prependListener, 2 } }, + { "prependListener"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_prependListener, 2 } }, { "prependOnce"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_prependOnceListener, 2 } }, { "removeListener"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_removeListener, 2 } }, { "off"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_removeListener, 2 } }, -- cgit v1.2.3 From 2a73d3c793c63042d1c5c9d509d15784d1f396b9 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 30 Jun 2023 20:03:53 +0300 Subject: [install] handle `workspace:` specifier correctly (#3474) fixes #3430 --- .vscode/launch.json | 2 +- src/install/lockfile.zig | 7 +++--- src/js/out/modules/node/assert.js | 2 +- src/js/out/modules/node/os.js | 2 +- src/js/out/modules/node/stream.js | 2 +- src/js/out/modules/node/wasi.js | 4 ++-- test/cli/install/bun-install.test.ts | 44 ++++++++++++++++++++++++++++++++++++ test/cli/install/bun-run.test.ts | 16 ++++++------- 8 files changed, 62 insertions(+), 17 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 22c8bdadd..9ca2aa36a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -325,7 +325,7 @@ "name": "bun install", "program": "bun-debug", "args": ["install"], - "cwd": "${workspaceFolder}", + "cwd": "${fileDirname}", "console": "internalConsole", "env": { "BUN_DEBUG_QUIET_LOGS": "1" diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index 7d21860ef..843381228 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -3103,9 +3103,10 @@ pub const Package = extern struct { string_builder.count(key); string_builder.count(value); - // If it's a folder, pessimistically assume we will need a maximum path - if (Dependency.Version.Tag.infer(value) == .folder) { - string_builder.cap += bun.MAX_PATH_BYTES; + // If it's a folder or workspace, pessimistically assume we will need a maximum path + switch (Dependency.Version.Tag.infer(value)) { + .folder, .workspace => string_builder.cap += bun.MAX_PATH_BYTES, + else => {}, } } total_dependencies_count += @truncate(u32, obj.properties.len); diff --git a/src/js/out/modules/node/assert.js b/src/js/out/modules/node/assert.js index 4086ef8d5..7590ea278 100644 --- a/src/js/out/modules/node/assert.js +++ b/src/js/out/modules/node/assert.js @@ -50,4 +50,4 @@ should equal `),i=0;i 1 && path[length - 1] === "/") path = path.slice(0, -1); diff --git a/src/js/out/modules/node/stream.js b/src/js/out/modules/node/stream.js index f96818bd6..57561d4a1 100644 --- a/src/js/out/modules/node/stream.js +++ b/src/js/out/modules/node/stream.js @@ -1,2 +1,2 @@ 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}; +`;super(Z);this.name="AggregateError",this.errors=K}};Q.exports={AggregateError:H,once(K){let Z=!1;return function(...B){if(Z)return;Z=!0,K.apply(this,B)}},createDeferredPromise:function(){let K,Z;return{promise:new Promise((Y,$)=>{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/wasi.js b/src/js/out/modules/node/wasi.js index f449f1e46..ab6cf6abf 100644 --- a/src/js/out/modules/node/wasi.js +++ b/src/js/out/modules/node/wasi.js @@ -1062,8 +1062,8 @@ var nodeFsConstants = constants, __getOwnPropNames = Object.getOwnPropertyNames, } } initWasiFdInfo() { - if (this.env["WASI_FD_INFO"] != null) { - const fdInfo = JSON.parse(this.env["WASI_FD_INFO"]); + if (this.env.WASI_FD_INFO != null) { + const fdInfo = JSON.parse(this.env.WASI_FD_INFO); for (let wasi_fd in fdInfo) { console.log(wasi_fd); const fd = parseInt(wasi_fd); diff --git a/test/cli/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts index 595e7bcdd..f2483c8d2 100644 --- a/test/cli/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -292,6 +292,50 @@ it("should handle workspaces", async () => { await access(join(package_dir, "bun.lockb")); }); +it("should handle `workspace:` specifier", async () => { + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ + name: "Foo", + version: "0.0.1", + dependencies: { + Bar: "workspace:path/to/bar", + }, + }), + ); + await mkdir(join(package_dir, "path", "to", "bar"), { recursive: true }); + await writeFile( + join(package_dir, "path", "to", "bar", "package.json"), + JSON.stringify({ + name: "Bar", + version: "0.0.2", + }), + ); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "install"], + cwd: package_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toContain("Saved lockfile"); + expect(stdout).toBeDefined(); + const out = await new Response(stdout).text(); + expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ + " + Bar@workspace:path/to/bar", + "", + " 1 packages installed", + ]); + expect(await exited).toBe(0); + expect(requested).toBe(0); + expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "Bar"]); + expect(await readlink(join(package_dir, "node_modules", "Bar"))).toBe(join("..", "path", "to", "bar")); + await access(join(package_dir, "bun.lockb")); +}); + it("should handle workspaces with packages array", async () => { await writeFile( join(package_dir, "package.json"), diff --git a/test/cli/install/bun-run.test.ts b/test/cli/install/bun-run.test.ts index fecbfc3d5..9ab094f08 100644 --- a/test/cli/install/bun-run.test.ts +++ b/test/cli/install/bun-run.test.ts @@ -19,9 +19,9 @@ it("should download dependency to run local file", async () => { await writeFile( join(run_dir, "test.js"), ` - const { minify } = require("uglify-js@3.17.4"); +const { minify } = require("uglify-js@3.17.4"); - console.log(minify("print(6 * 7)").code); +console.log(minify("print(6 * 7)").code); `, ); const { stdout, stderr, exited } = spawn({ @@ -49,13 +49,13 @@ it("should download dependencies to run local file", async () => { await writeFile( join(run_dir, "test.js"), ` - import { file } from "bun"; - import decompress from "decompress@4.2.1"; +import { file } from "bun"; +import decompress from "decompress@4.2.1"; - const buffer = await file("${join(import.meta.dir, "baz-0.0.3.tgz")}").arrayBuffer(); - for (const entry of await decompress(Buffer.from(buffer))) { - console.log(\`\${entry.type}: \${entry.path}\`); - } +const buffer = await file("${join(import.meta.dir, "baz-0.0.3.tgz")}").arrayBuffer(); +for (const entry of await decompress(Buffer.from(buffer))) { + console.log(\`\${entry.type}: \${entry.path}\`); +} `, ); const { stdout, stderr, exited } = spawn({ -- cgit v1.2.3 From b83faf8018a5f6836bd650e9e53e9ec908ec1db1 Mon Sep 17 00:00:00 2001 From: Stijn Van Hulle Date: Fri, 30 Jun 2023 19:04:46 +0200 Subject: fix: export `ClientRequest` and `OutgoingMessage` as part of the `node:http` package (#3470) --- src/js/node/http.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 5f21a791c..15b060d5f 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -1804,6 +1804,8 @@ var defaultObject = { debug(`${NODE_HTTP_WARNING}\n`, "setMaxIdleHTTPParsers() is a no-op"); }, globalAgent, + ClientRequest, + OutgoingMessage, [Symbol.for("CommonJS")]: 0, }; -- cgit v1.2.3 From d356cd5d4817852ad870f3fff0b07bb53fa55222 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Fri, 30 Jun 2023 17:58:38 -0400 Subject: implement perf_hooks.constants (#3476) --- packages/bun-types/perf_hooks.d.ts | 26 +++++++++++++------------- src/js/node/perf_hooks.js | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/packages/bun-types/perf_hooks.d.ts b/packages/bun-types/perf_hooks.d.ts index 802b0e082..792223e6b 100644 --- a/packages/bun-types/perf_hooks.d.ts +++ b/packages/bun-types/perf_hooks.d.ts @@ -452,19 +452,19 @@ declare module "perf_hooks" { // }, // ): void; // } - // namespace constants { - // const NODE_PERFORMANCE_GC_MAJOR: number; - // const NODE_PERFORMANCE_GC_MINOR: number; - // const NODE_PERFORMANCE_GC_INCREMENTAL: number; - // const NODE_PERFORMANCE_GC_WEAKCB: number; - // const NODE_PERFORMANCE_GC_FLAGS_NO: number; - // const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; - // const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; - // const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; - // const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; - // const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; - // const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; - // } + namespace constants { + const NODE_PERFORMANCE_GC_MAJOR: number; + const NODE_PERFORMANCE_GC_MINOR: number; + const NODE_PERFORMANCE_GC_INCREMENTAL: number; + const NODE_PERFORMANCE_GC_WEAKCB: number; + const NODE_PERFORMANCE_GC_FLAGS_NO: number; + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; + } const performance: Performance; // interface EventLoopMonitorOptions { // /** diff --git a/src/js/node/perf_hooks.js b/src/js/node/perf_hooks.js index fb5929c57..592868ab5 100644 --- a/src/js/node/perf_hooks.js +++ b/src/js/node/perf_hooks.js @@ -1,6 +1,20 @@ // Hardcoded module "node:perf_hooks" import { throwNotImplemented } from "../shared"; +export var constants = { + NODE_PERFORMANCE_GC_MAJOR: 4, + NODE_PERFORMANCE_GC_MINOR: 1, + NODE_PERFORMANCE_GC_INCREMENTAL: 8, + NODE_PERFORMANCE_GC_WEAKCB: 16, + NODE_PERFORMANCE_GC_FLAGS_NO: 0, + NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: 2, + NODE_PERFORMANCE_GC_FLAGS_FORCED: 4, + NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: 8, + NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: 16, + NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: 32, + NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: 64, +}; + export var performance = globalThis.performance; export class PerformanceObserver { @@ -22,6 +36,7 @@ export class PerformanceNodeTiming { export default { performance, + constants, PerformanceEntry, PerformanceNodeTiming, [Symbol.for("CommonJS")]: 0, -- cgit v1.2.3 From 02f707f231622066782066ba2c88aefab7f49377 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 1 Jul 2023 21:44:04 +0300 Subject: [jest] fix lifecycle hook execution order (#3461) * [jest] fix lifecycle hook execution order * strip `std.debug.assert()` from release build --- src/bun.js/test/jest.zig | 201 +++++++++++++++++++++--------------- test/js/bun/test/jest-hooks.test.ts | 31 ++++++ test/js/bun/test/test-test.test.ts | 6 +- 3 files changed, 153 insertions(+), 85 deletions(-) diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index d53194e00..6e4cb827c 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -493,8 +493,7 @@ pub const Jest = struct { var filepath = Fs.FileSystem.instance.filename_store.append([]const u8, slice) catch unreachable; var scope = runner_.getOrPutFile(filepath); - DescribeScope.active = scope; - DescribeScope.module = scope; + scope.push(); return Bun__Jest__testModuleObject(ctx).asObjectRef(); } @@ -751,17 +750,23 @@ pub const DescribeScope = struct { } pub fn push(new: *DescribeScope) void { - if (comptime is_bindgen) return undefined; - if (new == DescribeScope.active) return; - - new.parent = DescribeScope.active; + if (comptime is_bindgen) return; + if (new.parent) |scope| { + if (comptime Environment.allow_assert) { + std.debug.assert(DescribeScope.active != new); + std.debug.assert(scope == DescribeScope.active); + } + } else if (DescribeScope.active) |scope| { + // calling Bun.jest() within (already active) module + if (scope.parent != null) return; + } DescribeScope.active = new; } pub fn pop(this: *DescribeScope) void { - if (comptime is_bindgen) return undefined; - if (DescribeScope.active == this) - DescribeScope.active = this.parent orelse DescribeScope.active; + if (comptime is_bindgen) return; + if (comptime Environment.allow_assert) std.debug.assert(DescribeScope.active == this); + DescribeScope.active = this.parent; } pub const LifecycleHook = enum { @@ -771,8 +776,7 @@ pub const DescribeScope = struct { afterAll, }; - pub threadlocal var active: *DescribeScope = undefined; - pub threadlocal var module: *DescribeScope = undefined; + pub threadlocal var active: ?*DescribeScope = null; const CallbackFn = *const fn ( *JSC.JSGlobalObject, @@ -781,21 +785,24 @@ pub const DescribeScope = struct { fn createCallback(comptime hook: LifecycleHook) CallbackFn { return struct { - const this_hook = hook; pub fn run( globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { - const arguments_ = callframe.arguments(2); - const arguments = arguments_.ptr[0..arguments_.len]; - if (arguments.len == 0 or !arguments[0].isObject() or !arguments[0].isCallable(globalThis.vm())) { - globalThis.throwInvalidArgumentType(@tagName(this_hook), "callback", "function"); + const arguments = callframe.arguments(2); + if (arguments.len < 1) { + globalThis.throwNotEnoughArguments("callback", 1, arguments.len); + return .zero; + } + + const cb = arguments.ptr[0]; + if (!cb.isObject() or !cb.isCallable(globalThis.vm())) { + globalThis.throwInvalidArgumentType(@tagName(hook), "callback", "function"); return .zero; } - arguments[0].protect(); - const name = comptime @as(string, @tagName(this_hook)); - @field(DescribeScope.active, name).append(getAllocator(globalThis), arguments[0]) catch unreachable; + cb.protect(); + @field(DescribeScope.active.?, @tagName(hook)).append(getAllocator(globalThis), cb) catch unreachable; return JSC.JSValue.jsBoolean(true); } }.run; @@ -829,11 +836,24 @@ pub const DescribeScope = struct { pub const beforeAll = createCallback(.beforeAll); pub const beforeEach = createCallback(.beforeEach); - pub fn execCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) JSValue { - const name = comptime @as(string, @tagName(hook)); - var hooks: []JSC.JSValue = @field(this, name).items; - for (hooks, 0..) |cb, i| { - if (cb.isEmpty()) continue; + pub fn execCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { + var hooks = &@field(this, @tagName(hook)); + defer { + if (comptime hook == .beforeAll or hook == .afterAll) { + hooks.clearAndFree(getAllocator(globalObject)); + } + } + + for (hooks.items) |cb| { + if (comptime Environment.allow_assert) { + std.debug.assert(cb.isObject()); + std.debug.assert(cb.isCallable(globalObject.vm())); + } + defer { + if (comptime hook == .beforeAll or hook == .afterAll) { + cb.unprotect(); + } + } const pending_test = Jest.runner.?.pending_test; // forbid `expect()` within hooks @@ -843,20 +863,23 @@ pub const DescribeScope = struct { Jest.runner.?.did_pending_test_fail = false; const vm = VirtualMachine.get(); - var result: JSC.JSValue = if (cb.getLength(globalObject) > 0) brk: { - this.done = false; - const done_func = JSC.NewFunctionWithData( - globalObject, - ZigString.static("done"), - 0, - DescribeScope.onDone, - false, - this, - ); - var result = cb.call(globalObject, &.{done_func}); - vm.waitFor(&this.done); - break :brk result; - } else cb.call(globalObject, &.{}); + var result: JSC.JSValue = switch (cb.getLength(globalObject)) { + 0 => cb.call(globalObject, &.{}), + else => brk: { + this.done = false; + const done_func = JSC.NewFunctionWithData( + globalObject, + ZigString.static("done"), + 0, + DescribeScope.onDone, + false, + this, + ); + var result = cb.call(globalObject, &.{done_func}); + vm.waitFor(&this.done); + break :brk result; + }, + }; if (result.asAnyPromise()) |promise| { if (promise.status(globalObject.vm()) == .Pending) { result.protect(); @@ -870,19 +893,30 @@ pub const DescribeScope = struct { Jest.runner.?.pending_test = pending_test; Jest.runner.?.did_pending_test_fail = orig_did_pending_test_fail; if (result.isAnyError()) return result; - - if (comptime hook == .beforeAll or hook == .afterAll) { - hooks[i] = JSC.JSValue.zero; - } } - return JSValue.zero; + return null; } pub fn runGlobalCallbacks(globalThis: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { // global callbacks - for (@field(Jest.runner.?.global_callbacks, @tagName(hook)).items) |cb| { - if (cb.isEmpty()) continue; + var hooks = &@field(Jest.runner.?.global_callbacks, @tagName(hook)); + defer { + if (comptime hook == .beforeAll or hook == .afterAll) { + hooks.clearAndFree(getAllocator(globalThis)); + } + } + + for (hooks.items) |cb| { + if (comptime Environment.allow_assert) { + std.debug.assert(cb.isObject()); + std.debug.assert(cb.isCallable(globalThis.vm())); + } + defer { + if (comptime hook == .beforeAll or hook == .afterAll) { + cb.unprotect(); + } + } const pending_test = Jest.runner.?.pending_test; // forbid `expect()` within hooks @@ -909,28 +943,40 @@ pub const DescribeScope = struct { if (result.isAnyError()) return result; } - if (comptime hook == .beforeAll or hook == .afterAll) { - @field(Jest.runner.?.global_callbacks, @tagName(hook)).items.len = 0; - } - return null; } - pub fn runCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) JSValue { + fn runBeforeCallbacks(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { + if (this.parent) |scope| { + if (scope.runBeforeCallbacks(globalObject, hook)) |err| { + return err; + } + } + return this.execCallback(globalObject, hook); + } + + pub fn runCallback(this: *DescribeScope, globalObject: *JSC.JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { + if (comptime hook == .afterAll or hook == .afterEach) { + var parent: ?*DescribeScope = this; + while (parent) |scope| { + if (scope.execCallback(globalObject, hook)) |err| { + return err; + } + parent = scope.parent; + } + } + if (runGlobalCallbacks(globalObject, hook)) |err| { return err; } - var parent = this.parent; - while (parent) |scope| { - const ret = scope.execCallback(globalObject, hook); - if (!ret.isEmpty()) { - return ret; + if (comptime hook == .beforeAll or hook == .beforeEach) { + if (this.runBeforeCallbacks(globalObject, hook)) |err| { + return err; } - parent = scope.parent; } - return this.execCallback(globalObject, hook); + return null; } pub fn call(globalThis: *JSGlobalObject, callframe: *CallFrame) callconv(.C) JSValue { @@ -961,11 +1007,8 @@ pub const DescribeScope = struct { if (comptime is_bindgen) return undefined; callback.protect(); defer callback.unprotect(); - var original_active = active; - defer active = original_active; - if (this != module) - this.parent = this.parent orelse active; - active = this; + this.push(); + defer this.pop(); if (callback == .zero) { this.runTests(globalObject); @@ -1019,8 +1062,7 @@ pub const DescribeScope = struct { var i: TestRunner.Test.ID = 0; if (!this.isAllSkipped()) { - const beforeAllCallback = this.runCallback(globalObject, .beforeAll); - if (!beforeAllCallback.isEmpty()) { + if (this.runCallback(globalObject, .beforeAll)) |_| { while (i < end) { Jest.runner.?.reportFailure(i + this.test_id_start, source.path.text, tests[i].label, 0, 0, this); i += 1; @@ -1051,9 +1093,8 @@ pub const DescribeScope = struct { this.pending_tests.unset(test_id); if (!skipped) { - const afterEach_result = this.runCallback(globalThis, .afterEach); - if (!afterEach_result.isEmpty()) { - globalThis.bunVM().runErrorHandler(afterEach_result, null); + if (this.runCallback(globalThis, .afterEach)) |err| { + globalThis.bunVM().runErrorHandler(err, null); } } @@ -1064,9 +1105,8 @@ pub const DescribeScope = struct { if (!this.isAllSkipped()) { // Run the afterAll callbacks, in reverse order // unless there were no tests for this scope - const afterAll_result = this.execCallback(globalThis, .afterAll); - if (!afterAll_result.isEmpty()) { - globalThis.bunVM().runErrorHandler(afterAll_result, null); + if (this.execCallback(globalThis, .afterAll)) |err| { + globalThis.bunVM().runErrorHandler(err, null); } } @@ -1146,7 +1186,6 @@ pub const TestRunnerTask = struct { // reset the global state for each test // prior to the run - DescribeScope.active = describe; expect.active_test_expectation_counter = .{}; jsc_vm.last_reported_error_for_dedupe = .zero; @@ -1178,11 +1217,9 @@ pub const TestRunnerTask = struct { this.needs_before_each = false; const label = test_.label; - const beforeEach = this.describe.runCallback(globalThis, .beforeEach); - - if (!beforeEach.isEmpty()) { + if (this.describe.runCallback(globalThis, .beforeEach)) |err| { Jest.runner.?.reportFailure(test_id, this.source_file_path, label, 0, 0, this.describe); - jsc_vm.runErrorHandler(beforeEach, null); + jsc_vm.runErrorHandler(err, null); return false; } } @@ -1210,7 +1247,7 @@ pub const TestRunnerTask = struct { } pub fn timeout(this: *TestRunnerTask) void { - std.debug.assert(!this.reported); + if (comptime Environment.allow_assert) std.debug.assert(!this.reported); this.ref.unref(this.globalThis.bunVM()); this.globalThis.throwTerminationException(); @@ -1223,7 +1260,7 @@ pub const TestRunnerTask = struct { switch (comptime from) { .promise => { - std.debug.assert(this.promise_state == .pending); + if (comptime Environment.allow_assert) std.debug.assert(this.promise_state == .pending); this.promise_state = .fulfilled; if (this.done_callback_state == .pending and result == .pass) { @@ -1231,7 +1268,7 @@ pub const TestRunnerTask = struct { } }, .callback => { - std.debug.assert(this.done_callback_state == .pending); + if (comptime Environment.allow_assert) std.debug.assert(this.done_callback_state == .pending); this.done_callback_state = .fulfilled; if (this.promise_state == .pending and result == .pass) { @@ -1239,7 +1276,7 @@ pub const TestRunnerTask = struct { } }, .sync => { - std.debug.assert(this.sync_state == .pending); + if (comptime Environment.allow_assert) std.debug.assert(this.sync_state == .pending); this.sync_state = .fulfilled; }, .timeout, .unhandledRejection => {}, @@ -1417,7 +1454,7 @@ inline fn createScope( return .zero; } - const parent = DescribeScope.active; + const parent = DescribeScope.active.?; const allocator = getAllocator(globalThis); const label = if (description == .zero) "" @@ -1502,8 +1539,8 @@ inline fn createIfScope( // In Github Actions, emit an annotation that renders the error and location. // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message pub fn printGithubAnnotation(exception: *JSC.ZigException) void { - const name = @field(exception, "name"); - const message = @field(exception, "message"); + const name = exception.name; + const message = exception.message; const frames = exception.stack.frames(); const top_frame = if (frames.len > 0) frames[0] else null; const dir = bun.getenvZ("GITHUB_WORKSPACE") orelse bun.fs.FileSystem.instance.top_level_dir; diff --git a/test/js/bun/test/jest-hooks.test.ts b/test/js/bun/test/jest-hooks.test.ts index c99dc7759..618cdc4c6 100644 --- a/test/js/bun/test/jest-hooks.test.ts +++ b/test/js/bun/test/jest-hooks.test.ts @@ -1,5 +1,36 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "bun:test"; +let hooks_run: string[] = []; + +beforeAll(() => hooks_run.push("global beforeAll")); +beforeEach(() => hooks_run.push("global beforeEach")); +afterAll(() => hooks_run.push("global afterAll")); +afterEach(() => hooks_run.push("global afterEach")); + +describe("describe scope", () => { + beforeAll(() => hooks_run.push("describe beforeAll")); + beforeEach(() => hooks_run.push("describe beforeEach")); + afterAll(() => hooks_run.push("describe afterAll")); + afterEach(() => hooks_run.push("describe afterEach")); + + it("should run after beforeAll/beforeEach in the correct order", () => { + expect(hooks_run).toEqual(["global beforeAll", "describe beforeAll", "global beforeEach", "describe beforeEach"]); + }); + + it("should run after afterEach/afterAll in the correct order", () => { + expect(hooks_run).toEqual([ + "global beforeAll", + "describe beforeAll", + "global beforeEach", + "describe beforeEach", + "describe afterEach", + "global afterEach", + "global beforeEach", + "describe beforeEach", + ]); + }); +}); + describe("test jest hooks in bun-test", () => { describe("test beforeAll hook", () => { let animal = "tiger"; diff --git a/test/js/bun/test/test-test.test.ts b/test/js/bun/test/test-test.test.ts index 7ecfdef11..5f732bb82 100644 --- a/test/js/bun/test/test-test.test.ts +++ b/test/js/bun/test/test-test.test.ts @@ -540,18 +540,18 @@ beforeEach: #2 beforeEach: TEST-FILE beforeEach: one describe scope -- inside one describe scope -- +afterEach: one describe scope +afterEach: TEST-FILE afterEach: #1 afterEach: #2 -afterEach: TEST-FILE -afterEach: one describe scope afterAll: one describe scope beforeEach: #1 beforeEach: #2 beforeEach: TEST-FILE -- the top-level test -- +afterEach: TEST-FILE afterEach: #1 afterEach: #2 -afterEach: TEST-FILE afterAll: TEST-FILE afterAll: #1 afterAll: #2 -- cgit v1.2.3 From c794ea7ea76b1081f90759d494546cc67a86e318 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 13:31:12 -0700 Subject: Add test --- test/js/bun/util/error-gc-test.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/js/bun/util/error-gc-test.test.js b/test/js/bun/util/error-gc-test.test.js index 5f9134d4c..247bd68ef 100644 --- a/test/js/bun/util/error-gc-test.test.js +++ b/test/js/bun/util/error-gc-test.test.js @@ -33,3 +33,12 @@ test("error gc test #2", () => { Bun.gc(); } }); + +test("error gc test #2", () => { + for (let i = 0; i < 1000; i++) { + var err = new Error(); + Error.captureStackTrace(err); + Bun.inspect(err); + Bun.gc(); + } +}); -- cgit v1.2.3 From c033d55c47fc914a7725295aaf3304c177102a18 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Sat, 1 Jul 2023 14:38:38 -0700 Subject: skip private class fields (#3484) --- src/bun.js/bindings/bindings.cpp | 12 ++++----- test/js/bun/test/expect.test.js | 56 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index be3408555..96fcde303 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -679,8 +679,8 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, return false; } - JSC::PropertyNameArray a1(vm, PropertyNameMode::Symbols, PrivateSymbolMode::Include); - JSC::PropertyNameArray a2(vm, PropertyNameMode::Symbols, PrivateSymbolMode::Include); + JSC::PropertyNameArray a1(vm, PropertyNameMode::Symbols, PrivateSymbolMode::Exclude); + JSC::PropertyNameArray a2(vm, PropertyNameMode::Symbols, PrivateSymbolMode::Exclude); JSObject::getOwnPropertyNames(o1, globalObject, a1, DontEnumPropertiesMode::Exclude); JSObject::getOwnPropertyNames(o2, globalObject, a2, DontEnumPropertiesMode::Exclude); @@ -753,7 +753,7 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, } o1Structure->forEachProperty(vm, [&](const PropertyTableEntry& entry) -> bool { - if (entry.attributes() & PropertyAttribute::DontEnum) { + if (entry.attributes() & PropertyAttribute::DontEnum || PropertyName(entry.key()).isPrivateName()) { return true; } count1++; @@ -787,7 +787,7 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, if (result && o2Structure->id() != o1Structure->id()) { size_t remain = count1; o2Structure->forEachProperty(vm, [&](const PropertyTableEntry& entry) -> bool { - if (entry.attributes() & PropertyAttribute::DontEnum) { + if (entry.attributes() & PropertyAttribute::DontEnum || PropertyName(entry.key()).isPrivateName()) { return true; } @@ -815,8 +815,8 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, } } - JSC::PropertyNameArray a1(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Include); - JSC::PropertyNameArray a2(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Include); + JSC::PropertyNameArray a1(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude); + JSC::PropertyNameArray a2(vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude); o1->getPropertyNames(globalObject, a1, DontEnumPropertiesMode::Exclude); o2->getPropertyNames(globalObject, a2, DontEnumPropertiesMode::Exclude); diff --git a/test/js/bun/test/expect.test.js b/test/js/bun/test/expect.test.js index e7195d6f8..ed94b7e9a 100644 --- a/test/js/bun/test/expect.test.js +++ b/test/js/bun/test/expect.test.js @@ -1335,6 +1335,62 @@ describe("expect()", () => { expect([1, 2, 3, 4]).not.toEqual([1, 2, 3]); }); + test("toEqual() - private class fields", () => { + class A { + #three = 3; + set three(value) { + this.#three = value; + } + + get three() { + return this.#three; + } + } + + class B { + #three = 3; + set three(value) { + this.#three = value; + } + + get three() { + return this.#three; + } + } + + let a1 = new A(); + let a2 = new A(); + a1.three = 4; + expect(a1).toEqual(a2); + expect(a2).toEqual(a1); + + let a3 = new A(); + let a4 = new A(); + a3.three = 4; + // use indexed properties for slow path + a3[1] = 2; + a4[1] = 2; + expect(a3).toEqual(a4); + expect(a4).toEqual(a3); + + let b1 = new B(); + let a5 = new A(); + expect(b1).toEqual(a5); + expect(a5).toEqual(b1); + + b1.three = 4; + expect(b1).toEqual(a5); + expect(a5).toEqual(b1); + + b1[1] = 2; + expect(b1).not.toEqual(a5); + expect(a5).not.toEqual(b1); + + a5[1] = 2; + expect(b1).toEqual(a5); + expect(a5).toEqual(b1); + }); + test("properties with different circularity are not equal", () => { const a = {}; a.x = { y: a }; -- cgit v1.2.3 From df10252979aa3d87a8d127707a23678b76a15583 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 1 Jul 2023 14:40:05 -0700 Subject: Make HTTP Request struct use 8 bytes less memory (#3483) * Make HTTP Request struct use 8 bytes less memory * Update server.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/server.zig | 271 +++++++++++++++++++++++----------------------- 1 file changed, 137 insertions(+), 134 deletions(-) diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 32c4fd25c..136737069 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -1000,6 +1000,30 @@ const HTTPStatusText = struct { } }; +fn NewFlags(comptime debug_mode: bool) type { + return packed struct { + has_marked_complete: bool = false, + has_marked_pending: bool = false, + has_abort_handler: bool = false, + has_sendfile_ctx: bool = false, + has_called_error_handler: bool = false, + needs_content_length: bool = false, + needs_content_range: bool = false, + /// Used to avoid looking at the uws.Request struct after it's been freed + is_transfer_encoding: bool = false, + + /// Used to identify if request can be safely deinitialized + is_waiting_body: bool = false, + /// Used in renderMissing in debug mode to show the user an HTML page + /// Used to avoid looking at the uws.Request struct after it's been freed + is_web_browser_navigation: if (debug_mode) bool else void = if (debug_mode) false else {}, + has_written_status: bool = false, + response_protected: bool = false, + aborted: bool = false, + finalized: bun.DebugOnly(bool) = bun.DebugOnlyDefault(false), + }; +} + // This is defined separately partially to work-around an LLVM debugger bug. fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comptime ThisServer: type) type { return struct { @@ -1024,63 +1048,42 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp req: *uws.Request, signal: ?*JSC.WebCore.AbortSignal = null, method: HTTP.Method, - aborted: bool = false, - finalized: bun.DebugOnly(bool) = bun.DebugOnlyDefault(false), + + flags: NewFlags(debug_mode) = .{}, + upgrade_context: ?*uws.uws_socket_context_t = null, /// We can only safely free once the request body promise is finalized /// and the response is rejected + response_jsvalue: JSC.JSValue = JSC.JSValue.zero, pending_promises_for_abort: u8 = 0, - has_marked_complete: bool = false, - has_marked_pending: bool = false, - - response_jsvalue: JSC.JSValue = JSC.JSValue.zero, - response_protected: bool = false, response_ptr: ?*JSC.WebCore.Response = null, blob: JSC.WebCore.AnyBlob = JSC.WebCore.AnyBlob{ .Blob = .{} }, promise: ?*JSC.JSValue = null, - has_abort_handler: bool = false, - has_sendfile_ctx: bool = false, - has_called_error_handler: bool = false, - needs_content_length: bool = false, - needs_content_range: bool = false, + sendfile: SendfileContext = undefined, request_body: ?*JSC.WebCore.BodyValueRef = null, request_body_buf: std.ArrayListUnmanaged(u8) = .{}, request_body_content_len: usize = 0, - /// Used to avoid looking at the uws.Request struct after it's been freed - is_transfer_encoding: bool = false, - - /// Used to identify if request can be safely deinitialized - is_waiting_body: bool = false, - - /// Used in renderMissing in debug mode to show the user an HTML page - /// Used to avoid looking at the uws.Request struct after it's been freed - is_web_browser_navigation: if (debug_mode) bool else void = if (debug_mode) false else {}, - sink: ?*ResponseStream.JSSink = null, byte_stream: ?*JSC.WebCore.ByteStream = null, /// Used in errors pathname: []const u8 = "", - has_written_status: bool = false, - /// Used either for temporary blob data or fallback /// When the response body is a temporary value response_buf_owned: std.ArrayListUnmanaged(u8) = .{}, - keepalive: bool = true, - // TODO: support builtin compression const can_sendfile = !ssl_enabled; pub fn setAbortHandler(this: *RequestContext) void { - if (this.has_abort_handler) return; + if (this.flags.has_abort_handler) return; if (this.resp) |resp| { - this.has_abort_handler = true; + this.flags.has_abort_handler = true; resp.onAborted(*RequestContext, RequestContext.onAbort, this); } } @@ -1094,7 +1097,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp result.ensureStillAlive(); ctx.pending_promises_for_abort -|= 1; - if (ctx.aborted) { + if (ctx.flags.aborted) { ctx.finalizeForAbort(); return JSValue.jsUndefined(); } @@ -1121,8 +1124,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp return; }; ctx.response_jsvalue = value; - std.debug.assert(!ctx.response_protected); - ctx.response_protected = true; + std.debug.assert(!ctx.flags.response_protected); + ctx.flags.response_protected = true; JSC.C.JSValueProtect(ctx.server.globalThis, value.asObjectRef()); ctx.render(response); @@ -1143,7 +1146,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp ctx.pending_promises_for_abort -|= 1; - if (ctx.aborted) { + if (ctx.flags.aborted) { ctx.finalizeForAbort(); return JSValue.jsUndefined(); } @@ -1163,7 +1166,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp value, ); - if (ctx.aborted) { + if (ctx.flags.aborted) { ctx.finalizeForAbort(); return; } @@ -1174,7 +1177,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp return; } - if (!resp.hasResponded() and !ctx.has_marked_pending) { + if (!resp.hasResponded() and !ctx.flags.has_marked_pending) { ctx.renderMissing(); return; } @@ -1190,14 +1193,14 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn renderMissingCorked(ctx: *RequestContext) void { if (ctx.resp) |resp| { if (comptime !debug_mode) { - if (!ctx.has_written_status) + if (!ctx.flags.has_written_status) resp.writeStatus("204 No Content"); - ctx.has_written_status = true; + ctx.flags.has_written_status = true; ctx.end("", ctx.shouldCloseConnection()); } else { - if (ctx.is_web_browser_navigation) { + if (ctx.flags.is_web_browser_navigation) { resp.writeStatus("200 OK"); - ctx.has_written_status = true; + ctx.flags.has_written_status = true; resp.writeHeader("content-type", MimeType.html.value); resp.writeHeader("content-encoding", "gzip"); @@ -1206,9 +1209,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp return; } - if (!ctx.has_written_status) + if (!ctx.flags.has_written_status) resp.writeStatus("200 OK"); - ctx.has_written_status = true; + ctx.flags.has_written_status = true; ctx.end("Welcome to Bun! To get started, return a Response object.", ctx.shouldCloseConnection()); } } @@ -1222,8 +1225,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp comptime fmt: string, args: anytype, ) void { - if (!this.has_written_status) { - this.has_written_status = true; + if (!this.flags.has_written_status) { + this.flags.has_written_status = true; if (this.resp) |resp| { resp.writeStatus("500 Internal Server Error"); resp.writeHeader("content-type", MimeType.html.value); @@ -1265,7 +1268,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp return; } - this.has_marked_pending = true; + this.flags.has_marked_pending = true; this.response_buf_owned = std.ArrayListUnmanaged(u8){ .items = bb.items, .capacity = bb.capacity }; if (this.resp) |resp| { @@ -1290,7 +1293,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp this.response_buf_owned.items.len, this.shouldCloseConnection(), )) { - this.has_marked_pending = true; + this.flags.has_marked_pending = true; resp.onWritable(*RequestContext, onWritableCompleteResponseBuffer, this); this.setAbortHandler(); return; @@ -1314,8 +1317,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn end(this: *RequestContext, data: []const u8, closeConnection: bool) void { if (this.resp) |resp| { - if (this.is_waiting_body) { - this.is_waiting_body = false; + if (this.flags.is_waiting_body) { + this.flags.is_waiting_body = false; resp.clearOnData(); } resp.end(data, closeConnection); @@ -1325,8 +1328,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn endStream(this: *RequestContext, closeConnection: bool) void { if (this.resp) |resp| { - if (this.is_waiting_body) { - this.is_waiting_body = false; + if (this.flags.is_waiting_body) { + this.flags.is_waiting_body = false; resp.clearOnData(); } resp.endStream(closeConnection); @@ -1336,8 +1339,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn endWithoutBody(this: *RequestContext, closeConnection: bool) void { if (this.resp) |resp| { - if (this.is_waiting_body) { - this.is_waiting_body = false; + if (this.flags.is_waiting_body) { + this.flags.is_waiting_body = false; resp.clearOnData(); } resp.endWithoutBody(closeConnection); @@ -1347,7 +1350,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn onWritableResponseBuffer(this: *RequestContext, _: c_ulong, resp: *App.Response) callconv(.C) bool { std.debug.assert(this.resp == resp); - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return false; } @@ -1360,12 +1363,12 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn onWritableCompleteResponseBufferAndMetadata(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool { std.debug.assert(this.resp == resp); - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return false; } - if (!this.has_written_status) { + if (!this.flags.has_written_status) { this.renderMetadata(); } @@ -1380,7 +1383,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn onWritableCompleteResponseBuffer(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool { std.debug.assert(this.resp == resp); - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return false; } @@ -1417,9 +1420,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn onAbort(this: *RequestContext, resp: *App.Response) void { std.debug.assert(this.resp == resp); - std.debug.assert(!this.aborted); + std.debug.assert(!this.flags.aborted); //mark request as aborted - this.aborted = true; + this.flags.aborted = true; // if signal is not aborted, abort the signal if (this.signal) |signal| { @@ -1487,8 +1490,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } pub fn markComplete(this: *RequestContext) void { - if (!this.has_marked_complete) this.server.onRequestComplete(); - this.has_marked_complete = true; + if (!this.flags.has_marked_complete) this.server.onRequestComplete(); + this.flags.has_marked_complete = true; } // This function may be called multiple times @@ -1498,15 +1501,15 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp this.blob.detach(); if (comptime Environment.allow_assert) { - std.debug.assert(!this.finalized); - this.finalized = true; + std.debug.assert(!this.flags.finalized); + this.flags.finalized = true; } if (!this.response_jsvalue.isEmpty()) { ctxLog("finalizeWithoutDeinit: response_jsvalue != .zero", .{}); - if (this.response_protected) { + if (this.flags.response_protected) { this.response_jsvalue.unprotect(); - this.response_protected = false; + this.flags.response_protected = false; } this.response_jsvalue = JSC.JSValue.zero; } @@ -1514,7 +1517,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp // if signal is not aborted, abort the signal if (this.signal) |signal| { this.signal = null; - if (this.aborted and !signal.aborted()) { + if (this.flags.aborted and !signal.aborted()) { const reason = JSC.WebCore.AbortSignal.createAbortError(JSC.ZigString.static("The user aborted a request"), &JSC.ZigString.Empty, this.server.globalThis); reason.ensureStillAlive(); _ = signal.signal(reason); @@ -1557,9 +1560,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp // if we are waiting for the body yet and the request was not aborted we can safely clear the onData callback if (this.resp) |resp| { - if (this.is_waiting_body and this.aborted == false) { + if (this.flags.is_waiting_body and this.flags.aborted == false) { resp.clearOnData(); - this.is_waiting_body = false; + this.flags.is_waiting_body = false; } } } @@ -1573,10 +1576,10 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn deinit(this: *RequestContext) void { ctxLog("deinit ({*})", .{this}); if (comptime Environment.allow_assert) - std.debug.assert(this.finalized); + std.debug.assert(this.flags.finalized); if (comptime Environment.allow_assert) - std.debug.assert(this.has_marked_complete); + std.debug.assert(this.flags.has_marked_complete); var server = this.server; this.request_body_buf.clearAndFree(this.allocator); @@ -1604,8 +1607,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn writeStatus(this: *RequestContext, status: u16) void { var status_text_buf: [48]u8 = undefined; - std.debug.assert(!this.has_written_status); - this.has_written_status = true; + std.debug.assert(!this.flags.has_written_status); + this.flags.has_written_status = true; if (this.resp) |resp| { if (HTTPStatusText.get(status)) |text| { @@ -1634,7 +1637,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp }}; pub fn onSendfile(this: *RequestContext) bool { - if (this.aborted or this.resp == null) { + if (this.flags.aborted or this.resp == null) { this.cleanupAndFinalizeAfterSendfile(); return false; } @@ -1656,7 +1659,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp this.sendfile.remain -|= @intCast(Blob.SizeType, this.sendfile.offset -| start); - if (errcode != .SUCCESS or this.aborted or this.sendfile.remain == 0 or val == 0) { + if (errcode != .SUCCESS or this.flags.aborted or this.sendfile.remain == 0 or val == 0) { if (errcode != .AGAIN and errcode != .SUCCESS and errcode != .PIPE) { Output.prettyErrorln("Error: {s}", .{@tagName(errcode)}); Output.flush(); @@ -1679,7 +1682,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp const wrote = @intCast(Blob.SizeType, sbytes); this.sendfile.offset +|= wrote; this.sendfile.remain -|= wrote; - if (errcode != .AGAIN or this.aborted or this.sendfile.remain == 0 or sbytes == 0) { + if (errcode != .AGAIN or this.flags.aborted or this.sendfile.remain == 0 or sbytes == 0) { if (errcode != .AGAIN and errcode != .SUCCESS and errcode != .PIPE) { Output.prettyErrorln("Error: {s}", .{@tagName(errcode)}); Output.flush(); @@ -1691,7 +1694,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp if (!this.sendfile.has_set_on_writable) { this.sendfile.has_set_on_writable = true; - this.has_marked_pending = true; + this.flags.has_marked_pending = true; resp.onWritable(*RequestContext, onWritableSendfile, this); } @@ -1703,7 +1706,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn onWritableBytes(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool { std.debug.assert(this.resp == resp); - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return false; } @@ -1724,7 +1727,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp this.finalize(); return true; } else { - this.has_marked_pending = true; + this.flags.has_marked_pending = true; resp.onWritable(*RequestContext, onWritableBytes, this); return true; } @@ -1738,7 +1741,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp this.response_buf_owned.items.len = 0; this.finalize(); } else { - this.has_marked_pending = true; + this.flags.has_marked_pending = true; resp.onWritable(*RequestContext, onWritableCompleteResponseBuffer, this); } @@ -1827,21 +1830,21 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp else @min(original_size, stat_size); - this.needs_content_length = true; + this.flags.needs_content_length = true; this.sendfile = .{ .fd = fd, .remain = this.blob.Blob.offset + original_size, .offset = this.blob.Blob.offset, .auto_close = auto_close, - .socket_fd = if (!this.aborted) resp.getNativeHandle() else -999, + .socket_fd = if (!this.flags.aborted) resp.getNativeHandle() else -999, }; // if we are sending only part of a file, include the content-range header // only include content-range automatically when using a file path instead of an fd // this is to better support manually controlling the behavior if (std.os.S.ISREG(stat.mode) and auto_close) { - this.needs_content_range = (this.sendfile.remain -| this.sendfile.offset) != stat_size; + this.flags.needs_content_range = (this.sendfile.remain -| this.sendfile.offset) != stat_size; } // we know the bounds when we are sending a regular file @@ -1868,14 +1871,14 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } pub fn doSendfile(this: *RequestContext, blob: Blob) void { - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return; } - if (this.has_sendfile_ctx) return; + if (this.flags.has_sendfile_ctx) return; - this.has_sendfile_ctx = true; + this.flags.has_sendfile_ctx = true; if (comptime can_sendfile) { return this.renderSendFile(blob); @@ -1886,7 +1889,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } pub fn onReadFile(this: *RequestContext, result: Blob.Store.ReadFile.ResultType) void { - if (this.aborted or this.resp == null) { + if (this.flags.aborted or this.resp == null) { this.finalizeForAbort(); return; } @@ -1909,8 +1912,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp else @min(original_size, stat_size); - if (!this.has_written_status) - this.needs_content_range = true; + if (!this.flags.has_written_status) + this.flags.needs_content_range = true; // this is used by content-range this.sendfile = .{ @@ -1931,14 +1934,14 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } fn renderWithBlobFromBodyValue(this: *RequestContext) void { - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return; } if (this.blob.needsToReadFile()) { this.req.setYield(false); - if (!this.has_sendfile_ctx) + if (!this.flags.has_sendfile_ctx) this.doSendfile(this.blob.Blob); return; } @@ -1951,7 +1954,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp fn doRenderStream(pair: *StreamPair) void { var this = pair.this; var stream = pair.stream; - if (this.resp == null or this.aborted) { + if (this.resp == null or this.flags.aborted) { stream.value.unprotect(); this.finalizeForAbort(); return; @@ -2002,11 +2005,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } } - this.aborted = this.aborted or response_stream.sink.aborted; + this.flags.aborted = this.flags.aborted or response_stream.sink.aborted; if (assignment_result.toError()) |err_value| { streamLog("returned an error", .{}); - if (!this.aborted) resp.clearAborted(); + if (!this.flags.aborted) resp.clearAborted(); response_stream.detach(); this.sink = null; response_stream.sink.destroy(); @@ -2018,7 +2021,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp // TODO: is there a condition where resp could be freed before done? resp.hasResponded()) { - if (!this.aborted) resp.clearAborted(); + if (!this.flags.aborted) resp.clearAborted(); const wrote_anything = response_stream.sink.wrote > 0; streamLog("is done", .{}); const responded = resp.hasResponded(); @@ -2026,10 +2029,10 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp response_stream.detach(); this.sink = null; response_stream.sink.destroy(); - if (!responded and !wrote_anything and !this.aborted) { + if (!responded and !wrote_anything and !this.flags.aborted) { this.renderMissing(); return; - } else if (wrote_anything and !responded and !this.aborted) { + } else if (wrote_anything and !responded and !this.flags.aborted) { this.endStream(this.shouldCloseConnection()); } @@ -2077,7 +2080,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } } - if (this.aborted) { + if (this.flags.aborted) { response_stream.detach(); stream.cancel(this.server.globalThis); response_stream.sink.done = true; @@ -2126,7 +2129,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp request_value.ensureStillAlive(); response_value.ensureStillAlive(); - if (ctx.aborted) { + if (ctx.flags.aborted) { ctx.finalizeForAbort(); return; } @@ -2153,19 +2156,19 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp if (response_value.as(JSC.WebCore.Response)) |response| { ctx.response_jsvalue = response_value; ctx.response_jsvalue.ensureStillAlive(); - ctx.response_protected = false; + ctx.flags.response_protected = false; response.body.value.toBlobIfPossible(); switch (response.body.value) { .Blob => |*blob| { if (blob.needsToReadFile()) { response_value.protect(); - ctx.response_protected = true; + ctx.flags.response_protected = true; } }, .Locked => { response_value.protect(); - ctx.response_protected = true; + ctx.flags.response_protected = true; }, else => {}, } @@ -2203,19 +2206,19 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp ctx.response_jsvalue = fulfilled_value; ctx.response_jsvalue.ensureStillAlive(); - ctx.response_protected = false; + ctx.flags.response_protected = false; ctx.response_ptr = response; response.body.value.toBlobIfPossible(); switch (response.body.value) { .Blob => |*blob| { if (blob.needsToReadFile()) { fulfilled_value.protect(); - ctx.response_protected = true; + ctx.flags.response_protected = true; } }, .Locked => { fulfilled_value.protect(); - ctx.response_protected = true; + ctx.flags.response_protected = true; }, else => {}, } @@ -2258,7 +2261,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } if (ctx.resp) |resp| { // The user returned something that wasn't a promise or a promise with a response - if (!resp.hasResponded() and !ctx.has_marked_pending) ctx.renderMissing(); + if (!resp.hasResponded() and !ctx.flags.has_marked_pending) ctx.renderMissing(); } } @@ -2269,7 +2272,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp if (req.sink) |wrapper| { wrapper.sink.pending_flush = null; wrapper.sink.done = true; - req.aborted = req.aborted or wrapper.sink.aborted; + req.flags.aborted = req.flags.aborted or wrapper.sink.aborted; wrote_anything = wrapper.sink.wrote > 0; wrapper.sink.finalize(); wrapper.detach(); @@ -2287,7 +2290,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp streamLog("onResolve({any})", .{wrote_anything}); //aborted so call finalizeForAbort - if (req.aborted or req.resp == null) { + if (req.flags.aborted or req.resp == null) { req.finalizeForAbort(); return; } @@ -2325,13 +2328,13 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn handleRejectStream(req: *@This(), globalThis: *JSC.JSGlobalObject, err: JSValue) void { streamLog("handleRejectStream", .{}); - var wrote_anything = req.has_written_status; + var wrote_anything = req.flags.has_written_status; if (req.sink) |wrapper| { wrapper.sink.pending_flush = null; wrapper.sink.done = true; wrote_anything = wrote_anything or wrapper.sink.wrote > 0; - req.aborted = req.aborted or wrapper.sink.aborted; + req.flags.aborted = req.flags.aborted or wrapper.sink.aborted; wrapper.sink.finalize(); wrapper.detach(); req.sink = null; @@ -2348,7 +2351,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp streamLog("onReject({any})", .{wrote_anything}); //aborted so call finalizeForAbort - if (req.aborted) { + if (req.flags.aborted) { req.finalizeForAbort(); return; } @@ -2387,7 +2390,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp .Error => { const err = value.Error; _ = value.use(); - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return; } @@ -2405,7 +2408,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp return; }, .Locked => |*lock| { - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return; } @@ -2508,7 +2511,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } } - if (this.aborted or this.resp == null) { + if (this.flags.aborted or this.resp == null) { this.finalizeForAbort(); return; } @@ -2527,7 +2530,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } else { // when it's the last one, we just want to know if it's done if (stream.isDone()) { - this.has_marked_pending = true; + this.flags.has_marked_pending = true; resp.onWritable(*RequestContext, onWritableResponseBuffer, this); } } @@ -2539,7 +2542,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp // Faster to do the memcpy than to do the two network calls // We are not streaming // This is an important performance optimization - if (this.has_abort_handler and this.blob.fastSize() < 16384 - 1024) { + if (this.flags.has_abort_handler and this.blob.fastSize() < 16384 - 1024) { if (this.resp) |resp| { resp.runCorkedWithType(*RequestContext, doRenderBlobCorked, this); } @@ -2556,7 +2559,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn doRender(this: *RequestContext) void { ctxLog("render", .{}); - if (this.aborted) { + if (this.flags.aborted) { this.finalizeForAbort(); return; } @@ -2568,17 +2571,17 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp if (this.resp) |resp| { switch (status) { 404 => { - if (!this.has_written_status) { + if (!this.flags.has_written_status) { resp.writeStatus("404 Not Found"); - this.has_written_status = true; + this.flags.has_written_status = true; } this.endWithoutBody(this.shouldCloseConnection()); }, else => { - if (!this.has_written_status) { + if (!this.flags.has_written_status) { resp.writeStatus("500 Internal Server Error"); resp.writeHeader("content-type", "text/plain"); - this.has_written_status = true; + this.flags.has_written_status = true; } this.end("Something went wrong!", this.shouldCloseConnection()); @@ -2599,7 +2602,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp if (this.pathname.len > 0) return this.pathname; - if (!this.has_abort_handler) { + if (!this.flags.has_abort_handler) { return this.req.url(); } @@ -2642,8 +2645,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp status: u16, ) void { JSC.markBinding(@src()); - if (!this.server.config.onError.isEmpty() and !this.has_called_error_handler) { - this.has_called_error_handler = true; + if (!this.server.config.onError.isEmpty() and !this.flags.has_called_error_handler) { + this.flags.has_called_error_handler = true; var args = [_]JSC.C.JSValueRef{value.asObjectRef()}; const result = JSC.C.JSObjectCallAsFunctionReturnValue(this.server.globalThis, this.server.config.onError.asObjectRef(), this.server.thisObject.asObjectRef(), 1, &args); defer result.ensureStillAlive(); @@ -2678,7 +2681,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp var response: *JSC.WebCore.Response = this.response_ptr.?; var status = response.statusCode(); - var needs_content_range = this.needs_content_range and this.sendfile.remain < this.blob.size(); + var needs_content_range = this.flags.needs_content_range and this.sendfile.remain < this.blob.size(); const size = if (needs_content_range) this.sendfile.remain @@ -2756,9 +2759,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } } - if (this.needs_content_length) { + if (this.flags.needs_content_length) { resp.writeHeaderInt("content-length", size); - this.needs_content_length = false; + this.flags.needs_content_length = false; } if (needs_content_range) { @@ -2775,7 +2778,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp .{ this.sendfile.offset, this.sendfile.offset + (this.sendfile.remain -| 1) }, ) catch "bytes */*", ); - this.needs_content_range = false; + this.flags.needs_content_range = false; } } @@ -2789,7 +2792,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp bytes.len, this.shouldCloseConnection(), )) { - this.has_marked_pending = true; + this.flags.has_marked_pending = true; resp.onWritable(*RequestContext, onWritableBytes, this); // given a blob, we might not have set an abort handler yet this.setAbortHandler(); @@ -2812,8 +2815,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp std.debug.assert(this.resp == resp); - this.is_waiting_body = last == false; - if (this.aborted or this.has_marked_complete) return; + this.flags.is_waiting_body = last == false; + if (this.flags.aborted or this.flags.has_marked_complete) return; if (this.request_body != null) { var body = this.request_body.?; @@ -2893,7 +2896,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp pub fn onStartStreamingRequestBody(this: *RequestContext) JSC.WebCore.DrainResult { ctxLog("onStartStreamingRequestBody", .{}); - if (this.aborted) { + if (this.flags.aborted) { return JSC.WebCore.DrainResult{ .aborted = {}, }; @@ -2923,7 +2926,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp ctxLog("onStartBuffering", .{}); // TODO: check if is someone calling onStartBuffering other than onStartBufferingCallback // if is not, this should be removed and only keep protect + setAbortHandler - if (this.is_transfer_encoding == false and this.request_body_content_len == 0) { + if (this.flags.is_transfer_encoding == false and this.request_body_content_len == 0) { // no content-length or 0 content-length // no transfer-encoding if (this.request_body != null) { @@ -4479,7 +4482,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { } var upgrader = bun.cast(*RequestContext, request.upgrader.?); - if (upgrader.aborted or upgrader.resp == null) { + if (upgrader.flags.aborted or upgrader.resp == null) { return JSC.jsBoolean(false); } @@ -5105,7 +5108,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { }; if (comptime debug_mode) { - ctx.is_web_browser_navigation = brk: { + ctx.flags.is_web_browser_navigation = brk: { if (ctx.req.header("sec-fetch-dest")) |fetch_dest| { if (strings.eqlComptime(fetch_dest, "document")) { break :brk true; @@ -5136,8 +5139,8 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { } ctx.request_body_content_len = req_len; - ctx.is_transfer_encoding = req.header("transfer-encoding") != null; - if (req_len > 0 or ctx.is_transfer_encoding) { + ctx.flags.is_transfer_encoding = req.header("transfer-encoding") != null; + if (req_len > 0 or ctx.flags.is_transfer_encoding) { // we defer pre-allocating the body until we receive the first chunk // that way if the client is lying about how big the body is or the client aborts // we don't waste memory @@ -5149,7 +5152,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { .onStartStreaming = RequestContext.onStartStreamingRequestBodyCallback, }, }; - ctx.is_waiting_body = true; + ctx.flags.is_waiting_body = true; resp.onData(*RequestContext, RequestContext.onBufferedBodyChunk, ctx); } } -- cgit v1.2.3 From 4720fa1207d374a2447d457ad478f9f8911b959a Mon Sep 17 00:00:00 2001 From: Ai Hoshino Date: Sun, 2 Jul 2023 08:01:52 +0800 Subject: [WIP]Fix calling `Buffer.toString` with `(offset, length, encoding)` (#3467) * Allow `toString` to be called with `(offset, length, encoding)`. Close: #3085 * handle undefined value * add tests for buffer.xxxSlice * fix parameters * fix offset and length --- src/bun.js/bindings/JSBuffer.cpp | 67 ++++++++++++++++++------------ src/js/builtins/JSBufferPrototype.ts | 32 +++++++-------- test/js/node/buffer.test.js | 79 ++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 43 deletions(-) diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index 00965da89..4b0e058dd 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -1436,43 +1436,56 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS if (length == 0) return JSC::JSValue::encode(JSC::jsEmptyString(vm)); - switch (callFrame->argumentCount()) { - case 0: { - break; - } - case 2: - case 3: - case 1: { - EnsureStillAliveScope arg1 = callFrame->uncheckedArgument(0); - if (!arg1.value().isUndefined()) { - encoding = parseEncoding(lexicalGlobalObject, scope, arg1.value()); + size_t argsCount = callFrame->argumentCount(); + + JSC::JSValue arg1 = callFrame->argument(0); + JSC::JSValue arg2 = callFrame->argument(1); + JSC::JSValue arg3 = callFrame->argument(2); + + // This method could be called in following forms: + // - toString() + // - toString(encoding) + // - toString(encoding, start) + // - toString(encoding, start, end) + // - toString(offset, length) + // - toString(offset, length, encoding) + if (argsCount == 0) + return jsBufferToString(vm, lexicalGlobalObject, castedThis, offset, length, encoding); + + if (arg1.isString()) { + encoding = parseEncoding(lexicalGlobalObject, scope, arg1); RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); - } - if (callFrame->argumentCount() == 1) - break; - } - // any - case 5: { - JSC::JSValue arg2 = callFrame->uncheckedArgument(1); - int32_t ioffset = arg2.toInt32(lexicalGlobalObject); + + if (!arg3.isUndefined()) { + // length is end + length = std::min(byteLength, static_cast(arg3.toInt32(lexicalGlobalObject))); + } + + int32_t istart = arg2.toInt32(lexicalGlobalObject); + if (istart < 0) { + throwTypeError(lexicalGlobalObject, scope, "Start must be a positive integer"_s); + return JSC::JSValue::encode(jsUndefined()); + } + offset = static_cast(istart); + length = (length > offset) ? (length - offset) : 0; + } else { + int32_t ioffset = arg1.toInt32(lexicalGlobalObject); if (ioffset < 0) { throwTypeError(lexicalGlobalObject, scope, "Offset must be a positive integer"_s); return JSC::JSValue::encode(jsUndefined()); } offset = static_cast(ioffset); + length = (length > offset) ? (length - offset) : 0; - if (callFrame->argumentCount() == 2) - break; - } + if (!arg3.isUndefined()) { + encoding = parseEncoding(lexicalGlobalObject, scope, arg3); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + } - default: { - length = std::min(byteLength, static_cast(callFrame->argument(2).toInt32(lexicalGlobalObject))); - break; - } + if (!arg2.isUndefined()) + length = std::min(length, static_cast(arg2.toInt32(lexicalGlobalObject))); } - length -= std::min(offset, length); - return jsBufferToString(vm, lexicalGlobalObject, castedThis, offset, length, encoding); } diff --git a/src/js/builtins/JSBufferPrototype.ts b/src/js/builtins/JSBufferPrototype.ts index 97b25b9b2..f5d6a7bfb 100644 --- a/src/js/builtins/JSBufferPrototype.ts +++ b/src/js/builtins/JSBufferPrototype.ts @@ -427,29 +427,29 @@ export function hexWrite(this: BufferExt, text, offset, length) { return this.write(text, offset, length, "hex"); } -export function utf8Slice(this: BufferExt, offset, length) { - return this.toString(offset, length, "utf8"); +export function utf8Slice(this: BufferExt, start, end) { + return this.toString("utf8", start, end); } -export function ucs2Slice(this: BufferExt, offset, length) { - return this.toString(offset, length, "ucs2"); +export function ucs2Slice(this: BufferExt, start, end) { + return this.toString("ucs2", start, end); } -export function utf16leSlice(this: BufferExt, offset, length) { - return this.toString(offset, length, "utf16le"); +export function utf16leSlice(this: BufferExt, start, end) { + return this.toString("utf16le", start, end); } -export function latin1Slice(this: BufferExt, offset, length) { - return this.toString(offset, length, "latin1"); +export function latin1Slice(this: BufferExt, start, end) { + return this.toString("latin1", start, end); } -export function asciiSlice(this: BufferExt, offset, length) { - return this.toString(offset, length, "ascii"); +export function asciiSlice(this: BufferExt, start, end) { + return this.toString("ascii", start, end); } -export function base64Slice(this: BufferExt, offset, length) { - return this.toString(offset, length, "base64"); +export function base64Slice(this: BufferExt, start, end) { + return this.toString("base64", start, end); } -export function base64urlSlice(this: BufferExt, offset, length) { - return this.toString(offset, length, "base64url"); +export function base64urlSlice(this: BufferExt, start, end) { + return this.toString("base64url", start, end); } -export function hexSlice(this: BufferExt, offset, length) { - return this.toString(offset, length, "hex"); +export function hexSlice(this: BufferExt, start, end) { + return this.toString("hex", start, end); } export function toJSON(this: BufferExt) { diff --git a/test/js/node/buffer.test.js b/test/js/node/buffer.test.js index 697774e0a..e0d8f5486 100644 --- a/test/js/node/buffer.test.js +++ b/test/js/node/buffer.test.js @@ -2353,6 +2353,85 @@ it("Buffer.byteLength()", () => { } }); +it("Buffer.toString(encoding, start, end)", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.toString()).toStrictEqual("0123456789"); + expect(buf.toString("utf8")).toStrictEqual("0123456789"); + expect(buf.toString("utf8", 3)).toStrictEqual("3456789"); + expect(buf.toString("utf8", 3, 4)).toStrictEqual("3"); + + expect(buf.toString("utf8", 3, 100)).toStrictEqual("3456789"); + expect(buf.toString("utf8", 3, 1)).toStrictEqual(""); + expect(buf.toString("utf8", 100, 200)).toStrictEqual(""); + expect(buf.toString("utf8", 100, 1)).toStrictEqual(""); +}); + +it("Buffer.toString(offset, length, encoding)", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.toString(3, 6, "utf8")).toStrictEqual("345678"); + expect(buf.toString(3, 100, "utf8")).toStrictEqual("3456789"); + expect(buf.toString(100, 200, "utf8")).toStrictEqual(""); + expect(buf.toString(100, 50, "utf8")).toStrictEqual(""); +}); + +it("Buffer.asciiSlice())", () => { + const buf = Buffer.from("0123456789", "ascii"); + + expect(buf.asciiSlice()).toStrictEqual("0123456789"); + expect(buf.asciiSlice(3)).toStrictEqual("3456789"); + expect(buf.asciiSlice(3, 4)).toStrictEqual("3"); +}); + +it("Buffer.latin1Slice()", () => { + const buf = Buffer.from("âéö", "latin1"); + + expect(buf.latin1Slice()).toStrictEqual("âéö"); + expect(buf.latin1Slice(1)).toStrictEqual("éö"); + expect(buf.latin1Slice(1, 2)).toStrictEqual("é"); +}); + +it("Buffer.utf8Slice()", () => { + const buf = Buffer.from("あいうえお", "utf8"); + + expect(buf.utf8Slice()).toStrictEqual("あいうえお"); + expect(buf.utf8Slice(3)).toStrictEqual("いうえお"); + expect(buf.utf8Slice(3, 6)).toStrictEqual("い"); +}); + +it("Buffer.hexSlice()", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.hexSlice()).toStrictEqual("30313233343536373839"); + expect(buf.hexSlice(3)).toStrictEqual("33343536373839"); + expect(buf.hexSlice(3, 4)).toStrictEqual("33"); +}); + +it("Buffer.ucs2Slice()", () => { + const buf = Buffer.from("あいうえお", "ucs2"); + + expect(buf.ucs2Slice()).toStrictEqual("あいうえお"); + expect(buf.ucs2Slice(2)).toStrictEqual("いうえお"); + expect(buf.ucs2Slice(2, 6)).toStrictEqual("いう"); +}); + +it("Buffer.base64Slice()", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.base64Slice()).toStrictEqual("MDEyMzQ1Njc4OQ=="); + expect(buf.base64Slice(3)).toStrictEqual("MzQ1Njc4OQ=="); + expect(buf.base64Slice(3, 4)).toStrictEqual("Mw=="); +}); + +it("Buffer.base64urlSlice()", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.base64urlSlice()).toStrictEqual("MDEyMzQ1Njc4OQ"); + expect(buf.base64urlSlice(3)).toStrictEqual("MzQ1Njc4OQ"); + expect(buf.base64urlSlice(3, 4)).toStrictEqual("Mw"); +}); + it("should not crash on invalid UTF-8 byte sequence", () => { const buf = Buffer.from([0xc0, 0xfd]); expect(buf.length).toBe(2); -- cgit v1.2.3 From f3833376e75a2353285fc884f31a5be97a917b6e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 17:07:37 -0700 Subject: small cleanup --- src/bun.js/bindings/JSBuffer.cpp | 33 ++++--- src/js/out/WebCoreJSBuiltins.cpp | 192 +++++++++++++++++++-------------------- 2 files changed, 117 insertions(+), 108 deletions(-) diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index 4b0e058dd..10f9aab5a 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -1453,23 +1453,32 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS return jsBufferToString(vm, lexicalGlobalObject, castedThis, offset, length, encoding); if (arg1.isString()) { - encoding = parseEncoding(lexicalGlobalObject, scope, arg1); + encoding = parseEncoding(lexicalGlobalObject, scope, arg1); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + + if (!arg3.isUndefined()) { + // length is end + length = std::min(byteLength, static_cast(arg3.toInt32(lexicalGlobalObject))); RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + } - if (!arg3.isUndefined()) { - // length is end - length = std::min(byteLength, static_cast(arg3.toInt32(lexicalGlobalObject))); - } + int32_t istart = 0; - int32_t istart = arg2.toInt32(lexicalGlobalObject); - if (istart < 0) { - throwTypeError(lexicalGlobalObject, scope, "Start must be a positive integer"_s); - return JSC::JSValue::encode(jsUndefined()); - } - offset = static_cast(istart); - length = (length > offset) ? (length - offset) : 0; + if (!arg2.isUndefined()) { + istart = arg2.toInt32(lexicalGlobalObject); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + } + + if (istart < 0) { + throwTypeError(lexicalGlobalObject, scope, "Start must be a positive integer"_s); + return JSC::JSValue::encode(jsUndefined()); + } + offset = static_cast(istart); + length = (length > offset) ? (length - offset) : 0; } else { int32_t ioffset = arg1.toInt32(lexicalGlobalObject); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + if (ioffset < 0) { throwTypeError(lexicalGlobalObject, scope, "Offset must be a positive integer"_s); return JSC::JSValue::encode(jsUndefined()); diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index df64669b5..3c3a0eedc 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -114,9 +114,9 @@ const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 956; +const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 920; static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,o){\"use strict\";const w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,o){\"use strict\";const w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; // initializeWritableStreamSlots const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = 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,B){\"use strict\";const h=@getByIdDirectPrivate(c,\"state\");if(h===\"closed\"||h===\"errored\")return @Promise.@resolve();const _=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(_!==@undefined)return _.promise.@promise;@assert(h===\"writable\"||h===\"erroring\");let f=!1;if(h===\"erroring\")f=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:f}),!f)@writableStreamStartErroring(c,B);return j.@promise})\n"; +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"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = 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 (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"; +const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (_){\"use strict\";@assert(@getByIdDirectPrivate(_,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(_)),@putByIdDirectPrivate(_,\"state\",\"errored\");const h=@getByIdDirectPrivate(_,\"controller\");@getByIdDirectPrivate(h,\"errorSteps\").@call();const B=@getByIdDirectPrivate(_,\"storedError\"),A=@getByIdDirectPrivate(_,\"writeRequests\");for(var I=A.shift();I;I=A.shift())I.@reject.@call(@undefined,B);@putByIdDirectPrivate(_,\"writeRequests\",@createFIFO());const i=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(i===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}if(@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined),i.wasAlreadyErroring){i.promise.@reject.@call(@undefined,B),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}@getByIdDirectPrivate(h,\"abortSteps\").@call(@undefined,i.reason).@then(()=>{i.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)},(p)=>{i.promise.@reject.@call(@undefined,p),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const _=@getByIdDirectPrivate(d,\"state\");if(@assert(_===\"writable\"||_===\"erroring\"),_===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const n=@getByIdDirectPrivate(d,\"writer\");if(n!==@undefined)@getByIdDirectPrivate(n,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -220,7 +220,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength = 488; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,c){\"use strict\";const d=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(d!==@undefined),d.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(_,\"state\");@assert(n===\"writable\"||n===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,c)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,d){\"use strict\";const c=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(c!==@undefined),c.@reject.@call(@undefined,d),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(_,\"state\");@assert(n===\"writable\"||n===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,d),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,d)})\n"; // writableStreamFinishInFlightWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility = 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 (d,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const W=@getByIdDirectPrivate(P,\"controller\");@assert(W!==@undefined);const _=@writableStreamDefaultControllerGetChunkSize(W,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const b=@getByIdDirectPrivate(P,\"state\");if(b===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(b===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(b===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(W,g,_),f})\n"; +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"; // setUpWritableStreamDefaultController const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -370,9 +370,9 @@ const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartC const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 573; +const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,P,_,j,p){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},f=()=>{return @Promise.@resolve()};if(\"start\"in _){const E=_[\"start\"];x=()=>@promiseInvokeOrNoopMethodNoCatch(P,E,[q])}if(\"write\"in _){const E=_[\"write\"];B=(F)=>@promiseInvokeOrNoopMethod(P,E,[F,q])}if(\"close\"in _){const E=_[\"close\"];C=()=>@promiseInvokeOrNoopMethod(P,E,[])}if(\"abort\"in _){const E=_[\"abort\"];f=(F)=>@promiseInvokeOrNoopMethod(P,E,[F])}@setUpWritableStreamDefaultController(v,q,x,B,C,f,j,p)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,P,_,j,p){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},f=()=>{return @Promise.@resolve()};if(\"start\"in _){const E=_.start;x=()=>@promiseInvokeOrNoopMethodNoCatch(P,E,[q])}if(\"write\"in _){const E=_.write;B=(F)=>@promiseInvokeOrNoopMethod(P,E,[F,q])}if(\"close\"in _){const E=_.close;C=()=>@promiseInvokeOrNoopMethod(P,E,[])}if(\"abort\"in _){const E=_.abort;f=(F)=>@promiseInvokeOrNoopMethod(P,E,[F])}@setUpWritableStreamDefaultController(v,q,x,B,C,f,j,p)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = 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 (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"; +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"; #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 (_,c,j,q,v,x,B){\"use strict\";if(q===@undefined)q=1;if(v===@undefined)v=()=>1;if(x===@undefined)x=0;if(B===@undefined)B=()=>1;@assert(q>=0),@assert(x>=0);const D={};@putByIdDirectPrivate(D,\"TransformStream\",!0);const E=new @TransformStream(D),F=@newPromiseCapability(@Promise);@initializeTransformStream(E,F.@promise,q,v,x,B);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(E,G,c,j),_().@then(()=>{F.@resolve.@call()},(I)=>{F.@reject.@call(@undefined,I)}),E})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (j,q,v,x,B,D,E){\"use strict\";if(x===@undefined)x=1;if(B===@undefined)B=()=>1;if(D===@undefined)D=0;if(E===@undefined)E=()=>1;@assert(x>=0),@assert(D>=0);const F={};@putByIdDirectPrivate(F,\"TransformStream\",!0);const G=new @TransformStream(F),I=@newPromiseCapability(@Promise);@initializeTransformStream(G,I.@promise,x,B,D,E);const _=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(G,_,q,v),j().@then(()=>{I.@resolve.@call()},(c)=>{I.@reject.@call(@undefined,c)}),G})\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 (f,G,B,T,C,F){\"use strict\";const I=()=>{return G},J=(x)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,x)},K=(x)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,x)},j=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},L=@createWritableStream(I,J,j,K,B,T),N=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},q=(x)=>{return @transformStreamErrorWritableAndUnblockWrite(f,x),@Promise.@resolve()},D={};@putByIdDirectPrivate(D,\"start\",I),@putByIdDirectPrivate(D,\"pull\",N),@putByIdDirectPrivate(D,\"cancel\",q);const E={};@putByIdDirectPrivate(E,\"size\",F),@putByIdDirectPrivate(E,\"highWaterMark\",C);const v=new @ReadableStream(D,E);@putByIdDirectPrivate(f,\"writable\",L),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(L)),@putByIdDirectPrivate(f,\"readable\",v),@putByIdDirectPrivate(f,\"backpressure\",@undefined),@putByIdDirectPrivate(f,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(f,!0),@putByIdDirectPrivate(f,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (T,j,q,C,D,E){\"use strict\";const F=()=>{return j},G=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(T,N)},I=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(T,N)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(T)},f=@createWritableStream(F,G,J,I,q,C),B=()=>{return @transformStreamDefaultSourcePullAlgorithm(T)},v=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(T,N),@Promise.@resolve()},x={};@putByIdDirectPrivate(x,\"start\",F),@putByIdDirectPrivate(x,\"pull\",B),@putByIdDirectPrivate(x,\"cancel\",v);const K={};@putByIdDirectPrivate(K,\"size\",E),@putByIdDirectPrivate(K,\"highWaterMark\",D);const L=new @ReadableStream(x,K);@putByIdDirectPrivate(T,\"writable\",f),@putByIdDirectPrivate(T,\"internalWritable\",@getInternalWritableStream(f)),@putByIdDirectPrivate(T,\"readable\",L),@putByIdDirectPrivate(T,\"backpressure\",@undefined),@putByIdDirectPrivate(T,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(T,!0),@putByIdDirectPrivate(T,\"controller\",@undefined)})\n"; // transformStreamError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -548,9 +548,9 @@ const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControlle const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 449; +const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 443; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (d,p,v){\"use strict\";const b=new @TransformStreamDefaultController;let q=(j)=>{try{@transformStreamDefaultControllerEnqueue(b,j)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},_=()=>{return @Promise.@resolve()};if(\"transform\"in v)q=(j)=>{return @promiseInvokeOrNoopMethod(p,v[\"transform\"],[j,b])};if(\"flush\"in v)_=()=>{return @promiseInvokeOrNoopMethod(p,v[\"flush\"],[b])};@setUpTransformStreamDefaultController(d,b,q,_)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,d,p){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in p)b=(q)=>{return @promiseInvokeOrNoopMethod(d,p.transform,[q,v])};if(\"flush\"in p)j=()=>{return @promiseInvokeOrNoopMethod(d,p.flush,[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,f){\"use strict\";const g=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,f).@then(()=>{g.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),g.@reject.@call(@undefined,j)}),g.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (A,M){\"use strict\";var N={path:\"node:process\",require:M},O=(Z)=>N.require(Z);function Q(Z){var{Duplex:T,eos:x,destroy:Y}=O(\"node:stream\"),j=class H extends T{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=O(\"node:tty\").isatty(Z)}get fd(){return Z}constructor(V){super({readable:!0,writable:!0});this.#G=`/dev/fd/${V}`}#N(V){const L=this.#H;if(this.#H=null,L)L(V);else if(V)this.destroy(V);else if(!this.#j&&!this.#z)this.destroy()}_destroy(V,L){if(!V&&this.#H!==null){var X=class J extends Error{code;name;constructor(z=\"The operation was aborted\",P=void 0){if(P!==void 0&&typeof P!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(P,null,2)}`);super(z,P);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};V=new X}if(this.#J=null,this.#K=null,this.#H===null)L(V);else{if(this.#H=L,this.#$)Y(this.#$,V);if(this.#B)Y(this.#B,V)}}_write(V,L,X){if(!this.#$){var{createWriteStream:J}=O(\"node:fs\"),z=this.#$=J(this.#G);z.on(\"finish\",()=>{if(this.#K){const P=this.#K;this.#K=null,P()}}),z.on(\"drain\",()=>{if(this.#J){const P=this.#J;this.#J=null,P()}}),x(z,(P)=>{if(this.#z=!1,P)Y(z,P);this.#N(P)})}if(z.write(V,L))X();else this.#J=X}_final(V){this.#$&&this.#$.end(),this.#K=V}#O(){var{createReadStream:V}=O(\"node:fs\"),L=this.#B=V(this.#G);return L.on(\"readable\",()=>{if(this.#L){const X=this.#L;this.#L=null,X()}else this.read()}),L.on(\"end\",()=>{this.push(null)}),x(L,(X)=>{if(this.#j=!1,X)Y(L,X);this.#N(X)}),L}_read(){var V=this.#B;if(!V)V=this.#O();while(!0){const L=V.read();if(L===null||!this.push(L))return}}};return new j(Z)}var{EventEmitter:B}=O(\"node:events\");function G(Z){if(!Z)return!0;var T=Z.toLowerCase();return T===\"utf8\"||T===\"utf-8\"||T===\"buffer\"||T===\"binary\"}var U,K=class Z extends B{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(T){if(this.#B||!G(T))return this.#J(),this.#B.setDefaultEncoding(T)}#G(){switch(this.#$){case 1:{var T=@Bun.stdout.writer({highWaterMark:0});return T.unref(),T}case 2:{var T=@Bun.stderr.writer({highWaterMark:0});return T.unref(),T}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(T){super();this.#$=T}get fd(){return this.#$}get isTTY(){return this.#z\?\?=O(\"node:tty\").isatty(this.#$)}cursorTo(T,x,Y){return(U\?\?=O(\"readline\")).cursorTo(this,T,x,Y)}moveCursor(T,x,Y){return(U\?\?=O(\"readline\")).moveCursor(this,T,x,Y)}clearLine(T,x){return(U\?\?=O(\"readline\")).clearLine(this,T,x)}clearScreenDown(T){return(U\?\?=O(\"readline\")).clearScreenDown(this,T)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(T,x){if(T===\"close\"||T===\"finish\")return this.#J(),this.#B.on(T,x);if(T===\"drain\")return super.on(\"drain\",x);if(T===\"error\")return super.on(\"error\",x);return super.on(T,x)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(T){return this.#J(),this.#B.pipe(T)}unpipe(T){return this.#J(),this.#B.unpipe(T)}#J(){if(this.#B)return;this.#B=Q(this.#$);const T=this.eventNames();for(let x of T)this.#B.on(x,(...Y)=>{this.emit(x,...Y)})}#K(T){var x=this.#H();const Y=x.write(T);this.bytesWritten+=Y;const j=x.flush(!1);return!!(Y||j)}#L(T,x){if(!G(x))return this.#J(),this.#B.write(T,x);return this.#K(T)}#M(T,x){if(x)this.emit(\"error\",x);try{T(x\?x:null)}catch(Y){this.emit(\"error\",Y)}}#N(T,x,Y){if(!G(x))return this.#J(),this.#B.write(T,x,Y);var j=this.#H();const H=j.write(T),V=j.flush(!0);if(V\?.then)return V.then(()=>{this.#M(Y),this.emit(\"drain\")},(L)=>this.#M(Y,L)),!1;return queueMicrotask(()=>{this.#M(Y)}),!!(H||V)}write(T,x,Y){const j=this._write(T,x,Y);if(j)this.emit(\"drain\");return j}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(T,x,Y){var j=this.#B;if(j)return j.write(T,x,Y);switch(arguments.length){case 0:{var H=new Error(\"Invalid arguments\");throw H.code=\"ERR_INVALID_ARG_TYPE\",H}case 1:return this.#K(T);case 2:if(typeof x===\"function\")return this.#N(T,\"\",x);else if(typeof x===\"string\")return this.#L(T,x);default:{if(typeof x!==\"undefined\"&&typeof x!==\"string\"||typeof Y!==\"undefined\"&&typeof Y!==\"function\"){var H=new Error(\"Invalid arguments\");throw H.code=\"ERR_INVALID_ARG_TYPE\",H}if(typeof Y===\"undefined\")return this.#L(T,x);return this.#N(T,x,Y)}}}destroy(){return this}end(){return this}};return new K(A)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (j,H){\"use strict\";var K={path:\"node:process\",require:H},G=(N)=>K.require(N);function J(N){var{Duplex:O,eos:Q,destroy:U}=G(\"node:stream\"),V=class X extends O{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(N)}get fd(){return N}constructor(Z){super({readable:!0,writable:!0});this.#G=`/dev/fd/${Z}`}#N(Z){const Y=this.#H;if(this.#H=null,Y)Y(Z);else if(Z)this.destroy(Z);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Z,Y){if(!Z&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Z=new P}if(this.#J=null,this.#K=null,this.#H===null)Y(Z);else{if(this.#H=Y,this.#$)U(this.#$,Z);if(this.#B)U(this.#B,Z)}}_write(Z,Y,P){if(!this.#$){var{createWriteStream:A}=G(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),Q(T,(x)=>{if(this.#z=!1,x)U(T,x);this.#N(x)})}if(T.write(Z,Y))P();else this.#J=P}_final(Z){this.#$&&this.#$.end(),this.#K=Z}#O(){var{createReadStream:Z}=G(\"node:fs\"),Y=this.#B=Z(this.#G);return Y.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),Y.on(\"end\",()=>{this.push(null)}),Q(Y,(P)=>{if(this.#j=!1,P)U(Y,P);this.#N(P)}),Y}_read(){var Z=this.#B;if(!Z)Z=this.#O();while(!0){const Y=Z.read();if(Y===null||!this.push(Y))return}}};return new V(N)}var{EventEmitter:z}=G(\"node:events\");function L(N){if(!N)return!0;var O=N.toLowerCase();return O===\"utf8\"||O===\"utf-8\"||O===\"buffer\"||O===\"binary\"}var M,B=class N extends z{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(O){if(this.#B||!L(O))return this.#J(),this.#B.setDefaultEncoding(O)}#G(){switch(this.#$){case 1:{var O=@Bun.stdout.writer({highWaterMark:0});return O.unref(),O}case 2:{var O=@Bun.stderr.writer({highWaterMark:0});return O.unref(),O}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(O){super();this.#$=O}get fd(){return this.#$}get isTTY(){return this.#z\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(O,Q,U){return(M\?\?=G(\"readline\")).cursorTo(this,O,Q,U)}moveCursor(O,Q,U){return(M\?\?=G(\"readline\")).moveCursor(this,O,Q,U)}clearLine(O,Q){return(M\?\?=G(\"readline\")).clearLine(this,O,Q)}clearScreenDown(O){return(M\?\?=G(\"readline\")).clearScreenDown(this,O)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(O,Q){if(O===\"close\"||O===\"finish\")return this.#J(),this.#B.on(O,Q);if(O===\"drain\")return super.on(\"drain\",Q);if(O===\"error\")return super.on(\"error\",Q);return super.on(O,Q)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(O){return this.#J(),this.#B.pipe(O)}unpipe(O){return this.#J(),this.#B.unpipe(O)}#J(){if(this.#B)return;this.#B=J(this.#$);const O=this.eventNames();for(let Q of O)this.#B.on(Q,(...U)=>{this.emit(Q,...U)})}#K(O){var Q=this.#H();const U=Q.write(O);this.bytesWritten+=U;const V=Q.flush(!1);return!!(U||V)}#L(O,Q){if(!L(Q))return this.#J(),this.#B.write(O,Q);return this.#K(O)}#M(O,Q){if(Q)this.emit(\"error\",Q);try{O(Q\?Q:null)}catch(U){this.emit(\"error\",U)}}#N(O,Q,U){if(!L(Q))return this.#J(),this.#B.write(O,Q,U);var V=this.#H();const X=V.write(O),Z=V.flush(!0);if(Z\?.then)return Z.then(()=>{this.#M(U),this.emit(\"drain\")},(Y)=>this.#M(U,Y)),!1;return queueMicrotask(()=>{this.#M(U)}),!!(X||Z)}write(O,Q,U){const V=this._write(O,Q,U);if(V)this.emit(\"drain\");return V}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(O,Q,U){var V=this.#B;if(V)return V.write(O,Q,U);switch(arguments.length){case 0:{var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}case 1:return this.#K(O);case 2:if(typeof Q===\"function\")return this.#N(O,\"\",Q);else if(typeof Q===\"string\")return this.#L(O,Q);default:{if(typeof Q!==\"undefined\"&&typeof Q!==\"string\"||typeof U!==\"undefined\"&&typeof U!==\"function\"){var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}if(typeof U===\"undefined\")return this.#L(O,Q);return this.#N(O,Q,U)}}}destroy(){return this}end(){return this}};return new B(j)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = 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,j,z){\"use strict\";var G={path:\"node:process\",require:j},H=(M)=>G.require(M),{Duplex:I,eos:J,destroy:K}=H(\"node:stream\"),L=class M extends I{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return H(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(N){const P=this.#J;if(this.#J=null,P)P(N);else if(N)this.destroy(N);else if(!this.#z&&!this.#H)this.destroy()}_destroy(N,P){if(!N&&this.#J!==null){var Q=class T extends Error{constructor(U=\"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(U,V);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new Q}if(this.#J===null)P(N);else if(this.#J=P,this.#j)K(this.#j,N)}setRawMode(N){}on(N,P){if(N===\"readable\")this.ref(),this.#G=!0;return super.on(N,P)}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 N,P;const Q=this.#Y.readMany();if(!Q\?.then)({done:N,value:P}=Q);else({done:N,value:P}=await Q);if(!N){this.push(P[0]);const T=P.length;for(let U=1;U{if(this.#I){const Q=this.#I;this.#I=null,Q()}}),P.on(\"drain\",()=>{if(this.#K){const Q=this.#K;this.#K=null,Q()}}),J(P,(Q)=>{if(this.#H=!1,Q)K(P,Q);this.#L(Q)}),P}_write(N,P,Q){var T=this.#j;if(!T)T=this.#N();if(T.write(N,P))Q();else this.#K=Q}_final(N){this.#j.end(),this.#I=(...P)=>N(...P)}};return new L})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (Y,L,Q){\"use strict\";var M={path:\"node:process\",require:L},j=(N)=>M.require(N),{Duplex:T,eos:K,destroy:U}=j(\"node:stream\"),z=class N extends T{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return j(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(V){const G=this.#J;if(this.#J=null,G)G(V);else if(V)this.destroy(V);else if(!this.#z&&!this.#H)this.destroy()}_destroy(V,G){if(!V&&this.#J!==null){var H=class I extends Error{constructor(J=\"The operation was aborted\",P=void 0){if(P!==void 0&&typeof P!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(P,null,2)}`);super(J,P);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};V=new H}if(this.#J===null)G(V);else if(this.#J=G,this.#j)U(this.#j,V)}setRawMode(V){}on(V,G){if(V===\"readable\")this.ref(),this.#G=!0;return super.on(V,G)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#Y\?\?=Q.stdin.stream().getReader(),this.#$\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#$)clearInterval(this.#$),this.#$=null}async#M(){try{var V,G;const H=this.#Y.readMany();if(!H\?.then)({done:V,value:G}=H);else({done:V,value:G}=await H);if(!V){this.push(G[0]);const I=G.length;for(let J=1;J{if(this.#I){const H=this.#I;this.#I=null,H()}}),G.on(\"drain\",()=>{if(this.#K){const H=this.#K;this.#K=null,H()}}),K(G,(H)=>{if(this.#H=!1,H)U(G,H);this.#L(H)}),G}_write(V,G,H){var I=this.#j;if(!I)I=this.#N();if(I.write(V,G))H();else this.#K=H}_final(V){this.#j.end(),this.#I=(...G)=>V(...G)}};return new z})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -672,9 +672,9 @@ WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) const JSC::ConstructAbility s_transformStreamInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_transformStreamInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_transformStreamInitializeTransformStreamCodeLength = 1334; +const int s_transformStreamInitializeTransformStreamCodeLength = 1304; static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let B=arguments[1],u=arguments[2];if(_===@undefined)_=null;if(u===@undefined)u={};if(B===@undefined)B={};let j={};if(_!==null){if(\"start\"in _){if(j[\"start\"]=_[\"start\"],typeof j[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(j[\"transform\"]=_[\"transform\"],typeof j[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(j[\"flush\"]=_[\"flush\"],typeof j[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const v=@extractHighWaterMark(u,0),x=@extractSizeAlgorithm(u),E=@extractHighWaterMark(B,1),F=@extractSizeAlgorithm(B),G=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,G.@promise,E,F,v,x),@setUpTransformStreamDefaultControllerFromTransformer(this,_,j),(\"start\"in j)){const q=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,j[\"start\"],[q]))().@then(()=>{G.@resolve.@call()},(J)=>{G.@reject.@call(@undefined,J)})}else G.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let j=arguments[0];if(@isObject(j)&&@getByIdDirectPrivate(j,\"TransformStream\"))return this;let q=arguments[1],v=arguments[2];if(j===@undefined)j=null;if(v===@undefined)v={};if(q===@undefined)q={};let x={};if(j!==null){if(\"start\"in j){if(x.start=j.start,typeof x.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in j){if(x.transform=j.transform,typeof x.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in j){if(x.flush=j.flush,typeof x.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in j)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in j)@throwRangeError(\"TransformStream transformer has a writableType\")}const B=@extractHighWaterMark(v,0),E=@extractSizeAlgorithm(v),F=@extractHighWaterMark(q,1),G=@extractSizeAlgorithm(q),I=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,I.@promise,F,G,B,E),@setUpTransformStreamDefaultControllerFromTransformer(this,j,x),(\"start\"in x)){const J=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(j,x.start,[J]))().@then(()=>{I.@resolve.@call()},(u)=>{I.@reject.@call(@undefined,u)})}else I.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (_){\"use strict\";const S=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(S)return @evaluateCommonJSModule(S),S.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let f=@Loader.registry.@get(_);if(f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const h=f.module,r=@Loader.getModuleNamespaceObject(h),b=r\?.[@commonJSSymbol]===0||r\?.default\?.[@commonJSSymbol]===0\?r.default:r.__esModule\?r:Object.create(r,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}const L=@createCommonJSModule(_,{},!1);@requireMap.@set(_,L);var M=this.@require(_,L);if(M===-1){try{M=@requireESM(_)}catch(h){throw @requireMap.@delete(_),h}if(f=@Loader.registry.@get(_),f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const h=@Loader.getModuleNamespaceObject(f.module);return L.exports=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const M=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(M)return @evaluateCommonJSModule(M),M.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=S.module,h=@Loader.getModuleNamespaceObject(b),r=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const f=@createCommonJSModule(_,{},!1);@requireMap.@set(_,f);var L=this.@require(_,f);if(L===-1){try{L=@requireESM(_)}catch(b){throw @requireMap.@delete(_),b}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=@Loader.getModuleNamespaceObject(S.module);return f.exports=b\?.[@commonJSSymbol]===0||b\?.default\?.[@commonJSSymbol]===0\?b.default:b.__esModule\?b:Object.create(b,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(f),f.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,_){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:return u.getInt8(d);case 2:return u.getInt16(d,!0);case 3:{const r=u.getUint16(d,!0)+u.getUint8(d+2)*65536;return r|(r&8388608)*510}case 4:return u.getInt32(d,!0);case 5:{const r=u.getUint8(d+4);return(r|(r&128)*33554430)*4294967296+u.getUint32(d,!0)}case 6:{const r=u.getUint16(d+4,!0);return(r|(r&32768)*131070)*4294967296+u.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -838,7 +838,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntBECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,d){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return u.getInt8(r);case 2:return u.getInt16(r,!1);case 3:{const c=u.getUint16(r+1,!1)+u.getUint8(r)*65536;return c|(c&8388608)*510}case 4:return u.getInt32(r,!1);case 5:{const c=u.getUint8(r);return(c|(c&128)*33554430)*4294967296+u.getUint32(r+1,!1)}case 6:{const c=u.getUint16(r,!1);return(c|(c&32768)*131070)*4294967296+u.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,c){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:return u.getInt8(r);case 2:return u.getInt16(r,!1);case 3:{const d=u.getUint16(r+1,!1)+u.getUint8(r)*65536;return d|(d&8388608)*510}case 4:return u.getInt32(r,!1);case 5:{const d=u.getUint8(r);return(d|(d&128)*33554430)*4294967296+u.getUint32(r+1,!1)}case 6:{const d=u.getUint16(r,!1);return(d|(d&32768)*131070)*4294967296+u.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntLE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -950,7 +950,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt16BECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!1),d+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!1),c+2})\n"; // writeUInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1142,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,r,d){\"use strict\";return this.write(a,r,d,\"base64\")})\n"; +const char* const s_jsBufferPrototypeBase64WriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64\")})\n"; // base64urlWrite const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1150,7 +1150,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlWriteCodeLength = 70; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (d,a,r){\"use strict\";return this.write(d,a,r,\"base64url\")})\n"; +const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"base64url\")})\n"; // hexWrite const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1166,7 +1166,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf8SliceCodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf8SliceCodeLength = 64; static const JSC::Intrinsic s_jsBufferPrototypeUtf8SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf8SliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"utf8\")})\n"; +const char* const s_jsBufferPrototypeUtf8SliceCode = "(function (g,u){\"use strict\";return this.toString(\"utf8\",g,u)})\n"; // ucs2Slice const JSC::ConstructAbility s_jsBufferPrototypeUcs2SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1174,7 +1174,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUcs2SliceCodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUcs2SliceCodeLength = 64; static const JSC::Intrinsic s_jsBufferPrototypeUcs2SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUcs2SliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"ucs2\")})\n"; +const char* const s_jsBufferPrototypeUcs2SliceCode = "(function (g,u){\"use strict\";return this.toString(\"ucs2\",g,u)})\n"; // utf16leSlice const JSC::ConstructAbility s_jsBufferPrototypeUtf16leSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1182,7 +1182,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf16leSliceCodeLength = 67; static const JSC::Intrinsic s_jsBufferPrototypeUtf16leSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leSliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"utf16le\")})\n"; +const char* const s_jsBufferPrototypeUtf16leSliceCode = "(function (g,p){\"use strict\";return this.toString(\"utf16le\",g,p)})\n"; // latin1Slice const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1190,7 +1190,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeLatin1SliceCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeLatin1SliceCodeLength = 66; static const JSC::Intrinsic s_jsBufferPrototypeLatin1SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeLatin1SliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"latin1\")})\n"; +const char* const s_jsBufferPrototypeLatin1SliceCode = "(function (g,p){\"use strict\";return this.toString(\"latin1\",g,p)})\n"; // asciiSlice const JSC::ConstructAbility s_jsBufferPrototypeAsciiSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1198,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 (g,u){\"use strict\";return this.toString(\"ascii\",g,u)})\n"; // base64Slice const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1206,7 +1206,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeBase64SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64SliceCodeLength = 66; static const JSC::Intrinsic s_jsBufferPrototypeBase64SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64SliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"base64\")})\n"; +const char* const s_jsBufferPrototypeBase64SliceCode = "(function (g,p){\"use strict\";return this.toString(\"base64\",g,p)})\n"; // base64urlSlice const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1214,7 +1214,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlSliceCodeLength = 69; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlSliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"base64url\")})\n"; +const char* const s_jsBufferPrototypeBase64urlSliceCode = "(function (c,g){\"use strict\";return this.toString(\"base64url\",c,g)})\n"; // hexSlice const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1222,7 +1222,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeHexSliceCodeConstructorKind = JSC: const JSC::ImplementationVisibility s_jsBufferPrototypeHexSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeHexSliceCodeLength = 63; static const JSC::Intrinsic s_jsBufferPrototypeHexSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeHexSliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"hex\")})\n"; +const char* const s_jsBufferPrototypeHexSliceCode = "(function (g,_){\"use strict\";return this.toString(\"hex\",g,_)})\n"; // toJSON const JSC::ConstructAbility s_jsBufferPrototypeToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (p,q){\"use strict\";var{buffer:m,byteOffset:v,byteLength:c}=this;function w(z,k){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=k,z>0\?z:0;else return zi\?x-i:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (c,p){\"use strict\";var{buffer:i,byteOffset:k,byteLength:m}=this;function q(x,z){if(x=@trunc(x),x===0||@isNaN(x))return 0;else if(x<0)return x+=z,x>0\?x:0;else return xv\?w-v:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,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 l=@getByIdDirectPrivate(this,\"pendingPullIntos\");const m=l.peek();if(m){const a=new @Uint8Array(m.buffer,m.byteOffset+m.bytesFilled,m.byteLength-m.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,a,@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 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"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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*z(){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 q=0,A=H(_,q);while(A!==-1)yield F.decode(_.subarray(q,A)),q=A+1,A=H(_,q);w=_.subarray(q)}}}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 _=async function*q(){var A=@Bun.stdin.stream().getReader(),D=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),B,F=@Bun.indexOfLine;try{while(!0){var G,H,J;const L=A.readMany();if(@isPromise(L))({done:G,value:H}=await L);else({done:G,value:H}=L);if(G){if(J)yield D.decode(J);return}var j;for(let M of H){if(j=M,J)j=@Buffer.concat([J,M]),J=null;var m=0,K=F(j,m);while(K!==-1)yield D.decode(j.subarray(m,K)),m=K+1,K=F(j,m);J=j.subarray(m)}}}catch(L){B=L}finally{if(A.releaseLock(),B)throw B}},w=globalThis.Symbol.asyncIterator;return this[w]=_,_()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (a){\"use strict\";var d=@getByIdDirectPrivate(this,\"writer\");if(!d){var _=@toLength(a\?.length\?\?0);d=@Bun.stdout.writer({highWaterMark:_>65536\?_:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var b=d.write(a);const c=@argumentCount();for(var f=1;f65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a{},(S)=>{g.error(S)});function y(){@readableStreamDefaultReaderRead(h).@then(function(S){if(S.done){g.close();return}try{g.enqueue(S.value)}catch(_){g.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(S){g.error(S)})}y()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (_,c){\"use strict\";@assert(@isReadableStream(_));const g=new @ReadableStreamDefaultReader(_);@getByIdDirectPrivate(g,\"closedPromiseCapability\").@promise.@then(()=>{},(y)=>{c.error(y)});function h(){@readableStreamDefaultReaderRead(g).@then(function(y){if(y.done){c.close();return}try{c.enqueue(y.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}h()},function(y){c.error(y)})}h()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1404,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,v,_,w,f,x,j){\"use strict\";const B=new @ReadableStreamDefaultController(b,v,_,w,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(v,x,[B]),q=(D)=>@promiseInvokeOrNoopMethod(v,j,[D]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",q),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,b)}else if(A===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (v,w,A){\"use strict\";const C=w.type,b=@toString(C);if(b===\"bytes\"){if(A.highWaterMark===@undefined)A.highWaterMark=0;if(A.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(v,\"readableStreamController\",new @ReadableByteStreamController(v,w,A.highWaterMark,@isReadableStream))}else if(b===\"direct\"){var f=A\?.highWaterMark;@initializeArrayBufferStream.@call(v,w,f)}else if(C===@undefined){if(A.highWaterMark===@undefined)A.highWaterMark=1;@setupReadableStreamDefaultController(v,w,A.size,A.highWaterMark,w.start,w.pull,w.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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,q,w,x,F,G){\"use strict\";if(@assert(@isReadableStream(f)),@assert(@isWritableStream(q)),@assert(!@isReadableStreamLocked(f)),@assert(!@isWritableStreamLocked(q)),@assert(G===@undefined||@isAbortSignal(G)),@getByIdDirectPrivate(f,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:f,destination:q,preventAbort:x,preventCancel:F,preventClose:w,signal:G};if(_.reader=@acquireReadableStreamDefaultReader(f),_.writer=@acquireWritableStreamDefaultWriter(q),@putByIdDirectPrivate(f,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),G!==@undefined){const H=(I)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const E=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,I):@Promise.@resolve(),z=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,I):@Promise.@resolve();let B=@newPromiseCapability(@Promise),K=!0,T=()=>{if(K){K=!1;return}B.@resolve.@call()},L=(k)=>{B.@reject.@call(@undefined,k)};return E.@then(T,L),z.@then(T,L),B.@promise},I)};if(@whenSignalAborted(G,H))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (D,E,k,w,x,z){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(E)),@assert(z===@undefined||@isAbortSignal(z)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let B={source:D,destination:E,preventAbort:w,preventCancel:x,preventClose:k,signal:z};if(B.reader=@acquireReadableStreamDefaultReader(D),B.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(D,\"disturbed\",!0),B.finalized=!1,B.shuttingDown=!1,B.promiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability.@resolve.@call(),B.pendingWritePromise=@Promise.@resolve(),z!==@undefined){const F=(G)=>{if(B.finalized)return;@pipeToShutdownWithAction(B,()=>{const _=!B.preventAbort&&@getByIdDirectPrivate(B.destination,\"state\")===\"writable\"\?@writableStreamAbort(B.destination,G):@Promise.@resolve(),T=!B.preventCancel&&@getByIdDirectPrivate(B.source,\"state\")===@streamReadable\?@readableStreamCancel(B.source,G):@Promise.@resolve();let q=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}q.@resolve.@call()},K=(L)=>{q.@reject.@call(@undefined,L)};return _.@then(J,K),T.@then(J,K),q.@promise},G)};if(@whenSignalAborted(z,F))return B.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(B),@pipeToErrorsMustBePropagatedBackward(B),@pipeToClosingMustBePropagatedForward(B),@pipeToClosingMustBePropagatedBackward(B),@pipeToLoop(B),B.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1436,7 +1436,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToLoopCodeConstructorKin const JSC::ImplementationVisibility s_readableStreamInternalsPipeToLoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToLoopCodeLength = 110; static const JSC::Intrinsic s_readableStreamInternalsPipeToLoopCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToLoopCode = "(function (d){\"use strict\";if(d.shuttingDown)return;@pipeToDoReadWrite(d).@then((c)=>{if(c)@pipeToLoop(d)})})\n"; +const char* const s_readableStreamInternalsPipeToLoopCode = "(function (c){\"use strict\";if(c.shuttingDown)return;@pipeToDoReadWrite(c).@then((d)=>{if(d)@pipeToLoop(c)})})\n"; // pipeToDoReadWrite const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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],j=()=>{b().@then(()=>{if(d)@pipeToFinalize(m,g);else @pipeToFinalize(m)},(h)=>{@pipeToFinalize(m,h)})};if(@getByIdDirectPrivate(m.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(m.destination)){m.pendingReadPromiseCapability.@promise.@then(()=>{m.pendingWritePromise.@then(j,j)},(_)=>@pipeToFinalize(m,_));return}j()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (m,g){\"use strict\";if(m.shuttingDown)return;m.shuttingDown=!0;const h=arguments.length>2,d=arguments[2],j=()=>{g().@then(()=>{if(h)@pipeToFinalize(m,d);else @pipeToFinalize(m)},(b)=>{@pipeToFinalize(m,b)})};if(@getByIdDirectPrivate(m.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(m.destination)){m.pendingReadPromiseCapability.@promise.@then(()=>{m.pendingWritePromise.@then(j,j)},(_)=>@pipeToFinalize(m,_));return}j()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,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 (_,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"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (j,v,w){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function x(f,A){if(A&&w\?.cancel){try{var B=w.cancel(A);@markPromiseAsHandled(B)}catch(q){}w=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),A)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",A);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!w.pull){x();return}if(!@isCallable(w.pull)){x(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",v);const _=@getByIdDirectPrivate(j,\"highWaterMark\");v.start({highWaterMark:!_||_<64\?64:_}),@startDirectStream.@call(v,j,w.pull,x),@putByIdDirectPrivate(j,\"reader\",{});var z=w.pull(v);if(v=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1572,7 +1572,7 @@ const JSC::ConstructorKind s_readableStreamInternalsAssignToStreamCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsAssignToStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamInternalsAssignToStreamCodeLength = 221; static const JSC::Intrinsic s_readableStreamInternalsAssignToStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsAssignToStreamCode = "(function (_,b){\"use strict\";var f=@getByIdDirectPrivate(_,\"underlyingSource\");if(f)try{return @readDirectStream(_,b,f)}catch(h){throw h}finally{f=@undefined,_=@undefined,b=@undefined}return @readStreamIntoSink(_,b,!0)})\n"; +const char* const s_readableStreamInternalsAssignToStreamCode = "(function (h,_){\"use strict\";var b=@getByIdDirectPrivate(h,\"underlyingSource\");if(b)try{return @readDirectStream(h,_,b)}catch(f){throw f}finally{b=@undefined,h=@undefined,_=@undefined}return @readStreamIntoSink(h,_,!0)})\n"; // readStreamIntoSink const JSC::ConstructAbility s_readableStreamInternalsReadStreamIntoSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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 (_,E,c){\"use strict\";var f=!1,B=!1;try{var D=_.getReader(),F=D.readMany();if(F&&@isPromise(F))F=await F;if(F.done)return f=!0,E.end();var G=F.value.length;const q=@getByIdDirectPrivate(_,\"highWaterMark\");if(c)@startDirectStream.@call(E,_,@undefined,()=>!B&&@markPromiseAsHandled(_.cancel()));E.start({highWaterMark:q||0});for(var H=0,I=F.value,J=F.value.length;H!x&&@markPromiseAsHandled(_.cancel()));E.start({highWaterMark:q||0});for(var H=0,I=F.value,J=F.value.length;H{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"; +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 y;try{y=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(j){if(this._pendingRead){var b=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(b,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)&&y\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(C,{value:y,done:!1}),@readableStreamClose(v);return}}if(y\?.byteLength){var S=@getByIdDirectPrivate(B,\"readRequests\");if(S\?.isNotEmpty()){@readableStreamFulfillReadRequest(v,y,!1),@readableStreamClose(v);return}@putByIdDirectPrivate(v,\"state\",@streamReadable),this.@pull=()=>{var j=@createFulfilledPromise({value:y,done:!1});return y=@undefined,@readableStreamClose(v),v=@undefined,j}}else if(this._pendingRead){var b=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(b,{value:@undefined,done:!0})}@readableStreamClose(v)})\n"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,b=@getByIdDirectPrivate(c,\"reader\");if(!b||!@isReadableStreamDefaultReader(b))return;var i=this._pendingRead;if(this._pendingRead=@undefined,i&&@isPromise(i)){var B=this.@sink.flush();if(B\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(i,{value:B,done:!1});else this._pendingRead=i}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var B=this.@sink.flush();if(B\?.byteLength)@readableStreamFulfillReadRequest(c,B,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var B=this.@controlledReadableStream,i=@getByIdDirectPrivate(B,\"reader\");if(!i||!@isReadableStreamDefaultReader(i))return;var j=this._pendingRead;if(this._pendingRead=@undefined,j&&@isPromise(j)){var c=this.@sink.flush();if(c\?.byteLength)this._pendingRead=@getByIdDirectPrivate(B,\"readRequests\")\?.shift(),@fulfillPromise(j,{value:c,done:!1});else this._pendingRead=j}else if(@getByIdDirectPrivate(B,\"readRequests\")\?.isNotEmpty()){var c=this.@sink.flush();if(c\?.byteLength)@readableStreamFulfillReadRequest(B,c,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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 (_){\"use strict\";var j,q=[],x=!1,v=!1,z=\"\",C=@toLength(0),E=@newPromiseCapability(@Promise),F=!1;return j={start(){},write(G){if(typeof G===\"string\"){var A=@toLength(G.length);if(A>0)z+=G,x=!0,C+=A;return A}if(!G||!(@ArrayBuffer.@isView(G)||G instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const w=@toLength(G.byteLength);if(w>0)if(v=!0,z.length>0)@arrayPush(q,z,G),z=\"\";else @arrayPush(q,G);return C+=w,w},flush(){return 0},end(){if(F)return\"\";return j.fulfill()},fulfill(){F=!0;const G=j.finishInternal();return @fulfillPromise(E.@promise,G),G},finishInternal(){if(!x&&!v)return\"\";if(x&&!v)return z;if(v&&!x)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(q));var G=new @Bun.ArrayBufferSink;G.start({highWaterMark:C,asUint8Array:!0});for(let A of q)G.write(A);if(q.length=0,z.length>0)G.write(z),z=\"\";return new globalThis.TextDecoder().decode(G.end())},close(){try{if(!F)F=!0,j.fulfill()}catch(G){}}},[j,E]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (v){\"use strict\";var x,z=[],A=!1,j=!1,E=\"\",q=@toLength(0),F=@newPromiseCapability(@Promise),G=!1;return x={start(){},write(w){if(typeof w===\"string\"){var C=@toLength(w.length);if(C>0)E+=w,A=!0,q+=C;return C}if(!w||!(@ArrayBuffer.@isView(w)||w instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const _=@toLength(w.byteLength);if(_>0)if(j=!0,E.length>0)@arrayPush(z,E,w),E=\"\";else @arrayPush(z,w);return q+=_,_},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(!A&&!j)return\"\";if(A&&!j)return E;if(j&&!A)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(z));var w=new @Bun.ArrayBufferSink;w.start({highWaterMark:q,asUint8Array:!0});for(let C of z)w.write(C);if(z.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"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[b,f]=@createTextStream(m),p={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",p),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),f})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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 (p,b){\"use strict\";var d=[],j=@newPromiseCapability(@Promise),_=!1;function m(){return _=!0,j.@resolve.@call(@undefined,d),d}var t={start(){},write(v){return @arrayPush(d,v),v.byteLength||v.length},flush(){return 0},end(){if(_)return[];return m()},close(){if(!_)m()}},q={@underlyingSource:p,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:t,close:@onCloseDirectStream,write:t.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),j})\n"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (t,d){\"use strict\";var _=[],p=@newPromiseCapability(@Promise),b=!1;function j(){return b=!0,p.@resolve.@call(@undefined,_),_}var m={start(){},write(v){return @arrayPush(_,v),v.byteLength||v.length},flush(){return 0},end(){if(b)return[];return j()},close(){if(!b)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),p})\n"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const v=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(v)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (_,c){\"use strict\";@assert(@isReadableStream(_)),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamErrored),@putByIdDirectPrivate(_,\"storedError\",c);const f=@getByIdDirectPrivate(_,\"reader\");if(!f)return;if(@isReadableStreamDefaultReader(f)){const v=@getByIdDirectPrivate(f,\"readRequests\");@putByIdDirectPrivate(f,\"readRequests\",@createFIFO());for(var n=v.shift();n;n=v.shift())@rejectPromise(n,c)}else{@assert(@isReadableStreamBYOBReader(f));const v=@getByIdDirectPrivate(f,\"readIntoRequests\");@putByIdDirectPrivate(f,\"readIntoRequests\",@createFIFO());for(var n=v.shift();n;n=v.shift())@rejectPromise(n,c)}@getByIdDirectPrivate(f,\"closedPromiseCapability\").@reject.@call(@undefined,c);const h=@getByIdDirectPrivate(f,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (_,d){\"use strict\";@putByIdDirectPrivate(_,\"disturbed\",!0);const h=@getByIdDirectPrivate(_,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));@readableStreamClose(_);var p=@getByIdDirectPrivate(_,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,d).@then(function(){});var i=p.close;if(i)return @Promise.@resolve(p.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,_){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const d=@getByIdDirectPrivate(i,\"state\");if(d===@streamClosed)return @Promise.@resolve();if(d===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var h=@getByIdDirectPrivate(i,\"readableStreamController\"),p=h.@cancel;if(p)return p(h,_).@then(function(){});var u=h.close;if(u)return @Promise.@resolve(h.close(_));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1740,7 +1740,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 519; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const f=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:f,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),d})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const d=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:d,done:!1})}const f=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),f})\n"; // readableStreamDefaultControllerClose const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var i=d.shift();i;i=d.shift())@fulfillPromise(i,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const y=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!y);const n=@getByIdDirectPrivate(y,\"state\");if(@putByIdDirectPrivate(y,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(y,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(y,\"readableStreamController\").@pull(@getByIdDirectPrivate(y,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,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 (N,J){\"use strict\";var M=@getByIdDirectPrivate(N,\"bunNativeType\"),K=@getByIdDirectPrivate(N,\"bunNativePtr\"),L=@lazyStreamPrototypeMap.@get(M);if(L===@undefined){let q=function(x){var{c:H,v:z}=this;this.c=@undefined,this.v=@undefined,j(x,H,z)},G=function(x){try{x.close()}catch(H){globalThis.reportError(H)}},_=function(x,H,z,A){A[0]=!1;var y;try{y=b(x,z,A)}catch(I){return H.error(I)}return j(y,H,z)};var Y=q,Z=G,F=_,[b,B,O,P,f,D,Q]=@lazyLoad(M),U=[!1],j;j=function x(H,z,A){if(H&&@isPromise(H))return H.then(q.bind({c:z,v:A}),(y)=>z.error(y));else if(typeof H===\"number\")if(A&&A.byteLength===H&&A.buffer===z.byobRequest\?.view\?.buffer)z.byobRequest.respondWithNewView(A);else z.byobRequest.respond(H);else if(H.constructor===@Uint8Array)z.enqueue(H);if(U[0]||H===!1)@enqueueJob(G,z),U[0]=!1};const p=f\?new FinalizationRegistry(f):null;L=class x{constructor(H,z,A){if(this.#f=H,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=z,A!==@undefined)this.start=(y)=>{y.enqueue(A)};if(p)p.register(this,H,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=B;#j(H){var z=this.#f;if(!z){H.close();return}_(z,H,H.byobRequest.view,U)}#m(H){var z=this.#f;p&&p.unregister(this.#b),D&&D(z,!1),O(z,H)}static deinit=f;static drain=Q},@lazyStreamPrototypeMap.@set(M,L)}const E=L.startSync(K,J);var W;const{drain:X,deinit:m}=L;if(X)W=X(K);if(E===0){if(f&&K&&@enqueueJob(f,K),(W\?.byteLength\?\?0)>0)return{start(q){q.enqueue(W),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new L(K,E,W)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (I,y){\"use strict\";var G=@getByIdDirectPrivate(I,\"bunNativeType\"),B=@getByIdDirectPrivate(I,\"bunNativePtr\"),D=@lazyStreamPrototypeMap.@get(G);if(D===@undefined){let Z=function(p){var{c:z,v:A}=this;this.c=@undefined,this.v=@undefined,P(p,z,A)},j=function(p){try{p.close()}catch(z){globalThis.reportError(z)}},F=function(p,z,A,m){m[0]=!1;var q;try{q=J(p,A,m)}catch(x){return z.error(x)}return P(q,z,A)};var X=Z,Y=j,W=F,[J,K,L,M,H,b,N]=@lazyLoad(G),O=[!1],P;P=function p(z,A,m){if(z&&@isPromise(z))return z.then(Z.bind({c:A,v:m}),(q)=>A.error(q));else if(typeof z===\"number\")if(m&&m.byteLength===z&&m.buffer===A.byobRequest\?.view\?.buffer)A.byobRequest.respondWithNewView(m);else A.byobRequest.respond(z);else if(z.constructor===@Uint8Array)A.enqueue(z);if(O[0]||z===!1)@enqueueJob(j,A),O[0]=!1};const _=H\?new FinalizationRegistry(H):null;D=class p{constructor(z,A,m){if(this.#f=z,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=A,m!==@undefined)this.start=(q)=>{q.enqueue(m)};if(_)_.register(this,z,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=K;#j(z){var A=this.#f;if(!A){z.close();return}F(A,z,z.byobRequest.view,O)}#m(z){var A=this.#f;_&&_.unregister(this.#b),b&&b(A,!1),L(A,z)}static deinit=H;static drain=N},@lazyStreamPrototypeMap.@set(G,D)}const Q=D.startSync(B,y);var U;const{drain:f,deinit:E}=D;if(f)U=f(B);if(Q===0){if(H&&B&&@enqueueJob(H,B),(U\?.byteLength\?\?0)>0)return{start(Z){Z.enqueue(U),Z.close()},type:\"bytes\"};return{start(Z){Z.close()},type:\"bytes\"}}return new D(B,Q,U)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var b=_.getReader(),g=b.readMany();async function j(q){if(q.done)return[];var f=q.value||[];while(!0){var p=await b.read();if(p.done)break;f=f.concat(p.value)}return f}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var g=_.getReader(),p=g.readMany();async function j(q){if(q.done)return[];var f=q.value||[];while(!0){var b=await g.read();if(b.done)break;f=f.concat(b.value)}return f}if(p&&@isPromise(p))return p.@then(j);return j(p)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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 (O,_){\"use strict\";var q=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var x=@getByIdDirectPrivate(O,\"highWaterMark\");q.start(x\?{highWaterMark:x}:{});var v=@newPromiseCapability(@Promise),A=!1,z=_.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=z(C);if(F&&@isObject(F)&&@isPromise(F))return async function(G,j,w){while(!A)await w(G);return await j}(C,promise,z);return v.@promise}catch(F){return D=!0,@readableStreamError(O,F),@Promise.@reject(F)}finally{if(!D&&O)@readableStreamClose(O);C=B=q=z=O=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (j,w){\"use strict\";var _=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(j,\"underlyingSource\",@undefined);var x=@getByIdDirectPrivate(j,\"highWaterMark\");_.start(x\?{highWaterMark:x}:{});var O=@newPromiseCapability(@Promise),z=!1,q=w.pull,A=w.close,B={start(){},close(C){if(!z){if(z=!0,A)A();@fulfillPromise(O.@promise,_.end())}},end(){if(!z){if(z=!0,A)A();@fulfillPromise(O.@promise,_.end())}},flush(){return 0},write:_.write.bind(_)},v=!1;try{const C=q(B);if(C&&@isObject(C)&&@isPromise(C))return async function(D,F,G){while(!z)await G(D);return await F}(B,promise,q);return O.@promise}catch(C){return v=!0,@readableStreamError(j,C),@Promise.@reject(C)}finally{if(!v&&j)@readableStreamClose(j);B=A=_=q=j=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var k=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(_){}return k=@undefined,f=@undefined,j.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,f){\"use strict\";const h=@initializeTextStream.@call(_,f,@undefined);var j=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var p=await j.read();if(p.done)break}try{j.releaseLock()}catch(k){}return j=@undefined,_=@undefined,h.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,p){\"use strict\";const j=@initializeArrayStream.@call(_,p,@undefined);p=@undefined;var q=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await q.read();if(k.done)break}try{q.releaseLock()}catch(f){}return q=@undefined,@Promise.@resolve(j.@promise)}catch(f){throw f}finally{_=@undefined,q=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,j){\"use strict\";const k=@initializeArrayStream.@call(_,j,@undefined);j=@undefined;var p=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var q=await p.read();if(q.done)break}try{p.releaseLock()}catch(f){}return p=@undefined,@Promise.@resolve(k.@promise)}catch(f){throw f}finally{_=@undefined,p=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (k){\"use strict\";var g=globalThis.Symbol.asyncIterator,i=async function*D(q,F){var w=q.getReader(),G;try{while(!0){var x,h;const z=w.readMany();if(@isPromise(z))({done:x,value:h}=await z);else({done:x,value:h}=z);if(x)return;yield*h}}catch(z){G=z}finally{if(w.releaseLock(),!F)q.cancel(G);if(G)throw G}},B=function D(){return i(this,!1)},j=function D({preventCancel:q=!1}={preventCancel:!1}){return i(this,q)};return @Object.@defineProperty(k,g,{value:B}),@Object.@defineProperty(k,\"values\",{value:j}),k})\n"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (h){\"use strict\";var q=globalThis.Symbol.asyncIterator,D=async function*F(j,z){var g=j.getReader(),w;try{while(!0){var G,B;const i=g.readMany();if(@isPromise(i))({done:G,value:B}=await i);else({done:G,value:B}=i);if(G)return;yield*B}}catch(i){w=i}finally{if(g.releaseLock(),!z)j.cancel(w);if(w)throw w}},x=function F(){return D(this,!1)},k=function F({preventCancel:j=!1}={preventCancel:!1}){return D(this,j)};return @Object.@defineProperty(h,q,{value:x}),@Object.@defineProperty(h,\"values\",{value:k}),h})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2020,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 Q=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!Q)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const D=@getByIdDirectPrivate(Q,\"state\");if(@putByIdDirectPrivate(Q,\"disturbed\",!0),D===@streamClosed)return{value:[],size:0,done:!0};else if(D===@streamErrored)throw @getByIdDirectPrivate(Q,\"storedError\");var J=@getByIdDirectPrivate(Q,\"readableStreamController\"),E=@getByIdDirectPrivate(J,\"queue\");if(!E)return J.@pull(J).@then(function({done:k,value:K}){return k\?{done:!0,value:[],size:0}:{value:[K],size:1,done:!1}});const F=E.content;var w=E.size,I=F.toArray(!1),S=I.length;if(S>0){var j=@newArrayWithSize(S);if(@isReadableByteStreamController(J)){{const k=I[0];if(!(@ArrayBuffer.@isView(k)||k instanceof @ArrayBuffer))@putByValDirect(j,0,new @Uint8Array(k.buffer,k.byteOffset,k.byteLength));else @putByValDirect(j,0,k)}for(var _=1;_{if(k.done)return{value:[],size:0,done:!0};var K=@getByIdDirectPrivate(Q,\"readableStreamController\"),N=@getByIdDirectPrivate(K,\"queue\"),O=[k.value].concat(N.content.toArray(!1)),x=O.length;if(@isReadableByteStreamController(K))for(var d=0;d0){var I=@newArrayWithSize(Q);if(@isReadableByteStreamController(H)){{const j=B[0];if(!(@ArrayBuffer.@isView(j)||j instanceof @ArrayBuffer))@putByValDirect(I,0,new @Uint8Array(j.buffer,j.byteOffset,j.byteLength));else @putByValDirect(I,0,j)}for(var _=1;_{if(j.done)return{value:[],size:0,done:!0};var J=@getByIdDirectPrivate(O,\"readableStreamController\"),K=@getByIdDirectPrivate(J,\"queue\"),N=[j.value].concat(K.content.toArray(!1)),k=N.length;if(@isReadableByteStreamController(J))for(var G=0;G0}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:E,_tail:z,_list:v,_capacityMask:F}=this;if(E===z)return @undefined;var g=v[E];if(@putByValDirect(v,E,@undefined),E=this._head=E+1&F,E<2&&z>1e4&&z<=v.length>>>2)this._shrinkArray();return g}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(E){var z=this._tail;if(@putByValDirect(this._list,z,E),this._tail=z+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(E){var z=this._list,v=@toLength(z.length);if(E||this._head>this._tail){var F=@toLength(this._head),g=@toLength(this._tail),A=@toLength(v-F+g),x=@newArrayWithSize(A),w=0;for(var G=F;G>>=1,this._capacityMask>>>=1}}return new k})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2224,7 +2224,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (D){\"use strict\";var H=@Loader,_=@createFIFO(),I=D;while(I){var w=H.registry.@get(I);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(I),w=H.registry.@get(I);var L=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),J=H.parseModule(I,L),Q=w.module;if(J&&@isPromise(J)){var T=@getPromiseInternalField(J,@promiseFieldReactionsOrResult),x=@getPromiseInternalField(J,@promiseFieldFlags),U=x&@promiseStateMask;if(U===@promiseStatePending||T&&@isPromise(T))@throwTypeError(`require() async module \"${I}\" is unsupported. use \"await import()\" instead.`);else if(U===@promiseStateRejected){if(!T\?.message)@throwTypeError(`${T+\"\"\?T:\"An error occurred\"} occurred while parsing module \\\"${I}\\\"`);throw T}w.module=Q=T}else if(J&&!Q)w.module=Q=J;@setStateToMax(w,@ModuleLink);var V=Q.dependenciesMap,W=H.requestedModules(Q),X=@newArrayWithSize(W.length);for(var Y=0,Z=W.length;Y=@ModuleLink)I=_.shift()}var G=H.linkAndEvaluateModule(D,@undefined);if(G&&@isPromise(G))@throwTypeError(`require() async module \\\"${D}\\\" is unsupported. use \"await import()\" instead.`);return H.registry.@get(D)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (z){\"use strict\";var H=@Loader,I=@createFIFO(),B=z;while(B){var w=H.registry.@get(B);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(B),w=H.registry.@get(B);var T=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),J=H.parseModule(B,T),U=w.module;if(J&&@isPromise(J)){var V=@getPromiseInternalField(J,@promiseFieldReactionsOrResult),W=@getPromiseInternalField(J,@promiseFieldFlags),L=W&@promiseStateMask;if(L===@promiseStatePending||V&&@isPromise(V))@throwTypeError(`require() async module \"${B}\" is unsupported. use \"await import()\" instead.`);else if(L===@promiseStateRejected){if(!V\?.message)@throwTypeError(`${V+\"\"\?V:\"An error occurred\"} occurred while parsing module \\\"${B}\\\"`);throw V}w.module=U=V}else if(J&&!U)w.module=U=J;@setStateToMax(w,@ModuleLink);var D=U.dependenciesMap,_=H.requestedModules(U),Q=@newArrayWithSize(_.length);for(var F=0,X=_.length;F=@ModuleLink)B=I.shift()}var Z=H.linkAndEvaluateModule(z,@undefined);if(Z&&@isPromise(Z))@throwTypeError(`require() async module \\\"${z}\\\" is unsupported. use \"await import()\" instead.`);return H.registry.@get(z)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var _=@Loader.registry.@get(a);if(!_||!_.evaluated)_=@loadCJS2ESM(a);if(!_||!_.evaluated||!_.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var c=@Loader.getModuleNamespaceObject(_.module);if(c[@commonJSSymbol]===0)return;return c})\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; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -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 n=@createCommonJSModule(b,{},!0);return process.dlopen(n,b),@requireMap.@set(b,n),n.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 v=@requireMap.@get(b);if(v)return v.exports;var _=q\?.default;if(_\?.[@commonJSSymbol]===0)q=_;return @requireMap.@set(b,@createCommonJSModule(b,q,!0)),q}})\n"; +const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var g=@requireMap.@get(_);const n=_.substring(_.length-5);if(g)return g.exports;if(n===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,q,!0)),q}else if(n===\".node\"){const b=@createCommonJSModule(_,{},!0);return process.dlopen(b,_),@requireMap.@set(_,b),b.exports}else if(n===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,q,!0)),q}else{var q=@requireESM(_);const k=@requireMap.@get(_);if(k)return k.exports;var v=q\?.default;if(v\?.[@commonJSSymbol]===0)q=v;return @requireMap.@set(_,@createCommonJSModule(_,q,!0)),q}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,f={};return new Proxy(f,{get(h,t){const u=@requireMap.@get(t);if(u)return u;const L=@Loader.registry.@get(t);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(t,c,!0);return @requireMap.@set(t,g),g}return f[t]},set(h,t,u){return @requireMap.@set(t,u),!0},has(h,t){return @requireMap.@has(t)||@Loader.registry.@has(t)},deleteProperty(h,t){return _.@delete(t),@requireMap.@delete(t),@Loader.registry.@delete(t),!0},ownKeys(h){var t=[...@requireMap.@keys()];const u=[...@Loader.registry.@keys()];for(let L of u)if(!t.includes(L))@arrayPush(t,L);return t},getPrototypeOf(h){return null},getOwnPropertyDescriptor(h,t){if(@requireMap.@has(t)||@Loader.registry.@has(t))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,L={};return new Proxy(L,{get(f,h){const t=@requireMap.@get(h);if(t)return t;const u=@Loader.registry.@get(h);if(u\?.evaluated){const b=@Loader.getModuleNamespaceObject(u.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(h,c,!0);return @requireMap.@set(h,g),g}return L[h]},set(f,h,t){return @requireMap.@set(h,t),!0},has(f,h){return @requireMap.@has(h)||@Loader.registry.@has(h)},deleteProperty(f,h){return _.@delete(h),@requireMap.@delete(h),@Loader.registry.@delete(h),!0},ownKeys(f){var h=[...@requireMap.@keys()];const t=[...@Loader.registry.@keys()];for(let u of t)if(!h.includes(u))@arrayPush(h,u);return h},getPrototypeOf(f){return null},getOwnPropertyDescriptor(f,h){if(@requireMap.@has(h)||@Loader.registry.@has(h))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2432,7 +2432,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,b=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!b){const _=@getByIdDirectPrivate(m,\"size\"),I=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",I),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,I!==@undefined\?I:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(b){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const I=@lazyLoadStream(this,_);if(I)@createReadableStreamController(this,I,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,I=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!I){const _=@getByIdDirectPrivate(m,\"size\"),b=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,b!==@undefined\?b:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(I){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,_);if(b)@createReadableStreamController(this,b,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2448,7 +2448,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKi const JSC::ImplementationVisibility s_readableStreamReadableStreamToTextCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToTextCodeLength = 171; static const JSC::Intrinsic s_readableStreamReadableStreamToTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToTextCode = "(function (p){\"use strict\";var _=@getByIdDirectPrivate(p,\"underlyingSource\");if(_!==@undefined)return @readableStreamToTextDirect(p,_);return @readableStreamIntoText(p)})\n"; +const char* const s_readableStreamReadableStreamToTextCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToTextDirect(_,p);return @readableStreamIntoText(_)})\n"; // readableStreamToArrayBuffer const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2472,7 +2472,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToBlobCodeConstructorKi const JSC::ImplementationVisibility s_readableStreamReadableStreamToBlobCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToBlobCodeLength = 108; static const JSC::Intrinsic s_readableStreamReadableStreamToBlobCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToBlobCode = "(function (n){\"use strict\";return @Promise.resolve(@Bun.readableStreamToArray(n)).@then((B)=>new Blob(B))})\n"; +const char* const s_readableStreamReadableStreamToBlobCode = "(function (B){\"use strict\";return @Promise.resolve(@Bun.readableStreamToArray(B)).@then((n)=>new Blob(n))})\n"; // consumeReadableStream const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2480,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 (_,H,F){\"use strict\";const j=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var D=globalThis[j];if(!D)D=globalThis[j]=[];var G=D[H];if(G===@undefined){var[I,J,K,k,L,N]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](H);G=class A{handleError;handleClosed;processResult;constructor(B,w){this.#_=w,this.#F=B,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),B.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var B=this.#_;this.#_=0,k(B),N(B)}_handleError(B){if(this.#$)return;this.#$=!0;var w=this.#_;this.#_=0,J(w,B),N(w)}#_;#$=!1;#F;_handleReadMany({value:B,done:w,size:x}){if(w){this.handleClosed();return}if(this.#$)return;K(this.#_,B,w,x)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(B){if(B&&@isPromise(B)){if(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateFulfilled){const x=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);if(x)B=x}}if(B&&@isPromise(B))return B.then(this.processResult,this.handleError),null;if(B.done)return this.handleClosed(),0;else if(B.value)return B.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const q=H+1;if(D.length{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(_)},(R)=>{if(@getByIdDirectPrivate(v,\"state\")===@streamReadable)@readableByteStreamControllerError(_,R)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (v,b,f){\"use strict\";if(!@isReadableStream(v))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(v,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",v),@putByIdDirectPrivate(this,\"underlyingByteSource\",b),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let p=@toNumber(f);if(@isNaN(p)||p<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",p);let R=b.autoAllocateChunkSize;if(R!==@undefined){if(R=@toNumber(R),R<=0||R===@Infinity||R===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",R),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const _=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(_,\"underlyingByteSource\"),\"start\",[_]).@then(()=>{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(_)},(d)=>{if(@getByIdDirectPrivate(v,\"state\")===@streamReadable)@readableByteStreamControllerError(_,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2676,7 +2676,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var p=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=p.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var _=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=_.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2716,7 +2716,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBRea const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 125; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (n){\"use strict\";const u=@getByIdDirectPrivate(n,\"reader\");return u!==@undefined&&@isReadableStreamBYOBReader(u)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (u){\"use strict\";const n=@getByIdDirectPrivate(u,\"reader\");return n!==@undefined&&@isReadableStreamBYOBReader(n)})\n"; // readableStreamHasDefaultReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2740,7 +2740,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(d)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const R=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=R.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let F;try{F=new @Uint8Array(R.buffer,R.byteOffset,R.byteLength)}catch(P){return @Promise.@reject(P)}return @createFulfilledPromise({value:F,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let R;try{R=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(P){return @Promise.@reject(P)}const F={buffer:R,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(F)}const h=@readableStreamAddReadRequest(d);return @readableByteStreamControllerCallPullIfNeeded(_),h})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (d){\"use strict\";const h=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(h)),@getByIdDirectPrivate(d,\"queue\").content\?.isNotEmpty()){const P=@getByIdDirectPrivate(d,\"queue\").content.shift();@getByIdDirectPrivate(d,\"queue\").size-=P.byteLength,@readableByteStreamControllerHandleQueueDrain(d);let R;try{R=new @Uint8Array(P.buffer,P.byteOffset,P.byteLength)}catch(_){return @Promise.@reject(_)}return @createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(d,\"autoAllocateChunkSize\")!==@undefined){let P;try{P=@createUninitializedArrayBuffer(@getByIdDirectPrivate(d,\"autoAllocateChunkSize\"))}catch(_){return @Promise.@reject(_)}const R={buffer:P,byteOffset:0,byteLength:@getByIdDirectPrivate(d,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(d,\"pendingPullIntos\").push(R)}const F=@readableStreamAddReadRequest(h);return @readableByteStreamControllerCallPullIfNeeded(d),F})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2780,7 +2780,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1076; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,f){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(d,\"state\")===@streamReadable),@getByIdDirectPrivate(d,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(d,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(d,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(f.buffer),f.byteOffset,f.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const _=f.constructor===@Uint8Array\?f:new @Uint8Array(f.buffer,f.byteOffset,f.byteLength);@readableStreamFulfillReadRequest(d,_,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(f.buffer),f.byteOffset,f.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(d)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(f.buffer),f.byteOffset,f.byteLength);break}}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,d){\"use strict\";const _=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@getByIdDirectPrivate(_,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(_,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const f=d.constructor===@Uint8Array\?d:new @Uint8Array(d.buffer,d.byteOffset,d.byteLength);@readableStreamFulfillReadRequest(_,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(_)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);break}}})\n"; // readableByteStreamControllerEnqueueChunk const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2788,7 +2788,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,d,p){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:d,byteLength:p}),@getByIdDirectPrivate(_,\"queue\").size+=p})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,p,a,d){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:p,byteOffset:a,byteLength:d}),@getByIdDirectPrivate(_,\"queue\").size+=d})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2796,7 +2796,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 417; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (u,d){\"use strict\";@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty());let a=@getByIdDirectPrivate(u,\"pendingPullIntos\").peek();if(a.byteOffset+a.bytesFilled!==d.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(a.byteLength!==d.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");a.buffer=d.buffer,@readableByteStreamControllerRespondInternal(u,d.byteLength)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (u,a){\"use strict\";@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty());let d=@getByIdDirectPrivate(u,\"pendingPullIntos\").peek();if(d.byteOffset+d.bytesFilled!==a.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(d.byteLength!==a.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");d.buffer=a.buffer,@readableByteStreamControllerRespondInternal(u,a.byteLength)})\n"; // readableByteStreamControllerRespond const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2820,7 +2820,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,h,g){\"use strict\";if(g.bytesFilled+h>g.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===g),@readableByteStreamControllerInvalidateBYOBRequest(w),g.bytesFilled+=h,g.bytesFilled0){const _=g.byteOffset+g.bytesFilled,f=@cloneArrayBuffer(g.buffer,_-R,R);@readableByteStreamControllerEnqueueChunk(w,f,0,f.byteLength)}g.buffer=@transferBufferToCurrentRealm(g.buffer),g.bytesFilled-=R,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),g),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,R,_){\"use strict\";if(_.bytesFilled+R>_.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"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2828,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; @@ -2844,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 (q,_){\"use strict\";const j=_.bytesFilled-_.bytesFilled%_.elementSize,v=@getByIdDirectPrivate(q,\"queue\").size<_.byteLength-_.bytesFilled\?@getByIdDirectPrivate(q,\"queue\").size:_.byteLength-_.bytesFilled,k=_.bytesFilled+v,w=k-k%_.elementSize;let z=v,E=!1;if(w>j)z=w-_.bytesFilled,E=!0;while(z>0){let G=@getByIdDirectPrivate(q,\"queue\").content.peek();const H=z0),@assert(_.bytesFilled<_.elementSize);return E})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode = "(function (_,q){\"use strict\";const j=q.bytesFilled-q.bytesFilled%q.elementSize,w=@getByIdDirectPrivate(_,\"queue\").sizej)G=z-q.bytesFilled,H=!0;while(G>0){let v=@getByIdDirectPrivate(_,\"queue\").content.peek();const J=G0),@assert(q.bytesFilled0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,N)){const k=@readableByteStreamControllerConvertDescriptor(N);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}N.buffer=@transferBufferToCurrentRealm(N.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(N);const R=@readableStreamAddReadIntoRequest(E);return @readableByteStreamControllerCallPullIfNeeded(b),R})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (d,A){\"use strict\";const E=@getByIdDirectPrivate(d,\"controlledReadableStream\");let k=1;if(A.BYTES_PER_ELEMENT!==@undefined)k=A.BYTES_PER_ELEMENT;const _=A.constructor,L={buffer:A.buffer,byteOffset:A.byteOffset,byteLength:A.byteLength,bytesFilled:0,elementSize:k,ctor:_,readerType:\"byob\"};var b=@getByIdDirectPrivate(d,\"pendingPullIntos\");if(b\?.isNotEmpty())return L.buffer=@transferBufferToCurrentRealm(L.buffer),b.push(L),@readableStreamAddReadIntoRequest(E);if(@getByIdDirectPrivate(E,\"state\")===@streamClosed){const R=new _(L.buffer,L.byteOffset,0);return @createFulfilledPromise({value:R,done:!0})}if(@getByIdDirectPrivate(d,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(d,L)){const R=@readableByteStreamControllerConvertDescriptor(L);return @readableByteStreamControllerHandleQueueDrain(d),@createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(d,\"closeRequested\")){const R=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(d,R),@Promise.@reject(R)}}L.buffer=@transferBufferToCurrentRealm(L.buffer),@getByIdDirectPrivate(d,\"pendingPullIntos\").push(L);const N=@readableStreamAddReadIntoRequest(E);return @readableByteStreamControllerCallPullIfNeeded(d),N})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2952,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 A 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(Q){Q.#H()}static#X(Q,U){const V=Q.data,B=V.#L\?`Last-Event-ID: ${V.#L}\\r\\n`:\"\",W=`GET ${U.pathname}${U.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${B}\\r\\n`,X=Q.write(W);if(X!==W.length)V.#K=W.substring(X)}static#Y(Q,U,V){for(;;){if(V>=U.length)return;let B=-1,W=U.indexOf(\"\\r\\n\",V);const X=W+2;if(W>0)if(Q.#O===0){const j=parseInt(U.substring(V,W),16);if(j===0){Q.#j=2,Q.#G\?.end();return}B=X+j}else B=U.length;else{if(Q.#J.length===0){Q.#J+=U.substring(V);return}B=U.length}let M=U.substring(X,B);V=B+2;let F=0,Y=M.indexOf(\"\\n\\n\");if(Y==-1){Q.#J+=U.substring(X);return}if(Q.#J.length)Q.#J+=M,M=Q.#J,Q.#J=\"\";let G=!0;while(G){const j=M.substring(F,Y);let J,Z=\"\",O,w=0,K=-1;for(;;){let L=j.indexOf(\"\\n\",w);if(L===-1){if(w>=j.length)break;L=j.length}const H=j.substring(w,L);if(H.startsWith(\"data:\"))if(Z.length)Z+=`\\n${H.substring(5).trim()}`;else Z=H.substring(5).trim();else if(H.startsWith(\"event:\"))J=H.substring(6).trim();else if(H.startsWith(\"id:\"))O=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(K=parseInt(H.substring(6).trim(),10),@isNaN(K))K=-1}w=L+1}if(Q.#L=O||\"\",K>=0)Q.#U=K;if(Z||O||J)Q.dispatchEvent(new MessageEvent(J||\"message\",{data:Z||\"\",origin:Q.#$.origin,source:Q,lastEventId:O}));if(M.length===Y+2){G=!1;break}const z=M.indexOf(\"\\n\\n\",Y+1);if(z===-1)break;F=Y,Y=z}}}static#Z={open(Q){const U=Q.data;if(U.#G=Q,!U.#F)A.#X(Q,U.#$)},handshake(Q,U,V){const B=Q.data;if(U)A.#X(Q,B.#$);else B.#j=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:V})),Q.end()},data(Q,U){const V=Q.data;switch(V.#j){case 0:{let B=U.toString();const W=B.indexOf(\"\\r\\n\\r\\n\");if(W===-1){V.#J+=B;return}if(V.#J.length)V.#J+=B,B=V.#J,V.#J=\"\";const X=B.substring(0,W),M=X.indexOf(\"\\r\\n\");if(M===-1){V.#j=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),Q.end();return}const F=X.substring(0,M);if(F!==\"HTTP/1.1 200 OK\"){V.#j=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(F)})),Q.end();return}let Y=M+1,G=!1,j=-1;for(;;){let Z=X.indexOf(\"\\r\\n\",Y);if(Z===-1){if(Y>=X.length){if(!G)V.#j=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),Q.end();return}Z=X.length}const O=X.substring(Y+1,Z),w=O.indexOf(\":\"),K=O.substring(0,w),z=K.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(Y=Z+1,z)if(O.endsWith(\" text/event-stream\"))G=!0;else{V.#j=2,V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),Q.end();return}else if(K.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(j=parseInt(O.substring(w+1).trim(),10),@isNaN(j)||j<=0){V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),Q.end();return}if(G)break}else if(K.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(O.substring(w+1).trim()!==\"chunked\"){V.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),Q.end();return}if(j=0,G)break}}V.#O=j,V.#j=1,V.dispatchEvent(new Event(\"open\"));const J=B.substring(W+4);if(A.#Y(V,J,0),V.#O>0){if(V.#Q+=J.length,V.#Q>=V.#O)V.#j=2,Q.end()}return}case 1:if(A.#Y(V,U.toString(),2),V.#O>0){if(V.#Q+=U.byteLength,V.#Q>=V.#O)V.#j=2,Q.end()}return;default:break}},drain(Q){const U=Q.data;if(U.#j===0){const V=U.#J;if(V.length){const B=Q.write(V);if(B!==V.length)Q.data.#K=V.substring(B);else Q.data.#K=\"\"}}},close:A.#z,end(Q){A.#z(Q).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(Q){A.#z(Q).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(Q){const U=Q.data;if(U.#G=null,U.#Q=0,U.#j=2,U.#M){if(U.#V)clearTimeout(U.#V);U.#V=setTimeout(A.#W,U.#U,U)}return U}constructor(Q,U=@undefined){super();const V=new URL(Q);this.#F=V.protocol===\"https:\",this.#$=V,this.#j=2,process.nextTick(A.#W,this)}ref(){this.#V\?.ref(),this.#G\?.ref()}unref(){this.#V\?.unref(),this.#G\?.unref()}#H(){if(this.#j!==2)return;const Q=this.#$,U=this.#F;this.#j=0,@Bun.connect({data:this,socket:A.#Z,hostname:Q.hostname,port:parseInt(Q.port||(U\?\"443\":\"80\"),10),tls:U\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((V)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:V})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(A.#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(Q){if(this.#B)super.removeEventListener(\"close\",this.#B);super.addEventListener(\"open\",Q),this.#B=Q}set onerror(Q){if(this.#w)super.removeEventListener(\"error\",this.#w);super.addEventListener(\"error\",Q),this.#w=Q}set onmessage(Q){if(this.#A)super.removeEventListener(\"message\",this.#A);super.addEventListener(\"message\",Q),this.#A=Q}}return Object.defineProperty(A.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(A.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(A.prototype,\"CLOSED\",{enumerable:!0,value:2}),A[Symbol.for(\"CommonJS\")]=0,A})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class j extends EventTarget{#H;#$;#j;#w;#A;#B=!1;#F=null;#G=\"\";#J=\"\";#K=\"\";#L=!0;#M=0;#O=0;#Q=0;#U=null;static#V(L){L.#z()}static#W(L,K){const M=L.data,O=M.#K\?`Last-Event-ID: ${M.#K}\\r\\n`:\"\",w=`GET ${K.pathname}${K.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${O}\\r\\n`,Q=L.write(w);if(Q!==w.length)M.#J=w.substring(Q)}static#X(L,K,M){for(;;){if(M>=K.length)return;let O=-1,w=K.indexOf(\"\\r\\n\",M);const Q=w+2;if(w>0)if(L.#M===0){const X=parseInt(K.substring(M,w),16);if(X===0){L.#$=2,L.#F\?.end();return}O=Q+X}else O=K.length;else{if(L.#G.length===0){L.#G+=K.substring(M);return}O=K.length}let U=K.substring(Q,O);M=O+2;let V=0,W=U.indexOf(\"\\n\\n\");if(W==-1){L.#G+=K.substring(Q);return}if(L.#G.length)L.#G+=U,U=L.#G,L.#G=\"\";let A=!0;while(A){const X=U.substring(V,W);let Y,Z=\"\",G,z=0,H=-1;for(;;){let F=X.indexOf(\"\\n\",z);if(F===-1){if(z>=X.length)break;F=X.length}const J=X.substring(z,F);if(J.startsWith(\"data:\"))if(Z.length)Z+=`\\n${J.substring(5).trim()}`;else Z=J.substring(5).trim();else if(J.startsWith(\"event:\"))Y=J.substring(6).trim();else if(J.startsWith(\"id:\"))G=J.substring(3).trim();else if(J.startsWith(\"retry:\")){if(H=parseInt(J.substring(6).trim(),10),@isNaN(H))H=-1}z=F+1}if(L.#K=G||\"\",H>=0)L.#Q=H;if(Z||G||Y)L.dispatchEvent(new MessageEvent(Y||\"message\",{data:Z||\"\",origin:L.#H.origin,source:L,lastEventId:G}));if(U.length===W+2){A=!1;break}const B=U.indexOf(\"\\n\\n\",W+1);if(B===-1)break;V=W,W=B}}}static#Y={open(L){const K=L.data;if(K.#F=L,!K.#B)j.#W(L,K.#H)},handshake(L,K,M){const O=L.data;if(K)j.#W(L,O.#H);else O.#$=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:M})),L.end()},data(L,K){const M=L.data;switch(M.#$){case 0:{let O=K.toString();const w=O.indexOf(\"\\r\\n\\r\\n\");if(w===-1){M.#G+=O;return}if(M.#G.length)M.#G+=O,O=M.#G,M.#G=\"\";const Q=O.substring(0,w),U=Q.indexOf(\"\\r\\n\");if(U===-1){M.#$=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),L.end();return}const V=Q.substring(0,U);if(V!==\"HTTP/1.1 200 OK\"){M.#$=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(V)})),L.end();return}let W=U+1,A=!1,X=-1;for(;;){let Z=Q.indexOf(\"\\r\\n\",W);if(Z===-1){if(W>=Q.length){if(!A)M.#$=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),L.end();return}Z=Q.length}const G=Q.substring(W+1,Z),z=G.indexOf(\":\"),H=G.substring(0,z),B=H.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(W=Z+1,B)if(G.endsWith(\" text/event-stream\"))A=!0;else{M.#$=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),L.end();return}else if(H.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(X=parseInt(G.substring(z+1).trim(),10),@isNaN(X)||X<=0){M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),L.end();return}if(A)break}else if(H.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(G.substring(z+1).trim()!==\"chunked\"){M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),L.end();return}if(X=0,A)break}}M.#M=X,M.#$=1,M.dispatchEvent(new Event(\"open\"));const Y=O.substring(w+4);if(j.#X(M,Y,0),M.#M>0){if(M.#O+=Y.length,M.#O>=M.#M)M.#$=2,L.end()}return}case 1:if(j.#X(M,K.toString(),2),M.#M>0){if(M.#O+=K.byteLength,M.#O>=M.#M)M.#$=2,L.end()}return;default:break}},drain(L){const K=L.data;if(K.#$===0){const M=K.#G;if(M.length){const O=L.write(M);if(O!==M.length)L.data.#J=M.substring(O);else L.data.#J=\"\"}}},close:j.#Z,end(L){j.#Z(L).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(L){j.#Z(L).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#Z(L){const K=L.data;if(K.#F=null,K.#O=0,K.#$=2,K.#L){if(K.#U)clearTimeout(K.#U);K.#U=setTimeout(j.#V,K.#Q,K)}return K}constructor(L,K=@undefined){super();const M=new URL(L);this.#B=M.protocol===\"https:\",this.#H=M,this.#$=2,process.nextTick(j.#V,this)}ref(){this.#U\?.ref(),this.#F\?.ref()}unref(){this.#U\?.unref(),this.#F\?.unref()}#z(){if(this.#$!==2)return;const L=this.#H,K=this.#B;this.#$=0,@Bun.connect({data:this,socket:j.#Y,hostname:L.hostname,port:parseInt(L.port||(K\?\"443\":\"80\"),10),tls:K\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((M)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:M})),this.#L){if(this.#U)this.#U.unref\?.();this.#U=setTimeout(j.#V,1000,this)}})}get url(){return this.#H.href}get readyState(){return this.#$}close(){this.#L=!1,this.#$=2,this.#F\?.unref(),this.#F\?.end()}get onopen(){return this.#A}get onerror(){return this.#j}get onmessage(){return this.#w}set onopen(L){if(this.#A)super.removeEventListener(\"close\",this.#A);super.addEventListener(\"open\",L),this.#A=L}set onerror(L){if(this.#j)super.removeEventListener(\"error\",this.#j);super.addEventListener(\"error\",L),this.#j=L}set onmessage(L){if(this.#w)super.removeEventListener(\"message\",this.#w);super.addEventListener(\"message\",L),this.#w=L}}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) \ -- cgit v1.2.3 From a4fe433db776e9ffcc532c8aeb9ea93ff0a3c02a Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 17:09:59 -0700 Subject: Slight fixup --- src/bun.js/bindings/JSBuffer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index 10f9aab5a..87e1d4048 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -1476,13 +1476,19 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS offset = static_cast(istart); length = (length > offset) ? (length - offset) : 0; } else { - int32_t ioffset = arg1.toInt32(lexicalGlobalObject); - RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + + int32_t ioffset = 0; + + if (!arg1.isUndefined()) { + ioffset = arg1.toInt32(lexicalGlobalObject); + RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined())); + } if (ioffset < 0) { throwTypeError(lexicalGlobalObject, scope, "Offset must be a positive integer"_s); return JSC::JSValue::encode(jsUndefined()); } + offset = static_cast(ioffset); length = (length > offset) ? (length - offset) : 0; -- 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(-) 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 af46a8ded1be0af1a1f4f638122ca6d0d7b62405 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 17:38:19 -0700 Subject: Make this test less flaky --- test/js/bun/spawn/spawn-streaming-stdin.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/js/bun/spawn/spawn-streaming-stdin.test.ts b/test/js/bun/spawn/spawn-streaming-stdin.test.ts index 27efa14ec..0c430b680 100644 --- a/test/js/bun/spawn/spawn-streaming-stdin.test.ts +++ b/test/js/bun/spawn/spawn-streaming-stdin.test.ts @@ -2,18 +2,22 @@ import { it, test, expect } from "bun:test"; import { spawn } from "bun"; import { bunExe, bunEnv, gcTick } from "harness"; import { closeSync, openSync } from "fs"; +import { tmpdir } from "node:os"; +import { join } from "path"; +import { unlinkSync } from "node:fs"; const N = 100; test("spawn can write to stdin multiple chunks", async () => { const maxFD = openSync("/dev/null", "w"); for (let i = 0; i < N; i++) { + const tmperr = join(tmpdir(), "stdin-repro-error.log." + i); var exited; await (async function () { const proc = spawn({ cmd: [bunExe(), import.meta.dir + "/stdin-repro.js"], stdout: "pipe", stdin: "pipe", - stderr: Bun.file("/tmp/out.log"), + stderr: Bun.file(tmperr), env: bunEnv, }); exited = proc.exited; @@ -45,6 +49,10 @@ test("spawn can write to stdin multiple chunks", async () => { await Promise.all([prom, prom2]); expect(Buffer.concat(chunks).toString().trim()).toBe("Wrote to stdin!\n".repeat(4).trim()); await proc.exited; + + try { + unlinkSync(tmperr); + } catch (e) {} })(); } @@ -54,4 +62,4 @@ test("spawn can write to stdin multiple chunks", async () => { // assert we didn't leak any file descriptors expect(newMaxFD).toBe(maxFD); -}); +}, 10_000); -- cgit v1.2.3 From 01d3b130a9127b2c3654ff1abcaf2c7da0019151 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 17:44:40 -0700 Subject: Update build-id --- src/build-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build-id b/src/build-id index 48082f72f..b1bd38b62 100644 --- a/src/build-id +++ b/src/build-id @@ -1 +1 @@ -12 +13 -- cgit v1.2.3 From a2cca6e292d8e077306ba3b1b0c381a6441bbd61 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 18:31:38 -0700 Subject: Update WebCoreJSBuiltins.cpp --- src/js/out/WebCoreJSBuiltins.cpp | 250 +++++++++++++++++++-------------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index 3c3a0eedc..60be45097 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,g,j,q){\"use strict\";const v={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},w=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][q];var x=(async(y,z,B,C)=>{var F=this.onLoad.@get(B);if(!F)return this.onLoadAsync(y,null,null),null;for(let[K,Q]of F)if(K.test(z)){var G=Q({path:z,namespace:B,loader:C});while(G&&@isPromise(G)&&(@getPromiseInternalField(G,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)G=@getPromiseInternalField(G,@promiseFieldReactionsOrResult);if(G&&@isPromise(G))G=await G;if(!G||!@isObject(G))continue;var{contents:H,loader:J=C}=G;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=v[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(y,H,T),null}return this.onLoadAsync(y,null,null),null})(b,g,j,w);while(x&&@isPromise(x)&&(@getPromiseInternalField(x,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)x=@getPromiseInternalField(x,@promiseFieldReactionsOrResult);if(x&&@isPromise(x))x.then(()=>{},(y)=>{this.addError(b,y,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,g,x,w){\"use strict\";const y={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},z=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][w];var B=(async(C,F,j,G)=>{var H=this.onLoad.@get(j);if(!H)return this.onLoadAsync(C,null,null),null;for(let[q,T]of H)if(q.test(F)){var J=T({path:F,namespace:j,loader:G});while(J&&@isPromise(J)&&(@getPromiseInternalField(J,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)J=@getPromiseInternalField(J,@promiseFieldReactionsOrResult);if(J&&@isPromise(J))J=await J;if(!J||!@isObject(J))continue;var{contents:K,loader:Q=G}=J;if(typeof K!==\"string\"&&!@isTypedArrayView(K))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof Q!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const v=y[Q];if(v===@undefined)@throwTypeError(`Loader ${Q} is not supported.`);return this.onLoadAsync(C,K,v),null}return this.onLoadAsync(C,null,null),null})(b,g,x,z);while(B&&@isPromise(B)&&(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);if(B&&@isPromise(B))B.then(()=>{},(C)=>{this.addError(b,C,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -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,v){\"use strict\";if(@isWritableStreamLocked(v))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(n,\"stream\",v),@putByIdDirectPrivate(v,\"writer\",n);const B=@newPromiseCapability(@Promise),_=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"readyPromise\",B),@putByIdDirectPrivate(n,\"closedPromise\",_);const g=@getByIdDirectPrivate(v,\"state\");if(g===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(v)||!@getByIdDirectPrivate(v,\"backpressure\"))B.@resolve.@call()}else if(g===\"erroring\")B.@reject.@call(@undefined,@getByIdDirectPrivate(v,\"storedError\")),@markPromiseAsHandled(B.@promise);else if(g===\"closed\")B.@resolve.@call(),_.@resolve.@call();else{@assert(g===\"errored\");const h=@getByIdDirectPrivate(v,\"storedError\");B.@reject.@call(@undefined,h),@markPromiseAsHandled(B.@promise),_.@reject.@call(@undefined,h),@markPromiseAsHandled(_.@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 (c,f){\"use strict\";const j=@getByIdDirectPrivate(c,\"state\");if(j===\"closed\"||j===\"errored\")return @Promise.@resolve();const B=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(B!==@undefined)return B.promise.@promise;@assert(j===\"writable\"||j===\"erroring\");let h=!1;if(j===\"erroring\")h=!0,f=@undefined;const _=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:_,reason:f,wasAlreadyErroring:h}),!h)@writableStreamStartErroring(c,f);return _.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = 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 h=@getByIdDirectPrivate(_,\"controller\");@getByIdDirectPrivate(h,\"errorSteps\").@call();const B=@getByIdDirectPrivate(_,\"storedError\"),A=@getByIdDirectPrivate(_,\"writeRequests\");for(var I=A.shift();I;I=A.shift())I.@reject.@call(@undefined,B);@putByIdDirectPrivate(_,\"writeRequests\",@createFIFO());const i=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(i===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}if(@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined),i.wasAlreadyErroring){i.promise.@reject.@call(@undefined,B),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}@getByIdDirectPrivate(h,\"abortSteps\").@call(@undefined,i.reason).@then(()=>{i.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)},(p)=>{i.promise.@reject.@call(@undefined,p),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; +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 i=@getByIdDirectPrivate(_,\"storedError\"),B=@getByIdDirectPrivate(_,\"writeRequests\");for(var h=B.shift();h;h=B.shift())h.@reject.@call(@undefined,i);@putByIdDirectPrivate(_,\"writeRequests\",@createFIFO());const A=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(A===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}if(@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined),A.wasAlreadyErroring){A.promise.@reject.@call(@undefined,i),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}@getByIdDirectPrivate(p,\"abortSteps\").@call(@undefined,A.reason).@then(()=>{A.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)},(I)=>{A.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const c=@getByIdDirectPrivate(d,\"writer\");if(c!==@undefined)@getByIdDirectPrivate(c,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -220,7 +220,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength = 488; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,d){\"use strict\";const c=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(c!==@undefined),c.@reject.@call(@undefined,d),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(_,\"state\");@assert(n===\"writable\"||n===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,d),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,d)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (c,_){\"use strict\";const n=@getByIdDirectPrivate(c,\"inFlightCloseRequest\");@assert(n!==@undefined),n.@reject.@call(@undefined,_),@putByIdDirectPrivate(c,\"inFlightCloseRequest\",@undefined);const p=@getByIdDirectPrivate(c,\"state\");@assert(p===\"writable\"||p===\"erroring\");const d=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(d!==@undefined)d.promise.@reject.@call(@undefined,_),@putByIdDirectPrivate(c,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(c,_)})\n"; // writableStreamFinishInFlightWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -228,7 +228,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength = 187; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode = "(function (d){\"use strict\";const c=@getByIdDirectPrivate(d,\"inFlightWriteRequest\");@assert(c!==@undefined),c.@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightWriteRequest\",@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"inFlightWriteRequest\");@assert(d!==@undefined),d.@resolve.@call(),@putByIdDirectPrivate(c,\"inFlightWriteRequest\",@undefined)})\n"; // writableStreamFinishInFlightWriteWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -236,7 +236,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength = 319; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode = "(function (_,c){\"use strict\";const d=@getByIdDirectPrivate(_,\"inFlightWriteRequest\");@assert(d!==@undefined),d.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightWriteRequest\",@undefined);const p=@getByIdDirectPrivate(_,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@writableStreamDealWithRejection(_,c)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode = "(function (_,d){\"use strict\";const c=@getByIdDirectPrivate(_,\"inFlightWriteRequest\");@assert(c!==@undefined),c.@reject.@call(@undefined,d),@putByIdDirectPrivate(_,\"inFlightWriteRequest\",@undefined);const p=@getByIdDirectPrivate(_,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@writableStreamDealWithRejection(_,d)})\n"; // writableStreamHasOperationMarkedInFlight const JSC::ConstructAbility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -260,7 +260,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWrite const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength = 240; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"writeRequests\");@assert(@getByIdDirectPrivate(c,\"inFlightWriteRequest\")===@undefined),@assert(d.isNotEmpty());const h=d.shift();@putByIdDirectPrivate(c,\"inFlightWriteRequest\",h)})\n"; +const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (h){\"use strict\";const c=@getByIdDirectPrivate(h,\"writeRequests\");@assert(@getByIdDirectPrivate(h,\"inFlightWriteRequest\")===@undefined),@assert(c.isNotEmpty());const d=c.shift();@putByIdDirectPrivate(h,\"inFlightWriteRequest\",d)})\n"; // writableStreamRejectCloseAndClosedPromiseIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -268,7 +268,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAnd const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 516; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const h=@getByIdDirectPrivate(i,\"storedError\"),n=@getByIdDirectPrivate(i,\"closeRequest\");if(n!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),n.@reject.@call(@undefined,h),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(i,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,h),@markPromiseAsHandled(b.@promise)}})\n"; +const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const b=@getByIdDirectPrivate(i,\"storedError\"),B=@getByIdDirectPrivate(i,\"closeRequest\");if(B!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),B.@reject.@call(@undefined,b),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const h=@getByIdDirectPrivate(i,\"writer\");if(h!==@undefined){const n=@getByIdDirectPrivate(h,\"closedPromise\");n.@reject.@call(@undefined,b),@markPromiseAsHandled(n.@promise)}})\n"; // writableStreamStartErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -284,7 +284,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamUpdateBackpres const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength = 422; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamUpdateBackpressureCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode = "(function (n,d){\"use strict\";@assert(@getByIdDirectPrivate(n,\"state\")===\"writable\"),@assert(!@writableStreamCloseQueuedOrInFlight(n));const h=@getByIdDirectPrivate(n,\"writer\");if(h!==@undefined&&d!==@getByIdDirectPrivate(n,\"backpressure\"))if(d)@putByIdDirectPrivate(h,\"readyPromise\",@newPromiseCapability(@Promise));else @getByIdDirectPrivate(h,\"readyPromise\").@resolve.@call();@putByIdDirectPrivate(n,\"backpressure\",d)})\n"; +const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode = "(function (n,h){\"use strict\";@assert(@getByIdDirectPrivate(n,\"state\")===\"writable\"),@assert(!@writableStreamCloseQueuedOrInFlight(n));const d=@getByIdDirectPrivate(n,\"writer\");if(d!==@undefined&&h!==@getByIdDirectPrivate(n,\"backpressure\"))if(h)@putByIdDirectPrivate(d,\"readyPromise\",@newPromiseCapability(@Promise));else @getByIdDirectPrivate(d,\"readyPromise\").@resolve.@call();@putByIdDirectPrivate(n,\"backpressure\",h)})\n"; // writableStreamDefaultWriterAbort const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -332,7 +332,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterG const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength = 299; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (c){\"use strict\";const l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const _=@getByIdDirectPrivate(l,\"state\");if(_===\"errored\"||_===\"erroring\")return null;if(_===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(l,\"controller\"))})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (c){\"use strict\";const _=@getByIdDirectPrivate(c,\"stream\");@assert(_!==@undefined);const l=@getByIdDirectPrivate(_,\"state\");if(l===\"errored\"||l===\"erroring\")return null;if(l===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(_,\"controller\"))})\n"; // writableStreamDefaultWriterRelease const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility = 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){\"use strict\";const g=@getByIdDirectPrivate(_,\"stream\");@assert(g!==@undefined);const P=@getByIdDirectPrivate(g,\"controller\");@assert(P!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(P,d);if(g!==@getByIdDirectPrivate(_,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const W=@getByIdDirectPrivate(g,\"state\");if(W===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(g,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(g)||W===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(g)||W===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(W===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(g,\"storedError\"));@assert(W===\"writable\");const f=@writableStreamAddWriteRequest(g);return @writableStreamDefaultControllerWrite(P,d,b),f})\n"; // setUpWritableStreamDefaultController const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -364,7 +364,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 647; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const _=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(_.@call()).@then(()=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(d,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,u)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const d=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const _=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(d.@call()).@then(()=>{const u=@getByIdDirectPrivate(_,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(_,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(_,u)})})\n"; // setUpWritableStreamDefaultControllerFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,P,_,j,p){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},f=()=>{return @Promise.@resolve()};if(\"start\"in _){const E=_.start;x=()=>@promiseInvokeOrNoopMethodNoCatch(P,E,[q])}if(\"write\"in _){const E=_.write;B=(F)=>@promiseInvokeOrNoopMethod(P,E,[F,q])}if(\"close\"in _){const E=_.close;C=()=>@promiseInvokeOrNoopMethod(P,E,[])}if(\"abort\"in _){const E=_.abort;f=(F)=>@promiseInvokeOrNoopMethod(P,E,[F])}@setUpWritableStreamDefaultController(v,q,x,B,C,f,j,p)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,P,j,p,_){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},E=()=>{return @Promise.@resolve()};if(\"start\"in j){const f=j.start;x=()=>@promiseInvokeOrNoopMethodNoCatch(P,f,[q])}if(\"write\"in j){const f=j.write;B=(F)=>@promiseInvokeOrNoopMethod(P,f,[F,q])}if(\"close\"in j){const f=j.close;C=()=>@promiseInvokeOrNoopMethod(P,f,[])}if(\"abort\"in j){const f=j.abort;E=(F)=>@promiseInvokeOrNoopMethod(P,f,[F])}@setUpWritableStreamDefaultController(v,q,x,B,C,E,p,_)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -380,7 +380,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength = 582; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"stream\");if(@getByIdDirectPrivate(_,\"started\")!==1)return;if(@assert(d!==@undefined),@getByIdDirectPrivate(d,\"inFlightWriteRequest\")!==@undefined)return;const f=@getByIdDirectPrivate(d,\"state\");if(@assert(f!==\"closed\"||f!==\"errored\"),f===\"erroring\"){@writableStreamFinishErroring(d);return}const h=@getByIdDirectPrivate(_,\"queue\");if(h.content\?.isEmpty()\?\?!1)return;const i=@peekQueueValue(h);if(i===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(_);else @writableStreamDefaultControllerProcessWrite(_,i)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (d){\"use strict\";const _=@getByIdDirectPrivate(d,\"stream\");if(@getByIdDirectPrivate(d,\"started\")!==1)return;if(@assert(_!==@undefined),@getByIdDirectPrivate(_,\"inFlightWriteRequest\")!==@undefined)return;const f=@getByIdDirectPrivate(_,\"state\");if(@assert(f!==\"closed\"||f!==\"errored\"),f===\"erroring\"){@writableStreamFinishErroring(_);return}const i=@getByIdDirectPrivate(d,\"queue\");if(i.content\?.isEmpty()\?\?!1)return;const h=@peekQueueValue(i);if(h===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(d);else @writableStreamDefaultControllerProcessWrite(d,h)})\n"; // isCloseSentinel const JSC::ConstructAbility s_writableStreamInternalsIsCloseSentinelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -412,7 +412,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength = 237; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (i,h){\"use strict\";const b=@getByIdDirectPrivate(i,\"stream\");@assert(b!==@undefined),@assert(@getByIdDirectPrivate(b,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(i),@writableStreamStartErroring(b,h)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (i,b){\"use strict\";const h=@getByIdDirectPrivate(i,\"stream\");@assert(h!==@undefined),@assert(@getByIdDirectPrivate(h,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(i),@writableStreamStartErroring(h,b)})\n"; // writableStreamDefaultControllerErrorIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -452,7 +452,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength = 441; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkCloseRequestInFlight(_),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),@assert(@getByIdDirectPrivate(i,\"queue\").content\?.isEmpty());const d=@getByIdDirectPrivate(i,\"closeAlgorithm\").@call();@writableStreamDefaultControllerClearAlgorithms(i),d.@then(()=>{@writableStreamFinishInFlightClose(_)},(h)=>{@writableStreamFinishInFlightCloseWithError(_,h)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode = "(function (i){\"use strict\";const h=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkCloseRequestInFlight(h),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),@assert(@getByIdDirectPrivate(i,\"queue\").content\?.isEmpty());const _=@getByIdDirectPrivate(i,\"closeAlgorithm\").@call();@writableStreamDefaultControllerClearAlgorithms(i),_.@then(()=>{@writableStreamFinishInFlightClose(h)},(d)=>{@writableStreamFinishInFlightCloseWithError(h,d)})})\n"; // writableStreamDefaultControllerProcessWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructAbility = 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 (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"; +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"; // 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 (j,q,v,x,B,D,E){\"use strict\";if(x===@undefined)x=1;if(B===@undefined)B=()=>1;if(D===@undefined)D=0;if(E===@undefined)E=()=>1;@assert(x>=0),@assert(D>=0);const F={};@putByIdDirectPrivate(F,\"TransformStream\",!0);const G=new @TransformStream(F),I=@newPromiseCapability(@Promise);@initializeTransformStream(G,I.@promise,x,B,D,E);const _=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(G,_,q,v),j().@then(()=>{I.@resolve.@call()},(c)=>{I.@reject.@call(@undefined,c)}),G})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (q,v,B,c,x,D,E){\"use strict\";if(c===@undefined)c=1;if(x===@undefined)x=()=>1;if(D===@undefined)D=0;if(E===@undefined)E=()=>1;@assert(c>=0),@assert(D>=0);const F={};@putByIdDirectPrivate(F,\"TransformStream\",!0);const G=new @TransformStream(F),I=@newPromiseCapability(@Promise);@initializeTransformStream(G,I.@promise,c,x,D,E);const _=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(G,_,v,B),q().@then(()=>{I.@resolve.@call()},(j)=>{I.@reject.@call(@undefined,j)}),G})\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 (T,j,q,C,D,E){\"use strict\";const F=()=>{return j},G=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(T,N)},I=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(T,N)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(T)},f=@createWritableStream(F,G,J,I,q,C),B=()=>{return @transformStreamDefaultSourcePullAlgorithm(T)},v=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(T,N),@Promise.@resolve()},x={};@putByIdDirectPrivate(x,\"start\",F),@putByIdDirectPrivate(x,\"pull\",B),@putByIdDirectPrivate(x,\"cancel\",v);const K={};@putByIdDirectPrivate(K,\"size\",E),@putByIdDirectPrivate(K,\"highWaterMark\",D);const L=new @ReadableStream(x,K);@putByIdDirectPrivate(T,\"writable\",f),@putByIdDirectPrivate(T,\"internalWritable\",@getInternalWritableStream(f)),@putByIdDirectPrivate(T,\"readable\",L),@putByIdDirectPrivate(T,\"backpressure\",@undefined),@putByIdDirectPrivate(T,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(T,!0),@putByIdDirectPrivate(T,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (T,q,v,x,C,D){\"use strict\";const E=()=>{return q},f=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(T,N)},B=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(T,N)},F=()=>{return @transformStreamDefaultSinkCloseAlgorithm(T)},j=@createWritableStream(E,f,F,B,v,x),G=()=>{return @transformStreamDefaultSourcePullAlgorithm(T)},I=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(T,N),@Promise.@resolve()},J={};@putByIdDirectPrivate(J,\"start\",E),@putByIdDirectPrivate(J,\"pull\",G),@putByIdDirectPrivate(J,\"cancel\",I);const K={};@putByIdDirectPrivate(K,\"size\",D),@putByIdDirectPrivate(K,\"highWaterMark\",C);const L=new @ReadableStream(J,K);@putByIdDirectPrivate(T,\"writable\",j),@putByIdDirectPrivate(T,\"internalWritable\",@getInternalWritableStream(j)),@putByIdDirectPrivate(T,\"readable\",L),@putByIdDirectPrivate(T,\"backpressure\",@undefined),@putByIdDirectPrivate(T,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(T,!0),@putByIdDirectPrivate(T,\"controller\",@undefined)})\n"; // transformStreamError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -518,7 +518,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeCon const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorCodeLength = 222; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (f,i){\"use strict\";const n=@getByIdDirectPrivate(f,\"readable\"),_=@getByIdDirectPrivate(n,\"readableStreamController\");@readableStreamDefaultControllerError(_,i),@transformStreamErrorWritableAndUnblockWrite(f,i)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (f,n){\"use strict\";const i=@getByIdDirectPrivate(f,\"readable\"),_=@getByIdDirectPrivate(i,\"readableStreamController\");@readableStreamDefaultControllerError(_,n),@transformStreamErrorWritableAndUnblockWrite(f,n)})\n"; // transformStreamErrorWritableAndUnblockWrite const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility = 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(b,\"stream\",d),@putByIdDirectPrivate(d,\"controller\",b),@putByIdDirectPrivate(b,\"transformAlgorithm\",_),@putByIdDirectPrivate(b,\"flushAlgorithm\",P)})\n"; // setUpTransformStreamDefaultControllerFromTransformer const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 443; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,d,p){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in p)b=(q)=>{return @promiseInvokeOrNoopMethod(d,p.transform,[q,v])};if(\"flush\"in p)j=()=>{return @promiseInvokeOrNoopMethod(d,p.flush,[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,p,d){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in d)b=(q)=>{return @promiseInvokeOrNoopMethod(p,d.transform,[q,v])};if(\"flush\"in d)j=()=>{return @promiseInvokeOrNoopMethod(p,d.flush,[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = 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){\"use strict\";const W=@getByIdDirectPrivate(_,\"stream\"),f=@getByIdDirectPrivate(W,\"readable\"),g=@getByIdDirectPrivate(f,\"readableStreamController\");if(@assert(g!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(g))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(g,S)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(W,j),@getByIdDirectPrivate(f,\"storedError\")}const i=!@readableStreamDefaultControllerShouldCallPull(g);if(i!==@getByIdDirectPrivate(W,\"backpressure\"))@assert(i),@transformStreamSetBackpressure(W,!0)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (_,S){\"use strict\";const W=@getByIdDirectPrivate(_,\"stream\"),f=@getByIdDirectPrivate(W,\"readable\"),i=@getByIdDirectPrivate(f,\"readableStreamController\");if(@assert(i!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(i))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(i,S)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(W,j),@getByIdDirectPrivate(f,\"storedError\")}const g=!@readableStreamDefaultControllerShouldCallPull(i);if(g!==@getByIdDirectPrivate(W,\"backpressure\"))@assert(g),@transformStreamSetBackpressure(W,!0)})\n"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,f){\"use strict\";const g=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,f).@then(()=>{g.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),g.@reject.@call(@undefined,j)}),g.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -590,7 +590,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 367; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\"),f=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(f,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(_,u)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const f=@getByIdDirectPrivate(i,\"stream\"),_=@getByIdDirectPrivate(f,\"readable\"),k=@getByIdDirectPrivate(_,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(f,u)})\n"; // transformStreamDefaultSinkWriteAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = 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){\"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"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (_,q){\"use strict\";const z=@getByIdDirectPrivate(_,\"internalWritable\");@assert(@getByIdDirectPrivate(z,\"state\")===\"writable\");const v=@getByIdDirectPrivate(_,\"controller\");if(@getByIdDirectPrivate(_,\"backpressure\")){const d=@newPromiseCapability(@Promise),j=@getByIdDirectPrivate(_,\"backpressureChangePromise\");return @assert(j!==@undefined),j.@promise.@then(()=>{const x=@getByIdDirectPrivate(z,\"state\");if(x===\"erroring\"){d.@reject.@call(@undefined,@getByIdDirectPrivate(z,\"storedError\"));return}@assert(x===\"writable\"),@transformStreamDefaultControllerPerformTransform(v,q).@then(()=>{d.@resolve()},(f)=>{d.@reject.@call(@undefined,f)})},(x)=>{d.@reject.@call(@undefined,x)}),d.@promise}return @transformStreamDefaultControllerPerformTransform(v,q)})\n"; // transformStreamDefaultSinkAbortAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -640,7 +640,7 @@ const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsBindingCodeLength = 473; static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsBindingCode = "(function (l){\"use strict\";if(l!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var r=globalThis.Symbol.for(\"process.bindings.constants\"),I=globalThis[r];if(!I){const{constants:d}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");I={fs:d,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[r]=I}return I})\n"; +const char* const s_processObjectInternalsBindingCode = "(function (d){\"use strict\";if(d!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var l=globalThis.Symbol.for(\"process.bindings.constants\"),I=globalThis[l];if(!I){const{constants:r}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");I={fs:r,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[l]=I}return I})\n"; // getStdioWriteStream const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (j,H){\"use strict\";var K={path:\"node:process\",require:H},G=(N)=>K.require(N);function J(N){var{Duplex:O,eos:Q,destroy:U}=G(\"node:stream\"),V=class X extends O{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(N)}get fd(){return N}constructor(Z){super({readable:!0,writable:!0});this.#G=`/dev/fd/${Z}`}#N(Z){const Y=this.#H;if(this.#H=null,Y)Y(Z);else if(Z)this.destroy(Z);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Z,Y){if(!Z&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Z=new P}if(this.#J=null,this.#K=null,this.#H===null)Y(Z);else{if(this.#H=Y,this.#$)U(this.#$,Z);if(this.#B)U(this.#B,Z)}}_write(Z,Y,P){if(!this.#$){var{createWriteStream:A}=G(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),Q(T,(x)=>{if(this.#z=!1,x)U(T,x);this.#N(x)})}if(T.write(Z,Y))P();else this.#J=P}_final(Z){this.#$&&this.#$.end(),this.#K=Z}#O(){var{createReadStream:Z}=G(\"node:fs\"),Y=this.#B=Z(this.#G);return Y.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),Y.on(\"end\",()=>{this.push(null)}),Q(Y,(P)=>{if(this.#j=!1,P)U(Y,P);this.#N(P)}),Y}_read(){var Z=this.#B;if(!Z)Z=this.#O();while(!0){const Y=Z.read();if(Y===null||!this.push(Y))return}}};return new V(N)}var{EventEmitter:z}=G(\"node:events\");function L(N){if(!N)return!0;var O=N.toLowerCase();return O===\"utf8\"||O===\"utf-8\"||O===\"buffer\"||O===\"binary\"}var M,B=class N extends z{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(O){if(this.#B||!L(O))return this.#J(),this.#B.setDefaultEncoding(O)}#G(){switch(this.#$){case 1:{var O=@Bun.stdout.writer({highWaterMark:0});return O.unref(),O}case 2:{var O=@Bun.stderr.writer({highWaterMark:0});return O.unref(),O}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(O){super();this.#$=O}get fd(){return this.#$}get isTTY(){return this.#z\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(O,Q,U){return(M\?\?=G(\"readline\")).cursorTo(this,O,Q,U)}moveCursor(O,Q,U){return(M\?\?=G(\"readline\")).moveCursor(this,O,Q,U)}clearLine(O,Q){return(M\?\?=G(\"readline\")).clearLine(this,O,Q)}clearScreenDown(O){return(M\?\?=G(\"readline\")).clearScreenDown(this,O)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(O,Q){if(O===\"close\"||O===\"finish\")return this.#J(),this.#B.on(O,Q);if(O===\"drain\")return super.on(\"drain\",Q);if(O===\"error\")return super.on(\"error\",Q);return super.on(O,Q)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(O){return this.#J(),this.#B.pipe(O)}unpipe(O){return this.#J(),this.#B.unpipe(O)}#J(){if(this.#B)return;this.#B=J(this.#$);const O=this.eventNames();for(let Q of O)this.#B.on(Q,(...U)=>{this.emit(Q,...U)})}#K(O){var Q=this.#H();const U=Q.write(O);this.bytesWritten+=U;const V=Q.flush(!1);return!!(U||V)}#L(O,Q){if(!L(Q))return this.#J(),this.#B.write(O,Q);return this.#K(O)}#M(O,Q){if(Q)this.emit(\"error\",Q);try{O(Q\?Q:null)}catch(U){this.emit(\"error\",U)}}#N(O,Q,U){if(!L(Q))return this.#J(),this.#B.write(O,Q,U);var V=this.#H();const X=V.write(O),Z=V.flush(!0);if(Z\?.then)return Z.then(()=>{this.#M(U),this.emit(\"drain\")},(Y)=>this.#M(U,Y)),!1;return queueMicrotask(()=>{this.#M(U)}),!!(X||Z)}write(O,Q,U){const V=this._write(O,Q,U);if(V)this.emit(\"drain\");return V}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(O,Q,U){var V=this.#B;if(V)return V.write(O,Q,U);switch(arguments.length){case 0:{var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}case 1:return this.#K(O);case 2:if(typeof Q===\"function\")return this.#N(O,\"\",Q);else if(typeof Q===\"string\")return this.#L(O,Q);default:{if(typeof Q!==\"undefined\"&&typeof Q!==\"string\"||typeof U!==\"undefined\"&&typeof U!==\"function\"){var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}if(typeof U===\"undefined\")return this.#L(O,Q);return this.#N(O,Q,U)}}}destroy(){return this}end(){return this}};return new B(j)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (B,Q){\"use strict\";var j={path:\"node:process\",require:Q},U=(Z)=>j.require(Z);function z(Z){var{Duplex:J,eos:Y,destroy:K}=U(\"node:stream\"),P=class L extends J{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=U(\"node:tty\").isatty(Z)}get fd(){return Z}constructor(A){super({readable:!0,writable:!0});this.#G=`/dev/fd/${A}`}#N(A){const M=this.#H;if(this.#H=null,M)M(A);else if(A)this.destroy(A);else if(!this.#j&&!this.#z)this.destroy()}_destroy(A,M){if(!A&&this.#H!==null){var T=class N extends Error{code;name;constructor(x=\"The operation was aborted\",O=void 0){if(O!==void 0&&typeof O!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(O,null,2)}`);super(x,O);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};A=new T}if(this.#J=null,this.#K=null,this.#H===null)M(A);else{if(this.#H=M,this.#$)K(this.#$,A);if(this.#B)K(this.#B,A)}}_write(A,M,T){if(!this.#$){var{createWriteStream:N}=U(\"node:fs\"),x=this.#$=N(this.#G);x.on(\"finish\",()=>{if(this.#K){const O=this.#K;this.#K=null,O()}}),x.on(\"drain\",()=>{if(this.#J){const O=this.#J;this.#J=null,O()}}),Y(x,(O)=>{if(this.#z=!1,O)K(x,O);this.#N(O)})}if(x.write(A,M))T();else this.#J=T}_final(A){this.#$&&this.#$.end(),this.#K=A}#O(){var{createReadStream:A}=U(\"node:fs\"),M=this.#B=A(this.#G);return M.on(\"readable\",()=>{if(this.#L){const T=this.#L;this.#L=null,T()}else this.read()}),M.on(\"end\",()=>{this.push(null)}),Y(M,(T)=>{if(this.#j=!1,T)K(M,T);this.#N(T)}),M}_read(){var A=this.#B;if(!A)A=this.#O();while(!0){const M=A.read();if(M===null||!this.push(M))return}}};return new P(Z)}var{EventEmitter:V}=U(\"node:events\");function G(Z){if(!Z)return!0;var J=Z.toLowerCase();return J===\"utf8\"||J===\"utf-8\"||J===\"buffer\"||J===\"binary\"}var X,H=class Z extends V{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(J){if(this.#B||!G(J))return this.#J(),this.#B.setDefaultEncoding(J)}#G(){switch(this.#$){case 1:{var J=@Bun.stdout.writer({highWaterMark:0});return J.unref(),J}case 2:{var J=@Bun.stderr.writer({highWaterMark:0});return J.unref(),J}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(J){super();this.#$=J}get fd(){return this.#$}get isTTY(){return this.#z\?\?=U(\"node:tty\").isatty(this.#$)}cursorTo(J,Y,K){return(X\?\?=U(\"readline\")).cursorTo(this,J,Y,K)}moveCursor(J,Y,K){return(X\?\?=U(\"readline\")).moveCursor(this,J,Y,K)}clearLine(J,Y){return(X\?\?=U(\"readline\")).clearLine(this,J,Y)}clearScreenDown(J){return(X\?\?=U(\"readline\")).clearScreenDown(this,J)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(J,Y){if(J===\"close\"||J===\"finish\")return this.#J(),this.#B.on(J,Y);if(J===\"drain\")return super.on(\"drain\",Y);if(J===\"error\")return super.on(\"error\",Y);return super.on(J,Y)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(J){return this.#J(),this.#B.pipe(J)}unpipe(J){return this.#J(),this.#B.unpipe(J)}#J(){if(this.#B)return;this.#B=z(this.#$);const J=this.eventNames();for(let Y of J)this.#B.on(Y,(...K)=>{this.emit(Y,...K)})}#K(J){var Y=this.#H();const K=Y.write(J);this.bytesWritten+=K;const P=Y.flush(!1);return!!(K||P)}#L(J,Y){if(!G(Y))return this.#J(),this.#B.write(J,Y);return this.#K(J)}#M(J,Y){if(Y)this.emit(\"error\",Y);try{J(Y\?Y:null)}catch(K){this.emit(\"error\",K)}}#N(J,Y,K){if(!G(Y))return this.#J(),this.#B.write(J,Y,K);var P=this.#H();const L=P.write(J),A=P.flush(!0);if(A\?.then)return A.then(()=>{this.#M(K),this.emit(\"drain\")},(M)=>this.#M(K,M)),!1;return queueMicrotask(()=>{this.#M(K)}),!!(L||A)}write(J,Y,K){const P=this._write(J,Y,K);if(P)this.emit(\"drain\");return P}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(J,Y,K){var P=this.#B;if(P)return P.write(J,Y,K);switch(arguments.length){case 0:{var L=new Error(\"Invalid arguments\");throw L.code=\"ERR_INVALID_ARG_TYPE\",L}case 1:return this.#K(J);case 2:if(typeof Y===\"function\")return this.#N(J,\"\",Y);else if(typeof Y===\"string\")return this.#L(J,Y);default:{if(typeof Y!==\"undefined\"&&typeof Y!==\"string\"||typeof K!==\"undefined\"&&typeof K!==\"function\"){var L=new Error(\"Invalid arguments\");throw L.code=\"ERR_INVALID_ARG_TYPE\",L}if(typeof K===\"undefined\")return this.#L(J,Y);return this.#N(J,Y,K)}}}destroy(){return this}end(){return this}};return new H(B)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = 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,L,Q){\"use strict\";var M={path:\"node:process\",require:L},j=(N)=>M.require(N),{Duplex:T,eos:K,destroy:U}=j(\"node:stream\"),z=class N extends T{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return j(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(V){const G=this.#J;if(this.#J=null,G)G(V);else if(V)this.destroy(V);else if(!this.#z&&!this.#H)this.destroy()}_destroy(V,G){if(!V&&this.#J!==null){var H=class I extends Error{constructor(J=\"The operation was aborted\",P=void 0){if(P!==void 0&&typeof P!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(P,null,2)}`);super(J,P);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};V=new H}if(this.#J===null)G(V);else if(this.#J=G,this.#j)U(this.#j,V)}setRawMode(V){}on(V,G){if(V===\"readable\")this.ref(),this.#G=!0;return super.on(V,G)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#Y\?\?=Q.stdin.stream().getReader(),this.#$\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#$)clearInterval(this.#$),this.#$=null}async#M(){try{var V,G;const H=this.#Y.readMany();if(!H\?.then)({done:V,value:G}=H);else({done:V,value:G}=await H);if(!V){this.push(G[0]);const I=G.length;for(let J=1;J{if(this.#I){const H=this.#I;this.#I=null,H()}}),G.on(\"drain\",()=>{if(this.#K){const H=this.#K;this.#K=null,H()}}),K(G,(H)=>{if(this.#H=!1,H)U(G,H);this.#L(H)}),G}_write(V,G,H){var I=this.#j;if(!I)I=this.#N();if(I.write(V,G))H();else this.#K=H}_final(V){this.#j.end(),this.#I=(...G)=>V(...G)}};return new z})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (Y,j,z){\"use strict\";var G={path:\"node:process\",require:j},H=(T)=>G.require(T),{Duplex:I,eos:J,destroy:K}=H(\"node:stream\"),L=class T extends I{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return H(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(V){const M=this.#J;if(this.#J=null,M)M(V);else if(V)this.destroy(V);else if(!this.#z&&!this.#H)this.destroy()}_destroy(V,M){if(!V&&this.#J!==null){var N=class P extends Error{constructor(Q=\"The operation was aborted\",U=void 0){if(U!==void 0&&typeof U!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(U,null,2)}`);super(Q,U);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};V=new N}if(this.#J===null)M(V);else if(this.#J=M,this.#j)K(this.#j,V)}setRawMode(V){}on(V,M){if(V===\"readable\")this.ref(),this.#G=!0;return super.on(V,M)}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 V,M;const N=this.#Y.readMany();if(!N\?.then)({done:V,value:M}=N);else({done:V,value:M}=await N);if(!V){this.push(M[0]);const P=M.length;for(let Q=1;Q{if(this.#I){const N=this.#I;this.#I=null,N()}}),M.on(\"drain\",()=>{if(this.#K){const N=this.#K;this.#K=null,N()}}),J(M,(N)=>{if(this.#H=!1,N)K(M,N);this.#L(N)}),M}_write(V,M,N){var P=this.#j;if(!P)P=this.#N();if(P.write(V,M))N();else this.#K=N}_final(V){this.#j.end(),this.#I=(...M)=>V(...M)}};return new L})\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 = 1304; static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let j=arguments[0];if(@isObject(j)&&@getByIdDirectPrivate(j,\"TransformStream\"))return this;let q=arguments[1],v=arguments[2];if(j===@undefined)j=null;if(v===@undefined)v={};if(q===@undefined)q={};let x={};if(j!==null){if(\"start\"in j){if(x.start=j.start,typeof x.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in j){if(x.transform=j.transform,typeof x.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in j){if(x.flush=j.flush,typeof x.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in j)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in j)@throwRangeError(\"TransformStream transformer has a writableType\")}const B=@extractHighWaterMark(v,0),E=@extractSizeAlgorithm(v),F=@extractHighWaterMark(q,1),G=@extractSizeAlgorithm(q),I=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,I.@promise,F,G,B,E),@setUpTransformStreamDefaultControllerFromTransformer(this,j,x),(\"start\"in x)){const J=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(j,x.start,[J]))().@then(()=>{I.@resolve.@call()},(u)=>{I.@reject.@call(@undefined,u)})}else I.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let u=arguments[1],j=arguments[2];if(_===@undefined)_=null;if(j===@undefined)j={};if(u===@undefined)u={};let q={};if(_!==null){if(\"start\"in _){if(q.start=_.start,typeof q.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(q.transform=_.transform,typeof q.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(q.flush=_.flush,typeof q.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const v=@extractHighWaterMark(j,0),x=@extractSizeAlgorithm(j),B=@extractHighWaterMark(u,1),E=@extractSizeAlgorithm(u),F=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,F.@promise,B,E,v,x),@setUpTransformStreamDefaultControllerFromTransformer(this,_,q),(\"start\"in q)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,q.start,[G]))().@then(()=>{F.@resolve.@call()},(J)=>{F.@reject.@call(@undefined,J)})}else F.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (_){\"use strict\";const M=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(M)return @evaluateCommonJSModule(M),M.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=S.module,h=@Loader.getModuleNamespaceObject(b),r=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const f=@createCommonJSModule(_,{},!1);@requireMap.@set(_,f);var L=this.@require(_,f);if(L===-1){try{L=@requireESM(_)}catch(b){throw @requireMap.@delete(_),b}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=@Loader.getModuleNamespaceObject(S.module);return f.exports=b\?.[@commonJSSymbol]===0||b\?.default\?.[@commonJSSymbol]===0\?b.default:b.__esModule\?b:Object.create(b,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(f),f.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const f=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(f)return @evaluateCommonJSModule(f),f.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const L=S.module,h=@Loader.getModuleNamespaceObject(L),r=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const b=@createCommonJSModule(_,{},!1);@requireMap.@set(_,b);var M=this.@require(_,b);if(M===-1){try{M=@requireESM(_)}catch(L){throw @requireMap.@delete(_),L}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const L=@Loader.getModuleNamespaceObject(S.module);return b.exports=L\?.[@commonJSSymbol]===0||L\?.default\?.[@commonJSSymbol]===0\?L.default:L.__esModule\?L:Object.create(L,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(b),b.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -742,7 +742,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSetBigUint64CodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeSetBigUint64CodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSetBigUint64CodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeSetBigUint64CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSetBigUint64Code = "(function (d,r,t){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,r,t)})\n"; +const char* const s_jsBufferPrototypeSetBigUint64Code = "(function (r,d,t){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(r,d,t)})\n"; // readInt8 const JSC::ConstructAbility s_jsBufferPrototypeReadInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (r,u){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(u){case 1:return _.getInt8(r);case 2:return _.getInt16(r,!0);case 3:{const d=_.getUint16(r,!0)+_.getUint8(r+2)*65536;return d|(d&8388608)*510}case 4:return _.getInt32(r,!0);case 5:{const d=_.getUint8(r+4);return(d|(d&128)*33554430)*4294967296+_.getUint32(r,!0)}case 6:{const d=_.getUint16(r+4,!0);return(d|(d&32768)*131070)*4294967296+_.getUint32(r,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -838,7 +838,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntBECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,c){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:return u.getInt8(r);case 2:return u.getInt16(r,!1);case 3:{const d=u.getUint16(r+1,!1)+u.getUint8(r)*65536;return d|(d&8388608)*510}case 4:return u.getInt32(r,!1);case 5:{const d=u.getUint8(r);return(d|(d&128)*33554430)*4294967296+u.getUint32(r+1,!1)}case 6:{const d=u.getUint16(r,!1);return(d|(d&32768)*131070)*4294967296+u.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:return d.getInt8(r);case 2:return d.getInt16(r,!1);case 3:{const u=d.getUint16(r+1,!1)+d.getUint8(r)*65536;return u|(u&8388608)*510}case 4:return d.getInt32(r,!1);case 5:{const u=d.getUint8(r);return(u|(u&128)*33554430)*4294967296+d.getUint32(r+1,!1)}case 6:{const u=d.getUint16(r,!1);return(u|(u&32768)*131070)*4294967296+d.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntLE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -846,7 +846,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntLECodeLength = 445; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,d){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return r.getUint8(a);case 2:return r.getUint16(a,!0);case 3:return r.getUint16(a,!0)+r.getUint8(a+2)*65536;case 4:return r.getUint32(a,!0);case 5:return r.getUint8(a+4)*4294967296+r.getUint32(a,!0);case 6:return r.getUint16(a+4,!0)*4294967296+r.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,r){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return d.getUint8(a);case 2:return d.getUint16(a,!0);case 3:return d.getUint16(a,!0)+d.getUint8(a+2)*65536;case 4:return d.getUint32(a,!0);case 5:return d.getUint8(a+4)*4294967296+d.getUint32(a,!0);case 6:return d.getUint16(a+4,!0)*4294967296+d.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1022,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,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"; +const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (r,E,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{d.setUint8(E,r);break}case 2:{d.setUint16(E,r,!0);break}case 3:{d.setUint16(E,r&65535,!0),d.setUint8(E+2,Math.floor(r*0.0000152587890625));break}case 4:{d.setUint32(E,r,!0);break}case 5:{d.setUint32(E,r|0,!0),d.setUint8(E+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(E,r|0,!0),d.setUint16(E+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return E+c})\n"; // writeUIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1030,7 +1030,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntBECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (d,r,p){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:{_.setUint8(r,d);break}case 2:{_.setUint16(r,d,!1);break}case 3:{_.setUint16(r+1,d&65535,!1),_.setUint8(r,Math.floor(d*0.0000152587890625));break}case 4:{_.setUint32(r,d,!1);break}case 5:{_.setUint32(r+1,d|0,!1),_.setUint8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{_.setUint32(r+2,d|0,!1),_.setUint16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+p})\n"; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (d,r,_){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{p.setUint8(r,d);break}case 2:{p.setUint16(r,d,!1);break}case 3:{p.setUint16(r+1,d&65535,!1),p.setUint8(r,Math.floor(d*0.0000152587890625));break}case 4:{p.setUint32(r,d,!1);break}case 5:{p.setUint32(r+1,d|0,!1),p.setUint8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{p.setUint32(r+2,d|0,!1),p.setUint16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+_})\n"; // writeFloatLE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1094,7 +1094,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKin const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigUInt64BECodeLength = 139; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!1),c+8})\n"; // utf8Write const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1110,7 +1110,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUcs2WriteCodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUcs2WriteCodeLength = 65; static const JSC::Intrinsic s_jsBufferPrototypeUcs2WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUcs2WriteCode = "(function (c,d,r){\"use strict\";return this.write(c,d,r,\"ucs2\")})\n"; +const char* const s_jsBufferPrototypeUcs2WriteCode = "(function (d,c,r){\"use strict\";return this.write(d,c,r,\"ucs2\")})\n"; // utf16leWrite const JSC::ConstructAbility s_jsBufferPrototypeUtf16leWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1118,7 +1118,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf16leWriteCodeLength = 68; static const JSC::Intrinsic s_jsBufferPrototypeUtf16leWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (d,r,a){\"use strict\";return this.write(d,r,a,\"utf16le\")})\n"; +const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (d,a,r){\"use strict\";return this.write(d,a,r,\"utf16le\")})\n"; // latin1Write const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1126,7 +1126,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeLatin1WriteCodeLength = 67; static const JSC::Intrinsic s_jsBufferPrototypeLatin1WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"latin1\")})\n"; +const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"latin1\")})\n"; // asciiWrite const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1182,7 +1182,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf16leSliceCodeLength = 67; static const JSC::Intrinsic s_jsBufferPrototypeUtf16leSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leSliceCode = "(function (g,p){\"use strict\";return this.toString(\"utf16le\",g,p)})\n"; +const char* const s_jsBufferPrototypeUtf16leSliceCode = "(function (p,g){\"use strict\";return this.toString(\"utf16le\",p,g)})\n"; // latin1Slice const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1198,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 (g,u){\"use strict\";return this.toString(\"ascii\",g,u)})\n"; +const char* const s_jsBufferPrototypeAsciiSliceCode = "(function (u,g){\"use strict\";return this.toString(\"ascii\",u,g)})\n"; // base64Slice const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1206,7 +1206,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeBase64SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64SliceCodeLength = 66; static const JSC::Intrinsic s_jsBufferPrototypeBase64SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64SliceCode = "(function (g,p){\"use strict\";return this.toString(\"base64\",g,p)})\n"; +const char* const s_jsBufferPrototypeBase64SliceCode = "(function (p,g){\"use strict\";return this.toString(\"base64\",p,g)})\n"; // base64urlSlice const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1214,7 +1214,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlSliceCodeLength = 69; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlSliceCode = "(function (c,g){\"use strict\";return this.toString(\"base64url\",c,g)})\n"; +const char* const s_jsBufferPrototypeBase64urlSliceCode = "(function (g,c){\"use strict\";return this.toString(\"base64url\",g,c)})\n"; // hexSlice const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (c,p){\"use strict\";var{buffer:i,byteOffset:k,byteLength:m}=this;function q(x,z){if(x=@trunc(x),x===0||@isNaN(x))return 0;else if(x<0)return x+=z,x>0\?x:0;else return xv\?w-v:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (c,m){\"use strict\";var{buffer:v,byteOffset:w,byteLength:p}=this;function x(i,q){if(i=@trunc(i),i===0||@isNaN(i))return 0;else if(i<0)return i+=q,i>0\?i:0;else return ik\?z-k:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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 _=async function*q(){var A=@Bun.stdin.stream().getReader(),D=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),B,F=@Bun.indexOfLine;try{while(!0){var G,H,J;const L=A.readMany();if(@isPromise(L))({done:G,value:H}=await L);else({done:G,value:H}=L);if(G){if(J)yield D.decode(J);return}var j;for(let M of H){if(j=M,J)j=@Buffer.concat([J,M]),J=null;var m=0,K=F(j,m);while(K!==-1)yield D.decode(j.subarray(m,K)),m=K+1,K=F(j,m);J=j.subarray(m)}}}catch(L){B=L}finally{if(A.releaseLock(),B)throw B}},w=globalThis.Symbol.asyncIterator;return this[w]=_,_()})\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; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (d){\"use strict\";var _=@getByIdDirectPrivate(this,\"writer\");if(!_){var b=@toLength(d\?.length\?\?0);_=@Bun.stdout.writer({highWaterMark:b>65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",a)}var d=a.write(f);const c=@argumentCount();for(var _=1;_@promiseInvokeOrNoopMethod(v,x,[B]),q=(D)=>@promiseInvokeOrNoopMethod(v,j,[D]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",q),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (_,q,w,x,B,f,v){\"use strict\";const C=new @ReadableStreamDefaultController(_,q,w,x,@isReadableStream),b=()=>@promiseInvokeOrNoopMethod(q,f,[C]),D=(j)=>@promiseInvokeOrNoopMethod(q,v,[j]);@putByIdDirectPrivate(C,\"pullAlgorithm\",b),@putByIdDirectPrivate(C,\"cancelAlgorithm\",D),@putByIdDirectPrivate(C,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(C,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(_,\"readableStreamController\",C),@readableStreamDefaultControllerStart(C)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (v,w,A){\"use strict\";const C=w.type,b=@toString(C);if(b===\"bytes\"){if(A.highWaterMark===@undefined)A.highWaterMark=0;if(A.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(v,\"readableStreamController\",new @ReadableByteStreamController(v,w,A.highWaterMark,@isReadableStream))}else if(b===\"direct\"){var f=A\?.highWaterMark;@initializeArrayBufferStream.@call(v,w,f)}else if(C===@undefined){if(A.highWaterMark===@undefined)A.highWaterMark=1;@setupReadableStreamDefaultController(v,w,A.size,A.highWaterMark,w.start,w.pull,w.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,b)}else if(A===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1420,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 p=@getByIdDirectPrivate(m,\"underlyingSource\"),B=p.start;@putByIdDirectPrivate(m,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(p,B,[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; @@ -1428,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 (D,E,k,w,x,z){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(E)),@assert(z===@undefined||@isAbortSignal(z)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let B={source:D,destination:E,preventAbort:w,preventCancel:x,preventClose:k,signal:z};if(B.reader=@acquireReadableStreamDefaultReader(D),B.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(D,\"disturbed\",!0),B.finalized=!1,B.shuttingDown=!1,B.promiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability.@resolve.@call(),B.pendingWritePromise=@Promise.@resolve(),z!==@undefined){const F=(G)=>{if(B.finalized)return;@pipeToShutdownWithAction(B,()=>{const _=!B.preventAbort&&@getByIdDirectPrivate(B.destination,\"state\")===\"writable\"\?@writableStreamAbort(B.destination,G):@Promise.@resolve(),T=!B.preventCancel&&@getByIdDirectPrivate(B.source,\"state\")===@streamReadable\?@readableStreamCancel(B.source,G):@Promise.@resolve();let q=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}q.@resolve.@call()},K=(L)=>{q.@reject.@call(@undefined,L)};return _.@then(J,K),T.@then(J,K),q.@promise},G)};if(@whenSignalAborted(z,F))return B.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(B),@pipeToErrorsMustBePropagatedBackward(B),@pipeToClosingMustBePropagatedForward(B),@pipeToClosingMustBePropagatedBackward(B),@pipeToLoop(B),B.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (_,k,q,w,f,x){\"use strict\";if(@assert(@isReadableStream(_)),@assert(@isWritableStream(k)),@assert(!@isReadableStreamLocked(_)),@assert(!@isWritableStreamLocked(k)),@assert(x===@undefined||@isAbortSignal(x)),@getByIdDirectPrivate(_,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let z={source:_,destination:k,preventAbort:w,preventCancel:f,preventClose:q,signal:x};if(z.reader=@acquireReadableStreamDefaultReader(_),z.writer=@acquireWritableStreamDefaultWriter(k),@putByIdDirectPrivate(_,\"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 I=!z.preventAbort&&@getByIdDirectPrivate(z.destination,\"state\")===\"writable\"\?@writableStreamAbort(z.destination,F):@Promise.@resolve(),D=!z.preventCancel&&@getByIdDirectPrivate(z.source,\"state\")===@streamReadable\?@readableStreamCancel(z.source,F):@Promise.@resolve();let J=@newPromiseCapability(@Promise),E=!0,K=()=>{if(E){E=!1;return}J.@resolve.@call()},L=(T)=>{J.@reject.@call(@undefined,T)};return I.@then(K,L),D.@then(K,L),J.@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"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1452,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 (_){\"use strict\";const d=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,b),b);return}@pipeToShutdown(_,b)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){d();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,d)})\n"; // pipeToErrorsMustBePropagatedBackward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1460,7 +1460,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagated const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength = 369; static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const h=()=>{const y=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,y),y);return}@pipeToShutdown(m,y)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){h();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,h)})\n"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const y=()=>{const h=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,h),h);return}@pipeToShutdown(m,h)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){y();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,y)})\n"; // pipeToClosingMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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,g){\"use strict\";if(m.shuttingDown)return;m.shuttingDown=!0;const h=arguments.length>2,d=arguments[2],j=()=>{g().@then(()=>{if(h)@pipeToFinalize(m,d);else @pipeToFinalize(m)},(b)=>{@pipeToFinalize(m,b)})};if(@getByIdDirectPrivate(m.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(m.destination)){m.pendingReadPromiseCapability.@promise.@then(()=>{m.pendingWritePromise.@then(j,j)},(_)=>@pipeToFinalize(m,_));return}j()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (g,j){\"use strict\";if(g.shuttingDown)return;g.shuttingDown=!0;const _=arguments.length>2,b=arguments[2],d=()=>{j().@then(()=>{if(_)@pipeToFinalize(g,b);else @pipeToFinalize(g)},(h)=>{@pipeToFinalize(g,h)})};if(@getByIdDirectPrivate(g.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(g.destination)){g.pendingReadPromiseCapability.@promise.@then(()=>{g.pendingWritePromise.@then(d,d)},(m)=>@pipeToFinalize(g,m));return}d()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1492,7 +1492,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownCodeLength = 411; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const d=arguments.length>1,m=arguments[1],u=()=>{if(d)@pipeToFinalize(_,m);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(I)=>@pipeToFinalize(_,I));return}u()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,I=arguments[1],u=()=>{if(m)@pipeToFinalize(_,I);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(d)=>@pipeToFinalize(_,d));return}u()})\n"; // pipeToFinalize const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,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; @@ -1524,7 +1524,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1Canc const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength = 258; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,d){\"use strict\";return function(i){if(c.canceled1=!0,c.reason1=i,c.canceled2)@readableStreamCancel(d,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,i){\"use strict\";return function(d){if(c.canceled1=!0,c.reason1=d,c.canceled2)@readableStreamCancel(i,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; // readableStreamTeeBranch2CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1532,7 +1532,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch2Canc const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength = 258; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode = "(function (c,d){\"use strict\";return function(i){if(c.canceled2=!0,c.reason2=i,c.canceled1)@readableStreamCancel(d,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode = "(function (d,i){\"use strict\";return function(c){if(d.canceled2=!0,d.reason2=c,d.canceled1)@readableStreamCancel(i,[d.reason1,d.reason2]).@then(d.cancelPromiseCapability.@resolve,d.cancelPromiseCapability.@reject);return d.cancelPromiseCapability.@promise}})\n"; // isReadableStream const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,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,v,w){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function x(f,A){if(A&&w\?.cancel){try{var B=w.cancel(A);@markPromiseAsHandled(B)}catch(q){}w=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),A)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",A);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!w.pull){x();return}if(!@isCallable(w.pull)){x(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",v);const _=@getByIdDirectPrivate(j,\"highWaterMark\");v.start({highWaterMark:!_||_<64\?64:_}),@startDirectStream.@call(v,j,w.pull,x),@putByIdDirectPrivate(j,\"reader\",{});var z=w.pull(v);if(v=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (j,f,q){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function A(w,z){if(z&&q\?.cancel){try{var x=q.cancel(z);@markPromiseAsHandled(x)}catch(_){}q=@undefined}if(w){if(@putByIdDirectPrivate(w,\"readableStreamController\",@undefined),@putByIdDirectPrivate(w,\"reader\",@undefined),z)@putByIdDirectPrivate(w,\"state\",@streamErrored),@putByIdDirectPrivate(w,\"storedError\",z);else @putByIdDirectPrivate(w,\"state\",@streamClosed);w=@undefined}}if(!q.pull){A();return}if(!@isCallable(q.pull)){A(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",f);const v=@getByIdDirectPrivate(j,\"highWaterMark\");f.start({highWaterMark:!v||v<64\?64:v}),@startDirectStream.@call(f,j,q.pull,A),@putByIdDirectPrivate(j,\"reader\",{});var B=q.pull(f);if(f=@undefined,B&&@isPromise(B))return B.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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 (_,E,c){\"use strict\";var f=!1,x=!1;try{var D=_.getReader(),F=D.readMany();if(F&&@isPromise(F))F=await F;if(F.done)return f=!0,E.end();var G=F.value.length;const q=@getByIdDirectPrivate(_,\"highWaterMark\");if(c)@startDirectStream.@call(E,_,@undefined,()=>!x&&@markPromiseAsHandled(_.cancel()));E.start({highWaterMark:q||0});for(var H=0,I=F.value,J=F.value.length;H!A&&@markPromiseAsHandled(c.cancel()));x.start({highWaterMark:K||0});for(var E=0,F=B.value,G=B.value.length;E{var j=@createFulfilledPromise({value:y,done:!1});return y=@undefined,@readableStreamClose(v),v=@undefined,j}}else if(this._pendingRead){var b=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(b,{value:@undefined,done:!0})}@readableStreamClose(v)})\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; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var B=this.@controlledReadableStream,i=@getByIdDirectPrivate(B,\"reader\");if(!i||!@isReadableStreamDefaultReader(i))return;var j=this._pendingRead;if(this._pendingRead=@undefined,j&&@isPromise(j)){var c=this.@sink.flush();if(c\?.byteLength)this._pendingRead=@getByIdDirectPrivate(B,\"readRequests\")\?.shift(),@fulfillPromise(j,{value:c,done:!1});else this._pendingRead=j}else if(@getByIdDirectPrivate(B,\"readRequests\")\?.isNotEmpty()){var c=this.@sink.flush();if(c\?.byteLength)@readableStreamFulfillReadRequest(B,c,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var i=this.@sink.flush();if(i\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:i,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var i=this.@sink.flush();if(i\?.byteLength)@readableStreamFulfillReadRequest(c,i,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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,z=[],A=!1,j=!1,E=\"\",q=@toLength(0),F=@newPromiseCapability(@Promise),G=!1;return x={start(){},write(w){if(typeof w===\"string\"){var C=@toLength(w.length);if(C>0)E+=w,A=!0,q+=C;return C}if(!w||!(@ArrayBuffer.@isView(w)||w instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const _=@toLength(w.byteLength);if(_>0)if(j=!0,E.length>0)@arrayPush(z,E,w),E=\"\";else @arrayPush(z,w);return q+=_,_},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(!A&&!j)return\"\";if(A&&!j)return E;if(j&&!A)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(z));var w=new @Bun.ArrayBufferSink;w.start({highWaterMark:q,asUint8Array:!0});for(let C of z)w.write(C);if(z.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 F,j=[],G=!1,q=!1,v=\"\",w=@toLength(0),x=@newPromiseCapability(@Promise),z=!1;return F={start(){},write(A){if(typeof A===\"string\"){var C=@toLength(A.length);if(C>0)v+=A,G=!0,w+=C;return C}if(!A||!(@ArrayBuffer.@isView(A)||A instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const E=@toLength(A.byteLength);if(E>0)if(q=!0,v.length>0)@arrayPush(j,v,A),v=\"\";else @arrayPush(j,A);return w+=E,E},flush(){return 0},end(){if(z)return\"\";return F.fulfill()},fulfill(){z=!0;const A=F.finishInternal();return @fulfillPromise(x.@promise,A),A},finishInternal(){if(!G&&!q)return\"\";if(G&&!q)return v;if(q&&!G)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(j));var A=new @Bun.ArrayBufferSink;A.start({highWaterMark:w,asUint8Array:!0});for(let C of j)A.write(C);if(j.length=0,v.length>0)A.write(v),v=\"\";return new globalThis.TextDecoder().decode(A.end())},close(){try{if(!z)z=!0,F.fulfill()}catch(A){}}},[F,x]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,b){\"use strict\";var[m,f]=@createTextStream(b),p={@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\",p),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),f})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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,d){\"use strict\";var _=[],p=@newPromiseCapability(@Promise),b=!1;function j(){return b=!0,p.@resolve.@call(@undefined,_),_}var m={start(){},write(v){return @arrayPush(_,v),v.byteLength||v.length},flush(){return 0},end(){if(b)return[];return j()},close(){if(!b)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),p})\n"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (_,p){\"use strict\";var t=[],b=@newPromiseCapability(@Promise),d=!1;function j(){return d=!0,b.@resolve.@call(@undefined,t),t}var m={start(){},write(v){return @arrayPush(t,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; @@ -1668,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 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"; +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},b=new @Bun.ArrayBufferSink;b.start(w);var D={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write.bind(b),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",D),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; // readableStreamError const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (_,c){\"use strict\";@assert(@isReadableStream(_)),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamErrored),@putByIdDirectPrivate(_,\"storedError\",c);const f=@getByIdDirectPrivate(_,\"reader\");if(!f)return;if(@isReadableStreamDefaultReader(f)){const v=@getByIdDirectPrivate(f,\"readRequests\");@putByIdDirectPrivate(f,\"readRequests\",@createFIFO());for(var n=v.shift();n;n=v.shift())@rejectPromise(n,c)}else{@assert(@isReadableStreamBYOBReader(f));const v=@getByIdDirectPrivate(f,\"readIntoRequests\");@putByIdDirectPrivate(f,\"readIntoRequests\",@createFIFO());for(var n=v.shift();n;n=v.shift())@rejectPromise(n,c)}@getByIdDirectPrivate(f,\"closedPromiseCapability\").@reject.@call(@undefined,c);const h=@getByIdDirectPrivate(f,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,_){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",_);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const h=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=h.shift();f;f=h.shift())@rejectPromise(f,_)}else{@assert(@isReadableStreamBYOBReader(n));const h=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=h.shift();f;f=h.shift())@rejectPromise(f,_)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,_);const c=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(c)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1708,7 +1708,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 283; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\"),g=@getByIdDirectPrivate(d,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (d){\"use strict\";const i=@getByIdDirectPrivate(d,\"controlledReadableStream\"),g=@getByIdDirectPrivate(i,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(d,\"strategy\").highWaterMark-@getByIdDirectPrivate(d,\"queue\").size})\n"; // readableStreamReaderGenericCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1716,7 +1716,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 133; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,h){\"use strict\";const i=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,h)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (h,c){\"use strict\";const i=@getByIdDirectPrivate(h,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,c)})\n"; // readableStreamCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,_){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const d=@getByIdDirectPrivate(i,\"state\");if(d===@streamClosed)return @Promise.@resolve();if(d===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var h=@getByIdDirectPrivate(i,\"readableStreamController\"),p=h.@cancel;if(p)return p(h,_).@then(function(){});var u=h.close;if(u)return @Promise.@resolve(h.close(_));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,h){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const _=@getByIdDirectPrivate(i,\"state\");if(_===@streamClosed)return @Promise.@resolve();if(_===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var p=@getByIdDirectPrivate(i,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,h).@then(function(){});var d=p.close;if(d)return @Promise.@resolve(p.close(h));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1732,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; @@ -1740,7 +1740,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 519; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const d=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:d,done:!1})}const f=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),f})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const f=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:f,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),d})\n"; // readableStreamDefaultControllerClose const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (i){\"use strict\";if(@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamClosed),!@getByIdDirectPrivate(i,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(i,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\",@createFIFO());for(var _=d.shift();_;_=d.shift())@fulfillPromise(_,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1764,7 +1764,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadReq const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 157; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,p,y){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:p,done:y})})\n"; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,_,y){\"use strict\";const p=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(p,{value:_,done:y})})\n"; // readableStreamDefaultControllerEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (d,D){\"use strict\";const E=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(d)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,D,!1),@readableStreamDefaultControllerCallPullIfNeeded(d);return}try{let _=1;if(@getByIdDirectPrivate(d,\"strategy\").size!==@undefined)_=@getByIdDirectPrivate(d,\"strategy\").size(D);@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),D,_)}catch(_){throw @readableStreamDefaultControllerError(d,_),_}@readableStreamDefaultControllerCallPullIfNeeded(d)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const y=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!y);const n=@getByIdDirectPrivate(y,\"state\");if(@putByIdDirectPrivate(y,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(y,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(y,\"readableStreamController\").@pull(@getByIdDirectPrivate(y,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1804,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 (_){\"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"; +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"; // readableStreamDefaultControllerCanCloseOrEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,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 (I,y){\"use strict\";var G=@getByIdDirectPrivate(I,\"bunNativeType\"),B=@getByIdDirectPrivate(I,\"bunNativePtr\"),D=@lazyStreamPrototypeMap.@get(G);if(D===@undefined){let Z=function(p){var{c:z,v:A}=this;this.c=@undefined,this.v=@undefined,P(p,z,A)},j=function(p){try{p.close()}catch(z){globalThis.reportError(z)}},F=function(p,z,A,m){m[0]=!1;var q;try{q=J(p,A,m)}catch(x){return z.error(x)}return P(q,z,A)};var X=Z,Y=j,W=F,[J,K,L,M,H,b,N]=@lazyLoad(G),O=[!1],P;P=function p(z,A,m){if(z&&@isPromise(z))return z.then(Z.bind({c:A,v:m}),(q)=>A.error(q));else if(typeof z===\"number\")if(m&&m.byteLength===z&&m.buffer===A.byobRequest\?.view\?.buffer)A.byobRequest.respondWithNewView(m);else A.byobRequest.respond(z);else if(z.constructor===@Uint8Array)A.enqueue(z);if(O[0]||z===!1)@enqueueJob(j,A),O[0]=!1};const _=H\?new FinalizationRegistry(H):null;D=class p{constructor(z,A,m){if(this.#f=z,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=A,m!==@undefined)this.start=(q)=>{q.enqueue(m)};if(_)_.register(this,z,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=K;#j(z){var A=this.#f;if(!A){z.close();return}F(A,z,z.byobRequest.view,O)}#m(z){var A=this.#f;_&&_.unregister(this.#b),b&&b(A,!1),L(A,z)}static deinit=H;static drain=N},@lazyStreamPrototypeMap.@set(G,D)}const Q=D.startSync(B,y);var U;const{drain:f,deinit:E}=D;if(f)U=f(B);if(Q===0){if(H&&B&&@enqueueJob(H,B),(U\?.byteLength\?\?0)>0)return{start(Z){Z.enqueue(U),Z.close()},type:\"bytes\"};return{start(Z){Z.close()},type:\"bytes\"}}return new D(B,Q,U)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (m,b){\"use strict\";var N=@getByIdDirectPrivate(m,\"bunNativeType\"),P=@getByIdDirectPrivate(m,\"bunNativePtr\"),q=@lazyStreamPrototypeMap.@get(N);if(q===@undefined){let E=function(I){var{c:J,v:K}=this;this.c=@undefined,this.v=@undefined,x(I,J,K)},F=function(I){try{I.close()}catch(J){globalThis.reportError(J)}},G=function(I,J,K,L){L[0]=!1;var X;try{X=Z(I,K,L)}catch(Y){return J.error(Y)}return x(X,J,K)};var W=E,D=F,A=G,[Z,j,_,O,Q,U,f]=@lazyLoad(N),p=[!1],x;x=function I(J,K,L){if(J&&@isPromise(J))return J.then(E.bind({c:K,v:L}),(X)=>K.error(X));else if(typeof J===\"number\")if(L&&L.byteLength===J&&L.buffer===K.byobRequest\?.view\?.buffer)K.byobRequest.respondWithNewView(L);else K.byobRequest.respond(J);else if(J.constructor===@Uint8Array)K.enqueue(J);if(p[0]||J===!1)@enqueueJob(F,K),p[0]=!1};const H=Q\?new FinalizationRegistry(Q):null;q=class I{constructor(J,K,L){if(this.#f=J,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=K,L!==@undefined)this.start=(X)=>{X.enqueue(L)};if(H)H.register(this,J,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=j;#j(J){var K=this.#f;if(!K){J.close();return}G(K,J,J.byobRequest.view,p)}#m(J){var K=this.#f;H&&H.unregister(this.#b),U&&U(K,!1),_(K,J)}static deinit=Q;static drain=f},@lazyStreamPrototypeMap.@set(N,q)}const y=q.startSync(P,b);var M;const{drain:B,deinit:z}=q;if(B)M=B(P);if(y===0){if(Q&&P&&@enqueueJob(Q,P),(M\?.byteLength\?\?0)>0)return{start(E){E.enqueue(M),E.close()},type:\"bytes\"};return{start(E){E.close()},type:\"bytes\"}}return new q(P,y,M)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var g=_.getReader(),p=g.readMany();async function j(q){if(q.done)return[];var f=q.value||[];while(!0){var b=await g.read();if(b.done)break;f=f.concat(b.value)}return f}if(p&&@isPromise(p))return p.@then(j);return j(p)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var _=f.getReader(),b=_.readMany();async function g(j){if(j.done)return[];var q=j.value||[];while(!0){var p=await _.read();if(p.done)break;q=q.concat(p.value)}return q}if(b&&@isPromise(b))return b.@then(g);return g(b)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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,w){\"use strict\";var _=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(j,\"underlyingSource\",@undefined);var x=@getByIdDirectPrivate(j,\"highWaterMark\");_.start(x\?{highWaterMark:x}:{});var O=@newPromiseCapability(@Promise),z=!1,q=w.pull,A=w.close,B={start(){},close(C){if(!z){if(z=!0,A)A();@fulfillPromise(O.@promise,_.end())}},end(){if(!z){if(z=!0,A)A();@fulfillPromise(O.@promise,_.end())}},flush(){return 0},write:_.write.bind(_)},v=!1;try{const C=q(B);if(C&&@isObject(C)&&@isPromise(C))return async function(D,F,G){while(!z)await G(D);return await F}(B,promise,q);return O.@promise}catch(C){return v=!0,@readableStreamError(j,C),@Promise.@reject(C)}finally{if(!v&&j)@readableStreamClose(j);B=A=_=q=j=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (j,x){\"use strict\";var z=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(j,\"underlyingSource\",@undefined);var A=@getByIdDirectPrivate(j,\"highWaterMark\");z.start(A\?{highWaterMark:A}:{});var B=@newPromiseCapability(@Promise),C=!1,D=x.pull,_=x.close,O={start(){},close(q){if(!C){if(C=!0,_)_();@fulfillPromise(B.@promise,z.end())}},end(){if(!C){if(C=!0,_)_();@fulfillPromise(B.@promise,z.end())}},flush(){return 0},write:z.write.bind(z)},F=!1;try{const q=D(O);if(q&&@isObject(q)&&@isPromise(q))return async function(v,G,w){while(!C)await w(v);return await G}(O,promise,D);return B.@promise}catch(q){return F=!0,@readableStreamError(j,q),@Promise.@reject(q)}finally{if(!F&&j)@readableStreamClose(j);O=_=z=D=j=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,f){\"use strict\";const h=@initializeTextStream.@call(_,f,@undefined);var j=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var p=await j.read();if(p.done)break}try{j.releaseLock()}catch(k){}return j=@undefined,_=@undefined,h.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,j){\"use strict\";const p=@initializeTextStream.@call(_,j,@undefined);var h=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var f=await h.read();if(f.done)break}try{h.releaseLock()}catch(k){}return h=@undefined,_=@undefined,p.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,j){\"use strict\";const k=@initializeArrayStream.@call(_,j,@undefined);j=@undefined;var p=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var q=await p.read();if(q.done)break}try{p.releaseLock()}catch(f){}return p=@undefined,@Promise.@resolve(k.@promise)}catch(f){throw f}finally{_=@undefined,p=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,p){\"use strict\";const j=@initializeArrayStream.@call(f,p,@undefined);p=@undefined;var q=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var _=await q.read();if(_.done)break}try{q.releaseLock()}catch(k){}return q=@undefined,@Promise.@resolve(j.@promise)}catch(k){throw k}finally{f=@undefined,q=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 q=globalThis.Symbol.asyncIterator,D=async function*F(j,z){var g=j.getReader(),w;try{while(!0){var G,B;const i=g.readMany();if(@isPromise(i))({done:G,value:B}=await i);else({done:G,value:B}=i);if(G)return;yield*B}}catch(i){w=i}finally{if(g.releaseLock(),!z)j.cancel(w);if(w)throw w}},x=function F(){return D(this,!1)},k=function F({preventCancel:j=!1}={preventCancel:!1}){return D(this,j)};return @Object.@defineProperty(h,q,{value:x}),@Object.@defineProperty(h,\"values\",{value:k}),h})\n"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (i){\"use strict\";var h=globalThis.Symbol.asyncIterator,j=async function*B(g,D){var q=g.getReader(),F;try{while(!0){var x,k;const G=q.readMany();if(@isPromise(G))({done:x,value:k}=await G);else({done:x,value:k}=G);if(x)return;yield*k}}catch(G){F=G}finally{if(q.releaseLock(),!D)g.cancel(F);if(F)throw F}},w=function B(){return j(this,!1)},z=function B({preventCancel:g=!1}={preventCancel:!1}){return j(this,g)};return @Object.@defineProperty(i,h,{value:w}),@Object.@defineProperty(i,\"values\",{value:z}),i})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1986,7 +1986,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const u=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(u){const f=u.@call(n,\"string\");if(typeof f===\"string\")switch(@argumentCount()){case 1:return new @Buffer(f);case 2:return new @Buffer(f,@argument(1));default:return new @Buffer(f,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2020,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 O=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!O)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const A=@getByIdDirectPrivate(O,\"state\");if(@putByIdDirectPrivate(O,\"disturbed\",!0),A===@streamClosed)return{value:[],size:0,done:!0};else if(A===@streamErrored)throw @getByIdDirectPrivate(O,\"storedError\");var H=@getByIdDirectPrivate(O,\"readableStreamController\"),C=@getByIdDirectPrivate(H,\"queue\");if(!C)return H.@pull(H).@then(function({done:j,value:J}){return j\?{done:!0,value:[],size:0}:{value:[J],size:1,done:!1}});const D=C.content;var d=C.size,B=D.toArray(!1),Q=B.length;if(Q>0){var I=@newArrayWithSize(Q);if(@isReadableByteStreamController(H)){{const j=B[0];if(!(@ArrayBuffer.@isView(j)||j instanceof @ArrayBuffer))@putByValDirect(I,0,new @Uint8Array(j.buffer,j.byteOffset,j.byteLength));else @putByValDirect(I,0,j)}for(var _=1;_{if(j.done)return{value:[],size:0,done:!0};var J=@getByIdDirectPrivate(O,\"readableStreamController\"),K=@getByIdDirectPrivate(J,\"queue\"),N=[j.value].concat(K.content.toArray(!1)),k=N.length;if(@isReadableByteStreamController(J))for(var G=0;G0){var w=@newArrayWithSize(O);if(@isReadableByteStreamController(H)){{const I=G[0];if(!(@ArrayBuffer.@isView(I)||I instanceof @ArrayBuffer))@putByValDirect(w,0,new @Uint8Array(I.buffer,I.byteOffset,I.byteLength));else @putByValDirect(w,0,I)}for(var d=1;d{if(I.done)return{value:[],size:0,done:!0};var F=@getByIdDirectPrivate(_,\"readableStreamController\"),Q=@getByIdDirectPrivate(F,\"queue\"),S=[I.value].concat(Q.content.toArray(!1)),j=S.length;if(@isReadableByteStreamController(F))for(var T=0;T0}shift(){var{_head:E,_tail:z,_list:v,_capacityMask:F}=this;if(E===z)return @undefined;var g=v[E];if(@putByValDirect(v,E,@undefined),E=this._head=E+1&F,E<2&&z>1e4&&z<=v.length>>>2)this._shrinkArray();return g}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(E){var z=this._tail;if(@putByValDirect(this._list,z,E),this._tail=z+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(E){var z=this._list,v=@toLength(z.length);if(E||this._head>this._tail){var F=@toLength(this._head),g=@toLength(this._tail),A=@toLength(v-F+g),x=@newArrayWithSize(A),w=0;for(var G=F;G>>=1,this._capacityMask>>>=1}}return new k})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var b=@Array.prototype.slice;class z{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: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"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2150,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; @@ -2174,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 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"; +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"; // extractHighWaterMark const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2206,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 (n,c,p){\"use strict\";if(n===@undefined||n===null)return c;if(!@isObject(n))@throwTypeError(p);return n})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2224,7 +2224,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (z){\"use strict\";var H=@Loader,I=@createFIFO(),B=z;while(B){var w=H.registry.@get(B);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(B),w=H.registry.@get(B);var T=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),J=H.parseModule(B,T),U=w.module;if(J&&@isPromise(J)){var V=@getPromiseInternalField(J,@promiseFieldReactionsOrResult),W=@getPromiseInternalField(J,@promiseFieldFlags),L=W&@promiseStateMask;if(L===@promiseStatePending||V&&@isPromise(V))@throwTypeError(`require() async module \"${B}\" is unsupported. use \"await import()\" instead.`);else if(L===@promiseStateRejected){if(!V\?.message)@throwTypeError(`${V+\"\"\?V:\"An error occurred\"} occurred while parsing module \\\"${B}\\\"`);throw V}w.module=U=V}else if(J&&!U)w.module=U=J;@setStateToMax(w,@ModuleLink);var D=U.dependenciesMap,_=H.requestedModules(U),Q=@newArrayWithSize(_.length);for(var F=0,X=_.length;F=@ModuleLink)B=I.shift()}var Z=H.linkAndEvaluateModule(z,@undefined);if(Z&&@isPromise(Z))@throwTypeError(`require() async module \\\"${z}\\\" is unsupported. use \"await import()\" instead.`);return H.registry.@get(z)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (J){\"use strict\";var _=@Loader,D=@createFIFO(),w=J;while(w){var x=_.registry.@get(w);if((x\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(w),x=_.registry.@get(w);var I=@getPromiseInternalField(x.fetch,@promiseFieldReactionsOrResult),z=_.parseModule(w,I),B=x.module;if(z&&@isPromise(z)){var F=@getPromiseInternalField(z,@promiseFieldReactionsOrResult),Z=@getPromiseInternalField(z,@promiseFieldFlags),G=Z&@promiseStateMask;if(G===@promiseStatePending||F&&@isPromise(F))@throwTypeError(`require() async module \"${w}\" is unsupported. use \"await import()\" instead.`);else if(G===@promiseStateRejected){if(!F\?.message)@throwTypeError(`${F+\"\"\?F:\"An error occurred\"} occurred while parsing module \\\"${w}\\\"`);throw F}x.module=B=F}else if(z&&!B)x.module=B=z;@setStateToMax(x,@ModuleLink);var H=B.dependenciesMap,L=_.requestedModules(B),Q=@newArrayWithSize(L.length);for(var T=0,U=L.length;T=@ModuleLink)w=D.shift()}var Y=_.linkAndEvaluateModule(J,@undefined);if(Y&&@isPromise(Y))@throwTypeError(`require() async module \\\"${J}\\\" is unsupported. use \"await import()\" instead.`);return _.registry.@get(J)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var _=@Loader.registry.@get(a);if(!_||!_.evaluated)_=@loadCJS2ESM(a);if(!_||!_.evaluated||!_.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var c=@Loader.getModuleNamespaceObject(_.module);if(c[@commonJSSymbol]===0)return;return c})\n"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var g=@requireMap.@get(_);const n=_.substring(_.length-5);if(g)return g.exports;if(n===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,q,!0)),q}else if(n===\".node\"){const b=@createCommonJSModule(_,{},!0);return process.dlopen(b,_),@requireMap.@set(_,b),b.exports}else if(n===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),q=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,q,!0)),q}else{var q=@requireESM(_);const k=@requireMap.@get(_);if(k)return k.exports;var v=q\?.default;if(v\?.[@commonJSSymbol]===0)q=v;return @requireMap.@set(_,@createCommonJSModule(_,q,!0)),q}})\n"; +const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var b=@requireMap.@get(_);const g=_.substring(_.length-5);if(b)return b.exports;if(g===\".json\"){var q=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),j=JSON.parse(q.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,j,!0)),j}else if(g===\".node\"){const n=@createCommonJSModule(_,{},!0);return process.dlopen(n,_),@requireMap.@set(_,n),n.exports}else if(g===\".toml\"){var q=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),j=@Bun.TOML.parse(q.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,j,!0)),j}else{var j=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var k=j\?.default;if(k\?.[@commonJSSymbol]===0)j=k;return @requireMap.@set(_,@createCommonJSModule(_,j,!0)),j}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,L={};return new Proxy(L,{get(f,h){const t=@requireMap.@get(h);if(t)return t;const u=@Loader.registry.@get(h);if(u\?.evaluated){const b=@Loader.getModuleNamespaceObject(u.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(h,c,!0);return @requireMap.@set(h,g),g}return L[h]},set(f,h,t){return @requireMap.@set(h,t),!0},has(f,h){return @requireMap.@has(h)||@Loader.registry.@has(h)},deleteProperty(f,h){return _.@delete(h),@requireMap.@delete(h),@Loader.registry.@delete(h),!0},ownKeys(f){var h=[...@requireMap.@keys()];const t=[...@Loader.registry.@keys()];for(let u of t)if(!h.includes(u))@arrayPush(h,u);return h},getPrototypeOf(f){return null},getOwnPropertyDescriptor(f,h){if(@requireMap.@has(h)||@Loader.registry.@has(h))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var h=new Map,u={};return new Proxy(u,{get(L,b){const _=@requireMap.@get(b);if(_)return _;const f=@Loader.registry.@get(b);if(f\?.evaluated){const c=@Loader.getModuleNamespaceObject(f.module),t=c[@commonJSSymbol]===0||c.default\?.[@commonJSSymbol]\?c.default:c,g=@createCommonJSModule(b,t,!0);return @requireMap.@set(b,g),g}return u[b]},set(L,b,_){return @requireMap.@set(b,_),!0},has(L,b){return @requireMap.@has(b)||@Loader.registry.@has(b)},deleteProperty(L,b){return h.@delete(b),@requireMap.@delete(b),@Loader.registry.@delete(b),!0},ownKeys(L){var b=[...@requireMap.@keys()];const _=[...@Loader.registry.@keys()];for(let f of _)if(!b.includes(f))@arrayPush(b,f);return b},getPrototypeOf(L){return null},getOwnPropertyDescriptor(L,b){if(@requireMap.@has(b)||@Loader.registry.@has(b))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2432,7 +2432,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,I=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!I){const _=@getByIdDirectPrivate(m,\"size\"),b=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,b!==@undefined\?b:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(I){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,_);if(b)@createReadableStreamController(this,b,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const m=_.type===\"direct\",v=!!_.@lazy,B=m||v;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!B){const I=@getByIdDirectPrivate(f,\"size\"),b=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,I,b!==@undefined\?b:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(m)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(B){const I=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,I);if(b)@createReadableStreamController(this,b,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2448,7 +2448,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKi const JSC::ImplementationVisibility s_readableStreamReadableStreamToTextCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToTextCodeLength = 171; static const JSC::Intrinsic s_readableStreamReadableStreamToTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToTextCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToTextDirect(_,p);return @readableStreamIntoText(_)})\n"; +const char* const s_readableStreamReadableStreamToTextCode = "(function (p){\"use strict\";var _=@getByIdDirectPrivate(p,\"underlyingSource\");if(_!==@undefined)return @readableStreamToTextDirect(p,_);return @readableStreamIntoText(p)})\n"; // readableStreamToArrayBuffer const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2472,7 +2472,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToBlobCodeConstructorKi const JSC::ImplementationVisibility s_readableStreamReadableStreamToBlobCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToBlobCodeLength = 108; static const JSC::Intrinsic s_readableStreamReadableStreamToBlobCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToBlobCode = "(function (B){\"use strict\";return @Promise.resolve(@Bun.readableStreamToArray(B)).@then((n)=>new Blob(n))})\n"; +const char* const s_readableStreamReadableStreamToBlobCode = "(function (n){\"use strict\";return @Promise.resolve(@Bun.readableStreamToArray(n)).@then((B)=>new Blob(B))})\n"; // consumeReadableStream const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2480,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 (_,F,D){\"use strict\";const j=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var G=globalThis[j];if(!G)G=globalThis[j]=[];var k=G[F];if(k===@undefined){var[H,q,I,w,J,x]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](F);k=class A{handleError;handleClosed;processResult;constructor(L,B){this.#_=B,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,w(L),x(L)}_handleError(L){if(this.#$)return;this.#$=!0;var B=this.#_;this.#_=0,q(B,L),x(B)}#_;#$=!1;#F;_handleReadMany({value:L,done:B,size:N}){if(B){this.handleClosed();return}if(this.#$)return;I(this.#_,L,B,N)}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 N=@getPromiseInternalField(L,@promiseFieldReactionsOrResult);if(N)L=N}}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 K=F+1;if(G.length{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(_)},(d)=>{if(@getByIdDirectPrivate(v,\"state\")===@streamReadable)@readableByteStreamControllerError(_,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (_,p,v){\"use strict\";if(!@isReadableStream(_))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(_,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",_),@putByIdDirectPrivate(this,\"underlyingByteSource\",p),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let b=@toNumber(v);if(@isNaN(b)||b<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",b);let R=p.autoAllocateChunkSize;if(R!==@undefined){if(R=@toNumber(R),R<=0||R===@Infinity||R===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",R),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const f=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(f,\"underlyingByteSource\"),\"start\",[f]).@then(()=>{@putByIdDirectPrivate(f,\"started\",1),@assert(!@getByIdDirectPrivate(f,\"pulling\")),@assert(!@getByIdDirectPrivate(f,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(f)},(d)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(f,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2676,7 +2676,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var _=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=_.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2692,7 +2692,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength = 569; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode = "(function (d){\"use strict\";if(@assert(!@getByIdDirectPrivate(d,\"closeRequested\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(d,\"controlledReadableStream\"),\"state\")===@streamReadable),@getByIdDirectPrivate(d,\"queue\").size>0){@putByIdDirectPrivate(d,\"closeRequested\",!0);return}var a=@getByIdDirectPrivate(d,\"pendingPullIntos\")\?.peek();if(a){if(a.bytesFilled>0){const u=@makeTypeError(\"Close requested while there remain pending bytes\");throw @readableByteStreamControllerError(d,u),u}}@readableStreamClose(@getByIdDirectPrivate(d,\"controlledReadableStream\"))})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode = "(function (a){\"use strict\";if(@assert(!@getByIdDirectPrivate(a,\"closeRequested\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"state\")===@streamReadable),@getByIdDirectPrivate(a,\"queue\").size>0){@putByIdDirectPrivate(a,\"closeRequested\",!0);return}var d=@getByIdDirectPrivate(a,\"pendingPullIntos\")\?.peek();if(d){if(d.bytesFilled>0){const u=@makeTypeError(\"Close requested while there remain pending bytes\");throw @readableByteStreamControllerError(a,u),u}}@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"))})\n"; // readableByteStreamControllerClearPendingPullIntos const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2708,7 +2708,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 272; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const d=@getByIdDirectPrivate(u,\"controlledReadableStream\"),_=@getByIdDirectPrivate(d,\"state\");if(_===@streamErrored)return null;if(_===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const _=@getByIdDirectPrivate(u,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; // readableStreamHasBYOBReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2716,7 +2716,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBRea const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 125; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (u){\"use strict\";const n=@getByIdDirectPrivate(u,\"reader\");return n!==@undefined&&@isReadableStreamBYOBReader(n)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (n){\"use strict\";const u=@getByIdDirectPrivate(n,\"reader\");return u!==@undefined&&@isReadableStreamBYOBReader(u)})\n"; // readableStreamHasDefaultReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2740,7 +2740,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (d){\"use strict\";const h=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(h)),@getByIdDirectPrivate(d,\"queue\").content\?.isNotEmpty()){const P=@getByIdDirectPrivate(d,\"queue\").content.shift();@getByIdDirectPrivate(d,\"queue\").size-=P.byteLength,@readableByteStreamControllerHandleQueueDrain(d);let R;try{R=new @Uint8Array(P.buffer,P.byteOffset,P.byteLength)}catch(_){return @Promise.@reject(_)}return @createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(d,\"autoAllocateChunkSize\")!==@undefined){let P;try{P=@createUninitializedArrayBuffer(@getByIdDirectPrivate(d,\"autoAllocateChunkSize\"))}catch(_){return @Promise.@reject(_)}const R={buffer:P,byteOffset:0,byteLength:@getByIdDirectPrivate(d,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(d,\"pendingPullIntos\").push(R)}const F=@readableStreamAddReadRequest(h);return @readableByteStreamControllerCallPullIfNeeded(d),F})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const F=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(F)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const R=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=R.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let d;try{d=new @Uint8Array(R.buffer,R.byteOffset,R.byteLength)}catch(h){return @Promise.@reject(h)}return @createFulfilledPromise({value:d,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let R;try{R=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(h){return @Promise.@reject(h)}const d={buffer:R,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(d)}const P=@readableStreamAddReadRequest(F);return @readableByteStreamControllerCallPullIfNeeded(_),P})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 619; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const P=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(P,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const b=@getByIdDirectPrivate(P,\"reader\");if(b&&(@getByIdDirectPrivate(b,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(b,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(P)&&@getByIdDirectPrivate(@getByIdDirectPrivate(P,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (b){\"use strict\";const u=@getByIdDirectPrivate(b,\"controlledReadableStream\");if(@getByIdDirectPrivate(u,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(b,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(b,\"started\")>0))return!1;const P=@getByIdDirectPrivate(u,\"reader\");if(P&&(@getByIdDirectPrivate(P,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(P,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(u)&&@getByIdDirectPrivate(@getByIdDirectPrivate(u,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(b)>0)return!0;return!1})\n"; // readableByteStreamControllerCallPullIfNeeded const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2756,7 +2756,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength = 670; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode = "(function (i){\"use strict\";if(!@readableByteStreamControllerShouldCallPull(i))return;if(@getByIdDirectPrivate(i,\"pulling\")){@putByIdDirectPrivate(i,\"pullAgain\",!0);return}@assert(!@getByIdDirectPrivate(i,\"pullAgain\")),@putByIdDirectPrivate(i,\"pulling\",!0),@promiseInvokeOrNoop(@getByIdDirectPrivate(i,\"underlyingByteSource\"),\"pull\",[i]).@then(()=>{if(@putByIdDirectPrivate(i,\"pulling\",!1),@getByIdDirectPrivate(i,\"pullAgain\"))@putByIdDirectPrivate(i,\"pullAgain\",!1),@readableByteStreamControllerCallPullIfNeeded(i)},(_)=>{if(@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"controlledReadableStream\"),\"state\")===@streamReadable)@readableByteStreamControllerError(i,_)})})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode = "(function (_){\"use strict\";if(!@readableByteStreamControllerShouldCallPull(_))return;if(@getByIdDirectPrivate(_,\"pulling\")){@putByIdDirectPrivate(_,\"pullAgain\",!0);return}@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@putByIdDirectPrivate(_,\"pulling\",!0),@promiseInvokeOrNoop(@getByIdDirectPrivate(_,\"underlyingByteSource\"),\"pull\",[_]).@then(()=>{if(@putByIdDirectPrivate(_,\"pulling\",!1),@getByIdDirectPrivate(_,\"pullAgain\"))@putByIdDirectPrivate(_,\"pullAgain\",!1),@readableByteStreamControllerCallPullIfNeeded(_)},(i)=>{if(@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"controlledReadableStream\"),\"state\")===@streamReadable)@readableByteStreamControllerError(_,i)})})\n"; // transferBufferToCurrentRealm const JSC::ConstructAbility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2796,7 +2796,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 417; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (u,a){\"use strict\";@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty());let d=@getByIdDirectPrivate(u,\"pendingPullIntos\").peek();if(d.byteOffset+d.bytesFilled!==a.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(d.byteLength!==a.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");d.buffer=a.buffer,@readableByteStreamControllerRespondInternal(u,a.byteLength)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (a,d){\"use strict\";@assert(@getByIdDirectPrivate(a,\"pendingPullIntos\").isNotEmpty());let u=@getByIdDirectPrivate(a,\"pendingPullIntos\").peek();if(u.byteOffset+u.bytesFilled!==d.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(u.byteLength!==d.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");u.buffer=d.buffer,@readableByteStreamControllerRespondInternal(a,d.byteLength)})\n"; // readableByteStreamControllerRespond const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2820,7 +2820,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,R,_){\"use strict\";if(_.bytesFilled+R>_.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 (w,f,_){\"use strict\";if(_.bytesFilled+f>_.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===_),@readableByteStreamControllerInvalidateBYOBRequest(w),_.bytesFilled+=f,_.bytesFilled<_.elementSize)return;@readableByteStreamControllerShiftPendingDescriptor(w);const g=_.bytesFilled%_.elementSize;if(g>0){const R=_.byteOffset+_.bytesFilled,h=@cloneArrayBuffer(_.buffer,R-g,g);@readableByteStreamControllerEnqueueChunk(w,h,0,h.byteLength)}_.buffer=@transferBufferToCurrentRealm(_.buffer),_.bytesFilled-=g,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),_),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2844,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 (_,q){\"use strict\";const j=q.bytesFilled-q.bytesFilled%q.elementSize,w=@getByIdDirectPrivate(_,\"queue\").sizej)G=z-q.bytesFilled,H=!0;while(G>0){let v=@getByIdDirectPrivate(_,\"queue\").content.peek();const J=G0),@assert(q.bytesFilledw)k=z-v.bytesFilled,E=!0;while(k>0){let G=@getByIdDirectPrivate(j,\"queue\").content.peek();const H=k0),@assert(v.bytesFilled0){if(@readableByteStreamControllerFillDescriptorFromQueue(d,L)){const R=@readableByteStreamControllerConvertDescriptor(L);return @readableByteStreamControllerHandleQueueDrain(d),@createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(d,\"closeRequested\")){const R=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(d,R),@Promise.@reject(R)}}L.buffer=@transferBufferToCurrentRealm(L.buffer),@getByIdDirectPrivate(d,\"pendingPullIntos\").push(L);const N=@readableStreamAddReadIntoRequest(E);return @readableByteStreamControllerCallPullIfNeeded(d),N})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (d,k){\"use strict\";const A=@getByIdDirectPrivate(d,\"controlledReadableStream\");let E=1;if(k.BYTES_PER_ELEMENT!==@undefined)E=k.BYTES_PER_ELEMENT;const L=k.constructor,N={buffer:k.buffer,byteOffset:k.byteOffset,byteLength:k.byteLength,bytesFilled:0,elementSize:E,ctor:L,readerType:\"byob\"};var R=@getByIdDirectPrivate(d,\"pendingPullIntos\");if(R\?.isNotEmpty())return N.buffer=@transferBufferToCurrentRealm(N.buffer),R.push(N),@readableStreamAddReadIntoRequest(A);if(@getByIdDirectPrivate(A,\"state\")===@streamClosed){const b=new L(N.buffer,N.byteOffset,0);return @createFulfilledPromise({value:b,done:!0})}if(@getByIdDirectPrivate(d,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(d,N)){const b=@readableByteStreamControllerConvertDescriptor(N);return @readableByteStreamControllerHandleQueueDrain(d),@createFulfilledPromise({value:b,done:!1})}if(@getByIdDirectPrivate(d,\"closeRequested\")){const b=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(d,b),@Promise.@reject(b)}}N.buffer=@transferBufferToCurrentRealm(N.buffer),@getByIdDirectPrivate(d,\"pendingPullIntos\").push(N);const _=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(d),_})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2952,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{#H;#$;#j;#w;#A;#B=!1;#F=null;#G=\"\";#J=\"\";#K=\"\";#L=!0;#M=0;#O=0;#Q=0;#U=null;static#V(L){L.#z()}static#W(L,K){const M=L.data,O=M.#K\?`Last-Event-ID: ${M.#K}\\r\\n`:\"\",w=`GET ${K.pathname}${K.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${O}\\r\\n`,Q=L.write(w);if(Q!==w.length)M.#J=w.substring(Q)}static#X(L,K,M){for(;;){if(M>=K.length)return;let O=-1,w=K.indexOf(\"\\r\\n\",M);const Q=w+2;if(w>0)if(L.#M===0){const X=parseInt(K.substring(M,w),16);if(X===0){L.#$=2,L.#F\?.end();return}O=Q+X}else O=K.length;else{if(L.#G.length===0){L.#G+=K.substring(M);return}O=K.length}let U=K.substring(Q,O);M=O+2;let V=0,W=U.indexOf(\"\\n\\n\");if(W==-1){L.#G+=K.substring(Q);return}if(L.#G.length)L.#G+=U,U=L.#G,L.#G=\"\";let A=!0;while(A){const X=U.substring(V,W);let Y,Z=\"\",G,z=0,H=-1;for(;;){let F=X.indexOf(\"\\n\",z);if(F===-1){if(z>=X.length)break;F=X.length}const J=X.substring(z,F);if(J.startsWith(\"data:\"))if(Z.length)Z+=`\\n${J.substring(5).trim()}`;else Z=J.substring(5).trim();else if(J.startsWith(\"event:\"))Y=J.substring(6).trim();else if(J.startsWith(\"id:\"))G=J.substring(3).trim();else if(J.startsWith(\"retry:\")){if(H=parseInt(J.substring(6).trim(),10),@isNaN(H))H=-1}z=F+1}if(L.#K=G||\"\",H>=0)L.#Q=H;if(Z||G||Y)L.dispatchEvent(new MessageEvent(Y||\"message\",{data:Z||\"\",origin:L.#H.origin,source:L,lastEventId:G}));if(U.length===W+2){A=!1;break}const B=U.indexOf(\"\\n\\n\",W+1);if(B===-1)break;V=W,W=B}}}static#Y={open(L){const K=L.data;if(K.#F=L,!K.#B)j.#W(L,K.#H)},handshake(L,K,M){const O=L.data;if(K)j.#W(L,O.#H);else O.#$=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:M})),L.end()},data(L,K){const M=L.data;switch(M.#$){case 0:{let O=K.toString();const w=O.indexOf(\"\\r\\n\\r\\n\");if(w===-1){M.#G+=O;return}if(M.#G.length)M.#G+=O,O=M.#G,M.#G=\"\";const Q=O.substring(0,w),U=Q.indexOf(\"\\r\\n\");if(U===-1){M.#$=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),L.end();return}const V=Q.substring(0,U);if(V!==\"HTTP/1.1 200 OK\"){M.#$=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(V)})),L.end();return}let W=U+1,A=!1,X=-1;for(;;){let Z=Q.indexOf(\"\\r\\n\",W);if(Z===-1){if(W>=Q.length){if(!A)M.#$=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),L.end();return}Z=Q.length}const G=Q.substring(W+1,Z),z=G.indexOf(\":\"),H=G.substring(0,z),B=H.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(W=Z+1,B)if(G.endsWith(\" text/event-stream\"))A=!0;else{M.#$=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),L.end();return}else if(H.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(X=parseInt(G.substring(z+1).trim(),10),@isNaN(X)||X<=0){M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),L.end();return}if(A)break}else if(H.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(G.substring(z+1).trim()!==\"chunked\"){M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),L.end();return}if(X=0,A)break}}M.#M=X,M.#$=1,M.dispatchEvent(new Event(\"open\"));const Y=O.substring(w+4);if(j.#X(M,Y,0),M.#M>0){if(M.#O+=Y.length,M.#O>=M.#M)M.#$=2,L.end()}return}case 1:if(j.#X(M,K.toString(),2),M.#M>0){if(M.#O+=K.byteLength,M.#O>=M.#M)M.#$=2,L.end()}return;default:break}},drain(L){const K=L.data;if(K.#$===0){const M=K.#G;if(M.length){const O=L.write(M);if(O!==M.length)L.data.#J=M.substring(O);else L.data.#J=\"\"}}},close:j.#Z,end(L){j.#Z(L).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(L){j.#Z(L).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#Z(L){const K=L.data;if(K.#F=null,K.#O=0,K.#$=2,K.#L){if(K.#U)clearTimeout(K.#U);K.#U=setTimeout(j.#V,K.#Q,K)}return K}constructor(L,K=@undefined){super();const M=new URL(L);this.#B=M.protocol===\"https:\",this.#H=M,this.#$=2,process.nextTick(j.#V,this)}ref(){this.#U\?.ref(),this.#F\?.ref()}unref(){this.#U\?.unref(),this.#F\?.unref()}#z(){if(this.#$!==2)return;const L=this.#H,K=this.#B;this.#$=0,@Bun.connect({data:this,socket:j.#Y,hostname:L.hostname,port:parseInt(L.port||(K\?\"443\":\"80\"),10),tls:K\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((M)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:M})),this.#L){if(this.#U)this.#U.unref\?.();this.#U=setTimeout(j.#V,1000,this)}})}get url(){return this.#H.href}get readyState(){return this.#$}close(){this.#L=!1,this.#$=2,this.#F\?.unref(),this.#F\?.end()}get onopen(){return this.#A}get onerror(){return this.#j}get onmessage(){return this.#w}set onopen(L){if(this.#A)super.removeEventListener(\"close\",this.#A);super.addEventListener(\"open\",L),this.#A=L}set onerror(L){if(this.#j)super.removeEventListener(\"error\",this.#j);super.addEventListener(\"error\",L),this.#j=L}set onmessage(L){if(this.#w)super.removeEventListener(\"message\",this.#w);super.addEventListener(\"message\",L),this.#w=L}}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{#$;#W;#U;#K;#L;#j=!1;#X=null;#Y=\"\";#M=\"\";#w=\"\";#A=!0;#Z=0;#z=0;#O=0;#B=null;static#F(K){K.#J()}static#Q(K,L){const M=K.data,O=M.#w\?`Last-Event-ID: ${M.#w}\\r\\n`:\"\",w=`GET ${L.pathname}${L.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${O}\\r\\n`,Q=K.write(w);if(Q!==w.length)M.#M=w.substring(Q)}static#V(K,L,M){for(;;){if(M>=L.length)return;let O=-1,w=L.indexOf(\"\\r\\n\",M);const Q=w+2;if(w>0)if(K.#Z===0){const X=parseInt(L.substring(M,w),16);if(X===0){K.#W=2,K.#X\?.end();return}O=Q+X}else O=L.length;else{if(K.#Y.length===0){K.#Y+=L.substring(M);return}O=L.length}let U=L.substring(Q,O);M=O+2;let V=0,W=U.indexOf(\"\\n\\n\");if(W==-1){K.#Y+=L.substring(Q);return}if(K.#Y.length)K.#Y+=U,U=K.#Y,K.#Y=\"\";let A=!0;while(A){const X=U.substring(V,W);let Y,Z=\"\",z,B=0,H=-1;for(;;){let G=X.indexOf(\"\\n\",B);if(G===-1){if(B>=X.length)break;G=X.length}const J=X.substring(B,G);if(J.startsWith(\"data:\"))if(Z.length)Z+=`\\n${J.substring(5).trim()}`;else Z=J.substring(5).trim();else if(J.startsWith(\"event:\"))Y=J.substring(6).trim();else if(J.startsWith(\"id:\"))z=J.substring(3).trim();else if(J.startsWith(\"retry:\")){if(H=parseInt(J.substring(6).trim(),10),@isNaN(H))H=-1}B=G+1}if(K.#w=z||\"\",H>=0)K.#O=H;if(Z||z||Y)K.dispatchEvent(new MessageEvent(Y||\"message\",{data:Z||\"\",origin:K.#$.origin,source:K,lastEventId:z}));if(U.length===W+2){A=!1;break}const F=U.indexOf(\"\\n\\n\",W+1);if(F===-1)break;V=W,W=F}}}static#H={open(K){const L=K.data;if(L.#X=K,!L.#j)j.#Q(K,L.#$)},handshake(K,L,M){const O=K.data;if(L)j.#Q(K,O.#$);else O.#W=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:M})),K.end()},data(K,L){const M=K.data;switch(M.#W){case 0:{let O=L.toString();const w=O.indexOf(\"\\r\\n\\r\\n\");if(w===-1){M.#Y+=O;return}if(M.#Y.length)M.#Y+=O,O=M.#Y,M.#Y=\"\";const Q=O.substring(0,w),U=Q.indexOf(\"\\r\\n\");if(U===-1){M.#W=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),K.end();return}const V=Q.substring(0,U);if(V!==\"HTTP/1.1 200 OK\"){M.#W=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(V)})),K.end();return}let W=U+1,A=!1,X=-1;for(;;){let Z=Q.indexOf(\"\\r\\n\",W);if(Z===-1){if(W>=Q.length){if(!A)M.#W=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),K.end();return}Z=Q.length}const z=Q.substring(W+1,Z),B=z.indexOf(\":\"),H=z.substring(0,B),F=H.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(W=Z+1,F)if(z.endsWith(\" text/event-stream\"))A=!0;else{M.#W=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),K.end();return}else if(H.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(X=parseInt(z.substring(B+1).trim(),10),@isNaN(X)||X<=0){M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),K.end();return}if(A)break}else if(H.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(z.substring(B+1).trim()!==\"chunked\"){M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),K.end();return}if(X=0,A)break}}M.#Z=X,M.#W=1,M.dispatchEvent(new Event(\"open\"));const Y=O.substring(w+4);if(j.#V(M,Y,0),M.#Z>0){if(M.#z+=Y.length,M.#z>=M.#Z)M.#W=2,K.end()}return}case 1:if(j.#V(M,L.toString(),2),M.#Z>0){if(M.#z+=L.byteLength,M.#z>=M.#Z)M.#W=2,K.end()}return;default:break}},drain(K){const L=K.data;if(L.#W===0){const M=L.#Y;if(M.length){const O=K.write(M);if(O!==M.length)K.data.#M=M.substring(O);else K.data.#M=\"\"}}},close:j.#G,end(K){j.#G(K).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(K){j.#G(K).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#G(K){const L=K.data;if(L.#X=null,L.#z=0,L.#W=2,L.#A){if(L.#B)clearTimeout(L.#B);L.#B=setTimeout(j.#F,L.#O,L)}return L}constructor(K,L=@undefined){super();const M=new URL(K);this.#j=M.protocol===\"https:\",this.#$=M,this.#W=2,process.nextTick(j.#F,this)}ref(){this.#B\?.ref(),this.#X\?.ref()}unref(){this.#B\?.unref(),this.#X\?.unref()}#J(){if(this.#W!==2)return;const K=this.#$,L=this.#j;this.#W=0,@Bun.connect({data:this,socket:j.#H,hostname:K.hostname,port:parseInt(K.port||(L\?\"443\":\"80\"),10),tls:L\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((M)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:M})),this.#A){if(this.#B)this.#B.unref\?.();this.#B=setTimeout(j.#F,1000,this)}})}get url(){return this.#$.href}get readyState(){return this.#W}close(){this.#A=!1,this.#W=2,this.#X\?.unref(),this.#X\?.end()}get onopen(){return this.#L}get onerror(){return this.#U}get onmessage(){return this.#K}set onopen(K){if(this.#L)super.removeEventListener(\"close\",this.#L);super.addEventListener(\"open\",K),this.#L=K}set onerror(K){if(this.#U)super.removeEventListener(\"error\",this.#U);super.addEventListener(\"error\",K),this.#U=K}set onmessage(K){if(this.#K)super.removeEventListener(\"message\",this.#K);super.addEventListener(\"message\",K),this.#K=K}}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) \ -- cgit v1.2.3 From 6cae6ebafeac4ec2698dc746838b91b2f079f65f Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 1 Jul 2023 20:02:50 -0700 Subject: Make `buffer.toString("base64")` 4x faster (#3486) * Add libbase64 * Add bench * Update licensing.md --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- .gitmodules | 8 +++++++- Dockerfile | 22 ++++++++++++++++++++++ Makefile | 10 ++++++++-- bench/snippets/base64-buffer-to-string.mjs | 14 ++++++++++++++ docs/project/licensing.md | 5 +++++ src/base64/base64.zig | 20 +++++++++++++++++++- src/bun.js/node/types.zig | 4 ++-- src/deps/base64 | 1 + 8 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 bench/snippets/base64-buffer-to-string.mjs create mode 160000 src/deps/base64 diff --git a/.gitmodules b/.gitmodules index 9284d53f1..e8b448aa4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -68,4 +68,10 @@ fetchRecurseSubmodules = false [submodule "src/deps/zstd"] path = src/deps/zstd url = https://github.com/facebook/zstd.git - ignore = dirty \ No newline at end of file + ignore = dirty +[submodule "src/deps/base64"] + path = src/deps/base64 + url = https://github.com/aklomp/base64.git + ignore = dirty + depth = 1 + shallow = true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f50ada2d8..5f66a5e04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -295,6 +295,27 @@ WORKDIR $BUN_DIR RUN cd $BUN_DIR && \ make uws && rm -rf src/deps/uws Makefile +FROM bun-base as base64 + +ARG DEBIAN_FRONTEND +ARG GITHUB_WORKSPACE +ARG ZIG_PATH +# Directory extracts to "bun-webkit" +ARG WEBKIT_DIR +ARG BUN_RELEASE_DIR +ARG BUN_DEPS_OUT_DIR +ARG BUN_DIR +ARG CPU_TARGET +ENV CPU_TARGET=${CPU_TARGET} + +COPY Makefile ${BUN_DIR}/Makefile +COPY src/deps/base64 ${BUN_DIR}/src/deps/base64 + +WORKDIR $BUN_DIR + +RUN cd $BUN_DIR && \ + make base64 && rm -rf src/deps/base64 Makefile + FROM bun-base as picohttp ARG DEBIAN_FRONTEND @@ -556,6 +577,7 @@ ENV JSC_BASE_DIR=${WEBKIT_DIR} ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib COPY --from=zlib ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/ +COPY --from=base64 ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/ COPY --from=libarchive ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/ COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/ COPY --from=lolhtml ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/ diff --git a/Makefile b/Makefile index b023dc53c..b44aa9ecb 100644 --- a/Makefile +++ b/Makefile @@ -453,7 +453,8 @@ MINIMUM_ARCHIVE_FILES = -L$(BUN_DEPS_OUT_DIR) \ -ldecrepit \ -lssl \ -lcrypto \ - -llolhtml + -llolhtml \ + -lbase64 ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MINIMUM_ARCHIVE_FILES) \ -larchive \ @@ -1850,6 +1851,10 @@ copy-to-bun-release-dir-bin: PACKAGE_MAP = --pkg-begin async_io $(BUN_DIR)/src/io/io_darwin.zig --pkg-begin bun $(BUN_DIR)/src/bun_redirect.zig --pkg-end --pkg-end --pkg-begin javascript_core $(BUN_DIR)/src/jsc.zig --pkg-begin bun $(BUN_DIR)/src/bun_redirect.zig --pkg-end --pkg-end --pkg-begin bun $(BUN_DIR)/src/bun_redirect.zig --pkg-end +.PHONY: base64 +base64: + cd $(BUN_DEPS_DIR)/base64 && make clean && cmake $(CMAKE_FLAGS) . && make + cp $(BUN_DEPS_DIR)/base64/libbase64.a $(BUN_DEPS_OUT_DIR)/libbase64.a .PHONY: cold-jsc-start cold-jsc-start: @@ -1868,7 +1873,8 @@ cold-jsc-start: misctools/cold-jsc-start.cpp -o cold-jsc-start .PHONY: vendor-without-npm -vendor-without-npm: node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive lolhtml sqlite usockets uws tinycc c-ares zstd +vendor-without-npm: node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive lolhtml sqlite usockets uws tinycc c-ares zstd base64 + .PHONY: vendor-without-check vendor-without-check: npm-install vendor-without-npm diff --git a/bench/snippets/base64-buffer-to-string.mjs b/bench/snippets/base64-buffer-to-string.mjs new file mode 100644 index 000000000..a62b76379 --- /dev/null +++ b/bench/snippets/base64-buffer-to-string.mjs @@ -0,0 +1,14 @@ +import { bench, run } from "./runner.mjs"; +import { Buffer } from "node:buffer"; + +const bigBuffer = Buffer.from("hello world".repeat(10000)); +const converted = bigBuffer.toString("base64"); +bench("Buffer.toString('base64')", () => { + return bigBuffer.toString("base64"); +}); + +// bench("Buffer.from(str, 'base64')", () => { +// return Buffer.from(converted, "base64"); +// }); + +await run(); diff --git a/docs/project/licensing.md b/docs/project/licensing.md index ea49acb1d..ac7fef774 100644 --- a/docs/project/licensing.md +++ b/docs/project/licensing.md @@ -85,6 +85,11 @@ Bun statically links these libraries: --- +- [`libbase64`](https://github.com/aklomp/base64/blob/master/LICENSE) +- BSD 2-Clause + +--- + - A fork of [`uWebsockets`](https://github.com/jarred-sumner/uwebsockets) - Apache 2.0 licensed diff --git a/src/base64/base64.zig b/src/base64/base64.zig index bddc44564..8768b9c7b 100644 --- a/src/base64/base64.zig +++ b/src/base64/base64.zig @@ -5,6 +5,22 @@ pub const DecodeResult = struct { fail: bool = false, }; +pub const LibBase64 = struct { + pub const State = extern struct { + eof: c_int, + bytes: c_int, + flags: c_int, + carry: u8, + }; + pub extern fn base64_encode(src: [*]const u8, srclen: usize, out: [*]u8, outlen: *usize, flags: c_int) void; + pub extern fn base64_stream_encode_init(state: *State, flags: c_int) void; + pub extern fn base64_stream_encode(state: *State, src: [*]const u8, srclen: usize, out: [*]u8, outlen: *usize) void; + pub extern fn base64_stream_encode_final(state: *State, out: [*]u8, outlen: *usize) void; + pub extern fn base64_decode(src: [*]const u8, srclen: usize, out: [*]u8, outlen: *usize, flags: c_int) c_int; + pub extern fn base64_stream_decode_init(state: *State, flags: c_int) void; + pub extern fn base64_stream_decode(state: *State, src: [*]const u8, srclen: usize, out: [*]u8, outlen: *usize) c_int; +}; + const mixed_decoder = brk: { var decoder = zig_base64.standard.decoderWithIgnore("\xff \t\r\n" ++ [_]u8{ std.ascii.control_code.vt, @@ -30,7 +46,9 @@ pub fn decode(destination: []u8, source: []const u8) DecodeResult { } pub fn encode(destination: []u8, source: []const u8) usize { - return zig_base64.standard.Encoder.encode(destination, source).len; + var outlen: usize = destination.len; + LibBase64.base64_encode(source.ptr, source.len, destination.ptr, &outlen, 0); + return outlen; } pub fn decodeLenUpperBound(len: usize) usize { diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index b01eca8e0..96d04636e 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -524,8 +524,8 @@ pub const Encoding = enum(u8) { switch (encoding) { .base64 => { var base64: [std.base64.standard.Encoder.calcSize(size)]u8 = undefined; - const result = JSC.ZigString.init(std.base64.standard.Encoder.encode(&base64, input)).toValueGC(globalThis); - return result; + const len = bun.base64.encode(&base64, input); + return JSC.ZigString.init(base64[0..len]).toValueGC(globalThis); }, .base64url => { var buf: [std.base64.url_safe.Encoder.calcSize(size) + "data:;base64,".len]u8 = undefined; diff --git a/src/deps/base64 b/src/deps/base64 new file mode 160000 index 000000000..e77bd70bd --- /dev/null +++ b/src/deps/base64 @@ -0,0 +1 @@ +Subproject commit e77bd70bdd860c52c561568cffb251d88bba064c -- cgit v1.2.3 From c72c82b970eff579afedababad919b616acc51f7 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 21:08:26 -0700 Subject: Make this test less flaky --- test/js/bun/net/socket.test.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/js/bun/net/socket.test.ts b/test/js/bun/net/socket.test.ts index 1da000834..5126067e6 100644 --- a/test/js/bun/net/socket.test.ts +++ b/test/js/bun/net/socket.test.ts @@ -105,7 +105,28 @@ it("should reject on connection error, calling both connectError() and rejecting }); it("should not leak memory when connect() fails", async () => { - await expectMaxObjectTypeCount(expect, "TCPSocket", 1, 100); + await (async () => { + var promises = new Array(100); + for (let i = 0; i < 100; i++) { + promises[i] = connect({ + hostname: "localhost", + port: 55555, + socket: { + connectError(socket, error) {}, + data() {}, + drain() {}, + close() {}, + end() {}, + error() {}, + open() {}, + }, + }); + } + await Promise.allSettled(promises); + promises.length = 0; + })(); + + await expectMaxObjectTypeCount(expect, "TCPSocket", 50, 100); }); // this also tests we mark the promise as handled if connectError() is called -- cgit v1.2.3 From 617226e5845181e1947671b3b7b96efad82555be Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 21:10:43 -0700 Subject: Make this test less flaky --- test/js/web/fetch/fetch-leak-test-fixture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/web/fetch/fetch-leak-test-fixture.js b/test/js/web/fetch/fetch-leak-test-fixture.js index 07275a425..c83bbea83 100644 --- a/test/js/web/fetch/fetch-leak-test-fixture.js +++ b/test/js/web/fetch/fetch-leak-test-fixture.js @@ -29,6 +29,6 @@ await (async function runAll() { await Bun.sleep(10); Bun.gc(true); -if ((heapStats().objectTypeCounts.Response ?? 0) > 10) { +if ((heapStats().objectTypeCounts.Response ?? 0) > 1 + ((COUNT / 2) | 0)) { throw new Error("Too many Response objects: " + heapStats().objectTypeCounts.Response); } -- cgit v1.2.3 From 9fecb3dfb9597f7774a68fbf51557ff8576be84d Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 21:10:55 -0700 Subject: Bump --- src/js/out/modules/node/perf_hooks.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/js/out/modules/node/perf_hooks.js b/src/js/out/modules/node/perf_hooks.js index 387fd00b7..af20677d7 100644 --- a/src/js/out/modules/node/perf_hooks.js +++ b/src/js/out/modules/node/perf_hooks.js @@ -17,7 +17,19 @@ class NotImplementedError extends Error { } // src/js/node/perf_hooks.js -var performance = globalThis.performance; +var constants = { + NODE_PERFORMANCE_GC_MAJOR: 4, + NODE_PERFORMANCE_GC_MINOR: 1, + NODE_PERFORMANCE_GC_INCREMENTAL: 8, + NODE_PERFORMANCE_GC_WEAKCB: 16, + NODE_PERFORMANCE_GC_FLAGS_NO: 0, + NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: 2, + NODE_PERFORMANCE_GC_FLAGS_FORCED: 4, + NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: 8, + NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: 16, + NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: 32, + NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: 64 +}, performance = globalThis.performance; class PerformanceObserver { constructor() { @@ -38,6 +50,7 @@ class PerformanceNodeTiming { } var perf_hooks_default = { performance, + constants, PerformanceEntry, PerformanceNodeTiming, [Symbol.for("CommonJS")]: 0 @@ -45,6 +58,7 @@ var perf_hooks_default = { export { performance, perf_hooks_default as default, + constants, PerformanceObserver, PerformanceNodeTiming, PerformanceEntry -- cgit v1.2.3 From c7cc618376f2ffc8377cb40e83575ef66d402e9c Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 1 Jul 2023 21:58:06 -0700 Subject: Fix leak in fd (#3487) * Fix file descriptor leak * Skip unnecessary clone * Don't break --hot --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/javascript.zig | 2 +- src/bun.js/module_loader.zig | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 572b66716..b696c6cf2 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -2065,7 +2065,7 @@ pub const VirtualMachine = struct { )) |mapping| { var log = logger.Log.init(default_allocator); var errorable: ErrorableResolvedSource = undefined; - var original_source = fetchWithoutOnLoadPlugins(this, this.global, bun.String.init(top.source_url), bun.String.empty, &log, &errorable, .print_source) catch return; + var original_source = fetchWithoutOnLoadPlugins(this, this.global, top.source_url, bun.String.empty, &log, &errorable, .print_source) catch return; const code = original_source.source_code.toUTF8(bun.default_allocator); defer code.deinit(); diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index 6fd4fef99..e7e4d700e 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -982,6 +982,14 @@ pub const ModuleLoader = struct { jsc_vm.bundler.options.macro_remap; var fallback_source: logger.Source = undefined; + + // Usually, we want to close the input file automatically. + // + // If we're re-using the file descriptor from the fs watcher + // Do not close it because that will break the kqueue-based watcher + // + var should_close_input_file_fd = fd == null; + var input_file_fd: StoredFileDescriptorType = 0; var parse_options = Bundler.ParseOptions{ .allocator = allocator, @@ -1002,6 +1010,13 @@ pub const ModuleLoader = struct { jsc_vm.main_hash == hash and strings.eqlLong(jsc_vm.main, path.text, false), }; + defer { + if (should_close_input_file_fd and input_file_fd != 0) { + _ = bun.JSC.Node.Syscall.close(input_file_fd); + input_file_fd = 0; + } + } + if (is_node_override) { if (NodeFallbackModules.contentsFromPath(specifier)) |code| { const fallback_path = Fs.Path.initWithNamespace(specifier, "node"); @@ -1019,6 +1034,7 @@ pub const ModuleLoader = struct { if (jsc_vm.isWatcherEnabled()) { if (input_file_fd != 0) { if (jsc_vm.bun_watcher != null and !is_node_override and std.fs.path.isAbsolute(path.text) and !strings.contains(path.text, "node_modules")) { + should_close_input_file_fd = false; jsc_vm.bun_watcher.?.addFile( input_file_fd, path.text, @@ -1059,6 +1075,7 @@ pub const ModuleLoader = struct { if (jsc_vm.isWatcherEnabled()) { if (input_file_fd != 0) { if (jsc_vm.bun_watcher != null and !is_node_override and std.fs.path.isAbsolute(path.text) and !strings.contains(path.text, "node_modules")) { + should_close_input_file_fd = false; jsc_vm.bun_watcher.?.addFile( input_file_fd, path.text, -- cgit v1.2.3 From 800103837626b93d867a72239eb2818dcc8f0821 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 1 Jul 2023 22:43:59 -0700 Subject: Use exact versions in tests --- test/bun.lockb | Bin 140423 -> 139814 bytes test/internal/package-json-lint.test.ts | 42 +++++++++++++++++++++++++++++ test/js/third_party/esbuild/bun.lockb | Bin 8425 -> 9601 bytes test/js/third_party/esbuild/package.json | 4 +-- test/js/third_party/prisma/package.json | 4 +-- test/js/third_party/socket.io/package.json | 7 +++-- test/package.json | 38 +++++++++++++------------- 7 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 test/internal/package-json-lint.test.ts diff --git a/test/bun.lockb b/test/bun.lockb index f8ea8e4c6..f30ca197a 100755 Binary files a/test/bun.lockb and b/test/bun.lockb differ diff --git a/test/internal/package-json-lint.test.ts b/test/internal/package-json-lint.test.ts new file mode 100644 index 000000000..5a1fae5f9 --- /dev/null +++ b/test/internal/package-json-lint.test.ts @@ -0,0 +1,42 @@ +import { test, expect, describe } from "bun:test"; +import { join } from "path"; +import { readdirSync, existsSync } from "fs"; +const base = join(import.meta.dir, "../"); + +const packageJSONDirs = [ + base, + ...readdirSync(join(import.meta.dir, "../", "js", "third_party")) + .map(a => join(import.meta.dir, "../", "js", "third_party", a)) + .filter(a => existsSync(join(a, "./package.json"))), +]; + +// For test reliability and security reasons +// We must use exact versions for third-party dependencies in our tests. +describe("package.json dependencies must be exact versions", async () => { + for (const dir of packageJSONDirs) { + test(join("test", dir.replace(base, ""), "package.json"), async () => { + const { + dependencies = {}, + devDependencies = {}, + peerDependencies = {}, + optionalDependencies = {}, + } = await Bun.file(join(dir, "./package.json")).json(); + + for (const [name, dep] of Object.entries(dependencies)) { + expect(dep).toMatch(/^([a-zA-Z0-9\.])+$/); + } + + for (const [name, dep] of Object.entries(devDependencies)) { + expect(dep).toMatch(/^([a-zA-Z0-9\.])+$/); + } + + for (const [name, dep] of Object.entries(peerDependencies)) { + expect(dep).toMatch(/^([a-zA-Z0-9\.])+$/); + } + + for (const [name, dep] of Object.entries(optionalDependencies)) { + expect(dep).toMatch(/^([a-zA-Z0-9\.])+$/); + } + }); + } +}); diff --git a/test/js/third_party/esbuild/bun.lockb b/test/js/third_party/esbuild/bun.lockb index f46c6aa5d..1fcce3837 100755 Binary files a/test/js/third_party/esbuild/bun.lockb and b/test/js/third_party/esbuild/bun.lockb differ diff --git a/test/js/third_party/esbuild/package.json b/test/js/third_party/esbuild/package.json index ad6bc55f6..46535bc29 100644 --- a/test/js/third_party/esbuild/package.json +++ b/test/js/third_party/esbuild/package.json @@ -1,6 +1,6 @@ { "type": "module", "dependencies": { - "esbuild": "^0.17.11" + "esbuild": "0.17.11" } -} \ No newline at end of file +} diff --git a/test/js/third_party/prisma/package.json b/test/js/third_party/prisma/package.json index 369bd42ba..ac8694e36 100644 --- a/test/js/third_party/prisma/package.json +++ b/test/js/third_party/prisma/package.json @@ -3,11 +3,11 @@ "module": "index.ts", "type": "module", "devDependencies": { - "bun-types": "^0.6.0", + "bun-types": "0.6.12", "prisma": "4.15.0" }, "peerDependencies": { - "typescript": "^5.0.0" + "typescript": "5.0.0" }, "dependencies": { "@prisma/client": "4.15.0" diff --git a/test/js/third_party/socket.io/package.json b/test/js/third_party/socket.io/package.json index edeb84845..af70e36a6 100644 --- a/test/js/third_party/socket.io/package.json +++ b/test/js/third_party/socket.io/package.json @@ -2,9 +2,8 @@ "name": "socket.io", "version": "1.0.0", "dependencies": { - "socket.io": "^4.6.1", - "socket.io-client": "^4.6.1", - "supertest": "^6.1.6", - "uWebSockets.js": "uNetworking/uWebSockets.js#v20.24.0" + "socket.io": "4.6.1", + "socket.io-client": "4.6.1", + "supertest": "6.1.6" } } diff --git a/test/package.json b/test/package.json index d4246ea43..116571879 100644 --- a/test/package.json +++ b/test/package.json @@ -1,29 +1,29 @@ { "name": "test", "devDependencies": { - "@types/dedent": "^0.7.0" + "@types/dedent": "0.7.0" }, "dependencies": { "@prisma/client": "4.15.0", - "@swc/core": "^1.3.38", - "@types/react": "^18.0.28", - "@types/react-dom": "^18.0.11", - "bktree-fast": "^0.0.7", - "body-parser": "^1.20.2", - "dedent": "^0.7.0", - "esbuild": "^0.18.6", - "express": "^4.18.2", - "iconv-lite": "^0.6.3", - "jest-extended": "^4.0.0", - "lodash": "^4.17.21", + "@swc/core": "1.3.38", + "@types/react": "18.0.28", + "@types/react-dom": "18.0.11", + "bktree-fast": "0.0.7", + "body-parser": "1.20.2", + "dedent": "0.7.0", + "esbuild": "0.18.6", + "express": "4.18.2", + "iconv-lite": "0.6.3", + "jest-extended": "4.0.0", + "lodash": "4.17.21", "prisma": "4.15.0", - "socket.io": "^4.6.1", - "socket.io-client": "^4.6.1", - "supertest": "^6.1.6", - "svelte": "^3.55.1", - "typescript": "^5.0.2", - "undici": "^5.20.0", - "vitest": "^0.32.2", + "socket.io": "4.6.1", + "socket.io-client": "4.6.1", + "supertest": "6.1.6", + "svelte": "3.55.1", + "typescript": "5.0.2", + "undici": "5.20.0", + "vitest": "0.32.2", "webpack": "5.88.0", "webpack-cli": "4.7.2" }, -- cgit v1.2.3 From b05879e9e2e9d52359eb91a1305c1e694169c030 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 2 Jul 2023 01:06:40 -0700 Subject: Fixes #3489 (#3490) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/html_rewriter.zig | 35 ++++++++--------------------------- src/deps/lol-html.zig | 22 +++++++++++++++++++++- test/js/workerd/html-rewriter.test.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 28 deletions(-) diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig index 5e14d5503..532e0ae1e 100644 --- a/src/bun.js/api/html_rewriter.zig +++ b/src/bun.js/api/html_rewriter.zig @@ -996,26 +996,14 @@ const getterWrap = JSC.getterWrap; const setterWrap = JSC.setterWrap; const wrap = JSC.wrapSync; -pub fn free_html_writer_string(_: ?*anyopaque, ptr: ?*anyopaque, len: usize) callconv(.C) void { - var str = LOLHTML.HTMLString{ .ptr = bun.cast([*]const u8, ptr.?), .len = len }; - str.deinit(); -} - fn throwLOLHTMLError(global: *JSGlobalObject) JSValue { - var err = LOLHTML.HTMLString.lastError(); - return ZigString.init(err.slice()).toErrorInstance(global); + const err = LOLHTML.HTMLString.lastError(); + defer err.deinit(); + return ZigString.fromUTF8(err.slice()).toErrorInstance(global); } fn htmlStringValue(input: LOLHTML.HTMLString, globalObject: *JSGlobalObject) JSValue { - var str = ZigString.init( - input.slice(), - ); - str.detectEncoding(); - - return str.toExternalValueWithCallback( - globalObject, - free_html_writer_string, - ); + return input.toJS(globalObject); } pub const TextChunk = struct { @@ -1328,7 +1316,7 @@ pub const Comment = struct { pub fn getText(this: *Comment, global: *JSGlobalObject) JSValue { if (this.comment == null) return JSValue.jsNull(); - return ZigString.init(this.comment.?.getText().slice()).withEncoding().toValueGC(global); + return this.comment.?.getText().toJS(global); } pub fn setText( @@ -1458,7 +1446,7 @@ pub const EndTag = struct { if (this.end_tag == null) return JSC.JSValue.jsUndefined(); - return ZigString.init(this.end_tag.?.getName().slice()).withEncoding().toValueGC(global); + return this.end_tag.?.getName().toJS(global); } pub fn setName( @@ -1696,19 +1684,12 @@ pub const Element = struct { var slice = name.toSlice(bun.default_allocator); defer slice.deinit(); - var attr = this.element.?.getAttribute(slice.slice()).slice(); + var attr = this.element.?.getAttribute(slice.slice()); if (attr.len == 0) return JSC.JSValue.jsNull(); - var str = ZigString.init( - attr, - ); - - return str.toExternalValueWithCallback( - globalObject, - free_html_writer_string, - ); + return attr.toJS(globalObject); } /// Returns a boolean indicating whether an attribute exists on the element. diff --git a/src/deps/lol-html.zig b/src/deps/lol-html.zig index 9c5345046..50dab9592 100644 --- a/src/deps/lol-html.zig +++ b/src/deps/lol-html.zig @@ -1,6 +1,6 @@ pub const Error = error{Fail}; const std = @import("std"); - +const bun = @import("root").bun; pub const MemorySettings = extern struct { preallocated_parsing_buffer_size: usize, max_allowed_memory_usage: usize, @@ -563,6 +563,26 @@ pub const HTMLString = extern struct { @setRuntimeSafety(false); return this.ptr[0..this.len]; } + + fn deinit_external(ctx: *anyopaque, ptr: *anyopaque, len: u32) callconv(.C) void { + _ = ctx; + auto_disable(); + lol_html_str_free(.{ .ptr = @ptrCast([*]const u8, ptr), .len = len }); + } + + pub fn toJS(this: HTMLString, globalThis: *bun.JSC.JSGlobalObject) bun.JSC.JSValue { + const bytes = this.slice(); + if (bun.strings.isAllASCII(bytes)) { + var external = bun.String.createExternal(bytes, true, @constCast(bytes.ptr), &deinit_external); + defer external.deref(); + return external.toJS(globalThis); + } + defer this.deinit(); + + var str = bun.String.create(bytes); + defer str.deref(); + return str.toJS(globalThis); + } }; pub const EndTag = opaque { diff --git a/test/js/workerd/html-rewriter.test.js b/test/js/workerd/html-rewriter.test.js index 3f7b7493d..aaf912aff 100644 --- a/test/js/workerd/html-rewriter.test.js +++ b/test/js/workerd/html-rewriter.test.js @@ -337,3 +337,31 @@ it("#3334 regression", async () => { } Bun.gc(true); }); + +it("#3489", async () => { + var el; + await new HTMLRewriter() + .on("p", { + element(element) { + el = element.getAttribute("id"); + }, + }) + .transform(new Response('

')) + .text(); + expect(el).toEqual("Šžõäöü"); +}); + +it("get attribute - ascii", async () => { + for (let i = 0; i < 10; i++) { + var el; + await new HTMLRewriter() + .on("p", { + element(element) { + el = element.getAttribute("id"); + }, + }) + .transform(new Response(`

`)) + .text(); + expect(el).toEqual("asciii"); + } +}); -- cgit v1.2.3 From 69396aae012b42a277104b828646f7b96f680af7 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 10:09:52 -0700 Subject: Fixes #3495 --- src/bun.js/bindings/ZigSourceProvider.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bun.js/bindings/ZigSourceProvider.cpp b/src/bun.js/bindings/ZigSourceProvider.cpp index dda7135b4..a71e946de 100644 --- a/src/bun.js/bindings/ZigSourceProvider.cpp +++ b/src/bun.js/bindings/ZigSourceProvider.cpp @@ -64,10 +64,6 @@ Ref SourceProvider::create(Zig::GlobalObject* globalObject, Reso auto stringImpl = Bun::toWTFString(resolvedSource.source_code); auto sourceURLString = toStringCopy(resolvedSource.source_url); - if (stringImpl.impl()->refCount() > 1) - // Deref because we don't call a destructor for BunString - stringImpl.impl()->deref(); - auto provider = adoptRef(*new SourceProvider( globalObject->isThreadLocalDefaultGlobalObject ? globalObject : nullptr, resolvedSource, stringImpl.releaseImpl().releaseNonNull(), -- cgit v1.2.3 From 4cbda049e97b2e1049cd2c4c93a617a54931b220 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Sun, 2 Jul 2023 13:12:31 -0400 Subject: fix zero length env var (#3496) --- src/bun.js/bindings/JSEnvironmentVariableMap.cpp | 4 ++-- test/cli/run/env.test.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bun.js/bindings/JSEnvironmentVariableMap.cpp b/src/bun.js/bindings/JSEnvironmentVariableMap.cpp index 5c0357066..4989f7e96 100644 --- a/src/bun.js/bindings/JSEnvironmentVariableMap.cpp +++ b/src/bun.js/bindings/JSEnvironmentVariableMap.cpp @@ -30,7 +30,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsGetterEnvironmentVariable, (JSGlobalObject * globalOb if (UNLIKELY(name.len == 0)) return JSValue::encode(jsUndefined()); - if (!Bun__getEnvValue(globalObject, &name, &value) || value.len == 0) { + if (!Bun__getEnvValue(globalObject, &name, &value)) { return JSValue::encode(jsUndefined()); } @@ -144,4 +144,4 @@ JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject) return object; } -} \ No newline at end of file +} diff --git a/test/cli/run/env.test.ts b/test/cli/run/env.test.ts index 0cab610a5..e6ee99dd2 100644 --- a/test/cli/run/env.test.ts +++ b/test/cli/run/env.test.ts @@ -308,3 +308,13 @@ test(".env Windows-style newline (issue #3042)", () => { const { stdout } = bunRun(`${dir}/index.ts`); expect(stdout).toBe("|bar\n\nbaz|moo"); }); + +test(".env with zero length strings", () => { + const dir = tempDirWithFiles("dotenv-issue-zerolength", { + ".env": "FOO=''\n", + "index.ts": + "function i(a){return a}\nconsole.log([process.env.FOO,i(process.env).FOO,process.env.FOO.length,i(process.env).FOO.length].join('|'));", + }); + const { stdout } = bunRun(`${dir}/index.ts`); + expect(stdout).toBe("||0|0"); +}); -- cgit v1.2.3 From c3f8593f8cb1571b41b8233e5ded98e3d3f99fb0 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 2 Jul 2023 18:06:21 -0700 Subject: [node:buffer] Implement `isUtf8` and `isAscii` (#3498) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- packages/bun-types/buffer.d.ts | 24 +++++++ src/bun.js/modules/BufferModule.h | 130 ++++++++++++++++++++++++++++++++++++++ test/js/node/buffer.test.js | 24 ++++++- 3 files changed, 177 insertions(+), 1 deletion(-) diff --git a/packages/bun-types/buffer.d.ts b/packages/bun-types/buffer.d.ts index eb7335871..fd7201677 100644 --- a/packages/bun-types/buffer.d.ts +++ b/packages/bun-types/buffer.d.ts @@ -2084,6 +2084,30 @@ declare module "buffer" { values(): IterableIterator; } var Buffer: BufferConstructor; + + /** + * This function returns `true` if `input` contains only valid UTF-8-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since Bun v0.6.13 + * @param input The input to validate. + */ + export function isUtf8( + input: TypedArray | ArrayBufferLike | DataView, + ): boolean; + + /** + * This function returns `true` if `input` contains only valid ASCII-encoded data, + * including the case in which `input` is empty. + * + * Throws if the `input` is a detached array buffer. + * @since Bun v0.6.13 + * @param input The input to validate. + */ + export function isAscii( + input: TypedArray | ArrayBufferLike | DataView, + ): boolean; } } declare module "node:buffer" { diff --git a/src/bun.js/modules/BufferModule.h b/src/bun.js/modules/BufferModule.h index a96fb18c8..6e6e39e9c 100644 --- a/src/bun.js/modules/BufferModule.h +++ b/src/bun.js/modules/BufferModule.h @@ -2,11 +2,127 @@ #include "../bindings/ZigGlobalObject.h" #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/ObjectConstructor.h" +#include "simdutf.h" namespace Zig { using namespace WebCore; using namespace JSC; +// TODO: Add DOMJIT fast path +JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isUtf8, + (JSC::JSGlobalObject * lexicalGlobalObject, + JSC::CallFrame *callframe)) { + auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); + + auto buffer = callframe->argument(0); + auto *bufferView = JSC::jsDynamicCast(buffer); + const char *ptr = nullptr; + size_t byteLength = 0; + if (bufferView) { + if (UNLIKELY(bufferView->isDetached())) { + throwTypeError(lexicalGlobalObject, throwScope, + "ArrayBufferView is detached"_s); + return JSValue::encode({}); + } + + byteLength = bufferView->byteLength(); + + if (byteLength == 0) { + return JSValue::encode(jsBoolean(true)); + } + + ptr = reinterpret_cast(bufferView->vector()); + } else if (auto *arrayBuffer = + JSC::jsDynamicCast(buffer)) { + auto *impl = arrayBuffer->impl(); + + if (!impl) { + return JSValue::encode(jsBoolean(true)); + } + + if (UNLIKELY(impl->isDetached())) { + throwTypeError(lexicalGlobalObject, throwScope, + "ArrayBuffer is detached"_s); + return JSValue::encode({}); + } + + byteLength = impl->byteLength(); + + if (byteLength == 0) { + return JSValue::encode(jsBoolean(true)); + } + + ptr = reinterpret_cast(impl->data()); + } else { + throwVMError( + lexicalGlobalObject, throwScope, + createTypeError(lexicalGlobalObject, + "First argument must be an ArrayBufferView"_s)); + return JSValue::encode({}); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean( + simdutf::validate_utf8(ptr, byteLength)))); +} + +// TODO: Add DOMJIT fast path +JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isAscii, + (JSC::JSGlobalObject * lexicalGlobalObject, + JSC::CallFrame *callframe)) { + auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); + + auto buffer = callframe->argument(0); + auto *bufferView = JSC::jsDynamicCast(buffer); + const char *ptr = nullptr; + size_t byteLength = 0; + if (bufferView) { + + if (UNLIKELY(bufferView->isDetached())) { + throwTypeError(lexicalGlobalObject, throwScope, + "ArrayBufferView is detached"_s); + return JSValue::encode({}); + } + + byteLength = bufferView->byteLength(); + + if (byteLength == 0) { + return JSValue::encode(jsBoolean(true)); + } + + ptr = reinterpret_cast(bufferView->vector()); + } else if (auto *arrayBuffer = + JSC::jsDynamicCast(buffer)) { + auto *impl = arrayBuffer->impl(); + if (UNLIKELY(impl->isDetached())) { + throwTypeError(lexicalGlobalObject, throwScope, + "ArrayBuffer is detached"_s); + return JSValue::encode({}); + } + + if (!impl) { + return JSValue::encode(jsBoolean(true)); + } + + byteLength = impl->byteLength(); + + if (byteLength == 0) { + return JSValue::encode(jsBoolean(true)); + } + + ptr = reinterpret_cast(impl->data()); + } else { + throwVMError( + lexicalGlobalObject, throwScope, + createTypeError(lexicalGlobalObject, + "First argument must be an ArrayBufferView"_s)); + return JSValue::encode({}); + } + + RELEASE_AND_RETURN( + throwScope, + JSValue::encode(jsBoolean(simdutf::validate_ascii(ptr, byteLength)))); +} + JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplemented, (JSGlobalObject * globalObject, CallFrame *callFrame)) { @@ -106,6 +222,20 @@ inline void generateBufferSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, exportProperty(JSC::Identifier::fromString(vm, "resolveObjectURL"_s), resolveObjectURL); + exportProperty(JSC::Identifier::fromString(vm, "isAscii"_s), + JSC::JSFunction::create(vm, globalObject, 1, "isAscii"_s, + jsBufferConstructorFunction_isAscii, + ImplementationVisibility::Public, + NoIntrinsic, + jsBufferConstructorFunction_isUtf8)); + + exportProperty(JSC::Identifier::fromString(vm, "isUtf8"_s), + JSC::JSFunction::create(vm, globalObject, 1, "isUtf8"_s, + jsBufferConstructorFunction_isUtf8, + ImplementationVisibility::Public, + NoIntrinsic, + jsBufferConstructorFunction_isUtf8)); + exportNames.append(vm.propertyNames->defaultKeyword); exportValues.append(defaultObject); } diff --git a/test/js/node/buffer.test.js b/test/js/node/buffer.test.js index e0d8f5486..99562fedd 100644 --- a/test/js/node/buffer.test.js +++ b/test/js/node/buffer.test.js @@ -1,4 +1,4 @@ -import { Buffer, SlowBuffer } from "buffer"; +import { Buffer, SlowBuffer, isAscii, isUtf8 } from "buffer"; import { describe, it, expect, beforeEach, afterEach } from "bun:test"; import { gc } from "harness"; @@ -7,6 +7,28 @@ const BufferModule = await import("buffer"); beforeEach(() => gc()); afterEach(() => gc()); +it("isAscii", () => { + expect(isAscii(new Buffer("abc"))).toBeTrue(); + expect(isAscii(new Buffer(""))).toBeTrue(); + expect(isAscii(new Buffer([32, 32, 128]))).toBeFalse(); + expect(isAscii(new Buffer("What did the 🦊 say?"))).toBeFalse(); + + expect(isAscii(new Buffer("").buffer)).toBeTrue(); + expect(isAscii(new Buffer([32, 32, 128]).buffer)).toBeFalse(); +}); + +it("isUtf8", () => { + expect(isUtf8(new Buffer("abc"))).toBeTrue(); + expect(isAscii(new Buffer(""))).toBeTrue(); + expect(isUtf8(new Buffer("What did the 🦊 say?"))).toBeTrue(); + expect(isUtf8(new Buffer([129, 129, 129]))).toBeFalse(); + + expect(isUtf8(new Buffer("abc").buffer)).toBeTrue(); + expect(isAscii(new Buffer("").buffer)).toBeTrue(); + expect(isUtf8(new Buffer("What did the 🦊 say?").buffer)).toBeTrue(); + expect(isUtf8(new Buffer([129, 129, 129]).buffer)).toBeFalse(); +}); + // https://github.com/oven-sh/bun/issues/2052 it("Buffer global is settable", () => { var prevBuffer = globalThis.Buffer; -- cgit v1.2.3 From eb90ce50c362149829590dc78db4d4d73fb2b36e Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 2 Jul 2023 20:16:52 -0700 Subject: Use fast path for Base64 in `btoa` (#3504) * Use fast path for Base64 in `atob` * Fix utf16, crash on linux --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/ZigGlobalObject.cpp | 74 +++++++++++++++++++++++---------- test/js/web/util/atob.test.js | 9 ++-- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 7ba0f0b30..102e5e4e8 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -181,6 +181,8 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers; #include "DOMWrapperWorld-class.h" #include "CommonJSModuleRecord.h" #include +#include +#include "simdutf.h" constexpr size_t DEFAULT_ERROR_STACK_TRACE_LIMIT = 10; @@ -194,6 +196,24 @@ constexpr size_t DEFAULT_ERROR_STACK_TRACE_LIMIT = 10; // #include static bool has_loaded_jsc = false; +namespace WebCore { +class Base64Utilities { +public: + static ExceptionOr atob(const String& encodedString) + { + if (encodedString.isNull()) + return String(); + + auto decodedData = base64Decode(encodedString, Base64DecodeMode::DefaultValidatePaddingAndIgnoreWhitespace); + if (!decodedData) + return Exception { InvalidCharacterError }; + + return String(decodedData->data(), decodedData->size()); + } +}; + +} + extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(const char* ptr, size_t length)) { if (has_loaded_jsc) @@ -1164,53 +1184,65 @@ JSC_DEFINE_HOST_FUNCTION(functionBTOA, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(globalObject->vm()); if (callFrame->argumentCount() == 0) { - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - JSC::throwTypeError(globalObject, scope, "btoa requires 1 argument (a string)"_s); + JSC::throwTypeError(globalObject, throwScope, "btoa requires 1 argument (a string)"_s); return JSC::JSValue::encode(JSC::JSValue {}); } - const String& stringToEncode = callFrame->argument(0).toWTFString(globalObject); + JSValue arg0 = callFrame->uncheckedArgument(0); + WTF::String encodedString = arg0.toWTFString(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); - if (!stringToEncode || stringToEncode.isNull()) { - return JSC::JSValue::encode(JSC::jsString(vm, WTF::String())); + if (encodedString.isEmpty()) { + return JSC::JSValue::encode(JSC::jsEmptyString(vm)); } - if (!stringToEncode.isAllLatin1()) { - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - throwException(globalObject, scope, createDOMException(globalObject, ExceptionCode::InvalidCharacterError)); + if (!encodedString.isAllLatin1()) { + throwException(globalObject, throwScope, createDOMException(globalObject, InvalidCharacterError)); return JSC::JSValue::encode(JSC::JSValue {}); } - return JSC::JSValue::encode(JSC::jsString(vm, WTF::base64EncodeToString(stringToEncode.latin1()))); + if (!encodedString.is8Bit()) { + LChar* ptr; + unsigned length = encodedString.length(); + auto dest = WTF::String::createUninitialized(length, ptr); + WTF::StringImpl::copyCharacters(ptr, encodedString.characters16(), length); + encodedString = WTFMove(dest); + } + + unsigned length = encodedString.length(); + RELEASE_AND_RETURN( + throwScope, + Bun__encoding__toString( + encodedString.characters8(), + length, + globalObject, + static_cast(WebCore::BufferEncodingType::base64))); } static JSC_DEFINE_HOST_FUNCTION(functionATOB, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(globalObject->vm()); if (callFrame->argumentCount() == 0) { - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - JSC::throwTypeError(globalObject, scope, "atob requires 1 argument (a string)"_s); + JSC::throwTypeError(globalObject, throwScope, "atob requires 1 argument (a string)"_s); return JSC::JSValue::encode(JSC::JSValue {}); } - const WTF::String& encodedString = callFrame->argument(0).toWTFString(globalObject); + WTF::String encodedString = callFrame->uncheckedArgument(0).toWTFString(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); - if (encodedString.isNull()) { - return JSC::JSValue::encode(JSC::jsEmptyString(vm)); - } - - auto decodedData = WTF::base64Decode(encodedString, Base64DecodeMode::DefaultValidatePaddingAndIgnoreWhitespace); - if (!decodedData) { - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - throwException(globalObject, scope, createDOMException(globalObject, ExceptionCode::InvalidCharacterError)); + auto result = WebCore::Base64Utilities::atob(encodedString); + if (result.hasException()) { + throwException(globalObject, throwScope, createDOMException(*globalObject, result.releaseException())); return JSC::JSValue::encode(JSC::JSValue {}); } - return JSC::JSValue::encode(JSC::jsString(vm, WTF::String(decodedData->data(), decodedData->size()))); + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsString(vm, result.releaseReturnValue()))); } static JSC_DEFINE_HOST_FUNCTION(functionHashCode, diff --git a/test/js/web/util/atob.test.js b/test/js/web/util/atob.test.js index 4945829e1..20c029f14 100644 --- a/test/js/web/util/atob.test.js +++ b/test/js/web/util/atob.test.js @@ -60,18 +60,15 @@ it("btoa", () => { expect(btoa("abcde")).toBe("YWJjZGU="); expect(btoa("abcdef")).toBe("YWJjZGVm"); expect(typeof btoa).toBe("function"); - try { - btoa(); - throw new Error("Expected error"); - } catch (error) { - expect(error.name).toBe("TypeError"); - } + expect(() => btoa()).toThrow("btoa requires 1 argument (a string)"); var window = "[object Window]"; expect(btoa("")).toBe(""); expect(btoa(null)).toBe("bnVsbA=="); expect(btoa(undefined)).toBe("dW5kZWZpbmVk"); expect(btoa(window)).toBe("W29iamVjdCBXaW5kb3dd"); expect(btoa("éé")).toBe("6ek="); + // check for utf16 + expect(btoa("🧐éé".substring("🧐".length))).toBe("6ek="); expect(btoa("\u0080\u0081")).toBe("gIE="); expect(btoa(Bun)).toBe(btoa("[object Bun]")); }); -- cgit v1.2.3 From 3a0a423bcec850ea1a138f161012b0c622ccee28 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 20:17:25 -0700 Subject: Add comment --- src/bun.js/bindings/ZigGlobalObject.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 102e5e4e8..b69a4ebb3 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -1204,6 +1204,10 @@ JSC_DEFINE_HOST_FUNCTION(functionBTOA, return JSC::JSValue::encode(JSC::JSValue {}); } + // Reminder: btoa() is for Byte Strings + // Specifically: latin1 byte strings + // That means even though this looks like the wrong thing to do, + // we should be converting to latin1, not utf8. if (!encodedString.is8Bit()) { LChar* ptr; unsigned length = encodedString.length(); -- cgit v1.2.3 From 0db31c2b435ab7cd4d09810c2a2b22969c7366c5 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 20:18:21 -0700 Subject: Fixes #3499 --- src/bun.js/bindings/ZigGlobalObject.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index b69a4ebb3..c00670289 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -2861,15 +2861,13 @@ JSC_DEFINE_HOST_FUNCTION(errorConstructorFuncCaptureStackTrace, (JSC::JSGlobalOb errorObject->putDirect(vm, vm.propertyNames->stack, formattedStackTrace, 0); - if (!(caller && caller.isObject())) { - if (auto* instance = jsDynamicCast(errorObject)) { - // we make a separate copy of the StackTrace unfortunately so that we - // can later console.log it without losing the info - // - // This is not good. We should remove this in the future as it strictly makes this function - // already slower than necessary. - instance->captureStackTrace(vm, globalObject, 1, false); - } + if (auto* instance = jsDynamicCast(errorObject)) { + // we make a separate copy of the StackTrace unfortunately so that we + // can later console.log it without losing the info + // + // This is not good. We should remove this in the future as it strictly makes this function + // already slower than necessary. + instance->captureStackTrace(vm, globalObject, 1, false); } RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSValue {})); -- cgit v1.2.3 From c21fadf9bcc939dcf7d949cda86c974481b5f609 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Sun, 2 Jul 2023 23:24:15 -0400 Subject: set content-length 0 in some cases (#3503) --- src/http_client_async.zig | 3 +-- test/js/web/fetch/fetch.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/http_client_async.zig b/src/http_client_async.zig index a1962a8b9..2cb534ed2 100644 --- a/src/http_client_async.zig +++ b/src/http_client_async.zig @@ -1629,7 +1629,6 @@ pub fn buildRequest(this: *HTTPClient, body_len: usize) picohttp.Request { var override_accept_encoding = false; var override_accept_header = false; var override_host_header = false; - var override_user_agent = false; for (header_names, 0..) |head, i| { @@ -1710,7 +1709,7 @@ pub fn buildRequest(this: *HTTPClient, body_len: usize) picohttp.Request { header_count += 1; } - if (body_len > 0) { + if (body_len > 0 or this.method.hasRequestBody()) { request_headers_buf[header_count] = .{ .name = content_length_header_name, .value = std.fmt.bufPrint(&this.request_content_len_buf, "{d}", .{body_len}) catch "0", diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts index 4d529b231..6b87cc613 100644 --- a/test/js/web/fetch/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -387,6 +387,25 @@ describe("fetch", () => { }).toThrow("fetch() request with GET/HEAD/OPTIONS method cannot have body."); }), ); + + it("content length is inferred", async () => { + startServer({ + fetch(req) { + return new Response(req.headers.get("content-length")); + }, + hostname: "localhost", + }); + + // POST with body + const url = `http://${server.hostname}:${server.port}`; + const response = await fetch(url, { method: "POST", body: "buntastic" }); + expect(response.status).toBe(200); + expect(await response.text()).toBe("9"); + + const response2 = await fetch(url, { method: "POST", body: "" }); + expect(response2.status).toBe(200); + expect(await response2.text()).toBe("0"); + }); }); it("simultaneous HTTPS fetch", async () => { -- cgit v1.2.3 From aa38e51afb73dab3071addc07f82fd96153ff450 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 2 Jul 2023 22:09:50 -0700 Subject: Support mocking `new Date()` & `Date.now()` in bun:test (#3501) * Support changing the time * Bump WebKit * Update bun.lockb --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- .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 +- bun.lockb | Bin 72925 -> 72925 bytes package.json | 2 +- src/bun.js/WebKit | 2 +- src/bun.js/bindings/JSMockFunction.cpp | 24 ++++++++++++++++++++++++ src/bun.js/test/jest.zig | 5 +++++ test/js/bun/test/test-timers.test.ts | 11 +++++++++++ 12 files changed, 70 insertions(+), 30 deletions(-) create mode 100644 test/js/bun/test/test-timers.test.ts diff --git a/.github/workflows/bun-linux-aarch64.yml b/.github/workflows/bun-linux-aarch64.yml index 01714460b..13dddece4 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-2/bun-webkit-linux-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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 798ffaf33..e992770f1 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-2/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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 f281783bd..484c7035b 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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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 b5f79a757..fe8f0b396 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-2/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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 8b30321f0..ae265adab 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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/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-2/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-3/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index 5f66a5e04..66c3360af 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-2 +ARG WEBKIT_TAG=may20-3 ARG ZIG_TAG=jul1 ARG ZIG_VERSION="0.11.0-dev.3737+9eb008717" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" diff --git a/bun.lockb b/bun.lockb index e53db751b..69f9ded0b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 4fe213747..f4bd86e76 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-8a03cf746abef8a48c932ab25f8821390632f2e2" + "bun-webkit": "0.0.1-26c819733315f0ab64ae8e8e65b77d77d31211e1" }, "version": "0.0.0", "prettier": "./.prettierrc.cjs" diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit index 8a03cf746..26c819733 160000 --- a/src/bun.js/WebKit +++ b/src/bun.js/WebKit @@ -1 +1 @@ -Subproject commit 8a03cf746abef8a48c932ab25f8821390632f2e2 +Subproject commit 26c819733315f0ab64ae8e8e65b77d77d31211e1 diff --git a/src/bun.js/bindings/JSMockFunction.cpp b/src/bun.js/bindings/JSMockFunction.cpp index 33922c2b7..0e24e761c 100644 --- a/src/bun.js/bindings/JSMockFunction.cpp +++ b/src/bun.js/bindings/JSMockFunction.cpp @@ -19,6 +19,7 @@ #include #include #include +#include namespace Bun { @@ -65,6 +66,29 @@ JSC_DECLARE_HOST_FUNCTION(jsMockFunctionMockRejectedValueOnce); JSC_DECLARE_HOST_FUNCTION(jsMockFunctionWithImplementationCleanup); JSC_DECLARE_HOST_FUNCTION(jsMockFunctionWithImplementation); +extern "C" EncodedJSValue JSMock__jsNow(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) +{ + return JSValue::encode(jsNumber(globalObject->jsDateNow())); +} +extern "C" EncodedJSValue JSMock__jsSetSystemTime(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) +{ + JSValue argument0 = callFrame->argument(0); + + if (auto* dateInstance = jsDynamicCast(argument0)) { + if (std::isnormal(dateInstance->internalNumber())) { + globalObject->overridenDateNow = dateInstance->internalNumber(); + } + return JSValue::encode(callFrame->thisValue()); + } + + if (argument0.isNumber() && argument0.asNumber() > 0) { + globalObject->overridenDateNow = argument0.asNumber(); + } + + globalObject->overridenDateNow = -1; + return JSValue::encode(callFrame->thisValue()); +} + uint64_t JSMockModule::s_nextInvocationId = 0; // This is taken from JSWeakSet diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 6e4cb827c..727466835 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -440,6 +440,9 @@ pub const Jest = struct { jest.put(globalObject, ZigString.static("fn"), mockFn); jest.put(globalObject, ZigString.static("spyOn"), spyOn); jest.put(globalObject, ZigString.static("restoreAllMocks"), restoreAllMocks); + jest.put(globalObject, ZigString.static("now"), JSC.NewFunction(globalObject, ZigString.static("now"), 0, JSMock__jsNow, false)); + jest.put(globalObject, ZigString.static("setSystemTime"), JSC.NewFunction(globalObject, ZigString.static("setSystemTime"), 0, JSMock__jsSetSystemTime, false)); + module.put(globalObject, ZigString.static("jest"), jest); module.put(globalObject, ZigString.static("spyOn"), spyOn); @@ -455,6 +458,8 @@ pub const Jest = struct { extern fn Bun__Jest__testPreloadObject(*JSC.JSGlobalObject) JSC.JSValue; extern fn Bun__Jest__testModuleObject(*JSC.JSGlobalObject) JSC.JSValue; extern fn JSMock__jsMockFn(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; + extern fn JSMock__jsNow(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; + extern fn JSMock__jsSetSystemTime(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; extern fn JSMock__jsRestoreAllMocks(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; extern fn JSMock__jsSpyOn(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; diff --git a/test/js/bun/test/test-timers.test.ts b/test/js/bun/test/test-timers.test.ts new file mode 100644 index 000000000..64da0abda --- /dev/null +++ b/test/js/bun/test/test-timers.test.ts @@ -0,0 +1,11 @@ +test("we can go back in time", () => { + const dateNow = Date.now; + // jest.useFakeTimers(); + jest.setSystemTime(new Date("2020-01-01T00:00:00.000Z")); + expect(new Date().toISOString()).toBe("2020-01-01T00:00:00.000Z"); + expect(Date.now()).toBe(1577836800000); + expect(dateNow).toBe(Date.now); + + jest.setSystemTime(); + expect(new Date().toISOString()).not.toBe("2020-01-01T00:00:00.000Z"); +}); -- cgit v1.2.3 From f0a795b568b741f71945e1078b87355d3217cc23 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 22:42:13 -0700 Subject: Stub out `useFakeTimers` and `useRealTimers` --- packages/bun-types/bun-test.d.ts | 30 +++++++++++++++++++++++++++++ src/bun.js/bindings/JSMockFunction.cpp | 12 ++++++++++++ src/bun.js/test/jest.zig | 31 +++++++++++++++++++++++++++--- test/js/bun/test/test-timers.test.ts | 35 +++++++++++++++++++++++++--------- 4 files changed, 96 insertions(+), 12 deletions(-) diff --git a/packages/bun-types/bun-test.d.ts b/packages/bun-types/bun-test.d.ts index 156585766..5182f7e93 100644 --- a/packages/bun-types/bun-test.d.ts +++ b/packages/bun-types/bun-test.d.ts @@ -29,6 +29,36 @@ declare module "bun:test" { (Function: T): Mock; }; + /** + * Control the system time used by: + * - `Date.now()` + * - `new Date()` + * - `Intl.DateTimeFormat().format()` + * + * In the future, we may add support for more functions, but we haven't done that yet. + * + * @param now The time to set the system time to. If not provided, the system time will be reset. + * @returns `this` + * @since v0.6.13 + * + * ## Set Date to a specific time + * + * ```js + * import { setSystemTime } from 'bun:test'; + * + * setSystemTime(new Date('2020-01-01T00:00:00.000Z')); + * console.log(new Date().toISOString()); // 2020-01-01T00:00:00.000Z + * ``` + * ## Reset Date to the current time + * + * ```js + * import { setSystemTime } from 'bun:test'; + * + * setSystemTime(); + * ``` + */ + export function setSystemTime(now?: Date | number): ThisType; + interface Jest { restoreAllMocks(): void; fn(func?: T): Mock; diff --git a/src/bun.js/bindings/JSMockFunction.cpp b/src/bun.js/bindings/JSMockFunction.cpp index 0e24e761c..3a84f0139 100644 --- a/src/bun.js/bindings/JSMockFunction.cpp +++ b/src/bun.js/bindings/JSMockFunction.cpp @@ -66,6 +66,18 @@ JSC_DECLARE_HOST_FUNCTION(jsMockFunctionMockRejectedValueOnce); JSC_DECLARE_HOST_FUNCTION(jsMockFunctionWithImplementationCleanup); JSC_DECLARE_HOST_FUNCTION(jsMockFunctionWithImplementation); +// This is a stub. Exists so that the same code can be run in Jest +extern "C" EncodedJSValue JSMock__jsUseFakeTimers(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) +{ + return JSValue::encode(callFrame->thisValue()); +} + +extern "C" EncodedJSValue JSMock__jsUseRealTimers(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) +{ + globalObject->overridenDateNow = -1; + return JSValue::encode(callFrame->thisValue()); +} + extern "C" EncodedJSValue JSMock__jsNow(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) { return JSValue::encode(jsNumber(globalObject->jsDateNow())); diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 727466835..55600ded8 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -333,7 +333,7 @@ pub const Jest = struct { pub fn Bun__Jest__createTestModuleObject(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue { JSC.markBinding(@src()); - const module = JSC.JSValue.createEmptyObject(globalObject, 12); + const module = JSC.JSValue.createEmptyObject(globalObject, 13); const test_fn = JSC.NewFunction(globalObject, ZigString.static("test"), 2, TestScope.call, false); module.put( @@ -431,17 +431,40 @@ pub const Jest = struct { Expect.getConstructor(globalObject), ); + const setSystemTime = JSC.NewFunction(globalObject, ZigString.static("setSystemTime"), 0, JSMock__jsSetSystemTime, false); + module.put( + globalObject, + ZigString.static("setSystemTime"), + setSystemTime, + ); + const useFakeTimers = JSC.NewFunction(globalObject, ZigString.static("useFakeTimers"), 0, JSMock__jsUseFakeTimers, false); + const useRealTimers = JSC.NewFunction(globalObject, ZigString.static("useRealTimers"), 0, JSMock__jsUseRealTimers, false); + const mockFn = JSC.NewFunction(globalObject, ZigString.static("fn"), 1, JSMock__jsMockFn, false); const spyOn = JSC.NewFunction(globalObject, ZigString.static("spyOn"), 2, JSMock__jsSpyOn, false); const restoreAllMocks = JSC.NewFunction(globalObject, ZigString.static("restoreAllMocks"), 2, JSMock__jsRestoreAllMocks, false); module.put(globalObject, ZigString.static("mock"), mockFn); - const jest = JSValue.createEmptyObject(globalObject, 3); + const jest = JSValue.createEmptyObject(globalObject, 7); jest.put(globalObject, ZigString.static("fn"), mockFn); jest.put(globalObject, ZigString.static("spyOn"), spyOn); jest.put(globalObject, ZigString.static("restoreAllMocks"), restoreAllMocks); + jest.put( + globalObject, + ZigString.static("setSystemTime"), + setSystemTime, + ); + jest.put( + globalObject, + ZigString.static("useFakeTimers"), + useFakeTimers, + ); + jest.put( + globalObject, + ZigString.static("useRealTimers"), + useRealTimers, + ); jest.put(globalObject, ZigString.static("now"), JSC.NewFunction(globalObject, ZigString.static("now"), 0, JSMock__jsNow, false)); - jest.put(globalObject, ZigString.static("setSystemTime"), JSC.NewFunction(globalObject, ZigString.static("setSystemTime"), 0, JSMock__jsSetSystemTime, false)); module.put(globalObject, ZigString.static("jest"), jest); module.put(globalObject, ZigString.static("spyOn"), spyOn); @@ -462,6 +485,8 @@ pub const Jest = struct { extern fn JSMock__jsSetSystemTime(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; extern fn JSMock__jsRestoreAllMocks(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; extern fn JSMock__jsSpyOn(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; + extern fn JSMock__jsUseFakeTimers(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; + extern fn JSMock__jsUseRealTimers(*JSC.JSGlobalObject, *JSC.CallFrame) JSC.JSValue; pub fn call( _: void, diff --git a/test/js/bun/test/test-timers.test.ts b/test/js/bun/test/test-timers.test.ts index 64da0abda..963467dee 100644 --- a/test/js/bun/test/test-timers.test.ts +++ b/test/js/bun/test/test-timers.test.ts @@ -1,11 +1,28 @@ test("we can go back in time", () => { - const dateNow = Date.now; - // jest.useFakeTimers(); - jest.setSystemTime(new Date("2020-01-01T00:00:00.000Z")); - expect(new Date().toISOString()).toBe("2020-01-01T00:00:00.000Z"); - expect(Date.now()).toBe(1577836800000); - expect(dateNow).toBe(Date.now); - - jest.setSystemTime(); - expect(new Date().toISOString()).not.toBe("2020-01-01T00:00:00.000Z"); + const DateBeforeMocked = Date; + const orig = new Date(); + orig.setHours(0, 0, 0, 0); + jest.useFakeTimers(); + jest.setSystemTime(new Date("1995-12-19T00:00:00.000Z")); + + expect(new Date().toISOString()).toBe("1995-12-19T00:00:00.000Z"); + expect(Date.now()).toBe(819331200000); + + if (typeof Bun !== "undefined") { + // In bun, the Date object remains the same despite being mocked. + // This prevents a whole bunch of subtle bugs in tests. + expect(DateBeforeMocked).toBe(Date); + expect(DateBeforeMocked.now).toBe(Date.now); + + // Jest doesn't property mock new Intl.DateTimeFormat().format() + expect(new Intl.DateTimeFormat().format()).toBe("12/19/1995"); + } else { + expect(DateBeforeMocked).not.toBe(Date); + expect(DateBeforeMocked.now).not.toBe(Date.now); + } + + jest.useRealTimers(); + const now = new Date(); + now.setHours(0, 0, 0, 0); + expect(now.toISOString()).toBe(orig.toISOString()); }); -- cgit v1.2.3 From c77518ff9313e6cf0534fbd50ff564fd9849e41b Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 22:57:24 -0700 Subject: Update writing.md --- docs/test/writing.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/test/writing.md b/docs/test/writing.md index 391ee91c2..029418a48 100644 --- a/docs/test/writing.md +++ b/docs/test/writing.md @@ -217,13 +217,13 @@ Bun implements the following matchers. Full Jest compatibility is on the roadmap --- -- 🔴 -- [`.resolves()`](https://jestjs.io/docs/expect#resolves) +- 🟢 +- [`.resolves()`](https://jestjs.io/docs/expect#resolves) (since Bun v0.6.12+) --- -- 🔴 -- [`.rejects()`](https://jestjs.io/docs/expect#rejects) +- 🟢 +- [`.rejects()`](https://jestjs.io/docs/expect#rejects) (since Bun v0.6.12+) --- @@ -277,7 +277,7 @@ Bun implements the following matchers. Full Jest compatibility is on the roadmap --- -- 🔴 +- 🟢 - [`.toBeCloseTo()`](https://jestjs.io/docs/expect#tobeclosetonumber-numdigits) --- -- cgit v1.2.3 From 000417731b2a49a8b6c1a350f668b659adddc3d3 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:07:33 -0700 Subject: Add time doc --- docs/nav.ts | 9 +++++--- docs/test/time.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 docs/test/time.md diff --git a/docs/nav.ts b/docs/nav.ts index 12333e6da..2832a53cf 100644 --- a/docs/nav.ts +++ b/docs/nav.ts @@ -180,6 +180,9 @@ export default { page("cli/test", "`bun test`", { description: "Bun's test runner uses Jest-compatible syntax but runs 100x faster.", }), + page("test/hot", "Watch mode", { + description: "Reload your tests automatically on change.", + }), page("test/writing", "Writing tests", { description: "Write your tests using Jest-like expect matchers, plus setup/teardown hooks, snapshot testing, and more", @@ -190,12 +193,12 @@ export default { page("test/snapshots", "Snapshots", { description: "Add lifecycle hooks to your tests that run before/after each test or test run", }), + page("test/time", "Time", { + description: "Control the date & time in your tests for more reliable and deterministic tests", + }), page("test/dom", "DOM testing", { description: "Write headless tests for UI and React/Vue/Svelte/Lit components with happy-dom", }), - page("test/hot", "Watch mode", { - description: "Reload your tests automatically on change.", - }), divider("Package runner"), page("cli/bunx", "`bunx`", { diff --git a/docs/test/time.md b/docs/test/time.md new file mode 100644 index 000000000..94e954020 --- /dev/null +++ b/docs/test/time.md @@ -0,0 +1,64 @@ +`bun:test` lets you change what time it is in your tests. This was introduced in Bun v0.6.13. + +This works with any of the following: + +- `Date.now` +- `new Date()` +- `new Intl.DateTimeFormat().format()` + +Timers are not impacted yet, but may be in a future release of Bun. + +## `setSystemTime` + +To change the system time, use `setSystemTime`: + +```ts +import { setSystemTime, beforeAll } from "bun:test"; + +beforeAll(() => { + setSystemTime(new Date("2020-01-01T00:00:00.000Z")); +}); + +test("it is 2020", () => { + expect(new Date().getFullYear()).toBe(2020); +}); +``` + +### Reset the system time + +To reset the system time, pass no arguments to `setSystemTime`: + +```ts +import { setSystemTime, beforeAll } from "bun:test"; + +test("it was 2020, for a moment.", () => { + setSystemTime(new Date("2020-01-01T00:00:00.000Z")); + expect(new Date().getFullYear()).toBe(2020); + setSystemTime(); + expect(new Date().getFullYear()).toBeGreaterThan(2020); +}); +``` + +## Set the time zone + +To change the time zone, either pass the `$TZ` environment variable to your test runner, or set `process.env.TZ` at runtime: + +```ts +import { test, expect } from "bun:test"; + +test("Welcome to California!", () => { + process.env.TZ = "America/Los_Angeles"; + expect(new Date().getTimezoneOffset()).toBe(420); + expect(new Intl.DateTimeFormat().resolvedOptions().timeZone).toBe( + "America/Los_Angeles", + ); +}); + +test("Welcome to New York!", () => { + process.env.TZ = "America/New_York"; + expect(new Date().getTimezoneOffset()).toBe(300); + expect(new Intl.DateTimeFormat().resolvedOptions().timeZone).toBe( + "America/New_York", + ); +}); +``` -- cgit v1.2.3 From cd243f40eece9d70d901672086e5938188c27e83 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:10:50 -0700 Subject: Update time.md --- docs/test/time.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/test/time.md b/docs/test/time.md index 94e954020..1cc841fb9 100644 --- a/docs/test/time.md +++ b/docs/test/time.md @@ -56,7 +56,7 @@ test("Welcome to California!", () => { test("Welcome to New York!", () => { process.env.TZ = "America/New_York"; - expect(new Date().getTimezoneOffset()).toBe(300); + expect(new Date().getTimezoneOffset()).toBe(240); expect(new Intl.DateTimeFormat().resolvedOptions().timeZone).toBe( "America/New_York", ); -- cgit v1.2.3 From 9da9bac30cc0e1fb09181c20a10d24eb6d4609f8 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:18:58 -0700 Subject: Update time.md --- docs/test/time.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/test/time.md b/docs/test/time.md index 1cc841fb9..678312903 100644 --- a/docs/test/time.md +++ b/docs/test/time.md @@ -24,6 +24,20 @@ test("it is 2020", () => { }); ``` +To support existing tests that use Jest's `useFakeTimers` and `useRealTimers`, you can use `useFakeTimers` and `useRealTimers`: + +```ts +test("just like in jest", () => { + jest.useFakeTimers(); + jest.setSystemTime(new Date("2020-01-01T00:00:00.000Z")); + expect(new Date().getFullYear()).toBe(2020); + jest.useRealTimers(); + expect(new Date().getFullYear()).toBeGreaterThan(2020); +}); +``` + +Note that we have not implemented builtin support for mocking timers yet, but this is on the roadmap. + ### Reset the system time To reset the system time, pass no arguments to `setSystemTime`: @@ -32,9 +46,13 @@ To reset the system time, pass no arguments to `setSystemTime`: import { setSystemTime, beforeAll } from "bun:test"; test("it was 2020, for a moment.", () => { + // Set it to something! setSystemTime(new Date("2020-01-01T00:00:00.000Z")); expect(new Date().getFullYear()).toBe(2020); + + // reset it! setSystemTime(); + expect(new Date().getFullYear()).toBeGreaterThan(2020); }); ``` -- cgit v1.2.3 From 1206352b4ac8b12fffb497eab82f5e3db8ed0871 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:46:08 -0700 Subject: Update time.md --- docs/test/time.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/test/time.md b/docs/test/time.md index 678312903..dd23f788f 100644 --- a/docs/test/time.md +++ b/docs/test/time.md @@ -34,6 +34,21 @@ test("just like in jest", () => { jest.useRealTimers(); expect(new Date().getFullYear()).toBeGreaterThan(2020); }); + +test("unlike in jest", () => { + const OriginalDate = Date; + jest.useFakeTimers(); + if (typeof Bun === "undefined") { + // In Jest, the Date constructor changes + // That can cause all sorts of bugs because suddenly Date !== Date before the test. + expect(Date).not.toBe(OriginalDate); + expect(Date.now).not.toBe(OriginalDate.now); + } else { + // In bun:test, Date constructor does not change when you useFakeTimers + expect(Date).toBe(OriginalDate); + expect(Date.now).toBe(OriginalDate.now); + } +}); ``` Note that we have not implemented builtin support for mocking timers yet, but this is on the roadmap. @@ -73,6 +88,7 @@ test("Welcome to California!", () => { }); test("Welcome to New York!", () => { + // Unlike in jest, you can set the timezone multiple times at runtime and it will work. process.env.TZ = "America/New_York"; expect(new Date().getTimezoneOffset()).toBe(240); expect(new Intl.DateTimeFormat().resolvedOptions().timeZone).toBe( -- cgit v1.2.3 From 12a342b6c0d6dd9badb58a929b240663bae8edef Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:47:48 -0700 Subject: Update time.md --- docs/test/time.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/test/time.md b/docs/test/time.md index dd23f788f..3da79df8d 100644 --- a/docs/test/time.md +++ b/docs/test/time.md @@ -13,7 +13,7 @@ Timers are not impacted yet, but may be in a future release of Bun. To change the system time, use `setSystemTime`: ```ts -import { setSystemTime, beforeAll } from "bun:test"; +import { setSystemTime, beforeAll, test, expect } from "bun:test"; beforeAll(() => { setSystemTime(new Date("2020-01-01T00:00:00.000Z")); -- cgit v1.2.3 From 48d726bfd0701f8e33442f2c7075dc8191a2ccb4 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:48:31 -0700 Subject: Update time.md --- docs/test/time.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/test/time.md b/docs/test/time.md index 3da79df8d..ef741fc6f 100644 --- a/docs/test/time.md +++ b/docs/test/time.md @@ -74,7 +74,7 @@ test("it was 2020, for a moment.", () => { ## Set the time zone -To change the time zone, either pass the `$TZ` environment variable to your test runner, or set `process.env.TZ` at runtime: +To change the time zone, either pass the `$TZ` environment variable to `bun test`, or set `process.env.TZ` at runtime: ```ts import { test, expect } from "bun:test"; -- cgit v1.2.3 From a7a01bd52f20e7908f06d4de9a1814902b838a4b Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Mon, 3 Jul 2023 16:19:50 -0300 Subject: [tls] add socket parameter, setServername and ALPNprotocols support (#3457) * add socket parameter support * refactor #socket * add test and more fixs * some fixes * bump uws * handlers fix * more fixes * fix node net and node tls tests * fix duplicate port * fix deinit on CallbackJobs * cleanup * add setImmediate repro * add test to setImmediate * this is necessary? * fix prependOnce on native listener * try to findout the error on nodemailer CI * show error message * Update bun.lockb * prettier * Use exact versions of packages * add alpnProtocol support * update * emit error when connect fails on net.Socket * format * fix _write and cleanup * fixup * fix connect, add alpn test * fix socket.io * add socket parameter to TLSSocket * add TLSSocket socket first parameter * fixup and _start * remove flask tests * fmt --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/bun.zig | 2 + src/bun.js/api/bun/socket.zig | 544 +++++++++++++++++++-- src/bun.js/api/server.zig | 48 +- src/bun.js/api/sockets.classes.ts | 16 + src/bun.js/bindings/JSSink.cpp | 2 +- src/bun.js/bindings/JSSink.h | 2 +- src/bun.js/bindings/JSSinkLookupTable.h | 2 +- src/bun.js/bindings/ZigGeneratedClasses.cpp | 218 +++++++++ src/bun.js/bindings/generated_classes.zig | 26 + src/bun.js/bindings/webcore/JSEventEmitter.cpp | 2 +- src/deps/uws | 2 +- src/deps/uws.zig | 284 ++++++++++- src/js/node/net.js | 151 ++++-- src/js/node/tls.js | 351 ++++++++++++- src/js/out/modules/node/net.js | 118 +++-- src/js/out/modules/node/tls.js | 190 ++++++- test/bun.lockb | Bin 139814 -> 140524 bytes test/js/node/net/node-net-server.test.ts | 55 --- test/js/node/tls/node-tls-connect.test.ts | 32 ++ test/js/node/tls/node-tls-server.test.ts | 55 --- test/js/third_party/nodemailer/nodemailer.test.ts | 15 + test/js/third_party/nodemailer/package.json | 6 + .../nodemailer/process-nodemailer-fixture.js | 23 + test/js/web/timers/process-setImmediate-fixture.js | 9 + test/js/web/timers/setImmediate.test.js | 27 + test/package.json | 5 +- 26 files changed, 1888 insertions(+), 297 deletions(-) create mode 100644 test/js/node/tls/node-tls-connect.test.ts create mode 100644 test/js/third_party/nodemailer/nodemailer.test.ts create mode 100644 test/js/third_party/nodemailer/package.json create mode 100644 test/js/third_party/nodemailer/process-nodemailer-fixture.js create mode 100644 test/js/web/timers/process-setImmediate-fixture.js diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 2e6381c74..1e5a5e004 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -3794,6 +3794,8 @@ pub const Timer = struct { result.then(globalThis, this, CallbackJob__onResolve, CallbackJob__onReject); }, } + } else { + this.deinit(); } } }; diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 69d6611cb..329cc40e4 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -69,6 +69,11 @@ fn normalizeHost(input: anytype) @TypeOf(input) { const BinaryType = JSC.BinaryType; +const WrappedType = enum { + none, + tls, + tcp, +}; const Handlers = struct { onOpen: JSC.JSValue = .zero, onClose: JSC.JSValue = .zero, @@ -97,8 +102,8 @@ const Handlers = struct { handlers: *Handlers, socket_context: *uws.SocketContext, - pub fn exit(this: *Scope, ssl: bool) void { - this.handlers.markInactive(ssl, this.socket_context); + pub fn exit(this: *Scope, ssl: bool, wrapped: WrappedType) void { + this.handlers.markInactive(ssl, this.socket_context, wrapped); } }; @@ -123,19 +128,24 @@ const Handlers = struct { return true; } - pub fn markInactive(this: *Handlers, ssl: bool, ctx: *uws.SocketContext) void { + pub fn markInactive(this: *Handlers, ssl: bool, ctx: *uws.SocketContext, wrapped: WrappedType) void { Listener.log("markInactive", .{}); this.active_connections -= 1; - if (this.active_connections == 0 and this.is_server) { - var listen_socket: *Listener = @fieldParentPtr(Listener, "handlers", this); - // allow it to be GC'd once the last connection is closed and it's not listening anymore - if (listen_socket.listener == null) { - listen_socket.strong_self.clear(); + if (this.active_connections == 0) { + if (this.is_server) { + var listen_socket: *Listener = @fieldParentPtr(Listener, "handlers", this); + // allow it to be GC'd once the last connection is closed and it's not listening anymore + if (listen_socket.listener == null) { + listen_socket.strong_self.clear(); + } + } else { + this.unprotect(); + // will deinit when is not wrapped or when is the TCP wrapped connection + if (wrapped != .tls) { + ctx.deinit(ssl); + } + bun.default_allocator.destroy(this); } - } else if (this.active_connections == 0 and !this.is_server) { - this.unprotect(); - ctx.deinit(ssl); - bun.default_allocator.destroy(this); } } @@ -364,6 +374,7 @@ pub const Listener = struct { connection: UnixOrHost, socket_context: ?*uws.SocketContext = null, ssl: bool = false, + protos: ?[]const u8 = null, strong_data: JSC.Strong = .{}, strong_self: JSC.Strong = .{}, @@ -395,6 +406,19 @@ pub const Listener = struct { port: u16, }, + pub fn clone(this: UnixOrHost) UnixOrHost { + switch (this) { + .unix => |u| { + return .{ + .unix = (bun.default_allocator.dupe(u8, u) catch unreachable), + }; + }, + .host => |h| { + return .{ .host = .{ .host = (bun.default_allocator.dupe(u8, h.host) catch unreachable), .port = this.host.port } }; + }, + } + } + pub fn deinit(this: UnixOrHost) void { switch (this) { .unix => |u| { @@ -455,10 +479,12 @@ pub const Listener = struct { var socket_config = SocketConfig.fromJS(opts, globalObject, exception) orelse { return .zero; }; + var hostname_or_unix = socket_config.hostname_or_unix; var port = socket_config.port; var ssl = socket_config.ssl; var handlers = socket_config.handlers; + var protos: ?[]const u8 = null; const exclusive = socket_config.exclusive; handlers.is_server = true; @@ -496,6 +522,10 @@ pub const Listener = struct { }; if (ssl_enabled) { + if (ssl.?.protos) |p| { + protos = p[0..ssl.?.protos_len]; + } + uws.NewSocketHandler(true).configure( socket_context, true, @@ -593,6 +623,7 @@ pub const Listener = struct { .ssl = ssl_enabled, .socket_context = socket_context, .listener = listen_socket, + .protos = if (protos) |p| (bun.default_allocator.dupe(u8, p) catch unreachable) else null, }; socket.handlers.protect(); @@ -649,6 +680,8 @@ pub const Listener = struct { .handlers = &listener.handlers, .this_value = .zero, .socket = socket, + .protos = listener.protos, + .owned_protos = false, }; if (listener.strong_data.get()) |default_data| { const globalObject = listener.handlers.globalObject; @@ -715,6 +748,10 @@ pub const Listener = struct { this.handlers.unprotect(); this.connection.deinit(); + if (this.protos) |protos| { + this.protos = null; + bun.default_allocator.destroy(protos); + } bun.default_allocator.destroy(this); } @@ -775,13 +812,16 @@ pub const Listener = struct { const socket_config = SocketConfig.fromJS(opts, globalObject, exception) orelse { return .zero; }; + var hostname_or_unix = socket_config.hostname_or_unix; var port = socket_config.port; var ssl = socket_config.ssl; var handlers = socket_config.handlers; var default_data = socket_config.default_data; + var protos: ?[]const u8 = null; const ssl_enabled = ssl != null; + defer if (ssl != null) ssl.?.deinit(); handlers.protect(); @@ -797,6 +837,9 @@ pub const Listener = struct { }; if (ssl_enabled) { + if (ssl.?.protos) |p| { + protos = p[0..ssl.?.protos_len]; + } uws.NewSocketHandler(true).configure( socket_context, true, @@ -848,6 +891,7 @@ pub const Listener = struct { .this_value = .zero, .socket = undefined, .connection = connection, + .protos = if (protos) |p| (bun.default_allocator.dupe(u8, p) catch unreachable) else null, }; TLSSocket.dataSetCached(tls.getThisValue(globalObject), globalObject, default_data); @@ -871,6 +915,7 @@ pub const Listener = struct { .this_value = .zero, .socket = undefined, .connection = null, + .protos = null, }; TCPSocket.dataSetCached(tcp.getThisValue(globalObject), globalObject, default_data); @@ -898,11 +943,41 @@ fn JSSocketType(comptime ssl: bool) type { } } +fn selectALPNCallback( + _: ?*BoringSSL.SSL, + out: [*c][*c]const u8, + outlen: [*c]u8, + in: [*c]const u8, + inlen: c_uint, + arg: ?*anyopaque, +) callconv(.C) c_int { + const this = bun.cast(*TLSSocket, arg); + if (this.protos) |protos| { + if (protos.len == 0) { + return BoringSSL.SSL_TLSEXT_ERR_NOACK; + } + + const status = BoringSSL.SSL_select_next_proto(bun.cast([*c][*c]u8, out), outlen, protos.ptr, @intCast(c_uint, protos.len), in, inlen); + + // Previous versions of Node.js returned SSL_TLSEXT_ERR_NOACK if no protocol + // match was found. This would neither cause a fatal alert nor would it result + // in a useful ALPN response as part of the Server Hello message. + // We now return SSL_TLSEXT_ERR_ALERT_FATAL in that case as per Section 3.2 + // of RFC 7301, which causes a fatal no_application_protocol alert. + const expected = if (comptime BoringSSL.OPENSSL_NPN_NEGOTIATED == 1) BoringSSL.SSL_TLSEXT_ERR_OK else BoringSSL.SSL_TLSEXT_ERR_ALERT_FATAL; + + return if (status == expected) 1 else 0; + } else { + return BoringSSL.SSL_TLSEXT_ERR_NOACK; + } +} + fn NewSocket(comptime ssl: bool) type { return struct { pub const Socket = uws.NewSocketHandler(ssl); socket: Socket, detached: bool = false, + wrapped: WrappedType = .none, handlers: *Handlers, this_value: JSC.JSValue = .zero, poll_ref: JSC.PollRef = JSC.PollRef.init(), @@ -910,6 +985,8 @@ fn NewSocket(comptime ssl: bool) type { last_4: [4]u8 = .{ 0, 0, 0, 0 }, authorized: bool = false, connection: ?Listener.UnixOrHost = null, + protos: ?[]const u8, + owned_protos: bool = true, // TODO: switch to something that uses `visitAggregate` and have the // `Listener` keep a list of all the sockets JSValue in there @@ -1079,7 +1156,7 @@ fn NewSocket(comptime ssl: bool) type { var vm = this.handlers.vm; this.reffer.unref(vm); - this.handlers.markInactive(ssl, this.socket.context()); + this.handlers.markInactive(ssl, this.socket.context(), this.wrapped); this.poll_ref.unref(vm); this.has_pending_activity.store(false, .Release); } @@ -1091,25 +1168,35 @@ fn NewSocket(comptime ssl: bool) type { // Add SNI support for TLS (mongodb and others requires this) if (comptime ssl) { - if (this.connection) |connection| { - if (connection == .host) { - const host = normalizeHost(connection.host.host); - if (host.len > 0) { - var ssl_ptr: *BoringSSL.SSL = @ptrCast(*BoringSSL.SSL, socket.getNativeHandle()); - if (!ssl_ptr.isInitFinished()) { + var ssl_ptr: *BoringSSL.SSL = @ptrCast(*BoringSSL.SSL, socket.getNativeHandle()); + if (!ssl_ptr.isInitFinished()) { + if (this.connection) |connection| { + if (connection == .host) { + const host = normalizeHost(connection.host.host); + if (host.len > 0) { var host__ = default_allocator.dupeZ(u8, host) catch unreachable; defer default_allocator.free(host__); ssl_ptr.setHostname(host__); } } } + if (this.protos) |protos| { + if (this.handlers.is_server) { + BoringSSL.SSL_CTX_set_alpn_select_cb(BoringSSL.SSL_get_SSL_CTX(ssl_ptr), selectALPNCallback, bun.cast(*anyopaque, this)); + } else { + _ = BoringSSL.SSL_set_alpn_protos(ssl_ptr, protos.ptr, @intCast(c_uint, protos.len)); + } + } } } this.poll_ref.ref(this.handlers.vm); this.detached = false; this.socket = socket; - socket.ext(**anyopaque).?.* = bun.cast(**anyopaque, this); + + if (this.wrapped == .none) { + socket.ext(**anyopaque).?.* = bun.cast(**anyopaque, this); + } const handlers = this.handlers; const callback = handlers.onOpen; @@ -1174,7 +1261,7 @@ fn NewSocket(comptime ssl: bool) type { // the handlers must be kept alive for the duration of the function call // that way if we need to call the error handler, we can var scope = handlers.enter(socket.context()); - defer scope.exit(ssl); + defer scope.exit(ssl, this.wrapped); const globalObject = handlers.globalObject; const this_value = this.getThisValue(globalObject); @@ -1211,7 +1298,7 @@ fn NewSocket(comptime ssl: bool) type { // the handlers must be kept alive for the duration of the function call // that way if we need to call the error handler, we can var scope = handlers.enter(socket.context()); - defer scope.exit(ssl); + defer scope.exit(ssl, this.wrapped); const globalObject = handlers.globalObject; const this_value = this.getThisValue(globalObject); @@ -1255,7 +1342,6 @@ fn NewSocket(comptime ssl: bool) type { log("onClose", .{}); this.detached = true; defer this.markInactive(); - const handlers = this.handlers; this.poll_ref.unref(handlers.vm); @@ -1265,7 +1351,7 @@ fn NewSocket(comptime ssl: bool) type { // the handlers must be kept alive for the duration of the function call // that way if we need to call the error handler, we can var scope = handlers.enter(socket.context()); - defer scope.exit(ssl); + defer scope.exit(ssl, this.wrapped); var globalObject = handlers.globalObject; const this_value = this.getThisValue(globalObject); @@ -1295,7 +1381,7 @@ fn NewSocket(comptime ssl: bool) type { // the handlers must be kept alive for the duration of the function call // that way if we need to call the error handler, we can var scope = handlers.enter(socket.context()); - defer scope.exit(ssl); + defer scope.exit(ssl, this.wrapped); // const encoding = handlers.encoding; const result = callback.callWithThis(globalObject, this_value, &[_]JSValue{ @@ -1476,10 +1562,20 @@ fn NewSocket(comptime ssl: bool) type { } fn writeMaybeCorked(this: *This, buffer: []const u8, is_end: bool) i32 { - if (this.socket.isShutdown() or this.socket.isClosed()) { + if (this.detached or this.socket.isShutdown() or this.socket.isClosed()) { return -1; } // we don't cork yet but we might later + + if (comptime ssl) { + // TLS wrapped but in TCP mode + if (this.wrapped == .tcp) { + const res = this.socket.rawWrite(buffer, is_end); + log("write({d}, {any}) = {d}", .{ buffer.len, is_end, res }); + return res; + } + } + const res = this.socket.write(buffer, is_end); log("write({d}, {any}) = {d}", .{ buffer.len, is_end, res }); return res; @@ -1487,7 +1583,6 @@ fn NewSocket(comptime ssl: bool) type { fn writeOrEnd(this: *This, globalObject: *JSC.JSGlobalObject, args: []const JSC.JSValue, is_end: bool) WriteResult { if (args.len == 0) return .{ .success = .{} }; - if (args.ptr[0].asArrayBuffer(globalObject)) |array_buffer| { var slice = array_buffer.slice(); @@ -1681,9 +1776,6 @@ fn NewSocket(comptime ssl: bool) type { if (result.wrote == result.total) { this.socket.flush(); this.detached = true; - if (!this.socket.isClosed()) { - this.socket.close(0, null); - } this.markInactive(); } break :brk JSValue.jsNumber(result.wrote); @@ -1706,17 +1798,27 @@ fn NewSocket(comptime ssl: bool) type { pub fn finalize(this: *This) callconv(.C) void { log("finalize()", .{}); - if (this.detached) return; - this.detached = true; - if (!this.socket.isClosed()) { - this.socket.close(0, null); + if (!this.detached) { + this.detached = true; + if (!this.socket.isClosed()) { + this.socket.close(0, null); + } + this.markInactive(); + } + + this.poll_ref.unref(JSC.VirtualMachine.get()); + // need to deinit event without being attached + if (this.owned_protos) { + if (this.protos) |protos| { + this.protos = null; + default_allocator.free(protos); + } } + if (this.connection) |connection| { - connection.deinit(); this.connection = null; + connection.deinit(); } - this.markInactive(); - this.poll_ref.unref(JSC.VirtualMachine.get()); } pub fn reload(this: *This, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue { @@ -1756,8 +1858,376 @@ fn NewSocket(comptime ssl: bool) type { return JSValue.jsUndefined(); } + + pub fn getALPNProtocol( + this: *This, + globalObject: *JSC.JSGlobalObject, + ) callconv(.C) JSValue { + if (comptime ssl == false) { + return JSValue.jsBoolean(false); + } + + if (this.detached) { + return JSValue.jsBoolean(false); + } + + var alpn_proto: [*c]const u8 = null; + var alpn_proto_len: u32 = 0; + + var ssl_ptr: *BoringSSL.SSL = @ptrCast(*BoringSSL.SSL, this.socket.getNativeHandle()); + BoringSSL.SSL_get0_alpn_selected(ssl_ptr, &alpn_proto, &alpn_proto_len); + if (alpn_proto == null or alpn_proto_len == 0) { + return JSValue.jsBoolean(false); + } + + const slice = alpn_proto[0..alpn_proto_len]; + if (strings.eql(slice, "h2")) { + return ZigString.static("h2").toValue(globalObject); + } + if (strings.eql(slice, "http/1.1")) { + return ZigString.static("http/1.1").toValue(globalObject); + } + return ZigString.fromUTF8(slice).toValueGC(globalObject); + } + + pub fn setServername( + this: *This, + globalObject: *JSC.JSGlobalObject, + callframe: *JSC.CallFrame, + ) callconv(.C) JSValue { + if (comptime ssl == false) { + return JSValue.jsUndefined(); + } + if (this.detached) { + return JSValue.jsUndefined(); + } + + if (this.handlers.is_server) { + globalObject.throw("Cannot issue SNI from a TLS server-side socket", .{}); + return .zero; + } + + const args = callframe.arguments(1); + if (args.len < 1) { + globalObject.throw("Expected 1 argument", .{}); + return .zero; + } + + const server_name = args.ptr[0]; + if (!server_name.isString()) { + globalObject.throw("Expected \"serverName\" to be a string", .{}); + return .zero; + } + + const slice = server_name.getZigString(globalObject).toSlice(bun.default_allocator); + defer slice.deinit(); + const host = normalizeHost(slice.slice()); + if (host.len > 0) { + var ssl_ptr: *BoringSSL.SSL = @ptrCast(*BoringSSL.SSL, this.socket.getNativeHandle()); + if (ssl_ptr.isInitFinished()) { + // match node.js exceptions + globalObject.throw("Already started.", .{}); + return .zero; + } + var host__ = default_allocator.dupeZ(u8, host) catch unreachable; + defer default_allocator.free(host__); + ssl_ptr.setHostname(host__); + } + + return JSValue.jsUndefined(); + } + + pub fn open( + this: *This, + _: *JSC.JSGlobalObject, + _: *JSC.CallFrame, + ) callconv(.C) JSValue { + JSC.markBinding(@src()); + this.socket.open(!this.handlers.is_server); + return JSValue.jsUndefined(); + } + + // this invalidates the current socket returning 2 new sockets + // one for non-TLS and another for TLS + // handlers for non-TLS are preserved + pub fn wrapTLS( + this: *This, + globalObject: *JSC.JSGlobalObject, + callframe: *JSC.CallFrame, + ) callconv(.C) JSValue { + JSC.markBinding(@src()); + if (comptime ssl) { + return JSValue.jsUndefined(); + } + + if (this.detached) { + return JSValue.jsUndefined(); + } + + const args = callframe.arguments(1); + + if (args.len < 1) { + globalObject.throw("Expected 1 arguments", .{}); + return .zero; + } + + var exception: JSC.C.JSValueRef = null; + + const opts = args.ptr[0]; + if (opts.isEmptyOrUndefinedOrNull() or opts.isBoolean() or !opts.isObject()) { + globalObject.throw("Expected options object", .{}); + return .zero; + } + + var socket_obj = opts.get(globalObject, "socket") orelse { + globalObject.throw("Expected \"socket\" option", .{}); + return .zero; + }; + + var handlers = Handlers.fromJS(globalObject, socket_obj, &exception) orelse { + globalObject.throwValue(exception.?.value()); + return .zero; + }; + + var ssl_opts: ?JSC.API.ServerConfig.SSLConfig = null; + + if (opts.getTruthy(globalObject, "tls")) |tls| { + if (tls.isBoolean()) { + if (tls.toBoolean()) { + ssl_opts = JSC.API.ServerConfig.SSLConfig.zero; + } + } else { + if (JSC.API.ServerConfig.SSLConfig.inJS(globalObject, tls, &exception)) |ssl_config| { + ssl_opts = ssl_config; + } else if (exception != null) { + return .zero; + } + } + } + + if (ssl_opts == null) { + globalObject.throw("Expected \"tls\" option", .{}); + return .zero; + } + + var default_data = JSValue.zero; + if (opts.getTruthy(globalObject, "data")) |default_data_value| { + default_data = default_data_value; + default_data.ensureStillAlive(); + } + + var socket_config = ssl_opts.?; + defer socket_config.deinit(); + const options = socket_config.asUSockets(); + + const protos = socket_config.protos; + const protos_len = socket_config.protos_len; + + const ext_size = @sizeOf(WrappedSocket); + + var tls = handlers.vm.allocator.create(TLSSocket) catch @panic("OOM"); + var handlers_ptr = handlers.vm.allocator.create(Handlers) catch @panic("OOM"); + handlers_ptr.* = handlers; + handlers_ptr.is_server = this.handlers.is_server; + handlers_ptr.protect(); + + tls.* = .{ + .handlers = handlers_ptr, + .this_value = .zero, + .socket = undefined, + .connection = if (this.connection) |c| c.clone() else null, + .wrapped = .tls, + .protos = if (protos) |p| (bun.default_allocator.dupe(u8, p[0..protos_len]) catch unreachable) else null, + }; + + var tls_js_value = tls.getThisValue(globalObject); + TLSSocket.dataSetCached(tls_js_value, globalObject, default_data); + + const TCPHandler = NewWrappedHandler(false); + + // reconfigure context to use the new wrapper handlers + Socket.unsafeConfigure(this.socket.context(), true, true, WrappedSocket, TCPHandler); + const old_context = this.socket.context(); + const TLSHandler = NewWrappedHandler(true); + const new_socket = this.socket.wrapTLS( + options, + ext_size, + true, + WrappedSocket, + TLSHandler, + ) orelse { + handlers_ptr.unprotect(); + handlers.vm.allocator.destroy(handlers_ptr); + bun.default_allocator.destroy(tls); + return JSValue.jsUndefined(); + }; + tls.socket = new_socket; + + var raw = handlers.vm.allocator.create(TLSSocket) catch @panic("OOM"); + var raw_handlers_ptr = handlers.vm.allocator.create(Handlers) catch @panic("OOM"); + this.handlers.unprotect(); + + var cloned_handlers: Handlers = .{ + .vm = globalObject.bunVM(), + .globalObject = globalObject, + .onOpen = this.handlers.onOpen, + .onClose = this.handlers.onClose, + .onData = this.handlers.onData, + .onWritable = this.handlers.onWritable, + .onTimeout = this.handlers.onTimeout, + .onConnectError = this.handlers.onConnectError, + .onEnd = this.handlers.onEnd, + .onError = this.handlers.onError, + .onHandshake = this.handlers.onHandshake, + .binary_type = this.handlers.binary_type, + }; + + raw_handlers_ptr.* = cloned_handlers; + raw_handlers_ptr.is_server = this.handlers.is_server; + raw_handlers_ptr.protect(); + raw.* = .{ + .handlers = raw_handlers_ptr, + .this_value = .zero, + .socket = new_socket, + .connection = if (this.connection) |c| c.clone() else null, + .wrapped = .tcp, + .protos = null, + }; + + var raw_js_value = raw.getThisValue(globalObject); + if (JSSocketType(ssl).dataGetCached(this.getThisValue(globalObject))) |raw_default_data| { + raw_default_data.ensureStillAlive(); + TLSSocket.dataSetCached(raw_js_value, globalObject, raw_default_data); + } + // marks both as active + raw.markActive(); + // this will keep tls alive until socket.open() is called to start TLS certificate and the handshake process + // open is not immediately called because we need to set bunSocketInternal + tls.markActive(); + + // mark both instances on socket data + new_socket.ext(WrappedSocket).?.* = .{ .tcp = raw, .tls = tls }; + + //detach and invalidate the old instance + this.detached = true; + if (this.reffer.has) { + var vm = this.handlers.vm; + this.reffer.unref(vm); + old_context.deinit(ssl); + bun.default_allocator.destroy(this.handlers); + this.poll_ref.unref(vm); + this.has_pending_activity.store(false, .Release); + } + + const array = JSC.JSValue.createEmptyArray(globalObject, 2); + array.putIndex(globalObject, 0, raw_js_value); + array.putIndex(globalObject, 1, tls_js_value); + return array; + } }; } pub const TCPSocket = NewSocket(false); pub const TLSSocket = NewSocket(true); + +pub const WrappedSocket = extern struct { + // both shares the same socket but one behaves as TLS and the other as TCP + tls: *TLSSocket, + tcp: *TLSSocket, +}; + +pub fn NewWrappedHandler(comptime tls: bool) type { + const Socket = uws.NewSocketHandler(true); + return struct { + pub fn onOpen( + this: WrappedSocket, + socket: Socket, + ) void { + // only TLS will call onOpen + if (comptime tls) { + TLSSocket.onOpen(this.tls, socket); + } + } + + pub fn onEnd( + this: WrappedSocket, + socket: Socket, + ) void { + if (comptime tls) { + TLSSocket.onEnd(this.tls, socket); + } else { + TLSSocket.onEnd(this.tcp, socket); + } + } + + pub fn onHandshake( + this: WrappedSocket, + socket: Socket, + success: i32, + ssl_error: uws.us_bun_verify_error_t, + ) void { + // only TLS will call onHandshake + if (comptime tls) { + TLSSocket.onHandshake(this.tls, socket, success, ssl_error); + } + } + + pub fn onClose( + this: WrappedSocket, + socket: Socket, + err: c_int, + data: ?*anyopaque, + ) void { + if (comptime tls) { + TLSSocket.onClose(this.tls, socket, err, data); + } else { + TLSSocket.onClose(this.tcp, socket, err, data); + } + } + + pub fn onData( + this: WrappedSocket, + socket: Socket, + data: []const u8, + ) void { + if (comptime tls) { + TLSSocket.onData(this.tls, socket, data); + } else { + TLSSocket.onData(this.tcp, socket, data); + } + } + + pub fn onWritable( + this: WrappedSocket, + socket: Socket, + ) void { + if (comptime tls) { + TLSSocket.onWritable(this.tls, socket); + } else { + TLSSocket.onWritable(this.tcp, socket); + } + } + pub fn onTimeout( + this: WrappedSocket, + socket: Socket, + ) void { + if (comptime tls) { + TLSSocket.onTimeout(this.tls, socket); + } else { + TLSSocket.onTimeout(this.tcp, socket); + } + } + + pub fn onConnectError( + this: WrappedSocket, + socket: Socket, + errno: c_int, + ) void { + if (comptime tls) { + TLSSocket.onConnectError(this.tls, socket, errno); + } else { + TLSSocket.onConnectError(this.tcp, socket, errno); + } + } + }; +} diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 140e62ce4..f52c08301 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -163,6 +163,8 @@ pub const ServerConfig = struct { request_cert: i32 = 0, reject_unauthorized: i32 = 0, ssl_ciphers: [*c]const u8 = null, + protos: [*c]const u8 = null, + protos_len: usize = 0, const log = Output.scoped(.SSLConfig, false); @@ -215,6 +217,7 @@ pub const ServerConfig = struct { "dh_params_file_name", "passphrase", "ssl_ciphers", + "protos", }; inline for (fields) |field| { @@ -270,6 +273,9 @@ pub const ServerConfig = struct { pub fn inJS(global: *JSC.JSGlobalObject, obj: JSC.JSValue, exception: JSC.C.ExceptionRef) ?SSLConfig { var result = zero; + var arena: @import("root").bun.ArenaAllocator = @import("root").bun.ArenaAllocator.init(bun.default_allocator); + defer arena.deinit(); + if (!obj.isObject()) { JSC.throwInvalidArguments("tls option expects an object", .{}, global, exception); return null; @@ -301,7 +307,6 @@ pub const ServerConfig = struct { var i: u32 = 0; var valid_count: u32 = 0; - var arena: @import("root").bun.ArenaAllocator = @import("root").bun.ArenaAllocator.init(bun.default_allocator); while (i < count) : (i += 1) { const item = js_obj.getIndex(global, i); if (JSC.Node.StringOrBuffer.fromJS(global, arena.allocator(), item, exception)) |sb| { @@ -317,7 +322,6 @@ pub const ServerConfig = struct { valid_count += 1; any = true; } else { - arena.deinit(); // mark and free all CA's result.cert = native_array; result.deinit(); @@ -325,7 +329,6 @@ pub const ServerConfig = struct { } } else { global.throwInvalidArguments("key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", .{}); - arena.deinit(); // mark and free all keys result.key = native_array; result.deinit(); @@ -333,8 +336,6 @@ pub const ServerConfig = struct { } } - arena.deinit(); - if (valid_count == 0) { bun.default_allocator.free(native_array); } else { @@ -356,7 +357,6 @@ pub const ServerConfig = struct { } } else { const native_array = bun.default_allocator.alloc([*c]const u8, 1) catch unreachable; - var arena: @import("root").bun.ArenaAllocator = @import("root").bun.ArenaAllocator.init(bun.default_allocator); if (JSC.Node.StringOrBuffer.fromJS(global, arena.allocator(), js_obj, exception)) |sb| { const sliced = sb.slice(); if (sliced.len > 0) { @@ -369,14 +369,11 @@ pub const ServerConfig = struct { } } else { global.throwInvalidArguments("key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", .{}); - arena.deinit(); // mark and free all certs result.key = native_array; result.deinit(); return null; } - - arena.deinit(); } } @@ -394,6 +391,22 @@ pub const ServerConfig = struct { } } + if (obj.getTruthy(global, "ALPNProtocols")) |protocols| { + if (JSC.Node.StringOrBuffer.fromJS(global, arena.allocator(), protocols, exception)) |sb| { + const sliced = sb.slice(); + if (sliced.len > 0) { + result.protos = bun.default_allocator.dupeZ(u8, sliced) catch unreachable; + result.protos_len = sliced.len; + } + + any = true; + } else { + global.throwInvalidArguments("ALPNProtocols argument must be an string, Buffer or TypedArray", .{}); + result.deinit(); + return null; + } + } + if (obj.getTruthy(global, "cert")) |js_obj| { if (js_obj.jsType().isArray()) { const count = js_obj.getLength(global); @@ -403,7 +416,6 @@ pub const ServerConfig = struct { var i: u32 = 0; var valid_count: u32 = 0; - var arena: @import("root").bun.ArenaAllocator = @import("root").bun.ArenaAllocator.init(bun.default_allocator); while (i < count) : (i += 1) { const item = js_obj.getIndex(global, i); if (JSC.Node.StringOrBuffer.fromJS(global, arena.allocator(), item, exception)) |sb| { @@ -419,7 +431,6 @@ pub const ServerConfig = struct { valid_count += 1; any = true; } else { - arena.deinit(); // mark and free all CA's result.cert = native_array; result.deinit(); @@ -427,7 +438,6 @@ pub const ServerConfig = struct { } } else { global.throwInvalidArguments("cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", .{}); - arena.deinit(); // mark and free all certs result.cert = native_array; result.deinit(); @@ -435,8 +445,6 @@ pub const ServerConfig = struct { } } - arena.deinit(); - if (valid_count == 0) { bun.default_allocator.free(native_array); } else { @@ -458,7 +466,6 @@ pub const ServerConfig = struct { } } else { const native_array = bun.default_allocator.alloc([*c]const u8, 1) catch unreachable; - var arena: @import("root").bun.ArenaAllocator = @import("root").bun.ArenaAllocator.init(bun.default_allocator); if (JSC.Node.StringOrBuffer.fromJS(global, arena.allocator(), js_obj, exception)) |sb| { const sliced = sb.slice(); if (sliced.len > 0) { @@ -471,14 +478,11 @@ pub const ServerConfig = struct { } } else { global.throwInvalidArguments("cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", .{}); - arena.deinit(); // mark and free all certs result.cert = native_array; result.deinit(); return null; } - - arena.deinit(); } } @@ -518,7 +522,6 @@ pub const ServerConfig = struct { var i: u32 = 0; var valid_count: u32 = 0; - var arena: @import("root").bun.ArenaAllocator = @import("root").bun.ArenaAllocator.init(bun.default_allocator); while (i < count) : (i += 1) { const item = js_obj.getIndex(global, i); if (JSC.Node.StringOrBuffer.fromJS(global, arena.allocator(), item, exception)) |sb| { @@ -534,7 +537,6 @@ pub const ServerConfig = struct { valid_count += 1; any = true; } else { - arena.deinit(); // mark and free all CA's result.cert = native_array; result.deinit(); @@ -542,7 +544,6 @@ pub const ServerConfig = struct { } } else { global.throwInvalidArguments("ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", .{}); - arena.deinit(); // mark and free all CA's result.cert = native_array; result.deinit(); @@ -550,8 +551,6 @@ pub const ServerConfig = struct { } } - arena.deinit(); - if (valid_count == 0) { bun.default_allocator.free(native_array); } else { @@ -573,7 +572,6 @@ pub const ServerConfig = struct { } } else { const native_array = bun.default_allocator.alloc([*c]const u8, 1) catch unreachable; - var arena: @import("root").bun.ArenaAllocator = @import("root").bun.ArenaAllocator.init(bun.default_allocator); if (JSC.Node.StringOrBuffer.fromJS(global, arena.allocator(), js_obj, exception)) |sb| { const sliced = sb.slice(); if (sliced.len > 0) { @@ -586,13 +584,11 @@ pub const ServerConfig = struct { } } else { JSC.throwInvalidArguments("ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile", .{}, global, exception); - arena.deinit(); // mark and free all certs result.ca = native_array; result.deinit(); return null; } - arena.deinit(); } } diff --git a/src/bun.js/api/sockets.classes.ts b/src/bun.js/api/sockets.classes.ts index da07741a3..0c7847e19 100644 --- a/src/bun.js/api/sockets.classes.ts +++ b/src/bun.js/api/sockets.classes.ts @@ -15,10 +15,21 @@ function generate(ssl) { authorized: { getter: "getAuthorized", }, + alpnProtocol: { + getter: "getALPNProtocol", + }, write: { fn: "write", length: 3, }, + wrapTLS: { + fn: "wrapTLS", + length: 1, + }, + open: { + fn: "open", + length: 0, + }, end: { fn: "end", length: 3, @@ -82,6 +93,11 @@ function generate(ssl) { fn: "reload", length: 1, }, + + setServername: { + fn: "setServername", + length: 1, + }, }, finalize: true, construct: true, diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index 19bf05599..5f99d3792 100644 --- a/src/bun.js/bindings/JSSink.cpp +++ b/src/bun.js/bindings/JSSink.cpp @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-06-25T17:34:54.187Z +// Generated by 'make generate-sink' at 2023-07-02T16:19:51.440Z // To regenerate this file, run: // // make generate-sink diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h index 9bf5554c4..41d7065dc 100644 --- a/src/bun.js/bindings/JSSink.h +++ b/src/bun.js/bindings/JSSink.h @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-06-25T17:34:54.186Z +// Generated by 'make generate-sink' at 2023-07-02T16:19:51.438Z // #pragma once diff --git a/src/bun.js/bindings/JSSinkLookupTable.h b/src/bun.js/bindings/JSSinkLookupTable.h index f8518bc5e..e4ed81629 100644 --- a/src/bun.js/bindings/JSSinkLookupTable.h +++ b/src/bun.js/bindings/JSSinkLookupTable.h @@ -1,4 +1,4 @@ -// Automatically generated from src/bun.js/bindings/JSSink.cpp using /Users/silas/Workspace/opensource/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! +// Automatically generated from src/bun.js/bindings/JSSink.cpp using /home/cirospaciari/Repos/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp index b7461b5f0..866970e4d 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.cpp +++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp @@ -16872,6 +16872,9 @@ extern "C" void* TCPSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame* JSC_DECLARE_CUSTOM_GETTER(jsTCPSocketConstructor); extern "C" void TCPSocketClass__finalize(void*); +extern "C" JSC::EncodedJSValue TCPSocketPrototype__getALPNProtocol(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); +JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__alpnProtocolGetterWrap); + extern "C" JSC::EncodedJSValue TCPSocketPrototype__getAuthorized(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__authorizedGetterWrap); @@ -16896,6 +16899,9 @@ JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__listenerGetterWrap); extern "C" JSC::EncodedJSValue TCPSocketPrototype__getLocalPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__localPortGetterWrap); +extern "C" EncodedJSValue TCPSocketPrototype__open(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__openCallback); + extern "C" JSC::EncodedJSValue TCPSocketPrototype__getReadyState(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__readyStateGetterWrap); @@ -16908,6 +16914,9 @@ JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__reloadCallback); extern "C" JSC::EncodedJSValue TCPSocketPrototype__getRemoteAddress(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__remoteAddressGetterWrap); +extern "C" EncodedJSValue TCPSocketPrototype__setServername(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__setServernameCallback); + extern "C" EncodedJSValue TCPSocketPrototype__shutdown(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__shutdownCallback); @@ -16917,12 +16926,16 @@ JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__timeoutCallback); extern "C" EncodedJSValue TCPSocketPrototype__unref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback); +extern "C" EncodedJSValue TCPSocketPrototype__wrapTLS(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__wrapTLSCallback); + extern "C" EncodedJSValue TCPSocketPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__writeCallback); STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTCPSocketPrototype, JSTCPSocketPrototype::Base); static const HashTableValue JSTCPSocketPrototypeTableValues[] = { + { "alpnProtocol"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__alpnProtocolGetterWrap, 0 } }, { "authorized"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__authorizedGetterWrap, 0 } }, { "data"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__dataGetterWrap, TCPSocketPrototype__dataSetterWrap } }, { "end"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__endCallback, 3 } }, @@ -16930,13 +16943,16 @@ static const HashTableValue JSTCPSocketPrototypeTableValues[] = { { "getAuthorizationError"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__getAuthorizationErrorCallback, 0 } }, { "listener"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__listenerGetterWrap, 0 } }, { "localPort"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__localPortGetterWrap, 0 } }, + { "open"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__openCallback, 0 } }, { "readyState"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__readyStateGetterWrap, 0 } }, { "ref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__refCallback, 0 } }, { "reload"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__reloadCallback, 1 } }, { "remoteAddress"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__remoteAddressGetterWrap, 0 } }, + { "setServername"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__setServernameCallback, 1 } }, { "shutdown"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__shutdownCallback, 1 } }, { "timeout"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__timeoutCallback, 1 } }, { "unref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__unrefCallback, 0 } }, + { "wrapTLS"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__wrapTLSCallback, 1 } }, { "write"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__writeCallback, 3 } } }; @@ -16954,6 +16970,18 @@ JSC_DEFINE_CUSTOM_GETTER(jsTCPSocketConstructor, (JSGlobalObject * lexicalGlobal return JSValue::encode(globalObject->JSTCPSocketConstructor()); } +JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__alpnProtocolGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) +{ + auto& vm = lexicalGlobalObject->vm(); + Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + auto throwScope = DECLARE_THROW_SCOPE(vm); + JSTCPSocket* thisObject = jsCast(JSValue::decode(thisValue)); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EncodedJSValue result = TCPSocketPrototype__getALPNProtocol(thisObject->wrapped(), globalObject); + RETURN_IF_EXCEPTION(throwScope, {}); + RELEASE_AND_RETURN(throwScope, result); +} + JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__authorizedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { auto& vm = lexicalGlobalObject->vm(); @@ -17113,6 +17141,33 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__localPortGetterWrap, (JSGlobalObjec RELEASE_AND_RETURN(throwScope, result); } +JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__openCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSTCPSocket* 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 TCPSocketPrototype__open(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__readyStateGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { auto& vm = lexicalGlobalObject->vm(); @@ -17210,6 +17265,33 @@ extern "C" EncodedJSValue TCPSocketPrototype__remoteAddressGetCachedValue(JSC::E return JSValue::encode(thisObject->m_remoteAddress.get()); } +JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__setServernameCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSTCPSocket* 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 TCPSocketPrototype__setServername(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { auto& vm = lexicalGlobalObject->vm(); @@ -17291,6 +17373,33 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback, (JSGlobalObject * le return TCPSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); } +JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__wrapTLSCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSTCPSocket* 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 TCPSocketPrototype__wrapTLS(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { auto& vm = lexicalGlobalObject->vm(); @@ -17479,6 +17588,9 @@ extern "C" void* TLSSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame* JSC_DECLARE_CUSTOM_GETTER(jsTLSSocketConstructor); extern "C" void TLSSocketClass__finalize(void*); +extern "C" JSC::EncodedJSValue TLSSocketPrototype__getALPNProtocol(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); +JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__alpnProtocolGetterWrap); + extern "C" JSC::EncodedJSValue TLSSocketPrototype__getAuthorized(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__authorizedGetterWrap); @@ -17503,6 +17615,9 @@ JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__listenerGetterWrap); extern "C" JSC::EncodedJSValue TLSSocketPrototype__getLocalPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__localPortGetterWrap); +extern "C" EncodedJSValue TLSSocketPrototype__open(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__openCallback); + extern "C" JSC::EncodedJSValue TLSSocketPrototype__getReadyState(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__readyStateGetterWrap); @@ -17515,6 +17630,9 @@ JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__reloadCallback); extern "C" JSC::EncodedJSValue TLSSocketPrototype__getRemoteAddress(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__remoteAddressGetterWrap); +extern "C" EncodedJSValue TLSSocketPrototype__setServername(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__setServernameCallback); + extern "C" EncodedJSValue TLSSocketPrototype__shutdown(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__shutdownCallback); @@ -17524,12 +17642,16 @@ JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__timeoutCallback); extern "C" EncodedJSValue TLSSocketPrototype__unref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback); +extern "C" EncodedJSValue TLSSocketPrototype__wrapTLS(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__wrapTLSCallback); + extern "C" EncodedJSValue TLSSocketPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__writeCallback); STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTLSSocketPrototype, JSTLSSocketPrototype::Base); static const HashTableValue JSTLSSocketPrototypeTableValues[] = { + { "alpnProtocol"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__alpnProtocolGetterWrap, 0 } }, { "authorized"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__authorizedGetterWrap, 0 } }, { "data"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__dataGetterWrap, TLSSocketPrototype__dataSetterWrap } }, { "end"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__endCallback, 3 } }, @@ -17537,13 +17659,16 @@ static const HashTableValue JSTLSSocketPrototypeTableValues[] = { { "getAuthorizationError"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__getAuthorizationErrorCallback, 0 } }, { "listener"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__listenerGetterWrap, 0 } }, { "localPort"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__localPortGetterWrap, 0 } }, + { "open"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__openCallback, 0 } }, { "readyState"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__readyStateGetterWrap, 0 } }, { "ref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__refCallback, 0 } }, { "reload"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__reloadCallback, 1 } }, { "remoteAddress"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__remoteAddressGetterWrap, 0 } }, + { "setServername"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__setServernameCallback, 1 } }, { "shutdown"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__shutdownCallback, 1 } }, { "timeout"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__timeoutCallback, 1 } }, { "unref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__unrefCallback, 0 } }, + { "wrapTLS"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__wrapTLSCallback, 1 } }, { "write"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__writeCallback, 3 } } }; @@ -17561,6 +17686,18 @@ JSC_DEFINE_CUSTOM_GETTER(jsTLSSocketConstructor, (JSGlobalObject * lexicalGlobal return JSValue::encode(globalObject->JSTLSSocketConstructor()); } +JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__alpnProtocolGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) +{ + auto& vm = lexicalGlobalObject->vm(); + Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); + auto throwScope = DECLARE_THROW_SCOPE(vm); + JSTLSSocket* thisObject = jsCast(JSValue::decode(thisValue)); + JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + JSC::EncodedJSValue result = TLSSocketPrototype__getALPNProtocol(thisObject->wrapped(), globalObject); + RETURN_IF_EXCEPTION(throwScope, {}); + RELEASE_AND_RETURN(throwScope, result); +} + JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__authorizedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { auto& vm = lexicalGlobalObject->vm(); @@ -17720,6 +17857,33 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__localPortGetterWrap, (JSGlobalObjec RELEASE_AND_RETURN(throwScope, result); } +JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__openCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSTLSSocket* 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 TLSSocketPrototype__open(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__readyStateGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { auto& vm = lexicalGlobalObject->vm(); @@ -17817,6 +17981,33 @@ extern "C" EncodedJSValue TLSSocketPrototype__remoteAddressGetCachedValue(JSC::E return JSValue::encode(thisObject->m_remoteAddress.get()); } +JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__setServernameCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSTLSSocket* 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 TLSSocketPrototype__setServername(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { auto& vm = lexicalGlobalObject->vm(); @@ -17898,6 +18089,33 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback, (JSGlobalObject * le return TLSSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); } +JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__wrapTLSCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +{ + auto& vm = lexicalGlobalObject->vm(); + + JSTLSSocket* 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 TLSSocketPrototype__wrapTLS(thisObject->wrapped(), lexicalGlobalObject, callFrame); +} + JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__writeCallback, (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 04a72d7ed..a220b6814 100644 --- a/src/bun.js/bindings/generated_classes.zig +++ b/src/bun.js/bindings/generated_classes.zig @@ -4426,6 +4426,9 @@ pub const JSTCPSocket = struct { @compileLog("TCPSocket.finalize is not a finalizer"); } + if (@TypeOf(TCPSocket.getALPNProtocol) != GetterType) + @compileLog("Expected TCPSocket.getALPNProtocol to be a getter"); + if (@TypeOf(TCPSocket.getAuthorized) != GetterType) @compileLog("Expected TCPSocket.getAuthorized to be a getter"); @@ -4446,6 +4449,8 @@ pub const JSTCPSocket = struct { if (@TypeOf(TCPSocket.getLocalPort) != GetterType) @compileLog("Expected TCPSocket.getLocalPort to be a getter"); + if (@TypeOf(TCPSocket.open) != CallbackType) + @compileLog("Expected TCPSocket.open to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.open))); if (@TypeOf(TCPSocket.getReadyState) != GetterType) @compileLog("Expected TCPSocket.getReadyState to be a getter"); @@ -4456,18 +4461,23 @@ pub const JSTCPSocket = struct { if (@TypeOf(TCPSocket.getRemoteAddress) != GetterType) @compileLog("Expected TCPSocket.getRemoteAddress to be a getter"); + if (@TypeOf(TCPSocket.setServername) != CallbackType) + @compileLog("Expected TCPSocket.setServername to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.setServername))); if (@TypeOf(TCPSocket.shutdown) != CallbackType) @compileLog("Expected TCPSocket.shutdown to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.shutdown))); if (@TypeOf(TCPSocket.timeout) != CallbackType) @compileLog("Expected TCPSocket.timeout to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.timeout))); if (@TypeOf(TCPSocket.unref) != CallbackType) @compileLog("Expected TCPSocket.unref to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.unref))); + if (@TypeOf(TCPSocket.wrapTLS) != CallbackType) + @compileLog("Expected TCPSocket.wrapTLS to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.wrapTLS))); if (@TypeOf(TCPSocket.write) != CallbackType) @compileLog("Expected TCPSocket.write to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.write))); if (!JSC.is_bindgen) { @export(TCPSocket.end, .{ .name = "TCPSocketPrototype__end" }); @export(TCPSocket.finalize, .{ .name = "TCPSocketClass__finalize" }); @export(TCPSocket.flush, .{ .name = "TCPSocketPrototype__flush" }); + @export(TCPSocket.getALPNProtocol, .{ .name = "TCPSocketPrototype__getALPNProtocol" }); @export(TCPSocket.getAuthorizationError, .{ .name = "TCPSocketPrototype__getAuthorizationError" }); @export(TCPSocket.getAuthorized, .{ .name = "TCPSocketPrototype__getAuthorized" }); @export(TCPSocket.getData, .{ .name = "TCPSocketPrototype__getData" }); @@ -4476,12 +4486,15 @@ pub const JSTCPSocket = struct { @export(TCPSocket.getReadyState, .{ .name = "TCPSocketPrototype__getReadyState" }); @export(TCPSocket.getRemoteAddress, .{ .name = "TCPSocketPrototype__getRemoteAddress" }); @export(TCPSocket.hasPendingActivity, .{ .name = "TCPSocket__hasPendingActivity" }); + @export(TCPSocket.open, .{ .name = "TCPSocketPrototype__open" }); @export(TCPSocket.ref, .{ .name = "TCPSocketPrototype__ref" }); @export(TCPSocket.reload, .{ .name = "TCPSocketPrototype__reload" }); @export(TCPSocket.setData, .{ .name = "TCPSocketPrototype__setData" }); + @export(TCPSocket.setServername, .{ .name = "TCPSocketPrototype__setServername" }); @export(TCPSocket.shutdown, .{ .name = "TCPSocketPrototype__shutdown" }); @export(TCPSocket.timeout, .{ .name = "TCPSocketPrototype__timeout" }); @export(TCPSocket.unref, .{ .name = "TCPSocketPrototype__unref" }); + @export(TCPSocket.wrapTLS, .{ .name = "TCPSocketPrototype__wrapTLS" }); @export(TCPSocket.write, .{ .name = "TCPSocketPrototype__write" }); } } @@ -4581,6 +4594,9 @@ pub const JSTLSSocket = struct { @compileLog("TLSSocket.finalize is not a finalizer"); } + if (@TypeOf(TLSSocket.getALPNProtocol) != GetterType) + @compileLog("Expected TLSSocket.getALPNProtocol to be a getter"); + if (@TypeOf(TLSSocket.getAuthorized) != GetterType) @compileLog("Expected TLSSocket.getAuthorized to be a getter"); @@ -4601,6 +4617,8 @@ pub const JSTLSSocket = struct { if (@TypeOf(TLSSocket.getLocalPort) != GetterType) @compileLog("Expected TLSSocket.getLocalPort to be a getter"); + if (@TypeOf(TLSSocket.open) != CallbackType) + @compileLog("Expected TLSSocket.open to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.open))); if (@TypeOf(TLSSocket.getReadyState) != GetterType) @compileLog("Expected TLSSocket.getReadyState to be a getter"); @@ -4611,18 +4629,23 @@ pub const JSTLSSocket = struct { if (@TypeOf(TLSSocket.getRemoteAddress) != GetterType) @compileLog("Expected TLSSocket.getRemoteAddress to be a getter"); + if (@TypeOf(TLSSocket.setServername) != CallbackType) + @compileLog("Expected TLSSocket.setServername to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.setServername))); if (@TypeOf(TLSSocket.shutdown) != CallbackType) @compileLog("Expected TLSSocket.shutdown to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.shutdown))); if (@TypeOf(TLSSocket.timeout) != CallbackType) @compileLog("Expected TLSSocket.timeout to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.timeout))); if (@TypeOf(TLSSocket.unref) != CallbackType) @compileLog("Expected TLSSocket.unref to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.unref))); + if (@TypeOf(TLSSocket.wrapTLS) != CallbackType) + @compileLog("Expected TLSSocket.wrapTLS to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.wrapTLS))); if (@TypeOf(TLSSocket.write) != CallbackType) @compileLog("Expected TLSSocket.write to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.write))); if (!JSC.is_bindgen) { @export(TLSSocket.end, .{ .name = "TLSSocketPrototype__end" }); @export(TLSSocket.finalize, .{ .name = "TLSSocketClass__finalize" }); @export(TLSSocket.flush, .{ .name = "TLSSocketPrototype__flush" }); + @export(TLSSocket.getALPNProtocol, .{ .name = "TLSSocketPrototype__getALPNProtocol" }); @export(TLSSocket.getAuthorizationError, .{ .name = "TLSSocketPrototype__getAuthorizationError" }); @export(TLSSocket.getAuthorized, .{ .name = "TLSSocketPrototype__getAuthorized" }); @export(TLSSocket.getData, .{ .name = "TLSSocketPrototype__getData" }); @@ -4631,12 +4654,15 @@ pub const JSTLSSocket = struct { @export(TLSSocket.getReadyState, .{ .name = "TLSSocketPrototype__getReadyState" }); @export(TLSSocket.getRemoteAddress, .{ .name = "TLSSocketPrototype__getRemoteAddress" }); @export(TLSSocket.hasPendingActivity, .{ .name = "TLSSocket__hasPendingActivity" }); + @export(TLSSocket.open, .{ .name = "TLSSocketPrototype__open" }); @export(TLSSocket.ref, .{ .name = "TLSSocketPrototype__ref" }); @export(TLSSocket.reload, .{ .name = "TLSSocketPrototype__reload" }); @export(TLSSocket.setData, .{ .name = "TLSSocketPrototype__setData" }); + @export(TLSSocket.setServername, .{ .name = "TLSSocketPrototype__setServername" }); @export(TLSSocket.shutdown, .{ .name = "TLSSocketPrototype__shutdown" }); @export(TLSSocket.timeout, .{ .name = "TLSSocketPrototype__timeout" }); @export(TLSSocket.unref, .{ .name = "TLSSocketPrototype__unref" }); + @export(TLSSocket.wrapTLS, .{ .name = "TLSSocketPrototype__wrapTLS" }); @export(TLSSocket.write, .{ .name = "TLSSocketPrototype__write" }); } } diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.cpp b/src/bun.js/bindings/webcore/JSEventEmitter.cpp index 1957b404b..231ae0db4 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitter.cpp +++ b/src/bun.js/bindings/webcore/JSEventEmitter.cpp @@ -149,7 +149,7 @@ static const HashTableValue JSEventEmitterPrototypeTableValues[] = { { "on"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_addListener, 2 } }, { "once"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_addOnceListener, 2 } }, { "prependListener"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_prependListener, 2 } }, - { "prependOnce"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_prependOnceListener, 2 } }, + { "prependOnceListener"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_prependOnceListener, 2 } }, { "removeListener"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_removeListener, 2 } }, { "off"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_removeListener, 2 } }, { "removeAllListeners"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsEventEmitterPrototypeFunction_removeAllListeners, 1 } }, diff --git a/src/deps/uws b/src/deps/uws index d82c4a95d..875948226 160000 --- a/src/deps/uws +++ b/src/deps/uws @@ -1 +1 @@ -Subproject commit d82c4a95de3af01614ecb12bfff821611b4cc6b7 +Subproject commit 875948226eede72861a5170212ff6b43c4b7d7f9 diff --git a/src/deps/uws.zig b/src/deps/uws.zig index 8ebe04ac0..5dbe4f5d8 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -40,6 +40,129 @@ pub fn NewSocketHandler(comptime ssl: bool) type { return us_socket_timeout(comptime ssl_int, this.socket, seconds); } + pub fn open(this: ThisSocket, is_client: bool) void { + _ = us_socket_open(comptime ssl_int, this.socket, @intFromBool(is_client), null, 0); + } + + // Note: this assumes that the socket is non-TLS and will be adopted and wrapped with a new TLS context + // context ext will not be copied to the new context, new context will contain us_wrapped_socket_context_t on ext + pub fn wrapTLS( + this: ThisSocket, + options: us_bun_socket_context_options_t, + socket_ext_size: i32, + comptime deref: bool, + comptime ContextType: type, + comptime Fields: anytype, + ) ?NewSocketHandler(true) { + const Type = comptime if (@TypeOf(Fields) != type) @TypeOf(Fields) else Fields; + const TLSSocket = NewSocketHandler(true); + const SocketHandler = struct { + const alignment = if (ContextType == anyopaque) + @sizeOf(usize) + else + std.meta.alignment(ContextType); + const deref_ = deref; + const ValueType = if (deref) ContextType else *ContextType; + fn getValue(socket: *Socket) ValueType { + if (comptime ContextType == anyopaque) { + return us_socket_ext(1, socket).?; + } + + if (comptime deref_) { + return (TLSSocket{ .socket = socket }).ext(ContextType).?.*; + } + + return (TLSSocket{ .socket = socket }).ext(ContextType).?; + } + + pub fn on_open(socket: *Socket, is_client: i32, _: [*c]u8, _: i32) callconv(.C) ?*Socket { + if (comptime @hasDecl(Fields, "onCreate")) { + if (is_client == 0) { + Fields.onCreate( + TLSSocket{ .socket = socket }, + ); + } + } + Fields.onOpen( + getValue(socket), + TLSSocket{ .socket = socket }, + ); + return socket; + } + pub fn on_close(socket: *Socket, code: i32, reason: ?*anyopaque) callconv(.C) ?*Socket { + Fields.onClose( + getValue(socket), + TLSSocket{ .socket = socket }, + code, + reason, + ); + return socket; + } + pub fn on_data(socket: *Socket, buf: ?[*]u8, len: i32) callconv(.C) ?*Socket { + Fields.onData( + getValue(socket), + TLSSocket{ .socket = socket }, + buf.?[0..@intCast(usize, len)], + ); + return socket; + } + pub fn on_writable(socket: *Socket) callconv(.C) ?*Socket { + Fields.onWritable( + getValue(socket), + TLSSocket{ .socket = socket }, + ); + return socket; + } + pub fn on_timeout(socket: *Socket) callconv(.C) ?*Socket { + Fields.onTimeout( + getValue(socket), + TLSSocket{ .socket = socket }, + ); + return socket; + } + pub fn on_connect_error(socket: *Socket, code: i32) callconv(.C) ?*Socket { + Fields.onConnectError( + getValue(socket), + TLSSocket{ .socket = socket }, + code, + ); + return socket; + } + pub fn on_end(socket: *Socket) callconv(.C) ?*Socket { + Fields.onEnd( + getValue(socket), + TLSSocket{ .socket = socket }, + ); + return socket; + } + pub fn on_handshake(socket: *Socket, success: i32, verify_error: us_bun_verify_error_t, _: ?*anyopaque) callconv(.C) void { + Fields.onHandshake(getValue(socket), TLSSocket{ .socket = socket }, success, verify_error); + } + }; + + var events: us_socket_events_t = .{}; + + if (comptime @hasDecl(Type, "onOpen") and @typeInfo(@TypeOf(Type.onOpen)) != .Null) + events.on_open = SocketHandler.on_open; + if (comptime @hasDecl(Type, "onClose") and @typeInfo(@TypeOf(Type.onClose)) != .Null) + events.on_close = SocketHandler.on_close; + if (comptime @hasDecl(Type, "onData") and @typeInfo(@TypeOf(Type.onData)) != .Null) + events.on_data = SocketHandler.on_data; + if (comptime @hasDecl(Type, "onWritable") and @typeInfo(@TypeOf(Type.onWritable)) != .Null) + events.on_writable = SocketHandler.on_writable; + if (comptime @hasDecl(Type, "onTimeout") and @typeInfo(@TypeOf(Type.onTimeout)) != .Null) + events.on_timeout = SocketHandler.on_timeout; + if (comptime @hasDecl(Type, "onConnectError") and @typeInfo(@TypeOf(Type.onConnectError)) != .Null) + events.on_connect_error = SocketHandler.on_connect_error; + if (comptime @hasDecl(Type, "onEnd") and @typeInfo(@TypeOf(Type.onEnd)) != .Null) + events.on_end = SocketHandler.on_end; + if (comptime @hasDecl(Type, "onHandshake") and @typeInfo(@TypeOf(Type.onHandshake)) != .Null) + events.on_handshake = SocketHandler.on_handshake; + + const socket = us_socket_wrap_with_tls(ssl_int, this.socket, options, events, socket_ext_size) orelse return null; + return NewSocketHandler(true).from(socket); + } + pub fn getNativeHandle(this: ThisSocket) *NativeSocketHandleType(ssl) { return @ptrCast(*NativeSocketHandleType(ssl), us_socket_get_native_handle(comptime ssl_int, this.socket).?); } @@ -95,6 +218,17 @@ pub fn NewSocketHandler(comptime ssl: bool) type { @as(i32, @intFromBool(msg_more)), ); } + + pub fn rawWrite(this: ThisSocket, data: []const u8, msg_more: bool) i32 { + return us_socket_raw_write( + comptime ssl_int, + this.socket, + data.ptr, + // truncate to 31 bits since sign bit exists + @intCast(i32, @truncate(u31, data.len)), + @as(i32, @intFromBool(msg_more)), + ); + } pub fn shutdown(this: ThisSocket) void { debug("us_socket_shutdown({d})", .{@intFromPtr(this.socket)}); return us_socket_shutdown( @@ -241,13 +375,126 @@ pub fn NewSocketHandler(comptime ssl: bool) type { return socket_; } + pub fn unsafeConfigure( + ctx: *SocketContext, + comptime ssl_type: bool, + comptime deref: bool, + comptime ContextType: type, + comptime Fields: anytype, + ) void { + const SocketHandlerType = NewSocketHandler(ssl_type); + const ssl_type_int: i32 = @intFromBool(ssl_type); + const Type = comptime if (@TypeOf(Fields) != type) @TypeOf(Fields) else Fields; + + const SocketHandler = struct { + const alignment = if (ContextType == anyopaque) + @sizeOf(usize) + else + std.meta.alignment(ContextType); + const deref_ = deref; + const ValueType = if (deref) ContextType else *ContextType; + fn getValue(socket: *Socket) ValueType { + if (comptime ContextType == anyopaque) { + return us_socket_ext(ssl_type_int, socket).?; + } + + if (comptime deref_) { + return (SocketHandlerType{ .socket = socket }).ext(ContextType).?.*; + } + + return (SocketHandlerType{ .socket = socket }).ext(ContextType).?; + } + + pub fn on_open(socket: *Socket, is_client: i32, _: [*c]u8, _: i32) callconv(.C) ?*Socket { + if (comptime @hasDecl(Fields, "onCreate")) { + if (is_client == 0) { + Fields.onCreate( + SocketHandlerType{ .socket = socket }, + ); + } + } + Fields.onOpen( + getValue(socket), + SocketHandlerType{ .socket = socket }, + ); + return socket; + } + pub fn on_close(socket: *Socket, code: i32, reason: ?*anyopaque) callconv(.C) ?*Socket { + Fields.onClose( + getValue(socket), + SocketHandlerType{ .socket = socket }, + code, + reason, + ); + return socket; + } + pub fn on_data(socket: *Socket, buf: ?[*]u8, len: i32) callconv(.C) ?*Socket { + Fields.onData( + getValue(socket), + SocketHandlerType{ .socket = socket }, + buf.?[0..@intCast(usize, len)], + ); + return socket; + } + pub fn on_writable(socket: *Socket) callconv(.C) ?*Socket { + Fields.onWritable( + getValue(socket), + SocketHandlerType{ .socket = socket }, + ); + return socket; + } + pub fn on_timeout(socket: *Socket) callconv(.C) ?*Socket { + Fields.onTimeout( + getValue(socket), + SocketHandlerType{ .socket = socket }, + ); + return socket; + } + pub fn on_connect_error(socket: *Socket, code: i32) callconv(.C) ?*Socket { + Fields.onConnectError( + getValue(socket), + SocketHandlerType{ .socket = socket }, + code, + ); + return socket; + } + pub fn on_end(socket: *Socket) callconv(.C) ?*Socket { + Fields.onEnd( + getValue(socket), + SocketHandlerType{ .socket = socket }, + ); + return socket; + } + pub fn on_handshake(socket: *Socket, success: i32, verify_error: us_bun_verify_error_t, _: ?*anyopaque) callconv(.C) void { + Fields.onHandshake(getValue(socket), SocketHandlerType{ .socket = socket }, success, verify_error); + } + }; + + if (comptime @hasDecl(Type, "onOpen") and @typeInfo(@TypeOf(Type.onOpen)) != .Null) + us_socket_context_on_open(ssl_int, ctx, SocketHandler.on_open); + if (comptime @hasDecl(Type, "onClose") and @typeInfo(@TypeOf(Type.onClose)) != .Null) + us_socket_context_on_close(ssl_int, ctx, SocketHandler.on_close); + if (comptime @hasDecl(Type, "onData") and @typeInfo(@TypeOf(Type.onData)) != .Null) + us_socket_context_on_data(ssl_int, ctx, SocketHandler.on_data); + if (comptime @hasDecl(Type, "onWritable") and @typeInfo(@TypeOf(Type.onWritable)) != .Null) + us_socket_context_on_writable(ssl_int, ctx, SocketHandler.on_writable); + if (comptime @hasDecl(Type, "onTimeout") and @typeInfo(@TypeOf(Type.onTimeout)) != .Null) + us_socket_context_on_timeout(ssl_int, ctx, SocketHandler.on_timeout); + if (comptime @hasDecl(Type, "onConnectError") and @typeInfo(@TypeOf(Type.onConnectError)) != .Null) + us_socket_context_on_connect_error(ssl_int, ctx, SocketHandler.on_connect_error); + if (comptime @hasDecl(Type, "onEnd") and @typeInfo(@TypeOf(Type.onEnd)) != .Null) + us_socket_context_on_end(ssl_int, ctx, SocketHandler.on_end); + if (comptime @hasDecl(Type, "onHandshake") and @typeInfo(@TypeOf(Type.onHandshake)) != .Null) + us_socket_context_on_handshake(ssl_int, ctx, SocketHandler.on_handshake, null); + } + pub fn configure( ctx: *SocketContext, comptime deref: bool, comptime ContextType: type, comptime Fields: anytype, ) void { - const @"type" = comptime if (@TypeOf(Fields) != type) @TypeOf(Fields) else Fields; + const Type = comptime if (@TypeOf(Fields) != type) @TypeOf(Fields) else Fields; const SocketHandler = struct { const alignment = if (ContextType == anyopaque) @@ -333,21 +580,21 @@ pub fn NewSocketHandler(comptime ssl: bool) type { } }; - if (comptime @hasDecl(@"type", "onOpen") and @typeInfo(@TypeOf(@"type".onOpen)) != .Null) + if (comptime @hasDecl(Type, "onOpen") and @typeInfo(@TypeOf(Type.onOpen)) != .Null) us_socket_context_on_open(ssl_int, ctx, SocketHandler.on_open); - if (comptime @hasDecl(@"type", "onClose") and @typeInfo(@TypeOf(@"type".onClose)) != .Null) + if (comptime @hasDecl(Type, "onClose") and @typeInfo(@TypeOf(Type.onClose)) != .Null) us_socket_context_on_close(ssl_int, ctx, SocketHandler.on_close); - if (comptime @hasDecl(@"type", "onData") and @typeInfo(@TypeOf(@"type".onData)) != .Null) + if (comptime @hasDecl(Type, "onData") and @typeInfo(@TypeOf(Type.onData)) != .Null) us_socket_context_on_data(ssl_int, ctx, SocketHandler.on_data); - if (comptime @hasDecl(@"type", "onWritable") and @typeInfo(@TypeOf(@"type".onWritable)) != .Null) + if (comptime @hasDecl(Type, "onWritable") and @typeInfo(@TypeOf(Type.onWritable)) != .Null) us_socket_context_on_writable(ssl_int, ctx, SocketHandler.on_writable); - if (comptime @hasDecl(@"type", "onTimeout") and @typeInfo(@TypeOf(@"type".onTimeout)) != .Null) + if (comptime @hasDecl(Type, "onTimeout") and @typeInfo(@TypeOf(Type.onTimeout)) != .Null) us_socket_context_on_timeout(ssl_int, ctx, SocketHandler.on_timeout); - if (comptime @hasDecl(@"type", "onConnectError") and @typeInfo(@TypeOf(@"type".onConnectError)) != .Null) + if (comptime @hasDecl(Type, "onConnectError") and @typeInfo(@TypeOf(Type.onConnectError)) != .Null) us_socket_context_on_connect_error(ssl_int, ctx, SocketHandler.on_connect_error); - if (comptime @hasDecl(@"type", "onEnd") and @typeInfo(@TypeOf(@"type".onEnd)) != .Null) + if (comptime @hasDecl(Type, "onEnd") and @typeInfo(@TypeOf(Type.onEnd)) != .Null) us_socket_context_on_end(ssl_int, ctx, SocketHandler.on_end); - if (comptime @hasDecl(@"type", "onHandshake") and @typeInfo(@TypeOf(@"type".onHandshake)) != .Null) + if (comptime @hasDecl(Type, "onHandshake") and @typeInfo(@TypeOf(Type.onHandshake)) != .Null) us_socket_context_on_handshake(ssl_int, ctx, SocketHandler.on_handshake, null); } @@ -659,6 +906,20 @@ pub const us_bun_verify_error_t = extern struct { reason: [*c]const u8 = null, }; +pub const us_socket_events_t = extern struct { + on_open: ?*const fn (*Socket, i32, [*c]u8, i32) callconv(.C) ?*Socket = null, + on_data: ?*const fn (*Socket, [*c]u8, i32) callconv(.C) ?*Socket = null, + on_writable: ?*const fn (*Socket) callconv(.C) ?*Socket = null, + on_close: ?*const fn (*Socket, i32, ?*anyopaque) callconv(.C) ?*Socket = null, + + on_timeout: ?*const fn (*Socket) callconv(.C) ?*Socket = null, + on_long_timeout: ?*const fn (*Socket) callconv(.C) ?*Socket = null, + on_end: ?*const fn (*Socket) callconv(.C) ?*Socket = null, + on_connect_error: ?*const fn (*Socket, i32) callconv(.C) ?*Socket = null, + on_handshake: ?*const fn (*Socket, i32, us_bun_verify_error_t, ?*anyopaque) callconv(.C) void = null, +}; + +pub extern fn us_socket_wrap_with_tls(ssl: i32, s: *Socket, options: us_bun_socket_context_options_t, events: us_socket_events_t, socket_ext_size: i32) ?*Socket; extern fn us_socket_verify_error(ssl: i32, context: *Socket) us_bun_verify_error_t; extern fn SocketContextimestamp(ssl: i32, context: ?*SocketContext) c_ushort; pub extern fn us_socket_context_add_server_name(ssl: i32, context: ?*SocketContext, hostname_pattern: [*c]const u8, options: us_socket_context_options_t, ?*anyopaque) void; @@ -777,11 +1038,16 @@ extern fn us_socket_ext(ssl: i32, s: ?*Socket) ?*anyopaque; extern fn us_socket_context(ssl: i32, s: ?*Socket) ?*SocketContext; extern fn us_socket_flush(ssl: i32, s: ?*Socket) void; extern fn us_socket_write(ssl: i32, s: ?*Socket, data: [*c]const u8, length: i32, msg_more: i32) i32; +extern fn us_socket_raw_write(ssl: i32, s: ?*Socket, data: [*c]const u8, length: i32, msg_more: i32) i32; extern fn us_socket_shutdown(ssl: i32, s: ?*Socket) void; extern fn us_socket_shutdown_read(ssl: i32, s: ?*Socket) void; extern fn us_socket_is_shut_down(ssl: i32, s: ?*Socket) i32; extern fn us_socket_is_closed(ssl: i32, s: ?*Socket) i32; extern fn us_socket_close(ssl: i32, s: ?*Socket, code: i32, reason: ?*anyopaque) ?*Socket; +// if a TLS socket calls this, it will start SSL instance and call open event will also do TLS handshake if required +// will have no effect if the socket is closed or is not TLS +extern fn us_socket_open(ssl: i32, s: ?*Socket, is_client: i32, ip: [*c]const u8, ip_length: i32) ?*Socket; + extern fn us_socket_local_port(ssl: i32, s: ?*Socket) i32; extern fn us_socket_remote_address(ssl: i32, s: ?*Socket, buf: [*c]u8, length: [*c]i32) void; pub const uws_app_s = opaque {}; diff --git a/src/js/node/net.js b/src/js/node/net.js index 430a0dfa2..1b7742dd1 100644 --- a/src/js/node/net.js +++ b/src/js/node/net.js @@ -64,6 +64,7 @@ const bunTlsSymbol = Symbol.for("::buntls::"); const bunSocketServerHandlers = Symbol.for("::bunsocket_serverhandlers::"); const bunSocketServerConnections = Symbol.for("::bunnetserverconnections::"); const bunSocketServerOptions = Symbol.for("::bunnetserveroptions::"); +const bunSocketInternal = Symbol.for("::bunnetsocketinternal::"); var SocketClass; const Socket = (function (InternalSocket) { @@ -117,7 +118,7 @@ const Socket = (function (InternalSocket) { const self = socket.data; socket.timeout(self.timeout); socket.ref(); - self.#socket = socket; + self[bunSocketInternal] = socket; self.connecting = false; self.emit("connect", self); Socket.#Drain(socket); @@ -164,7 +165,7 @@ const Socket = (function (InternalSocket) { if (self.#closed) return; self.#closed = true; //socket cannot be used after close - self.#socket = null; + self[bunSocketInternal] = null; const queue = self.#readQueue; if (queue.isEmpty()) { if (self.push(null)) return; @@ -289,23 +290,33 @@ const Socket = (function (InternalSocket) { localAddress = "127.0.0.1"; #readQueue = createFIFO(); remotePort; - #socket; + [bunSocketInternal] = null; timeout = 0; #writeCallback; #writeChunk; #pendingRead; isServer = false; + _handle; + _parent; + _parentWrap; + #socket; constructor(options) { - const { signal, write, read, allowHalfOpen = false, ...opts } = options || {}; + const { socket, signal, write, read, allowHalfOpen = false, ...opts } = options || {}; super({ ...opts, allowHalfOpen, readable: true, writable: true, }); + this._handle = this; + this._parent = this; + this._parentWrap = this; this.#pendingRead = undefined; + if (socket instanceof Socket) { + this.#socket = socket; + } signal?.once("abort", () => this.destroy()); this.once("connect", () => this.emit("ready")); } @@ -327,7 +338,7 @@ const Socket = (function (InternalSocket) { socket.data = this; socket.timeout(this.timeout); socket.ref(); - this.#socket = socket; + this[bunSocketInternal] = socket; this.connecting = false; this.emit("connect", this); Socket.#Drain(socket); @@ -335,6 +346,7 @@ const Socket = (function (InternalSocket) { connect(port, host, connectListener) { var path; + var connection = this.#socket; if (typeof port === "string") { path = port; port = undefined; @@ -357,6 +369,7 @@ const Socket = (function (InternalSocket) { port, host, path, + socket, // TODOs localAddress, localPort, @@ -371,7 +384,11 @@ const Socket = (function (InternalSocket) { pauseOnConnect, servername, } = port; + this.servername = servername; + if (socket) { + connection = socket; + } } if (!pauseOnConnect) { @@ -399,41 +416,117 @@ const Socket = (function (InternalSocket) { } else { tls.rejectUnauthorized = rejectUnauthorized; tls.requestCert = true; + if (!connection && tls.socket) { + connection = tls.socket; + } + } + } + if (connection) { + if ( + typeof connection !== "object" || + !(connection instanceof Socket) || + typeof connection[bunTlsSymbol] === "function" + ) { + throw new TypeError("socket must be an instance of net.Socket"); } } - this.authorized = false; this.secureConnecting = true; this._secureEstablished = false; this._securePending = true; if (connectListener) this.on("secureConnect", connectListener); } else if (connectListener) this.on("connect", connectListener); - bunConnect( - path - ? { + // start using existing connection + + if (connection) { + const socket = connection[bunSocketInternal]; + + if (socket) { + const result = socket.wrapTLS({ + data: this, + tls, + socket: Socket.#Handlers, + }); + if (result) { + const [raw, tls] = result; + // replace socket + connection[bunSocketInternal] = raw; + raw.timeout(raw.timeout); + raw.connecting = false; + // set new socket + this[bunSocketInternal] = tls; + tls.timeout(tls.timeout); + tls.connecting = true; + this[bunSocketInternal] = socket; + // start tls + tls.open(); + } else { + this[bunSocketInternal] = null; + throw new Error("Invalid socket"); + } + } else { + // wait to be connected + connection.once("connect", () => { + const socket = connection[bunSocketInternal]; + if (!socket) return; + + const result = socket.wrapTLS({ data: this, - unix: path, - socket: Socket.#Handlers, tls, - } - : { - data: this, - hostname: host || "localhost", - port: port, socket: Socket.#Handlers, - tls, - }, - ); + }); + + if (result) { + const [raw, tls] = result; + // replace socket + connection[bunSocketInternal] = raw; + raw.timeout(raw.timeout); + raw.connecting = false; + // set new socket + this[bunSocketInternal] = tls; + tls.timeout(tls.timeout); + tls.connecting = true; + this[bunSocketInternal] = socket; + // start tls + tls.open(); + } else { + this[bunSocketInternal] = null; + throw new Error("Invalid socket"); + } + }); + } + } else if (path) { + // start using unix socket + bunConnect({ + data: this, + unix: path, + socket: Socket.#Handlers, + tls, + }).catch(error => { + this.emit("error", error); + }); + } else { + // default start + bunConnect({ + data: this, + hostname: host || "localhost", + port: port, + socket: Socket.#Handlers, + tls, + }).catch(error => { + this.emit("error", error); + }); + } return this; } _destroy(err, callback) { - this.#socket?.end(); + this[bunSocketInternal]?.end(); callback(err); } _final(callback) { - this.#socket?.end(); + this[bunSocketInternal]?.end(); callback(); } @@ -446,7 +539,7 @@ const Socket = (function (InternalSocket) { } get localPort() { - return this.#socket?.localPort; + return this[bunSocketInternal]?.localPort; } get pending() { @@ -472,11 +565,11 @@ const Socket = (function (InternalSocket) { } ref() { - this.#socket?.ref(); + this[bunSocketInternal]?.ref(); } get remoteAddress() { - return this.#socket?.remoteAddress; + return this[bunSocketInternal]?.remoteAddress; } get remoteFamily() { @@ -484,7 +577,7 @@ const Socket = (function (InternalSocket) { } resetAndDestroy() { - this.#socket?.end(); + this[bunSocketInternal]?.end(); } setKeepAlive(enable = false, initialDelay = 0) { @@ -498,19 +591,19 @@ const Socket = (function (InternalSocket) { } setTimeout(timeout, callback) { - this.#socket?.timeout(timeout); + this[bunSocketInternal]?.timeout(timeout); this.timeout = timeout; if (callback) this.once("timeout", callback); return this; } unref() { - this.#socket?.unref(); + this[bunSocketInternal]?.unref(); } _write(chunk, encoding, callback) { - if (typeof chunk == "string" && encoding !== "utf8") chunk = Buffer.from(chunk, encoding); - var written = this.#socket?.write(chunk); + if (typeof chunk == "string" && encoding !== "ascii") chunk = Buffer.from(chunk, encoding); + var written = this[bunSocketInternal]?.write(chunk); if (written == chunk.length) { callback(); } else if (this.#writeCallback) { diff --git a/src/js/node/tls.js b/src/js/node/tls.js index 356c25cbd..310a36620 100644 --- a/src/js/node/tls.js +++ b/src/js/node/tls.js @@ -1,9 +1,30 @@ // Hardcoded module "node:tls" -import { isTypedArray } from "util/types"; +import { isArrayBufferView, isTypedArray } from "util/types"; import net, { Server as NetServer } from "node:net"; const InternalTCPSocket = net[Symbol.for("::bunternal::")]; - +const bunSocketInternal = Symbol.for("::bunnetsocketinternal::"); + +const { RegExp, Array, String } = globalThis[Symbol.for("Bun.lazy")]("primordials"); +const SymbolReplace = Symbol.replace; +const RegExpPrototypeSymbolReplace = RegExp.prototype[SymbolReplace]; +const RegExpPrototypeExec = RegExp.prototype.exec; + +const StringPrototypeStartsWith = String.prototype.startsWith; +const StringPrototypeSlice = String.prototype.slice; +const StringPrototypeIncludes = String.prototype.includes; +const StringPrototypeSplit = String.prototype.split; +const StringPrototypeIndexOf = String.prototype.indexOf; +const StringPrototypeSubstring = String.prototype.substring; +const StringPrototypeEndsWith = String.prototype.endsWith; + +const ArrayPrototypeIncludes = Array.prototype.includes; +const ArrayPrototypeJoin = Array.prototype.join; +const ArrayPrototypeForEach = Array.prototype.forEach; +const ArrayPrototypePush = Array.prototype.push; +const ArrayPrototypeSome = Array.prototype.some; +const ArrayPrototypeReduce = Array.prototype.reduce; function parseCertString() { + // Removed since JAN 2022 Node v18.0.0+ https://github.com/nodejs/node/pull/41479 throwNotImplemented("Not implemented"); } @@ -18,6 +39,164 @@ function isValidTLSArray(obj) { } } +function unfqdn(host) { + return RegExpPrototypeSymbolReplace(/[.]$/, host, ""); +} + +function splitHost(host) { + return StringPrototypeSplit.call(RegExpPrototypeSymbolReplace(/[A-Z]/g, unfqdn(host), toLowerCase), "."); +} + +function check(hostParts, pattern, wildcards) { + // Empty strings, null, undefined, etc. never match. + if (!pattern) return false; + + const patternParts = splitHost(pattern); + + if (hostParts.length !== patternParts.length) return false; + + // Pattern has empty components, e.g. "bad..example.com". + if (ArrayPrototypeIncludes.call(patternParts, "")) return false; + + // RFC 6125 allows IDNA U-labels (Unicode) in names but we have no + // good way to detect their encoding or normalize them so we simply + // reject them. Control characters and blanks are rejected as well + // because nothing good can come from accepting them. + const isBad = s => RegExpPrototypeExec.call(/[^\u0021-\u007F]/u, s) !== null; + if (ArrayPrototypeSome.call(patternParts, isBad)) return false; + + // Check host parts from right to left first. + for (let i = hostParts.length - 1; i > 0; i -= 1) { + if (hostParts[i] !== patternParts[i]) return false; + } + + const hostSubdomain = hostParts[0]; + const patternSubdomain = patternParts[0]; + const patternSubdomainParts = StringPrototypeSplit.call(patternSubdomain, "*"); + + // Short-circuit when the subdomain does not contain a wildcard. + // RFC 6125 does not allow wildcard substitution for components + // containing IDNA A-labels (Punycode) so match those verbatim. + if (patternSubdomainParts.length === 1 || StringPrototypeIncludes.call(patternSubdomain, "xn--")) + return hostSubdomain === patternSubdomain; + + if (!wildcards) return false; + + // More than one wildcard is always wrong. + if (patternSubdomainParts.length > 2) return false; + + // *.tld wildcards are not allowed. + if (patternParts.length <= 2) return false; + + const { 0: prefix, 1: suffix } = patternSubdomainParts; + + if (prefix.length + suffix.length > hostSubdomain.length) return false; + + if (!StringPrototypeStartsWith.call(hostSubdomain, prefix)) return false; + + if (!StringPrototypeEndsWith.call(hostSubdomain, suffix)) return false; + + return true; +} + +// This pattern is used to determine the length of escaped sequences within +// the subject alt names string. It allows any valid JSON string literal. +// This MUST match the JSON specification (ECMA-404 / RFC8259) exactly. +const jsonStringPattern = + // eslint-disable-next-line no-control-regex + /^"(?:[^"\\\u0000-\u001f]|\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4}))*"/; + +function splitEscapedAltNames(altNames) { + const result = []; + let currentToken = ""; + let offset = 0; + while (offset !== altNames.length) { + const nextSep = StringPrototypeIndexOf.call(altNames, ", ", offset); + const nextQuote = StringPrototypeIndexOf.call(altNames, '"', offset); + if (nextQuote !== -1 && (nextSep === -1 || nextQuote < nextSep)) { + // There is a quote character and there is no separator before the quote. + currentToken += StringPrototypeSubstring.call(altNames, offset, nextQuote); + const match = RegExpPrototypeExec.call(jsonStringPattern, StringPrototypeSubstring.call(altNames, nextQuote)); + if (!match) { + let error = new SyntaxError("ERR_TLS_CERT_ALTNAME_FORMAT: Invalid subject alternative name string"); + error.name = ERR_TLS_CERT_ALTNAME_FORMAT; + throw error; + } + currentToken += JSON.parse(match[0]); + offset = nextQuote + match[0].length; + } else if (nextSep !== -1) { + // There is a separator and no quote before it. + currentToken += StringPrototypeSubstring.call(altNames, offset, nextSep); + ArrayPrototypePush.call(result, currentToken); + currentToken = ""; + offset = nextSep + 2; + } else { + currentToken += StringPrototypeSubstring.call(altNames, offset); + offset = altNames.length; + } + } + ArrayPrototypePush.call(result, currentToken); + return result; +} +function checkServerIdentity(hostname, cert) { + const subject = cert.subject; + const altNames = cert.subjectaltname; + const dnsNames = []; + const ips = []; + + hostname = "" + hostname; + + if (altNames) { + const splitAltNames = StringPrototypeIncludes.call(altNames, '"') + ? splitEscapedAltNames(altNames) + : StringPrototypeSplit.call(altNames, ", "); + ArrayPrototypeForEach.call(splitAltNames, name => { + if (StringPrototypeStartsWith.call(name, "DNS:")) { + ArrayPrototypePush.call(dnsNames, StringPrototypeSlice.call(name, 4)); + } else if (StringPrototypeStartsWith.call(name, "IP Address:")) { + ArrayPrototypePush.call(ips, canonicalizeIP(StringPrototypeSlice.call(name, 11))); + } + }); + } + + let valid = false; + let reason = "Unknown reason"; + + hostname = unfqdn(hostname); // Remove trailing dot for error messages. + + if (net.isIP(hostname)) { + valid = ArrayPrototypeIncludes.call(ips, canonicalizeIP(hostname)); + if (!valid) reason = `IP: ${hostname} is not in the cert's list: ` + ArrayPrototypeJoin.call(ips, ", "); + } else if (dnsNames.length > 0 || subject?.CN) { + const hostParts = splitHost(hostname); + const wildcard = pattern => check(hostParts, pattern, true); + + if (dnsNames.length > 0) { + valid = ArrayPrototypeSome.call(dnsNames, wildcard); + if (!valid) reason = `Host: ${hostname}. is not in the cert's altnames: ${altNames}`; + } else { + // Match against Common Name only if no supported identifiers exist. + const cn = subject.CN; + + if (ArrayIsArray(cn)) valid = ArrayPrototypeSome.call(cn, wildcard); + else if (cn) valid = wildcard(cn); + + if (!valid) reason = `Host: ${hostname}. is not cert's CN: ${cn}`; + } + } else { + reason = "Cert does not contain a DNS name"; + } + + if (!valid) { + let error = new Error(`ERR_TLS_CERT_ALTNAME_INVALID: Hostname/IP does not match certificate's altnames: ${reason}`); + error.name = "ERR_TLS_CERT_ALTNAME_INVALID"; + error.reason = reason; + error.host = host; + error.cert = cert; + return error; + } +} + var InternalSecureContext = class SecureContext { context; @@ -83,6 +262,36 @@ function createSecureContext(options) { return new SecureContext(options); } +// Translate some fields from the handle's C-friendly format into more idiomatic +// javascript object representations before passing them back to the user. Can +// be used on any cert object, but changing the name would be semver-major. +function translatePeerCertificate(c) { + if (!c) return null; + + if (c.issuerCertificate != null && c.issuerCertificate !== c) { + c.issuerCertificate = translatePeerCertificate(c.issuerCertificate); + } + if (c.infoAccess != null) { + const info = c.infoAccess; + c.infoAccess = { __proto__: null }; + + // XXX: More key validation? + RegExpPrototypeSymbolReplace(/([^\n:]*):([^\n]*)(?:\n|$)/g, info, (all, key, val) => { + if (val.charCodeAt(0) === 0x22) { + // The translatePeerCertificate function is only + // used on internally created legacy certificate + // objects, and any value that contains a quote + // will always be a valid JSON string literal, + // so this should never throw. + val = JSONParse(val); + } + if (key in c.infoAccess) ArrayPrototypePush.call(c.infoAccess[key], val); + else c.infoAccess[key] = [val]; + }); + } + return c; +} + const buntls = Symbol.for("::buntls::"); var SocketClass; @@ -107,8 +316,22 @@ const TLSSocket = (function (InternalTLSSocket) { })( class TLSSocket extends InternalTCPSocket { #secureContext; - constructor(options) { - super(options); + ALPNProtocols; + #socket; + + constructor(socket, options) { + super(socket instanceof InternalTCPSocket ? options : options || socket); + options = options || socket || {}; + if (typeof options === "object") { + const { ALPNProtocols } = options; + if (ALPNProtocols) { + convertALPNProtocols(ALPNProtocols, this); + } + if (socket instanceof InternalTCPSocket) { + this.#socket = socket; + } + } + this.#secureContext = options.secureContext || createSecureContext(options); this.authorized = false; this.secureConnecting = true; @@ -123,28 +346,52 @@ const TLSSocket = (function (InternalTLSSocket) { secureConnecting = false; _SNICallback; servername; - alpnProtocol; authorized = false; authorizationError; encrypted = true; - exportKeyingMaterial() { - throw Error("Not implented in Bun yet"); + _start() { + // some frameworks uses this _start internal implementation is suposed to start TLS handshake + // on Bun we auto start this after on_open callback and when wrapping we start it after the socket is attached to the net.Socket/tls.Socket } - setMaxSendFragment() { + + exportKeyingMaterial(length, label, context) { + //SSL_export_keying_material throw Error("Not implented in Bun yet"); } - setServername() { + setMaxSendFragment(size) { + // SSL_set_max_send_fragment throw Error("Not implented in Bun yet"); } + setServername(name) { + if (this.isServer) { + let error = new Error("ERR_TLS_SNI_FROM_SERVER: Cannot issue SNI from a TLS server-side socket"); + error.name = "ERR_TLS_SNI_FROM_SERVER"; + throw error; + } + // if the socket is detached we can't set the servername but we set this property so when open will auto set to it + this.servername = name; + this[bunSocketInternal]?.setServername(name); + } setSession() { throw Error("Not implented in Bun yet"); } getPeerCertificate() { + // need to implement peerCertificate on socket.zig + // const cert = this[bunSocketInternal]?.peerCertificate; + // if(cert) { + // return translatePeerCertificate(cert); + // } throw Error("Not implented in Bun yet"); } getCertificate() { + // need to implement certificate on socket.zig + // const cert = this[bunSocketInternal]?.certificate; + // if(cert) { + // It's not a peer cert, but the formatting is identical. + // return translatePeerCertificate(cert); + // } throw Error("Not implented in Bun yet"); } getPeerX509Certificate() { @@ -154,16 +401,17 @@ const TLSSocket = (function (InternalTLSSocket) { throw Error("Not implented in Bun yet"); } - [buntls](port, host) { - var { servername } = this; - if (servername) { - return { - serverName: typeof servername === "string" ? servername : host, - ...this.#secureContext, - }; - } + get alpnProtocol() { + return this[bunSocketInternal]?.alpnProtocol; + } - return true; + [buntls](port, host) { + return { + socket: this.#socket, + ALPNProtocols: this.ALPNProtocols, + serverName: this.servername || host || "localhost", + ...this.#secureContext, + }; } }, ); @@ -177,9 +425,12 @@ class Server extends NetServer { _rejectUnauthorized; _requestCert; servername; + ALPNProtocols; + #checkServerIdentity; constructor(options, secureConnectionListener) { super(options, secureConnectionListener); + this.#checkServerIdentity = options?.checkServerIdentity || checkServerIdentity; this.setSecureContext(options); } emit(event, args) { @@ -197,6 +448,12 @@ class Server extends NetServer { options = options.context; } if (options) { + const { ALPNProtocols } = options; + + if (ALPNProtocols) { + convertALPNProtocols(ALPNProtocols, this); + } + let key = options.key; if (key) { if (!isValidTLSArray(key)) { @@ -277,6 +534,8 @@ class Server extends NetServer { // Client always is NONE on set_verify rejectUnauthorized: isClient ? false : this._rejectUnauthorized, requestCert: isClient ? false : this._requestCert, + ALPNProtocols: this.ALPNProtocols, + checkServerIdentity: this.#checkServerIdentity, }, SocketClass, ]; @@ -296,6 +555,11 @@ const CLIENT_RENEG_LIMIT = 3, DEFAULT_MAX_VERSION = "TLSv1.3", createConnection = (port, host, connectListener) => { if (typeof port === "object") { + port.checkServerIdentity || checkServerIdentity; + const { ALPNProtocols } = port; + if (ALPNProtocols) { + convertALPNProtocols(ALPNProtocols, port); + } // port is option pass Socket options and let connect handle connection options return new TLSSocket(port).connect(port, host, connectListener); } @@ -312,7 +576,55 @@ function getCurves() { return; } -function convertALPNProtocols(protocols, out) {} +// Convert protocols array into valid OpenSSL protocols list +// ("\x06spdy/2\x08http/1.1\x08http/1.0") +function convertProtocols(protocols) { + const lens = new Array(protocols.length); + const buff = Buffer.allocUnsafe( + ArrayPrototypeReduce.call( + protocols, + (p, c, i) => { + const len = Buffer.byteLength(c); + if (len > 255) { + throw new RangeError( + "The byte length of the protocol at index " + `${i} exceeds the maximum length.`, + "<= 255", + len, + true, + ); + } + lens[i] = len; + return p + 1 + len; + }, + 0, + ), + ); + + let offset = 0; + for (let i = 0, c = protocols.length; i < c; i++) { + buff[offset++] = lens[i]; + buff.write(protocols[i], offset); + offset += lens[i]; + } + + return buff; +} + +function convertALPNProtocols(protocols, out) { + // If protocols is Array - translate it into buffer + if (Array.isArray(protocols)) { + out.ALPNProtocols = convertProtocols(protocols); + } else if (isTypedArray(protocols)) { + // Copy new buffer not to be modified by user. + out.ALPNProtocols = Buffer.from(protocols); + } else if (isArrayBufferView(protocols)) { + out.ALPNProtocols = Buffer.from( + protocols.buffer.slice(protocols.byteOffset, protocols.byteOffset + protocols.byteLength), + ); + } else if (Buffer.isBuffer(protocols)) { + out.ALPNProtocols = protocols; + } +} var exports = { [Symbol.for("CommonJS")]: 0, @@ -351,6 +663,7 @@ export { getCurves, parseCertString, SecureContext, + checkServerIdentity, Server, TLSSocket, exports as default, diff --git a/src/js/out/modules/node/net.js b/src/js/out/modules/node/net.js index 164ec6677..c34f86b04 100644 --- a/src/js/out/modules/node/net.js +++ b/src/js/out/modules/node/net.js @@ -26,7 +26,7 @@ var isIPv4 = function(s) { self.emit("listening"); }, createServer = function(options, connectionListener) { return new Server(options, connectionListener); -}, 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) { +}, 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::"), bunSocketInternal = Symbol.for("::bunnetsocketinternal::"), SocketClass, Socket = function(InternalSocket) { return SocketClass = InternalSocket, Object.defineProperty(SocketClass.prototype, Symbol.toStringTag, { value: "Socket", enumerable: !1 @@ -62,7 +62,7 @@ var isIPv4 = function(s) { }, open(socket) { const self = socket.data; - socket.timeout(self.timeout), socket.ref(), self.#socket = socket, self.connecting = !1, self.emit("connect", self), Socket2.#Drain(socket); + socket.timeout(self.timeout), socket.ref(), self[bunSocketInternal] = socket, self.connecting = !1, self.emit("connect", self), Socket2.#Drain(socket); }, handshake(socket, success, verifyError) { const { data: self } = socket; @@ -87,7 +87,7 @@ var isIPv4 = function(s) { const self = socket.data; if (self.#closed) return; - self.#closed = !0, self.#socket = null; + self.#closed = !0, self[bunSocketInternal] = null; const queue = self.#readQueue; if (queue.isEmpty()) { if (self.push(null)) @@ -163,21 +163,27 @@ var isIPv4 = function(s) { localAddress = "127.0.0.1"; #readQueue = createFIFO(); remotePort; - #socket; + [bunSocketInternal] = null; timeout = 0; #writeCallback; #writeChunk; #pendingRead; isServer = !1; + _handle; + _parent; + _parentWrap; + #socket; constructor(options) { - const { signal, write, read, allowHalfOpen = !1, ...opts } = options || {}; + const { socket, signal, write, read, allowHalfOpen = !1, ...opts } = options || {}; super({ ...opts, allowHalfOpen, readable: !0, writable: !0 }); - this.#pendingRead = void 0, signal?.once("abort", () => this.destroy()), this.once("connect", () => this.emit("ready")); + if (this._handle = this, this._parent = this, this._parentWrap = this, this.#pendingRead = void 0, socket instanceof Socket2) + this.#socket = socket; + signal?.once("abort", () => this.destroy()), this.once("connect", () => this.emit("ready")); } address() { return { @@ -190,10 +196,10 @@ var isIPv4 = function(s) { return this.writableLength; } #attach(port, socket) { - this.remotePort = port, socket.data = this, socket.timeout(this.timeout), socket.ref(), this.#socket = socket, this.connecting = !1, this.emit("connect", this), Socket2.#Drain(socket); + this.remotePort = port, socket.data = this, socket.timeout(this.timeout), socket.ref(), this[bunSocketInternal] = socket, this.connecting = !1, this.emit("connect", this), Socket2.#Drain(socket); } connect(port, host, connectListener) { - var path; + var path, connection = this.#socket; if (typeof port === "string") { if (path = port, port = void 0, typeof host === "function") connectListener = host, host = void 0; @@ -207,6 +213,7 @@ var isIPv4 = function(s) { port, host, path, + socket, localAddress, localPort, family, @@ -220,7 +227,8 @@ var isIPv4 = function(s) { pauseOnConnect, servername } = port; - this.servername = servername; + if (this.servername = servername, socket) + connection = socket; } if (!pauseOnConnect) this.resume(); @@ -228,36 +236,78 @@ var isIPv4 = function(s) { const bunTLS = this[bunTlsSymbol]; var tls = void 0; if (typeof bunTLS === "function") { - if (tls = bunTLS.call(this, port, host, !0), this._requestCert = !0, this._rejectUnauthorized = rejectUnauthorized, tls) + if (tls = bunTLS.call(this, port, host, !0), this._requestCert = !0, this._rejectUnauthorized = rejectUnauthorized, tls) { if (typeof tls !== "object") tls = { rejectUnauthorized, requestCert: !0 }; - else - tls.rejectUnauthorized = rejectUnauthorized, tls.requestCert = !0; + else if (tls.rejectUnauthorized = rejectUnauthorized, tls.requestCert = !0, !connection && tls.socket) + connection = tls.socket; + } + if (connection) { + if (typeof connection !== "object" || !(connection instanceof Socket2) || typeof connection[bunTlsSymbol] === "function") + throw new TypeError("socket must be an instance of net.Socket"); + } if (this.authorized = !1, this.secureConnecting = !0, this._secureEstablished = !1, this._securePending = !0, connectListener) this.on("secureConnect", connectListener); } else if (connectListener) this.on("connect", connectListener); - return bunConnect(path ? { - data: this, - unix: path, - socket: Socket2.#Handlers, - tls - } : { - data: this, - hostname: host || "localhost", - port, - socket: Socket2.#Handlers, - tls - }), this; + if (connection) { + const socket2 = connection[bunSocketInternal]; + if (socket2) { + const result = socket2.wrapTLS({ + data: this, + tls, + socket: Socket2.#Handlers + }); + if (result) { + const [raw, tls2] = result; + connection[bunSocketInternal] = raw, raw.timeout(raw.timeout), raw.connecting = !1, this[bunSocketInternal] = tls2, tls2.timeout(tls2.timeout), tls2.connecting = !0, this[bunSocketInternal] = socket2, tls2.open(); + } else + throw this[bunSocketInternal] = null, new Error("Invalid socket"); + } else + connection.once("connect", () => { + const socket3 = connection[bunSocketInternal]; + if (!socket3) + return; + const result = socket3.wrapTLS({ + data: this, + tls, + socket: Socket2.#Handlers + }); + if (result) { + const [raw, tls2] = result; + connection[bunSocketInternal] = raw, raw.timeout(raw.timeout), raw.connecting = !1, this[bunSocketInternal] = tls2, tls2.timeout(tls2.timeout), tls2.connecting = !0, this[bunSocketInternal] = socket3, tls2.open(); + } else + throw this[bunSocketInternal] = null, new Error("Invalid socket"); + }); + } else if (path) + bunConnect({ + data: this, + unix: path, + socket: Socket2.#Handlers, + tls + }).catch((error) => { + this.emit("error", error); + }); + else + bunConnect({ + data: this, + hostname: host || "localhost", + port, + socket: Socket2.#Handlers, + tls + }).catch((error) => { + this.emit("error", error); + }); + return this; } _destroy(err, callback) { - this.#socket?.end(), callback(err); + this[bunSocketInternal]?.end(), callback(err); } _final(callback) { - this.#socket?.end(), callback(); + this[bunSocketInternal]?.end(), callback(); } get localAddress() { return "127.0.0.1"; @@ -266,7 +316,7 @@ var isIPv4 = function(s) { return "IPv4"; } get localPort() { - return this.#socket?.localPort; + return this[bunSocketInternal]?.localPort; } get pending() { return this.connecting; @@ -289,16 +339,16 @@ var isIPv4 = function(s) { return this.writable ? "writeOnly" : "closed"; } ref() { - this.#socket?.ref(); + this[bunSocketInternal]?.ref(); } get remoteAddress() { - return this.#socket?.remoteAddress; + return this[bunSocketInternal]?.remoteAddress; } get remoteFamily() { return "IPv4"; } resetAndDestroy() { - this.#socket?.end(); + this[bunSocketInternal]?.end(); } setKeepAlive(enable = !1, initialDelay = 0) { return this; @@ -307,17 +357,17 @@ var isIPv4 = function(s) { return this; } setTimeout(timeout, callback) { - if (this.#socket?.timeout(timeout), this.timeout = timeout, callback) + if (this[bunSocketInternal]?.timeout(timeout), this.timeout = timeout, callback) this.once("timeout", callback); return this; } unref() { - this.#socket?.unref(); + this[bunSocketInternal]?.unref(); } _write(chunk, encoding, callback) { - if (typeof chunk == "string" && encoding !== "utf8") + if (typeof chunk == "string" && encoding !== "ascii") chunk = Buffer.from(chunk, encoding); - var written = this.#socket?.write(chunk); + var written = this[bunSocketInternal]?.write(chunk); if (written == chunk.length) callback(); else if (this.#writeCallback) diff --git a/src/js/out/modules/node/tls.js b/src/js/out/modules/node/tls.js index 4cceadc7f..ca8a13270 100644 --- a/src/js/out/modules/node/tls.js +++ b/src/js/out/modules/node/tls.js @@ -1,4 +1,4 @@ -import {isTypedArray} from "node:util/types"; +import {isArrayBufferView, isTypedArray} from "node:util/types"; import net, {Server as NetServer} from "node:net"; var parseCertString = function() { throwNotImplemented("Not implemented"); @@ -11,18 +11,127 @@ var parseCertString = function() { return !1; return !0; } +}, unfqdn = function(host2) { + return RegExpPrototypeSymbolReplace(/[.]$/, host2, ""); +}, splitHost = function(host2) { + return StringPrototypeSplit.call(RegExpPrototypeSymbolReplace(/[A-Z]/g, unfqdn(host2), toLowerCase), "."); +}, check = function(hostParts, pattern, wildcards) { + if (!pattern) + return !1; + const patternParts = splitHost(pattern); + if (hostParts.length !== patternParts.length) + return !1; + if (ArrayPrototypeIncludes.call(patternParts, "")) + return !1; + const isBad = (s) => RegExpPrototypeExec.call(/[^\u0021-\u007F]/u, s) !== null; + if (ArrayPrototypeSome.call(patternParts, isBad)) + return !1; + for (let i = hostParts.length - 1;i > 0; i -= 1) + if (hostParts[i] !== patternParts[i]) + return !1; + const hostSubdomain = hostParts[0], patternSubdomain = patternParts[0], patternSubdomainParts = StringPrototypeSplit.call(patternSubdomain, "*"); + if (patternSubdomainParts.length === 1 || StringPrototypeIncludes.call(patternSubdomain, "xn--")) + return hostSubdomain === patternSubdomain; + if (!wildcards) + return !1; + if (patternSubdomainParts.length > 2) + return !1; + if (patternParts.length <= 2) + return !1; + const { 0: prefix, 1: suffix } = patternSubdomainParts; + if (prefix.length + suffix.length > hostSubdomain.length) + return !1; + if (!StringPrototypeStartsWith.call(hostSubdomain, prefix)) + return !1; + if (!StringPrototypeEndsWith.call(hostSubdomain, suffix)) + return !1; + return !0; +}, splitEscapedAltNames = function(altNames) { + const result = []; + let currentToken = "", offset = 0; + while (offset !== altNames.length) { + const nextSep = StringPrototypeIndexOf.call(altNames, ", ", offset), nextQuote = StringPrototypeIndexOf.call(altNames, '"', offset); + if (nextQuote !== -1 && (nextSep === -1 || nextQuote < nextSep)) { + currentToken += StringPrototypeSubstring.call(altNames, offset, nextQuote); + const match = RegExpPrototypeExec.call(jsonStringPattern, StringPrototypeSubstring.call(altNames, nextQuote)); + if (!match) { + let error = new SyntaxError("ERR_TLS_CERT_ALTNAME_FORMAT: Invalid subject alternative name string"); + throw error.name = ERR_TLS_CERT_ALTNAME_FORMAT, error; + } + currentToken += JSON.parse(match[0]), offset = nextQuote + match[0].length; + } else if (nextSep !== -1) + currentToken += StringPrototypeSubstring.call(altNames, offset, nextSep), ArrayPrototypePush.call(result, currentToken), currentToken = "", offset = nextSep + 2; + else + currentToken += StringPrototypeSubstring.call(altNames, offset), offset = altNames.length; + } + return ArrayPrototypePush.call(result, currentToken), result; +}, checkServerIdentity = function(hostname, cert) { + const { subject, subjectaltname: altNames } = cert, dnsNames = [], ips = []; + if (hostname = "" + hostname, altNames) { + const splitAltNames = StringPrototypeIncludes.call(altNames, '"') ? splitEscapedAltNames(altNames) : StringPrototypeSplit.call(altNames, ", "); + ArrayPrototypeForEach.call(splitAltNames, (name) => { + if (StringPrototypeStartsWith.call(name, "DNS:")) + ArrayPrototypePush.call(dnsNames, StringPrototypeSlice.call(name, 4)); + else if (StringPrototypeStartsWith.call(name, "IP Address:")) + ArrayPrototypePush.call(ips, canonicalizeIP(StringPrototypeSlice.call(name, 11))); + }); + } + let valid = !1, reason = "Unknown reason"; + if (hostname = unfqdn(hostname), net.isIP(hostname)) { + if (valid = ArrayPrototypeIncludes.call(ips, canonicalizeIP(hostname)), !valid) + reason = `IP: ${hostname} is not in the cert's list: ` + ArrayPrototypeJoin.call(ips, ", "); + } else if (dnsNames.length > 0 || subject?.CN) { + const hostParts = splitHost(hostname), wildcard = (pattern) => check(hostParts, pattern, !0); + if (dnsNames.length > 0) { + if (valid = ArrayPrototypeSome.call(dnsNames, wildcard), !valid) + reason = `Host: ${hostname}. is not in the cert's altnames: ${altNames}`; + } else { + const cn = subject.CN; + if (ArrayIsArray(cn)) + valid = ArrayPrototypeSome.call(cn, wildcard); + else if (cn) + valid = wildcard(cn); + if (!valid) + reason = `Host: ${hostname}. is not cert's CN: ${cn}`; + } + } else + reason = "Cert does not contain a DNS name"; + if (!valid) { + let error = new Error(`ERR_TLS_CERT_ALTNAME_INVALID: Hostname/IP does not match certificate's altnames: ${reason}`); + return error.name = "ERR_TLS_CERT_ALTNAME_INVALID", error.reason = reason, error.host = host, error.cert = cert, error; + } }, SecureContext = function(options) { return new InternalSecureContext(options); }, createSecureContext = function(options) { return new SecureContext(options); -}, createServer = function(options, connectionListener) { +}; +var createServer = function(options, connectionListener) { return new Server(options, connectionListener); }, getCiphers = function() { return DEFAULT_CIPHERS.split(":"); }, getCurves = function() { return; +}, convertProtocols = function(protocols) { + const lens = new Array(protocols.length), buff = Buffer.allocUnsafe(ArrayPrototypeReduce.call(protocols, (p, c, i) => { + const len = Buffer.byteLength(c); + if (len > 255) + throw new RangeError("The byte length of the protocol at index " + `${i} exceeds the maximum length.`, "<= 255", len, !0); + return lens[i] = len, p + 1 + len; + }, 0)); + let offset = 0; + for (let i = 0, c = protocols.length;i < c; i++) + buff[offset++] = lens[i], buff.write(protocols[i], offset), offset += lens[i]; + return buff; }, convertALPNProtocols = function(protocols, out) { -}, InternalTCPSocket = net[Symbol.for("::bunternal::")], InternalSecureContext = class SecureContext2 { + if (Array.isArray(protocols)) + out.ALPNProtocols = convertProtocols(protocols); + else if (isTypedArray(protocols)) + out.ALPNProtocols = Buffer.from(protocols); + else if (isArrayBufferView(protocols)) + out.ALPNProtocols = Buffer.from(protocols.buffer.slice(protocols.byteOffset, protocols.byteOffset + protocols.byteLength)); + else if (Buffer.isBuffer(protocols)) + out.ALPNProtocols = protocols; +}, InternalTCPSocket = net[Symbol.for("::bunternal::")], bunSocketInternal = Symbol.for("::bunnetsocketinternal::"), { RegExp, Array, String } = globalThis[Symbol.for("Bun.lazy")]("primordials"), SymbolReplace = Symbol.replace, RegExpPrototypeSymbolReplace = RegExp.prototype[SymbolReplace], RegExpPrototypeExec = RegExp.prototype.exec, StringPrototypeStartsWith = String.prototype.startsWith, StringPrototypeSlice = String.prototype.slice, StringPrototypeIncludes = String.prototype.includes, StringPrototypeSplit = String.prototype.split, StringPrototypeIndexOf = String.prototype.indexOf, StringPrototypeSubstring = String.prototype.substring, StringPrototypeEndsWith = String.prototype.endsWith, ArrayPrototypeIncludes = Array.prototype.includes, ArrayPrototypeJoin = Array.prototype.join, ArrayPrototypeForEach = Array.prototype.forEach, ArrayPrototypePush = Array.prototype.push, ArrayPrototypeSome = Array.prototype.some, ArrayPrototypeReduce = Array.prototype.reduce, jsonStringPattern = /^"(?:[^"\\\u0000-\u001f]|\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4}))*"/, InternalSecureContext = class SecureContext2 { context; constructor(options) { const context = {}; @@ -73,8 +182,17 @@ var parseCertString = function() { }); }(class TLSSocket2 extends InternalTCPSocket { #secureContext; - constructor(options) { - super(options); + ALPNProtocols; + #socket; + constructor(socket, options) { + super(socket instanceof InternalTCPSocket ? options : options || socket); + if (options = options || socket || {}, typeof options === "object") { + const { ALPNProtocols } = options; + if (ALPNProtocols) + convertALPNProtocols(ALPNProtocols, this); + if (socket instanceof InternalTCPSocket) + this.#socket = socket; + } this.#secureContext = options.secureContext || createSecureContext(options), this.authorized = !1, this.secureConnecting = !0, this._secureEstablished = !1, this._securePending = !0; } _secureEstablished = !1; @@ -84,19 +202,24 @@ var parseCertString = function() { secureConnecting = !1; _SNICallback; servername; - alpnProtocol; authorized = !1; authorizationError; encrypted = !0; - exportKeyingMaterial() { - throw Error("Not implented in Bun yet"); + _start() { } - setMaxSendFragment() { + exportKeyingMaterial(length, label, context) { throw Error("Not implented in Bun yet"); } - setServername() { + setMaxSendFragment(size) { throw Error("Not implented in Bun yet"); } + setServername(name) { + if (this.isServer) { + let error = new Error("ERR_TLS_SNI_FROM_SERVER: Cannot issue SNI from a TLS server-side socket"); + throw error.name = "ERR_TLS_SNI_FROM_SERVER", error; + } + this.servername = name, this[bunSocketInternal]?.setServername(name); + } setSession() { throw Error("Not implented in Bun yet"); } @@ -112,14 +235,16 @@ var parseCertString = function() { getX509Certificate() { throw Error("Not implented in Bun yet"); } - [buntls](port, host) { - var { servername } = this; - if (servername) - return { - serverName: typeof servername === "string" ? servername : host, - ...this.#secureContext - }; - return !0; + get alpnProtocol() { + return this[bunSocketInternal]?.alpnProtocol; + } + [buntls](port, host2) { + return { + socket: this.#socket, + ALPNProtocols: this.ALPNProtocols, + serverName: this.servername || host2 || "localhost", + ...this.#secureContext + }; } }); @@ -132,9 +257,11 @@ class Server extends NetServer { _rejectUnauthorized; _requestCert; servername; + ALPNProtocols; + #checkServerIdentity; constructor(options, secureConnectionListener) { super(options, secureConnectionListener); - this.setSecureContext(options); + this.#checkServerIdentity = options?.checkServerIdentity || checkServerIdentity, this.setSecureContext(options); } emit(event, args) { if (super.emit(event, args), event === "connection") @@ -146,6 +273,9 @@ class Server extends NetServer { if (options instanceof InternalSecureContext) options = options.context; if (options) { + const { ALPNProtocols } = options; + if (ALPNProtocols) + convertALPNProtocols(ALPNProtocols, this); let key = options.key; if (key) { if (!isValidTLSArray(key)) @@ -194,26 +324,33 @@ class Server extends NetServer { setTicketKeys() { throw Error("Not implented in Bun yet"); } - [buntls](port, host, isClient) { + [buntls](port, host2, isClient) { return [ { - serverName: this.servername || host || "localhost", + serverName: this.servername || host2 || "localhost", key: this.key, cert: this.cert, ca: this.ca, passphrase: this.passphrase, secureOptions: this.secureOptions, rejectUnauthorized: isClient ? !1 : this._rejectUnauthorized, - requestCert: isClient ? !1 : this._requestCert + requestCert: isClient ? !1 : this._requestCert, + ALPNProtocols: this.ALPNProtocols, + checkServerIdentity: this.#checkServerIdentity }, SocketClass ]; } } -var CLIENT_RENEG_LIMIT = 3, CLIENT_RENEG_WINDOW = 600, DEFAULT_ECDH_CURVE = "auto", DEFAULT_CIPHERS = "DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256", DEFAULT_MIN_VERSION = "TLSv1.2", DEFAULT_MAX_VERSION = "TLSv1.3", createConnection = (port, host, connectListener) => { - if (typeof port === "object") - return new TLSSocket(port).connect(port, host, connectListener); - return new TLSSocket().connect(port, host, connectListener); +var CLIENT_RENEG_LIMIT = 3, CLIENT_RENEG_WINDOW = 600, DEFAULT_ECDH_CURVE = "auto", DEFAULT_CIPHERS = "DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256", DEFAULT_MIN_VERSION = "TLSv1.2", DEFAULT_MAX_VERSION = "TLSv1.3", createConnection = (port, host2, connectListener) => { + if (typeof port === "object") { + port.checkServerIdentity; + const { ALPNProtocols } = port; + if (ALPNProtocols) + convertALPNProtocols(ALPNProtocols, port); + return new TLSSocket(port).connect(port, host2, connectListener); + } + return new TLSSocket().connect(port, host2, connectListener); }, connect = createConnection, exports = { [Symbol.for("CommonJS")]: 0, CLIENT_RENEG_LIMIT, @@ -244,6 +381,7 @@ export { createConnection, convertALPNProtocols, connect, + checkServerIdentity, TLSSocket, Server, SecureContext, diff --git a/test/bun.lockb b/test/bun.lockb index f30ca197a..e3a2abdfa 100755 Binary files a/test/bun.lockb and b/test/bun.lockb differ diff --git a/test/js/node/net/node-net-server.test.ts b/test/js/node/net/node-net-server.test.ts index 398959bd6..3cdaa17e1 100644 --- a/test/js/node/net/node-net-server.test.ts +++ b/test/js/node/net/node-net-server.test.ts @@ -181,61 +181,6 @@ describe("net.createServer listen", () => { ); }); - it("should listen on the correct port", done => { - const { mustCall, mustNotCall } = createCallCheckCtx(done); - - const server: Server = createServer(); - - let timeout: Timer; - const closeAndFail = () => { - clearTimeout(timeout); - server.close(); - mustNotCall()(); - }; - server.on("error", closeAndFail); - timeout = setTimeout(closeAndFail, 100); - - server.listen( - 49027, - mustCall(() => { - const address = server.address() as AddressInfo; - expect(address.address).toStrictEqual("::"); - expect(address.port).toStrictEqual(49027); - expect(address.family).toStrictEqual("IPv6"); - server.close(); - done(); - }), - ); - }); - - it("should listen on the correct port with IPV4", done => { - const { mustCall, mustNotCall } = createCallCheckCtx(done); - - const server: Server = createServer(); - - let timeout: Timer; - const closeAndFail = () => { - clearTimeout(timeout); - server.close(); - mustNotCall()(); - }; - server.on("error", closeAndFail); - timeout = setTimeout(closeAndFail, 100); - - server.listen( - 49026, - "0.0.0.0", - mustCall(() => { - const address = server.address() as AddressInfo; - expect(address.address).toStrictEqual("0.0.0.0"); - expect(address.port).toStrictEqual(49026); - expect(address.family).toStrictEqual("IPv4"); - server.close(); - done(); - }), - ); - }); - it("should listen on unix domain socket", done => { const { mustCall, mustNotCall } = createCallCheckCtx(done); diff --git a/test/js/node/tls/node-tls-connect.test.ts b/test/js/node/tls/node-tls-connect.test.ts new file mode 100644 index 000000000..791dba88a --- /dev/null +++ b/test/js/node/tls/node-tls-connect.test.ts @@ -0,0 +1,32 @@ +import { TLSSocket, connect } from "tls"; + +it("should work with alpnProtocols", done => { + try { + let socket: TLSSocket | null = connect({ + ALPNProtocols: ["http/1.1"], + host: "bun.sh", + servername: "bun.sh", + port: 443, + rejectUnauthorized: false, + }); + + const timeout = setTimeout(() => { + socket?.end(); + done("timeout"); + }, 3000); + + socket.on("error", err => { + clearTimeout(timeout); + done(err); + }); + + socket.on("secureConnect", () => { + clearTimeout(timeout); + done(socket?.alpnProtocol === "http/1.1" ? undefined : "alpnProtocol is not http/1.1"); + socket?.end(); + socket = null; + }); + } catch (err) { + done(err); + } +}); diff --git a/test/js/node/tls/node-tls-server.test.ts b/test/js/node/tls/node-tls-server.test.ts index 6879d0927..2a6101b9f 100644 --- a/test/js/node/tls/node-tls-server.test.ts +++ b/test/js/node/tls/node-tls-server.test.ts @@ -195,61 +195,6 @@ describe("tls.createServer listen", () => { ); }); - it("should listen on the correct port", done => { - const { mustCall, mustNotCall } = createCallCheckCtx(done); - - const server: Server = createServer(COMMON_CERT); - - let timeout: Timer; - const closeAndFail = () => { - clearTimeout(timeout); - server.close(); - mustNotCall()(); - }; - server.on("error", closeAndFail); - timeout = setTimeout(closeAndFail, 100); - - server.listen( - 49027, - mustCall(() => { - const address = server.address() as AddressInfo; - expect(address.address).toStrictEqual("::"); - expect(address.port).toStrictEqual(49027); - expect(address.family).toStrictEqual("IPv6"); - server.close(); - done(); - }), - ); - }); - - it("should listen on the correct port with IPV4", done => { - const { mustCall, mustNotCall } = createCallCheckCtx(done); - - const server: Server = createServer(COMMON_CERT); - - let timeout: Timer; - const closeAndFail = () => { - clearTimeout(timeout); - server.close(); - mustNotCall()(); - }; - server.on("error", closeAndFail); - timeout = setTimeout(closeAndFail, 100); - - server.listen( - 49026, - "0.0.0.0", - mustCall(() => { - const address = server.address() as AddressInfo; - expect(address.address).toStrictEqual("0.0.0.0"); - expect(address.port).toStrictEqual(49026); - expect(address.family).toStrictEqual("IPv4"); - server.close(); - done(); - }), - ); - }); - it("should listen on unix domain socket", done => { const { mustCall, mustNotCall } = createCallCheckCtx(done); diff --git a/test/js/third_party/nodemailer/nodemailer.test.ts b/test/js/third_party/nodemailer/nodemailer.test.ts new file mode 100644 index 000000000..265112608 --- /dev/null +++ b/test/js/third_party/nodemailer/nodemailer.test.ts @@ -0,0 +1,15 @@ +import { test, expect, describe } from "bun:test"; +import { bunRun } from "harness"; +import path from "path"; + +describe("nodemailer", () => { + test("basic smtp", async () => { + try { + const info = bunRun(path.join(import.meta.dir, "process-nodemailer-fixture.js")); + expect(info.stdout).toBe("true"); + expect(info.stderr || "").toBe(""); + } catch (err: any) { + expect(err?.message || err).toBe(""); + } + }, 10000); +}); diff --git a/test/js/third_party/nodemailer/package.json b/test/js/third_party/nodemailer/package.json new file mode 100644 index 000000000..08e98074f --- /dev/null +++ b/test/js/third_party/nodemailer/package.json @@ -0,0 +1,6 @@ +{ + "name": "nodemailer", + "dependencies": { + "nodemailer": "6.9.3" + } +} diff --git a/test/js/third_party/nodemailer/process-nodemailer-fixture.js b/test/js/third_party/nodemailer/process-nodemailer-fixture.js new file mode 100644 index 000000000..a54735f26 --- /dev/null +++ b/test/js/third_party/nodemailer/process-nodemailer-fixture.js @@ -0,0 +1,23 @@ +import nodemailer from "nodemailer"; +const account = await nodemailer.createTestAccount(); +const transporter = nodemailer.createTransport({ + host: account.smtp.host, + port: account.smtp.port, + secure: account.smtp.secure, + auth: { + user: account.user, // generated ethereal user + pass: account.pass, // generated ethereal password + }, +}); + +// send mail with defined transport object +let info = await transporter.sendMail({ + from: '"Fred Foo 👻" ', // sender address + to: "example@gmail.com", // list of receivers + subject: "Hello ✔", // Subject line + text: "Hello world?", // plain text body + html: "Hello world?", // html body +}); +const url = nodemailer.getTestMessageUrl(info); +console.log(typeof url === "string" && url.length > 0); +transporter.close(); diff --git a/test/js/web/timers/process-setImmediate-fixture.js b/test/js/web/timers/process-setImmediate-fixture.js new file mode 100644 index 000000000..6ffd91c8d --- /dev/null +++ b/test/js/web/timers/process-setImmediate-fixture.js @@ -0,0 +1,9 @@ +setImmediate(() => { + console.log("setImmediate"); + return { + a: 1, + b: 2, + c: 3, + d: 4, + }; +}); diff --git a/test/js/web/timers/setImmediate.test.js b/test/js/web/timers/setImmediate.test.js index 9cd6fa1c9..d00224e0f 100644 --- a/test/js/web/timers/setImmediate.test.js +++ b/test/js/web/timers/setImmediate.test.js @@ -1,4 +1,6 @@ import { it, expect } from "bun:test"; +import { bunExe, bunEnv } from "harness"; +import path from "path"; it("setImmediate", async () => { var lastID = -1; @@ -45,3 +47,28 @@ it("clearImmediate", async () => { }); expect(called).toBe(false); }); + +it("setImmediate should not keep the process alive forever", async () => { + let process = null; + const success = async () => { + process = Bun.spawn({ + cmd: [bunExe(), "run", path.join(import.meta.dir, "process-setImmediate-fixture.js")], + stdout: "ignore", + env: { + ...bunEnv, + NODE_ENV: undefined, + }, + }); + await process.exited; + process = null; + return true; + }; + + const fail = async () => { + await Bun.sleep(500); + process?.kill(); + return false; + }; + + expect(await Promise.race([success(), fail()])).toBe(true); +}); diff --git a/test/package.json b/test/package.json index 116571879..db0053874 100644 --- a/test/package.json +++ b/test/package.json @@ -16,9 +16,10 @@ "iconv-lite": "0.6.3", "jest-extended": "4.0.0", "lodash": "4.17.21", + "nodemailer": "6.9.3", "prisma": "4.15.0", - "socket.io": "4.6.1", - "socket.io-client": "4.6.1", + "socket.io": "4.7.1", + "socket.io-client": "4.7.1", "supertest": "6.1.6", "svelte": "3.55.1", "typescript": "5.0.2", -- cgit v1.2.3 From 983039a18afccb2f7d78dfdb06724d1ea58edde6 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 3 Jul 2023 13:16:45 -0700 Subject: Fixes #3508 --- src/bun.js/bindings/bindings.zig | 22 +++++++++- src/bun.js/webcore/encoding.zig | 8 ++++ src/napi/napi.zig | 94 +++++++++++----------------------------- src/string.zig | 52 +++++++++++++++++++++- 4 files changed, 105 insertions(+), 71 deletions(-) diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 777860d3c..277172b81 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -291,7 +291,27 @@ pub const ZigString = extern struct { return this.len * 2; } - /// Count the number of code points in the string. + pub fn utf16ByteLength(this: ZigString) usize { + if (this.isUTF8()) { + return bun.simdutf.length.utf16.from.utf8.le(this.slice()); + } + + if (this.is16Bit()) { + return this.len * 2; + } + + return JSC.WebCore.Encoder.byteLengthU8(this.slice().ptr, this.slice().len, .utf16le); + } + + pub fn latin1ByteLength(this: ZigString) usize { + if (this.isUTF8()) { + @panic("TODO"); + } + + return this.len; + } + + /// Count the number of bytes in the UTF-8 version of the string. /// This function is slow. Use maxUITF8ByteLength() to get a quick estimate pub fn utf8ByteLength(this: ZigString) usize { if (this.isUTF8()) { diff --git a/src/bun.js/webcore/encoding.zig b/src/bun.js/webcore/encoding.zig index 061a25eed..bb1180acb 100644 --- a/src/bun.js/webcore/encoding.zig +++ b/src/bun.js/webcore/encoding.zig @@ -985,6 +985,14 @@ pub const Encoder = struct { } } + pub fn encodeIntoFrom16(input: []const u16, to: []u8, comptime encoding: JSC.Node.Encoding, comptime allow_partial_write: bool) !usize { + return writeU16(input.ptr, input.len, to.ptr, to.len, encoding, allow_partial_write); + } + + pub fn encodeIntoFrom8(input: []const u8, to: []u8, comptime encoding: JSC.Node.Encoding) !usize { + return writeU8(input.ptr, input.len, to.ptr, to.len, encoding); + } + pub fn writeU16(input: [*]const u16, len: usize, to: [*]u8, to_len: usize, comptime encoding: JSC.Node.Encoding, comptime allow_partial_write: bool) !usize { if (len == 0) return 0; diff --git a/src/napi/napi.zig b/src/napi/napi.zig index 439319489..d9c7b5993 100644 --- a/src/napi/napi.zig +++ b/src/napi/napi.zig @@ -289,7 +289,10 @@ pub export fn napi_create_string_utf8(env: napi_env, str: [*]const u8, length: u log("napi_create_string_utf8: {s}", .{slice}); - setNapiValue(result, JSC.ZigString.fromUTF8(slice).toValueGC(env)); + var string = bun.String.create(slice); + defer string.deref(); + + setNapiValue(result, string.toJS(env)); return .ok; } pub export fn napi_create_string_utf16(env: napi_env, str: [*]const char16_t, length: usize, result: *napi_value) napi_status { @@ -340,18 +343,14 @@ inline fn maybeAppendNull(ptr: anytype, doit: bool) void { pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf_ptr: [*c]u8, bufsize: usize, result: *usize) napi_status { log("napi_get_value_string_latin1", .{}); defer value.ensureStillAlive(); - const zig_str = value.getZigString(env); + const str = value.toBunString(env); var buf = buf_ptr orelse { - result.* = if (!zig_str.is16Bit()) - zig_str.len - else - // should be same length if valid latin1 - strings.elementLengthUTF16IntoUTF8([]const u16, zig_str.utf16SliceAligned()); + result.* = str.latin1ByteLength(); return .ok; }; - if (zig_str.len == 0) { + if (str.isEmpty()) { result.* = 0; buf[0] = 0; @@ -367,18 +366,7 @@ pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf return .ok; } } - - if (zig_str.is16Bit()) { - const utf16 = zig_str.utf16SliceAligned(); - const wrote = JSC.WebCore.Encoder.writeU16(utf16.ptr, utf16.len, buf, buf_.len, .latin1, false) catch return genericFailure(); - maybeAppendNull(&buf[wrote], bufsize == 0); - // if zero terminated, report the length of the string without the null - result.* = @intCast(@TypeOf(result.*), wrote); - return .ok; - } - const to_copy = @min(zig_str.len, buf_.len); - @memcpy(buf[0..to_copy], zig_str.slice().ptr[0..to_copy]); - buf[to_copy] = 0; + const to_copy = str.encodeInto(buf_, .latin1) catch unreachable; // if zero terminated, report the length of the string without the null result.* = to_copy; return .ok; @@ -399,24 +387,22 @@ pub export fn napi_get_value_string_utf8(env: napi_env, value: napi_value, buf_p return .string_expected; } - const zig_str = value.getZigString(env); - var buf = buf_ptr orelse { + const str = value.toBunString(env); + + if (str.isEmpty()) { if (result_ptr) |result| { - result.* = if (!zig_str.is16Bit()) - zig_str.len - else - JSC.WebCore.Encoder.byteLengthU16(zig_str.utf16SliceAligned().ptr, zig_str.utf16SliceAligned().len, .utf8); + result.* = 0; } - return .ok; - }; + } - if (zig_str.len == 0) { + var buf = buf_ptr orelse { if (result_ptr) |result| { - result.* = 0; + result.* = str.utf8ByteLength(); } + return .ok; - } + }; var buf_ = buf[0..bufsize]; @@ -430,44 +416,29 @@ pub export fn napi_get_value_string_utf8(env: napi_env, value: napi_value, buf_p } } - if (zig_str.is16Bit()) { - const utf16 = zig_str.utf16SliceAligned(); - const wrote = JSC.WebCore.Encoder.writeU16(utf16.ptr, utf16.len, buf, buf_.len, .utf8, false) catch return genericFailure(); - buf[wrote] = 0; - if (result_ptr) |result| { - result.* = @intCast(@TypeOf(result.*), wrote); - } - - return .ok; - } + const written = str.encodeInto(buf_, .utf8) catch unreachable; - const to_copy = @min(zig_str.len, buf_.len); - @memcpy(buf[0..to_copy], zig_str.slice().ptr[0..to_copy]); - buf[to_copy] = 0; if (result_ptr) |result| { - result.* = @intCast(@TypeOf(result.*), to_copy); + result.* = written; } - log("napi_get_value_string_utf8: {s}", .{buf[0..to_copy]}); + log("napi_get_value_string_utf8: {s}", .{buf[0..written]}); return .ok; } pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ptr: [*c]char16_t, bufsize: usize, result_ptr: ?*usize) napi_status { log("napi_get_value_string_utf16", .{}); defer value.ensureStillAlive(); - const zig_str = value.getZigString(env); + const str = value.toBunString(env); var buf = buf_ptr orelse { if (result_ptr) |result| { - result.* = if (zig_str.is16Bit()) - zig_str.len - else - JSC.WebCore.Encoder.byteLengthU16(zig_str.utf16SliceAligned().ptr, zig_str.utf16SliceAligned().len, .latin1); + result.* = str.utf16ByteLength(); } return .ok; }; - if (zig_str.len == 0) { + if (str.isEmpty()) { if (result_ptr) |result| { result.* = 0; } @@ -487,20 +458,7 @@ pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ return .ok; } } - - if (!zig_str.is16Bit()) { - const slice = zig_str.slice(); - const encode_into_result = strings.copyLatin1IntoUTF16([]char16_t, buf_, []const u8, slice); - buf[@intCast(usize, encode_into_result.written)] = 0; - - if (result_ptr) |result| { - result.* = encode_into_result.written; - } - return .ok; - } - - const to_copy = @min(zig_str.len, buf_.len) * 2; - @memcpy(std.mem.sliceAsBytes(buf_)[0..to_copy], std.mem.sliceAsBytes(zig_str.utf16SliceAligned())[0..to_copy]); + const to_copy = (str.encodeInto(std.mem.sliceAsBytes(buf_), .utf16le) catch unreachable) >> 1; buf[to_copy] = 0; // if zero terminated, report the length of the string without the null if (result_ptr) |result| { @@ -509,9 +467,9 @@ pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ return .ok; } -pub export fn napi_coerce_to_bool(_: napi_env, value: napi_value, result: *napi_value) napi_status { +pub export fn napi_coerce_to_bool(env: napi_env, value: napi_value, result: *napi_value) napi_status { log("napi_coerce_to_bool", .{}); - result.* = JSValue.jsBoolean(value.to(bool)); + result.* = JSValue.jsBoolean(value.coerce(bool, env)); return .ok; } pub export fn napi_coerce_to_number(env: napi_env, value: napi_value, result: *napi_value) napi_status { diff --git a/src/string.zig b/src/string.zig index 3c0c99ce5..166a0a6f7 100644 --- a/src/string.zig +++ b/src/string.zig @@ -160,6 +160,17 @@ pub const WTFStringImplStruct = extern struct { } } + pub fn utf16ByteLength(this: WTFStringImpl) usize { + // All latin1 characters fit in a single UTF-16 code unit. + return this.length() * 2; + } + + pub fn latin1ByteLength(this: WTFStringImpl) usize { + // Not all UTF-16 characters fit are representable in latin1. + // Those get truncated? + return this.length(); + } + pub fn refCountAllocator(self: WTFStringImpl) std.mem.Allocator { return std.mem.Allocator{ .ptr = self, .vtable = StringImplAllocator.VTablePtr }; } @@ -286,6 +297,31 @@ pub const String = extern struct { return this; } + pub fn utf8ByteLength(this: String) usize { + return switch (this.tag) { + .WTFStringImpl => this.value.WTFStringImpl.utf8ByteLength(), + .ZigString => this.value.ZigString.utf8ByteLength(), + .StaticZigString => this.value.StaticZigString.utf8ByteLength(), + .Dead, .Empty => 0, + }; + } + + pub fn utf16ByteLength(this: String) usize { + return switch (this.tag) { + .WTFStringImpl => this.value.WTFStringImpl.utf16ByteLength(), + .StaticZigString, .ZigString => this.value.ZigString.utf16ByteLength(), + .Dead, .Empty => 0, + }; + } + + pub fn latin1ByteLength(this: String) usize { + return switch (this.tag) { + .WTFStringImpl => this.value.WTFStringImpl.latin1ByteLength(), + .StaticZigString, .ZigString => this.value.ZigString.latin1ByteLength(), + .Dead, .Empty => 0, + }; + } + pub fn initWithType(comptime Type: type, value: Type) String { switch (comptime Type) { ZigString => return String{ .tag = .ZigString, .value = .{ .ZigString = value } }, @@ -431,7 +467,7 @@ pub const String = extern struct { } pub fn isUTF8(self: String) bool { - if (!self.tag == .ZigString or self.tag == .StaticZigString) + if (!(self.tag == .ZigString or self.tag == .StaticZigString)) return false; return self.value.ZigString.isUTF8(); @@ -466,11 +502,23 @@ pub const String = extern struct { return !self.value.WTFStringImpl.is8Bit(); if (self.tag == .ZigString or self.tag == .StaticZigString) - return self.value.ZigString.isUTF16(); + return self.value.ZigString.is16Bit(); return false; } + pub fn encodeInto(self: String, out: []u8, comptime enc: JSC.Node.Encoding) !usize { + if (self.isUTF16()) { + return JSC.WebCore.Encoder.encodeIntoFrom16(self.utf16(), out, enc, true); + } + + if (self.isUTF8()) { + @panic("TODO"); + } + + return JSC.WebCore.Encoder.encodeIntoFrom8(self.latin1(), out, enc); + } + pub inline fn utf8(self: String) []const u8 { if (comptime bun.Environment.allow_assert) std.debug.assert(self.canBeUTF8()); -- cgit v1.2.3 From e5f93ddf55311a1e29f836676ce7b1a91a35eecb Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 3 Jul 2023 13:46:20 -0700 Subject: Update lifecycle.md --- docs/test/lifecycle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/test/lifecycle.md b/docs/test/lifecycle.md index ccb7ce85d..176c476de 100644 --- a/docs/test/lifecycle.md +++ b/docs/test/lifecycle.md @@ -10,7 +10,7 @@ The test runner supports the following lifecycle hooks. This is useful for loadi Perform per-test setup and teardown logic with `beforeEach` and `afterEach`. ```ts -import { expect, test } from "bun:test"; +import { beforeEach, afterEach } from "bun:test"; beforeEach(() => { console.log("running test."); -- cgit v1.2.3 From 424717a9737321a3f37f7596f62067d72cd97e25 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 3 Jul 2023 13:47:37 -0700 Subject: Fixes #3317 --- src/bun.js/bindings/napi.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp index bb62cb2a0..5d7204285 100644 --- a/src/bun.js/bindings/napi.cpp +++ b/src/bun.js/bindings/napi.cpp @@ -1539,8 +1539,10 @@ extern "C" napi_status napi_typeof(napi_env env, napi_value val, JSC::JSValue value = toJS(val); - if (UNLIKELY(value.isEmpty())) { - return napi_invalid_arg; + if (value.isEmpty()) { + // This can happen + *result = napi_undefined; + return napi_ok; } if (value.isCell()) { @@ -1579,17 +1581,18 @@ extern "C" napi_status napi_typeof(napi_env env, napi_value val, *result = napi_object; return napi_ok; - default: - if (cell->isObject()) { - *result = napi_object; + default: { + if (cell->isCallable() || cell->isConstructor()) { + *result = napi_function; return napi_ok; } - if (cell->isCallable() || cell->isConstructor()) { - *result = napi_function; + if (cell->isObject()) { + *result = napi_object; return napi_ok; } } + } } if (value.isNumber()) { -- cgit v1.2.3 From 034577c9dad2486324e3bd65907794dd9a3ee217 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Mon, 3 Jul 2023 18:08:49 -0300 Subject: [fix] patch fs.watch sym link (#3481) * oopsie * add tests --------- Co-authored-by: Jarred Sumner --- src/bun.js/node/node_fs_watcher.zig | 2 +- test/js/node/watch/fs.watch.test.js | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/bun.js/node/node_fs_watcher.zig b/src/bun.js/node/node_fs_watcher.zig index b1f4ec8a9..d0af350c0 100644 --- a/src/bun.js/node/node_fs_watcher.zig +++ b/src/bun.js/node/node_fs_watcher.zig @@ -802,7 +802,7 @@ pub const FSWatcher = struct { result.fd = file.handle; const _stat = try file.stat(); - result.is_file = _stat.kind == .directory; + result.is_file = _stat.kind != .directory; }, .directory => { const dir = (try std.fs.openIterableDirAbsoluteZ(absolute_path_z, .{ diff --git a/test/js/node/watch/fs.watch.test.js b/test/js/node/watch/fs.watch.test.js index 33d05df29..faf6a8546 100644 --- a/test/js/node/watch/fs.watch.test.js +++ b/test/js/node/watch/fs.watch.test.js @@ -19,6 +19,8 @@ const testDir = tempDirWithFiles("watch", { "url.txt": "hello", "close.txt": "hello", "close-close.txt": "hello", + "sym-sync.txt": "hello", + "sym.txt": "hello", [encodingFileName]: "hello", }); @@ -341,6 +343,36 @@ describe("fs.watch", () => { watcher.once("close", () => reject()); }); }); + + test("should work with symlink", async () => { + const filepath = path.join(testDir, "sym-symlink2.txt"); + await fs.promises.symlink(path.join(testDir, "sym-sync.txt"), filepath); + + const interval = repeat(() => { + fs.writeFileSync(filepath, "hello"); + }); + + const promise = new Promise((resolve, reject) => { + let timeout = null; + const watcher = fs.watch(filepath, event => { + clearTimeout(timeout); + clearInterval(interval); + try { + resolve(event); + } catch (e) { + reject(e); + } finally { + watcher.close(); + } + }); + setTimeout(() => { + clearInterval(interval); + watcher?.close(); + reject("timeout"); + }, 3000); + }); + expect(promise).resolves.toBe("change"); + }); }); describe("fs.promises.watch", () => { @@ -464,4 +496,27 @@ describe("fs.promises.watch", () => { } })(); }); + + test("should work with symlink", async () => { + const filepath = path.join(testDir, "sym-symlink.txt"); + await fs.promises.symlink(path.join(testDir, "sym.txt"), filepath); + + const watcher = fs.promises.watch(filepath); + const interval = repeat(() => { + fs.writeFileSync(filepath, "hello"); + }); + + const promise = (async () => { + try { + for await (const event of watcher) { + return event.eventType; + } + } catch (e) { + expect("unreacheable").toBe(false); + } finally { + clearInterval(interval); + } + })(); + expect(promise).resolves.toBe("change"); + }); }); -- cgit v1.2.3 From b26b0d886ce2f9898833e8efa16b71952c39b615 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 3 Jul 2023 15:56:58 -0700 Subject: Fix napi bug --- src/napi/napi.zig | 42 +++++++++++++++++++++++-------- test/js/third_party/prisma/prisma.test.ts | 2 +- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/napi/napi.zig b/src/napi/napi.zig index d9c7b5993..dc2cb602e 100644 --- a/src/napi/napi.zig +++ b/src/napi/napi.zig @@ -340,18 +340,22 @@ inline fn maybeAppendNull(ptr: anytype, doit: bool) void { ptr.* = 0; } } -pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf_ptr: [*c]u8, bufsize: usize, result: *usize) napi_status { +pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf_ptr: [*c]u8, bufsize: usize, result_ptr: ?*usize) napi_status { log("napi_get_value_string_latin1", .{}); defer value.ensureStillAlive(); const str = value.toBunString(env); var buf = buf_ptr orelse { - result.* = str.latin1ByteLength(); + if (result_ptr) |result| { + result.* = str.latin1ByteLength(); + } return .ok; }; if (str.isEmpty()) { - result.* = 0; + if (result_ptr) |result| { + result.* = 0; + } buf[0] = 0; return .ok; @@ -362,13 +366,21 @@ pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf if (bufsize == 0) { buf_ = bun.sliceTo(buf_ptr, 0); if (buf_.len == 0) { - result.* = 0; + if (result_ptr) |result| { + result.* = 0; + } return .ok; } } - const to_copy = str.encodeInto(buf_, .latin1) catch unreachable; - // if zero terminated, report the length of the string without the null - result.* = to_copy; + const written = str.encodeInto(buf_, .latin1) catch unreachable; + const max_buf_len = if (bufsize == 0) buf_.len else bufsize; + + if (result_ptr) |result| { + result.* = written; + } else if (written < max_buf_len) { + buf[written] = 0; + } + return .ok; } @@ -417,9 +429,12 @@ pub export fn napi_get_value_string_utf8(env: napi_env, value: napi_value, buf_p } const written = str.encodeInto(buf_, .utf8) catch unreachable; + const max_buf_len = if (bufsize == 0) buf_.len else bufsize; if (result_ptr) |result| { result.* = written; + } else if (written < max_buf_len) { + buf[written] = 0; } log("napi_get_value_string_utf8: {s}", .{buf[0..written]}); @@ -458,11 +473,16 @@ pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ return .ok; } } - const to_copy = (str.encodeInto(std.mem.sliceAsBytes(buf_), .utf16le) catch unreachable) >> 1; - buf[to_copy] = 0; - // if zero terminated, report the length of the string without the null + + const max_buf_len = if (bufsize == 0) buf_.len else bufsize; + const written = (str.encodeInto(std.mem.sliceAsBytes(buf_), .utf16le) catch unreachable) >> 1; + if (result_ptr) |result| { - result.* = to_copy; + result.* = written; + // We should only write to the buffer is no result pointer is provided. + // If we perform both operations, + } else if (written < max_buf_len) { + buf[written] = 0; } return .ok; diff --git a/test/js/third_party/prisma/prisma.test.ts b/test/js/third_party/prisma/prisma.test.ts index abe6f0635..2c87a9fcb 100644 --- a/test/js/third_party/prisma/prisma.test.ts +++ b/test/js/third_party/prisma/prisma.test.ts @@ -10,7 +10,7 @@ function* TestIDGenerator() { } const test_id = TestIDGenerator(); -["sqlite", "postgres", "mongodb"].forEach(async type => { +["sqlite" /*"postgres", "mongodb"*/].forEach(async type => { let Client: typeof PrismaClient; try { -- cgit v1.2.3 From 3345a7fc3c81f914000fd5a3c5a24f920a70386a Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 3 Jul 2023 20:53:41 -0700 Subject: Allow zero length WebSocket client & server messages (#3488) * Allow zero length WebSocket client & server messages * Add test * Clean this up a little * Clean up these tests a little * Hopefully fix the test failure in release build * Don't copy into the receive buffer * Less flaky --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/server.zig | 53 ----- src/bun.js/bindings/ZigGlobalObject.cpp | 26 +++ src/bun.js/bindings/ZigGlobalObject.h | 2 + src/bun.js/bindings/bindings.zig | 17 ++ src/bun.js/bindings/webcore/WebSocket.cpp | 27 ++- src/bun.js/bindings/webcore/WebSocket.h | 28 +-- src/http/websocket_http_client.zig | 172 +++++++++------ test/js/bun/websocket/websocket-server.test.ts | 292 +++++++++++++++---------- test/js/web/websocket/websocket.test.js | 34 ++- 9 files changed, 391 insertions(+), 260 deletions(-) diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index f52c08301..9625ff693 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -3560,11 +3560,6 @@ pub const ServerWebSocket = struct { if (message_value.asArrayBuffer(globalThis)) |array_buffer| { const buffer = array_buffer.slice(); - if (buffer.len == 0) { - globalThis.throw("publish requires a non-empty message", .{}); - return .zero; - } - const result = if (!publish_to_self) this.websocket.publish(topic_slice.slice(), buffer, .binary, compress) else @@ -3580,9 +3575,6 @@ pub const ServerWebSocket = struct { { var string_slice = message_value.toSlice(globalThis, bun.default_allocator); defer string_slice.deinit(); - if (string_slice.len == 0) { - return JSValue.jsNumber(0); - } const buffer = string_slice.slice(); @@ -3634,10 +3626,6 @@ pub const ServerWebSocket = struct { var topic_slice = topic_value.toSlice(globalThis, bun.default_allocator); defer topic_slice.deinit(); - if (topic_slice.len == 0) { - globalThis.throw("publishText requires a non-empty topic", .{}); - return .zero; - } const compress = args.len > 1 and compress_value.toBoolean(); @@ -3648,9 +3636,6 @@ pub const ServerWebSocket = struct { var string_slice = message_value.toSlice(globalThis, bun.default_allocator); defer string_slice.deinit(); - if (string_slice.len == 0) { - return JSValue.jsNumber(0); - } const buffer = string_slice.slice(); @@ -3715,10 +3700,6 @@ pub const ServerWebSocket = struct { }; const buffer = array_buffer.slice(); - if (buffer.len == 0) { - return JSC.JSValue.jsNumber(0); - } - const result = if (!publish_to_self) this.websocket.publish(topic_slice.slice(), buffer, .binary, compress) else @@ -3883,10 +3864,6 @@ pub const ServerWebSocket = struct { } if (message_value.asArrayBuffer(globalThis)) |buffer| { - if (buffer.len == 0) { - return JSValue.jsNumber(0); - } - switch (this.websocket.send(buffer.slice(), .binary, compress, true)) { .backpressure => { log("send() backpressure ({d} bytes)", .{buffer.len}); @@ -3906,9 +3883,6 @@ pub const ServerWebSocket = struct { { var string_slice = message_value.toSlice(globalThis, bun.default_allocator); defer string_slice.deinit(); - if (string_slice.len == 0) { - return JSValue.jsNumber(0); - } const buffer = string_slice.slice(); switch (this.websocket.send(buffer, .text, compress, true)) { @@ -3960,9 +3934,6 @@ pub const ServerWebSocket = struct { var string_slice = message_value.toSlice(globalThis, bun.default_allocator); defer string_slice.deinit(); - if (string_slice.len == 0) { - return JSValue.jsNumber(0); - } const buffer = string_slice.slice(); switch (this.websocket.send(buffer, .text, compress, true)) { @@ -3994,9 +3965,6 @@ pub const ServerWebSocket = struct { var string_slice = message_str.toSlice(globalThis, bun.default_allocator); defer string_slice.deinit(); - if (string_slice.len == 0) { - return JSValue.jsNumber(0); - } const buffer = string_slice.slice(); switch (this.websocket.send(buffer, .text, compress, true)) { @@ -4043,10 +4011,6 @@ pub const ServerWebSocket = struct { return .zero; }; - if (buffer.len == 0) { - return JSValue.jsNumber(0); - } - switch (this.websocket.send(buffer.slice(), .binary, compress, true)) { .backpressure => { log("sendBinary() backpressure ({d} bytes)", .{buffer.len}); @@ -4076,10 +4040,6 @@ pub const ServerWebSocket = struct { const buffer = array_buffer.slice(); - if (buffer.len == 0) { - return JSValue.jsNumber(0); - } - switch (this.websocket.send(buffer, .binary, compress, true)) { .backpressure => { log("sendBinary() backpressure ({d} bytes)", .{buffer.len}); @@ -4416,17 +4376,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { const compress = (compress_value orelse JSValue.jsBoolean(true)).toBoolean(); - if (message_value.isEmptyOrUndefinedOrNull()) { - JSC.JSError(this.vm.allocator, "publish requires a non-empty message", .{}, globalThis, exception); - return .zero; - } - if (message_value.asArrayBuffer(globalThis)) |buffer| { - if (buffer.len == 0) { - JSC.JSError(this.vm.allocator, "publish requires a non-empty message", .{}, globalThis, exception); - return .zero; - } - return JSValue.jsNumber( // if 0, return 0 // else return number of bytes sent @@ -4437,9 +4387,6 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { { var string_slice = message_value.toSlice(globalThis, bun.default_allocator); defer string_slice.deinit(); - if (string_slice.len == 0) { - return JSValue.jsNumber(0); - } const buffer = string_slice.slice(); return JSValue.jsNumber( diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index c00670289..b3236a4a2 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -1021,6 +1021,20 @@ JSC_DEFINE_HOST_FUNCTION(functionBunSleepThenCallback, return JSC::JSValue::encode(promise); } +using MicrotaskCallback = void (*)(void*); + +JSC_DEFINE_HOST_FUNCTION(functionNativeMicrotaskTrampoline, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + JSCell* cellPtr = callFrame->uncheckedArgument(0).asCell(); + JSCell* callbackPtr = callFrame->uncheckedArgument(1).asCell(); + + void* cell = reinterpret_cast(cellPtr); + auto* callback = reinterpret_cast(callbackPtr); + callback(cell); + return JSValue::encode(jsUndefined()); +} + JSC_DEFINE_HOST_FUNCTION(functionBunSleep, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { @@ -3027,6 +3041,11 @@ void GlobalObject::finishCreation(VM& vm) init.set(JSFunction::create(init.vm, init.owner, 4, "performMicrotaskVariadic"_s, jsFunctionPerformMicrotaskVariadic, ImplementationVisibility::Public)); }); + m_nativeMicrotaskTrampoline.initLater( + [](const Initializer& init) { + init.set(JSFunction::create(init.vm, init.owner, 2, ""_s, functionNativeMicrotaskTrampoline, ImplementationVisibility::Public)); + }); + m_navigatorObject.initLater( [](const Initializer& init) { int cpuCount = 0; @@ -4225,6 +4244,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) thisObject->m_JSFileSinkControllerPrototype.visit(visitor); thisObject->m_JSHTTPSResponseControllerPrototype.visit(visitor); thisObject->m_navigatorObject.visit(visitor); + thisObject->m_nativeMicrotaskTrampoline.visit(visitor); thisObject->m_performanceObject.visit(visitor); thisObject->m_primordialsObject.visit(visitor); thisObject->m_processEnvObject.visit(visitor); @@ -4387,6 +4407,12 @@ extern "C" void JSC__JSGlobalObject__reload(JSC__JSGlobalObject* arg0) globalObject->reload(); } +extern "C" void JSC__JSGlobalObject__queueMicrotaskCallback(Zig::GlobalObject* globalObject, void* ptr, MicrotaskCallback callback) +{ + JSFunction* function = globalObject->nativeMicrotaskTrampoline(); + globalObject->queueMicrotask(function, JSValue(reinterpret_cast(ptr)), JSValue(reinterpret_cast(callback)), jsUndefined(), jsUndefined()); +} + JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, JSModuleLoader* loader, JSValue key, JSValue referrer, JSValue origin) diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index a5b802ced..da6ba92a0 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -369,6 +369,7 @@ public: mutable WriteBarrier m_thenables[promiseFunctionsSize + 1]; JSObject* navigatorObject(); + JSFunction* nativeMicrotaskTrampoline() { return m_nativeMicrotaskTrampoline.getInitializedOnMainThread(this); } void trackFFIFunction(JSC::JSFunction* function) { @@ -466,6 +467,7 @@ private: */ LazyProperty m_pendingVirtualModuleResultStructure; LazyProperty m_performMicrotaskFunction; + LazyProperty m_nativeMicrotaskTrampoline; LazyProperty m_performMicrotaskVariadicFunction; LazyProperty m_emitReadableNextTickFunction; LazyProperty m_lazyReadableStreamPrototypeMap; diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 277172b81..07882d857 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -2732,6 +2732,23 @@ pub const JSGlobalObject = extern struct { this.vm().throwError(this, this.createErrorInstance(Output.prettyFmt(fmt, false), args)); } } + extern fn JSC__JSGlobalObject__queueMicrotaskCallback(*JSGlobalObject, *anyopaque, Function: *const (fn (*anyopaque) callconv(.C) void)) void; + pub fn queueMicrotaskCallback( + this: *JSGlobalObject, + ctx_val: anytype, + comptime Function: fn (ctx: @TypeOf(ctx_val)) void, + ) void { + JSC.markBinding(@src()); + const Fn = Function; + const ContextType = @TypeOf(ctx_val); + const Wrapper = struct { + pub fn call(p: *anyopaque) callconv(.C) void { + Fn(bun.cast(ContextType, p)); + } + }; + + JSC__JSGlobalObject__queueMicrotaskCallback(this, ctx_val, &Wrapper.call); + } pub fn queueMicrotask( this: *JSGlobalObject, diff --git a/src/bun.js/bindings/webcore/WebSocket.cpp b/src/bun.js/bindings/webcore/WebSocket.cpp index a346175df..1d6392f44 100644 --- a/src/bun.js/bindings/webcore/WebSocket.cpp +++ b/src/bun.js/bindings/webcore/WebSocket.cpp @@ -458,8 +458,8 @@ ExceptionOr WebSocket::send(const String& message) return {}; } - if (message.length() > 0) - this->sendWebSocketString(message); + // 0-length is allowed + this->sendWebSocketString(message); return {}; } @@ -477,8 +477,8 @@ ExceptionOr WebSocket::send(ArrayBuffer& binaryData) } char* data = static_cast(binaryData.data()); size_t length = binaryData.byteLength(); - if (length > 0) - this->sendWebSocketData(data, length); + // 0-length is allowed + this->sendWebSocketData(data, length); return {}; } @@ -498,8 +498,8 @@ ExceptionOr WebSocket::send(ArrayBufferView& arrayBufferView) auto buffer = arrayBufferView.unsharedBuffer().get(); char* baseAddress = reinterpret_cast(buffer->data()) + arrayBufferView.byteOffset(); size_t length = arrayBufferView.byteLength(); - if (length > 0) - this->sendWebSocketData(baseAddress, length); + // 0-length is allowed + this->sendWebSocketData(baseAddress, length); return {}; } @@ -1232,14 +1232,19 @@ extern "C" void WebSocket__didCloseWithErrorCode(WebCore::WebSocket* webSocket, extern "C" void WebSocket__didReceiveText(WebCore::WebSocket* webSocket, bool clone, const ZigString* str) { - WTF::String wtf_str = Zig::toString(*str); - if (clone) { - wtf_str = wtf_str.isolatedCopy(); - } - + WTF::String wtf_str = clone ? Zig::toStringCopy(*str) : Zig::toString(*str); webSocket->didReceiveMessage(WTFMove(wtf_str)); } extern "C" void WebSocket__didReceiveBytes(WebCore::WebSocket* webSocket, uint8_t* bytes, size_t len) { webSocket->didReceiveBinaryData({ bytes, len }); } + +extern "C" void WebSocket__incrementPendingActivity(WebCore::WebSocket* webSocket) +{ + webSocket->incPendingActivityCount(); +} +extern "C" void WebSocket__decrementPendingActivity(WebCore::WebSocket* webSocket) +{ + webSocket->decPendingActivityCount(); +} \ No newline at end of file diff --git a/src/bun.js/bindings/webcore/WebSocket.h b/src/bun.js/bindings/webcore/WebSocket.h index 42261cfc4..846bd186b 100644 --- a/src/bun.js/bindings/webcore/WebSocket.h +++ b/src/bun.js/bindings/webcore/WebSocket.h @@ -111,6 +111,20 @@ public: return m_hasPendingActivity.load(); } + void incPendingActivityCount() + { + m_pendingActivityCount++; + ref(); + updateHasPendingActivity(); + } + + void decPendingActivityCount() + { + m_pendingActivityCount--; + deref(); + updateHasPendingActivity(); + } + private: typedef union AnyWebSocket { WebSocketClient* client; @@ -147,20 +161,6 @@ private: void sendWebSocketString(const String& message); void sendWebSocketData(const char* data, size_t length); - void incPendingActivityCount() - { - m_pendingActivityCount++; - ref(); - updateHasPendingActivity(); - } - - void decPendingActivityCount() - { - m_pendingActivityCount--; - deref(); - updateHasPendingActivity(); - } - void failAsynchronously(); enum class BinaryType { Blob, diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index ee0fb9c77..a3ae8c3ba 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -145,6 +145,15 @@ const CppWebSocket = opaque { pub const didCloseWithErrorCode = WebSocket__didCloseWithErrorCode; pub const didReceiveText = WebSocket__didReceiveText; pub const didReceiveBytes = WebSocket__didReceiveBytes; + extern fn WebSocket__incrementPendingActivity(websocket_context: *CppWebSocket) void; + extern fn WebSocket__decrementPendingActivity(websocket_context: *CppWebSocket) void; + pub fn ref(this: *CppWebSocket) void { + WebSocket__incrementPendingActivity(this); + } + + pub fn unref(this: *CppWebSocket) void { + WebSocket__decrementPendingActivity(this); + } }; const body_buf_len = 16384 - 16; @@ -163,8 +172,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { to_send: []const u8 = "", read_length: usize = 0, headers_buf: [128]PicoHTTP.Header = undefined, - body_buf: ?*BodyBuf = null, - body_written: usize = 0, + body: std.ArrayListUnmanaged(u8) = .{}, websocket_protocol: u64 = 0, hostname: [:0]const u8 = "", poll_ref: JSC.PollRef = .{}, @@ -280,10 +288,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { this.poll_ref.unrefOnNextTick(JSC.VirtualMachine.get()); this.clearInput(); - if (this.body_buf) |buf| { - this.body_buf = null; - buf.release(); - } + this.body.clearAndFree(bun.default_allocator); } pub fn cancel(this: *HTTPClient) callconv(.C) void { this.clearData(); @@ -355,14 +360,6 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { this.to_send = this.input_body_buf[@intCast(usize, wrote)..]; } - fn getBody(this: *HTTPClient) *BodyBufBytes { - if (this.body_buf == null) { - this.body_buf = BodyBufPool.get(bun.default_allocator); - } - - return &this.body_buf.?.data; - } - pub fn handleData(this: *HTTPClient, socket: Socket, data: []const u8) void { log("onData", .{}); std.debug.assert(socket.socket == this.tcp.socket); @@ -374,43 +371,37 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { if (comptime Environment.allow_assert) std.debug.assert(!socket.isShutdown()); - var body = this.getBody(); - var remain = body[this.body_written..]; - const is_first = this.body_written == 0; + var body = data; + if (this.body.items.len > 0) { + this.body.appendSlice(bun.default_allocator, data) catch @panic("out of memory"); + body = this.body.items; + } + + const is_first = this.body.items.len == 0; if (is_first) { // fail early if we receive a non-101 status code - if (!strings.hasPrefixComptime(data, "HTTP/1.1 101 ")) { + if (!strings.hasPrefixComptime(body, "HTTP/1.1 101 ")) { this.terminate(ErrorCode.expected_101_status_code); return; } } - const to_write = remain[0..@min(remain.len, data.len)]; - if (data.len > 0 and to_write.len > 0) { - @memcpy(remain[0..to_write.len], data[0..to_write.len]); - this.body_written += to_write.len; - } - - const overflow = data[to_write.len..]; - - const available_to_read = body[0..this.body_written]; - const response = PicoHTTP.Response.parse(available_to_read, &this.headers_buf) catch |err| { + const response = PicoHTTP.Response.parse(body, &this.headers_buf) catch |err| { switch (err) { error.Malformed_HTTP_Response => { this.terminate(ErrorCode.invalid_response); return; }, error.ShortRead => { - if (overflow.len > 0) { - this.terminate(ErrorCode.headers_too_large); - return; + if (this.body.items.len == 0) { + this.body.appendSlice(bun.default_allocator, data) catch @panic("out of memory"); } return; }, } }; - this.processResponse(response, available_to_read[@intCast(usize, response.bytes_read)..]); + this.processResponse(response, body[@intCast(usize, response.bytes_read)..]); } pub fn handleEnd(this: *HTTPClient, socket: Socket) void { @@ -420,8 +411,6 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { } pub fn processResponse(this: *HTTPClient, response: PicoHTTP.Response, remain_buf: []const u8) void { - std.debug.assert(this.body_written > 0); - var upgrade_header = PicoHTTP.Header{ .name = "", .value = "" }; var connection_header = PicoHTTP.Header{ .name = "", .value = "" }; var websocket_accept_header = PicoHTTP.Header{ .name = "", .value = "" }; @@ -524,7 +513,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { this.terminate(ErrorCode.invalid_response); return; }; - if (remain_buf.len > 0) @memcpy(overflow[0..remain_buf.len], remain_buf); + @memcpy(overflow, remain_buf); } this.clearData(); @@ -866,6 +855,8 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { globalThis: *JSC.JSGlobalObject, poll_ref: JSC.PollRef = JSC.PollRef.init(), + initial_data_handler: ?*InitialDataHandler = null, + pub const name = if (ssl) "WebSocketClientTLS" else "WebSocketClient"; pub const shim = JSC.Shimmer("Bun", name, @This()); @@ -927,6 +918,8 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { JSC.markBinding(@src()); if (this.outgoing_websocket) |ws| { this.outgoing_websocket = null; + log("fail ({s})", .{@tagName(code)}); + ws.didCloseWithErrorCode(code); } @@ -937,7 +930,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { _ = socket; _ = ssl_error; JSC.markBinding(@src()); - log("WebSocket.onHandshake({d})", .{success}); + log("onHandshake({d})", .{success}); JSC.markBinding(@src()); if (success == 0) { if (this.outgoing_websocket) |ws| { @@ -1044,6 +1037,24 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { } pub fn handleData(this: *WebSocket, socket: Socket, data_: []const u8) void { + // Due to scheduling, it is possible for the websocket onData + // handler to run with additional data before the microtask queue is + // drained. + if (this.initial_data_handler) |initial_handler| { + // This calls `handleData` + // We deliberately do not set this.initial_data_handler to null here, that's done in handleWithoutDeinit. + // We do not free the memory here since the lifetime is managed by the microtask queue (it should free when called from there) + initial_handler.handleWithoutDeinit(); + + // handleWithoutDeinit is supposed to clear the handler from WebSocket* + // to prevent an infinite loop + std.debug.assert(this.initial_data_handler == null); + + // If we disconnected for any reason in the re-entrant case, we should just ignore the data + if (this.outgoing_websocket == null or this.tcp.isShutdown() or this.tcp.isClosed()) + return; + } + var data = data_; var receive_state = this.receive_state; var terminated = false; @@ -1141,6 +1152,30 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { terminated = true; break; } + + // Handle when the payload length is 0, but it is a message + // + // This should become + // + // - ArrayBuffer(0) + // - "" + // - Buffer(0) (etc) + // + if (receive_body_remain == 0 and receive_state == .need_body and is_final) { + _ = this.consume( + "", + receive_body_remain, + last_receive_data_type, + is_final, + ); + + // Return to the header state to read the next frame + receive_state = .need_header; + is_fragmented = false; + + // Bail out if there's nothing left to read + if (data.len == 0) break; + } }, .need_mask => { this.terminate(.unexpected_mask_from_server); @@ -1201,6 +1236,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { if (data.len == 0) break; }, .need_body => { + // Empty messages are valid, but we handle that earlier in the flow. if (receive_body_remain == 0 and data.len > 0) { this.terminate(ErrorCode.expected_control_frame); terminated = true; @@ -1434,9 +1470,6 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { return; } - if (len == 0) - return; - const slice = ptr[0..len]; const bytes = Copy{ .bytes = slice }; // fast path: small frame, no backpressure, attempt to send without allocating @@ -1460,9 +1493,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { return; } - if (str.len == 0) { - return; - } + // Note: 0 is valid { var inline_buf: [stack_frame_size]u8 = undefined; @@ -1525,6 +1556,33 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { this.sendCloseWithBody(this.tcp, code, null, 0); } + const InitialDataHandler = struct { + adopted: ?*WebSocket, + ws: *CppWebSocket, + slice: []u8, + + pub const Handle = JSC.AnyTask.New(@This(), handle); + + pub fn handleWithoutDeinit(this: *@This()) void { + var this_socket = this.adopted orelse return; + this.adopted = null; + this_socket.initial_data_handler = null; + var ws = this.ws; + defer ws.unref(); + + if (this_socket.outgoing_websocket != null) + this_socket.handleData(this_socket.tcp, this.slice); + } + + pub fn handle(this: *@This()) void { + defer { + bun.default_allocator.free(this.slice); + bun.default_allocator.destroy(this); + } + this.handleWithoutDeinit(); + } + }; + pub fn init( outgoing: *CppWebSocket, input_socket: *anyopaque, @@ -1554,33 +1612,19 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { var buffered_slice: []u8 = buffered_data[0..buffered_data_len]; if (buffered_slice.len > 0) { - const InitialDataHandler = struct { - adopted: *WebSocket, - slice: []u8, - task: JSC.AnyTask = undefined, - - pub const Handle = JSC.AnyTask.New(@This(), handle); - - pub fn handle(this: *@This()) void { - defer { - bun.default_allocator.free(this.slice); - bun.default_allocator.destroy(this); - } - - this.adopted.receive_buffer.ensureUnusedCapacity(this.slice.len) catch return; - var writable = this.adopted.receive_buffer.writableSlice(0); - @memcpy(writable[0..this.slice.len], this.slice); - - this.adopted.handleData(this.adopted.tcp, writable); - } - }; var initial_data = bun.default_allocator.create(InitialDataHandler) catch unreachable; initial_data.* = .{ .adopted = adopted, .slice = buffered_slice, + .ws = outgoing, }; - initial_data.task = InitialDataHandler.Handle.init(initial_data); - globalThis.bunVM().eventLoop().enqueueTask(JSC.Task.init(&initial_data.task)); + + // Use a higher-priority callback for the initial onData handler + globalThis.queueMicrotaskCallback(initial_data, InitialDataHandler.handle); + + // We need to ref the outgoing websocket so that it doesn't get finalized + // before the initial data handler is called + outgoing.ref(); } return @ptrCast( *anyopaque, diff --git a/test/js/bun/websocket/websocket-server.test.ts b/test/js/bun/websocket/websocket-server.test.ts index 2c2352f91..7913147f9 100644 --- a/test/js/bun/websocket/websocket-server.test.ts +++ b/test/js/bun/websocket/websocket-server.test.ts @@ -3,6 +3,77 @@ import { gcTick } from "harness"; import { serve, ServerWebSocket } from "bun"; describe("websocket server", () => { + it("send & receive empty messages", done => { + const serverReceived: any[] = []; + const clientReceived: any[] = []; + var clientDone = false; + var serverDone = false; + + let server = Bun.serve({ + websocket: { + open(ws) { + ws.send(""); + ws.send(new ArrayBuffer(0)); + }, + message(ws, data) { + serverReceived.push(data); + + if (serverReceived.length === 2) { + if (serverReceived.find(d => d === "") === undefined) { + done(new Error("expected empty string")); + } + + if (!serverReceived.find(d => d.byteLength === 0)) { + done(new Error("expected empty Buffer")); + } + + serverDone = true; + + if (clientDone && serverDone) { + z.close(); + server.stop(true); + done(); + } + } + }, + close() {}, + }, + fetch(req, server) { + if (!server.upgrade(req)) { + return new Response(null, { status: 404 }); + } + }, + port: 0, + }); + + let z = new WebSocket(`ws://${server.hostname}:${server.port}`); + z.onmessage = e => { + clientReceived.push(e.data); + + if (clientReceived.length === 2) { + if (clientReceived.find(d => d === "") === undefined) { + done(new Error("expected empty string")); + } + + if (!clientReceived.find(d => d.byteLength === 0)) { + done(new Error("expected empty Buffer")); + } + + clientDone = true; + if (clientDone && serverDone) { + server.stop(true); + z.close(); + + done(); + } + } + }; + z.addEventListener("open", () => { + z.send(""); + z.send(new Buffer(0)); + }); + }); + it("remoteAddress works", done => { let server = Bun.serve({ websocket: { @@ -859,16 +930,13 @@ describe("websocket server", () => { const server = serve({ port: 0, websocket: { - open(ws) { - server.stop(); - }, + open(ws) {}, message(ws, msg) { ws.send(sendQueue[serverCounter++] + " "); - gcTick(); + serverCounter % 10 === 0 && gcTick(); }, }, fetch(req, server) { - server.stop(); if ( server.upgrade(req, { data: { count: 0 }, @@ -879,32 +947,39 @@ describe("websocket server", () => { return new Response("noooooo hello world"); }, }); + try { + await new Promise((resolve, reject) => { + const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`); + websocket.onerror = e => { + reject(e); + }; - await new Promise((resolve, reject) => { - const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`); - websocket.onerror = e => { - reject(e); - }; + websocket.onopen = () => { + server.stop(); + websocket.send("first"); + }; - var counter = 0; - websocket.onopen = () => websocket.send("first"); - websocket.onmessage = e => { - try { - const expected = sendQueue[clientCounter++] + " "; - expect(e.data).toBe(expected); - websocket.send("next"); - if (clientCounter === sendQueue.length) { + websocket.onmessage = e => { + try { + const expected = sendQueue[clientCounter++] + " "; + expect(e.data).toBe(expected); + websocket.send("next"); + if (clientCounter === sendQueue.length) { + websocket.close(); + resolve(); + } + } catch (r) { + reject(r); + console.error(r); websocket.close(); - resolve(); } - } catch (r) { - reject(r); - console.error(r); - websocket.close(); - } - }; - }); - server.stop(true); + }; + }); + } catch (e) { + throw e; + } finally { + server.stop(true); + } }); // this test sends 100 messages to 10 connected clients via pubsub @@ -913,20 +988,15 @@ describe("websocket server", () => { var sendQueue: any[] = []; for (var i = 0; i < 100; i++) { sendQueue.push(ropey + " " + i); - gcTick(); } + var serverCounter = 0; var clientCount = 0; const server = serve({ port: 0, websocket: { - // FIXME: update this test to not rely on publishToSelf: true, - publishToSelf: true, - open(ws) { - server.stop(); ws.subscribe("test"); - gcTick(); if (!ws.isSubscribed("test")) { throw new Error("not subscribed"); } @@ -936,15 +1006,15 @@ describe("websocket server", () => { } ws.subscribe("test"); clientCount++; - if (clientCount === 10) setTimeout(() => ws.publish("test", "hello world"), 1); + if (clientCount === 10) { + setTimeout(() => server.publish("test", "hello world"), 1); + } }, message(ws, msg) { - if (serverCounter < sendQueue.length) ws.publish("test", sendQueue[serverCounter++] + " "); + if (serverCounter < sendQueue.length) server.publish("test", sendQueue[serverCounter++] + " "); }, }, fetch(req) { - gcTick(); - server.stop(); if ( server.upgrade(req, { data: { count: 0 }, @@ -954,89 +1024,89 @@ describe("websocket server", () => { return new Response("noooooo hello world"); }, }); + try { + const connections = new Array(10); + const websockets = new Array(connections.length); + var doneCounter = 0; + await new Promise(done => { + for (var i = 0; i < connections.length; i++) { + var j = i; + var resolve: (_?: unknown) => void, + reject: (_?: unknown) => void, + resolveConnection: (_?: unknown) => void, + rejectConnection: (_?: unknown) => void; + connections[j] = new Promise((res, rej) => { + resolveConnection = res; + rejectConnection = rej; + }); + websockets[j] = new Promise((res, rej) => { + resolve = res; + reject = rej; + }); + const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`); + websocket.onerror = e => { + reject(e); + }; + websocket.onclose = () => { + doneCounter++; + if (doneCounter === connections.length) { + done(); + } + }; + var hasOpened = false; + websocket.onopen = () => { + if (!hasOpened) { + hasOpened = true; + resolve(websocket); + } + }; - const connections = new Array(10); - const websockets = new Array(connections.length); - var doneCounter = 0; - await new Promise(done => { - for (var i = 0; i < connections.length; i++) { - var j = i; - var resolve: (_?: unknown) => void, - reject: (_?: unknown) => void, - resolveConnection: (_?: unknown) => void, - rejectConnection: (_?: unknown) => void; - connections[j] = new Promise((res, rej) => { - resolveConnection = res; - rejectConnection = rej; - }); - websockets[j] = new Promise((res, rej) => { - resolve = res; - reject = rej; - }); - gcTick(); - const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`); - websocket.onerror = e => { - reject(e); - }; - websocket.onclose = () => { - doneCounter++; - if (doneCounter === connections.length) { - done(); - } - }; - var hasOpened = false; - websocket.onopen = () => { - if (!hasOpened) { - hasOpened = true; - resolve(websocket); - } - }; - - let clientCounter = -1; - var hasSentThisTick = false; - - websocket.onmessage = e => { - gcTick(); - - if (!hasOpened) { - hasOpened = true; - resolve(websocket); - } + let clientCounter = -1; + var hasSentThisTick = false; - if (e.data === "hello world") { - clientCounter = 0; - websocket.send("first"); - return; - } + websocket.onmessage = e => { + if (!hasOpened) { + hasOpened = true; + resolve(websocket); + } - try { - expect(!!sendQueue.find(a => a + " " === e.data)).toBe(true); - - if (!hasSentThisTick) { - websocket.send("second"); - hasSentThisTick = true; - queueMicrotask(() => { - hasSentThisTick = false; - }); + if (e.data === "hello world") { + clientCounter = 0; + websocket.send("first"); + return; } - gcTick(); + try { + expect(!!sendQueue.find(a => a + " " === e.data)).toBe(true); + + if (!hasSentThisTick) { + websocket.send("second"); + hasSentThisTick = true; + queueMicrotask(() => { + hasSentThisTick = false; + }); + } - if (clientCounter++ === sendQueue.length - 1) { + if (clientCounter++ === sendQueue.length - 1) { + websocket.close(); + resolveConnection(); + } + } catch (r) { + console.error(r); websocket.close(); - resolveConnection(); + rejectConnection(r); } - } catch (r) { - console.error(r); - websocket.close(); - rejectConnection(r); - gcTick(); - } - }; - } - }); + }; + } + }); + } catch (e) { + throw e; + } finally { + server.stop(true); + gcTick(); + } + expect(serverCounter).toBe(sendQueue.length); - server.stop(true); }, 30_000); it("can close with reason and code #2631", done => { let timeout: any; diff --git a/test/js/web/websocket/websocket.test.js b/test/js/web/websocket/websocket.test.js index 867b86123..76ff16ecb 100644 --- a/test/js/web/websocket/websocket.test.js +++ b/test/js/web/websocket/websocket.test.js @@ -6,16 +6,33 @@ const TEST_WEBSOCKET_HOST = process.env.TEST_WEBSOCKET_HOST || "wss://ws.postman describe("WebSocket", () => { it("should connect", async () => { - const ws = new WebSocket(TEST_WEBSOCKET_HOST); - await new Promise((resolve, reject) => { + const server = Bun.serve({ + port: 0, + fetch(req, server) { + if (server.upgrade(req)) { + server.stop(); + return; + } + + return new Response(); + }, + websocket: { + open(ws) {}, + message(ws) { + ws.close(); + }, + }, + }); + const ws = new WebSocket(`ws://${server.hostname}:${server.port}`, {}); + await new Promise(resolve => { ws.onopen = resolve; - ws.onerror = reject; }); - var closed = new Promise((resolve, reject) => { + var closed = new Promise(resolve => { ws.onclose = resolve; }); ws.close(); await closed; + server.stop(true); }); it("should connect over https", async () => { @@ -59,17 +76,18 @@ describe("WebSocket", () => { const server = Bun.serve({ port: 0, fetch(req, server) { - server.stop(); done(); + server.stop(); return new Response(); }, websocket: { - open(ws) { + open(ws) {}, + message(ws) { ws.close(); }, }, }); - const ws = new WebSocket(`http://${server.hostname}:${server.port}`, {}); + new WebSocket(`http://${server.hostname}:${server.port}`, {}); }); describe("nodebuffer", () => { it("should support 'nodebuffer' binaryType", done => { @@ -93,6 +111,7 @@ describe("WebSocket", () => { expect(ws.binaryType).toBe("nodebuffer"); Bun.gc(true); ws.onmessage = ({ data }) => { + ws.close(); expect(Buffer.isBuffer(data)).toBe(true); expect(data).toEqual(new Uint8Array([1, 2, 3])); server.stop(true); @@ -117,6 +136,7 @@ describe("WebSocket", () => { ws.sendBinary(new Uint8Array([1, 2, 3])); setTimeout(() => { client.onmessage = ({ data }) => { + client.close(); expect(Buffer.isBuffer(data)).toBe(true); expect(data).toEqual(new Uint8Array([1, 2, 3])); server.stop(true); -- cgit v1.2.3 From 33bc507f7453beecd831295b576941b2d5fa6cfd Mon Sep 17 00:00:00 2001 From: Jarred SUmner Date: Tue, 4 Jul 2023 01:04:18 -0700 Subject: Fix napi --- src/bun.js/bindings/napi.cpp | 84 +++++++++++++++++++++++++++++++++++++++++--- src/napi/napi.zig | 63 ++------------------------------- 2 files changed, 82 insertions(+), 65 deletions(-) diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp index 5d7204285..8fffcc05f 100644 --- a/src/bun.js/bindings/napi.cpp +++ b/src/bun.js/bindings/napi.cpp @@ -14,7 +14,7 @@ #include "wtf/text/StringView.h" #include "wtf/text/StringBuilder.h" #include "wtf/text/WTFString.h" - +#include "BufferEncodingType.h" #include "JavaScriptCore/AggregateError.h" #include "JavaScriptCore/BytecodeIndex.h" #include "JavaScriptCore/CallFrame.h" @@ -1188,9 +1188,7 @@ void NapiClass::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(NapiClass); -static JSC_DECLARE_HOST_FUNCTION(NapiClass_ConstructorFunction); - -static JSC_DEFINE_HOST_FUNCTION(NapiClass_ConstructorFunction, +JSC_DEFINE_HOST_FUNCTION(NapiClass_ConstructorFunction, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { JSC::VM& vm = globalObject->vm(); @@ -1280,7 +1278,6 @@ NapiClass* NapiClass::create(VM& vm, Zig::GlobalObject* globalObject, const char { WTF::String name = WTF::String::fromUTF8(utf8name, length).isolatedCopy(); NativeExecutable* executable = vm.getHostFunction(NapiClass_ConstructorFunction, ImplementationVisibility::Public, NapiClass_ConstructorFunction, name); - Structure* structure = globalObject->NapiClassStructure(); NapiClass* napiClass = new (NotNull, allocateCell(vm)) NapiClass(vm, executable, globalObject, structure); napiClass->finishCreation(vm, executable, length, name, constructor, data, property_count, properties); @@ -1492,6 +1489,83 @@ extern "C" napi_status napi_get_property_names(napi_env env, napi_value object, return napi_ok; } +extern "C" napi_status napi_get_value_string_utf8(napi_env env, + napi_value napiValue, char* buf, + size_t bufsize, + size_t* writtenPtr) +{ + JSGlobalObject* globalObject = toJS(env); + JSC::VM& vm = globalObject->vm(); + + JSValue jsValue = toJS(napiValue); + if (!jsValue || !jsValue.isString()) { + return napi_string_expected; + } + + JSString* jsString = jsValue.toStringOrNull(globalObject); + if (UNLIKELY(!jsString)) { + return napi_generic_failure; + } + + size_t length = jsString->length(); + auto viewWithUnderlyingString = jsString->viewWithUnderlyingString(globalObject); + auto view = viewWithUnderlyingString.view; + + if (buf == nullptr) { + if (writtenPtr != nullptr) { + if (view.is8Bit()) { + *writtenPtr = Bun__encoding__byteLengthLatin1(view.characters8(), length, static_cast(WebCore::BufferEncodingType::utf8)); + } else { + *writtenPtr = Bun__encoding__byteLengthUTF16(view.characters16(), length, static_cast(WebCore::BufferEncodingType::utf8)); + } + } + + return napi_ok; + } + + if (bufsize == NAPI_AUTO_LENGTH) { + bufsize = strlen(buf); + } + + size_t written; + if (view.is8Bit()) { + written = Bun__encoding__writeLatin1(view.characters8(), view.length(), reinterpret_cast(buf), bufsize, static_cast(WebCore::BufferEncodingType::utf8)); + } else { + written = Bun__encoding__writeUTF16(view.characters16(), view.length(), reinterpret_cast(buf), bufsize, static_cast(WebCore::BufferEncodingType::utf8)); + } + + if (writtenPtr != nullptr) { + *writtenPtr = written; + } + + if (written < bufsize) { + buf[written] = '\0'; + } + + return napi_ok; +} + +extern "C" napi_status napi_get_element(napi_env env, napi_value objectValue, + uint32_t index, napi_value* result) +{ + JSValue jsValue = toJS(objectValue); + if (!jsValue || !jsValue.isObject()) { + return napi_invalid_arg; + } + + JSObject* object = jsValue.getObject(); + + auto scope = DECLARE_THROW_SCOPE(object->vm()); + JSValue element = object->getIndex(toJS(env), index); + RETURN_IF_EXCEPTION(scope, napi_generic_failure); + + if (result) { + *result = toNapi(element); + } + + return napi_ok; +} + extern "C" napi_status napi_create_object(napi_env env, napi_value* result) { diff --git a/src/napi/napi.zig b/src/napi/napi.zig index dc2cb602e..92b03aef0 100644 --- a/src/napi/napi.zig +++ b/src/napi/napi.zig @@ -291,7 +291,6 @@ pub export fn napi_create_string_utf8(env: napi_env, str: [*]const u8, length: u var string = bun.String.create(slice); defer string.deref(); - setNapiValue(result, string.toJS(env)); return .ok; } @@ -392,56 +391,8 @@ pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf /// If buf is NULL, this method returns the length of the string (in bytes) /// via the result parameter. /// The result argument is optional unless buf is NULL. -pub export fn napi_get_value_string_utf8(env: napi_env, value: napi_value, buf_ptr: [*c]u8, bufsize: usize, result_ptr: ?*usize) napi_status { - defer value.ensureStillAlive(); - - if (!value.isString()) { - return .string_expected; - } - - const str = value.toBunString(env); - - if (str.isEmpty()) { - if (result_ptr) |result| { - result.* = 0; - } - return .ok; - } - - var buf = buf_ptr orelse { - if (result_ptr) |result| { - result.* = str.utf8ByteLength(); - } - - return .ok; - }; - - var buf_ = buf[0..bufsize]; - - if (bufsize == 0) { - buf_ = bun.sliceTo(buf_ptr, 0); - if (buf_.len == 0) { - if (result_ptr) |result| { - result.* = 0; - } - return .ok; - } - } - - const written = str.encodeInto(buf_, .utf8) catch unreachable; - const max_buf_len = if (bufsize == 0) buf_.len else bufsize; - - if (result_ptr) |result| { - result.* = written; - } else if (written < max_buf_len) { - buf[written] = 0; - } - - log("napi_get_value_string_utf8: {s}", .{buf[0..written]}); - - return .ok; -} -pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ptr: [*c]char16_t, bufsize: usize, result_ptr: ?*usize) napi_status { +pub extern fn napi_get_value_string_utf8(env: napi_env, value: napi_value, buf_ptr: [*c]u8, bufsize: usize, result_ptr: ?*usize) napi_status ; +pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ptr: ?[*]char16_t, bufsize: usize, result_ptr: ?*usize) napi_status { log("napi_get_value_string_utf16", .{}); defer value.ensureStillAlive(); const str = value.toBunString(env); @@ -539,15 +490,7 @@ pub export fn napi_has_element(env: napi_env, object: napi_value, index: c_uint, result.* = object.getLength(env) > index; return .ok; } -pub export fn napi_get_element(env: napi_env, object: napi_value, index: u32, result: *napi_value) napi_status { - log("napi_get_element", .{}); - if (!object.jsType().isIndexable()) { - return .array_expected; - } - - result.* = JSC.JSObject.getIndex(object, env, index); - return .ok; -} +pub extern fn napi_get_element(env: napi_env, object: napi_value, index: u32, result: *napi_value) napi_status; pub extern fn napi_define_properties(env: napi_env, object: napi_value, property_count: usize, properties: [*c]const napi_property_descriptor) napi_status; pub export fn napi_is_array(_: napi_env, value: napi_value, result: *bool) napi_status { log("napi_is_array", .{}); -- cgit v1.2.3 From a76b07a802ddddcb1ac5791de73554f1e553bd0f Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 01:18:13 -0700 Subject: cleanup --- src/napi/napi.zig | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/napi/napi.zig b/src/napi/napi.zig index 92b03aef0..5caef4547 100644 --- a/src/napi/napi.zig +++ b/src/napi/napi.zig @@ -339,9 +339,11 @@ inline fn maybeAppendNull(ptr: anytype, doit: bool) void { ptr.* = 0; } } -pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf_ptr: [*c]u8, bufsize: usize, result_ptr: ?*usize) napi_status { +pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf_ptr_: ?[*:0]c_char, bufsize: usize, result_ptr: ?*usize) napi_status { log("napi_get_value_string_latin1", .{}); defer value.ensureStillAlive(); + var buf_ptr = @ptrCast(?[*:0]u8, buf_ptr_); + const str = value.toBunString(env); var buf = buf_ptr orelse { if (result_ptr) |result| { @@ -362,8 +364,8 @@ pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf var buf_ = buf[0..bufsize]; - if (bufsize == 0) { - buf_ = bun.sliceTo(buf_ptr, 0); + if (bufsize == NAPI_AUTO_LENGTH) { + buf_ = bun.sliceTo(buf_ptr.?, 0); if (buf_.len == 0) { if (result_ptr) |result| { result.* = 0; @@ -372,7 +374,7 @@ pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf } } const written = str.encodeInto(buf_, .latin1) catch unreachable; - const max_buf_len = if (bufsize == 0) buf_.len else bufsize; + const max_buf_len = buf_.len; if (result_ptr) |result| { result.* = written; @@ -391,7 +393,7 @@ pub export fn napi_get_value_string_latin1(env: napi_env, value: napi_value, buf /// If buf is NULL, this method returns the length of the string (in bytes) /// via the result parameter. /// The result argument is optional unless buf is NULL. -pub extern fn napi_get_value_string_utf8(env: napi_env, value: napi_value, buf_ptr: [*c]u8, bufsize: usize, result_ptr: ?*usize) napi_status ; +pub extern fn napi_get_value_string_utf8(env: napi_env, value: napi_value, buf_ptr: [*c]u8, bufsize: usize, result_ptr: ?*usize) napi_status; pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ptr: ?[*]char16_t, bufsize: usize, result_ptr: ?*usize) napi_status { log("napi_get_value_string_utf16", .{}); defer value.ensureStillAlive(); @@ -415,8 +417,8 @@ pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ var buf_ = buf[0..bufsize]; - if (bufsize == 0) { - buf_ = bun.sliceTo(buf_ptr, 0); + if (bufsize == NAPI_AUTO_LENGTH) { + buf_ = bun.sliceTo(@ptrCast([*:0]u16, buf_ptr.?), 0); if (buf_.len == 0) { if (result_ptr) |result| { result.* = 0; @@ -425,7 +427,7 @@ pub export fn napi_get_value_string_utf16(env: napi_env, value: napi_value, buf_ } } - const max_buf_len = if (bufsize == 0) buf_.len else bufsize; + const max_buf_len = buf_.len; const written = (str.encodeInto(std.mem.sliceAsBytes(buf_), .utf16le) catch unreachable) >> 1; if (result_ptr) |result| { -- cgit v1.2.3 From bc7b5165beba1388a39215ccfa8e848e4982f1ed Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 01:51:09 -0700 Subject: less flaky --- test/js/bun/websocket/websocket-server.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/bun/websocket/websocket-server.test.ts b/test/js/bun/websocket/websocket-server.test.ts index 7913147f9..a7b9b1777 100644 --- a/test/js/bun/websocket/websocket-server.test.ts +++ b/test/js/bun/websocket/websocket-server.test.ts @@ -920,7 +920,7 @@ describe("websocket server", () => { it("send rope strings", async () => { var ropey = "hello world".repeat(10); var sendQueue: any[] = []; - for (var i = 0; i < 100; i++) { + for (var i = 0; i < 20; i++) { sendQueue.push(ropey + " " + i); } -- cgit v1.2.3 From 3d0ffc48cb2608ed696581e10cb082c68b56c6b9 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 4 Jul 2023 12:09:58 +0300 Subject: [install] fix run-time module loading (#3510) - fix version buffer confusion - improve workaround to handle cached modules fixes #3507 --- src/install/install.zig | 84 +++++++++++++++--------------- src/js/out/modules/node/http.js | 2 + src/resolver/resolver.zig | 46 ++++++++--------- test/cli/install/bun-run.test.ts | 108 +++++++++++++++++++++++++++++++++------ 4 files changed, 154 insertions(+), 86 deletions(-) diff --git a/src/install/install.zig b/src/install/install.zig index 87f931291..f6133afce 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -1742,55 +1742,51 @@ pub const PackageManager = struct { pub fn enqueueDependencyToRoot( this: *PackageManager, name: []const u8, - version_buf: []const u8, version: *const Dependency.Version, + version_buf: []const u8, behavior: Dependency.Behavior, ) DependencyToEnqueue { - const str_buf = this.lockfile.buffers.string_bytes.items; - for (this.lockfile.buffers.dependencies.items, 0..) |dependency, dependency_id| { - if (!strings.eqlLong(dependency.name.slice(str_buf), name, true)) continue; - if (!dependency.version.eql(version, str_buf, version_buf)) continue; - return switch (this.lockfile.buffers.resolutions.items[dependency_id]) { - invalid_package_id => .{ - .pending = @truncate(DependencyID, dependency_id), - }, - else => |resolution_id| .{ - .resolution = .{ - .resolution = this.lockfile.packages.items(.resolution)[resolution_id], - .package_id = resolution_id, - }, - }, + const dep_id = @truncate(DependencyID, brk: { + const str_buf = this.lockfile.buffers.string_bytes.items; + for (this.lockfile.buffers.dependencies.items, 0..) |dep, id| { + if (!strings.eqlLong(dep.name.slice(str_buf), name, true)) continue; + if (!dep.version.eql(version, str_buf, version_buf)) continue; + break :brk id; + } + + var builder = this.lockfile.stringBuilder(); + const dummy = Dependency{ + .name = String.init(name, name), + .name_hash = String.Builder.stringHash(name), + .version = version.*, + .behavior = behavior, }; - } + dummy.countWithDifferentBuffers(name, version_buf, @TypeOf(&builder), &builder); - var builder = this.lockfile.stringBuilder(); - const dependency = Dependency{ - .name = String.init(name, name), - .name_hash = String.Builder.stringHash(name), - .version = version.*, - .behavior = behavior, - }; - dependency.countWithDifferentBuffers(name, version_buf, @TypeOf(&builder), &builder); - - builder.allocate() catch |err| return .{ .failure = err }; - - const cloned_dependency = dependency.cloneWithDifferentBuffers(name, version_buf, @TypeOf(&builder), &builder) catch unreachable; - builder.clamp(); - const index = @truncate(DependencyID, this.lockfile.buffers.dependencies.items.len); - this.lockfile.buffers.dependencies.append(this.allocator, cloned_dependency) catch unreachable; - this.lockfile.buffers.resolutions.append(this.allocator, invalid_package_id) catch unreachable; - if (comptime Environment.allow_assert) std.debug.assert(this.lockfile.buffers.dependencies.items.len == this.lockfile.buffers.resolutions.items.len); - this.enqueueDependencyWithMainAndSuccessFn( - index, - &cloned_dependency, - invalid_package_id, - assignRootResolution, - failRootResolution, - ) catch |err| { - return .{ .failure = err }; - }; + builder.allocate() catch |err| return .{ .failure = err }; + + const dep = dummy.cloneWithDifferentBuffers(name, version_buf, @TypeOf(&builder), &builder) catch unreachable; + builder.clamp(); + const index = this.lockfile.buffers.dependencies.items.len; + this.lockfile.buffers.dependencies.append(this.allocator, dep) catch unreachable; + this.lockfile.buffers.resolutions.append(this.allocator, invalid_package_id) catch unreachable; + if (comptime Environment.allow_assert) std.debug.assert(this.lockfile.buffers.dependencies.items.len == this.lockfile.buffers.resolutions.items.len); + break :brk index; + }); + + if (this.lockfile.buffers.resolutions.items[dep_id] == invalid_package_id) { + this.enqueueDependencyWithMainAndSuccessFn( + dep_id, + &this.lockfile.buffers.dependencies.items[dep_id], + invalid_package_id, + assignRootResolution, + failRootResolution, + ) catch |err| { + return .{ .failure = err }; + }; + } - const resolution_id = switch (this.lockfile.buffers.resolutions.items[index]) { + const resolution_id = switch (this.lockfile.buffers.resolutions.items[dep_id]) { invalid_package_id => brk: { this.drainDependencyList(); @@ -1815,7 +1811,7 @@ pub const PackageManager = struct { }, } - break :brk this.lockfile.buffers.resolutions.items[index]; + break :brk this.lockfile.buffers.resolutions.items[dep_id]; }, // we managed to synchronously resolve the dependency else => |pkg_id| pkg_id, diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index 955c83642..f07dcc2e0 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -1085,6 +1085,8 @@ var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, METHODS = [ debug(`${NODE_HTTP_WARNING}\n`, "setMaxIdleHTTPParsers() is a no-op"); }, globalAgent, + ClientRequest, + OutgoingMessage, [Symbol.for("CommonJS")]: 0 }, http_default = defaultObject; export { diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index e1e83ba4f..409df85af 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -1256,14 +1256,8 @@ pub const Resolver = struct { if (check_package) { if (r.opts.polyfill_node_globals) { - var import_path_without_node_prefix = import_path; - const had_node_prefix = import_path_without_node_prefix.len > "node:".len and - strings.eqlComptime(import_path_without_node_prefix[0.."node:".len], "node:"); - - import_path_without_node_prefix = if (had_node_prefix) - import_path_without_node_prefix["node:".len..] - else - import_path_without_node_prefix; + const had_node_prefix = strings.hasPrefixComptime(import_path, "node:"); + const import_path_without_node_prefix = if (had_node_prefix) import_path["node:".len..] else import_path; if (NodeFallbackModules.Map.get(import_path_without_node_prefix)) |*fallback_module| { result.path_pair.primary = fallback_module.path; @@ -1278,7 +1272,7 @@ pub const Resolver = struct { } else if (had_node_prefix or (strings.hasPrefixComptime(import_path_without_node_prefix, "fs") and (import_path_without_node_prefix.len == 2 or - import_path_without_node_prefix[3] == '/'))) + import_path_without_node_prefix[2] == '/'))) { result.path_pair.primary.namespace = "node"; result.path_pair.primary.text = import_path_without_node_prefix; @@ -1698,8 +1692,9 @@ pub const Resolver = struct { // If the source directory doesn't have a node_modules directory, we can // check the global cache directory for a package.json file. var manager = r.getPackageManager(); - var dependency_version: Dependency.Version = .{}; + var dependency_version = Dependency.Version{}; var dependency_behavior = @enumFromInt(Dependency.Behavior, Dependency.Behavior.normal); + var string_buf = esm.version; // const initial_pending_tasks = manager.pending_tasks; var resolved_package_id: Install.PackageID = brk: { @@ -1707,7 +1702,6 @@ pub const Resolver = struct { // and try to look up the dependency from there if (dir_info.package_json_for_dependencies) |package_json| { var dependencies_list: []const Dependency = &[_]Dependency{}; - var string_buf: []const u8 = ""; const resolve_from_lockfile = package_json.package_manager_package_id != Install.invalid_package_id; if (resolve_from_lockfile) { @@ -1723,24 +1717,21 @@ pub const Resolver = struct { } for (dependencies_list, 0..) |dependency, dependency_id| { - const dep_name = dependency.name.slice(string_buf); - if (dep_name.len == esm.name.len) { - if (!strings.eqlLong(dep_name, esm.name, false)) { - continue; - } + if (!strings.eqlLong(dependency.name.slice(string_buf), esm.name, true)) { + continue; + } - dependency_version = dependency.version; - dependency_behavior = dependency.behavior; + dependency_version = dependency.version; + dependency_behavior = dependency.behavior; - if (resolve_from_lockfile) { - const resolutions = &manager.lockfile.packages.items(.resolutions)[package_json.package_manager_package_id]; + if (resolve_from_lockfile) { + const resolutions = &manager.lockfile.packages.items(.resolutions)[package_json.package_manager_package_id]; - // found it! - break :brk resolutions.get(manager.lockfile.buffers.resolutions.items)[dependency_id]; - } - - break; + // found it! + break :brk resolutions.get(manager.lockfile.buffers.resolutions.items)[dependency_id]; } + + break; } } @@ -1770,6 +1761,7 @@ pub const Resolver = struct { if (esm_.?.version.len > 0 and dir_info.enclosing_package_json != null and global_cache.allowVersionSpecifier()) { return .{ .failure = error.VersionSpecifierNotAllowedHere }; } + string_buf = esm.version; dependency_version = Dependency.parse( r.allocator, Semver.String.init(esm.name, esm.name), @@ -1795,6 +1787,7 @@ pub const Resolver = struct { dependency_behavior, &resolved_package_id, dependency_version, + string_buf, )) { .resolution => |res| break :brk res, .pending => |pending| return .{ .pending = pending }, @@ -2073,6 +2066,7 @@ pub const Resolver = struct { behavior: Dependency.Behavior, input_package_id_: *Install.PackageID, version: Dependency.Version, + version_buf: []const u8, ) DependencyToResolve { if (r.debug_logs) |*debug| { debug.addNoteFmt("Enqueueing pending dependency \"{s}@{s}\"", .{ esm.name, esm.version }); @@ -2135,7 +2129,7 @@ pub const Resolver = struct { // All packages are enqueued to the root // because we download all the npm package dependencies - switch (pm.enqueueDependencyToRoot(esm.name, esm.version, &version, behavior)) { + switch (pm.enqueueDependencyToRoot(esm.name, &version, version_buf, behavior)) { .resolution => |result| { input_package_id_.* = result.package_id; return .{ .resolution = result.resolution }; diff --git a/test/cli/install/bun-run.test.ts b/test/cli/install/bun-run.test.ts index 9ab094f08..95f33ebb8 100644 --- a/test/cli/install/bun-run.test.ts +++ b/test/cli/install/bun-run.test.ts @@ -24,7 +24,37 @@ const { minify } = require("uglify-js@3.17.4"); console.log(minify("print(6 * 7)").code); `, ); - const { stdout, stderr, exited } = spawn({ + const { + stdout: stdout1, + stderr: stderr1, + exited: exited1, + } = spawn({ + cmd: [bunExe(), "run", "test.js"], + cwd: run_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env: { + ...env, + BUN_INSTALL_CACHE_DIR: join(run_dir, ".cache"), + }, + }); + expect(stderr1).toBeDefined(); + const err1 = await new Response(stderr1).text(); + expect(err1).toBe(""); + expect(await readdirSorted(run_dir)).toEqual([".cache", "test.js"]); + expect(await readdirSorted(join(run_dir, ".cache"))).toContain("uglify-js"); + expect(await readdirSorted(join(run_dir, ".cache", "uglify-js"))).toEqual(["3.17.4"]); + expect(stdout1).toBeDefined(); + const out1 = await new Response(stdout1).text(); + expect(out1.split(/\r?\n/)).toEqual(["print(42);", ""]); + expect(await exited1).toBe(0); + // Perform `bun test.js` with cached dependencies + const { + stdout: stdout2, + stderr: stderr2, + exited: exited2, + } = spawn({ cmd: [bunExe(), "test.js"], cwd: run_dir, stdout: null, @@ -35,14 +65,16 @@ console.log(minify("print(6 * 7)").code); BUN_INSTALL_CACHE_DIR: join(run_dir, ".cache"), }, }); - expect(stderr).toBeDefined(); - const err = await new Response(stderr).text(); - expect(err).toBe(""); - expect(stdout).toBeDefined(); - const out = await new Response(stdout).text(); - expect(out.split(/\r?\n/)).toEqual(["print(42);", ""]); - expect(await exited).toBe(0); + expect(stderr2).toBeDefined(); + const err2 = await new Response(stderr2).text(); + expect(err2).toBe(""); expect(await readdirSorted(run_dir)).toEqual([".cache", "test.js"]); + expect(await readdirSorted(join(run_dir, ".cache"))).toContain("uglify-js"); + expect(await readdirSorted(join(run_dir, ".cache", "uglify-js"))).toEqual(["3.17.4"]); + expect(stdout2).toBeDefined(); + const out2 = await new Response(stdout2).text(); + expect(out2.split(/\r?\n/)).toEqual(["print(42);", ""]); + expect(await exited2).toBe(0); }); it("should download dependencies to run local file", async () => { @@ -58,7 +90,11 @@ for (const entry of await decompress(Buffer.from(buffer))) { } `, ); - const { stdout, stderr, exited } = spawn({ + const { + stdout: stdout1, + stderr: stderr1, + exited: exited1, + } = spawn({ cmd: [bunExe(), "test.js"], cwd: run_dir, stdout: null, @@ -69,9 +105,49 @@ for (const entry of await decompress(Buffer.from(buffer))) { BUN_INSTALL_CACHE_DIR: join(run_dir, ".cache"), }, }); - expect(stderr).toBeDefined(); - const err = await new Response(stderr).text(); - expect(err).toBe(""); + expect(stderr1).toBeDefined(); + const err1 = await new Response(stderr1).text(); + expect(err1).toBe(""); + expect(await readdirSorted(run_dir)).toEqual([".cache", "test.js"]); + expect(await readdirSorted(join(run_dir, ".cache"))).toContain("decompress"); + expect(await readdirSorted(join(run_dir, ".cache", "decompress"))).toEqual(["4.2.1"]); + expect(await readdirSorted(join(run_dir, ".cache", "decompress", "4.2.1"))).toEqual([ + "index.js", + "license", + "package.json", + "readme.md", + ]); + expect(await file(join(run_dir, ".cache", "decompress", "4.2.1", "index.js")).text()).toContain( + "\nmodule.exports = ", + ); + expect(stdout1).toBeDefined(); + const out1 = await new Response(stdout1).text(); + expect(out1.split(/\r?\n/)).toEqual([ + "directory: package/", + "file: package/index.js", + "file: package/package.json", + "", + ]); + expect(await exited1).toBe(0); + // Perform `bun run test.js` with cached dependencies + const { + stdout: stdout2, + stderr: stderr2, + exited: exited2, + } = spawn({ + cmd: [bunExe(), "run", "test.js"], + cwd: run_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env: { + ...env, + BUN_INSTALL_CACHE_DIR: join(run_dir, ".cache"), + }, + }); + expect(stderr2).toBeDefined(); + const err2 = await new Response(stderr2).text(); + expect(err2).toBe(""); expect(await readdirSorted(run_dir)).toEqual([".cache", "test.js"]); expect(await readdirSorted(join(run_dir, ".cache"))).toContain("decompress"); expect(await readdirSorted(join(run_dir, ".cache", "decompress"))).toEqual(["4.2.1"]); @@ -84,13 +160,13 @@ for (const entry of await decompress(Buffer.from(buffer))) { expect(await file(join(run_dir, ".cache", "decompress", "4.2.1", "index.js")).text()).toContain( "\nmodule.exports = ", ); - expect(stdout).toBeDefined(); - const out = await new Response(stdout).text(); - expect(out.split(/\r?\n/)).toEqual([ + expect(stdout2).toBeDefined(); + const out2 = await new Response(stdout2).text(); + expect(out2.split(/\r?\n/)).toEqual([ "directory: package/", "file: package/index.js", "file: package/package.json", "", ]); - expect(await exited).toBe(0); + expect(await exited2).toBe(0); }); -- cgit v1.2.3 From f49a308d2c2d30c798de738e05b528ecc4eaf9ee Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 03:47:31 -0700 Subject: Create readfile-not-found.mjs --- bench/snippets/readfile-not-found.mjs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bench/snippets/readfile-not-found.mjs diff --git a/bench/snippets/readfile-not-found.mjs b/bench/snippets/readfile-not-found.mjs new file mode 100644 index 000000000..c28100ba4 --- /dev/null +++ b/bench/snippets/readfile-not-found.mjs @@ -0,0 +1,17 @@ +import { bench, run } from "./runner.mjs"; +import { readFileSync, existsSync } from "node:fs"; +import { readFile } from "node:fs/promises"; + +bench(`readFileSync(/tmp/404-not-found)`, () => { + try { + readFileSync("/tmp/404-not-found"); + } catch (e) {} +}); + +bench(`readFile(/tmp/404-not-found)`, async () => { + try { + await readFile("/tmp/404-not-found"); + } catch (e) {} +}); + +await run(); -- cgit v1.2.3 From bb96aa5156cd13cb6662991368a10b19a8d13239 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 04:07:35 -0700 Subject: Fix crash --- src/bun.js/bindings/ZigGlobalObject.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index b3236a4a2..4bb5445e1 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -1026,11 +1026,12 @@ using MicrotaskCallback = void (*)(void*); JSC_DEFINE_HOST_FUNCTION(functionNativeMicrotaskTrampoline, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { - JSCell* cellPtr = callFrame->uncheckedArgument(0).asCell(); - JSCell* callbackPtr = callFrame->uncheckedArgument(1).asCell(); + // Do not use JSCell* here because the GC will try to visit it. + double cellPtr = callFrame->uncheckedArgument(0).asNumber(); + double callbackPtr = callFrame->uncheckedArgument(1).asNumber(); - void* cell = reinterpret_cast(cellPtr); - auto* callback = reinterpret_cast(callbackPtr); + void* cell = reinterpret_cast(bitwise_cast(cellPtr)); + auto* callback = reinterpret_cast(bitwise_cast(callbackPtr)); callback(cell); return JSValue::encode(jsUndefined()); } @@ -4410,7 +4411,9 @@ extern "C" void JSC__JSGlobalObject__reload(JSC__JSGlobalObject* arg0) extern "C" void JSC__JSGlobalObject__queueMicrotaskCallback(Zig::GlobalObject* globalObject, void* ptr, MicrotaskCallback callback) { JSFunction* function = globalObject->nativeMicrotaskTrampoline(); - globalObject->queueMicrotask(function, JSValue(reinterpret_cast(ptr)), JSValue(reinterpret_cast(callback)), jsUndefined(), jsUndefined()); + + // Do not use JSCell* here because the GC will try to visit it. + globalObject->queueMicrotask(function, JSValue(bitwise_cast(reinterpret_cast(ptr))), JSValue(bitwise_cast(reinterpret_cast(callback))), jsUndefined(), jsUndefined()); } JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, -- cgit v1.2.3 From 491e8f7e00aaf710f2fcd480a96cb002541de013 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 04:14:06 -0700 Subject: bump --- test/bun.lockb | Bin 140524 -> 141113 bytes test/js/third_party/socket.io/package.json | 2 +- test/package.json | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bun.lockb b/test/bun.lockb index e3a2abdfa..c35182d46 100755 Binary files a/test/bun.lockb and b/test/bun.lockb differ diff --git a/test/js/third_party/socket.io/package.json b/test/js/third_party/socket.io/package.json index af70e36a6..e54aa3de9 100644 --- a/test/js/third_party/socket.io/package.json +++ b/test/js/third_party/socket.io/package.json @@ -4,6 +4,6 @@ "dependencies": { "socket.io": "4.6.1", "socket.io-client": "4.6.1", - "supertest": "6.1.6" + "supertest": "6.3.3" } } diff --git a/test/package.json b/test/package.json index db0053874..d26875126 100644 --- a/test/package.json +++ b/test/package.json @@ -20,7 +20,7 @@ "prisma": "4.15.0", "socket.io": "4.7.1", "socket.io-client": "4.7.1", - "supertest": "6.1.6", + "supertest": "6.3.3", "svelte": "3.55.1", "typescript": "5.0.2", "undici": "5.20.0", -- cgit v1.2.3 From 31f7f9e2dc1504a93467f07eb2dd3bb7b94dbc0b Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 04:15:22 -0700 Subject: reduce count --- test/js/bun/websocket/websocket-server.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/js/bun/websocket/websocket-server.test.ts b/test/js/bun/websocket/websocket-server.test.ts index a7b9b1777..7a79f9f5f 100644 --- a/test/js/bun/websocket/websocket-server.test.ts +++ b/test/js/bun/websocket/websocket-server.test.ts @@ -982,11 +982,11 @@ describe("websocket server", () => { } }); - // this test sends 100 messages to 10 connected clients via pubsub + // this test sends 50 messages to 10 connected clients via pubsub it("pub/sub", async () => { var ropey = "hello world".repeat(10); var sendQueue: any[] = []; - for (var i = 0; i < 100; i++) { + for (var i = 0; i < 50; i++) { sendQueue.push(ropey + " " + i); } -- cgit v1.2.3 From c2755f770cb0d6296c82a6f6d633d62307449028 Mon Sep 17 00:00:00 2001 From: Ai Hoshino Date: Wed, 5 Jul 2023 06:38:44 +0800 Subject: Add alias for readBigUInt64BE ... (#3514) * Add alias for `readBigUInt64BE` ... Close: https://github.com/oven-sh/bun/issues/3338 * add some tests for `readBigUint64BE` alias * format code --- src/bun.js/bindings/JSBuffer.cpp | 17 +++++++++++---- test/js/node/buffer.test.js | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index 87e1d4048..08475735b 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -1877,11 +1877,17 @@ static const HashTableValue JSBufferPrototypeTableValues[] { "readUInt8"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUInt8CodeGenerator, 1 } }, { "readUIntBE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUIntBECodeGenerator, 1 } }, { "readUIntLE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUIntLECodeGenerator, 1 } }, + // name alias + { "readUintBE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUIntBECodeGenerator, 1 } }, + { "readUintLE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUIntLECodeGenerator, 1 } }, + { "readUint8"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUInt8CodeGenerator, 1 } }, { "readUint16BE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUInt16BECodeGenerator, 1 } }, { "readUint16LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUInt16LECodeGenerator, 1 } }, { "readUint32BE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUInt32BECodeGenerator, 1 } }, { "readUint32LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUInt32LECodeGenerator, 1 } }, - { "readUint8"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadUInt8CodeGenerator, 1 } }, + { "readBigUint64BE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadBigUInt64BECodeGenerator, 1 } }, + { "readBigUint64LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeReadBigUInt64LECodeGenerator, 1 } }, + { "slice"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeSliceCodeGenerator, 2 } }, { "subarray"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeSliceCodeGenerator, 2 } }, { "swap16"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBufferPrototypeFunction_swap16, 0 } }, @@ -1901,8 +1907,6 @@ static const HashTableValue JSBufferPrototypeTableValues[] { "writeBigInt64LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteBigInt64LECodeGenerator, 1 } }, { "writeBigUInt64BE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteBigUInt64BECodeGenerator, 1 } }, { "writeBigUInt64LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteBigUInt64LECodeGenerator, 1 } }, - { "writeBigUint64BE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteBigUInt64BECodeGenerator, 1 } }, - { "writeBigUint64LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteBigUInt64LECodeGenerator, 1 } }, { "writeDouble"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteDoubleLECodeGenerator, 1 } }, { "writeDoubleBE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteDoubleBECodeGenerator, 1 } }, { "writeDoubleLE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteDoubleLECodeGenerator, 1 } }, @@ -1925,13 +1929,18 @@ static const HashTableValue JSBufferPrototypeTableValues[] { "writeUInt8"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt8CodeGenerator, 1 } }, { "writeUIntBE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUIntBECodeGenerator, 1 } }, { "writeUIntLE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUIntLECodeGenerator, 1 } }, + // name alias + { "writeUintBE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUIntBECodeGenerator, 1 } }, + { "writeUintLE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUIntLECodeGenerator, 1 } }, + { "writeUint8"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt8CodeGenerator, 1 } }, { "writeUint16"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt16LECodeGenerator, 1 } }, { "writeUint16BE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt16BECodeGenerator, 1 } }, { "writeUint16LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt16LECodeGenerator, 1 } }, { "writeUint32"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt32LECodeGenerator, 1 } }, { "writeUint32BE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt32BECodeGenerator, 1 } }, { "writeUint32LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt32LECodeGenerator, 1 } }, - { "writeUint8"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteUInt8CodeGenerator, 1 } }, + { "writeBigUint64BE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteBigUInt64BECodeGenerator, 1 } }, + { "writeBigUint64LE"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteBigUInt64LECodeGenerator, 1 } }, }; void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis) diff --git a/test/js/node/buffer.test.js b/test/js/node/buffer.test.js index 99562fedd..cfd114423 100644 --- a/test/js/node/buffer.test.js +++ b/test/js/node/buffer.test.js @@ -2493,3 +2493,48 @@ it("inspect() should exist", () => { expect(Buffer.prototype.inspect).toBeInstanceOf(Function); expect(new Buffer("123").inspect()).toBe(Bun.inspect(new Buffer("123"))); }); + +it("read alias", () => { + var buf = new Buffer(1024); + var data = new DataView(buf.buffer); + + data.setUint8(0, 200, false); + + expect(buf.readUint8(0)).toBe(buf.readUInt8(0)); + expect(buf.readUintBE(0, 4)).toBe(buf.readUIntBE(0, 4)); + expect(buf.readUintLE(0, 4)).toBe(buf.readUIntLE(0, 4)); + expect(buf.readUint16BE(0)).toBe(buf.readUInt16BE(0)); + expect(buf.readUint16LE(0)).toBe(buf.readUInt16LE(0)); + expect(buf.readUint32BE(0)).toBe(buf.readUInt32BE(0)); + expect(buf.readUint32LE(0)).toBe(buf.readUInt32LE(0)); + expect(buf.readBigUint64BE(0)).toBe(buf.readBigUInt64BE(0)); + expect(buf.readBigUint64LE(0)).toBe(buf.readBigUInt64LE(0)); +}); + +it("write alias", () => { + var buf = new Buffer(1024); + var buf2 = new Buffer(1024); + + function reset() { + new Uint8Array(buf.buffer).fill(0); + new Uint8Array(buf2.buffer).fill(0); + } + + function shouldBeSame(name, name2, ...args) { + buf[name].call(buf, ...args); + buf2[name2].call(buf2, ...args); + + expect(buf).toStrictEqual(buf2); + reset(); + } + + shouldBeSame("writeUint8", "writeUInt8", 10); + shouldBeSame("writeUintBE", "writeUIntBE", 10, 0, 4); + shouldBeSame("writeUintLE", "writeUIntLE", 10, 0, 4); + shouldBeSame("writeUint16BE", "writeUInt16BE", 1000); + shouldBeSame("writeUint16LE", "writeUInt16LE", 1000); + shouldBeSame("writeUint32BE", "writeUInt32BE", 1000); + shouldBeSame("writeUint32LE", "writeUInt32LE", 1000); + shouldBeSame("writeBigUint64BE", "writeBigUInt64BE", BigInt(1000)); + shouldBeSame("writeBigUint64LE", "writeBigUInt64LE", BigInt(1000)); +}); -- cgit v1.2.3 From 979e99940374289e21332a0a7214889648e7397b Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Tue, 4 Jul 2023 19:40:26 -0300 Subject: [tls] fix servername (#3513) * fix servername * add postgres tls tests * update test packages * add basic CRUD test --- src/bun.js/api/bun/socket.zig | 48 +++++++++++++++++++---- test/js/third_party/postgres/package.json | 8 ++++ test/js/third_party/postgres/postgres.test.ts | 56 +++++++++++++++++++++++++++ test/package.json | 5 ++- 4 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 test/js/third_party/postgres/package.json create mode 100644 test/js/third_party/postgres/postgres.test.ts diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 329cc40e4..12a4cffc8 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -820,6 +820,7 @@ pub const Listener = struct { var default_data = socket_config.default_data; var protos: ?[]const u8 = null; + var server_name: ?[]const u8 = null; const ssl_enabled = ssl != null; defer if (ssl != null) ssl.?.deinit(); @@ -840,6 +841,9 @@ pub const Listener = struct { if (ssl.?.protos) |p| { protos = p[0..ssl.?.protos_len]; } + if (ssl.?.server_name) |s| { + server_name = bun.default_allocator.dupe(u8, s[0..bun.len(s)]) catch unreachable; + } uws.NewSocketHandler(true).configure( socket_context, true, @@ -892,6 +896,7 @@ pub const Listener = struct { .socket = undefined, .connection = connection, .protos = if (protos) |p| (bun.default_allocator.dupe(u8, p) catch unreachable) else null, + .server_name = server_name, }; TLSSocket.dataSetCached(tls.getThisValue(globalObject), globalObject, default_data); @@ -916,6 +921,7 @@ pub const Listener = struct { .socket = undefined, .connection = null, .protos = null, + .server_name = null, }; TCPSocket.dataSetCached(tcp.getThisValue(globalObject), globalObject, default_data); @@ -987,6 +993,7 @@ fn NewSocket(comptime ssl: bool) type { connection: ?Listener.UnixOrHost = null, protos: ?[]const u8, owned_protos: bool = true, + server_name: ?[]const u8 = null, // TODO: switch to something that uses `visitAggregate` and have the // `Listener` keep a list of all the sockets JSValue in there @@ -1170,7 +1177,14 @@ fn NewSocket(comptime ssl: bool) type { if (comptime ssl) { var ssl_ptr: *BoringSSL.SSL = @ptrCast(*BoringSSL.SSL, socket.getNativeHandle()); if (!ssl_ptr.isInitFinished()) { - if (this.connection) |connection| { + if (this.server_name) |server_name| { + const host = normalizeHost(server_name); + if (host.len > 0) { + var host__ = default_allocator.dupeZ(u8, host) catch unreachable; + defer default_allocator.free(host__); + ssl_ptr.setHostname(host__); + } + } else if (this.connection) |connection| { if (connection == .host) { const host = normalizeHost(connection.host.host); if (host.len > 0) { @@ -1248,6 +1262,8 @@ fn NewSocket(comptime ssl: bool) type { pub fn onEnd(this: *This, socket: Socket) void { JSC.markBinding(@src()); log("onEnd", .{}); + if (this.detached) return; + this.detached = true; defer this.markInactive(); @@ -1815,6 +1831,11 @@ fn NewSocket(comptime ssl: bool) type { } } + if (this.server_name) |server_name| { + this.server_name = null; + default_allocator.free(server_name); + } + if (this.connection) |connection| { this.connection = null; connection.deinit(); @@ -1898,9 +1919,6 @@ fn NewSocket(comptime ssl: bool) type { if (comptime ssl == false) { return JSValue.jsUndefined(); } - if (this.detached) { - return JSValue.jsUndefined(); - } if (this.handlers.is_server) { globalObject.throw("Cannot issue SNI from a TLS server-side socket", .{}); @@ -1919,9 +1937,20 @@ fn NewSocket(comptime ssl: bool) type { return .zero; } - const slice = server_name.getZigString(globalObject).toSlice(bun.default_allocator); - defer slice.deinit(); - const host = normalizeHost(slice.slice()); + const slice = server_name.getZigString(globalObject).toOwnedSlice(bun.default_allocator) catch unreachable; + if (this.server_name) |old| { + this.server_name = slice; + default_allocator.free(old); + } else { + this.server_name = slice; + } + + if (this.detached) { + // will be attached onOpen + return JSValue.jsUndefined(); + } + + const host = normalizeHost(@as([]const u8, slice)); if (host.len > 0) { var ssl_ptr: *BoringSSL.SSL = @ptrCast(*BoringSSL.SSL, this.socket.getNativeHandle()); if (ssl_ptr.isInitFinished()) { @@ -2040,6 +2069,10 @@ fn NewSocket(comptime ssl: bool) type { .protos = if (protos) |p| (bun.default_allocator.dupe(u8, p[0..protos_len]) catch unreachable) else null, }; + if (socket_config.server_name) |server_name| { + tls.server_name = bun.default_allocator.dupe(u8, server_name[0..bun.len(server_name)]) catch unreachable; + } + var tls_js_value = tls.getThisValue(globalObject); TLSSocket.dataSetCached(tls_js_value, globalObject, default_data); @@ -2061,6 +2094,7 @@ fn NewSocket(comptime ssl: bool) type { bun.default_allocator.destroy(tls); return JSValue.jsUndefined(); }; + tls.socket = new_socket; var raw = handlers.vm.allocator.create(TLSSocket) catch @panic("OOM"); diff --git a/test/js/third_party/postgres/package.json b/test/js/third_party/postgres/package.json new file mode 100644 index 000000000..90809f48f --- /dev/null +++ b/test/js/third_party/postgres/package.json @@ -0,0 +1,8 @@ +{ + "name": "postgres", + "dependencies": { + "pg": "8.11.1", + "postgres": "3.3.5", + "pg-connection-string": "2.6.1" + } +} diff --git a/test/js/third_party/postgres/postgres.test.ts b/test/js/third_party/postgres/postgres.test.ts new file mode 100644 index 000000000..490192ae7 --- /dev/null +++ b/test/js/third_party/postgres/postgres.test.ts @@ -0,0 +1,56 @@ +import { test, expect, describe } from "bun:test"; +import { Pool } from "pg"; +import { parse } from "pg-connection-string"; +import postgres from "postgres"; + +const CONNECTION_STRING = process.env.TLS_POSTGRES_DATABASE_URL; + +const it = CONNECTION_STRING ? test : test.skip; + +describe("pg", () => { + it("should connect using TLS", async () => { + const pool = new Pool(parse(CONNECTION_STRING as string)); + try { + const { rows } = await pool.query("SELECT version()", []); + const [{ version }] = rows; + + expect(version).toMatch(/PostgreSQL/); + } finally { + pool.end(); + } + }); +}); + +describe("postgres", () => { + it("should connect using TLS", async () => { + const sql = postgres(CONNECTION_STRING as string); + try { + const [{ version }] = await sql`SELECT version()`; + expect(version).toMatch(/PostgreSQL/); + } finally { + sql.end(); + } + }); + + it("should insert, select and delete", async () => { + const sql = postgres(CONNECTION_STRING as string); + try { + await sql`CREATE TABLE IF NOT EXISTS users ( + user_id serial PRIMARY KEY, + username VARCHAR ( 50 ) NOT NULL + );`; + + const [{ user_id, username }] = await sql`insert into users (username) values ('bun') returning *`; + expect(username).toBe("bun"); + + const [{ user_id: user_id2, username: username2 }] = await sql`select * from users where user_id = ${user_id}`; + expect(username2).toBe("bun"); + expect(user_id2).toBe(user_id); + + const [{ username: username3 }] = await sql`delete from users where user_id = ${user_id} returning *`; + expect(username3).toBe("bun"); + } finally { + sql.end(); + } + }); +}); diff --git a/test/package.json b/test/package.json index d26875126..5529d3f20 100644 --- a/test/package.json +++ b/test/package.json @@ -26,7 +26,10 @@ "undici": "5.20.0", "vitest": "0.32.2", "webpack": "5.88.0", - "webpack-cli": "4.7.2" + "webpack-cli": "4.7.2", + "pg": "8.11.1", + "postgres": "3.3.5", + "pg-connection-string": "2.6.1" }, "private": true, "scripts": { -- cgit v1.2.3 From 3a93ddfab35841f242db0cdf472ce941bfa94984 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Tue, 4 Jul 2023 19:41:37 -0300 Subject: use sengrid account on nodemailer test (#3517) --- test/js/third_party/nodemailer/nodemailer.test.ts | 8 ++++++-- .../nodemailer/process-nodemailer-fixture.js | 21 +++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/test/js/third_party/nodemailer/nodemailer.test.ts b/test/js/third_party/nodemailer/nodemailer.test.ts index 265112608..36a229524 100644 --- a/test/js/third_party/nodemailer/nodemailer.test.ts +++ b/test/js/third_party/nodemailer/nodemailer.test.ts @@ -2,10 +2,14 @@ import { test, expect, describe } from "bun:test"; import { bunRun } from "harness"; import path from "path"; +const it = process.env.SMTP_SENDGRID_KEY && process.env.SMTP_SENDGRID_SENDER ? test : test.skip; describe("nodemailer", () => { - test("basic smtp", async () => { + it("basic smtp", async () => { try { - const info = bunRun(path.join(import.meta.dir, "process-nodemailer-fixture.js")); + const info = bunRun(path.join(import.meta.dir, "process-nodemailer-fixture.js"), { + SMTP_SENDGRID_SENDER: process.env.SMTP_SENDGRID_SENDER as string, + SMTP_SENDGRID_KEY: process.env.SMTP_SENDGRID_KEY as string, + }); expect(info.stdout).toBe("true"); expect(info.stderr || "").toBe(""); } catch (err: any) { diff --git a/test/js/third_party/nodemailer/process-nodemailer-fixture.js b/test/js/third_party/nodemailer/process-nodemailer-fixture.js index a54735f26..49ab6a516 100644 --- a/test/js/third_party/nodemailer/process-nodemailer-fixture.js +++ b/test/js/third_party/nodemailer/process-nodemailer-fixture.js @@ -1,23 +1,20 @@ -import nodemailer from "nodemailer"; -const account = await nodemailer.createTestAccount(); +const nodemailer = require("nodemailer"); const transporter = nodemailer.createTransport({ - host: account.smtp.host, - port: account.smtp.port, - secure: account.smtp.secure, + host: "smtp.sendgrid.net", + port: 587, + secure: false, auth: { - user: account.user, // generated ethereal user - pass: account.pass, // generated ethereal password + user: "apikey", // generated ethereal user + pass: process.env.SMTP_SENDGRID_KEY, // generated ethereal password }, }); // send mail with defined transport object let info = await transporter.sendMail({ - from: '"Fred Foo 👻" ', // sender address - to: "example@gmail.com", // list of receivers + from: process.env.SMTP_SENDGRID_SENDER, // sender address + to: process.env.SMTP_SENDGRID_SENDER, // list of receivers subject: "Hello ✔", // Subject line text: "Hello world?", // plain text body html: "Hello world?", // html body }); -const url = nodemailer.getTestMessageUrl(info); -console.log(typeof url === "string" && url.length > 0); -transporter.close(); +console.log(typeof info?.messageId === "string"); -- cgit v1.2.3 From b2e28f133e7fbc3d0ba58218f6867fbaeb699d23 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 16:57:46 -0700 Subject: boop --- src/js/out/modules/node/assert.js | 84 ++++++++++++++--------------- src/js/out/modules/node/crypto.js | 8 +-- src/js/out/modules/node/fs.promises.js | 2 +- src/js/out/modules/node/path.js | 2 +- src/js/out/modules/node/path.posix.js | 2 +- src/js/out/modules/node/path.win32.js | 2 +- 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/stream.web.js | 2 +- 10 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/js/out/modules/node/assert.js b/src/js/out/modules/node/assert.js index 7590ea278..eca1f9d97 100644 --- a/src/js/out/modules/node/assert.js +++ b/src/js/out/modules/node/assert.js @@ -1,53 +1,53 @@ -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],` +import J1 from"node:util";var V1=function(){throw new Error("CallTracker is not supported yet")},{Bun:Y1}=globalThis[Symbol.for("Bun.lazy")]("primordials"),t=Y1.deepEquals,X1=(i,L)=>function(){return L||(0,i[Object.keys(i)[0]])((L={exports:{}}).exports,L),L.exports},W1=X1({"assert/build/internal/errors.js"(i,L){function P(Y){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?P=function(X){return typeof X}:P=function(X){return X&&typeof Symbol=="function"&&X.constructor===Symbol&&X!==Symbol.prototype?"symbol":typeof X},P(Y)}function p(Y,X){if(!(Y instanceof X))throw new TypeError("Cannot call a class as a function")}function l(Y,X){return X&&(P(X)==="object"||typeof X=="function")?X:b(Y)}function b(Y){if(Y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y}function x(Y){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(X){return X.__proto__||Object.getPrototypeOf(X)},x(Y)}function A(Y,X){if(typeof X!="function"&&X!==null)throw new TypeError("Super expression must either be null or a function");Y.prototype=Object.create(X&&X.prototype,{constructor:{value:Y,writable:!0,configurable:!0}}),X&&m(Y,X)}function m(Y,X){return m=Object.setPrototypeOf||function(D,q){return D.__proto__=q,D},m(Y,X)}var u={},N,C;function j(Y,X,D){D||(D=Error);function q(T,G,f){return typeof X=="string"?X:X(T,G,f)}var M=function(T){A(G,T);function G(f,w,S){var y;return p(this,G),y=l(this,x(G).call(this,q(f,w,S))),y.code=Y,y}return G}(D);u[Y]=M}function n(Y,X){if(Array.isArray(Y)){var D=Y.length;return Y=Y.map(function(q){return String(q)}),D>2?"one of ".concat(X," ").concat(Y.slice(0,D-1).join(", "),", or ")+Y[D-1]:D===2?"one of ".concat(X," ").concat(Y[0]," or ").concat(Y[1]):"of ".concat(X," ").concat(Y[0])}else return"of ".concat(X," ").concat(String(Y))}function h(Y,X,D){return Y.substr(!D||D<0?0:+D,X.length)===X}function R(Y,X,D){return(D===void 0||D>Y.length)&&(D=Y.length),Y.substring(D-X.length,D)===X}function I(Y,X,D){return typeof D!="number"&&(D=0),D+X.length>Y.length?!1:Y.indexOf(X,D)!==-1}j("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),j("ERR_INVALID_ARG_TYPE",function(Y,X,D){N===void 0&&(N=z1()),N(typeof Y=="string","'name' must be a string");var q;typeof X=="string"&&h(X,"not ")?(q="must not be",X=X.replace(/^not /,"")):q="must be";var M;if(R(Y," argument"))M="The ".concat(Y," ").concat(q," ").concat(n(X,"type"));else{var T=I(Y,".")?"property":"argument";M='The "'.concat(Y,'" ').concat(T," ").concat(q," ").concat(n(X,"type"))}return M+=". Received type ".concat(P(D)),M},TypeError),j("ERR_INVALID_ARG_VALUE",function(Y,X){var D=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid",q=C.inspect(X);return q.length>128&&(q="".concat(q.slice(0,128),"...")),"The argument '".concat(Y,"' ").concat(D,". Received ").concat(q)},TypeError,RangeError),j("ERR_INVALID_RETURN_VALUE",function(Y,X,D){var q;return D&&D.constructor&&D.constructor.name?q="instance of ".concat(D.constructor.name):q="type ".concat(P(D)),"Expected ".concat(Y,' to be returned from the "').concat(X,'"')+" function but got ".concat(q,".")},TypeError),j("ERR_MISSING_ARGS",function(){for(var Y=arguments.length,X=new Array(Y),D=0;D0,"At least one arg needs to be specified");var q="The ",M=X.length;switch(X=X.map(function(T){return'"'.concat(T,'"')}),M){case 1:q+="".concat(X[0]," argument");break;case 2:q+="".concat(X[0]," and ").concat(X[1]," arguments");break;default:q+=X.slice(0,M-1).join(", "),q+=", and ".concat(X[M-1]," arguments");break}return"".concat(q," must be specified")},TypeError),L.exports.codes=u}}),B1=X1({"assert/build/internal/assert/assertion_error.js"(i,L){function P(U){for(var J=1;JU.length)&&(W=U.length),U.substring(W-J.length,W)===J}function M(U,J){if(J=Math.floor(J),U.length==0||J==0)return"";var W=U.length*J;for(J=Math.floor(Math.log(J)/Math.log(2));J;)U+=U,J--;return U+=U.substring(0,W-U.length),U}var T="",G="",f="",w="",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:"},y=10;function c(U){var J=Object.keys(U),W=Object.create(Object.getPrototypeOf(U));return J.forEach(function(V){W[V]=U[V]}),Object.defineProperty(W,"message",{value:U.message}),W}function g(U){return Y(U,{compact:!1,customInspect:!1,depth:1000,maxArrayLength:Infinity,showHidden:!1,breakLength:Infinity,showProxy:!1,sorted:!0,getters:!0})}function r(U,J,W){var V="",v="",Z=0,H="",Q=!1,z=g(U),$=z.split(` +`),K=g(J).split(` +`),B=0,O="";if(W==="strictEqual"&&I(U)==="object"&&I(J)==="object"&&U!==null&&J!==null&&(W="strictEqualObject"),$.length===1&&K.length===1&&$[0]!==K[0]){var F=$[0].length+K[0].length;if(F<=y){if((I(U)!=="object"||U===null)&&(I(J)!=="object"||J===null)&&(U!==0||J!==0))return"".concat(S[W],` -`)+"".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($[0]," !== ").concat(K[0],` +`)}else if(W!=="strictEqualObject"){var d=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(F2&&(O=` + `.concat(M(" ",B),"^"),B=0)}}}for(var e=$[$.length-1],U1=K[K.length-1];e===U1&&(B++<2?H=` + `.concat(e).concat(H):V=e,$.pop(),K.pop(),!($.length===0||K.length===0));)e=$[$.length-1],U1=K[K.length-1];var Q1=Math.max($.length,K.length);if(Q1===0){var o=z.split(` +`);if(o.length>30)for(o[26]="".concat(T,"...").concat(w);o.length>27;)o.pop();return"".concat(S.notIdentical,` -`).concat(t.join(` +`).concat(o.join(` `),` -`)}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,` +`)}B>3&&(H=` +`.concat(T,"...").concat(w).concat(H),Q=!0),V!==""&&(H=` + `.concat(V).concat(H),V="");var E=0,$1=S[W]+` +`.concat(G,"+ actual").concat(w," ").concat(f,"- expected").concat(w),K1=" ".concat(T,"...").concat(w," Lines skipped");for(B=0;B1&&B>2&&(k>4?(v+=` +`.concat(T,"...").concat(w),Q=!0):k>3&&(v+=` + `.concat(K[B-2]),E++),v+=` + `.concat(K[B-1]),E++),Z=B,V+=` +`.concat(f,"-").concat(w," ").concat(K[B]),E++;else if(K.length1&&B>2&&(k>4?(v+=` +`.concat(T,"...").concat(w),Q=!0):k>3&&(v+=` + `.concat($[B-2]),E++),v+=` + `.concat($[B-1]),E++),Z=B,v+=` +`.concat(G,"+").concat(w," ").concat($[B]),E++;else{var a=K[B],_=$[B],Z1=_!==a&&(!q(_,",")||_.slice(0,-1)!==a);Z1&&q(a,",")&&a.slice(0,-1)===_&&(Z1=!1,_+=","),Z1?(k>1&&B>2&&(k>4?(v+=` +`.concat(T,"...").concat(w),Q=!0):k>3&&(v+=` + `.concat($[B-2]),E++),v+=` + `.concat($[B-1]),E++),Z=B,v+=` +`.concat(G,"+").concat(w," ").concat(_),V+=` +`.concat(f,"-").concat(w," ").concat(a),E+=2):(v+=V,V="",(k===1||B===0)&&(v+=` + `.concat(_),E++))}if(E>20&&B30)for(B[26]="".concat(T,"...").concat(w);B.length>27;)B.pop();B.length===1?V=A(this,R(J).call(this,"".concat(K," ").concat(B[0]))):V=A(this,R(J).call(this,"".concat(K,` -`).concat(n.join(` +`).concat(B.join(` `),` -`)))}else{var i=f(g),p="",l=S[x];x==="notDeepEqual"||x==="notEqual"?(i="".concat(S[x],` +`)))}else{var O=g(Q),F="",d=S[Z];Z==="notDeepEqual"||Z==="notEqual"?(O="".concat(S[Z],` -`).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(O),O.length>1024&&(O="".concat(O.slice(0,1021),"..."))):(F="".concat(g(z)),O.length>512&&(O="".concat(O.slice(0,509),"...")),F.length>512&&(F="".concat(F.slice(0,509),"...")),Z==="deepEqual"||Z==="equal"?O="".concat(d,` -`).concat(i,` +`).concat(O,` should equal -`):p=" ".concat(x," ").concat(p)),k=$(this,q(b).call(this,"".concat(i).concat(p)))}return Error.stackTraceLimit=_,k.generatedMessage=!m,Object.defineProperty(K(k),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),k.code="ERR_ASSERTION",k.actual=g,k.expected=d,k.operator=x,Error.captureStackTrace&&Error.captureStackTrace(K(k),y),k.stack,k.name="AssertionError",$(k)}return U(b,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:G.custom,value:function(h,k){return G(this,Z({},k,{customInspect:!1,depth:0}))}}]),b}(Y(Error));Q.exports=E}}),U1=W1({"assert/build/assert.js"(H,Q){function Z(x){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Z=function(y){return typeof y}:Z=function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y},Z(x)}function J(x,y){if(!(x instanceof y))throw new TypeError("Cannot call a class as a function")}var z=Y1(),X=z.codes,U=X.ERR_AMBIGUOUS_ARGUMENT,$=X.ERR_INVALID_ARG_TYPE,K=X.ERR_INVALID_ARG_VALUE,W=X.ERR_INVALID_RETURN_VALUE,Y=X.ERR_MISSING_ARGS,B=B1(),V=X1,D=V.inspect,M=X1.types,q=M.isPromise,v=M.isRegExp,G=Object.assign,T=Object.is,w=new Map,O=!1,F=Q.exports=S,N={};function I(x){throw x.message instanceof Error?x.message:new B(x)}function P(x,y,g,d,_){var u=arguments.length,n;if(u===0)n="Failed";else if(u===1)g=x,x=void 0;else{if(O===!1){O=!0;var i=process.emitWarning?process.emitWarning:console.warn.bind(console);i("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 p={actual:x,expected:y,operator:d===void 0?"fail":d,stackStartFn:_||P};g!==void 0&&(p.message=g);var l=new B(p);throw n&&(l.message=n,l.generatedMessage=!0),l}F.fail=P,F.AssertionError=B;function A(x,y,g,d){if(!g){var _=!1;if(y===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:x});throw u.generatedMessage=_,u}}function S(){for(var x=arguments.length,y=new Array(x),g=0;g1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?g-1:0),_=1;_1?Q-1:0),$=1;$1?Q-1:0),$=1;$1?Q-1:0),$=1;$1?Q-1:0),$=1;$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(),ZZ=(...$)=>H$.randomInt(...$),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,GZ="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,VZ="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(VZ,"name",{value:"::bunternal::"}),Object.defineProperty(GZ,"name",{value:"::bunternal::"}));var C$=H$;j$($Z,{DEFAULT_ENCODING:()=>T$,getRandomValues:()=>QZ,randomUUID:()=>YZ,randomInt:()=>ZZ,scrypt:()=>VZ,scryptSync:()=>GZ,timingSafeEqual:()=>D$,webcrypto:()=>C$,subtle:()=>C$.subtle});var{randomBytes:UZ,rng:XZ,pseudoRandomBytes:KZ,prng:IZ,Hash:OZ,createHash:JZ,createHmac:FZ,Hmac:AZ,getHashes:HZ,pbkdf2:WZ,pbkdf2Sync:EZ,Cipher:TZ,createCipher:DZ,Cipheriv:CZ,createCipheriv:LZ,Decipher:RZ,createDecipher:PZ,Decipheriv:zZ,createDecipheriv:MZ,getCiphers:SZ,listCiphers:vZ,DiffieHellmanGroup:qZ,createDiffieHellmanGroup:jZ,getDiffieHellman:kZ,createDiffieHellman:gZ,DiffieHellman:_Z,createSign:NZ,Sign:xZ,createVerify:BZ,Verify:yZ,createECDH:wZ,publicEncrypt:pZ,privateEncrypt:fZ,publicDecrypt:cZ,privateDecrypt:hZ,randomFill:dZ,randomFillSync:bZ,createCredentials:lZ,constants:oZ}=$Z;var nZ=$Z;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{C$ as webcrypto,D$ as timingSafeEqual,GZ as scryptSync,VZ as scrypt,XZ as rng,YZ as randomUUID,ZZ as randomInt,bZ as randomFillSync,dZ as randomFill,UZ as randomBytes,pZ as publicEncrypt,cZ as publicDecrypt,KZ as pseudoRandomBytes,IZ as prng,fZ as privateEncrypt,hZ as privateDecrypt,EZ as pbkdf2Sync,WZ as pbkdf2,vZ as listCiphers,QZ as getRandomValues,HZ as getHashes,kZ as getDiffieHellman,SZ as getCiphers,nZ as default,BZ as createVerify,NZ as createSign,FZ as createHmac,JZ as createHash,wZ as createECDH,jZ as createDiffieHellmanGroup,gZ as createDiffieHellman,MZ as createDecipheriv,PZ as createDecipher,lZ as createCredentials,LZ as createCipheriv,DZ as createCipher,oZ as constants,yZ as Verify,xZ as Sign,AZ as Hmac,OZ as Hash,qZ as DiffieHellmanGroup,_Z as DiffieHellman,zZ as Decipheriv,RZ as Decipher,T$ as DEFAULT_ENCODING,CZ as Cipheriv,TZ as Cipher}; +import{StringDecoder as bQ} from"node:string_decoder";import*as r$ from"node:buffer";import*as A$ from"node:stream";var hQ=Object.defineProperty;var dQ=Object.getOwnPropertyNames;var lQ=536870888,g0=globalThis.Buffer,H$=globalThis.crypto,i$=H$;var S0=(N,_)=>function(){return _||(0,N[dQ(N)[0]])((_={exports:{}}).exports,_),_.exports},oQ=(N,_)=>{for(var k in _)hQ(N,k,{get:_[k],enumerable:!0})};var N0=S0({"node_modules/safe-buffer/index.js"(N,_){var k=r$,j=k.Buffer;function F(X,C){for(var P in X)C[P]=X[P]}j.from&&j.alloc&&j.allocUnsafe&&j.allocUnsafeSlow?_.exports=k:(F(k,N),N.Buffer=z);function z(X,C,P){return j(X,C,P)}z.prototype=Object.create(j.prototype),F(j,z),z.from=function(X,C,P){if(typeof X=="number")throw new TypeError("Argument must not be a number");return j(X,C,P)},z.alloc=function(X,C,P){if(typeof X!="number")throw new TypeError("Argument must be a number");var T=j(X);return C!==void 0?typeof P=="string"?T.fill(C,P):T.fill(C):T.fill(0),T},z.allocUnsafe=function(X){if(typeof X!="number")throw new TypeError("Argument must be a number");return j(X)},z.allocUnsafeSlow=function(X){if(typeof X!="number")throw new TypeError("Argument must be a number");return k.SlowBuffer(X)}}}),L$=S0({"node_modules/randombytes/browser.js"(N,_){var k=65536,j=4294967295;function F(){throw new Error(`Secure random number generation is not supported by this browser. +Use Chrome, Firefox or Internet Explorer 11`)}var z=N0().Buffer,X=i$;X&&X.getRandomValues?_.exports=C:_.exports=F;function C(P,T){if(P>j)throw new RangeError("requested too many random bytes");var W=z.allocUnsafe(P);if(P>0)if(P>k)for(var J=0;J=this._blockSize;){for(var W=this._blockOffset;W0;++J)this._length[J]+=H,H=this._length[J]/4294967296|0,H>0&&(this._length[J]-=4294967296*H);return this},z.prototype._update=function(){throw new Error("_update is not implemented")},z.prototype.digest=function(X){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var C=this._digest();X!==void 0&&(C=C.toString(X)),this._block.fill(0),this._blockOffset=0;for(var P=0;P<4;++P)this._length[P]=0;return C},z.prototype._digest=function(){throw new Error("_digest is not implemented")},_.exports=z}}),QQ=S0({"node_modules/md5.js/index.js"(N,_){var k=B0(),j=$Q(),F=N0().Buffer,z=new Array(16);function X(){j.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}k(X,j),X.prototype._update=function(){for(var H=z,D=0;D<16;++D)H[D]=this._block.readInt32LE(D*4);var E=this._a,L=this._b,M=this._c,v=this._d;E=P(E,L,M,v,H[0],3614090360,7),v=P(v,E,L,M,H[1],3905402710,12),M=P(M,v,E,L,H[2],606105819,17),L=P(L,M,v,E,H[3],3250441966,22),E=P(E,L,M,v,H[4],4118548399,7),v=P(v,E,L,M,H[5],1200080426,12),M=P(M,v,E,L,H[6],2821735955,17),L=P(L,M,v,E,H[7],4249261313,22),E=P(E,L,M,v,H[8],1770035416,7),v=P(v,E,L,M,H[9],2336552879,12),M=P(M,v,E,L,H[10],4294925233,17),L=P(L,M,v,E,H[11],2304563134,22),E=P(E,L,M,v,H[12],1804603682,7),v=P(v,E,L,M,H[13],4254626195,12),M=P(M,v,E,L,H[14],2792965006,17),L=P(L,M,v,E,H[15],1236535329,22),E=T(E,L,M,v,H[1],4129170786,5),v=T(v,E,L,M,H[6],3225465664,9),M=T(M,v,E,L,H[11],643717713,14),L=T(L,M,v,E,H[0],3921069994,20),E=T(E,L,M,v,H[5],3593408605,5),v=T(v,E,L,M,H[10],38016083,9),M=T(M,v,E,L,H[15],3634488961,14),L=T(L,M,v,E,H[4],3889429448,20),E=T(E,L,M,v,H[9],568446438,5),v=T(v,E,L,M,H[14],3275163606,9),M=T(M,v,E,L,H[3],4107603335,14),L=T(L,M,v,E,H[8],1163531501,20),E=T(E,L,M,v,H[13],2850285829,5),v=T(v,E,L,M,H[2],4243563512,9),M=T(M,v,E,L,H[7],1735328473,14),L=T(L,M,v,E,H[12],2368359562,20),E=W(E,L,M,v,H[5],4294588738,4),v=W(v,E,L,M,H[8],2272392833,11),M=W(M,v,E,L,H[11],1839030562,16),L=W(L,M,v,E,H[14],4259657740,23),E=W(E,L,M,v,H[1],2763975236,4),v=W(v,E,L,M,H[4],1272893353,11),M=W(M,v,E,L,H[7],4139469664,16),L=W(L,M,v,E,H[10],3200236656,23),E=W(E,L,M,v,H[13],681279174,4),v=W(v,E,L,M,H[0],3936430074,11),M=W(M,v,E,L,H[3],3572445317,16),L=W(L,M,v,E,H[6],76029189,23),E=W(E,L,M,v,H[9],3654602809,4),v=W(v,E,L,M,H[12],3873151461,11),M=W(M,v,E,L,H[15],530742520,16),L=W(L,M,v,E,H[2],3299628645,23),E=J(E,L,M,v,H[0],4096336452,6),v=J(v,E,L,M,H[7],1126891415,10),M=J(M,v,E,L,H[14],2878612391,15),L=J(L,M,v,E,H[5],4237533241,21),E=J(E,L,M,v,H[12],1700485571,6),v=J(v,E,L,M,H[3],2399980690,10),M=J(M,v,E,L,H[10],4293915773,15),L=J(L,M,v,E,H[1],2240044497,21),E=J(E,L,M,v,H[8],1873313359,6),v=J(v,E,L,M,H[15],4264355552,10),M=J(M,v,E,L,H[6],2734768916,15),L=J(L,M,v,E,H[13],1309151649,21),E=J(E,L,M,v,H[4],4149444226,6),v=J(v,E,L,M,H[11],3174756917,10),M=J(M,v,E,L,H[2],718787259,15),L=J(L,M,v,E,H[9],3951481745,21),this._a=this._a+E|0,this._b=this._b+L|0,this._c=this._c+M|0,this._d=this._d+v|0},X.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 H=F.allocUnsafe(16);return H.writeInt32LE(this._a,0),H.writeInt32LE(this._b,4),H.writeInt32LE(this._c,8),H.writeInt32LE(this._d,12),H};function C(H,D){return H<>>32-D}function P(H,D,E,L,M,v,q){return C(H+(D&E|~D&L)+M+v|0,q)+D|0}function T(H,D,E,L,M,v,q){return C(H+(D&L|E&~L)+M+v|0,q)+D|0}function W(H,D,E,L,M,v,q){return C(H+(D^E^L)+M+v|0,q)+D|0}function J(H,D,E,L,M,v,q){return C(H+(E^(D|~L))+M+v|0,q)+D|0}_.exports=X}}),YQ=S0({"node_modules/ripemd160/index.js"(N,_){var k=g0,j=B0(),F=$Q(),z=new Array(16),X=[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],C=[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],P=[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],T=[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],W=[0,1518500249,1859775393,2400959708,2840853838],J=[1352829926,1548603684,1836072691,2053994217,0];function H(){F.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}j(H,F),H.prototype._update=function(){for(var g=z,y=0;y<16;++y)g[y]=this._block.readInt32LE(y*4);for(var w=this._a|0,f=this._b|0,b=this._c|0,u=this._d|0,Y0=this._e|0,p=this._a|0,v0=this._b|0,$=this._c|0,Y=this._d|0,G=this._e|0,Z=0;Z<80;Z+=1){var V,I;Z<16?(V=E(w,f,b,u,Y0,g[X[Z]],W[0],P[Z]),I=q(p,v0,$,Y,G,g[C[Z]],J[0],T[Z])):Z<32?(V=L(w,f,b,u,Y0,g[X[Z]],W[1],P[Z]),I=v(p,v0,$,Y,G,g[C[Z]],J[1],T[Z])):Z<48?(V=M(w,f,b,u,Y0,g[X[Z]],W[2],P[Z]),I=M(p,v0,$,Y,G,g[C[Z]],J[2],T[Z])):Z<64?(V=v(w,f,b,u,Y0,g[X[Z]],W[3],P[Z]),I=L(p,v0,$,Y,G,g[C[Z]],J[3],T[Z])):(V=q(w,f,b,u,Y0,g[X[Z]],W[4],P[Z]),I=E(p,v0,$,Y,G,g[C[Z]],J[4],T[Z])),w=Y0,Y0=u,u=D(b,10),b=f,f=V,p=G,G=Y,Y=D($,10),$=v0,v0=I}var O=this._b+b+Y|0;this._b=this._c+u+G|0,this._c=this._d+Y0+p|0,this._d=this._e+w+v0|0,this._e=this._a+f+$|0,this._a=O},H.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 g=k.alloc?k.alloc(20):new k(20);return g.writeInt32LE(this._a,0),g.writeInt32LE(this._b,4),g.writeInt32LE(this._c,8),g.writeInt32LE(this._d,12),g.writeInt32LE(this._e,16),g};function D(g,y){return g<>>32-y}function E(g,y,w,f,b,u,Y0,p){return D(g+(y^w^f)+u+Y0|0,p)+b|0}function L(g,y,w,f,b,u,Y0,p){return D(g+(y&w|~y&f)+u+Y0|0,p)+b|0}function M(g,y,w,f,b,u,Y0,p){return D(g+((y|~w)^f)+u+Y0|0,p)+b|0}function v(g,y,w,f,b,u,Y0,p){return D(g+(y&f|w&~f)+u+Y0|0,p)+b|0}function q(g,y,w,f,b,u,Y0,p){return D(g+(y^(w|~f))+u+Y0|0,p)+b|0}_.exports=H}}),R$=S0({"node_modules/sha.js/hash.js"(N,_){var k=N0().Buffer;function j(F,z){this._block=k.alloc(F),this._finalSize=z,this._blockSize=F,this._len=0}j.prototype.update=function(F,z){typeof F=="string"&&(z=z||"utf8",F=k.from(F,z));for(var X=this._block,C=this._blockSize,P=F.length,T=this._len,W=0;W=this._finalSize&&(this._update(this._block),this._block.fill(0));var X=this._len*8;if(X<=4294967295)this._block.writeUInt32BE(X,this._blockSize-4);else{var C=(X&4294967295)>>>0,P=(X-C)/4294967296;this._block.writeUInt32BE(P,this._blockSize-8),this._block.writeUInt32BE(C,this._blockSize-4)}this._update(this._block);var T=this._hash();return F?T.toString(F):T},j.prototype._update=function(){throw new Error("_update must be implemented by subclass")},_.exports=j}}),uQ=S0({"node_modules/sha.js/sha.js"(N,_){var k=B0(),j=R$(),F=N0().Buffer,z=[1518500249,1859775393,-1894007588,-899497514],X=new Array(80);function C(){this.init(),this._w=X,j.call(this,64,56)}k(C,j),C.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function P(J){return J<<5|J>>>27}function T(J){return J<<30|J>>>2}function W(J,H,D,E){return J===0?H&D|~H&E:J===2?H&D|H&E|D&E:H^D^E}C.prototype._update=function(J){for(var H=this._w,D=this._a|0,E=this._b|0,L=this._c|0,M=this._d|0,v=this._e|0,q=0;q<16;++q)H[q]=J.readInt32BE(q*4);for(;q<80;++q)H[q]=H[q-3]^H[q-8]^H[q-14]^H[q-16];for(var g=0;g<80;++g){var y=~~(g/20),w=P(D)+W(y,E,L,M)+v+H[g]+z[y]|0;v=M,M=L,L=T(E),E=D,D=w}this._a=D+this._a|0,this._b=E+this._b|0,this._c=L+this._c|0,this._d=M+this._d|0,this._e=v+this._e|0},C.prototype._hash=function(){var J=F.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=C}}),nQ=S0({"node_modules/sha.js/sha1.js"(N,_){var k=B0(),j=R$(),F=N0().Buffer,z=[1518500249,1859775393,-1894007588,-899497514],X=new Array(80);function C(){this.init(),this._w=X,j.call(this,64,56)}k(C,j),C.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function P(H){return H<<1|H>>>31}function T(H){return H<<5|H>>>27}function W(H){return H<<30|H>>>2}function J(H,D,E,L){return H===0?D&E|~D&L:H===2?D&E|D&L|E&L:D^E^L}C.prototype._update=function(H){for(var D=this._w,E=this._a|0,L=this._b|0,M=this._c|0,v=this._d|0,q=this._e|0,g=0;g<16;++g)D[g]=H.readInt32BE(g*4);for(;g<80;++g)D[g]=P(D[g-3]^D[g-8]^D[g-14]^D[g-16]);for(var y=0;y<80;++y){var w=~~(y/20),f=T(E)+J(w,L,M,v)+q+D[y]+z[w]|0;q=v,v=M,M=W(L),L=E,E=f}this._a=E+this._a|0,this._b=L+this._b|0,this._c=M+this._c|0,this._d=v+this._d|0,this._e=q+this._e|0},C.prototype._hash=function(){var H=F.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},_.exports=C}}),ZQ=S0({"node_modules/sha.js/sha256.js"(N,_){var k=B0(),j=R$(),F=N0().Buffer,z=[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],X=new Array(64);function C(){this.init(),this._w=X,j.call(this,64,56)}k(C,j),C.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 P(E,L,M){return M^E&(L^M)}function T(E,L,M){return E&L|M&(E|L)}function W(E){return(E>>>2|E<<30)^(E>>>13|E<<19)^(E>>>22|E<<10)}function J(E){return(E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7)}function H(E){return(E>>>7|E<<25)^(E>>>18|E<<14)^E>>>3}function D(E){return(E>>>17|E<<15)^(E>>>19|E<<13)^E>>>10}C.prototype._update=function(E){for(var L=this._w,M=this._a|0,v=this._b|0,q=this._c|0,g=this._d|0,y=this._e|0,w=this._f|0,f=this._g|0,b=this._h|0,u=0;u<16;++u)L[u]=E.readInt32BE(u*4);for(;u<64;++u)L[u]=D(L[u-2])+L[u-7]+H(L[u-15])+L[u-16]|0;for(var Y0=0;Y0<64;++Y0){var p=b+J(y)+P(y,w,f)+z[Y0]+L[Y0]|0,v0=W(M)+T(M,v,q)|0;b=f,f=w,w=y,y=g+p|0,g=q,q=v,v=M,M=p+v0|0}this._a=M+this._a|0,this._b=v+this._b|0,this._c=q+this._c|0,this._d=g+this._d|0,this._e=y+this._e|0,this._f=w+this._f|0,this._g=f+this._g|0,this._h=b+this._h|0},C.prototype._hash=function(){var E=F.allocUnsafe(32);return E.writeInt32BE(this._a,0),E.writeInt32BE(this._b,4),E.writeInt32BE(this._c,8),E.writeInt32BE(this._d,12),E.writeInt32BE(this._e,16),E.writeInt32BE(this._f,20),E.writeInt32BE(this._g,24),E.writeInt32BE(this._h,28),E},_.exports=C}}),sQ=S0({"node_modules/sha.js/sha224.js"(N,_){var k=B0(),j=ZQ(),F=R$(),z=N0().Buffer,X=new Array(64);function C(){this.init(),this._w=X,F.call(this,64,56)}k(C,j),C.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},C.prototype._hash=function(){var P=z.allocUnsafe(28);return P.writeInt32BE(this._a,0),P.writeInt32BE(this._b,4),P.writeInt32BE(this._c,8),P.writeInt32BE(this._d,12),P.writeInt32BE(this._e,16),P.writeInt32BE(this._f,20),P.writeInt32BE(this._g,24),P},_.exports=C}}),GQ=S0({"node_modules/sha.js/sha512.js"(N,_){var k=B0(),j=R$(),F=N0().Buffer,z=[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],X=new Array(160);function C(){this.init(),this._w=X,j.call(this,128,112)}k(C,j),C.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 P(v,q,g){return g^v&(q^g)}function T(v,q,g){return v&q|g&(v|q)}function W(v,q){return(v>>>28|q<<4)^(q>>>2|v<<30)^(q>>>7|v<<25)}function J(v,q){return(v>>>14|q<<18)^(v>>>18|q<<14)^(q>>>9|v<<23)}function H(v,q){return(v>>>1|q<<31)^(v>>>8|q<<24)^v>>>7}function D(v,q){return(v>>>1|q<<31)^(v>>>8|q<<24)^(v>>>7|q<<25)}function E(v,q){return(v>>>19|q<<13)^(q>>>29|v<<3)^v>>>6}function L(v,q){return(v>>>19|q<<13)^(q>>>29|v<<3)^(v>>>6|q<<26)}function M(v,q){return v>>>0>>0?1:0}C.prototype._update=function(v){for(var q=this._w,g=this._ah|0,y=this._bh|0,w=this._ch|0,f=this._dh|0,b=this._eh|0,u=this._fh|0,Y0=this._gh|0,p=this._hh|0,v0=this._al|0,$=this._bl|0,Y=this._cl|0,G=this._dl|0,Z=this._el|0,V=this._fl|0,I=this._gl|0,O=this._hl|0,U=0;U<32;U+=2)q[U]=v.readInt32BE(U*4),q[U+1]=v.readInt32BE(U*4+4);for(;U<160;U+=2){var Q=q[U-30],K=q[U-30+1],R=H(Q,K),A=D(K,Q);Q=q[U-4],K=q[U-4+1];var S=E(Q,K),x=L(K,Q),B=q[U-14],c=q[U-14+1],q0=q[U-32],h=q[U-32+1],d=A+c|0,_0=R+B+M(d,A)|0;d=d+x|0,_0=_0+S+M(d,x)|0,d=d+h|0,_0=_0+q0+M(d,h)|0,q[U]=_0,q[U+1]=d}for(var l=0;l<160;l+=2){_0=q[l],d=q[l+1];var n=T(g,y,w),y0=T(v0,$,Y),t=W(g,v0),s=W(v0,g),w0=J(b,Z),m=J(Z,b),r=z[l],$$=z[l+1],i=P(b,u,Y0),e=P(Z,V,I),x0=O+m|0,o=p+w0+M(x0,O)|0;x0=x0+e|0,o=o+i+M(x0,e)|0,x0=x0+$$|0,o=o+r+M(x0,$$)|0,x0=x0+d|0,o=o+_0+M(x0,d)|0;var a=s+y0|0,p0=t+n+M(a,s)|0;p=Y0,O=I,Y0=u,I=V,u=b,V=Z,Z=G+x0|0,b=f+o+M(Z,G)|0,f=w,G=Y,w=y,Y=$,y=g,$=v0,v0=x0+a|0,g=o+p0+M(v0,x0)|0}this._al=this._al+v0|0,this._bl=this._bl+$|0,this._cl=this._cl+Y|0,this._dl=this._dl+G|0,this._el=this._el+Z|0,this._fl=this._fl+V|0,this._gl=this._gl+I|0,this._hl=this._hl+O|0,this._ah=this._ah+g+M(this._al,v0)|0,this._bh=this._bh+y+M(this._bl,$)|0,this._ch=this._ch+w+M(this._cl,Y)|0,this._dh=this._dh+f+M(this._dl,G)|0,this._eh=this._eh+b+M(this._el,Z)|0,this._fh=this._fh+u+M(this._fl,V)|0,this._gh=this._gh+Y0+M(this._gl,I)|0,this._hh=this._hh+p+M(this._hl,O)|0},C.prototype._hash=function(){var v=F.allocUnsafe(64);function q(g,y,w){v.writeInt32BE(g,w),v.writeInt32BE(y,w+4)}return q(this._ah,this._al,0),q(this._bh,this._bl,8),q(this._ch,this._cl,16),q(this._dh,this._dl,24),q(this._eh,this._el,32),q(this._fh,this._fl,40),q(this._gh,this._gl,48),q(this._hh,this._hl,56),v},_.exports=C}}),tQ=S0({"node_modules/sha.js/sha384.js"(N,_){var k=B0(),j=GQ(),F=R$(),z=N0().Buffer,X=new Array(160);function C(){this.init(),this._w=X,F.call(this,128,112)}k(C,j),C.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},C.prototype._hash=function(){var P=z.allocUnsafe(48);function T(W,J,H){P.writeInt32BE(W,H),P.writeInt32BE(J,H+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),P},_.exports=C}}),VQ=S0({"node_modules/sha.js/index.js"(k,_){var k=_.exports=function(j){j=j.toLowerCase();var F=k[j];if(!F)throw new Error(j+" is not supported (we accept pull requests)");return new F};k.sha=uQ(),k.sha1=nQ(),k.sha224=sQ(),k.sha256=ZQ(),k.sha384=tQ(),k.sha512=GQ()}}),C$=S0({"node_modules/cipher-base/index.js"(N,_){var k=N0().Buffer,j=B0();function F(z){A$.Transform.call(this),this.hashMode=typeof z=="string",this.hashMode?this[z]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}j(F,A$.Transform),F.prototype.update=function(z,X,C){typeof z=="string"&&(z=k.from(z,X));var P=this._update(z);return this.hashMode?this:(C&&(P=this._toString(P,C)),P)},F.prototype.setAutoPadding=function(){},F.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},F.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},F.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},F.prototype._transform=function(z,X,C){var P;try{this.hashMode?this._update(z):this.push(this._update(z))}catch(T){P=T}finally{C(P)}},F.prototype._flush=function(z){var X;try{this.push(this.__final())}catch(C){X=C}z(X)},F.prototype._finalOrDigest=function(z){var X=this.__final()||k.alloc(0);return z&&(X=this._toString(X,z,!0)),X},F.prototype._toString=function(z,X,C){if(this._decoder||(this._decoder=new bQ(X),this._encoding=X),this._encoding!==X)throw new Error("can't switch encodings");var P=this._decoder.write(z);return C&&(P+=this._decoder.end()),P},_.exports=F}}),M$=S0({"node_modules/create-hash/browser.js"(N,_){const k=function z(X,C){this._options=C,this._hasher=new mY(X,C),this._finalized=!1};k.prototype=Object.create(A$.Transform.prototype),k.prototype.update=function z(X,C){return this._checkFinalized(),this._hasher.update(X,C),this},k.prototype.digest=function z(X,C){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(X,C)},k.prototype._checkFinalized=function z(){if(this._finalized){var X=new Error("Digest already called");throw X.code="ERR_CRYPTO_HASH_FINALIZED",X}},k.prototype.copy=function z(){const X=Object.create(k.prototype);return X._options=this._options,X._hasher=this._hasher.copy(),X._finalized=this._finalized,X};const j={__proto__:A$.Transform.prototype,...k.prototype,_transform(z,X,C){this.update(z,X),C&&C()},_flush(z){this.push(this.digest()),z()}},F=["_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 z of F)Object.defineProperty(k.prototype,z,{get(){return Object.setPrototypeOf(this,j),A$.Transform.call(this,this._options),this[z]},enumerable:!1,configurable:!0});_.exports=function z(X){return new k(X)},_.exports.createHash=_.exports,_.exports.Hash=k}}),mQ=S0({"node_modules/create-hmac/legacy.js"(N,_){var k=B0(),j=N0().Buffer,F=C$(),z=j.alloc(128),X=64;function C(P,T){F.call(this,"digest"),typeof T=="string"&&(T=j.from(T)),this._alg=P,this._key=T,T.length>X?T=P(T):T.lengthD){var E=J==="rmd160"?new C:P(J);H=E.update(H).digest()}else H.lengthk||F!==F)throw new TypeError("Bad key length")}}}),OQ=S0({"node_modules/pbkdf2/lib/default-encoding.js"(N,_){var k;global.process&&global.process.browser?k="utf-8":global.process&&global.process.version?(j=parseInt(process.version.split(".")[0].slice(1),10),k=j>=6?"utf-8":"binary"):k="utf-8";var j;_.exports=k}}),JQ=S0({"node_modules/pbkdf2/lib/to-buffer.js"(N,_){var k=N0().Buffer;_.exports=function(j,F,z){if(k.isBuffer(j))return j;if(typeof j=="string")return k.from(j,F);if(ArrayBuffer.isView(j))return k.from(j.buffer);throw new TypeError(z+" must be a string, a Buffer, a typed array or a DataView")}}}),FQ=S0({"node_modules/pbkdf2/lib/sync-browser.js"(N,_){var k=UQ(),j=YQ(),F=VQ(),z=N0().Buffer,X=IQ(),C=OQ(),P=JQ(),T=z.alloc(128),W={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function J(E,L,M){var v=H(E),q=E==="sha512"||E==="sha384"?128:64;L.length>q?L=v(L):L.length>>0},N.writeUInt32BE=function(F,z,X){F[0+X]=z>>>24,F[1+X]=z>>>16&255,F[2+X]=z>>>8&255,F[3+X]=z&255},N.ip=function(F,z,X,C){for(var P=0,T=0,W=6;W>=0;W-=2){for(var J=0;J<=24;J+=8)P<<=1,P|=z>>>J+W&1;for(var J=0;J<=24;J+=8)P<<=1,P|=F>>>J+W&1}for(var W=6;W>=0;W-=2){for(var J=1;J<=25;J+=8)T<<=1,T|=z>>>J+W&1;for(var J=1;J<=25;J+=8)T<<=1,T|=F>>>J+W&1}X[C+0]=P>>>0,X[C+1]=T>>>0},N.rip=function(F,z,X,C){for(var P=0,T=0,W=0;W<4;W++)for(var J=24;J>=0;J-=8)P<<=1,P|=z>>>J+W&1,P<<=1,P|=F>>>J+W&1;for(var W=4;W<8;W++)for(var J=24;J>=0;J-=8)T<<=1,T|=z>>>J+W&1,T<<=1,T|=F>>>J+W&1;X[C+0]=P>>>0,X[C+1]=T>>>0},N.pc1=function(F,z,X,C){for(var P=0,T=0,W=7;W>=5;W--){for(var J=0;J<=24;J+=8)P<<=1,P|=z>>J+W&1;for(var J=0;J<=24;J+=8)P<<=1,P|=F>>J+W&1}for(var J=0;J<=24;J+=8)P<<=1,P|=z>>J+W&1;for(var W=1;W<=3;W++){for(var J=0;J<=24;J+=8)T<<=1,T|=z>>J+W&1;for(var J=0;J<=24;J+=8)T<<=1,T|=F>>J+W&1}for(var J=0;J<=24;J+=8)T<<=1,T|=F>>J+W&1;X[C+0]=P>>>0,X[C+1]=T>>>0},N.r28shl=function(F,z){return F<>>28-z};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];N.pc2=function(F,z,X,C){for(var P=0,T=0,W=_.length>>>1,J=0;J>>_[J]&1;for(var J=W;J<_.length;J++)T<<=1,T|=z>>>_[J]&1;X[C+0]=P>>>0,X[C+1]=T>>>0},N.expand=function(F,z,X){var C=0,P=0;C=(F&1)<<5|F>>>27;for(var T=23;T>=15;T-=4)C<<=6,C|=F>>>T&63;for(var T=11;T>=3;T-=4)P|=F>>>T&63,P<<=6;P|=(F&31)<<1|F>>>31,z[X+0]=C>>>0,z[X+1]=P>>>0};var k=[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];N.substitute=function(F,z){for(var X=0,C=0;C<4;C++){var P=F>>>18-C*6&63,T=k[C*64+P];X<<=4,X|=T}for(var C=0;C<4;C++){var P=z>>>18-C*6&63,T=k[256+C*64+P];X<<=4,X|=T}return X>>>0};var j=[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];N.permute=function(F){for(var z=0,X=0;X>>j[X]&1;return z>>>0},N.padSplit=function(F,z,X){for(var C=F.toString(2);C.length0;C--)z+=this._buffer(F,z),X+=this._flushBuffer(P,X);return z+=this._buffer(F,z),P},j.prototype.final=function(F){var z;F&&(z=this.update(F));var X;return this.type==="encrypt"?X=this._finalEncrypt():X=this._finalDecrypt(),z?z.concat(X):X},j.prototype._pad=function(F,z){if(z===0)return!1;for(;z>>1];J=F.r28shl(J,E),H=F.r28shl(H,E),F.pc2(J,H,T.keys,D)}},C.prototype._update=function(T,W,J,H){var D=this._desState,E=F.readUInt32BE(T,W),L=F.readUInt32BE(T,W+4);F.ip(E,L,D.tmp,0),E=D.tmp[0],L=D.tmp[1],this.type==="encrypt"?this._encrypt(D,E,L,D.tmp,0):this._decrypt(D,E,L,D.tmp,0),E=D.tmp[0],L=D.tmp[1],F.writeUInt32BE(J,E,H),F.writeUInt32BE(J,L,H+4)},C.prototype._pad=function(T,W){for(var J=T.length-W,H=W;H>>0,E=w}F.rip(L,E,H,D)},C.prototype._decrypt=function(T,W,J,H,D){for(var E=J,L=W,M=T.keys.length-2;M>=0;M-=2){var v=T.keys[M],q=T.keys[M+1];F.expand(E,T.tmp,0),v^=T.tmp[0],q^=T.tmp[1];var g=F.substitute(v,q),y=F.permute(g),w=E;E=(L^y)>>>0,L=w}F.rip(E,L,H,D)}}}),rQ=S0({"node_modules/des.js/lib/des/cbc.js"(N){var _=W$(),k=B0(),j={};function F(X){_.equal(X.length,8,"Invalid IV length"),this.iv=new Array(8);for(var C=0;C>P%8,F._prev=j(F._prev,X?J:H);return W}function j(F,z){var X=F.length,C=-1,P=_.allocUnsafe(F.length);for(F=_.concat([F,_.from([z])]);++C>7;return P}N.encrypt=function(F,z,X){for(var C=z.length,P=_.allocUnsafe(C),T=-1;++T>>24]^L[g>>>16&255]^M[y>>>8&255]^v[w&255]^W[p++],b=E[g>>>24]^L[y>>>16&255]^M[w>>>8&255]^v[q&255]^W[p++],u=E[y>>>24]^L[w>>>16&255]^M[q>>>8&255]^v[g&255]^W[p++],Y0=E[w>>>24]^L[q>>>16&255]^M[g>>>8&255]^v[y&255]^W[p++],q=f,g=b,y=u,w=Y0;return f=(H[q>>>24]<<24|H[g>>>16&255]<<16|H[y>>>8&255]<<8|H[w&255])^W[p++],b=(H[g>>>24]<<24|H[y>>>16&255]<<16|H[w>>>8&255]<<8|H[q&255])^W[p++],u=(H[y>>>24]<<24|H[w>>>16&255]<<16|H[q>>>8&255]<<8|H[g&255])^W[p++],Y0=(H[w>>>24]<<24|H[q>>>16&255]<<16|H[g>>>8&255]<<8|H[y&255])^W[p++],f=f>>>0,b=b>>>0,u=u>>>0,Y0=Y0>>>0,[f,b,u,Y0]}var X=[0,1,2,4,8,16,32,64,128,27,54],C=function(){for(var T=new Array(256),W=0;W<256;W++)W<128?T[W]=W<<1:T[W]=W<<1^283;for(var J=[],H=[],D=[[],[],[],[]],E=[[],[],[],[]],L=0,M=0,v=0;v<256;++v){var q=M^M<<1^M<<2^M<<3^M<<4;q=q>>>8^q&255^99,J[L]=q,H[q]=L;var g=T[L],y=T[g],w=T[y],f=T[q]*257^q*16843008;D[0][L]=f<<24|f>>>8,D[1][L]=f<<16|f>>>16,D[2][L]=f<<8|f>>>24,D[3][L]=f,f=w*16843009^y*65537^g*257^L*16843008,E[0][q]=f<<24|f>>>8,E[1][q]=f<<16|f>>>16,E[2][q]=f<<8|f>>>24,E[3][q]=f,L===0?L=M=1:(L=g^T[T[T[w^g]]],M^=T[T[M]])}return{SBOX:J,INV_SBOX:H,SUB_MIX:D,INV_SUB_MIX:E}}();function P(T){this._key=j(T),this._reset()}P.blockSize=16,P.keySize=32,P.prototype.blockSize=P.blockSize,P.prototype.keySize=P.keySize,P.prototype._reset=function(){for(var T=this._key,W=T.length,J=W+6,H=(J+1)*4,D=[],E=0;E>>24,L=C.SBOX[L>>>24]<<24|C.SBOX[L>>>16&255]<<16|C.SBOX[L>>>8&255]<<8|C.SBOX[L&255],L^=X[E/W|0]<<24):W>6&&E%W===4&&(L=C.SBOX[L>>>24]<<24|C.SBOX[L>>>16&255]<<16|C.SBOX[L>>>8&255]<<8|C.SBOX[L&255]),D[E]=D[E-W]^L}for(var M=[],v=0;v>>24]]^C.INV_SUB_MIX[1][C.SBOX[g>>>16&255]]^C.INV_SUB_MIX[2][C.SBOX[g>>>8&255]]^C.INV_SUB_MIX[3][C.SBOX[g&255]]}this._nRounds=J,this._keySchedule=D,this._invKeySchedule=M},P.prototype.encryptBlockRaw=function(T){return T=j(T),z(T,this._keySchedule,C.SUB_MIX,C.SBOX,this._nRounds)},P.prototype.encryptBlock=function(T){var W=this.encryptBlockRaw(T),J=k.allocUnsafe(16);return J.writeUInt32BE(W[0],0),J.writeUInt32BE(W[1],4),J.writeUInt32BE(W[2],8),J.writeUInt32BE(W[3],12),J},P.prototype.decryptBlock=function(T){T=j(T);var W=T[1];T[1]=T[3],T[3]=W;var J=z(T,this._invKeySchedule,C.INV_SUB_MIX,C.INV_SBOX,this._nRounds),H=k.allocUnsafe(16);return H.writeUInt32BE(J[0],0),H.writeUInt32BE(J[3],4),H.writeUInt32BE(J[2],8),H.writeUInt32BE(J[1],12),H},P.prototype.scrub=function(){F(this._keySchedule),F(this._invKeySchedule),F(this._key)},_.exports.AES=P}}),KY=S0({"node_modules/browserify-aes/ghash.js"(N,_){var k=N0().Buffer,j=k.alloc(16,0);function F(C){return[C.readUInt32BE(0),C.readUInt32BE(4),C.readUInt32BE(8),C.readUInt32BE(12)]}function z(C){var P=k.allocUnsafe(16);return P.writeUInt32BE(C[0]>>>0,0),P.writeUInt32BE(C[1]>>>0,4),P.writeUInt32BE(C[2]>>>0,8),P.writeUInt32BE(C[3]>>>0,12),P}function X(C){this.h=C,this.state=k.alloc(16,0),this.cache=k.allocUnsafe(0)}X.prototype.ghash=function(C){for(var P=-1;++P0;T--)C[T]=C[T]>>>1|(C[T-1]&1)<<31;C[0]=C[0]>>>1,J&&(C[0]=C[0]^225<<24)}this.state=z(P)},X.prototype.update=function(C){this.cache=k.concat([this.cache,C]);for(var P;this.cache.length>=16;)P=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(P)},X.prototype.final=function(C,P){return this.cache.length&&this.ghash(k.concat([this.cache,j],16)),this.ghash(z([0,C,0,P])),this.state},_.exports=X}}),DQ=S0({"node_modules/browserify-aes/authCipher.js"(N,_){var k=q$(),j=N0().Buffer,F=C$(),z=B0(),X=KY(),C=S$(),P=EQ();function T(H,D){var E=0;H.length!==D.length&&E++;for(var L=Math.min(H.length,D.length),M=0;M0||P>0;){var D=new j;D.update(H),D.update(z),X&&D.update(X),H=D.digest();var E=0;if(T>0){var L=W.length-T;E=Math.min(T,H.length),H.copy(W,L,0,E),T-=E}if(E0){var M=J.length-P,v=Math.min(P,H.length-E);H.copy(J,M,E,E+v),P-=v}}return H.fill(0),{key:W,iv:J}}_.exports=F}}),IY=S0({"node_modules/browserify-aes/encrypter.js"(N){var _=w$(),k=DQ(),j=N0().Buffer,F=CQ(),z=C$(),X=q$(),C=j$(),P=B0();function T(E,L,M){z.call(this),this._cache=new J,this._cipher=new X.AES(L),this._prev=j.from(M),this._mode=E,this._autopadding=!0}P(T,z),T.prototype._update=function(E){this._cache.add(E);for(var L,M,v=[];L=this._cache.get();)M=this._mode.encrypt(this,L),v.push(M);return j.concat(v)};var W=j.alloc(16,16);T.prototype._final=function(){var E=this._cache.flush();if(this._autopadding)return E=this._mode.encrypt(this,E),this._cipher.scrub(),E;if(!E.equals(W))throw this._cipher.scrub(),new Error("data not multiple of block length")},T.prototype.setAutoPadding=function(E){return this._autopadding=!!E,this};function J(){this.cache=j.allocUnsafe(0)}J.prototype.add=function(E){this.cache=j.concat([this.cache,E])},J.prototype.get=function(){if(this.cache.length>15){var E=this.cache.slice(0,16);return this.cache=this.cache.slice(16),E}return null},J.prototype.flush=function(){for(var E=16-this.cache.length,L=j.allocUnsafe(E),M=-1;++M16)return L=this.cache.slice(0,16),this.cache=this.cache.slice(16),L}else if(this.cache.length>=16)return L=this.cache.slice(0,16),this.cache=this.cache.slice(16),L;return null},W.prototype.flush=function(){if(this.cache.length)return this.cache};function J(E){var L=E[15];if(L<1||L>16)throw new Error("unable to decrypt data");for(var M=-1;++M0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),AY=S0({"node_modules/miller-rabin/node_modules/bn.js/lib/bn.js"(N,_){(function(k,j){function F($,Y){if(!$)throw new Error(Y||"Assertion failed")}function z($,Y){$.super_=Y;var G=function(){};G.prototype=Y.prototype,$.prototype=new G,$.prototype.constructor=$}function X($,Y,G){if(X.isBN($))return $;this.negative=0,this.words=null,this.length=0,this.red=null,$!==null&&((Y==="le"||Y==="be")&&(G=Y,Y=10),this._init($||0,Y||10,G||"be"))}typeof k=="object"?k.exports=X:j.BN=X,X.BN=X,X.wordSize=26;var C=g0;X.isBN=function($){return $ instanceof X?!0:$!==null&&typeof $=="object"&&$.constructor.wordSize===X.wordSize&&Array.isArray($.words)},X.max=function($,Y){return $.cmp(Y)>0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),VZ=S0({"(disabled):node_modules/crypto-browserify/index.js"(){}}),f$=S0({"node_modules/brorand/index.js"(N,_){var k;_.exports=function(F){return k||(k=new j(null)),k.generate(F)};function j(F){this.rand=F}_.exports.Rand=j,j.prototype.generate=function(F){return this._rand(F)},j.prototype._rand=function(F){var z=new g0(F);return H$.getRandomValues(z),z}}}),RQ=S0({"node_modules/miller-rabin/lib/mr.js"(N,_){var k=AY(),j=f$();function F(z){this.rand=z||new j.Rand}_.exports=F,F.create=function(z){return new F(z)},F.prototype._randbelow=function(z){var X=z.bitLength(),C=Math.ceil(X/8);do var P=new k(this.rand.generate(C));while(P.cmp(z)>=0);return P},F.prototype._randrange=function(z,X){var C=X.sub(z);return z.add(this._randbelow(C))},F.prototype.test=function(z,X,C){var P=z.bitLength(),T=k.mont(z),W=new k(1).toRed(T);X||(X=Math.max(1,P/48|0));for(var J=z.subn(1),H=0;!J.testn(H);H++);for(var D=z.shrn(H),E=J.toRed(T),L=!0;X>0;X--){var M=this._randrange(new k(2),J);C&&C(M);var v=M.toRed(T).redPow(D);if(!(v.cmp(W)===0||v.cmp(E)===0)){for(var q=1;q0;X--){var E=this._randrange(new k(2),W),L=z.gcd(E);if(L.cmpn(1)!==0)return L;var M=E.toRed(P).redPow(H);if(!(M.cmp(T)===0||M.cmp(D)===0)){for(var v=1;vb;)Y0.ishrn(1);if(Y0.isEven()&&Y0.iadd(C),Y0.testn(1)||Y0.iadd(P),u.cmp(P)){if(!u.cmp(T))for(;Y0.mod(H).cmp(D);)Y0.iadd(M)}else for(;Y0.mod(F).cmp(L);)Y0.iadd(M);if(p=Y0.shrn(1),y(p)&&y(Y0)&&w(p)&&w(Y0)&&X.test(p)&&X.test(Y0))return Y0}}}}),HY=S0({"node_modules/diffie-hellman/lib/primes.json"(N,_){_.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"}}}}),WY=S0({"node_modules/diffie-hellman/lib/dh.js"(N,_){var k=LQ(),j=RQ(),F=new j,z=new k(24),X=new k(11),C=new k(10),P=new k(3),T=new k(7),W=PQ(),J=L$();_.exports=M;function H(q,g){return g=g||"utf8",g0.isBuffer(q)||(q=new g0(q,g)),this._pub=new k(q),this}function D(q,g){return g=g||"utf8",g0.isBuffer(q)||(q=new g0(q,g)),this._priv=new k(q),this}var E={};function L(q,g){var y=g.toString("hex"),w=[y,q.toString(16)].join("_");if(w in E)return E[w];var f=0;if(q.isEven()||!W.simpleSieve||!W.fermatTest(q)||!F.test(q))return f+=1,y==="02"||y==="05"?f+=8:f+=4,E[w]=f,f;F.test(q.shrn(1))||(f+=2);var b;switch(y){case"02":q.mod(z).cmp(X)&&(f+=8);break;case"05":b=q.mod(C),b.cmp(P)&&b.cmp(T)&&(f+=8);break;default:f+=4}return E[w]=f,f}function M(q,g,y){this.setGenerator(g),this.__prime=new k(q),this._prime=k.mont(this.__prime),this._primeLen=q.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,y?(this.setPublicKey=H,this.setPrivateKey=D):this._primeCode=8}Object.defineProperty(M.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=L(this.__prime,this.__gen)),this._primeCode}}),M.prototype.generateKeys=function(){return this._priv||(this._priv=new k(J(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},M.prototype.computeSecret=function(q){q=new k(q),q=q.toRed(this._prime);var g=q.redPow(this._priv).fromRed(),y=new g0(g.toArray()),w=this.getPrime();if(y.length0?Z:V},X.min=function(Z,V){return Z.cmp(V)<0?Z:V},X.prototype._init=function(Z,V,I){if(typeof Z=="number")return this._initNumber(Z,V,I);if(typeof Z=="object")return this._initArray(Z,V,I);V==="hex"&&(V=16),F(V===(V|0)&&V>=2&&V<=36),Z=Z.toString().replace(/\s+/g,"");var O=0;Z[0]==="-"&&(O++,this.negative=1),O=0;O-=3)Q=Z[O]|Z[O-1]<<8|Z[O-2]<<16,this.words[U]|=Q<>>26-K&67108863,K+=24,K>=26&&(K-=26,U++);else if(I==="le")for(O=0,U=0;O>>26-K&67108863,K+=24,K>=26&&(K-=26,U++);return this._strip()};function P(Z,V){var I=Z.charCodeAt(V);if(I>=48&&I<=57)return I-48;if(I>=65&&I<=70)return I-55;if(I>=97&&I<=102)return I-87;F(!1,"Invalid character in "+Z)}function T(Z,V,I){var O=P(Z,I);return I-1>=V&&(O|=P(Z,I-1)<<4),O}X.prototype._parseHex=function(Z,V,I){this.length=Math.ceil((Z.length-V)/6),this.words=new Array(this.length);for(var O=0;O=V;O-=2)K=T(Z,V,O)<=18?(U-=18,Q+=1,this.words[Q]|=K>>>26):U+=8;else{var R=Z.length-V;for(O=R%2===0?V+1:V;O=18?(U-=18,Q+=1,this.words[Q]|=K>>>26):U+=8}this._strip()};function W(Z,V,I,O){for(var U=0,Q=0,K=Math.min(Z.length,I),R=V;R=49?Q=A-49+10:A>=17?Q=A-17+10:Q=A,F(A>=0&&Q1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{X.prototype[Symbol.for("nodejs.util.inspect.custom")]=H}catch{X.prototype.inspect=H}else X.prototype.inspect=H;function H(){return(this.red?""}var D=["","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"],E=[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],L=[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];X.prototype.toString=function(Z,V){Z=Z||10,V=V|0||1;var I;if(Z===16||Z==="hex"){I="";for(var O=0,U=0,Q=0;Q>>24-O&16777215,O+=2,O>=26&&(O-=26,Q--),U!==0||Q!==this.length-1?I=D[6-R.length]+R+I:I=R+I}for(U!==0&&(I=U.toString(16)+I);I.length%V!==0;)I="0"+I;return this.negative!==0&&(I="-"+I),I}if(Z===(Z|0)&&Z>=2&&Z<=36){var A=E[Z],S=L[Z];I="";var x=this.clone();for(x.negative=0;!x.isZero();){var B=x.modrn(S).toString(Z);x=x.idivn(S),x.isZero()?I=B+I:I=D[A-B.length]+B+I}for(this.isZero()&&(I="0"+I);I.length%V!==0;)I="0"+I;return this.negative!==0&&(I="-"+I),I}F(!1,"Base should be between 2 and 36")},X.prototype.toNumber=function(){var Z=this.words[0];return this.length===2?Z+=this.words[1]*67108864:this.length===3&&this.words[2]===1?Z+=4503599627370496+this.words[1]*67108864:this.length>2&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-Z:Z},X.prototype.toJSON=function(){return this.toString(16,2)},C&&(X.prototype.toBuffer=function(Z,V){return this.toArrayLike(C,Z,V)}),X.prototype.toArray=function(Z,V){return this.toArrayLike(Array,Z,V)};var M=function(Z,V){return Z.allocUnsafe?Z.allocUnsafe(V):new Z(V)};X.prototype.toArrayLike=function(Z,V,I){this._strip();var O=this.byteLength(),U=I||Math.max(1,O);F(O<=U,"byte array longer than desired length"),F(U>0,"Requested array length <= 0");var Q=M(Z,U),K=V==="le"?"LE":"BE";return this["_toArrayLike"+K](Q,O),Q},X.prototype._toArrayLikeLE=function(Z,V){for(var I=0,O=0,U=0,Q=0;U>8&255),I>16&255),Q===6?(I>24&255),O=0,Q=0):(O=K>>>24,Q+=2)}if(I=0&&(Z[I--]=K>>8&255),I>=0&&(Z[I--]=K>>16&255),Q===6?(I>=0&&(Z[I--]=K>>24&255),O=0,Q=0):(O=K>>>24,Q+=2)}if(I>=0)for(Z[I--]=O;I>=0;)Z[I--]=0},Math.clz32?X.prototype._countBits=function(Z){return 32-Math.clz32(Z)}:X.prototype._countBits=function(Z){var V=Z,I=0;return V>=4096&&(I+=13,V>>>=13),V>=64&&(I+=7,V>>>=7),V>=8&&(I+=4,V>>>=4),V>=2&&(I+=2,V>>>=2),I+V},X.prototype._zeroBits=function(Z){if(Z===0)return 26;var V=Z,I=0;return(V&8191)===0&&(I+=13,V>>>=13),(V&127)===0&&(I+=7,V>>>=7),(V&15)===0&&(I+=4,V>>>=4),(V&3)===0&&(I+=2,V>>>=2),(V&1)===0&&I++,I},X.prototype.bitLength=function(){var Z=this.words[this.length-1],V=this._countBits(Z);return(this.length-1)*26+V};function v(Z){for(var V=new Array(Z.bitLength()),I=0;I>>U&1}return V}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var Z=0,V=0;VZ.length?this.clone().ior(Z):Z.clone().ior(this)},X.prototype.uor=function(Z){return this.length>Z.length?this.clone().iuor(Z):Z.clone().iuor(this)},X.prototype.iuand=function(Z){var V;this.length>Z.length?V=Z:V=this;for(var I=0;IZ.length?this.clone().iand(Z):Z.clone().iand(this)},X.prototype.uand=function(Z){return this.length>Z.length?this.clone().iuand(Z):Z.clone().iuand(this)},X.prototype.iuxor=function(Z){var V,I;this.length>Z.length?(V=this,I=Z):(V=Z,I=this);for(var O=0;OZ.length?this.clone().ixor(Z):Z.clone().ixor(this)},X.prototype.uxor=function(Z){return this.length>Z.length?this.clone().iuxor(Z):Z.clone().iuxor(this)},X.prototype.inotn=function(Z){F(typeof Z=="number"&&Z>=0);var V=Math.ceil(Z/26)|0,I=Z%26;this._expand(V),I>0&&V--;for(var O=0;O0&&(this.words[O]=~this.words[O]&67108863>>26-I),this._strip()},X.prototype.notn=function(Z){return this.clone().inotn(Z)},X.prototype.setn=function(Z,V){F(typeof Z=="number"&&Z>=0);var I=Z/26|0,O=Z%26;return this._expand(I+1),V?this.words[I]=this.words[I]|1<Z.length?(I=this,O=Z):(I=Z,O=this);for(var U=0,Q=0;Q>>26;for(;U!==0&&Q>>26;if(this.length=I.length,U!==0)this.words[this.length]=U,this.length++;else if(I!==this)for(;QZ.length?this.clone().iadd(Z):Z.clone().iadd(this)},X.prototype.isub=function(Z){if(Z.negative!==0){Z.negative=0;var V=this.iadd(Z);return Z.negative=1,V._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Z),this.negative=1,this._normSign();var I=this.cmp(Z);if(I===0)return this.negative=0,this.length=1,this.words[0]=0,this;var O,U;I>0?(O=this,U=Z):(O=Z,U=this);for(var Q=0,K=0;K>26,this.words[K]=V&67108863;for(;Q!==0&&K>26,this.words[K]=V&67108863;if(Q===0&&K>>26,B=A&67108863,c=Math.min(S,V.length-1),q0=Math.max(0,S-Z.length+1);q0<=c;q0++){var h=S-q0|0;U=Z.words[h]|0,Q=V.words[q0]|0,K=U*Q+B,x+=K/67108864|0,B=K&67108863}I.words[S]=B|0,A=x|0}return A!==0?I.words[S]=A|0:I.length--,I._strip()}var g=function(Z,V,I){var O=Z.words,U=V.words,Q=I.words,K=0,R,A,S,x=O[0]|0,B=x&8191,c=x>>>13,q0=O[1]|0,h=q0&8191,d=q0>>>13,_0=O[2]|0,l=_0&8191,n=_0>>>13,y0=O[3]|0,t=y0&8191,s=y0>>>13,w0=O[4]|0,m=w0&8191,r=w0>>>13,$$=O[5]|0,i=$$&8191,e=$$>>>13,x0=O[6]|0,o=x0&8191,a=x0>>>13,p0=O[7]|0,$0=p0&8191,Q0=p0>>>13,Y$=O[8]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=O[9]|0,V0=Z$&8191,U0=Z$>>>13,G$=U[0]|0,X0=G$&8191,K0=G$>>>13,V$=U[1]|0,I0=V$&8191,O0=V$>>>13,U$=U[2]|0,J0=U$&8191,F0=U$>>>13,X$=U[3]|0,A0=X$&8191,H0=X$>>>13,K$=U[4]|0,W0=K$&8191,E0=K$>>>13,I$=U[5]|0,T0=I$&8191,D0=I$>>>13,O$=U[6]|0,C0=O$&8191,L0=O$>>>13,J$=U[7]|0,R0=J$&8191,P0=J$>>>13,F$=U[8]|0,z0=F$&8191,M0=F$>>>13,Q$=U[9]|0,j0=Q$&8191,k0=Q$>>>13;I.negative=Z.negative^V.negative,I.length=19,R=Math.imul(B,X0),A=Math.imul(B,K0),A=A+Math.imul(c,X0)|0,S=Math.imul(c,K0);var f0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(f0>>>26)|0,f0&=67108863,R=Math.imul(h,X0),A=Math.imul(h,K0),A=A+Math.imul(d,X0)|0,S=Math.imul(d,K0),R=R+Math.imul(B,I0)|0,A=A+Math.imul(B,O0)|0,A=A+Math.imul(c,I0)|0,S=S+Math.imul(c,O0)|0;var c0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(c0>>>26)|0,c0&=67108863,R=Math.imul(l,X0),A=Math.imul(l,K0),A=A+Math.imul(n,X0)|0,S=Math.imul(n,K0),R=R+Math.imul(h,I0)|0,A=A+Math.imul(h,O0)|0,A=A+Math.imul(d,I0)|0,S=S+Math.imul(d,O0)|0,R=R+Math.imul(B,J0)|0,A=A+Math.imul(B,F0)|0,A=A+Math.imul(c,J0)|0,S=S+Math.imul(c,F0)|0;var h0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(h0>>>26)|0,h0&=67108863,R=Math.imul(t,X0),A=Math.imul(t,K0),A=A+Math.imul(s,X0)|0,S=Math.imul(s,K0),R=R+Math.imul(l,I0)|0,A=A+Math.imul(l,O0)|0,A=A+Math.imul(n,I0)|0,S=S+Math.imul(n,O0)|0,R=R+Math.imul(h,J0)|0,A=A+Math.imul(h,F0)|0,A=A+Math.imul(d,J0)|0,S=S+Math.imul(d,F0)|0,R=R+Math.imul(B,A0)|0,A=A+Math.imul(B,H0)|0,A=A+Math.imul(c,A0)|0,S=S+Math.imul(c,H0)|0;var d0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(d0>>>26)|0,d0&=67108863,R=Math.imul(m,X0),A=Math.imul(m,K0),A=A+Math.imul(r,X0)|0,S=Math.imul(r,K0),R=R+Math.imul(t,I0)|0,A=A+Math.imul(t,O0)|0,A=A+Math.imul(s,I0)|0,S=S+Math.imul(s,O0)|0,R=R+Math.imul(l,J0)|0,A=A+Math.imul(l,F0)|0,A=A+Math.imul(n,J0)|0,S=S+Math.imul(n,F0)|0,R=R+Math.imul(h,A0)|0,A=A+Math.imul(h,H0)|0,A=A+Math.imul(d,A0)|0,S=S+Math.imul(d,H0)|0,R=R+Math.imul(B,W0)|0,A=A+Math.imul(B,E0)|0,A=A+Math.imul(c,W0)|0,S=S+Math.imul(c,E0)|0;var b0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(b0>>>26)|0,b0&=67108863,R=Math.imul(i,X0),A=Math.imul(i,K0),A=A+Math.imul(e,X0)|0,S=Math.imul(e,K0),R=R+Math.imul(m,I0)|0,A=A+Math.imul(m,O0)|0,A=A+Math.imul(r,I0)|0,S=S+Math.imul(r,O0)|0,R=R+Math.imul(t,J0)|0,A=A+Math.imul(t,F0)|0,A=A+Math.imul(s,J0)|0,S=S+Math.imul(s,F0)|0,R=R+Math.imul(l,A0)|0,A=A+Math.imul(l,H0)|0,A=A+Math.imul(n,A0)|0,S=S+Math.imul(n,H0)|0,R=R+Math.imul(h,W0)|0,A=A+Math.imul(h,E0)|0,A=A+Math.imul(d,W0)|0,S=S+Math.imul(d,E0)|0,R=R+Math.imul(B,T0)|0,A=A+Math.imul(B,D0)|0,A=A+Math.imul(c,T0)|0,S=S+Math.imul(c,D0)|0;var l0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(l0>>>26)|0,l0&=67108863,R=Math.imul(o,X0),A=Math.imul(o,K0),A=A+Math.imul(a,X0)|0,S=Math.imul(a,K0),R=R+Math.imul(i,I0)|0,A=A+Math.imul(i,O0)|0,A=A+Math.imul(e,I0)|0,S=S+Math.imul(e,O0)|0,R=R+Math.imul(m,J0)|0,A=A+Math.imul(m,F0)|0,A=A+Math.imul(r,J0)|0,S=S+Math.imul(r,F0)|0,R=R+Math.imul(t,A0)|0,A=A+Math.imul(t,H0)|0,A=A+Math.imul(s,A0)|0,S=S+Math.imul(s,H0)|0,R=R+Math.imul(l,W0)|0,A=A+Math.imul(l,E0)|0,A=A+Math.imul(n,W0)|0,S=S+Math.imul(n,E0)|0,R=R+Math.imul(h,T0)|0,A=A+Math.imul(h,D0)|0,A=A+Math.imul(d,T0)|0,S=S+Math.imul(d,D0)|0,R=R+Math.imul(B,C0)|0,A=A+Math.imul(B,L0)|0,A=A+Math.imul(c,C0)|0,S=S+Math.imul(c,L0)|0;var o0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(o0>>>26)|0,o0&=67108863,R=Math.imul($0,X0),A=Math.imul($0,K0),A=A+Math.imul(Q0,X0)|0,S=Math.imul(Q0,K0),R=R+Math.imul(o,I0)|0,A=A+Math.imul(o,O0)|0,A=A+Math.imul(a,I0)|0,S=S+Math.imul(a,O0)|0,R=R+Math.imul(i,J0)|0,A=A+Math.imul(i,F0)|0,A=A+Math.imul(e,J0)|0,S=S+Math.imul(e,F0)|0,R=R+Math.imul(m,A0)|0,A=A+Math.imul(m,H0)|0,A=A+Math.imul(r,A0)|0,S=S+Math.imul(r,H0)|0,R=R+Math.imul(t,W0)|0,A=A+Math.imul(t,E0)|0,A=A+Math.imul(s,W0)|0,S=S+Math.imul(s,E0)|0,R=R+Math.imul(l,T0)|0,A=A+Math.imul(l,D0)|0,A=A+Math.imul(n,T0)|0,S=S+Math.imul(n,D0)|0,R=R+Math.imul(h,C0)|0,A=A+Math.imul(h,L0)|0,A=A+Math.imul(d,C0)|0,S=S+Math.imul(d,L0)|0,R=R+Math.imul(B,R0)|0,A=A+Math.imul(B,P0)|0,A=A+Math.imul(c,R0)|0,S=S+Math.imul(c,P0)|0;var u0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(u0>>>26)|0,u0&=67108863,R=Math.imul(Z0,X0),A=Math.imul(Z0,K0),A=A+Math.imul(G0,X0)|0,S=Math.imul(G0,K0),R=R+Math.imul($0,I0)|0,A=A+Math.imul($0,O0)|0,A=A+Math.imul(Q0,I0)|0,S=S+Math.imul(Q0,O0)|0,R=R+Math.imul(o,J0)|0,A=A+Math.imul(o,F0)|0,A=A+Math.imul(a,J0)|0,S=S+Math.imul(a,F0)|0,R=R+Math.imul(i,A0)|0,A=A+Math.imul(i,H0)|0,A=A+Math.imul(e,A0)|0,S=S+Math.imul(e,H0)|0,R=R+Math.imul(m,W0)|0,A=A+Math.imul(m,E0)|0,A=A+Math.imul(r,W0)|0,S=S+Math.imul(r,E0)|0,R=R+Math.imul(t,T0)|0,A=A+Math.imul(t,D0)|0,A=A+Math.imul(s,T0)|0,S=S+Math.imul(s,D0)|0,R=R+Math.imul(l,C0)|0,A=A+Math.imul(l,L0)|0,A=A+Math.imul(n,C0)|0,S=S+Math.imul(n,L0)|0,R=R+Math.imul(h,R0)|0,A=A+Math.imul(h,P0)|0,A=A+Math.imul(d,R0)|0,S=S+Math.imul(d,P0)|0,R=R+Math.imul(B,z0)|0,A=A+Math.imul(B,M0)|0,A=A+Math.imul(c,z0)|0,S=S+Math.imul(c,M0)|0;var n0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(n0>>>26)|0,n0&=67108863,R=Math.imul(V0,X0),A=Math.imul(V0,K0),A=A+Math.imul(U0,X0)|0,S=Math.imul(U0,K0),R=R+Math.imul(Z0,I0)|0,A=A+Math.imul(Z0,O0)|0,A=A+Math.imul(G0,I0)|0,S=S+Math.imul(G0,O0)|0,R=R+Math.imul($0,J0)|0,A=A+Math.imul($0,F0)|0,A=A+Math.imul(Q0,J0)|0,S=S+Math.imul(Q0,F0)|0,R=R+Math.imul(o,A0)|0,A=A+Math.imul(o,H0)|0,A=A+Math.imul(a,A0)|0,S=S+Math.imul(a,H0)|0,R=R+Math.imul(i,W0)|0,A=A+Math.imul(i,E0)|0,A=A+Math.imul(e,W0)|0,S=S+Math.imul(e,E0)|0,R=R+Math.imul(m,T0)|0,A=A+Math.imul(m,D0)|0,A=A+Math.imul(r,T0)|0,S=S+Math.imul(r,D0)|0,R=R+Math.imul(t,C0)|0,A=A+Math.imul(t,L0)|0,A=A+Math.imul(s,C0)|0,S=S+Math.imul(s,L0)|0,R=R+Math.imul(l,R0)|0,A=A+Math.imul(l,P0)|0,A=A+Math.imul(n,R0)|0,S=S+Math.imul(n,P0)|0,R=R+Math.imul(h,z0)|0,A=A+Math.imul(h,M0)|0,A=A+Math.imul(d,z0)|0,S=S+Math.imul(d,M0)|0,R=R+Math.imul(B,j0)|0,A=A+Math.imul(B,k0)|0,A=A+Math.imul(c,j0)|0,S=S+Math.imul(c,k0)|0;var s0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(s0>>>26)|0,s0&=67108863,R=Math.imul(V0,I0),A=Math.imul(V0,O0),A=A+Math.imul(U0,I0)|0,S=Math.imul(U0,O0),R=R+Math.imul(Z0,J0)|0,A=A+Math.imul(Z0,F0)|0,A=A+Math.imul(G0,J0)|0,S=S+Math.imul(G0,F0)|0,R=R+Math.imul($0,A0)|0,A=A+Math.imul($0,H0)|0,A=A+Math.imul(Q0,A0)|0,S=S+Math.imul(Q0,H0)|0,R=R+Math.imul(o,W0)|0,A=A+Math.imul(o,E0)|0,A=A+Math.imul(a,W0)|0,S=S+Math.imul(a,E0)|0,R=R+Math.imul(i,T0)|0,A=A+Math.imul(i,D0)|0,A=A+Math.imul(e,T0)|0,S=S+Math.imul(e,D0)|0,R=R+Math.imul(m,C0)|0,A=A+Math.imul(m,L0)|0,A=A+Math.imul(r,C0)|0,S=S+Math.imul(r,L0)|0,R=R+Math.imul(t,R0)|0,A=A+Math.imul(t,P0)|0,A=A+Math.imul(s,R0)|0,S=S+Math.imul(s,P0)|0,R=R+Math.imul(l,z0)|0,A=A+Math.imul(l,M0)|0,A=A+Math.imul(n,z0)|0,S=S+Math.imul(n,M0)|0,R=R+Math.imul(h,j0)|0,A=A+Math.imul(h,k0)|0,A=A+Math.imul(d,j0)|0,S=S+Math.imul(d,k0)|0;var t0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(t0>>>26)|0,t0&=67108863,R=Math.imul(V0,J0),A=Math.imul(V0,F0),A=A+Math.imul(U0,J0)|0,S=Math.imul(U0,F0),R=R+Math.imul(Z0,A0)|0,A=A+Math.imul(Z0,H0)|0,A=A+Math.imul(G0,A0)|0,S=S+Math.imul(G0,H0)|0,R=R+Math.imul($0,W0)|0,A=A+Math.imul($0,E0)|0,A=A+Math.imul(Q0,W0)|0,S=S+Math.imul(Q0,E0)|0,R=R+Math.imul(o,T0)|0,A=A+Math.imul(o,D0)|0,A=A+Math.imul(a,T0)|0,S=S+Math.imul(a,D0)|0,R=R+Math.imul(i,C0)|0,A=A+Math.imul(i,L0)|0,A=A+Math.imul(e,C0)|0,S=S+Math.imul(e,L0)|0,R=R+Math.imul(m,R0)|0,A=A+Math.imul(m,P0)|0,A=A+Math.imul(r,R0)|0,S=S+Math.imul(r,P0)|0,R=R+Math.imul(t,z0)|0,A=A+Math.imul(t,M0)|0,A=A+Math.imul(s,z0)|0,S=S+Math.imul(s,M0)|0,R=R+Math.imul(l,j0)|0,A=A+Math.imul(l,k0)|0,A=A+Math.imul(n,j0)|0,S=S+Math.imul(n,k0)|0;var m0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(m0>>>26)|0,m0&=67108863,R=Math.imul(V0,A0),A=Math.imul(V0,H0),A=A+Math.imul(U0,A0)|0,S=Math.imul(U0,H0),R=R+Math.imul(Z0,W0)|0,A=A+Math.imul(Z0,E0)|0,A=A+Math.imul(G0,W0)|0,S=S+Math.imul(G0,E0)|0,R=R+Math.imul($0,T0)|0,A=A+Math.imul($0,D0)|0,A=A+Math.imul(Q0,T0)|0,S=S+Math.imul(Q0,D0)|0,R=R+Math.imul(o,C0)|0,A=A+Math.imul(o,L0)|0,A=A+Math.imul(a,C0)|0,S=S+Math.imul(a,L0)|0,R=R+Math.imul(i,R0)|0,A=A+Math.imul(i,P0)|0,A=A+Math.imul(e,R0)|0,S=S+Math.imul(e,P0)|0,R=R+Math.imul(m,z0)|0,A=A+Math.imul(m,M0)|0,A=A+Math.imul(r,z0)|0,S=S+Math.imul(r,M0)|0,R=R+Math.imul(t,j0)|0,A=A+Math.imul(t,k0)|0,A=A+Math.imul(s,j0)|0,S=S+Math.imul(s,k0)|0;var a0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(a0>>>26)|0,a0&=67108863,R=Math.imul(V0,W0),A=Math.imul(V0,E0),A=A+Math.imul(U0,W0)|0,S=Math.imul(U0,E0),R=R+Math.imul(Z0,T0)|0,A=A+Math.imul(Z0,D0)|0,A=A+Math.imul(G0,T0)|0,S=S+Math.imul(G0,D0)|0,R=R+Math.imul($0,C0)|0,A=A+Math.imul($0,L0)|0,A=A+Math.imul(Q0,C0)|0,S=S+Math.imul(Q0,L0)|0,R=R+Math.imul(o,R0)|0,A=A+Math.imul(o,P0)|0,A=A+Math.imul(a,R0)|0,S=S+Math.imul(a,P0)|0,R=R+Math.imul(i,z0)|0,A=A+Math.imul(i,M0)|0,A=A+Math.imul(e,z0)|0,S=S+Math.imul(e,M0)|0,R=R+Math.imul(m,j0)|0,A=A+Math.imul(m,k0)|0,A=A+Math.imul(r,j0)|0,S=S+Math.imul(r,k0)|0;var e0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(e0>>>26)|0,e0&=67108863,R=Math.imul(V0,T0),A=Math.imul(V0,D0),A=A+Math.imul(U0,T0)|0,S=Math.imul(U0,D0),R=R+Math.imul(Z0,C0)|0,A=A+Math.imul(Z0,L0)|0,A=A+Math.imul(G0,C0)|0,S=S+Math.imul(G0,L0)|0,R=R+Math.imul($0,R0)|0,A=A+Math.imul($0,P0)|0,A=A+Math.imul(Q0,R0)|0,S=S+Math.imul(Q0,P0)|0,R=R+Math.imul(o,z0)|0,A=A+Math.imul(o,M0)|0,A=A+Math.imul(a,z0)|0,S=S+Math.imul(a,M0)|0,R=R+Math.imul(i,j0)|0,A=A+Math.imul(i,k0)|0,A=A+Math.imul(e,j0)|0,S=S+Math.imul(e,k0)|0;var r0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(r0>>>26)|0,r0&=67108863,R=Math.imul(V0,C0),A=Math.imul(V0,L0),A=A+Math.imul(U0,C0)|0,S=Math.imul(U0,L0),R=R+Math.imul(Z0,R0)|0,A=A+Math.imul(Z0,P0)|0,A=A+Math.imul(G0,R0)|0,S=S+Math.imul(G0,P0)|0,R=R+Math.imul($0,z0)|0,A=A+Math.imul($0,M0)|0,A=A+Math.imul(Q0,z0)|0,S=S+Math.imul(Q0,M0)|0,R=R+Math.imul(o,j0)|0,A=A+Math.imul(o,k0)|0,A=A+Math.imul(a,j0)|0,S=S+Math.imul(a,k0)|0;var i0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(i0>>>26)|0,i0&=67108863,R=Math.imul(V0,R0),A=Math.imul(V0,P0),A=A+Math.imul(U0,R0)|0,S=Math.imul(U0,P0),R=R+Math.imul(Z0,z0)|0,A=A+Math.imul(Z0,M0)|0,A=A+Math.imul(G0,z0)|0,S=S+Math.imul(G0,M0)|0,R=R+Math.imul($0,j0)|0,A=A+Math.imul($0,k0)|0,A=A+Math.imul(Q0,j0)|0,S=S+Math.imul(Q0,k0)|0;var _$=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(_$>>>26)|0,_$&=67108863,R=Math.imul(V0,z0),A=Math.imul(V0,M0),A=A+Math.imul(U0,z0)|0,S=Math.imul(U0,M0),R=R+Math.imul(Z0,j0)|0,A=A+Math.imul(Z0,k0)|0,A=A+Math.imul(G0,j0)|0,S=S+Math.imul(G0,k0)|0;var N$=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(N$>>>26)|0,N$&=67108863,R=Math.imul(V0,j0),A=Math.imul(V0,k0),A=A+Math.imul(U0,j0)|0,S=Math.imul(U0,k0);var x$=(K+R|0)+((A&8191)<<13)|0;return K=(S+(A>>>13)|0)+(x$>>>26)|0,x$&=67108863,Q[0]=f0,Q[1]=c0,Q[2]=h0,Q[3]=d0,Q[4]=b0,Q[5]=l0,Q[6]=o0,Q[7]=u0,Q[8]=n0,Q[9]=s0,Q[10]=t0,Q[11]=m0,Q[12]=a0,Q[13]=e0,Q[14]=r0,Q[15]=i0,Q[16]=_$,Q[17]=N$,Q[18]=x$,K!==0&&(Q[19]=K,I.length++),I};Math.imul||(g=q);function y(Z,V,I){I.negative=V.negative^Z.negative,I.length=Z.length+V.length;for(var O=0,U=0,Q=0;Q>>26)|0,U+=K>>>26,K&=67108863}I.words[Q]=R,O=K,K=U}return O!==0?I.words[Q]=O:I.length--,I._strip()}function w(Z,V,I){return y(Z,V,I)}X.prototype.mulTo=function(Z,V){var I,O=this.length+Z.length;return this.length===10&&Z.length===10?I=g(this,Z,V):O<63?I=q(this,Z,V):O<1024?I=y(this,Z,V):I=w(this,Z,V),I};function f(Z,V){this.x=Z,this.y=V}f.prototype.makeRBT=function(Z){for(var V=new Array(Z),I=X.prototype._countBits(Z)-1,O=0;O>=1;return O},f.prototype.permute=function(Z,V,I,O,U,Q){for(var K=0;K>>1)U++;return 1<>>13,I[2*Q+1]=U&8191,U=U>>>13;for(Q=2*V;Q>=26,I+=U/67108864|0,I+=Q>>>26,this.words[O]=Q&67108863}return I!==0&&(this.words[O]=I,this.length++),V?this.ineg():this},X.prototype.muln=function(Z){return this.clone().imuln(Z)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function(Z){var V=v(Z);if(V.length===0)return new X(1);for(var I=this,O=0;O=0);var V=Z%26,I=(Z-V)/26,O=67108863>>>26-V<<26-V,U;if(V!==0){var Q=0;for(U=0;U>>26-V}Q&&(this.words[U]=Q,this.length++)}if(I!==0){for(U=this.length-1;U>=0;U--)this.words[U+I]=this.words[U];for(U=0;U=0);var O;V?O=(V-V%26)/26:O=0;var U=Z%26,Q=Math.min((Z-U)/26,this.length),K=67108863^67108863>>>U<Q)for(this.length-=Q,A=0;A=0&&(S!==0||A>=O);A--){var x=this.words[A]|0;this.words[A]=S<<26-U|x>>>U,S=x&K}return R&&S!==0&&(R.words[R.length++]=S),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},X.prototype.ishrn=function(Z,V,I){return F(this.negative===0),this.iushrn(Z,V,I)},X.prototype.shln=function(Z){return this.clone().ishln(Z)},X.prototype.ushln=function(Z){return this.clone().iushln(Z)},X.prototype.shrn=function(Z){return this.clone().ishrn(Z)},X.prototype.ushrn=function(Z){return this.clone().iushrn(Z)},X.prototype.testn=function(Z){F(typeof Z=="number"&&Z>=0);var V=Z%26,I=(Z-V)/26,O=1<=0);var V=Z%26,I=(Z-V)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=I)return this;if(V!==0&&I++,this.length=Math.min(I,this.length),V!==0){var O=67108863^67108863>>>V<=67108864;V++)this.words[V]-=67108864,V===this.length-1?this.words[V+1]=1:this.words[V+1]++;return this.length=Math.max(this.length,V+1),this},X.prototype.isubn=function(Z){if(F(typeof Z=="number"),F(Z<67108864),Z<0)return this.iaddn(-Z);if(this.negative!==0)return this.negative=0,this.iaddn(Z),this.negative=1,this;if(this.words[0]-=Z,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var V=0;V>26)-(R/67108864|0),this.words[U+I]=Q&67108863}for(;U>26,this.words[U+I]=Q&67108863;if(K===0)return this._strip();for(F(K===-1),K=0,U=0;U>26,this.words[U]=Q&67108863;return this.negative=1,this._strip()},X.prototype._wordDiv=function(Z,V){var I=this.length-Z.length,O=this.clone(),U=Z,Q=U.words[U.length-1]|0,K=this._countBits(Q);I=26-K,I!==0&&(U=U.ushln(I),O.iushln(I),Q=U.words[U.length-1]|0);var R=O.length-U.length,A;if(V!=="mod"){A=new X(null),A.length=R+1,A.words=new Array(A.length);for(var S=0;S=0;B--){var c=(O.words[U.length+B]|0)*67108864+(O.words[U.length+B-1]|0);for(c=Math.min(c/Q|0,67108863),O._ishlnsubmul(U,c,B);O.negative!==0;)c--,O.negative=0,O._ishlnsubmul(U,1,B),O.isZero()||(O.negative^=1);A&&(A.words[B]=c)}return A&&A._strip(),O._strip(),V!=="div"&&I!==0&&O.iushrn(I),{div:A||null,mod:O}},X.prototype.divmod=function(Z,V,I){if(F(!Z.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var O,U,Q;return this.negative!==0&&Z.negative===0?(Q=this.neg().divmod(Z,V),V!=="mod"&&(O=Q.div.neg()),V!=="div"&&(U=Q.mod.neg(),I&&U.negative!==0&&U.iadd(Z)),{div:O,mod:U}):this.negative===0&&Z.negative!==0?(Q=this.divmod(Z.neg(),V),V!=="mod"&&(O=Q.div.neg()),{div:O,mod:Q.mod}):(this.negative&Z.negative)!==0?(Q=this.neg().divmod(Z.neg(),V),V!=="div"&&(U=Q.mod.neg(),I&&U.negative!==0&&U.isub(Z)),{div:Q.div,mod:U}):Z.length>this.length||this.cmp(Z)<0?{div:new X(0),mod:this}:Z.length===1?V==="div"?{div:this.divn(Z.words[0]),mod:null}:V==="mod"?{div:null,mod:new X(this.modrn(Z.words[0]))}:{div:this.divn(Z.words[0]),mod:new X(this.modrn(Z.words[0]))}:this._wordDiv(Z,V)},X.prototype.div=function(Z){return this.divmod(Z,"div",!1).div},X.prototype.mod=function(Z){return this.divmod(Z,"mod",!1).mod},X.prototype.umod=function(Z){return this.divmod(Z,"mod",!0).mod},X.prototype.divRound=function(Z){var V=this.divmod(Z);if(V.mod.isZero())return V.div;var I=V.div.negative!==0?V.mod.isub(Z):V.mod,O=Z.ushrn(1),U=Z.andln(1),Q=I.cmp(O);return Q<0||U===1&&Q===0?V.div:V.div.negative!==0?V.div.isubn(1):V.div.iaddn(1)},X.prototype.modrn=function(Z){var V=Z<0;V&&(Z=-Z),F(Z<=67108863);for(var I=(1<<26)%Z,O=0,U=this.length-1;U>=0;U--)O=(I*O+(this.words[U]|0))%Z;return V?-O:O},X.prototype.modn=function(Z){return this.modrn(Z)},X.prototype.idivn=function(Z){var V=Z<0;V&&(Z=-Z),F(Z<=67108863);for(var I=0,O=this.length-1;O>=0;O--){var U=(this.words[O]|0)+I*67108864;this.words[O]=U/Z|0,I=U%Z}return this._strip(),V?this.ineg():this},X.prototype.divn=function(Z){return this.clone().idivn(Z)},X.prototype.egcd=function(Z){F(Z.negative===0),F(!Z.isZero());var V=this,I=Z.clone();V.negative!==0?V=V.umod(Z):V=V.clone();for(var O=new X(1),U=new X(0),Q=new X(0),K=new X(1),R=0;V.isEven()&&I.isEven();)V.iushrn(1),I.iushrn(1),++R;for(var A=I.clone(),S=V.clone();!V.isZero();){for(var x=0,B=1;(V.words[0]&B)===0&&x<26;++x,B<<=1);if(x>0)for(V.iushrn(x);x-- >0;)(O.isOdd()||U.isOdd())&&(O.iadd(A),U.isub(S)),O.iushrn(1),U.iushrn(1);for(var c=0,q0=1;(I.words[0]&q0)===0&&c<26;++c,q0<<=1);if(c>0)for(I.iushrn(c);c-- >0;)(Q.isOdd()||K.isOdd())&&(Q.iadd(A),K.isub(S)),Q.iushrn(1),K.iushrn(1);V.cmp(I)>=0?(V.isub(I),O.isub(Q),U.isub(K)):(I.isub(V),Q.isub(O),K.isub(U))}return{a:Q,b:K,gcd:I.iushln(R)}},X.prototype._invmp=function(Z){F(Z.negative===0),F(!Z.isZero());var V=this,I=Z.clone();V.negative!==0?V=V.umod(Z):V=V.clone();for(var O=new X(1),U=new X(0),Q=I.clone();V.cmpn(1)>0&&I.cmpn(1)>0;){for(var K=0,R=1;(V.words[0]&R)===0&&K<26;++K,R<<=1);if(K>0)for(V.iushrn(K);K-- >0;)O.isOdd()&&O.iadd(Q),O.iushrn(1);for(var A=0,S=1;(I.words[0]&S)===0&&A<26;++A,S<<=1);if(A>0)for(I.iushrn(A);A-- >0;)U.isOdd()&&U.iadd(Q),U.iushrn(1);V.cmp(I)>=0?(V.isub(I),O.isub(U)):(I.isub(V),U.isub(O))}var x;return V.cmpn(1)===0?x=O:x=U,x.cmpn(0)<0&&x.iadd(Z),x},X.prototype.gcd=function(Z){if(this.isZero())return Z.abs();if(Z.isZero())return this.abs();var V=this.clone(),I=Z.clone();V.negative=0,I.negative=0;for(var O=0;V.isEven()&&I.isEven();O++)V.iushrn(1),I.iushrn(1);do{for(;V.isEven();)V.iushrn(1);for(;I.isEven();)I.iushrn(1);var U=V.cmp(I);if(U<0){var Q=V;V=I,I=Q}else if(U===0||I.cmpn(1)===0)break;V.isub(I)}while(!0);return I.iushln(O)},X.prototype.invm=function(Z){return this.egcd(Z).a.umod(Z)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function(Z){return this.words[0]&Z},X.prototype.bincn=function(Z){F(typeof Z=="number");var V=Z%26,I=(Z-V)/26,O=1<>>26,K&=67108863,this.words[Q]=K}return U!==0&&(this.words[Q]=U,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function(Z){var V=Z<0;if(this.negative!==0&&!V)return-1;if(this.negative===0&&V)return 1;this._strip();var I;if(this.length>1)I=1;else{V&&(Z=-Z),F(Z<=67108863,"Number is too big");var O=this.words[0]|0;I=O===Z?0:OZ.length)return 1;if(this.length=0;I--){var O=this.words[I]|0,U=Z.words[I]|0;if(O!==U){OU&&(V=1);break}}return V},X.prototype.gtn=function(Z){return this.cmpn(Z)===1},X.prototype.gt=function(Z){return this.cmp(Z)===1},X.prototype.gten=function(Z){return this.cmpn(Z)>=0},X.prototype.gte=function(Z){return this.cmp(Z)>=0},X.prototype.ltn=function(Z){return this.cmpn(Z)===-1},X.prototype.lt=function(Z){return this.cmp(Z)===-1},X.prototype.lten=function(Z){return this.cmpn(Z)<=0},X.prototype.lte=function(Z){return this.cmp(Z)<=0},X.prototype.eqn=function(Z){return this.cmpn(Z)===0},X.prototype.eq=function(Z){return this.cmp(Z)===0},X.red=function(Z){return new Y(Z)},X.prototype.toRed=function(Z){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),Z.convertTo(this)._forceRed(Z)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function(Z){return this.red=Z,this},X.prototype.forceRed=function(Z){return F(!this.red,"Already a number in reduction context"),this._forceRed(Z)},X.prototype.redAdd=function(Z){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,Z)},X.prototype.redIAdd=function(Z){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Z)},X.prototype.redSub=function(Z){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,Z)},X.prototype.redISub=function(Z){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,Z)},X.prototype.redShl=function(Z){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,Z)},X.prototype.redMul=function(Z){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,Z),this.red.mul(this,Z)},X.prototype.redIMul=function(Z){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,Z),this.red.imul(this,Z)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function(Z){return F(this.red&&!Z.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Z)};var b={k256:null,p224:null,p192:null,p25519:null};function u(Z,V){this.name=Z,this.p=new X(V,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}u.prototype._tmp=function(){var Z=new X(null);return Z.words=new Array(Math.ceil(this.n/13)),Z},u.prototype.ireduce=function(Z){var V=Z,I;do this.split(V,this.tmp),V=this.imulK(V),V=V.iadd(this.tmp),I=V.bitLength();while(I>this.n);var O=I0?V.isub(this.p):V.strip!==void 0?V.strip():V._strip(),V},u.prototype.split=function(Z,V){Z.iushrn(this.n,0,V)},u.prototype.imulK=function(Z){return Z.imul(this.k)};function Y0(){u.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(Y0,u),Y0.prototype.split=function(Z,V){for(var I=4194303,O=Math.min(Z.length,9),U=0;U>>22,Q=K}Q>>>=22,Z.words[U-10]=Q,Q===0&&Z.length>10?Z.length-=10:Z.length-=9},Y0.prototype.imulK=function(Z){Z.words[Z.length]=0,Z.words[Z.length+1]=0,Z.length+=2;for(var V=0,I=0;I>>=26,Z.words[I]=U,V=O}return V!==0&&(Z.words[Z.length++]=V),Z},X._prime=function(Z){if(b[Z])return b[Z];var V;if(Z==="k256")V=new Y0;else if(Z==="p224")V=new p;else if(Z==="p192")V=new v0;else if(Z==="p25519")V=new $;else throw new Error("Unknown prime "+Z);return b[Z]=V,V};function Y(Z){if(typeof Z=="string"){var V=X._prime(Z);this.m=V.p,this.prime=V}else F(Z.gtn(1),"modulus must be greater than 1"),this.m=Z,this.prime=null}Y.prototype._verify1=function(Z){F(Z.negative===0,"red works only with positives"),F(Z.red,"red works only with red numbers")},Y.prototype._verify2=function(Z,V){F((Z.negative|V.negative)===0,"red works only with positives"),F(Z.red&&Z.red===V.red,"red works only with red numbers")},Y.prototype.imod=function(Z){return this.prime?this.prime.ireduce(Z)._forceRed(this):(J(Z,Z.umod(this.m)._forceRed(this)),Z)},Y.prototype.neg=function(Z){return Z.isZero()?Z.clone():this.m.sub(Z)._forceRed(this)},Y.prototype.add=function(Z,V){this._verify2(Z,V);var I=Z.add(V);return I.cmp(this.m)>=0&&I.isub(this.m),I._forceRed(this)},Y.prototype.iadd=function(Z,V){this._verify2(Z,V);var I=Z.iadd(V);return I.cmp(this.m)>=0&&I.isub(this.m),I},Y.prototype.sub=function(Z,V){this._verify2(Z,V);var I=Z.sub(V);return I.cmpn(0)<0&&I.iadd(this.m),I._forceRed(this)},Y.prototype.isub=function(Z,V){this._verify2(Z,V);var I=Z.isub(V);return I.cmpn(0)<0&&I.iadd(this.m),I},Y.prototype.shl=function(Z,V){return this._verify1(Z),this.imod(Z.ushln(V))},Y.prototype.imul=function(Z,V){return this._verify2(Z,V),this.imod(Z.imul(V))},Y.prototype.mul=function(Z,V){return this._verify2(Z,V),this.imod(Z.mul(V))},Y.prototype.isqr=function(Z){return this.imul(Z,Z.clone())},Y.prototype.sqr=function(Z){return this.mul(Z,Z)},Y.prototype.sqrt=function(Z){if(Z.isZero())return Z.clone();var V=this.m.andln(3);if(F(V%2===1),V===3){var I=this.m.add(new X(1)).iushrn(2);return this.pow(Z,I)}for(var O=this.m.subn(1),U=0;!O.isZero()&&O.andln(1)===0;)U++,O.iushrn(1);F(!O.isZero());var Q=new X(1).toRed(this),K=Q.redNeg(),R=this.m.subn(1).iushrn(1),A=this.m.bitLength();for(A=new X(2*A*A).toRed(this);this.pow(A,R).cmp(K)!==0;)A.redIAdd(K);for(var S=this.pow(A,O),x=this.pow(Z,O.addn(1).iushrn(1)),B=this.pow(Z,O),c=U;B.cmp(Q)!==0;){for(var q0=B,h=0;q0.cmp(Q)!==0;h++)q0=q0.redSqr();F(h=0;U--){for(var S=V.words[U],x=A-1;x>=0;x--){var B=S>>x&1;if(Q!==O[0]&&(Q=this.sqr(Q)),B===0&&K===0){R=0;continue}K<<=1,K|=B,R++,!(R!==I&&(U!==0||x!==0))&&(Q=this.mul(Q,O[K]),R=0,K=0)}A=26}return Q},Y.prototype.convertTo=function(Z){var V=Z.umod(this.m);return V===Z?V.clone():V},Y.prototype.convertFrom=function(Z){var V=Z.clone();return V.red=null,V},X.mont=function(Z){return new G(Z)};function G(Z){Y.call(this,Z),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(G,Y),G.prototype.convertTo=function(Z){return this.imod(Z.ushln(this.shift))},G.prototype.convertFrom=function(Z){var V=this.imod(Z.mul(this.rinv));return V.red=null,V},G.prototype.imul=function(Z,V){if(Z.isZero()||V.isZero())return Z.words[0]=0,Z.length=1,Z;var I=Z.imul(V),O=I.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),U=I.isub(O).iushrn(this.shift),Q=U;return U.cmp(this.m)>=0?Q=U.isub(this.m):U.cmpn(0)<0&&(Q=U.iadd(this.m)),Q._forceRed(this)},G.prototype.mul=function(Z,V){if(Z.isZero()||V.isZero())return new X(0)._forceRed(this);var I=Z.mul(V),O=I.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),U=I.isub(O).iushrn(this.shift),Q=U;return U.cmp(this.m)>=0?Q=U.isub(this.m):U.cmpn(0)<0&&(Q=U.iadd(this.m)),Q._forceRed(this)},G.prototype.invm=function(Z){var V=this.imod(Z._invmp(this.m).mul(this.r2));return V._forceRed(this)}})(typeof _>"u"||_,N)}}),h$=S0({"node_modules/browserify-rsa/index.js"(N,_){var k=c$(),j=L$();function F(C){var P=z(C),T=P.toRed(k.mont(C.modulus)).redPow(new k(C.publicExponent)).fromRed();return{blinder:T,unblinder:P.invm(C.modulus)}}function z(C){var P=C.modulus.byteLength(),T;do T=new k(j(P));while(T.cmp(C.modulus)>=0||!T.umod(C.prime1)||!T.umod(C.prime2));return T}function X(C,P){var T=F(P),W=P.modulus.byteLength(),J=new k(C).mul(T.blinder).umod(P.modulus),H=J.toRed(k.mont(P.prime1)),D=J.toRed(k.mont(P.prime2)),E=P.coefficient,L=P.prime1,M=P.prime2,v=H.redPow(P.exponent1).fromRed(),q=D.redPow(P.exponent2).fromRed(),g=v.isub(q).imul(E).umod(L).imul(M);return q.iadd(g).imul(T.unblinder).umod(P.modulus).toArrayLike(g0,"be",W)}X.getr=z,_.exports=X}}),TY=S0({"node_modules/elliptic/package.json"(N,_){_.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"}}}}),D$=S0({"node_modules/elliptic/node_modules/bn.js/lib/bn.js"(N,_){(function(k,j){function F($,Y){if(!$)throw new Error(Y||"Assertion failed")}function z($,Y){$.super_=Y;var G=function(){};G.prototype=Y.prototype,$.prototype=new G,$.prototype.constructor=$}function X($,Y,G){if(X.isBN($))return $;this.negative=0,this.words=null,this.length=0,this.red=null,$!==null&&((Y==="le"||Y==="be")&&(G=Y,Y=10),this._init($||0,Y||10,G||"be"))}typeof k=="object"?k.exports=X:j.BN=X,X.BN=X,X.wordSize=26;var C=g0;X.isBN=function($){return $ instanceof X?!0:$!==null&&typeof $=="object"&&$.constructor.wordSize===X.wordSize&&Array.isArray($.words)},X.max=function($,Y){return $.cmp(Y)>0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),zQ=S0({"node_modules/minimalistic-crypto-utils/lib/utils.js"(N){var _=N;function k(z,X){if(Array.isArray(z))return z.slice();if(!z)return[];var C=[];if(typeof z!="string"){for(var P=0;P>8,J=T&255;W?C.push(W,J):C.push(J)}return C}_.toArray=k;function j(z){return z.length===1?"0"+z:z}_.zero2=j;function F(z){for(var X="",C=0;C(E>>1)-1?v=(E>>1)-q:v=q,L.isubn(v)):v=0,D[M]=v,L.iushrn(1)}return D}_.getNAF=z;function X(W,J){var H=[[],[]];W=W.clone(),J=J.clone();for(var D=0,E=0,L;W.cmpn(-D)>0||J.cmpn(-E)>0;){var M=W.andln(3)+D&3,v=J.andln(3)+E&3;M===3&&(M=-1),v===3&&(v=-1);var q;(M&1)===0?q=0:(L=W.andln(7)+D&7,(L===3||L===5)&&v===2?q=-M:q=M),H[0].push(q);var g;(v&1)===0?g=0:(L=J.andln(7)+E&7,(L===3||L===5)&&M===2?g=-v:g=v),H[1].push(g),2*D===q+1&&(D=1-D),2*E===g+1&&(E=1-E),W.iushrn(1),J.iushrn(1)}return H}_.getJSF=X;function C(W,J,H){var D="_"+J;W.prototype[J]=function(){return this[D]!==void 0?this[D]:this[D]=H.call(this)}}_.cachedProperty=C;function P(W){return typeof W=="string"?_.toArray(W,"hex"):W}_.parseBytes=P;function T(W){return new k(W,"hex","le")}_.intFromLE=T}}),k$=S0({"node_modules/elliptic/lib/elliptic/curve/base.js"(N,_){var k=D$(),j=E$(),F=j.getNAF,z=j.getJSF,X=j.assert;function C(T,W){this.type=T,this.p=new k(W.p,16),this.red=W.prime?k.red(W.prime):k.mont(this.p),this.zero=new k(0).toRed(this.red),this.one=new k(1).toRed(this.red),this.two=new k(2).toRed(this.red),this.n=W.n&&new k(W.n,16),this.g=W.g&&this.pointFromJSON(W.g,W.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=C,C.prototype.point=function(){throw new Error("Not implemented")},C.prototype.validate=function(){throw new Error("Not implemented")},C.prototype._fixedNafMul=function(T,W){X(T.precomputed);var J=T._getDoubles(),H=F(W,1,this._bitLength),D=(1<=L;v--)M=(M<<1)+H[v];E.push(M)}for(var q=this.jpoint(null,null,null),g=this.jpoint(null,null,null),y=D;y>0;y--){for(L=0;L=0;M--){for(var v=0;M>=0&&E[M]===0;M--)v++;if(M>=0&&v++,L=L.dblp(v),M<0)break;var q=E[M];X(q!==0),T.type==="affine"?q>0?L=L.mixedAdd(D[q-1>>1]):L=L.mixedAdd(D[-q-1>>1].neg()):q>0?L=L.add(D[q-1>>1]):L=L.add(D[-q-1>>1].neg())}return T.type==="affine"?L.toP():L},C.prototype._wnafMulAdd=function(T,W,J,H,D){var E=this._wnafT1,L=this._wnafT2,M=this._wnafT3,v=0,q,g,y;for(q=0;q=1;q-=2){var f=q-1,b=q;if(E[f]!==1||E[b]!==1){M[f]=F(J[f],E[f],this._bitLength),M[b]=F(J[b],E[b],this._bitLength),v=Math.max(M[f].length,v),v=Math.max(M[b].length,v);continue}var u=[W[f],null,null,W[b]];W[f].y.cmp(W[b].y)===0?(u[1]=W[f].add(W[b]),u[2]=W[f].toJ().mixedAdd(W[b].neg())):W[f].y.cmp(W[b].y.redNeg())===0?(u[1]=W[f].toJ().mixedAdd(W[b]),u[2]=W[f].add(W[b].neg())):(u[1]=W[f].toJ().mixedAdd(W[b]),u[2]=W[f].toJ().mixedAdd(W[b].neg()));var Y0=[-3,-1,-5,-7,0,7,5,1,3],p=z(J[f],J[b]);for(v=Math.max(p[0].length,v),M[f]=new Array(v),M[b]=new Array(v),g=0;g=0;q--){for(var Z=0;q>=0;){var V=!0;for(g=0;g=0&&Z++,Y=Y.dblp(Z),q<0)break;for(g=0;g0?y=L[g][I-1>>1]:I<0&&(y=L[g][-I-1>>1].neg()),y.type==="affine"?Y=Y.mixedAdd(y):Y=Y.add(y))}}for(q=0;q=Math.ceil((T.bitLength()+1)/W.step):!1},P.prototype._getDoubles=function(T,W){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var J=[this],H=this,D=0;D=0&&(f=q,b=g),y.negative&&(y=y.neg(),w=w.neg()),f.negative&&(f=f.neg(),b=b.neg()),[{a:y,b:w},{a:f,b}]},C.prototype._endoSplit=function(W){var J=this.endo.basis,H=J[0],D=J[1],E=D.b.mul(W).divRound(this.n),L=H.b.neg().mul(W).divRound(this.n),M=E.mul(H.a),v=L.mul(D.a),q=E.mul(H.b),g=L.mul(D.b),y=W.sub(M).sub(v),w=q.add(g).neg();return{k1:y,k2:w}},C.prototype.pointFromX=function(W,J){W=new j(W,16),W.red||(W=W.toRed(this.red));var H=W.redSqr().redMul(W).redIAdd(W.redMul(this.a)).redIAdd(this.b),D=H.redSqrt();if(D.redSqr().redSub(H).cmp(this.zero)!==0)throw new Error("invalid point");var E=D.fromRed().isOdd();return(J&&!E||!J&&E)&&(D=D.redNeg()),this.point(W,D)},C.prototype.validate=function(W){if(W.inf)return!0;var{x:J,y:H}=W,D=this.a.redMul(J),E=J.redSqr().redMul(J).redIAdd(D).redIAdd(this.b);return H.redSqr().redISub(E).cmpn(0)===0},C.prototype._endoWnafMulAdd=function(W,J,H){for(var D=this._endoWnafT1,E=this._endoWnafT2,L=0;L":""},P.prototype.isInfinity=function(){return this.inf},P.prototype.add=function(W){if(this.inf)return W;if(W.inf)return this;if(this.eq(W))return this.dbl();if(this.neg().eq(W))return this.curve.point(null,null);if(this.x.cmp(W.x)===0)return this.curve.point(null,null);var J=this.y.redSub(W.y);J.cmpn(0)!==0&&(J=J.redMul(this.x.redSub(W.x).redInvm()));var H=J.redSqr().redISub(this.x).redISub(W.x),D=J.redMul(this.x.redSub(H)).redISub(this.y);return this.curve.point(H,D)},P.prototype.dbl=function(){if(this.inf)return this;var W=this.y.redAdd(this.y);if(W.cmpn(0)===0)return this.curve.point(null,null);var J=this.curve.a,H=this.x.redSqr(),D=W.redInvm(),E=H.redAdd(H).redIAdd(H).redIAdd(J).redMul(D),L=E.redSqr().redISub(this.x.redAdd(this.x)),M=E.redMul(this.x.redSub(L)).redISub(this.y);return this.curve.point(L,M)},P.prototype.getX=function(){return this.x.fromRed()},P.prototype.getY=function(){return this.y.fromRed()},P.prototype.mul=function(W){return W=new j(W,16),this.isInfinity()?this:this._hasDoubles(W)?this.curve._fixedNafMul(this,W):this.curve.endo?this.curve._endoWnafMulAdd([this],[W]):this.curve._wnafMul(this,W)},P.prototype.mulAdd=function(W,J,H){var D=[this,J],E=[W,H];return this.curve.endo?this.curve._endoWnafMulAdd(D,E):this.curve._wnafMulAdd(1,D,E,2)},P.prototype.jmulAdd=function(W,J,H){var D=[this,J],E=[W,H];return this.curve.endo?this.curve._endoWnafMulAdd(D,E,!0):this.curve._wnafMulAdd(1,D,E,2,!0)},P.prototype.eq=function(W){return this===W||this.inf===W.inf&&(this.inf||this.x.cmp(W.x)===0&&this.y.cmp(W.y)===0)},P.prototype.neg=function(W){if(this.inf)return this;var J=this.curve.point(this.x,this.y.redNeg());if(W&&this.precomputed){var H=this.precomputed,D=function(E){return E.neg()};J.precomputed={naf:H.naf&&{wnd:H.naf.wnd,points:H.naf.points.map(D)},doubles:H.doubles&&{step:H.doubles.step,points:H.doubles.points.map(D)}}}return J},P.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var W=this.curve.jpoint(this.x,this.y,this.curve.one);return W};function T(W,J,H,D){z.BasePoint.call(this,W,"jacobian"),J===null&&H===null&&D===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new j(0)):(this.x=new j(J,16),this.y=new j(H,16),this.z=new j(D,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}F(T,z.BasePoint),C.prototype.jpoint=function(W,J,H){return new T(this,W,J,H)},T.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var W=this.z.redInvm(),J=W.redSqr(),H=this.x.redMul(J),D=this.y.redMul(J).redMul(W);return this.curve.point(H,D)},T.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},T.prototype.add=function(W){if(this.isInfinity())return W;if(W.isInfinity())return this;var J=W.z.redSqr(),H=this.z.redSqr(),D=this.x.redMul(J),E=W.x.redMul(H),L=this.y.redMul(J.redMul(W.z)),M=W.y.redMul(H.redMul(this.z)),v=D.redSub(E),q=L.redSub(M);if(v.cmpn(0)===0)return q.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=v.redSqr(),y=g.redMul(v),w=D.redMul(g),f=q.redSqr().redIAdd(y).redISub(w).redISub(w),b=q.redMul(w.redISub(f)).redISub(L.redMul(y)),u=this.z.redMul(W.z).redMul(v);return this.curve.jpoint(f,b,u)},T.prototype.mixedAdd=function(W){if(this.isInfinity())return W.toJ();if(W.isInfinity())return this;var J=this.z.redSqr(),H=this.x,D=W.x.redMul(J),E=this.y,L=W.y.redMul(J).redMul(this.z),M=H.redSub(D),v=E.redSub(L);if(M.cmpn(0)===0)return v.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var q=M.redSqr(),g=q.redMul(M),y=H.redMul(q),w=v.redSqr().redIAdd(g).redISub(y).redISub(y),f=v.redMul(y.redISub(w)).redISub(E.redMul(g)),b=this.z.redMul(M);return this.curve.jpoint(w,f,b)},T.prototype.dblp=function(W){if(W===0)return this;if(this.isInfinity())return this;if(!W)return this.dbl();var J;if(this.curve.zeroA||this.curve.threeA){var H=this;for(J=0;J=0)return!1;if(H.redIAdd(E),this.x.cmp(H)===0)return!0}},T.prototype.inspect=function(){return this.isInfinity()?"":""},T.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),CY=S0({"node_modules/elliptic/lib/elliptic/curve/mont.js"(N,_){var k=D$(),j=B0(),F=k$(),z=E$();function X(P){F.call(this,"mont",P),this.a=new k(P.a,16).toRed(this.red),this.b=new k(P.b,16).toRed(this.red),this.i4=new k(4).toRed(this.red).redInvm(),this.two=new k(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}j(X,F),_.exports=X,X.prototype.validate=function(P){var T=P.normalize().x,W=T.redSqr(),J=W.redMul(T).redAdd(W.redMul(this.a)).redAdd(T),H=J.redSqrt();return H.redSqr().cmp(J)===0};function C(P,T,W){F.BasePoint.call(this,P,"projective"),T===null&&W===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new k(T,16),this.z=new k(W,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}j(C,F.BasePoint),X.prototype.decodePoint=function(P,T){return this.point(z.toArray(P,T),1)},X.prototype.point=function(P,T){return new C(this,P,T)},X.prototype.pointFromJSON=function(P){return C.fromJSON(this,P)},C.prototype.precompute=function(){},C.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},C.fromJSON=function(P,T){return new C(P,T[0],T[1]||P.one)},C.prototype.inspect=function(){return this.isInfinity()?"":""},C.prototype.isInfinity=function(){return this.z.cmpn(0)===0},C.prototype.dbl=function(){var P=this.x.redAdd(this.z),T=P.redSqr(),W=this.x.redSub(this.z),J=W.redSqr(),H=T.redSub(J),D=T.redMul(J),E=H.redMul(J.redAdd(this.curve.a24.redMul(H)));return this.curve.point(D,E)},C.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},C.prototype.diffAdd=function(P,T){var W=this.x.redAdd(this.z),J=this.x.redSub(this.z),H=P.x.redAdd(P.z),D=P.x.redSub(P.z),E=D.redMul(W),L=H.redMul(J),M=T.z.redMul(E.redAdd(L).redSqr()),v=T.x.redMul(E.redISub(L).redSqr());return this.curve.point(M,v)},C.prototype.mul=function(P){for(var T=P.clone(),W=this,J=this.curve.point(null,null),H=this,D=[];T.cmpn(0)!==0;T.iushrn(1))D.push(T.andln(1));for(var E=D.length-1;E>=0;E--)D[E]===0?(W=W.diffAdd(J,H),J=J.dbl()):(J=W.diffAdd(J,H),W=W.dbl());return J},C.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},C.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},C.prototype.eq=function(P){return this.getX().cmp(P.getX())===0},C.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},C.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),LY=S0({"node_modules/elliptic/lib/elliptic/curve/edwards.js"(N,_){var k=E$(),j=D$(),F=B0(),z=k$(),X=k.assert;function C(T){this.twisted=(T.a|0)!==1,this.mOneA=this.twisted&&(T.a|0)===-1,this.extended=this.mOneA,z.call(this,"edwards",T),this.a=new j(T.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new j(T.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new j(T.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),X(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(T.c|0)===1}F(C,z),_.exports=C,C.prototype._mulA=function(T){return this.mOneA?T.redNeg():this.a.redMul(T)},C.prototype._mulC=function(T){return this.oneC?T:this.c.redMul(T)},C.prototype.jpoint=function(T,W,J,H){return this.point(T,W,J,H)},C.prototype.pointFromX=function(T,W){T=new j(T,16),T.red||(T=T.toRed(this.red));var J=T.redSqr(),H=this.c2.redSub(this.a.redMul(J)),D=this.one.redSub(this.c2.redMul(this.d).redMul(J)),E=H.redMul(D.redInvm()),L=E.redSqrt();if(L.redSqr().redSub(E).cmp(this.zero)!==0)throw new Error("invalid point");var M=L.fromRed().isOdd();return(W&&!M||!W&&M)&&(L=L.redNeg()),this.point(T,L)},C.prototype.pointFromY=function(T,W){T=new j(T,16),T.red||(T=T.toRed(this.red));var J=T.redSqr(),H=J.redSub(this.c2),D=J.redMul(this.d).redMul(this.c2).redSub(this.a),E=H.redMul(D.redInvm());if(E.cmp(this.zero)===0){if(W)throw new Error("invalid point");return this.point(this.zero,T)}var L=E.redSqrt();if(L.redSqr().redSub(E).cmp(this.zero)!==0)throw new Error("invalid point");return L.fromRed().isOdd()!==W&&(L=L.redNeg()),this.point(L,T)},C.prototype.validate=function(T){if(T.isInfinity())return!0;T.normalize();var W=T.x.redSqr(),J=T.y.redSqr(),H=W.redMul(this.a).redAdd(J),D=this.c2.redMul(this.one.redAdd(this.d.redMul(W).redMul(J)));return H.cmp(D)===0};function P(T,W,J,H,D){z.BasePoint.call(this,T,"projective"),W===null&&J===null&&H===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 j(W,16),this.y=new j(J,16),this.z=H?new j(H,16):this.curve.one,this.t=D&&new j(D,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()))))}F(P,z.BasePoint),C.prototype.pointFromJSON=function(T){return P.fromJSON(this,T)},C.prototype.point=function(T,W,J,H){return new P(this,T,W,J,H)},P.fromJSON=function(T,W){return new P(T,W[0],W[1],W[2])},P.prototype.inspect=function(){return this.isInfinity()?"":""},P.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},P.prototype._extDbl=function(){var T=this.x.redSqr(),W=this.y.redSqr(),J=this.z.redSqr();J=J.redIAdd(J);var H=this.curve._mulA(T),D=this.x.redAdd(this.y).redSqr().redISub(T).redISub(W),E=H.redAdd(W),L=E.redSub(J),M=H.redSub(W),v=D.redMul(L),q=E.redMul(M),g=D.redMul(M),y=L.redMul(E);return this.curve.point(v,q,y,g)},P.prototype._projDbl=function(){var T=this.x.redAdd(this.y).redSqr(),W=this.x.redSqr(),J=this.y.redSqr(),H,D,E,L,M,v;if(this.curve.twisted){L=this.curve._mulA(W);var q=L.redAdd(J);this.zOne?(H=T.redSub(W).redSub(J).redMul(q.redSub(this.curve.two)),D=q.redMul(L.redSub(J)),E=q.redSqr().redSub(q).redSub(q)):(M=this.z.redSqr(),v=q.redSub(M).redISub(M),H=T.redSub(W).redISub(J).redMul(v),D=q.redMul(L.redSub(J)),E=q.redMul(v))}else L=W.redAdd(J),M=this.curve._mulC(this.z).redSqr(),v=L.redSub(M).redSub(M),H=this.curve._mulC(T.redISub(L)).redMul(v),D=this.curve._mulC(L).redMul(W.redISub(J)),E=L.redMul(v);return this.curve.point(H,D,E)},P.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},P.prototype._extAdd=function(T){var W=this.y.redSub(this.x).redMul(T.y.redSub(T.x)),J=this.y.redAdd(this.x).redMul(T.y.redAdd(T.x)),H=this.t.redMul(this.curve.dd).redMul(T.t),D=this.z.redMul(T.z.redAdd(T.z)),E=J.redSub(W),L=D.redSub(H),M=D.redAdd(H),v=J.redAdd(W),q=E.redMul(L),g=M.redMul(v),y=E.redMul(v),w=L.redMul(M);return this.curve.point(q,g,w,y)},P.prototype._projAdd=function(T){var W=this.z.redMul(T.z),J=W.redSqr(),H=this.x.redMul(T.x),D=this.y.redMul(T.y),E=this.curve.d.redMul(H).redMul(D),L=J.redSub(E),M=J.redAdd(E),v=this.x.redAdd(this.y).redMul(T.x.redAdd(T.y)).redISub(H).redISub(D),q=W.redMul(L).redMul(v),g,y;return this.curve.twisted?(g=W.redMul(M).redMul(D.redSub(this.curve._mulA(H))),y=L.redMul(M)):(g=W.redMul(M).redMul(D.redSub(H)),y=this.curve._mulC(L).redMul(M)),this.curve.point(q,g,y)},P.prototype.add=function(T){return this.isInfinity()?T:T.isInfinity()?this:this.curve.extended?this._extAdd(T):this._projAdd(T)},P.prototype.mul=function(T){return this._hasDoubles(T)?this.curve._fixedNafMul(this,T):this.curve._wnafMul(this,T)},P.prototype.mulAdd=function(T,W,J){return this.curve._wnafMulAdd(1,[this,W],[T,J],2,!1)},P.prototype.jmulAdd=function(T,W,J){return this.curve._wnafMulAdd(1,[this,W],[T,J],2,!0)},P.prototype.normalize=function(){if(this.zOne)return this;var T=this.z.redInvm();return this.x=this.x.redMul(T),this.y=this.y.redMul(T),this.t&&(this.t=this.t.redMul(T)),this.z=this.curve.one,this.zOne=!0,this},P.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},P.prototype.getX=function(){return this.normalize(),this.x.fromRed()},P.prototype.getY=function(){return this.normalize(),this.y.fromRed()},P.prototype.eq=function(T){return this===T||this.getX().cmp(T.getX())===0&&this.getY().cmp(T.getY())===0},P.prototype.eqXToP=function(T){var W=T.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(W)===0)return!0;for(var J=T.clone(),H=this.curve.redN.redMul(this.z);;){if(J.iadd(this.curve.n),J.cmp(this.curve.p)>=0)return!1;if(W.redIAdd(H),this.x.cmp(W)===0)return!0}},P.prototype.toP=P.prototype.normalize,P.prototype.mixedAdd=P.prototype.add}}),MQ=S0({"node_modules/elliptic/lib/elliptic/curve/index.js"(N){var _=N;_.base=k$(),_.short=DY(),_.mont=CY(),_.edwards=LY()}}),T$=S0({"node_modules/hash.js/lib/hash/utils.js"(N){var _=W$(),k=B0();N.inherits=k;function j(Y,G){return(Y.charCodeAt(G)&64512)!==55296||G<0||G+1>=Y.length?!1:(Y.charCodeAt(G+1)&64512)===56320}function F(Y,G){if(Array.isArray(Y))return Y.slice();if(!Y)return[];var Z=[];if(typeof Y=="string")if(G){if(G==="hex")for(Y=Y.replace(/[^a-z0-9]+/gi,""),Y.length%2!==0&&(Y="0"+Y),I=0;I>6|192,Z[V++]=O&63|128):j(Y,I)?(O=65536+((O&1023)<<10)+(Y.charCodeAt(++I)&1023),Z[V++]=O>>18|240,Z[V++]=O>>12&63|128,Z[V++]=O>>6&63|128,Z[V++]=O&63|128):(Z[V++]=O>>12|224,Z[V++]=O>>6&63|128,Z[V++]=O&63|128)}else for(I=0;I>>24|Y>>>8&65280|Y<<8&16711680|(Y&255)<<24;return G>>>0}N.htonl=X;function C(Y,G){for(var Z="",V=0;V>>0}return O}N.join32=W;function J(Y,G){for(var Z=new Array(Y.length*4),V=0,I=0;V>>24,Z[I+1]=O>>>16&255,Z[I+2]=O>>>8&255,Z[I+3]=O&255):(Z[I+3]=O>>>24,Z[I+2]=O>>>16&255,Z[I+1]=O>>>8&255,Z[I]=O&255)}return Z}N.split32=J;function H(Y,G){return Y>>>G|Y<<32-G}N.rotr32=H;function D(Y,G){return Y<>>32-G}N.rotl32=D;function E(Y,G){return Y+G>>>0}N.sum32=E;function L(Y,G,Z){return Y+G+Z>>>0}N.sum32_3=L;function M(Y,G,Z,V){return Y+G+Z+V>>>0}N.sum32_4=M;function v(Y,G,Z,V,I){return Y+G+Z+V+I>>>0}N.sum32_5=v;function q(Y,G,Z,V){var I=Y[G],O=Y[G+1],U=V+O>>>0,Q=(U>>0,Y[G+1]=U}N.sum64=q;function g(Y,G,Z,V){var I=G+V>>>0,O=(I>>0}N.sum64_hi=g;function y(Y,G,Z,V){var I=G+V;return I>>>0}N.sum64_lo=y;function w(Y,G,Z,V,I,O,U,Q){var K=0,R=G;R=R+V>>>0,K+=R>>0,K+=R>>0,K+=R>>0}N.sum64_4_hi=w;function f(Y,G,Z,V,I,O,U,Q){var K=G+V+O+Q;return K>>>0}N.sum64_4_lo=f;function b(Y,G,Z,V,I,O,U,Q,K,R){var A=0,S=G;S=S+V>>>0,A+=S>>0,A+=S>>0,A+=S>>0,A+=S>>0}N.sum64_5_hi=b;function u(Y,G,Z,V,I,O,U,Q,K,R){var A=G+V+O+Q+R;return A>>>0}N.sum64_5_lo=u;function Y0(Y,G,Z){var V=G<<32-Z|Y>>>Z;return V>>>0}N.rotr64_hi=Y0;function p(Y,G,Z){var V=Y<<32-Z|G>>>Z;return V>>>0}N.rotr64_lo=p;function v0(Y,G,Z){return Y>>>Z}N.shr64_hi=v0;function $(Y,G,Z){var V=Y<<32-Z|G>>>Z;return V>>>0}N.shr64_lo=$}}),v$=S0({"node_modules/hash.js/lib/hash/common.js"(N){var _=T$(),k=W$();function j(){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}N.BlockHash=j,j.prototype.update=function(F,z){if(F=_.toArray(F,z),this.pending?this.pending=this.pending.concat(F):this.pending=F,this.pendingTotal+=F.length,this.pending.length>=this._delta8){F=this.pending;var X=F.length%this._delta8;this.pending=F.slice(F.length-X,F.length),this.pending.length===0&&(this.pending=null),F=_.join32(F,0,F.length-X,this.endian);for(var C=0;C>>24&255,C[P++]=F>>>16&255,C[P++]=F>>>8&255,C[P++]=F&255}else for(C[P++]=F&255,C[P++]=F>>>8&255,C[P++]=F>>>16&255,C[P++]=F>>>24&255,C[P++]=0,C[P++]=0,C[P++]=0,C[P++]=0,T=8;T>>3}N.g0_256=T;function W(J){return k(J,17)^k(J,19)^J>>>10}N.g1_256=W}}),RY=S0({"node_modules/hash.js/lib/hash/sha/1.js"(N,_){var k=T$(),j=v$(),F=SQ(),z=k.rotl32,X=k.sum32,C=k.sum32_5,P=F.ft_1,T=j.BlockHash,W=[1518500249,1859775393,2400959708,3395469782];function J(){if(!(this instanceof J))return new J;T.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}k.inherits(J,T),_.exports=J,J.blockSize=512,J.outSize=160,J.hmacStrength=80,J.padLength=64,J.prototype._update=function(H,D){for(var E=this.W,L=0;L<16;L++)E[L]=H[D+L];for(;Lthis.blockSize&&(z=new this.Hash().update(z).digest()),j(z.length<=this.blockSize);for(var X=z.length;X=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(C,P,T)}_.exports=z,z.prototype._init=function(X,C,P){var T=X.concat(C).concat(P);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var W=0;W=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(X.concat(P||[])),this._reseed=1},z.prototype.generate=function(X,C,P,T){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof C!="string"&&(T=P,P=C,C=null),P&&(P=j.toArray(P,T||"hex"),this._update(P));for(var W=[];W.length"}}}),gY=S0({"node_modules/elliptic/lib/elliptic/ec/signature.js"(N,_){var k=D$(),j=E$(),F=j.assert;function z(W,J){if(W instanceof z)return W;this._importDER(W,J)||(F(W.r&&W.s,"Signature without r or s"),this.r=new k(W.r,16),this.s=new k(W.s,16),W.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=W.recoveryParam)}_.exports=z;function X(){this.place=0}function C(W,J){var H=W[J.place++];if(!(H&128))return H;var D=H&15;if(D===0||D>4)return!1;for(var E=0,L=0,M=J.place;L>>=0;return E<=127?!1:(J.place=M,E)}function P(W){for(var J=0,H=W.length-1;!W[J]&&!(W[J+1]&128)&&J>>3);for(W.push(H|128);--H;)W.push(J>>>(H<<3)&255);W.push(J)}z.prototype.toDER=function(W){var J=this.r.toArray(),H=this.s.toArray();for(J[0]&128&&(J=[0].concat(J)),H[0]&128&&(H=[0].concat(H)),J=P(J),H=P(H);!H[0]&&!(H[1]&128);)H=H.slice(1);var D=[2];T(D,J.length),D=D.concat(J),D.push(2),T(D,H.length);var E=D.concat(H),L=[48];return T(L,E.length),L=L.concat(E),j.encode(L,W)}}}),_Y=S0({"node_modules/elliptic/lib/elliptic/ec/index.js"(N,_){var k=D$(),j=jY(),F=E$(),z=b$(),X=f$(),C=F.assert,P=kY(),T=gY();function W(J){if(!(this instanceof W))return new W(J);typeof J=="string"&&(C(Object.prototype.hasOwnProperty.call(z,J),"Unknown curve "+J),J=z[J]),J instanceof z.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=W,W.prototype.keyPair=function(J){return new P(this,J)},W.prototype.keyFromPrivate=function(J,H){return P.fromPrivate(this,J,H)},W.prototype.keyFromPublic=function(J,H){return P.fromPublic(this,J,H)},W.prototype.genKeyPair=function(J){J||(J={});for(var H=new j({hash:this.hash,pers:J.pers,persEnc:J.persEnc||"utf8",entropy:J.entropy||X(this.hash.hmacStrength),entropyEnc:J.entropy&&J.entropyEnc||"utf8",nonce:this.n.toArray()}),D=this.n.byteLength(),E=this.n.sub(new k(2));;){var L=new k(H.generate(D));if(!(L.cmp(E)>0))return L.iaddn(1),this.keyFromPrivate(L)}},W.prototype._truncateToN=function(J,H){var D=J.byteLength()*8-this.n.bitLength();return D>0&&(J=J.ushrn(D)),!H&&J.cmp(this.n)>=0?J.sub(this.n):J},W.prototype.sign=function(J,H,D,E){typeof D=="object"&&(E=D,D=null),E||(E={}),H=this.keyFromPrivate(H,D),J=this._truncateToN(new k(J,16));for(var L=this.n.byteLength(),M=H.getPrivate().toArray("be",L),v=J.toArray("be",L),q=new j({hash:this.hash,entropy:M,nonce:v,pers:E.pers,persEnc:E.persEnc||"utf8"}),g=this.n.sub(new k(1)),y=0;;y++){var w=E.k?E.k(y):new k(q.generate(this.n.byteLength()));if(w=this._truncateToN(w,!0),!(w.cmpn(1)<=0||w.cmp(g)>=0)){var f=this.g.mul(w);if(!f.isInfinity()){var b=f.getX(),u=b.umod(this.n);if(u.cmpn(0)!==0){var Y0=w.invm(this.n).mul(u.mul(H.getPrivate()).iadd(J));if(Y0=Y0.umod(this.n),Y0.cmpn(0)!==0){var p=(f.getY().isOdd()?1:0)|(b.cmp(u)!==0?2:0);return E.canonical&&Y0.cmp(this.nh)>0&&(Y0=this.n.sub(Y0),p^=1),new T({r:u,s:Y0,recoveryParam:p})}}}}}},W.prototype.verify=function(J,H,D,E){J=this._truncateToN(new k(J,16)),D=this.keyFromPublic(D,E),H=new T(H,"hex");var{r:L,s:M}=H;if(L.cmpn(1)<0||L.cmp(this.n)>=0||M.cmpn(1)<0||M.cmp(this.n)>=0)return!1;var v=M.invm(this.n),q=v.mul(J).umod(this.n),g=v.mul(L).umod(this.n),y;return this.curve._maxwellTrick?(y=this.g.jmulAdd(q,D.getPublic(),g),y.isInfinity()?!1:y.eqXToP(L)):(y=this.g.mulAdd(q,D.getPublic(),g),y.isInfinity()?!1:y.getX().umod(this.n).cmp(L)===0)},W.prototype.recoverPubKey=function(J,H,D,E){C((3&D)===D,"The recovery param is more than two bits"),H=new T(H,E);var L=this.n,M=new k(J),v=H.r,q=H.s,g=D&1,y=D>>1;if(v.cmp(this.curve.p.umod(this.curve.n))>=0&&y)throw new Error("Unable to find sencond key candinate");y?v=this.curve.pointFromX(v.add(this.curve.n),g):v=this.curve.pointFromX(v,g);var w=H.r.invm(L),f=L.sub(M).mul(w).umod(L),b=q.mul(w).umod(L);return this.g.mulAdd(f,v,b)},W.prototype.getKeyRecoveryParam=function(J,H,D,E){if(H=new T(H,E),H.recoveryParam!==null)return H.recoveryParam;for(var L=0;L<4;L++){var M;try{M=this.recoverPubKey(J,H,L)}catch{continue}if(M.eq(D))return L}throw new Error("Unable to find valid recovery factor")}}}),NY=S0({"node_modules/elliptic/lib/elliptic/eddsa/key.js"(N,_){var k=E$(),j=k.assert,F=k.parseBytes,z=k.cachedProperty;function X(C,P){this.eddsa=C,this._secret=F(P.secret),C.isPoint(P.pub)?this._pub=P.pub:this._pubBytes=F(P.pub)}X.fromPublic=function(C,P){return P instanceof X?P:new X(C,{pub:P})},X.fromSecret=function(C,P){return P instanceof X?P:new X(C,{secret:P})},X.prototype.secret=function(){return this._secret},z(X,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),z(X,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),z(X,"privBytes",function(){var C=this.eddsa,P=this.hash(),T=C.encodingLength-1,W=P.slice(0,C.encodingLength);return W[0]&=248,W[T]&=127,W[T]|=64,W}),z(X,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),z(X,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),z(X,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),X.prototype.sign=function(C){return j(this._secret,"KeyPair can only verify"),this.eddsa.sign(C,this)},X.prototype.verify=function(C,P){return this.eddsa.verify(C,P,this)},X.prototype.getSecret=function(C){return j(this._secret,"KeyPair is public only"),k.encode(this.secret(),C)},X.prototype.getPublic=function(C){return k.encode(this.pubBytes(),C)},_.exports=X}}),xY=S0({"node_modules/elliptic/lib/elliptic/eddsa/signature.js"(N,_){var k=D$(),j=E$(),F=j.assert,z=j.cachedProperty,X=j.parseBytes;function C(P,T){this.eddsa=P,typeof T!="object"&&(T=X(T)),Array.isArray(T)&&(T={R:T.slice(0,P.encodingLength),S:T.slice(P.encodingLength)}),F(T.R&&T.S,"Signature without R or S"),P.isPoint(T.R)&&(this._R=T.R),T.S instanceof k&&(this._S=T.S),this._Rencoded=Array.isArray(T.R)?T.R:T.Rencoded,this._Sencoded=Array.isArray(T.S)?T.S:T.Sencoded}z(C,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),z(C,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),z(C,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),z(C,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),C.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},C.prototype.toHex=function(){return j.encode(this.toBytes(),"hex").toUpperCase()},_.exports=C}}),BY=S0({"node_modules/elliptic/lib/elliptic/eddsa/index.js"(N,_){var k=d$(),j=b$(),F=E$(),z=F.assert,X=F.parseBytes,C=NY(),P=xY();function T(W){if(z(W==="ed25519","only tested with ed25519 so far"),!(this instanceof T))return new T(W);W=j[W].curve,this.curve=W,this.g=W.g,this.g.precompute(W.n.bitLength()+1),this.pointClass=W.point().constructor,this.encodingLength=Math.ceil(W.n.bitLength()/8),this.hash=k.sha512}_.exports=T,T.prototype.sign=function(W,J){W=X(W);var H=this.keyFromSecret(J),D=this.hashInt(H.messagePrefix(),W),E=this.g.mul(D),L=this.encodePoint(E),M=this.hashInt(L,H.pubBytes(),W).mul(H.priv()),v=D.add(M).umod(this.curve.n);return this.makeSignature({R:E,S:v,Rencoded:L})},T.prototype.verify=function(W,J,H){W=X(W),J=this.makeSignature(J);var D=this.keyFromPublic(H),E=this.hashInt(J.Rencoded(),D.pubBytes(),W),L=this.g.mul(J.S()),M=J.R().add(D.pub().mul(E));return M.eq(L)},T.prototype.hashInt=function(){for(var W=this.hash(),J=0;J0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),o$=S0({"node_modules/safer-buffer/safer.js"(N,_){var k=r$,j=g0,F={},z;for(z in k)!k.hasOwnProperty(z)||z==="SlowBuffer"||z==="Buffer"||(F[z]=k[z]);var X=F.Buffer={};for(z in j)!j.hasOwnProperty(z)||z==="allocUnsafe"||z==="allocUnsafeSlow"||(X[z]=j[z]);if(F.Buffer.prototype=j.prototype,(!X.from||X.from===Uint8Array.from)&&(X.from=function(C,P,T){if(typeof C=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof C);if(C&&typeof C.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof C);return j(C,P,T)}),X.alloc||(X.alloc=function(C,P,T){if(typeof C!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof C);if(C<0||C>=2*(1<<30))throw new RangeError('The value "'+C+'" is invalid for option "size"');var W=j(C);return!P||P.length===0?W.fill(0):typeof T=="string"?W.fill(P,T):W.fill(P),W}),!F.kStringMaxLength)try{F.kStringMaxLength=lQ}catch{}F.constants||(F.constants={MAX_LENGTH:F.kMaxLength},F.kStringMaxLength&&(F.constants.MAX_STRING_LENGTH=F.kStringMaxLength)),_.exports=F}}),u$=S0({"node_modules/asn1.js/lib/asn1/base/reporter.js"(N){var _=B0();function k(F){this._reporterState={obj:null,path:[],options:F||{},errors:[]}}N.Reporter=k,k.prototype.isError=function(F){return F instanceof j},k.prototype.save=function(){let F=this._reporterState;return{obj:F.obj,pathLen:F.path.length}},k.prototype.restore=function(F){let z=this._reporterState;z.obj=F.obj,z.path=z.path.slice(0,F.pathLen)},k.prototype.enterKey=function(F){return this._reporterState.path.push(F)},k.prototype.exitKey=function(F){let z=this._reporterState;z.path=z.path.slice(0,F-1)},k.prototype.leaveKey=function(F,z,X){let C=this._reporterState;this.exitKey(F),C.obj!==null&&(C.obj[z]=X)},k.prototype.path=function(){return this._reporterState.path.join("/")},k.prototype.enterObject=function(){let F=this._reporterState,z=F.obj;return F.obj={},z},k.prototype.leaveObject=function(F){let z=this._reporterState,X=z.obj;return z.obj=F,X},k.prototype.error=function(F){let z,X=this._reporterState,C=F instanceof j;if(C?z=F:z=new j(X.path.map(function(P){return"["+JSON.stringify(P)+"]"}).join(""),F.message||F,F.stack),!X.options.partial)throw z;return C||X.errors.push(z),z},k.prototype.wrapResult=function(F){let z=this._reporterState;return z.options.partial?{result:this.isError(F)?null:F,errors:z.errors}:F};function j(F,z){this.path=F,this.rethrow(z)}_(j,Error),j.prototype.rethrow=function(F){if(this.message=F+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,j),!this.stack)try{throw new Error(this.message)}catch(z){this.stack=z.stack}return this}}}),P$=S0({"node_modules/asn1.js/lib/asn1/base/buffer.js"(N){var _=B0(),k=u$().Reporter,j=o$().Buffer;function F(X,C){if(k.call(this,C),!j.isBuffer(X)){this.error("Input not Buffer");return}this.base=X,this.offset=0,this.length=X.length}_(F,k),N.DecoderBuffer=F,F.isDecoderBuffer=function(X){return X instanceof F?!0:typeof X=="object"&&j.isBuffer(X.base)&&X.constructor.name==="DecoderBuffer"&&typeof X.offset=="number"&&typeof X.length=="number"&&typeof X.save=="function"&&typeof X.restore=="function"&&typeof X.isEmpty=="function"&&typeof X.readUInt8=="function"&&typeof X.skip=="function"&&typeof X.raw=="function"},F.prototype.save=function(){return{offset:this.offset,reporter:k.prototype.save.call(this)}},F.prototype.restore=function(X){let C=new F(this.base);return C.offset=X.offset,C.length=this.offset,this.offset=X.offset,k.prototype.restore.call(this,X.reporter),C},F.prototype.isEmpty=function(){return this.offset===this.length},F.prototype.readUInt8=function(X){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(X||"DecoderBuffer overrun")},F.prototype.skip=function(X,C){if(!(this.offset+X<=this.length))return this.error(C||"DecoderBuffer overrun");let P=new F(this.base);return P._reporterState=this._reporterState,P.offset=this.offset,P.length=this.offset+X,this.offset+=X,P},F.prototype.raw=function(X){return this.base.slice(X?X.offset:this.offset,this.length)};function z(X,C){if(Array.isArray(X))this.length=0,this.value=X.map(function(P){return z.isEncoderBuffer(P)||(P=new z(P,C)),this.length+=P.length,P},this);else if(typeof X=="number"){if(!(0<=X&&X<=255))return C.error("non-byte EncoderBuffer value");this.value=X,this.length=1}else if(typeof X=="string")this.value=X,this.length=j.byteLength(X);else if(j.isBuffer(X))this.value=X,this.length=X.length;else return C.error("Unsupported type: "+typeof X)}N.EncoderBuffer=z,z.isEncoderBuffer=function(X){return X instanceof z?!0:typeof X=="object"&&X.constructor.name==="EncoderBuffer"&&typeof X.length=="number"&&typeof X.join=="function"},z.prototype.join=function(X,C){return X||(X=j.alloc(this.length)),C||(C=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(P){P.join(X,C),C+=P.length}):(typeof this.value=="number"?X[C]=this.value:typeof this.value=="string"?X.write(this.value,C):j.isBuffer(this.value)&&this.value.copy(X,C),C+=this.length)),X}}}),n$=S0({"node_modules/asn1.js/lib/asn1/base/node.js"(N,_){var k=u$().Reporter,j=P$().EncoderBuffer,F=P$().DecoderBuffer,z=W$(),X=["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"],C=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(X),P=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function T(J,H,D){let E={};this._baseState=E,E.name=D,E.enc=J,E.parent=H||null,E.children=null,E.tag=null,E.args=null,E.reverseArgs=null,E.choice=null,E.optional=!1,E.any=!1,E.obj=!1,E.use=null,E.useDecoder=null,E.key=null,E.default=null,E.explicit=null,E.implicit=null,E.contains=null,E.parent||(E.children=[],this._wrap())}_.exports=T;var W=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];T.prototype.clone=function(){let J=this._baseState,H={};W.forEach(function(E){H[E]=J[E]});let D=new this.constructor(H.parent);return D._baseState=H,D},T.prototype._wrap=function(){let J=this._baseState;C.forEach(function(H){this[H]=function(){let D=new this.constructor(this);return J.children.push(D),D[H].apply(D,arguments)}},this)},T.prototype._init=function(J){let H=this._baseState;z(H.parent===null),J.call(this),H.children=H.children.filter(function(D){return D._baseState.parent===this},this),z.equal(H.children.length,1,"Root node can have only one child")},T.prototype._useArgs=function(J){let H=this._baseState,D=J.filter(function(E){return E instanceof this.constructor},this);J=J.filter(function(E){return!(E instanceof this.constructor)},this),D.length!==0&&(z(H.children===null),H.children=D,D.forEach(function(E){E._baseState.parent=this},this)),J.length!==0&&(z(H.args===null),H.args=J,H.reverseArgs=J.map(function(E){if(typeof E!="object"||E.constructor!==Object)return E;let L={};return Object.keys(E).forEach(function(M){M==(M|0)&&(M|=0);let v=E[M];L[v]=M}),L}))},P.forEach(function(J){T.prototype[J]=function(){let H=this._baseState;throw new Error(J+" not implemented for encoding: "+H.enc)}}),X.forEach(function(J){T.prototype[J]=function(){let H=this._baseState,D=Array.prototype.slice.call(arguments);return z(H.tag===null),H.tag=J,this._useArgs(D),this}}),T.prototype.use=function(J){z(J);let H=this._baseState;return z(H.use===null),H.use=J,this},T.prototype.optional=function(){let J=this._baseState;return J.optional=!0,this},T.prototype.def=function(J){let H=this._baseState;return z(H.default===null),H.default=J,H.optional=!0,this},T.prototype.explicit=function(J){let H=this._baseState;return z(H.explicit===null&&H.implicit===null),H.explicit=J,this},T.prototype.implicit=function(J){let H=this._baseState;return z(H.explicit===null&&H.implicit===null),H.implicit=J,this},T.prototype.obj=function(){let J=this._baseState,H=Array.prototype.slice.call(arguments);return J.obj=!0,H.length!==0&&this._useArgs(H),this},T.prototype.key=function(J){let H=this._baseState;return z(H.key===null),H.key=J,this},T.prototype.any=function(){let J=this._baseState;return J.any=!0,this},T.prototype.choice=function(J){let H=this._baseState;return z(H.choice===null),H.choice=J,this._useArgs(Object.keys(J).map(function(D){return J[D]})),this},T.prototype.contains=function(J){let H=this._baseState;return z(H.use===null),H.contains=J,this},T.prototype._decode=function(J,H){let D=this._baseState;if(D.parent===null)return J.wrapResult(D.children[0]._decode(J,H));let E=D.default,L=!0,M=null;if(D.key!==null&&(M=J.enterKey(D.key)),D.optional){let q=null;if(D.explicit!==null?q=D.explicit:D.implicit!==null?q=D.implicit:D.tag!==null&&(q=D.tag),q===null&&!D.any){let g=J.save();try{D.choice===null?this._decodeGeneric(D.tag,J,H):this._decodeChoice(J,H),L=!0}catch{L=!1}J.restore(g)}else if(L=this._peekTag(J,q,D.any),J.isError(L))return L}let v;if(D.obj&&L&&(v=J.enterObject()),L){if(D.explicit!==null){let g=this._decodeTag(J,D.explicit);if(J.isError(g))return g;J=g}let q=J.offset;if(D.use===null&&D.choice===null){let g;D.any&&(g=J.save());let y=this._decodeTag(J,D.implicit!==null?D.implicit:D.tag,D.any);if(J.isError(y))return y;D.any?E=J.raw(g):J=y}if(H&&H.track&&D.tag!==null&&H.track(J.path(),q,J.length,"tagged"),H&&H.track&&D.tag!==null&&H.track(J.path(),J.offset,J.length,"content"),D.any||(D.choice===null?E=this._decodeGeneric(D.tag,J,H):E=this._decodeChoice(J,H)),J.isError(E))return E;if(!D.any&&D.choice===null&&D.children!==null&&D.children.forEach(function(g){g._decode(J,H)}),D.contains&&(D.tag==="octstr"||D.tag==="bitstr")){let g=new F(E);E=this._getUse(D.contains,J._reporterState.obj)._decode(g,H)}}return D.obj&&L&&(E=J.leaveObject(v)),D.key!==null&&(E!==null||L===!0)?J.leaveKey(M,D.key,E):M!==null&&J.exitKey(M),E},T.prototype._decodeGeneric=function(J,H,D){let E=this._baseState;return J==="seq"||J==="set"?null:J==="seqof"||J==="setof"?this._decodeList(H,J,E.args[0],D):/str$/.test(J)?this._decodeStr(H,J,D):J==="objid"&&E.args?this._decodeObjid(H,E.args[0],E.args[1],D):J==="objid"?this._decodeObjid(H,null,null,D):J==="gentime"||J==="utctime"?this._decodeTime(H,J,D):J==="null_"?this._decodeNull(H,D):J==="bool"?this._decodeBool(H,D):J==="objDesc"?this._decodeStr(H,J,D):J==="int"||J==="enum"?this._decodeInt(H,E.args&&E.args[0],D):E.use!==null?this._getUse(E.use,H._reporterState.obj)._decode(H,D):H.error("unknown tag: "+J)},T.prototype._getUse=function(J,H){let D=this._baseState;return D.useDecoder=this._use(J,H),z(D.useDecoder._baseState.parent===null),D.useDecoder=D.useDecoder._baseState.children[0],D.implicit!==D.useDecoder._baseState.implicit&&(D.useDecoder=D.useDecoder.clone(),D.useDecoder._baseState.implicit=D.implicit),D.useDecoder},T.prototype._decodeChoice=function(J,H){let D=this._baseState,E=null,L=!1;return Object.keys(D.choice).some(function(M){let v=J.save(),q=D.choice[M];try{let g=q._decode(J,H);if(J.isError(g))return!1;E={type:M,value:g},L=!0}catch{return J.restore(v),!1}return!0},this),L?E:J.error("Choice not matched")},T.prototype._createEncoderBuffer=function(J){return new j(J,this.reporter)},T.prototype._encode=function(J,H,D){let E=this._baseState;if(E.default!==null&&E.default===J)return;let L=this._encodeValue(J,H,D);if(L!==void 0&&!this._skipDefault(L,H,D))return L},T.prototype._encodeValue=function(J,H,D){let E=this._baseState;if(E.parent===null)return E.children[0]._encode(J,H||new k);let L=null;if(this.reporter=H,E.optional&&J===void 0)if(E.default!==null)J=E.default;else return;let M=null,v=!1;if(E.any)L=this._createEncoderBuffer(J);else if(E.choice)L=this._encodeChoice(J,H);else if(E.contains)M=this._getUse(E.contains,D)._encode(J,H),v=!0;else if(E.children)M=E.children.map(function(q){if(q._baseState.tag==="null_")return q._encode(null,H,J);if(q._baseState.key===null)return H.error("Child should have a key");let g=H.enterKey(q._baseState.key);if(typeof J!="object")return H.error("Child expected, but input is not object");let y=q._encode(J[q._baseState.key],H,J);return H.leaveKey(g),y},this).filter(function(q){return q}),M=this._createEncoderBuffer(M);else if(E.tag==="seqof"||E.tag==="setof"){if(!(E.args&&E.args.length===1))return H.error("Too many args for : "+E.tag);if(!Array.isArray(J))return H.error("seqof/setof, but data is not Array");let q=this.clone();q._baseState.implicit=null,M=this._createEncoderBuffer(J.map(function(g){let y=this._baseState;return this._getUse(y.args[0],J)._encode(g,H)},q))}else E.use!==null?L=this._getUse(E.use,D)._encode(J,H):(M=this._encodePrimitive(E.tag,J),v=!0);if(!E.any&&E.choice===null){let q=E.implicit!==null?E.implicit:E.tag,g=E.implicit===null?"universal":"context";q===null?E.use===null&&H.error("Tag could be omitted only for .use()"):E.use===null&&(L=this._encodeComposite(q,v,g,M))}return E.explicit!==null&&(L=this._encodeComposite(E.explicit,!1,"context",L)),L},T.prototype._encodeChoice=function(J,H){let D=this._baseState,E=D.choice[J.type];return E||z(!1,J.type+" not found in "+JSON.stringify(Object.keys(D.choice))),E._encode(J.value,H)},T.prototype._encodePrimitive=function(J,H){let D=this._baseState;if(/str$/.test(J))return this._encodeStr(H,J);if(J==="objid"&&D.args)return this._encodeObjid(H,D.reverseArgs[0],D.args[1]);if(J==="objid")return this._encodeObjid(H,null,null);if(J==="gentime"||J==="utctime")return this._encodeTime(H,J);if(J==="null_")return this._encodeNull();if(J==="int"||J==="enum")return this._encodeInt(H,D.args&&D.reverseArgs[0]);if(J==="bool")return this._encodeBool(H);if(J==="objDesc")return this._encodeStr(H,J);throw new Error("Unsupported tag: "+J)},T.prototype._isNumstr=function(J){return/^[0-9 ]*$/.test(J)},T.prototype._isPrintstr=function(J){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(J)}}}),s$=S0({"node_modules/asn1.js/lib/asn1/constants/der.js"(N){function _(k){let j={};return Object.keys(k).forEach(function(F){(F|0)==F&&(F=F|0);let z=k[F];j[z]=F}),j}N.tagClass={0:"universal",1:"application",2:"context",3:"private"},N.tagClassByName=_(N.tagClass),N.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"},N.tagByName=_(N.tag)}}),kQ=S0({"node_modules/asn1.js/lib/asn1/encoders/der.js"(N,_){var k=B0(),j=o$().Buffer,F=n$(),z=s$();function X(W){this.enc="der",this.name=W.name,this.entity=W,this.tree=new C,this.tree._init(W.body)}_.exports=X,X.prototype.encode=function(W,J){return this.tree._encode(W,J).join()};function C(W){F.call(this,"der",W)}k(C,F),C.prototype._encodeComposite=function(W,J,H,D){let E=T(W,J,H,this.reporter);if(D.length<128){let v=j.alloc(2);return v[0]=E,v[1]=D.length,this._createEncoderBuffer([v,D])}let L=1;for(let v=D.length;v>=256;v>>=8)L++;let M=j.alloc(2+L);M[0]=E,M[1]=128|L;for(let v=1+L,q=D.length;q>0;v--,q>>=8)M[v]=q&255;return this._createEncoderBuffer([M,D])},C.prototype._encodeStr=function(W,J){if(J==="bitstr")return this._createEncoderBuffer([W.unused|0,W.data]);if(J==="bmpstr"){let H=j.alloc(W.length*2);for(let D=0;D=40)return this.reporter.error("Second objid identifier OOB");W.splice(0,2,W[0]*40+W[1])}let D=0;for(let M=0;M=128;v>>=7)D++}let E=j.alloc(D),L=E.length-1;for(let M=W.length-1;M>=0;M--){let v=W[M];for(E[L--]=v&127;(v>>=7)>0;)E[L--]=128|v&127}return this._createEncoderBuffer(E)};function P(W){return W<10?"0"+W:W}C.prototype._encodeTime=function(W,J){let H,D=new Date(W);return J==="gentime"?H=[P(D.getUTCFullYear()),P(D.getUTCMonth()+1),P(D.getUTCDate()),P(D.getUTCHours()),P(D.getUTCMinutes()),P(D.getUTCSeconds()),"Z"].join(""):J==="utctime"?H=[P(D.getUTCFullYear()%100),P(D.getUTCMonth()+1),P(D.getUTCDate()),P(D.getUTCHours()),P(D.getUTCMinutes()),P(D.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+J+" time is not supported yet"),this._encodeStr(H,"octstr")},C.prototype._encodeNull=function(){return this._createEncoderBuffer("")},C.prototype._encodeInt=function(W,J){if(typeof W=="string"){if(!J)return this.reporter.error("String int or enum given, but no values map");if(!J.hasOwnProperty(W))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(W));W=J[W]}if(typeof W!="number"&&!j.isBuffer(W)){let E=W.toArray();!W.sign&&E[0]&128&&E.unshift(0),W=j.from(E)}if(j.isBuffer(W)){let E=W.length;W.length===0&&E++;let L=j.alloc(E);return W.copy(L),W.length===0&&(L[0]=0),this._createEncoderBuffer(L)}if(W<128)return this._createEncoderBuffer(W);if(W<256)return this._createEncoderBuffer([0,W]);let H=1;for(let E=W;E>=256;E>>=8)H++;let D=new Array(H);for(let E=D.length-1;E>=0;E--)D[E]=W&255,W>>=8;return D[0]&128&&D.unshift(0),this._createEncoderBuffer(j.from(D))},C.prototype._encodeBool=function(W){return this._createEncoderBuffer(W?255:0)},C.prototype._use=function(W,J){return typeof W=="function"&&(W=W(J)),W._getEncoder("der").tree},C.prototype._skipDefault=function(W,J,H){let D=this._baseState,E;if(D.default===null)return!1;let L=W.join();if(D.defaultBuffer===void 0&&(D.defaultBuffer=this._encodeValue(D.default,J,H).join()),L.length!==D.defaultBuffer.length)return!1;for(E=0;E=31?D.error("Multi-octet tag encoding unsupported"):(J||(E|=32),E|=z.tagClassByName[H||"universal"]<<6,E)}}}),yY=S0({"node_modules/asn1.js/lib/asn1/encoders/pem.js"(N,_){var k=B0(),j=kQ();function F(z){j.call(this,z),this.enc="pem"}k(F,j),_.exports=F,F.prototype.encode=function(z,X){let C=j.prototype.encode.call(this,z).toString("base64"),P=["-----BEGIN "+X.label+"-----"];for(let T=0;T>6],L=(D&32)===0;if((D&31)===31){let v=D;for(D=0;(v&128)===128;){if(v=J.readUInt8(H),J.isError(v))return v;D<<=7,D|=v&127}}else D&=31;let M=X.tag[D];return{cls:E,primitive:L,tag:D,tagStr:M}}function W(J,H,D){let E=J.readUInt8(D);if(J.isError(E))return E;if(!H&&E===128)return null;if((E&128)===0)return E;let L=E&127;if(L>4)return J.error("length octect is too long");E=0;for(let M=0;M0&&y.ishrn(w),y}function L(q,g){q=E(q,g),q=q.mod(g);var y=k.from(q.toArray());if(y.length=H)throw new Error("invalid sig")}_.exports=C}}),nY=S0({"node_modules/browserify-sign/browser/index.js"(N,_){var k=N0().Buffer,j=M$(),F=B0(),z=oY(),X=uY(),C=KQ();Object.keys(C).forEach(function(H){C[H].id=k.from(C[H].id,"hex"),C[H.toLowerCase()]=C[H]});function P(H){A$.Writable.call(this);var D=C[H];if(!D)throw new Error("Unknown message digest");this._hashType=D.hash,this._hash=j(D.hash),this._tag=D.id,this._signType=D.sign}F(P,A$.Writable),P.prototype._write=function(H,D,E){this._hash.update(H),E()},P.prototype.update=function(H,D){return typeof H=="string"&&(H=k.from(H,D)),this._hash.update(H),this},P.prototype.sign=function(H,D){this.end();var E=this._hash.digest(),L=z(E,H,this._hashType,this._signType,this._tag);return D?L.toString(D):L};function T(H){A$.Writable.call(this);var D=C[H];if(!D)throw new Error("Unknown message digest");this._hash=j(D.hash),this._tag=D.id,this._signType=D.sign}F(T,A$.Writable),T.prototype._write=function(H,D,E){this._hash.update(H),E()},T.prototype.update=function(H,D){return typeof H=="string"&&(H=k.from(H,D)),this._hash.update(H),this},T.prototype.verify=function(H,D,E){typeof D=="string"&&(D=k.from(D,E)),this.end();var L=this._hash.digest();return X(D,L,H,this._signType,this._tag)};function W(H){return new P(H)}function J(H){return new T(H)}_.exports={Sign:W,Verify:J,createSign:W,createVerify:J}}}),sY=S0({"node_modules/create-ecdh/node_modules/bn.js/lib/bn.js"(N,_){(function(k,j){function F($,Y){if(!$)throw new Error(Y||"Assertion failed")}function z($,Y){$.super_=Y;var G=function(){};G.prototype=Y.prototype,$.prototype=new G,$.prototype.constructor=$}function X($,Y,G){if(X.isBN($))return $;this.negative=0,this.words=null,this.length=0,this.red=null,$!==null&&((Y==="le"||Y==="be")&&(G=Y,Y=10),this._init($||0,Y||10,G||"be"))}typeof k=="object"?k.exports=X:j.BN=X,X.BN=X,X.wordSize=26;var C=g0;X.isBN=function($){return $ instanceof X?!0:$!==null&&typeof $=="object"&&$.constructor.wordSize===X.wordSize&&Array.isArray($.words)},X.max=function($,Y){return $.cmp(Y)>0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),tY=S0({"node_modules/create-ecdh/browser.js"(N,_){var k=l$(),j=sY();_.exports=function(C){return new z(C)};var F={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}};F.p224=F.secp224r1,F.p256=F.secp256r1=F.prime256v1,F.p192=F.secp192r1=F.prime192v1,F.p384=F.secp384r1,F.p521=F.secp521r1;function z(C){this.curveType=F[C],this.curveType||(this.curveType={name:C}),this.curve=new k.ec(this.curveType.name),this.keys=void 0}z.prototype.generateKeys=function(C,P){return this.keys=this.curve.genKeyPair(),this.getPublicKey(C,P)},z.prototype.computeSecret=function(C,P,T){P=P||"utf8",g0.isBuffer(C)||(C=new g0(C,P));var W=this.curve.keyFromPublic(C).getPublic(),J=W.mul(this.keys.getPrivate()).getX();return X(J,T,this.curveType.byteLength)},z.prototype.getPublicKey=function(C,P){var T=this.keys.getPublic(P==="compressed",!0);return P==="hybrid"&&(T[T.length-1]%2?T[0]=7:T[0]=6),X(T,C)},z.prototype.getPrivateKey=function(C){return X(this.keys.getPrivate(),C)},z.prototype.setPublicKey=function(C,P){return P=P||"utf8",g0.isBuffer(C)||(C=new g0(C,P)),this.keys._importPublic(C),this},z.prototype.setPrivateKey=function(C,P){P=P||"utf8",g0.isBuffer(C)||(C=new g0(C,P));var T=new j(C);return T=T.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(T),this};function X(C,P,T){Array.isArray(C)||(C=C.toArray());var W=new g0(C);if(T&&W.length0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),{CryptoHasher:mY}=globalThis.Bun,pQ=S0({"node_modules/public-encrypt/withPublic.js"(N,_){var k=t$(),j=N0().Buffer;function F(z,X){return j.from(z.toRed(k.mont(X.modulus)).redPow(new k(X.publicExponent)).fromRed().toArray())}_.exports=F}}),aY=S0({"node_modules/public-encrypt/publicEncrypt.js"(N,_){var k=g$(),j=L$(),F=M$(),z=yQ(),X=wQ(),C=t$(),P=pQ(),T=h$(),W=N0().Buffer;_.exports=function(E,L,M){var v;E.padding?v=E.padding:M?v=1:v=4;var q=k(E),g;if(v===4)g=J(q,L);else if(v===1)g=H(q,L,M);else if(v===3){if(g=new C(L),g.cmp(q.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return M?T(g,q):P(g,q)};function J(E,L){var M=E.modulus.byteLength(),v=L.length,q=F("sha1").update(W.alloc(0)).digest(),g=q.length,y=2*g;if(v>M-y-2)throw new Error("message too long");var w=W.alloc(M-v-y-2),f=M-g-1,b=j(g),u=X(W.concat([q,w,W.alloc(1,1),L],f),z(b,f)),Y0=X(b,z(u,g));return new C(W.concat([W.alloc(1),Y0,u],M))}function H(E,L,M){var v=L.length,q=E.modulus.byteLength();if(v>q-11)throw new Error("message too long");var g;return M?g=W.alloc(q-v-3,255):g=D(q-v-3),new C(W.concat([W.from([0,M?1:2]),g,W.alloc(1),L],q))}function D(E){for(var L=W.allocUnsafe(E),M=0,v=j(E*2),q=0,g;Mq||new z(E).cmp(v.modulus)>=0)throw new Error("decryption error");var g;L?g=P(new z(E),v):g=X(E,v);var y=T.alloc(q-g.length);if(g=T.concat([y,g],q),M===4)return W(v,g);if(M===1)return J(v,g,L);if(M===3)return g;throw new Error("unknown padding")};function W(D,E){var L=D.modulus.byteLength(),M=C("sha1").update(T.alloc(0)).digest(),v=M.length;if(E[0]!==0)throw new Error("decryption error");var q=E.slice(1,v+1),g=E.slice(v+1),y=F(q,j(g,v)),w=F(g,j(y,L-v-1));if(H(M,w.slice(0,v)))throw new Error("decryption error");for(var f=v;w[f]===0;)f++;if(w[f++]!==1)throw new Error("decryption error");return w.slice(f)}function J(D,E,L){for(var M=E.slice(0,2),v=2,q=0;E[v++]!==0;)if(v>=E.length){q++;break}var g=E.slice(2,v-1);if((M.toString("hex")!=="0002"&&!L||M.toString("hex")!=="0001"&&L)&&q++,g.length<8&&q++,q)throw new Error("decryption error");return E.slice(v)}function H(D,E){D=T.from(D),E=T.from(E);var L=0,M=D.length;D.length!==E.length&&(L++,M=Math.min(D.length,E.length));for(var v=-1;++vz||J<0)throw new TypeError("offset must be a uint32");if(J>F||J>H)throw new RangeError("offset out of range")}function C(J,H,D){if(typeof J!="number"||J!==J)throw new TypeError("size must be a number");if(J>z||J<0)throw new TypeError("size must be a uint32");if(J+H>D||J>F)throw new RangeError("buffer too small")}N.randomFill=P,N.randomFillSync=W;function P(J,H,D,E){if(!j.isBuffer(J)&&!(J instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof H=="function")E=H,H=0,D=J.length;else if(typeof D=="function")E=D,D=J.length-H;else if(typeof E!="function")throw new TypeError('"cb" argument must be a function');return X(H,J.length),C(D,H,J.length),T(J,H,D,E)}function T(J,H,D,E){if(E){k(D,function(M,v){if(M)return E(M);v.copy(J,H),E(null,J)});return}var L=k(D);return L.copy(J,H),J}function W(J,H,D){if(typeof H>"u"&&(H=0),!j.isBuffer(J)&&!(J instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return X(H,J.length),D===void 0&&(D=J.length-H),C(D,H,J.length),T(J,H,D)}}}),$Z=S0({"node_modules/crypto-browserify/index.js"(N){N.randomBytes=N.rng=N.pseudoRandomBytes=N.prng=L$(),N.createHash=M$(),N.Hash=N.createHash.Hash,N.createHmac=N.Hmac=XQ();var _=aQ(),k=Object.keys(_),j=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(k);N.getHashes=function(){return j};var F=AQ();N.pbkdf2=F.pbkdf2,N.pbkdf2Sync=F.pbkdf2Sync;var z=FY();N.Cipher=z.Cipher,N.createCipher=z.createCipher,N.Cipheriv=z.Cipheriv,N.createCipheriv=z.createCipheriv,N.Decipher=z.Decipher,N.createDecipher=z.createDecipher,N.Decipheriv=z.Decipheriv,N.createDecipheriv=z.createDecipheriv,N.getCiphers=z.getCiphers,N.listCiphers=z.listCiphers;var X=EY();N.DiffieHellmanGroup=X.DiffieHellmanGroup,N.createDiffieHellmanGroup=X.createDiffieHellmanGroup,N.getDiffieHellman=X.getDiffieHellman,N.createDiffieHellman=X.createDiffieHellman,N.DiffieHellman=X.DiffieHellman;var C=nY();N.createSign=C.createSign,N.Sign=C.Sign,N.createVerify=C.createVerify,N.Verify=C.Verify,N.createECDH=tY();var P=rY();N.publicEncrypt=P.publicEncrypt,N.privateEncrypt=P.privateEncrypt,N.publicDecrypt=P.publicDecrypt,N.privateDecrypt=P.privateDecrypt,N.getRandomValues=(W)=>H$.getRandomValues(W);var T=iY();N.randomFill=T.randomFill,N.randomFillSync=T.randomFillSync,N.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` +`))},N.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}}}),m$={...$Z(),[Symbol.for("CommonJS")]:0},z$="buffer",QZ=(N)=>H$.getRandomValues(N),YZ=()=>H$.randomUUID(),ZZ=(...N)=>H$.randomInt(...N),B$="timingSafeEqual"in H$?(N,_)=>{let{byteLength:k}=N,{byteLength:j}=_;if(typeof k!="number"||typeof j!="number")throw new TypeError("Input must be an array buffer view");if(k!==j)throw new RangeError("Input buffers must have the same length");return H$.timingSafeEqual(N,_)}:void 0,fQ="scryptSync"in H$?(N,_,k,j)=>{let F=H$.scryptSync(N,_,k,j);return z$!=="buffer"?new g0(F).toString(z$):new g0(F)}:void 0,cQ="scryptSync"in H$?function(N,_,k,j,F){if(typeof j=="function"&&(F=j,j=void 0),typeof F!="function"){var z=new TypeError("callback must be a function");throw z.code="ERR_INVALID_CALLBACK",z}try{let X=H$.scryptSync(N,_,k,j);process.nextTick(F,null,z$!=="buffer"?new g0(X).toString(z$):new g0(X))}catch(X){throw X}}:void 0;B$&&(Object.defineProperty(B$,"name",{value:"::bunternal::"}),Object.defineProperty(cQ,"name",{value:"::bunternal::"}),Object.defineProperty(fQ,"name",{value:"::bunternal::"}));var e$=H$;oQ(m$,{DEFAULT_ENCODING:()=>z$,getRandomValues:()=>QZ,randomUUID:()=>YZ,randomInt:()=>ZZ,scrypt:()=>cQ,scryptSync:()=>fQ,timingSafeEqual:()=>B$,webcrypto:()=>e$,subtle:()=>e$.subtle});var{randomBytes:UZ,rng:XZ,pseudoRandomBytes:KZ,prng:IZ,Hash:OZ,createHash:JZ,createHmac:FZ,Hmac:AZ,getHashes:HZ,pbkdf2:WZ,pbkdf2Sync:EZ,Cipher:TZ,createCipher:DZ,Cipheriv:CZ,createCipheriv:LZ,Decipher:RZ,createDecipher:PZ,Decipheriv:zZ,createDecipheriv:MZ,getCiphers:SZ,listCiphers:vZ,DiffieHellmanGroup:qZ,createDiffieHellmanGroup:jZ,getDiffieHellman:kZ,createDiffieHellman:gZ,DiffieHellman:_Z,createSign:NZ,Sign:xZ,createVerify:BZ,Verify:yZ,createECDH:wZ,publicEncrypt:pZ,privateEncrypt:fZ,publicDecrypt:cZ,privateDecrypt:hZ,randomFill:dZ,randomFillSync:bZ,createCredentials:lZ,constants:oZ}=m$;var nZ=m$;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{e$ as webcrypto,B$ as timingSafeEqual,fQ as scryptSync,cQ as scrypt,XZ as rng,YZ as randomUUID,ZZ as randomInt,bZ as randomFillSync,dZ as randomFill,UZ as randomBytes,pZ as publicEncrypt,cZ as publicDecrypt,KZ as pseudoRandomBytes,IZ as prng,fZ as privateEncrypt,hZ as privateDecrypt,EZ as pbkdf2Sync,WZ as pbkdf2,vZ as listCiphers,QZ as getRandomValues,HZ as getHashes,kZ as getDiffieHellman,SZ as getCiphers,nZ as default,BZ as createVerify,NZ as createSign,FZ as createHmac,JZ as createHash,wZ as createECDH,jZ as createDiffieHellmanGroup,gZ as createDiffieHellman,MZ as createDecipheriv,PZ as createDecipher,lZ as createCredentials,LZ as createCipheriv,DZ as createCipher,oZ as constants,yZ as Verify,xZ as Sign,AZ as Hmac,OZ as Hash,qZ as DiffieHellmanGroup,_Z as DiffieHellman,zZ as Decipheriv,RZ as Decipher,z$ as DEFAULT_ENCODING,CZ as Cipheriv,TZ as Cipher}; diff --git a/src/js/out/modules/node/fs.promises.js b/src/js/out/modules/node/fs.promises.js index 549ba0c9c..90adbae88 100644 --- a/src/js/out/modules/node/fs.promises.js +++ b/src/js/out/modules/node/fs.promises.js @@ -1 +1 @@ -function J(S,q={}){const z=[];if(S instanceof URL)throw new TypeError("Watch URLs are not supported yet");else if(Buffer.isBuffer(S))S=S.toString();else if(typeof S!=="string")throw new TypeError("Expected path to be a string or Buffer");let A=null;if(typeof q==="string")q={encoding:q};return H.watch(S,q||{},(B,C)=>{if(z.push({eventType:B,filename:C}),A){const D=A;A=null,D()}}),{async*[Symbol.asyncIterator](){let B=!1;while(!B){while(z.length){let C=z.shift();if(C.eventType==="close"){B=!0;break}if(C.eventType==="error")throw B=!0,C.filename;yield C}await new Promise((C)=>A=C)}}}}var H=Bun.fs(),G="::bunternal::",I={[G]:(S)=>{var q={[G]:function(z,A,B){var C;try{C=S.apply(H,B),B=void 0}catch(D){B=void 0,A(D);return}z(C)}}[G];return async function(...z){return await new Promise((A,B)=>{process.nextTick(q,A,B,z)})}}}[G],K=I(H.accessSync),L=I(H.appendFileSync),M=I(H.closeSync),N=I(H.copyFileSync),O=I(H.existsSync),P=I(H.chownSync),Q=I(H.chmodSync),U=I(H.fchmodSync),V=I(H.fchownSync),X=I(H.fstatSync),Y=I(H.fsyncSync),Z=I(H.ftruncateSync),_=I(H.futimesSync),$=I(H.lchmodSync),T=I(H.lchownSync),W=I(H.linkSync),k=I(H.lstatSync),E=I(H.mkdirSync),x=I(H.mkdtempSync),F=I(H.openSync),R=I(H.readSync),g=I(H.writeSync),h=I(H.readdirSync),j=I(H.readFileSync),w=I(H.writeFileSync),b=I(H.readlinkSync),u=I(H.realpathSync),d=I(H.renameSync),c=I(H.statSync),v=I(H.symlinkSync),a=I(H.truncateSync),y=I(H.unlinkSync),l=I(H.utimesSync),p=I(H.lutimesSync),m=I(H.rmSync),n=I(H.rmdirSync),t=(S,q,z)=>{return new Promise((A,B)=>{try{var C=H.writevSync(S,q,z)}catch(D){B(D);return}A({bytesWritten:C,buffers:q})})},o=(S,q,z)=>{return new Promise((A,B)=>{try{var C=H.readvSync(S,q,z)}catch(D){B(D);return}A({bytesRead:C,buffers:q})})},r={access:K,appendFile:L,close:M,copyFile:N,exists:O,chown:P,chmod:Q,fchmod:U,fchown:V,fstat:X,fsync:Y,ftruncate:Z,futimes:_,lchmod:$,lchown:T,link:W,lstat:k,mkdir:E,mkdtemp:x,open:F,read:R,write:g,readdir:h,readFile:j,writeFile:w,readlink:b,realpath:u,rename:d,stat:c,symlink:v,truncate:a,unlink:y,utimes:l,lutimes:p,rm:m,rmdir:n,watch:J,writev:t,readv:o,constants,[Symbol.for("CommonJS")]:0};export{t as writev,w as writeFile,g as write,J as watch,l as utimes,y as unlink,a as truncate,v as symlink,c as stat,n as rmdir,m as rm,d as rename,u as realpath,o as readv,b as readlink,h as readdir,j as readFile,R as read,F as open,x as mkdtemp,E as mkdir,p as lutimes,k as lstat,W as link,T as lchown,$ as lchmod,_ as futimes,Z as ftruncate,Y as fsync,X as fstat,V as fchown,U as fchmod,O as exists,r as default,N as copyFile,M as close,P as chown,Q as chmod,L as appendFile,K as access}; +function J(B,C={}){const G=[];if(B instanceof URL)throw new TypeError("Watch URLs are not supported yet");else if(Buffer.isBuffer(B))B=B.toString();else if(typeof B!=="string")throw new TypeError("Expected path to be a string or Buffer");let D=null;if(typeof C==="string")C={encoding:C};return S.watch(B,C||{},(z,A)=>{if(G.push({eventType:z,filename:A}),D){const H=D;D=null,H()}}),{async*[Symbol.asyncIterator](){let z=!1;while(!z){while(G.length){let A=G.shift();if(A.eventType==="close"){z=!0;break}if(A.eventType==="error")throw z=!0,A.filename;yield A}await new Promise((A)=>D=A)}}}}var S=Bun.fs(),I="::bunternal::",q={[I]:(B)=>{var C={[I]:function(G,D,z){var A;try{A=B.apply(S,z),z=void 0}catch(H){z=void 0,D(H);return}G(A)}}[I];return async function(...G){return await new Promise((D,z)=>{process.nextTick(C,D,z,G)})}}}[I],K=q(S.accessSync),L=q(S.appendFileSync),M=q(S.closeSync),N=q(S.copyFileSync),O=q(S.existsSync),P=q(S.chownSync),Q=q(S.chmodSync),U=q(S.fchmodSync),V=q(S.fchownSync),X=q(S.fstatSync),Y=q(S.fsyncSync),Z=q(S.ftruncateSync),_=q(S.futimesSync),$=q(S.lchmodSync),T=q(S.lchownSync),W=q(S.linkSync),k=q(S.lstatSync),E=q(S.mkdirSync),x=q(S.mkdtempSync),F=q(S.openSync),R=q(S.readSync),g=q(S.writeSync),h=q(S.readdirSync),j=q(S.readFileSync),w=q(S.writeFileSync),b=q(S.readlinkSync),u=q(S.realpathSync),d=q(S.renameSync),c=q(S.statSync),v=q(S.symlinkSync),a=q(S.truncateSync),y=q(S.unlinkSync),l=q(S.utimesSync),p=q(S.lutimesSync),m=q(S.rmSync),n=q(S.rmdirSync),t=(B,C,G)=>{return new Promise((D,z)=>{try{var A=S.writevSync(B,C,G)}catch(H){z(H);return}D({bytesWritten:A,buffers:C})})},o=(B,C,G)=>{return new Promise((D,z)=>{try{var A=S.readvSync(B,C,G)}catch(H){z(H);return}D({bytesRead:A,buffers:C})})},r={access:K,appendFile:L,close:M,copyFile:N,exists:O,chown:P,chmod:Q,fchmod:U,fchown:V,fstat:X,fsync:Y,ftruncate:Z,futimes:_,lchmod:$,lchown:T,link:W,lstat:k,mkdir:E,mkdtemp:x,open:F,read:R,write:g,readdir:h,readFile:j,writeFile:w,readlink:b,realpath:u,rename:d,stat:c,symlink:v,truncate:a,unlink:y,utimes:l,lutimes:p,rm:m,rmdir:n,watch:J,writev:t,readv:o,constants,[Symbol.for("CommonJS")]:0};export{t as writev,w as writeFile,g as write,J as watch,l as utimes,y as unlink,a as truncate,v as symlink,c as stat,n as rmdir,m as rm,d as rename,u as realpath,o as readv,b as readlink,h as readdir,j as readFile,R as read,F as open,x as mkdtemp,E as mkdir,p as lutimes,k as lstat,W as link,T as lchown,$ as lchmod,_ as futimes,Z as ftruncate,Y as fsync,X as fstat,V as fchown,U as fchmod,O as exists,r as default,N as copyFile,M as close,P as chown,Q as chmod,L as appendFile,K as access}; diff --git a/src/js/out/modules/node/path.js b/src/js/out/modules/node/path.js index 3a3a75207..edc4f1d3c 100644 --- a/src/js/out/modules/node/path.js +++ b/src/js/out/modules/node/path.js @@ -1 +1 @@ -var i=function(N){var m=g({basename:N.basename.bind(N),dirname:N.dirname.bind(N),extname:N.extname.bind(N),format:N.format.bind(N),isAbsolute:N.isAbsolute.bind(N),join:N.join.bind(N),normalize:N.normalize.bind(N),parse:N.parse.bind(N),relative:N.relative.bind(N),resolve:N.resolve.bind(N),toNamespacedPath:N.toNamespacedPath.bind(N),sep:N.sep,delimiter:N.delimiter});return m.default=m,m},g=(N)=>Object.assign(Object.create(null),N),f=i(Bun._Path()),J=i(Bun._Path(!1)),k=i(Bun._Path(!0));f.win32=k;f.posix=J;var{basename:q,dirname:v,extname:y,format:z,isAbsolute:A,join:B,normalize:K,parse:C,relative:D,resolve:E,toNamespacedPath:F,sep:G,delimiter:H,__esModule:I}=f;f[Symbol.for("CommonJS")]=0;f.__esModule=!0;var O=f;export{k as win32,F as toNamespacedPath,G as sep,E as resolve,D as relative,J as posix,C as parse,K as normalize,B as join,A as isAbsolute,z as format,y as extname,v as dirname,H as delimiter,O as default,g as createModule,q as basename,I as __esModule}; +var g=function(i){var m=k({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 m.default=m,m},k=(i)=>Object.assign(Object.create(null),i),f=g(Bun._Path()),q=g(Bun._Path(!1)),v=g(Bun._Path(!0));f.win32=v;f.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}=f;f[Symbol.for("CommonJS")]=0;f.__esModule=!0;var O=f;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,k 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 64e8a62f5..179f2b9aa 100644 --- a/src/js/out/modules/node/path.posix.js +++ b/src/js/out/modules/node/path.posix.js @@ -1 +1 @@ -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}; +var r=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}},i=r(Bun._Path(!1));i[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}=i,z=i;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/path.win32.js b/src/js/out/modules/node/path.win32.js index 03d7b81c8..a1b929c52 100644 --- a/src/js/out/modules/node/path.win32.js +++ b/src/js/out/modules/node/path.win32.js @@ -1 +1 @@ -var e=function(i){return{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}},r=e(Bun._Path(!0)),{basename:s,dirname:t,extname:c,format:d,isAbsolute:f,join:g,normalize:k,parse:l,relative:m,resolve:n,toNamespacedPath:q,sep:v,delimiter:w}=r,y=r;export{q as toNamespacedPath,v as sep,n as resolve,m as relative,l as parse,k as normalize,g as join,f as isAbsolute,d as format,c as extname,t as dirname,w as delimiter,y as default,s as basename}; +var r=function(i){return{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}},e=r(Bun._Path(!0)),{basename:s,dirname:t,extname:c,format:d,isAbsolute:f,join:g,normalize:k,parse:l,relative:m,resolve:n,toNamespacedPath:q,sep:v,delimiter:w}=e,y=e;export{q as toNamespacedPath,v as sep,n as resolve,m as relative,l as parse,k as normalize,g as join,f as isAbsolute,d as format,c as extname,t as dirname,w as delimiter,y as default,s as basename}; diff --git a/src/js/out/modules/node/stream.consumers.js b/src/js/out/modules/node/stream.consumers.js index 20bbb7de4..a4a60e626 100644 --- a/src/js/out/modules/node/stream.consumers.js +++ b/src/js/out/modules/node/stream.consumers.js @@ -1 +1 @@ -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}; +var{Bun:h}=globalThis[Symbol.for("Bun.lazy")]("primordials"),p=h.readableStreamToArrayBuffer,c=h.readableStreamToText,g=(o)=>h.readableStreamToText(o).then(JSON.parse),i=async(o)=>{return new Buffer(await p(o))},k=h.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 57561d4a1..f7e94b00d 100644 --- a/src/js/out/modules/node/stream.js +++ b/src/js/out/modules/node/stream.js @@ -1,2 +1,2 @@ -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}; +import{EventEmitter as Tq} from"bun:events_native";import{StringDecoder as rq} from"node:string_decoder";var qQ=function(t){return typeof t==="object"&&t!==null&&t instanceof ReadableStream},QQ=function(t,M){if(typeof t!=="boolean")throw new XQ(M,"boolean",t)};var XQ=function(t,M,B){return new Error(`The argument '${t}' is invalid. Received '${B}' for type '${M}'`)},JQ=function(t,M,B){return new Error(`The value '${M}' is invalid for argument '${t}'. Reason: ${B}`)},zQ=function(t,M){var[B,F,y,I,j,R,x]=globalThis[Symbol.for("Bun.lazy")](t),g=[!1],f=function(P,A,K,U){if(A>0){const T=K.subarray(0,A),C=K.subarray(A);if(T.byteLength>0)P.push(T);if(U)P.push(null);return C.byteLength>0?C:void 0}if(U)P.push(null);return K},c=function(P,A,K,U){if(A.byteLength>0)P.push(A);if(U)P.push(null);return K},_=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const i=new FinalizationRegistry((P)=>P&&j(P)),D=512;var p=class P extends M{#q;#Q=1;#X=!1;#H=void 0;#J;#K=!1;#Z=!_;#B;constructor(A,K={}){super(K);if(typeof K.highWaterMark==="number")this.#J=K.highWaterMark;else this.#J=262144;this.#q=A,this.#X=!1,this.#H=void 0,this.#K=!1,this.#B={},i.register(this,this.#q,this.#B)}_read(A){if(n&&d("NativeReadable._read",this.__id),this.#K){n&&d("pendingRead is true",this.__id);return}var K=this.#q;if(n&&d("ptr @ NativeReadable._read",K,this.__id),K===0){this.push(null);return}if(!this.#X)n&&d("NativeReadable not constructed yet",this.__id),this.#$(K);return this.#V(this.#z(A),K)}#$(A){this.#X=!0;const K=F(A,this.#J);if(n&&d("NativeReadable internal `start` result",K,this.__id),typeof K==="number"&&K>1)this.#Z=!0,n&&d("NativeReadable resized",this.__id),this.#J=Math.min(this.#J,K);if(x){const U=x(A);if(n&&d("NativeReadable drain result",U,this.__id),(U?.byteLength??0)>0)this.push(U)}}#z(A=this.#J){var K=this.#H;if(n&&d("chunk @ #getRemainingChunk",K,this.__id),K?.byteLength??0D?A:D;this.#H=K=new Buffer(U)}return K}push(A,K){return n&&d("NativeReadable push -- result, encoding",A,K,this.__id),super.push(...arguments)}#Y(A,K,U){if(n&&d("result, isClosed @ #handleResult",A,U,this.__id),typeof A==="number"){if(A>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0;return f(this,A,K,U)}else if(typeof A==="boolean")return this.push(null),K?.byteLength??0>0?K:void 0;else if(ArrayBuffer.isView(A)){if(A.byteLength>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0,n&&d("Resized",this.__id);return c(this,A,K,U)}else throw n&&d("Unknown result type",A,this.__id),new Error("Invalid result from pull")}#V(A,K){n&&d("#internalRead()",this.__id),g[0]=!1;var U=B(K,A,g);if(Oq(U))return this.#K=!0,U.then((T)=>{this.#K=!1,n&&d("pending no longerrrrrrrr (result returned from pull)",this.__id),this.#H=this.#Y(T,A,g[0])},(T)=>{n&&d("error from pull",T,this.__id),errorOrDestroy(this,T)});else this.#H=this.#Y(U,A,g[0])}_destroy(A,K){var U=this.#q;if(U===0){K(A);return}if(i.unregister(this.#B),this.#q=0,R)R(U,!1);n&&d("NativeReadable destroyed",this.__id),y(U,A),K(A)}ref(){var A=this.#q;if(A===0)return;if(this.#Q++===0)R(A,!0)}unref(){var A=this.#q;if(A===0)return;if(this.#Q--===1)R(A,!1)}};if(!R)p.prototype.ref=void 0,p.prototype.unref=void 0;return p},iq=function(t,M){return VQ[t]||=zQ(t,M)},UQ=function(t,M,B){if(!(M&&typeof M==="object"&&M instanceof ReadableStream))return;const F=aq(M);if(!F){d("no native readable stream");return}const{stream:y,data:I}=F;return new(iq(I,t))(y,B)},{isPromise:Oq,isCallable:sq,direct:aq,Object:Uq}=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 tq=!!process.env.DEBUG_TRACK_EE,n=!!(process.env.DEBUG||process.env.DEBUG_STREAMS||tq),d=n?globalThis.__IDS_TO_TRACK?(...t)=>{const M=t[t.length-1];if(!globalThis.__IDS_TO_TRACK.includes(M))return;console.log(`ID: ${M}`,...t.slice(0,-1))}:(...t)=>console.log(...t.slice(0,-1)):()=>{},FQ=Uq.create,LQ=Uq.defineProperty,jQ=Uq.getOwnPropertyDescriptor,eq=Uq.getOwnPropertyNames,NQ=Uq.getPrototypeOf,AQ=Uq.prototype.hasOwnProperty,EQ=Uq.setPrototypeOf,$q=(t,M)=>function B(){return M||(0,t[eq(t)[0]])((M={exports:{}}).exports,M),M.exports};var Hq=process.nextTick;var IQ=Array.isArray,Wq=$q({"node_modules/readable-stream/lib/ours/primordials.js"(t,M){M.exports={ArrayIsArray(B){return Array.isArray(B)},ArrayPrototypeIncludes(B,F){return B.includes(F)},ArrayPrototypeIndexOf(B,F){return B.indexOf(F)},ArrayPrototypeJoin(B,F){return B.join(F)},ArrayPrototypeMap(B,F){return B.map(F)},ArrayPrototypePop(B,F){return B.pop(F)},ArrayPrototypePush(B,F){return B.push(F)},ArrayPrototypeSlice(B,F,y){return B.slice(F,y)},Error,FunctionPrototypeCall(B,F,...y){return B.call(F,...y)},FunctionPrototypeSymbolHasInstance(B,F){return Function.prototype[Symbol.hasInstance].call(B,F)},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(B,F){return Uq.defineProperties(B,F)},ObjectDefineProperty(B,F,y){return Uq.defineProperty(B,F,y)},ObjectGetOwnPropertyDescriptor(B,F){return Uq.getOwnPropertyDescriptor(B,F)},ObjectKeys(B){return Uq.keys(B)},ObjectSetPrototypeOf(B,F){return Uq.setPrototypeOf(B,F)},Promise,PromisePrototypeCatch(B,F){return B.catch(F)},PromisePrototypeThen(B,F,y){return B.then(F,y)},PromiseReject(B){return Promise.reject(B)},ReflectApply:Reflect.apply,RegExpPrototypeTest(B,F){return B.test(F)},SafeSet:Set,String,StringPrototypeSlice(B,F,y){return B.slice(F,y)},StringPrototypeToLowerCase(B){return B.toLowerCase()},StringPrototypeToUpperCase(B){return B.toUpperCase()},StringPrototypeTrim(B){return B.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(B,F,y){return B.set(F,y)},Uint8Array}}}),Eq=$q({"node_modules/readable-stream/lib/ours/util.js"(t,M){var B=Uq.getPrototypeOf(async function(){}).constructor,F=typeof Blob!=="undefined"?function I(j){return j instanceof Blob}:function I(j){return!1},y=class extends Error{constructor(I){if(!Array.isArray(I))throw new TypeError(`Expected input to be an Array, got ${typeof I}`);let j="";for(let R=0;R{I=x,j=g}),resolve:I,reject:j}},promisify(I){return new Promise((j,R)=>{I((x,...g)=>{if(x)return R(x);return j(...g)})})},debuglog(){return function(){}},format(I,...j){return I.replace(/%([sdifj])/g,function(...[R,x]){const g=j.shift();if(x==="f")return g.toFixed(6);else if(x==="j")return JSON.stringify(g);else if(x==="s"&&typeof g==="object")return`${g.constructor!==Uq?g.constructor.name:""} {}`.trim();else return g.toString()})},inspect(I){switch(typeof I){case"string":if(I.includes("'")){if(!I.includes('"'))return`"${I}"`;else if(!I.includes("`")&&!I.includes("${"))return`\`${I}\``}return`'${I}'`;case"number":if(isNaN(I))return"NaN";else if(Uq.is(I,-0))return String(I);return I;case"bigint":return`${String(I)}n`;case"boolean":case"undefined":return String(I);case"object":return"{}"}},types:{isAsyncFunction(I){return I instanceof B},isArrayBufferView(I){return ArrayBuffer.isView(I)}},isBlob:F},M.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),Mq=$q({"node_modules/readable-stream/lib/ours/errors.js"(t,M){var{format:B,inspect:F,AggregateError:y}=Eq(),I=globalThis.AggregateError||y,j=Symbol("kIsNodeError"),R=["string","function","number","object","Function","Object","boolean","bigint","symbol"],x=/^([A-Z][a-z0-9]*)+$/,g="__node_internal_",f={};function c(K,U){if(!K)throw new f.ERR_INTERNAL_ASSERTION(U)}function _(K){let U="",T=K.length;const C=K[0]==="-"?1:0;for(;T>=C+4;T-=3)U=`_${K.slice(T-3,T)}${U}`;return`${K.slice(0,T)}${U}`}function i(K,U,T){if(typeof U==="function")return c(U.length<=T.length,`Code: ${K}; The provided arguments length (${T.length}) does not match the required ones (${U.length}).`),U(...T);const C=(U.match(/%[dfijoOs]/g)||[]).length;if(c(C===T.length,`Code: ${K}; The provided arguments length (${T.length}) does not match the required ones (${C}).`),T.length===0)return U;return B(U,...T)}function D(K,U,T){if(!T)T=Error;class C extends T{constructor(...qq){super(i(K,U,qq))}toString(){return`${this.name} [${K}]: ${this.message}`}}Uq.defineProperties(C.prototype,{name:{value:T.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${K}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),C.prototype.code=K,C.prototype[j]=!0,f[K]=C}function p(K){const U=g+K.name;return Uq.defineProperty(K,"name",{value:U}),K}function P(K,U){if(K&&U&&K!==U){if(Array.isArray(U.errors))return U.errors.push(K),U;const T=new I([U,K],U.message);return T.code=U.code,T}return K||U}var A=class extends Error{constructor(K="The operation was aborted",U=void 0){if(U!==void 0&&typeof U!=="object")throw new f.ERR_INVALID_ARG_TYPE("options","Object",U);super(K,U);this.code="ABORT_ERR",this.name="AbortError"}};D("ERR_ASSERTION","%s",Error),D("ERR_INVALID_ARG_TYPE",(K,U,T)=>{if(c(typeof K==="string","'name' must be a string"),!Array.isArray(U))U=[U];let C="The ";if(K.endsWith(" argument"))C+=`${K} `;else C+=`"${K}" ${K.includes(".")?"property":"argument"} `;C+="must be ";const qq=[],o=[],$=[];for(let Y of U)if(c(typeof Y==="string","All expected entries have to be of type string"),R.includes(Y))qq.push(Y.toLowerCase());else if(x.test(Y))o.push(Y);else c(Y!=="object",'The value "object" should be written as "Object"'),$.push(Y);if(o.length>0){const Y=qq.indexOf("object");if(Y!==-1)qq.splice(qq,Y,1),o.push("Object")}if(qq.length>0){switch(qq.length){case 1:C+=`of type ${qq[0]}`;break;case 2:C+=`one of type ${qq[0]} or ${qq[1]}`;break;default:{const Y=qq.pop();C+=`one of type ${qq.join(", ")}, or ${Y}`}}if(o.length>0||$.length>0)C+=" or "}if(o.length>0){switch(o.length){case 1:C+=`an instance of ${o[0]}`;break;case 2:C+=`an instance of ${o[0]} or ${o[1]}`;break;default:{const Y=o.pop();C+=`an instance of ${o.join(", ")}, or ${Y}`}}if($.length>0)C+=" or "}switch($.length){case 0:break;case 1:if($[0].toLowerCase()!==$[0])C+="an ";C+=`${$[0]}`;break;case 2:C+=`one of ${$[0]} or ${$[1]}`;break;default:{const Y=$.pop();C+=`one of ${$.join(", ")}, or ${Y}`}}if(T==null)C+=`. Received ${T}`;else if(typeof T==="function"&&T.name)C+=`. Received function ${T.name}`;else if(typeof T==="object"){var s;if((s=T.constructor)!==null&&s!==void 0&&s.name)C+=`. Received an instance of ${T.constructor.name}`;else{const Y=F(T,{depth:-1});C+=`. Received ${Y}`}}else{let Y=F(T,{colors:!1});if(Y.length>25)Y=`${Y.slice(0,25)}...`;C+=`. Received type ${typeof T} (${Y})`}return C},TypeError),D("ERR_INVALID_ARG_VALUE",(K,U,T="is invalid")=>{let C=F(U);if(C.length>128)C=C.slice(0,128)+"...";return`The ${K.includes(".")?"property":"argument"} '${K}' ${T}. Received ${C}`},TypeError),D("ERR_INVALID_RETURN_VALUE",(K,U,T)=>{var C;const qq=T!==null&&T!==void 0&&(C=T.constructor)!==null&&C!==void 0&&C.name?`instance of ${T.constructor.name}`:`type ${typeof T}`;return`Expected ${K} to be returned from the "${U}" function but got ${qq}.`},TypeError),D("ERR_MISSING_ARGS",(...K)=>{c(K.length>0,"At least one arg needs to be specified");let U;const T=K.length;switch(K=(Array.isArray(K)?K:[K]).map((C)=>`"${C}"`).join(" or "),T){case 1:U+=`The ${K[0]} argument`;break;case 2:U+=`The ${K[0]} and ${K[1]} arguments`;break;default:{const C=K.pop();U+=`The ${K.join(", ")}, and ${C} arguments`}break}return`${U} must be specified`},TypeError),D("ERR_OUT_OF_RANGE",(K,U,T)=>{c(U,'Missing "range" argument');let C;if(Number.isInteger(T)&&Math.abs(T)>4294967296)C=_(String(T));else if(typeof T==="bigint"){if(C=String(T),T>2n**32n||T<-(2n**32n))C=_(C);C+="n"}else C=F(T);return`The value of "${K}" is out of range. It must be ${U}. Received ${C}`},RangeError),D("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),D("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),D("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),D("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),D("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),D("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),D("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),D("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),D("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),D("ERR_STREAM_WRITE_AFTER_END","write after end",Error),D("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),M.exports={AbortError:A,aggregateTwoErrors:p(P),hideStackFrames:p,codes:f}}}),Cq=$q({"node_modules/readable-stream/lib/internal/validators.js"(t,M){var{ArrayIsArray:B,ArrayPrototypeIncludes:F,ArrayPrototypeJoin:y,ArrayPrototypeMap:I,NumberIsInteger:j,NumberMAX_SAFE_INTEGER:R,NumberMIN_SAFE_INTEGER:x,NumberParseInt:g,RegExpPrototypeTest:f,String:c,StringPrototypeToUpperCase:_,StringPrototypeTrim:i}=Wq(),{hideStackFrames:D,codes:{ERR_SOCKET_BAD_PORT:p,ERR_INVALID_ARG_TYPE:P,ERR_INVALID_ARG_VALUE:A,ERR_OUT_OF_RANGE:K,ERR_UNKNOWN_SIGNAL:U}}=Mq(),{normalizeEncoding:T}=Eq(),{isAsyncFunction:C,isArrayBufferView:qq}=Eq().types,o={};function $(V){return V===(V|0)}function s(V){return V===V>>>0}var Y=/^[0-7]+$/,Z="must be a 32-bit unsigned integer or an octal string";function N(V,h,X){if(typeof V==="undefined")V=X;if(typeof V==="string"){if(!f(Y,V))throw new A(h,V,Z);V=g(V,8)}return u(V,h,0,4294967295),V}var m=D((V,h,X=x,H=R)=>{if(typeof V!=="number")throw new P(h,"number",V);if(!j(V))throw new K(h,"an integer",V);if(VH)throw new K(h,`>= ${X} && <= ${H}`,V)}),u=D((V,h,X=-2147483648,H=2147483647)=>{if(typeof V!=="number")throw new P(h,"number",V);if(!$(V)){if(!j(V))throw new K(h,"an integer",V);throw new K(h,`>= ${X} && <= ${H}`,V)}if(VH)throw new K(h,`>= ${X} && <= ${H}`,V)}),J=D((V,h,X)=>{if(typeof V!=="number")throw new P(h,"number",V);if(!s(V)){if(!j(V))throw new K(h,"an integer",V);throw new K(h,`>= ${X?1:0} && < 4294967296`,V)}if(X&&V===0)throw new K(h,">= 1 && < 4294967296",V)});function z(V,h){if(typeof V!=="string")throw new P(h,"string",V)}function w(V,h){if(typeof V!=="number")throw new P(h,"number",V)}var S=D((V,h,X)=>{if(!F(X,V)){const L="must be one of: "+y(I(X,(l)=>typeof l==="string"?`'${l}'`:c(l)),", ");throw new A(h,V,L)}});function E(V,h){if(typeof V!=="boolean")throw new P(h,"boolean",V)}var W=D((V,h,X)=>{const H=X==null,L=H?!1:X.allowArray,l=H?!1:X.allowFunction;if(!(H?!1:X.nullable)&&V===null||!L&&B(V)||typeof V!=="object"&&(!l||typeof V!=="function"))throw new P(h,"Object",V)}),b=D((V,h,X=0)=>{if(!B(V))throw new P(h,"Array",V);if(V.length{if(!qq(V))throw new P(h,["Buffer","TypedArray","DataView"],V)});function Qq(V,h){const X=T(h),H=V.length;if(X==="hex"&&H%2!==0)throw new A("encoding",h,`is invalid for data of length ${H}`)}function Zq(V,h="Port",X=!0){if(typeof V!=="number"&&typeof V!=="string"||typeof V==="string"&&i(V).length===0||+V!==+V>>>0||V>65535||V===0&&!X)throw new p(h,V,X);return V|0}var Vq=D((V,h)=>{if(V!==void 0&&(V===null||typeof V!=="object"||!("aborted"in V)))throw new P(h,"AbortSignal",V)}),Xq=D((V,h)=>{if(typeof V!=="function")throw new P(h,"Function",V)}),Bq=D((V,h)=>{if(typeof V!=="function"||C(V))throw new P(h,"Function",V)}),Jq=D((V,h)=>{if(V!==void 0)throw new P(h,"undefined",V)});M.exports={isInt32:$,isUint32:s,parseFileMode:N,validateArray:b,validateBoolean:E,validateBuffer:r,validateEncoding:Qq,validateFunction:Xq,validateInt32:u,validateInteger:m,validateNumber:w,validateObject:W,validateOneOf:S,validatePlainFunction:Bq,validatePort:Zq,validateSignalName:a,validateString:z,validateUint32:J,validateUndefined:Jq,validateAbortSignal:Vq}}}),Iq=$q({"node_modules/readable-stream/lib/internal/streams/utils.js"(t,M){var{Symbol:B,SymbolAsyncIterator:F,SymbolIterator:y}=Wq(),I=B("kDestroyed"),j=B("kIsErrored"),R=B("kIsReadable"),x=B("kIsDisturbed");function g(J,z=!1){var w;return!!(J&&typeof J.pipe==="function"&&typeof J.on==="function"&&(!z||typeof J.pause==="function"&&typeof J.resume==="function")&&(!J._writableState||((w=J._readableState)===null||w===void 0?void 0:w.readable)!==!1)&&(!J._writableState||J._readableState))}function f(J){var z;return!!(J&&typeof J.write==="function"&&typeof J.on==="function"&&(!J._readableState||((z=J._writableState)===null||z===void 0?void 0:z.writable)!==!1))}function c(J){return!!(J&&typeof J.pipe==="function"&&J._readableState&&typeof J.on==="function"&&typeof J.write==="function")}function _(J){return J&&(J._readableState||J._writableState||typeof J.write==="function"&&typeof J.on==="function"||typeof J.pipe==="function"&&typeof J.on==="function")}function i(J,z){if(J==null)return!1;if(z===!0)return typeof J[F]==="function";if(z===!1)return typeof J[y]==="function";return typeof J[F]==="function"||typeof J[y]==="function"}function D(J){if(!_(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!!(J.destroyed||J[I]||S!==null&&S!==void 0&&S.destroyed)}function p(J){if(!f(J))return null;if(J.writableEnded===!0)return!0;const z=J._writableState;if(z!==null&&z!==void 0&&z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function P(J,z){if(!f(J))return null;if(J.writableFinished===!0)return!0;const w=J._writableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.finished)!=="boolean")return null;return!!(w.finished||z===!1&&w.ended===!0&&w.length===0)}function A(J){if(!g(J))return null;if(J.readableEnded===!0)return!0;const z=J._readableState;if(!z||z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function K(J,z){if(!g(J))return null;const w=J._readableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.endEmitted)!=="boolean")return null;return!!(w.endEmitted||z===!1&&w.ended===!0&&w.length===0)}function U(J){if(J&&J[R]!=null)return J[R];if(typeof(J===null||J===void 0?void 0:J.readable)!=="boolean")return null;if(D(J))return!1;return g(J)&&J.readable&&!K(J)}function T(J){if(typeof(J===null||J===void 0?void 0:J.writable)!=="boolean")return null;if(D(J))return!1;return f(J)&&J.writable&&!p(J)}function C(J,z){if(!_(J))return null;if(D(J))return!0;if((z===null||z===void 0?void 0:z.readable)!==!1&&U(J))return!1;if((z===null||z===void 0?void 0:z.writable)!==!1&&T(J))return!1;return!0}function qq(J){var z,w;if(!_(J))return null;if(J.writableErrored)return J.writableErrored;return(z=(w=J._writableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function o(J){var z,w;if(!_(J))return null;if(J.readableErrored)return J.readableErrored;return(z=(w=J._readableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function $(J){if(!_(J))return null;if(typeof J.closed==="boolean")return J.closed;const{_writableState:z,_readableState:w}=J;if(typeof(z===null||z===void 0?void 0:z.closed)==="boolean"||typeof(w===null||w===void 0?void 0:w.closed)==="boolean")return(z===null||z===void 0?void 0:z.closed)||(w===null||w===void 0?void 0:w.closed);if(typeof J._closed==="boolean"&&s(J))return J._closed;return null}function s(J){return typeof J._closed==="boolean"&&typeof J._defaultKeepAlive==="boolean"&&typeof J._removedConnection==="boolean"&&typeof J._removedContLen==="boolean"}function Y(J){return typeof J._sent100==="boolean"&&s(J)}function Z(J){var z;return typeof J._consuming==="boolean"&&typeof J._dumped==="boolean"&&((z=J.req)===null||z===void 0?void 0:z.upgradeOrConnect)===void 0}function N(J){if(!_(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!S&&Y(J)||!!(S&&S.autoDestroy&&S.emitClose&&S.closed===!1)}function m(J){var z;return!!(J&&((z=J[x])!==null&&z!==void 0?z:J.readableDidRead||J.readableAborted))}function u(J){var z,w,S,E,W,b,a,r,Qq,Zq;return!!(J&&((z=(w=(S=(E=(W=(b=J[j])!==null&&b!==void 0?b:J.readableErrored)!==null&&W!==void 0?W:J.writableErrored)!==null&&E!==void 0?E:(a=J._readableState)===null||a===void 0?void 0:a.errorEmitted)!==null&&S!==void 0?S:(r=J._writableState)===null||r===void 0?void 0:r.errorEmitted)!==null&&w!==void 0?w:(Qq=J._readableState)===null||Qq===void 0?void 0:Qq.errored)!==null&&z!==void 0?z:(Zq=J._writableState)===null||Zq===void 0?void 0:Zq.errored))}M.exports={kDestroyed:I,isDisturbed:m,kIsDisturbed:x,isErrored:u,kIsErrored:j,isReadable:U,kIsReadable:R,isClosed:$,isDestroyed:D,isDuplexNodeStream:c,isFinished:C,isIterable:i,isReadableNodeStream:g,isReadableEnded:A,isReadableFinished:K,isReadableErrored:o,isNodeStream:_,isWritable:T,isWritableNodeStream:f,isWritableEnded:p,isWritableFinished:P,isWritableErrored:qq,isServerRequest:Z,isServerResponse:Y,willEmitClose:N}}}),jq=$q({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(t,M){var{AbortError:B,codes:F}=Mq(),{ERR_INVALID_ARG_TYPE:y,ERR_STREAM_PREMATURE_CLOSE:I}=F,{once:j}=Eq(),{validateAbortSignal:R,validateFunction:x,validateObject:g}=Cq(),{Promise:f}=Wq(),{isClosed:c,isReadable:_,isReadableNodeStream:i,isReadableFinished:D,isReadableErrored:p,isWritable:P,isWritableNodeStream:A,isWritableFinished:K,isWritableErrored:U,isNodeStream:T,willEmitClose:C}=Iq();function qq(Y){return Y.setHeader&&typeof Y.abort==="function"}var o=()=>{};function $(Y,Z,N){var m,u;if(arguments.length===2)N=Z,Z={};else if(Z==null)Z={};else g(Z,"options");x(N,"callback"),R(Z.signal,"options.signal"),N=j(N);const J=(m=Z.readable)!==null&&m!==void 0?m:i(Y),z=(u=Z.writable)!==null&&u!==void 0?u:A(Y);if(!T(Y))throw new y("stream","Stream",Y);const{_writableState:w,_readableState:S}=Y,E=()=>{if(!Y.writable)a()};let W=C(Y)&&i(Y)===J&&A(Y)===z,b=K(Y,!1);const a=()=>{if(b=!0,Y.destroyed)W=!1;if(W&&(!Y.readable||J))return;if(!J||r)N.call(Y)};let r=D(Y,!1);const Qq=()=>{if(r=!0,Y.destroyed)W=!1;if(W&&(!Y.writable||z))return;if(!z||b)N.call(Y)},Zq=(V)=>{N.call(Y,V)};let Vq=c(Y);const Xq=()=>{Vq=!0;const V=U(Y)||p(Y);if(V&&typeof V!=="boolean")return N.call(Y,V);if(J&&!r&&i(Y,!0)){if(!D(Y,!1))return N.call(Y,new I)}if(z&&!b){if(!K(Y,!1))return N.call(Y,new I)}N.call(Y)},Bq=()=>{Y.req.on("finish",a)};if(qq(Y)){if(Y.on("complete",a),!W)Y.on("abort",Xq);if(Y.req)Bq();else Y.on("request",Bq)}else if(z&&!w)Y.on("end",E),Y.on("close",E);if(!W&&typeof Y.aborted==="boolean")Y.on("aborted",Xq);if(Y.on("end",Qq),Y.on("finish",a),Z.error!==!1)Y.on("error",Zq);if(Y.on("close",Xq),Vq)Hq(Xq);else if(w!==null&&w!==void 0&&w.errorEmitted||S!==null&&S!==void 0&&S.errorEmitted){if(!W)Hq(Xq)}else if(!J&&(!W||_(Y))&&(b||P(Y)===!1))Hq(Xq);else if(!z&&(!W||P(Y))&&(r||_(Y)===!1))Hq(Xq);else if(S&&Y.req&&Y.aborted)Hq(Xq);const Jq=()=>{if(N=o,Y.removeListener("aborted",Xq),Y.removeListener("complete",a),Y.removeListener("abort",Xq),Y.removeListener("request",Bq),Y.req)Y.req.removeListener("finish",a);Y.removeListener("end",E),Y.removeListener("close",E),Y.removeListener("finish",a),Y.removeListener("end",Qq),Y.removeListener("error",Zq),Y.removeListener("close",Xq)};if(Z.signal&&!Vq){const V=()=>{const h=N;Jq(),h.call(Y,new B(void 0,{cause:Z.signal.reason}))};if(Z.signal.aborted)Hq(V);else{const h=N;N=j((...X)=>{Z.signal.removeEventListener("abort",V),h.apply(Y,X)}),Z.signal.addEventListener("abort",V)}}return Jq}function s(Y,Z){return new f((N,m)=>{$(Y,Z,(u)=>{if(u)m(u);else N()})})}M.exports=$,M.exports.finished=s}}),HQ=$q({"node_modules/readable-stream/lib/internal/streams/operators.js"(t,M){var{codes:{ERR_INVALID_ARG_TYPE:B,ERR_MISSING_ARGS:F,ERR_OUT_OF_RANGE:y},AbortError:I}=Mq(),{validateAbortSignal:j,validateInteger:R,validateObject:x}=Cq(),g=Wq().Symbol("kWeak"),{finished:f}=jq(),{ArrayPrototypePush:c,MathFloor:_,Number:i,NumberIsNaN:D,Promise:p,PromiseReject:P,PromisePrototypeCatch:A,Symbol:K}=Wq(),U=K("kEmpty"),T=K("kEof");function C(E,W){if(typeof E!=="function")throw new B("fn",["Function","AsyncFunction"],E);if(W!=null)x(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)j(W.signal,"options.signal");let b=1;if((W===null||W===void 0?void 0:W.concurrency)!=null)b=_(W.concurrency);return R(b,"concurrency",1),async function*a(){var r,Qq;const Zq=new AbortController,Vq=this,Xq=[],Bq=Zq.signal,Jq={signal:Bq},V=()=>Zq.abort();if(W!==null&&W!==void 0&&(r=W.signal)!==null&&r!==void 0&&r.aborted)V();W===null||W===void 0||(Qq=W.signal)===null||Qq===void 0||Qq.addEventListener("abort",V);let h,X,H=!1;function L(){H=!0}async function l(){try{for await(let q of Vq){var k;if(H)return;if(Bq.aborted)throw new I;try{q=E(q,Jq)}catch(Q){q=P(Q)}if(q===U)continue;if(typeof((k=q)===null||k===void 0?void 0:k.catch)==="function")q.catch(L);if(Xq.push(q),h)h(),h=null;if(!H&&Xq.length&&Xq.length>=b)await new p((Q)=>{X=Q})}Xq.push(T)}catch(q){const Q=P(q);A(Q,L),Xq.push(Q)}finally{var e;if(H=!0,h)h(),h=null;W===null||W===void 0||(e=W.signal)===null||e===void 0||e.removeEventListener("abort",V)}}l();try{while(!0){while(Xq.length>0){const k=await Xq[0];if(k===T)return;if(Bq.aborted)throw new I;if(k!==U)yield k;if(Xq.shift(),X)X(),X=null}await new p((k)=>{h=k})}}finally{if(Zq.abort(),H=!0,X)X(),X=null}}.call(this)}function qq(E=void 0){if(E!=null)x(E,"options");if((E===null||E===void 0?void 0:E.signal)!=null)j(E.signal,"options.signal");return async function*W(){let b=0;for await(let r of this){var a;if(E!==null&&E!==void 0&&(a=E.signal)!==null&&a!==void 0&&a.aborted)throw new I({cause:E.signal.reason});yield[b++,r]}}.call(this)}async function o(E,W=void 0){for await(let b of Z.call(this,E,W))return!0;return!1}async function $(E,W=void 0){if(typeof E!=="function")throw new B("fn",["Function","AsyncFunction"],E);return!await o.call(this,async(...b)=>{return!await E(...b)},W)}async function s(E,W){for await(let b of Z.call(this,E,W))return b;return}async function Y(E,W){if(typeof E!=="function")throw new B("fn",["Function","AsyncFunction"],E);async function b(a,r){return await E(a,r),U}for await(let a of C.call(this,b,W));}function Z(E,W){if(typeof E!=="function")throw new B("fn",["Function","AsyncFunction"],E);async function b(a,r){if(await E(a,r))return a;return U}return C.call(this,b,W)}var N=class extends F{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function m(E,W,b){var a;if(typeof E!=="function")throw new B("reducer",["Function","AsyncFunction"],E);if(b!=null)x(b,"options");if((b===null||b===void 0?void 0:b.signal)!=null)j(b.signal,"options.signal");let r=arguments.length>1;if(b!==null&&b!==void 0&&(a=b.signal)!==null&&a!==void 0&&a.aborted){const Bq=new I(void 0,{cause:b.signal.reason});throw this.once("error",()=>{}),await f(this.destroy(Bq)),Bq}const Qq=new AbortController,Zq=Qq.signal;if(b!==null&&b!==void 0&&b.signal){const Bq={once:!0,[g]:this};b.signal.addEventListener("abort",()=>Qq.abort(),Bq)}let Vq=!1;try{for await(let Bq of this){var Xq;if(Vq=!0,b!==null&&b!==void 0&&(Xq=b.signal)!==null&&Xq!==void 0&&Xq.aborted)throw new I;if(!r)W=Bq,r=!0;else W=await E(W,Bq,{signal:Zq})}if(!Vq&&!r)throw new N}finally{Qq.abort()}return W}async function u(E){if(E!=null)x(E,"options");if((E===null||E===void 0?void 0:E.signal)!=null)j(E.signal,"options.signal");const W=[];for await(let a of this){var b;if(E!==null&&E!==void 0&&(b=E.signal)!==null&&b!==void 0&&b.aborted)throw new I(void 0,{cause:E.signal.reason});c(W,a)}return W}function J(E,W){const b=C.call(this,E,W);return async function*a(){for await(let r of b)yield*r}.call(this)}function z(E){if(E=i(E),D(E))return 0;if(E<0)throw new y("number",">= 0",E);return E}function w(E,W=void 0){if(W!=null)x(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)j(W.signal,"options.signal");return E=z(E),async function*b(){var a;if(W!==null&&W!==void 0&&(a=W.signal)!==null&&a!==void 0&&a.aborted)throw new I;for await(let Qq of this){var r;if(W!==null&&W!==void 0&&(r=W.signal)!==null&&r!==void 0&&r.aborted)throw new I;if(E--<=0)yield Qq}}.call(this)}function S(E,W=void 0){if(W!=null)x(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)j(W.signal,"options.signal");return E=z(E),async function*b(){var a;if(W!==null&&W!==void 0&&(a=W.signal)!==null&&a!==void 0&&a.aborted)throw new I;for await(let Qq of this){var r;if(W!==null&&W!==void 0&&(r=W.signal)!==null&&r!==void 0&&r.aborted)throw new I;if(E-- >0)yield Qq;else return}}.call(this)}M.exports.streamReturningOperators={asIndexedPairs:qq,drop:w,filter:Z,flatMap:J,map:C,take:S},M.exports.promiseReturningOperators={every:$,forEach:Y,reduce:m,toArray:u,some:o,find:s}}}),Pq=$q({"node_modules/readable-stream/lib/internal/streams/destroy.js"(t,M){var{aggregateTwoErrors:B,codes:{ERR_MULTIPLE_CALLBACK:F},AbortError:y}=Mq(),{Symbol:I}=Wq(),{kDestroyed:j,isDestroyed:R,isFinished:x,isServerRequest:g}=Iq(),f="#kDestroy",c="#kConstruct";function _(Z,N,m){if(Z){if(Z.stack,N&&!N.errored)N.errored=Z;if(m&&!m.errored)m.errored=Z}}function i(Z,N){const m=this._readableState,u=this._writableState,J=u||m;if(u&&u.destroyed||m&&m.destroyed){if(typeof N==="function")N();return this}if(_(Z,u,m),u)u.destroyed=!0;if(m)m.destroyed=!0;if(!J.constructed)this.once(f,(z)=>{D(this,B(z,Z),N)});else D(this,Z,N);return this}function D(Z,N,m){let u=!1;function J(z){if(u)return;u=!0;const{_readableState:w,_writableState:S}=Z;if(_(z,S,w),S)S.closed=!0;if(w)w.closed=!0;if(typeof m==="function")m(z);if(z)Hq(p,Z,z);else Hq(P,Z)}try{Z._destroy(N||null,J)}catch(z){J(z)}}function p(Z,N){A(Z,N),P(Z)}function P(Z){const{_readableState:N,_writableState:m}=Z;if(m)m.closeEmitted=!0;if(N)N.closeEmitted=!0;if(m&&m.emitClose||N&&N.emitClose)Z.emit("close")}function A(Z,N){const m=Z?._readableState,u=Z?._writableState;if(u?.errorEmitted||m?.errorEmitted)return;if(u)u.errorEmitted=!0;if(m)m.errorEmitted=!0;Z?.emit?.("error",N)}function K(){const Z=this._readableState,N=this._writableState;if(Z)Z.constructed=!0,Z.closed=!1,Z.closeEmitted=!1,Z.destroyed=!1,Z.errored=null,Z.errorEmitted=!1,Z.reading=!1,Z.ended=Z.readable===!1,Z.endEmitted=Z.readable===!1;if(N)N.constructed=!0,N.destroyed=!1,N.closed=!1,N.closeEmitted=!1,N.errored=null,N.errorEmitted=!1,N.finalCalled=!1,N.prefinished=!1,N.ended=N.writable===!1,N.ending=N.writable===!1,N.finished=N.writable===!1}function U(Z,N,m){const u=Z?._readableState,J=Z?._writableState;if(J&&J.destroyed||u&&u.destroyed)return this;if(u&&u.autoDestroy||J&&J.autoDestroy)Z.destroy(N);else if(N){if(Error.captureStackTrace(N),J&&!J.errored)J.errored=N;if(u&&!u.errored)u.errored=N;if(m)Hq(A,Z,N);else A(Z,N)}}function T(Z,N){if(typeof Z._construct!=="function")return;const{_readableState:m,_writableState:u}=Z;if(m)m.constructed=!1;if(u)u.constructed=!1;if(Z.once(c,N),Z.listenerCount(c)>1)return;Hq(C,Z)}function C(Z){let N=!1;function m(u){if(N){U(Z,u!==null&&u!==void 0?u:new F);return}N=!0;const{_readableState:J,_writableState:z}=Z,w=z||J;if(J)J.constructed=!0;if(z)z.constructed=!0;if(w.destroyed)Z.emit(f,u);else if(u)U(Z,u,!0);else Hq(qq,Z)}try{Z._construct(m)}catch(u){m(u)}}function qq(Z){Z.emit(c)}function o(Z){return Z&&Z.setHeader&&typeof Z.abort==="function"}function $(Z){Z.emit("close")}function s(Z,N){Z.emit("error",N),Hq($,Z)}function Y(Z,N){if(!Z||R(Z))return;if(!N&&!x(Z))N=new y;if(g(Z))Z.socket=null,Z.destroy(N);else if(o(Z))Z.abort();else if(o(Z.req))Z.req.abort();else if(typeof Z.destroy==="function")Z.destroy(N);else if(typeof Z.close==="function")Z.close();else if(N)Hq(s,Z);else Hq($,Z);if(!Z.destroyed)Z[j]=!0}M.exports={construct:T,destroyer:Y,destroy:i,undestroy:K,errorOrDestroy:U}}}),Sq=$q({"node_modules/readable-stream/lib/internal/streams/legacy.js"(t,M){var{ArrayIsArray:B,ObjectSetPrototypeOf:F}=Wq();function y(j){if(!(this instanceof y))return new y(j);Tq.call(this,j)}F(y.prototype,Tq.prototype),F(y,Tq),y.prototype.pipe=function(j,R){const x=this;function g(P){if(j.writable&&j.write(P)===!1&&x.pause)x.pause()}x.on("data",g);function f(){if(x.readable&&x.resume)x.resume()}if(j.on("drain",f),!j._isStdio&&(!R||R.end!==!1))x.on("end",_),x.on("close",i);let c=!1;function _(){if(c)return;c=!0,j.end()}function i(){if(c)return;if(c=!0,typeof j.destroy==="function")j.destroy()}function D(P){if(p(),Tq.listenerCount(this,"error")===0)this.emit("error",P)}I(x,"error",D),I(j,"error",D);function p(){x.removeListener("data",g),j.removeListener("drain",f),x.removeListener("end",_),x.removeListener("close",i),x.removeListener("error",D),j.removeListener("error",D),x.removeListener("end",p),x.removeListener("close",p),j.removeListener("close",p)}return x.on("end",p),x.on("close",p),j.on("close",p),j.emit("pipe",x),j};function I(j,R,x){if(typeof j.prependListener==="function")return j.prependListener(R,x);if(!j._events||!j._events[R])j.on(R,x);else if(B(j._events[R]))j._events[R].unshift(x);else j._events[R]=[x,j._events[R]]}M.exports={Stream:y,prependListener:I}}}),gq=$q({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(t,M){var{AbortError:B,codes:F}=Mq(),y=jq(),{ERR_INVALID_ARG_TYPE:I}=F,j=(x,g)=>{if(typeof x!=="object"||!("aborted"in x))throw new I(g,"AbortSignal",x)};function R(x){return!!(x&&typeof x.pipe==="function")}M.exports.addAbortSignal=function x(g,f){if(j(g,"signal"),!R(f))throw new I("stream","stream.Stream",f);return M.exports.addAbortSignalNoValidate(g,f)},M.exports.addAbortSignalNoValidate=function(x,g){if(typeof x!=="object"||!("aborted"in x))return g;const f=()=>{g.destroy(new B(void 0,{cause:x.reason}))};if(x.aborted)f();else x.addEventListener("abort",f),y(g,()=>x.removeEventListener("abort",f));return g}}}),KQ=$q({"node_modules/readable-stream/lib/internal/streams/state.js"(t,M){var{MathFloor:B,NumberIsInteger:F}=Wq(),{ERR_INVALID_ARG_VALUE:y}=Mq().codes;function I(x,g,f){return x.highWaterMark!=null?x.highWaterMark:g?x[f]:null}function j(x){return x?16:16384}function R(x,g,f,c){const _=I(g,c,f);if(_!=null){if(!F(_)||_<0){const i=c?`options.${f}`:"options.highWaterMark";throw new y(i,_)}return B(_)}return j(x.objectMode)}M.exports={getHighWaterMark:R,getDefaultHighWaterMark:j}}}),pq=$q({"node_modules/readable-stream/lib/internal/streams/from.js"(t,M){var{PromisePrototypeThen:B,SymbolAsyncIterator:F,SymbolIterator:y}=Wq(),{ERR_INVALID_ARG_TYPE:I,ERR_STREAM_NULL_VALUES:j}=Mq().codes;function R(x,g,f){let c;if(typeof g==="string"||g instanceof Buffer)return new x({objectMode:!0,...f,read(){this.push(g),this.push(null)}});let _;if(g&&g[F])_=!0,c=g[F]();else if(g&&g[y])_=!1,c=g[y]();else throw new I("iterable",["Iterable"],g);const i=new x({objectMode:!0,highWaterMark:1,...f});let D=!1;i._read=function(){if(!D)D=!0,P()},i._destroy=function(A,K){B(p(A),()=>Hq(K,A),(U)=>Hq(K,U||A))};async function p(A){const K=A!==void 0&&A!==null,U=typeof c.throw==="function";if(K&&U){const{value:T,done:C}=await c.throw(A);if(await T,C)return}if(typeof c.return==="function"){const{value:T}=await c.return();await T}}async function P(){for(;;){try{const{value:A,done:K}=_?await c.next():c.next();if(K)i.push(null);else{const U=A&&typeof A.then==="function"?await A:A;if(U===null)throw D=!1,new j;else if(i.push(U))continue;else D=!1}}catch(A){i.destroy(A)}break}}return i}M.exports=R}}),uq,bq,Dq=$q({"node_modules/readable-stream/lib/internal/streams/readable.js"(t,M){var{ArrayPrototypeIndexOf:B,NumberIsInteger:F,NumberIsNaN:y,NumberParseInt:I,ObjectDefineProperties:j,ObjectKeys:R,ObjectSetPrototypeOf:x,Promise:g,SafeSet:f,SymbolAsyncIterator:c,Symbol:_}=Wq(),i=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{Stream:D,prependListener:p}=Sq();function P(q){if(!(this instanceof P))return new P(q);const Q=this instanceof Lq();if(this._readableState=new i(q,this,Q),q){const{read:O,destroy:G,construct:v,signal:Kq}=q;if(typeof O==="function")this._read=O;if(typeof G==="function")this._destroy=G;if(typeof v==="function")this._construct=v;if(Kq&&!Q)U(Kq,this)}D.call(this,q),Z.construct(this,()=>{if(this._readableState.needReadable)s(this,this._readableState)})}x(P.prototype,D.prototype),x(P,D),P.prototype.on=function(q,Q){const O=D.prototype.on.call(this,q,Q),G=this._readableState;if(q==="data")if(G.readableListening=this.listenerCount("readable")>0,G.flowing!==!1)n&&d("in flowing mode!",this.__id),this.resume();else n&&d("in readable mode!",this.__id);else if(q==="readable"){if(n&&d("readable listener added!",this.__id),!G.endEmitted&&!G.readableListening){if(G.readableListening=G.needReadable=!0,G.flowing=!1,G.emittedReadable=!1,n&&d("on readable - state.length, reading, emittedReadable",G.length,G.reading,G.emittedReadable,this.__id),G.length)Y(this,G);else if(!G.reading)Hq(Jq,this)}else if(G.endEmitted)n&&d("end already emitted...",this.__id)}return O};class A extends P{#q;#Q;#X;#H;constructor(q,Q){const{objectMode:O,highWaterMark:G,encoding:v,signal:Kq}=q;super({objectMode:O,highWaterMark:G,encoding:v,signal:Kq});this.#X=[],this.#q=void 0,this.#H=Q,this.#Q=!1}#J(){var q=this.#X,Q=0,O=q.length;for(;Q0)this.#X=[];return!1}#K(q){q.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){n&&d("ReadableFromWeb _read()",this.__id);var q=this.#H,Q=this.#q;if(q)Q=this.#q=q.getReader(),this.#H=void 0;else if(this.#J())return;var O;try{do{var G=!1,v;const Kq=Q.readMany();if(Oq(Kq)){if({done:G,value:v}=await Kq,this.#Q){this.#X.push(...v);return}}else({done:G,value:v}=Kq);if(G){this.#K(Q);return}if(!this.push(v[0])){this.#X=v.slice(1);return}for(let Yq=1,_q=v.length;Yq<_q;Yq++)if(!this.push(v[Yq])){this.#X=v.slice(Yq+1);return}}while(!this.#Q)}catch(Kq){O=Kq}finally{if(O)throw O}}_destroy(q,Q){if(!this.#Q){var O=this.#q;if(O)this.#q=void 0,O.cancel(q).finally(()=>{this.#Q=!0,Q(q)});return}try{Q(q)}catch(G){globalThis.reportError(G)}}}bq=A;function K(q,Q={}){if(!qQ(q))throw new m("readableStream","ReadableStream",q);S(Q,"options");const{highWaterMark:O,encoding:G,objectMode:v=!1,signal:Kq}=Q;if(G!==void 0&&!Buffer.isEncoding(G))throw new JQ(G,"options.encoding");return QQ(v,"options.objectMode"),UQ(P,q,Q)||new A({highWaterMark:O,encoding:G,objectMode:v,signal:Kq},q)}M.exports=P,uq=K;var{addAbortSignal:U}=gq(),T=jq();const{maybeReadMore:C,resume:qq,emitReadable:o,onEofChunk:$}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function s(q,Q){process.nextTick(C,q,Q)}function Y(q,Q){n&&d("NativeReadable - emitReadable",q.__id),o(q,Q)}var Z=Pq(),{aggregateTwoErrors:N,codes:{ERR_INVALID_ARG_TYPE:m,ERR_METHOD_NOT_IMPLEMENTED:u,ERR_OUT_OF_RANGE:J,ERR_STREAM_PUSH_AFTER_EOF:z,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:w}}=Mq(),{validateObject:S}=Cq(),E=pq(),W=()=>{},{errorOrDestroy:b}=Z;P.prototype.destroy=Z.destroy,P.prototype._undestroy=Z.undestroy,P.prototype._destroy=function(q,Q){Q(q)},P.prototype[Tq.captureRejectionSymbol]=function(q){this.destroy(q)},P.prototype.push=function(q,Q){return a(this,q,Q,!1)},P.prototype.unshift=function(q,Q){return a(this,q,Q,!0)};function a(q,Q,O,G){n&&d("readableAddChunk",Q,q.__id);const v=q._readableState;let Kq;if(!v.objectMode){if(typeof Q==="string"){if(O=O||v.defaultEncoding,v.encoding!==O)if(G&&v.encoding)Q=Buffer.from(Q,O).toString(v.encoding);else Q=Buffer.from(Q,O),O=""}else if(Q instanceof Buffer)O="";else if(D._isUint8Array(Q)){if(G||!v.decoder)Q=D._uint8ArrayToBuffer(Q);O=""}else if(Q!=null)Kq=new m("chunk",["string","Buffer","Uint8Array"],Q)}if(Kq)b(q,Kq);else if(Q===null)v.reading=!1,$(q,v);else if(v.objectMode||Q&&Q.length>0)if(G)if(v.endEmitted)b(q,new w);else if(v.destroyed||v.errored)return!1;else r(q,v,Q,!0);else if(v.ended)b(q,new z);else if(v.destroyed||v.errored)return!1;else if(v.reading=!1,v.decoder&&!O)if(Q=v.decoder.write(Q),v.objectMode||Q.length!==0)r(q,v,Q,!1);else s(q,v);else r(q,v,Q,!1);else if(!G)v.reading=!1,s(q,v);return!v.ended&&(v.length0){if(Q.multiAwaitDrain)Q.awaitDrainWriters.clear();else Q.awaitDrainWriters=null;Q.dataEmitted=!0,q.emit("data",O)}else{if(Q.length+=Q.objectMode?1:O.length,G)Q.buffer.unshift(O);else Q.buffer.push(O);if(n&&d("needReadable @ addChunk",Q.needReadable,q.__id),Q.needReadable)Y(q,Q)}s(q,Q)}P.prototype.isPaused=function(){const q=this._readableState;return q.paused===!0||q.flowing===!1},P.prototype.setEncoding=function(q){const Q=new rq(q);this._readableState.decoder=Q,this._readableState.encoding=this._readableState.decoder.encoding;const O=this._readableState.buffer;let G="";for(let v=O.length;v>0;v--)G+=Q.write(O.shift());if(G!=="")O.push(G);return this._readableState.length=G.length,this};var Qq=1073741824;function Zq(q){if(q>Qq)throw new J("size","<= 1GiB",q);else q--,q|=q>>>1,q|=q>>>2,q|=q>>>4,q|=q>>>8,q|=q>>>16,q++;return q}function Vq(q,Q){if(q<=0||Q.length===0&&Q.ended)return 0;if(Q.objectMode)return 1;if(y(q)){if(Q.flowing&&Q.length)return Q.buffer.first().length;return Q.length}if(q<=Q.length)return q;return Q.ended?Q.length:0}P.prototype.read=function(q){if(n&&d("read - n =",q,this.__id),!F(q))q=I(q,10);const Q=this._readableState,O=q;if(q>Q.highWaterMark)Q.highWaterMark=Zq(q);if(q!==0)Q.emittedReadable=!1;if(q===0&&Q.needReadable&&((Q.highWaterMark!==0?Q.length>=Q.highWaterMark:Q.length>0)||Q.ended)){if(n&&d("read: emitReadable or endReadable",Q.length,Q.ended,this.__id),Q.length===0&&Q.ended)H(this);else Y(this,Q);return null}if(q=Vq(q,Q),q===0&&Q.ended){if(n&&d("read: calling endReadable if length 0 -- length, state.ended",Q.length,Q.ended,this.__id),Q.length===0)H(this);return null}let G=Q.needReadable;if(n&&d("need readable",G,this.__id),Q.length===0||Q.length-q0)Kq=X(q,Q);else Kq=null;if(n&&d("ret @ read",Kq,this.__id),Kq===null)Q.needReadable=Q.length<=Q.highWaterMark,n&&d("state.length while ret = null",Q.length,this.__id),q=0;else if(Q.length-=q,Q.multiAwaitDrain)Q.awaitDrainWriters.clear();else Q.awaitDrainWriters=null;if(Q.length===0){if(!Q.ended)Q.needReadable=!0;if(O!==q&&Q.ended)H(this)}if(Kq!==null&&!Q.errorEmitted&&!Q.closeEmitted)Q.dataEmitted=!0,this.emit("data",Kq);return Kq},P.prototype._read=function(q){throw new u("_read()")},P.prototype.pipe=function(q,Q){const O=this,G=this._readableState;if(G.pipes.length===1){if(!G.multiAwaitDrain)G.multiAwaitDrain=!0,G.awaitDrainWriters=new f(G.awaitDrainWriters?[G.awaitDrainWriters]:[])}G.pipes.push(q),n&&d("pipe count=%d opts=%j",G.pipes.length,Q,O.__id);const Kq=(!Q||Q.end!==!1)&&q!==process.stdout&&q!==process.stderr?_q:xq;if(G.endEmitted)Hq(Kq);else O.once("end",Kq);q.on("unpipe",Yq);function Yq(Aq,Fq){if(n&&d("onunpipe",O.__id),Aq===O){if(Fq&&Fq.hasUnpiped===!1)Fq.hasUnpiped=!0,oq()}}function _q(){n&&d("onend",O.__id),q.end()}let Nq,kq=!1;function oq(){if(n&&d("cleanup",O.__id),q.removeListener("close",vq),q.removeListener("finish",Rq),Nq)q.removeListener("drain",Nq);if(q.removeListener("error",wq),q.removeListener("unpipe",Yq),O.removeListener("end",_q),O.removeListener("end",xq),O.removeListener("data",hq),kq=!0,Nq&&G.awaitDrainWriters&&(!q._writableState||q._writableState.needDrain))Nq()}function yq(){if(!kq){if(G.pipes.length===1&&G.pipes[0]===q)n&&d("false write response, pause",0,O.__id),G.awaitDrainWriters=q,G.multiAwaitDrain=!1;else if(G.pipes.length>1&&G.pipes.includes(q))n&&d("false write response, pause",G.awaitDrainWriters.size,O.__id),G.awaitDrainWriters.add(q);O.pause()}if(!Nq)Nq=Xq(O,q),q.on("drain",Nq)}O.on("data",hq);function hq(Aq){n&&d("ondata",O.__id);const Fq=q.write(Aq);if(n&&d("dest.write",Fq,O.__id),Fq===!1)yq()}function wq(Aq){if(d("onerror",Aq),xq(),q.removeListener("error",wq),q.listenerCount("error")===0){const Fq=q._writableState||q._readableState;if(Fq&&!Fq.errorEmitted)b(q,Aq);else q.emit("error",Aq)}}p(q,"error",wq);function vq(){q.removeListener("finish",Rq),xq()}q.once("close",vq);function Rq(){d("onfinish"),q.removeListener("close",vq),xq()}q.once("finish",Rq);function xq(){d("unpipe"),O.unpipe(q)}if(q.emit("pipe",O),q.writableNeedDrain===!0){if(G.flowing)yq()}else if(!G.flowing)d("pipe resume"),O.resume();return q};function Xq(q,Q){return function O(){const G=q._readableState;if(G.awaitDrainWriters===Q)d("pipeOnDrain",1),G.awaitDrainWriters=null;else if(G.multiAwaitDrain)d("pipeOnDrain",G.awaitDrainWriters.size),G.awaitDrainWriters.delete(Q);if((!G.awaitDrainWriters||G.awaitDrainWriters.size===0)&&q.listenerCount("data"))q.resume()}}P.prototype.unpipe=function(q){const Q=this._readableState,O={hasUnpiped:!1};if(Q.pipes.length===0)return this;if(!q){const v=Q.pipes;Q.pipes=[],this.pause();for(let Kq=0;Kq0,Q.resumeScheduled&&Q.paused===!1)Q.flowing=!0;else if(q.listenerCount("data")>0)q.resume();else if(!Q.readableListening)Q.flowing=null}function Jq(q){n&&d("on readable nextTick, calling read(0)",q.__id),q.read(0)}P.prototype.resume=function(){const q=this._readableState;if(!q.flowing)n&&d("resume",this.__id),q.flowing=!q.readableListening,qq(this,q);return q.paused=!1,this},P.prototype.pause=function(){if(n&&d("call pause flowing=%j",this._readableState.flowing,this.__id),this._readableState.flowing!==!1)n&&d("pause",this.__id),this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},P.prototype.wrap=function(q){let Q=!1;q.on("data",(G)=>{if(!this.push(G)&&q.pause)Q=!0,q.pause()}),q.on("end",()=>{this.push(null)}),q.on("error",(G)=>{b(this,G)}),q.on("close",()=>{this.destroy()}),q.on("destroy",()=>{this.destroy()}),this._read=()=>{if(Q&&q.resume)Q=!1,q.resume()};const O=R(q);for(let G=1;G{v=Yq?N(v,Yq):null,O(),O=W});try{while(!0){const Yq=q.destroyed?null:q.read();if(Yq!==null)yield Yq;else if(v)throw v;else if(v===null)return;else await new g(G)}}catch(Yq){throw v=N(v,Yq),v}finally{if((v||(Q===null||Q===void 0?void 0:Q.destroyOnReturn)!==!1)&&(v===void 0||q._readableState.autoDestroy))Z.destroyer(q,null);else q.off("readable",G),Kq()}}j(P.prototype,{readable:{get(){const q=this._readableState;return!!q&&q.readable!==!1&&!q.destroyed&&!q.errorEmitted&&!q.endEmitted},set(q){if(this._readableState)this._readableState.readable=!!q}},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(q){if(this._readableState)this._readableState.flowing=q}},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(q){if(!this._readableState)return;this._readableState.destroyed=q}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),P._fromList=X;function X(q,Q){if(Q.length===0)return null;let O;if(Q.objectMode)O=Q.buffer.shift();else if(!q||q>=Q.length){if(Q.decoder)O=Q.buffer.join("");else if(Q.buffer.length===1)O=Q.buffer.first();else O=Q.buffer.concat(Q.length);Q.buffer.clear()}else O=Q.buffer.consume(q,Q.decoder);return O}function H(q){const Q=q._readableState;if(n&&d("endEmitted @ endReadable",Q.endEmitted,q.__id),!Q.endEmitted)Q.ended=!0,Hq(L,Q,q)}function L(q,Q){if(n&&d("endReadableNT -- endEmitted, state.length",q.endEmitted,q.length,Q.__id),!q.errored&&!q.closeEmitted&&!q.endEmitted&&q.length===0){if(q.endEmitted=!0,Q.emit("end"),n&&d("end emitted @ endReadableNT",Q.__id),Q.writable&&Q.allowHalfOpen===!1)Hq(l,Q);else if(q.autoDestroy){const O=Q._writableState;if(!O||O.autoDestroy&&(O.finished||O.writable===!1))Q.destroy()}}}function l(q){if(q.writable&&!q.writableEnded&&!q.destroyed)q.end()}P.from=function(q,Q){return E(P,q,Q)};var k={newStreamReadableFromReadableStream:K};function e(){if(k===void 0)k={};return k}P.fromWeb=function(q,Q){return e().newStreamReadableFromReadableStream(q,Q)},P.toWeb=function(q){return e().newReadableStreamFromStreamReadable(q)},P.wrap=function(q,Q){var O,G;return new P({objectMode:(O=(G=q.readableObjectMode)!==null&&G!==void 0?G:q.objectMode)!==null&&O!==void 0?O:!0,...Q,destroy(v,Kq){Z.destroyer(q,v),Kq(v)}}).wrap(q)}}}),mq=$q({"node_modules/readable-stream/lib/internal/streams/writable.js"(t,M){var{ArrayPrototypeSlice:B,Error:F,FunctionPrototypeSymbolHasInstance:y,ObjectDefineProperty:I,ObjectDefineProperties:j,ObjectSetPrototypeOf:R,StringPrototypeToLowerCase:x,Symbol:g,SymbolHasInstance:f}=Wq(),c=Sq().Stream,_=Pq(),{addAbortSignal:i}=gq(),{getHighWaterMark:D,getDefaultHighWaterMark:p}=KQ(),{ERR_INVALID_ARG_TYPE:P,ERR_METHOD_NOT_IMPLEMENTED:A,ERR_MULTIPLE_CALLBACK:K,ERR_STREAM_CANNOT_PIPE:U,ERR_STREAM_DESTROYED:T,ERR_STREAM_ALREADY_FINISHED:C,ERR_STREAM_NULL_VALUES:qq,ERR_STREAM_WRITE_AFTER_END:o,ERR_UNKNOWN_ENCODING:$}=Mq().codes,{errorOrDestroy:s}=_;function Y(X={}){const H=this instanceof Lq();if(!H&&!y(Y,this))return new Y(X);if(this._writableState=new m(X,this,H),X){if(typeof X.write==="function")this._write=X.write;if(typeof X.writev==="function")this._writev=X.writev;if(typeof X.destroy==="function")this._destroy=X.destroy;if(typeof X.final==="function")this._final=X.final;if(typeof X.construct==="function")this._construct=X.construct;if(X.signal)i(X.signal,this)}c.call(this,X),_.construct(this,()=>{const L=this._writableState;if(!L.writing)r(this,L);Xq(this,L)})}R(Y.prototype,c.prototype),R(Y,c),M.exports=Y;function Z(){}var N=g("kOnFinished");function m(X,H,L){if(typeof L!=="boolean")L=H instanceof Lq();if(this.objectMode=!!(X&&X.objectMode),L)this.objectMode=this.objectMode||!!(X&&X.writableObjectMode);this.highWaterMark=X?D(this,X,"writableHighWaterMark",L):p(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const l=!!(X&&X.decodeStrings===!1);this.decodeStrings=!l,this.defaultEncoding=X&&X.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=E.bind(void 0,H),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,u(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!X||X.emitClose!==!1,this.autoDestroy=!X||X.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[N]=[]}function u(X){X.buffered=[],X.bufferedIndex=0,X.allBuffers=!0,X.allNoop=!0}m.prototype.getBuffer=function X(){return B(this.buffered,this.bufferedIndex)},I(m.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),I(Y,f,{value:function(X){if(y(this,X))return!0;if(this!==Y)return!1;return X&&X._writableState instanceof m}}),Y.prototype.pipe=function(){s(this,new U)};function J(X,H,L,l){const k=X._writableState;if(typeof L==="function")l=L,L=k.defaultEncoding;else{if(!L)L=k.defaultEncoding;else if(L!=="buffer"&&!Buffer.isEncoding(L))throw new $(L);if(typeof l!=="function")l=Z}if(H===null)throw new qq;else if(!k.objectMode)if(typeof H==="string"){if(k.decodeStrings!==!1)H=Buffer.from(H,L),L="buffer"}else if(H instanceof Buffer)L="buffer";else if(c._isUint8Array(H))H=c._uint8ArrayToBuffer(H),L="buffer";else throw new P("chunk",["string","Buffer","Uint8Array"],H);let e;if(k.ending)e=new o;else if(k.destroyed)e=new T("write");if(e)return Hq(l,e),s(X,e,!0),e;return k.pendingcb++,z(X,k,H,L,l)}Y.prototype.write=function(X,H,L){return J(this,X,H,L)===!0},Y.prototype.cork=function(){this._writableState.corked++},Y.prototype.uncork=function(){const X=this._writableState;if(X.corked){if(X.corked--,!X.writing)r(this,X)}},Y.prototype.setDefaultEncoding=function X(H){if(typeof H==="string")H=x(H);if(!Buffer.isEncoding(H))throw new $(H);return this._writableState.defaultEncoding=H,this};function z(X,H,L,l,k){const e=H.objectMode?1:L.length;H.length+=e;const q=H.lengthL.bufferedIndex)r(X,L);if(l)if(L.afterWriteTickInfo!==null&&L.afterWriteTickInfo.cb===k)L.afterWriteTickInfo.count++;else L.afterWriteTickInfo={count:1,cb:k,stream:X,state:L},Hq(W,L.afterWriteTickInfo);else b(X,L,1,k)}}function W({stream:X,state:H,count:L,cb:l}){return H.afterWriteTickInfo=null,b(X,H,L,l)}function b(X,H,L,l){if(!H.ending&&!X.destroyed&&H.length===0&&H.needDrain)H.needDrain=!1,X.emit("drain");while(L-- >0)H.pendingcb--,l();if(H.destroyed)a(H);Xq(X,H)}function a(X){if(X.writing)return;for(let k=X.bufferedIndex;k1&&X._writev){H.pendingcb-=e-1;const Q=H.allNoop?Z:(G)=>{for(let v=q;v256)L.splice(0,q),H.bufferedIndex=0;else H.bufferedIndex=q}H.bufferProcessing=!1}Y.prototype._write=function(X,H,L){if(this._writev)this._writev([{chunk:X,encoding:H}],L);else throw new A("_write()")},Y.prototype._writev=null,Y.prototype.end=function(X,H,L,l=!1){const k=this._writableState;if(n&&d("end",k,this.__id),typeof X==="function")L=X,X=null,H=null;else if(typeof H==="function")L=H,H=null;let e;if(X!==null&&X!==void 0){let q;if(!l)q=J(this,X,H);else q=this.write(X,H);if(q instanceof F)e=q}if(k.corked)k.corked=1,this.uncork();if(e)this.emit("error",e);else if(!k.errored&&!k.ending)k.ending=!0,Xq(this,k,!0),k.ended=!0;else if(k.finished)e=new C("end");else if(k.destroyed)e=new T("end");if(typeof L==="function")if(e||k.finished)Hq(L,e);else k[N].push(L);return this};function Qq(X,H){var L=X.ending&&!X.destroyed&&X.constructed&&X.length===0&&!X.errored&&X.buffered.length===0&&!X.finished&&!X.writing&&!X.errorEmitted&&!X.closeEmitted;return d("needFinish",L,H),L}function Zq(X,H){let L=!1;function l(k){if(L){s(X,k!==null&&k!==void 0?k:K());return}if(L=!0,H.pendingcb--,k){const e=H[N].splice(0);for(let q=0;q{if(Qq(k))Bq(l,k);else k.pendingcb--},X,H);else if(Qq(H))H.pendingcb++,Bq(X,H)}}function Bq(X,H){H.pendingcb--,H.finished=!0;const L=H[N].splice(0);for(let l=0;l{if(S!=null)throw new _("nully","body",S)},(S)=>{i(z,S)});return z=new T({objectMode:!0,readable:!1,write:N,final(S){m(async()=>{try{await w,Hq(S,null)}catch(E){Hq(S,E)}})},destroy:u})}throw new _("Iterable, AsyncIterable or AsyncFunction",s,Z)}if(K($))return o($.arrayBuffer());if(y($))return A(T,$,{objectMode:!0,writable:!1});if(typeof($===null||$===void 0?void 0:$.writable)==="object"||typeof($===null||$===void 0?void 0:$.readable)==="object"){const Z=$!==null&&$!==void 0&&$.readable?j($===null||$===void 0?void 0:$.readable)?$===null||$===void 0?void 0:$.readable:o($.readable):void 0,N=$!==null&&$!==void 0&&$.writable?R($===null||$===void 0?void 0:$.writable)?$===null||$===void 0?void 0:$.writable:o($.writable):void 0;return qq({readable:Z,writable:N})}const Y=$===null||$===void 0?void 0:$.then;if(typeof Y==="function"){let Z;return U(Y,$,(N)=>{if(N!=null)Z.push(N);Z.push(null)},(N)=>{i(Z,N)}),Z=new T({objectMode:!0,writable:!1,read(){}})}throw new c(s,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],$)};function C(o){let{promise:$,resolve:s}=P();const Y=new AbortController,Z=Y.signal;return{value:o(async function*(){while(!0){const m=$;$=null;const{chunk:u,done:J,cb:z}=await m;if(Hq(z),J)return;if(Z.aborted)throw new f(void 0,{cause:Z.reason});({promise:$,resolve:s}=P()),yield u}}(),{signal:Z}),write(m,u,J){const z=s;s=null,z({chunk:m,done:!1,cb:J})},final(m){const u=s;s=null,u({done:!0,cb:m})},destroy(m,u){Y.abort(),u(m)}}}function qq(o){const $=o.readable&&typeof o.readable.read!=="function"?p.wrap(o.readable):o.readable,s=o.writable;let Y=!!B($),Z=!!F(s),N,m,u,J,z;function w(S){const E=J;if(J=null,E)E(S);else if(S)z.destroy(S);else if(!Y&&!Z)z.destroy()}if(z=new T({readableObjectMode:!!($!==null&&$!==void 0&&$.readableObjectMode),writableObjectMode:!!(s!==null&&s!==void 0&&s.writableObjectMode),readable:Y,writable:Z}),Z)g(s,(S)=>{if(Z=!1,S)i($,S);w(S)}),z._write=function(S,E,W){if(s.write(S,E))W();else N=W},z._final=function(S){s.end(),m=S},s.on("drain",function(){if(N){const S=N;N=null,S()}}),s.on("finish",function(){if(m){const S=m;m=null,S()}});if(Y)g($,(S)=>{if(Y=!1,S)i($,S);w(S)}),$.on("readable",function(){if(u){const S=u;u=null,S()}}),$.on("end",function(){z.push(null)}),z._read=function(){while(!0){const S=$.read();if(S===null){u=z._read;return}if(!z.push(S))return}};return z._destroy=function(S,E){if(!S&&J!==null)S=new f;if(u=null,N=null,m=null,J===null)E(S);else J=E,i(s,S),i($,S)},z}}}),Lq=$q({"node_modules/readable-stream/lib/internal/streams/duplex.js"(t,M){var{ObjectDefineProperties:B,ObjectGetOwnPropertyDescriptor:F,ObjectKeys:y,ObjectSetPrototypeOf:I}=Wq(),j=Dq();function R(_){if(!(this instanceof R))return new R(_);if(j.call(this,_),Gq.call(this,_),_){if(this.allowHalfOpen=_.allowHalfOpen!==!1,_.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(_.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}M.exports=R,I(R.prototype,j.prototype),I(R,j);for(var x in Gq.prototype)if(!R.prototype[x])R.prototype[x]=Gq.prototype[x];B(R.prototype,{writable:F(Gq.prototype,"writable"),writableHighWaterMark:F(Gq.prototype,"writableHighWaterMark"),writableObjectMode:F(Gq.prototype,"writableObjectMode"),writableBuffer:F(Gq.prototype,"writableBuffer"),writableLength:F(Gq.prototype,"writableLength"),writableFinished:F(Gq.prototype,"writableFinished"),writableCorked:F(Gq.prototype,"writableCorked"),writableEnded:F(Gq.prototype,"writableEnded"),writableNeedDrain:F(Gq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(_){if(this._readableState&&this._writableState)this._readableState.destroyed=_,this._writableState.destroyed=_}}});var g;function f(){if(g===void 0)g={};return g}R.fromWeb=function(_,i){return f().newStreamDuplexFromReadableWritablePair(_,i)},R.toWeb=function(_){return f().newReadableWritablePairFromDuplex(_)};var c;R.from=function(_){if(!c)c=ZQ();return c(_,"body")}}}),cq=$q({"node_modules/readable-stream/lib/internal/streams/transform.js"(t,M){var{ObjectSetPrototypeOf:B,Symbol:F}=Wq(),{ERR_METHOD_NOT_IMPLEMENTED:y}=Mq().codes,I=Lq();function j(f){if(!(this instanceof j))return new j(f);if(I.call(this,f),this._readableState.sync=!1,this[R]=null,f){if(typeof f.transform==="function")this._transform=f.transform;if(typeof f.flush==="function")this._flush=f.flush}this.on("prefinish",g.bind(this))}B(j.prototype,I.prototype),B(j,I),M.exports=j;var R=F("kCallback");function x(f){if(typeof this._flush==="function"&&!this.destroyed)this._flush((c,_)=>{if(c){if(f)f(c);else this.destroy(c);return}if(_!=null)this.push(_);if(this.push(null),f)f()});else if(this.push(null),f)f()}function g(){if(this._final!==x)x.call(this)}j.prototype._final=x,j.prototype._transform=function(f,c,_){throw new y("_transform()")},j.prototype._write=function(f,c,_){const i=this._readableState,D=this._writableState,p=i.length;this._transform(f,c,(P,A)=>{if(P){_(P);return}if(A!=null)this.push(A);if(D.ended||p===i.length||i.length{S=!0});const E=I(J,{readable:z,writable:w},(W)=>{S=!W});return{destroy:(W)=>{if(S)return;S=!0,R.destroyer(J,W||new i("pipe"))},cleanup:E}}function $(J){return p(J[J.length-1],"streams[stream.length - 1]"),J.pop()}function s(J){if(A(J))return J;else if(U(J))return Y(J);throw new f("val",["Readable","Iterable","AsyncIterable"],J)}async function*Y(J){if(!qq)qq=Dq();yield*qq.prototype[y].call(J)}async function Z(J,z,w,{end:S}){let E,W=null;const b=(Qq)=>{if(Qq)E=Qq;if(W){const Zq=W;W=null,Zq()}},a=()=>new F((Qq,Zq)=>{if(E)Zq(E);else W=()=>{if(E)Zq(E);else Qq()}});z.on("drain",b);const r=I(z,{readable:!1},b);try{if(z.writableNeedDrain)await a();for await(let Qq of J)if(!z.write(Qq))await a();if(S)z.end();await a(),w()}catch(Qq){w(E!==Qq?g(E,Qq):Qq)}finally{r(),z.off("drain",b)}}function N(...J){return m(J,j($(J)))}function m(J,z,w){if(J.length===1&&B(J[0]))J=J[0];if(J.length<2)throw new _("streams");const S=new AbortController,E=S.signal,W=w===null||w===void 0?void 0:w.signal,b=[];P(W,"options.signal");function a(){Bq(new D)}W===null||W===void 0||W.addEventListener("abort",a);let r,Qq;const Zq=[];let Vq=0;function Xq(h){Bq(h,--Vq===0)}function Bq(h,X){if(h&&(!r||r.code==="ERR_STREAM_PREMATURE_CLOSE"))r=h;if(!r&&!X)return;while(Zq.length)Zq.shift()(r);if(W===null||W===void 0||W.removeEventListener("abort",a),S.abort(),X){if(!r)b.forEach((H)=>H());Hq(z,r,Qq)}}let Jq;for(let h=0;h0,l=H||(w===null||w===void 0?void 0:w.end)!==!1,k=h===J.length-1;if(T(X)){let e=function(q){if(q&&q.name!=="AbortError"&&q.code!=="ERR_STREAM_PREMATURE_CLOSE")Xq(q)};if(l){const{destroy:q,cleanup:Q}=o(X,H,L);if(Zq.push(q),K(X)&&k)b.push(Q)}if(X.on("error",e),K(X)&&k)b.push(()=>{X.removeListener("error",e)})}if(h===0)if(typeof X==="function"){if(Jq=X({signal:E}),!A(Jq))throw new c("Iterable, AsyncIterable or Stream","source",Jq)}else if(A(X)||U(X))Jq=X;else Jq=x.from(X);else if(typeof X==="function")if(Jq=s(Jq),Jq=X(Jq,{signal:E}),H){if(!A(Jq,!0))throw new c("AsyncIterable",`transform[${h-1}]`,Jq)}else{var V;if(!C)C=dq();const e=new C({objectMode:!0}),q=(V=Jq)===null||V===void 0?void 0:V.then;if(typeof q==="function")Vq++,q.call(Jq,(G)=>{if(Qq=G,G!=null)e.write(G);if(l)e.end();Hq(Xq)},(G)=>{e.destroy(G),Hq(Xq,G)});else if(A(Jq,!0))Vq++,Z(Jq,e,Xq,{end:l});else throw new c("AsyncIterable or Promise","destination",Jq);Jq=e;const{destroy:Q,cleanup:O}=o(Jq,!1,!0);if(Zq.push(Q),k)b.push(O)}else if(T(X)){if(U(Jq)){Vq+=2;const e=u(Jq,X,Xq,{end:l});if(K(X)&&k)b.push(e)}else if(A(Jq))Vq++,Z(Jq,X,Xq,{end:l});else throw new f("val",["Readable","Iterable","AsyncIterable"],Jq);Jq=X}else Jq=x.from(X)}if(E!==null&&E!==void 0&&E.aborted||W!==null&&W!==void 0&&W.aborted)Hq(a);return Jq}function u(J,z,w,{end:S}){if(J.pipe(z,{end:S}),S)J.once("end",()=>z.end());else w();return I(J,{readable:!0,writable:!1},(E)=>{const W=J._readableState;if(E&&E.code==="ERR_STREAM_PREMATURE_CLOSE"&&W&&W.ended&&!W.errored&&!W.errorEmitted)J.once("end",w).once("error",w);else w(E)}),I(z,{readable:!1,writable:!0},w)}M.exports={pipelineImpl:m,pipeline:N}}}),BQ=$q({"node_modules/readable-stream/lib/internal/streams/compose.js"(t,M){var{pipeline:B}=fq(),F=Lq(),{destroyer:y}=Pq(),{isNodeStream:I,isReadable:j,isWritable:R}=Iq(),{AbortError:x,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:f}}=Mq();M.exports=function c(..._){if(_.length===0)throw new f("streams");if(_.length===1)return F.from(_[0]);const i=[..._];if(typeof _[0]==="function")_[0]=F.from(_[0]);if(typeof _[_.length-1]==="function"){const $=_.length-1;_[$]=F.from(_[$])}for(let $=0;$<_.length;++$){if(!I(_[$]))continue;if($<_.length-1&&!j(_[$]))throw new g(`streams[${$}]`,i[$],"must be readable");if($>0&&!R(_[$]))throw new g(`streams[${$}]`,i[$],"must be writable")}let D,p,P,A,K;function U($){const s=A;if(A=null,s)s($);else if($)K.destroy($);else if(!o&&!qq)K.destroy()}const T=_[0],C=B(_,U),qq=!!R(T),o=!!j(C);if(K=new F({writableObjectMode:!!(T!==null&&T!==void 0&&T.writableObjectMode),readableObjectMode:!!(C!==null&&C!==void 0&&C.writableObjectMode),writable:qq,readable:o}),qq)K._write=function($,s,Y){if(T.write($,s))Y();else D=Y},K._final=function($){T.end(),p=$},T.on("drain",function(){if(D){const $=D;D=null,$()}}),C.on("finish",function(){if(p){const $=p;p=null,$()}});if(o)C.on("readable",function(){if(P){const $=P;P=null,$()}}),C.on("end",function(){K.push(null)}),K._read=function(){while(!0){const $=C.read();if($===null){P=K._read;return}if(!K.push($))return}};return K._destroy=function($,s){if(!$&&A!==null)$=new x;if(P=null,D=null,p=null,A===null)s($);else A=s,y(C,$)},K}}}),lq=$q({"node_modules/readable-stream/lib/stream/promises.js"(t,M){var{ArrayPrototypePop:B,Promise:F}=Wq(),{isIterable:y,isNodeStream:I}=Iq(),{pipelineImpl:j}=fq(),{finished:R}=jq();function x(...g){return new F((f,c)=>{let _,i;const D=g[g.length-1];if(D&&typeof D==="object"&&!I(D)&&!y(D)){const p=B(g);_=p.signal,i=p.end}j(g,(p,P)=>{if(p)c(p);else f(P)},{signal:_,end:i})})}M.exports={finished:R,pipeline:x}}}),YQ=$q({"node_modules/readable-stream/lib/stream.js"(t,M){var{ObjectDefineProperty:B,ObjectKeys:F,ReflectApply:y}=Wq(),{promisify:{custom:I}}=Eq(),{streamReturningOperators:j,promiseReturningOperators:R}=HQ(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:x}}=Mq(),g=BQ(),{pipeline:f}=fq(),{destroyer:c}=Pq(),_=jq(),i=lq(),D=Iq(),p=M.exports=Sq().Stream;p.isDisturbed=D.isDisturbed,p.isErrored=D.isErrored,p.isWritable=D.isWritable,p.isReadable=D.isReadable,p.Readable=Dq();for(let A of F(j)){let K=function(...T){if(new.target)throw x();return p.Readable.from(y(U,this,T))};const U=j[A];B(K,"name",{value:U.name}),B(K,"length",{value:U.length}),B(p.Readable.prototype,A,{value:K,enumerable:!1,configurable:!0,writable:!0})}for(let A of F(R)){let K=function(...T){if(new.target)throw x();return y(U,this,T)};const U=R[A];B(K,"name",{value:U.name}),B(K,"length",{value:U.length}),B(p.Readable.prototype,A,{value:K,enumerable:!1,configurable:!0,writable:!0})}p.Writable=mq(),p.Duplex=Lq(),p.Transform=cq(),p.PassThrough=dq(),p.pipeline=f;var{addAbortSignal:P}=gq();p.addAbortSignal=P,p.finished=_,p.destroy=c,p.compose=g,B(p,"promises",{configurable:!0,enumerable:!0,get(){return i}}),B(f,I,{enumerable:!0,get(){return i.pipeline}}),B(_,I,{enumerable:!0,get(){return i.finished}}),p.Stream=p,p._isUint8Array=function A(K){return K instanceof Uint8Array},p._uint8ArrayToBuffer=function A(K){return new Buffer(K.buffer,K.byteOffset,K.byteLength)}}}),$Q=$q({"node_modules/readable-stream/lib/ours/index.js"(t,M){const B=YQ(),F=lq(),y=B.Readable.destroy;M.exports=B,M.exports._uint8ArrayToBuffer=B._uint8ArrayToBuffer,M.exports._isUint8Array=B._isUint8Array,M.exports.isDisturbed=B.isDisturbed,M.exports.isErrored=B.isErrored,M.exports.isWritable=B.isWritable,M.exports.isReadable=B.isReadable,M.exports.Readable=B.Readable,M.exports.Writable=B.Writable,M.exports.Duplex=B.Duplex,M.exports.Transform=B.Transform,M.exports.PassThrough=B.PassThrough,M.exports.addAbortSignal=B.addAbortSignal,M.exports.finished=B.finished,M.exports.destroy=B.destroy,M.exports.destroy=y,M.exports.pipeline=B.pipeline,M.exports.compose=B.compose,M.exports._getNativeReadableStreamPrototype=iq,M.exports.NativeWritable=nq,Uq.defineProperty(B,"promises",{configurable:!0,enumerable:!0,get(){return F}}),M.exports.Stream=B.Stream,M.exports.default=M.exports}}),VQ={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Gq=mq(),nq=class t extends Gq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(M,B={}){super(B);this._construct=this.#H,this._destroy=this.#K,this._final=this.#Z,this.#q=M}#H(M){this._writableState.constructed=!0,this.constructed=!0,M()}#J(){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(M,B,F,y=this.#X){if(!y)return this.#X=!1,super.write(M,B,F);if(!this.#Q)this.#J();var I=this.#Q,j=I.write(M);if(Oq(j))return j.then(()=>{this.emit("drain"),I.flush(!0)}),!1;if(I.flush(!0),F)F(null,M.byteLength);return!0}end(M,B,F,y=this.#X){return super.end(M,B,F,y)}#K(M,B){if(this._writableState.destroyed=!0,B)B(M)}#Z(M){if(this.#Q)this.#Q.end();if(M)M()}ref(){if(!this.#Q)this.#J();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},zq=$Q();zq[Symbol.for("CommonJS")]=0;zq[Symbol.for("::bunternal::")]={_ReadableFromWeb:uq,_ReadableFromWebForUndici:bq};var lQ=zq,TQ=zq._uint8ArrayToBuffer,PQ=zq._isUint8Array,xQ=zq.isDisturbed,OQ=zq.isErrored,_Q=zq.isWritable,CQ=zq.isReadable,DQ=zq.Readable,Gq=zq.Writable,wQ=zq.Duplex,vQ=zq.Transform,RQ=zq.PassThrough,SQ=zq.addAbortSignal,gQ=zq.finished,fQ=zq.destroy,kQ=zq.pipeline,yQ=zq.compose,WQ=zq.Stream,hQ=zq.eos=jq,pQ=zq._getNativeReadableStreamPrototype,nq=zq.NativeWritable,uQ=WQ.promises;export{uQ as promises,kQ as pipeline,_Q as isWritable,CQ as isReadable,OQ as isErrored,xQ as isDisturbed,gQ as finished,hQ as eos,fQ as destroy,lQ as default,yQ as compose,SQ as addAbortSignal,TQ as _uint8ArrayToBuffer,PQ as _isUint8Array,pQ as _getNativeReadableStreamPrototype,Gq as Writable,vQ as Transform,WQ as Stream,DQ as Readable,RQ as PassThrough,nq as NativeWritable,wQ as Duplex}; diff --git a/src/js/out/modules/node/stream.promises.js b/src/js/out/modules/node/stream.promises.js index f095ac718..838d40efa 100644 --- a/src/js/out/modules/node/stream.promises.js +++ b/src/js/out/modules/node/stream.promises.js @@ -1 +1 @@ -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}; +import{promises as J} from"node:stream";var{pipeline:S,finished:b}=J,g={pipeline:S,finished:b,[Symbol.for("CommonJS")]:0};export{S as pipeline,b as finished,g as default}; diff --git a/src/js/out/modules/node/stream.web.js b/src/js/out/modules/node/stream.web.js index f91ee03b4..bb906418c 100644 --- a/src/js/out/modules/node/stream.web.js +++ b/src/js/out/modules/node/stream.web.js @@ -1 +1 @@ -var{ReadableStream:k,ReadableStreamDefaultController:v,WritableStream:w,WritableStreamDefaultController:x,WritableStreamDefaultWriter:z,TransformStream:A,TransformStreamDefaultController:E,ByteLengthQueuingStrategy:F,CountQueuingStrategy:c,ReadableStreamBYOBReader:j,ReadableStreamBYOBRequest:G,ReadableStreamDefaultReader:p}=globalThis,H={ReadableStream:k,ReadableStreamDefaultController:v,WritableStream:w,WritableStreamDefaultController:x,WritableStreamDefaultWriter:z,TransformStream:A,TransformStreamDefaultController:E,ByteLengthQueuingStrategy:F,CountQueuingStrategy:c,ReadableStreamBYOBReader:j,ReadableStreamBYOBRequest:G,ReadableStreamDefaultReader:p,[Symbol.for("CommonJS")]:0};export{H as default,z as WritableStreamDefaultWriter,x as WritableStreamDefaultController,w as WritableStream,E as TransformStreamDefaultController,A as TransformStream,p as ReadableStreamDefaultReader,v as ReadableStreamDefaultController,G as ReadableStreamBYOBRequest,j as ReadableStreamBYOBReader,k as ReadableStream,c as CountQueuingStrategy,F as ByteLengthQueuingStrategy}; +var{ReadableStream:c,ReadableStreamDefaultController:j,WritableStream:k,WritableStreamDefaultController:p,WritableStreamDefaultWriter:v,TransformStream:w,TransformStreamDefaultController:x,ByteLengthQueuingStrategy:z,CountQueuingStrategy:A,ReadableStreamBYOBReader:E,ReadableStreamBYOBRequest:F,ReadableStreamDefaultReader:G}=globalThis,H={ReadableStream:c,ReadableStreamDefaultController:j,WritableStream:k,WritableStreamDefaultController:p,WritableStreamDefaultWriter:v,TransformStream:w,TransformStreamDefaultController:x,ByteLengthQueuingStrategy:z,CountQueuingStrategy:A,ReadableStreamBYOBReader:E,ReadableStreamBYOBRequest:F,ReadableStreamDefaultReader:G,[Symbol.for("CommonJS")]:0};export{H as default,v as WritableStreamDefaultWriter,p as WritableStreamDefaultController,k as WritableStream,x as TransformStreamDefaultController,w as TransformStream,G as ReadableStreamDefaultReader,j as ReadableStreamDefaultController,F as ReadableStreamBYOBRequest,E as ReadableStreamBYOBReader,c as ReadableStream,A as CountQueuingStrategy,z as ByteLengthQueuingStrategy}; -- cgit v1.2.3 From 9c374eac96779aa1c217f53c4d781fc5c8add938 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 16:59:03 -0700 Subject: Fix build determinism issue (thanks to @alexlamsl) cc @dylan-conway this was the cause --- src/renamer.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renamer.zig b/src/renamer.zig index 8f6af149f..5c7177577 100644 --- a/src/renamer.zig +++ b/src/renamer.zig @@ -291,8 +291,8 @@ pub const MinifyRenamer = struct { try sorted.ensureUnusedCapacity(slots.items.len); sorted.items.len = slots.items.len; - for (sorted.items, 0..) |*slot, i| { - slot.* = SlotAndCount{ + for (sorted.items, slots.items, 0..) |*elem, slot, i| { + elem.* = SlotAndCount{ .slot = @intCast(u32, i), .count = slot.count, }; -- cgit v1.2.3 From cac7dcdc76aba387383067a51f4ae19049e4ed53 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 4 Jul 2023 16:59:33 -0700 Subject: Update build-id --- src/build-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build-id b/src/build-id index b1bd38b62..8351c1939 100644 --- a/src/build-id +++ b/src/build-id @@ -1 +1 @@ -13 +14 -- cgit v1.2.3 From 75816aa3ab5bfbfe054c527d4100e9ebd141bd79 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Wed, 5 Jul 2023 04:08:49 -0300 Subject: add envs on tests (#3518) Co-authored-by: Jarred Sumner --- .github/workflows/bun-linux-build.yml | 5 +++++ .github/workflows/bun-mac-aarch64.yml | 5 +++++ .github/workflows/bun-mac-x64-baseline.yml | 5 +++++ .github/workflows/bun-mac-x64.yml | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/.github/workflows/bun-linux-build.yml b/.github/workflows/bun-linux-build.yml index e992770f1..77a641c08 100644 --- a/.github/workflows/bun-linux-build.yml +++ b/.github/workflows/bun-linux-build.yml @@ -191,6 +191,11 @@ jobs: ./bun --version - id: test name: Test (node runner) + env: + SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }} + TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }} + PRISMA_POSTGRES_DATABASE_URL: ${{ secrets.PRISMA_POSTGRES_DATABASE_URL }} + PRISMA_MONGODB_DATABASE_URL: ${{ secrets.PRISMA_MONGODB_DATABASE_URL }} # if: ${{github.event.inputs.use_bun == 'false'}} run: | bun install diff --git a/.github/workflows/bun-mac-aarch64.yml b/.github/workflows/bun-mac-aarch64.yml index 484c7035b..c89782a29 100644 --- a/.github/workflows/bun-mac-aarch64.yml +++ b/.github/workflows/bun-mac-aarch64.yml @@ -430,6 +430,11 @@ jobs: ./bun --version - id: test name: Test (node runner) + env: + SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }} + TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }} + PRISMA_POSTGRES_DATABASE_URL: ${{ secrets.PRISMA_POSTGRES_DATABASE_URL }} + PRISMA_MONGODB_DATABASE_URL: ${{ secrets.PRISMA_MONGODB_DATABASE_URL }} # if: ${{github.event.inputs.use_bun == 'false'}} run: | bun install diff --git a/.github/workflows/bun-mac-x64-baseline.yml b/.github/workflows/bun-mac-x64-baseline.yml index fe8f0b396..294eaf924 100644 --- a/.github/workflows/bun-mac-x64-baseline.yml +++ b/.github/workflows/bun-mac-x64-baseline.yml @@ -434,6 +434,11 @@ jobs: ./bun --version - id: test name: Test (node runner) + env: + SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }} + TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }} + PRISMA_POSTGRES_DATABASE_URL: ${{ secrets.PRISMA_POSTGRES_DATABASE_URL }} + PRISMA_MONGODB_DATABASE_URL: ${{ secrets.PRISMA_MONGODB_DATABASE_URL }} # if: ${{github.event.inputs.use_bun == 'false'}} run: | bun install diff --git a/.github/workflows/bun-mac-x64.yml b/.github/workflows/bun-mac-x64.yml index ae265adab..f301d56f6 100644 --- a/.github/workflows/bun-mac-x64.yml +++ b/.github/workflows/bun-mac-x64.yml @@ -436,6 +436,11 @@ jobs: ./bun --version - id: test name: Test (node runner) + env: + SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }} + TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }} + PRISMA_POSTGRES_DATABASE_URL: ${{ secrets.PRISMA_POSTGRES_DATABASE_URL }} + PRISMA_MONGODB_DATABASE_URL: ${{ secrets.PRISMA_MONGODB_DATABASE_URL }} # if: ${{github.event.inputs.use_bun == 'false'}} run: | bun install -- cgit v1.2.3 From a7f5a91cfbf93a31cc53974a6c27185e57a57f64 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 5 Jul 2023 00:08:59 -0700 Subject: Fixes #3520 (#3522) * Fixes #3520 * Update html_rewriter.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/html_rewriter.zig | 26 ++++++++------------------ src/deps/lol-html.zig | 11 ++++++----- test/js/workerd/html-rewriter.test.js | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig index 532e0ae1e..b309e07d7 100644 --- a/src/bun.js/api/html_rewriter.zig +++ b/src/bun.js/api/html_rewriter.zig @@ -1558,27 +1558,16 @@ pub const AttributeIterator = struct { return JSC.JSValue.jsNull(); }; - // TODO: don't clone here const value = attribute.value(); const name = attribute.name(); - defer name.deinit(); - defer value.deinit(); - var strs = [2]ZigString{ - ZigString.init(name.slice()), - ZigString.init(value.slice()), - }; - - var valid_strs: []ZigString = strs[0..2]; - - var array = JSC.JSValue.createStringArray( + return bun.String.toJSArray( globalObject, - valid_strs.ptr, - valid_strs.len, - true, + &[_]bun.String{ + name.toString(), + value.toString(), + }, ); - - return array; } }; pub const Element = struct { @@ -1864,8 +1853,9 @@ pub const Element = struct { pub fn getNamespaceURI(this: *Element, globalObject: *JSGlobalObject) JSValue { if (this.element == null) return JSValue.jsUndefined(); - - return ZigString.init(std.mem.span(this.element.?.namespaceURI())).toValueGC(globalObject); + var str = bun.String.create(std.mem.span(this.element.?.namespaceURI())); + defer str.deref(); + return str.toJS(globalObject); } pub fn getAttributes(this: *Element, globalObject: *JSGlobalObject) JSValue { diff --git a/src/deps/lol-html.zig b/src/deps/lol-html.zig index 50dab9592..bac422fb0 100644 --- a/src/deps/lol-html.zig +++ b/src/deps/lol-html.zig @@ -570,16 +570,17 @@ pub const HTMLString = extern struct { lol_html_str_free(.{ .ptr = @ptrCast([*]const u8, ptr), .len = len }); } - pub fn toJS(this: HTMLString, globalThis: *bun.JSC.JSGlobalObject) bun.JSC.JSValue { + pub fn toString(this: HTMLString) bun.String { const bytes = this.slice(); if (bun.strings.isAllASCII(bytes)) { - var external = bun.String.createExternal(bytes, true, @constCast(bytes.ptr), &deinit_external); - defer external.deref(); - return external.toJS(globalThis); + return bun.String.createExternal(bytes, true, @constCast(bytes.ptr), &deinit_external); } defer this.deinit(); + return bun.String.create(bytes); + } - var str = bun.String.create(bytes); + pub fn toJS(this: HTMLString, globalThis: *bun.JSC.JSGlobalObject) bun.JSC.JSValue { + var str = this.toString(); defer str.deref(); return str.toJS(globalThis); } diff --git a/test/js/workerd/html-rewriter.test.js b/test/js/workerd/html-rewriter.test.js index aaf912aff..44961df3b 100644 --- a/test/js/workerd/html-rewriter.test.js +++ b/test/js/workerd/html-rewriter.test.js @@ -365,3 +365,26 @@ it("get attribute - ascii", async () => { expect(el).toEqual("asciii"); } }); + +it("#3520", async () => { + const pairs = []; + + await new HTMLRewriter() + .on("p", { + element(element) { + for (const pair of element.attributes) { + pairs.push(pair); + } + }, + }) + .transform(new Response('

')) + .text(); + + expect(pairs).toEqual([ + ["šž", "Õäöü"], + ["ab", "Õäöü"], + ["šž", "Õäöü"], + ["šž", "dc"], + ["šž", "🕵🏻"], + ]); +}); -- cgit v1.2.3 From c864976da6140c1c92dae8472b1813a1eca8a78c Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 5 Jul 2023 01:21:35 -0700 Subject: Fixes #3515 (#3523) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/JSBuffer.cpp | 33 +--- src/js/builtins/JSBufferConstructor.ts | 4 + src/js/out/WebCoreJSBuiltins.cpp | 324 +++++++++++++++++---------------- src/js/out/WebCoreJSBuiltins.h | 11 ++ 4 files changed, 182 insertions(+), 190 deletions(-) diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index 08475735b..e420e24ef 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -1690,14 +1690,6 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_compare, (JSGlobalObject * return jsBufferConstructorFunction_compareBody(lexicalGlobalObject, callFrame); } -JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isBuffer, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - if (callFrame->argumentCount() < 1) - return JSC::JSValue::encode(JSC::jsBoolean(false)); - - return JSC::JSValue::encode(JSC::jsBoolean(JSBuffer__isBuffer(lexicalGlobalObject, JSC::JSValue::encode(callFrame->uncheckedArgument(0))))); -} - JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_concat, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferConstructorFunction_concatBody(lexicalGlobalObject, callFrame); @@ -1706,24 +1698,6 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_concat, (JSGlobalObject * l extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsBufferConstructorAllocWithoutTypeChecks, JSUint8Array*, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int size)); extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsBufferConstructorAllocUnsafeWithoutTypeChecks, JSUint8Array*, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int size)); extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsBufferConstructorAllocUnsafeSlowWithoutTypeChecks, JSUint8Array*, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int size)); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsBufferConstructorIsBufferWithoutTypeChecks, JSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void*, JSUint8Array* value)); - -static bool isBufferWithCell(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSUint8Array* cell) -{ - auto& vm = lexicalGlobalObject->vm(); - JSValue prototype = cell->getPrototype(vm, lexicalGlobalObject); - return prototype.inherits(); -} - -JSC_DEFINE_JIT_OPERATION(jsBufferConstructorIsBufferWithoutTypeChecks, JSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* ctx, JSUint8Array* thisValue)) -{ - VM& vm = JSC::getVM(lexicalGlobalObject); - IGNORE_WARNINGS_BEGIN("frame-address") - CallFrame* callFrame = DECLARE_CALL_FRAME(vm); - IGNORE_WARNINGS_END - JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); - return jsBoolean(isBufferWithCell(lexicalGlobalObject, thisValue)); -} JSC_DEFINE_JIT_OPERATION(jsBufferConstructorAllocWithoutTypeChecks, JSUint8Array*, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int byteLength)) { @@ -1965,11 +1939,6 @@ static const JSC::DOMJIT::Signature DOMJITSignaturejsBufferConstructorAlloc(jsBu JSC::DOMJIT::Effect::forWriteKinds(JSC::DFG::AbstractHeapKind::Heap), JSC::SpecUint8Array, JSC::SpecInt32Only); -static const JSC::DOMJIT::Signature DOMJITSignaturejsBufferConstructorIsBuffer(jsBufferConstructorIsBufferWithoutTypeChecks, - JSBufferConstructor::info(), - JSC::DOMJIT::Effect::forPure(), - JSC::SpecOther, JSC::SpecUint8Array); - static const JSC::DOMJIT::Signature DOMJITSignaturejsBufferConstructorAllocUnsafe(jsBufferConstructorAllocUnsafeWithoutTypeChecks, JSBufferConstructor::info(), JSC::DOMJIT::Effect::forWriteKinds(JSC::DFG::AbstractHeapKind::Heap), @@ -1991,7 +1960,7 @@ static const HashTableValue JSBufferConstructorTableValues[] = { { "compare"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBufferConstructorFunction_compare, 2 } }, { "concat"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBufferConstructorFunction_concat, 2 } }, { "from"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferConstructorFromCodeGenerator, 1 } }, - { "isBuffer"_s, static_cast(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction), NoIntrinsic, { HashTableValue::DOMJITFunctionType, jsBufferConstructorFunction_isBuffer, &DOMJITSignaturejsBufferConstructorIsBuffer } }, + { "isBuffer"_s, static_cast(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferConstructorIsBufferCodeGenerator, 1 } }, { "toBuffer"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBufferConstructorFunction_toBuffer, 1 } }, { "isEncoding"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsBufferConstructorFunction_isEncoding, 1 } }, }; diff --git a/src/js/builtins/JSBufferConstructor.ts b/src/js/builtins/JSBufferConstructor.ts index debc62d51..a1072ea10 100644 --- a/src/js/builtins/JSBufferConstructor.ts +++ b/src/js/builtins/JSBufferConstructor.ts @@ -65,3 +65,7 @@ export function from(items) { // That means we cannot use $tailCallFowrardArguments here, sadly return new $Buffer(Uint8Array.from(arrayLike).buffer); } + +export function isBuffer(bufferlike) { + return bufferlike instanceof $Buffer; +} diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index 60be45097..5ad79fa10 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -16,7 +16,7 @@ const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunSetupFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunSetupFunctionCodeLength = 2165; static const JSC::Intrinsic s_bundlerPluginRunSetupFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunSetupFunctionCode = "(function (_,E){\"use strict\";var w=new Map,h=new Map;function q(D,F,G){if(!D||!@isObject(D))@throwTypeError('Expected an object with \"filter\" RegExp');if(!F||!@isCallable(F))@throwTypeError(\"callback must be a function\");var{filter:H,namespace:I=\"file\"}=D;if(!H)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(H))@throwTypeError(\"filter must be a RegExp\");if(I&&typeof I!==\"string\")@throwTypeError(\"namespace must be a string\");if((I\?.length\?\?0)===0)I=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(I))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var J=G.@get(I);if(!J)G.@set(I,[[H,F]]);else @arrayPush(J,[H,F])}function z(D,F){q(D,F,w)}function A(D,F){q(D,F,h)}const B=()=>{var D=!1,F=!1;for(var[G,H]of w.entries())for(var[I]of H)this.addFilter(I,G,1),D=!0;for(var[G,H]of h.entries())for(var[I]of H)this.addFilter(I,G,0),F=!0;if(F){var J=this.onResolve;if(!J)this.onResolve=h;else for(var[G,H]of h.entries()){var K=J.@get(G);if(!K)J.@set(G,H);else J.@set(G,K.concat(H))}}if(D){var M=this.onLoad;if(!M)this.onLoad=w;else for(var[G,H]of w.entries()){var K=M.@get(G);if(!K)M.@set(G,H);else M.@set(G,K.concat(H))}}return D||F};var C=_({config:E,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:z,onResolve:A,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{...E,bundle:!0,entryPoints:E.entrypoints\?\?E.entryPoints\?\?[],minify:typeof E.minify===\"boolean\"\?E.minify:!1,minifyIdentifiers:E.minify===!0||E.minify\?.identifiers,minifyWhitespace:E.minify===!0||E.minify\?.whitespace,minifySyntax:E.minify===!0||E.minify\?.syntax,outbase:E.root,platform:E.target===\"bun\"\?\"node\":E.target},esbuild:{}});if(C&&@isPromise(C))if(@getPromiseInternalField(C,@promiseFieldFlags)&@promiseStateFulfilled)C=@getPromiseInternalField(C,@promiseFieldReactionsOrResult);else return C.@then(B);return B()})\n"; +const char* const s_bundlerPluginRunSetupFunctionCode = "(function (J,_){\"use strict\";var D=new Map,F=new Map;function H(q,h,E){if(!q||!@isObject(q))@throwTypeError('Expected an object with \"filter\" RegExp');if(!h||!@isCallable(h))@throwTypeError(\"callback must be a function\");var{filter:w,namespace:z=\"file\"}=q;if(!w)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(w))@throwTypeError(\"filter must be a RegExp\");if(z&&typeof z!==\"string\")@throwTypeError(\"namespace must be a string\");if((z\?.length\?\?0)===0)z=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(z))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var A=E.@get(z);if(!A)E.@set(z,[[w,h]]);else @arrayPush(A,[w,h])}function K(q,h){H(q,h,D)}function M(q,h){H(q,h,F)}const I=()=>{var q=!1,h=!1;for(var[E,w]of D.entries())for(var[z]of w)this.addFilter(z,E,1),q=!0;for(var[E,w]of F.entries())for(var[z]of w)this.addFilter(z,E,0),h=!0;if(h){var A=this.onResolve;if(!A)this.onResolve=F;else for(var[E,w]of F.entries()){var C=A.@get(E);if(!C)A.@set(E,w);else A.@set(E,C.concat(w))}}if(q){var G=this.onLoad;if(!G)this.onLoad=D;else for(var[E,w]of D.entries()){var C=G.@get(E);if(!C)G.@set(E,w);else G.@set(E,C.concat(w))}}return q||h};var B=J({config:_,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:K,onResolve:M,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{..._,bundle:!0,entryPoints:_.entrypoints\?\?_.entryPoints\?\?[],minify:typeof _.minify===\"boolean\"\?_.minify:!1,minifyIdentifiers:_.minify===!0||_.minify\?.identifiers,minifyWhitespace:_.minify===!0||_.minify\?.whitespace,minifySyntax:_.minify===!0||_.minify\?.syntax,outbase:_.root,platform:_.target===\"bun\"\?\"node\":_.target},esbuild:{}});if(B&&@isPromise(B))if(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);else return B.@then(I);return I()})\n"; // runOnResolvePlugins const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -24,7 +24,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnResolvePluginsCodeLength = 1711; static const JSC::Intrinsic s_bundlerPluginRunOnResolvePluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (_,w,g,y,b){\"use strict\";const j=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][b];var q=(async(z,A,B,C)=>{var{onResolve:E,onLoad:F}=this,G=E.@get(A);if(!G)return this.onResolveAsync(y,null,null,null),null;for(let[O,Q]of G)if(O.test(z)){var H=Q({path:z,importer:B,namespace:A,kind:C});while(H&&@isPromise(H)&&(@getPromiseInternalField(H,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)H=@getPromiseInternalField(H,@promiseFieldReactionsOrResult);if(H&&@isPromise(H))H=await H;if(!H||!@isObject(H))continue;var{path:J,namespace:K=A,external:M}=H;if(typeof J!==\"string\"||typeof K!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!J)continue;if(!K)K=A;if(typeof M!==\"boolean\"&&!@isUndefinedOrNull(M))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!M){if(K===\"file\"){if(darwin!==\"win32\"){if(J[0]!==\"/\"||J.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(K===\"dataurl\"){if(!J.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(K&&K!==\"file\"&&(!F||!F.@has(K)))@throwTypeError(`Expected onLoad plugin for namespace ${K} to exist`)}return this.onResolveAsync(y,J,K,M),null}return this.onResolveAsync(y,null,null,null),null})(_,w,g,j);while(q&&@isPromise(q)&&(@getPromiseInternalField(q,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)q=@getPromiseInternalField(q,@promiseFieldReactionsOrResult);if(q&&@isPromise(q))q.then(()=>{},(z)=>{this.addError(y,z,0)})})\n"; +const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (C,E,F,b,G){\"use strict\";const H=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][G];var g=(async(j,q,J,K)=>{var{onResolve:M,onLoad:A}=this,B=M.@get(q);if(!B)return this.onResolveAsync(b,null,null,null),null;for(let[O,Q]of B)if(O.test(j)){var _=Q({path:j,importer:J,namespace:q,kind:K});while(_&&@isPromise(_)&&(@getPromiseInternalField(_,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)_=@getPromiseInternalField(_,@promiseFieldReactionsOrResult);if(_&&@isPromise(_))_=await _;if(!_||!@isObject(_))continue;var{path:y,namespace:w=q,external:z}=_;if(typeof y!==\"string\"||typeof w!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!y)continue;if(!w)w=q;if(typeof z!==\"boolean\"&&!@isUndefinedOrNull(z))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!z){if(w===\"file\"){if(darwin!==\"win32\"){if(y[0]!==\"/\"||y.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(w===\"dataurl\"){if(!y.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(w&&w!==\"file\"&&(!A||!A.@has(w)))@throwTypeError(`Expected onLoad plugin for namespace ${w} to exist`)}return this.onResolveAsync(b,y,w,z),null}return this.onResolveAsync(b,null,null,null),null})(C,E,F,H);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(b,j,0)})})\n"; // runOnLoadPlugins const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,g,x,w){\"use strict\";const y={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},z=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][w];var B=(async(C,F,j,G)=>{var H=this.onLoad.@get(j);if(!H)return this.onLoadAsync(C,null,null),null;for(let[q,T]of H)if(q.test(F)){var J=T({path:F,namespace:j,loader:G});while(J&&@isPromise(J)&&(@getPromiseInternalField(J,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)J=@getPromiseInternalField(J,@promiseFieldReactionsOrResult);if(J&&@isPromise(J))J=await J;if(!J||!@isObject(J))continue;var{contents:K,loader:Q=G}=J;if(typeof K!==\"string\"&&!@isTypedArrayView(K))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof Q!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const v=y[Q];if(v===@undefined)@throwTypeError(`Loader ${Q} is not supported.`);return this.onLoadAsync(C,K,v),null}return this.onLoadAsync(C,null,null),null})(b,g,x,z);while(B&&@isPromise(B)&&(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);if(B&&@isPromise(B))B.then(()=>{},(C)=>{this.addError(b,C,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (w,F,G,H){\"use strict\";const J={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},K=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][H];var g=(async(j,x,y,z)=>{var B=this.onLoad.@get(y);if(!B)return this.onLoadAsync(j,null,null),null;for(let[Q,T]of B)if(Q.test(x)){var b=T({path:x,namespace:y,loader:z});while(b&&@isPromise(b)&&(@getPromiseInternalField(b,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)b=@getPromiseInternalField(b,@promiseFieldReactionsOrResult);if(b&&@isPromise(b))b=await b;if(!b||!@isObject(b))continue;var{contents:q,loader:v=z}=b;if(typeof q!==\"string\"&&!@isTypedArrayView(q))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof v!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const C=J[v];if(C===@undefined)@throwTypeError(`Loader ${v} is not supported.`);return this.onLoadAsync(j,q,C),null}return this.onLoadAsync(j,null,null),null})(w,F,G,K);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(w,j,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -108,7 +108,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeCons const JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateWritableStreamCodeLength = 278; static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (u,d,p,N,_,f){\"use strict\";@assert(typeof _===\"number\"&&!@isNaN(_)&&_>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,d,p,N,_,f),@createWritableStreamFromInternal(j)})\n"; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (p,N,_,f,u,j){\"use strict\";@assert(typeof u===\"number\"&&!@isNaN(u)&&u>=0);const d={};@initializeWritableStreamSlots(d,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(d,q,p,N,_,f,u,j),@createWritableStreamFromInternal(d)})\n"; // createInternalWritableStreamFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -116,7 +116,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStream const JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 920; static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,o){\"use strict\";const w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,w){\"use strict\";const C={};if(f===@undefined)f={};if(w===@undefined)w={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const E=@extractSizeAlgorithm(w),_=@extractHighWaterMark(w,1),o={};if(\"start\"in f){if(o.start=f.start,typeof o.start!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in f){if(o.write=f.write,typeof o.write!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in f){if(o.close=f.close,typeof o.close!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in f){if(o.abort=f.abort,typeof o.abort!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(C,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(C,f,o,_,E),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 B=@newPromiseCapability(@Promise),_=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"readyPromise\",B),@putByIdDirectPrivate(n,\"closedPromise\",_);const g=@getByIdDirectPrivate(v,\"state\");if(g===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(v)||!@getByIdDirectPrivate(v,\"backpressure\"))B.@resolve.@call()}else if(g===\"erroring\")B.@reject.@call(@undefined,@getByIdDirectPrivate(v,\"storedError\")),@markPromiseAsHandled(B.@promise);else if(g===\"closed\")B.@resolve.@call(),_.@resolve.@call();else{@assert(g===\"errored\");const h=@getByIdDirectPrivate(v,\"storedError\");B.@reject.@call(@undefined,h),@markPromiseAsHandled(B.@promise),_.@reject.@call(@undefined,h),@markPromiseAsHandled(_.@promise)}})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = "(function (g,n){\"use strict\";if(@isWritableStreamLocked(n))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(g,\"stream\",n),@putByIdDirectPrivate(n,\"writer\",g);const v=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(g,\"readyPromise\",v),@putByIdDirectPrivate(g,\"closedPromise\",h);const B=@getByIdDirectPrivate(n,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(n)||!@getByIdDirectPrivate(n,\"backpressure\"))v.@resolve.@call()}else if(B===\"erroring\")v.@reject.@call(@undefined,@getByIdDirectPrivate(n,\"storedError\")),@markPromiseAsHandled(v.@promise);else if(B===\"closed\")v.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(n,\"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,f){\"use strict\";const j=@getByIdDirectPrivate(c,\"state\");if(j===\"closed\"||j===\"errored\")return @Promise.@resolve();const B=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(B!==@undefined)return B.promise.@promise;@assert(j===\"writable\"||j===\"erroring\");let h=!1;if(j===\"erroring\")h=!0,f=@undefined;const _=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:_,reason:f,wasAlreadyErroring:h}),!h)@writableStreamStartErroring(c,f);return _.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (h,B){\"use strict\";const c=@getByIdDirectPrivate(h,\"state\");if(c===\"closed\"||c===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(h,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(c===\"writable\"||c===\"erroring\");let _=!1;if(c===\"erroring\")_=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(h,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:_}),!_)@writableStreamStartErroring(h,B);return j.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -196,7 +196,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithReject const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDealWithRejectionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength = 189; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDealWithRejectionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,n){\"use strict\";const c=@getByIdDirectPrivate(i,\"state\");if(c===\"writable\"){@writableStreamStartErroring(i,n);return}@assert(c===\"erroring\"),@writableStreamFinishErroring(i)})\n"; +const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,c){\"use strict\";const n=@getByIdDirectPrivate(i,\"state\");if(n===\"writable\"){@writableStreamStartErroring(i,c);return}@assert(n===\"erroring\"),@writableStreamFinishErroring(i)})\n"; // writableStreamFinishErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility = 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 i=@getByIdDirectPrivate(_,\"storedError\"),B=@getByIdDirectPrivate(_,\"writeRequests\");for(var h=B.shift();h;h=B.shift())h.@reject.@call(@undefined,i);@putByIdDirectPrivate(_,\"writeRequests\",@createFIFO());const A=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(A===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}if(@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined),A.wasAlreadyErroring){A.promise.@reject.@call(@undefined,i),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_);return}@getByIdDirectPrivate(p,\"abortSteps\").@call(@undefined,A.reason).@then(()=>{A.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(_)},(I)=>{A.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 h=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(h,\"errorSteps\").@call();const A=@getByIdDirectPrivate(i,\"storedError\"),B=@getByIdDirectPrivate(i,\"writeRequests\");for(var p=B.shift();p;p=B.shift())p.@reject.@call(@undefined,A);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const _=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(_===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),_.wasAlreadyErroring){_.promise.@reject.@call(@undefined,A),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(h,\"abortSteps\").@call(@undefined,_.reason).@then(()=>{_.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(I)=>{_.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const c=@getByIdDirectPrivate(d,\"writer\");if(c!==@undefined)@getByIdDirectPrivate(c,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const i=@getByIdDirectPrivate(d,\"state\");if(@assert(i===\"writable\"||i===\"erroring\"),i===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const n=@getByIdDirectPrivate(d,\"writer\");if(n!==@undefined)@getByIdDirectPrivate(n,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -220,7 +220,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength = 488; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (c,_){\"use strict\";const n=@getByIdDirectPrivate(c,\"inFlightCloseRequest\");@assert(n!==@undefined),n.@reject.@call(@undefined,_),@putByIdDirectPrivate(c,\"inFlightCloseRequest\",@undefined);const p=@getByIdDirectPrivate(c,\"state\");@assert(p===\"writable\"||p===\"erroring\");const d=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(d!==@undefined)d.promise.@reject.@call(@undefined,_),@putByIdDirectPrivate(c,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(c,_)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,c){\"use strict\";const d=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(d!==@undefined),d.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(_,\"state\");@assert(n===\"writable\"||n===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,c)})\n"; // writableStreamFinishInFlightWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -228,7 +228,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength = 187; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"inFlightWriteRequest\");@assert(d!==@undefined),d.@resolve.@call(),@putByIdDirectPrivate(c,\"inFlightWriteRequest\",@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode = "(function (d){\"use strict\";const c=@getByIdDirectPrivate(d,\"inFlightWriteRequest\");@assert(c!==@undefined),c.@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightWriteRequest\",@undefined)})\n"; // writableStreamFinishInFlightWriteWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -236,7 +236,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength = 319; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode = "(function (_,d){\"use strict\";const c=@getByIdDirectPrivate(_,\"inFlightWriteRequest\");@assert(c!==@undefined),c.@reject.@call(@undefined,d),@putByIdDirectPrivate(_,\"inFlightWriteRequest\",@undefined);const p=@getByIdDirectPrivate(_,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@writableStreamDealWithRejection(_,d)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode = "(function (_,c){\"use strict\";const d=@getByIdDirectPrivate(_,\"inFlightWriteRequest\");@assert(d!==@undefined),d.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightWriteRequest\",@undefined);const p=@getByIdDirectPrivate(_,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@writableStreamDealWithRejection(_,c)})\n"; // writableStreamHasOperationMarkedInFlight const JSC::ConstructAbility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -260,7 +260,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWrite const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength = 240; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (h){\"use strict\";const c=@getByIdDirectPrivate(h,\"writeRequests\");@assert(@getByIdDirectPrivate(h,\"inFlightWriteRequest\")===@undefined),@assert(c.isNotEmpty());const d=c.shift();@putByIdDirectPrivate(h,\"inFlightWriteRequest\",d)})\n"; +const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"writeRequests\");@assert(@getByIdDirectPrivate(c,\"inFlightWriteRequest\")===@undefined),@assert(d.isNotEmpty());const h=d.shift();@putByIdDirectPrivate(c,\"inFlightWriteRequest\",h)})\n"; // writableStreamRejectCloseAndClosedPromiseIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -268,7 +268,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAnd const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 516; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const b=@getByIdDirectPrivate(i,\"storedError\"),B=@getByIdDirectPrivate(i,\"closeRequest\");if(B!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),B.@reject.@call(@undefined,b),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const h=@getByIdDirectPrivate(i,\"writer\");if(h!==@undefined){const n=@getByIdDirectPrivate(h,\"closedPromise\");n.@reject.@call(@undefined,b),@markPromiseAsHandled(n.@promise)}})\n"; +const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"errored\");const h=@getByIdDirectPrivate(i,\"storedError\"),n=@getByIdDirectPrivate(i,\"closeRequest\");if(n!==@undefined)@assert(@getByIdDirectPrivate(i,\"inFlightCloseRequest\")===@undefined),n.@reject.@call(@undefined,h),@putByIdDirectPrivate(i,\"closeRequest\",@undefined);const B=@getByIdDirectPrivate(i,\"writer\");if(B!==@undefined){const b=@getByIdDirectPrivate(B,\"closedPromise\");b.@reject.@call(@undefined,h),@markPromiseAsHandled(b.@promise)}})\n"; // writableStreamStartErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -284,7 +284,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamUpdateBackpres const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength = 422; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamUpdateBackpressureCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode = "(function (n,h){\"use strict\";@assert(@getByIdDirectPrivate(n,\"state\")===\"writable\"),@assert(!@writableStreamCloseQueuedOrInFlight(n));const d=@getByIdDirectPrivate(n,\"writer\");if(d!==@undefined&&h!==@getByIdDirectPrivate(n,\"backpressure\"))if(h)@putByIdDirectPrivate(d,\"readyPromise\",@newPromiseCapability(@Promise));else @getByIdDirectPrivate(d,\"readyPromise\").@resolve.@call();@putByIdDirectPrivate(n,\"backpressure\",h)})\n"; +const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode = "(function (n,d){\"use strict\";@assert(@getByIdDirectPrivate(n,\"state\")===\"writable\"),@assert(!@writableStreamCloseQueuedOrInFlight(n));const h=@getByIdDirectPrivate(n,\"writer\");if(h!==@undefined&&d!==@getByIdDirectPrivate(n,\"backpressure\"))if(d)@putByIdDirectPrivate(h,\"readyPromise\",@newPromiseCapability(@Promise));else @getByIdDirectPrivate(h,\"readyPromise\").@resolve.@call();@putByIdDirectPrivate(n,\"backpressure\",d)})\n"; // writableStreamDefaultWriterAbort const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -292,7 +292,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterA const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength = 130; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (c,d){\"use strict\";const f=@getByIdDirectPrivate(c,\"stream\");return @assert(f!==@undefined),@writableStreamAbort(f,d)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (d,f){\"use strict\";const c=@getByIdDirectPrivate(d,\"stream\");return @assert(c!==@undefined),@writableStreamAbort(c,f)})\n"; // writableStreamDefaultWriterClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -300,7 +300,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength = 126; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");return @assert(c!==@undefined),@writableStreamClose(c)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (c){\"use strict\";const _=@getByIdDirectPrivate(c,\"stream\");return @assert(_!==@undefined),@writableStreamClose(_)})\n"; // writableStreamDefaultWriterCloseWithErrorPropagation const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -308,7 +308,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength = 385; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (c){\"use strict\";const l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const u=@getByIdDirectPrivate(l,\"state\");if(@writableStreamCloseQueuedOrInFlight(l)||u===\"closed\")return @Promise.@resolve();if(u===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(l,\"storedError\"));return @assert(u===\"writable\"||u===\"erroring\"),@writableStreamDefaultWriterClose(c)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (u){\"use strict\";const c=@getByIdDirectPrivate(u,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(@writableStreamCloseQueuedOrInFlight(c)||l===\"closed\")return @Promise.@resolve();if(l===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(c,\"storedError\"));return @assert(l===\"writable\"||l===\"erroring\"),@writableStreamDefaultWriterClose(u)})\n"; // writableStreamDefaultWriterEnsureClosedPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -316,7 +316,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength = 329; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (_,n){\"use strict\";let h=@getByIdDirectPrivate(_,\"closedPromise\"),u=h.@promise;if((@getPromiseInternalField(u,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),u=h.@promise,@putByIdDirectPrivate(_,\"closedPromise\",h);h.@reject.@call(@undefined,n),@markPromiseAsHandled(u)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (h,u){\"use strict\";let _=@getByIdDirectPrivate(h,\"closedPromise\"),n=_.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)_=@newPromiseCapability(@Promise),n=_.@promise,@putByIdDirectPrivate(h,\"closedPromise\",_);_.@reject.@call(@undefined,u),@markPromiseAsHandled(n)})\n"; // writableStreamDefaultWriterEnsureReadyPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -324,7 +324,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 327; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (c,g){\"use strict\";let h=@getByIdDirectPrivate(c,\"readyPromise\"),n=h.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),n=h.@promise,@putByIdDirectPrivate(c,\"readyPromise\",h);h.@reject.@call(@undefined,g),@markPromiseAsHandled(n)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (h,n){\"use strict\";let c=@getByIdDirectPrivate(h,\"readyPromise\"),g=c.@promise;if((@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)c=@newPromiseCapability(@Promise),g=c.@promise,@putByIdDirectPrivate(h,\"readyPromise\",c);c.@reject.@call(@undefined,n),@markPromiseAsHandled(g)})\n"; // writableStreamDefaultWriterGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -332,7 +332,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterG const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength = 299; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (c){\"use strict\";const _=@getByIdDirectPrivate(c,\"stream\");@assert(_!==@undefined);const l=@getByIdDirectPrivate(_,\"state\");if(l===\"errored\"||l===\"erroring\")return null;if(l===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(_,\"controller\"))})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(l===\"errored\"||l===\"erroring\")return null;if(l===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(c,\"controller\"))})\n"; // writableStreamDefaultWriterRelease const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility = 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 (_,d){\"use strict\";const g=@getByIdDirectPrivate(_,\"stream\");@assert(g!==@undefined);const P=@getByIdDirectPrivate(g,\"controller\");@assert(P!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(P,d);if(g!==@getByIdDirectPrivate(_,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const W=@getByIdDirectPrivate(g,\"state\");if(W===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(g,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(g)||W===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(g)||W===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(W===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(g,\"storedError\"));@assert(W===\"writable\");const f=@writableStreamAddWriteRequest(g);return @writableStreamDefaultControllerWrite(P,d,b),f})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (W,_){\"use strict\";const d=@getByIdDirectPrivate(W,\"stream\");@assert(d!==@undefined);const P=@getByIdDirectPrivate(d,\"controller\");@assert(P!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(P,_);if(d!==@getByIdDirectPrivate(W,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const g=@getByIdDirectPrivate(d,\"state\");if(g===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(g===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));@assert(g===\"writable\");const f=@writableStreamAddWriteRequest(d);return @writableStreamDefaultControllerWrite(P,_,b),f})\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 (_,d,B,v,P,U,f,j){\"use strict\";@assert(@isWritableStream(_)),@assert(@getByIdDirectPrivate(_,\"controller\")===@undefined),@putByIdDirectPrivate(d,\"stream\",_),@putByIdDirectPrivate(_,\"controller\",d),@resetQueue(@getByIdDirectPrivate(d,\"queue\")),@putByIdDirectPrivate(d,\"started\",-1),@putByIdDirectPrivate(d,\"startAlgorithm\",B),@putByIdDirectPrivate(d,\"strategySizeAlgorithm\",j),@putByIdDirectPrivate(d,\"strategyHWM\",f),@putByIdDirectPrivate(d,\"writeAlgorithm\",v),@putByIdDirectPrivate(d,\"closeAlgorithm\",P),@putByIdDirectPrivate(d,\"abortAlgorithm\",U);const q=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(_,q),@writableStreamDefaultControllerStart(d)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (B,_,v,P,U,d,f,j){\"use strict\";@assert(@isWritableStream(B)),@assert(@getByIdDirectPrivate(B,\"controller\")===@undefined),@putByIdDirectPrivate(_,\"stream\",B),@putByIdDirectPrivate(B,\"controller\",_),@resetQueue(@getByIdDirectPrivate(_,\"queue\")),@putByIdDirectPrivate(_,\"started\",-1),@putByIdDirectPrivate(_,\"startAlgorithm\",v),@putByIdDirectPrivate(_,\"strategySizeAlgorithm\",j),@putByIdDirectPrivate(_,\"strategyHWM\",f),@putByIdDirectPrivate(_,\"writeAlgorithm\",P),@putByIdDirectPrivate(_,\"closeAlgorithm\",U),@putByIdDirectPrivate(_,\"abortAlgorithm\",d);const q=@writableStreamDefaultControllerGetBackpressure(_);@writableStreamUpdateBackpressure(B,q),@writableStreamDefaultControllerStart(_)})\n"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -364,7 +364,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 647; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const d=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const _=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(d.@call()).@then(()=>{const u=@getByIdDirectPrivate(_,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(_,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(_,u)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const p=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(p.@call()).@then(()=>{const _=@getByIdDirectPrivate(d,\"state\");@assert(_===\"writable\"||_===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(_)=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,_)})})\n"; // setUpWritableStreamDefaultControllerFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (v,P,j,p,_){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},E=()=>{return @Promise.@resolve()};if(\"start\"in j){const f=j.start;x=()=>@promiseInvokeOrNoopMethodNoCatch(P,f,[q])}if(\"write\"in j){const f=j.write;B=(F)=>@promiseInvokeOrNoopMethod(P,f,[F,q])}if(\"close\"in j){const f=j.close;C=()=>@promiseInvokeOrNoopMethod(P,f,[])}if(\"abort\"in j){const f=j.abort;E=(F)=>@promiseInvokeOrNoopMethod(P,f,[F])}@setUpWritableStreamDefaultController(v,q,x,B,C,E,p,_)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,_,v,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let p=()=>{},q=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in v){const P=v.start;p=()=>@promiseInvokeOrNoopMethodNoCatch(_,P,[f])}if(\"write\"in v){const P=v.write;q=(j)=>@promiseInvokeOrNoopMethod(_,P,[j,f])}if(\"close\"in v){const P=v.close;x=()=>@promiseInvokeOrNoopMethod(_,P,[])}if(\"abort\"in v){const P=v.abort;B=(j)=>@promiseInvokeOrNoopMethod(_,P,[j])}@setUpWritableStreamDefaultController(C,f,p,q,x,B,E,F)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -380,7 +380,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength = 582; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (d){\"use strict\";const _=@getByIdDirectPrivate(d,\"stream\");if(@getByIdDirectPrivate(d,\"started\")!==1)return;if(@assert(_!==@undefined),@getByIdDirectPrivate(_,\"inFlightWriteRequest\")!==@undefined)return;const f=@getByIdDirectPrivate(_,\"state\");if(@assert(f!==\"closed\"||f!==\"errored\"),f===\"erroring\"){@writableStreamFinishErroring(_);return}const i=@getByIdDirectPrivate(d,\"queue\");if(i.content\?.isEmpty()\?\?!1)return;const h=@peekQueueValue(i);if(h===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(d);else @writableStreamDefaultControllerProcessWrite(d,h)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"stream\");if(@getByIdDirectPrivate(_,\"started\")!==1)return;if(@assert(d!==@undefined),@getByIdDirectPrivate(d,\"inFlightWriteRequest\")!==@undefined)return;const f=@getByIdDirectPrivate(d,\"state\");if(@assert(f!==\"closed\"||f!==\"errored\"),f===\"erroring\"){@writableStreamFinishErroring(d);return}const h=@getByIdDirectPrivate(_,\"queue\");if(h.content\?.isEmpty()\?\?!1)return;const i=@peekQueueValue(h);if(i===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(_);else @writableStreamDefaultControllerProcessWrite(_,i)})\n"; // isCloseSentinel const JSC::ConstructAbility s_writableStreamInternalsIsCloseSentinelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -412,7 +412,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength = 237; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (i,b){\"use strict\";const h=@getByIdDirectPrivate(i,\"stream\");@assert(h!==@undefined),@assert(@getByIdDirectPrivate(h,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(i),@writableStreamStartErroring(h,b)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (h,b){\"use strict\";const i=@getByIdDirectPrivate(h,\"stream\");@assert(i!==@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(h),@writableStreamStartErroring(i,b)})\n"; // writableStreamDefaultControllerErrorIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -452,7 +452,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength = 441; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode = "(function (i){\"use strict\";const h=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkCloseRequestInFlight(h),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),@assert(@getByIdDirectPrivate(i,\"queue\").content\?.isEmpty());const _=@getByIdDirectPrivate(i,\"closeAlgorithm\").@call();@writableStreamDefaultControllerClearAlgorithms(i),_.@then(()=>{@writableStreamFinishInFlightClose(h)},(d)=>{@writableStreamFinishInFlightCloseWithError(h,d)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkCloseRequestInFlight(_),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),@assert(@getByIdDirectPrivate(i,\"queue\").content\?.isEmpty());const d=@getByIdDirectPrivate(i,\"closeAlgorithm\").@call();@writableStreamDefaultControllerClearAlgorithms(i),d.@then(()=>{@writableStreamFinishInFlightClose(_)},(h)=>{@writableStreamFinishInFlightCloseWithError(_,h)})})\n"; // writableStreamDefaultControllerProcessWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructAbility = 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,v){\"use strict\";const i=@getByIdDirectPrivate(d,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(i),@getByIdDirectPrivate(d,\"writeAlgorithm\").@call(@undefined,v).@then(()=>{@writableStreamFinishInFlightWrite(i);const _=@getByIdDirectPrivate(i,\"state\");if(@assert(_===\"writable\"||_===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(d,\"queue\")),!@writableStreamCloseQueuedOrInFlight(i)&&_===\"writable\"){const q=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(i,q)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)},(_)=>{if(@getByIdDirectPrivate(i,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(d);@writableStreamFinishInFlightWriteWithError(i,_)})})\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 (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"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = "(function (d,B,D){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),B,D);const y=@getByIdDirectPrivate(d,\"stream\"),I=@getByIdDirectPrivate(y,\"state\");if(!@writableStreamCloseQueuedOrInFlight(y)&&I===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(y,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)}catch(y){@writableStreamDefaultControllerErrorIfNeeded(d,y)}})\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 (q,v,B,c,x,D,E){\"use strict\";if(c===@undefined)c=1;if(x===@undefined)x=()=>1;if(D===@undefined)D=0;if(E===@undefined)E=()=>1;@assert(c>=0),@assert(D>=0);const F={};@putByIdDirectPrivate(F,\"TransformStream\",!0);const G=new @TransformStream(F),I=@newPromiseCapability(@Promise);@initializeTransformStream(G,I.@promise,c,x,D,E);const _=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(G,_,v,B),q().@then(()=>{I.@resolve.@call()},(j)=>{I.@reject.@call(@undefined,j)}),G})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (D,E,F,_,j,c,q){\"use strict\";if(_===@undefined)_=1;if(j===@undefined)j=()=>1;if(c===@undefined)c=0;if(q===@undefined)q=()=>1;@assert(_>=0),@assert(c>=0);const B={};@putByIdDirectPrivate(B,\"TransformStream\",!0);const v=new @TransformStream(B),x=@newPromiseCapability(@Promise);@initializeTransformStream(v,x.@promise,_,j,c,q);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(v,G,E,F),D().@then(()=>{x.@resolve.@call()},(I)=>{x.@reject.@call(@undefined,I)}),v})\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 (T,q,v,x,C,D){\"use strict\";const E=()=>{return q},f=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(T,N)},B=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(T,N)},F=()=>{return @transformStreamDefaultSinkCloseAlgorithm(T)},j=@createWritableStream(E,f,F,B,v,x),G=()=>{return @transformStreamDefaultSourcePullAlgorithm(T)},I=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(T,N),@Promise.@resolve()},J={};@putByIdDirectPrivate(J,\"start\",E),@putByIdDirectPrivate(J,\"pull\",G),@putByIdDirectPrivate(J,\"cancel\",I);const K={};@putByIdDirectPrivate(K,\"size\",D),@putByIdDirectPrivate(K,\"highWaterMark\",C);const L=new @ReadableStream(J,K);@putByIdDirectPrivate(T,\"writable\",j),@putByIdDirectPrivate(T,\"internalWritable\",@getInternalWritableStream(j)),@putByIdDirectPrivate(T,\"readable\",L),@putByIdDirectPrivate(T,\"backpressure\",@undefined),@putByIdDirectPrivate(T,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(T,!0),@putByIdDirectPrivate(T,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (f,x,C,D,E,F){\"use strict\";const q=()=>{return x},G=(B)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,B)},I=(B)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,B)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},v=@createWritableStream(q,G,J,I,C,D),K=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},L=(B)=>{return @transformStreamErrorWritableAndUnblockWrite(f,B),@Promise.@resolve()},T={};@putByIdDirectPrivate(T,\"start\",q),@putByIdDirectPrivate(T,\"pull\",K),@putByIdDirectPrivate(T,\"cancel\",L);const j={};@putByIdDirectPrivate(j,\"size\",F),@putByIdDirectPrivate(j,\"highWaterMark\",E);const N=new @ReadableStream(T,j);@putByIdDirectPrivate(f,\"writable\",v),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(v)),@putByIdDirectPrivate(f,\"readable\",N),@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; @@ -518,7 +518,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeCon const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorCodeLength = 222; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (f,n){\"use strict\";const i=@getByIdDirectPrivate(f,\"readable\"),_=@getByIdDirectPrivate(i,\"readableStreamController\");@readableStreamDefaultControllerError(_,n),@transformStreamErrorWritableAndUnblockWrite(f,n)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (f,i){\"use strict\";const n=@getByIdDirectPrivate(f,\"readable\"),_=@getByIdDirectPrivate(n,\"readableStreamController\");@readableStreamDefaultControllerError(_,i),@transformStreamErrorWritableAndUnblockWrite(f,i)})\n"; // transformStreamErrorWritableAndUnblockWrite const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility = 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,b,_,P){\"use strict\";@assert(@isTransformStream(d)),@assert(@getByIdDirectPrivate(d,\"controller\")===@undefined),@putByIdDirectPrivate(b,\"stream\",d),@putByIdDirectPrivate(d,\"controller\",b),@putByIdDirectPrivate(b,\"transformAlgorithm\",_),@putByIdDirectPrivate(b,\"flushAlgorithm\",P)})\n"; +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"; // setUpTransformStreamDefaultControllerFromTransformer const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 443; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,p,d){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in d)b=(q)=>{return @promiseInvokeOrNoopMethod(p,d.transform,[q,v])};if(\"flush\"in d)j=()=>{return @promiseInvokeOrNoopMethod(p,d.flush,[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (q,v,_){\"use strict\";const d=new @TransformStreamDefaultController;let b=(p)=>{try{@transformStreamDefaultControllerEnqueue(d,p)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in _)b=(p)=>{return @promiseInvokeOrNoopMethod(v,_.transform,[p,d])};if(\"flush\"in _)j=()=>{return @promiseInvokeOrNoopMethod(v,_.flush,[d])};@setUpTransformStreamDefaultController(q,d,b,j)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = 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){\"use strict\";const W=@getByIdDirectPrivate(_,\"stream\"),f=@getByIdDirectPrivate(W,\"readable\"),i=@getByIdDirectPrivate(f,\"readableStreamController\");if(@assert(i!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(i))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(i,S)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(W,j),@getByIdDirectPrivate(f,\"storedError\")}const g=!@readableStreamDefaultControllerShouldCallPull(i);if(g!==@getByIdDirectPrivate(W,\"backpressure\"))@assert(g),@transformStreamSetBackpressure(W,!0)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (g,i){\"use strict\";const _=@getByIdDirectPrivate(g,\"stream\"),W=@getByIdDirectPrivate(_,\"readable\"),S=@getByIdDirectPrivate(W,\"readableStreamController\");if(@assert(S!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(S))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(S,i)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(_,j),@getByIdDirectPrivate(W,\"storedError\")}const f=!@readableStreamDefaultControllerShouldCallPull(S);if(f!==@getByIdDirectPrivate(_,\"backpressure\"))@assert(f),@transformStreamSetBackpressure(_,!0)})\n"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (d,g){\"use strict\";const _=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(d,\"transformAlgorithm\").@call(@undefined,g).@then(()=>{_.@resolve()},(f)=>{@transformStreamError(@getByIdDirectPrivate(d,\"stream\"),f),_.@reject.@call(@undefined,f)}),_.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -590,7 +590,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 367; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const f=@getByIdDirectPrivate(i,\"stream\"),_=@getByIdDirectPrivate(f,\"readable\"),k=@getByIdDirectPrivate(_,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(f,u)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (f){\"use strict\";const i=@getByIdDirectPrivate(f,\"stream\"),k=@getByIdDirectPrivate(i,\"readable\"),_=@getByIdDirectPrivate(k,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(_))@readableStreamDefaultControllerClose(_);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(i,u)})\n"; // transformStreamDefaultSinkWriteAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = 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 (_,q){\"use strict\";const z=@getByIdDirectPrivate(_,\"internalWritable\");@assert(@getByIdDirectPrivate(z,\"state\")===\"writable\");const v=@getByIdDirectPrivate(_,\"controller\");if(@getByIdDirectPrivate(_,\"backpressure\")){const d=@newPromiseCapability(@Promise),j=@getByIdDirectPrivate(_,\"backpressureChangePromise\");return @assert(j!==@undefined),j.@promise.@then(()=>{const x=@getByIdDirectPrivate(z,\"state\");if(x===\"erroring\"){d.@reject.@call(@undefined,@getByIdDirectPrivate(z,\"storedError\"));return}@assert(x===\"writable\"),@transformStreamDefaultControllerPerformTransform(v,q).@then(()=>{d.@resolve()},(f)=>{d.@reject.@call(@undefined,f)})},(x)=>{d.@reject.@call(@undefined,x)}),d.@promise}return @transformStreamDefaultControllerPerformTransform(v,q)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (d,j){\"use strict\";const f=@getByIdDirectPrivate(d,\"internalWritable\");@assert(@getByIdDirectPrivate(f,\"state\")===\"writable\");const q=@getByIdDirectPrivate(d,\"controller\");if(@getByIdDirectPrivate(d,\"backpressure\")){const _=@newPromiseCapability(@Promise),x=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(x!==@undefined),x.@promise.@then(()=>{const v=@getByIdDirectPrivate(f,\"state\");if(v===\"erroring\"){_.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(v===\"writable\"),@transformStreamDefaultControllerPerformTransform(q,j).@then(()=>{_.@resolve()},(z)=>{_.@reject.@call(@undefined,z)})},(v)=>{_.@reject.@call(@undefined,v)}),_.@promise}return @transformStreamDefaultControllerPerformTransform(q,j)})\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 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"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode = "(function (f){\"use strict\";const _=@getByIdDirectPrivate(f,\"readable\"),q=@getByIdDirectPrivate(f,\"controller\"),j=@getByIdDirectPrivate(_,\"readableStreamController\"),k=@getByIdDirectPrivate(q,\"flushAlgorithm\");@assert(k!==@undefined);const u=@getByIdDirectPrivate(q,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(q);const I=@newPromiseCapability(@Promise);return u.@then(()=>{if(@getByIdDirectPrivate(_,\"state\")===@streamErrored){I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(j))@readableStreamDefaultControllerClose(j);I.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(q,\"stream\"),v),I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"))}),I.@promise})\n"; // transformStreamDefaultSourcePullAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -640,7 +640,7 @@ const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsBindingCodeLength = 473; static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsBindingCode = "(function (d){\"use strict\";if(d!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var l=globalThis.Symbol.for(\"process.bindings.constants\"),I=globalThis[l];if(!I){const{constants:r}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");I={fs:r,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[l]=I}return I})\n"; +const char* const s_processObjectInternalsBindingCode = "(function (I){\"use strict\";if(I!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var r=globalThis.Symbol.for(\"process.bindings.constants\"),l=globalThis[r];if(!l){const{constants:d}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");l={fs:d,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[r]=l}return l})\n"; // getStdioWriteStream const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (B,Q){\"use strict\";var j={path:\"node:process\",require:Q},U=(Z)=>j.require(Z);function z(Z){var{Duplex:J,eos:Y,destroy:K}=U(\"node:stream\"),P=class L extends J{#$;#B;#j=!0;#z=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=U(\"node:tty\").isatty(Z)}get fd(){return Z}constructor(A){super({readable:!0,writable:!0});this.#G=`/dev/fd/${A}`}#N(A){const M=this.#H;if(this.#H=null,M)M(A);else if(A)this.destroy(A);else if(!this.#j&&!this.#z)this.destroy()}_destroy(A,M){if(!A&&this.#H!==null){var T=class N extends Error{code;name;constructor(x=\"The operation was aborted\",O=void 0){if(O!==void 0&&typeof O!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(O,null,2)}`);super(x,O);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};A=new T}if(this.#J=null,this.#K=null,this.#H===null)M(A);else{if(this.#H=M,this.#$)K(this.#$,A);if(this.#B)K(this.#B,A)}}_write(A,M,T){if(!this.#$){var{createWriteStream:N}=U(\"node:fs\"),x=this.#$=N(this.#G);x.on(\"finish\",()=>{if(this.#K){const O=this.#K;this.#K=null,O()}}),x.on(\"drain\",()=>{if(this.#J){const O=this.#J;this.#J=null,O()}}),Y(x,(O)=>{if(this.#z=!1,O)K(x,O);this.#N(O)})}if(x.write(A,M))T();else this.#J=T}_final(A){this.#$&&this.#$.end(),this.#K=A}#O(){var{createReadStream:A}=U(\"node:fs\"),M=this.#B=A(this.#G);return M.on(\"readable\",()=>{if(this.#L){const T=this.#L;this.#L=null,T()}else this.read()}),M.on(\"end\",()=>{this.push(null)}),Y(M,(T)=>{if(this.#j=!1,T)K(M,T);this.#N(T)}),M}_read(){var A=this.#B;if(!A)A=this.#O();while(!0){const M=A.read();if(M===null||!this.push(M))return}}};return new P(Z)}var{EventEmitter:V}=U(\"node:events\");function G(Z){if(!Z)return!0;var J=Z.toLowerCase();return J===\"utf8\"||J===\"utf-8\"||J===\"buffer\"||J===\"binary\"}var X,H=class Z extends V{#$;#B;#j;#z;bytesWritten=0;setDefaultEncoding(J){if(this.#B||!G(J))return this.#J(),this.#B.setDefaultEncoding(J)}#G(){switch(this.#$){case 1:{var J=@Bun.stdout.writer({highWaterMark:0});return J.unref(),J}case 2:{var J=@Bun.stderr.writer({highWaterMark:0});return J.unref(),J}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#G()}constructor(J){super();this.#$=J}get fd(){return this.#$}get isTTY(){return this.#z\?\?=U(\"node:tty\").isatty(this.#$)}cursorTo(J,Y,K){return(X\?\?=U(\"readline\")).cursorTo(this,J,Y,K)}moveCursor(J,Y,K){return(X\?\?=U(\"readline\")).moveCursor(this,J,Y,K)}clearLine(J,Y){return(X\?\?=U(\"readline\")).clearLine(this,J,Y)}clearScreenDown(J){return(X\?\?=U(\"readline\")).clearScreenDown(this,J)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(J,Y){if(J===\"close\"||J===\"finish\")return this.#J(),this.#B.on(J,Y);if(J===\"drain\")return super.on(\"drain\",Y);if(J===\"error\")return super.on(\"error\",Y);return super.on(J,Y)}get _writableState(){return this.#J(),this.#B._writableState}get _readableState(){return this.#J(),this.#B._readableState}pipe(J){return this.#J(),this.#B.pipe(J)}unpipe(J){return this.#J(),this.#B.unpipe(J)}#J(){if(this.#B)return;this.#B=z(this.#$);const J=this.eventNames();for(let Y of J)this.#B.on(Y,(...K)=>{this.emit(Y,...K)})}#K(J){var Y=this.#H();const K=Y.write(J);this.bytesWritten+=K;const P=Y.flush(!1);return!!(K||P)}#L(J,Y){if(!G(Y))return this.#J(),this.#B.write(J,Y);return this.#K(J)}#M(J,Y){if(Y)this.emit(\"error\",Y);try{J(Y\?Y:null)}catch(K){this.emit(\"error\",K)}}#N(J,Y,K){if(!G(Y))return this.#J(),this.#B.write(J,Y,K);var P=this.#H();const L=P.write(J),A=P.flush(!0);if(A\?.then)return A.then(()=>{this.#M(K),this.emit(\"drain\")},(M)=>this.#M(K,M)),!1;return queueMicrotask(()=>{this.#M(K)}),!!(L||A)}write(J,Y,K){const P=this._write(J,Y,K);if(P)this.emit(\"drain\");return P}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(J,Y,K){var P=this.#B;if(P)return P.write(J,Y,K);switch(arguments.length){case 0:{var L=new Error(\"Invalid arguments\");throw L.code=\"ERR_INVALID_ARG_TYPE\",L}case 1:return this.#K(J);case 2:if(typeof Y===\"function\")return this.#N(J,\"\",Y);else if(typeof Y===\"string\")return this.#L(J,Y);default:{if(typeof Y!==\"undefined\"&&typeof Y!==\"string\"||typeof K!==\"undefined\"&&typeof K!==\"function\"){var L=new Error(\"Invalid arguments\");throw L.code=\"ERR_INVALID_ARG_TYPE\",L}if(typeof K===\"undefined\")return this.#L(J,Y);return this.#N(J,Y,K)}}}destroy(){return this}end(){return this}};return new H(B)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (Z,Y){\"use strict\";var P={path:\"node:process\",require:Y},L=(M)=>P.require(M);function A(M){var{Duplex:B,eos:j,destroy:z}=L(\"node:stream\"),J=class O extends B{#j;#$;#M=!0;#N=!0;#J;#z;#B;#G;#H;#K;get isTTY(){return this.#K\?\?=L(\"node:tty\").isatty(M)}get fd(){return M}constructor(G){super({readable:!0,writable:!0});this.#J=`/dev/fd/${G}`}#L(G){const H=this.#z;if(this.#z=null,H)H(G);else if(G)this.destroy(G);else if(!this.#M&&!this.#N)this.destroy()}_destroy(G,H){if(!G&&this.#z!==null){var N=class X extends Error{code;name;constructor(Q=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(Q,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};G=new N}if(this.#B=null,this.#G=null,this.#z===null)H(G);else{if(this.#z=H,this.#j)z(this.#j,G);if(this.#$)z(this.#$,G)}}_write(G,H,N){if(!this.#j){var{createWriteStream:X}=L(\"node:fs\"),Q=this.#j=X(this.#J);Q.on(\"finish\",()=>{if(this.#G){const K=this.#G;this.#G=null,K()}}),Q.on(\"drain\",()=>{if(this.#B){const K=this.#B;this.#B=null,K()}}),j(Q,(K)=>{if(this.#N=!1,K)z(Q,K);this.#L(K)})}if(Q.write(G,H))N();else this.#B=N}_final(G){this.#j&&this.#j.end(),this.#G=G}#O(){var{createReadStream:G}=L(\"node:fs\"),H=this.#$=G(this.#J);return H.on(\"readable\",()=>{if(this.#H){const N=this.#H;this.#H=null,N()}else this.read()}),H.on(\"end\",()=>{this.push(null)}),j(H,(N)=>{if(this.#M=!1,N)z(H,N);this.#L(N)}),H}_read(){var G=this.#$;if(!G)G=this.#O();while(!0){const H=G.read();if(H===null||!this.push(H))return}}};return new J(M)}var{EventEmitter:T}=L(\"node:events\");function V(M){if(!M)return!0;var B=M.toLowerCase();return B===\"utf8\"||B===\"utf-8\"||B===\"buffer\"||B===\"binary\"}var U,x=class M extends T{#j;#$;#M;#N;bytesWritten=0;setDefaultEncoding(B){if(this.#$||!V(B))return this.#B(),this.#$.setDefaultEncoding(B)}#J(){switch(this.#j){case 1:{var B=@Bun.stdout.writer({highWaterMark:0});return B.unref(),B}case 2:{var B=@Bun.stderr.writer({highWaterMark:0});return B.unref(),B}default:throw new Error(\"Unsupported writer\")}}#z(){return this.#M\?\?=this.#J()}constructor(B){super();this.#j=B}get fd(){return this.#j}get isTTY(){return this.#N\?\?=L(\"node:tty\").isatty(this.#j)}cursorTo(B,j,z){return(U\?\?=L(\"readline\")).cursorTo(this,B,j,z)}moveCursor(B,j,z){return(U\?\?=L(\"readline\")).moveCursor(this,B,j,z)}clearLine(B,j){return(U\?\?=L(\"readline\")).clearLine(this,B,j)}clearScreenDown(B){return(U\?\?=L(\"readline\")).clearScreenDown(this,B)}ref(){this.#z().ref()}unref(){this.#z().unref()}on(B,j){if(B===\"close\"||B===\"finish\")return this.#B(),this.#$.on(B,j);if(B===\"drain\")return super.on(\"drain\",j);if(B===\"error\")return super.on(\"error\",j);return super.on(B,j)}get _writableState(){return this.#B(),this.#$._writableState}get _readableState(){return this.#B(),this.#$._readableState}pipe(B){return this.#B(),this.#$.pipe(B)}unpipe(B){return this.#B(),this.#$.unpipe(B)}#B(){if(this.#$)return;this.#$=A(this.#j);const B=this.eventNames();for(let j of B)this.#$.on(j,(...z)=>{this.emit(j,...z)})}#G(B){var j=this.#z();const z=j.write(B);this.bytesWritten+=z;const J=j.flush(!1);return!!(z||J)}#H(B,j){if(!V(j))return this.#B(),this.#$.write(B,j);return this.#G(B)}#K(B,j){if(j)this.emit(\"error\",j);try{B(j\?j:null)}catch(z){this.emit(\"error\",z)}}#L(B,j,z){if(!V(j))return this.#B(),this.#$.write(B,j,z);var J=this.#z();const O=J.write(B),G=J.flush(!0);if(G\?.then)return G.then(()=>{this.#K(z),this.emit(\"drain\")},(H)=>this.#K(z,H)),!1;return queueMicrotask(()=>{this.#K(z)}),!!(O||G)}write(B,j,z){const J=this._write(B,j,z);if(J)this.emit(\"drain\");return J}get hasColors(){return @Bun.tty[this.#j].hasColors}_write(B,j,z){var J=this.#$;if(J)return J.write(B,j,z);switch(arguments.length){case 0:{var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}case 1:return this.#G(B);case 2:if(typeof j===\"function\")return this.#L(B,\"\",j);else if(typeof j===\"string\")return this.#H(B,j);default:{if(typeof j!==\"undefined\"&&typeof j!==\"string\"||typeof z!==\"undefined\"&&typeof z!==\"function\"){var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}if(typeof z===\"undefined\")return this.#H(B,j);return this.#L(B,j,z)}}}destroy(){return this}end(){return this}};return new x(Z)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = 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,j,z){\"use strict\";var G={path:\"node:process\",require:j},H=(T)=>G.require(T),{Duplex:I,eos:J,destroy:K}=H(\"node:stream\"),L=class T extends I{#Y;#$;#j;#z=!0;#G=!1;#H=!0;#I;#J;#K;get isTTY(){return H(\"tty\").isatty(Y)}get fd(){return Y}constructor(){super({readable:!0,writable:!0})}#L(V){const M=this.#J;if(this.#J=null,M)M(V);else if(V)this.destroy(V);else if(!this.#z&&!this.#H)this.destroy()}_destroy(V,M){if(!V&&this.#J!==null){var N=class P extends Error{constructor(Q=\"The operation was aborted\",U=void 0){if(U!==void 0&&typeof U!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(U,null,2)}`);super(Q,U);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};V=new N}if(this.#J===null)M(V);else if(this.#J=M,this.#j)K(this.#j,V)}setRawMode(V){}on(V,M){if(V===\"readable\")this.ref(),this.#G=!0;return super.on(V,M)}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 V,M;const N=this.#Y.readMany();if(!N\?.then)({done:V,value:M}=N);else({done:V,value:M}=await N);if(!V){this.push(M[0]);const P=M.length;for(let Q=1;Q{if(this.#I){const N=this.#I;this.#I=null,N()}}),M.on(\"drain\",()=>{if(this.#K){const N=this.#K;this.#K=null,N()}}),J(M,(N)=>{if(this.#H=!1,N)K(M,N);this.#L(N)}),M}_write(V,M,N){var P=this.#j;if(!P)P=this.#N();if(P.write(V,M))N();else this.#K=N}_final(V){this.#j.end(),this.#I=(...M)=>V(...M)}};return new L})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (L,N,P){\"use strict\";var Q={path:\"node:process\",require:N},J=(K)=>Q.require(K),{Duplex:T,eos:U,destroy:M}=J(\"node:stream\"),V=class K extends T{#K;#j;#Y;#H=!0;#I=!1;#L=!0;#z;#$;#G;get isTTY(){return J(\"tty\").isatty(L)}get fd(){return L}constructor(){super({readable:!0,writable:!0})}#J(Y){const j=this.#$;if(this.#$=null,j)j(Y);else if(Y)this.destroy(Y);else if(!this.#H&&!this.#L)this.destroy()}_destroy(Y,j){if(!Y&&this.#$!==null){var z=class G extends Error{constructor(H=\"The operation was aborted\",I=void 0){if(I!==void 0&&typeof I!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(I,null,2)}`);super(H,I);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Y=new z}if(this.#$===null)j(Y);else if(this.#$=j,this.#Y)M(this.#Y,Y)}setRawMode(Y){}on(Y,j){if(Y===\"readable\")this.ref(),this.#I=!0;return super.on(Y,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#K\?\?=P.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#M(){try{var Y,j;const z=this.#K.readMany();if(!z\?.then)({done:Y,value:j}=z);else({done:Y,value:j}=await z);if(!Y){this.push(j[0]);const G=j.length;for(let H=1;H{if(this.#z){const z=this.#z;this.#z=null,z()}}),j.on(\"drain\",()=>{if(this.#G){const z=this.#G;this.#G=null,z()}}),U(j,(z)=>{if(this.#L=!1,z)M(j,z);this.#J(z)}),j}_write(Y,j,z){var G=this.#Y;if(!G)G=this.#N();if(G.write(Y,j))z();else this.#G=z}_final(Y){this.#Y.end(),this.#z=(...j)=>Y(...j)}};return new V})\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 = 1304; static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let u=arguments[1],j=arguments[2];if(_===@undefined)_=null;if(j===@undefined)j={};if(u===@undefined)u={};let q={};if(_!==null){if(\"start\"in _){if(q.start=_.start,typeof q.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(q.transform=_.transform,typeof q.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(q.flush=_.flush,typeof q.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const v=@extractHighWaterMark(j,0),x=@extractSizeAlgorithm(j),B=@extractHighWaterMark(u,1),E=@extractSizeAlgorithm(u),F=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,F.@promise,B,E,v,x),@setUpTransformStreamDefaultControllerFromTransformer(this,_,q),(\"start\"in q)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,q.start,[G]))().@then(()=>{F.@resolve.@call()},(J)=>{F.@reject.@call(@undefined,J)})}else F.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let j=arguments[1],q=arguments[2];if(_===@undefined)_=null;if(q===@undefined)q={};if(j===@undefined)j={};let u={};if(_!==null){if(\"start\"in _){if(u.start=_.start,typeof u.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(u.transform=_.transform,typeof u.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(u.flush=_.flush,typeof u.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const x=@extractHighWaterMark(q,0),B=@extractSizeAlgorithm(q),E=@extractHighWaterMark(j,1),F=@extractSizeAlgorithm(j),v=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,v.@promise,E,F,x,B),@setUpTransformStreamDefaultControllerFromTransformer(this,_,u),(\"start\"in u)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,u.start,[G]))().@then(()=>{v.@resolve.@call()},(I)=>{v.@reject.@call(@undefined,I)})}else v.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (_){\"use strict\";const f=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(f)return @evaluateCommonJSModule(f),f.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const L=S.module,h=@Loader.getModuleNamespaceObject(L),r=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const b=@createCommonJSModule(_,{},!1);@requireMap.@set(_,b);var M=this.@require(_,b);if(M===-1){try{M=@requireESM(_)}catch(L){throw @requireMap.@delete(_),L}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const L=@Loader.getModuleNamespaceObject(S.module);return b.exports=L\?.[@commonJSSymbol]===0||L\?.default\?.[@commonJSSymbol]===0\?L.default:L.__esModule\?L:Object.create(L,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(b),b.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const b=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(b)return @evaluateCommonJSModule(b),b.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=S.module,f=@Loader.getModuleNamespaceObject(M),r=f\?.[@commonJSSymbol]===0||f\?.default\?.[@commonJSSymbol]===0\?f.default:f.__esModule\?f:Object.create(f,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const L=@createCommonJSModule(_,{},!1);@requireMap.@set(_,L);var h=this.@require(_,L);if(h===-1){try{h=@requireESM(_)}catch(M){throw @requireMap.@delete(_),M}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=@Loader.getModuleNamespaceObject(S.module);return L.exports=M\?.[@commonJSSymbol]===0||M\?.default\?.[@commonJSSymbol]===0\?M.default:M.__esModule\?M:Object.create(M,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -742,7 +742,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSetBigUint64CodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeSetBigUint64CodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSetBigUint64CodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeSetBigUint64CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSetBigUint64Code = "(function (r,d,t){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(r,d,t)})\n"; +const char* const s_jsBufferPrototypeSetBigUint64Code = "(function (d,r,t){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,r,t)})\n"; // readInt8 const JSC::ConstructAbility s_jsBufferPrototypeReadInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (r,u){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(u){case 1:return _.getInt8(r);case 2:return _.getInt16(r,!0);case 3:{const d=_.getUint16(r,!0)+_.getUint8(r+2)*65536;return d|(d&8388608)*510}case 4:return _.getInt32(r,!0);case 5:{const d=_.getUint8(r+4);return(d|(d&128)*33554430)*4294967296+_.getUint32(r,!0)}case 6:{const d=_.getUint16(r+4,!0);return(d|(d&32768)*131070)*4294967296+_.getUint32(r,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,u){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(u){case 1:return r.getInt8(d);case 2:return r.getInt16(d,!0);case 3:{const _=r.getUint16(d,!0)+r.getUint8(d+2)*65536;return _|(_&8388608)*510}case 4:return r.getInt32(d,!0);case 5:{const _=r.getUint8(d+4);return(_|(_&128)*33554430)*4294967296+r.getUint32(d,!0)}case 6:{const _=r.getUint16(d+4,!0);return(_|(_&32768)*131070)*4294967296+r.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -854,7 +854,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntBECodeLength = 504; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,r){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return c.getUint8(d);case 2:return c.getUint16(d,!1);case 3:return c.getUint16(d+1,!1)+c.getUint8(d)*65536;case 4:return c.getUint32(d,!1);case 5:{const p=c.getUint8(d);return(p|(p&128)*33554430)*4294967296+c.getUint32(d+1,!1)}case 6:{const p=c.getUint16(d,!1);return(p|(p&32768)*131070)*4294967296+c.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,p){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:return r.getUint8(d);case 2:return r.getUint16(d,!1);case 3:return r.getUint16(d+1,!1)+r.getUint8(d)*65536;case 4:return r.getUint32(d,!1);case 5:{const c=r.getUint8(d);return(c|(c&128)*33554430)*4294967296+r.getUint32(d+1,!1)}case 6:{const c=r.getUint16(d,!1);return(c|(c&32768)*131070)*4294967296+r.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readFloatLE const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -926,7 +926,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt8CodeLength = 131; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt8Code = "(function (d,r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(r,d),r+1})\n"; +const char* const s_jsBufferPrototypeWriteInt8Code = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(d,r),d+1})\n"; // writeUInt8 const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -934,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(d,c),d+1})\n"; +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"; // writeInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -942,7 +942,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt16LECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!0),d+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!0),c+2})\n"; // writeInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -958,7 +958,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt16LECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!0),d+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!0),c+2})\n"; // writeUInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -966,7 +966,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt16BECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!1),d+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!1),c+2})\n"; // writeInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -974,7 +974,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt32LECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!0),c+4})\n"; // writeInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -982,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; @@ -990,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!0),d+4})\n"; +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"; // writeUInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -998,7 +998,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt32BECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(c,d,!1),c+4})\n"; // writeIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1006,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 (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"; +const char* const s_jsBufferPrototypeWriteIntLECode = "(function (r,d,j){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(j){case 1:{c.setInt8(d,r);break}case 2:{c.setInt16(d,r,!0);break}case 3:{c.setUint16(d,r&65535,!0),c.setInt8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{c.setInt32(d,r,!0);break}case 5:{c.setUint32(d,r|0,!0),c.setInt8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{c.setUint32(d,r|0,!0),c.setInt16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+j})\n"; // writeIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1014,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 (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"; +const char* const s_jsBufferPrototypeWriteIntBECode = "(function (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setInt8(d,r);break}case 2:{E.setInt16(d,r,!1);break}case 3:{E.setUint16(d+1,r&65535,!1),E.setInt8(d,Math.floor(r*0.0000152587890625));break}case 4:{E.setInt32(d,r,!1);break}case 5:{E.setUint32(d+1,r|0,!1),E.setInt8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d+2,r|0,!1),E.setInt16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\n"; // writeUIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1022,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 (r,E,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{d.setUint8(E,r);break}case 2:{d.setUint16(E,r,!0);break}case 3:{d.setUint16(E,r&65535,!0),d.setUint8(E+2,Math.floor(r*0.0000152587890625));break}case 4:{d.setUint32(E,r,!0);break}case 5:{d.setUint32(E,r|0,!0),d.setUint8(E+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(E,r|0,!0),d.setUint16(E+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return E+c})\n"; +const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setUint8(d,r);break}case 2:{E.setUint16(d,r,!0);break}case 3:{E.setUint16(d,r&65535,!0),E.setUint8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{E.setUint32(d,r,!0);break}case 5:{E.setUint32(d,r|0,!0),E.setUint8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d,r|0,!0),E.setUint16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\n"; // writeUIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1030,7 +1030,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntBECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (d,r,_){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{p.setUint8(r,d);break}case 2:{p.setUint16(r,d,!1);break}case 3:{p.setUint16(r+1,d&65535,!1),p.setUint8(r,Math.floor(d*0.0000152587890625));break}case 4:{p.setUint32(r,d,!1);break}case 5:{p.setUint32(r+1,d|0,!1),p.setUint8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{p.setUint32(r+2,d|0,!1),p.setUint16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+_})\n"; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (r,d,_){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{p.setUint8(d,r);break}case 2:{p.setUint16(d,r,!1);break}case 3:{p.setUint16(d+1,r&65535,!1),p.setUint8(d,Math.floor(r*0.0000152587890625));break}case 4:{p.setUint32(d,r,!1);break}case 5:{p.setUint32(d+1,r|0,!1),p.setUint8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{p.setUint32(d+2,r|0,!1),p.setUint16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+_})\n"; // writeFloatLE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1038,7 +1038,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!0),c+4})\n"; // writeFloatBE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1046,7 +1046,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!1),c+4})\n"; // writeDoubleLE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1054,7 +1054,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteDoubleLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!0),c+8})\n"; // writeDoubleBE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1062,7 +1062,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteDoubleBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!1),c+8})\n"; // writeBigInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1070,7 +1070,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigInt64LECodeLength = 138; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,d,!0),c+8})\n"; // writeBigInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1078,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!1),d+8})\n"; +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"; // writeBigUInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1086,7 +1086,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKin const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigUInt64LECodeLength = 139; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!0),c+8})\n"; // writeBigUInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1110,7 +1110,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUcs2WriteCodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUcs2WriteCodeLength = 65; static const JSC::Intrinsic s_jsBufferPrototypeUcs2WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUcs2WriteCode = "(function (d,c,r){\"use strict\";return this.write(d,c,r,\"ucs2\")})\n"; +const char* const s_jsBufferPrototypeUcs2WriteCode = "(function (c,d,r){\"use strict\";return this.write(c,d,r,\"ucs2\")})\n"; // utf16leWrite const JSC::ConstructAbility s_jsBufferPrototypeUtf16leWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1118,7 +1118,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf16leWriteCodeLength = 68; static const JSC::Intrinsic s_jsBufferPrototypeUtf16leWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (d,a,r){\"use strict\";return this.write(d,a,r,\"utf16le\")})\n"; +const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (d,r,a){\"use strict\";return this.write(d,r,a,\"utf16le\")})\n"; // latin1Write const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1126,7 +1126,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeLatin1WriteCodeLength = 67; static const JSC::Intrinsic s_jsBufferPrototypeLatin1WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (a,r,d){\"use strict\";return this.write(a,r,d,\"latin1\")})\n"; +const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (a,d,r){\"use strict\";return this.write(a,d,r,\"latin1\")})\n"; // asciiWrite const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1182,7 +1182,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf16leSliceCodeLength = 67; static const JSC::Intrinsic s_jsBufferPrototypeUtf16leSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leSliceCode = "(function (p,g){\"use strict\";return this.toString(\"utf16le\",p,g)})\n"; +const char* const s_jsBufferPrototypeUtf16leSliceCode = "(function (g,p){\"use strict\";return this.toString(\"utf16le\",g,p)})\n"; // latin1Slice const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1198,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 (u,g){\"use strict\";return this.toString(\"ascii\",u,g)})\n"; +const char* const s_jsBufferPrototypeAsciiSliceCode = "(function (g,u){\"use strict\";return this.toString(\"ascii\",g,u)})\n"; // base64Slice const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1206,7 +1206,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeBase64SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64SliceCodeLength = 66; static const JSC::Intrinsic s_jsBufferPrototypeBase64SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64SliceCode = "(function (p,g){\"use strict\";return this.toString(\"base64\",p,g)})\n"; +const char* const s_jsBufferPrototypeBase64SliceCode = "(function (g,p){\"use strict\";return this.toString(\"base64\",g,p)})\n"; // base64urlSlice const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1214,7 +1214,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeBase64urlSliceCodeLength = 69; static const JSC::Intrinsic s_jsBufferPrototypeBase64urlSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlSliceCode = "(function (g,c){\"use strict\";return this.toString(\"base64url\",g,c)})\n"; +const char* const s_jsBufferPrototypeBase64urlSliceCode = "(function (c,g){\"use strict\";return this.toString(\"base64url\",c,g)})\n"; // hexSlice const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (c,m){\"use strict\";var{buffer:v,byteOffset:w,byteLength:p}=this;function x(i,q){if(i=@trunc(i),i===0||@isNaN(i))return 0;else if(i<0)return i+=q,i>0\?i:0;else return ik\?z-k:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (w,m){\"use strict\";var{buffer:x,byteOffset:z,byteLength:p}=this;function q(c,k){if(c=@trunc(c),c===0||@isNaN(c))return 0;else if(c<0)return c+=k,c>0\?c:0;else return ci\?v-i:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,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 a=@getByIdDirectPrivate(this,\"byobRequest\");if(a===@undefined){var l=@getByIdDirectPrivate(this,\"pendingPullIntos\");const _=l.peek();if(_){const m=new @Uint8Array(_.buffer,_.byteOffset+_.bytesFilled,_.byteLength-_.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,m,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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 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"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const D=async function*L(){var F=@Bun.stdin.stream().getReader(),G=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),z,H=@Bun.indexOfLine;try{while(!0){var A,B,w;const m=F.readMany();if(@isPromise(m))({done:A,value:B}=await m);else({done:A,value:B}=m);if(A){if(w)yield G.decode(w);return}var _;for(let J of B){if(_=J,w)_=@Buffer.concat([w,J]),w=null;var j=0,q=H(_,j);while(q!==-1)yield G.decode(_.subarray(j,q)),j=q+1,q=H(_,j);w=_.subarray(j)}}}catch(m){z=m}finally{if(F.releaseLock(),z)throw z}},K=globalThis.Symbol.asyncIterator;return this[K]=D,D()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (f){\"use strict\";var a=@getByIdDirectPrivate(this,\"writer\");if(!a){var b=@toLength(f\?.length\?\?0);a=@Bun.stdout.writer({highWaterMark:b>65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",a)}var d=a.write(f);const c=@argumentCount();for(var _=1;_65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",a)}var c=a.write(_);const f=@argumentCount();for(var d=1;d{},(y)=>{c.error(y)});function h(){@readableStreamDefaultReaderRead(g).@then(function(y){if(y.done){c.close();return}try{c.enqueue(y.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}h()},function(y){c.error(y)})}h()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (g,c){\"use strict\";@assert(@isReadableStream(g));const h=new @ReadableStreamDefaultReader(g);@getByIdDirectPrivate(h,\"closedPromiseCapability\").@promise.@then(()=>{},(_)=>{c.error(_)});function y(){@readableStreamDefaultReaderRead(h).@then(function(_){if(_.done){c.close();return}try{c.enqueue(_.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(_){c.error(_)})}y()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1404,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 (_,q,w,x,B,f,v){\"use strict\";const C=new @ReadableStreamDefaultController(_,q,w,x,@isReadableStream),b=()=>@promiseInvokeOrNoopMethod(q,f,[C]),D=(j)=>@promiseInvokeOrNoopMethod(q,v,[j]);@putByIdDirectPrivate(C,\"pullAlgorithm\",b),@putByIdDirectPrivate(C,\"cancelAlgorithm\",D),@putByIdDirectPrivate(C,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(C,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(_,\"readableStreamController\",C),@readableStreamDefaultControllerStart(C)})\n"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (b,f,j,q,D,v,w){\"use strict\";const _=new @ReadableStreamDefaultController(b,f,j,q,@isReadableStream),x=()=>@promiseInvokeOrNoopMethod(f,v,[_]),B=(C)=>@promiseInvokeOrNoopMethod(f,w,[C]);@putByIdDirectPrivate(_,\"pullAlgorithm\",x),@putByIdDirectPrivate(_,\"cancelAlgorithm\",B),@putByIdDirectPrivate(_,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(_,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",_),@readableStreamDefaultControllerStart(_)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,b)}else if(A===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (w,v,f){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(f.highWaterMark===@undefined)f.highWaterMark=0;if(f.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(w,\"readableStreamController\",new @ReadableByteStreamController(w,v,f.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=f\?.highWaterMark;@initializeArrayBufferStream.@call(w,v,b)}else if(A===@undefined){if(f.highWaterMark===@undefined)f.highWaterMark=1;@setupReadableStreamDefaultController(w,v,f.size,f.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1420,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 p=@getByIdDirectPrivate(m,\"underlyingSource\"),B=p.start;@putByIdDirectPrivate(m,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(p,B,[m]).@then(()=>{@putByIdDirectPrivate(m,\"started\",1),@assert(!@getByIdDirectPrivate(m,\"pulling\")),@assert(!@getByIdDirectPrivate(m,\"pullAgain\")),@readableStreamDefaultControllerCallPullIfNeeded(m)},(a)=>{@readableStreamDefaultControllerError(m,a)})})\n"; +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"; // readableStreamPipeToWritableStream const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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 (_,k,q,w,f,x){\"use strict\";if(@assert(@isReadableStream(_)),@assert(@isWritableStream(k)),@assert(!@isReadableStreamLocked(_)),@assert(!@isWritableStreamLocked(k)),@assert(x===@undefined||@isAbortSignal(x)),@getByIdDirectPrivate(_,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let z={source:_,destination:k,preventAbort:w,preventCancel:f,preventClose:q,signal:x};if(z.reader=@acquireReadableStreamDefaultReader(_),z.writer=@acquireWritableStreamDefaultWriter(k),@putByIdDirectPrivate(_,\"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 I=!z.preventAbort&&@getByIdDirectPrivate(z.destination,\"state\")===\"writable\"\?@writableStreamAbort(z.destination,F):@Promise.@resolve(),D=!z.preventCancel&&@getByIdDirectPrivate(z.source,\"state\")===@streamReadable\?@readableStreamCancel(z.source,F):@Promise.@resolve();let J=@newPromiseCapability(@Promise),E=!0,K=()=>{if(E){E=!1;return}J.@resolve.@call()},L=(T)=>{J.@reject.@call(@undefined,T)};return I.@then(K,L),D.@then(K,L),J.@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 (f,E,z,B,F,D){\"use strict\";if(@assert(@isReadableStream(f)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(f)),@assert(!@isWritableStreamLocked(E)),@assert(D===@undefined||@isAbortSignal(D)),@getByIdDirectPrivate(f,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:f,destination:E,preventAbort:B,preventCancel:F,preventClose:z,signal:D};if(_.reader=@acquireReadableStreamDefaultReader(f),_.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(f,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),D!==@undefined){const G=(T)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const H=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,T):@Promise.@resolve(),I=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,T):@Promise.@resolve();let k=@newPromiseCapability(@Promise),q=!0,w=()=>{if(q){q=!1;return}k.@resolve.@call()},x=(J)=>{k.@reject.@call(@undefined,J)};return H.@then(w,x),I.@then(w,x),k.@promise},T)};if(@whenSignalAborted(D,G))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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 (g,j){\"use strict\";if(g.shuttingDown)return;g.shuttingDown=!0;const _=arguments.length>2,b=arguments[2],d=()=>{j().@then(()=>{if(_)@pipeToFinalize(g,b);else @pipeToFinalize(g)},(h)=>{@pipeToFinalize(g,h)})};if(@getByIdDirectPrivate(g.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(g.destination)){g.pendingReadPromiseCapability.@promise.@then(()=>{g.pendingWritePromise.@then(d,d)},(m)=>@pipeToFinalize(g,m));return}d()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (_,d){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const g=arguments.length>2,h=arguments[2],m=()=>{d().@then(()=>{if(g)@pipeToFinalize(_,h);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(m,m)},(b)=>@pipeToFinalize(_,b));return}m()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1492,7 +1492,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownCodeLength = 411; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,I=arguments[1],u=()=>{if(m)@pipeToFinalize(_,I);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(d)=>@pipeToFinalize(_,d));return}u()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,u=arguments[1],d=()=>{if(m)@pipeToFinalize(_,u);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(d,d)},(I)=>@pipeToFinalize(_,I));return}d()})\n"; // pipeToFinalize const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,f){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof f===\"boolean\");var g=@getByIdDirectPrivate(_,\"start\");if(g)@putByIdDirectPrivate(_,\"start\",@undefined),g();const j=new @ReadableStreamDefaultReader(_),k={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};k.cancelPromiseCapability=@newPromiseCapability(@Promise);const q=@readableStreamTeePullFunction(k,j,f),v={};@putByIdDirectPrivate(v,\"pull\",q),@putByIdDirectPrivate(v,\"cancel\",@readableStreamTeeBranch1CancelFunction(k,_));const w={};@putByIdDirectPrivate(w,\"pull\",q),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(k,_));const x=new @ReadableStream(v),y=new @ReadableStream(w);return @getByIdDirectPrivate(j,\"closedPromiseCapability\").@promise.@then(@undefined,function(i){if(k.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,i),@readableStreamDefaultControllerError(y.@readableStreamController,i),k.closedOrErrored=!0,!k.canceled1||!k.canceled2)k.cancelPromiseCapability.@resolve.@call()}),k.branch1=x,k.branch2=y,[x,y]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,q){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof q===\"boolean\");var v=@getByIdDirectPrivate(_,\"start\");if(v)@putByIdDirectPrivate(_,\"start\",@undefined),v();const w=new @ReadableStreamDefaultReader(_),i={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};i.cancelPromiseCapability=@newPromiseCapability(@Promise);const x=@readableStreamTeePullFunction(i,w,q),f={};@putByIdDirectPrivate(f,\"pull\",x),@putByIdDirectPrivate(f,\"cancel\",@readableStreamTeeBranch1CancelFunction(i,_));const g={};@putByIdDirectPrivate(g,\"pull\",x),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch2CancelFunction(i,_));const j=new @ReadableStream(f),k=new @ReadableStream(g);return @getByIdDirectPrivate(w,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(i.closedOrErrored)return;if(@readableStreamDefaultControllerError(j.@readableStreamController,y),@readableStreamDefaultControllerError(k.@readableStreamController,y),i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}),i.branch1=j,i.branch2=k,[j,k]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1524,7 +1524,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1Canc const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength = 258; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,i){\"use strict\";return function(d){if(c.canceled1=!0,c.reason1=d,c.canceled2)@readableStreamCancel(i,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,d){\"use strict\";return function(i){if(c.canceled1=!0,c.reason1=i,c.canceled2)@readableStreamCancel(d,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; // readableStreamTeeBranch2CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1532,7 +1532,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch2Canc const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength = 258; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode = "(function (d,i){\"use strict\";return function(c){if(d.canceled2=!0,d.reason2=c,d.canceled1)@readableStreamCancel(i,[d.reason1,d.reason2]).@then(d.cancelPromiseCapability.@resolve,d.cancelPromiseCapability.@reject);return d.cancelPromiseCapability.@promise}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode = "(function (c,d){\"use strict\";return function(i){if(c.canceled2=!0,c.reason2=i,c.canceled1)@readableStreamCancel(d,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; // isReadableStream const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,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,f,q){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function A(w,z){if(z&&q\?.cancel){try{var x=q.cancel(z);@markPromiseAsHandled(x)}catch(_){}q=@undefined}if(w){if(@putByIdDirectPrivate(w,\"readableStreamController\",@undefined),@putByIdDirectPrivate(w,\"reader\",@undefined),z)@putByIdDirectPrivate(w,\"state\",@streamErrored),@putByIdDirectPrivate(w,\"storedError\",z);else @putByIdDirectPrivate(w,\"state\",@streamClosed);w=@undefined}}if(!q.pull){A();return}if(!@isCallable(q.pull)){A(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",f);const v=@getByIdDirectPrivate(j,\"highWaterMark\");f.start({highWaterMark:!v||v<64\?64:v}),@startDirectStream.@call(f,j,q.pull,A),@putByIdDirectPrivate(j,\"reader\",{});var B=q.pull(f);if(f=@undefined,B&&@isPromise(B))return B.@then(()=>{})})\n"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (j,q,_){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function w(f,v){if(v&&_\?.cancel){try{var A=_.cancel(v);@markPromiseAsHandled(A)}catch(B){}_=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),v)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",v);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!_.pull){w();return}if(!@isCallable(_.pull)){w(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",q);const x=@getByIdDirectPrivate(j,\"highWaterMark\");q.start({highWaterMark:!x||x<64\?64:x}),@startDirectStream.@call(q,j,_.pull,w),@putByIdDirectPrivate(j,\"reader\",{});var z=_.pull(q);if(q=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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,x,f){\"use strict\";var z=!1,A=!1;try{var I=c.getReader(),B=I.readMany();if(B&&@isPromise(B))B=await B;if(B.done)return z=!0,x.end();var D=B.value.length;const K=@getByIdDirectPrivate(c,\"highWaterMark\");if(f)@startDirectStream.@call(x,c,@undefined,()=>!A&&@markPromiseAsHandled(c.cancel()));x.start({highWaterMark:K||0});for(var E=0,F=B.value,G=B.value.length;E!B&&@markPromiseAsHandled(_.cancel()));c.start({highWaterMark:q||0});for(var D=0,F=f.value,G=f.value.length;D{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"; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (S){\"use strict\";var c=this.@controlledReadableStream;if(!c||@getByIdDirectPrivate(c,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=S;return}if(@putByIdDirectPrivate(c,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,S)}catch(b){}var v;try{v=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(b){if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(y,b)}@readableStreamError(c,b);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var B=@getByIdDirectPrivate(c,\"reader\");if(B&&@isReadableStreamDefaultReader(B)){var C=this._pendingRead;if(C&&@isPromise(C)&&v\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(C,{value:v,done:!1}),@readableStreamClose(c);return}}if(v\?.byteLength){var j=@getByIdDirectPrivate(B,\"readRequests\");if(j\?.isNotEmpty()){@readableStreamFulfillReadRequest(c,v,!1),@readableStreamClose(c);return}@putByIdDirectPrivate(c,\"state\",@streamReadable),this.@pull=()=>{var b=@createFulfilledPromise({value:v,done:!1});return v=@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"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var i=this.@sink.flush();if(i\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:i,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var i=this.@sink.flush();if(i\?.byteLength)@readableStreamFulfillReadRequest(c,i,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var B=this.@controlledReadableStream,i=@getByIdDirectPrivate(B,\"reader\");if(!i||!@isReadableStreamDefaultReader(i))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var c=this.@sink.flush();if(c\?.byteLength)this._pendingRead=@getByIdDirectPrivate(B,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:c,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(B,\"readRequests\")\?.isNotEmpty()){var c=this.@sink.flush();if(c\?.byteLength)@readableStreamFulfillReadRequest(B,c,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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 (_){\"use strict\";var F,j=[],G=!1,q=!1,v=\"\",w=@toLength(0),x=@newPromiseCapability(@Promise),z=!1;return F={start(){},write(A){if(typeof A===\"string\"){var C=@toLength(A.length);if(C>0)v+=A,G=!0,w+=C;return C}if(!A||!(@ArrayBuffer.@isView(A)||A instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const E=@toLength(A.byteLength);if(E>0)if(q=!0,v.length>0)@arrayPush(j,v,A),v=\"\";else @arrayPush(j,A);return w+=E,E},flush(){return 0},end(){if(z)return\"\";return F.fulfill()},fulfill(){z=!0;const A=F.finishInternal();return @fulfillPromise(x.@promise,A),A},finishInternal(){if(!G&&!q)return\"\";if(G&&!q)return v;if(q&&!G)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(j));var A=new @Bun.ArrayBufferSink;A.start({highWaterMark:w,asUint8Array:!0});for(let C of j)A.write(C);if(j.length=0,v.length>0)A.write(v),v=\"\";return new globalThis.TextDecoder().decode(A.end())},close(){try{if(!z)z=!0,F.fulfill()}catch(A){}}},[F,x]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (G){\"use strict\";var q,v=[],x=!1,z=!1,j=\"\",C=@toLength(0),F=@newPromiseCapability(@Promise),A=!1;return q={start(){},write(_){if(typeof _===\"string\"){var w=@toLength(_.length);if(w>0)j+=_,x=!0,C+=w;return w}if(!_||!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const E=@toLength(_.byteLength);if(E>0)if(z=!0,j.length>0)@arrayPush(v,j,_),j=\"\";else @arrayPush(v,_);return C+=E,E},flush(){return 0},end(){if(A)return\"\";return q.fulfill()},fulfill(){A=!0;const _=q.finishInternal();return @fulfillPromise(F.@promise,_),_},finishInternal(){if(!x&&!z)return\"\";if(x&&!z)return j;if(z&&!x)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(v));var _=new @Bun.ArrayBufferSink;_.start({highWaterMark:C,asUint8Array:!0});for(let w of v)_.write(w);if(v.length=0,j.length>0)_.write(j),j=\"\";return new globalThis.TextDecoder().decode(_.end())},close(){try{if(!A)A=!0,q.fulfill()}catch(_){}}},[q,F]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,b){\"use strict\";var[m,f]=@createTextStream(b),p={@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\",p),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),f})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (m,p){\"use strict\";var[_,b]=@createTextStream(p),f={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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 (_,p){\"use strict\";var t=[],b=@newPromiseCapability(@Promise),d=!1;function j(){return d=!0,b.@resolve.@call(@undefined,t),t}var m={start(){},write(v){return @arrayPush(t,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"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (m,v){\"use strict\";var _=[],b=@newPromiseCapability(@Promise),t=!1;function d(){return t=!0,b.@resolve.@call(@undefined,_),_}var j={start(){},write(p){return @arrayPush(_,p),p.byteLength||p.length},flush(){return 0},end(){if(t)return[];return d()},close(){if(!t)d()}},q={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:j,close:@onCloseDirectStream,write:j.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; @@ -1668,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 w=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},b=new @Bun.ArrayBufferSink;b.start(w);var D={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write.bind(b),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",D),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; +const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (w,m){\"use strict\";var D=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},_=new @Bun.ArrayBufferSink;_.start(D);var b={@underlyingSource:w,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write.bind(_),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; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,_){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",_);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const h=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=h.shift();f;f=h.shift())@rejectPromise(f,_)}else{@assert(@isReadableStreamBYOBReader(n));const h=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=h.shift();f;f=h.shift())@rejectPromise(f,_)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,_);const c=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(c)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (c,f){\"use strict\";@assert(@isReadableStream(c)),@assert(@getByIdDirectPrivate(c,\"state\")===@streamReadable),@putByIdDirectPrivate(c,\"state\",@streamErrored),@putByIdDirectPrivate(c,\"storedError\",f);const _=@getByIdDirectPrivate(c,\"reader\");if(!_)return;if(@isReadableStreamDefaultReader(_)){const n=@getByIdDirectPrivate(_,\"readRequests\");@putByIdDirectPrivate(_,\"readRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}else{@assert(@isReadableStreamBYOBReader(_));const n=@getByIdDirectPrivate(_,\"readIntoRequests\");@putByIdDirectPrivate(_,\"readIntoRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}@getByIdDirectPrivate(_,\"closedPromiseCapability\").@reject.@call(@undefined,f);const h=@getByIdDirectPrivate(_,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1708,7 +1708,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 283; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (d){\"use strict\";const i=@getByIdDirectPrivate(d,\"controlledReadableStream\"),g=@getByIdDirectPrivate(i,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(d,\"strategy\").highWaterMark-@getByIdDirectPrivate(d,\"queue\").size})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const g=@getByIdDirectPrivate(i,\"controlledReadableStream\"),d=@getByIdDirectPrivate(g,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; // readableStreamReaderGenericCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1716,7 +1716,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 133; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (h,c){\"use strict\";const i=@getByIdDirectPrivate(h,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,c)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (h,i){\"use strict\";const c=@getByIdDirectPrivate(h,\"ownerReadableStream\");return @assert(!!c),@readableStreamCancel(c,i)})\n"; // readableStreamCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,h){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const _=@getByIdDirectPrivate(i,\"state\");if(_===@streamClosed)return @Promise.@resolve();if(_===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var p=@getByIdDirectPrivate(i,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,h).@then(function(){});var d=p.close;if(d)return @Promise.@resolve(p.close(h));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,d){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const h=@getByIdDirectPrivate(i,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var _=@getByIdDirectPrivate(i,\"readableStreamController\"),p=_.@cancel;if(p)return p(_,d).@then(function(){});var u=_.close;if(u)return @Promise.@resolve(_.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1732,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(d,\"queue\",@newQueue()),@getByIdDirectPrivate(d,\"cancelAlgorithm\").@call(@undefined,_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode = "(function (_,d){\"use strict\";return @putByIdDirectPrivate(_,\"queue\",@newQueue()),@getByIdDirectPrivate(_,\"cancelAlgorithm\").@call(@undefined,d)})\n"; // readableStreamDefaultControllerPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (i){\"use strict\";if(@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamClosed),!@getByIdDirectPrivate(i,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(i,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\",@createFIFO());for(var _=d.shift();_;_=d.shift())@fulfillPromise(_,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1764,7 +1764,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadReq const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 157; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,_,y){\"use strict\";const p=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(p,{value:_,done:y})})\n"; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,p,y){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:p,done:y})})\n"; // readableStreamDefaultControllerEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (d,D){\"use strict\";const E=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(d)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,D,!1),@readableStreamDefaultControllerCallPullIfNeeded(d);return}try{let _=1;if(@getByIdDirectPrivate(d,\"strategy\").size!==@undefined)_=@getByIdDirectPrivate(d,\"strategy\").size(D);@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),D,_)}catch(_){throw @readableStreamDefaultControllerError(d,_),_}@readableStreamDefaultControllerCallPullIfNeeded(d)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,D){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,D,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let d=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)d=@getByIdDirectPrivate(_,\"strategy\").size(D);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),D,d)}catch(d){throw @readableStreamDefaultControllerError(_,d),d}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const y=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!y);const n=@getByIdDirectPrivate(y,\"state\");if(@putByIdDirectPrivate(y,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(y,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(y,\"readableStreamController\").@pull(@getByIdDirectPrivate(y,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (y){\"use strict\";const i=@getByIdDirectPrivate(y,\"ownerReadableStream\");@assert(!!i);const n=@getByIdDirectPrivate(i,\"state\");if(@putByIdDirectPrivate(i,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(i,\"readableStreamController\").@pull(@getByIdDirectPrivate(i,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1804,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; @@ -1820,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 (m,b){\"use strict\";var N=@getByIdDirectPrivate(m,\"bunNativeType\"),P=@getByIdDirectPrivate(m,\"bunNativePtr\"),q=@lazyStreamPrototypeMap.@get(N);if(q===@undefined){let E=function(I){var{c:J,v:K}=this;this.c=@undefined,this.v=@undefined,x(I,J,K)},F=function(I){try{I.close()}catch(J){globalThis.reportError(J)}},G=function(I,J,K,L){L[0]=!1;var X;try{X=Z(I,K,L)}catch(Y){return J.error(Y)}return x(X,J,K)};var W=E,D=F,A=G,[Z,j,_,O,Q,U,f]=@lazyLoad(N),p=[!1],x;x=function I(J,K,L){if(J&&@isPromise(J))return J.then(E.bind({c:K,v:L}),(X)=>K.error(X));else if(typeof J===\"number\")if(L&&L.byteLength===J&&L.buffer===K.byobRequest\?.view\?.buffer)K.byobRequest.respondWithNewView(L);else K.byobRequest.respond(J);else if(J.constructor===@Uint8Array)K.enqueue(J);if(p[0]||J===!1)@enqueueJob(F,K),p[0]=!1};const H=Q\?new FinalizationRegistry(Q):null;q=class I{constructor(J,K,L){if(this.#f=J,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=K,L!==@undefined)this.start=(X)=>{X.enqueue(L)};if(H)H.register(this,J,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=j;#j(J){var K=this.#f;if(!K){J.close();return}G(K,J,J.byobRequest.view,p)}#m(J){var K=this.#f;H&&H.unregister(this.#b),U&&U(K,!1),_(K,J)}static deinit=Q;static drain=f},@lazyStreamPrototypeMap.@set(N,q)}const y=q.startSync(P,b);var M;const{drain:B,deinit:z}=q;if(B)M=B(P);if(y===0){if(Q&&P&&@enqueueJob(Q,P),(M\?.byteLength\?\?0)>0)return{start(E){E.enqueue(M),E.close()},type:\"bytes\"};return{start(E){E.close()},type:\"bytes\"}}return new q(P,y,M)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (J,P){\"use strict\";var G=@getByIdDirectPrivate(J,\"bunNativeType\"),B=@getByIdDirectPrivate(J,\"bunNativePtr\"),x=@lazyStreamPrototypeMap.@get(G);if(x===@undefined){let q=function(m){var{c:b,v:f}=this;this.c=@undefined,this.v=@undefined,I(m,b,f)},N=function(m){try{m.close()}catch(b){globalThis.reportError(b)}},O=function(m,b,f,j){j[0]=!1;var y;try{y=Q(m,f,j)}catch(Y){return b.error(Y)}return I(y,b,f)};var z=q,A=N,p=O,[Q,U,W,Z,D,K,X]=@lazyLoad(G),H=[!1],I;I=function m(b,f,j){if(b&&@isPromise(b))return b.then(q.bind({c:f,v:j}),(y)=>f.error(y));else if(typeof b===\"number\")if(j&&j.byteLength===b&&j.buffer===f.byobRequest\?.view\?.buffer)f.byobRequest.respondWithNewView(j);else f.byobRequest.respond(b);else if(b.constructor===@Uint8Array)f.enqueue(b);if(H[0]||b===!1)@enqueueJob(N,f),H[0]=!1};const F=D\?new FinalizationRegistry(D):null;x=class m{constructor(b,f,j){if(this.#f=b,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=f,j!==@undefined)this.start=(y)=>{y.enqueue(j)};if(F)F.register(this,b,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=U;#j(b){var f=this.#f;if(!f){b.close();return}O(f,b,b.byobRequest.view,H)}#m(b){var f=this.#f;F&&F.unregister(this.#b),K&&K(f,!1),W(f,b)}static deinit=D;static drain=X},@lazyStreamPrototypeMap.@set(G,x)}const L=x.startSync(B,P);var E;const{drain:M,deinit:_}=x;if(M)E=M(B);if(L===0){if(D&&B&&@enqueueJob(D,B),(E\?.byteLength\?\?0)>0)return{start(q){q.enqueue(E),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new x(B,L,E)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (f){\"use strict\";var _=f.getReader(),b=_.readMany();async function g(j){if(j.done)return[];var q=j.value||[];while(!0){var p=await _.read();if(p.done)break;q=q.concat(p.value)}return q}if(b&&@isPromise(b))return b.@then(g);return g(b)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (q){\"use strict\";var b=q.getReader(),f=b.readMany();async function g(j){if(j.done)return[];var _=j.value||[];while(!0){var p=await b.read();if(p.done)break;_=_.concat(p.value)}return _}if(f&&@isPromise(f))return f.@then(g);return g(f)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1836,7 +1836,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 214; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (i){\"use strict\";const[_,d]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),h=@readStreamIntoSink(i,_,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (_){\"use strict\";const[h,d]=@createTextStream(@getByIdDirectPrivate(_,\"highWaterMark\")),i=@readStreamIntoSink(_,h,!1);if(i&&@isPromise(i))return @Promise.@resolve(i).@then(d.@promise);return d.@promise})\n"; // readableStreamToArrayBufferDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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,x){\"use strict\";var z=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(j,\"underlyingSource\",@undefined);var A=@getByIdDirectPrivate(j,\"highWaterMark\");z.start(A\?{highWaterMark:A}:{});var B=@newPromiseCapability(@Promise),C=!1,D=x.pull,_=x.close,O={start(){},close(q){if(!C){if(C=!0,_)_();@fulfillPromise(B.@promise,z.end())}},end(){if(!C){if(C=!0,_)_();@fulfillPromise(B.@promise,z.end())}},flush(){return 0},write:z.write.bind(z)},F=!1;try{const q=D(O);if(q&&@isObject(q)&&@isPromise(q))return async function(v,G,w){while(!C)await w(v);return await G}(O,promise,D);return B.@promise}catch(q){return F=!0,@readableStreamError(j,q),@Promise.@reject(q)}finally{if(!F&&j)@readableStreamClose(j);O=_=z=D=j=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,A){\"use strict\";var j=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var B=@getByIdDirectPrivate(O,\"highWaterMark\");j.start(B\?{highWaterMark:B}:{});var w=@newPromiseCapability(@Promise),q=!1,x=A.pull,v=A.close,z={start(){},close(_){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},end(){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},flush(){return 0},write:j.write.bind(j)},C=!1;try{const _=x(z);if(_&&@isObject(_)&&@isPromise(_))return async function(D,F,G){while(!q)await G(D);return await F}(z,promise,x);return w.@promise}catch(_){return C=!0,@readableStreamError(O,_),@Promise.@reject(_)}finally{if(!C&&O)@readableStreamClose(O);z=v=j=x=O=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,j){\"use strict\";const p=@initializeTextStream.@call(_,j,@undefined);var h=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var f=await h.read();if(f.done)break}try{h.releaseLock()}catch(k){}return h=@undefined,_=@undefined,p.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,h){\"use strict\";const j=@initializeTextStream.@call(_,h,@undefined);var f=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await f.read();if(k.done)break}try{f.releaseLock()}catch(p){}return f=@undefined,_=@undefined,j.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,p){\"use strict\";const j=@initializeArrayStream.@call(f,p,@undefined);p=@undefined;var q=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var _=await q.read();if(_.done)break}try{q.releaseLock()}catch(k){}return q=@undefined,@Promise.@resolve(j.@promise)}catch(k){throw k}finally{f=@undefined,q=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,j){\"use strict\";const p=@initializeArrayStream.@call(f,j,@undefined);j=@undefined;var _=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var q=await _.read();if(q.done)break}try{_.releaseLock()}catch(k){}return _=@undefined,@Promise.@resolve(p.@promise)}catch(k){throw k}finally{f=@undefined,_=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (i){\"use strict\";var h=globalThis.Symbol.asyncIterator,j=async function*B(g,D){var q=g.getReader(),F;try{while(!0){var x,k;const G=q.readMany();if(@isPromise(G))({done:x,value:k}=await G);else({done:x,value:k}=G);if(x)return;yield*k}}catch(G){F=G}finally{if(q.releaseLock(),!D)g.cancel(F);if(F)throw F}},w=function B(){return j(this,!1)},z=function B({preventCancel:g=!1}={preventCancel:!1}){return j(this,g)};return @Object.@defineProperty(i,h,{value:w}),@Object.@defineProperty(i,\"values\",{value:z}),i})\n"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (i){\"use strict\";var B=globalThis.Symbol.asyncIterator,w=async function*x(k,G){var z=k.getReader(),g;try{while(!0){var j,q;const h=z.readMany();if(@isPromise(h))({done:j,value:q}=await h);else({done:j,value:q}=h);if(j)return;yield*q}}catch(h){g=h}finally{if(z.releaseLock(),!G)k.cancel(g);if(g)throw g}},D=function x(){return w(this,!1)},F=function x({preventCancel:k=!1}={preventCancel:!1}){return w(this,k)};return @Object.@defineProperty(i,B,{value:D}),@Object.@defineProperty(i,\"values\",{value:F}),i})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1988,6 +1988,14 @@ const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const u=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(u){const f=u.@call(n,\"string\");if(typeof f===\"string\")switch(@argumentCount()){case 1:return new @Buffer(f);case 2:return new @Buffer(f,@argument(1));default:return new @Buffer(f,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; +// isBuffer +const JSC::ConstructAbility s_jsBufferConstructorIsBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferConstructorIsBufferCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferConstructorIsBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferConstructorIsBufferCodeLength = 57; +static const JSC::Intrinsic s_jsBufferConstructorIsBufferCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferConstructorIsBufferCode = "(function (a){\"use strict\";return a instanceof @Buffer})\n"; + #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ {\ @@ -2020,7 +2028,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 _=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!_)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const E=@getByIdDirectPrivate(_,\"state\");if(@putByIdDirectPrivate(_,\"disturbed\",!0),E===@streamClosed)return{value:[],size:0,done:!0};else if(E===@streamErrored)throw @getByIdDirectPrivate(_,\"storedError\");var H=@getByIdDirectPrivate(_,\"readableStreamController\"),J=@getByIdDirectPrivate(H,\"queue\");if(!J)return H.@pull(H).@then(function({done:I,value:F}){return I\?{done:!0,value:[],size:0}:{value:[F],size:1,done:!1}});const K=J.content;var N=J.size,G=K.toArray(!1),O=G.length;if(O>0){var w=@newArrayWithSize(O);if(@isReadableByteStreamController(H)){{const I=G[0];if(!(@ArrayBuffer.@isView(I)||I instanceof @ArrayBuffer))@putByValDirect(w,0,new @Uint8Array(I.buffer,I.byteOffset,I.byteLength));else @putByValDirect(w,0,I)}for(var d=1;d{if(I.done)return{value:[],size:0,done:!0};var F=@getByIdDirectPrivate(_,\"readableStreamController\"),Q=@getByIdDirectPrivate(F,\"queue\"),S=[I.value].concat(Q.content.toArray(!1)),j=S.length;if(@isReadableByteStreamController(F))for(var T=0;T0){var j=@newArrayWithSize(C);if(@isReadableByteStreamController(w)){{const _=A[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(j,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(j,0,_)}for(var d=1;d{if(_.done)return{value:[],size:0,done:!0};var B=@getByIdDirectPrivate(k,\"readableStreamController\"),F=@getByIdDirectPrivate(B,\"queue\"),x=[_.value].concat(F.content.toArray(!1)),K=x.length;if(@isReadableByteStreamController(B))for(var I=0;I0}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 E=@Array.prototype.slice;class A{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:v,_tail:b,_list:g,_capacityMask:k}=this;if(v===b)return @undefined;var w=g[v];if(@putByValDirect(g,v,@undefined),v=this._head=v+1&k,v<2&&b>1e4&&b<=g.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(v){var b=this._tail;if(@putByValDirect(this._list,b,v),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(v){var b=this._list,g=@toLength(b.length);if(v||this._head>this._tail){var k=@toLength(this._head),w=@toLength(this._tail),F=@toLength(g-k+w),z=@newArrayWithSize(F),B=0;for(var x=k;x>>=1,this._capacityMask>>>=1}}return new A})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2150,7 +2158,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,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"; +const char* const s_streamInternalsEnqueueValueWithSizeCode = "(function (d,o,n){\"use strict\";if(n=@toNumber(n),!@isFinite(n)||n<0)@throwRangeError(\"size has an incorrect value\");d.content.push({value:o,size:n}),d.size+=n})\n"; // peekQueueValue const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2174,7 +2182,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 (p){\"use strict\";const d=p.size;if(d===@undefined)return()=>1;if(typeof d!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(w)=>{return d(w)}})\n"; // extractHighWaterMark const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2182,7 +2190,7 @@ const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorK const JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsExtractHighWaterMarkCodeLength = 188; static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (o,b){\"use strict\";const c=o.highWaterMark;if(c===@undefined)return b;if(@isNaN(c)||c<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(c)})\n"; +const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (b,c){\"use strict\";const o=b.highWaterMark;if(o===@undefined)return c;if(@isNaN(o)||o<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(o)})\n"; // extractHighWaterMarkFromQueuingStrategyInit const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2198,7 +2206,7 @@ const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructo const JSC::ImplementationVisibility s_streamInternalsCreateFulfilledPromiseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsCreateFulfilledPromiseCodeLength = 81; static const JSC::Intrinsic s_streamInternalsCreateFulfilledPromiseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (d){\"use strict\";const n=@newPromise();return @fulfillPromise(n,d),n})\n"; +const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (n){\"use strict\";const d=@newPromise();return @fulfillPromise(d,n),d})\n"; // toDictionary const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2206,7 +2214,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 (n,c,p){\"use strict\";if(n===@undefined||n===null)return c;if(!@isObject(n))@throwTypeError(p);return n})\n"; +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"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2224,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (J){\"use strict\";var _=@Loader,D=@createFIFO(),w=J;while(w){var x=_.registry.@get(w);if((x\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(w),x=_.registry.@get(w);var I=@getPromiseInternalField(x.fetch,@promiseFieldReactionsOrResult),z=_.parseModule(w,I),B=x.module;if(z&&@isPromise(z)){var F=@getPromiseInternalField(z,@promiseFieldReactionsOrResult),Z=@getPromiseInternalField(z,@promiseFieldFlags),G=Z&@promiseStateMask;if(G===@promiseStatePending||F&&@isPromise(F))@throwTypeError(`require() async module \"${w}\" is unsupported. use \"await import()\" instead.`);else if(G===@promiseStateRejected){if(!F\?.message)@throwTypeError(`${F+\"\"\?F:\"An error occurred\"} occurred while parsing module \\\"${w}\\\"`);throw F}x.module=B=F}else if(z&&!B)x.module=B=z;@setStateToMax(x,@ModuleLink);var H=B.dependenciesMap,L=_.requestedModules(B),Q=@newArrayWithSize(L.length);for(var T=0,U=L.length;T=@ModuleLink)w=D.shift()}var Y=_.linkAndEvaluateModule(J,@undefined);if(Y&&@isPromise(Y))@throwTypeError(`require() async module \\\"${J}\\\" is unsupported. use \"await import()\" instead.`);return _.registry.@get(J)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (B){\"use strict\";var D=@Loader,H=@createFIFO(),_=B;while(_){var w=D.registry.@get(_);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(_),w=D.registry.@get(_);var W=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),x=D.parseModule(_,W),z=w.module;if(x&&@isPromise(x)){var J=@getPromiseInternalField(x,@promiseFieldReactionsOrResult),X=@getPromiseInternalField(x,@promiseFieldFlags),Q=X&@promiseStateMask;if(Q===@promiseStatePending||J&&@isPromise(J))@throwTypeError(`require() async module \"${_}\" is unsupported. use \"await import()\" instead.`);else if(Q===@promiseStateRejected){if(!J\?.message)@throwTypeError(`${J+\"\"\?J:\"An error occurred\"} occurred while parsing module \\\"${_}\\\"`);throw J}w.module=z=J}else if(x&&!z)w.module=z=x;@setStateToMax(w,@ModuleLink);var Y=z.dependenciesMap,I=D.requestedModules(z),T=@newArrayWithSize(I.length);for(var F=0,Z=I.length;F=@ModuleLink)_=H.shift()}var V=D.linkAndEvaluateModule(B,@undefined);if(V&&@isPromise(V))@throwTypeError(`require() async module \\\"${B}\\\" is unsupported. use \"await import()\" instead.`);return D.registry.@get(B)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var _=@Loader.registry.@get(a);if(!_||!_.evaluated)_=@loadCJS2ESM(a);if(!_||!_.evaluated||!_.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var c=@Loader.getModuleNamespaceObject(_.module);if(c[@commonJSSymbol]===0)return;return c})\n"; +const char* const s_importMetaObjectRequireESMCode = "(function (c){\"use strict\";var a=@Loader.registry.@get(c);if(!a||!a.evaluated)a=@loadCJS2ESM(c);if(!a||!a.evaluated||!a.module)@throwTypeError(`require() failed to evaluate module \"${c}\". This is an internal consistentency error.`);var _=@Loader.getModuleNamespaceObject(a.module);if(_[@commonJSSymbol]===0)return;return _})\n"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2240,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var b=@requireMap.@get(_);const g=_.substring(_.length-5);if(b)return b.exports;if(g===\".json\"){var q=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),j=JSON.parse(q.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,j,!0)),j}else if(g===\".node\"){const n=@createCommonJSModule(_,{},!0);return process.dlopen(n,_),@requireMap.@set(_,n),n.exports}else if(g===\".toml\"){var q=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),j=@Bun.TOML.parse(q.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,j,!0)),j}else{var j=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var k=j\?.default;if(k\?.[@commonJSSymbol]===0)j=k;return @requireMap.@set(_,@createCommonJSModule(_,j,!0)),j}})\n"; +const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var n=@requireMap.@get(_);const g=_.substring(_.length-5);if(n)return n.exports;if(g===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else if(g===\".node\"){const k=@createCommonJSModule(_,{},!0);return process.dlopen(k,_),@requireMap.@set(_,k),k.exports}else if(g===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else{var b=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var q=b\?.default;if(q\?.[@commonJSSymbol]===0)b=q;return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,7 +2256,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var h=new Map,u={};return new Proxy(u,{get(L,b){const _=@requireMap.@get(b);if(_)return _;const f=@Loader.registry.@get(b);if(f\?.evaluated){const c=@Loader.getModuleNamespaceObject(f.module),t=c[@commonJSSymbol]===0||c.default\?.[@commonJSSymbol]\?c.default:c,g=@createCommonJSModule(b,t,!0);return @requireMap.@set(b,g),g}return u[b]},set(L,b,_){return @requireMap.@set(b,_),!0},has(L,b){return @requireMap.@has(b)||@Loader.registry.@has(b)},deleteProperty(L,b){return h.@delete(b),@requireMap.@delete(b),@Loader.registry.@delete(b),!0},ownKeys(L){var b=[...@requireMap.@keys()];const _=[...@Loader.registry.@keys()];for(let f of _)if(!b.includes(f))@arrayPush(b,f);return b},getPrototypeOf(L){return null},getOwnPropertyDescriptor(L,b){if(@requireMap.@has(b)||@Loader.registry.@has(b))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var c=new Map,L={};return new Proxy(L,{get(f,_){const h=@requireMap.@get(_);if(h)return h;const t=@Loader.registry.@get(_);if(t\?.evaluated){const u=@Loader.getModuleNamespaceObject(t.module),g=u[@commonJSSymbol]===0||u.default\?.[@commonJSSymbol]\?u.default:u,b=@createCommonJSModule(_,g,!0);return @requireMap.@set(_,b),b}return L[_]},set(f,_,h){return @requireMap.@set(_,h),!0},has(f,_){return @requireMap.@has(_)||@Loader.registry.@has(_)},deleteProperty(f,_){return c.@delete(_),@requireMap.@delete(_),@Loader.registry.@delete(_),!0},ownKeys(f){var _=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let t of h)if(!_.includes(t))@arrayPush(_,t);return _},getPrototypeOf(f){return null},getOwnPropertyDescriptor(f,_){if(@requireMap.@has(_)||@Loader.registry.@has(_))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2432,7 +2440,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const m=_.type===\"direct\",v=!!_.@lazy,B=m||v;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!B){const I=@getByIdDirectPrivate(f,\"size\"),b=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,I,b!==@undefined\?b:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(m)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(B){const I=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",I||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,I);if(b)@createReadableStreamController(this,b,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const B=_.type===\"direct\",b=!!_.@lazy,I=B||b;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!I){const v=@getByIdDirectPrivate(f,\"size\"),m=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",m),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,v,m!==@undefined\?m:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(B)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(I){const v=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",v||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const m=@lazyLoadStream(this,v);if(m)@createReadableStreamController(this,m,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2456,7 +2464,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2480,7 +2488,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,D,G){\"use strict\";const H=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var F=globalThis[H];if(!F)F=globalThis[H]=[];var I=F[D];if(I===@undefined){var[_,J,k,K,L,N]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](D);I=class q{handleError;handleClosed;processResult;constructor(w,A){this.#_=A,this.#F=w,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),w.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var w=this.#_;this.#_=0,K(w),N(w)}_handleError(w){if(this.#$)return;this.#$=!0;var A=this.#_;this.#_=0,J(A,w),N(A)}#_;#$=!1;#F;_handleReadMany({value:w,done:A,size:B}){if(A){this.handleClosed();return}if(this.#$)return;k(this.#_,w,A,B)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(w){if(w&&@isPromise(w)){if(@getPromiseInternalField(w,@promiseFieldFlags)&@promiseStateFulfilled){const B=@getPromiseInternalField(w,@promiseFieldReactionsOrResult);if(B)w=B}}if(w&&@isPromise(w))return w.then(this.processResult,this.handleError),null;if(w.done)return this.handleClosed(),0;else if(w.value)return w.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const x=D+1;if(F.length{@putByIdDirectPrivate(f,\"started\",1),@assert(!@getByIdDirectPrivate(f,\"pulling\")),@assert(!@getByIdDirectPrivate(f,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(f)},(d)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(f,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (b,p,R){\"use strict\";if(!@isReadableStream(b))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(b,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",b),@putByIdDirectPrivate(this,\"underlyingByteSource\",p),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let f=@toNumber(R);if(@isNaN(f)||f<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",f);let _=p.autoAllocateChunkSize;if(_!==@undefined){if(_=@toNumber(_),_<=0||_===@Infinity||_===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",_),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const v=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(v,\"underlyingByteSource\"),\"start\",[v]).@then(()=>{@putByIdDirectPrivate(v,\"started\",1),@assert(!@getByIdDirectPrivate(v,\"pulling\")),@assert(!@getByIdDirectPrivate(v,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(v)},(d)=>{if(@getByIdDirectPrivate(b,\"state\")===@streamReadable)@readableByteStreamControllerError(v,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2676,7 +2684,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var _=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=_.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2692,7 +2700,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength = 569; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode = "(function (a){\"use strict\";if(@assert(!@getByIdDirectPrivate(a,\"closeRequested\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"state\")===@streamReadable),@getByIdDirectPrivate(a,\"queue\").size>0){@putByIdDirectPrivate(a,\"closeRequested\",!0);return}var d=@getByIdDirectPrivate(a,\"pendingPullIntos\")\?.peek();if(d){if(d.bytesFilled>0){const u=@makeTypeError(\"Close requested while there remain pending bytes\");throw @readableByteStreamControllerError(a,u),u}}@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"))})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode = "(function (d){\"use strict\";if(@assert(!@getByIdDirectPrivate(d,\"closeRequested\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(d,\"controlledReadableStream\"),\"state\")===@streamReadable),@getByIdDirectPrivate(d,\"queue\").size>0){@putByIdDirectPrivate(d,\"closeRequested\",!0);return}var a=@getByIdDirectPrivate(d,\"pendingPullIntos\")\?.peek();if(a){if(a.bytesFilled>0){const u=@makeTypeError(\"Close requested while there remain pending bytes\");throw @readableByteStreamControllerError(d,u),u}}@readableStreamClose(@getByIdDirectPrivate(d,\"controlledReadableStream\"))})\n"; // readableByteStreamControllerClearPendingPullIntos const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2716,7 +2724,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBRea const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 125; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (n){\"use strict\";const u=@getByIdDirectPrivate(n,\"reader\");return u!==@undefined&&@isReadableStreamBYOBReader(u)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (u){\"use strict\";const n=@getByIdDirectPrivate(u,\"reader\");return n!==@undefined&&@isReadableStreamBYOBReader(n)})\n"; // readableStreamHasDefaultReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2724,7 +2732,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefault const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength = 128; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (l){\"use strict\";const n=@getByIdDirectPrivate(l,\"reader\");return n!==@undefined&&@isReadableStreamDefaultReader(n)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (n){\"use strict\";const l=@getByIdDirectPrivate(n,\"reader\");return l!==@undefined&&@isReadableStreamDefaultReader(l)})\n"; // readableByteStreamControllerHandleQueueDrain const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2740,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const F=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(F)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const R=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=R.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let d;try{d=new @Uint8Array(R.buffer,R.byteOffset,R.byteLength)}catch(h){return @Promise.@reject(h)}return @createFulfilledPromise({value:d,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let R;try{R=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(h){return @Promise.@reject(h)}const d={buffer:R,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(d)}const P=@readableStreamAddReadRequest(F);return @readableByteStreamControllerCallPullIfNeeded(_),P})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const P=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(P)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const d=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=d.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let h;try{h=new @Uint8Array(d.buffer,d.byteOffset,d.byteLength)}catch(F){return @Promise.@reject(F)}return @createFulfilledPromise({value:h,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let d;try{d=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(F){return @Promise.@reject(F)}const h={buffer:d,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(h)}const R=@readableStreamAddReadRequest(P);return @readableByteStreamControllerCallPullIfNeeded(_),R})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2756,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 619; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (b){\"use strict\";const u=@getByIdDirectPrivate(b,\"controlledReadableStream\");if(@getByIdDirectPrivate(u,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(b,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(b,\"started\")>0))return!1;const P=@getByIdDirectPrivate(u,\"reader\");if(P&&(@getByIdDirectPrivate(P,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(P,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(u)&&@getByIdDirectPrivate(@getByIdDirectPrivate(u,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(b)>0)return!0;return!1})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const P=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(P,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const b=@getByIdDirectPrivate(P,\"reader\");if(b&&(@getByIdDirectPrivate(b,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(b,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(P)&&@getByIdDirectPrivate(@getByIdDirectPrivate(P,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; // readableByteStreamControllerCallPullIfNeeded const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2756,7 +2764,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength = 670; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode = "(function (_){\"use strict\";if(!@readableByteStreamControllerShouldCallPull(_))return;if(@getByIdDirectPrivate(_,\"pulling\")){@putByIdDirectPrivate(_,\"pullAgain\",!0);return}@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@putByIdDirectPrivate(_,\"pulling\",!0),@promiseInvokeOrNoop(@getByIdDirectPrivate(_,\"underlyingByteSource\"),\"pull\",[_]).@then(()=>{if(@putByIdDirectPrivate(_,\"pulling\",!1),@getByIdDirectPrivate(_,\"pullAgain\"))@putByIdDirectPrivate(_,\"pullAgain\",!1),@readableByteStreamControllerCallPullIfNeeded(_)},(i)=>{if(@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"controlledReadableStream\"),\"state\")===@streamReadable)@readableByteStreamControllerError(_,i)})})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode = "(function (i){\"use strict\";if(!@readableByteStreamControllerShouldCallPull(i))return;if(@getByIdDirectPrivate(i,\"pulling\")){@putByIdDirectPrivate(i,\"pullAgain\",!0);return}@assert(!@getByIdDirectPrivate(i,\"pullAgain\")),@putByIdDirectPrivate(i,\"pulling\",!0),@promiseInvokeOrNoop(@getByIdDirectPrivate(i,\"underlyingByteSource\"),\"pull\",[i]).@then(()=>{if(@putByIdDirectPrivate(i,\"pulling\",!1),@getByIdDirectPrivate(i,\"pullAgain\"))@putByIdDirectPrivate(i,\"pullAgain\",!1),@readableByteStreamControllerCallPullIfNeeded(i)},(_)=>{if(@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"controlledReadableStream\"),\"state\")===@streamReadable)@readableByteStreamControllerError(i,_)})})\n"; // transferBufferToCurrentRealm const JSC::ConstructAbility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2780,7 +2788,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1076; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,d){\"use strict\";const _=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@getByIdDirectPrivate(_,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(_,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const f=d.constructor===@Uint8Array\?d:new @Uint8Array(d.buffer,d.byteOffset,d.byteLength);@readableStreamFulfillReadRequest(_,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(_)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);break}}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (d,i){\"use strict\";const _=@getByIdDirectPrivate(d,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(d,\"closeRequested\")),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@getByIdDirectPrivate(_,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(_,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);else{@assert(!@getByIdDirectPrivate(d,\"queue\").content.size());const f=i.constructor===@Uint8Array\?i:new @Uint8Array(i.buffer,i.byteOffset,i.byteLength);@readableStreamFulfillReadRequest(_,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength),@readableByteStreamControllerProcessPullDescriptors(d);break}case 3:break;default:{@assert(!@isReadableStreamLocked(_)),@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);break}}})\n"; // readableByteStreamControllerEnqueueChunk const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2788,7 +2796,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,p,a,d){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:p,byteOffset:a,byteLength:d}),@getByIdDirectPrivate(_,\"queue\").size+=d})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,d,p,a){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:d,byteOffset:p,byteLength:a}),@getByIdDirectPrivate(_,\"queue\").size+=a})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2796,7 +2804,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 417; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (a,d){\"use strict\";@assert(@getByIdDirectPrivate(a,\"pendingPullIntos\").isNotEmpty());let u=@getByIdDirectPrivate(a,\"pendingPullIntos\").peek();if(u.byteOffset+u.bytesFilled!==d.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(u.byteLength!==d.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");u.buffer=d.buffer,@readableByteStreamControllerRespondInternal(a,d.byteLength)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (d,u){\"use strict\";@assert(@getByIdDirectPrivate(d,\"pendingPullIntos\").isNotEmpty());let a=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek();if(a.byteOffset+a.bytesFilled!==u.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(a.byteLength!==u.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");a.buffer=u.buffer,@readableByteStreamControllerRespondInternal(d,u.byteLength)})\n"; // readableByteStreamControllerRespond const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2804,7 +2812,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength = 251; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (u,I){\"use strict\";if(I=@toNumber(I),@isNaN(I)||I===@Infinity||I<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(u,I)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (I,u){\"use strict\";if(u=@toNumber(u),@isNaN(u)||u===@Infinity||u<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(I,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(I,u)})\n"; // readableByteStreamControllerRespondInternal const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2820,7 +2828,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,f,_){\"use strict\";if(_.bytesFilled+f>_.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===_),@readableByteStreamControllerInvalidateBYOBRequest(w),_.bytesFilled+=f,_.bytesFilled<_.elementSize)return;@readableByteStreamControllerShiftPendingDescriptor(w);const g=_.bytesFilled%_.elementSize;if(g>0){const R=_.byteOffset+_.bytesFilled,h=@cloneArrayBuffer(_.buffer,R-g,g);@readableByteStreamControllerEnqueueChunk(w,h,0,h.byteLength)}_.buffer=@transferBufferToCurrentRealm(_.buffer),_.bytesFilled-=g,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),_),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,_,f){\"use strict\";if(f.bytesFilled+_>f.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===f),@readableByteStreamControllerInvalidateBYOBRequest(w),f.bytesFilled+=_,f.bytesFilled0){const h=f.byteOffset+f.bytesFilled,g=@cloneArrayBuffer(f.buffer,h-R,R);@readableByteStreamControllerEnqueueChunk(w,g,0,g.byteLength)}f.buffer=@transferBufferToCurrentRealm(f.buffer),f.bytesFilled-=R,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),f),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2844,7 +2852,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 (j,v){\"use strict\";const w=v.bytesFilled-v.bytesFilled%v.elementSize,_=@getByIdDirectPrivate(j,\"queue\").sizew)k=z-v.bytesFilled,E=!0;while(k>0){let G=@getByIdDirectPrivate(j,\"queue\").content.peek();const H=k0),@assert(v.bytesFilledH)v=G-_.bytesFilled,w=!0;while(v>0){let j=@getByIdDirectPrivate(q,\"queue\").content.peek();const k=v0),@assert(_.bytesFilled<_.elementSize);return w})\n"; // readableByteStreamControllerShiftPendingDescriptor const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2868,7 +2876,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength = 386; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode = "(function (_,h){\"use strict\";@assert(@getByIdDirectPrivate(_,\"state\")!==@streamErrored);let b=!1;if(@getByIdDirectPrivate(_,\"state\")===@streamClosed)@assert(!h.bytesFilled),b=!0;let g=@readableByteStreamControllerConvertDescriptor(h);if(h.readerType===\"default\")@readableStreamFulfillReadRequest(_,g,b);else @assert(h.readerType===\"byob\"),@readableStreamFulfillReadIntoRequest(_,g,b)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode = "(function (_,b){\"use strict\";@assert(@getByIdDirectPrivate(_,\"state\")!==@streamErrored);let g=!1;if(@getByIdDirectPrivate(_,\"state\")===@streamClosed)@assert(!b.bytesFilled),g=!0;let h=@readableByteStreamControllerConvertDescriptor(b);if(b.readerType===\"default\")@readableStreamFulfillReadRequest(_,h,g);else @assert(b.readerType===\"byob\"),@readableStreamFulfillReadIntoRequest(_,h,g)})\n"; // readableByteStreamControllerConvertDescriptor const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2892,7 +2900,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReader const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength = 356; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = "(function (o,c){\"use strict\";const l=@getByIdDirectPrivate(o,\"ownerReadableStream\");if(@assert(!!l),@putByIdDirectPrivate(l,\"disturbed\",!0),@getByIdDirectPrivate(l,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(l,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(l,\"readableStreamController\"),c)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = "(function (c,l){\"use strict\";const o=@getByIdDirectPrivate(c,\"ownerReadableStream\");if(@assert(!!o),@putByIdDirectPrivate(o,\"disturbed\",!0),@getByIdDirectPrivate(o,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(o,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(o,\"readableStreamController\"),l)})\n"; // readableByteStreamControllerPullInto const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2900,7 +2908,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength = 1255; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (d,k){\"use strict\";const A=@getByIdDirectPrivate(d,\"controlledReadableStream\");let E=1;if(k.BYTES_PER_ELEMENT!==@undefined)E=k.BYTES_PER_ELEMENT;const L=k.constructor,N={buffer:k.buffer,byteOffset:k.byteOffset,byteLength:k.byteLength,bytesFilled:0,elementSize:E,ctor:L,readerType:\"byob\"};var R=@getByIdDirectPrivate(d,\"pendingPullIntos\");if(R\?.isNotEmpty())return N.buffer=@transferBufferToCurrentRealm(N.buffer),R.push(N),@readableStreamAddReadIntoRequest(A);if(@getByIdDirectPrivate(A,\"state\")===@streamClosed){const b=new L(N.buffer,N.byteOffset,0);return @createFulfilledPromise({value:b,done:!0})}if(@getByIdDirectPrivate(d,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(d,N)){const b=@readableByteStreamControllerConvertDescriptor(N);return @readableByteStreamControllerHandleQueueDrain(d),@createFulfilledPromise({value:b,done:!1})}if(@getByIdDirectPrivate(d,\"closeRequested\")){const b=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(d,b),@Promise.@reject(b)}}N.buffer=@transferBufferToCurrentRealm(N.buffer),@getByIdDirectPrivate(d,\"pendingPullIntos\").push(N);const _=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(d),_})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (b,d){\"use strict\";const A=@getByIdDirectPrivate(b,\"controlledReadableStream\");let E=1;if(d.BYTES_PER_ELEMENT!==@undefined)E=d.BYTES_PER_ELEMENT;const L=d.constructor,_={buffer:d.buffer,byteOffset:d.byteOffset,byteLength:d.byteLength,bytesFilled:0,elementSize:E,ctor:L,readerType:\"byob\"};var N=@getByIdDirectPrivate(b,\"pendingPullIntos\");if(N\?.isNotEmpty())return _.buffer=@transferBufferToCurrentRealm(_.buffer),N.push(_),@readableStreamAddReadIntoRequest(A);if(@getByIdDirectPrivate(A,\"state\")===@streamClosed){const k=new L(_.buffer,_.byteOffset,0);return @createFulfilledPromise({value:k,done:!0})}if(@getByIdDirectPrivate(b,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,_)){const k=@readableByteStreamControllerConvertDescriptor(_);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}_.buffer=@transferBufferToCurrentRealm(_.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(_);const R=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(b),R})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2952,7 +2960,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{#$;#W;#U;#K;#L;#j=!1;#X=null;#Y=\"\";#M=\"\";#w=\"\";#A=!0;#Z=0;#z=0;#O=0;#B=null;static#F(K){K.#J()}static#Q(K,L){const M=K.data,O=M.#w\?`Last-Event-ID: ${M.#w}\\r\\n`:\"\",w=`GET ${L.pathname}${L.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${O}\\r\\n`,Q=K.write(w);if(Q!==w.length)M.#M=w.substring(Q)}static#V(K,L,M){for(;;){if(M>=L.length)return;let O=-1,w=L.indexOf(\"\\r\\n\",M);const Q=w+2;if(w>0)if(K.#Z===0){const X=parseInt(L.substring(M,w),16);if(X===0){K.#W=2,K.#X\?.end();return}O=Q+X}else O=L.length;else{if(K.#Y.length===0){K.#Y+=L.substring(M);return}O=L.length}let U=L.substring(Q,O);M=O+2;let V=0,W=U.indexOf(\"\\n\\n\");if(W==-1){K.#Y+=L.substring(Q);return}if(K.#Y.length)K.#Y+=U,U=K.#Y,K.#Y=\"\";let A=!0;while(A){const X=U.substring(V,W);let Y,Z=\"\",z,B=0,H=-1;for(;;){let G=X.indexOf(\"\\n\",B);if(G===-1){if(B>=X.length)break;G=X.length}const J=X.substring(B,G);if(J.startsWith(\"data:\"))if(Z.length)Z+=`\\n${J.substring(5).trim()}`;else Z=J.substring(5).trim();else if(J.startsWith(\"event:\"))Y=J.substring(6).trim();else if(J.startsWith(\"id:\"))z=J.substring(3).trim();else if(J.startsWith(\"retry:\")){if(H=parseInt(J.substring(6).trim(),10),@isNaN(H))H=-1}B=G+1}if(K.#w=z||\"\",H>=0)K.#O=H;if(Z||z||Y)K.dispatchEvent(new MessageEvent(Y||\"message\",{data:Z||\"\",origin:K.#$.origin,source:K,lastEventId:z}));if(U.length===W+2){A=!1;break}const F=U.indexOf(\"\\n\\n\",W+1);if(F===-1)break;V=W,W=F}}}static#H={open(K){const L=K.data;if(L.#X=K,!L.#j)j.#Q(K,L.#$)},handshake(K,L,M){const O=K.data;if(L)j.#Q(K,O.#$);else O.#W=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:M})),K.end()},data(K,L){const M=K.data;switch(M.#W){case 0:{let O=L.toString();const w=O.indexOf(\"\\r\\n\\r\\n\");if(w===-1){M.#Y+=O;return}if(M.#Y.length)M.#Y+=O,O=M.#Y,M.#Y=\"\";const Q=O.substring(0,w),U=Q.indexOf(\"\\r\\n\");if(U===-1){M.#W=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),K.end();return}const V=Q.substring(0,U);if(V!==\"HTTP/1.1 200 OK\"){M.#W=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(V)})),K.end();return}let W=U+1,A=!1,X=-1;for(;;){let Z=Q.indexOf(\"\\r\\n\",W);if(Z===-1){if(W>=Q.length){if(!A)M.#W=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),K.end();return}Z=Q.length}const z=Q.substring(W+1,Z),B=z.indexOf(\":\"),H=z.substring(0,B),F=H.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(W=Z+1,F)if(z.endsWith(\" text/event-stream\"))A=!0;else{M.#W=2,M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),K.end();return}else if(H.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(X=parseInt(z.substring(B+1).trim(),10),@isNaN(X)||X<=0){M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),K.end();return}if(A)break}else if(H.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(z.substring(B+1).trim()!==\"chunked\"){M.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),K.end();return}if(X=0,A)break}}M.#Z=X,M.#W=1,M.dispatchEvent(new Event(\"open\"));const Y=O.substring(w+4);if(j.#V(M,Y,0),M.#Z>0){if(M.#z+=Y.length,M.#z>=M.#Z)M.#W=2,K.end()}return}case 1:if(j.#V(M,L.toString(),2),M.#Z>0){if(M.#z+=L.byteLength,M.#z>=M.#Z)M.#W=2,K.end()}return;default:break}},drain(K){const L=K.data;if(L.#W===0){const M=L.#Y;if(M.length){const O=K.write(M);if(O!==M.length)K.data.#M=M.substring(O);else K.data.#M=\"\"}}},close:j.#G,end(K){j.#G(K).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(K){j.#G(K).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#G(K){const L=K.data;if(L.#X=null,L.#z=0,L.#W=2,L.#A){if(L.#B)clearTimeout(L.#B);L.#B=setTimeout(j.#F,L.#O,L)}return L}constructor(K,L=@undefined){super();const M=new URL(K);this.#j=M.protocol===\"https:\",this.#$=M,this.#W=2,process.nextTick(j.#F,this)}ref(){this.#B\?.ref(),this.#X\?.ref()}unref(){this.#B\?.unref(),this.#X\?.unref()}#J(){if(this.#W!==2)return;const K=this.#$,L=this.#j;this.#W=0,@Bun.connect({data:this,socket:j.#H,hostname:K.hostname,port:parseInt(K.port||(L\?\"443\":\"80\"),10),tls:L\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((M)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:M})),this.#A){if(this.#B)this.#B.unref\?.();this.#B=setTimeout(j.#F,1000,this)}})}get url(){return this.#$.href}get readyState(){return this.#W}close(){this.#A=!1,this.#W=2,this.#X\?.unref(),this.#X\?.end()}get onopen(){return this.#L}get onerror(){return this.#U}get onmessage(){return this.#K}set onopen(K){if(this.#L)super.removeEventListener(\"close\",this.#L);super.addEventListener(\"open\",K),this.#L=K}set onerror(K){if(this.#U)super.removeEventListener(\"error\",this.#U);super.addEventListener(\"error\",K),this.#U=K}set onmessage(K){if(this.#K)super.removeEventListener(\"message\",this.#K);super.addEventListener(\"message\",K),this.#K=K}}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 F extends EventTarget{#B;#$;#J;#K;#L;#M=!1;#A=null;#j=\"\";#O=\"\";#Q=\"\";#U=!0;#F=0;#G=0;#X=0;#w=null;static#V(j){j.#H()}static#Y(j,A){const w=j.data,B=w.#Q\?`Last-Event-ID: ${w.#Q}\\r\\n`:\"\",K=`GET ${A.pathname}${A.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${B}\\r\\n`,G=j.write(K);if(G!==K.length)w.#O=K.substring(G)}static#Z(j,A,w){for(;;){if(w>=A.length)return;let B=-1,K=A.indexOf(\"\\r\\n\",w);const G=K+2;if(K>0)if(j.#F===0){const J=parseInt(A.substring(w,K),16);if(J===0){j.#$=2,j.#A\?.end();return}B=G+J}else B=A.length;else{if(j.#j.length===0){j.#j+=A.substring(w);return}B=A.length}let M=A.substring(G,B);w=B+2;let Z=0,L=M.indexOf(\"\\n\\n\");if(L==-1){j.#j+=A.substring(G);return}if(j.#j.length)j.#j+=M,M=j.#j,j.#j=\"\";let X=!0;while(X){const J=M.substring(Z,L);let Y,O=\"\",Q,W=0,V=-1;for(;;){let z=J.indexOf(\"\\n\",W);if(z===-1){if(W>=J.length)break;z=J.length}const U=J.substring(W,z);if(U.startsWith(\"data:\"))if(O.length)O+=`\\n${U.substring(5).trim()}`;else O=U.substring(5).trim();else if(U.startsWith(\"event:\"))Y=U.substring(6).trim();else if(U.startsWith(\"id:\"))Q=U.substring(3).trim();else if(U.startsWith(\"retry:\")){if(V=parseInt(U.substring(6).trim(),10),@isNaN(V))V=-1}W=z+1}if(j.#Q=Q||\"\",V>=0)j.#X=V;if(O||Q||Y)j.dispatchEvent(new MessageEvent(Y||\"message\",{data:O||\"\",origin:j.#B.origin,source:j,lastEventId:Q}));if(M.length===L+2){X=!1;break}const H=M.indexOf(\"\\n\\n\",L+1);if(H===-1)break;Z=L,L=H}}}static#z={open(j){const A=j.data;if(A.#A=j,!A.#M)F.#Y(j,A.#B)},handshake(j,A,w){const B=j.data;if(A)F.#Y(j,B.#B);else B.#$=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:w})),j.end()},data(j,A){const w=j.data;switch(w.#$){case 0:{let B=A.toString();const K=B.indexOf(\"\\r\\n\\r\\n\");if(K===-1){w.#j+=B;return}if(w.#j.length)w.#j+=B,B=w.#j,w.#j=\"\";const G=B.substring(0,K),M=G.indexOf(\"\\r\\n\");if(M===-1){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),j.end();return}const Z=G.substring(0,M);if(Z!==\"HTTP/1.1 200 OK\"){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Z)})),j.end();return}let L=M+1,X=!1,J=-1;for(;;){let O=G.indexOf(\"\\r\\n\",L);if(O===-1){if(L>=G.length){if(!X)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.`)})),j.end();return}O=G.length}const Q=G.substring(L+1,O),W=Q.indexOf(\":\"),V=Q.substring(0,W),H=V.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(L=O+1,H)if(Q.endsWith(\" text/event-stream\"))X=!0;else{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.`)})),j.end();return}else if(V.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(J=parseInt(Q.substring(W+1).trim(),10),@isNaN(J)||J<=0){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),j.end();return}if(X)break}else if(V.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(Q.substring(W+1).trim()!==\"chunked\"){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),j.end();return}if(J=0,X)break}}w.#F=J,w.#$=1,w.dispatchEvent(new Event(\"open\"));const Y=B.substring(K+4);if(F.#Z(w,Y,0),w.#F>0){if(w.#G+=Y.length,w.#G>=w.#F)w.#$=2,j.end()}return}case 1:if(F.#Z(w,A.toString(),2),w.#F>0){if(w.#G+=A.byteLength,w.#G>=w.#F)w.#$=2,j.end()}return;default:break}},drain(j){const A=j.data;if(A.#$===0){const w=A.#j;if(w.length){const B=j.write(w);if(B!==w.length)j.data.#O=w.substring(B);else j.data.#O=\"\"}}},close:F.#W,end(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#W(j){const A=j.data;if(A.#A=null,A.#G=0,A.#$=2,A.#U){if(A.#w)clearTimeout(A.#w);A.#w=setTimeout(F.#V,A.#X,A)}return A}constructor(j,A=@undefined){super();const w=new URL(j);this.#M=w.protocol===\"https:\",this.#B=w,this.#$=2,process.nextTick(F.#V,this)}ref(){this.#w\?.ref(),this.#A\?.ref()}unref(){this.#w\?.unref(),this.#A\?.unref()}#H(){if(this.#$!==2)return;const j=this.#B,A=this.#M;this.#$=0,@Bun.connect({data:this,socket:F.#z,hostname:j.hostname,port:parseInt(j.port||(A\?\"443\":\"80\"),10),tls:A\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((w)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:w})),this.#U){if(this.#w)this.#w.unref\?.();this.#w=setTimeout(F.#V,1000,this)}})}get url(){return this.#B.href}get readyState(){return this.#$}close(){this.#U=!1,this.#$=2,this.#A\?.unref(),this.#A\?.end()}get onopen(){return this.#L}get onerror(){return this.#J}get onmessage(){return this.#K}set onopen(j){if(this.#L)super.removeEventListener(\"close\",this.#L);super.addEventListener(\"open\",j),this.#L=j}set onerror(j){if(this.#J)super.removeEventListener(\"error\",this.#J);super.addEventListener(\"error\",j),this.#J=j}set onmessage(j){if(this.#K)super.removeEventListener(\"message\",this.#K);super.addEventListener(\"message\",j),this.#K=j}}return Object.defineProperty(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\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 d17918af2..d00ae735e 100644 --- a/src/js/out/WebCoreJSBuiltins.h +++ b/src/js/out/WebCoreJSBuiltins.h @@ -3527,14 +3527,25 @@ extern const JSC::ConstructAbility s_jsBufferConstructorFromCodeConstructAbility extern const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind; extern const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility; +// isBuffer +#define WEBCORE_BUILTIN_JSBUFFERCONSTRUCTOR_ISBUFFER 1 +extern const char* const s_jsBufferConstructorIsBufferCode; +extern const int s_jsBufferConstructorIsBufferCodeLength; +extern const JSC::ConstructAbility s_jsBufferConstructorIsBufferCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferConstructorIsBufferCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferConstructorIsBufferCodeImplementationVisibility; + #define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_DATA(macro) \ macro(from, jsBufferConstructorFrom, 1) \ + macro(isBuffer, jsBufferConstructorIsBuffer, 1) \ #define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(macro) \ macro(jsBufferConstructorFromCode, from, ASCIILiteral(), s_jsBufferConstructorFromCodeLength) \ + macro(jsBufferConstructorIsBufferCode, isBuffer, ASCIILiteral(), s_jsBufferConstructorIsBufferCodeLength) \ #define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_FUNCTION_NAME(macro) \ macro(from) \ + macro(isBuffer) \ #define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM&); -- cgit v1.2.3 From 3aaec120e7ac26b3904895d2783a08352b63201a Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 5 Jul 2023 03:46:10 -0700 Subject: Fixes #3512 (#3526) * Fixes #3512 * Fix `clearTimeout` and `clearInterval` not cancelling jobs same-tick --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- packages/bun-types/timers.d.ts | 4 +- src/bun.js/api/bun.zig | 100 ++++++++++++++++------- test/js/node/timers/node-timers.test.ts | 13 +-- test/js/web/timers/setTimeout-unref-fixture-2.js | 9 ++ test/js/web/timers/setTimeout-unref-fixture-3.js | 7 ++ test/js/web/timers/setTimeout-unref-fixture-4.js | 5 ++ test/js/web/timers/setTimeout-unref-fixture-5.js | 5 ++ test/js/web/timers/setTimeout-unref-fixture.js | 12 +++ test/js/web/timers/setTimeout.test.js | 51 +++++++++++- 9 files changed, 168 insertions(+), 38 deletions(-) create mode 100644 test/js/web/timers/setTimeout-unref-fixture-2.js create mode 100644 test/js/web/timers/setTimeout-unref-fixture-3.js create mode 100644 test/js/web/timers/setTimeout-unref-fixture-4.js create mode 100644 test/js/web/timers/setTimeout-unref-fixture-5.js create mode 100644 test/js/web/timers/setTimeout-unref-fixture.js diff --git a/packages/bun-types/timers.d.ts b/packages/bun-types/timers.d.ts index ab1e29953..0d2f3e745 100644 --- a/packages/bun-types/timers.d.ts +++ b/packages/bun-types/timers.d.ts @@ -11,8 +11,8 @@ declare module "timers" { class Timer { - ref(): void; - unref(): void; + ref(): Timer; + unref(): Timer; hasRef(): boolean; } diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 1e5a5e004..fbf567446 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -3715,21 +3715,32 @@ pub const Timer = struct { const kind = this.kind; var map: *TimeoutMap = vm.timer.maps.get(kind); - // This doesn't deinit the timer - // Timers are deinit'd separately - // We do need to handle when the timer is cancelled after the job has been enqueued - if (kind != .setInterval) { - if (map.fetchSwapRemove(this.id) == null) { - // if the timeout was cancelled, don't run the callback - this.deinit(); - return; - } - } else { - if (!map.contains(this.id)) { - // if the interval was cancelled, don't run the callback - this.deinit(); - return; + const should_cancel_job = brk: { + // This doesn't deinit the timer + // Timers are deinit'd separately + // We do need to handle when the timer is cancelled after the job has been enqueued + if (kind != .setInterval) { + if (map.get(this.id)) |tombstone_or_timer| { + break :brk tombstone_or_timer != null; + } else { + // clearTimeout has been called + break :brk true; + } + } else { + if (map.get(this.id)) |tombstone_or_timer| { + // .refresh() was called after CallbackJob enqueued + break :brk tombstone_or_timer == null; + } } + + break :brk false; + }; + + if (should_cancel_job) { + this.deinit(); + return; + } else if (kind != .setInterval) { + _ = map.swapRemove(this.id); } var args_buf: [8]JSC.JSValue = undefined; @@ -3825,10 +3836,29 @@ pub const Timer = struct { return timer_js; } - pub fn doRef(this: *TimerObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSValue { + pub fn doRef(this: *TimerObject, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue { + const this_value = callframe.this(); + this_value.ensureStillAlive(); if (this.ref_count > 0) this.ref_count +|= 1; - return JSValue.jsUndefined(); + + var vm = globalObject.bunVM(); + switch (this.kind) { + .setTimeout, .setImmediate, .setInterval => { + if (vm.timer.maps.get(this.kind).getPtr(this.id)) |val_| { + if (val_.*) |*val| { + val.poll_ref.ref(vm); + + if (val.did_unref_timer) { + val.did_unref_timer = false; + vm.uws_event_loop.?.num_polls += 1; + } + } + } + }, + } + + return this_value; } pub fn doRefresh(this: *TimerObject, globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue { @@ -3924,20 +3954,27 @@ pub const Timer = struct { return JSValue.jsUndefined(); } - pub fn doUnref(this: *TimerObject, globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSValue { + pub fn doUnref(this: *TimerObject, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue { + const this_value = callframe.this(); + this_value.ensureStillAlive(); this.ref_count -|= 1; - if (this.ref_count == 0) { - switch (this.kind) { - .setTimeout, .setImmediate => { - _ = clearTimeout(globalObject, JSValue.jsNumber(this.id)); - }, - .setInterval => { - _ = clearInterval(globalObject, JSValue.jsNumber(this.id)); - }, - } + var vm = globalObject.bunVM(); + switch (this.kind) { + .setTimeout, .setImmediate, .setInterval => { + if (vm.timer.maps.get(this.kind).getPtr(this.id)) |val_| { + if (val_.*) |*val| { + val.poll_ref.unref(vm); + + if (!val.did_unref_timer) { + val.did_unref_timer = true; + vm.uws_event_loop.?.num_polls -= 1; + } + } + } + }, } - return JSValue.jsUndefined(); + return this_value; } pub fn hasRef(this: *TimerObject, globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSValue { return JSValue.jsBoolean(this.ref_count > 0 and globalObject.bunVM().timer.maps.get(this.kind).contains(this.id)); @@ -3959,6 +3996,7 @@ pub const Timer = struct { callback: JSC.Strong = .{}, globalThis: *JSC.JSGlobalObject, timer: *uws.Timer, + did_unref_timer: bool = false, poll_ref: JSC.PollRef = JSC.PollRef.init(), arguments: JSC.Strong = .{}, @@ -4060,8 +4098,14 @@ pub const Timer = struct { var vm = this.globalThis.bunVM(); - this.poll_ref.unrefOnNextTick(vm); + this.poll_ref.unref(vm); + this.timer.deinit(); + if (this.did_unref_timer) { + // balance double-unrefing + vm.uws_event_loop.?.num_polls += 1; + } + this.callback.deinit(); this.arguments.deinit(); } diff --git a/test/js/node/timers/node-timers.test.ts b/test/js/node/timers/node-timers.test.ts index e6fa48010..412eabc22 100644 --- a/test/js/node/timers/node-timers.test.ts +++ b/test/js/node/timers/node-timers.test.ts @@ -1,17 +1,18 @@ import { describe, test } from "bun:test"; -import { setTimeout, clearTimeout, setInterval, setImmediate } from "node:timers"; +import { setTimeout, clearTimeout, setInterval, clearInterval, setImmediate } from "node:timers"; -for (const fn of [setTimeout, setInterval, setImmediate]) { +for (const fn of [setTimeout, setInterval]) { describe(fn.name, () => { test("unref is possible", done => { const timer = fn(() => { done(new Error("should not be called")); - }, 1); - fn(() => { + }, 1).unref(); + const other = fn(() => { + clearInterval(other); done(); }, 2); - timer.unref(); - if (fn !== setImmediate) clearTimeout(timer); + if (fn === setTimeout) clearTimeout(timer); + if (fn === setInterval) clearInterval(timer); }); }); } diff --git a/test/js/web/timers/setTimeout-unref-fixture-2.js b/test/js/web/timers/setTimeout-unref-fixture-2.js new file mode 100644 index 000000000..6a78f13cd --- /dev/null +++ b/test/js/web/timers/setTimeout-unref-fixture-2.js @@ -0,0 +1,9 @@ +setTimeout(() => { + console.log("TEST FAILED!"); +}, 100) + .ref() + .unref(); + +setTimeout(() => { + // this one should always run +}, 1); diff --git a/test/js/web/timers/setTimeout-unref-fixture-3.js b/test/js/web/timers/setTimeout-unref-fixture-3.js new file mode 100644 index 000000000..41808f5fc --- /dev/null +++ b/test/js/web/timers/setTimeout-unref-fixture-3.js @@ -0,0 +1,7 @@ +setTimeout(() => { + setTimeout(() => {}, 999_999); +}, 100).unref(); + +setTimeout(() => { + // this one should always run +}, 1); diff --git a/test/js/web/timers/setTimeout-unref-fixture-4.js b/test/js/web/timers/setTimeout-unref-fixture-4.js new file mode 100644 index 000000000..9968f3b36 --- /dev/null +++ b/test/js/web/timers/setTimeout-unref-fixture-4.js @@ -0,0 +1,5 @@ +setTimeout(() => { + console.log("TEST PASSED!"); +}, 1) + .unref() + .ref(); diff --git a/test/js/web/timers/setTimeout-unref-fixture-5.js b/test/js/web/timers/setTimeout-unref-fixture-5.js new file mode 100644 index 000000000..e5caa1be4 --- /dev/null +++ b/test/js/web/timers/setTimeout-unref-fixture-5.js @@ -0,0 +1,5 @@ +setTimeout(() => { + console.log("TEST FAILED!"); +}, 100) + .ref() + .unref(); diff --git a/test/js/web/timers/setTimeout-unref-fixture.js b/test/js/web/timers/setTimeout-unref-fixture.js new file mode 100644 index 000000000..97a0f78a2 --- /dev/null +++ b/test/js/web/timers/setTimeout-unref-fixture.js @@ -0,0 +1,12 @@ +const timer = setTimeout(() => {}, 999_999_999); +if (timer.unref() !== timer) throw new Error("Expected timer.unref() === timer"); + +var ranCount = 0; +const going2Refresh = setTimeout(() => { + if (ranCount < 1) going2Refresh.refresh(); + ranCount++; + + if (ranCount === 2) { + console.log("SUCCESS"); + } +}, 1); diff --git a/test/js/web/timers/setTimeout.test.js b/test/js/web/timers/setTimeout.test.js index dbe89dea8..eef6bbae0 100644 --- a/test/js/web/timers/setTimeout.test.js +++ b/test/js/web/timers/setTimeout.test.js @@ -1,5 +1,7 @@ +import { spawnSync } from "bun"; import { it, expect } from "bun:test"; - +import { bunEnv, bunExe } from "harness"; +import path from "node:path"; it("setTimeout", async () => { var lastID = -1; const result = await new Promise((resolve, reject) => { @@ -172,11 +174,56 @@ it.skip("order of setTimeouts", done => { Promise.resolve().then(maybeDone(() => nums.push(1))); }); +it("setTimeout -> refresh", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), path.join(import.meta.dir, "setTimeout-unref-fixture.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString()).toBe("SUCCESS\n"); +}); + +it("setTimeout -> unref -> ref works", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), path.join(import.meta.dir, "setTimeout-unref-fixture-4.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString()).toBe("TEST PASSED!\n"); +}); + +it("setTimeout -> ref -> unref works, even if there is another timer", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), path.join(import.meta.dir, "setTimeout-unref-fixture-2.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString()).toBe(""); +}); + +it("setTimeout -> ref -> unref works", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), path.join(import.meta.dir, "setTimeout-unref-fixture-5.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString()).toBe(""); +}); + +it("setTimeout -> unref doesn't keep event loop alive forever", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), path.join(import.meta.dir, "setTimeout-unref-fixture-3.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString()).toBe(""); +}); + it("setTimeout should refresh N times", done => { let count = 0; let timer = setTimeout(() => { count++; - timer.refresh(); + expect(timer.refresh()).toBe(timer); }, 50); setTimeout(() => { -- cgit v1.2.3 From f61d9ef4761444d0550aea90b2656727d41ce1fa Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Wed, 5 Jul 2023 12:45:20 -0700 Subject: Update websocket_http_client.zig --- src/http/websocket_http_client.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index a3ae8c3ba..f495af3b7 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -148,10 +148,12 @@ const CppWebSocket = opaque { extern fn WebSocket__incrementPendingActivity(websocket_context: *CppWebSocket) void; extern fn WebSocket__decrementPendingActivity(websocket_context: *CppWebSocket) void; pub fn ref(this: *CppWebSocket) void { + JSC.markBinding(@src()); WebSocket__incrementPendingActivity(this); } pub fn unref(this: *CppWebSocket) void { + JSC.markBinding(@src()); WebSocket__decrementPendingActivity(this); } }; -- cgit v1.2.3 From 8869bac4117b41196c4a73d9145c0beaf5e8437d Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Thu, 6 Jul 2023 02:22:56 -0300 Subject: fix callbacks on release version (#3531) --- src/bun.js/api/bun/socket.zig | 29 +++++++++++++++++------------ src/deps/uws.zig | 29 ++++++++++------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 12a4cffc8..8807d32de 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -1972,7 +1972,11 @@ fn NewSocket(comptime ssl: bool) type { _: *JSC.CallFrame, ) callconv(.C) JSValue { JSC.markBinding(@src()); - this.socket.open(!this.handlers.is_server); + if (comptime ssl) { + if (!this.detached) { + this.socket.open(!this.handlers.is_server); + } + } return JSValue.jsUndefined(); } @@ -2067,12 +2071,9 @@ fn NewSocket(comptime ssl: bool) type { .connection = if (this.connection) |c| c.clone() else null, .wrapped = .tls, .protos = if (protos) |p| (bun.default_allocator.dupe(u8, p[0..protos_len]) catch unreachable) else null, + .server_name = if (socket_config.server_name) |server_name| (bun.default_allocator.dupe(u8, server_name[0..bun.len(server_name)]) catch unreachable) else null, }; - if (socket_config.server_name) |server_name| { - tls.server_name = bun.default_allocator.dupe(u8, server_name[0..bun.len(server_name)]) catch unreachable; - } - var tls_js_value = tls.getThisValue(globalObject); TLSSocket.dataSetCached(tls_js_value, globalObject, default_data); @@ -2099,9 +2100,7 @@ fn NewSocket(comptime ssl: bool) type { var raw = handlers.vm.allocator.create(TLSSocket) catch @panic("OOM"); var raw_handlers_ptr = handlers.vm.allocator.create(Handlers) catch @panic("OOM"); - this.handlers.unprotect(); - - var cloned_handlers: Handlers = .{ + raw_handlers_ptr.* = .{ .vm = globalObject.bunVM(), .globalObject = globalObject, .onOpen = this.handlers.onOpen, @@ -2114,11 +2113,17 @@ fn NewSocket(comptime ssl: bool) type { .onError = this.handlers.onError, .onHandshake = this.handlers.onHandshake, .binary_type = this.handlers.binary_type, + .is_server = this.handlers.is_server, }; - - raw_handlers_ptr.* = cloned_handlers; - raw_handlers_ptr.is_server = this.handlers.is_server; - raw_handlers_ptr.protect(); + this.handlers.onOpen = .zero; + this.handlers.onClose = .zero; + this.handlers.onData = .zero; + this.handlers.onWritable = .zero; + this.handlers.onTimeout = .zero; + this.handlers.onConnectError = .zero; + this.handlers.onEnd = .zero; + this.handlers.onError = .zero; + this.handlers.onHandshake = .zero; raw.* = .{ .handlers = raw_handlers_ptr, .this_value = .zero, diff --git a/src/deps/uws.zig b/src/deps/uws.zig index 5dbe4f5d8..c2cd24063 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -54,7 +54,6 @@ pub fn NewSocketHandler(comptime ssl: bool) type { comptime ContextType: type, comptime Fields: anytype, ) ?NewSocketHandler(true) { - const Type = comptime if (@TypeOf(Fields) != type) @TypeOf(Fields) else Fields; const TLSSocket = NewSocketHandler(true); const SocketHandler = struct { const alignment = if (ContextType == anyopaque) @@ -140,24 +139,16 @@ pub fn NewSocketHandler(comptime ssl: bool) type { } }; - var events: us_socket_events_t = .{}; - - if (comptime @hasDecl(Type, "onOpen") and @typeInfo(@TypeOf(Type.onOpen)) != .Null) - events.on_open = SocketHandler.on_open; - if (comptime @hasDecl(Type, "onClose") and @typeInfo(@TypeOf(Type.onClose)) != .Null) - events.on_close = SocketHandler.on_close; - if (comptime @hasDecl(Type, "onData") and @typeInfo(@TypeOf(Type.onData)) != .Null) - events.on_data = SocketHandler.on_data; - if (comptime @hasDecl(Type, "onWritable") and @typeInfo(@TypeOf(Type.onWritable)) != .Null) - events.on_writable = SocketHandler.on_writable; - if (comptime @hasDecl(Type, "onTimeout") and @typeInfo(@TypeOf(Type.onTimeout)) != .Null) - events.on_timeout = SocketHandler.on_timeout; - if (comptime @hasDecl(Type, "onConnectError") and @typeInfo(@TypeOf(Type.onConnectError)) != .Null) - events.on_connect_error = SocketHandler.on_connect_error; - if (comptime @hasDecl(Type, "onEnd") and @typeInfo(@TypeOf(Type.onEnd)) != .Null) - events.on_end = SocketHandler.on_end; - if (comptime @hasDecl(Type, "onHandshake") and @typeInfo(@TypeOf(Type.onHandshake)) != .Null) - events.on_handshake = SocketHandler.on_handshake; + var events: us_socket_events_t = .{ + .on_open = SocketHandler.on_open, + .on_close = SocketHandler.on_close, + .on_data = SocketHandler.on_data, + .on_writable = SocketHandler.on_writable, + .on_timeout = SocketHandler.on_timeout, + .on_connect_error = SocketHandler.on_connect_error, + .on_end = SocketHandler.on_end, + .on_handshake = SocketHandler.on_handshake, + }; const socket = us_socket_wrap_with_tls(ssl_int, this.socket, options, events, socket_ext_size) orelse return null; return NewSocketHandler(true).from(socket); -- cgit v1.2.3 From 6bf8f6f9f252dc92dc7da1fcfc3449057edd8be1 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Wed, 5 Jul 2023 22:23:32 -0700 Subject: don't unwrap react below version `18.0.0` (#3538) * don't unwrap react below version 18 * empty string * also `react-dom` --- src/bundler/bundle_v2.zig | 4 ++++ src/js_parser.zig | 25 ++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index f534e4184..1fd77f5f2 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -2279,6 +2279,7 @@ pub const ParseTask = struct { known_target: ?options.Target = null, module_type: options.ModuleType = .unknown, ctx: *BundleV2, + package_version: string = "", /// Used by generated client components presolved_source_indices: []const Index.Int = &.{}, @@ -2299,6 +2300,7 @@ pub const ParseTask = struct { .jsx = resolve_result.jsx, .source_index = source_index orelse Index.invalid, .module_type = resolve_result.module_type, + .package_version = if (resolve_result.package_json) |package_json| package_json.version else "", }; } @@ -2591,6 +2593,8 @@ pub const ParseTask = struct { opts.warn_about_unbundled_modules = false; opts.macro_context = &this.data.macro_context; opts.bundle = true; + opts.package_version = task.package_version; + opts.features.top_level_await = true; opts.features.jsx_optimization_inline = target.isBun() and (bundler.options.jsx_optimization_inline orelse !task.jsx.development); opts.features.auto_import_jsx = task.jsx.parse and bundler.options.auto_import_jsx; diff --git a/src/js_parser.zig b/src/js_parser.zig index 5729efa39..6a2cc1228 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -2629,6 +2629,7 @@ pub const Parser = struct { tree_shaking: bool = false, bundle: bool = false, + package_version: string = "", macro_context: *MacroContextType() = undefined, @@ -21918,11 +21919,25 @@ fn NewParser_( // Only enable during bundling .commonjs_named_exports_deoptimized = !opts.bundle, - .unwrap_all_requires = opts.bundle and - if (source.path.packageName()) |pkg| - opts.features.shouldUnwrapRequire(pkg) - else - false, + }; + + this.unwrap_all_requires = brk: { + if (opts.bundle) { + if (source.path.packageName()) |pkg| { + if (opts.features.shouldUnwrapRequire(pkg)) { + if (strings.eqlComptime(pkg, "react") or strings.eqlComptime(pkg, "react-dom")) { + const version = opts.package_version; + if (version.len > 2 and (version[0] == '0' or (version[0] == '1' and version[1] < '8'))) { + break :brk false; + } + } + + break :brk true; + } + } + } + + break :brk false; }; this.symbols = std.ArrayList(Symbol).init(allocator); -- cgit v1.2.3 From ee57935260214cbd6f580a756903df7eebe495ef Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 6 Jul 2023 00:06:43 -0700 Subject: Fixes #3537 (#3539) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/js_parser.zig | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/src/js_parser.zig b/src/js_parser.zig index 6a2cc1228..230a09fd0 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -3159,22 +3159,53 @@ pub const Parser = struct { const left = bin.left; const right = bin.right; if (bin.op == .bin_assign and - right.data == .e_require_string and left.data == .e_dot and strings.eqlComptime(left.data.e_dot.name, "exports") and left.data.e_dot.target.data == .e_identifier and left.data.e_dot.target.data.e_identifier.ref.eql(p.module_ref)) { - part.symbol_uses = .{}; - return js_ast.Result{ - .ast = js_ast.Ast{ - .allocator = p.allocator, - .import_records = ImportRecord.List.init(p.import_records.items), - .redirect_import_record_index = right.data.e_require_string.import_record_index, - .named_imports = p.named_imports, - .named_exports = p.named_exports, - }, + const redirect_import_record_index: ?u32 = brk: { + // general case: + // + // module.exports = require("foo"); + // + if (right.data == .e_require_string) { + break :brk right.data.e_require_string.import_record_index; + } + + // special case: a module for us to unwrap + // + // module.exports = require("react/jsx-runtime") + // ^ was converted into: + // + // import * as Foo from 'bar'; + // module.exports = Foo; + // + // This is what fixes #3537 + if (right.data == .e_identifier and + p.import_records.items.len == 1 and + p.imports_to_convert_from_require.items.len == 1 and + p.imports_to_convert_from_require.items[0].namespace.ref.?.eql(right.data.e_identifier.ref)) + { + // We know it's 0 because there is only one import in the whole file + // so that one import must be the one we're looking for + break :brk 0; + } + + break :brk null; }; + if (redirect_import_record_index) |id| { + part.symbol_uses = .{}; + return js_ast.Result{ + .ast = js_ast.Ast{ + .allocator = p.allocator, + .import_records = ImportRecord.List.init(p.import_records.items), + .redirect_import_record_index = id, + .named_imports = p.named_imports, + .named_exports = p.named_exports, + }, + }; + } } } } -- cgit v1.2.3 From 95ddfcc4377350b1d604c39c36562bde45fad2a9 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Thu, 6 Jul 2023 16:01:16 -0300 Subject: fix query without slash (#3547) --- src/url.zig | 20 ++++++++++---------- test/js/web/fetch/fetch.test.ts | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/url.zig b/src/url.zig index 66c4ff015..af13b139c 100644 --- a/src/url.zig +++ b/src/url.zig @@ -348,8 +348,8 @@ pub const URL = struct { url.username = str[0..i]; return i + 1; }, - // if we reach a slash, there's no username - '/' => { + // if we reach a slash or "?", there's no username + '?', '/' => { return null; }, else => {}, @@ -374,8 +374,8 @@ pub const URL = struct { if (Environment.allow_assert) std.debug.assert(str[i..].len < 2 or std.mem.readIntNative(u16, str[i..][0..2]) != std.mem.readIntNative(u16, "//")); return i + 1; }, - // if we reach a slash, there's no password - '/' => { + // if we reach a slash or "?", there's no password + '?', '/' => { return null; }, else => {}, @@ -402,8 +402,8 @@ pub const URL = struct { ipv6_i = if (ipv6_i == null and str[i] == ']') i else ipv6_i; colon_i = if (ipv6_i != null and colon_i == null and str[i] == ':') i else colon_i; switch (str[i]) { - // alright, we found the slash - '/' => { + // alright, we found the slash or "?" + '?', '/' => { break; }, else => {}, @@ -421,8 +421,8 @@ pub const URL = struct { } } else { - // look for the first "/" - // if we have a slash, anything before that is the host + // look for the first "/" or "?" + // if we have a slash or "?", anything before that is the host // anything before the colon is the hostname // anything after the colon but before the slash is the port // the origin is the scheme before the slash @@ -432,8 +432,8 @@ pub const URL = struct { colon_i = if (colon_i == null and str[i] == ':') i else colon_i; switch (str[i]) { - // alright, we found the slash - '/' => { + // alright, we found the slash or "?" + '?', '/' => { break; }, else => {}, diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts index 6b87cc613..768818420 100644 --- a/test/js/web/fetch/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -1175,6 +1175,10 @@ it("#2794", () => { expect(typeof Bun.fetch.bind).toBe("function"); }); +it("#3545", () => { + expect(() => fetch("http://example.com?a=b")).not.toThrow(); +}); + it("invalid header doesnt crash", () => { expect(() => fetch("http://example.com", { -- cgit v1.2.3 From 109ebc14fda92bc2c84459b9911bef03b08f1b0a Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Thu, 6 Jul 2023 13:02:29 -0700 Subject: Various docs updates (#3437) * Various docs updates * Add mocks page * Fix make * WebKit instructions * Update instructions * Updates * Update nodejs compat table * Document trusted deps * Tweak trustedDependencies docs * Document --exact * Update test docs * Tweaks * Boring * Remove redundant j * Undo makefile changes * Undo makefile changes * Update page title * Regen * Undo changes --- docs/api/http.md | 107 ++++++++++++++++++++----------- docs/api/streams.md | 6 +- docs/cli/install.md | 52 ++++++++++++++- docs/cli/test.md | 18 ++++++ docs/nav.ts | 11 ++-- docs/project/development.md | 31 +++++++++ docs/runtime/nodejs-apis.md | 6 +- docs/runtime/typescript.md | 11 ++++ docs/test/lifecycle.md | 2 +- docs/test/mocks.md | 55 ++++++++++++++++ docs/test/time.md | 14 +++- docs/test/writing.md | 82 +++++++++++++++++++++++ packages/bun-types/tests/serve.test-d.ts | 13 ++++ 13 files changed, 355 insertions(+), 53 deletions(-) create mode 100644 docs/test/mocks.md diff --git a/docs/api/http.md b/docs/api/http.md index aed9da27c..8520604e8 100644 --- a/docs/api/http.md +++ b/docs/api/http.md @@ -67,7 +67,7 @@ Bun.serve({ fetch(req) { throw new Error("woops!"); }, - error(error: Error) { + error(error) { return new Response(`
${error}\n${error.stack}
`, { headers: { "Content-Type": "text/html", @@ -95,37 +95,37 @@ server.stop(); ## TLS -Bun supports TLS out of the box, powered by [OpenSSL](https://www.openssl.org/). Enable TLS by passing in a value for `key` and `cert`; both are required to enable TLS. If needed, supply a `passphrase` to decrypt the `keyFile`. +Bun supports TLS out of the box, powered by [BoringSSL](https://boringssl.googlesource.com/boringssl). Enable TLS by passing in a value for `key` and `cert`; both are required to enable TLS. -```ts -Bun.serve({ - fetch(req) { - return new Response("Hello!!!"); - }, - - // can be string, BunFile, TypedArray, Buffer, or array thereof - key: Bun.file("./key.pem"), - cert: Bun.file("./cert.pem"), +```ts-diff + Bun.serve({ + fetch(req) { + return new Response("Hello!!!"); + }, - // passphrase, only required if key is encrypted - passphrase: "super-secret", -}); ++ tls: { ++ key: Bun.file("./key.pem"), ++ cert: Bun.file("./cert.pem"), ++ } + }); ``` -The `key` and `cert` fields expect the _contents_ of your TLS key and certificate. This can be a string, `BunFile`, `TypedArray`, or `Buffer`. +The `key` and `cert` fields expect the _contents_ of your TLS key and certificate, _not a path to it_. This can be a string, `BunFile`, `TypedArray`, or `Buffer`. ```ts Bun.serve({ fetch() {}, - // BunFile - key: Bun.file("./key.pem"), - // Buffer - key: fs.readFileSync("./key.pem"), - // string - key: fs.readFileSync("./key.pem", "utf8"), - // array of above - key: [Bun.file('./key1.pem'), Bun.file('./key2.pem')], + tls: { + // BunFile + key: Bun.file("./key.pem"), + // Buffer + key: fs.readFileSync("./key.pem"), + // string + key: fs.readFileSync("./key.pem", "utf8"), + // array of above + key: [Bun.file("./key1.pem"), Bun.file("./key2.pem")], + }, }); ``` @@ -135,17 +135,35 @@ Bun.serve({ {% /callout %} +If your private key is encrypted with a passphrase, provide a value for `passphrase` to decrypt it. + +```ts-diff + Bun.serve({ + fetch(req) { + return new Response("Hello!!!"); + }, + + tls: { + key: Bun.file("./key.pem"), + cert: Bun.file("./cert.pem"), ++ passphrase: "my-secret-passphrase", + } + }); +``` + Optionally, you can override the trusted CA certificates by passing a value for `ca`. By default, the server will trust the list of well-known CAs curated by Mozilla. When `ca` is specified, the Mozilla list is overwritten. -```ts -Bun.serve({ - fetch(req) { - return new Response("Hello!!!"); - }, - key: Bun.file("./key.pem"), // path to TLS key - cert: Bun.file("./cert.pem"), // path to TLS cert - ca: Bun.file("./ca.pem"), // path to root CA certificate -}); +```ts-diff + Bun.serve({ + fetch(req) { + return new Response("Hello!!!"); + }, + tls: { + key: Bun.file("./key.pem"), // path to TLS key + cert: Bun.file("./cert.pem"), // path to TLS cert ++ ca: Bun.file("./ca.pem"), // path to root CA certificate + } + }); ``` To override Diffie-Helman parameters: @@ -153,7 +171,10 @@ To override Diffie-Helman parameters: ```ts Bun.serve({ // ... - dhParamsFile: "./dhparams.pem", // path to Diffie Helman parameters + tls: { + // other config + dhParamsFile: "/path/to/dhparams.pem", // path to Diffie Helman parameters + }, }); ``` @@ -274,11 +295,21 @@ interface Bun { port?: number; development?: boolean; error?: (error: Error) => Response | Promise; - keyFile?: string; - certFile?: string; - caFile?: string; - dhParamsFile?: string; - passphrase?: string; + tls?: { + key?: + | string + | TypedArray + | BunFile + | Array; + cert?: + | string + | TypedArray + | BunFile + | Array; + ca?: string | TypedArray | BunFile | Array; + passphrase?: string; + dhParamsFile?: string; + }; maxRequestBodySize?: number; lowMemoryMode?: boolean; }): Server; diff --git a/docs/api/streams.md b/docs/api/streams.md index 7f3e3bcb4..210090927 100644 --- a/docs/api/streams.md +++ b/docs/api/streams.md @@ -28,8 +28,6 @@ for await (const chunk of stream) { } ``` -For a more complete discusson of streams in Bun, see [API > Streams](/docs/api/streams). - ## Direct `ReadableStream` Bun implements an optimized version of `ReadableStream` that avoid unnecessary data copying & queue management logic. With a traditional `ReadableStream`, chunks of data are _enqueued_. Each chunk is copied into a queue, where it sits until the stream is ready to send more data. @@ -154,7 +152,9 @@ export class ArrayBufferSink { stream?: boolean; }): void; - write(chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer): number; + write( + chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer, + ): number; /** * Flush the internal buffer * diff --git a/docs/cli/install.md b/docs/cli/install.md index 4489a0d4a..f7b081ba8 100644 --- a/docs/cli/install.md +++ b/docs/cli/install.md @@ -49,7 +49,7 @@ To install in production mode (i.e. without `devDependencies`): $ bun install --production ``` -To install dependencies without allowing changes to lockfile (useful on CI): +To install with reproducible dependencies, use `--frozen-lockfile`. If your `package.json` disagrees with `bun.lockb`, Bun will exit with an error. This is useful for production builds and CI environments. ```bash $ bun install --frozen-lockfile @@ -124,6 +124,26 @@ To add a package as an optional dependency (`"optionalDependencies"`): $ bun add --optional lodash ``` +To add a package and pin to the resolved version, use `--exact`. This will resolve the version of the package and add it to your `package.json` with an exact version number instead of a version range. + +```bash +$ bun add react --exact +``` + +This will add the following to your `package.json`: + +```jsonc +{ + "dependencies": { + // without --exact + "react": "^18.2.0", // this matches >= 18.2.0 < 19.0.0 + + // with --exact + "react": "18.2.0" // this matches only 18.2.0 exactly + } +} +``` + To install a package globally: ```bash @@ -206,6 +226,36 @@ In addition, the `--save` flag can be used to add `cool-pkg` to the `dependencie } ``` +## Trusted dependencies + +Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts for installed dependencies, such as `postinstall`. These scripts represent a potential security risk, as they can execute arbitrary code on your machine. + + + +To tell Bun to allow lifecycle scripts for a particular package, add the package to `trustedDependencies` in your package.json. + +```json-diff + { + "name": "my-app", + "version": "1.0.0", ++ "trustedDependencies": { ++ "my-trusted-package": "*" ++ } + } +``` + +Bun reads this field and will run lifecycle scripts for `my-trusted-package`. If you specify a version range, Bun will only execute lifecycle scripts if the resolved package version matches the range. + +```json +{ + "name": "my-app", + "version": "1.0.0", + "trustedDependencies": { + "my-trusted-package": "^1.0.0" + } +} +``` + ## Git dependencies To add a dependency from a git repository: diff --git a/docs/cli/test.md b/docs/cli/test.md index d19a45a12..7af8dcc20 100644 --- a/docs/cli/test.md +++ b/docs/cli/test.md @@ -65,6 +65,24 @@ $ bun test --preload ./setup.ts See [Test > Lifecycle](/docs/test/lifecycle) for complete documentation. +## Mocks + +Create mocks with the `mock` function. Mocks are automatically reset between tests. + +``` +import { test, expect, mock } from "bun:test"; +const random = mock(() => Math.random()); + +test("random", async () => { + const val = random(); + expect(val).toBeGreaterThan(0); + expect(random).toHaveBeenCalled(); + expect(random).toHaveBeenCalledTimes(1); +}); +``` + +See [Test > Mocks](/docs/test/mocks) for complete documentation. + ## Snapshot testing Snapshots are supported by `bun test`. See [Test > Snapshots](/docs/test/snapshots) for complete documentation. diff --git a/docs/nav.ts b/docs/nav.ts index 2832a53cf..5b35036d3 100644 --- a/docs/nav.ts +++ b/docs/nav.ts @@ -135,13 +135,13 @@ export default { description: "Install all dependencies with `bun install`, or manage dependencies with `bun add` and `bun remove`.", }), - page("install/workspaces", "Workspaces", { - description: "Bun's package manager supports workspaces and mono-repo development workflows.", - }), page("install/cache", "Global cache", { description: "Bun's package manager installs all packages into a shared global cache to avoid redundant re-downloads.", }), + page("install/workspaces", "Workspaces", { + description: "Bun's package manager supports workspaces and mono-repo development workflows.", + }), page("install/lockfile", "Lockfile", { description: "Bun's binary lockfile `bun.lockb` tracks your resolved dependency ytrr, making future installs fast and repeatable.", @@ -190,10 +190,13 @@ export default { page("test/lifecycle", "Lifecycle hooks", { description: "Add lifecycle hooks to your tests that run before/after each test or test run", }), + page("test/mocks", "Mocks", { + description: "Mocks functions and track method calls", + }), page("test/snapshots", "Snapshots", { description: "Add lifecycle hooks to your tests that run before/after each test or test run", }), - page("test/time", "Time", { + page("test/time", "Dates and times", { description: "Control the date & time in your tests for more reliable and deterministic tests", }), page("test/dom", "DOM testing", { diff --git a/docs/project/development.md b/docs/project/development.md index d21641aff..e50f53215 100644 --- a/docs/project/development.md +++ b/docs/project/development.md @@ -217,6 +217,37 @@ You'll need a very recent version of Valgrind due to DWARF 5 debug symbols. You $ valgrind --fair-sched=try --track-origins=yes bun-debug ``` +## Updating `WebKit` + +The Bun team will occasionally bump the version of WebKit used in Bun. When this happens, you may see something like this with you run `git status`. + +```bash +$ git status +On branch my-branch +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + modified: src/bun.js/WebKit (new commits) +``` + +For performance reasons, `bun submodule update` does not automatically update the WebKit submodule. To update, run the following commands from the root of the Bun repo: + +```bash +$ bun install +$ make bindings +``` + + + + + ## Troubleshooting ### libarchive diff --git a/docs/runtime/nodejs-apis.md b/docs/runtime/nodejs-apis.md index ac42559a0..593954aae 100644 --- a/docs/runtime/nodejs-apis.md +++ b/docs/runtime/nodejs-apis.md @@ -51,7 +51,7 @@ This page is updated regularly to reflect compatibility status of the latest ver - {% anchor id="node_crypto" %} [`node:crypto`](https://nodejs.org/api/crypto.html) {% /anchor %} - 🟡 -- Missing `crypto.Certificate` `crypto.ECDH` `crypto.KeyObject` `crypto.X509Certificate` `crypto.checkPrime{Sync}` `crypto.createPrivateKey` `crypto.createPublicKey` `crypto.createSecretKey` `crypto.diffieHellman` `crypto.generateKey{Sync}` `crypto.generateKeyPair{Sync}` `crypto.generatePrime{Sync}` `crypto.getCipherInfo` `crypto.getCurves` `crypto.{get|set}Fips` `crypto.hkdf` `crypto.hkdfSync` `crypto.randomInt` `crypto.secureHeapUsed` `crypto.setEngine` `crypto.sign` `crypto.verify` +- Missing `crypto.Certificate` `crypto.ECDH` `crypto.KeyObject` `crypto.X509Certificate` `crypto.checkPrime{Sync}` `crypto.createPrivateKey` `crypto.createPublicKey` `crypto.createSecretKey` `crypto.diffieHellman` `crypto.generateKey{Sync}` `crypto.generateKeyPair{Sync}` `crypto.generatePrime{Sync}` `crypto.getCipherInfo` `crypto.getCurves` `crypto.{get|set}Fips` `crypto.hkdf` `crypto.hkdfSync` `crypto.secureHeapUsed` `crypto.setEngine` `crypto.sign` `crypto.verify` --- @@ -87,7 +87,7 @@ This page is updated regularly to reflect compatibility status of the latest ver - {% anchor id="node_fs" %} [`node:fs`](https://nodejs.org/api/fs.html) {% /anchor %} - 🟡 -- Missing `fs.fdatasync{Sync}` `fs.opendir{Sync}` `fs.readv{Sync}` `fs.{watch|watchFile|unwatchFile}` `fs.writev{Sync}`. +- Missing `fs.fdatasync{Sync}` `fs.opendir{Sync}` `fs.{watchFile|unwatchFile}` `fs.{cp|cpSync}`. --- @@ -558,7 +558,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa - {% anchor id="node_require" %} [`require()`](https://nodejs.org/api/globals.html#require) {% /anchor %} - 🟢 -- Fully implemented. +- Fully implemented, as well as [`require.main`](https://nodejs.org/api/modules.html#requiremain), [`require.cache`](https://nodejs.org/api/modules.html#requirecache), and [`require.resolve`](https://nodejs.org/api/modules.html#requireresolverequest-options) --- diff --git a/docs/runtime/typescript.md b/docs/runtime/typescript.md index d466bb016..b79b1ec6d 100644 --- a/docs/runtime/typescript.md +++ b/docs/runtime/typescript.md @@ -93,6 +93,17 @@ These are the recommended `compilerOptions` for a Bun project. } ``` +### Add DOM types + +Settings `"types": ["bun-types"]` means TypeScript will ignore other global type definitions, including `lib: ["dom"]`. To add DOM types into your project, add the following [triple-slash directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) at the top of any TypeScript file in your project. + +```ts +/// +/// +``` + +The same applies to other global type definition _libs_ like `webworker`. + ## Path mapping When resolving modules, Bun's runtime respects path mappings defined in [`compilerOptions.paths`](https://www.typescriptlang.org/tsconfig#paths) in your `tsconfig.json`. No other runtime does this. diff --git a/docs/test/lifecycle.md b/docs/test/lifecycle.md index 176c476de..fd804c9bb 100644 --- a/docs/test/lifecycle.md +++ b/docs/test/lifecycle.md @@ -70,7 +70,7 @@ afterAll(() => { Then use `--preload` to run the setup script before any test files. ```ts -bun test --preload ./setup.ts +$ bun test --preload ./setup.ts ``` To avoid typing `--preload` every time you run tests, it can be added to your `bunfig.toml`: diff --git a/docs/test/mocks.md b/docs/test/mocks.md new file mode 100644 index 000000000..31b5dab41 --- /dev/null +++ b/docs/test/mocks.md @@ -0,0 +1,55 @@ +Create mocks with the `mock` function. + +```ts +import { test, expect, mock } from "bun:test"; +const random = mock(() => Math.random()); + +test("random", async () => { + const val = random(); + expect(val).toBeGreaterThan(0); + expect(random).toHaveBeenCalled(); + expect(random).toHaveBeenCalledTimes(1); +}); +``` + +The result of `mock()` is a new function that's been decorated with some additional properties. + +```ts +import { mock } from "bun:test"; +const random = mock((multiplier: number) => multiplier * Math.random()); + +random(2); +random(10); + +random.mock.calls; +// [[ 2 ], [ 10 ]] + +random.mock.results; +// [ +// { type: "return", value: 0.6533907460954099 }, +// { type: "return", value: 0.6452713933037312 } +// ] +``` + +## `.spyOn()` + +It's possible to track calls to a function without replacing it with a mock. Use `spyOn()` to create a spy; these spies can be passed to `.toHaveBeenCalled()` and `.toHaveBeenCalledTimes()`. + +```ts +import { test, expect, spyOn } from "bun:test"; + +const ringo = { + name: "Ringo", + sayHi() { + console.log(`Hello I'm ${this.name}`); + }, +}; + +const spy = spyOn(ringo, "sayHi"); + +test("spyon", () => { + expect(spy).toHaveBeenCalledTimes(0); + ringo.sayHi(); + expect(spy).toHaveBeenCalledTimes(1); +}); +``` diff --git a/docs/test/time.md b/docs/test/time.md index ef741fc6f..4a0f98407 100644 --- a/docs/test/time.md +++ b/docs/test/time.md @@ -51,7 +51,9 @@ test("unlike in jest", () => { }); ``` -Note that we have not implemented builtin support for mocking timers yet, but this is on the roadmap. +{% callout %} +**Timers** — Note that we have not implemented builtin support for mocking timers yet, but this is on the roadmap. +{% /callout %} ### Reset the system time @@ -74,7 +76,13 @@ test("it was 2020, for a moment.", () => { ## Set the time zone -To change the time zone, either pass the `$TZ` environment variable to `bun test`, or set `process.env.TZ` at runtime: +To change the time zone, either pass the `$TZ` environment variable to `bun test`. + +```sh +TZ=America/Los_Angeles bun test +``` + +Or set `process.env.TZ` at runtime: ```ts import { test, expect } from "bun:test"; @@ -88,7 +96,7 @@ test("Welcome to California!", () => { }); test("Welcome to New York!", () => { - // Unlike in jest, you can set the timezone multiple times at runtime and it will work. + // Unlike in Jest, you can set the timezone multiple times at runtime and it will work. process.env.TZ = "America/New_York"; expect(new Date().getTimezoneOffset()).toBe(240); expect(new Intl.DateTimeFormat().resolvedOptions().timeZone).toBe( diff --git a/docs/test/writing.md b/docs/test/writing.md index 029418a48..6a29bf81f 100644 --- a/docs/test/writing.md +++ b/docs/test/writing.md @@ -63,6 +63,21 @@ test("2 * 2", done => { }); ``` +## Timeouts + +Optionally specify a per-test timeout in milliseconds by passing a number as the third argument to `test`. + +```ts +import { test } from "bun:test"; + +test.skip("wat", async () => { + const data = await slowOperation(); + expect(data).toBe(42); +}, 500); // test must run in <500ms +``` + +## `test.skip` + Skip individual tests with `test.skip`. These tests will not be run. ```ts @@ -74,6 +89,8 @@ test.skip("wat", () => { }); ``` +## `test.todo` + Mark a test as a todo with `test.todo`. These tests _will_ be run, and the test runner will expect them to fail. If they pass, you will be prompted to mark it as a regular test. ```ts @@ -84,6 +101,71 @@ test.todo("fix this", () => { }); ``` +To exlusively run tests marked as _todo_, use `bun test --todo`. + +```sh +$ bun test --todo +``` + +## `test.only` + +To run a particular test or suite of tests use `test.only()` or `describe.only()`. Once declared, running `bun test --skip` will only execute tests/suites that have been marked with `.only()`. + +```ts +import { test, describe } from "bun:test"; + +test("test #1", () => { + // does not run +}); + +test.only("test #2", () => { + // runs +}); + +describe.only("only", () => { + test("test #3", () => { + // runs + }); +}); +``` + +The following command will only execute tests #2 and #3. + +```sh +$ bun test --only +``` + +## `test.if` + +To run a test conditionally, use `test.if()`. The test will run if the condition is truthy. This is particularly useful for tests that should only run on specific architectures or operating systems. + +```ts +test.if(Math.random() > 0.5)("runs half the time", () => { + // ... +}); +``` + +```ts +test.if(Math.random() > 0.5)("runs half the time", () => { + // ... +}); + +const macOS = process.arch === "darwin"; +test.if(macOS)("runs on macOS", () => { + // runs if macOS +}); +``` + +To instead skip a test based on some condition, use `test.skipIf()` or `describe.skipIf()`. + +```ts +const macOS = process.arch === "darwin"; + +test.skipIf(macOS)("runs on non-macOS", () => { + // runs if *not* macOS +}); +``` + ## Matchers Bun implements the following matchers. Full Jest compatibility is on the roadmap; track progress [here](https://github.com/oven-sh/bun/issues/1825). diff --git a/packages/bun-types/tests/serve.test-d.ts b/packages/bun-types/tests/serve.test-d.ts index 2477433dc..4ba3144b8 100644 --- a/packages/bun-types/tests/serve.test-d.ts +++ b/packages/bun-types/tests/serve.test-d.ts @@ -79,4 +79,17 @@ Bun.serve({ }, }); +Bun.serve({ + fetch(req) { + throw new Error("woops!"); + }, + error(error) { + return new Response(`
${error}\n${error.stack}
`, { + headers: { + "Content-Type": "text/html", + }, + }); + }, +}); + export {}; -- cgit v1.2.3 From abe095dd1e0962e3510596ccb8c66e0695947c3a Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Thu, 6 Jul 2023 13:55:00 -0700 Subject: fixes #3544 (#3549) --- src/node-fallbacks/node-fetch.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node-fallbacks/node-fetch.js b/src/node-fallbacks/node-fetch.js index f124e6461..c65d4f6ed 100644 --- a/src/node-fallbacks/node-fetch.js +++ b/src/node-fallbacks/node-fetch.js @@ -70,6 +70,7 @@ export default Object.assign(fetch, { fileFrom, fileFromSync, isRedirect, + default: fetch, [Symbol.for("CommonJS")]: 0, }); -- cgit v1.2.3 From 954b6fcaf39c2346762ff40e9cf25705fcbd7ffb Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Thu, 6 Jul 2023 17:55:27 -0300 Subject: refactor (#3543) --- src/bun.js/api/bun/socket.zig | 24 +++------ src/bun.js/api/sockets.classes.ts | 8 +-- src/bun.js/bindings/JSSink.cpp | 2 +- src/bun.js/bindings/JSSink.h | 2 +- src/bun.js/bindings/ZigGeneratedClasses.cpp | 82 ++++------------------------- src/bun.js/bindings/generated_classes.zig | 18 +++---- src/deps/uws.zig | 2 +- src/js/node/net.js | 29 +++++----- src/js/out/modules/node/net.js | 17 +++--- 9 files changed, 53 insertions(+), 131 deletions(-) diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 8807d32de..1d85c705c 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -1966,24 +1966,10 @@ fn NewSocket(comptime ssl: bool) type { return JSValue.jsUndefined(); } - pub fn open( - this: *This, - _: *JSC.JSGlobalObject, - _: *JSC.CallFrame, - ) callconv(.C) JSValue { - JSC.markBinding(@src()); - if (comptime ssl) { - if (!this.detached) { - this.socket.open(!this.handlers.is_server); - } - } - return JSValue.jsUndefined(); - } - // this invalidates the current socket returning 2 new sockets // one for non-TLS and another for TLS // handlers for non-TLS are preserved - pub fn wrapTLS( + pub fn upgradeTLS( this: *This, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame, @@ -2058,10 +2044,11 @@ fn NewSocket(comptime ssl: bool) type { const ext_size = @sizeOf(WrappedSocket); + const is_server = this.handlers.is_server; var tls = handlers.vm.allocator.create(TLSSocket) catch @panic("OOM"); var handlers_ptr = handlers.vm.allocator.create(Handlers) catch @panic("OOM"); handlers_ptr.* = handlers; - handlers_ptr.is_server = this.handlers.is_server; + handlers_ptr.is_server = is_server; handlers_ptr.protect(); tls.* = .{ @@ -2113,7 +2100,7 @@ fn NewSocket(comptime ssl: bool) type { .onError = this.handlers.onError, .onHandshake = this.handlers.onHandshake, .binary_type = this.handlers.binary_type, - .is_server = this.handlers.is_server, + .is_server = is_server, }; this.handlers.onOpen = .zero; this.handlers.onClose = .zero; @@ -2147,6 +2134,9 @@ fn NewSocket(comptime ssl: bool) type { // mark both instances on socket data new_socket.ext(WrappedSocket).?.* = .{ .tcp = raw, .tls = tls }; + // start TLS handshake after we set ext + new_socket.startTLS(!this.handlers.is_server); + //detach and invalidate the old instance this.detached = true; if (this.reffer.has) { diff --git a/src/bun.js/api/sockets.classes.ts b/src/bun.js/api/sockets.classes.ts index 0c7847e19..5bd073b9f 100644 --- a/src/bun.js/api/sockets.classes.ts +++ b/src/bun.js/api/sockets.classes.ts @@ -22,14 +22,10 @@ function generate(ssl) { fn: "write", length: 3, }, - wrapTLS: { - fn: "wrapTLS", + upgradeTLS: { + fn: "upgradeTLS", length: 1, }, - open: { - fn: "open", - length: 0, - }, end: { fn: "end", length: 3, diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index 5f99d3792..ed2554dc7 100644 --- a/src/bun.js/bindings/JSSink.cpp +++ b/src/bun.js/bindings/JSSink.cpp @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-07-02T16:19:51.440Z +// Generated by 'make generate-sink' at 2023-07-06T14:22:07.346Z // To regenerate this file, run: // // make generate-sink diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h index 41d7065dc..386554ebb 100644 --- a/src/bun.js/bindings/JSSink.h +++ b/src/bun.js/bindings/JSSink.h @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-07-02T16:19:51.438Z +// Generated by 'make generate-sink' at 2023-07-06T14:22:07.345Z // #pragma once diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp index 866970e4d..b4d672328 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.cpp +++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp @@ -16899,9 +16899,6 @@ JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__listenerGetterWrap); extern "C" JSC::EncodedJSValue TCPSocketPrototype__getLocalPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__localPortGetterWrap); -extern "C" EncodedJSValue TCPSocketPrototype__open(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); -JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__openCallback); - extern "C" JSC::EncodedJSValue TCPSocketPrototype__getReadyState(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__readyStateGetterWrap); @@ -16926,8 +16923,8 @@ JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__timeoutCallback); extern "C" EncodedJSValue TCPSocketPrototype__unref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback); -extern "C" EncodedJSValue TCPSocketPrototype__wrapTLS(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); -JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__wrapTLSCallback); +extern "C" EncodedJSValue TCPSocketPrototype__upgradeTLS(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__upgradeTLSCallback); extern "C" EncodedJSValue TCPSocketPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__writeCallback); @@ -16943,7 +16940,6 @@ static const HashTableValue JSTCPSocketPrototypeTableValues[] = { { "getAuthorizationError"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__getAuthorizationErrorCallback, 0 } }, { "listener"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__listenerGetterWrap, 0 } }, { "localPort"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__localPortGetterWrap, 0 } }, - { "open"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__openCallback, 0 } }, { "readyState"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__readyStateGetterWrap, 0 } }, { "ref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__refCallback, 0 } }, { "reload"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__reloadCallback, 1 } }, @@ -16952,7 +16948,7 @@ static const HashTableValue JSTCPSocketPrototypeTableValues[] = { { "shutdown"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__shutdownCallback, 1 } }, { "timeout"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__timeoutCallback, 1 } }, { "unref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__unrefCallback, 0 } }, - { "wrapTLS"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__wrapTLSCallback, 1 } }, + { "upgradeTLS"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__upgradeTLSCallback, 1 } }, { "write"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__writeCallback, 3 } } }; @@ -17141,33 +17137,6 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__localPortGetterWrap, (JSGlobalObjec RELEASE_AND_RETURN(throwScope, result); } -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__openCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTCPSocket* 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 TCPSocketPrototype__open(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} - JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__readyStateGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { auto& vm = lexicalGlobalObject->vm(); @@ -17373,7 +17342,7 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback, (JSGlobalObject * le return TCPSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); } -JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__wrapTLSCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__upgradeTLSCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { auto& vm = lexicalGlobalObject->vm(); @@ -17397,7 +17366,7 @@ JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__wrapTLSCallback, (JSGlobalObject * } #endif - return TCPSocketPrototype__wrapTLS(thisObject->wrapped(), lexicalGlobalObject, callFrame); + return TCPSocketPrototype__upgradeTLS(thisObject->wrapped(), lexicalGlobalObject, callFrame); } JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) @@ -17615,9 +17584,6 @@ JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__listenerGetterWrap); extern "C" JSC::EncodedJSValue TLSSocketPrototype__getLocalPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__localPortGetterWrap); -extern "C" EncodedJSValue TLSSocketPrototype__open(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); -JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__openCallback); - extern "C" JSC::EncodedJSValue TLSSocketPrototype__getReadyState(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject); JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__readyStateGetterWrap); @@ -17642,8 +17608,8 @@ JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__timeoutCallback); extern "C" EncodedJSValue TLSSocketPrototype__unref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback); -extern "C" EncodedJSValue TLSSocketPrototype__wrapTLS(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); -JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__wrapTLSCallback); +extern "C" EncodedJSValue TLSSocketPrototype__upgradeTLS(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); +JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__upgradeTLSCallback); extern "C" EncodedJSValue TLSSocketPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame); JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__writeCallback); @@ -17659,7 +17625,6 @@ static const HashTableValue JSTLSSocketPrototypeTableValues[] = { { "getAuthorizationError"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__getAuthorizationErrorCallback, 0 } }, { "listener"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__listenerGetterWrap, 0 } }, { "localPort"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__localPortGetterWrap, 0 } }, - { "open"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__openCallback, 0 } }, { "readyState"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__readyStateGetterWrap, 0 } }, { "ref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__refCallback, 0 } }, { "reload"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__reloadCallback, 1 } }, @@ -17668,7 +17633,7 @@ static const HashTableValue JSTLSSocketPrototypeTableValues[] = { { "shutdown"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__shutdownCallback, 1 } }, { "timeout"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__timeoutCallback, 1 } }, { "unref"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__unrefCallback, 0 } }, - { "wrapTLS"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__wrapTLSCallback, 1 } }, + { "upgradeTLS"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__upgradeTLSCallback, 1 } }, { "write"_s, static_cast(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__writeCallback, 3 } } }; @@ -17857,33 +17822,6 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__localPortGetterWrap, (JSGlobalObjec RELEASE_AND_RETURN(throwScope, result); } -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__openCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - auto& vm = lexicalGlobalObject->vm(); - - JSTLSSocket* 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 TLSSocketPrototype__open(thisObject->wrapped(), lexicalGlobalObject, callFrame); -} - JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__readyStateGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { auto& vm = lexicalGlobalObject->vm(); @@ -18089,7 +18027,7 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback, (JSGlobalObject * le return TLSSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame); } -JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__wrapTLSCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__upgradeTLSCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { auto& vm = lexicalGlobalObject->vm(); @@ -18113,7 +18051,7 @@ JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__wrapTLSCallback, (JSGlobalObject * } #endif - return TLSSocketPrototype__wrapTLS(thisObject->wrapped(), lexicalGlobalObject, callFrame); + return TLSSocketPrototype__upgradeTLS(thisObject->wrapped(), lexicalGlobalObject, callFrame); } JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig index a220b6814..171bba792 100644 --- a/src/bun.js/bindings/generated_classes.zig +++ b/src/bun.js/bindings/generated_classes.zig @@ -4449,8 +4449,6 @@ pub const JSTCPSocket = struct { if (@TypeOf(TCPSocket.getLocalPort) != GetterType) @compileLog("Expected TCPSocket.getLocalPort to be a getter"); - if (@TypeOf(TCPSocket.open) != CallbackType) - @compileLog("Expected TCPSocket.open to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.open))); if (@TypeOf(TCPSocket.getReadyState) != GetterType) @compileLog("Expected TCPSocket.getReadyState to be a getter"); @@ -4469,8 +4467,8 @@ pub const JSTCPSocket = struct { @compileLog("Expected TCPSocket.timeout to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.timeout))); if (@TypeOf(TCPSocket.unref) != CallbackType) @compileLog("Expected TCPSocket.unref to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.unref))); - if (@TypeOf(TCPSocket.wrapTLS) != CallbackType) - @compileLog("Expected TCPSocket.wrapTLS to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.wrapTLS))); + if (@TypeOf(TCPSocket.upgradeTLS) != CallbackType) + @compileLog("Expected TCPSocket.upgradeTLS to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.upgradeTLS))); if (@TypeOf(TCPSocket.write) != CallbackType) @compileLog("Expected TCPSocket.write to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.write))); if (!JSC.is_bindgen) { @@ -4486,7 +4484,6 @@ pub const JSTCPSocket = struct { @export(TCPSocket.getReadyState, .{ .name = "TCPSocketPrototype__getReadyState" }); @export(TCPSocket.getRemoteAddress, .{ .name = "TCPSocketPrototype__getRemoteAddress" }); @export(TCPSocket.hasPendingActivity, .{ .name = "TCPSocket__hasPendingActivity" }); - @export(TCPSocket.open, .{ .name = "TCPSocketPrototype__open" }); @export(TCPSocket.ref, .{ .name = "TCPSocketPrototype__ref" }); @export(TCPSocket.reload, .{ .name = "TCPSocketPrototype__reload" }); @export(TCPSocket.setData, .{ .name = "TCPSocketPrototype__setData" }); @@ -4494,7 +4491,7 @@ pub const JSTCPSocket = struct { @export(TCPSocket.shutdown, .{ .name = "TCPSocketPrototype__shutdown" }); @export(TCPSocket.timeout, .{ .name = "TCPSocketPrototype__timeout" }); @export(TCPSocket.unref, .{ .name = "TCPSocketPrototype__unref" }); - @export(TCPSocket.wrapTLS, .{ .name = "TCPSocketPrototype__wrapTLS" }); + @export(TCPSocket.upgradeTLS, .{ .name = "TCPSocketPrototype__upgradeTLS" }); @export(TCPSocket.write, .{ .name = "TCPSocketPrototype__write" }); } } @@ -4617,8 +4614,6 @@ pub const JSTLSSocket = struct { if (@TypeOf(TLSSocket.getLocalPort) != GetterType) @compileLog("Expected TLSSocket.getLocalPort to be a getter"); - if (@TypeOf(TLSSocket.open) != CallbackType) - @compileLog("Expected TLSSocket.open to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.open))); if (@TypeOf(TLSSocket.getReadyState) != GetterType) @compileLog("Expected TLSSocket.getReadyState to be a getter"); @@ -4637,8 +4632,8 @@ pub const JSTLSSocket = struct { @compileLog("Expected TLSSocket.timeout to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.timeout))); if (@TypeOf(TLSSocket.unref) != CallbackType) @compileLog("Expected TLSSocket.unref to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.unref))); - if (@TypeOf(TLSSocket.wrapTLS) != CallbackType) - @compileLog("Expected TLSSocket.wrapTLS to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.wrapTLS))); + if (@TypeOf(TLSSocket.upgradeTLS) != CallbackType) + @compileLog("Expected TLSSocket.upgradeTLS to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.upgradeTLS))); if (@TypeOf(TLSSocket.write) != CallbackType) @compileLog("Expected TLSSocket.write to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.write))); if (!JSC.is_bindgen) { @@ -4654,7 +4649,6 @@ pub const JSTLSSocket = struct { @export(TLSSocket.getReadyState, .{ .name = "TLSSocketPrototype__getReadyState" }); @export(TLSSocket.getRemoteAddress, .{ .name = "TLSSocketPrototype__getRemoteAddress" }); @export(TLSSocket.hasPendingActivity, .{ .name = "TLSSocket__hasPendingActivity" }); - @export(TLSSocket.open, .{ .name = "TLSSocketPrototype__open" }); @export(TLSSocket.ref, .{ .name = "TLSSocketPrototype__ref" }); @export(TLSSocket.reload, .{ .name = "TLSSocketPrototype__reload" }); @export(TLSSocket.setData, .{ .name = "TLSSocketPrototype__setData" }); @@ -4662,7 +4656,7 @@ pub const JSTLSSocket = struct { @export(TLSSocket.shutdown, .{ .name = "TLSSocketPrototype__shutdown" }); @export(TLSSocket.timeout, .{ .name = "TLSSocketPrototype__timeout" }); @export(TLSSocket.unref, .{ .name = "TLSSocketPrototype__unref" }); - @export(TLSSocket.wrapTLS, .{ .name = "TLSSocketPrototype__wrapTLS" }); + @export(TLSSocket.upgradeTLS, .{ .name = "TLSSocketPrototype__upgradeTLS" }); @export(TLSSocket.write, .{ .name = "TLSSocketPrototype__write" }); } } diff --git a/src/deps/uws.zig b/src/deps/uws.zig index c2cd24063..83edbe410 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -40,7 +40,7 @@ pub fn NewSocketHandler(comptime ssl: bool) type { return us_socket_timeout(comptime ssl_int, this.socket, seconds); } - pub fn open(this: ThisSocket, is_client: bool) void { + pub fn startTLS(this: ThisSocket, is_client: bool) void { _ = us_socket_open(comptime ssl_int, this.socket, @intFromBool(is_client), null, 0); } diff --git a/src/js/node/net.js b/src/js/node/net.js index 1b7742dd1..6c690b349 100644 --- a/src/js/node/net.js +++ b/src/js/node/net.js @@ -120,11 +120,16 @@ const Socket = (function (InternalSocket) { socket.ref(); self[bunSocketInternal] = socket; self.connecting = false; - self.emit("connect", self); + if (!self.#upgraded) { + // this is not actually emitted on nodejs when socket used on the connection + // this is already emmited on non-TLS socket and on TLS socket is emmited secureConnect on handshake + self.emit("connect", self); + } Socket.#Drain(socket); }, handshake(socket, success, verifyError) { const { data: self } = socket; + self._securePending = false; self.secureConnecting = false; self._secureEstablished = !!success; @@ -301,6 +306,7 @@ const Socket = (function (InternalSocket) { _parent; _parentWrap; #socket; + #upgraded; constructor(options) { const { socket, signal, write, read, allowHalfOpen = false, ...opts } = options || {}; @@ -314,6 +320,7 @@ const Socket = (function (InternalSocket) { this._parent = this; this._parentWrap = this; this.#pendingRead = undefined; + this.#upgraded = false; if (socket instanceof Socket) { this.#socket = socket; } @@ -442,7 +449,9 @@ const Socket = (function (InternalSocket) { const socket = connection[bunSocketInternal]; if (socket) { - const result = socket.wrapTLS({ + this.connecting = true; + this.#upgraded = true; + const result = socket.upgradeTLS({ data: this, tls, socket: Socket.#Handlers, @@ -453,13 +462,7 @@ const Socket = (function (InternalSocket) { connection[bunSocketInternal] = raw; raw.timeout(raw.timeout); raw.connecting = false; - // set new socket this[bunSocketInternal] = tls; - tls.timeout(tls.timeout); - tls.connecting = true; - this[bunSocketInternal] = socket; - // start tls - tls.open(); } else { this[bunSocketInternal] = null; throw new Error("Invalid socket"); @@ -470,7 +473,9 @@ const Socket = (function (InternalSocket) { const socket = connection[bunSocketInternal]; if (!socket) return; - const result = socket.wrapTLS({ + this.connecting = true; + this.#upgraded = true; + const result = socket.upgradeTLS({ data: this, tls, socket: Socket.#Handlers, @@ -482,13 +487,7 @@ const Socket = (function (InternalSocket) { connection[bunSocketInternal] = raw; raw.timeout(raw.timeout); raw.connecting = false; - // set new socket this[bunSocketInternal] = tls; - tls.timeout(tls.timeout); - tls.connecting = true; - this[bunSocketInternal] = socket; - // start tls - tls.open(); } else { this[bunSocketInternal] = null; throw new Error("Invalid socket"); diff --git a/src/js/out/modules/node/net.js b/src/js/out/modules/node/net.js index c34f86b04..7f3102648 100644 --- a/src/js/out/modules/node/net.js +++ b/src/js/out/modules/node/net.js @@ -62,7 +62,9 @@ var isIPv4 = function(s) { }, open(socket) { const self = socket.data; - socket.timeout(self.timeout), socket.ref(), self[bunSocketInternal] = socket, self.connecting = !1, self.emit("connect", self), Socket2.#Drain(socket); + if (socket.timeout(self.timeout), socket.ref(), self[bunSocketInternal] = socket, self.connecting = !1, !self.#upgraded) + self.emit("connect", self); + Socket2.#Drain(socket); }, handshake(socket, success, verifyError) { const { data: self } = socket; @@ -173,6 +175,7 @@ var isIPv4 = function(s) { _parent; _parentWrap; #socket; + #upgraded; constructor(options) { const { socket, signal, write, read, allowHalfOpen = !1, ...opts } = options || {}; super({ @@ -181,7 +184,7 @@ var isIPv4 = function(s) { readable: !0, writable: !0 }); - if (this._handle = this, this._parent = this, this._parentWrap = this, this.#pendingRead = void 0, socket instanceof Socket2) + if (this._handle = this, this._parent = this, this._parentWrap = this, this.#pendingRead = void 0, this.#upgraded = !1, socket instanceof Socket2) this.#socket = socket; signal?.once("abort", () => this.destroy()), this.once("connect", () => this.emit("ready")); } @@ -256,14 +259,15 @@ var isIPv4 = function(s) { if (connection) { const socket2 = connection[bunSocketInternal]; if (socket2) { - const result = socket2.wrapTLS({ + this.connecting = !0, this.#upgraded = !0; + const result = socket2.upgradeTLS({ data: this, tls, socket: Socket2.#Handlers }); if (result) { const [raw, tls2] = result; - connection[bunSocketInternal] = raw, raw.timeout(raw.timeout), raw.connecting = !1, this[bunSocketInternal] = tls2, tls2.timeout(tls2.timeout), tls2.connecting = !0, this[bunSocketInternal] = socket2, tls2.open(); + connection[bunSocketInternal] = raw, raw.timeout(raw.timeout), raw.connecting = !1, this[bunSocketInternal] = tls2; } else throw this[bunSocketInternal] = null, new Error("Invalid socket"); } else @@ -271,14 +275,15 @@ var isIPv4 = function(s) { const socket3 = connection[bunSocketInternal]; if (!socket3) return; - const result = socket3.wrapTLS({ + this.connecting = !0, this.#upgraded = !0; + const result = socket3.upgradeTLS({ data: this, tls, socket: Socket2.#Handlers }); if (result) { const [raw, tls2] = result; - connection[bunSocketInternal] = raw, raw.timeout(raw.timeout), raw.connecting = !1, this[bunSocketInternal] = tls2, tls2.timeout(tls2.timeout), tls2.connecting = !0, this[bunSocketInternal] = socket3, tls2.open(); + connection[bunSocketInternal] = raw, raw.timeout(raw.timeout), raw.connecting = !1, this[bunSocketInternal] = tls2; } else throw this[bunSocketInternal] = null, new Error("Invalid socket"); }); -- cgit v1.2.3 From a415f482db09ae50474dd8b6258c4e5166e63670 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Thu, 6 Jul 2023 15:33:42 -0700 Subject: Update trustedDeps doc --- docs/cli/install.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/cli/install.md b/docs/cli/install.md index f7b081ba8..c805b14f6 100644 --- a/docs/cli/install.md +++ b/docs/cli/install.md @@ -244,8 +244,18 @@ To tell Bun to allow lifecycle scripts for a particular package, add the package } ``` -Bun reads this field and will run lifecycle scripts for `my-trusted-package`. If you specify a version range, Bun will only execute lifecycle scripts if the resolved package version matches the range. +```json-diff + { + "name": "my-app", + "version": "1.0.0", ++ "trustedDependencies": ["my-trusted-package"] + } +``` +Bun reads this field and will run lifecycle scripts for `my-trusted-package`. + + + ## Git dependencies -- cgit v1.2.3 From d377265b67df34495274ad7be9f8ad1852e3b23b Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Thu, 6 Jul 2023 15:44:48 -0700 Subject: Update trustedDeps doc --- docs/cli/install.md | 4 ++-- packages/bun-types/tests/serve.test-d.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/cli/install.md b/docs/cli/install.md index c805b14f6..584350a42 100644 --- a/docs/cli/install.md +++ b/docs/cli/install.md @@ -234,7 +234,7 @@ Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts for i To tell Bun to allow lifecycle scripts for a particular package, add the package to `trustedDependencies` in your package.json. -```json-diff + ```json-diff { diff --git a/packages/bun-types/tests/serve.test-d.ts b/packages/bun-types/tests/serve.test-d.ts index 4ba3144b8..976466022 100644 --- a/packages/bun-types/tests/serve.test-d.ts +++ b/packages/bun-types/tests/serve.test-d.ts @@ -93,3 +93,13 @@ Bun.serve({ }); export {}; + +Bun.serve({ + port: 1234, + fetch(req, server) { + server.upgrade(req); + if (Math.random() > 0.5) return undefined; + return new Response(); + }, + websocket: { message() {} }, +}); -- cgit v1.2.3 From 038ca83004d43b7943ba141756e51df6b8c279fd Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 6 Jul 2023 16:49:41 -0700 Subject: Add missing export in `url` --- src/js/build-esm.ts | 1 + src/js/node/url.js | 1 + src/js/out/modules/node/url.js | 367 +---------------------------------------- 3 files changed, 3 insertions(+), 366 deletions(-) diff --git a/src/js/build-esm.ts b/src/js/build-esm.ts index b3ece01a1..f3d9feed7 100644 --- a/src/js/build-esm.ts +++ b/src/js/build-esm.ts @@ -20,6 +20,7 @@ const minifyList = [ "node/stream.promises.js", "node/stream.consumers.js", "node/stream.web.js", + "node/url.js", ]; if (fs.existsSync(OUT_DIR + "/modules")) { diff --git a/src/js/node/url.js b/src/js/node/url.js index 9fb1b4374..bb7093bcc 100644 --- a/src/js/node/url.js +++ b/src/js/node/url.js @@ -834,6 +834,7 @@ const defaultObject = { pathToFileURL, fileURLToPath, urlToHttpOptions, + [Symbol.for("CommonJS")]: 0, }; export { diff --git a/src/js/out/modules/node/url.js b/src/js/out/modules/node/url.js index 25172c68f..adff460cf 100644 --- a/src/js/out/modules/node/url.js +++ b/src/js/out/modules/node/url.js @@ -1,366 +1 @@ -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; -}, 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, - gopher: !0, - file: !0, - "http:": !0, - "https:": !0, - "ftp:": !0, - "gopher:": !0, - "file:": !0 -}; -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 proto = protocolPattern.exec(rest); - if (proto) { - proto = proto[0]; - var lowerProto = proto.toLowerCase(); - this.protocol = lowerProto, rest = rest.substr(proto.length); - } - if (slashesDenoteHost || proto || rest.match(/^\/\/[^@/]+@[^@/]+/)) { - var slashes = rest.substr(0, 2) === "//"; - if (slashes && !(proto && hostlessProtocol[proto])) - rest = rest.substr(2), this.slashes = !0; - } - 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 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; - } - 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; - } - } - } - } - 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 (!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 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; -}; -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; -}; -Url.prototype.resolve = function(relative) { - return this.resolveObject(urlParse(relative, !1, !0)).format(); -}; -Url.prototype.resolveObject = function(relative) { - if (typeof relative === "string") { - var rel = new Url; - rel.parse(relative, !1, !0), relative = rel; - } - 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 (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]; - } - if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) - result.pathname = "/", result.path = result.pathname; - return result.href = result.format(), result; - } - 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 result.href = result.format(), result; - } - if (result.protocol = relative.protocol, !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; - 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; - } - mustEndAbs = mustEndAbs && (relPath[0] === "" || srcPath[0] === ""); - } - 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; - } - 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 (!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); - } - if (host) - this.hostname = host; -}; -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 { - urlToHttpOptions, - urlResolveObject as resolveObject, - urlResolve as resolve, - pathToFileURL, - urlParse as parse, - urlFormat as format, - fileURLToPath, - defaultObject as default, - Url, - URLSearchParams, - URL -}; +var $=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},g=function(N,J,f){if(N&&typeof N==="object"&&N instanceof $)return N;var X=new $;return X.parse(N,J,f),X},t=function(N){if(typeof N==="string")N=g(N);if(!(N instanceof $))return $.prototype.format.call(N);return N.format()},ff=function(N,J){return g(N,!1,!0).resolve(J)},Nf=function(N,J){if(!N)return J;return g(N,!1,!0).resolveObject(J)},Bf=function(N){const J={protocol:N.protocol,hostname:typeof N.hostname==="string"&&N.hostname.startsWith("[")?N.hostname.slice(1,-1):N.hostname,hash:N.hash,search:N.search,pathname:N.pathname,path:`${N.pathname||""}${N.search||""}`,href:N.href};if(N.port!=="")J.port=Number(N.port);if(N.username||N.password)J.auth=`${decodeURIComponent(N.username)}:${decodeURIComponent(N.password)}`;return J},{URL:n,URLSearchParams:S}=globalThis,i=/^([a-z0-9.+-]+:)/i,o=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,a=["<",">",'"',"`"," ","\r","\n","\t"],l=["{","}","|","\\","^","`"].concat(a),E=["'"].concat(l),m=["%","/","?",";","#"].concat(E),c=["/","?","#"],s=255,P=/^[+a-z0-9A-Z_-]{0,63}$/,r=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,e={javascript:!0,"javascript:":!0},d={javascript:!0,"javascript:":!0},Q={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};$.prototype.parse=function(N,J,f){if(typeof N!=="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof N);var X=N.indexOf("?"),V=X!==-1&&X127)z+="x";else z+=F[C];if(!z.match(P)){var q=G.slice(0,K),O=G.slice(K+1),L=F.match(r);if(L)q.push(L[1]),O.unshift(L[2]);if(O.length)B="/"+O.join(".")+B;this.hostname=q.join(".");break}}}}if(this.hostname.length>s)this.hostname="";else this.hostname=this.hostname.toLowerCase();if(!R)this.hostname=new n("http://"+this.hostname).hostname;var b=this.port?":"+this.port:"",v=this.hostname||"";if(this.host=v+b,this.href+=this.host,R){if(this.hostname=this.hostname.substr(1,this.hostname.length-2),B[0]!=="/")B="/"+B}}if(!e[I])for(var K=0,M=E.length;K0?f.host.split("@"):!1;if(z)f.auth=z.shift(),f.hostname=z.shift(),f.host=f.hostname}if(f.search=N.search,f.query=N.query,f.pathname!==null||f.search!==null)f.path=(f.pathname?f.pathname:"")+(f.search?f.search:"");return f.href=f.format(),f}if(!G.length){if(f.pathname=null,f.search)f.path="/"+f.search;else f.path=null;return f.href=f.format(),f}var C=G.slice(-1)[0],H=(f.host||N.host||G.length>1)&&(C==="."||C==="..")||C==="",q=0;for(var O=G.length;O>=0;O--)if(C=G[O],C===".")G.splice(O,1);else if(C==="..")G.splice(O,1),q++;else if(q)G.splice(O,1),q--;if(!Z&&!R)for(;q--;q)G.unshift("..");if(Z&&G[0]!==""&&(!G[0]||G[0].charAt(0)!=="/"))G.unshift("");if(H&&G.join("/").substr(-1)!=="/")G.push("");var L=G[0]===""||G[0]&&G[0].charAt(0)==="/";if(F){f.hostname=L?"":G.length?G.shift():"",f.host=f.hostname;var z=f.host&&f.host.indexOf("@")>0?f.host.split("@"):!1;if(z)f.auth=z.shift(),f.hostname=z.shift(),f.host=f.hostname}if(Z=Z||f.host&&G.length,Z&&!L)G.unshift("");if(G.length>0)f.pathname=G.join("/");else f.pathname=null,f.path=null;if(f.pathname!==null||f.search!==null)f.path=(f.pathname?f.pathname:"")+(f.search?f.search:"");return f.auth=N.auth||f.auth,f.slashes=f.slashes||N.slashes,f.href=f.format(),f};$.prototype.parseHost=function(){var N=this.host,J=o.exec(N);if(J){if(J=J[0],J!==":")this.port=J.substr(1);N=N.substr(0,N.length-J.length)}if(N)this.hostname=N};var p=globalThis[Symbol.for("Bun.lazy")],Gf=p("pathToFileURL"),Jf=p("fileURLToPath"),Kf={parse:g,resolve:ff,resolveObject:Nf,format:t,Url:$,URLSearchParams:S,URL:n,pathToFileURL:Gf,fileURLToPath:Jf,urlToHttpOptions:Bf,[Symbol.for("CommonJS")]:0};export{Bf as urlToHttpOptions,Nf as resolveObject,ff as resolve,Gf as pathToFileURL,g as parse,t as format,Jf as fileURLToPath,Kf as default,$ as Url,S as URLSearchParams,n as URL}; -- cgit v1.2.3 From d905dbe2145a1b50584f156f819f392ee689b05d Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 6 Jul 2023 16:50:03 -0700 Subject: Minify zlib because its huge --- src/js/build-esm.ts | 1 + src/js/out/modules/node/zlib.js | 2553 +-------------------------------------- 2 files changed, 2 insertions(+), 2552 deletions(-) diff --git a/src/js/build-esm.ts b/src/js/build-esm.ts index f3d9feed7..edfe7c04f 100644 --- a/src/js/build-esm.ts +++ b/src/js/build-esm.ts @@ -21,6 +21,7 @@ const minifyList = [ "node/stream.consumers.js", "node/stream.web.js", "node/url.js", + "node/zlib.js", ]; if (fs.existsSync(OUT_DIR + "/modules")) { diff --git a/src/js/out/modules/node/zlib.js b/src/js/out/modules/node/zlib.js index ff9ab3f3b..3558e2548 100644 --- a/src/js/out/modules/node/zlib.js +++ b/src/js/out/modules/node/zlib.js @@ -1,2552 +1 @@ -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 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; - } - module2.exports = ZStream; - } -}), require_common = __commonJS({ - "node_modules/pako/lib/utils/common.js"(exports) { - var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined"; - function _has(obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - } - exports.assign = function(obj) { - var sources = Array.prototype.slice.call(arguments, 1); - while (sources.length) { - var source = sources.shift(); - if (!source) - continue; - if (typeof source !== "object") - throw new TypeError(source + "must be non-object"); - for (var p in source) - if (_has(source, p)) - obj[p] = source[p]; - } - return obj; - }, exports.shrinkBuf = function(buf, size) { - if (buf.length === size) - return buf; - if (buf.subarray) - return buf.subarray(0, size); - return buf.length = size, buf; - }; - var fnTyped = { - arraySet: function(dest, src, src_offs, len, dest_offs) { - if (src.subarray && dest.subarray) { - dest.set(src.subarray(src_offs, src_offs + len), dest_offs); - return; - } - for (var i = 0;i < len; i++) - dest[dest_offs + i] = src[src_offs + i]; - }, - flattenChunks: function(chunks) { - var i, l, len, pos, chunk, result; - len = 0; - for (i = 0, l = chunks.length;i < l; i++) - len += chunks[i].length; - result = new Uint8Array(len), pos = 0; - for (i = 0, l = chunks.length;i < l; i++) - chunk = chunks[i], result.set(chunk, pos), pos += chunk.length; - return result; - } - }, fnUntyped = { - arraySet: function(dest, src, src_offs, len, dest_offs) { - for (var i = 0;i < len; i++) - dest[dest_offs + i] = src[src_offs + i]; - }, - flattenChunks: function(chunks) { - return [].concat.apply([], chunks); - } - }; - exports.setTyped = function(on) { - if (on) - exports.Buf8 = Uint8Array, exports.Buf16 = Uint16Array, exports.Buf32 = Int32Array, exports.assign(exports, fnTyped); - else - exports.Buf8 = Array, exports.Buf16 = Array, exports.Buf32 = Array, exports.assign(exports, fnUntyped); - }, exports.setTyped(TYPED_OK); - } -}), require_trees = __commonJS({ - "node_modules/pako/lib/zlib/trees.js"(exports) { - var utils = require_common(), Z_FIXED = 4, Z_BINARY = 0, Z_TEXT = 1, Z_UNKNOWN = 2; - function zero(buf) { - var len = buf.length; - while (--len >= 0) - buf[len] = 0; - } - var STORED_BLOCK = 0, STATIC_TREES = 1, DYN_TREES = 2, MIN_MATCH = 3, MAX_MATCH = 258, LENGTH_CODES = 29, LITERALS = 256, L_CODES = LITERALS + 1 + LENGTH_CODES, D_CODES = 30, BL_CODES = 19, HEAP_SIZE = 2 * L_CODES + 1, MAX_BITS = 15, Buf_size = 16, MAX_BL_BITS = 7, END_BLOCK = 256, REP_3_6 = 16, REPZ_3_10 = 17, REPZ_11_138 = 18, extra_lbits = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], extra_dbits = [ - 0, - 0, - 0, - 0, - 1, - 1, - 2, - 2, - 3, - 3, - 4, - 4, - 5, - 5, - 6, - 6, - 7, - 7, - 8, - 8, - 9, - 9, - 10, - 10, - 11, - 11, - 12, - 12, - 13, - 13 - ], extra_blbits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], DIST_CODE_LEN = 512, static_ltree = new Array((L_CODES + 2) * 2); - zero(static_ltree); - var static_dtree = new Array(D_CODES * 2); - zero(static_dtree); - var _dist_code = new Array(DIST_CODE_LEN); - zero(_dist_code); - var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1); - zero(_length_code); - var base_length = new Array(LENGTH_CODES); - zero(base_length); - var base_dist = new Array(D_CODES); - zero(base_dist); - function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { - this.static_tree = static_tree, this.extra_bits = extra_bits, this.extra_base = extra_base, this.elems = elems, this.max_length = max_length, this.has_stree = static_tree && static_tree.length; - } - var static_l_desc, static_d_desc, static_bl_desc; - function TreeDesc(dyn_tree, stat_desc) { - this.dyn_tree = dyn_tree, this.max_code = 0, this.stat_desc = stat_desc; - } - function d_code(dist) { - return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)]; - } - function put_short(s, w) { - s.pending_buf[s.pending++] = w & 255, s.pending_buf[s.pending++] = w >>> 8 & 255; - } - function send_bits(s, value, length) { - if (s.bi_valid > Buf_size - length) - s.bi_buf |= value << s.bi_valid & 65535, put_short(s, s.bi_buf), s.bi_buf = value >> Buf_size - s.bi_valid, s.bi_valid += length - Buf_size; - else - s.bi_buf |= value << s.bi_valid & 65535, s.bi_valid += length; - } - function send_code(s, c, tree) { - send_bits(s, tree[c * 2], tree[c * 2 + 1]); - } - function bi_reverse(code, len) { - var res = 0; - do - res |= code & 1, code >>>= 1, res <<= 1; - while (--len > 0); - return res >>> 1; - } - function bi_flush(s) { - if (s.bi_valid === 16) - put_short(s, s.bi_buf), s.bi_buf = 0, s.bi_valid = 0; - else if (s.bi_valid >= 8) - s.pending_buf[s.pending++] = s.bi_buf & 255, s.bi_buf >>= 8, s.bi_valid -= 8; - } - function gen_bitlen(s, desc) { - var { dyn_tree: tree, max_code } = desc, stree = desc.stat_desc.static_tree, has_stree = desc.stat_desc.has_stree, extra = desc.stat_desc.extra_bits, base = desc.stat_desc.extra_base, max_length = desc.stat_desc.max_length, h, n, m, bits, xbits, f, overflow = 0; - for (bits = 0;bits <= MAX_BITS; bits++) - s.bl_count[bits] = 0; - tree[s.heap[s.heap_max] * 2 + 1] = 0; - for (h = s.heap_max + 1;h < HEAP_SIZE; h++) { - if (n = s.heap[h], bits = tree[tree[n * 2 + 1] * 2 + 1] + 1, bits > max_length) - bits = max_length, overflow++; - if (tree[n * 2 + 1] = bits, n > max_code) - continue; - if (s.bl_count[bits]++, xbits = 0, n >= base) - xbits = extra[n - base]; - if (f = tree[n * 2], s.opt_len += f * (bits + xbits), has_stree) - s.static_len += f * (stree[n * 2 + 1] + xbits); - } - if (overflow === 0) - return; - do { - bits = max_length - 1; - while (s.bl_count[bits] === 0) - bits--; - s.bl_count[bits]--, s.bl_count[bits + 1] += 2, s.bl_count[max_length]--, overflow -= 2; - } while (overflow > 0); - for (bits = max_length;bits !== 0; bits--) { - n = s.bl_count[bits]; - while (n !== 0) { - if (m = s.heap[--h], m > max_code) - continue; - if (tree[m * 2 + 1] !== bits) - s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2], tree[m * 2 + 1] = bits; - n--; - } - } - } - function gen_codes(tree, max_code, bl_count) { - var next_code = new Array(MAX_BITS + 1), code = 0, bits, n; - for (bits = 1;bits <= MAX_BITS; bits++) - next_code[bits] = code = code + bl_count[bits - 1] << 1; - for (n = 0;n <= max_code; n++) { - var len = tree[n * 2 + 1]; - if (len === 0) - continue; - tree[n * 2] = bi_reverse(next_code[len]++, len); - } - } - function tr_static_init() { - var n, bits, length, code, dist, bl_count = new Array(MAX_BITS + 1); - length = 0; - for (code = 0;code < LENGTH_CODES - 1; code++) { - base_length[code] = length; - for (n = 0;n < 1 << extra_lbits[code]; n++) - _length_code[length++] = code; - } - _length_code[length - 1] = code, dist = 0; - for (code = 0;code < 16; code++) { - base_dist[code] = dist; - for (n = 0;n < 1 << extra_dbits[code]; n++) - _dist_code[dist++] = code; - } - dist >>= 7; - for (;code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0;n < 1 << extra_dbits[code] - 7; n++) - _dist_code[256 + dist++] = code; - } - for (bits = 0;bits <= MAX_BITS; bits++) - bl_count[bits] = 0; - n = 0; - while (n <= 143) - static_ltree[n * 2 + 1] = 8, n++, bl_count[8]++; - while (n <= 255) - static_ltree[n * 2 + 1] = 9, n++, bl_count[9]++; - while (n <= 279) - static_ltree[n * 2 + 1] = 7, n++, bl_count[7]++; - while (n <= 287) - static_ltree[n * 2 + 1] = 8, n++, bl_count[8]++; - gen_codes(static_ltree, L_CODES + 1, bl_count); - for (n = 0;n < D_CODES; n++) - static_dtree[n * 2 + 1] = 5, static_dtree[n * 2] = bi_reverse(n, 5); - static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS), static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS), static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); - } - function init_block(s) { - var n; - for (n = 0;n < L_CODES; n++) - s.dyn_ltree[n * 2] = 0; - for (n = 0;n < D_CODES; n++) - s.dyn_dtree[n * 2] = 0; - for (n = 0;n < BL_CODES; n++) - s.bl_tree[n * 2] = 0; - s.dyn_ltree[END_BLOCK * 2] = 1, s.opt_len = s.static_len = 0, s.last_lit = s.matches = 0; - } - function bi_windup(s) { - if (s.bi_valid > 8) - put_short(s, s.bi_buf); - else if (s.bi_valid > 0) - s.pending_buf[s.pending++] = s.bi_buf; - s.bi_buf = 0, s.bi_valid = 0; - } - function copy_block(s, buf, len, header) { - if (bi_windup(s), header) - put_short(s, len), put_short(s, ~len); - utils.arraySet(s.pending_buf, s.window, buf, len, s.pending), s.pending += len; - } - function smaller(tree, n, m, depth) { - var _n2 = n * 2, _m2 = m * 2; - return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m]; - } - function pqdownheap(s, tree, k) { - var v = s.heap[k], j = k << 1; - while (j <= s.heap_len) { - if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) - j++; - if (smaller(tree, v, s.heap[j], s.depth)) - break; - s.heap[k] = s.heap[j], k = j, j <<= 1; - } - s.heap[k] = v; - } - function compress_block(s, ltree, dtree) { - var dist, lc, lx = 0, code, extra; - if (s.last_lit !== 0) - do - if (dist = s.pending_buf[s.d_buf + lx * 2] << 8 | s.pending_buf[s.d_buf + lx * 2 + 1], lc = s.pending_buf[s.l_buf + lx], lx++, dist === 0) - send_code(s, lc, ltree); - else { - if (code = _length_code[lc], send_code(s, code + LITERALS + 1, ltree), extra = extra_lbits[code], extra !== 0) - lc -= base_length[code], send_bits(s, lc, extra); - if (dist--, code = d_code(dist), send_code(s, code, dtree), extra = extra_dbits[code], extra !== 0) - dist -= base_dist[code], send_bits(s, dist, extra); - } - while (lx < s.last_lit); - send_code(s, END_BLOCK, ltree); - } - function build_tree(s, desc) { - var tree = desc.dyn_tree, stree = desc.stat_desc.static_tree, has_stree = desc.stat_desc.has_stree, elems = desc.stat_desc.elems, n, m, max_code = -1, node; - s.heap_len = 0, s.heap_max = HEAP_SIZE; - for (n = 0;n < elems; n++) - if (tree[n * 2] !== 0) - s.heap[++s.heap_len] = max_code = n, s.depth[n] = 0; - else - tree[n * 2 + 1] = 0; - while (s.heap_len < 2) - if (node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0, tree[node * 2] = 1, s.depth[node] = 0, s.opt_len--, has_stree) - s.static_len -= stree[node * 2 + 1]; - desc.max_code = max_code; - for (n = s.heap_len >> 1;n >= 1; n--) - pqdownheap(s, tree, n); - node = elems; - do - n = s.heap[1], s.heap[1] = s.heap[s.heap_len--], pqdownheap(s, tree, 1), m = s.heap[1], s.heap[--s.heap_max] = n, s.heap[--s.heap_max] = m, tree[node * 2] = tree[n * 2] + tree[m * 2], s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1, tree[n * 2 + 1] = tree[m * 2 + 1] = node, s.heap[1] = node++, pqdownheap(s, tree, 1); - while (s.heap_len >= 2); - s.heap[--s.heap_max] = s.heap[1], gen_bitlen(s, desc), gen_codes(tree, max_code, s.bl_count); - } - function scan_tree(s, tree, max_code) { - var n, prevlen = -1, curlen, nextlen = tree[1], count = 0, max_count = 7, min_count = 4; - if (nextlen === 0) - max_count = 138, min_count = 3; - tree[(max_code + 1) * 2 + 1] = 65535; - for (n = 0;n <= max_code; n++) { - if (curlen = nextlen, nextlen = tree[(n + 1) * 2 + 1], ++count < max_count && curlen === nextlen) - continue; - else if (count < min_count) - s.bl_tree[curlen * 2] += count; - else if (curlen !== 0) { - if (curlen !== prevlen) - s.bl_tree[curlen * 2]++; - s.bl_tree[REP_3_6 * 2]++; - } else if (count <= 10) - s.bl_tree[REPZ_3_10 * 2]++; - else - s.bl_tree[REPZ_11_138 * 2]++; - if (count = 0, prevlen = curlen, nextlen === 0) - max_count = 138, min_count = 3; - else if (curlen === nextlen) - max_count = 6, min_count = 3; - else - max_count = 7, min_count = 4; - } - } - function send_tree(s, tree, max_code) { - var n, prevlen = -1, curlen, nextlen = tree[1], count = 0, max_count = 7, min_count = 4; - if (nextlen === 0) - max_count = 138, min_count = 3; - for (n = 0;n <= max_code; n++) { - if (curlen = nextlen, nextlen = tree[(n + 1) * 2 + 1], ++count < max_count && curlen === nextlen) - continue; - else if (count < min_count) - do - send_code(s, curlen, s.bl_tree); - while (--count !== 0); - else if (curlen !== 0) { - if (curlen !== prevlen) - send_code(s, curlen, s.bl_tree), count--; - send_code(s, REP_3_6, s.bl_tree), send_bits(s, count - 3, 2); - } else if (count <= 10) - send_code(s, REPZ_3_10, s.bl_tree), send_bits(s, count - 3, 3); - else - send_code(s, REPZ_11_138, s.bl_tree), send_bits(s, count - 11, 7); - if (count = 0, prevlen = curlen, nextlen === 0) - max_count = 138, min_count = 3; - else if (curlen === nextlen) - max_count = 6, min_count = 3; - else - max_count = 7, min_count = 4; - } - } - function build_bl_tree(s) { - var max_blindex; - scan_tree(s, s.dyn_ltree, s.l_desc.max_code), scan_tree(s, s.dyn_dtree, s.d_desc.max_code), build_tree(s, s.bl_desc); - for (max_blindex = BL_CODES - 1;max_blindex >= 3; max_blindex--) - if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) - break; - return s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4, max_blindex; - } - function send_all_trees(s, lcodes, dcodes, blcodes) { - var rank; - send_bits(s, lcodes - 257, 5), send_bits(s, dcodes - 1, 5), send_bits(s, blcodes - 4, 4); - for (rank = 0;rank < blcodes; rank++) - send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3); - send_tree(s, s.dyn_ltree, lcodes - 1), send_tree(s, s.dyn_dtree, dcodes - 1); - } - function detect_data_type(s) { - var black_mask = 4093624447, n; - for (n = 0;n <= 31; n++, black_mask >>>= 1) - if (black_mask & 1 && s.dyn_ltree[n * 2] !== 0) - return Z_BINARY; - if (s.dyn_ltree[18] !== 0 || s.dyn_ltree[20] !== 0 || s.dyn_ltree[26] !== 0) - return Z_TEXT; - for (n = 32;n < LITERALS; n++) - if (s.dyn_ltree[n * 2] !== 0) - return Z_TEXT; - return Z_BINARY; - } - var static_init_done = !1; - function _tr_init(s) { - if (!static_init_done) - tr_static_init(), static_init_done = !0; - s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc), s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc), s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc), s.bi_buf = 0, s.bi_valid = 0, init_block(s); - } - function _tr_stored_block(s, buf, stored_len, last) { - send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3), copy_block(s, buf, stored_len, !0); - } - function _tr_align(s) { - send_bits(s, STATIC_TREES << 1, 3), send_code(s, END_BLOCK, static_ltree), bi_flush(s); - } - function _tr_flush_block(s, buf, stored_len, last) { - var opt_lenb, static_lenb, max_blindex = 0; - if (s.level > 0) { - if (s.strm.data_type === Z_UNKNOWN) - s.strm.data_type = detect_data_type(s); - if (build_tree(s, s.l_desc), build_tree(s, s.d_desc), max_blindex = build_bl_tree(s), opt_lenb = s.opt_len + 3 + 7 >>> 3, static_lenb = s.static_len + 3 + 7 >>> 3, static_lenb <= opt_lenb) - opt_lenb = static_lenb; - } else - opt_lenb = static_lenb = stored_len + 5; - if (stored_len + 4 <= opt_lenb && buf !== -1) - _tr_stored_block(s, buf, stored_len, last); - else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) - send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3), compress_block(s, static_ltree, static_dtree); - else - send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3), send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1), compress_block(s, s.dyn_ltree, s.dyn_dtree); - if (init_block(s), last) - bi_windup(s); - } - function _tr_tally(s, dist, lc) { - if (s.pending_buf[s.d_buf + s.last_lit * 2] = dist >>> 8 & 255, s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 255, s.pending_buf[s.l_buf + s.last_lit] = lc & 255, s.last_lit++, dist === 0) - s.dyn_ltree[lc * 2]++; - else - s.matches++, dist--, s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++, s.dyn_dtree[d_code(dist) * 2]++; - return s.last_lit === s.lit_bufsize - 1; - } - exports._tr_init = _tr_init, exports._tr_stored_block = _tr_stored_block, exports._tr_flush_block = _tr_flush_block, exports._tr_tally = _tr_tally, exports._tr_align = _tr_align; - } -}), require_adler32 = __commonJS({ - "node_modules/pako/lib/zlib/adler32.js"(exports, module2) { - function adler32(adler, buf, len, pos) { - var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0; - while (len !== 0) { - n = len > 2000 ? 2000 : len, len -= n; - do - s1 = s1 + buf[pos++] | 0, s2 = s2 + s1 | 0; - while (--n); - s1 %= 65521, s2 %= 65521; - } - return s1 | s2 << 16 | 0; - } - module2.exports = adler32; - } -}), require_crc32 = __commonJS({ - "node_modules/pako/lib/zlib/crc32.js"(exports, module2) { - function makeTable() { - var c, table = []; - for (var n = 0;n < 256; n++) { - c = n; - for (var k = 0;k < 8; k++) - c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1; - table[n] = c; - } - return table; - } - var crcTable = makeTable(); - function crc32(crc, buf, len, pos) { - var t = crcTable, end = pos + len; - crc ^= -1; - for (var i = pos;i < end; i++) - crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255]; - return crc ^ -1; - } - module2.exports = crc32; - } -}), require_messages = __commonJS({ - "node_modules/pako/lib/zlib/messages.js"(exports, module2) { - module2.exports = { - 2: "need dictionary", - 1: "stream end", - 0: "", - "-1": "file error", - "-2": "stream error", - "-3": "data error", - "-4": "insufficient memory", - "-5": "buffer error", - "-6": "incompatible version" - }; - } -}), require_deflate = __commonJS({ - "node_modules/pako/lib/zlib/deflate.js"(exports) { - var utils = require_common(), trees = require_trees(), adler32 = require_adler32(), crc32 = require_crc32(), msg = require_messages(), Z_NO_FLUSH = 0, Z_PARTIAL_FLUSH = 1, Z_FULL_FLUSH = 3, Z_FINISH = 4, Z_BLOCK = 5, Z_OK = 0, Z_STREAM_END = 1, Z_STREAM_ERROR = -2, Z_DATA_ERROR = -3, Z_BUF_ERROR = -5, Z_DEFAULT_COMPRESSION = -1, Z_FILTERED = 1, Z_HUFFMAN_ONLY = 2, Z_RLE = 3, Z_FIXED = 4, Z_DEFAULT_STRATEGY = 0, Z_UNKNOWN = 2, Z_DEFLATED = 8, MAX_MEM_LEVEL = 9, MAX_WBITS = 15, DEF_MEM_LEVEL = 8, LENGTH_CODES = 29, LITERALS = 256, L_CODES = LITERALS + 1 + LENGTH_CODES, D_CODES = 30, BL_CODES = 19, HEAP_SIZE = 2 * L_CODES + 1, MAX_BITS = 15, MIN_MATCH = 3, MAX_MATCH = 258, MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1, PRESET_DICT = 32, INIT_STATE = 42, EXTRA_STATE = 69, NAME_STATE = 73, COMMENT_STATE = 91, HCRC_STATE = 103, BUSY_STATE = 113, FINISH_STATE = 666, BS_NEED_MORE = 1, BS_BLOCK_DONE = 2, BS_FINISH_STARTED = 3, BS_FINISH_DONE = 4, OS_CODE = 3; - function err(strm, errorCode) { - return strm.msg = msg[errorCode], errorCode; - } - function rank(f) { - return (f << 1) - (f > 4 ? 9 : 0); - } - function zero(buf) { - var len = buf.length; - while (--len >= 0) - buf[len] = 0; - } - function flush_pending(strm) { - var s = strm.state, len = s.pending; - if (len > strm.avail_out) - len = strm.avail_out; - if (len === 0) - return; - if (utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out), strm.next_out += len, s.pending_out += len, strm.total_out += len, strm.avail_out -= len, s.pending -= len, s.pending === 0) - s.pending_out = 0; - } - function flush_block_only(s, last) { - trees._tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last), s.block_start = s.strstart, flush_pending(s.strm); - } - function put_byte(s, b) { - s.pending_buf[s.pending++] = b; - } - function putShortMSB(s, b) { - s.pending_buf[s.pending++] = b >>> 8 & 255, s.pending_buf[s.pending++] = b & 255; - } - function read_buf(strm, buf, start, size) { - var len = strm.avail_in; - if (len > size) - len = size; - if (len === 0) - return 0; - if (strm.avail_in -= len, utils.arraySet(buf, strm.input, strm.next_in, len, start), strm.state.wrap === 1) - strm.adler = adler32(strm.adler, buf, len, start); - else if (strm.state.wrap === 2) - strm.adler = crc32(strm.adler, buf, len, start); - return strm.next_in += len, strm.total_in += len, len; - } - function longest_match(s, cur_match) { - var { max_chain_length: chain_length, strstart: scan } = s, match, len, best_len = s.prev_length, nice_match = s.nice_match, limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0, _win = s.window, wmask = s.w_mask, prev = s.prev, strend = s.strstart + MAX_MATCH, scan_end1 = _win[scan + best_len - 1], scan_end = _win[scan + best_len]; - if (s.prev_length >= s.good_match) - chain_length >>= 2; - if (nice_match > s.lookahead) - nice_match = s.lookahead; - do { - if (match = cur_match, _win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) - continue; - scan += 2, match++; - do - ; - while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend); - if (len = MAX_MATCH - (strend - scan), scan = strend - MAX_MATCH, len > best_len) { - if (s.match_start = cur_match, best_len = len, len >= nice_match) - break; - scan_end1 = _win[scan + best_len - 1], scan_end = _win[scan + best_len]; - } - } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0); - if (best_len <= s.lookahead) - return best_len; - return s.lookahead; - } - function fill_window(s) { - var _w_size = s.w_size, p, n, m, more, str; - do { - if (more = s.window_size - s.lookahead - s.strstart, s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) { - utils.arraySet(s.window, s.window, _w_size, _w_size, 0), s.match_start -= _w_size, s.strstart -= _w_size, s.block_start -= _w_size, n = s.hash_size, p = n; - do - m = s.head[--p], s.head[p] = m >= _w_size ? m - _w_size : 0; - while (--n); - n = _w_size, p = n; - do - m = s.prev[--p], s.prev[p] = m >= _w_size ? m - _w_size : 0; - while (--n); - more += _w_size; - } - if (s.strm.avail_in === 0) - break; - if (n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more), s.lookahead += n, s.lookahead + s.insert >= MIN_MATCH) { - str = s.strstart - s.insert, s.ins_h = s.window[str], s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + 1]) & s.hash_mask; - while (s.insert) - if (s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask, s.prev[str & s.w_mask] = s.head[s.ins_h], s.head[s.ins_h] = str, str++, s.insert--, s.lookahead + s.insert < MIN_MATCH) - break; - } - } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0); - } - function deflate_stored(s, flush) { - var max_block_size = 65535; - if (max_block_size > s.pending_buf_size - 5) - max_block_size = s.pending_buf_size - 5; - for (;; ) { - if (s.lookahead <= 1) { - if (fill_window(s), s.lookahead === 0 && flush === Z_NO_FLUSH) - return BS_NEED_MORE; - if (s.lookahead === 0) - break; - } - s.strstart += s.lookahead, s.lookahead = 0; - var max_start = s.block_start + max_block_size; - if (s.strstart === 0 || s.strstart >= max_start) { - if (s.lookahead = s.strstart - max_start, s.strstart = max_start, flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - } - if (s.insert = 0, flush === Z_FINISH) { - if (flush_block_only(s, !0), s.strm.avail_out === 0) - return BS_FINISH_STARTED; - return BS_FINISH_DONE; - } - if (s.strstart > s.block_start) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - return BS_NEED_MORE; - } - function deflate_fast(s, flush) { - var hash_head, bflush; - for (;; ) { - if (s.lookahead < MIN_LOOKAHEAD) { - if (fill_window(s), s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) - return BS_NEED_MORE; - if (s.lookahead === 0) - break; - } - if (hash_head = 0, s.lookahead >= MIN_MATCH) - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask, hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h], s.head[s.ins_h] = s.strstart; - if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) - s.match_length = longest_match(s, hash_head); - if (s.match_length >= MIN_MATCH) - if (bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH), s.lookahead -= s.match_length, s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) { - s.match_length--; - do - s.strstart++, s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask, hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h], s.head[s.ins_h] = s.strstart; - while (--s.match_length !== 0); - s.strstart++; - } else - s.strstart += s.match_length, s.match_length = 0, s.ins_h = s.window[s.strstart], s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + 1]) & s.hash_mask; - else - bflush = trees._tr_tally(s, 0, s.window[s.strstart]), s.lookahead--, s.strstart++; - if (bflush) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - } - if (s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1, flush === Z_FINISH) { - if (flush_block_only(s, !0), s.strm.avail_out === 0) - return BS_FINISH_STARTED; - return BS_FINISH_DONE; - } - if (s.last_lit) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - return BS_BLOCK_DONE; - } - function deflate_slow(s, flush) { - var hash_head, bflush, max_insert; - for (;; ) { - if (s.lookahead < MIN_LOOKAHEAD) { - if (fill_window(s), s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) - return BS_NEED_MORE; - if (s.lookahead === 0) - break; - } - if (hash_head = 0, s.lookahead >= MIN_MATCH) - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask, hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h], s.head[s.ins_h] = s.strstart; - if (s.prev_length = s.match_length, s.prev_match = s.match_start, s.match_length = MIN_MATCH - 1, hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) { - if (s.match_length = longest_match(s, hash_head), s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) - s.match_length = MIN_MATCH - 1; - } - if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) { - max_insert = s.strstart + s.lookahead - MIN_MATCH, bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH), s.lookahead -= s.prev_length - 1, s.prev_length -= 2; - do - if (++s.strstart <= max_insert) - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask, hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h], s.head[s.ins_h] = s.strstart; - while (--s.prev_length !== 0); - if (s.match_available = 0, s.match_length = MIN_MATCH - 1, s.strstart++, bflush) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - } else if (s.match_available) { - if (bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]), bflush) - flush_block_only(s, !1); - if (s.strstart++, s.lookahead--, s.strm.avail_out === 0) - return BS_NEED_MORE; - } else - s.match_available = 1, s.strstart++, s.lookahead--; - } - if (s.match_available) - bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]), s.match_available = 0; - if (s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1, flush === Z_FINISH) { - if (flush_block_only(s, !0), s.strm.avail_out === 0) - return BS_FINISH_STARTED; - return BS_FINISH_DONE; - } - if (s.last_lit) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - return BS_BLOCK_DONE; - } - function deflate_rle(s, flush) { - var bflush, prev, scan, strend, _win = s.window; - for (;; ) { - if (s.lookahead <= MAX_MATCH) { - if (fill_window(s), s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) - return BS_NEED_MORE; - if (s.lookahead === 0) - break; - } - if (s.match_length = 0, s.lookahead >= MIN_MATCH && s.strstart > 0) { - if (scan = s.strstart - 1, prev = _win[scan], prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) { - strend = s.strstart + MAX_MATCH; - do - ; - while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend); - if (s.match_length = MAX_MATCH - (strend - scan), s.match_length > s.lookahead) - s.match_length = s.lookahead; - } - } - if (s.match_length >= MIN_MATCH) - bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH), s.lookahead -= s.match_length, s.strstart += s.match_length, s.match_length = 0; - else - bflush = trees._tr_tally(s, 0, s.window[s.strstart]), s.lookahead--, s.strstart++; - if (bflush) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - } - if (s.insert = 0, flush === Z_FINISH) { - if (flush_block_only(s, !0), s.strm.avail_out === 0) - return BS_FINISH_STARTED; - return BS_FINISH_DONE; - } - if (s.last_lit) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - return BS_BLOCK_DONE; - } - function deflate_huff(s, flush) { - var bflush; - for (;; ) { - if (s.lookahead === 0) { - if (fill_window(s), s.lookahead === 0) { - if (flush === Z_NO_FLUSH) - return BS_NEED_MORE; - break; - } - } - if (s.match_length = 0, bflush = trees._tr_tally(s, 0, s.window[s.strstart]), s.lookahead--, s.strstart++, bflush) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - } - if (s.insert = 0, flush === Z_FINISH) { - if (flush_block_only(s, !0), s.strm.avail_out === 0) - return BS_FINISH_STARTED; - return BS_FINISH_DONE; - } - if (s.last_lit) { - if (flush_block_only(s, !1), s.strm.avail_out === 0) - return BS_NEED_MORE; - } - return BS_BLOCK_DONE; - } - function Config(good_length, max_lazy, nice_length, max_chain, func) { - this.good_length = good_length, this.max_lazy = max_lazy, this.nice_length = nice_length, this.max_chain = max_chain, this.func = func; - } - var configuration_table = [ - new Config(0, 0, 0, 0, deflate_stored), - new Config(4, 4, 8, 4, deflate_fast), - new Config(4, 5, 16, 8, deflate_fast), - new Config(4, 6, 32, 32, deflate_fast), - new Config(4, 4, 16, 16, deflate_slow), - new Config(8, 16, 32, 32, deflate_slow), - new Config(8, 16, 128, 128, deflate_slow), - new Config(8, 32, 128, 256, deflate_slow), - new Config(32, 128, 258, 1024, deflate_slow), - new Config(32, 258, 258, 4096, deflate_slow) - ]; - function lm_init(s) { - s.window_size = 2 * s.w_size, zero(s.head), s.max_lazy_match = configuration_table[s.level].max_lazy, s.good_match = configuration_table[s.level].good_length, s.nice_match = configuration_table[s.level].nice_length, s.max_chain_length = configuration_table[s.level].max_chain, s.strstart = 0, s.block_start = 0, s.lookahead = 0, s.insert = 0, s.match_length = s.prev_length = MIN_MATCH - 1, s.match_available = 0, s.ins_h = 0; - } - function DeflateState() { - this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = Z_DEFLATED, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2), this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2), this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2), zero(this.dyn_ltree), zero(this.dyn_dtree), zero(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new utils.Buf16(MAX_BITS + 1), this.heap = new utils.Buf16(2 * L_CODES + 1), zero(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new utils.Buf16(2 * L_CODES + 1), zero(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; - } - function deflateResetKeep(strm) { - var s; - if (!strm || !strm.state) - return err(strm, Z_STREAM_ERROR); - if (strm.total_in = strm.total_out = 0, strm.data_type = Z_UNKNOWN, s = strm.state, s.pending = 0, s.pending_out = 0, s.wrap < 0) - s.wrap = -s.wrap; - return s.status = s.wrap ? INIT_STATE : BUSY_STATE, strm.adler = s.wrap === 2 ? 0 : 1, s.last_flush = Z_NO_FLUSH, trees._tr_init(s), Z_OK; - } - function deflateReset(strm) { - var ret = deflateResetKeep(strm); - if (ret === Z_OK) - lm_init(strm.state); - return ret; - } - function deflateSetHeader(strm, head) { - if (!strm || !strm.state) - return Z_STREAM_ERROR; - if (strm.state.wrap !== 2) - return Z_STREAM_ERROR; - return strm.state.gzhead = head, Z_OK; - } - function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { - if (!strm) - return Z_STREAM_ERROR; - var wrap = 1; - if (level === Z_DEFAULT_COMPRESSION) - level = 6; - if (windowBits < 0) - wrap = 0, windowBits = -windowBits; - else if (windowBits > 15) - wrap = 2, windowBits -= 16; - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) - return err(strm, Z_STREAM_ERROR); - if (windowBits === 8) - windowBits = 9; - var s = new DeflateState; - return strm.state = s, s.strm = strm, s.wrap = wrap, s.gzhead = null, s.w_bits = windowBits, s.w_size = 1 << s.w_bits, s.w_mask = s.w_size - 1, s.hash_bits = memLevel + 7, s.hash_size = 1 << s.hash_bits, s.hash_mask = s.hash_size - 1, s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH), s.window = new utils.Buf8(s.w_size * 2), s.head = new utils.Buf16(s.hash_size), s.prev = new utils.Buf16(s.w_size), s.lit_bufsize = 1 << memLevel + 6, s.pending_buf_size = s.lit_bufsize * 4, s.pending_buf = new utils.Buf8(s.pending_buf_size), s.d_buf = 1 * s.lit_bufsize, s.l_buf = 3 * s.lit_bufsize, s.level = level, s.strategy = strategy, s.method = method, deflateReset(strm); - } - function deflateInit(strm, level) { - return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); - } - 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; - if (s = strm.state, !strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE && flush !== Z_FINISH) - return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR); - if (s.strm = strm, old_flush = s.last_flush, s.last_flush = flush, s.status === INIT_STATE) - if (s.wrap === 2) - if (strm.adler = 0, put_byte(s, 31), put_byte(s, 139), put_byte(s, 8), !s.gzhead) - put_byte(s, 0), put_byte(s, 0), put_byte(s, 0), put_byte(s, 0), put_byte(s, 0), put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0), put_byte(s, OS_CODE), s.status = BUSY_STATE; - else { - if (put_byte(s, (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)), put_byte(s, s.gzhead.time & 255), put_byte(s, s.gzhead.time >> 8 & 255), put_byte(s, s.gzhead.time >> 16 & 255), put_byte(s, s.gzhead.time >> 24 & 255), put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0), put_byte(s, s.gzhead.os & 255), s.gzhead.extra && s.gzhead.extra.length) - put_byte(s, s.gzhead.extra.length & 255), put_byte(s, s.gzhead.extra.length >> 8 & 255); - if (s.gzhead.hcrc) - strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0); - s.gzindex = 0, s.status = EXTRA_STATE; - } - else { - var header = Z_DEFLATED + (s.w_bits - 8 << 4) << 8, level_flags = -1; - if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) - level_flags = 0; - else if (s.level < 6) - level_flags = 1; - else if (s.level === 6) - level_flags = 2; - else - level_flags = 3; - if (header |= level_flags << 6, s.strstart !== 0) - header |= PRESET_DICT; - if (header += 31 - header % 31, s.status = BUSY_STATE, putShortMSB(s, header), s.strstart !== 0) - putShortMSB(s, strm.adler >>> 16), putShortMSB(s, strm.adler & 65535); - strm.adler = 1; - } - if (s.status === EXTRA_STATE) - if (s.gzhead.extra) { - beg = s.pending; - while (s.gzindex < (s.gzhead.extra.length & 65535)) { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - if (flush_pending(strm), beg = s.pending, s.pending === s.pending_buf_size) - break; - } - put_byte(s, s.gzhead.extra[s.gzindex] & 255), s.gzindex++; - } - if (s.gzhead.hcrc && s.pending > beg) - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - if (s.gzindex === s.gzhead.extra.length) - s.gzindex = 0, s.status = NAME_STATE; - } else - s.status = NAME_STATE; - if (s.status === NAME_STATE) - if (s.gzhead.name) { - beg = s.pending; - do { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - if (flush_pending(strm), beg = s.pending, s.pending === s.pending_buf_size) { - val = 1; - break; - } - } - if (s.gzindex < s.gzhead.name.length) - val = s.gzhead.name.charCodeAt(s.gzindex++) & 255; - else - val = 0; - put_byte(s, val); - } while (val !== 0); - if (s.gzhead.hcrc && s.pending > beg) - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - if (val === 0) - s.gzindex = 0, s.status = COMMENT_STATE; - } else - s.status = COMMENT_STATE; - if (s.status === COMMENT_STATE) - if (s.gzhead.comment) { - beg = s.pending; - do { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - if (flush_pending(strm), beg = s.pending, s.pending === s.pending_buf_size) { - val = 1; - break; - } - } - if (s.gzindex < s.gzhead.comment.length) - val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255; - else - val = 0; - put_byte(s, val); - } while (val !== 0); - if (s.gzhead.hcrc && s.pending > beg) - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - if (val === 0) - s.status = HCRC_STATE; - } else - s.status = HCRC_STATE; - if (s.status === HCRC_STATE) - if (s.gzhead.hcrc) { - if (s.pending + 2 > s.pending_buf_size) - flush_pending(strm); - if (s.pending + 2 <= s.pending_buf_size) - put_byte(s, strm.adler & 255), put_byte(s, strm.adler >> 8 & 255), strm.adler = 0, s.status = BUSY_STATE; - } else - s.status = BUSY_STATE; - if (s.pending !== 0) { - if (flush_pending(strm), strm.avail_out === 0) - return s.last_flush = -1, Z_OK; - } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) - return err(strm, Z_BUF_ERROR); - if (s.status === FINISH_STATE && strm.avail_in !== 0) - return err(strm, Z_BUF_ERROR); - if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH && s.status !== FINISH_STATE) { - var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush); - if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) - s.status = FINISH_STATE; - if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) { - if (strm.avail_out === 0) - s.last_flush = -1; - return Z_OK; - } - if (bstate === BS_BLOCK_DONE) { - if (flush === Z_PARTIAL_FLUSH) - trees._tr_align(s); - else if (flush !== Z_BLOCK) { - if (trees._tr_stored_block(s, 0, 0, !1), flush === Z_FULL_FLUSH) { - if (zero(s.head), s.lookahead === 0) - s.strstart = 0, s.block_start = 0, s.insert = 0; - } - } - if (flush_pending(strm), strm.avail_out === 0) - return s.last_flush = -1, Z_OK; - } - } - if (flush !== Z_FINISH) - return Z_OK; - if (s.wrap <= 0) - return Z_STREAM_END; - if (s.wrap === 2) - put_byte(s, strm.adler & 255), put_byte(s, strm.adler >> 8 & 255), put_byte(s, strm.adler >> 16 & 255), put_byte(s, strm.adler >> 24 & 255), put_byte(s, strm.total_in & 255), put_byte(s, strm.total_in >> 8 & 255), put_byte(s, strm.total_in >> 16 & 255), put_byte(s, strm.total_in >> 24 & 255); - else - putShortMSB(s, strm.adler >>> 16), putShortMSB(s, strm.adler & 65535); - if (flush_pending(strm), s.wrap > 0) - s.wrap = -s.wrap; - return s.pending !== 0 ? Z_OK : Z_STREAM_END; - } - function deflateEnd(strm) { - var status; - if (!strm || !strm.state) - return Z_STREAM_ERROR; - if (status = strm.state.status, status !== INIT_STATE && status !== EXTRA_STATE && status !== NAME_STATE && status !== COMMENT_STATE && status !== HCRC_STATE && status !== BUSY_STATE && status !== FINISH_STATE) - return err(strm, Z_STREAM_ERROR); - return strm.state = null, status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK; - } - function deflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length, s, str, n, wrap, avail, next, input, tmpDict; - if (!strm || !strm.state) - return Z_STREAM_ERROR; - if (s = strm.state, wrap = s.wrap, wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) - return Z_STREAM_ERROR; - if (wrap === 1) - strm.adler = adler32(strm.adler, dictionary, dictLength, 0); - if (s.wrap = 0, dictLength >= s.w_size) { - if (wrap === 0) - zero(s.head), s.strstart = 0, s.block_start = 0, s.insert = 0; - tmpDict = new utils.Buf8(s.w_size), utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0), dictionary = tmpDict, dictLength = s.w_size; - } - avail = strm.avail_in, next = strm.next_in, input = strm.input, strm.avail_in = dictLength, strm.next_in = 0, strm.input = dictionary, fill_window(s); - while (s.lookahead >= MIN_MATCH) { - str = s.strstart, n = s.lookahead - (MIN_MATCH - 1); - do - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask, s.prev[str & s.w_mask] = s.head[s.ins_h], s.head[s.ins_h] = str, str++; - while (--n); - s.strstart = str, s.lookahead = MIN_MATCH - 1, fill_window(s); - } - 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 = 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) { - var BAD = 30, TYPE = 12; - module2.exports = function inflate_fast(strm, start) { - var state, _in, last, _out, beg, end, dmax, wsize, whave, wnext, s_window, hold, bits, lcode, dcode, lmask, dmask, here, op, len, dist, from, from_source, input, output; - state = strm.state, _in = strm.next_in, input = strm.input, last = _in + (strm.avail_in - 5), _out = strm.next_out, output = strm.output, beg = _out - (start - strm.avail_out), end = _out + (strm.avail_out - 257), dmax = state.dmax, wsize = state.wsize, whave = state.whave, wnext = state.wnext, s_window = state.window, hold = state.hold, bits = state.bits, lcode = state.lencode, dcode = state.distcode, lmask = (1 << state.lenbits) - 1, dmask = (1 << state.distbits) - 1; - top: - do { - if (bits < 15) - hold += input[_in++] << bits, bits += 8, hold += input[_in++] << bits, bits += 8; - here = lcode[hold & lmask]; - dolen: - for (;; ) { - if (op = here >>> 24, hold >>>= op, bits -= op, op = here >>> 16 & 255, op === 0) - output[_out++] = here & 65535; - else if (op & 16) { - if (len = here & 65535, op &= 15, op) { - if (bits < op) - hold += input[_in++] << bits, bits += 8; - len += hold & (1 << op) - 1, hold >>>= op, bits -= op; - } - if (bits < 15) - hold += input[_in++] << bits, bits += 8, hold += input[_in++] << bits, bits += 8; - here = dcode[hold & dmask]; - dodist: - for (;; ) { - if (op = here >>> 24, hold >>>= op, bits -= op, op = here >>> 16 & 255, op & 16) { - if (dist = here & 65535, op &= 15, bits < op) { - if (hold += input[_in++] << bits, bits += 8, bits < op) - hold += input[_in++] << bits, bits += 8; - } - if (dist += hold & (1 << op) - 1, dist > dmax) { - strm.msg = "invalid distance too far back", state.mode = BAD; - break top; - } - if (hold >>>= op, bits -= op, op = _out - beg, dist > op) { - if (op = dist - op, op > whave) { - if (state.sane) { - strm.msg = "invalid distance too far back", state.mode = BAD; - break top; - } - } - if (from = 0, from_source = s_window, wnext === 0) { - if (from += wsize - op, op < len) { - len -= op; - do - output[_out++] = s_window[from++]; - while (--op); - from = _out - dist, from_source = output; - } - } else if (wnext < op) { - if (from += wsize + wnext - op, op -= wnext, op < len) { - len -= op; - do - output[_out++] = s_window[from++]; - while (--op); - if (from = 0, wnext < len) { - op = wnext, len -= op; - do - output[_out++] = s_window[from++]; - while (--op); - from = _out - dist, from_source = output; - } - } - } else if (from += wnext - op, op < len) { - len -= op; - do - output[_out++] = s_window[from++]; - while (--op); - from = _out - dist, from_source = output; - } - while (len > 2) - output[_out++] = from_source[from++], output[_out++] = from_source[from++], output[_out++] = from_source[from++], len -= 3; - if (len) { - if (output[_out++] = from_source[from++], len > 1) - output[_out++] = from_source[from++]; - } - } else { - from = _out - dist; - do - output[_out++] = output[from++], output[_out++] = output[from++], output[_out++] = output[from++], len -= 3; - while (len > 2); - if (len) { - if (output[_out++] = output[from++], len > 1) - output[_out++] = output[from++]; - } - } - } else if ((op & 64) === 0) { - here = dcode[(here & 65535) + (hold & (1 << op) - 1)]; - continue dodist; - } else { - strm.msg = "invalid distance code", state.mode = BAD; - break top; - } - break; - } - } else if ((op & 64) === 0) { - here = lcode[(here & 65535) + (hold & (1 << op) - 1)]; - continue dolen; - } else if (op & 32) { - state.mode = TYPE; - break top; - } else { - strm.msg = "invalid literal/length code", state.mode = BAD; - break top; - } - break; - } - } while (_in < last && _out < end); - len = bits >> 3, _in -= len, bits -= len << 3, hold &= (1 << bits) - 1, strm.next_in = _in, strm.next_out = _out, strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last), strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end), state.hold = hold, state.bits = bits; - return; - }; - } -}), require_inftrees = __commonJS({ - "node_modules/pako/lib/zlib/inftrees.js"(exports, module2) { - var utils = require_common(), MAXBITS = 15, ENOUGH_LENS = 852, ENOUGH_DISTS = 592, CODES = 0, LENS = 1, DISTS = 2, lbase = [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 13, - 15, - 17, - 19, - 23, - 27, - 31, - 35, - 43, - 51, - 59, - 67, - 83, - 99, - 115, - 131, - 163, - 195, - 227, - 258, - 0, - 0 - ], lext = [ - 16, - 16, - 16, - 16, - 16, - 16, - 16, - 16, - 17, - 17, - 17, - 17, - 18, - 18, - 18, - 18, - 19, - 19, - 19, - 19, - 20, - 20, - 20, - 20, - 21, - 21, - 21, - 21, - 16, - 72, - 78 - ], dbase = [ - 1, - 2, - 3, - 4, - 5, - 7, - 9, - 13, - 17, - 25, - 33, - 49, - 65, - 97, - 129, - 193, - 257, - 385, - 513, - 769, - 1025, - 1537, - 2049, - 3073, - 4097, - 6145, - 8193, - 12289, - 16385, - 24577, - 0, - 0 - ], dext = [ - 16, - 16, - 16, - 16, - 17, - 17, - 18, - 18, - 19, - 19, - 20, - 20, - 21, - 21, - 22, - 22, - 23, - 23, - 24, - 24, - 25, - 25, - 26, - 26, - 27, - 27, - 28, - 28, - 29, - 29, - 64, - 64 - ]; - module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { - var bits = opts.bits, len = 0, sym = 0, min = 0, max = 0, root = 0, curr = 0, drop = 0, left = 0, used = 0, huff = 0, incr, fill, low, mask, next, base = null, base_index = 0, end, count = new utils.Buf16(MAXBITS + 1), offs = new utils.Buf16(MAXBITS + 1), extra = null, extra_index = 0, here_bits, here_op, here_val; - for (len = 0;len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0;sym < codes; sym++) - count[lens[lens_index + sym]]++; - root = bits; - for (max = MAXBITS;max >= 1; max--) - if (count[max] !== 0) - break; - if (root > max) - root = max; - if (max === 0) - return table[table_index++] = 1 << 24 | 64 << 16 | 0, table[table_index++] = 1 << 24 | 64 << 16 | 0, opts.bits = 1, 0; - for (min = 1;min < max; min++) - if (count[min] !== 0) - break; - if (root < min) - root = min; - left = 1; - for (len = 1;len <= MAXBITS; len++) - if (left <<= 1, left -= count[len], left < 0) - return -1; - if (left > 0 && (type === CODES || max !== 1)) - return -1; - offs[1] = 0; - for (len = 1;len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - for (sym = 0;sym < codes; sym++) - if (lens[lens_index + sym] !== 0) - work[offs[lens[lens_index + sym]]++] = sym; - if (type === CODES) - base = extra = work, end = 19; - else if (type === LENS) - base = lbase, base_index -= 257, extra = lext, extra_index -= 257, end = 256; - else - base = dbase, extra = dext, end = -1; - if (huff = 0, sym = 0, len = min, next = table_index, curr = root, drop = 0, low = -1, used = 1 << root, mask = used - 1, type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) - return 1; - for (;; ) { - if (here_bits = len - drop, work[sym] < end) - here_op = 0, here_val = work[sym]; - else if (work[sym] > end) - here_op = extra[extra_index + work[sym]], here_val = base[base_index + work[sym]]; - else - here_op = 96, here_val = 0; - incr = 1 << len - drop, fill = 1 << curr, min = fill; - do - fill -= incr, table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0; - while (fill !== 0); - incr = 1 << len - 1; - while (huff & incr) - incr >>= 1; - if (incr !== 0) - huff &= incr - 1, huff += incr; - else - huff = 0; - if (sym++, --count[len] === 0) { - if (len === max) - break; - len = lens[lens_index + work[sym]]; - } - if (len > root && (huff & mask) !== low) { - if (drop === 0) - drop = root; - next += min, curr = len - drop, left = 1 << curr; - while (curr + drop < max) { - if (left -= count[curr + drop], left <= 0) - break; - curr++, left <<= 1; - } - if (used += 1 << curr, type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) - return 1; - low = huff & mask, table[low] = root << 24 | curr << 16 | next - table_index | 0; - } - } - if (huff !== 0) - table[next + huff] = len - drop << 24 | 64 << 16 | 0; - return opts.bits = root, 0; - }; - } -}), require_inflate = __commonJS({ - "node_modules/pako/lib/zlib/inflate.js"(exports) { - var utils = require_common(), adler32 = require_adler32(), crc32 = require_crc32(), inflate_fast = require_inffast(), inflate_table = require_inftrees(), CODES = 0, LENS = 1, DISTS = 2, Z_FINISH = 4, Z_BLOCK = 5, Z_TREES = 6, Z_OK = 0, Z_STREAM_END = 1, Z_NEED_DICT = 2, Z_STREAM_ERROR = -2, Z_DATA_ERROR = -3, Z_MEM_ERROR = -4, Z_BUF_ERROR = -5, Z_DEFLATED = 8, HEAD = 1, FLAGS = 2, TIME = 3, OS = 4, EXLEN = 5, EXTRA = 6, NAME = 7, COMMENT = 8, HCRC = 9, DICTID = 10, DICT = 11, TYPE = 12, TYPEDO = 13, STORED = 14, COPY_ = 15, COPY = 16, TABLE = 17, LENLENS = 18, CODELENS = 19, LEN_ = 20, LEN = 21, LENEXT = 22, DIST = 23, DISTEXT = 24, MATCH = 25, LIT = 26, CHECK = 27, LENGTH = 28, DONE = 29, BAD = 30, MEM = 31, SYNC = 32, ENOUGH_LENS = 852, ENOUGH_DISTS = 592, MAX_WBITS = 15, DEF_WBITS = MAX_WBITS; - function zswap32(q) { - return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24); - } - function InflateState() { - this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new utils.Buf16(320), this.work = new utils.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; - } - function inflateResetKeep(strm) { - var state; - if (!strm || !strm.state) - return Z_STREAM_ERROR; - if (state = strm.state, strm.total_in = strm.total_out = state.total = 0, strm.msg = "", state.wrap) - strm.adler = state.wrap & 1; - return state.mode = HEAD, state.last = 0, state.havedict = 0, state.dmax = 32768, state.head = null, state.hold = 0, state.bits = 0, state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS), state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS), state.sane = 1, state.back = -1, Z_OK; - } - function inflateReset(strm) { - var state; - if (!strm || !strm.state) - return Z_STREAM_ERROR; - return state = strm.state, state.wsize = 0, state.whave = 0, state.wnext = 0, inflateResetKeep(strm); - } - function inflateReset2(strm, windowBits) { - var wrap, state; - if (!strm || !strm.state) - return Z_STREAM_ERROR; - if (state = strm.state, windowBits < 0) - wrap = 0, windowBits = -windowBits; - else if (wrap = (windowBits >> 4) + 1, windowBits < 48) - windowBits &= 15; - if (windowBits && (windowBits < 8 || windowBits > 15)) - return Z_STREAM_ERROR; - if (state.window !== null && state.wbits !== windowBits) - state.window = null; - return state.wrap = wrap, state.wbits = windowBits, inflateReset(strm); - } - function inflateInit2(strm, windowBits) { - var ret, state; - if (!strm) - return Z_STREAM_ERROR; - if (state = new InflateState, strm.state = state, state.window = null, ret = inflateReset2(strm, windowBits), ret !== Z_OK) - strm.state = null; - return ret; - } - function inflateInit(strm) { - return inflateInit2(strm, DEF_WBITS); - } - var virgin = !0, lenfix, distfix; - function fixedtables(state) { - if (virgin) { - var sym; - lenfix = new utils.Buf32(512), distfix = new utils.Buf32(32), sym = 0; - while (sym < 144) - state.lens[sym++] = 8; - while (sym < 256) - state.lens[sym++] = 9; - while (sym < 280) - state.lens[sym++] = 7; - while (sym < 288) - state.lens[sym++] = 8; - inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { - bits: 9 - }), sym = 0; - while (sym < 32) - state.lens[sym++] = 5; - inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { - bits: 5 - }), virgin = !1; - } - state.lencode = lenfix, state.lenbits = 9, state.distcode = distfix, state.distbits = 5; - } - function updatewindow(strm, src, end, copy) { - var dist, state = strm.state; - if (state.window === null) - state.wsize = 1 << state.wbits, state.wnext = 0, state.whave = 0, state.window = new utils.Buf8(state.wsize); - if (copy >= state.wsize) - utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0), state.wnext = 0, state.whave = state.wsize; - else { - if (dist = state.wsize - state.wnext, dist > copy) - dist = copy; - if (utils.arraySet(state.window, src, end - copy, dist, state.wnext), copy -= dist, copy) - utils.arraySet(state.window, src, end - copy, copy, 0), state.wnext = copy, state.whave = state.wsize; - else { - if (state.wnext += dist, state.wnext === state.wsize) - state.wnext = 0; - if (state.whave < state.wsize) - state.whave += dist; - } - } - return 0; - } - 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; - if (state = strm.state, state.mode === TYPE) - state.mode = TYPEDO; - put = strm.next_out, output = strm.output, left = strm.avail_out, next = strm.next_in, input = strm.input, have = strm.avail_in, hold = state.hold, bits = state.bits, _in = have, _out = left, ret = Z_OK; - inf_leave: - for (;; ) - switch (state.mode) { - case HEAD: - if (state.wrap === 0) { - state.mode = TYPEDO; - break; - } - while (bits < 16) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (state.wrap & 2 && hold === 35615) { - state.check = 0, hbuf[0] = hold & 255, hbuf[1] = hold >>> 8 & 255, state.check = crc32(state.check, hbuf, 2, 0), hold = 0, bits = 0, state.mode = FLAGS; - break; - } - if (state.flags = 0, state.head) - state.head.done = !1; - if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) { - strm.msg = "incorrect header check", state.mode = BAD; - break; - } - if ((hold & 15) !== Z_DEFLATED) { - strm.msg = "unknown compression method", state.mode = BAD; - break; - } - if (hold >>>= 4, bits -= 4, len = (hold & 15) + 8, state.wbits === 0) - state.wbits = len; - else if (len > state.wbits) { - strm.msg = "invalid window size", state.mode = BAD; - break; - } - state.dmax = 1 << len, strm.adler = state.check = 1, state.mode = hold & 512 ? DICTID : TYPE, hold = 0, bits = 0; - break; - case FLAGS: - while (bits < 16) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (state.flags = hold, (state.flags & 255) !== Z_DEFLATED) { - strm.msg = "unknown compression method", state.mode = BAD; - break; - } - if (state.flags & 57344) { - strm.msg = "unknown header flags set", state.mode = BAD; - break; - } - if (state.head) - state.head.text = hold >> 8 & 1; - if (state.flags & 512) - hbuf[0] = hold & 255, hbuf[1] = hold >>> 8 & 255, state.check = crc32(state.check, hbuf, 2, 0); - hold = 0, bits = 0, state.mode = TIME; - case TIME: - while (bits < 32) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (state.head) - state.head.time = hold; - if (state.flags & 512) - hbuf[0] = hold & 255, hbuf[1] = hold >>> 8 & 255, hbuf[2] = hold >>> 16 & 255, hbuf[3] = hold >>> 24 & 255, state.check = crc32(state.check, hbuf, 4, 0); - hold = 0, bits = 0, state.mode = OS; - case OS: - while (bits < 16) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (state.head) - state.head.xflags = hold & 255, state.head.os = hold >> 8; - if (state.flags & 512) - hbuf[0] = hold & 255, hbuf[1] = hold >>> 8 & 255, state.check = crc32(state.check, hbuf, 2, 0); - hold = 0, bits = 0, state.mode = EXLEN; - case EXLEN: - if (state.flags & 1024) { - while (bits < 16) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (state.length = hold, state.head) - state.head.extra_len = hold; - if (state.flags & 512) - hbuf[0] = hold & 255, hbuf[1] = hold >>> 8 & 255, state.check = crc32(state.check, hbuf, 2, 0); - hold = 0, bits = 0; - } else if (state.head) - state.head.extra = null; - state.mode = EXTRA; - case EXTRA: - if (state.flags & 1024) { - if (copy = state.length, copy > have) - copy = have; - if (copy) { - if (state.head) { - if (len = state.head.extra_len - state.length, !state.head.extra) - state.head.extra = new Array(state.head.extra_len); - utils.arraySet(state.head.extra, input, next, copy, len); - } - if (state.flags & 512) - state.check = crc32(state.check, input, copy, next); - have -= copy, next += copy, state.length -= copy; - } - if (state.length) - break inf_leave; - } - state.length = 0, state.mode = NAME; - case NAME: - if (state.flags & 2048) { - if (have === 0) - break inf_leave; - copy = 0; - do - if (len = input[next + copy++], state.head && len && state.length < 65536) - state.head.name += String.fromCharCode(len); - while (len && copy < have); - if (state.flags & 512) - state.check = crc32(state.check, input, copy, next); - if (have -= copy, next += copy, len) - break inf_leave; - } else if (state.head) - state.head.name = null; - state.length = 0, state.mode = COMMENT; - case COMMENT: - if (state.flags & 4096) { - if (have === 0) - break inf_leave; - copy = 0; - do - if (len = input[next + copy++], state.head && len && state.length < 65536) - state.head.comment += String.fromCharCode(len); - while (len && copy < have); - if (state.flags & 512) - state.check = crc32(state.check, input, copy, next); - if (have -= copy, next += copy, len) - break inf_leave; - } else if (state.head) - state.head.comment = null; - state.mode = HCRC; - case HCRC: - if (state.flags & 512) { - while (bits < 16) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (hold !== (state.check & 65535)) { - strm.msg = "header crc mismatch", state.mode = BAD; - break; - } - hold = 0, bits = 0; - } - if (state.head) - state.head.hcrc = state.flags >> 9 & 1, state.head.done = !0; - strm.adler = state.check = 0, state.mode = TYPE; - break; - case DICTID: - while (bits < 32) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - strm.adler = state.check = zswap32(hold), hold = 0, bits = 0, state.mode = DICT; - case DICT: - if (state.havedict === 0) - return strm.next_out = put, strm.avail_out = left, strm.next_in = next, strm.avail_in = have, state.hold = hold, state.bits = bits, Z_NEED_DICT; - strm.adler = state.check = 1, state.mode = TYPE; - case TYPE: - if (flush === Z_BLOCK || flush === Z_TREES) - break inf_leave; - case TYPEDO: - if (state.last) { - hold >>>= bits & 7, bits -= bits & 7, state.mode = CHECK; - break; - } - while (bits < 3) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - switch (state.last = hold & 1, hold >>>= 1, bits -= 1, hold & 3) { - case 0: - state.mode = STORED; - break; - case 1: - if (fixedtables(state), state.mode = LEN_, flush === Z_TREES) { - hold >>>= 2, bits -= 2; - break inf_leave; - } - break; - case 2: - state.mode = TABLE; - break; - case 3: - strm.msg = "invalid block type", state.mode = BAD; - } - hold >>>= 2, bits -= 2; - break; - case STORED: - hold >>>= bits & 7, bits -= bits & 7; - while (bits < 32) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if ((hold & 65535) !== (hold >>> 16 ^ 65535)) { - strm.msg = "invalid stored block lengths", state.mode = BAD; - break; - } - if (state.length = hold & 65535, hold = 0, bits = 0, state.mode = COPY_, flush === Z_TREES) - break inf_leave; - case COPY_: - state.mode = COPY; - case COPY: - if (copy = state.length, copy) { - if (copy > have) - copy = have; - if (copy > left) - copy = left; - if (copy === 0) - break inf_leave; - utils.arraySet(output, input, next, copy, put), have -= copy, next += copy, left -= copy, put += copy, state.length -= copy; - break; - } - state.mode = TYPE; - break; - case TABLE: - while (bits < 14) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (state.nlen = (hold & 31) + 257, hold >>>= 5, bits -= 5, state.ndist = (hold & 31) + 1, hold >>>= 5, bits -= 5, state.ncode = (hold & 15) + 4, hold >>>= 4, bits -= 4, state.nlen > 286 || state.ndist > 30) { - strm.msg = "too many length or distance symbols", state.mode = BAD; - break; - } - state.have = 0, state.mode = LENLENS; - case LENLENS: - while (state.have < state.ncode) { - while (bits < 3) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - state.lens[order[state.have++]] = hold & 7, hold >>>= 3, bits -= 3; - } - while (state.have < 19) - state.lens[order[state.have++]] = 0; - if (state.lencode = state.lendyn, state.lenbits = 7, opts = { bits: state.lenbits }, ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts), state.lenbits = opts.bits, ret) { - strm.msg = "invalid code lengths set", state.mode = BAD; - break; - } - state.have = 0, state.mode = CODELENS; - case CODELENS: - while (state.have < state.nlen + state.ndist) { - for (;; ) { - if (here = state.lencode[hold & (1 << state.lenbits) - 1], here_bits = here >>> 24, here_op = here >>> 16 & 255, here_val = here & 65535, here_bits <= bits) - break; - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (here_val < 16) - hold >>>= here_bits, bits -= here_bits, state.lens[state.have++] = here_val; - else { - if (here_val === 16) { - n = here_bits + 2; - while (bits < n) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (hold >>>= here_bits, bits -= here_bits, state.have === 0) { - strm.msg = "invalid bit length repeat", state.mode = BAD; - break; - } - len = state.lens[state.have - 1], copy = 3 + (hold & 3), hold >>>= 2, bits -= 2; - } else if (here_val === 17) { - n = here_bits + 3; - while (bits < n) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - hold >>>= here_bits, bits -= here_bits, len = 0, copy = 3 + (hold & 7), hold >>>= 3, bits -= 3; - } else { - n = here_bits + 7; - while (bits < n) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - hold >>>= here_bits, bits -= here_bits, len = 0, copy = 11 + (hold & 127), hold >>>= 7, bits -= 7; - } - if (state.have + copy > state.nlen + state.ndist) { - strm.msg = "invalid bit length repeat", state.mode = BAD; - break; - } - while (copy--) - state.lens[state.have++] = len; - } - } - if (state.mode === BAD) - break; - if (state.lens[256] === 0) { - strm.msg = "invalid code -- missing end-of-block", state.mode = BAD; - break; - } - if (state.lenbits = 9, opts = { bits: state.lenbits }, ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts), state.lenbits = opts.bits, ret) { - strm.msg = "invalid literal/lengths set", state.mode = BAD; - break; - } - if (state.distbits = 6, state.distcode = state.distdyn, opts = { bits: state.distbits }, ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts), state.distbits = opts.bits, ret) { - strm.msg = "invalid distances set", state.mode = BAD; - break; - } - if (state.mode = LEN_, flush === Z_TREES) - break inf_leave; - case LEN_: - state.mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - if (strm.next_out = put, strm.avail_out = left, strm.next_in = next, strm.avail_in = have, state.hold = hold, state.bits = bits, inflate_fast(strm, _out), put = strm.next_out, output = strm.output, left = strm.avail_out, next = strm.next_in, input = strm.input, have = strm.avail_in, hold = state.hold, bits = state.bits, state.mode === TYPE) - state.back = -1; - break; - } - state.back = 0; - for (;; ) { - if (here = state.lencode[hold & (1 << state.lenbits) - 1], here_bits = here >>> 24, here_op = here >>> 16 & 255, here_val = here & 65535, here_bits <= bits) - break; - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (here_op && (here_op & 240) === 0) { - last_bits = here_bits, last_op = here_op, last_val = here_val; - for (;; ) { - if (here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)], here_bits = here >>> 24, here_op = here >>> 16 & 255, here_val = here & 65535, last_bits + here_bits <= bits) - break; - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - hold >>>= last_bits, bits -= last_bits, state.back += last_bits; - } - if (hold >>>= here_bits, bits -= here_bits, state.back += here_bits, state.length = here_val, here_op === 0) { - state.mode = LIT; - break; - } - if (here_op & 32) { - state.back = -1, state.mode = TYPE; - break; - } - if (here_op & 64) { - strm.msg = "invalid literal/length code", state.mode = BAD; - break; - } - state.extra = here_op & 15, state.mode = LENEXT; - case LENEXT: - if (state.extra) { - n = state.extra; - while (bits < n) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - state.length += hold & (1 << state.extra) - 1, hold >>>= state.extra, bits -= state.extra, state.back += state.extra; - } - state.was = state.length, state.mode = DIST; - case DIST: - for (;; ) { - if (here = state.distcode[hold & (1 << state.distbits) - 1], here_bits = here >>> 24, here_op = here >>> 16 & 255, here_val = here & 65535, here_bits <= bits) - break; - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if ((here_op & 240) === 0) { - last_bits = here_bits, last_op = here_op, last_val = here_val; - for (;; ) { - if (here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)], here_bits = here >>> 24, here_op = here >>> 16 & 255, here_val = here & 65535, last_bits + here_bits <= bits) - break; - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - hold >>>= last_bits, bits -= last_bits, state.back += last_bits; - } - if (hold >>>= here_bits, bits -= here_bits, state.back += here_bits, here_op & 64) { - strm.msg = "invalid distance code", state.mode = BAD; - break; - } - state.offset = here_val, state.extra = here_op & 15, state.mode = DISTEXT; - case DISTEXT: - if (state.extra) { - n = state.extra; - while (bits < n) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - state.offset += hold & (1 << state.extra) - 1, hold >>>= state.extra, bits -= state.extra, state.back += state.extra; - } - if (state.offset > state.dmax) { - strm.msg = "invalid distance too far back", state.mode = BAD; - break; - } - state.mode = MATCH; - case MATCH: - if (left === 0) - break inf_leave; - if (copy = _out - left, state.offset > copy) { - if (copy = state.offset - copy, copy > state.whave) { - if (state.sane) { - strm.msg = "invalid distance too far back", state.mode = BAD; - break; - } - } - if (copy > state.wnext) - copy -= state.wnext, from = state.wsize - copy; - else - from = state.wnext - copy; - if (copy > state.length) - copy = state.length; - from_source = state.window; - } else - from_source = output, from = put - state.offset, copy = state.length; - if (copy > left) - copy = left; - left -= copy, state.length -= copy; - do - output[put++] = from_source[from++]; - while (--copy); - if (state.length === 0) - state.mode = LEN; - break; - case LIT: - if (left === 0) - break inf_leave; - output[put++] = state.length, left--, state.mode = LEN; - break; - case CHECK: - if (state.wrap) { - while (bits < 32) { - if (have === 0) - break inf_leave; - have--, hold |= input[next++] << bits, bits += 8; - } - if (_out -= left, strm.total_out += _out, state.total += _out, _out) - strm.adler = state.check = state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out); - if (_out = left, (state.flags ? hold : zswap32(hold)) !== state.check) { - strm.msg = "incorrect data check", state.mode = BAD; - break; - } - hold = 0, bits = 0; - } - state.mode = LENGTH; - case LENGTH: - if (state.wrap && state.flags) { - while (bits < 32) { - if (have === 0) - break inf_leave; - have--, hold += input[next++] << bits, bits += 8; - } - if (hold !== (state.total & 4294967295)) { - strm.msg = "incorrect length check", state.mode = BAD; - break; - } - hold = 0, bits = 0; - } - state.mode = DONE; - case DONE: - ret = Z_STREAM_END; - break inf_leave; - case BAD: - ret = Z_DATA_ERROR; - break inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - if (strm.next_out = put, strm.avail_out = left, strm.next_in = next, strm.avail_in = have, state.hold = hold, state.bits = bits, state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) { - if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) - return state.mode = MEM, Z_MEM_ERROR; - } - if (_in -= strm.avail_in, _out -= strm.avail_out, strm.total_in += _in, strm.total_out += _out, state.total += _out, state.wrap && _out) - strm.adler = state.check = state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out); - if (strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0), (_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) - ret = Z_BUF_ERROR; - return ret; - } - function inflateEnd(strm) { - if (!strm || !strm.state) - return Z_STREAM_ERROR; - var state = strm.state; - if (state.window) - state.window = null; - return strm.state = null, Z_OK; - } - function inflateGetHeader(strm, head) { - var state; - if (!strm || !strm.state) - return Z_STREAM_ERROR; - if (state = strm.state, (state.wrap & 2) === 0) - return Z_STREAM_ERROR; - return state.head = head, head.done = !1, Z_OK; - } - function inflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length, state, dictid, ret; - if (!strm || !strm.state) - return Z_STREAM_ERROR; - if (state = strm.state, state.wrap !== 0 && state.mode !== DICT) - return Z_STREAM_ERROR; - if (state.mode === DICT) { - if (dictid = 1, dictid = adler32(dictid, dictionary, dictLength, 0), dictid !== state.check) - return Z_DATA_ERROR; - } - if (ret = updatewindow(strm, dictionary, dictLength, dictLength), ret) - 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 = 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) { - module2.exports = { - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - Z_BUF_ERROR: -5, - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - Z_BINARY: 0, - Z_TEXT: 1, - Z_UNKNOWN: 2, - Z_DEFLATED: 8 - }; - } -}), require_binding = __commonJS({ - "node_modules/browserify-zlib/lib/binding.js"(exports) { - 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; - function Zlib(mode) { - if (typeof mode !== "number" || mode < exports.DEFLATE || mode > exports.UNZIP) - throw new TypeError("Bad argument"); - this.dictionary = null, this.err = 0, this.flush = 0, this.init_done = !1, this.level = 0, this.memLevel = 0, this.mode = mode, this.strategy = 0, this.windowBits = 0, this.write_in_progress = !1, this.pending_close = !1, this.gzip_id_bytes_read = 0; - } - Zlib.prototype.close = function() { - if (this.write_in_progress) { - this.pending_close = !0; - return; - } - if (this.pending_close = !1, assert(this.init_done, "close before init"), assert(this.mode <= exports.UNZIP), this.mode === exports.DEFLATE || this.mode === exports.GZIP || this.mode === exports.DEFLATERAW) - zlib_deflate.deflateEnd(this.strm); - else if (this.mode === exports.INFLATE || this.mode === exports.GUNZIP || this.mode === exports.INFLATERAW || this.mode === exports.UNZIP) - zlib_inflate.inflateEnd(this.strm); - this.mode = exports.NONE, this.dictionary = null; - }, Zlib.prototype.write = function(flush, input, in_off, in_len, out, out_off, out_len) { - return this._write(!0, flush, input, in_off, in_len, out, out_off, out_len); - }, Zlib.prototype.writeSync = function(flush, input, in_off, in_len, out, out_off, out_len) { - return this._write(!1, flush, input, in_off, in_len, out, out_off, out_len); - }, Zlib.prototype._write = function(async, flush, input, in_off, in_len, out, out_off, out_len) { - if (assert.equal(arguments.length, 8), assert(this.init_done, "write before init"), assert(this.mode !== exports.NONE, "already finalized"), assert.equal(!1, this.write_in_progress, "write already in progress"), assert.equal(!1, this.pending_close, "close is pending"), this.write_in_progress = !0, assert.equal(!1, flush === void 0, "must provide flush value"), this.write_in_progress = !0, flush !== exports.Z_NO_FLUSH && flush !== exports.Z_PARTIAL_FLUSH && flush !== exports.Z_SYNC_FLUSH && flush !== exports.Z_FULL_FLUSH && flush !== exports.Z_FINISH && flush !== exports.Z_BLOCK) - throw new Error("Invalid flush value"); - if (input == null) - input = Buffer.alloc(0), in_len = 0, in_off = 0; - if (this.strm.avail_in = in_len, this.strm.input = input, this.strm.next_in = in_off, this.strm.avail_out = out_len, this.strm.output = out, this.strm.next_out = out_off, this.flush = flush, !async) { - if (this._process(), this._checkError()) - return this._afterSync(); - return; - } - var self = this; - return process.nextTick(function() { - self._process(), self._after(); - }), this; - }, Zlib.prototype._afterSync = function() { - var avail_out = this.strm.avail_out, avail_in = this.strm.avail_in; - return this.write_in_progress = !1, [avail_in, avail_out]; - }, Zlib.prototype._process = function() { - var next_expected_header_byte = null; - switch (this.mode) { - case exports.DEFLATE: - case exports.GZIP: - case exports.DEFLATERAW: - this.err = zlib_deflate.deflate(this.strm, this.flush); - break; - case exports.UNZIP: - if (this.strm.avail_in > 0) - next_expected_header_byte = this.strm.next_in; - switch (this.gzip_id_bytes_read) { - case 0: - if (next_expected_header_byte === null) - break; - if (this.strm.input[next_expected_header_byte] === GZIP_HEADER_ID1) { - if (this.gzip_id_bytes_read = 1, next_expected_header_byte++, this.strm.avail_in === 1) - break; - } else { - this.mode = exports.INFLATE; - break; - } - case 1: - if (next_expected_header_byte === null) - break; - if (this.strm.input[next_expected_header_byte] === GZIP_HEADER_ID2) - this.gzip_id_bytes_read = 2, this.mode = exports.GUNZIP; - else - this.mode = exports.INFLATE; - break; - default: - throw new Error("invalid number of gzip magic number bytes read"); - } - case exports.INFLATE: - case exports.GUNZIP: - case exports.INFLATERAW: - if (this.err = zlib_inflate.inflate(this.strm, this.flush), this.err === exports.Z_NEED_DICT && this.dictionary) { - if (this.err = zlib_inflate.inflateSetDictionary(this.strm, this.dictionary), this.err === exports.Z_OK) - this.err = zlib_inflate.inflate(this.strm, this.flush); - else if (this.err === exports.Z_DATA_ERROR) - this.err = exports.Z_NEED_DICT; - } - while (this.strm.avail_in > 0 && this.mode === exports.GUNZIP && this.err === exports.Z_STREAM_END && this.strm.next_in[0] !== 0) - this.reset(), this.err = zlib_inflate.inflate(this.strm, this.flush); - break; - default: - throw new Error("Unknown mode " + this.mode); - } - }, Zlib.prototype._checkError = function() { - switch (this.err) { - case exports.Z_OK: - case exports.Z_BUF_ERROR: - if (this.strm.avail_out !== 0 && this.flush === exports.Z_FINISH) - return this._error("unexpected end of file"), !1; - break; - case exports.Z_STREAM_END: - break; - case exports.Z_NEED_DICT: - if (this.dictionary == null) - this._error("Missing dictionary"); - else - this._error("Bad dictionary"); - return !1; - default: - return this._error("Zlib error"), !1; - } - return !0; - }, Zlib.prototype._after = function() { - if (!this._checkError()) - return; - var avail_out = this.strm.avail_out, avail_in = this.strm.avail_in; - if (this.write_in_progress = !1, this.callback(avail_in, avail_out), this.pending_close) - this.close(); - }, Zlib.prototype._error = function(message) { - if (this.strm.msg) - message = this.strm.msg; - if (this.onerror(message, this.err), this.write_in_progress = !1, this.pending_close) - this.close(); - }, Zlib.prototype.init = function(windowBits, level, memLevel, strategy, dictionary) { - assert(arguments.length === 4 || arguments.length === 5, "init(windowBits, level, memLevel, strategy, [dictionary])"), assert(windowBits >= 8 && windowBits <= 15, "invalid windowBits"), assert(level >= -1 && level <= 9, "invalid compression level"), assert(memLevel >= 1 && memLevel <= 9, "invalid memlevel"), assert(strategy === exports.Z_FILTERED || strategy === exports.Z_HUFFMAN_ONLY || strategy === exports.Z_RLE || strategy === exports.Z_FIXED || strategy === exports.Z_DEFAULT_STRATEGY, "invalid strategy"), this._init(level, windowBits, memLevel, strategy, dictionary), this._setDictionary(); - }, Zlib.prototype.params = function() { - throw new Error("deflateParams Not supported"); - }, Zlib.prototype.reset = function() { - this._reset(), this._setDictionary(); - }, Zlib.prototype._init = function(level, windowBits, memLevel, strategy, dictionary) { - if (this.level = level, this.windowBits = windowBits, this.memLevel = memLevel, this.strategy = strategy, this.flush = exports.Z_NO_FLUSH, this.err = exports.Z_OK, this.mode === exports.GZIP || this.mode === exports.GUNZIP) - this.windowBits += 16; - if (this.mode === exports.UNZIP) - this.windowBits += 32; - if (this.mode === exports.DEFLATERAW || this.mode === exports.INFLATERAW) - this.windowBits = -1 * this.windowBits; - switch (this.strm = new Zstream, this.mode) { - case exports.DEFLATE: - case exports.GZIP: - case exports.DEFLATERAW: - this.err = zlib_deflate.deflateInit2(this.strm, this.level, exports.Z_DEFLATED, this.windowBits, this.memLevel, this.strategy); - break; - case exports.INFLATE: - case exports.GUNZIP: - case exports.INFLATERAW: - case exports.UNZIP: - this.err = zlib_inflate.inflateInit2(this.strm, this.windowBits); - break; - default: - throw new Error("Unknown mode " + this.mode); - } - if (this.err !== exports.Z_OK) - this._error("Init error"); - this.dictionary = dictionary, this.write_in_progress = !1, this.init_done = !0; - }, Zlib.prototype._setDictionary = function() { - if (this.dictionary == null) - return; - switch (this.err = exports.Z_OK, this.mode) { - case exports.DEFLATE: - case exports.DEFLATERAW: - this.err = zlib_deflate.deflateSetDictionary(this.strm, this.dictionary); - break; - default: - break; - } - if (this.err !== exports.Z_OK) - this._error("Failed to set dictionary"); - }, Zlib.prototype._reset = function() { - switch (this.err = exports.Z_OK, this.mode) { - case exports.DEFLATE: - case exports.DEFLATERAW: - case exports.GZIP: - this.err = zlib_deflate.deflateReset(this.strm); - break; - case exports.INFLATE: - case exports.INFLATERAW: - case exports.GUNZIP: - this.err = zlib_inflate.inflateReset(this.strm); - break; - default: - break; - } - if (this.err !== exports.Z_OK) - this._error("Failed to reset stream"); - }, exports.Zlib = Zlib; - } -}), require_lib = __commonJS({ - "node_modules/browserify-zlib/lib/index.js"(exports) { - 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++) - if (bkey = bkeys[bk], bkey.match(/^Z/)) - Object.defineProperty(exports, bkey, { - enumerable: !0, - value: binding[bkey], - writable: !1 - }); - var bkey, bk, codes = { - Z_OK: binding.Z_OK, - Z_STREAM_END: binding.Z_STREAM_END, - Z_NEED_DICT: binding.Z_NEED_DICT, - Z_ERRNO: binding.Z_ERRNO, - Z_STREAM_ERROR: binding.Z_STREAM_ERROR, - Z_DATA_ERROR: binding.Z_DATA_ERROR, - Z_MEM_ERROR: binding.Z_MEM_ERROR, - Z_BUF_ERROR: binding.Z_BUF_ERROR, - Z_VERSION_ERROR: binding.Z_VERSION_ERROR - }, ckeys = Object.keys(codes); - for (ck = 0;ck < ckeys.length; ck++) - ckey = ckeys[ck], codes[codes[ckey]] = ckey; - var ckey, ck; - Object.defineProperty(exports, "codes", { - enumerable: !0, - value: Object.freeze(codes), - writable: !1 - }), 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 Inflate2(o); - }, exports.createDeflateRaw = function(o) { - return new DeflateRaw2(o); - }, exports.createInflateRaw = function(o) { - return new InflateRaw2(o); - }, exports.createGzip = function(o) { - return new Gzip2(o); - }, exports.createGunzip = function(o) { - return new Gunzip2(o); - }, exports.createUnzip = function(o) { - return new Unzip2(o); - }, exports.deflate = function(buffer, opts, callback) { - if (typeof opts === "function") - callback = opts, opts = {}; - return zlibBuffer(new Deflate2(opts), buffer, callback); - }, exports.deflateSync = function(buffer, opts) { - return zlibBufferSync(new Deflate2(opts), buffer); - }, exports.gzip = function(buffer, opts, callback) { - if (typeof opts === "function") - callback = opts, opts = {}; - return zlibBuffer(new Gzip2(opts), buffer, callback); - }, exports.gzipSync = function(buffer, opts) { - return zlibBufferSync(new Gzip2(opts), buffer); - }, exports.deflateRaw = function(buffer, opts, callback) { - if (typeof opts === "function") - callback = opts, opts = {}; - return zlibBuffer(new DeflateRaw2(opts), buffer, callback); - }, exports.deflateRawSync = function(buffer, opts) { - return zlibBufferSync(new DeflateRaw2(opts), buffer); - }, exports.unzip = function(buffer, opts, callback) { - if (typeof opts === "function") - callback = opts, opts = {}; - return zlibBuffer(new Unzip2(opts), buffer, callback); - }, exports.unzipSync = function(buffer, opts) { - return zlibBufferSync(new Unzip2(opts), buffer); - }, exports.inflate = function(buffer, opts, callback) { - if (typeof opts === "function") - callback = opts, opts = {}; - return zlibBuffer(new Inflate2(opts), buffer, callback); - }, exports.inflateSync = function(buffer, opts) { - return zlibBufferSync(new Inflate2(opts), buffer); - }, exports.gunzip = function(buffer, opts, callback) { - if (typeof opts === "function") - callback = opts, opts = {}; - return zlibBuffer(new Gunzip2(opts), buffer, callback); - }, exports.gunzipSync = function(buffer, opts) { - return zlibBufferSync(new Gunzip2(opts), buffer); - }, exports.inflateRaw = function(buffer, opts, callback) { - if (typeof opts === "function") - callback = opts, opts = {}; - return zlibBuffer(new InflateRaw2(opts), buffer, callback); - }, exports.inflateRawSync = function(buffer, opts) { - return zlibBufferSync(new InflateRaw2(opts), buffer); - }; - function zlibBuffer(engine, buffer, callback) { - var buffers = [], nread = 0; - engine.on("error", onError), engine.on("end", onEnd), engine.end(buffer), flow(); - function flow() { - var chunk; - while ((chunk = engine.read()) !== null) - buffers.push(chunk), nread += chunk.length; - engine.once("readable", flow); - } - function onError(err) { - engine.removeListener("end", onEnd), engine.removeListener("readable", flow), callback(err); - } - function onEnd() { - var buf, err = null; - if (nread >= kMaxLength2) - err = new RangeError(kRangeErrorMessage); - else - buf = Buffer22.concat(buffers, nread); - buffers = [], engine.close(), callback(err, buf); - } - } - function zlibBufferSync(engine, buffer) { - if (typeof buffer === "string") - 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 Deflate2(opts) { - if (!(this instanceof Deflate2)) - return new Deflate2(opts); - Zlib.call(this, opts, binding.DEFLATE); - } - function Inflate2(opts) { - if (!(this instanceof Inflate2)) - return new Inflate2(opts); - Zlib.call(this, opts, binding.INFLATE); - } - function Gzip2(opts) { - if (!(this instanceof Gzip2)) - return new Gzip2(opts); - Zlib.call(this, opts, binding.GZIP); - } - function Gunzip2(opts) { - if (!(this instanceof Gunzip2)) - return new Gunzip2(opts); - Zlib.call(this, opts, binding.GUNZIP); - } - function DeflateRaw2(opts) { - if (!(this instanceof DeflateRaw2)) - return new DeflateRaw2(opts); - Zlib.call(this, opts, binding.DEFLATERAW); - } - function InflateRaw2(opts) { - if (!(this instanceof InflateRaw2)) - return new InflateRaw2(opts); - Zlib.call(this, opts, binding.INFLATERAW); - } - function Unzip2(opts) { - if (!(this instanceof Unzip2)) - return new Unzip2(opts); - Zlib.call(this, opts, binding.UNZIP); - } - function isValidFlushFlag(flag) { - return flag === binding.Z_NO_FLUSH || flag === binding.Z_PARTIAL_FLUSH || flag === binding.Z_SYNC_FLUSH || flag === binding.Z_FULL_FLUSH || flag === binding.Z_FINISH || flag === binding.Z_BLOCK; - } - function Zlib(opts, mode) { - var _this = this; - 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); - if (this._flushFlag = opts.flush || binding.Z_NO_FLUSH, this._finishFlushFlag = typeof opts.finishFlush !== "undefined" ? opts.finishFlush : binding.Z_FINISH, opts.chunkSize) { - if (opts.chunkSize < exports.Z_MIN_CHUNK || opts.chunkSize > exports.Z_MAX_CHUNK) - throw new Error("Invalid chunk size: " + opts.chunkSize); - } - if (opts.windowBits) { - if (opts.windowBits < exports.Z_MIN_WINDOWBITS || opts.windowBits > exports.Z_MAX_WINDOWBITS) - throw new Error("Invalid windowBits: " + opts.windowBits); - } - if (opts.level) { - if (opts.level < exports.Z_MIN_LEVEL || opts.level > exports.Z_MAX_LEVEL) - throw new Error("Invalid compression level: " + opts.level); - } - if (opts.memLevel) { - if (opts.memLevel < exports.Z_MIN_MEMLEVEL || opts.memLevel > exports.Z_MAX_MEMLEVEL) - throw new Error("Invalid memLevel: " + opts.memLevel); - } - if (opts.strategy) { - if (opts.strategy != exports.Z_FILTERED && opts.strategy != exports.Z_HUFFMAN_ONLY && opts.strategy != exports.Z_RLE && opts.strategy != exports.Z_FIXED && opts.strategy != exports.Z_DEFAULT_STRATEGY) - throw new Error("Invalid strategy: " + opts.strategy); - } - if (opts.dictionary) { - if (!Buffer22.isBuffer(opts.dictionary)) - throw new Error("Invalid dictionary: it should be a Buffer instance"); - } - this._handle = new binding.Zlib(mode); - var self = this; - this._hadError = !1, this._handle.onerror = function(message, errno) { - _close(self), self._hadError = !0; - var error = new Error(message); - error.errno = errno, error.code = exports.codes[errno], self.emit("error", error); - }; - var level = exports.Z_DEFAULT_COMPRESSION; - if (typeof opts.level === "number") - level = opts.level; - 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 = 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; - }, - configurable: !0, - enumerable: !0 - }); - } - 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) - throw new TypeError("Invalid strategy: " + strategy); - if (this._level !== level || this._strategy !== strategy) { - var self = this; - this.flush(binding.Z_SYNC_FLUSH, function() { - if (assert2(self._handle, "zlib binding closed"), self._handle.params(level, strategy), !self._hadError) { - if (self._level = level, self._strategy = strategy, callback) - callback(); - } - }); - } else - process.nextTick(callback); - }, Zlib.prototype.reset = function() { - return assert2(this._handle, "zlib binding closed"), this._handle.reset(); - }, Zlib.prototype._flush = function(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) - callback = kind, kind = binding.Z_FULL_FLUSH; - if (ws.ended) { - if (callback) - process.nextTick(callback); - } else if (ws.ending) { - if (callback) - this.once("end", callback); - } else if (ws.needDrain) { - if (callback) - this.once("drain", function() { - return _this2.flush(kind, callback); - }); - } else - this._flushFlag = kind, this.write(Buffer22.alloc(0), "", callback); - }, Zlib.prototype.close = function(callback) { - _close(this, callback), process.nextTick(emitCloseNT, this); - }; - function _close(engine, callback) { - if (callback) - process.nextTick(callback); - if (!engine._handle) - return; - engine._handle.close(), engine._handle = null; - } - function emitCloseNT(self) { - self.emit("close"); - } - 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 && !Buffer22.isBuffer(chunk)) - return cb(new Error("invalid input")); - if (!this._handle) - return cb(new Error("zlib binding closed")); - if (last) - flushFlag = this._finishFlushFlag; - else if (flushFlag = this._flushFlag, chunk.length >= ws.length) - this._flushFlag = this._opts.flush || binding.Z_NO_FLUSH; - this._processChunk(chunk, flushFlag, cb); - }, Zlib.prototype._processChunk = function(chunk, flushFlag, cb) { - var availInBefore = chunk && chunk.length, availOutBefore = this._chunkSize - this._offset, inOff = 0, self = this, async = typeof cb === "function"; - if (!async) { - var buffers = [], nread = 0, error; - this.on("error", function(er) { - error = er; - }), 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 >= kMaxLength2) - throw _close(this), new RangeError(kRangeErrorMessage); - var buf = Buffer22.concat(buffers, nread); - return _close(this), buf; - } - 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) { - if (this) - this.buffer = null, this.callback = null; - if (self._hadError) - return; - var have = availOutBefore - availOutAfter; - 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); - else - buffers.push(out), nread += out.length; - } - if (availOutAfter === 0 || self._offset >= 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; - var newReq = self._handle.write(flushFlag, chunk, inOff, availInBefore, self._buffer, self._offset, self._chunkSize); - newReq.callback = callback, newReq.buffer = chunk; - return; - } - if (!async) - return !1; - cb(); - } - }, 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 = 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, - inflateSync, - inflateRawSync, - inflateRaw, - inflate, - gzipSync, - gzip, - gunzipSync, - gunzip, - deflateSync, - deflateRawSync, - deflateRaw, - deflate, - zlib_default as default, - createUnzip, - createInflateRaw, - createInflate, - createGzip, - createGunzip, - createDeflateRaw, - createDeflate, - constants, - Unzip, - InflateRaw, - Inflate, - Gzip, - Gunzip, - DeflateRaw, - Deflate -}; +import{default as R0} from"node:assert";import*as t0 from"node:assert";import*as o0 from"node:buffer";import*as s0 from"node:stream";import*as W1 from"node:util";var j1,J1,Y1,G1,q1,X1,U1,P1,K1,F1,H1,z1,Z1,L1,C1,N1,I1,O1,B1,D1,M1,k1,v1,R1,A1,g1,w1,T1,S1;var y1=Object.getOwnPropertyNames;var A0=(Y,g)=>function b(){return g||(0,Y[y1(Y)[0]])((g={exports:{}}).exports,g),g.exports};var E1=A0({"node_modules/pako/lib/zlib/zstream.js"(Y,g){function b(){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}g.exports=b}}),r0=A0({"node_modules/pako/lib/utils/common.js"(Y){var g=typeof Uint8Array!=="undefined"&&typeof Uint16Array!=="undefined"&&typeof Int32Array!=="undefined";function b(C,w){return Object.prototype.hasOwnProperty.call(C,w)}Y.assign=function(C){var w=Array.prototype.slice.call(arguments,1);while(w.length){var v=w.shift();if(!v)continue;if(typeof v!=="object")throw new TypeError(v+"must be non-object");for(var k in v)if(b(v,k))C[k]=v[k]}return C},Y.shrinkBuf=function(C,w){if(C.length===w)return C;if(C.subarray)return C.subarray(0,w);return C.length=w,C};var L={arraySet:function(C,w,v,k,B){if(w.subarray&&C.subarray){C.set(w.subarray(v,v+k),B);return}for(var N=0;N=0)W[F]=0}var v=0,k=1,B=2,N=3,y=258,m=29,p=256,t=p+1+m,u=30,s=19,W0=2*t+1,E=15,S=16,J0=7,G0=256,F0=16,f=17,d=18,z=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],h=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],V0=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],K=512,O=new Array((t+2)*2);w(O);var I=new Array(u*2);w(I);var c=new Array(K);w(c);var l=new Array(y-N+1);w(l);var D=new Array(m);w(D);var Q0=new Array(u);w(Q0);function i(W,F,Z,R,G){this.static_tree=W,this.extra_bits=F,this.extra_base=Z,this.elems=R,this.max_length=G,this.has_stree=W&&W.length}var H0,N0,I0;function K0(W,F){this.dyn_tree=W,this.max_code=0,this.stat_desc=F}function X0(W){return W<256?c[W]:c[256+(W>>>7)]}function U0(W,F){W.pending_buf[W.pending++]=F&255,W.pending_buf[W.pending++]=F>>>8&255}function a(W,F,Z){if(W.bi_valid>S-Z)W.bi_buf|=F<>S-W.bi_valid,W.bi_valid+=Z-S;else W.bi_buf|=F<>>=1,Z<<=1;while(--F>0);return Z>>>1}function z0(W){if(W.bi_valid===16)U0(W,W.bi_buf),W.bi_buf=0,W.bi_valid=0;else if(W.bi_valid>=8)W.pending_buf[W.pending++]=W.bi_buf&255,W.bi_buf>>=8,W.bi_valid-=8}function Z0(W,F){var{dyn_tree:Z,max_code:R}=F,G=F.stat_desc.static_tree,P=F.stat_desc.has_stree,$=F.stat_desc.extra_bits,H=F.stat_desc.extra_base,x=F.stat_desc.max_length,Q,X,U,V,J,q,T=0;for(V=0;V<=E;V++)W.bl_count[V]=0;Z[W.heap[W.heap_max]*2+1]=0;for(Q=W.heap_max+1;Qx)V=x,T++;if(Z[X*2+1]=V,X>R)continue;if(W.bl_count[V]++,J=0,X>=H)J=$[X-H];if(q=Z[X*2],W.opt_len+=q*(V+J),P)W.static_len+=q*(G[X*2+1]+J)}if(T===0)return;do{V=x-1;while(W.bl_count[V]===0)V--;W.bl_count[V]--,W.bl_count[V+1]+=2,W.bl_count[x]--,T-=2}while(T>0);for(V=x;V!==0;V--){X=W.bl_count[V];while(X!==0){if(U=W.heap[--Q],U>R)continue;if(Z[U*2+1]!==V)W.opt_len+=(V-Z[U*2+1])*Z[U*2],Z[U*2+1]=V;X--}}}function g0(W,F,Z){var R=new Array(E+1),G=0,P,$;for(P=1;P<=E;P++)R[P]=G=G+Z[P-1]<<1;for($=0;$<=F;$++){var H=W[$*2+1];if(H===0)continue;W[$*2]=r(R[H]++,H)}}function j0(){var W,F,Z,R,G,P=new Array(E+1);Z=0;for(R=0;R>=7;for(;R8)U0(W,W.bi_buf);else if(W.bi_valid>0)W.pending_buf[W.pending++]=W.bi_buf;W.bi_buf=0,W.bi_valid=0}function w0(W,F,Z,R){if(c0(W),R)U0(W,Z),U0(W,~Z);g.arraySet(W.pending_buf,W.window,F,Z,W.pending),W.pending+=Z}function v0(W,F,Z,R){var G=F*2,P=Z*2;return W[G]>1;$>=1;$--)q0(W,Z,$);Q=P;do $=W.heap[1],W.heap[1]=W.heap[W.heap_len--],q0(W,Z,1),H=W.heap[1],W.heap[--W.heap_max]=$,W.heap[--W.heap_max]=H,Z[Q*2]=Z[$*2]+Z[H*2],W.depth[Q]=(W.depth[$]>=W.depth[H]?W.depth[$]:W.depth[H])+1,Z[$*2+1]=Z[H*2+1]=Q,W.heap[1]=Q++,q0(W,Z,1);while(W.heap_len>=2);W.heap[--W.heap_max]=W.heap[1],Z0(W,F),g0(Z,x,W.bl_count)}function p0(W,F,Z){var R,G=-1,P,$=F[1],H=0,x=7,Q=4;if($===0)x=138,Q=3;F[(Z+1)*2+1]=65535;for(R=0;R<=Z;R++){if(P=$,$=F[(R+1)*2+1],++H=3;F--)if(W.bl_tree[j[F]*2+1]!==0)break;return W.opt_len+=3*(F+1)+5+5+4,F}function i0(W,F,Z,R){var G;a(W,F-257,5),a(W,Z-1,5),a(W,R-4,4);for(G=0;G>>=1)if(F&1&&W.dyn_ltree[Z*2]!==0)return L;if(W.dyn_ltree[18]!==0||W.dyn_ltree[20]!==0||W.dyn_ltree[26]!==0)return n;for(Z=32;Z0){if(W.strm.data_type===C)W.strm.data_type=d0(W);if(T0(W,W.l_desc),T0(W,W.d_desc),$=S0(W),G=W.opt_len+3+7>>>3,P=W.static_len+3+7>>>3,P<=G)G=P}else G=P=Z+5;if(Z+4<=G&&F!==-1)m0(W,F,Z,R);else if(W.strategy===b||P===G)a(W,(k<<1)+(R?1:0),3),_(W,O,I);else a(W,(B<<1)+(R?1:0),3),i0(W,W.l_desc.max_code+1,W.d_desc.max_code+1,$+1),_(W,W.dyn_ltree,W.dyn_dtree);if(M0(W),R)c0(W)}function n0(W,F,Z){if(W.pending_buf[W.d_buf+W.last_lit*2]=F>>>8&255,W.pending_buf[W.d_buf+W.last_lit*2+1]=F&255,W.pending_buf[W.l_buf+W.last_lit]=Z&255,W.last_lit++,F===0)W.dyn_ltree[Z*2]++;else W.matches++,F--,W.dyn_ltree[(l[Z]+p+1)*2]++,W.dyn_dtree[X0(F)*2]++;return W.last_lit===W.lit_bufsize-1}Y._tr_init=_0,Y._tr_stored_block=m0,Y._tr_flush_block=h0,Y._tr_tally=n0,Y._tr_align=B0}}),Q1=A0({"node_modules/pako/lib/zlib/adler32.js"(Y,g){function b(L,n,C,w){var v=L&65535|0,k=L>>>16&65535|0,B=0;while(C!==0){B=C>2000?2000:C,C-=B;do v=v+n[w++]|0,k=k+v|0;while(--B);v%=65521,k%=65521}return v|k<<16|0}g.exports=b}}),$1=A0({"node_modules/pako/lib/zlib/crc32.js"(Y,g){function b(){var C,w=[];for(var v=0;v<256;v++){C=v;for(var k=0;k<8;k++)C=C&1?3988292384^C>>>1:C>>>1;w[v]=C}return w}var L=b();function n(C,w,v,k){var B=L,N=k+v;C^=-1;for(var y=k;y>>8^B[(C^w[y])&255];return C^-1}g.exports=n}}),h1=A0({"node_modules/pako/lib/zlib/messages.js"(Y,g){g.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}}}),f1=A0({"node_modules/pako/lib/zlib/deflate.js"(Y){var g=r0(),b=x1(),L=Q1(),n=$1(),C=h1(),w=0,v=1,k=3,B=4,N=5,y=0,m=1,p=-2,t=-3,u=-5,s=-1,W0=1,E=2,S=3,J0=4,G0=0,F0=2,f=8,d=9,z=15,h=8,V0=29,j=256,K=j+1+V0,O=30,I=19,c=2*K+1,l=15,D=3,Q0=258,i=Q0+D+1,H0=32,N0=42,I0=69,K0=73,X0=91,U0=103,a=113,Y0=666,r=1,z0=2,Z0=3,g0=4,j0=3;function M0(Q,X){return Q.msg=C[X],X}function c0(Q){return(Q<<1)-(Q>4?9:0)}function w0(Q){var X=Q.length;while(--X>=0)Q[X]=0}function v0(Q){var X=Q.state,U=X.pending;if(U>Q.avail_out)U=Q.avail_out;if(U===0)return;if(g.arraySet(Q.output,X.pending_buf,X.pending_out,U,Q.next_out),Q.next_out+=U,X.pending_out+=U,Q.total_out+=U,Q.avail_out-=U,X.pending-=U,X.pending===0)X.pending_out=0}function q0(Q,X){b._tr_flush_block(Q,Q.block_start>=0?Q.block_start:-1,Q.strstart-Q.block_start,X),Q.block_start=Q.strstart,v0(Q.strm)}function _(Q,X){Q.pending_buf[Q.pending++]=X}function T0(Q,X){Q.pending_buf[Q.pending++]=X>>>8&255,Q.pending_buf[Q.pending++]=X&255}function p0(Q,X,U,V){var J=Q.avail_in;if(J>V)J=V;if(J===0)return 0;if(Q.avail_in-=J,g.arraySet(X,Q.input,Q.next_in,J,U),Q.state.wrap===1)Q.adler=L(Q.adler,X,J,U);else if(Q.state.wrap===2)Q.adler=n(Q.adler,X,J,U);return Q.next_in+=J,Q.total_in+=J,J}function b0(Q,X){var{max_chain_length:U,strstart:V}=Q,J,q,T=Q.prev_length,M=Q.nice_match,A=Q.strstart>Q.w_size-i?Q.strstart-(Q.w_size-i):0,o=Q.window,f0=Q.w_mask,P0=Q.prev,e=Q.strstart+Q0,C0=o[V+T-1],D0=o[V+T];if(Q.prev_length>=Q.good_match)U>>=2;if(M>Q.lookahead)M=Q.lookahead;do{if(J=X,o[J+T]!==D0||o[J+T-1]!==C0||o[J]!==o[V]||o[++J]!==o[V+1])continue;V+=2,J++;do;while(o[++V]===o[++J]&&o[++V]===o[++J]&&o[++V]===o[++J]&&o[++V]===o[++J]&&o[++V]===o[++J]&&o[++V]===o[++J]&&o[++V]===o[++J]&&o[++V]===o[++J]&&VT){if(Q.match_start=X,T=q,q>=M)break;C0=o[V+T-1],D0=o[V+T]}}while((X=P0[X&f0])>A&&--U!==0);if(T<=Q.lookahead)return T;return Q.lookahead}function S0(Q){var X=Q.w_size,U,V,J,q,T;do{if(q=Q.window_size-Q.lookahead-Q.strstart,Q.strstart>=X+(X-i)){g.arraySet(Q.window,Q.window,X,X,0),Q.match_start-=X,Q.strstart-=X,Q.block_start-=X,V=Q.hash_size,U=V;do J=Q.head[--U],Q.head[U]=J>=X?J-X:0;while(--V);V=X,U=V;do J=Q.prev[--U],Q.prev[U]=J>=X?J-X:0;while(--V);q+=X}if(Q.strm.avail_in===0)break;if(V=p0(Q.strm,Q.window,Q.strstart+Q.lookahead,q),Q.lookahead+=V,Q.lookahead+Q.insert>=D){T=Q.strstart-Q.insert,Q.ins_h=Q.window[T],Q.ins_h=(Q.ins_h<Q.pending_buf_size-5)U=Q.pending_buf_size-5;for(;;){if(Q.lookahead<=1){if(S0(Q),Q.lookahead===0&&X===w)return r;if(Q.lookahead===0)break}Q.strstart+=Q.lookahead,Q.lookahead=0;var V=Q.block_start+U;if(Q.strstart===0||Q.strstart>=V){if(Q.lookahead=Q.strstart-V,Q.strstart=V,q0(Q,!1),Q.strm.avail_out===0)return r}if(Q.strstart-Q.block_start>=Q.w_size-i){if(q0(Q,!1),Q.strm.avail_out===0)return r}}if(Q.insert=0,X===B){if(q0(Q,!0),Q.strm.avail_out===0)return Z0;return g0}if(Q.strstart>Q.block_start){if(q0(Q,!1),Q.strm.avail_out===0)return r}return r}function d0(Q,X){var U,V;for(;;){if(Q.lookahead=D)Q.ins_h=(Q.ins_h<=D)if(V=b._tr_tally(Q,Q.strstart-Q.match_start,Q.match_length-D),Q.lookahead-=Q.match_length,Q.match_length<=Q.max_lazy_match&&Q.lookahead>=D){Q.match_length--;do Q.strstart++,Q.ins_h=(Q.ins_h<=D)Q.ins_h=(Q.ins_h<4096))Q.match_length=D-1}if(Q.prev_length>=D&&Q.match_length<=Q.prev_length){J=Q.strstart+Q.lookahead-D,V=b._tr_tally(Q,Q.strstart-1-Q.prev_match,Q.prev_length-D),Q.lookahead-=Q.prev_length-1,Q.prev_length-=2;do if(++Q.strstart<=J)Q.ins_h=(Q.ins_h<=D&&Q.strstart>0){if(J=Q.strstart-1,V=T[J],V===T[++J]&&V===T[++J]&&V===T[++J]){q=Q.strstart+Q0;do;while(V===T[++J]&&V===T[++J]&&V===T[++J]&&V===T[++J]&&V===T[++J]&&V===T[++J]&&V===T[++J]&&V===T[++J]&&JQ.lookahead)Q.match_length=Q.lookahead}}if(Q.match_length>=D)U=b._tr_tally(Q,1,Q.match_length-D),Q.lookahead-=Q.match_length,Q.strstart+=Q.match_length,Q.match_length=0;else U=b._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++;if(U){if(q0(Q,!1),Q.strm.avail_out===0)return r}}if(Q.insert=0,X===B){if(q0(Q,!0),Q.strm.avail_out===0)return Z0;return g0}if(Q.last_lit){if(q0(Q,!1),Q.strm.avail_out===0)return r}return z0}function m0(Q,X){var U;for(;;){if(Q.lookahead===0){if(S0(Q),Q.lookahead===0){if(X===w)return r;break}}if(Q.match_length=0,U=b._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++,U){if(q0(Q,!1),Q.strm.avail_out===0)return r}}if(Q.insert=0,X===B){if(q0(Q,!0),Q.strm.avail_out===0)return Z0;return g0}if(Q.last_lit){if(q0(Q,!1),Q.strm.avail_out===0)return r}return z0}function B0(Q,X,U,V,J){this.good_length=Q,this.max_lazy=X,this.nice_length=U,this.max_chain=V,this.func=J}var h0=[new B0(0,0,0,0,i0),new B0(4,4,8,4,d0),new B0(4,5,16,8,d0),new B0(4,6,32,32,d0),new B0(4,4,16,16,E0),new B0(8,16,32,32,E0),new B0(8,16,128,128,E0),new B0(8,32,128,256,E0),new B0(32,128,258,1024,E0),new B0(32,258,258,4096,E0)];function n0(Q){Q.window_size=2*Q.w_size,w0(Q.head),Q.max_lazy_match=h0[Q.level].max_lazy,Q.good_match=h0[Q.level].good_length,Q.nice_match=h0[Q.level].nice_length,Q.max_chain_length=h0[Q.level].max_chain,Q.strstart=0,Q.block_start=0,Q.lookahead=0,Q.insert=0,Q.match_length=Q.prev_length=D-1,Q.match_available=0,Q.ins_h=0}function W(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=f,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new g.Buf16(c*2),this.dyn_dtree=new g.Buf16((2*O+1)*2),this.bl_tree=new g.Buf16((2*I+1)*2),w0(this.dyn_ltree),w0(this.dyn_dtree),w0(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new g.Buf16(l+1),this.heap=new g.Buf16(2*K+1),w0(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new g.Buf16(2*K+1),w0(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function F(Q){var X;if(!Q||!Q.state)return M0(Q,p);if(Q.total_in=Q.total_out=0,Q.data_type=F0,X=Q.state,X.pending=0,X.pending_out=0,X.wrap<0)X.wrap=-X.wrap;return X.status=X.wrap?N0:a,Q.adler=X.wrap===2?0:1,X.last_flush=w,b._tr_init(X),y}function Z(Q){var X=F(Q);if(X===y)n0(Q.state);return X}function R(Q,X){if(!Q||!Q.state)return p;if(Q.state.wrap!==2)return p;return Q.state.gzhead=X,y}function G(Q,X,U,V,J,q){if(!Q)return p;var T=1;if(X===s)X=6;if(V<0)T=0,V=-V;else if(V>15)T=2,V-=16;if(J<1||J>d||U!==f||V<8||V>15||X<0||X>9||q<0||q>J0)return M0(Q,p);if(V===8)V=9;var M=new W;return Q.state=M,M.strm=Q,M.wrap=T,M.gzhead=null,M.w_bits=V,M.w_size=1<N||X<0)return Q?M0(Q,p):p;if(V=Q.state,!Q.output||!Q.input&&Q.avail_in!==0||V.status===Y0&&X!==B)return M0(Q,Q.avail_out===0?u:p);if(V.strm=Q,U=V.last_flush,V.last_flush=X,V.status===N0)if(V.wrap===2)if(Q.adler=0,_(V,31),_(V,139),_(V,8),!V.gzhead)_(V,0),_(V,0),_(V,0),_(V,0),_(V,0),_(V,V.level===9?2:V.strategy>=E||V.level<2?4:0),_(V,j0),V.status=a;else{if(_(V,(V.gzhead.text?1:0)+(V.gzhead.hcrc?2:0)+(!V.gzhead.extra?0:4)+(!V.gzhead.name?0:8)+(!V.gzhead.comment?0:16)),_(V,V.gzhead.time&255),_(V,V.gzhead.time>>8&255),_(V,V.gzhead.time>>16&255),_(V,V.gzhead.time>>24&255),_(V,V.level===9?2:V.strategy>=E||V.level<2?4:0),_(V,V.gzhead.os&255),V.gzhead.extra&&V.gzhead.extra.length)_(V,V.gzhead.extra.length&255),_(V,V.gzhead.extra.length>>8&255);if(V.gzhead.hcrc)Q.adler=n(Q.adler,V.pending_buf,V.pending,0);V.gzindex=0,V.status=I0}else{var T=f+(V.w_bits-8<<4)<<8,M=-1;if(V.strategy>=E||V.level<2)M=0;else if(V.level<6)M=1;else if(V.level===6)M=2;else M=3;if(T|=M<<6,V.strstart!==0)T|=H0;if(T+=31-T%31,V.status=a,T0(V,T),V.strstart!==0)T0(V,Q.adler>>>16),T0(V,Q.adler&65535);Q.adler=1}if(V.status===I0)if(V.gzhead.extra){J=V.pending;while(V.gzindex<(V.gzhead.extra.length&65535)){if(V.pending===V.pending_buf_size){if(V.gzhead.hcrc&&V.pending>J)Q.adler=n(Q.adler,V.pending_buf,V.pending-J,J);if(v0(Q),J=V.pending,V.pending===V.pending_buf_size)break}_(V,V.gzhead.extra[V.gzindex]&255),V.gzindex++}if(V.gzhead.hcrc&&V.pending>J)Q.adler=n(Q.adler,V.pending_buf,V.pending-J,J);if(V.gzindex===V.gzhead.extra.length)V.gzindex=0,V.status=K0}else V.status=K0;if(V.status===K0)if(V.gzhead.name){J=V.pending;do{if(V.pending===V.pending_buf_size){if(V.gzhead.hcrc&&V.pending>J)Q.adler=n(Q.adler,V.pending_buf,V.pending-J,J);if(v0(Q),J=V.pending,V.pending===V.pending_buf_size){q=1;break}}if(V.gzindexJ)Q.adler=n(Q.adler,V.pending_buf,V.pending-J,J);if(q===0)V.gzindex=0,V.status=X0}else V.status=X0;if(V.status===X0)if(V.gzhead.comment){J=V.pending;do{if(V.pending===V.pending_buf_size){if(V.gzhead.hcrc&&V.pending>J)Q.adler=n(Q.adler,V.pending_buf,V.pending-J,J);if(v0(Q),J=V.pending,V.pending===V.pending_buf_size){q=1;break}}if(V.gzindexJ)Q.adler=n(Q.adler,V.pending_buf,V.pending-J,J);if(q===0)V.status=U0}else V.status=U0;if(V.status===U0)if(V.gzhead.hcrc){if(V.pending+2>V.pending_buf_size)v0(Q);if(V.pending+2<=V.pending_buf_size)_(V,Q.adler&255),_(V,Q.adler>>8&255),Q.adler=0,V.status=a}else V.status=a;if(V.pending!==0){if(v0(Q),Q.avail_out===0)return V.last_flush=-1,y}else if(Q.avail_in===0&&c0(X)<=c0(U)&&X!==B)return M0(Q,u);if(V.status===Y0&&Q.avail_in!==0)return M0(Q,u);if(Q.avail_in!==0||V.lookahead!==0||X!==w&&V.status!==Y0){var A=V.strategy===E?m0(V,X):V.strategy===S?_0(V,X):h0[V.level].func(V,X);if(A===Z0||A===g0)V.status=Y0;if(A===r||A===Z0){if(Q.avail_out===0)V.last_flush=-1;return y}if(A===z0){if(X===v)b._tr_align(V);else if(X!==N){if(b._tr_stored_block(V,0,0,!1),X===k){if(w0(V.head),V.lookahead===0)V.strstart=0,V.block_start=0,V.insert=0}}if(v0(Q),Q.avail_out===0)return V.last_flush=-1,y}}if(X!==B)return y;if(V.wrap<=0)return m;if(V.wrap===2)_(V,Q.adler&255),_(V,Q.adler>>8&255),_(V,Q.adler>>16&255),_(V,Q.adler>>24&255),_(V,Q.total_in&255),_(V,Q.total_in>>8&255),_(V,Q.total_in>>16&255),_(V,Q.total_in>>24&255);else T0(V,Q.adler>>>16),T0(V,Q.adler&65535);if(v0(Q),V.wrap>0)V.wrap=-V.wrap;return V.pending!==0?y:m}function H(Q){var X;if(!Q||!Q.state)return p;if(X=Q.state.status,X!==N0&&X!==I0&&X!==K0&&X!==X0&&X!==U0&&X!==a&&X!==Y0)return M0(Q,p);return Q.state=null,X===a?M0(Q,t):y}function x(Q,X){var U=X.length,V,J,q,T,M,A,o,f0;if(!Q||!Q.state)return p;if(V=Q.state,T=V.wrap,T===2||T===1&&V.status!==N0||V.lookahead)return p;if(T===1)Q.adler=L(Q.adler,X,U,0);if(V.wrap=0,U>=V.w_size){if(T===0)w0(V.head),V.strstart=0,V.block_start=0,V.insert=0;f0=new g.Buf8(V.w_size),g.arraySet(f0,X,U-V.w_size,V.w_size,0),X=f0,U=V.w_size}M=Q.avail_in,A=Q.next_in,o=Q.input,Q.avail_in=U,Q.next_in=0,Q.input=X,S0(V);while(V.lookahead>=D){J=V.strstart,q=V.lookahead-(D-1);do V.ins_h=(V.ins_h<>>24,E>>>=z,S-=z,z=d>>>16&255,z===0)I[N++]=d&65535;else if(z&16){if(h=d&65535,z&=15,z){if(S>>=z,S-=z}if(S<15)E+=O[k++]<>>24,E>>>=z,S-=z,z=d>>>16&255,z&16){if(V0=d&65535,z&=15,Sp){C.msg="invalid distance too far back",v.mode=b;break Q}if(E>>>=z,S-=z,z=N-y,V0>z){if(z=V0-z,z>u){if(v.sane){C.msg="invalid distance too far back",v.mode=b;break Q}}if(j=0,K=W0,s===0){if(j+=t-z,z2)I[N++]=K[j++],I[N++]=K[j++],I[N++]=K[j++],h-=3;if(h){if(I[N++]=K[j++],h>1)I[N++]=K[j++]}}else{j=N-V0;do I[N++]=I[j++],I[N++]=I[j++],I[N++]=I[j++],h-=3;while(h>2);if(h){if(I[N++]=I[j++],h>1)I[N++]=I[j++]}}}else if((z&64)===0){d=G0[(d&65535)+(E&(1<>3,k-=h,S-=h<<3,E&=(1<=1;h--)if(X0[h]!==0)break;if(V0>h)V0=h;if(h===0)return E[S++]=1<<24|64<<16|0,E[S++]=1<<24|64<<16|0,G0.bits=1,0;for(z=1;z0&&(t===w||h!==1))return-1;U0[1]=0;for(f=1;fn||t===k&&I>C)return 1;for(;;){if(r=f-K,J0[d]K0)z0=a[Y0+J0[d]],Z0=N0[I0+J0[d]];else z0=96,Z0=0;l=1<>K)+D]=r<<24|z0<<16|Z0|0;while(D!==0);l=1<>=1;if(l!==0)c&=l-1,c+=l;else c=0;if(d++,--X0[f]===0){if(f===h)break;f=u[s+J0[d]]}if(f>V0&&(c&i)!==Q0){if(K===0)K=V0;H0+=z,j=f-K,O=1<n||t===k&&I>C)return 1;Q0=c&i,E[Q0]=V0<<24|j<<16|H0-S|0}}if(c!==0)E[H0+c]=f-K<<24|64<<16|0;return G0.bits=V0,0}}}),d1=A0({"node_modules/pako/lib/zlib/inflate.js"(Y){var g=r0(),b=Q1(),L=$1(),n=u1(),C=b1(),w=0,v=1,k=2,B=4,N=5,y=6,m=0,p=1,t=2,u=-2,s=-3,W0=-4,E=-5,S=8,J0=1,G0=2,F0=3,f=4,d=5,z=6,h=7,V0=8,j=9,K=10,O=11,I=12,c=13,l=14,D=15,Q0=16,i=17,H0=18,N0=19,I0=20,K0=21,X0=22,U0=23,a=24,Y0=25,r=26,z0=27,Z0=28,g0=29,j0=30,M0=31,c0=32,w0=852,v0=592,q0=15,_=q0;function T0(G){return(G>>>24&255)+(G>>>8&65280)+((G&65280)<<8)+((G&255)<<24)}function p0(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new g.Buf16(320),this.work=new g.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b0(G){var P;if(!G||!G.state)return u;if(P=G.state,G.total_in=G.total_out=P.total=0,G.msg="",P.wrap)G.adler=P.wrap&1;return P.mode=J0,P.last=0,P.havedict=0,P.dmax=32768,P.head=null,P.hold=0,P.bits=0,P.lencode=P.lendyn=new g.Buf32(w0),P.distcode=P.distdyn=new g.Buf32(v0),P.sane=1,P.back=-1,m}function S0(G){var P;if(!G||!G.state)return u;return P=G.state,P.wsize=0,P.whave=0,P.wnext=0,b0(G)}function i0(G,P){var $,H;if(!G||!G.state)return u;if(H=G.state,P<0)$=0,P=-P;else if($=(P>>4)+1,P<48)P&=15;if(P&&(P<8||P>15))return u;if(H.window!==null&&H.wbits!==P)H.window=null;return H.wrap=$,H.wbits=P,S0(G)}function d0(G,P){var $,H;if(!G)return u;if(H=new p0,G.state=H,H.window=null,$=i0(G,P),$!==m)G.state=null;return $}function E0(G){return d0(G,_)}var _0=!0,m0,B0;function h0(G){if(_0){var P;m0=new g.Buf32(512),B0=new g.Buf32(32),P=0;while(P<144)G.lens[P++]=8;while(P<256)G.lens[P++]=9;while(P<280)G.lens[P++]=7;while(P<288)G.lens[P++]=8;C(v,G.lens,0,288,m0,0,G.work,{bits:9}),P=0;while(P<32)G.lens[P++]=5;C(k,G.lens,0,32,B0,0,G.work,{bits:5}),_0=!1}G.lencode=m0,G.lenbits=9,G.distcode=B0,G.distbits=5}function n0(G,P,$,H){var x,Q=G.state;if(Q.window===null)Q.wsize=1<=Q.wsize)g.arraySet(Q.window,P,$-Q.wsize,Q.wsize,0),Q.wnext=0,Q.whave=Q.wsize;else{if(x=Q.wsize-Q.wnext,x>H)x=H;if(g.arraySet(Q.window,P,$-H,x,Q.wnext),H-=x,H)g.arraySet(Q.window,P,$-H,H,0),Q.wnext=H,Q.whave=Q.wsize;else{if(Q.wnext+=x,Q.wnext===Q.wsize)Q.wnext=0;if(Q.whave>>8&255,$.check=L($.check,O0,2,0),J=0,q=0,$.mode=G0;break}if($.flags=0,$.head)$.head.done=!1;if(!($.wrap&1)||(((J&255)<<8)+(J>>8))%31){G.msg="incorrect header check",$.mode=j0;break}if((J&15)!==S){G.msg="unknown compression method",$.mode=j0;break}if(J>>>=4,q-=4,L0=(J&15)+8,$.wbits===0)$.wbits=L0;else if(L0>$.wbits){G.msg="invalid window size",$.mode=j0;break}$.dmax=1<>8&1;if($.flags&512)O0[0]=J&255,O0[1]=J>>>8&255,$.check=L($.check,O0,2,0);J=0,q=0,$.mode=F0;case F0:while(q<32){if(U===0)break Q;U--,J+=H[Q++]<>>8&255,O0[2]=J>>>16&255,O0[3]=J>>>24&255,$.check=L($.check,O0,4,0);J=0,q=0,$.mode=f;case f:while(q<16){if(U===0)break Q;U--,J+=H[Q++]<>8;if($.flags&512)O0[0]=J&255,O0[1]=J>>>8&255,$.check=L($.check,O0,2,0);J=0,q=0,$.mode=d;case d:if($.flags&1024){while(q<16){if(U===0)break Q;U--,J+=H[Q++]<>>8&255,$.check=L($.check,O0,2,0);J=0,q=0}else if($.head)$.head.extra=null;$.mode=z;case z:if($.flags&1024){if(A=$.length,A>U)A=U;if(A){if($.head){if(L0=$.head.extra_len-$.length,!$.head.extra)$.head.extra=new Array($.head.extra_len);g.arraySet($.head.extra,H,Q,A,L0)}if($.flags&512)$.check=L($.check,H,A,Q);U-=A,Q+=A,$.length-=A}if($.length)break Q}$.length=0,$.mode=h;case h:if($.flags&2048){if(U===0)break Q;A=0;do if(L0=H[Q+A++],$.head&&L0&&$.length<65536)$.head.name+=String.fromCharCode(L0);while(L0&&A>9&1,$.head.done=!0;G.adler=$.check=0,$.mode=I;break;case K:while(q<32){if(U===0)break Q;U--,J+=H[Q++]<>>=q&7,q-=q&7,$.mode=z0;break}while(q<3){if(U===0)break Q;U--,J+=H[Q++]<>>=1,q-=1,J&3){case 0:$.mode=l;break;case 1:if(h0($),$.mode=I0,P===y){J>>>=2,q-=2;break Q}break;case 2:$.mode=i;break;case 3:G.msg="invalid block type",$.mode=j0}J>>>=2,q-=2;break;case l:J>>>=q&7,q-=q&7;while(q<32){if(U===0)break Q;U--,J+=H[Q++]<>>16^65535)){G.msg="invalid stored block lengths",$.mode=j0;break}if($.length=J&65535,J=0,q=0,$.mode=D,P===y)break Q;case D:$.mode=Q0;case Q0:if(A=$.length,A){if(A>U)A=U;if(A>V)A=V;if(A===0)break Q;g.arraySet(x,H,Q,A,X),U-=A,Q+=A,V-=A,X+=A,$.length-=A;break}$.mode=I;break;case i:while(q<14){if(U===0)break Q;U--,J+=H[Q++]<>>=5,q-=5,$.ndist=(J&31)+1,J>>>=5,q-=5,$.ncode=(J&15)+4,J>>>=4,q-=4,$.nlen>286||$.ndist>30){G.msg="too many length or distance symbols",$.mode=j0;break}$.have=0,$.mode=H0;case H0:while($.have<$.ncode){while(q<3){if(U===0)break Q;U--,J+=H[Q++]<>>=3,q-=3}while($.have<19)$.lens[e0[$.have++]]=0;if($.lencode=$.lendyn,$.lenbits=7,u0={bits:$.lenbits},y0=C(w,$.lens,0,19,$.lencode,0,$.work,u0),$.lenbits=u0.bits,y0){G.msg="invalid code lengths set",$.mode=j0;break}$.have=0,$.mode=N0;case N0:while($.have<$.nlen+$.ndist){for(;;){if(P0=$.lencode[J&(1<<$.lenbits)-1],e=P0>>>24,C0=P0>>>16&255,D0=P0&65535,e<=q)break;if(U===0)break Q;U--,J+=H[Q++]<>>=e,q-=e,$.lens[$.have++]=D0;else{if(D0===16){x0=e+2;while(q>>=e,q-=e,$.have===0){G.msg="invalid bit length repeat",$.mode=j0;break}L0=$.lens[$.have-1],A=3+(J&3),J>>>=2,q-=2}else if(D0===17){x0=e+3;while(q>>=e,q-=e,L0=0,A=3+(J&7),J>>>=3,q-=3}else{x0=e+7;while(q>>=e,q-=e,L0=0,A=11+(J&127),J>>>=7,q-=7}if($.have+A>$.nlen+$.ndist){G.msg="invalid bit length repeat",$.mode=j0;break}while(A--)$.lens[$.have++]=L0}}if($.mode===j0)break;if($.lens[256]===0){G.msg="invalid code -- missing end-of-block",$.mode=j0;break}if($.lenbits=9,u0={bits:$.lenbits},y0=C(v,$.lens,0,$.nlen,$.lencode,0,$.work,u0),$.lenbits=u0.bits,y0){G.msg="invalid literal/lengths set",$.mode=j0;break}if($.distbits=6,$.distcode=$.distdyn,u0={bits:$.distbits},y0=C(k,$.lens,$.nlen,$.ndist,$.distcode,0,$.work,u0),$.distbits=u0.bits,y0){G.msg="invalid distances set",$.mode=j0;break}if($.mode=I0,P===y)break Q;case I0:$.mode=K0;case K0:if(U>=6&&V>=258){if(G.next_out=X,G.avail_out=V,G.next_in=Q,G.avail_in=U,$.hold=J,$.bits=q,n(G,M),X=G.next_out,x=G.output,V=G.avail_out,Q=G.next_in,H=G.input,U=G.avail_in,J=$.hold,q=$.bits,$.mode===I)$.back=-1;break}$.back=0;for(;;){if(P0=$.lencode[J&(1<<$.lenbits)-1],e=P0>>>24,C0=P0>>>16&255,D0=P0&65535,e<=q)break;if(U===0)break Q;U--,J+=H[Q++]<>k0)],e=P0>>>24,C0=P0>>>16&255,D0=P0&65535,k0+e<=q)break;if(U===0)break Q;U--,J+=H[Q++]<>>=k0,q-=k0,$.back+=k0}if(J>>>=e,q-=e,$.back+=e,$.length=D0,C0===0){$.mode=r;break}if(C0&32){$.back=-1,$.mode=I;break}if(C0&64){G.msg="invalid literal/length code",$.mode=j0;break}$.extra=C0&15,$.mode=X0;case X0:if($.extra){x0=$.extra;while(q>>=$.extra,q-=$.extra,$.back+=$.extra}$.was=$.length,$.mode=U0;case U0:for(;;){if(P0=$.distcode[J&(1<<$.distbits)-1],e=P0>>>24,C0=P0>>>16&255,D0=P0&65535,e<=q)break;if(U===0)break Q;U--,J+=H[Q++]<>k0)],e=P0>>>24,C0=P0>>>16&255,D0=P0&65535,k0+e<=q)break;if(U===0)break Q;U--,J+=H[Q++]<>>=k0,q-=k0,$.back+=k0}if(J>>>=e,q-=e,$.back+=e,C0&64){G.msg="invalid distance code",$.mode=j0;break}$.offset=D0,$.extra=C0&15,$.mode=a;case a:if($.extra){x0=$.extra;while(q>>=$.extra,q-=$.extra,$.back+=$.extra}if($.offset>$.dmax){G.msg="invalid distance too far back",$.mode=j0;break}$.mode=Y0;case Y0:if(V===0)break Q;if(A=M-V,$.offset>A){if(A=$.offset-A,A>$.whave){if($.sane){G.msg="invalid distance too far back",$.mode=j0;break}}if(A>$.wnext)A-=$.wnext,o=$.wsize-A;else o=$.wnext-A;if(A>$.length)A=$.length;f0=$.window}else f0=x,o=X-$.offset,A=$.length;if(A>V)A=V;V-=A,$.length-=A;do x[X++]=f0[o++];while(--A);if($.length===0)$.mode=K0;break;case r:if(V===0)break Q;x[X++]=$.length,V--,$.mode=K0;break;case z0:if($.wrap){while(q<32){if(U===0)break Q;U--,J|=H[Q++]<Y.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=B,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}k.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}if(this.pending_close=!1,R0(this.init_done,"close before init"),R0(this.mode<=Y.UNZIP),this.mode===Y.DEFLATE||this.mode===Y.GZIP||this.mode===Y.DEFLATERAW)b.deflateEnd(this.strm);else if(this.mode===Y.INFLATE||this.mode===Y.GUNZIP||this.mode===Y.INFLATERAW||this.mode===Y.UNZIP)L.inflateEnd(this.strm);this.mode=Y.NONE,this.dictionary=null},k.prototype.write=function(B,N,y,m,p,t,u){return this._write(!0,B,N,y,m,p,t,u)},k.prototype.writeSync=function(B,N,y,m,p,t,u){return this._write(!1,B,N,y,m,p,t,u)},k.prototype._write=function(B,N,y,m,p,t,u,s){if(R0.equal(arguments.length,8),R0(this.init_done,"write before init"),R0(this.mode!==Y.NONE,"already finalized"),R0.equal(!1,this.write_in_progress,"write already in progress"),R0.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,R0.equal(!1,N===void 0,"must provide flush value"),this.write_in_progress=!0,N!==Y.Z_NO_FLUSH&&N!==Y.Z_PARTIAL_FLUSH&&N!==Y.Z_SYNC_FLUSH&&N!==Y.Z_FULL_FLUSH&&N!==Y.Z_FINISH&&N!==Y.Z_BLOCK)throw new Error("Invalid flush value");if(y==null)y=Buffer.alloc(0),p=0,m=0;if(this.strm.avail_in=p,this.strm.input=y,this.strm.next_in=m,this.strm.avail_out=s,this.strm.output=t,this.strm.next_out=u,this.flush=N,!B){if(this._process(),this._checkError())return this._afterSync();return}var W0=this;return process.nextTick(function(){W0._process(),W0._after()}),this},k.prototype._afterSync=function(){var B=this.strm.avail_out,N=this.strm.avail_in;return this.write_in_progress=!1,[N,B]},k.prototype._process=function(){var B=null;switch(this.mode){case Y.DEFLATE:case Y.GZIP:case Y.DEFLATERAW:this.err=b.deflate(this.strm,this.flush);break;case Y.UNZIP:if(this.strm.avail_in>0)B=this.strm.next_in;switch(this.gzip_id_bytes_read){case 0:if(B===null)break;if(this.strm.input[B]===w){if(this.gzip_id_bytes_read=1,B++,this.strm.avail_in===1)break}else{this.mode=Y.INFLATE;break}case 1:if(B===null)break;if(this.strm.input[B]===v)this.gzip_id_bytes_read=2,this.mode=Y.GUNZIP;else this.mode=Y.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case Y.INFLATE:case Y.GUNZIP:case Y.INFLATERAW:if(this.err=L.inflate(this.strm,this.flush),this.err===Y.Z_NEED_DICT&&this.dictionary){if(this.err=L.inflateSetDictionary(this.strm,this.dictionary),this.err===Y.Z_OK)this.err=L.inflate(this.strm,this.flush);else if(this.err===Y.Z_DATA_ERROR)this.err=Y.Z_NEED_DICT}while(this.strm.avail_in>0&&this.mode===Y.GUNZIP&&this.err===Y.Z_STREAM_END&&this.strm.next_in[0]!==0)this.reset(),this.err=L.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},k.prototype._checkError=function(){switch(this.err){case Y.Z_OK:case Y.Z_BUF_ERROR:if(this.strm.avail_out!==0&&this.flush===Y.Z_FINISH)return this._error("unexpected end of file"),!1;break;case Y.Z_STREAM_END:break;case Y.Z_NEED_DICT:if(this.dictionary==null)this._error("Missing dictionary");else this._error("Bad dictionary");return!1;default:return this._error("Zlib error"),!1}return!0},k.prototype._after=function(){if(!this._checkError())return;var B=this.strm.avail_out,N=this.strm.avail_in;if(this.write_in_progress=!1,this.callback(N,B),this.pending_close)this.close()},k.prototype._error=function(B){if(this.strm.msg)B=this.strm.msg;if(this.onerror(B,this.err),this.write_in_progress=!1,this.pending_close)this.close()},k.prototype.init=function(B,N,y,m,p){R0(arguments.length===4||arguments.length===5,"init(windowBits, level, memLevel, strategy, [dictionary])"),R0(B>=8&&B<=15,"invalid windowBits"),R0(N>=-1&&N<=9,"invalid compression level"),R0(y>=1&&y<=9,"invalid memlevel"),R0(m===Y.Z_FILTERED||m===Y.Z_HUFFMAN_ONLY||m===Y.Z_RLE||m===Y.Z_FIXED||m===Y.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(N,B,y,m,p),this._setDictionary()},k.prototype.params=function(){throw new Error("deflateParams Not supported")},k.prototype.reset=function(){this._reset(),this._setDictionary()},k.prototype._init=function(B,N,y,m,p){if(this.level=B,this.windowBits=N,this.memLevel=y,this.strategy=m,this.flush=Y.Z_NO_FLUSH,this.err=Y.Z_OK,this.mode===Y.GZIP||this.mode===Y.GUNZIP)this.windowBits+=16;if(this.mode===Y.UNZIP)this.windowBits+=32;if(this.mode===Y.DEFLATERAW||this.mode===Y.INFLATERAW)this.windowBits=-1*this.windowBits;switch(this.strm=new g,this.mode){case Y.DEFLATE:case Y.GZIP:case Y.DEFLATERAW:this.err=b.deflateInit2(this.strm,this.level,Y.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case Y.INFLATE:case Y.GUNZIP:case Y.INFLATERAW:case Y.UNZIP:this.err=L.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}if(this.err!==Y.Z_OK)this._error("Init error");this.dictionary=p,this.write_in_progress=!1,this.init_done=!0},k.prototype._setDictionary=function(){if(this.dictionary==null)return;switch(this.err=Y.Z_OK,this.mode){case Y.DEFLATE:case Y.DEFLATERAW:this.err=b.deflateSetDictionary(this.strm,this.dictionary);break;default:break}if(this.err!==Y.Z_OK)this._error("Failed to set dictionary")},k.prototype._reset=function(){switch(this.err=Y.Z_OK,this.mode){case Y.DEFLATE:case Y.DEFLATERAW:case Y.GZIP:this.err=b.deflateReset(this.strm);break;case Y.INFLATE:case Y.INFLATERAW:case Y.GUNZIP:this.err=L.inflateReset(this.strm);break;default:break}if(this.err!==Y.Z_OK)this._error("Failed to reset stream")},Y.Zlib=k}}),c1=A0({"node_modules/browserify-zlib/lib/index.js"(Y){var g=o0.Buffer,b=s0.Transform,L=m1(),n=W1,C=t0.ok,w=o0.kMaxLength,v="Cannot create final Buffer. It would be larger than 0x"+w.toString(16)+" bytes";L.Z_MIN_WINDOWBITS=8,L.Z_MAX_WINDOWBITS=15,L.Z_DEFAULT_WINDOWBITS=15,L.Z_MIN_CHUNK=64,L.Z_MAX_CHUNK=Infinity,L.Z_DEFAULT_CHUNK=16384,L.Z_MIN_MEMLEVEL=1,L.Z_MAX_MEMLEVEL=9,L.Z_DEFAULT_MEMLEVEL=8,L.Z_MIN_LEVEL=-1,L.Z_MAX_LEVEL=9,L.Z_DEFAULT_LEVEL=L.Z_DEFAULT_COMPRESSION;var k=Object.keys(L);for(N=0;N=w)H0=new RangeError(v);else i=g.concat(I,c);I=[],j.close(),O(H0,i)}}function s(j,K){if(typeof K==="string")K=g.from(K);if(!g.isBuffer(K))throw new TypeError("Not a string or buffer");var O=j._finishFlushFlag;return j._processChunk(K,O)}function W0(j){if(!(this instanceof W0))return new W0(j);z.call(this,j,L.DEFLATE)}function E(j){if(!(this instanceof E))return new E(j);z.call(this,j,L.INFLATE)}function S(j){if(!(this instanceof S))return new S(j);z.call(this,j,L.GZIP)}function J0(j){if(!(this instanceof J0))return new J0(j);z.call(this,j,L.GUNZIP)}function G0(j){if(!(this instanceof G0))return new G0(j);z.call(this,j,L.DEFLATERAW)}function F0(j){if(!(this instanceof F0))return new F0(j);z.call(this,j,L.INFLATERAW)}function f(j){if(!(this instanceof f))return new f(j);z.call(this,j,L.UNZIP)}function d(j){return j===L.Z_NO_FLUSH||j===L.Z_PARTIAL_FLUSH||j===L.Z_SYNC_FLUSH||j===L.Z_FULL_FLUSH||j===L.Z_FINISH||j===L.Z_BLOCK}function z(j,K){var O=this;if(this._opts=j=j||{},this._chunkSize=j.chunkSize||Y.Z_DEFAULT_CHUNK,b.call(this,j),j.flush&&!d(j.flush))throw new Error("Invalid flush flag: "+j.flush);if(j.finishFlush&&!d(j.finishFlush))throw new Error("Invalid flush flag: "+j.finishFlush);if(this._flushFlag=j.flush||L.Z_NO_FLUSH,this._finishFlushFlag=typeof j.finishFlush!=="undefined"?j.finishFlush:L.Z_FINISH,j.chunkSize){if(j.chunkSizeY.Z_MAX_CHUNK)throw new Error("Invalid chunk size: "+j.chunkSize)}if(j.windowBits){if(j.windowBitsY.Z_MAX_WINDOWBITS)throw new Error("Invalid windowBits: "+j.windowBits)}if(j.level){if(j.levelY.Z_MAX_LEVEL)throw new Error("Invalid compression level: "+j.level)}if(j.memLevel){if(j.memLevelY.Z_MAX_MEMLEVEL)throw new Error("Invalid memLevel: "+j.memLevel)}if(j.strategy){if(j.strategy!=Y.Z_FILTERED&&j.strategy!=Y.Z_HUFFMAN_ONLY&&j.strategy!=Y.Z_RLE&&j.strategy!=Y.Z_FIXED&&j.strategy!=Y.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+j.strategy)}if(j.dictionary){if(!g.isBuffer(j.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance")}this._handle=new L.Zlib(K);var I=this;this._hadError=!1,this._handle.onerror=function(D,Q0){h(I),I._hadError=!0;var i=new Error(D);i.errno=Q0,i.code=Y.codes[Q0],I.emit("error",i)};var c=Y.Z_DEFAULT_COMPRESSION;if(typeof j.level==="number")c=j.level;var l=Y.Z_DEFAULT_STRATEGY;if(typeof j.strategy==="number")l=j.strategy;this._handle.init(j.windowBits||Y.Z_DEFAULT_WINDOWBITS,c,j.memLevel||Y.Z_DEFAULT_MEMLEVEL,l,j.dictionary),this._buffer=g.allocUnsafe(this._chunkSize),this._offset=0,this._level=c,this._strategy=l,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!O._handle},configurable:!0,enumerable:!0})}n.inherits(z,b),z.prototype.params=function(j,K,O){if(jY.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+j);if(K!=Y.Z_FILTERED&&K!=Y.Z_HUFFMAN_ONLY&&K!=Y.Z_RLE&&K!=Y.Z_FIXED&&K!=Y.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+K);if(this._level!==j||this._strategy!==K){var I=this;this.flush(L.Z_SYNC_FLUSH,function(){if(C(I._handle,"zlib binding closed"),I._handle.params(j,K),!I._hadError){if(I._level=j,I._strategy=K,O)O()}})}else process.nextTick(O)},z.prototype.reset=function(){return C(this._handle,"zlib binding closed"),this._handle.reset()},z.prototype._flush=function(j){this._transform(g.alloc(0),"",j)},z.prototype.flush=function(j,K){var O=this,I=this._writableState;if(typeof j==="function"||j===void 0&&!K)K=j,j=L.Z_FULL_FLUSH;if(I.ended){if(K)process.nextTick(K)}else if(I.ending){if(K)this.once("end",K)}else if(I.needDrain){if(K)this.once("drain",function(){return O.flush(j,K)})}else this._flushFlag=j,this.write(g.alloc(0),"",K)},z.prototype.close=function(j){h(this,j),process.nextTick(V0,this)};function h(j,K){if(K)process.nextTick(K);if(!j._handle)return;j._handle.close(),j._handle=null}function V0(j){j.emit("close")}z.prototype._transform=function(j,K,O){var I,c=this._writableState,l=c.ending||c.ended,D=l&&(!j||c.length===j.length);if(j!==null&&!g.isBuffer(j))return O(new Error("invalid input"));if(!this._handle)return O(new Error("zlib binding closed"));if(D)I=this._finishFlushFlag;else if(I=this._flushFlag,j.length>=c.length)this._flushFlag=this._opts.flush||L.Z_NO_FLUSH;this._processChunk(j,I,O)},z.prototype._processChunk=function(j,K,O){var I=j&&j.length,c=this._chunkSize-this._offset,l=0,D=this,Q0=typeof O==="function";if(!Q0){var i=[],H0=0,N0;this.on("error",function(a){N0=a}),C(this._handle,"zlib binding closed");do var I0=this._handle.writeSync(K,j,l,I,this._buffer,this._offset,c);while(!this._hadError&&U0(I0[0],I0[1]));if(this._hadError)throw N0;if(H0>=w)throw h(this),new RangeError(v);var K0=g.concat(i,H0);return h(this),K0}C(this._handle,"zlib binding closed");var X0=this._handle.write(K,j,l,I,this._buffer,this._offset,c);X0.buffer=j,X0.callback=U0;function U0(a,Y0){if(this)this.buffer=null,this.callback=null;if(D._hadError)return;var r=c-Y0;if(C(r>=0,"have should not go down"),r>0){var z0=D._buffer.slice(D._offset,D._offset+r);if(D._offset+=r,Q0)D.push(z0);else i.push(z0),H0+=z0.length}if(Y0===0||D._offset>=D._chunkSize)c=D._chunkSize,D._offset=0,D._buffer=g.allocUnsafe(D._chunkSize);if(Y0===0){if(l+=I-a,I=a,!Q0)return!0;var Z0=D._handle.write(K,j,l,I,D._buffer,D._offset,D._chunkSize);Z0.callback=U0,Z0.buffer=j;return}if(!Q0)return!1;O()}},n.inherits(W0,z),n.inherits(E,z),n.inherits(S,z),n.inherits(J0,z),n.inherits(G0,z),n.inherits(F0,z),n.inherits(f,z)}}),$0=c1();$0[Symbol.for("CommonJS")]=0;var _1=$0;j1=$0.Deflate;J1=$0.Inflate;Y1=$0.Gzip;G1=$0.Gunzip;q1=$0.DeflateRaw;X1=$0.InflateRaw;U1=$0.Unzip;P1=$0.createDeflate;K1=$0.createInflate;F1=$0.createDeflateRaw;H1=$0.createInflateRaw;z1=$0.createGzip;Z1=$0.createGunzip;L1=$0.createUnzip;C1=$0.deflate;N1=$0.deflateSync;I1=$0.gzip;O1=$0.gzipSync;B1=$0.deflateRaw;D1=$0.deflateRawSync;M1=$0.unzip;k1=$0.unzipSync;v1=$0.inflate;R1=$0.inflateSync;A1=$0.gunzip;g1=$0.gunzipSync;w1=$0.inflateRaw;T1=$0.inflateRawSync;S1=$0.constants;export{k1 as unzipSync,M1 as unzip,R1 as inflateSync,T1 as inflateRawSync,w1 as inflateRaw,v1 as inflate,O1 as gzipSync,I1 as gzip,g1 as gunzipSync,A1 as gunzip,N1 as deflateSync,D1 as deflateRawSync,B1 as deflateRaw,C1 as deflate,_1 as default,L1 as createUnzip,H1 as createInflateRaw,K1 as createInflate,z1 as createGzip,Z1 as createGunzip,F1 as createDeflateRaw,P1 as createDeflate,S1 as constants,U1 as Unzip,X1 as InflateRaw,J1 as Inflate,Y1 as Gzip,G1 as Gunzip,q1 as DeflateRaw,j1 as Deflate}; -- cgit v1.2.3 From 4d2c86fd5cb29ed0c76e5763de7f935e15ea0414 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 6 Jul 2023 17:08:01 -0700 Subject: Add util.toUSVString --- src/js/node/util.js | 5 +++++ src/js/out/modules/node/util.js | 6 +++++- test/js/node/util/util.test.js | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/js/node/util.js b/src/js/node/util.js index 8f20a4bc1..2ec4aadb9 100644 --- a/src/js/node/util.js +++ b/src/js/node/util.js @@ -552,6 +552,9 @@ function callbackify(original) { } export var TextDecoder = globalThis.TextDecoder; export var TextEncoder = globalThis.TextEncoder; +var toUSVString = input => { + return (input + "").toWellFormed(); +}; Object.assign(cjs_exports, { format, @@ -577,6 +580,7 @@ Object.assign(cjs_exports, { isBuffer, log, inherits, + toUSVString, promisify, callbackify, isDeepStrictEqual, @@ -609,4 +613,5 @@ export { promisify, callbackify, isDeepStrictEqual, + toUSVString, }; diff --git a/src/js/out/modules/node/util.js b/src/js/out/modules/node/util.js index 48b22871f..eade9e0d9 100644 --- a/src/js/out/modules/node/util.js +++ b/src/js/out/modules/node/util.js @@ -386,7 +386,9 @@ var isRegExp2 = types.isRegExp, isDate2 = types.isDate, isError = types.isNative return Object.defineProperties(fn, getOwnPropertyDescriptors(original)); }; promisify.custom = kCustomPromisifiedSymbol; -var { TextDecoder, TextEncoder } = globalThis; +var { TextDecoder, TextEncoder } = globalThis, toUSVString = (input) => { + return (input + "").toWellFormed(); +}; Object.assign(cjs_exports, { format, deprecate, @@ -411,6 +413,7 @@ Object.assign(cjs_exports, { isBuffer, log, inherits, + toUSVString, promisify, callbackify, isDeepStrictEqual, @@ -420,6 +423,7 @@ Object.assign(cjs_exports, { }); export { default2 as types, + toUSVString, promisify, log, isUndefined, diff --git a/test/js/node/util/util.test.js b/test/js/node/util/util.test.js index 45ecffda8..741b27d19 100644 --- a/test/js/node/util/util.test.js +++ b/test/js/node/util/util.test.js @@ -36,6 +36,23 @@ const deepStrictEqual = (...args) => { // Tests adapted from https://github.com/nodejs/node/blob/main/test/parallel/test-util.js describe("util", () => { + it("toUSVString", () => { + const strings = [ + // Lone high surrogate + "ab\uD800", + "ab\uD800c", + // Lone low surrogate + "\uDFFFab", + "c\uDFFFab", + // Well-formed + "abc", + "ab\uD83D\uDE04c", + ]; + const outputs = ["ab�", "ab�c", "�ab", "c�ab", "abc", "ab😄c"]; + for (let i = 0; i < strings.length; i++) { + expect(util.toUSVString(strings[i])).toBe(outputs[i]); + } + }); describe("isArray", () => { it("all cases", () => { strictEqual(util.isArray([]), true); -- cgit v1.2.3 From 5c0a5646cd26690c78531206e34ab8fd947f5f92 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 6 Jul 2023 17:11:01 -0700 Subject: Update list --- docs/runtime/nodejs-apis.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/runtime/nodejs-apis.md b/docs/runtime/nodejs-apis.md index 593954aae..5f798fc39 100644 --- a/docs/runtime/nodejs-apis.md +++ b/docs/runtime/nodejs-apis.md @@ -1,6 +1,6 @@ Bun aims for complete Node.js API compatibility. Most `npm` packages intended for `Node.js` environments will work with Bun out of the box; the best way to know for certain is to try it. -This page is updated regularly to reflect compatibility status of the latest version of Bun. +This page is updated regularly to reflect compatibility status of the latest version of Bun. If you run into any bugs with a particular package, please [open an issue](https://bun.sh/issues). Opening issues for compatibility bugs helps us prioritize what to work on next. ## Built-in modules @@ -123,7 +123,7 @@ This page is updated regularly to reflect compatibility status of the latest ver - {% anchor id="node_net" %} [`node:net`](https://nodejs.org/api/net.html) {% /anchor %} - 🟡 -- Missing `net.createServer` `net.{get|set}DefaultAutoSelectFamily` `net.SocketAddress` `net.BlockList`. +- Missing `net.{get|set}DefaultAutoSelectFamily` `net.SocketAddress` `net.BlockList`. --- @@ -201,7 +201,7 @@ This page is updated regularly to reflect compatibility status of the latest ver - {% anchor id="node_tls" %} [`node:tls`](https://nodejs.org/api/tls.html) {% /anchor %} - 🟡 -- Missing `tls.Server` `tls.createServer` `tls.createSecurePair` `tls.checkServerIdentity` `tls.rootCertificates` +- Missing `tls.createSecurePair` `tls.checkServerIdentity` `tls.rootCertificates` --- @@ -219,13 +219,13 @@ This page is updated regularly to reflect compatibility status of the latest ver - {% anchor id="node_url" %} [`node:url`](https://nodejs.org/api/url.html) {% /anchor %} - 🟡 -- Missing `url.domainTo{ASCII|Unicode}` `url.urlToHttpOptions`. Recommended to use `URL` and `URLSearchParams` globals instead. +- Missing `url.domainTo{ASCII|Unicode}`. Recommended to use `URL` and `URLSearchParams` globals instead. --- - {% anchor id="node_util" %} [`node:util`](https://nodejs.org/api/util.html) {% /anchor %} - 🟡 -- Missing `util.MIMEParams` `util.MIMEType` `util.formatWithOptions()` `util.getSystemErrorMap()` `util.getSystemErrorName()` `util.parseArgs()` `util.stripVTControlCharacters()` `util.toUSVString()` `util.transferableAbortController()` `util.transferableAbortSignal()`. +- Missing `util.MIMEParams` `util.MIMEType` `util.formatWithOptions()` `util.getSystemErrorMap()` `util.getSystemErrorName()` `util.parseArgs()` `util.stripVTControlCharacters()` `util.transferableAbortController()` `util.transferableAbortSignal()`. --- -- cgit v1.2.3 From 9bebb7f03d79186b69ec6d5d553a7f5c90101123 Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Thu, 6 Jul 2023 20:51:41 -0700 Subject: add `[dir]` to default --- src/options.zig | 2 +- test/bundler/__snapshots__/bun-build-api.test.ts.snap | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/options.zig b/src/options.zig index 3a4eaa9eb..d4df6d4f5 100644 --- a/src/options.zig +++ b/src/options.zig @@ -2838,7 +2838,7 @@ pub const PathTemplate = struct { }; pub const file = PathTemplate{ - .data = "./[name].[ext]", + .data = "[dir]/[name].[ext]", .placeholder = .{}, }; diff --git a/test/bundler/__snapshots__/bun-build-api.test.ts.snap b/test/bundler/__snapshots__/bun-build-api.test.ts.snap index 45932d789..1076dc34f 100644 --- a/test/bundler/__snapshots__/bun-build-api.test.ts.snap +++ b/test/bundler/__snapshots__/bun-build-api.test.ts.snap @@ -72,11 +72,11 @@ NS.then(({ fn: fn2 }) => { " `; -exports[`Bun.build BuildArtifact properties: hash 1`] = `"6d09d5a2f0a15119"`; +exports[`Bun.build BuildArtifact properties: hash 1`] = `"eed0054b0aa2037b"`; exports[`Bun.build BuildArtifact properties + entry.naming: hash 1`] = `"82b2e1b4a1117627"`; -exports[`Bun.build BuildArtifact properties sourcemap: hash index.js 1`] = `"6d09d5a2f0a15119"`; +exports[`Bun.build BuildArtifact properties sourcemap: hash index.js 1`] = `"eed0054b0aa2037b"`; exports[`Bun.build BuildArtifact properties sourcemap: hash index.js.map 1`] = `"0000000000000000"`; -- cgit v1.2.3 From 284aaec3cd41b527428c475c345d79fd67b6dce2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 6 Jul 2023 23:50:32 -0700 Subject: Remove unnecessary `@setRuntimeSafety(false)` --- src/js_ast.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/js_ast.zig b/src/js_ast.zig index 8ae652bb9..71e51b5b0 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -1734,23 +1734,23 @@ pub const E = struct { } pub inline fn toU64(self: Number) u64 { - @setRuntimeSafety(false); - return @intFromFloat(u64, @max(@trunc(self.value), 0)); + return self.to(u64); } pub inline fn toUsize(self: Number) usize { - @setRuntimeSafety(false); - return @intFromFloat(usize, @max(@trunc(self.value), 0)); + return self.to(usize); } pub inline fn toU32(self: Number) u32 { - @setRuntimeSafety(false); - return @intFromFloat(u32, @max(@trunc(self.value), 0)); + return self.to(u32); } pub inline fn toU16(self: Number) u16 { - @setRuntimeSafety(false); - return @intFromFloat(u16, @max(@trunc(self.value), 0)); + return self.to(u16); + } + + pub fn to(self: Number, comptime T: type) T { + return @intFromFloat(T, @min(@max(@trunc(self.value), 0), comptime @min(std.math.floatMax(f64), std.math.maxInt(T)))); } pub fn jsonStringify(self: *const Number, opts: anytype, o: anytype) !void { -- cgit v1.2.3 From 0ecdbf4793f19b3244a3e099bd47e3e81e993811 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 7 Jul 2023 00:33:43 -0700 Subject: [node:fs] `read`, `write` - support large numbers and BigInt (#3556) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/bindings.zig | 5 ++-- src/bun.js/node/node_fs.zig | 50 +++++++++++++++++++------------------- test/js/node/fs/fs.test.ts | 52 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 27 deletions(-) diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 07882d857..c8d0515e9 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -3445,6 +3445,7 @@ pub const JSValue = enum(JSValueReprInt) { c_int => @intCast(c_int, toInt32(this)), ?AnyPromise => asAnyPromise(this), u52 => @truncate(u52, @intCast(u64, @max(this.toInt64(), 0))), + i52 => @truncate(i52, @intCast(i52, this.toInt64())), u64 => toUInt64NoTruncate(this), u8 => @truncate(u8, toU32(this)), i16 => @truncate(i16, toInt32(this)), @@ -4620,11 +4621,11 @@ pub const JSValue = enum(JSValueReprInt) { } pub inline fn toU16(this: JSValue) u16 { - return @truncate(u16, this.toU32()); + return @truncate(u16, @max(this.toInt32(), 0)); } pub inline fn toU32(this: JSValue) u32 { - return @intCast(u32, @max(this.toInt32(), 0)); + return @intCast(u32, @min(@max(this.toInt64(), 0), std.math.maxInt(u32))); } /// This function supports: diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index fa33a575b..74a41c5bd 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -35,7 +35,7 @@ const Mode = JSC.Node.Mode; const uid_t = std.os.uid_t; const gid_t = std.os.gid_t; /// u63 to allow one null bit -const ReadPosition = u63; +const ReadPosition = i64; const Stats = JSC.Node.Stats; const Dirent = JSC.Node.Dirent; @@ -1524,7 +1524,7 @@ pub const Arguments = struct { // fs.write(fd, string[, position[, encoding]], callback) .string => { if (current.isNumber()) { - args.position = current.toU32(); + args.position = current.to(i52); arguments.eat(); current = arguments.next() orelse break :parse; } @@ -1540,18 +1540,18 @@ pub const Arguments = struct { break :parse; } - if (!current.isNumber()) break :parse; - args.offset = current.toU32(); + if (!(current.isNumber() or current.isBigInt())) break :parse; + args.offset = current.to(u52); arguments.eat(); current = arguments.next() orelse break :parse; - if (!current.isNumber()) break :parse; - args.length = current.toU32(); + if (!(current.isNumber() or current.isBigInt())) break :parse; + args.length = current.to(u52); arguments.eat(); current = arguments.next() orelse break :parse; - if (!current.isNumber()) break :parse; - args.position = current.toU32(); + if (!(current.isNumber() or current.isBigInt())) break :parse; + args.position = current.to(i52); arguments.eat(); }, } @@ -1631,8 +1631,8 @@ pub const Arguments = struct { if (arguments.next()) |current| { arguments.eat(); - if (current.isNumber()) { - args.offset = current.toU32(); + if (current.isNumber() or current.isBigInt()) { + args.offset = current.to(u52); if (arguments.remaining.len < 2) { JSC.throwInvalidArguments( @@ -1644,8 +1644,8 @@ pub const Arguments = struct { return null; } - - args.length = arguments.remaining[0].toU32(); + if (arguments.remaining[0].isNumber() or arguments.remaining[0].isBigInt()) + args.length = arguments.remaining[0].to(u52); if (args.length == 0) { JSC.throwInvalidArguments( @@ -1658,26 +1658,26 @@ pub const Arguments = struct { return null; } - const position: i32 = if (arguments.remaining[1].isNumber()) - arguments.remaining[1].toInt32() - else - -1; + if (arguments.remaining[1].isNumber() or arguments.remaining[1].isBigInt()) + args.position = @intCast(ReadPosition, arguments.remaining[1].to(i52)); - args.position = if (position > -1) @intCast(ReadPosition, position) else null; arguments.remaining = arguments.remaining[2..]; } else if (current.isObject()) { - if (current.getIfPropertyExists(ctx.ptr(), "offset")) |num| { - args.offset = num.toU32(); + if (current.getTruthy(ctx.ptr(), "offset")) |num| { + if (num.isNumber() or num.isBigInt()) { + args.offset = num.to(u52); + } } - if (current.getIfPropertyExists(ctx.ptr(), "length")) |num| { - args.length = num.toU32(); + if (current.getTruthy(ctx.ptr(), "length")) |num| { + if (num.isNumber() or num.isBigInt()) { + args.length = num.to(u52); + } } - if (current.getIfPropertyExists(ctx.ptr(), "position")) |num| { - const position: i32 = if (num.isEmptyOrUndefinedOrNull()) -1 else num.coerce(i32, ctx); - if (position > -1) { - args.position = @intCast(ReadPosition, position); + if (current.getTruthy(ctx.ptr(), "position")) |num| { + if (num.isNumber() or num.isBigInt()) { + args.position = num.to(i52); } } } diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index 272522fc0..3b1688c15 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -278,6 +278,41 @@ it("readdirSync throws when given a file path with trailing slash", () => { describe("readSync", () => { const firstFourBytes = new Uint32Array(new TextEncoder().encode("File").buffer)[0]; + + it("works on large files", () => { + const dest = join(tmpdir(), "readSync-large-file.txt"); + rmSync(dest, { force: true }); + + const writefd = openSync(dest, "w"); + writeSync(writefd, Buffer.from([0x10]), 0, 1, 4_900_000_000); + closeSync(writefd); + + const fd = openSync(dest, "r"); + const out = Buffer.alloc(1); + const bytes = readSync(fd, out, 0, 1, 4_900_000_000); + expect(bytes).toBe(1); + expect(out[0]).toBe(0x10); + closeSync(fd); + rmSync(dest, { force: true }); + }); + + it("works with bigint on read", () => { + const dest = join(tmpdir(), "readSync-large-file-bigint.txt"); + rmSync(dest, { force: true }); + + const writefd = openSync(dest, "w"); + writeSync(writefd, Buffer.from([0x10]), 0, 1, 400); + closeSync(writefd); + + const fd = openSync(dest, "r"); + const out = Buffer.alloc(1); + const bytes = readSync(fd, out, 0, 1, 400n as any); + expect(bytes).toBe(1); + expect(out[0]).toBe(0x10); + closeSync(fd); + rmSync(dest, { force: true }); + }); + it("works with a position set to 0", () => { const fd = openSync(import.meta.dir + "/readFileSync.txt", "r"); const four = new Uint8Array(4); @@ -367,6 +402,23 @@ it("preadv", () => { }); describe("writeSync", () => { + it("works with bigint", () => { + const dest = join(tmpdir(), "writeSync-large-file-bigint.txt"); + rmSync(dest, { force: true }); + + const writefd = openSync(dest, "w"); + writeSync(writefd, Buffer.from([0x10]), 0, 1, 400n as any); + closeSync(writefd); + + const fd = openSync(dest, "r"); + const out = Buffer.alloc(1); + const bytes = readSync(fd, out, 0, 1, 400 as any); + expect(bytes).toBe(1); + expect(out[0]).toBe(0x10); + closeSync(fd); + rmSync(dest, { force: true }); + }); + it("works with a position set to 0", () => { const fd = openSync(import.meta.dir + "/writeFileSync.txt", "w+"); const four = new Uint8Array(4); -- cgit v1.2.3 From 7ab8d832fb847e9d2850f9b076174994e3505c0d Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 7 Jul 2023 00:38:18 -0700 Subject: Add obscure HTTP methods (#3553) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/webcore/request.zig | 14 +------ src/http/method.zig | 88 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 17 deletions(-) diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig index 231f0deed..cff2ef2f3 100644 --- a/src/bun.js/webcore/request.zig +++ b/src/bun.js/webcore/request.zig @@ -255,19 +255,7 @@ pub const Request = struct { this: *Request, globalThis: *JSC.JSGlobalObject, ) callconv(.C) JSC.JSValue { - const string_contents: string = switch (this.method) { - .GET => "GET", - .HEAD => "HEAD", - .PATCH => "PATCH", - .PUT => "PUT", - .POST => "POST", - .OPTIONS => "OPTIONS", - .CONNECT => "CONNECT", - .TRACE => "TRACE", - .DELETE => "DELETE", - }; - - return ZigString.init(string_contents).toValueGC(globalThis); + return bun.String.static(@tagName(this.method)).toJSConst(globalThis); } pub fn getMode( diff --git a/src/http/method.zig b/src/http/method.zig index 4a3d45133..d2668f1b7 100644 --- a/src/http/method.zig +++ b/src/http/method.zig @@ -11,15 +11,42 @@ const C = bun.C; const std = @import("std"); pub const Method = enum { + ACL, + BIND, + CHECKOUT, + CONNECT, + COPY, + DELETE, GET, HEAD, + LINK, + LOCK, + @"M-SEARCH", + MERGE, + MKACTIVITY, + MKCALENDAR, + MKCOL, + MOVE, + NOTIFY, + OPTIONS, PATCH, - PUT, POST, - OPTIONS, - CONNECT, + PROPFIND, + PROPPATCH, + PURGE, + PUT, + /// https://httpwg.org/http-extensions/draft-ietf-httpbis-safe-method-w-body.html + QUERY, + REBIND, + REPORT, + SEARCH, + SOURCE, + SUBSCRIBE, TRACE, - DELETE, + UNBIND, + UNLINK, + UNLOCK, + UNSUBSCRIBE, const with_body: std.enums.EnumSet(Method) = brk: { var values = std.enums.EnumSet(Method).initFull(); @@ -47,24 +74,77 @@ pub const Method = enum { } const Map = bun.ComptimeStringMap(Method, .{ + .{ "ACL", Method.ACL }, + .{ "BIND", Method.BIND }, + .{ "CHECKOUT", Method.CHECKOUT }, .{ "CONNECT", Method.CONNECT }, + .{ "COPY", Method.COPY }, .{ "DELETE", Method.DELETE }, .{ "GET", Method.GET }, .{ "HEAD", Method.HEAD }, + .{ "LINK", Method.LINK }, + .{ "LOCK", Method.LOCK }, + .{ "M-SEARCH", Method.@"M-SEARCH" }, + .{ "MERGE", Method.MERGE }, + .{ "MKACTIVITY", Method.MKACTIVITY }, + .{ "MKCALENDAR", Method.MKCALENDAR }, + .{ "MKCOL", Method.MKCOL }, + .{ "MOVE", Method.MOVE }, + .{ "NOTIFY", Method.NOTIFY }, .{ "OPTIONS", Method.OPTIONS }, .{ "PATCH", Method.PATCH }, .{ "POST", Method.POST }, + .{ "PROPFIND", Method.PROPFIND }, + .{ "PROPPATCH", Method.PROPPATCH }, + .{ "PURGE", Method.PURGE }, .{ "PUT", Method.PUT }, + .{ "QUERY", Method.QUERY }, + .{ "REBIND", Method.REBIND }, + .{ "REPORT", Method.REPORT }, + .{ "SEARCH", Method.SEARCH }, + .{ "SOURCE", Method.SOURCE }, + .{ "SUBSCRIBE", Method.SUBSCRIBE }, .{ "TRACE", Method.TRACE }, + .{ "UNBIND", Method.UNBIND }, + .{ "UNLINK", Method.UNLINK }, + .{ "UNLOCK", Method.UNLOCK }, + .{ "UNSUBSCRIBE", Method.UNSUBSCRIBE }, + + .{ "acl", Method.ACL }, + .{ "bind", Method.BIND }, + .{ "checkout", Method.CHECKOUT }, .{ "connect", Method.CONNECT }, + .{ "copy", Method.COPY }, .{ "delete", Method.DELETE }, .{ "get", Method.GET }, .{ "head", Method.HEAD }, + .{ "link", Method.LINK }, + .{ "lock", Method.LOCK }, + .{ "m-search", Method.@"M-SEARCH" }, + .{ "merge", Method.MERGE }, + .{ "mkactivity", Method.MKACTIVITY }, + .{ "mkcalendar", Method.MKCALENDAR }, + .{ "mkcol", Method.MKCOL }, + .{ "move", Method.MOVE }, + .{ "notify", Method.NOTIFY }, .{ "options", Method.OPTIONS }, .{ "patch", Method.PATCH }, .{ "post", Method.POST }, + .{ "propfind", Method.PROPFIND }, + .{ "proppatch", Method.PROPPATCH }, + .{ "purge", Method.PURGE }, .{ "put", Method.PUT }, + .{ "query", Method.QUERY }, + .{ "rebind", Method.REBIND }, + .{ "report", Method.REPORT }, + .{ "search", Method.SEARCH }, + .{ "source", Method.SOURCE }, + .{ "subscribe", Method.SUBSCRIBE }, .{ "trace", Method.TRACE }, + .{ "unbind", Method.UNBIND }, + .{ "unlink", Method.UNLINK }, + .{ "unlock", Method.UNLOCK }, + .{ "unsubscribe", Method.UNSUBSCRIBE }, }); pub fn which(str: []const u8) ?Method { -- cgit v1.2.3 From affd06d05cc756df33854bc1d56e2284ff22b22d Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Fri, 7 Jul 2023 15:10:33 -0700 Subject: Update types, partially fix `typecheck` (#3551) * Update types * Remove caret --- packages/bun-types/assert.d.ts | 6 +- packages/bun-types/ffi.d.ts | 1 + packages/bun-types/fs.d.ts | 213 ++++++---- packages/bun-types/globals.d.ts | 21 +- packages/bun-types/http.d.ts | 18 + packages/bun-types/tests/fs.test-d.ts | 9 + src/js/builtins/ReadableStreamDefaultReader.ts | 4 +- src/js/builtins/ReadableStreamInternals.ts | 1 + src/js/builtins/StreamInternals.ts | 2 +- src/js/builtins/TransformStream.ts | 1 + src/js/builtins/TransformStreamInternals.ts | 1 + src/js/builtins/WritableStreamDefaultWriter.ts | 1 + src/js/builtins/WritableStreamInternals.ts | 9 +- src/js/builtins/builtins.d.ts | 6 +- src/js/bun/ffi.ts | 8 +- src/js/node/trace_events.ts | 2 + src/js/private.d.ts | 3 +- test/bun.lockb | Bin 141113 -> 148733 bytes test/js/node/watch/fs.watch.test.js | 522 ------------------------- test/js/node/watch/fs.watch.test.ts | 522 +++++++++++++++++++++++++ test/js/third_party/socket.io/support/util.ts | 1 + test/js/web/html/FormData.test.ts | 19 +- test/js/web/html/URLSearchParams.test.ts | 5 + test/package.json | 9 +- test/tsconfig.json | 34 +- tsconfig.json | 9 +- 26 files changed, 749 insertions(+), 678 deletions(-) delete mode 100644 test/js/node/watch/fs.watch.test.js create mode 100644 test/js/node/watch/fs.watch.test.ts diff --git a/packages/bun-types/assert.d.ts b/packages/bun-types/assert.d.ts index ae3b54ff2..658e7df5b 100644 --- a/packages/bun-types/assert.d.ts +++ b/packages/bun-types/assert.d.ts @@ -931,7 +931,11 @@ declare module "assert" { * instance of an `Error` then it will be thrown instead of the `AssertionError`. */ // FIXME: assert.doesNotMatch is typed, but not in the browserify polyfill? - // function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void; + function doesNotMatch( + value: string, + regExp: RegExp, + message?: string | Error, + ): void; const strict: Omit< typeof assert, diff --git a/packages/bun-types/ffi.d.ts b/packages/bun-types/ffi.d.ts index 3e7e91534..9705e810b 100644 --- a/packages/bun-types/ffi.d.ts +++ b/packages/bun-types/ffi.d.ts @@ -344,6 +344,7 @@ declare module "bun:ffi" { * */ u64_fast = 16, + function = 17, } type UNTYPED = never; diff --git a/packages/bun-types/fs.d.ts b/packages/bun-types/fs.d.ts index 5dfb2c7f2..379e0ef25 100644 --- a/packages/bun-types/fs.d.ts +++ b/packages/bun-types/fs.d.ts @@ -3932,100 +3932,141 @@ declare module "fs" { } export interface FSWatcher extends EventEmitter { - /** - * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable. - * @since v0.6.8 - */ - close(): void; - - /** - * When called, requests that the Node.js event loop not exit so long as the is active. Calling watcher.ref() multiple times will have no effect. - */ - ref(): void; - - /** - * When called, the active object will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before the object's callback is invoked. Calling watcher.unref() multiple times will have no effect. - */ - unref(): void; - - /** - * events.EventEmitter - * 1. change - * 2. error - */ - addListener(event: string, listener: (...args: any[]) => void): this; - addListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; - addListener(event: 'error', listener: (error: Error) => void): this; - addListener(event: 'close', listener: () => void): this; - on(event: string, listener: (...args: any[]) => void): this; - on(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; - on(event: 'error', listener: (error: Error) => void): this; - on(event: 'close', listener: () => void): this; - once(event: string, listener: (...args: any[]) => void): this; - once(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; - once(event: 'error', listener: (error: Error) => void): this; - once(event: 'close', listener: () => void): this; - prependListener(event: string, listener: (...args: any[]) => void): this; - prependListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; - prependListener(event: 'error', listener: (error: Error) => void): this; - prependListener(event: 'close', listener: () => void): this; - prependOnceListener(event: string, listener: (...args: any[]) => void): this; - prependOnceListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this; - prependOnceListener(event: 'error', listener: (error: Error) => void): this; - prependOnceListener(event: 'close', listener: () => void): this; - } - /** - * Watch for changes on `filename`, where `filename` is either a file or a - * directory. - * - * The second argument is optional. If `options` is provided as a string, it - * specifies the `encoding`. Otherwise `options` should be passed as an object. - * - * The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'` or `'change'`, and `filename` is the name of the file - * which triggered the event. - * - * On most platforms, `'rename'` is emitted whenever a filename appears or - * disappears in the directory. - * - * The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`. - * - * If a `signal` is passed, aborting the corresponding AbortController will close - * the returned `fs.FSWatcher`. + /** + * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable. * @since v0.6.8 - * @param listener */ - export function watch( - filename: PathLike, - options: - | (WatchOptions & { - encoding: 'buffer'; - }) - | 'buffer', - listener?: WatchListener - ): FSWatcher; + close(): void; + /** - * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. - * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. - * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. - * If `encoding` is not supplied, the default of `'utf8'` is used. - * If `persistent` is not supplied, the default of `true` is used. - * If `recursive` is not supplied, the default of `false` is used. + * When called, requests that the Node.js event loop not exit so long as the is active. Calling watcher.ref() multiple times will have no effect. */ - export function watch(filename: PathLike, options?: WatchOptions | BufferEncoding | null, listener?: WatchListener): FSWatcher; + ref(): void; + /** - * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. - * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. - * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. - * If `encoding` is not supplied, the default of `'utf8'` is used. - * If `persistent` is not supplied, the default of `true` is used. - * If `recursive` is not supplied, the default of `false` is used. + * When called, the active object will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before the object's callback is invoked. Calling watcher.unref() multiple times will have no effect. */ - export function watch(filename: PathLike, options: WatchOptions | string, listener?: WatchListener): FSWatcher; + unref(): void; + /** - * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. - * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * events.EventEmitter + * 1. change + * 2. error */ - export function watch(filename: PathLike, listener?: WatchListener): FSWatcher; + addListener(event: string, listener: (...args: any[]) => void): this; + addListener( + event: "change", + listener: (eventType: string, filename: string | Buffer) => void, + ): this; + addListener(event: "error", listener: (error: Error) => void): this; + addListener(event: "close", listener: () => void): this; + on(event: string, listener: (...args: any[]) => void): this; + on( + event: "change", + listener: (eventType: string, filename: string | Buffer) => void, + ): this; + on(event: "error", listener: (error: Error) => void): this; + on(event: "close", listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + once( + event: "change", + listener: (eventType: string, filename: string | Buffer) => void, + ): this; + once(event: "error", listener: (error: Error) => void): this; + once(event: "close", listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependListener( + event: "change", + listener: (eventType: string, filename: string | Buffer) => void, + ): this; + prependListener(event: "error", listener: (error: Error) => void): this; + prependListener(event: "close", listener: () => void): this; + prependOnceListener( + event: string, + listener: (...args: any[]) => void, + ): this; + prependOnceListener( + event: "change", + listener: (eventType: string, filename: string | Buffer) => void, + ): this; + prependOnceListener(event: "error", listener: (error: Error) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + } + + type WatchOptions = { + encoding?: BufferEncoding; + persistent?: boolean; + recursive?: boolean; + signal?: AbortSignal; + }; + type WatchEventType = "rename" | "change" | "error" | "close"; + type WatchListener = ( + event: WatchEventType, + filename: T | Error | undefined, + ) => void; + /** + * Watch for changes on `filename`, where `filename` is either a file or a + * directory. + * + * The second argument is optional. If `options` is provided as a string, it + * specifies the `encoding`. Otherwise `options` should be passed as an object. + * + * The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'` or `'change'`, and `filename` is the name of the file + * which triggered the event. + * + * On most platforms, `'rename'` is emitted whenever a filename appears or + * disappears in the directory. + * + * The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`. + * + * If a `signal` is passed, aborting the corresponding AbortController will close + * the returned `fs.FSWatcher`. + * @since v0.6.8 + * @param listener + */ + export function watch( + filename: PathLike, + options: + | (WatchOptions & { + encoding: "buffer"; + }) + | "buffer", + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + export function watch( + filename: PathLike, + options?: WatchOptions | BufferEncoding | null, + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. + * If `encoding` is not supplied, the default of `'utf8'` is used. + * If `persistent` is not supplied, the default of `true` is used. + * If `recursive` is not supplied, the default of `false` is used. + */ + export function watch( + filename: PathLike, + options: WatchOptions | string, + listener?: WatchListener, + ): FSWatcher; + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. + * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. + */ + export function watch( + filename: PathLike, + listener?: WatchListener, + ): FSWatcher; } declare module "node:fs" { diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index 5784f91c2..da412b211 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -1401,34 +1401,33 @@ declare function clearTimeout(id?: number | Timer): void; declare function clearImmediate(id?: number | Timer): void; // declare function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise; // declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; + /** * Send a HTTP(s) request * - * @param url URL string + * @param request Request object * @param init A structured value that contains settings for the fetch() request. * * @returns A promise that resolves to {@link Response} object. * * */ - -declare function fetch( - url: string | URL | Request, - init?: FetchRequestInit, -): Promise; - +// tslint:disable-next-line:unified-signatures +declare function fetch(request: Request, init?: RequestInit): Promise; /** * Send a HTTP(s) request * - * @param request Request object + * @param url URL string * @param init A structured value that contains settings for the fetch() request. * * @returns A promise that resolves to {@link Response} object. * * */ -// tslint:disable-next-line:unified-signatures -declare function fetch(request: Request, init?: RequestInit): Promise; +declare function fetch( + url: string | URL | Request, + init?: FetchRequestInit, +): Promise; declare function queueMicrotask(callback: (...args: any[]) => void): void; /** @@ -1951,7 +1950,7 @@ interface URLSearchParams { ): void; /** Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */ toString(): string; - [Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>; + [Symbol.iterator](): IterableIterator<[string, string]>; } declare var URLSearchParams: { diff --git a/packages/bun-types/http.d.ts b/packages/bun-types/http.d.ts index 710fea4f4..118cf7ac1 100644 --- a/packages/bun-types/http.d.ts +++ b/packages/bun-types/http.d.ts @@ -1785,6 +1785,24 @@ declare module "http" { callback?: (res: IncomingMessage) => void, ): ClientRequest; + /** + * Performs the low-level validations on the provided name that are done when `res.setHeader(name, value)` is called. + * Passing illegal value as name will result in a TypeError being thrown, identified by `code: 'ERR_INVALID_HTTP_TOKEN'`. + * @param name Header name + * @since v14.3.0 + */ + function validateHeaderName(name: string): void; + /** + * Performs the low-level validations on the provided value that are done when `res.setHeader(name, value)` is called. + * Passing illegal value as value will result in a TypeError being thrown. + * - Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`. + * - Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`. + * @param name Header name + * @param value Header value + * @since v14.3.0 + */ + function validateHeaderValue(name: string, value: string): void; + let globalAgent: Agent; /** diff --git a/packages/bun-types/tests/fs.test-d.ts b/packages/bun-types/tests/fs.test-d.ts index 1ef14a2f8..3acfafa76 100644 --- a/packages/bun-types/tests/fs.test-d.ts +++ b/packages/bun-types/tests/fs.test-d.ts @@ -1,6 +1,15 @@ +import { watch } from "node:fs"; import * as tsd from "tsd"; import * as fs from "fs"; import { exists } from "fs/promises"; tsd.expectType>(exists("/etc/passwd")); tsd.expectType>(fs.promises.exists("/etc/passwd")); + +// file path +watch(".", (eventType, filename) => { + console.log(`event type = ${eventType}`); + if (filename) { + console.log(`filename = ${filename}`); + } +}); diff --git a/src/js/builtins/ReadableStreamDefaultReader.ts b/src/js/builtins/ReadableStreamDefaultReader.ts index 70c6df8c3..a5654d834 100644 --- a/src/js/builtins/ReadableStreamDefaultReader.ts +++ b/src/js/builtins/ReadableStreamDefaultReader.ts @@ -75,7 +75,7 @@ export function readMany(this: ReadableStreamDefaultReader): ReadableStreamDefau var length = values.length; if (length > 0) { - var outValues = $newArrayWithSize(length); + var outValues = $newArrayWithSize(length); if ($isReadableByteStreamController(controller)) { { const buf = values[0]; @@ -150,7 +150,7 @@ export function readMany(this: ReadableStreamDefaultReader): ReadableStreamDefau var pullResult = controller.$pull(controller); if (pullResult && $isPromise(pullResult)) { - return pullResult.$then(onPullMany); + return pullResult.$then(onPullMany) as any; } return onPullMany(pullResult); diff --git a/src/js/builtins/ReadableStreamInternals.ts b/src/js/builtins/ReadableStreamInternals.ts index 0c4e816f4..a9d67aa06 100644 --- a/src/js/builtins/ReadableStreamInternals.ts +++ b/src/js/builtins/ReadableStreamInternals.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* * Copyright (C) 2015 Canon Inc. All rights reserved. * Copyright (C) 2015 Igalia. diff --git a/src/js/builtins/StreamInternals.ts b/src/js/builtins/StreamInternals.ts index b42dc2f57..7bb262951 100644 --- a/src/js/builtins/StreamInternals.ts +++ b/src/js/builtins/StreamInternals.ts @@ -184,7 +184,7 @@ export function createFIFO() { this._capacityMask = (this._capacityMask << 1) | 1; } - shrinkArray() { + _shrinkArray() { this._list.length >>>= 1; this._capacityMask >>>= 1; } diff --git a/src/js/builtins/TransformStream.ts b/src/js/builtins/TransformStream.ts index 54467db39..2a124d4e1 100644 --- a/src/js/builtins/TransformStream.ts +++ b/src/js/builtins/TransformStream.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* * Copyright (C) 2020 Apple Inc. All rights reserved. * diff --git a/src/js/builtins/TransformStreamInternals.ts b/src/js/builtins/TransformStreamInternals.ts index 9994d1282..9da403e71 100644 --- a/src/js/builtins/TransformStreamInternals.ts +++ b/src/js/builtins/TransformStreamInternals.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* * Copyright (C) 2020 Apple Inc. All rights reserved. * diff --git a/src/js/builtins/WritableStreamDefaultWriter.ts b/src/js/builtins/WritableStreamDefaultWriter.ts index 795b43892..50b2cd13f 100644 --- a/src/js/builtins/WritableStreamDefaultWriter.ts +++ b/src/js/builtins/WritableStreamDefaultWriter.ts @@ -1,3 +1,4 @@ +// @ts-nocheck /* * Copyright (C) 2020 Apple Inc. All rights reserved. * diff --git a/src/js/builtins/WritableStreamInternals.ts b/src/js/builtins/WritableStreamInternals.ts index f436a285e..2008dab1c 100644 --- a/src/js/builtins/WritableStreamInternals.ts +++ b/src/js/builtins/WritableStreamInternals.ts @@ -610,16 +610,17 @@ export function setUpWritableStreamDefaultControllerFromUnderlyingSink( highWaterMark, sizeAlgorithm, ) { + // @ts-ignore const controller = new $WritableStreamDefaultController(); - let startAlgorithm = () => {}; - let writeAlgorithm = () => { + let startAlgorithm: (...args: any[]) => any = () => {}; + let writeAlgorithm: (...args: any[]) => any = () => { return Promise.$resolve(); }; - let closeAlgorithm = () => { + let closeAlgorithm: (...args: any[]) => any = () => { return Promise.$resolve(); }; - let abortAlgorithm = () => { + let abortAlgorithm: (...args: any[]) => any = () => { return Promise.$resolve(); }; diff --git a/src/js/builtins/builtins.d.ts b/src/js/builtins/builtins.d.ts index 2de8d8206..9b32ea45e 100644 --- a/src/js/builtins/builtins.d.ts +++ b/src/js/builtins/builtins.d.ts @@ -57,6 +57,9 @@ declare function $getPromiseInternalField( promise: Promise, key: K, ): PromiseFieldToValue; +declare function $fulfillPromise(...args: any[]): TODO; +declare function $evaluateCommonJSModule(...args: any[]): TODO; +declare function $loadCJS2ESM(...args: any[]): TODO; declare function $getGeneratorInternalField(): TODO; declare function $getAsyncGeneratorInternalField(): TODO; declare function $getAbstractModuleRecordInternalField(): TODO; @@ -229,7 +232,7 @@ declare function $createFIFO(): TODO; declare function $createNativeReadableStream(): TODO; declare function $createReadableStream(): TODO; declare function $createUninitializedArrayBuffer(size: number): ArrayBuffer; -declare function $createWritableStreamFromInternal(): TODO; +declare function $createWritableStreamFromInternal(...args: any[]): TODO; declare function $cwd(): TODO; declare function $data(): TODO; declare function $dataView(): TODO; @@ -330,6 +333,7 @@ declare function $read(): TODO; declare function $readIntoRequests(): TODO; declare function $readRequests(): TODO; declare function $readable(): TODO; +declare function $readableByteStreamControllerGetDesiredSize(...args: any): TODO; declare function $readableStreamController(): TODO; declare function $readableStreamToArray(): TODO; declare function $reader(): TODO; diff --git a/src/js/bun/ffi.ts b/src/js/bun/ffi.ts index 7abfe5078..1272e7450 100644 --- a/src/js/bun/ffi.ts +++ b/src/js/bun/ffi.ts @@ -239,7 +239,7 @@ ffiWrappers[FFIType.function] = function functionType(val) { }; function FFIBuilder(params, returnType, functionToCall, name) { - const hasReturnType = typeof FFIType[returnType] === "number" && FFIType[returnType] !== FFIType.void; + const hasReturnType = typeof FFIType[returnType] === "number" && FFIType[returnType as string] !== FFIType.void; var paramNames = new Array(params.length); var args = new Array(params.length); for (let i = 0; i < params.length; i++) { @@ -255,7 +255,7 @@ function FFIBuilder(params, returnType, functionToCall, name) { var code = `functionToCall(${args.join(", ")})`; if (hasReturnType) { - if (FFIType[returnType] === FFIType.cstring) { + if (FFIType[returnType as string] === FFIType.cstring) { code = `return (${cstringReturnType.toString()})(${code})`; } else { code = `return ${code}`; @@ -328,7 +328,7 @@ export function dlopen(path, options) { for (let key in result.symbols) { var symbol = result.symbols[key]; - if (options[key]?.args?.length || FFIType[options[key]?.returns] === FFIType.cstring) { + if (options[key]?.args?.length || FFIType[options[key]?.returns as string] === FFIType.cstring) { result.symbols[key] = FFIBuilder( options[key].args ?? [], options[key].returns ?? FFIType.void, @@ -354,7 +354,7 @@ export function linkSymbols(options) { for (let key in result.symbols) { var symbol = result.symbols[key]; - if (options[key]?.args?.length || FFIType[options[key]?.returns] === FFIType.cstring) { + if (options[key]?.args?.length || FFIType[options[key]?.returns as string] === FFIType.cstring) { result.symbols[key] = FFIBuilder(options[key].args ?? [], options[key].returns ?? FFIType.void, symbol, key); } else { // consistentcy diff --git a/src/js/node/trace_events.ts b/src/js/node/trace_events.ts index 789c41222..7edcc57d0 100644 --- a/src/js/node/trace_events.ts +++ b/src/js/node/trace_events.ts @@ -13,10 +13,12 @@ function ERR_INVALID_ARG_TYPE(name, type, value) { function createTracing(opts) { if (typeof opts !== "object" || opts == null) { + // @ts-ignore throw new ERR_INVALID_ARG_TYPE("options", "Object", opts); } // TODO: validate categories + // @ts-ignore return new Tracing(opts); } diff --git a/src/js/private.d.ts b/src/js/private.d.ts index 500048dd7..d59c6aad8 100644 --- a/src/js/private.d.ts +++ b/src/js/private.d.ts @@ -7,9 +7,8 @@ declare function $bundleError(error: string); type BunFSWatchOptions = { encoding?: BufferEncoding; persistent?: boolean; recursive?: boolean; signal?: AbortSignal }; - type BunWatchEventType = "rename" | "change" | "error" | "close"; -type BunWatchListener = (event: WatchEventType, filename: T | Error | undefined) => void; +type BunWatchListener = (event: WatchEventType, filename: T | undefined) => void; interface BunFSWatcher { /** diff --git a/test/bun.lockb b/test/bun.lockb index c35182d46..01afbfa4e 100755 Binary files a/test/bun.lockb and b/test/bun.lockb differ diff --git a/test/js/node/watch/fs.watch.test.js b/test/js/node/watch/fs.watch.test.js deleted file mode 100644 index faf6a8546..000000000 --- a/test/js/node/watch/fs.watch.test.js +++ /dev/null @@ -1,522 +0,0 @@ -import fs from "fs"; -import path from "path"; -import { tempDirWithFiles, bunRun, bunRunAsScript } from "harness"; -import { pathToFileURL } from "bun"; - -import { describe, expect, test } from "bun:test"; -// Because macOS (and possibly other operating systems) can return a watcher -// before it is actually watching, we need to repeat the operation to avoid -// a race condition. -function repeat(fn) { - const interval = setInterval(fn, 20); - return interval; -} -const encodingFileName = `新建文夹件.txt`; -const testDir = tempDirWithFiles("watch", { - "watch.txt": "hello", - "relative.txt": "hello", - "abort.txt": "hello", - "url.txt": "hello", - "close.txt": "hello", - "close-close.txt": "hello", - "sym-sync.txt": "hello", - "sym.txt": "hello", - [encodingFileName]: "hello", -}); - -describe("fs.watch", () => { - test("non-persistent watcher should not block the event loop", done => { - try { - // https://github.com/joyent/node/issues/2293 - non-persistent watcher should not block the event loop - bunRun(path.join(import.meta.dir, "fixtures", "persistent.js")); - done(); - } catch (e) { - done(e); - } - }); - - test("watcher should close and not block the event loop", done => { - try { - bunRun(path.join(import.meta.dir, "fixtures", "close.js")); - done(); - } catch (e) { - done(e); - } - }); - - test("unref watcher should not block the event loop", done => { - try { - bunRun(path.join(import.meta.dir, "fixtures", "unref.js")); - done(); - } catch (e) { - done(e); - } - }); - - test("should work with relative files", done => { - try { - bunRunAsScript(testDir, path.join(import.meta.dir, "fixtures", "relative.js")); - done(); - } catch (e) { - done(e); - } - }); - - test("add file/folder to folder", done => { - let count = 0; - const root = path.join(testDir, "add-directory"); - try { - fs.mkdirSync(root); - } catch {} - let err = undefined; - const watcher = fs.watch(root, { signal: AbortSignal.timeout(3000) }); - watcher.on("change", (event, filename) => { - count++; - try { - expect(event).toBe("rename"); - expect(["new-file.txt", "new-folder.txt"]).toContain(filename); - if (count >= 2) { - watcher.close(); - } - } catch (e) { - err = e; - watcher.close(); - } - }); - - watcher.on("error", e => (err = e)); - watcher.on("close", () => { - clearInterval(interval); - done(err); - }); - - const interval = repeat(() => { - fs.writeFileSync(path.join(root, "new-file.txt"), "hello"); - fs.mkdirSync(path.join(root, "new-folder.txt")); - fs.rmdirSync(path.join(root, "new-folder.txt")); - }); - }); - - test("add file/folder to subfolder", done => { - let count = 0; - const root = path.join(testDir, "add-subdirectory"); - try { - fs.mkdirSync(root); - } catch {} - const subfolder = path.join(root, "subfolder"); - fs.mkdirSync(subfolder); - const watcher = fs.watch(root, { recursive: true, signal: AbortSignal.timeout(3000) }); - let err = undefined; - watcher.on("change", (event, filename) => { - const basename = path.basename(filename); - - if (basename === "subfolder") return; - count++; - try { - expect(event).toBe("rename"); - expect(["new-file.txt", "new-folder.txt"]).toContain(basename); - if (count >= 2) { - watcher.close(); - } - } catch (e) { - err = e; - watcher.close(); - } - }); - watcher.on("error", e => (err = e)); - watcher.on("close", () => { - clearInterval(interval); - done(err); - }); - - const interval = repeat(() => { - fs.writeFileSync(path.join(subfolder, "new-file.txt"), "hello"); - fs.mkdirSync(path.join(subfolder, "new-folder.txt")); - fs.rmdirSync(path.join(subfolder, "new-folder.txt")); - }); - }); - - test("should emit event when file is deleted", done => { - const testsubdir = tempDirWithFiles("subdir", { - "deleted.txt": "hello", - }); - const filepath = path.join(testsubdir, "deleted.txt"); - let err = undefined; - const watcher = fs.watch(testsubdir, function (event, filename) { - try { - expect(event).toBe("rename"); - expect(filename).toBe("deleted.txt"); - } catch (e) { - err = e; - } finally { - clearInterval(interval); - watcher.close(); - } - }); - - watcher.once("close", () => { - done(err); - }); - - const interval = repeat(() => { - fs.rmSync(filepath, { force: true }); - const fd = fs.openSync(filepath, "w"); - fs.closeSync(fd); - }); - }); - - test("should emit 'change' event when file is modified", done => { - const filepath = path.join(testDir, "watch.txt"); - - const watcher = fs.watch(filepath); - let err = undefined; - watcher.on("change", function (event, filename) { - try { - expect(event).toBe("change"); - expect(filename).toBe("watch.txt"); - } catch (e) { - err = e; - } finally { - clearInterval(interval); - watcher.close(); - } - }); - - watcher.once("close", () => { - done(err); - }); - - const interval = repeat(() => { - fs.writeFileSync(filepath, "world"); - }); - }); - - test("should error on invalid path", done => { - try { - fs.watch(path.join(testDir, "404.txt")); - done(new Error("should not reach here")); - } catch (err) { - expect(err).toBeInstanceOf(Error); - expect(err.code).toBe("ENOENT"); - expect(err.syscall).toBe("watch"); - done(); - } - }); - - const encodings = ["utf8", "buffer", "hex", "ascii", "base64", "utf16le", "ucs2", "latin1", "binary"]; - - test(`should work with encodings ${encodings.join(", ")}`, async () => { - const watchers = []; - const filepath = path.join(testDir, encodingFileName); - - const promises = []; - encodings.forEach(name => { - const encoded_filename = - name !== "buffer" ? Buffer.from(encodingFileName, "utf8").toString(name) : Buffer.from(encodingFileName); - - promises.push( - new Promise((resolve, reject) => { - watchers.push( - fs.watch(filepath, { encoding: name }, (event, filename) => { - try { - expect(event).toBe("change"); - - if (name !== "buffer") { - expect(filename).toBe(encoded_filename); - } else { - expect(filename).toBeInstanceOf(Buffer); - expect(filename.toString("utf8")).toBe(encodingFileName); - } - - resolve(); - } catch (e) { - reject(e); - } - }), - ); - }), - ); - }); - - const interval = repeat(() => { - fs.writeFileSync(filepath, "world"); - }); - - try { - await Promise.all(promises); - } finally { - clearInterval(interval); - watchers.forEach(watcher => watcher.close()); - } - }); - - test("should work with url", done => { - const filepath = path.join(testDir, "url.txt"); - try { - const watcher = fs.watch(pathToFileURL(filepath)); - let err = undefined; - watcher.on("change", function (event, filename) { - try { - expect(event).toBe("change"); - expect(filename).toBe("url.txt"); - } catch (e) { - err = e; - } finally { - clearInterval(interval); - watcher.close(); - } - }); - - watcher.once("close", () => { - done(err); - }); - - const interval = repeat(() => { - fs.writeFileSync(filepath, "world"); - }); - } catch (e) { - done(e); - } - }); - - test("calling close from error event should not throw", done => { - const filepath = path.join(testDir, "close.txt"); - try { - const ac = new AbortController(); - const watcher = fs.watch(pathToFileURL(filepath), { signal: ac.signal }); - watcher.once("error", () => { - try { - watcher.close(); - done(); - } catch (e) { - done("Should not error when calling close from error event"); - } - }); - ac.abort(); - } catch (e) { - done(e); - } - }); - - test("calling close from close event should not throw", done => { - const filepath = path.join(testDir, "close-close.txt"); - try { - const ac = new AbortController(); - const watcher = fs.watch(pathToFileURL(filepath), { signal: ac.signal }); - - watcher.once("close", () => { - try { - watcher.close(); - done(); - } catch (e) { - done("Should not error when calling close from close event"); - } - }); - - ac.abort(); - } catch (e) { - done(e); - } - }); - - test("Signal aborted after creating the watcher", async () => { - const filepath = path.join(testDir, "abort.txt"); - - const ac = new AbortController(); - const promise = new Promise((resolve, reject) => { - const watcher = fs.watch(filepath, { signal: ac.signal }); - watcher.once("error", err => (err.message === "The operation was aborted." ? resolve() : reject(err))); - watcher.once("close", () => reject()); - }); - await Bun.sleep(10); - ac.abort(); - await promise; - }); - - test("Signal aborted before creating the watcher", async () => { - const filepath = path.join(testDir, "abort.txt"); - - const signal = AbortSignal.abort(); - await new Promise((resolve, reject) => { - const watcher = fs.watch(filepath, { signal }); - watcher.once("error", err => (err.message === "The operation was aborted." ? resolve() : reject(err))); - watcher.once("close", () => reject()); - }); - }); - - test("should work with symlink", async () => { - const filepath = path.join(testDir, "sym-symlink2.txt"); - await fs.promises.symlink(path.join(testDir, "sym-sync.txt"), filepath); - - const interval = repeat(() => { - fs.writeFileSync(filepath, "hello"); - }); - - const promise = new Promise((resolve, reject) => { - let timeout = null; - const watcher = fs.watch(filepath, event => { - clearTimeout(timeout); - clearInterval(interval); - try { - resolve(event); - } catch (e) { - reject(e); - } finally { - watcher.close(); - } - }); - setTimeout(() => { - clearInterval(interval); - watcher?.close(); - reject("timeout"); - }, 3000); - }); - expect(promise).resolves.toBe("change"); - }); -}); - -describe("fs.promises.watch", () => { - test("add file/folder to folder", async () => { - let count = 0; - const root = path.join(testDir, "add-promise-directory"); - try { - fs.mkdirSync(root); - } catch {} - let success = false; - let err = undefined; - try { - const ac = new AbortController(); - const watcher = fs.promises.watch(root, { signal: ac.signal }); - - const interval = repeat(() => { - fs.writeFileSync(path.join(root, "new-file.txt"), "hello"); - fs.mkdirSync(path.join(root, "new-folder.txt")); - fs.rmdirSync(path.join(root, "new-folder.txt")); - }); - - for await (const event of watcher) { - count++; - try { - expect(event.eventType).toBe("rename"); - expect(["new-file.txt", "new-folder.txt"]).toContain(event.filename); - - if (count >= 2) { - success = true; - clearInterval(interval); - ac.abort(); - } - } catch (e) { - err = e; - clearInterval(interval); - ac.abort(); - } - } - } catch (e) { - if (!success) { - throw err || e; - } - } - }); - - test("add file/folder to subfolder", async () => { - let count = 0; - const root = path.join(testDir, "add-promise-subdirectory"); - try { - fs.mkdirSync(root); - } catch {} - const subfolder = path.join(root, "subfolder"); - fs.mkdirSync(subfolder); - let success = false; - let err = undefined; - - try { - const ac = new AbortController(); - const watcher = fs.promises.watch(root, { recursive: true, signal: ac.signal }); - - const interval = repeat(() => { - fs.writeFileSync(path.join(subfolder, "new-file.txt"), "hello"); - fs.mkdirSync(path.join(subfolder, "new-folder.txt")); - fs.rmdirSync(path.join(subfolder, "new-folder.txt")); - }); - for await (const event of watcher) { - const basename = path.basename(event.filename); - if (basename === "subfolder") continue; - - count++; - try { - expect(event.eventType).toBe("rename"); - expect(["new-file.txt", "new-folder.txt"]).toContain(basename); - - if (count >= 2) { - success = true; - clearInterval(interval); - ac.abort(); - } - } catch (e) { - err = e; - clearInterval(interval); - ac.abort(); - } - } - } catch (e) { - if (!success) { - throw err || e; - } - } - }); - - test("Signal aborted after creating the watcher", async () => { - const filepath = path.join(testDir, "abort.txt"); - - const ac = new AbortController(); - const watcher = fs.promises.watch(filepath, { signal: ac.signal }); - - const promise = (async () => { - try { - for await (const _ of watcher); - } catch (e) { - expect(e.message).toBe("The operation was aborted."); - } - })(); - await Bun.sleep(10); - ac.abort(); - await promise; - }); - - test("Signal aborted before creating the watcher", async () => { - const filepath = path.join(testDir, "abort.txt"); - - const signal = AbortSignal.abort(); - const watcher = fs.promises.watch(filepath, { signal }); - await (async () => { - try { - for await (const _ of watcher); - } catch (e) { - expect(e.message).toBe("The operation was aborted."); - } - })(); - }); - - test("should work with symlink", async () => { - const filepath = path.join(testDir, "sym-symlink.txt"); - await fs.promises.symlink(path.join(testDir, "sym.txt"), filepath); - - const watcher = fs.promises.watch(filepath); - const interval = repeat(() => { - fs.writeFileSync(filepath, "hello"); - }); - - const promise = (async () => { - try { - for await (const event of watcher) { - return event.eventType; - } - } catch (e) { - expect("unreacheable").toBe(false); - } finally { - clearInterval(interval); - } - })(); - expect(promise).resolves.toBe("change"); - }); -}); diff --git a/test/js/node/watch/fs.watch.test.ts b/test/js/node/watch/fs.watch.test.ts new file mode 100644 index 000000000..aa7959bed --- /dev/null +++ b/test/js/node/watch/fs.watch.test.ts @@ -0,0 +1,522 @@ +import fs, { FSWatcher } from "node:fs"; +import path from "path"; +import { tempDirWithFiles, bunRun, bunRunAsScript } from "harness"; +import { pathToFileURL } from "bun"; + +import { describe, expect, test } from "bun:test"; +// Because macOS (and possibly other operating systems) can return a watcher +// before it is actually watching, we need to repeat the operation to avoid +// a race condition. +function repeat(fn: any) { + const interval = setInterval(fn, 20); + return interval; +} +const encodingFileName = `新建文夹件.txt`; +const testDir = tempDirWithFiles("watch", { + "watch.txt": "hello", + "relative.txt": "hello", + "abort.txt": "hello", + "url.txt": "hello", + "close.txt": "hello", + "close-close.txt": "hello", + "sym-sync.txt": "hello", + "sym.txt": "hello", + [encodingFileName]: "hello", +}); + +describe("fs.watch", () => { + test("non-persistent watcher should not block the event loop", done => { + try { + // https://github.com/joyent/node/issues/2293 - non-persistent watcher should not block the event loop + bunRun(path.join(import.meta.dir, "fixtures", "persistent.js")); + done(); + } catch (e: any) { + done(e); + } + }); + + test("watcher should close and not block the event loop", done => { + try { + bunRun(path.join(import.meta.dir, "fixtures", "close.js")); + done(); + } catch (e: any) { + done(e); + } + }); + + test("unref watcher should not block the event loop", done => { + try { + bunRun(path.join(import.meta.dir, "fixtures", "unref.js")); + done(); + } catch (e: any) { + done(e); + } + }); + + test("should work with relative files", done => { + try { + bunRunAsScript(testDir, path.join(import.meta.dir, "fixtures", "relative.js")); + done(); + } catch (e: any) { + done(e); + } + }); + + test("add file/folder to folder", done => { + let count = 0; + const root = path.join(testDir, "add-directory"); + try { + fs.mkdirSync(root); + } catch {} + let err: Error | undefined = undefined; + const watcher = fs.watch(root, { signal: AbortSignal.timeout(3000) }); + watcher.on("change", (event, filename) => { + count++; + try { + expect(event).toBe("rename"); + expect(["new-file.txt", "new-folder.txt"]).toContain(filename); + if (count >= 2) { + watcher.close(); + } + } catch (e: any) { + err = e; + watcher.close(); + } + }); + + watcher.on("error", e => (err = e)); + watcher.on("close", () => { + clearInterval(interval); + done(err); + }); + + const interval = repeat(() => { + fs.writeFileSync(path.join(root, "new-file.txt"), "hello"); + fs.mkdirSync(path.join(root, "new-folder.txt")); + fs.rmdirSync(path.join(root, "new-folder.txt")); + }); + }); + + test("add file/folder to subfolder", done => { + let count = 0; + const root = path.join(testDir, "add-subdirectory"); + try { + fs.mkdirSync(root); + } catch {} + const subfolder = path.join(root, "subfolder"); + fs.mkdirSync(subfolder); + const watcher = fs.watch(root, { recursive: true, signal: AbortSignal.timeout(3000) }); + let err: Error | undefined = undefined; + watcher.on("change", (event, filename) => { + const basename = path.basename(filename as string); + + if (basename === "subfolder") return; + count++; + try { + expect(event).toBe("rename"); + expect(["new-file.txt", "new-folder.txt"]).toContain(basename); + if (count >= 2) { + watcher.close(); + } + } catch (e: any) { + err = e; + watcher.close(); + } + }); + watcher.on("error", e => (err = e)); + watcher.on("close", () => { + clearInterval(interval); + done(err); + }); + + const interval = repeat(() => { + fs.writeFileSync(path.join(subfolder, "new-file.txt"), "hello"); + fs.mkdirSync(path.join(subfolder, "new-folder.txt")); + fs.rmdirSync(path.join(subfolder, "new-folder.txt")); + }); + }); + + test("should emit event when file is deleted", done => { + const testsubdir = tempDirWithFiles("subdir", { + "deleted.txt": "hello", + }); + const filepath = path.join(testsubdir, "deleted.txt"); + let err: Error | undefined = undefined; + const watcher = fs.watch(testsubdir, function (event, filename) { + try { + expect(event).toBe("rename"); + expect(filename).toBe("deleted.txt"); + } catch (e: any) { + err = e; + } finally { + clearInterval(interval); + watcher.close(); + } + }); + + watcher.once("close", () => { + done(err); + }); + + const interval = repeat(() => { + fs.rmSync(filepath, { force: true }); + const fd = fs.openSync(filepath, "w"); + fs.closeSync(fd); + }); + }); + + test("should emit 'change' event when file is modified", done => { + const filepath = path.join(testDir, "watch.txt"); + + const watcher = fs.watch(filepath); + let err: Error | undefined = undefined; + watcher.on("change", function (event, filename) { + try { + expect(event).toBe("change"); + expect(filename).toBe("watch.txt"); + } catch (e: any) { + err = e; + } finally { + clearInterval(interval); + watcher.close(); + } + }); + + watcher.once("close", () => { + done(err); + }); + + const interval = repeat(() => { + fs.writeFileSync(filepath, "world"); + }); + }); + + test("should error on invalid path", done => { + try { + fs.watch(path.join(testDir, "404.txt")); + done(new Error("should not reach here")); + } catch (err: any) { + expect(err).toBeInstanceOf(Error); + expect(err.code).toBe("ENOENT"); + expect(err.syscall).toBe("watch"); + done(); + } + }); + + const encodings = ["utf8", "buffer", "hex", "ascii", "base64", "utf16le", "ucs2", "latin1", "binary"] as const; + + test(`should work with encodings ${encodings.join(", ")}`, async () => { + const watchers: FSWatcher[] = []; + const filepath = path.join(testDir, encodingFileName); + + const promises: Promise[] = []; + encodings.forEach(name => { + const encoded_filename = + name !== "buffer" ? Buffer.from(encodingFileName, "utf8").toString(name) : Buffer.from(encodingFileName); + + promises.push( + new Promise((resolve, reject) => { + watchers.push( + fs.watch(filepath, { encoding: name }, (event, filename) => { + try { + expect(event).toBe("change"); + + if (name !== "buffer") { + expect(filename).toBe(encoded_filename); + } else { + expect(filename).toBeInstanceOf(Buffer); + expect((filename as any as Buffer)!.toString("utf8")).toBe(encodingFileName); + } + + resolve(undefined); + } catch (e: any) { + reject(e); + } + }), + ); + }), + ); + }); + + const interval = repeat(() => { + fs.writeFileSync(filepath, "world"); + }); + + try { + await Promise.all(promises); + } finally { + clearInterval(interval); + watchers.forEach(watcher => watcher.close()); + } + }); + + test("should work with url", done => { + const filepath = path.join(testDir, "url.txt"); + try { + const watcher = fs.watch(pathToFileURL(filepath)); + let err: Error | undefined = undefined; + watcher.on("change", function (event, filename) { + try { + expect(event).toBe("change"); + expect(filename).toBe("url.txt"); + } catch (e: any) { + err = e; + } finally { + clearInterval(interval); + watcher.close(); + } + }); + + watcher.once("close", () => { + done(err); + }); + + const interval = repeat(() => { + fs.writeFileSync(filepath, "world"); + }); + } catch (e: any) { + done(e); + } + }); + + test("calling close from error event should not throw", done => { + const filepath = path.join(testDir, "close.txt"); + try { + const ac = new AbortController(); + const watcher = fs.watch(pathToFileURL(filepath), { signal: ac.signal }); + watcher.once("error", () => { + try { + watcher.close(); + done(); + } catch (e: any) { + done("Should not error when calling close from error event"); + } + }); + ac.abort(); + } catch (e: any) { + done(e); + } + }); + + test("calling close from close event should not throw", done => { + const filepath = path.join(testDir, "close-close.txt"); + try { + const ac = new AbortController(); + const watcher = fs.watch(pathToFileURL(filepath), { signal: ac.signal }); + + watcher.once("close", () => { + try { + watcher.close(); + done(); + } catch (e: any) { + done("Should not error when calling close from close event"); + } + }); + + ac.abort(); + } catch (e: any) { + done(e); + } + }); + + test("Signal aborted after creating the watcher", async () => { + const filepath = path.join(testDir, "abort.txt"); + + const ac = new AbortController(); + const promise = new Promise((resolve, reject) => { + const watcher = fs.watch(filepath, { signal: ac.signal }); + watcher.once("error", err => (err.message === "The operation was aborted." ? resolve(undefined) : reject(err))); + watcher.once("close", () => reject()); + }); + await Bun.sleep(10); + ac.abort(); + await promise; + }); + + test("Signal aborted before creating the watcher", async () => { + const filepath = path.join(testDir, "abort.txt"); + + const signal = AbortSignal.abort(); + await new Promise((resolve, reject) => { + const watcher = fs.watch(filepath, { signal }); + watcher.once("error", err => (err.message === "The operation was aborted." ? resolve(undefined) : reject(err))); + watcher.once("close", () => reject()); + }); + }); + + test("should work with symlink", async () => { + const filepath = path.join(testDir, "sym-symlink2.txt"); + await fs.promises.symlink(path.join(testDir, "sym-sync.txt"), filepath); + + const interval = repeat(() => { + fs.writeFileSync(filepath, "hello"); + }); + + const promise = new Promise((resolve, reject) => { + let timeout: any = null; + const watcher = fs.watch(filepath, event => { + clearTimeout(timeout); + clearInterval(interval); + try { + resolve(event); + } catch (e: any) { + reject(e); + } finally { + watcher.close(); + } + }); + setTimeout(() => { + clearInterval(interval); + watcher?.close(); + reject("timeout"); + }, 3000); + }); + expect(promise).resolves.toBe("change"); + }); +}); + +describe("fs.promises.watch", () => { + test("add file/folder to folder", async () => { + let count = 0; + const root = path.join(testDir, "add-promise-directory"); + try { + fs.mkdirSync(root); + } catch {} + let success = false; + let err: Error | undefined = undefined; + try { + const ac = new AbortController(); + const watcher = fs.promises.watch(root, { signal: ac.signal }); + + const interval = repeat(() => { + fs.writeFileSync(path.join(root, "new-file.txt"), "hello"); + fs.mkdirSync(path.join(root, "new-folder.txt")); + fs.rmdirSync(path.join(root, "new-folder.txt")); + }); + + for await (const event of watcher) { + count++; + try { + expect(event.eventType).toBe("rename"); + expect(["new-file.txt", "new-folder.txt"]).toContain(event.filename); + + if (count >= 2) { + success = true; + clearInterval(interval); + ac.abort(); + } + } catch (e: any) { + err = e; + clearInterval(interval); + ac.abort(); + } + } + } catch (e: any) { + if (!success) { + throw err || e; + } + } + }); + + test("add file/folder to subfolder", async () => { + let count = 0; + const root = path.join(testDir, "add-promise-subdirectory"); + try { + fs.mkdirSync(root); + } catch {} + const subfolder = path.join(root, "subfolder"); + fs.mkdirSync(subfolder); + let success = false; + let err: Error | undefined = undefined; + + try { + const ac = new AbortController(); + const watcher = fs.promises.watch(root, { recursive: true, signal: ac.signal }); + + const interval = repeat(() => { + fs.writeFileSync(path.join(subfolder, "new-file.txt"), "hello"); + fs.mkdirSync(path.join(subfolder, "new-folder.txt")); + fs.rmdirSync(path.join(subfolder, "new-folder.txt")); + }); + for await (const event of watcher) { + const basename = path.basename(event.filename!); + if (basename === "subfolder") continue; + + count++; + try { + expect(event.eventType).toBe("rename"); + expect(["new-file.txt", "new-folder.txt"]).toContain(basename); + + if (count >= 2) { + success = true; + clearInterval(interval); + ac.abort(); + } + } catch (e: any) { + err = e; + clearInterval(interval); + ac.abort(); + } + } + } catch (e: any) { + if (!success) { + throw err || e; + } + } + }); + + test("Signal aborted after creating the watcher", async () => { + const filepath = path.join(testDir, "abort.txt"); + + const ac = new AbortController(); + const watcher = fs.promises.watch(filepath, { signal: ac.signal }); + + const promise = (async () => { + try { + for await (const _ of watcher); + } catch (e: any) { + expect(e.message).toBe("The operation was aborted."); + } + })(); + await Bun.sleep(10); + ac.abort(); + await promise; + }); + + test("Signal aborted before creating the watcher", async () => { + const filepath = path.join(testDir, "abort.txt"); + + const signal = AbortSignal.abort(); + const watcher = fs.promises.watch(filepath, { signal }); + await (async () => { + try { + for await (const _ of watcher); + } catch (e: any) { + expect(e.message).toBe("The operation was aborted."); + } + })(); + }); + + test("should work with symlink", async () => { + const filepath = path.join(testDir, "sym-symlink.txt"); + await fs.promises.symlink(path.join(testDir, "sym.txt"), filepath); + + const watcher = fs.promises.watch(filepath); + const interval = repeat(() => { + fs.writeFileSync(filepath, "hello"); + }); + + const promise = (async () => { + try { + for await (const event of watcher) { + return event.eventType; + } + } catch (e: any) { + expect("unreacheable").toBe(false); + } finally { + clearInterval(interval); + } + })(); + expect(promise).resolves.toBe("change"); + }); +}); diff --git a/test/js/third_party/socket.io/support/util.ts b/test/js/third_party/socket.io/support/util.ts index 597b40d65..b5f515568 100644 --- a/test/js/third_party/socket.io/support/util.ts +++ b/test/js/third_party/socket.io/support/util.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import type { Server } from "socket.io"; import request from "supertest"; diff --git a/test/js/web/html/FormData.test.ts b/test/js/web/html/FormData.test.ts index cbaf5aaa7..45b4f2f5a 100644 --- a/test/js/web/html/FormData.test.ts +++ b/test/js/web/html/FormData.test.ts @@ -301,17 +301,18 @@ describe("FormData", () => { expect(await (body.get("foo") as Blob).text()).toBe("baz"); server.stop(true); }); - + type FetchReqArgs = [request: Request, init?: RequestInit]; + type FetchURLArgs = [url: string | URL | Request, init?: FetchRequestInit]; for (let useRequestConstructor of [true, false]) { describe(useRequestConstructor ? "Request constructor" : "fetch()", () => { - function send(args: Parameters) { + function send(args: FetchReqArgs | FetchURLArgs) { if (useRequestConstructor) { - return fetch(new Request(...args)); + return fetch(new Request(...(args as FetchReqArgs))); } else { - return fetch(...args); + return fetch(...(args as FetchURLArgs)); } } - for (let headers of [{}, undefined, { headers: { X: "Y" } }]) { + for (let headers of [{} as {}, undefined, { headers: { X: "Y" } }]) { describe("headers: " + Bun.inspect(headers).replaceAll(/([\n ])/gim, ""), () => { it("send on HTTP server with FormData & Blob (roundtrip)", async () => { let contentType = ""; @@ -330,11 +331,10 @@ describe("FormData", () => { form.append("bar", "baz"); // @ts-ignore - const reqBody = [ + const reqBody: FetchURLArgs = [ `http://${server.hostname}:${server.port}`, { body: form, - headers, method: "POST", }, @@ -364,7 +364,6 @@ describe("FormData", () => { form.append("foo", file); form.append("bar", "baz"); - // @ts-ignore const reqBody = [ `http://${server.hostname}:${server.port}`, { @@ -374,7 +373,7 @@ describe("FormData", () => { method: "POST", }, ]; - const res = await send(reqBody); + const res = await send(reqBody as FetchURLArgs); const body = await res.formData(); expect(await (body.get("foo") as Blob).text()).toBe(text); expect(contentType).toContain("multipart/form-data"); @@ -410,7 +409,7 @@ describe("FormData", () => { method: "POST", }, ]; - const res = await send(reqBody); + const res = await send(reqBody as FetchURLArgs); const body = await res.formData(); expect(contentType).toContain("multipart/form-data"); expect(body.get("foo")).toBe("boop"); diff --git a/test/js/web/html/URLSearchParams.test.ts b/test/js/web/html/URLSearchParams.test.ts index 120bb2321..41c42c25d 100644 --- a/test/js/web/html/URLSearchParams.test.ts +++ b/test/js/web/html/URLSearchParams.test.ts @@ -7,15 +7,20 @@ describe("URLSearchParams", () => { params.append("foo", "bar"); params.append("foo", "boop"); params.append("bar", "baz"); + // @ts-ignore expect(params.length).toBe(3); params.delete("foo"); + // @ts-ignore expect(params.length).toBe(1); params.append("foo", "bar"); + // @ts-ignore expect(params.length).toBe(2); params.delete("foo"); params.delete("foo"); + // @ts-ignore expect(params.length).toBe(1); params.delete("bar"); + // @ts-ignore expect(params.length).toBe(0); }); diff --git a/test/package.json b/test/package.json index 5529d3f20..75f8d35e3 100644 --- a/test/package.json +++ b/test/package.json @@ -8,6 +8,7 @@ "@swc/core": "1.3.38", "@types/react": "18.0.28", "@types/react-dom": "18.0.11", + "@types/supertest": "2.0.12", "bktree-fast": "0.0.7", "body-parser": "1.20.2", "dedent": "0.7.0", @@ -17,6 +18,9 @@ "jest-extended": "4.0.0", "lodash": "4.17.21", "nodemailer": "6.9.3", + "pg": "8.11.1", + "pg-connection-string": "2.6.1", + "postgres": "3.3.5", "prisma": "4.15.0", "socket.io": "4.7.1", "socket.io-client": "4.7.1", @@ -26,10 +30,7 @@ "undici": "5.20.0", "vitest": "0.32.2", "webpack": "5.88.0", - "webpack-cli": "4.7.2", - "pg": "8.11.1", - "postgres": "3.3.5", - "pg-connection-string": "2.6.1" + "webpack-cli": "4.7.2" }, "private": true, "scripts": { diff --git a/test/tsconfig.json b/test/tsconfig.json index 67f706cdf..a5e77bf59 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,13 +1,8 @@ { - "include": [ - ".", - "../packages/bun-types/index.d.ts" - ], + "include": [".", "../packages/bun-types/index.d.ts"], "compilerOptions": { "noEmit": true, - "lib": [ - "ESNext" - ], + "lib": ["ESNext"], "module": "ESNext", "target": "ESNext", "moduleResolution": "bundler", @@ -23,25 +18,14 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "harness": [ - "harness.ts" - ], - "mkfifo": [ - "mkfifo.ts" - ], - "node-harness": [ - "js/node/harness.ts" - ], - "deno:harness": [ - "js/deno/harness.ts" - ], - "foo/bar": [ - "js/bun/resolve/baz.js" - ], - "@faasjs/*": [ - "js/bun/resolve/*.js" - ] + "harness": ["harness.ts"], + "mkfifo": ["mkfifo.ts"], + "node-harness": ["js/node/harness.ts"], + "deno:harness": ["js/deno/harness.ts"], + "foo/bar": ["js/bun/resolve/baz.js"], + "@faasjs/*": ["js/bun/resolve/*.js"] } }, + "exclude": ["bundler/fixtures", "snapshots", "js/deno"] } diff --git a/tsconfig.json b/tsconfig.json index 0ee640ea0..d8be0da03 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,12 +6,10 @@ // "skipLibCheck": true, "allowJs": true }, - "include": [ - ".", - "packages/bun-types/index.d.ts" - ], + "include": [".", "packages/bun-types/index.d.ts"], "exclude": [ "src/test", + // "src/js/builtins", "packages", "bench", "examples/*/*", @@ -21,5 +19,6 @@ "src/bun.js/WebKit", "src/api/demo", "node_modules" - ] + ], + "files": ["src/js/builtins/builtins.d.ts"] } -- cgit v1.2.3 From c0cf7b4501efe579f0cbd6c2118c00df2ebc6a13 Mon Sep 17 00:00:00 2001 From: Ai Hoshino Date: Sat, 8 Jul 2023 06:10:49 +0800 Subject: fix decoding invalid UTF-8 input (#3563) * fix decoding invalid UTF-8 input Close: https://github.com/oven-sh/bun/issues/3562 * add unittest --- src/bun.js/bindings/JSStringDecoder.cpp | 4 ++-- test/js/node/string_decoder/string-decoder.test.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bun.js/bindings/JSStringDecoder.cpp b/src/bun.js/bindings/JSStringDecoder.cpp index 5ec258522..b8c2dd50c 100644 --- a/src/bun.js/bindings/JSStringDecoder.cpp +++ b/src/bun.js/bindings/JSStringDecoder.cpp @@ -129,7 +129,7 @@ uint8_t JSStringDecoder::utf8CheckIncomplete(uint8_t* bufPtr, uint32_t length, u m_lastNeed = nb - 1; return nb; } - if (--j < i || nb == -2) + if (j == 0 || --j < i || nb == -2) return 0; nb = utf8CheckByte(bufPtr[j]); if (nb >= 0) { @@ -137,7 +137,7 @@ uint8_t JSStringDecoder::utf8CheckIncomplete(uint8_t* bufPtr, uint32_t length, u m_lastNeed = nb - 2; return nb; } - if (--j < i || nb == -2) + if (j == 0 || --j < i || nb == -2) return 0; nb = utf8CheckByte(bufPtr[j]); if (nb >= 0) { diff --git a/test/js/node/string_decoder/string-decoder.test.js b/test/js/node/string_decoder/string-decoder.test.js index f37326678..aba73401a 100644 --- a/test/js/node/string_decoder/string-decoder.test.js +++ b/test/js/node/string_decoder/string-decoder.test.js @@ -241,3 +241,12 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) { }); }); } + +it("invalid utf-8 input, pr #3562", () => { + const decoder = new RealStringDecoder("utf-8"); + let output = ""; + output += decoder.write(Buffer.from("B9", "hex")); + output += decoder.write(Buffer.from("A9", "hex")); + output += decoder.end(); + expect(output).toStrictEqual("\uFFFD\uFFFD"); +}); -- cgit v1.2.3 From 42eacaf3a9344355adb448fb83e9127c2c87e00d Mon Sep 17 00:00:00 2001 From: Artur Androsovych Date: Sat, 8 Jul 2023 02:24:07 +0300 Subject: Update installation guide in `development.md` (#3532) * Update installation guide in `development.md` * Updates --------- Co-authored-by: Colin McDonnell --- docs/project/development.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/project/development.md b/docs/project/development.md index e50f53215..93327824f 100644 --- a/docs/project/development.md +++ b/docs/project/development.md @@ -41,9 +41,7 @@ $ brew install llvm@15 ``` ```bash#Ubuntu/Debian -# On Ubuntu 22.04 and newer, LLVM 15 is available in the default repositories -$ sudo apt install llvm-15 lld-15 clang-15 -# On older versions, +$ # LLVM has an automatic installation script that is compatible with all versions of Ubuntu $ wget https://apt.llvm.org/llvm.sh -O - | sudo bash -s -- 15 all ``` @@ -85,7 +83,7 @@ $ brew install automake ccache cmake coreutils esbuild gnu-sed go libiconv libto ``` ```bash#Ubuntu/Debian -$ sudo apt install cargo ccache cmake esbuild git golang libtool ninja-build pkg-config rustc +$ sudo apt install cargo ccache cmake git golang libtool ninja-build pkg-config rustc esbuild ``` ```bash#Arch @@ -94,7 +92,19 @@ $ pacman -S base-devel ccache cmake esbuild git go libiconv libtool make ninja p {% /codetabs %} -In addition to this, you will need either `bun` or `npm` installed to install the package.json dependencies. +{% details summary="Ubuntu — Unable to locate package esbuild" %} + +The `apt install esbuild` command may fail with an `Unable to locate package` error if you are using a Ubuntu mirror that does not contain an exact copy of the original Ubuntu server. Note that the same error may occur if you are not using any mirror but have the Ubuntu Universe enabled in the `sources.list`. In this case, you can install esbuild manually: + +```bash +$ curl -fsSL https://esbuild.github.io/dl/latest | sh +$ chmod +x ./esbuild +$ sudo mv ./esbuild /usr/local/bin +``` + +{% /details %} + +In addition to this, you will need an npm package manager (`bun`, `npm`, etc) to install the `package.json` dependencies. ## Install Zig @@ -107,7 +117,7 @@ $ zigup 0.11.0-dev.3737+9eb008717 ## Building -After cloning the repository, prepare bun to be built: +After cloning the repository, run the following command. The runs ```bash $ make setup -- cgit v1.2.3 From 67ee498861caae104c90faccb04e73e65a1a3d95 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 7 Jul 2023 20:12:39 -0700 Subject: Fix potential coercion issue (#3558) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/bindings.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index c8d0515e9..7e3fa6d8e 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -4597,13 +4597,20 @@ pub const JSValue = enum(JSValueReprInt) { return FFI.JSVALUE_TO_BOOL(.{ .asJSValue = this }); } + pub inline fn asInt52(this: JSValue) i64 { + if (comptime bun.Environment.allow_assert) { + std.debug.assert(this.isNumber()); + } + return @intFromFloat(i64, @max(@min(this.asDouble(), std.math.maxInt(i52)), std.math.minInt(i52))); + } + pub fn toInt32(this: JSValue) i32 { if (this.isInt32()) { return asInt32(this); } if (this.isNumber()) { - return @truncate(i32, @intFromFloat(i64, asDouble(this))); + return @truncate(i32, this.asInt52()); } if (comptime bun.Environment.allow_assert) { -- cgit v1.2.3 From 386d8b78369edf235c5cd92e52b94126f406a0fd Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 7 Jul 2023 21:20:16 -0700 Subject: Update test --- test/bundler/bundler_edgecase.test.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/bundler/bundler_edgecase.test.ts b/test/bundler/bundler_edgecase.test.ts index 1b9b60a68..aa1f68688 100644 --- a/test/bundler/bundler_edgecase.test.ts +++ b/test/bundler/bundler_edgecase.test.ts @@ -397,24 +397,25 @@ describe("bundler", () => { }, }); itBundled("edgecase/PackageJSONDefaultConditionImport", { - todo: true, files: { "/entry.js": /* js */ ` - import React from 'react' + import React from 'boop' console.log(React) `, - "/node_modules/react/package.json": /* json */ ` + // NOTE: this test fails if the package name is "react" + // most likely an issue with commonjs unwrapping. + "/node_modules/boop/package.json": /* json */ ` { - "name": "react", + "name": "boop", "exports": { ".": { "react-server": "./ignore.js", - "default": "./react.js" + "default": "./boop.js" } } } `, - "/node_modules/react/react.js": /* js */ ` + "/node_modules/boop/boop.js": /* js */ ` export default 123 `, }, -- cgit v1.2.3 From 52b7962dae593ef45c2cef20bfb2eafad0d50518 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 7 Jul 2023 21:20:30 -0700 Subject: Use BunString in JSBundlerPlugin (#3557) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/api/JSBundler.zig | 41 ++++++++++++++------------ src/bun.js/bindings/JSBundlerPlugin.cpp | 52 ++++++++++++++++++++------------- src/bun.js/bindings/JSBundlerPlugin.h | 15 ++++++++-- 3 files changed, 67 insertions(+), 41 deletions(-) diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig index e3b540da1..44ceaee9d 100644 --- a/src/bun.js/api/JSBundler.zig +++ b/src/bun.js/api/JSBundler.zig @@ -26,7 +26,7 @@ const strings = bun.strings; const NewClass = Base.NewClass; const To = Base.To; const Request = WebCore.Request; - +const String = bun.String; const FetchEvent = WebCore.FetchEvent; const MacroMap = @import("../../resolver/package_json.zig").MacroMap; const TSConfigJSON = @import("../../resolver/tsconfig_json.zig").TSConfigJSON; @@ -871,16 +871,16 @@ pub const JSBundler = struct { extern fn JSBundlerPlugin__anyMatches( *Plugin, - namespaceString: *const ZigString, - path: *const ZigString, + namespaceString: *const String, + path: *const String, bool, ) bool; extern fn JSBundlerPlugin__matchOnLoad( *JSC.JSGlobalObject, *Plugin, - namespaceString: *const ZigString, - path: *const ZigString, + namespaceString: *const String, + path: *const String, context: *anyopaque, u8, ) void; @@ -888,9 +888,9 @@ pub const JSBundler = struct { extern fn JSBundlerPlugin__matchOnResolve( *JSC.JSGlobalObject, *Plugin, - namespaceString: *const ZigString, - path: *const ZigString, - importer: *const ZigString, + namespaceString: *const String, + path: *const String, + importer: *const String, context: *anyopaque, u8, ) void; @@ -905,10 +905,10 @@ pub const JSBundler = struct { defer tracer.end(); const namespace_string = if (path.isFile()) - ZigString.Empty + bun.String.empty else - ZigString.fromUTF8(path.namespace); - const path_string = ZigString.fromUTF8(path.text); + bun.String.create(path.namespace); + const path_string = bun.String.create(path.text); return JSBundlerPlugin__anyMatches(this, &namespace_string, &path_string, is_onLoad); } @@ -924,10 +924,12 @@ pub const JSBundler = struct { const tracer = bun.tracy.traceNamed(@src(), "JSBundler.matchOnLoad"); defer tracer.end(); const namespace_string = if (namespace.len == 0) - ZigString.init("file") + bun.String.static("file") else - ZigString.fromUTF8(namespace); - const path_string = ZigString.fromUTF8(path); + bun.String.create(namespace); + const path_string = bun.String.create(path); + defer namespace_string.deref(); + defer path_string.deref(); JSBundlerPlugin__matchOnLoad(globalThis, this, &namespace_string, &path_string, context, @intFromEnum(default_loader)); } @@ -944,11 +946,14 @@ pub const JSBundler = struct { const tracer = bun.tracy.traceNamed(@src(), "JSBundler.matchOnResolve"); defer tracer.end(); const namespace_string = if (strings.eqlComptime(namespace, "file")) - ZigString.Empty + bun.String.empty else - ZigString.fromUTF8(namespace); - const path_string = ZigString.fromUTF8(path); - const importer_string = ZigString.fromUTF8(importer); + bun.String.create(namespace); + const path_string = bun.String.create(path); + const importer_string = bun.String.create(importer); + defer namespace_string.deref(); + defer path_string.deref(); + defer importer_string.deref(); JSBundlerPlugin__matchOnResolve(globalThis, this, &namespace_string, &path_string, &importer_string, context, @intFromEnum(import_record_kind)); } diff --git a/src/bun.js/bindings/JSBundlerPlugin.cpp b/src/bun.js/bindings/JSBundlerPlugin.cpp index cae6a4b22..d55c5fc2e 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.cpp +++ b/src/bun.js/bindings/JSBundlerPlugin.cpp @@ -54,7 +54,7 @@ void BundlerPlugin::NamespaceList::append(JSC::VM& vm, JSC::RegExp* filter, Stri nsGroup->append(WTFMove(regex)); } -bool BundlerPlugin::anyMatchesCrossThread(JSC::VM& vm, const ZigString* namespaceStr, const ZigString* path, bool isOnLoad) +bool BundlerPlugin::anyMatchesCrossThread(JSC::VM& vm, const BunString* namespaceStr, const BunString* path, bool isOnLoad) { constexpr bool usesPatternContextBuffer = false; if (isOnLoad) { @@ -62,7 +62,7 @@ bool BundlerPlugin::anyMatchesCrossThread(JSC::VM& vm, const ZigString* namespac return false; // Avoid unnecessary string copies - auto namespaceString = namespaceStr ? Zig::toString(*namespaceStr) : String(); + auto namespaceString = namespaceStr ? Bun::toWTFString(*namespaceStr) : String(); auto* group = this->onLoad.group(namespaceString); if (group == nullptr) { @@ -70,7 +70,7 @@ bool BundlerPlugin::anyMatchesCrossThread(JSC::VM& vm, const ZigString* namespac } auto& filters = *group; - auto pathString = Zig::toString(*path); + auto pathString = Bun::toWTFString(*path); for (auto& filter : filters) { Yarr::MatchingContextHolder regExpContext(vm, usesPatternContextBuffer, nullptr, Yarr::MatchFrom::CompilerThread); @@ -84,14 +84,14 @@ bool BundlerPlugin::anyMatchesCrossThread(JSC::VM& vm, const ZigString* namespac return false; // Avoid unnecessary string copies - auto namespaceString = namespaceStr ? Zig::toString(*namespaceStr) : String(); + auto namespaceString = namespaceStr ? Bun::toWTFString(*namespaceStr) : String(); auto* group = this->onResolve.group(namespaceString); if (group == nullptr) { return false; } - auto pathString = Zig::toString(*path); + auto pathString = Bun::toWTFString(*path); auto& filters = *group; for (auto& filter : filters) { @@ -115,9 +115,19 @@ static const HashTableValue JSBundlerPluginHashTable[] = { class JSBundlerPlugin final : public JSC::JSNonFinalObject { public: using Base = JSC::JSNonFinalObject; - static JSBundlerPlugin* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* config, BunPluginTarget target) + static JSBundlerPlugin* create(JSC::VM& vm, + JSC::JSGlobalObject* globalObject, + JSC::Structure* structure, + void* config, + BunPluginTarget target, + JSBundlerPluginAddErrorCallback addError = JSBundlerPlugin__addError, + JSBundlerPluginOnLoadAsyncCallback onLoadAsync = JSBundlerPlugin__onLoadAsync, + JSBundlerPluginOnResolveAsyncCallback onResolveAsync = JSBundlerPlugin__onResolveAsync) { - JSBundlerPlugin* ptr = new (NotNull, JSC::allocateCell(vm)) JSBundlerPlugin(vm, globalObject, structure, config, target); + JSBundlerPlugin* ptr = new (NotNull, JSC::allocateCell(vm)) JSBundlerPlugin(vm, globalObject, structure, config, target, + addError, + onLoadAsync, + onResolveAsync); ptr->finishCreation(vm); return ptr; } @@ -147,9 +157,9 @@ public: JSC::LazyProperty setupFunction; private: - JSBundlerPlugin(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure, void* config, BunPluginTarget target) + JSBundlerPlugin(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure, void* config, BunPluginTarget target, JSBundlerPluginAddErrorCallback addError, JSBundlerPluginOnLoadAsyncCallback onLoadAsync, JSBundlerPluginOnResolveAsyncCallback onResolveAsync) : JSC::JSNonFinalObject(vm, structure) - , plugin(BundlerPlugin(config, target)) + , plugin(BundlerPlugin(config, target, addError, onLoadAsync, onResolveAsync)) { } @@ -199,7 +209,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBundlerPluginFunction_addError, (JSC::JSGlobalObject { JSBundlerPlugin* thisObject = jsCast(callFrame->thisValue()); if (!thisObject->plugin.tombstoned) { - JSBundlerPlugin__addError( + thisObject->plugin.addError( UNWRAP_BUNDLER_PLUGIN(callFrame), thisObject->plugin.config, JSValue::encode(callFrame->argument(1)), @@ -212,7 +222,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBundlerPluginFunction_onLoadAsync, (JSC::JSGlobalObje { JSBundlerPlugin* thisObject = jsCast(callFrame->thisValue()); if (!thisObject->plugin.tombstoned) { - JSBundlerPlugin__onLoadAsync( + thisObject->plugin.onLoadAsync( UNWRAP_BUNDLER_PLUGIN(callFrame), thisObject->plugin.config, JSValue::encode(callFrame->argument(1)), @@ -225,7 +235,7 @@ JSC_DEFINE_HOST_FUNCTION(jsBundlerPluginFunction_onResolveAsync, (JSC::JSGlobalO { JSBundlerPlugin* thisObject = jsCast(callFrame->thisValue()); if (!thisObject->plugin.tombstoned) { - JSBundlerPlugin__onResolveAsync( + thisObject->plugin.onResolveAsync( UNWRAP_BUNDLER_PLUGIN(callFrame), thisObject->plugin.config, JSValue::encode(callFrame->argument(1)), @@ -274,15 +284,15 @@ void JSBundlerPlugin::finishCreation(JSC::VM& vm) reifyStaticProperties(vm, JSBundlerPlugin::info(), JSBundlerPluginHashTable, *this); } -extern "C" bool JSBundlerPlugin__anyMatches(Bun::JSBundlerPlugin* pluginObject, const ZigString* namespaceString, const ZigString* path, bool isOnLoad) +extern "C" bool JSBundlerPlugin__anyMatches(Bun::JSBundlerPlugin* pluginObject, const BunString* namespaceString, const BunString* path, bool isOnLoad) { return pluginObject->plugin.anyMatchesCrossThread(pluginObject->vm(), namespaceString, path, isOnLoad); } -extern "C" void JSBundlerPlugin__matchOnLoad(JSC::JSGlobalObject* globalObject, Bun::JSBundlerPlugin* plugin, const ZigString* namespaceString, const ZigString* path, void* context, uint8_t defaultLoaderId) +extern "C" void JSBundlerPlugin__matchOnLoad(JSC::JSGlobalObject* globalObject, Bun::JSBundlerPlugin* plugin, const BunString* namespaceString, const BunString* path, void* context, uint8_t defaultLoaderId) { - WTF::String namespaceStringStr = namespaceString ? Zig::toStringCopy(*namespaceString) : WTF::String(); - WTF::String pathStr = path ? Zig::toStringCopy(*path) : WTF::String(); + WTF::String namespaceStringStr = namespaceString ? Bun::toWTFString(*namespaceString) : WTF::String(); + WTF::String pathStr = path ? Bun::toWTFString(*path) : WTF::String(); JSFunction* function = plugin->onLoadFunction.get(plugin); if (UNLIKELY(!function)) @@ -306,7 +316,7 @@ extern "C" void JSBundlerPlugin__matchOnLoad(JSC::JSGlobalObject* globalObject, auto exception = scope.exception(); scope.clearException(); if (!plugin->plugin.tombstoned) { - JSBundlerPlugin__addError( + plugin->plugin.addError( context, plugin->plugin.config, JSC::JSValue::encode(exception), @@ -315,14 +325,14 @@ extern "C" void JSBundlerPlugin__matchOnLoad(JSC::JSGlobalObject* globalObject, } } -extern "C" void JSBundlerPlugin__matchOnResolve(JSC::JSGlobalObject* globalObject, Bun::JSBundlerPlugin* plugin, const ZigString* namespaceString, const ZigString* path, const ZigString* importer, void* context, uint8_t kindId) +extern "C" void JSBundlerPlugin__matchOnResolve(JSC::JSGlobalObject* globalObject, Bun::JSBundlerPlugin* plugin, const BunString* namespaceString, const BunString* path, const BunString* importer, void* context, uint8_t kindId) { - WTF::String namespaceStringStr = namespaceString ? Zig::toStringCopy(*namespaceString) : WTF::String("file"_s); + WTF::String namespaceStringStr = namespaceString ? Bun::toWTFString(*namespaceString) : WTF::String("file"_s); if (namespaceStringStr.length() == 0) { namespaceStringStr = WTF::String("file"_s); } - WTF::String pathStr = path ? Zig::toStringCopy(*path) : WTF::String(); - WTF::String importerStr = importer ? Zig::toStringCopy(*importer) : WTF::String(); + WTF::String pathStr = path ? Bun::toWTFString(*path) : WTF::String(); + WTF::String importerStr = importer ? Bun::toWTFString(*importer) : WTF::String(); auto& vm = globalObject->vm(); JSFunction* function = plugin->onResolveFunction.get(plugin); diff --git a/src/bun.js/bindings/JSBundlerPlugin.h b/src/bun.js/bindings/JSBundlerPlugin.h index 08aa1d140..4d82cdc1b 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.h +++ b/src/bun.js/bindings/JSBundlerPlugin.h @@ -9,6 +9,10 @@ #include #include +typedef void (*JSBundlerPluginAddErrorCallback)(void*, void*, JSC::EncodedJSValue, JSC::EncodedJSValue); +typedef void (*JSBundlerPluginOnLoadAsyncCallback)(void*, void*, JSC::EncodedJSValue, JSC::EncodedJSValue); +typedef void (*JSBundlerPluginOnResolveAsyncCallback)(void*, void*, JSC::EncodedJSValue, JSC::EncodedJSValue, JSC::EncodedJSValue); + namespace Bun { using namespace JSC; @@ -42,10 +46,13 @@ public: }; public: - bool anyMatchesCrossThread(JSC::VM&, const ZigString* namespaceStr, const ZigString* path, bool isOnLoad); + bool anyMatchesCrossThread(JSC::VM&, const BunString* namespaceStr, const BunString* path, bool isOnLoad); void tombstone() { tombstoned = true; } - BundlerPlugin(void* config, BunPluginTarget target) + BundlerPlugin(void* config, BunPluginTarget target, JSBundlerPluginAddErrorCallback addError, JSBundlerPluginOnLoadAsyncCallback onLoadAsync, JSBundlerPluginOnResolveAsyncCallback onResolveAsync) + : addError(addError) + , onLoadAsync(onLoadAsync) + , onResolveAsync(onResolveAsync) { this->target = target; this->config = config; @@ -54,6 +61,10 @@ public: NamespaceList onLoad = {}; NamespaceList onResolve = {}; BunPluginTarget target { BunPluginTargetBrowser }; + + JSBundlerPluginAddErrorCallback addError; + JSBundlerPluginOnLoadAsyncCallback onLoadAsync; + JSBundlerPluginOnResolveAsyncCallback onResolveAsync; void* config { nullptr }; bool tombstoned { false }; }; -- cgit v1.2.3 From fceacea37ce735c1417ff4e3bbb3fe5b38db44e0 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 7 Jul 2023 22:01:02 -0700 Subject: Unmark as TODO --- test/bundler/bundler_edgecase.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/bundler/bundler_edgecase.test.ts b/test/bundler/bundler_edgecase.test.ts index aa1f68688..bbbe4270b 100644 --- a/test/bundler/bundler_edgecase.test.ts +++ b/test/bundler/bundler_edgecase.test.ts @@ -320,7 +320,6 @@ describe("bundler", () => { }, }); itBundled("edgecase/JSONDefaultAndNamedImport", { - // We don't support rewriting default import to property acceses yet todo: true, files: { "/entry.js": /* js */ ` @@ -662,7 +661,6 @@ describe("bundler", () => { target: "bun", }); itBundled("edgecase/RuntimeExternalRequire", { - todo: true, files: { "/entry.ts": /* ts */ ` console.log(require("hello-1").type); -- cgit v1.2.3 From e26d3821ce2282d042d51246abcdcec76c3944d1 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 7 Jul 2023 22:01:43 -0700 Subject: Update settings.json --- .vscode/settings.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 454cd849d..81fc2affe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,8 @@ "search.followSymlinks": false, "search.useIgnoreFiles": true, "zig.buildOnSave": false, + // We do this until we upgrade to latest Zig so that zls doesn't break our code. + "zig.formattingProvider": "extension", "zig.buildArgs": ["obj", "-Dfor-editor"], "zig.buildOption": "build", "zig.buildFilePath": "${workspaceFolder}/build.zig", -- cgit v1.2.3 From 5846ad00edddd89127873bed8df911b48c5bc792 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 7 Jul 2023 22:01:58 -0700 Subject: Add assertion --- src/cli/test_command.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 445473839..dc67c6d98 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -363,6 +363,9 @@ const Scanner = struct { return; } + if (comptime Environment.allow_assert) + std.debug.assert(!strings.contains(name, std.fs.path.sep_str ++ "node_modules" ++ std.fs.path.sep_str)); + for (this.exclusion_names) |exclude_name| { if (strings.eql(exclude_name, name)) return; } -- cgit v1.2.3 From fa632c33312ad3b4dca9e4bddaa2af1c7db07597 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 8 Jul 2023 04:00:55 -0700 Subject: Fix bug with decorators not being generated in `export default class` (#3577) * Fix bug with decorators not being generated in `export default class` * Update decorator-export-default-class-fixture.ts --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/js_parser.zig | 13 ++++++++++++- test/transpiler/decorator-export-default-class-fixture.ts | 10 ++++++++++ test/transpiler/decorators.test.ts | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/transpiler/decorator-export-default-class-fixture.ts diff --git a/src/js_parser.zig b/src/js_parser.zig index 230a09fd0..df5c84294 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -18146,7 +18146,18 @@ fn NewParser_( data.default_name = createDefaultName(p, stmt.loc) catch unreachable; } - stmts.append(stmt.*) catch unreachable; + var class_stmts = p.lowerClass(.{ .stmt = s2 }); + + if (class_stmts.len > 1) { + std.debug.assert(class_stmts[0].data == .s_class); + data.value.stmt = class_stmts[0]; + stmts.append(stmt.*) catch {}; + stmts.appendSlice(class_stmts[1..]) catch {}; + } else { + data.value.stmt = class_stmts[0]; + stmts.append(stmt.*) catch {}; + } + return; }, else => {}, diff --git a/test/transpiler/decorator-export-default-class-fixture.ts b/test/transpiler/decorator-export-default-class-fixture.ts new file mode 100644 index 000000000..901c17718 --- /dev/null +++ b/test/transpiler/decorator-export-default-class-fixture.ts @@ -0,0 +1,10 @@ +function decorator(target: any, propertyKey: any) { + target[propertyKey + "decorated"] = true; +} + +export default class DecoratedClass { + @decorator + method() { + return 42; + } +} diff --git a/test/transpiler/decorators.test.ts b/test/transpiler/decorators.test.ts index 8769ea2bc..ad0980930 100644 --- a/test/transpiler/decorators.test.ts +++ b/test/transpiler/decorators.test.ts @@ -1,5 +1,6 @@ // @ts-nocheck import { test, expect, describe } from "bun:test"; +import DecoratedClass from "./decorator-export-default-class-fixture"; test("decorator order of evaluation", () => { let counter = 0; @@ -988,3 +989,7 @@ describe("constructor statements", () => { expect(a.v2).toBe(0); }); }); + +test("export default class works", () => { + expect(new DecoratedClass()["methoddecorated"]).toBe(true); +}); -- cgit v1.2.3 From aa8b832ef61ada31176d248e716074ff22bb9dee Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 8 Jul 2023 14:26:19 -0700 Subject: Implement `process.on("beforeExit", cb)` and `process.on("exit", cb)` (#3576) * Support `process.on('beforeExit')` and `process.on('exit')` * [bun:sqlite] Always call sqlite3_close on exit * Update process.test.js --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/Process.cpp | 189 +++++++++++++++++---- src/bun.js/bindings/ZigGlobalObject.h | 2 + src/bun.js/bindings/sqlite/JSSQLStatement.cpp | 86 +++++++--- src/bun.js/bindings/sqlite/JSSQLStatement.h | 15 -- src/bun.js/javascript.zig | 50 ++++++ src/bun.js/node/types.zig | 4 +- src/bun_js.zig | 14 +- test/js/node/process/process-exit-fixture.js | 16 ++ test/js/node/process/process-exitCode-fixture.js | 7 + test/js/node/process/process-exitCode-with-exit.js | 8 + .../node/process/process-onBeforeExit-fixture.js | 7 + .../node/process/process-onBeforeExit-keepAlive.js | 18 ++ test/js/node/process/process.test.js | 64 ++++++- 13 files changed, 402 insertions(+), 78 deletions(-) create mode 100644 test/js/node/process/process-exit-fixture.js create mode 100644 test/js/node/process/process-exitCode-fixture.js create mode 100644 test/js/node/process/process-exitCode-with-exit.js create mode 100644 test/js/node/process/process-onBeforeExit-fixture.js create mode 100644 test/js/node/process/process-onBeforeExit-keepAlive.js diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 6320deaf1..1d6b5d33a 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -42,6 +42,35 @@ static JSC_DECLARE_CUSTOM_GETTER(Process_getPID); static JSC_DECLARE_CUSTOM_GETTER(Process_getPPID); static JSC_DECLARE_HOST_FUNCTION(Process_functionCwd); +static bool processIsExiting = false; + +extern "C" uint8_t Bun__getExitCode(void*); +extern "C" uint8_t Bun__setExitCode(void*, uint8_t); +extern "C" void* Bun__getVM(); +extern "C" Zig::GlobalObject* Bun__getDefaultGlobal(); + +static void dispatchExitInternal(JSC::JSGlobalObject* globalObject, Process* process, int exitCode) +{ + + if (processIsExiting) + return; + processIsExiting = true; + auto& emitter = process->wrapped(); + auto& vm = globalObject->vm(); + + if (vm.hasTerminationRequest() || vm.hasExceptionsAfterHandlingTraps()) + return; + + auto event = Identifier::fromString(vm, "exit"_s); + if (!emitter.hasEventListeners(event)) { + return; + } + process->putDirect(vm, Identifier::fromString(vm, "_exiting"_s), jsBoolean(true), 0); + + MarkedArgumentBuffer arguments; + arguments.append(jsNumber(exitCode)); + emitter.emit(event, arguments); +} static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, int fd) { @@ -324,6 +353,29 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionUmask, extern "C" uint64_t Bun__readOriginTimer(void*); extern "C" double Bun__readOriginTimerStart(void*); +// https://github.com/nodejs/node/blob/1936160c31afc9780e4365de033789f39b7cbc0c/src/api/hooks.cc#L49 +extern "C" void Process__dispatchOnBeforeExit(Zig::GlobalObject* globalObject, uint8_t exitCode) +{ + if (!globalObject->hasProcessObject()) { + return; + } + + auto* process = jsCast(globalObject->processObject()); + MarkedArgumentBuffer arguments; + arguments.append(jsNumber(exitCode)); + process->wrapped().emit(Identifier::fromString(globalObject->vm(), "beforeExit"_s), arguments); +} + +extern "C" void Process__dispatchOnExit(Zig::GlobalObject* globalObject, uint8_t exitCode) +{ + if (!globalObject->hasProcessObject()) { + return; + } + + auto* process = jsCast(globalObject->processObject()); + dispatchExitInternal(globalObject, process, exitCode); +} + JSC_DEFINE_HOST_FUNCTION(Process_functionUptime, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { @@ -336,14 +388,38 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionUptime, JSC_DEFINE_HOST_FUNCTION(Process_functionExit, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { - if (callFrame->argumentCount() == 0) { - // TODO: exitCode - Bun__Process__exit(globalObject, 0); + auto throwScope = DECLARE_THROW_SCOPE(globalObject->vm()); + uint8_t exitCode = 0; + JSValue arg0 = callFrame->argument(0); + if (arg0.isNumber()) { + if (!arg0.isInt32()) { + throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + int extiCode32 = arg0.toInt32(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); + + if (extiCode32 < 0 || extiCode32 > 127) { + throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer between 0 and 127"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + exitCode = static_cast(extiCode32); + } else if (!arg0.isUndefinedOrNull()) { + throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); } else { - Bun__Process__exit(globalObject, callFrame->argument(0).toInt32(globalObject)); + exitCode = Bun__getExitCode(Bun__getVM()); + } + + auto* zigGlobal = jsDynamicCast(globalObject); + if (UNLIKELY(!zigGlobal)) { + zigGlobal = Bun__getDefaultGlobal(); } - return JSC::JSValue::encode(JSC::jsUndefined()); + Process__dispatchOnExit(zigGlobal, exitCode); + Bun__Process__exit(zigGlobal, exitCode); } extern "C" uint64_t Bun__readOriginTimer(void*); @@ -391,18 +467,15 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, array->setIndexQuickly(vm, 1, JSC::jsNumber(nanoseconds)); return JSC::JSValue::encode(JSC::JSValue(array)); } -static JSC_DECLARE_HOST_FUNCTION(Process_functionHRTimeBigInt); -static JSC_DEFINE_HOST_FUNCTION(Process_functionHRTimeBigInt, +JSC_DEFINE_HOST_FUNCTION(Process_functionHRTimeBigInt, (JSC::JSGlobalObject * globalObject_, JSC::CallFrame* callFrame)) { Zig::GlobalObject* globalObject = reinterpret_cast(globalObject_); return JSC::JSValue::encode(JSValue(JSC::JSBigInt::createFrom(globalObject, Bun__readOriginTimer(globalObject->bunVM())))); } -static JSC_DECLARE_HOST_FUNCTION(Process_functionChdir); - -static JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, +JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); @@ -611,6 +684,46 @@ JSC_DEFINE_CUSTOM_GETTER(Process_lazyExecArgvGetter, (JSC::JSGlobalObject * glob return ret; } +JSC_DEFINE_CUSTOM_GETTER(Process__getExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) +{ + Process* process = jsDynamicCast(JSValue::decode(thisValue)); + if (!process) { + return JSValue::encode(jsUndefined()); + } + + return JSValue::encode(jsNumber(Bun__getExitCode(jsCast(process->globalObject())->bunVM()))); +} +JSC_DEFINE_CUSTOM_SETTER(Process__setExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName)) +{ + Process* process = jsDynamicCast(JSValue::decode(thisValue)); + if (!process) { + return false; + } + + auto throwScope = DECLARE_THROW_SCOPE(process->vm()); + JSValue exitCode = JSValue::decode(value); + if (!exitCode.isNumber()) { + throwTypeError(lexicalGlobalObject, throwScope, "exitCode must be a number"_s); + return false; + } + + if (!exitCode.isInt32()) { + throwRangeError(lexicalGlobalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + int exitCodeInt = exitCode.toInt32(lexicalGlobalObject); + RETURN_IF_EXCEPTION(throwScope, false); + if (exitCodeInt < 0 || exitCodeInt > 127) { + throwRangeError(lexicalGlobalObject, throwScope, "exitCode must be between 0 and 127"_s); + return false; + } + + void* ptr = jsCast(process->globalObject())->bunVM(); + Bun__setExitCode(ptr, static_cast(exitCodeInt)); + return true; +} + JSC_DEFINE_CUSTOM_GETTER(Process_lazyExecPathGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) { JSC::JSObject* thisObject = JSValue::decode(thisValue).getObject(); @@ -677,39 +790,42 @@ void Process::finishCreation(JSC::VM& vm) vm, clientData->builtinNames().versionsPublicName(), JSC::CustomGetterSetter::create(vm, Process_getVersionsLazy, Process_setVersionsLazy), 0); // this should be transpiled out, but just incase - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "browser"_s), - JSC::JSValue(false)); + this->putDirect(vm, JSC::Identifier::fromString(vm, "browser"_s), + JSC::JSValue(false), PropertyAttribute::DontEnum | 0); - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "exitCode"_s), - JSC::JSValue(JSC::jsNumber(0))); + this->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "exitCode"_s), + JSC::CustomGetterSetter::create(vm, + Process__getExitCode, + Process__setExitCode), + 0); - this->putDirect(this->vm(), clientData->builtinNames().versionPublicName(), - JSC::jsString(this->vm(), makeString("v", REPORTED_NODE_VERSION))); + this->putDirect(vm, clientData->builtinNames().versionPublicName(), + JSC::jsString(vm, makeString("v", REPORTED_NODE_VERSION))); // this gives some way of identifying at runtime whether the SSR is happening in node or not. // this should probably be renamed to what the name of the bundler is, instead of "notNodeJS" // but it must be something that won't evaluate to truthy in Node.js - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "isBun"_s), JSC::JSValue(true)); + this->putDirect(vm, JSC::Identifier::fromString(vm, "isBun"_s), JSC::JSValue(true)); #if defined(__APPLE__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "platform"_s), - JSC::jsString(this->vm(), makeAtomString("darwin"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "platform"_s), + JSC::jsString(vm, makeAtomString("darwin"))); #else - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "platform"_s), - JSC::jsString(this->vm(), makeAtomString("linux"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "platform"_s), + JSC::jsString(vm, makeAtomString("linux"))); #endif #if defined(__x86_64__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"_s), - JSC::jsString(this->vm(), makeAtomString("x64"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), + JSC::jsString(vm, makeAtomString("x64"))); #elif defined(__i386__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"_s), - JSC::jsString(this->vm(), makeAtomString("x86"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), + JSC::jsString(vm, makeAtomString("x86"))); #elif defined(__arm__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"_s), - JSC::jsString(this->vm(), makeAtomString("arm"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), + JSC::jsString(vm, makeAtomString("arm"))); #elif defined(__aarch64__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"_s), - JSC::jsString(this->vm(), makeAtomString("arm64"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), + JSC::jsString(vm, makeAtomString("arm64"))); #endif JSC::JSFunction* hrtime = JSC::JSFunction::create(vm, globalObject, 0, @@ -719,7 +835,7 @@ void Process::finishCreation(JSC::VM& vm) MAKE_STATIC_STRING_IMPL("bigint"), Process_functionHRTimeBigInt, ImplementationVisibility::Public); hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt); - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "hrtime"_s), hrtime); + this->putDirect(vm, JSC::Identifier::fromString(vm, "hrtime"_s), hrtime); this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "release"_s)), JSC::CustomGetterSetter::create(vm, Process_getterRelease, Process_setterRelease), 0); @@ -733,7 +849,10 @@ void Process::finishCreation(JSC::VM& vm) this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "stdin"_s)), JSC::CustomGetterSetter::create(vm, Process_lazyStdinGetter, Process_defaultSetter), 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "abort"_s), + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "abort"_s), + 0, Process_functionAbort, ImplementationVisibility::Public, NoIntrinsic, 0); + + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "abort"_s), 0, Process_functionAbort, ImplementationVisibility::Public, NoIntrinsic, 0); this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "argv0"_s)), @@ -745,13 +864,13 @@ void Process::finishCreation(JSC::VM& vm) this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "execArgv"_s)), JSC::CustomGetterSetter::create(vm, Process_lazyExecArgvGetter, Process_defaultSetter), 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "uptime"_s), + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "uptime"_s), 0, Process_functionUptime, ImplementationVisibility::Public, NoIntrinsic, 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "umask"_s), + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "umask"_s), 1, Process_functionUmask, ImplementationVisibility::Public, NoIntrinsic, 0); - this->putDirectBuiltinFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "binding"_s), + this->putDirectBuiltinFunction(vm, globalObject, JSC::Identifier::fromString(vm, "binding"_s), processObjectInternalsBindingCodeGenerator(vm), 0); @@ -788,7 +907,7 @@ void Process::finishCreation(JSC::VM& vm) config->putDirect(vm, JSC::Identifier::fromString(vm, "variables"_s), variables, 0); this->putDirect(vm, JSC::Identifier::fromString(vm, "config"_s), config, 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "emitWarning"_s), + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "emitWarning"_s), 1, Process_emitWarning, ImplementationVisibility::Public, NoIntrinsic, 0); JSC::JSFunction* requireDotMainFunction = JSFunction::create( diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index da6ba92a0..f44212da1 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -270,6 +270,8 @@ public: JSWeakMap* vmModuleContextMap() { return m_vmModuleContextMap.getInitializedOnMainThread(this); } + bool hasProcessObject() const { return m_processObject.isInitialized(); } + JSC::JSObject* processObject() { return m_processObject.getInitializedOnMainThread(this); diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index a6855fd19..61ac91ba7 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -107,6 +107,50 @@ static JSC_DECLARE_HOST_FUNCTION(jsSQLStatementDeserialize); return JSValue::encode(jsUndefined()); \ } +class VersionSqlite3 { +public: + explicit VersionSqlite3(sqlite3* db) + : db(db) + , version(0) + { + } + sqlite3* db; + std::atomic version; +}; + +class SQLiteSingleton { +public: + Vector databases; + Vector> schema_versions; +}; + +static SQLiteSingleton* _instance = nullptr; + +static Vector& databases() +{ + if (!_instance) { + _instance = new SQLiteSingleton(); + _instance->databases = Vector(); + _instance->databases.reserveInitialCapacity(4); + _instance->schema_versions = Vector>(); + } + + return _instance->databases; +} + +extern "C" void Bun__closeAllSQLiteDatabasesForTermination() +{ + if (!_instance) { + return; + } + auto& dbs = _instance->databases; + + for (auto& db : dbs) { + if (db->db) + sqlite3_close_v2(db->db); + } +} + namespace WebCore { using namespace JSC; @@ -272,10 +316,6 @@ void JSSQLStatement::destroy(JSC::JSCell* cell) void JSSQLStatementConstructor::destroy(JSC::JSCell* cell) { - JSSQLStatementConstructor* thisObject = static_cast(cell); - for (auto version_db : thisObject->databases) { - delete version_db; - } } static inline bool rebindValue(JSC::JSGlobalObject* lexicalGlobalObject, sqlite3_stmt* stmt, int i, JSC::JSValue value, JSC::ThrowScope& scope, bool clone) @@ -547,8 +587,8 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementDeserialize, (JSC::JSGlobalObject * lexic return JSValue::encode(JSC::jsUndefined()); } - auto count = thisObject->databases.size(); - thisObject->databases.append(new VersionSqlite3(db)); + auto count = databases().size(); + databases().append(new VersionSqlite3(db)); RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(count))); } @@ -565,12 +605,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSerialize, (JSC::JSGlobalObject * lexical } int32_t dbIndex = callFrame->argument(0).toInt32(lexicalGlobalObject); - if (UNLIKELY(dbIndex < 0 || dbIndex >= thisObject->databases.size())) { + if (UNLIKELY(dbIndex < 0 || dbIndex >= databases().size())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } - sqlite3* db = thisObject->databases[dbIndex]->db; + sqlite3* db = databases()[dbIndex]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Can't do this on a closed database"_s)); return JSValue::encode(JSC::jsUndefined()); @@ -606,7 +646,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje } int32_t dbIndex = callFrame->argument(0).toInt32(lexicalGlobalObject); - if (UNLIKELY(dbIndex < 0 || dbIndex >= thisObject->databases.size())) { + if (UNLIKELY(dbIndex < 0 || dbIndex >= databases().size())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } @@ -620,7 +660,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje auto extensionString = extension.toWTFString(lexicalGlobalObject); RETURN_IF_EXCEPTION(scope, {}); - sqlite3* db = thisObject->databases[dbIndex]->db; + sqlite3* db = databases()[dbIndex]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Can't do this on a closed database"_s)); return JSValue::encode(JSC::jsUndefined()); @@ -661,11 +701,11 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l } int32_t handle = callFrame->argument(0).toInt32(lexicalGlobalObject); - if (thisObject->databases.size() < handle) { + if (databases().size() < handle) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } - sqlite3* db = thisObject->databases[handle]->db; + sqlite3* db = databases()[handle]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Database has closed"_s)); @@ -724,7 +764,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l rc = sqlite3_step(statement); if (!sqlite3_stmt_readonly(statement)) { - thisObject->databases[handle]->version++; + databases()[handle]->version++; } while (rc == SQLITE_ROW) { @@ -765,12 +805,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementIsInTransactionFunction, (JSC::JSGlobalOb int32_t handle = dbNumber.toInt32(lexicalGlobalObject); - if (handle < 0 || handle > thisObject->databases.size()) { + if (handle < 0 || handle > databases().size()) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } - sqlite3* db = thisObject->databases[handle]->db; + sqlite3* db = databases()[handle]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Database has closed"_s)); @@ -803,12 +843,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO } int32_t handle = dbNumber.toInt32(lexicalGlobalObject); - if (handle < 0 || handle > thisObject->databases.size()) { + if (handle < 0 || handle > databases().size()) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } - sqlite3* db = thisObject->databases[handle]->db; + sqlite3* db = databases()[handle]->db; if (!db) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Cannot use a closed database"_s)); return JSValue::encode(JSC::jsUndefined()); @@ -848,7 +888,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO auto* structure = JSSQLStatement::createStructure(vm, lexicalGlobalObject, lexicalGlobalObject->objectPrototype()); // auto* structure = JSSQLStatement::createStructure(vm, globalObject(), thisObject->getDirect(vm, vm.propertyNames->prototype)); JSSQLStatement* sqlStatement = JSSQLStatement::create( - structure, reinterpret_cast(lexicalGlobalObject), statement, thisObject->databases[handle]); + structure, reinterpret_cast(lexicalGlobalObject), statement, databases()[handle]); if (bindings.isObject()) { auto* castedThis = sqlStatement; DO_REBIND(bindings) @@ -924,8 +964,8 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementOpenStatementFunction, (JSC::JSGlobalObje status = sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1, NULL); assert(status == SQLITE_OK); - auto count = constructor->databases.size(); - constructor->databases.append(new VersionSqlite3(db)); + auto count = databases().size(); + databases().append(new VersionSqlite3(db)); RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(count))); } @@ -956,12 +996,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj int dbIndex = dbNumber.toInt32(lexicalGlobalObject); - if (dbIndex < 0 || dbIndex >= constructor->databases.size()) { + if (dbIndex < 0 || dbIndex >= databases().size()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(jsUndefined()); } - sqlite3* db = constructor->databases[dbIndex]->db; + sqlite3* db = databases()[dbIndex]->db; // no-op if already closed if (!db) { return JSValue::encode(jsUndefined()); @@ -973,7 +1013,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj return JSValue::encode(jsUndefined()); } - constructor->databases[dbIndex]->db = nullptr; + databases()[dbIndex]->db = nullptr; return JSValue::encode(jsUndefined()); } diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.h b/src/bun.js/bindings/sqlite/JSSQLStatement.h index e63b99fbb..8566fcdd9 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.h +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.h @@ -47,17 +47,6 @@ namespace WebCore { -class VersionSqlite3 { -public: - explicit VersionSqlite3(sqlite3* db) - : db(db) - , version(0) - { - } - sqlite3* db; - std::atomic version; -}; - class JSSQLStatementConstructor final : public JSC::JSFunction { public: using Base = JSC::JSFunction; @@ -82,13 +71,9 @@ public: return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); } - Vector databases; - Vector> schema_versions; - private: JSSQLStatementConstructor(JSC::VM& vm, NativeExecutable* native, JSGlobalObject* globalObject, JSC::Structure* structure) : Base(vm, native, globalObject, structure) - , databases() { } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index b696c6cf2..7d2435823 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -334,6 +334,33 @@ pub export fn Bun__onDidAppendPlugin(jsc_vm: *VirtualMachine, globalObject: *JSG jsc_vm.bundler.linker.plugin_runner = &jsc_vm.plugin_runner.?; } +pub const ExitHandler = struct { + exit_code: u8 = 0, + + pub export fn Bun__getExitCode(vm: *VirtualMachine) u8 { + return vm.exit_handler.exit_code; + } + + pub export fn Bun__setExitCode(vm: *VirtualMachine, code: u8) void { + vm.exit_handler.exit_code = code; + } + + extern fn Process__dispatchOnBeforeExit(*JSC.JSGlobalObject, code: u8) void; + extern fn Process__dispatchOnExit(*JSC.JSGlobalObject, code: u8) void; + extern fn Bun__closeAllSQLiteDatabasesForTermination() void; + + pub fn dispatchOnExit(this: *ExitHandler) void { + var vm = @fieldParentPtr(VirtualMachine, "exit_handler", this); + Process__dispatchOnExit(vm.global, this.exit_code); + Bun__closeAllSQLiteDatabasesForTermination(); + } + + pub fn dispatchOnBeforeExit(this: *ExitHandler) void { + var vm = @fieldParentPtr(VirtualMachine, "exit_handler", this); + Process__dispatchOnBeforeExit(vm.global, this.exit_code); + } +}; + /// TODO: rename this to ScriptExecutionContext /// This is the shared global state for a single JS instance execution /// Today, Bun is one VM per thread, so the name "VirtualMachine" sort of makes sense @@ -376,6 +403,7 @@ pub const VirtualMachine = struct { plugin_runner: ?PluginRunner = null, is_main_thread: bool = false, last_reported_error_for_dedupe: JSValue = .zero, + exit_handler: ExitHandler = .{}, /// Do not access this field directly /// It exists in the VirtualMachine struct so that @@ -620,7 +648,29 @@ pub const VirtualMachine = struct { loop.run(); } + pub fn onBeforeExit(this: *VirtualMachine) void { + this.exit_handler.dispatchOnBeforeExit(); + var dispatch = false; + while (true) { + while (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.uws_event_loop.?.active > 0) : (dispatch = true) { + this.tick(); + this.eventLoop().autoTickActive(); + } + + if (dispatch) { + this.exit_handler.dispatchOnBeforeExit(); + dispatch = false; + + if (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.uws_event_loop.?.active > 0) continue; + } + + break; + } + } + pub fn onExit(this: *VirtualMachine) void { + this.exit_handler.dispatchOnExit(); + var rare_data = this.rare_data orelse return; var hook = rare_data.cleanup_hook orelse return; hook.execute(); diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index 96d04636e..553b292d6 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -2202,7 +2202,9 @@ pub const Process = struct { } } - pub fn exit(_: *JSC.JSGlobalObject, code: i32) callconv(.C) void { + pub fn exit(globalObject: *JSC.JSGlobalObject, code: i32) callconv(.C) void { + globalObject.bunVM().onExit(); + std.os.exit(@truncate(u8, @intCast(u32, @max(code, 0)))); } diff --git a/src/bun_js.zig b/src/bun_js.zig index 63ffe0611..72b7f8de9 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -248,6 +248,8 @@ pub const Run = struct { vm.eventLoop().tick(); vm.eventLoop().tickPossiblyForever(); } else { + vm.exit_handler.exit_code = 1; + vm.onExit(); Global.exit(1); } } @@ -279,6 +281,8 @@ pub const Run = struct { vm.eventLoop().tick(); vm.eventLoop().tickPossiblyForever(); } else { + vm.exit_handler.exit_code = 1; + vm.onExit(); Global.exit(1); } } @@ -315,6 +319,8 @@ pub const Run = struct { vm.eventLoop().autoTickActive(); } + vm.onBeforeExit(); + if (this.vm.pending_internal_promise.status(vm.global.vm()) == .Rejected and prev_promise != this.vm.pending_internal_promise) { prev_promise = this.vm.pending_internal_promise; vm.onUnhandledError(this.vm.global, this.vm.pending_internal_promise.result(vm.global.vm())); @@ -332,6 +338,8 @@ pub const Run = struct { vm.tick(); vm.eventLoop().autoTickActive(); } + + vm.onBeforeExit(); } if (vm.log.msgs.items.len > 0) { @@ -347,10 +355,14 @@ pub const Run = struct { vm.onUnhandledRejection = &onUnhandledRejectionBeforeClose; vm.global.handleRejectedPromises(); + if (this.any_unhandled and this.vm.exit_handler.exit_code == 0) { + this.vm.exit_handler.exit_code = 1; + } + const exit_code = this.vm.exit_handler.exit_code; vm.onExit(); if (!JSC.is_bindgen) JSC.napi.fixDeadCodeElimination(); - Global.exit(@intFromBool(this.any_unhandled)); + Global.exit(exit_code); } }; diff --git a/test/js/node/process/process-exit-fixture.js b/test/js/node/process/process-exit-fixture.js new file mode 100644 index 000000000..c5a492285 --- /dev/null +++ b/test/js/node/process/process-exit-fixture.js @@ -0,0 +1,16 @@ +process.on("beforeExit", () => { + throw new Error("process.on('beforeExit') called"); +}); + +if (process._exiting) { + throw new Error("process._exiting should be undefined"); +} + +process.on("exit", () => { + if (!process._exiting) { + throw new Error("process.on('exit') called with process._exiting false"); + } + console.log("PASS"); +}); + +process.exit(0); diff --git a/test/js/node/process/process-exitCode-fixture.js b/test/js/node/process/process-exitCode-fixture.js new file mode 100644 index 000000000..2d5182d93 --- /dev/null +++ b/test/js/node/process/process-exitCode-fixture.js @@ -0,0 +1,7 @@ +process.exitCode = Number(process.argv.at(-1)); +process.on("exit", code => { + if (code !== process.exitCode) { + throw new Error("process.exitCode should be " + process.exitCode); + } + console.log("PASS"); +}); diff --git a/test/js/node/process/process-exitCode-with-exit.js b/test/js/node/process/process-exitCode-with-exit.js new file mode 100644 index 000000000..610975bc2 --- /dev/null +++ b/test/js/node/process/process-exitCode-with-exit.js @@ -0,0 +1,8 @@ +process.exitCode = Number(process.argv.at(-1)); +process.on("exit", code => { + if (code !== process.exitCode) { + throw new Error("process.exitCode should be " + process.exitCode); + } + console.log("PASS"); +}); +process.exit(); diff --git a/test/js/node/process/process-onBeforeExit-fixture.js b/test/js/node/process/process-onBeforeExit-fixture.js new file mode 100644 index 000000000..8cbdcebf0 --- /dev/null +++ b/test/js/node/process/process-onBeforeExit-fixture.js @@ -0,0 +1,7 @@ +process.on("beforeExit", () => { + console.log("beforeExit"); +}); + +process.on("exit", () => { + console.log("exit"); +}); diff --git a/test/js/node/process/process-onBeforeExit-keepAlive.js b/test/js/node/process/process-onBeforeExit-keepAlive.js new file mode 100644 index 000000000..45b20b763 --- /dev/null +++ b/test/js/node/process/process-onBeforeExit-keepAlive.js @@ -0,0 +1,18 @@ +let counter = 0; +process.on("beforeExit", () => { + if (process._exiting) { + throw new Error("process._exiting should be undefined"); + } + + console.log("beforeExit:", counter); + if (!counter++) { + setTimeout(() => {}, 1); + } +}); + +process.on("exit", () => { + if (!process._exiting) { + throw new Error("process.on('exit') called with process._exiting false"); + } + console.log("exit:", counter); +}); diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index 61ac3839c..c4701f664 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -1,8 +1,8 @@ -import { resolveSync, which } from "bun"; +import { resolveSync, spawnSync, which } from "bun"; import { describe, expect, it } from "bun:test"; import { existsSync, readFileSync, realpathSync } from "fs"; -import { bunExe } from "harness"; -import { basename, resolve } from "path"; +import { bunEnv, bunExe } from "harness"; +import { basename, join, resolve } from "path"; it("process", () => { // this property isn't implemented yet but it should at least return a string @@ -233,3 +233,61 @@ it("process.argv in testing", () => { // assert we aren't creating a new process.argv each call expect(process.argv).toBe(process.argv); }); + +describe("process.exitCode", () => { + it("validates int", () => { + expect(() => (process.exitCode = "potato")).toThrow("exitCode must be a number"); + expect(() => (process.exitCode = 1.2)).toThrow('The "code" argument must be an integer'); + expect(() => (process.exitCode = NaN)).toThrow('The "code" argument must be an integer'); + expect(() => (process.exitCode = Infinity)).toThrow('The "code" argument must be an integer'); + expect(() => (process.exitCode = -Infinity)).toThrow('The "code" argument must be an integer'); + expect(() => (process.exitCode = -1)).toThrow("exitCode must be between 0 and 127"); + }); + + it("works with implicit process.exit", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-exitCode-with-exit.js"), "42"], + env: bunEnv, + }); + expect(exitCode).toBe(42); + expect(stdout.toString().trim()).toBe("PASS"); + }); + + it("works with explicit process.exit", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-exitCode-fixture.js"), "42"], + env: bunEnv, + }); + expect(exitCode).toBe(42); + expect(stdout.toString().trim()).toBe("PASS"); + }); +}); + +it("process.exit", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-exit-fixture.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString().trim()).toBe("PASS"); +}); + +describe("process.onBeforeExit", () => { + it("emitted", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-onBeforeExit-fixture.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString().trim()).toBe("beforeExit\nexit"); + }); + + it("works with explicit process.exit", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-onBeforeExit-keepAlive.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString().trim()).toBe("beforeExit: 0\nbeforeExit: 1\nexit: 2"); + }); +}); -- cgit v1.2.3 From 59570fe237f91dd04ce8f37779902cffa4352010 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 8 Jul 2023 17:41:24 -0700 Subject: Handle case with TS decorators and export default anonymous class (#3578) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/js_parser.zig | 12 +++++++++++- .../decorator-export-default-class-fixture-anon.ts | 10 ++++++++++ test/transpiler/decorators.test.ts | 7 ++++++- test/transpiler/export-default-with-static-initializer.js | 5 +++++ test/transpiler/export-default.test.js | 6 ++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/transpiler/decorator-export-default-class-fixture-anon.ts create mode 100644 test/transpiler/export-default-with-static-initializer.js create mode 100644 test/transpiler/export-default.test.js diff --git a/src/js_parser.zig b/src/js_parser.zig index df5c84294..3c706b1bb 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -18146,10 +18146,20 @@ fn NewParser_( data.default_name = createDefaultName(p, stmt.loc) catch unreachable; } + // We only inject a name into classes when there is a decorator + if (class.class.has_decorators) { + if (class.class.class_name == null or + class.class.class_name.?.ref == null) + { + class.class.class_name = data.default_name; + } + } + + // This is to handle TS decorators, mostly. var class_stmts = p.lowerClass(.{ .stmt = s2 }); + std.debug.assert(class_stmts[0].data == .s_class); if (class_stmts.len > 1) { - std.debug.assert(class_stmts[0].data == .s_class); data.value.stmt = class_stmts[0]; stmts.append(stmt.*) catch {}; stmts.appendSlice(class_stmts[1..]) catch {}; diff --git a/test/transpiler/decorator-export-default-class-fixture-anon.ts b/test/transpiler/decorator-export-default-class-fixture-anon.ts new file mode 100644 index 000000000..bf81afa2c --- /dev/null +++ b/test/transpiler/decorator-export-default-class-fixture-anon.ts @@ -0,0 +1,10 @@ +function decorator(target: any, propertyKey: any) { + target[propertyKey + "decorated"] = true; +} + +export default class { + @decorator + method() { + return 42; + } +} diff --git a/test/transpiler/decorators.test.ts b/test/transpiler/decorators.test.ts index ad0980930..100ecc3bc 100644 --- a/test/transpiler/decorators.test.ts +++ b/test/transpiler/decorators.test.ts @@ -1,6 +1,7 @@ // @ts-nocheck import { test, expect, describe } from "bun:test"; import DecoratedClass from "./decorator-export-default-class-fixture"; +import DecoratedAnonClass from "./decorator-export-default-class-fixture-anon"; test("decorator order of evaluation", () => { let counter = 0; @@ -990,6 +991,10 @@ describe("constructor statements", () => { }); }); -test("export default class works", () => { +test("export default class Named works", () => { expect(new DecoratedClass()["methoddecorated"]).toBe(true); }); + +test("export default class works (anonymous name)", () => { + expect(new DecoratedAnonClass()["methoddecorated"]).toBe(true); +}); diff --git a/test/transpiler/export-default-with-static-initializer.js b/test/transpiler/export-default-with-static-initializer.js new file mode 100644 index 000000000..2d390b008 --- /dev/null +++ b/test/transpiler/export-default-with-static-initializer.js @@ -0,0 +1,5 @@ +export default class { + static { + this.boop = "boop"; + } +} diff --git a/test/transpiler/export-default.test.js b/test/transpiler/export-default.test.js new file mode 100644 index 000000000..e557ffe00 --- /dev/null +++ b/test/transpiler/export-default.test.js @@ -0,0 +1,6 @@ +import WithStatic from "./export-default-with-static-initializer"; +import { test, expect } from "bun:test"; + +test("static initializer", () => { + expect(WithStatic.boop).toBe("boop"); +}); -- 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(-) 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 From ca42c820d29400d8bd93f493064db029f6d4420d Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 9 Jul 2023 16:33:49 -0700 Subject: Implement nearly all of `process` object methods and properties (#3581) * Add special case * Make process object load faster * Fix openStdin --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/CommonJSModuleRecord.cpp | 6 + src/bun.js/bindings/Process.cpp | 960 +++++++++++++++------------ src/bun.js/bindings/Process.h | 2 +- src/bun.js/bindings/Process.lut.h | 208 ++++++ src/bun.js/bindings/ZigGlobalObject.cpp | 6 +- src/bun.js/modules/ProcessModule.h | 8 + src/js/builtins/ProcessObjectInternals.ts | 22 +- src/js/builtins/codegen/index.ts | 30 + src/js/out/WebCoreJSBuiltins.cpp | 16 +- src/js/out/WebCoreJSBuiltins.h | 4 +- 10 files changed, 812 insertions(+), 450 deletions(-) create mode 100644 src/bun.js/bindings/Process.lut.h diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index c7dac89c2..8adba197c 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -817,6 +817,12 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireCommonJS, (JSGlobalObject * lexicalGlo WTF::String specifier = specifierValue.toWTFString(globalObject); RETURN_IF_EXCEPTION(throwScope, {}); + // Special-case for "process" to just return the process object directly. + if (UNLIKELY(specifier == "process"_s || specifier == "node:process"_s)) { + jsDynamicCast(callframe->argument(1))->putDirect(vm, builtinNames(vm).exportsPublicName(), globalObject->processObject(), 0); + return JSValue::encode(globalObject->processObject()); + } + WTF::String referrer = thisObject->id().toWTFString(globalObject); RETURN_IF_EXCEPTION(throwScope, {}); diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 1d6b5d33a..8d94594cc 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -11,13 +11,24 @@ #include #include "ZigConsoleClient.h" #include +#include #pragma mark - Node.js Process +#if !defined(_MSC_VER) +#include // setuid, getuid +#endif + namespace Zig { using namespace JSC; #define REPORTED_NODE_VERSION "18.15.0" +#define processObjectBindingCodeGenerator processObjectInternalsBindingCodeGenerator +#define processObjectMainModuleCodeGenerator moduleMainCodeGenerator + +#if !defined(BUN_WEBKIT_VERSION) +#define BUN_WEBKIT_VERSION "unknown" +#endif using JSGlobalObject = JSC::JSGlobalObject; using Exception = JSC::Exception; @@ -31,23 +42,20 @@ using JSObject = JSC::JSObject; using JSNonFinalObject = JSC::JSNonFinalObject; namespace JSCastingHelpers = JSC::JSCastingHelpers; -static JSC_DECLARE_CUSTOM_SETTER(Process_setTitle); -static JSC_DECLARE_CUSTOM_GETTER(Process_getArgv); -static JSC_DECLARE_CUSTOM_SETTER(Process_setArgv); -static JSC_DECLARE_CUSTOM_GETTER(Process_getTitle); -static JSC_DECLARE_CUSTOM_GETTER(Process_getVersionsLazy); -static JSC_DECLARE_CUSTOM_SETTER(Process_setVersionsLazy); - -static JSC_DECLARE_CUSTOM_GETTER(Process_getPID); -static JSC_DECLARE_CUSTOM_GETTER(Process_getPPID); - -static JSC_DECLARE_HOST_FUNCTION(Process_functionCwd); +JSC_DECLARE_CUSTOM_SETTER(Process_setTitle); +JSC_DECLARE_CUSTOM_GETTER(Process_getArgv); +JSC_DECLARE_CUSTOM_SETTER(Process_setArgv); +JSC_DECLARE_CUSTOM_GETTER(Process_getTitle); +JSC_DECLARE_CUSTOM_GETTER(Process_getPID); +JSC_DECLARE_CUSTOM_GETTER(Process_getPPID); +JSC_DECLARE_HOST_FUNCTION(Process_functionCwd); static bool processIsExiting = false; extern "C" uint8_t Bun__getExitCode(void*); extern "C" uint8_t Bun__setExitCode(void*, uint8_t); extern "C" void* Bun__getVM(); extern "C" Zig::GlobalObject* Bun__getDefaultGlobal(); +extern "C" const char* Bun__githubURL; static void dispatchExitInternal(JSC::JSGlobalObject* globalObject, Process* process, int exitCode) { @@ -72,107 +80,6 @@ static void dispatchExitInternal(JSC::JSGlobalObject* globalObject, Process* pro emitter.emit(event, arguments); } -static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, int fd) -{ - auto& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - auto* thisObject = reinterpret_cast(globalObject); - JSC::JSFunction* getStdioWriteStream = JSC::JSFunction::create(vm, processObjectInternalsGetStdioWriteStreamCodeGenerator(vm), globalObject); - JSC::MarkedArgumentBuffer args; - WTF::String process = WTF::String("node:process"_s); - JSC::JSValue requireFunction = Zig::ImportMetaObject::createRequireFunction( - vm, - globalObject, - process); - - args.append(JSC::jsNumber(fd)); - args.append(requireFunction); - - auto clientData = WebCore::clientData(vm); - JSC::CallData callData = JSC::getCallData(getStdioWriteStream); - - NakedPtr returnedException = nullptr; - auto result = JSC::call(globalObject, getStdioWriteStream, callData, globalObject->globalThis(), args, returnedException); - RETURN_IF_EXCEPTION(scope, {}); - - if (returnedException) { - throwException(globalObject, scope, returnedException.get()); - return {}; - } - - return result; -} - -JSC_DEFINE_CUSTOM_GETTER( - Process_lazyStdinGetter, - (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName property)) -{ - auto& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - JSC::JSValue value = JSC::JSValue::decode(thisValue); - if (!value || value.isUndefinedOrNull() || !value.isObject()) - return JSValue::encode(jsUndefined()); - - auto* thisObject = reinterpret_cast(globalObject); - JSC::JSFunction* getStdioWriteStream = JSC::JSFunction::create(vm, processObjectInternalsGetStdinStreamCodeGenerator(vm), globalObject); - JSC::MarkedArgumentBuffer args; - WTF::String process = WTF::String("node:process"_s); - JSC::JSValue requireFunction = Zig::ImportMetaObject::createRequireFunction( - vm, - globalObject, - process); - - args.append(JSC::jsNumber(STDIN_FILENO)); - args.append(requireFunction); - args.append(thisObject->get(globalObject, PropertyName(JSC::Identifier::fromString(vm, "Bun"_s)))); - - auto clientData = WebCore::clientData(vm); - JSC::CallData callData = JSC::getCallData(getStdioWriteStream); - - NakedPtr returnedException = nullptr; - auto result = JSC::call(globalObject, getStdioWriteStream, callData, globalObject->globalThis(), args, returnedException); - RETURN_IF_EXCEPTION(scope, {}); - - if (UNLIKELY(returnedException)) { - throwException(globalObject, scope, returnedException.get()); - return {}; - } - - if (LIKELY(result)) - value.getObject()->putDirect(vm, property, result, 0); - - return JSValue::encode(result); -} - -JSC_DEFINE_CUSTOM_GETTER( - Process_lazyStdoutGetter, - (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName property)) -{ - JSValue value = JSValue::decode(thisValue); - auto& vm = globalObject->vm(); - JSC::JSObject* thisObject = value.toObject(globalObject); - JSC::JSValue stream = constructStdioWriteStream(globalObject, 1); - - if (stream) - thisObject->putDirect(vm, property, stream, 0); - - return JSValue::encode(stream); -} - -JSC_DEFINE_CUSTOM_GETTER( - Process_lazyStderrGetter, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName property)) -{ - JSValue value = JSValue::decode(thisValue); - auto& vm = globalObject->vm(); - JSC::JSObject* thisObject = value.toObject(globalObject); - JSC::JSValue stream = constructStdioWriteStream(globalObject, 2); - - if (stream) - thisObject->putDirect(vm, property, stream, 0); - - return JSValue::encode(stream); -} - JSC_DEFINE_CUSTOM_SETTER(Process_defaultSetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName propertyName)) @@ -420,6 +327,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionExit, Process__dispatchOnExit(zigGlobal, exitCode); Bun__Process__exit(zigGlobal, exitCode); + __builtin_unreachable(); } extern "C" uint64_t Bun__readOriginTimer(void*); @@ -497,34 +405,6 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, return JSC::JSValue::encode(result); } -extern "C" const char* Bun__githubURL; - -JSC_DEFINE_CUSTOM_GETTER(Process_getterRelease, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName)) -{ - auto& vm = globalObject->vm(); - - auto* release = JSC::constructEmptyObject(globalObject); - release->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, WTF::String("bun"_s)), 0); - release->putDirect(vm, Identifier::fromString(vm, "lts"_s), jsBoolean(false), 0); - release->putDirect(vm, Identifier::fromString(vm, "sourceUrl"_s), jsString(vm, WTF::String(Bun__githubURL, strlen(Bun__githubURL))), 0); - release->putDirect(vm, Identifier::fromString(vm, "headersUrl"_s), jsEmptyString(vm), 0); - release->putDirect(vm, Identifier::fromString(vm, "libUrl"_s), jsEmptyString(vm), 0); - - return JSValue::encode(release); -} - -JSC_DEFINE_CUSTOM_SETTER(Process_setterRelease, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue value, JSC::PropertyName)) -{ - JSC::VM& vm = globalObject->vm(); - - JSC::JSObject* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - thisObject->putDirect(vm, JSC::Identifier::fromString(vm, "release"_s), JSValue::decode(value), 0); - - return true; -} - // static const NeverDestroyed signalNames[] = { // MAKE_STATIC_STRING_IMPL("SIGHUP"), // MAKE_STATIC_STRING_IMPL("SIGINT"), @@ -660,31 +540,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_emitWarning, (JSGlobalObject * lexicalGlobalObj return JSValue::encode(jsUndefined()); } -JSC_DEFINE_CUSTOM_GETTER(Process_lazyArgv0Getter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) -{ - JSC::JSObject* thisObject = JSValue::decode(thisValue).getObject(); - EncodedJSValue ret = Bun__Process__getArgv0(globalObject); - - if (LIKELY(thisObject)) { - thisObject->putDirect(globalObject->vm(), name, JSValue::decode(ret), 0); - } - - return ret; -} - -JSC_DEFINE_CUSTOM_GETTER(Process_lazyExecArgvGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) -{ - JSC::JSObject* thisObject = JSValue::decode(thisValue).getObject(); - EncodedJSValue ret = Bun__Process__getExecArgv(globalObject); - - if (LIKELY(thisObject)) { - thisObject->putDirect(globalObject->vm(), name, JSValue::decode(ret), 0); - } - - return ret; -} - -JSC_DEFINE_CUSTOM_GETTER(Process__getExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) +JSC_DEFINE_CUSTOM_GETTER(processExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) { Process* process = jsDynamicCast(JSValue::decode(thisValue)); if (!process) { @@ -693,7 +549,7 @@ JSC_DEFINE_CUSTOM_GETTER(Process__getExitCode, (JSC::JSGlobalObject * lexicalGlo return JSValue::encode(jsNumber(Bun__getExitCode(jsCast(process->globalObject())->bunVM()))); } -JSC_DEFINE_CUSTOM_SETTER(Process__setExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName)) +JSC_DEFINE_CUSTOM_SETTER(setProcessExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName)) { Process* process = jsDynamicCast(JSValue::decode(thisValue)); if (!process) { @@ -724,158 +580,56 @@ JSC_DEFINE_CUSTOM_SETTER(Process__setExitCode, (JSC::JSGlobalObject * lexicalGlo return true; } -JSC_DEFINE_CUSTOM_GETTER(Process_lazyExecPathGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) +static JSValue constructVersions(VM& vm, JSObject* processObject) { - JSC::JSObject* thisObject = JSValue::decode(thisValue).getObject(); - EncodedJSValue ret = Bun__Process__getExecPath(globalObject); - - if (LIKELY(thisObject)) { - thisObject->putDirect(globalObject->vm(), name, JSValue::decode(ret), 0); - } - - return ret; -} - -void Process::finishCreation(JSC::VM& vm) -{ - Base::finishCreation(vm); - auto clientData = WebCore::clientData(vm); - auto* globalObject = reinterpret_cast(this->globalObject()); - - putDirectCustomAccessor(vm, clientData->builtinNames().pidPublicName(), - JSC::CustomGetterSetter::create(vm, Process_getPID, nullptr), - static_cast(JSC::PropertyAttribute::CustomValue)); - - putDirectCustomAccessor(vm, clientData->builtinNames().ppidPublicName(), - JSC::CustomGetterSetter::create(vm, Process_getPPID, nullptr), - static_cast(JSC::PropertyAttribute::CustomValue)); - - putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "title"_s), - JSC::CustomGetterSetter::create(vm, Process_getTitle, Process_setTitle), - static_cast(JSC::PropertyAttribute::CustomValue)); - - putDirectCustomAccessor(vm, clientData->builtinNames().argvPublicName(), - JSC::CustomGetterSetter::create(vm, Process_getArgv, Process_setArgv), - static_cast(JSC::PropertyAttribute::CustomValue)); - - putDirect(vm, JSC::Identifier::fromString(vm, "revision"_s), - JSC::jsString(vm, makeAtomString(Bun__version_sha)), 0); - - this->putDirect(vm, clientData->builtinNames().nextTickPublicName(), - JSC::JSFunction::create(vm, globalObject, 1, - MAKE_STATIC_STRING_IMPL("nextTick"), Process_functionNextTick, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - this->putDirect(vm, JSC::Identifier::fromString(vm, "dlopen"_s), - JSC::JSFunction::create(vm, globalObject, 1, - MAKE_STATIC_STRING_IMPL("dlopen"), Process_functionDlopen, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - this->putDirect(vm, clientData->builtinNames().cwdPublicName(), - JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("cwd"), Process_functionCwd, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - this->putDirect(vm, clientData->builtinNames().chdirPublicName(), - JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("chdir"), Process_functionChdir, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - this->putDirect(vm, JSC::Identifier::fromString(vm, "exit"_s), - JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("exit"), Process_functionExit, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - putDirectCustomAccessor( - vm, clientData->builtinNames().versionsPublicName(), - JSC::CustomGetterSetter::create(vm, Process_getVersionsLazy, Process_setVersionsLazy), 0); - // this should be transpiled out, but just incase - this->putDirect(vm, JSC::Identifier::fromString(vm, "browser"_s), - JSC::JSValue(false), PropertyAttribute::DontEnum | 0); - - this->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "exitCode"_s), - JSC::CustomGetterSetter::create(vm, - Process__getExitCode, - Process__setExitCode), - 0); - - this->putDirect(vm, clientData->builtinNames().versionPublicName(), - JSC::jsString(vm, makeString("v", REPORTED_NODE_VERSION))); - - // this gives some way of identifying at runtime whether the SSR is happening in node or not. - // this should probably be renamed to what the name of the bundler is, instead of "notNodeJS" - // but it must be something that won't evaluate to truthy in Node.js - this->putDirect(vm, JSC::Identifier::fromString(vm, "isBun"_s), JSC::JSValue(true)); -#if defined(__APPLE__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "platform"_s), - JSC::jsString(vm, makeAtomString("darwin"))); -#else - this->putDirect(vm, JSC::Identifier::fromString(vm, "platform"_s), - JSC::jsString(vm, makeAtomString("linux"))); -#endif - -#if defined(__x86_64__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), - JSC::jsString(vm, makeAtomString("x64"))); -#elif defined(__i386__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), - JSC::jsString(vm, makeAtomString("x86"))); -#elif defined(__arm__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), - JSC::jsString(vm, makeAtomString("arm"))); -#elif defined(__aarch64__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), - JSC::jsString(vm, makeAtomString("arm64"))); -#endif - - JSC::JSFunction* hrtime = JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("hrtime"), Process_functionHRTime, ImplementationVisibility::Public); - - JSC::JSFunction* hrtimeBigInt = JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("bigint"), Process_functionHRTimeBigInt, ImplementationVisibility::Public); - - hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt); - this->putDirect(vm, JSC::Identifier::fromString(vm, "hrtime"_s), hrtime); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "release"_s)), - JSC::CustomGetterSetter::create(vm, Process_getterRelease, Process_setterRelease), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "stdout"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyStdoutGetter, Process_defaultSetter), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "stderr"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyStderrGetter, Process_defaultSetter), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "stdin"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyStdinGetter, Process_defaultSetter), 0); - - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "abort"_s), - 0, Process_functionAbort, ImplementationVisibility::Public, NoIntrinsic, 0); - - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "abort"_s), - 0, Process_functionAbort, ImplementationVisibility::Public, NoIntrinsic, 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "argv0"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyArgv0Getter, Process_defaultSetter), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "execPath"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyExecPathGetter, Process_defaultSetter), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "execArgv"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyExecArgvGetter, Process_defaultSetter), 0); + auto* globalObject = processObject->globalObject(); + JSC::JSObject* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 19); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "uptime"_s), - 0, Process_functionUptime, ImplementationVisibility::Public, NoIntrinsic, 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "node"_s), + JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(REPORTED_NODE_VERSION)))); + object->putDirect( + vm, JSC::Identifier::fromString(vm, "bun"_s), + JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(Bun__version + 1 /* prefix with v */)))); + object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), + JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(BUN_WEBKIT_VERSION)))); + object->putDirect(vm, JSC::Identifier::fromString(vm, "boringssl"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_boringssl))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "libarchive"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_libarchive))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "mimalloc"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_mimalloc))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "picohttpparser"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_picohttpparser))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "uwebsockets"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_uws))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_webkit))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "zig"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_zig))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "zlib"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_zlib))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "tinycc"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_tinycc))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "lolhtml"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_lolhtml))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "ares"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_c_ares))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "usockets"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_usockets))), 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "umask"_s), - 1, Process_functionUmask, ImplementationVisibility::Public, NoIntrinsic, 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "v8"_s), JSValue(JSC::jsString(vm, makeString("10.8.168.20-node.8"_s))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "uv"_s), JSValue(JSC::jsString(vm, makeString("1.44.2"_s))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "napi"_s), JSValue(JSC::jsString(vm, makeString("8"_s))), 0); - this->putDirectBuiltinFunction(vm, globalObject, JSC::Identifier::fromString(vm, "binding"_s), - processObjectInternalsBindingCodeGenerator(vm), - 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "modules"_s), + JSC::JSValue(JSC::jsString(vm, makeAtomString("108")))); - this->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("process"_s)), 0); + return object; +} +static JSValue constructProcessConfigObject(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); // target_defaults: // { cflags: [], // default_configuration: 'Release', @@ -905,179 +659,455 @@ void Process::finishCreation(JSC::VM& vm) JSC::jsNumber(1), 0); config->putDirect(vm, JSC::Identifier::fromString(vm, "target_defaults"_s), JSC::constructEmptyObject(globalObject), 0); config->putDirect(vm, JSC::Identifier::fromString(vm, "variables"_s), variables, 0); - this->putDirect(vm, JSC::Identifier::fromString(vm, "config"_s), config, 0); - - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "emitWarning"_s), - 1, Process_emitWarning, ImplementationVisibility::Public, NoIntrinsic, 0); - - JSC::JSFunction* requireDotMainFunction = JSFunction::create( - vm, - moduleMainCodeGenerator(vm), - globalObject->globalScope()); - // https://nodejs.org/api/process.html#processmainmodule - this->putDirect( - vm, - JSC::Identifier::fromString(vm, "mainModule"_s), - JSC::GetterSetter::create(vm, globalObject, requireDotMainFunction, JSValue()), - PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); + + return config; } -const JSC::ClassInfo Process::s_info = { "Process"_s, &Base::s_info, nullptr, nullptr, - CREATE_METHOD_TABLE(Process) }; +static JSValue constructProcessReleaseObject(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + auto* release = JSC::constructEmptyObject(globalObject); + release->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, WTF::String("bun"_s)), 0); + release->putDirect(vm, Identifier::fromString(vm, "lts"_s), jsBoolean(false), 0); + release->putDirect(vm, Identifier::fromString(vm, "sourceUrl"_s), jsString(vm, WTF::String(Bun__githubURL, strlen(Bun__githubURL))), 0); + release->putDirect(vm, Identifier::fromString(vm, "headersUrl"_s), jsEmptyString(vm), 0); + release->putDirect(vm, Identifier::fromString(vm, "libUrl"_s), jsEmptyString(vm), 0); + + return release; +} -JSC_DEFINE_CUSTOM_GETTER(Process_getTitle, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +static JSValue constructProcessHrtimeObject(VM& vm, JSObject* processObject) { - ZigString str; - Bun__Process__getTitle(globalObject, &str); - return JSValue::encode(Zig::toJSStringValue(str, globalObject)); + auto* globalObject = processObject->globalObject(); + JSC::JSFunction* hrtime = JSC::JSFunction::create(vm, globalObject, 0, + MAKE_STATIC_STRING_IMPL("hrtime"), Process_functionHRTime, ImplementationVisibility::Public); + + JSC::JSFunction* hrtimeBigInt = JSC::JSFunction::create(vm, globalObject, 0, + MAKE_STATIC_STRING_IMPL("bigint"), Process_functionHRTimeBigInt, ImplementationVisibility::Public); + + hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt); + + return hrtime; } -JSC_DEFINE_CUSTOM_SETTER(Process_setTitle, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue value, JSC::PropertyName)) +static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, int fd) { - JSC::VM& vm = globalObject->vm(); + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSC::JSFunction* getStdioWriteStream = JSC::JSFunction::create(vm, processObjectInternalsGetStdioWriteStreamCodeGenerator(vm), globalObject); + JSC::MarkedArgumentBuffer args; + args.append(JSC::jsNumber(fd)); - JSC::JSObject* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - JSC::JSString* jsString = JSC::jsDynamicCast(JSValue::decode(value)); - if (!thisObject || !jsString) { - return false; + auto clientData = WebCore::clientData(vm); + JSC::CallData callData = JSC::getCallData(getStdioWriteStream); + + NakedPtr returnedException = nullptr; + auto result = JSC::call(globalObject, getStdioWriteStream, callData, globalObject->globalThis(), args, returnedException); + RETURN_IF_EXCEPTION(scope, {}); + + if (returnedException) { + throwException(globalObject, scope, returnedException.get()); + return {}; } - ZigString str = Zig::toZigString(jsString, globalObject); - Bun__Process__setTitle(globalObject, &str); + return result; +} - return true; +static JSValue constructStdout(VM& vm, JSObject* processObject) +{ + auto* globalObject = Bun__getDefaultGlobal(); + return constructStdioWriteStream(globalObject, 1); } -JSC_DEFINE_CUSTOM_GETTER(Process_getArgv, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +static JSValue constructStderr(VM& vm, JSObject* processObject) { - JSC::VM& vm = globalObject->vm(); + auto* globalObject = Bun__getDefaultGlobal(); + return constructStdioWriteStream(globalObject, 2); +} - Zig::Process* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) { - return JSValue::encode(JSC::jsUndefined()); - } +static JSValue constructStdin(VM& vm, JSObject* processObject) +{ + auto* globalObject = Bun__getDefaultGlobal(); + auto scope = DECLARE_THROW_SCOPE(vm); + auto* thisObject = reinterpret_cast(globalObject); + JSC::JSFunction* getStdioWriteStream = JSC::JSFunction::create(vm, processObjectInternalsGetStdinStreamCodeGenerator(vm), globalObject); + JSC::MarkedArgumentBuffer args; + args.append(JSC::jsNumber(STDIN_FILENO)); - JSC::EncodedJSValue argv_ = Bun__Process__getArgv(globalObject); auto clientData = WebCore::clientData(vm); + JSC::CallData callData = JSC::getCallData(getStdioWriteStream); + + NakedPtr returnedException = nullptr; + auto result = JSC::call(globalObject, getStdioWriteStream, callData, globalObject, args, returnedException); + RETURN_IF_EXCEPTION(scope, {}); - thisObject->putDirect(vm, clientData->builtinNames().argvPublicName(), - JSC::JSValue::decode(argv_), 0); + if (UNLIKELY(returnedException)) { + throwException(globalObject, scope, returnedException.get()); + return {}; + } - return argv_; + RELEASE_AND_RETURN(scope, result); } -JSC_DEFINE_CUSTOM_SETTER(Process_setArgv, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue value, JSC::PropertyName)) +static JSValue constructPid(VM& vm, JSObject* processObject) { - JSC::VM& vm = globalObject->vm(); + return jsNumber(getpid()); +} - JSC::JSObject* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) { - return false; - } +static JSValue constructPpid(VM& vm, JSObject* processObject) +{ + return jsNumber(getppid()); +} - auto clientData = WebCore::clientData(vm); +static JSValue constructArgv0(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + return JSValue::decode(Bun__Process__getArgv0(globalObject)); +} - return thisObject->putDirect(vm, clientData->builtinNames().argvPublicName(), - JSC::JSValue::decode(value)); +static JSValue constructExecArgv(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + return JSValue::decode(Bun__Process__getExecArgv(globalObject)); } -JSC_DEFINE_CUSTOM_GETTER(Process_getPID, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +static JSValue constructExecPath(VM& vm, JSObject* processObject) { - return JSC::JSValue::encode(JSC::JSValue(getpid())); + auto* globalObject = processObject->globalObject(); + return JSValue::decode(Bun__Process__getExecPath(globalObject)); } -JSC_DEFINE_CUSTOM_GETTER(Process_getPPID, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +static JSValue constructArgv(VM& vm, JSObject* processObject) { - return JSC::JSValue::encode(JSC::JSValue(getppid())); + auto* globalObject = processObject->globalObject(); + return JSValue::decode(Bun__Process__getArgv(globalObject)); } -#if !defined(BUN_WEBKIT_VERSION) -#define BUN_WEBKIT_VERSION "unknown" +static JSValue constructArch(VM& vm, JSObject* processObject) +{ +#if defined(__x86_64__) + return JSC::jsString(vm, makeAtomString("x64")); +#elif defined(__i386__) + return JSC::jsString(vm, makeAtomString("x86")); +#elif defined(__arm__) + return JSC::jsString(vm, makeAtomString("arm")); +#elif defined(__aarch64__) + return JSC::jsString(vm, makeAtomString("arm64")); +#else +#error "Unknown architecture" #endif +} -JSC_DEFINE_CUSTOM_GETTER(Process_getVersionsLazy, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::PropertyName)) +static JSValue constructPlatform(VM& vm, JSObject* processObject) { - JSC::VM& vm = globalObject->vm(); - auto clientData = WebCore::clientData(vm); +#if defined(__APPLE__) + return JSC::jsString(vm, makeAtomString("darwin")); +#elif defined(__linux__) + return JSC::jsString(vm, makeAtomString("linux")); +#else +#error "Unknown platform" +#endif +} - Zig::Process* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) { - return JSValue::encode(JSC::jsUndefined()); +static JSValue constructBrowser(VM& vm, JSObject* processObject) +{ + return jsBoolean(false); +} + +static JSValue constructVersion(VM& vm, JSObject* processObject) +{ + return JSC::jsString(vm, makeString("v", REPORTED_NODE_VERSION)); +} + +static JSValue constructIsBun(VM& vm, JSObject* processObject) +{ + return jsBoolean(true); +} + +static JSValue constructRevision(VM& vm, JSObject* processObject) +{ + return JSC::jsString(vm, makeAtomString(Bun__version_sha)); +} + +static JSValue constructEnv(VM& vm, JSObject* processObject) +{ + auto* globalObject = jsCast(processObject->globalObject()); + return globalObject->processEnvObject(); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongetuid, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsNumber(getuid())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongeteuid, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsNumber(geteuid())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongetegid, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsNumber(getegid())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongetgid, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsNumber(getgid())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongetgroups, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + int ngroups = getgroups(0, nullptr); + auto throwScope = DECLARE_THROW_SCOPE(vm); + if (ngroups == -1) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("getgroups"_s); + throwException(globalObject, throwScope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSValue::encode(jsUndefined()); } - auto scope = DECLARE_THROW_SCOPE(vm); - JSC::JSObject* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 19); + gid_t egid = getegid(); + JSArray* groups = constructEmptyArray(globalObject, nullptr, static_cast(ngroups)); + Vector groupVector(ngroups); + getgroups(1, &egid); + bool needsEgid = true; + for (unsigned i = 0; i < ngroups; i++) { + auto current = groupVector[i]; + if (current == needsEgid) { + needsEgid = false; + } - object->putDirect(vm, JSC::Identifier::fromString(vm, "node"_s), - JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(REPORTED_NODE_VERSION)))); - object->putDirect( - vm, JSC::Identifier::fromString(vm, "bun"_s), - JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(Bun__version + 1 /* prefix with v */)))); - object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), - JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(BUN_WEBKIT_VERSION)))); - object->putDirect(vm, JSC::Identifier::fromString(vm, "boringssl"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_boringssl))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "libarchive"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_libarchive))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "mimalloc"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_mimalloc))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "picohttpparser"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_picohttpparser))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "uwebsockets"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_uws))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_webkit))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "zig"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_zig))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "zlib"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_zlib))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "tinycc"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_tinycc))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "lolhtml"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_lolhtml))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "ares"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_c_ares))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "usockets"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_usockets))), 0); + groups->putDirectIndex(globalObject, i, jsNumber(current)); + } - object->putDirect(vm, JSC::Identifier::fromString(vm, "v8"_s), JSValue(JSC::jsString(vm, makeString("10.8.168.20-node.8"_s))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "uv"_s), JSValue(JSC::jsString(vm, makeString("1.44.2"_s))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "napi"_s), JSValue(JSC::jsString(vm, makeString("8"_s))), 0); + if (needsEgid) + groups->push(globalObject, jsNumber(egid)); - object->putDirect(vm, JSC::Identifier::fromString(vm, "modules"_s), - JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString("108")))); + return JSValue::encode(groups); +} - thisObject->putDirect(vm, clientData->builtinNames().versionsPublicName(), object, 0); +JSC_DEFINE_HOST_FUNCTION(Process_functionAssert, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); - RETURN_IF_EXCEPTION(scope, {}); + JSValue arg0 = callFrame->argument(0); + bool condition = arg0.toBoolean(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + if (condition) { + return JSValue::encode(jsUndefined()); + } - return JSValue::encode(object); + JSValue arg1 = callFrame->argument(1); + String message = arg1.isUndefined() ? String() : arg1.toWTFString(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + auto error = createError(globalObject, makeString("Assertion failed: "_s, message)); + error->putDirect(vm, Identifier::fromString(vm, "code"_s), jsString(vm, makeString("ERR_ASSERTION"_s))); + throwException(globalObject, throwScope, error); + return JSValue::encode(jsUndefined()); } -JSC_DEFINE_CUSTOM_SETTER(Process_setVersionsLazy, + +JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + uint8_t exitCode = 0; + JSValue arg0 = callFrame->argument(0); + if (arg0.isNumber()) { + if (!arg0.isInt32()) { + throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + int extiCode32 = arg0.toInt32(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); + + if (extiCode32 < 0 || extiCode32 > 127) { + throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer between 0 and 127"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + exitCode = static_cast(extiCode32); + } else if (!arg0.isUndefinedOrNull()) { + throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } else { + exitCode = Bun__getExitCode(Bun__getVM()); + } + + auto* zigGlobal = jsDynamicCast(globalObject); + if (UNLIKELY(!zigGlobal)) { + zigGlobal = Bun__getDefaultGlobal(); + } + Bun__Process__exit(zigGlobal, exitCode); + __builtin_unreachable(); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functionOpenStdin, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + Zig::GlobalObject* global = jsDynamicCast(globalObject); + if (UNLIKELY(!global)) { + global = Bun__getDefaultGlobal(); + } + auto throwScope = DECLARE_THROW_SCOPE(vm); + + if (JSValue stdin = global->processObject()->getIfPropertyExists(globalObject, Identifier::fromString(vm, "stdin"_s))) { + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + + if (!stdin.isObject()) { + throwTypeError(globalObject, throwScope, "stdin is not an object"_s); + return JSValue::encode(jsUndefined()); + } + + JSValue resumeValue = stdin.getObject()->getIfPropertyExists(globalObject, Identifier::fromString(vm, "resume"_s)); + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + if (!resumeValue.isUndefinedOrNull()) { + auto resumeFunction = jsDynamicCast(resumeValue); + if (UNLIKELY(!resumeFunction)) { + throwTypeError(globalObject, throwScope, "stdin.resume is not a function"_s); + return JSValue::encode(jsUndefined()); + } + + auto callData = getCallData(resumeFunction); + + MarkedArgumentBuffer args; + JSC::call(globalObject, resumeFunction, callData, stdin, args); + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(stdin)); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsUndefined())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_stubEmptyFunction, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsUndefined()); +} + +JSC_DEFINE_HOST_FUNCTION(Process_stubFunctionReturningArray, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(JSC::constructEmptyArray(globalObject, nullptr)); +} + +static JSValue Process_stubEmptyObject(VM& vm, JSObject* processObject) +{ + return JSC::constructEmptyObject(processObject->globalObject()); +} + +static JSValue Process_stubEmptyArray(VM& vm, JSObject* processObject) +{ + return JSC::constructEmptyArray(processObject->globalObject(), nullptr); +} + +static JSValue Process_stubEmptySet(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + return JSSet::create(vm, globalObject->setStructure()); +} + +static JSValue constructFeatures(VM& vm, JSObject* processObject) +{ + // { + // inspector: true, + // debug: false, + // uv: true, + // ipv6: true, + // tls_alpn: true, + // tls_sni: true, + // tls_ocsp: true, + // tls: true, + // cached_builtins: [Getter] + // } + auto* globalObject = processObject->globalObject(); + auto* object = constructEmptyObject(globalObject); + + object->putDirect(vm, Identifier::fromString(vm, "inspector"_s), jsBoolean(true)); +#ifdef BUN_DEBUG + object->putDirect(vm, Identifier::fromString(vm, "debug"_s), jsBoolean(true)); +#else + object->putDirect(vm, Identifier::fromString(vm, "debug"_s), jsBoolean(false)); +#endif + // lying + object->putDirect(vm, Identifier::fromString(vm, "uv"_s), jsBoolean(true)); + + object->putDirect(vm, Identifier::fromString(vm, "ipv6"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "tls_alpn"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "tls_sni"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "tls_ocsp"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "tls"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "cached_builtins"_s), jsBoolean(true)); + + return object; +} + +static int _debugPort; + +JSC_DEFINE_CUSTOM_GETTER(processDebugPort, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + if (_debugPort == 0) { + _debugPort = 9229; + } + + return JSC::JSValue::encode(jsNumber(_debugPort)); +} + +JSC_DEFINE_CUSTOM_SETTER(setProcessDebugPort, + (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue encodedValue, JSC::PropertyName)) +{ + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSValue value = JSValue::decode(encodedValue); + + if (!value.isInt32()) { + throwRangeError(globalObject, scope, "debugPort must be 0 or in range 1024 to 65535"_s); + return false; + } + + int port = value.asInt32(); + + if (port != 0) { + if (port < 1024 || port > 65535) { + throwRangeError(globalObject, scope, "debugPort must be 0 or in range 1024 to 65535"_s); + return false; + } + } + + _debugPort = port; + return true; +} + +JSC_DEFINE_CUSTOM_GETTER(processTitle, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + ZigString str; + Bun__Process__getTitle(globalObject, &str); + return JSValue::encode(Zig::toJSStringValue(str, globalObject)); +} + +JSC_DEFINE_CUSTOM_SETTER(setProcessTitle, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName)) { JSC::VM& vm = globalObject->vm(); - auto clientData = WebCore::clientData(vm); - Zig::Process* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) { - return JSValue::encode(JSC::jsUndefined()); + JSC::JSObject* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); + JSC::JSString* jsString = JSC::jsDynamicCast(JSValue::decode(value)); + if (!thisObject || !jsString) { + return false; } - thisObject->putDirect(vm, clientData->builtinNames().versionsPublicName(), - JSC::JSValue::decode(value), 0); + ZigString str = Zig::toZigString(jsString, globalObject); + Bun__Process__setTitle(globalObject, &str); return true; } -static JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, +JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); @@ -1091,4 +1121,78 @@ static JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, return JSC::JSValue::encode(result); } +/* Source for Process.lut.h +@begin processObjectTable + abort Process_functionAbort Function 1 + allowedNodeEnvironmentFlags Process_stubEmptySet PropertyCallback + arch constructArch PropertyCallback + argv constructArgv PropertyCallback + argv0 constructArgv0 PropertyCallback + assert Process_functionAssert Function 1 + binding JSBuiltin Function 1 + browser constructBrowser PropertyCallback + chdir Process_functionChdir Function 1 + config constructProcessConfigObject PropertyCallback + debugPort processDebugPort CustomAccessor + exitCode processExitCode CustomAccessor + title processTitle CustomAccessor + cwd Process_functionCwd Function 1 + dlopen Process_functionDlopen Function 1 + emitWarning Process_emitWarning Function 1 + env constructEnv PropertyCallback + execArgv constructExecArgv PropertyCallback + execPath constructExecPath PropertyCallback + exit Process_functionExit Function 1 + features constructFeatures PropertyCallback + getActiveResourcesInfo Process_stubFunctionReturningArray Function 0 + getegid Process_functiongetegid Function 0 + geteuid Process_functiongeteuid Function 0 + getgid Process_functiongetgid Function 0 + getgroups Process_functiongetgroups Function 0 + getuid Process_functiongetuid Function 0 + hrtime constructProcessHrtimeObject PropertyCallback + isBun constructIsBun PropertyCallback + mainModule JSBuiltin ReadOnly|Builtin|Accessor|Function 0 + moduleLoadList Process_stubEmptyArray PropertyCallback + nextTick Process_functionNextTick Function 1 + openStdin Process_functionOpenStdin Function 0 + pid constructPid PropertyCallback + platform constructPlatform PropertyCallback + ppid constructPpid PropertyCallback + reallyExit Process_functionReallyExit Function 1 + release constructProcessReleaseObject PropertyCallback + revision constructRevision PropertyCallback + setSourceMapsEnabled Process_stubEmptyFunction Function 1 + stderr constructStderr PropertyCallback + stdin constructStdin PropertyCallback + stdout constructStdout PropertyCallback + umask Process_functionUmask Function 1 + uptime Process_functionUptime Function 1 + version constructVersion PropertyCallback + versions constructVersions PropertyCallback + _debugEnd Process_stubEmptyFunction Function 0 + _debugProcess Process_stubEmptyFunction Function 0 + _fatalException Process_stubEmptyFunction Function 1 + _getActiveRequests Process_stubFunctionReturningArray Function 0 + _getActiveHandles Process_stubFunctionReturningArray Function 0 + _linkedBinding Process_stubEmptyFunction Function 0 + _preload_modules Process_stubEmptyObject PropertyCallback + _rawDebug Process_stubEmptyFunction Function 0 + _startProfilerIdleNotifier Process_stubEmptyFunction Function 0 + _stopProfilerIdleNotifier Process_stubEmptyFunction Function 0 + _tickCallback Process_stubEmptyFunction Function 0 +@end +*/ + +#include "Process.lut.h" +const JSC::ClassInfo Process::s_info = { "Process"_s, &Base::s_info, &processObjectTable, nullptr, + CREATE_METHOD_TABLE(Process) }; + +void Process::finishCreation(JSC::VM& vm) +{ + Base::finishCreation(vm); + + this->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("process"_s)), 0); +} + } // namespace Zig diff --git a/src/bun.js/bindings/Process.h b/src/bun.js/bindings/Process.h index 322b39078..8b703b8b1 100644 --- a/src/bun.js/bindings/Process.h +++ b/src/bun.js/bindings/Process.h @@ -28,7 +28,7 @@ public: ~Process(); - static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/src/bun.js/bindings/Process.lut.h b/src/bun.js/bindings/Process.lut.h new file mode 100644 index 000000000..5c0bd2c5a --- /dev/null +++ b/src/bun.js/bindings/Process.lut.h @@ -0,0 +1,208 @@ +// File generated via `make generate-builtins` +static const struct CompactHashIndex processObjectTableIndex[141] = { + { 42, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 16, 130 }, + { -1, -1 }, + { -1, -1 }, + { 19, 137 }, + { -1, -1 }, + { 43, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 3, 140 }, + { 1, 128 }, + { -1, -1 }, + { 57, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 30, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 50, -1 }, + { 27, -1 }, + { 10, -1 }, + { -1, -1 }, + { 11, -1 }, + { -1, -1 }, + { 15, 136 }, + { -1, -1 }, + { 35, -1 }, + { -1, -1 }, + { 37, -1 }, + { 53, -1 }, + { 34, -1 }, + { 6, 138 }, + { -1, -1 }, + { 49, -1 }, + { 4, -1 }, + { 45, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 2, -1 }, + { 7, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 39, -1 }, + { -1, -1 }, + { 36, -1 }, + { -1, -1 }, + { 0, -1 }, + { 12, 129 }, + { 17, 131 }, + { 38, -1 }, + { -1, -1 }, + { 23, -1 }, + { 13, -1 }, + { -1, -1 }, + { -1, -1 }, + { 56, -1 }, + { -1, -1 }, + { -1, -1 }, + { 47, -1 }, + { -1, -1 }, + { 29, -1 }, + { 22, -1 }, + { -1, -1 }, + { -1, -1 }, + { 24, -1 }, + { -1, -1 }, + { -1, -1 }, + { 20, -1 }, + { -1, -1 }, + { 5, -1 }, + { -1, -1 }, + { -1, -1 }, + { 46, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 14, 132 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 9, -1 }, + { 25, 134 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 21, 135 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 44, 139 }, + { -1, -1 }, + { 18, -1 }, + { 8, -1 }, + { 26, -1 }, + { 28, -1 }, + { 31, 133 }, + { 32, -1 }, + { 33, -1 }, + { 40, -1 }, + { 41, -1 }, + { 48, -1 }, + { 51, -1 }, + { 52, -1 }, + { 54, -1 }, + { 55, -1 }, +}; + +static const struct HashTableValue processObjectTableValues[58] = { + { "abort"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionAbort, 1 } }, + { "allowedNodeEnvironmentFlags"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptySet } }, + { "arch"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArch } }, + { "argv"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArgv } }, + { "argv0"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArgv0 } }, + { "assert"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionAssert, 1 } }, + { "binding"_s, ((static_cast(PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, processObjectBindingCodeGenerator, 1 } }, + { "browser"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructBrowser } }, + { "chdir"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionChdir, 1 } }, + { "config"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessConfigObject } }, + { "debugPort"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processDebugPort, setProcessDebugPort } }, + { "exitCode"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processExitCode, setProcessExitCode } }, + { "title"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processTitle, setProcessTitle } }, + { "cwd"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionCwd, 1 } }, + { "dlopen"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionDlopen, 1 } }, + { "emitWarning"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_emitWarning, 1 } }, + { "env"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructEnv } }, + { "execArgv"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructExecArgv } }, + { "execPath"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructExecPath } }, + { "exit"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionExit, 1 } }, + { "features"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructFeatures } }, + { "getActiveResourcesInfo"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubFunctionReturningArray, 0 } }, + { "getegid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetegid, 0 } }, + { "geteuid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongeteuid, 0 } }, + { "getgid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetgid, 0 } }, + { "getgroups"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetgroups, 0 } }, + { "getuid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetuid, 0 } }, + { "hrtime"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessHrtimeObject } }, + { "isBun"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructIsBun } }, + { "mainModule"_s, ((static_cast(PropertyAttribute::ReadOnly|PropertyAttribute::Builtin|PropertyAttribute::Accessor|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, processObjectMainModuleCodeGenerator, 0 } }, + { "moduleLoadList"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptyArray } }, + { "nextTick"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionNextTick, 1 } }, + { "openStdin"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionOpenStdin, 0 } }, + { "pid"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructPid } }, + { "platform"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructPlatform } }, + { "ppid"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructPpid } }, + { "reallyExit"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionReallyExit, 1 } }, + { "release"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessReleaseObject } }, + { "revision"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructRevision } }, + { "setSourceMapsEnabled"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 1 } }, + { "stderr"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStderr } }, + { "stdin"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStdin } }, + { "stdout"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStdout } }, + { "umask"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionUmask, 1 } }, + { "uptime"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionUptime, 1 } }, + { "version"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructVersion } }, + { "versions"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructVersions } }, + { "_debugEnd"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_debugProcess"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_fatalException"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 1 } }, + { "_getActiveRequests"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubFunctionReturningArray, 0 } }, + { "_getActiveHandles"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubFunctionReturningArray, 0 } }, + { "_linkedBinding"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_preload_modules"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptyObject } }, + { "_rawDebug"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_startProfilerIdleNotifier"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_stopProfilerIdleNotifier"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_tickCallback"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, +}; + +static const struct HashTable processObjectTable = + { 58, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 4bb5445e1..3291b204e 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -3160,11 +3160,7 @@ void GlobalObject::finishCreation(VM& vm) Zig::GlobalObject* globalObject = reinterpret_cast(init.owner); auto* process = Zig::Process::create( *globalObject, Zig::Process::createStructure(init.vm, init.owner, WebCore::JSEventEmitter::prototype(init.vm, *globalObject))); - process->putDirectCustomAccessor(init.vm, JSC::Identifier::fromString(init.vm, "env"_s), - JSC::CustomGetterSetter::create(init.vm, lazyProcessEnvGetter, lazyProcessEnvSetter), - JSC::PropertyAttribute::DontDelete - | JSC::PropertyAttribute::CustomValue - | 0); + init.set(process); }); diff --git a/src/bun.js/modules/ProcessModule.h b/src/bun.js/modules/ProcessModule.h index 2df74598a..fab0298ae 100644 --- a/src/bun.js/modules/ProcessModule.h +++ b/src/bun.js/modules/ProcessModule.h @@ -44,11 +44,19 @@ inline void generateProcessSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, reinterpret_cast(lexicalGlobalObject); JSC::JSObject *process = globalObject->processObject(); + auto scope = DECLARE_THROW_SCOPE(vm); + if (!process->staticPropertiesReified()) { + process->reifyAllStaticProperties(globalObject); + if (scope.exception()) + return; + } PropertyNameArray properties(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); process->getPropertyNames(globalObject, properties, DontEnumPropertiesMode::Exclude); + if (scope.exception()) + return; exportNames.append(vm.propertyNames->defaultKeyword); exportValues.append(process); diff --git a/src/js/builtins/ProcessObjectInternals.ts b/src/js/builtins/ProcessObjectInternals.ts index 8b24e68ba..8e2449a43 100644 --- a/src/js/builtins/ProcessObjectInternals.ts +++ b/src/js/builtins/ProcessObjectInternals.ts @@ -49,9 +49,14 @@ export function binding(bindingName) { return constants; } -export function getStdioWriteStream(fd_, rawRequire) { - var module = { path: "node:process", require: rawRequire }; - var require = path => module.require(path); +export function getStdioWriteStream(fd_) { + var require = path => { + var existing = $requireMap.get(path); + if (existing) return existing.exports; + + return $internalRequire(path); + }; + var module = { path: "node:process", require }; function createStdioWriteStream(fd_) { var { Duplex, eos, destroy } = require("node:stream"); @@ -472,10 +477,15 @@ export function getStdioWriteStream(fd_, rawRequire) { return new FastStdioWriteStream(fd_); } -export function getStdinStream(fd_, rawRequire, Bun) { - var module = { path: "node:process", require: rawRequire }; - var require = path => module.require(path); +export function getStdinStream(fd_) { + var require = path => { + var existing = $requireMap.get(path); + if (existing) return existing.exports; + + return $internalRequire(path); + }; + var module = { path: "node:process", require: require }; var { Duplex, eos, destroy } = require("node:stream"); var StdinStream = class StdinStream extends Duplex { diff --git a/src/js/builtins/codegen/index.ts b/src/js/builtins/codegen/index.ts index e20601a15..a5d3c2dc8 100644 --- a/src/js/builtins/codegen/index.ts +++ b/src/js/builtins/codegen/index.ts @@ -3,7 +3,35 @@ import path from "path"; import { sliceSourceCode } from "./builtin-parser"; import { applyGlobalReplacements, enums, globalsToPrefix } from "./replacements"; import { cap, fmtCPPString, low } from "./helpers"; +import { spawn, spawnSync } from "bun"; + +async function createStaticHashtables() { + const STATIC_HASH_TABLES = ["src/bun.js/bindings/Process.cpp"]; + console.time("Creating static hash tables..."); + const create_hash_table = path.join( + import.meta.dir, + "../../../../bun-webkit/Source/JavaScriptCore/create_hash_table", + ); + for (let cpp of STATIC_HASH_TABLES) { + cpp = path.join(import.meta.dir, "../../../../", cpp); + const { stdout, exited } = spawn({ + cmd: [create_hash_table, cpp], + stdout: "pipe", + stderr: "inherit", + }); + await exited; + let str = await new Response(stdout).text(); + str = str.replaceAll(/^\/\/.*$/gm, ""); + str = str.replaceAll(/^#include.*$/gm, ""); + str = str.replaceAll(`namespace JSC {`, ""); + str = str.replaceAll(`} // namespace JSC`, ""); + str = "// File generated via `make generate-builtins`\n" + str.trim() + "\n"; + await Bun.write(cpp.replace(/\.cpp$/, ".lut.h"), str); + } + console.timeEnd("Creating static hash tables..."); +} +const staticHashTablePromise = createStaticHashtables(); console.log("Bundling Bun builtins..."); const MINIFY = process.argv.includes("--minify") || process.argv.includes("-m"); @@ -618,6 +646,8 @@ if (!KEEP_TMP) { await rmSync(TMP_DIR, { recursive: true }); } +await staticHashTablePromise; + console.log( `Embedded JS size: %s bytes (across %s functions, %s files)`, totalJSSize, diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index 5ad79fa10..f20f626d4 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,_,v,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let p=()=>{},q=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in v){const P=v.start;p=()=>@promiseInvokeOrNoopMethodNoCatch(_,P,[f])}if(\"write\"in v){const P=v.write;q=(j)=>@promiseInvokeOrNoopMethod(_,P,[j,f])}if(\"close\"in v){const P=v.close;x=()=>@promiseInvokeOrNoopMethod(_,P,[])}if(\"abort\"in v){const P=v.abort;B=(j)=>@promiseInvokeOrNoopMethod(_,P,[j])}@setUpWritableStreamDefaultController(C,f,p,q,x,B,E,F)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,O,_,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let q=()=>{},v=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in _){const p=_.start;q=()=>@promiseInvokeOrNoopMethodNoCatch(O,p,[f])}if(\"write\"in _){const p=_.write;v=(j)=>@promiseInvokeOrNoopMethod(O,p,[j,f])}if(\"close\"in _){const p=_.close;x=()=>@promiseInvokeOrNoopMethod(O,p,[])}if(\"abort\"in _){const p=_.abort;B=(j)=>@promiseInvokeOrNoopMethod(O,p,[j])}@setUpWritableStreamDefaultController(C,f,q,v,x,B,E,F)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -646,17 +646,17 @@ const char* const s_processObjectInternalsBindingCode = "(function (I){\"use str const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; +const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4311; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (Z,Y){\"use strict\";var P={path:\"node:process\",require:Y},L=(M)=>P.require(M);function A(M){var{Duplex:B,eos:j,destroy:z}=L(\"node:stream\"),J=class O extends B{#j;#$;#M=!0;#N=!0;#J;#z;#B;#G;#H;#K;get isTTY(){return this.#K\?\?=L(\"node:tty\").isatty(M)}get fd(){return M}constructor(G){super({readable:!0,writable:!0});this.#J=`/dev/fd/${G}`}#L(G){const H=this.#z;if(this.#z=null,H)H(G);else if(G)this.destroy(G);else if(!this.#M&&!this.#N)this.destroy()}_destroy(G,H){if(!G&&this.#z!==null){var N=class X extends Error{code;name;constructor(Q=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(Q,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};G=new N}if(this.#B=null,this.#G=null,this.#z===null)H(G);else{if(this.#z=H,this.#j)z(this.#j,G);if(this.#$)z(this.#$,G)}}_write(G,H,N){if(!this.#j){var{createWriteStream:X}=L(\"node:fs\"),Q=this.#j=X(this.#J);Q.on(\"finish\",()=>{if(this.#G){const K=this.#G;this.#G=null,K()}}),Q.on(\"drain\",()=>{if(this.#B){const K=this.#B;this.#B=null,K()}}),j(Q,(K)=>{if(this.#N=!1,K)z(Q,K);this.#L(K)})}if(Q.write(G,H))N();else this.#B=N}_final(G){this.#j&&this.#j.end(),this.#G=G}#O(){var{createReadStream:G}=L(\"node:fs\"),H=this.#$=G(this.#J);return H.on(\"readable\",()=>{if(this.#H){const N=this.#H;this.#H=null,N()}else this.read()}),H.on(\"end\",()=>{this.push(null)}),j(H,(N)=>{if(this.#M=!1,N)z(H,N);this.#L(N)}),H}_read(){var G=this.#$;if(!G)G=this.#O();while(!0){const H=G.read();if(H===null||!this.push(H))return}}};return new J(M)}var{EventEmitter:T}=L(\"node:events\");function V(M){if(!M)return!0;var B=M.toLowerCase();return B===\"utf8\"||B===\"utf-8\"||B===\"buffer\"||B===\"binary\"}var U,x=class M extends T{#j;#$;#M;#N;bytesWritten=0;setDefaultEncoding(B){if(this.#$||!V(B))return this.#B(),this.#$.setDefaultEncoding(B)}#J(){switch(this.#j){case 1:{var B=@Bun.stdout.writer({highWaterMark:0});return B.unref(),B}case 2:{var B=@Bun.stderr.writer({highWaterMark:0});return B.unref(),B}default:throw new Error(\"Unsupported writer\")}}#z(){return this.#M\?\?=this.#J()}constructor(B){super();this.#j=B}get fd(){return this.#j}get isTTY(){return this.#N\?\?=L(\"node:tty\").isatty(this.#j)}cursorTo(B,j,z){return(U\?\?=L(\"readline\")).cursorTo(this,B,j,z)}moveCursor(B,j,z){return(U\?\?=L(\"readline\")).moveCursor(this,B,j,z)}clearLine(B,j){return(U\?\?=L(\"readline\")).clearLine(this,B,j)}clearScreenDown(B){return(U\?\?=L(\"readline\")).clearScreenDown(this,B)}ref(){this.#z().ref()}unref(){this.#z().unref()}on(B,j){if(B===\"close\"||B===\"finish\")return this.#B(),this.#$.on(B,j);if(B===\"drain\")return super.on(\"drain\",j);if(B===\"error\")return super.on(\"error\",j);return super.on(B,j)}get _writableState(){return this.#B(),this.#$._writableState}get _readableState(){return this.#B(),this.#$._readableState}pipe(B){return this.#B(),this.#$.pipe(B)}unpipe(B){return this.#B(),this.#$.unpipe(B)}#B(){if(this.#$)return;this.#$=A(this.#j);const B=this.eventNames();for(let j of B)this.#$.on(j,(...z)=>{this.emit(j,...z)})}#G(B){var j=this.#z();const z=j.write(B);this.bytesWritten+=z;const J=j.flush(!1);return!!(z||J)}#H(B,j){if(!V(j))return this.#B(),this.#$.write(B,j);return this.#G(B)}#K(B,j){if(j)this.emit(\"error\",j);try{B(j\?j:null)}catch(z){this.emit(\"error\",z)}}#L(B,j,z){if(!V(j))return this.#B(),this.#$.write(B,j,z);var J=this.#z();const O=J.write(B),G=J.flush(!0);if(G\?.then)return G.then(()=>{this.#K(z),this.emit(\"drain\")},(H)=>this.#K(z,H)),!1;return queueMicrotask(()=>{this.#K(z)}),!!(O||G)}write(B,j,z){const J=this._write(B,j,z);if(J)this.emit(\"drain\");return J}get hasColors(){return @Bun.tty[this.#j].hasColors}_write(B,j,z){var J=this.#$;if(J)return J.write(B,j,z);switch(arguments.length){case 0:{var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}case 1:return this.#G(B);case 2:if(typeof j===\"function\")return this.#L(B,\"\",j);else if(typeof j===\"string\")return this.#H(B,j);default:{if(typeof j!==\"undefined\"&&typeof j!==\"string\"||typeof z!==\"undefined\"&&typeof z!==\"function\"){var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}if(typeof z===\"undefined\")return this.#H(B,j);return this.#L(B,j,z)}}}destroy(){return this}end(){return this}};return new x(Z)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (Z){\"use strict\";var L=(M)=>{var G=@requireMap.get(M);if(G)return G.exports;return @internalRequire(M)},D={path:\"node:process\",require:L};function Y(M){var{Duplex:G,eos:j,destroy:z}=L(\"node:stream\"),J=class O extends G{#j;#$;#M=!0;#N=!0;#J;#z;#G;#B;#H;#K;get isTTY(){return this.#K\?\?=L(\"node:tty\").isatty(M)}get fd(){return M}constructor(B){super({readable:!0,writable:!0});this.#J=`/dev/fd/${B}`}#L(B){const H=this.#z;if(this.#z=null,H)H(B);else if(B)this.destroy(B);else if(!this.#M&&!this.#N)this.destroy()}_destroy(B,H){if(!B&&this.#z!==null){var N=class X extends Error{code;name;constructor(Q=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(Q,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};B=new N}if(this.#G=null,this.#B=null,this.#z===null)H(B);else{if(this.#z=H,this.#j)z(this.#j,B);if(this.#$)z(this.#$,B)}}_write(B,H,N){if(!this.#j){var{createWriteStream:X}=L(\"node:fs\"),Q=this.#j=X(this.#J);Q.on(\"finish\",()=>{if(this.#B){const K=this.#B;this.#B=null,K()}}),Q.on(\"drain\",()=>{if(this.#G){const K=this.#G;this.#G=null,K()}}),j(Q,(K)=>{if(this.#N=!1,K)z(Q,K);this.#L(K)})}if(Q.write(B,H))N();else this.#G=N}_final(B){this.#j&&this.#j.end(),this.#B=B}#O(){var{createReadStream:B}=L(\"node:fs\"),H=this.#$=B(this.#J);return H.on(\"readable\",()=>{if(this.#H){const N=this.#H;this.#H=null,N()}else this.read()}),H.on(\"end\",()=>{this.push(null)}),j(H,(N)=>{if(this.#M=!1,N)z(H,N);this.#L(N)}),H}_read(){var B=this.#$;if(!B)B=this.#O();while(!0){const H=B.read();if(H===null||!this.push(H))return}}};return new J(M)}var{EventEmitter:P}=L(\"node:events\");function V(M){if(!M)return!0;var G=M.toLowerCase();return G===\"utf8\"||G===\"utf-8\"||G===\"buffer\"||G===\"binary\"}var U,A=class M extends P{#j;#$;#M;#N;bytesWritten=0;setDefaultEncoding(G){if(this.#$||!V(G))return this.#G(),this.#$.setDefaultEncoding(G)}#J(){switch(this.#j){case 1:{var G=@Bun.stdout.writer({highWaterMark:0});return G.unref(),G}case 2:{var G=@Bun.stderr.writer({highWaterMark:0});return G.unref(),G}default:throw new Error(\"Unsupported writer\")}}#z(){return this.#M\?\?=this.#J()}constructor(G){super();this.#j=G}get fd(){return this.#j}get isTTY(){return this.#N\?\?=L(\"node:tty\").isatty(this.#j)}cursorTo(G,j,z){return(U\?\?=L(\"readline\")).cursorTo(this,G,j,z)}moveCursor(G,j,z){return(U\?\?=L(\"readline\")).moveCursor(this,G,j,z)}clearLine(G,j){return(U\?\?=L(\"readline\")).clearLine(this,G,j)}clearScreenDown(G){return(U\?\?=L(\"readline\")).clearScreenDown(this,G)}ref(){this.#z().ref()}unref(){this.#z().unref()}on(G,j){if(G===\"close\"||G===\"finish\")return this.#G(),this.#$.on(G,j);if(G===\"drain\")return super.on(\"drain\",j);if(G===\"error\")return super.on(\"error\",j);return super.on(G,j)}get _writableState(){return this.#G(),this.#$._writableState}get _readableState(){return this.#G(),this.#$._readableState}pipe(G){return this.#G(),this.#$.pipe(G)}unpipe(G){return this.#G(),this.#$.unpipe(G)}#G(){if(this.#$)return;this.#$=Y(this.#j);const G=this.eventNames();for(let j of G)this.#$.on(j,(...z)=>{this.emit(j,...z)})}#B(G){var j=this.#z();const z=j.write(G);this.bytesWritten+=z;const J=j.flush(!1);return!!(z||J)}#H(G,j){if(!V(j))return this.#G(),this.#$.write(G,j);return this.#B(G)}#K(G,j){if(j)this.emit(\"error\",j);try{G(j\?j:null)}catch(z){this.emit(\"error\",z)}}#L(G,j,z){if(!V(j))return this.#G(),this.#$.write(G,j,z);var J=this.#z();const O=J.write(G),B=J.flush(!0);if(B\?.then)return B.then(()=>{this.#K(z),this.emit(\"drain\")},(H)=>this.#K(z,H)),!1;return queueMicrotask(()=>{this.#K(z)}),!!(O||B)}write(G,j,z){const J=this._write(G,j,z);if(J)this.emit(\"drain\");return J}get hasColors(){return @Bun.tty[this.#j].hasColors}_write(G,j,z){var J=this.#$;if(J)return J.write(G,j,z);switch(arguments.length){case 0:{var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}case 1:return this.#B(G);case 2:if(typeof j===\"function\")return this.#L(G,\"\",j);else if(typeof j===\"string\")return this.#H(G,j);default:{if(typeof j!==\"undefined\"&&typeof j!==\"string\"||typeof z!==\"undefined\"&&typeof z!==\"function\"){var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}if(typeof z===\"undefined\")return this.#H(G,j);return this.#L(G,j,z)}}}destroy(){return this}end(){return this}};return new A(Z)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_processObjectInternalsGetStdinStreamCodeLength = 1799; +const int s_processObjectInternalsGetStdinStreamCodeLength = 1861; static const JSC::Intrinsic s_processObjectInternalsGetStdinStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdinStreamCode = "(function (L,N,P){\"use strict\";var Q={path:\"node:process\",require:N},J=(K)=>Q.require(K),{Duplex:T,eos:U,destroy:M}=J(\"node:stream\"),V=class K extends T{#K;#j;#Y;#H=!0;#I=!1;#L=!0;#z;#$;#G;get isTTY(){return J(\"tty\").isatty(L)}get fd(){return L}constructor(){super({readable:!0,writable:!0})}#J(Y){const j=this.#$;if(this.#$=null,j)j(Y);else if(Y)this.destroy(Y);else if(!this.#H&&!this.#L)this.destroy()}_destroy(Y,j){if(!Y&&this.#$!==null){var z=class G extends Error{constructor(H=\"The operation was aborted\",I=void 0){if(I!==void 0&&typeof I!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(I,null,2)}`);super(H,I);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Y=new z}if(this.#$===null)j(Y);else if(this.#$=j,this.#Y)M(this.#Y,Y)}setRawMode(Y){}on(Y,j){if(Y===\"readable\")this.ref(),this.#I=!0;return super.on(Y,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#K\?\?=P.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#M(){try{var Y,j;const z=this.#K.readMany();if(!z\?.then)({done:Y,value:j}=z);else({done:Y,value:j}=await z);if(!Y){this.push(j[0]);const G=j.length;for(let H=1;H{if(this.#z){const z=this.#z;this.#z=null,z()}}),j.on(\"drain\",()=>{if(this.#G){const z=this.#G;this.#G=null,z()}}),U(j,(z)=>{if(this.#L=!1,z)M(j,z);this.#J(z)}),j}_write(Y,j,z){var G=this.#Y;if(!G)G=this.#N();if(G.write(Y,j))z();else this.#G=z}_final(Y){this.#Y.end(),this.#z=(...j)=>Y(...j)}};return new V})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (K){\"use strict\";var H=(I)=>{var N=@requireMap.get(I);if(N)return N.exports;return @internalRequire(I)},T={path:\"node:process\",require:H},{Duplex:M,eos:P,destroy:L}=H(\"node:stream\"),Q=class I extends M{#J;#j;#$;#G=!0;#H=!1;#K=!0;#z;#N;#B;get isTTY(){return H(\"tty\").isatty(K)}get fd(){return K}constructor(){super({readable:!0,writable:!0})}#I(N){const j=this.#N;if(this.#N=null,j)j(N);else if(N)this.destroy(N);else if(!this.#G&&!this.#K)this.destroy()}_destroy(N,j){if(!N&&this.#N!==null){var z=class B extends Error{constructor(G=\"The operation was aborted\",J=void 0){if(J!==void 0&&typeof J!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(J,null,2)}`);super(G,J);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new z}if(this.#N===null)j(N);else if(this.#N=j,this.#$)L(this.#$,N)}setRawMode(N){}on(N,j){if(N===\"readable\")this.ref(),this.#H=!0;return super.on(N,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#J\?\?=@Bun.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#L(){try{var N,j;const z=this.#J.readMany();if(!z\?.then)({done:N,value:j}=z);else({done:N,value:j}=await z);if(!N){this.push(j[0]);const B=j.length;for(let G=1;G{if(this.#z){const z=this.#z;this.#z=null,z()}}),j.on(\"drain\",()=>{if(this.#B){const z=this.#B;this.#B=null,z()}}),P(j,(z)=>{if(this.#K=!1,z)L(j,z);this.#I(z)}),j}_write(N,j,z){var B=this.#$;if(!B)B=this.#M();if(B.write(N,j))z();else this.#B=z}_final(N){this.#$.end(),this.#z=(...j)=>N(...j)}};return new Q})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2028,7 +2028,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 H=@getByIdDirectPrivate(k,\"state\");if(@putByIdDirectPrivate(k,\"disturbed\",!0),H===@streamClosed)return{value:[],size:0,done:!0};else if(H===@streamErrored)throw @getByIdDirectPrivate(k,\"storedError\");var w=@getByIdDirectPrivate(k,\"readableStreamController\"),E=@getByIdDirectPrivate(w,\"queue\");if(!E)return w.@pull(w).@then(function({done:_,value:B}){return _\?{done:!0,value:[],size:0}:{value:[B],size:1,done:!1}});const N=E.content;var O=E.size,A=N.toArray(!1),C=A.length;if(C>0){var j=@newArrayWithSize(C);if(@isReadableByteStreamController(w)){{const _=A[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(j,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(j,0,_)}for(var d=1;d{if(_.done)return{value:[],size:0,done:!0};var B=@getByIdDirectPrivate(k,\"readableStreamController\"),F=@getByIdDirectPrivate(B,\"queue\"),x=[_.value].concat(F.content.toArray(!1)),K=x.length;if(@isReadableByteStreamController(B))for(var I=0;I0){var D=@newArrayWithSize(C);if(@isReadableByteStreamController(B)){{const _=x[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(D,0,_)}for(var d=1;d{if(_.done)return{value:[],size:0,done:!0};var w=@getByIdDirectPrivate(j,\"readableStreamController\"),G=@getByIdDirectPrivate(w,\"queue\"),k=[_.value].concat(G.content.toArray(!1)),K=k.length;if(@isReadableByteStreamController(w))for(var A=0;A0}shift(){var{_head:v,_tail:b,_list:g,_capacityMask:k}=this;if(v===b)return @undefined;var w=g[v];if(@putByValDirect(g,v,@undefined),v=this._head=v+1&k,v<2&&b>1e4&&b<=g.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(v){var b=this._tail;if(@putByValDirect(this._list,b,v),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(v){var b=this._list,g=@toLength(b.length);if(v||this._head>this._tail){var k=@toLength(this._head),w=@toLength(this._tail),F=@toLength(g-k+w),z=@newArrayWithSize(F),B=0;for(var x=k;x>>=1,this._capacityMask>>>=1}}return new A})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var E=@Array.prototype.slice;class A{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:g,_tail:b,_list:x,_capacityMask:M}=this;if(g===b)return @undefined;var w=x[g];if(@putByValDirect(x,g,@undefined),g=this._head=g+1&M,g<2&&b>1e4&&b<=x.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(g){var b=this._tail;if(@putByValDirect(this._list,b,g),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(g){var b=this._list,x=@toLength(b.length);if(g||this._head>this._tail){var M=@toLength(this._head),w=@toLength(this._tail),F=@toLength(x-M+w),z=@newArrayWithSize(F),B=0;for(var v=M;v>>=1,this._capacityMask>>>=1}}return new A})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; diff --git a/src/js/out/WebCoreJSBuiltins.h b/src/js/out/WebCoreJSBuiltins.h index d00ae735e..42d14b154 100644 --- a/src/js/out/WebCoreJSBuiltins.h +++ b/src/js/out/WebCoreJSBuiltins.h @@ -1181,8 +1181,8 @@ extern const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStrea #define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_DATA(macro) \ macro(binding, processObjectInternalsBinding, 1) \ - macro(getStdioWriteStream, processObjectInternalsGetStdioWriteStream, 2) \ - macro(getStdinStream, processObjectInternalsGetStdinStream, 3) \ + macro(getStdioWriteStream, processObjectInternalsGetStdioWriteStream, 1) \ + macro(getStdinStream, processObjectInternalsGetStdinStream, 1) \ #define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(macro) \ macro(processObjectInternalsBindingCode, binding, ASCIILiteral(), s_processObjectInternalsBindingCodeLength) \ -- cgit v1.2.3 From 2f5e4fffe9554fcc7afa6980b3af6b33bc3a3a5e Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 9 Jul 2023 21:50:19 -0700 Subject: Implement process.memoryUsage() and process.cpuUsage() (#3586) * Implement process.memoryUsage() and process.cpuUsage() * Avoid mi_process_info * Update bench * Update Process.cpp * fixup * More tests + linux fixup * Skip it for now since it seems less accurate --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- bench/snippets/process-info.mjs | 33 ++ src/bun.js/bindings/Process.cpp | 388 ++++++++++++++++++++- src/bun.js/bindings/Process.h | 18 + src/bun.js/bindings/Process.lut.h | 97 +++--- .../bindings/webcore/DOMClientIsoSubspaces.h | 1 + src/bun.js/bindings/webcore/DOMIsoSubspaces.h | 1 + test/js/node/process/process.test.js | 142 +++++++- 7 files changed, 620 insertions(+), 60 deletions(-) create mode 100644 bench/snippets/process-info.mjs diff --git a/bench/snippets/process-info.mjs b/bench/snippets/process-info.mjs new file mode 100644 index 000000000..0366472e5 --- /dev/null +++ b/bench/snippets/process-info.mjs @@ -0,0 +1,33 @@ +import { bench, run } from "./runner.mjs"; +import { performance } from "perf_hooks"; + +bench("process.memoryUsage()", () => { + process.memoryUsage(); +}); + +bench("process.memoryUsage.rss()", () => { + process.memoryUsage.rss(); +}); + +bench("process.cpuUsage()", () => { + process.cpuUsage(); +}); + +const init = process.cpuUsage(); +bench("process.cpuUsage(delta)", () => { + process.cpuUsage(init); +}); + +bench("performance.now()", () => { + performance.now(); +}); + +bench("process.hrtime()", () => { + process.hrtime(); +}); + +bench("process.hrtime.bigint()", () => { + process.hrtime.bigint(); +}); + +await run(); diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 8d94594cc..7d7bdd982 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -12,8 +12,24 @@ #include "ZigConsoleClient.h" #include #include +#include +#include +#include + #pragma mark - Node.js Process +#if defined(__APPLE__) +#include +#include +#endif + +#if defined(__linux__) +#include +#include +#include +#include +#endif + #if !defined(_MSC_VER) #include // setuid, getuid #endif @@ -335,9 +351,12 @@ extern "C" uint64_t Bun__readOriginTimer(void*); JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, (JSC::JSGlobalObject * globalObject_, JSC::CallFrame* callFrame)) { + Zig::GlobalObject* globalObject = reinterpret_cast(globalObject_); auto& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + uint64_t time = Bun__readOriginTimer(globalObject->bunVM()); int64_t seconds = static_cast(time / 1000000000); int64_t nanoseconds = time % 1000000000; @@ -346,7 +365,6 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, JSC::JSValue arg0 = callFrame->uncheckedArgument(0); if (!arg0.isUndefinedOrNull()) { JSArray* relativeArray = JSC::jsDynamicCast(arg0); - auto throwScope = DECLARE_THROW_SCOPE(vm); if ((!relativeArray && !arg0.isUndefinedOrNull()) || relativeArray->length() < 2) { JSC::throwTypeError(globalObject, throwScope, "hrtime() argument must be an array or undefined"_s); return JSC::JSValue::encode(JSC::JSValue {}); @@ -366,14 +384,28 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, seconds--; nanoseconds += 1000000000; } - throwScope.release(); } } - auto* array = JSArray::create(vm, globalObject->originalArrayStructureForIndexingType(ArrayWithContiguous), 2); - array->setIndexQuickly(vm, 0, JSC::jsNumber(seconds)); - array->setIndexQuickly(vm, 1, JSC::jsNumber(nanoseconds)); - return JSC::JSValue::encode(JSC::JSValue(array)); + JSC::JSArray* array = nullptr; + { + JSC::ObjectInitializationScope initializationScope(vm); + if ((array = JSC::JSArray::tryCreateUninitializedRestricted( + initializationScope, nullptr, + globalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous), + 2))) { + + array->initializeIndex(initializationScope, 0, JSC::jsNumber(seconds)); + array->initializeIndex(initializationScope, 1, JSC::jsNumber(nanoseconds)); + } + } + + if (UNLIKELY(!array)) { + JSC::throwOutOfMemoryError(globalObject, throwScope); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(array)); } JSC_DEFINE_HOST_FUNCTION(Process_functionHRTimeBigInt, @@ -680,10 +712,10 @@ static JSValue constructProcessHrtimeObject(VM& vm, JSObject* processObject) { auto* globalObject = processObject->globalObject(); JSC::JSFunction* hrtime = JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("hrtime"), Process_functionHRTime, ImplementationVisibility::Public); + String("hrtime"_s), Process_functionHRTime, ImplementationVisibility::Public); JSC::JSFunction* hrtimeBigInt = JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("bigint"), Process_functionHRTimeBigInt, ImplementationVisibility::Public); + String("bigint"_s), Process_functionHRTimeBigInt, ImplementationVisibility::Public); hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt); @@ -945,6 +977,317 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObj __builtin_unreachable(); } +template +void Process::visitChildrenImpl(JSCell* cell, Visitor& visitor) +{ + Process* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + Base::visitChildren(thisObject, visitor); + thisObject->cpuUsageStructure.visit(visitor); + thisObject->memoryUsageStructure.visit(visitor); +} + +DEFINE_VISIT_CHILDREN(Process); + +static Structure* constructCPUUsageStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) +{ + JSC::Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype(globalObject, globalObject->objectPrototype(), 2); + PropertyOffset offset; + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "user"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "system"_s), + 0, + offset); + return structure; +} +static Structure* constructMemoryUsageStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) +{ + JSC::Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype(globalObject, globalObject->objectPrototype(), 5); + PropertyOffset offset; + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "rss"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "heapTotal"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "heapUsed"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "external"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "arrayBuffers"_s), + 0, + offset); + + return structure; +} + +static Process* getProcessObject(JSC::JSGlobalObject* lexicalGlobalObject, JSValue thisValue) +{ + Process* process = jsDynamicCast(thisValue); + + // Handle "var memoryUsage = process.memoryUsage; memoryUsage()" + if (UNLIKELY(!process)) { + // Handle calling this function from inside a node:vm + Zig::GlobalObject* zigGlobalObject = jsDynamicCast(lexicalGlobalObject); + + if (UNLIKELY(!zigGlobalObject)) { + zigGlobalObject = Bun__getDefaultGlobal(); + } + + return jsCast(zigGlobalObject->processObject()); + } + + return process; +} + +JSC_DEFINE_HOST_FUNCTION(Process_functionCpuUsage, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + struct rusage rusage; + if (getrusage(RUSAGE_SELF, &rusage) != 0) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("getrusage"_s); + error.message = Bun::toString("Failed to get CPU usage"_s); + throwException(globalObject, throwScope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSValue::encode(jsUndefined()); + } + + auto* process = getProcessObject(globalObject, callFrame->thisValue()); + + Structure* cpuUsageStructure = process->cpuUsageStructure.getInitializedOnMainThread(process); + + constexpr double MICROS_PER_SEC = 1000000.0; + + double user = MICROS_PER_SEC * rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec; + double system = MICROS_PER_SEC * rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec; + + if (callFrame->argumentCount() > 0) { + JSValue comparatorValue = callFrame->argument(0); + if (!comparatorValue.isUndefined()) { + if (UNLIKELY(!comparatorValue.isObject())) { + throwTypeError(globalObject, throwScope, "Expected an object as the first argument"_s); + return JSC::JSValue::encode(JSC::jsUndefined()); + } + + JSC::JSObject* comparator = comparatorValue.getObject(); + JSValue userValue; + JSValue systemValue; + + if (LIKELY(comparator->structureID() == cpuUsageStructure->id())) { + userValue = comparator->getDirect(0); + systemValue = comparator->getDirect(1); + } else { + userValue = comparator->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "user"_s)); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined())); + + systemValue = comparator->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "system"_s)); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined())); + } + + if (UNLIKELY(!userValue || !userValue.isNumber())) { + throwTypeError(globalObject, throwScope, "Expected a number for the user property"_s); + return JSC::JSValue::encode(JSC::jsUndefined()); + } + + if (UNLIKELY(!systemValue || !systemValue.isNumber())) { + throwTypeError(globalObject, throwScope, "Expected a number for the system property"_s); + return JSC::JSValue::encode(JSC::jsUndefined()); + } + + double userComparator = userValue.asNumber(); + double systemComparator = systemValue.asNumber(); + + user -= userComparator; + system -= systemComparator; + } + } + + JSC::JSObject* result = JSC::constructEmptyObject(vm, cpuUsageStructure); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined())); + + result->putDirectOffset(vm, 0, JSC::jsNumber(user)); + result->putDirectOffset(vm, 1, JSC::jsNumber(system)); + + RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(result)); +} + +static int getRSS(size_t* rss) +{ +#if defined(__APPLE__) + mach_msg_type_number_t count; + task_basic_info_data_t info; + kern_return_t err; + + count = TASK_BASIC_INFO_COUNT; + err = task_info(mach_task_self(), + TASK_BASIC_INFO, + reinterpret_cast(&info), + &count); + + if (err == KERN_SUCCESS) { + *rss = (size_t)info.resident_size; + return 0; + } + + return -1; +#elif defined(__linux__) + // Taken from libuv. + char buf[1024]; + const char* s; + ssize_t n; + long val; + int fd; + int i; + + do + fd = open("/proc/self/stat", O_RDONLY); + while (fd == -1 && errno == EINTR); + + if (fd == -1) + return errno; + + do + n = read(fd, buf, sizeof(buf) - 1); + while (n == -1 && errno == EINTR); + + int closeErrno = 0; + do { + closeErrno = close(fd); + } while (closeErrno == -1 && errno == EINTR); + + if (n == -1) + return errno; + buf[n] = '\0'; + + s = strchr(buf, ' '); + if (s == NULL) + goto err; + + s += 1; + if (*s != '(') + goto err; + + s = strchr(s, ')'); + if (s == NULL) + goto err; + + for (i = 1; i <= 22; i++) { + s = strchr(s + 1, ' '); + if (s == NULL) + goto err; + } + + errno = 0; + val = strtol(s, NULL, 10); + if (errno != 0) + goto err; + if (val < 0) + goto err; + + *rss = val * getpagesize(); + return 0; + +err: + return EINVAL; +#else +#error "Unsupported platform" +#endif +} + +JSC_DEFINE_HOST_FUNCTION(Process_functionMemoryUsage, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + auto* process = getProcessObject(globalObject, callFrame->thisValue()); + + size_t current_rss = 0; + if (getRSS(¤t_rss) != 0) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("memoryUsage"_s); + error.message = Bun::toString("Failed to get memory usage"_s); + throwException(globalObject, throwScope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + JSC::JSObject* result = JSC::constructEmptyObject(vm, process->memoryUsageStructure.getInitializedOnMainThread(process)); + if (UNLIKELY(throwScope.exception())) { + return JSC::JSValue::encode(JSC::JSValue {}); + } + + // Node.js: + // { + // rss: 4935680, + // heapTotal: 1826816, + // heapUsed: 650472, + // external: 49879, + // arrayBuffers: 9386 + // } + + result->putDirectOffset(vm, 0, JSC::jsNumber(current_rss)); + result->putDirectOffset(vm, 1, JSC::jsNumber(vm.heap.blockBytesAllocated())); + + // heap.size() loops through every cell... + // TODO: add a binding for heap.sizeAfterLastCollection() + result->putDirectOffset(vm, 2, JSC::jsNumber(vm.heap.sizeAfterLastEdenCollection())); + + result->putDirectOffset(vm, 3, JSC::jsNumber(vm.heap.externalMemorySize())); + + // We report 0 for this because m_arrayBuffers in JSC::Heap is private and we need to add a binding + // If we use objectTypeCounts(), it's hideously slow because it loops through every single object in the heap + // TODO: add a binding for m_arrayBuffers, registerWrapper() in TypedArrayController doesn't work + result->putDirectOffset(vm, 4, JSC::jsNumber(0)); + + RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(result)); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functionMemoryUsageRSS, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + + size_t current_rss = 0; + if (getRSS(¤t_rss) != 0) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("memoryUsage"_s); + error.message = Bun::toString("Failed to get memory usage"_s); + throwException(globalObject, throwScope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsNumber(current_rss))); +} + JSC_DEFINE_HOST_FUNCTION(Process_functionOpenStdin, (JSGlobalObject * globalObject, CallFrame* callFrame)) { auto& vm = globalObject->vm(); @@ -1010,6 +1353,19 @@ static JSValue Process_stubEmptySet(VM& vm, JSObject* processObject) return JSSet::create(vm, globalObject->setStructure()); } +static JSValue constructMemoryUsage(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + JSC::JSFunction* memoryUsage = JSC::JSFunction::create(vm, globalObject, 0, + String("memoryUsage"_s), Process_functionMemoryUsage, ImplementationVisibility::Public); + + JSC::JSFunction* rss = JSC::JSFunction::create(vm, globalObject, 0, + String("rss"_s), Process_functionMemoryUsageRSS, ImplementationVisibility::Public); + + memoryUsage->putDirect(vm, JSC::Identifier::fromString(vm, "rss"_s), rss, JSC::PropertyAttribute::Function | 0); + return memoryUsage; +} + static JSValue constructFeatures(VM& vm, JSObject* processObject) { // { @@ -1133,16 +1489,16 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, browser constructBrowser PropertyCallback chdir Process_functionChdir Function 1 config constructProcessConfigObject PropertyCallback - debugPort processDebugPort CustomAccessor - exitCode processExitCode CustomAccessor - title processTitle CustomAccessor + cpuUsage Process_functionCpuUsage Function 1 cwd Process_functionCwd Function 1 + debugPort processDebugPort CustomAccessor dlopen Process_functionDlopen Function 1 emitWarning Process_emitWarning Function 1 env constructEnv PropertyCallback execArgv constructExecArgv PropertyCallback execPath constructExecPath PropertyCallback exit Process_functionExit Function 1 + exitCode processExitCode CustomAccessor features constructFeatures PropertyCallback getActiveResourcesInfo Process_stubFunctionReturningArray Function 0 getegid Process_functiongetegid Function 0 @@ -1153,6 +1509,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, hrtime constructProcessHrtimeObject PropertyCallback isBun constructIsBun PropertyCallback mainModule JSBuiltin ReadOnly|Builtin|Accessor|Function 0 + memoryUsage constructMemoryUsage PropertyCallback moduleLoadList Process_stubEmptyArray PropertyCallback nextTick Process_functionNextTick Function 1 openStdin Process_functionOpenStdin Function 0 @@ -1166,6 +1523,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, stderr constructStderr PropertyCallback stdin constructStdin PropertyCallback stdout constructStdout PropertyCallback + title processTitle CustomAccessor umask Process_functionUmask Function 1 uptime Process_functionUptime Function 1 version constructVersion PropertyCallback @@ -1192,6 +1550,14 @@ void Process::finishCreation(JSC::VM& vm) { Base::finishCreation(vm); + this->cpuUsageStructure.initLater([](const JSC::LazyProperty::Initializer& init) { + init.set(constructCPUUsageStructure(init.vm, init.owner->globalObject())); + }); + + this->memoryUsageStructure.initLater([](const JSC::LazyProperty::Initializer& init) { + init.set(constructMemoryUsageStructure(init.vm, init.owner->globalObject())); + }); + this->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("process"_s)), 0); } diff --git a/src/bun.js/bindings/Process.h b/src/bun.js/bindings/Process.h index 8b703b8b1..fbad9b1ff 100644 --- a/src/bun.js/bindings/Process.h +++ b/src/bun.js/bindings/Process.h @@ -45,6 +45,24 @@ public: return accessor; } + LazyProperty cpuUsageStructure; + LazyProperty memoryUsageStructure; + + DECLARE_VISIT_CHILDREN; + + 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_clientSubspaceForProcessObject.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForProcessObject = std::forward(space); }, + [](auto& spaces) { return spaces.m_subspaceForProcessObject.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForProcessObject = std::forward(space); }); + } + void finishCreation(JSC::VM& vm); }; diff --git a/src/bun.js/bindings/Process.lut.h b/src/bun.js/bindings/Process.lut.h index 5c0bd2c5a..81eb1b7b9 100644 --- a/src/bun.js/bindings/Process.lut.h +++ b/src/bun.js/bindings/Process.lut.h @@ -1,6 +1,6 @@ // File generated via `make generate-builtins` -static const struct CompactHashIndex processObjectTableIndex[141] = { - { 42, -1 }, +static const struct CompactHashIndex processObjectTableIndex[142] = { + { 43, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -11,12 +11,12 @@ static const struct CompactHashIndex processObjectTableIndex[141] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 16, 130 }, + { 15, 129 }, { -1, -1 }, { -1, -1 }, - { 19, 137 }, + { 18, 138 }, { -1, -1 }, - { 43, -1 }, + { 45, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -33,37 +33,37 @@ static const struct CompactHashIndex processObjectTableIndex[141] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 3, 140 }, + { 3, 141 }, { 1, 128 }, { -1, -1 }, - { 57, -1 }, - { -1, -1 }, + { 59, -1 }, { -1, -1 }, + { 10, -1 }, { -1, -1 }, { -1, -1 }, - { 30, -1 }, + { 31, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 50, -1 }, + { 52, -1 }, { 27, -1 }, - { 10, -1 }, + { 12, -1 }, { -1, -1 }, - { 11, -1 }, + { 19, -1 }, { -1, -1 }, - { 15, 136 }, + { 14, 137 }, { -1, -1 }, - { 35, -1 }, + { 36, -1 }, { -1, -1 }, - { 37, -1 }, - { 53, -1 }, - { 34, -1 }, - { 6, 138 }, + { 38, -1 }, + { 55, -1 }, + { 35, -1 }, + { 6, 139 }, { -1, -1 }, - { 49, -1 }, + { 51, -1 }, { 4, -1 }, - { 45, -1 }, + { 47, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -75,23 +75,23 @@ static const struct CompactHashIndex processObjectTableIndex[141] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 39, -1 }, + { 40, -1 }, { -1, -1 }, - { 36, -1 }, + { 37, -1 }, { -1, -1 }, { 0, -1 }, - { 12, 129 }, - { 17, 131 }, - { 38, -1 }, + { 26, 135 }, + { 16, 130 }, + { 39, -1 }, { -1, -1 }, { 23, -1 }, - { 13, -1 }, + { 11, -1 }, { -1, -1 }, { -1, -1 }, - { 56, -1 }, + { 58, -1 }, { -1, -1 }, { -1, -1 }, - { 47, -1 }, + { 30, 136 }, { -1, -1 }, { 29, -1 }, { 22, -1 }, @@ -105,45 +105,46 @@ static const struct CompactHashIndex processObjectTableIndex[141] = { { 5, -1 }, { -1, -1 }, { -1, -1 }, - { 46, -1 }, + { 48, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 14, 132 }, + { 13, 131 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { 9, -1 }, - { 25, 134 }, + { 25, 133 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 21, 135 }, + { 21, 134 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 44, 139 }, + { 46, 140 }, { -1, -1 }, - { 18, -1 }, + { 17, -1 }, { 8, -1 }, - { 26, -1 }, { 28, -1 }, - { 31, 133 }, - { 32, -1 }, + { 32, 132 }, { 33, -1 }, - { 40, -1 }, + { 34, -1 }, { 41, -1 }, - { 48, -1 }, - { 51, -1 }, - { 52, -1 }, + { 42, -1 }, + { 44, -1 }, + { 49, -1 }, + { 50, -1 }, + { 53, -1 }, { 54, -1 }, - { 55, -1 }, + { 56, -1 }, + { 57, -1 }, }; -static const struct HashTableValue processObjectTableValues[58] = { +static const struct HashTableValue processObjectTableValues[60] = { { "abort"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionAbort, 1 } }, { "allowedNodeEnvironmentFlags"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptySet } }, { "arch"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArch } }, @@ -154,16 +155,16 @@ static const struct HashTableValue processObjectTableValues[58] = { { "browser"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructBrowser } }, { "chdir"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionChdir, 1 } }, { "config"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessConfigObject } }, - { "debugPort"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processDebugPort, setProcessDebugPort } }, - { "exitCode"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processExitCode, setProcessExitCode } }, - { "title"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processTitle, setProcessTitle } }, + { "cpuUsage"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionCpuUsage, 1 } }, { "cwd"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionCwd, 1 } }, + { "debugPort"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processDebugPort, setProcessDebugPort } }, { "dlopen"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionDlopen, 1 } }, { "emitWarning"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_emitWarning, 1 } }, { "env"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructEnv } }, { "execArgv"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructExecArgv } }, { "execPath"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructExecPath } }, { "exit"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionExit, 1 } }, + { "exitCode"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processExitCode, setProcessExitCode } }, { "features"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructFeatures } }, { "getActiveResourcesInfo"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubFunctionReturningArray, 0 } }, { "getegid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetegid, 0 } }, @@ -174,6 +175,7 @@ static const struct HashTableValue processObjectTableValues[58] = { { "hrtime"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessHrtimeObject } }, { "isBun"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructIsBun } }, { "mainModule"_s, ((static_cast(PropertyAttribute::ReadOnly|PropertyAttribute::Builtin|PropertyAttribute::Accessor|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, processObjectMainModuleCodeGenerator, 0 } }, + { "memoryUsage"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructMemoryUsage } }, { "moduleLoadList"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptyArray } }, { "nextTick"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionNextTick, 1 } }, { "openStdin"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionOpenStdin, 0 } }, @@ -187,6 +189,7 @@ static const struct HashTableValue processObjectTableValues[58] = { { "stderr"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStderr } }, { "stdin"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStdin } }, { "stdout"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStdout } }, + { "title"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processTitle, setProcessTitle } }, { "umask"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionUmask, 1 } }, { "uptime"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionUptime, 1 } }, { "version"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructVersion } }, @@ -205,4 +208,4 @@ static const struct HashTableValue processObjectTableValues[58] = { }; static const struct HashTable processObjectTable = - { 58, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; + { 60, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; diff --git a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h index 65875d091..82a2c6a24 100644 --- a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h @@ -38,6 +38,7 @@ public: std::unique_ptr m_clientSubspaceForJSMockImplementation; std::unique_ptr m_clientSubspaceForJSMockFunction; std::unique_ptr m_clientSubspaceForMockWithImplementationCleanupData; + std::unique_ptr m_clientSubspaceForProcessObject; #include "ZigGeneratedClasses+DOMClientIsoSubspaces.h" /* --- bun --- */ diff --git a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h index 433832450..f1b290d25 100644 --- a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h @@ -38,6 +38,7 @@ public: std::unique_ptr m_subspaceForJSMockImplementation; std::unique_ptr m_subspaceForJSMockFunction; std::unique_ptr m_subspaceForMockWithImplementationCleanupData; + std::unique_ptr m_subspaceForProcessObject; #include "ZigGeneratedClasses+DOMIsoSubspaces.h" /*-- BUN --*/ diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index c4701f664..e038383de 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -162,7 +162,8 @@ it("process.umask()", () => { expect(process.umask()).toBe(orig); }); -const versions = existsSync(import.meta.dir + "/../../src/generated_versions_list.zig"); +const generated_versions_list = join(import.meta.dir, "../../../../src/generated_versions_list.zig"); +const versions = existsSync(generated_versions_list); (versions ? it : it.skip)("process.versions", () => { // Generate a list of all the versions in the versions object // example: @@ -178,7 +179,7 @@ const versions = existsSync(import.meta.dir + "/../../src/generated_versions_lis // pub const c_ares = "0e7a5dee0fbb04080750cf6eabbe89d8bae87faa"; // pub const usockets = "fafc241e8664243fc0c51d69684d5d02b9805134"; const versions = Object.fromEntries( - readFileSync(import.meta.dir + "/../../src/generated_versions_list.zig", "utf8") + readFileSync(generated_versions_list, "utf8") .split("\n") .filter(line => line.startsWith("pub const") && !line.includes("zig") && line.includes(' = "')) .map(line => line.split(" = ")) @@ -291,3 +292,140 @@ describe("process.onBeforeExit", () => { expect(stdout.toString().trim()).toBe("beforeExit: 0\nbeforeExit: 1\nexit: 2"); }); }); + +it("process.memoryUsage", () => { + expect(process.memoryUsage()).toEqual({ + rss: expect.any(Number), + heapTotal: expect.any(Number), + heapUsed: expect.any(Number), + external: expect.any(Number), + arrayBuffers: expect.any(Number), + }); +}); + +it("process.memoryUsage.rss", () => { + expect(process.memoryUsage.rss()).toEqual(expect.any(Number)); +}); + +describe("process.cpuUsage", () => { + it("works", () => { + expect(process.cpuUsage()).toEqual({ + user: expect.any(Number), + system: expect.any(Number), + }); + }); + + it("works with diff", () => { + const init = process.cpuUsage(); + for (let i = 0; i < 1000; i++) {} + const delta = process.cpuUsage(init); + expect(delta.user).toBeGreaterThan(0); + expect(delta.system).toBeGreaterThan(0); + }); + + it("works with diff of different structure", () => { + const init = { + user: 0, + system: 0, + }; + for (let i = 0; i < 1000; i++) {} + const delta = process.cpuUsage(init); + expect(delta.user).toBeGreaterThan(0); + expect(delta.system).toBeGreaterThan(0); + }); + + it("throws on invalid property", () => { + const fixtures = [ + {}, + { user: null }, + { user: {} }, + { user: "potato" }, + + { user: 123 }, + { user: 123, system: null }, + { user: 123, system: "potato" }, + ]; + for (const fixture of fixtures) { + expect(() => process.cpuUsage(fixture)).toThrow(); + } + }); + + // Skipped on Linux because it seems to not change as often as on macOS + it.skipIf(process.platform === "linux")("increases monotonically", () => { + const init = process.cpuUsage(); + for (let i = 0; i < 10000; i++) {} + const another = process.cpuUsage(); + expect(another.user).toBeGreaterThan(init.user); + expect(another.system).toBeGreaterThan(init.system); + }); +}); + +it("process.getegid", () => { + expect(typeof process.getegid()).toBe("number"); +}); +it("process.geteuid", () => { + expect(typeof process.geteuid()).toBe("number"); +}); +it("process.getgid", () => { + expect(typeof process.getgid()).toBe("number"); +}); +it("process.getgroups", () => { + expect(process.getgroups()).toBeInstanceOf(Array); + expect(process.getgroups().length).toBeGreaterThan(0); +}); +it("process.getuid", () => { + expect(typeof process.getuid()).toBe("number"); +}); + +it("process.getuid", () => { + expect(typeof process.getuid()).toBe("number"); +}); + +const undefinedStubs = [ + "_debugEnd", + "_debugProcess", + "_fatalException", + "_linkedBinding", + "_rawDebug", + "_startProfilerIdleNotifier", + "_stopProfilerIdleNotifier", + "_tickCallback", +]; + +for (const stub of undefinedStubs) { + it(`process.${stub}`, () => { + expect(process[stub]()).toBeUndefined(); + }); +} + +const arrayStubs = ["getActiveResourcesInfo", "_getActiveRequests", "_getActiveHandles"]; + +for (const stub of arrayStubs) { + it(`process.${stub}`, () => { + expect(process[stub]()).toBeInstanceOf(Array); + }); +} + +const emptyObjectStubs = ["_preload_modules"]; +const emptySetStubs = ["allowedNodeEnvironmentFlags"]; +const emptyArrayStubs = ["moduleLoadList"]; + +for (const stub of emptyObjectStubs) { + it(`process.${stub}`, () => { + expect(process[stub]).toEqual({}); + }); +} + +for (const stub of emptySetStubs) { + it(`process.${stub}`, () => { + expect(process[stub]).toBeInstanceOf(Set); + expect(process[stub].size).toBe(0); + }); +} + +for (const stub of emptyArrayStubs) { + it(`process.${stub}`, () => { + expect(process[stub]).toBeInstanceOf(Array); + expect(process[stub]).toHaveLength(0); + }); +} -- cgit v1.2.3 From 963d4311e614ac197427104b9cf265bbe2a890af Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 9 Jul 2023 22:36:24 -0700 Subject: Fixes #3530 (#3587) * Fixes #3530 * Handle OOM * Add test --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/BunString.cpp | 23 +++++++++++++++++ src/bun.js/node/types.zig | 30 +++++++++++++++++----- src/bun.js/webcore/encoding.zig | 36 ++++++++++++--------------- src/string.zig | 26 +++++++++++++++++++ test/js/node/crypto/node-crypto.test.js | 44 +++++++++++++++++++++++++++++++++ 5 files changed, 133 insertions(+), 26 deletions(-) diff --git a/src/bun.js/bindings/BunString.cpp b/src/bun.js/bindings/BunString.cpp index 4c8ff384e..21541d711 100644 --- a/src/bun.js/bindings/BunString.cpp +++ b/src/bun.js/bindings/BunString.cpp @@ -169,6 +169,29 @@ extern "C" JSC::EncodedJSValue BunString__toJS(JSC::JSGlobalObject* globalObject return JSValue::encode(Bun::toJS(globalObject, *bunString)); } +extern "C" BunString BunString__fromUTF16Unitialized(size_t length) +{ + unsigned utf16Length = length; + UChar* ptr; + auto impl = WTF::StringImpl::createUninitialized(utf16Length, ptr); + if (UNLIKELY(!ptr)) + return { BunStringTag::Dead }; + + impl->ref(); + return { BunStringTag::WTFStringImpl, { .wtf = &impl.leakRef() } }; +} + +extern "C" BunString BunString__fromLatin1Unitialized(size_t length) +{ + unsigned latin1Length = length; + LChar* ptr; + auto impl = WTF::StringImpl::createUninitialized(latin1Length, ptr); + if (UNLIKELY(!ptr)) + return { BunStringTag::Dead }; + impl->ref(); + return { BunStringTag::WTFStringImpl, { .wtf = &impl.leakRef() } }; +} + extern "C" BunString BunString__fromUTF8(const char* bytes, size_t length) { if (simdutf::validate_utf8(bytes, length)) { diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index 553b292d6..642039ba5 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -541,9 +541,18 @@ pub const Encoding = enum(u8) { const result = JSC.ZigString.init(out).toValueGC(globalThis); return result; }, - else => { - globalThis.throwInvalidArguments("Unexpected encoding", .{}); - return JSC.JSValue.zero; + .buffer => { + return JSC.ArrayBuffer.createBuffer(globalThis, input); + }, + + inline else => |enc| { + const res = JSC.WebCore.Encoder.toString(input.ptr, size, globalThis, enc); + if (res.isError()) { + globalThis.throwValue(res); + return .zero; + } + + return res; }, } } @@ -571,9 +580,18 @@ pub const Encoding = enum(u8) { const result = JSC.ZigString.init(out).toValueGC(globalThis); return result; }, - else => { - globalThis.throwInvalidArguments("Unexpected encoding", .{}); - return JSC.JSValue.zero; + .buffer => { + return JSC.ArrayBuffer.createBuffer(globalThis, input); + }, + inline else => |enc| { + const res = JSC.WebCore.Encoder.toString(input.ptr, input.len, globalThis, enc); + + if (res.isError()) { + globalThis.throwValue(res); + return .zero; + } + + return res; }, } } diff --git a/src/bun.js/webcore/encoding.zig b/src/bun.js/webcore/encoding.zig index bb1180acb..dd47ccc29 100644 --- a/src/bun.js/webcore/encoding.zig +++ b/src/bun.js/webcore/encoding.zig @@ -829,23 +829,18 @@ pub const Encoder = struct { return ZigString.init(input).toValueGC(global); } - if (input.len < 512) { - var buf: [512]u8 = undefined; - var to = buf[0..input.len]; - strings.copyLatin1IntoASCII(to, input); - return ZigString.init(to).toValueGC(global); - } - - var to = allocator.alloc(u8, len) catch return ZigString.init("Out of memory").toErrorInstance(global); - strings.copyLatin1IntoASCII(to, input); - return ZigString.init(to).toExternalValue(global); + var str = bun.String.createUninitialized(.latin1, len) orelse return ZigString.init("Out of memory").toErrorInstance(global); + defer str.deref(); + strings.copyLatin1IntoASCII(@constCast(str.latin1()), input); + return str.toJS(global); }, .latin1 => { - var to = allocator.alloc(u8, len) catch return ZigString.init("Out of memory").toErrorInstance(global); + var str = bun.String.createUninitialized(.latin1, len) orelse return ZigString.init("Out of memory").toErrorInstance(global); + defer str.deref(); - @memcpy(to, input_ptr[0..to.len]); + @memcpy(@constCast(str.latin1()), input_ptr[0..len]); - return ZigString.init(to).toExternalValue(global); + return str.toJS(global); }, .buffer, .utf8 => { const converted = strings.toUTF16Alloc(allocator, input, false) catch return ZigString.init("Out of memory").toErrorInstance(global); @@ -861,21 +856,22 @@ pub const Encoder = struct { // Avoid incomplete characters if (len / 2 == 0) return ZigString.Empty.toValue(global); - var output = allocator.alloc(u16, len / 2) catch return ZigString.init("Out of memory").toErrorInstance(global); - var output_bytes = std.mem.sliceAsBytes(output); + var output = bun.String.createUninitialized(.utf16, len / 2) orelse return ZigString.init("Out of memory").toErrorInstance(global); + defer output.deref(); + var output_bytes = std.mem.sliceAsBytes(@constCast(output.utf16())); output_bytes[output_bytes.len - 1] = 0; @memcpy(output_bytes, input_ptr[0..output_bytes.len]); - return ZigString.toExternalU16(output.ptr, output.len, global); + return output.toJS(global); }, .hex => { - var output = allocator.alloc(u8, input.len * 2) catch return ZigString.init("Out of memory").toErrorInstance(global); + var str = bun.String.createUninitialized(.latin1, len * 2) orelse return ZigString.init("Out of memory").toErrorInstance(global); + defer str.deref(); + var output = @constCast(str.latin1()); const wrote = strings.encodeBytesToHex(output, input); std.debug.assert(wrote == output.len); - var val = ZigString.init(output); - val.mark(); - return val.toExternalValue(global); + return str.toJS(global); }, .base64url => { diff --git a/src/string.zig b/src/string.zig index 166a0a6f7..5f107197f 100644 --- a/src/string.zig +++ b/src/string.zig @@ -257,6 +257,8 @@ pub const String = extern struct { extern fn BunString__fromLatin1(bytes: [*]const u8, len: usize) String; extern fn BunString__fromBytes(bytes: [*]const u8, len: usize) String; + extern fn BunString__fromLatin1Unitialized(len: usize) String; + extern fn BunString__fromUTF16Unitialized(len: usize) String; pub fn toOwnedSlice(this: String, allocator: std.mem.Allocator) ![]u8 { switch (this.tag) { @@ -278,6 +280,30 @@ pub const String = extern struct { } } + pub fn createUninitializedLatin1(len: usize) String { + JSC.markBinding(@src()); + return BunString__fromLatin1Unitialized(len); + } + + pub fn createUninitializedUTF16(len: usize) String { + JSC.markBinding(@src()); + return BunString__fromUTF16Unitialized(len); + } + + pub fn createUninitialized(comptime kind: @Type(.EnumLiteral), len: usize) ?String { + const without_check = switch (comptime kind) { + .latin1 => createUninitializedLatin1(len), + .utf16 => createUninitializedUTF16(len), + else => @compileError("Invalid string kind"), + }; + + if (without_check.tag == .Dead) { + return null; + } + + return without_check; + } + pub fn createLatin1(bytes: []const u8) String { JSC.markBinding(@src()); return BunString__fromLatin1(bytes.ptr, bytes.len); diff --git a/test/js/node/crypto/node-crypto.test.js b/test/js/node/crypto/node-crypto.test.js index 5a68540cf..2489f96c7 100644 --- a/test/js/node/crypto/node-crypto.test.js +++ b/test/js/node/crypto/node-crypto.test.js @@ -43,6 +43,50 @@ describe("createHash", () => { expect(Buffer.isBuffer(hash.digest())).toBeTrue(); }); + const otherEncodings = { + ucs2: [ + 11626, 2466, 37699, 38942, 64564, 53010, 48101, 47943, 44761, 18499, 12442, 26994, 46434, 62582, 39395, 20542, + ], + latin1: [ + 106, 45, 162, 9, 67, 147, 30, 152, 52, 252, 18, 207, 229, 187, 71, 187, 217, 174, 67, 72, 154, 48, 114, 105, 98, + 181, 118, 244, 227, 153, 62, 80, + ], + binary: [ + 106, 45, 162, 9, 67, 147, 30, 152, 52, 252, 18, 207, 229, 187, 71, 187, 217, 174, 67, 72, 154, 48, 114, 105, 98, + 181, 118, 244, 227, 153, 62, 80, + ], + base64: [ + 97, 105, 50, 105, 67, 85, 79, 84, 72, 112, 103, 48, 47, 66, 76, 80, 53, 98, 116, 72, 117, 57, 109, 117, 81, 48, + 105, 97, 77, 72, 74, 112, 89, 114, 86, 50, 57, 79, 79, 90, 80, 108, 65, 61, + ], + hex: [ + 54, 97, 50, 100, 97, 50, 48, 57, 52, 51, 57, 51, 49, 101, 57, 56, 51, 52, 102, 99, 49, 50, 99, 102, 101, 53, 98, + 98, 52, 55, 98, 98, 100, 57, 97, 101, 52, 51, 52, 56, 57, 97, 51, 48, 55, 50, 54, 57, 54, 50, 98, 53, 55, 54, 102, + 52, 101, 51, 57, 57, 51, 101, 53, 48, + ], + ascii: [ + 106, 45, 34, 9, 67, 19, 30, 24, 52, 124, 18, 79, 101, 59, 71, 59, 89, 46, 67, 72, 26, 48, 114, 105, 98, 53, 118, + 116, 99, 25, 62, 80, + ], + utf8: [ + 106, 45, 65533, 9, 67, 65533, 30, 65533, 52, 65533, 18, 65533, 65533, 71, 65533, 1646, 67, 72, 65533, 48, 114, + 105, 98, 65533, 118, 65533, 65533, 62, 80, + ], + }; + + for (let encoding in otherEncodings) { + it("digest " + encoding, () => { + const hash = crypto.createHash("sha256"); + hash.update("some data to hash"); + expect( + hash + .digest(encoding) + .split("") + .map(a => a.charCodeAt(0)), + ).toEqual(otherEncodings[encoding]); + }); + } + it("stream (sync)", () => { const hash = crypto.createHash("sha256"); hash.write("some data to hash"); -- cgit v1.2.3 From 93b0e94410754eea36a4f5a5a9f953ed959eee99 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 10 Jul 2023 01:26:02 -0700 Subject: trim node:stream a little --- src/js/build-esm.ts | 22 +++++++++++++++++++--- src/js/node/stream.js | 28 +++++++++++++++++----------- src/js/out/modules/node/stream.js | 4 ++-- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/js/build-esm.ts b/src/js/build-esm.ts index edfe7c04f..8cdca3688 100644 --- a/src/js/build-esm.ts +++ b/src/js/build-esm.ts @@ -55,23 +55,39 @@ const opts = { }, } as const; +const productionOpts = { + ...opts, + define: { + ...opts.define, + "IS_BUN_DEVELOPMENT": "false", + }, +}; + +const devOpts = { + ...opts, + define: { + ...opts.define, + "IS_BUN_DEVELOPMENT": "true", + }, +}; + const build_prod_minified = await Bun.build({ entrypoints: entrypoints.filter(file => minifyList.includes(file.slice(import.meta.dir.length + 1))), minify: true, - ...opts, + ...productionOpts, }); const build_prod_unminified = await Bun.build({ entrypoints: entrypoints.filter(file => !minifyList.includes(file.slice(import.meta.dir.length + 1))), minify: { syntax: true }, - ...opts, + ...productionOpts, }); const build_dev = await Bun.build({ entrypoints: entrypoints, minify: { syntax: true }, sourcemap: "external", - ...opts, + ...devOpts, }); for (const [build, outdir] of [ diff --git a/src/js/node/stream.js b/src/js/node/stream.js index 9344fa73f..741b2f65c 100644 --- a/src/js/node/stream.js +++ b/src/js/node/stream.js @@ -1,15 +1,20 @@ // Hardcoded module "node:stream" / "readable-stream" // "readable-stream" npm package // just transpiled -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(",") - : process.env.DEBUG_STREAMS?.length - ? process.env.DEBUG_STREAMS.split(",") - : null; +// This must go at the top of the file, before any side effects. +// IS_BUN_DEVELOPMENT is a bundle-only global variable that is set to true when +// building a development bundle. +const __TRACK_EE__ = IS_BUN_DEVELOPMENT && !!process.env.DEBUG_TRACK_EE; +const __DEBUG__ = IS_BUN_DEVELOPMENT && !!(process.env.DEBUG || process.env.DEBUG_STREAMS || __TRACK_EE__); + +if (__DEBUG__) { + 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; +} // Separating DEBUG, DEBUG_STREAMS and DEBUG_TRACK_EE env vars makes it easier to focus on the // events in this file rather than all debug output across all files @@ -18,9 +23,6 @@ globalThis.__IDS_TO_TRACK = process.env.DEBUG_TRACK_EE?.length // The events and/or all of the outputs for the given stream IDs assigned at stream construction // By default, child_process gives -const __TRACK_EE__ = !!process.env.DEBUG_TRACK_EE; -const __DEBUG__ = !!(process.env.DEBUG || process.env.DEBUG_STREAMS || __TRACK_EE__); - var debug = __DEBUG__ ? globalThis.__IDS_TO_TRACK ? // If we are tracking IDs for debug event emitters, we should prefix the debug output with the ID @@ -32,6 +34,10 @@ var debug = __DEBUG__ : (...args) => console.log(...args.slice(0, -1)) : () => {}; +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"; + var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; diff --git a/src/js/out/modules/node/stream.js b/src/js/out/modules/node/stream.js index f7e94b00d..0497ffd82 100644 --- a/src/js/out/modules/node/stream.js +++ b/src/js/out/modules/node/stream.js @@ -1,2 +1,2 @@ -import{EventEmitter as Tq} from"bun:events_native";import{StringDecoder as rq} from"node:string_decoder";var qQ=function(t){return typeof t==="object"&&t!==null&&t instanceof ReadableStream},QQ=function(t,M){if(typeof t!=="boolean")throw new XQ(M,"boolean",t)};var XQ=function(t,M,B){return new Error(`The argument '${t}' is invalid. Received '${B}' for type '${M}'`)},JQ=function(t,M,B){return new Error(`The value '${M}' is invalid for argument '${t}'. Reason: ${B}`)},zQ=function(t,M){var[B,F,y,I,j,R,x]=globalThis[Symbol.for("Bun.lazy")](t),g=[!1],f=function(P,A,K,U){if(A>0){const T=K.subarray(0,A),C=K.subarray(A);if(T.byteLength>0)P.push(T);if(U)P.push(null);return C.byteLength>0?C:void 0}if(U)P.push(null);return K},c=function(P,A,K,U){if(A.byteLength>0)P.push(A);if(U)P.push(null);return K},_=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const i=new FinalizationRegistry((P)=>P&&j(P)),D=512;var p=class P extends M{#q;#Q=1;#X=!1;#H=void 0;#J;#K=!1;#Z=!_;#B;constructor(A,K={}){super(K);if(typeof K.highWaterMark==="number")this.#J=K.highWaterMark;else this.#J=262144;this.#q=A,this.#X=!1,this.#H=void 0,this.#K=!1,this.#B={},i.register(this,this.#q,this.#B)}_read(A){if(n&&d("NativeReadable._read",this.__id),this.#K){n&&d("pendingRead is true",this.__id);return}var K=this.#q;if(n&&d("ptr @ NativeReadable._read",K,this.__id),K===0){this.push(null);return}if(!this.#X)n&&d("NativeReadable not constructed yet",this.__id),this.#$(K);return this.#V(this.#z(A),K)}#$(A){this.#X=!0;const K=F(A,this.#J);if(n&&d("NativeReadable internal `start` result",K,this.__id),typeof K==="number"&&K>1)this.#Z=!0,n&&d("NativeReadable resized",this.__id),this.#J=Math.min(this.#J,K);if(x){const U=x(A);if(n&&d("NativeReadable drain result",U,this.__id),(U?.byteLength??0)>0)this.push(U)}}#z(A=this.#J){var K=this.#H;if(n&&d("chunk @ #getRemainingChunk",K,this.__id),K?.byteLength??0D?A:D;this.#H=K=new Buffer(U)}return K}push(A,K){return n&&d("NativeReadable push -- result, encoding",A,K,this.__id),super.push(...arguments)}#Y(A,K,U){if(n&&d("result, isClosed @ #handleResult",A,U,this.__id),typeof A==="number"){if(A>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0;return f(this,A,K,U)}else if(typeof A==="boolean")return this.push(null),K?.byteLength??0>0?K:void 0;else if(ArrayBuffer.isView(A)){if(A.byteLength>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0,n&&d("Resized",this.__id);return c(this,A,K,U)}else throw n&&d("Unknown result type",A,this.__id),new Error("Invalid result from pull")}#V(A,K){n&&d("#internalRead()",this.__id),g[0]=!1;var U=B(K,A,g);if(Oq(U))return this.#K=!0,U.then((T)=>{this.#K=!1,n&&d("pending no longerrrrrrrr (result returned from pull)",this.__id),this.#H=this.#Y(T,A,g[0])},(T)=>{n&&d("error from pull",T,this.__id),errorOrDestroy(this,T)});else this.#H=this.#Y(U,A,g[0])}_destroy(A,K){var U=this.#q;if(U===0){K(A);return}if(i.unregister(this.#B),this.#q=0,R)R(U,!1);n&&d("NativeReadable destroyed",this.__id),y(U,A),K(A)}ref(){var A=this.#q;if(A===0)return;if(this.#Q++===0)R(A,!0)}unref(){var A=this.#q;if(A===0)return;if(this.#Q--===1)R(A,!1)}};if(!R)p.prototype.ref=void 0,p.prototype.unref=void 0;return p},iq=function(t,M){return VQ[t]||=zQ(t,M)},UQ=function(t,M,B){if(!(M&&typeof M==="object"&&M instanceof ReadableStream))return;const F=aq(M);if(!F){d("no native readable stream");return}const{stream:y,data:I}=F;return new(iq(I,t))(y,B)},{isPromise:Oq,isCallable:sq,direct:aq,Object:Uq}=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 tq=!!process.env.DEBUG_TRACK_EE,n=!!(process.env.DEBUG||process.env.DEBUG_STREAMS||tq),d=n?globalThis.__IDS_TO_TRACK?(...t)=>{const M=t[t.length-1];if(!globalThis.__IDS_TO_TRACK.includes(M))return;console.log(`ID: ${M}`,...t.slice(0,-1))}:(...t)=>console.log(...t.slice(0,-1)):()=>{},FQ=Uq.create,LQ=Uq.defineProperty,jQ=Uq.getOwnPropertyDescriptor,eq=Uq.getOwnPropertyNames,NQ=Uq.getPrototypeOf,AQ=Uq.prototype.hasOwnProperty,EQ=Uq.setPrototypeOf,$q=(t,M)=>function B(){return M||(0,t[eq(t)[0]])((M={exports:{}}).exports,M),M.exports};var Hq=process.nextTick;var IQ=Array.isArray,Wq=$q({"node_modules/readable-stream/lib/ours/primordials.js"(t,M){M.exports={ArrayIsArray(B){return Array.isArray(B)},ArrayPrototypeIncludes(B,F){return B.includes(F)},ArrayPrototypeIndexOf(B,F){return B.indexOf(F)},ArrayPrototypeJoin(B,F){return B.join(F)},ArrayPrototypeMap(B,F){return B.map(F)},ArrayPrototypePop(B,F){return B.pop(F)},ArrayPrototypePush(B,F){return B.push(F)},ArrayPrototypeSlice(B,F,y){return B.slice(F,y)},Error,FunctionPrototypeCall(B,F,...y){return B.call(F,...y)},FunctionPrototypeSymbolHasInstance(B,F){return Function.prototype[Symbol.hasInstance].call(B,F)},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(B,F){return Uq.defineProperties(B,F)},ObjectDefineProperty(B,F,y){return Uq.defineProperty(B,F,y)},ObjectGetOwnPropertyDescriptor(B,F){return Uq.getOwnPropertyDescriptor(B,F)},ObjectKeys(B){return Uq.keys(B)},ObjectSetPrototypeOf(B,F){return Uq.setPrototypeOf(B,F)},Promise,PromisePrototypeCatch(B,F){return B.catch(F)},PromisePrototypeThen(B,F,y){return B.then(F,y)},PromiseReject(B){return Promise.reject(B)},ReflectApply:Reflect.apply,RegExpPrototypeTest(B,F){return B.test(F)},SafeSet:Set,String,StringPrototypeSlice(B,F,y){return B.slice(F,y)},StringPrototypeToLowerCase(B){return B.toLowerCase()},StringPrototypeToUpperCase(B){return B.toUpperCase()},StringPrototypeTrim(B){return B.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(B,F,y){return B.set(F,y)},Uint8Array}}}),Eq=$q({"node_modules/readable-stream/lib/ours/util.js"(t,M){var B=Uq.getPrototypeOf(async function(){}).constructor,F=typeof Blob!=="undefined"?function I(j){return j instanceof Blob}:function I(j){return!1},y=class extends Error{constructor(I){if(!Array.isArray(I))throw new TypeError(`Expected input to be an Array, got ${typeof I}`);let j="";for(let R=0;R{I=x,j=g}),resolve:I,reject:j}},promisify(I){return new Promise((j,R)=>{I((x,...g)=>{if(x)return R(x);return j(...g)})})},debuglog(){return function(){}},format(I,...j){return I.replace(/%([sdifj])/g,function(...[R,x]){const g=j.shift();if(x==="f")return g.toFixed(6);else if(x==="j")return JSON.stringify(g);else if(x==="s"&&typeof g==="object")return`${g.constructor!==Uq?g.constructor.name:""} {}`.trim();else return g.toString()})},inspect(I){switch(typeof I){case"string":if(I.includes("'")){if(!I.includes('"'))return`"${I}"`;else if(!I.includes("`")&&!I.includes("${"))return`\`${I}\``}return`'${I}'`;case"number":if(isNaN(I))return"NaN";else if(Uq.is(I,-0))return String(I);return I;case"bigint":return`${String(I)}n`;case"boolean":case"undefined":return String(I);case"object":return"{}"}},types:{isAsyncFunction(I){return I instanceof B},isArrayBufferView(I){return ArrayBuffer.isView(I)}},isBlob:F},M.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),Mq=$q({"node_modules/readable-stream/lib/ours/errors.js"(t,M){var{format:B,inspect:F,AggregateError:y}=Eq(),I=globalThis.AggregateError||y,j=Symbol("kIsNodeError"),R=["string","function","number","object","Function","Object","boolean","bigint","symbol"],x=/^([A-Z][a-z0-9]*)+$/,g="__node_internal_",f={};function c(K,U){if(!K)throw new f.ERR_INTERNAL_ASSERTION(U)}function _(K){let U="",T=K.length;const C=K[0]==="-"?1:0;for(;T>=C+4;T-=3)U=`_${K.slice(T-3,T)}${U}`;return`${K.slice(0,T)}${U}`}function i(K,U,T){if(typeof U==="function")return c(U.length<=T.length,`Code: ${K}; The provided arguments length (${T.length}) does not match the required ones (${U.length}).`),U(...T);const C=(U.match(/%[dfijoOs]/g)||[]).length;if(c(C===T.length,`Code: ${K}; The provided arguments length (${T.length}) does not match the required ones (${C}).`),T.length===0)return U;return B(U,...T)}function D(K,U,T){if(!T)T=Error;class C extends T{constructor(...qq){super(i(K,U,qq))}toString(){return`${this.name} [${K}]: ${this.message}`}}Uq.defineProperties(C.prototype,{name:{value:T.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${K}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),C.prototype.code=K,C.prototype[j]=!0,f[K]=C}function p(K){const U=g+K.name;return Uq.defineProperty(K,"name",{value:U}),K}function P(K,U){if(K&&U&&K!==U){if(Array.isArray(U.errors))return U.errors.push(K),U;const T=new I([U,K],U.message);return T.code=U.code,T}return K||U}var A=class extends Error{constructor(K="The operation was aborted",U=void 0){if(U!==void 0&&typeof U!=="object")throw new f.ERR_INVALID_ARG_TYPE("options","Object",U);super(K,U);this.code="ABORT_ERR",this.name="AbortError"}};D("ERR_ASSERTION","%s",Error),D("ERR_INVALID_ARG_TYPE",(K,U,T)=>{if(c(typeof K==="string","'name' must be a string"),!Array.isArray(U))U=[U];let C="The ";if(K.endsWith(" argument"))C+=`${K} `;else C+=`"${K}" ${K.includes(".")?"property":"argument"} `;C+="must be ";const qq=[],o=[],$=[];for(let Y of U)if(c(typeof Y==="string","All expected entries have to be of type string"),R.includes(Y))qq.push(Y.toLowerCase());else if(x.test(Y))o.push(Y);else c(Y!=="object",'The value "object" should be written as "Object"'),$.push(Y);if(o.length>0){const Y=qq.indexOf("object");if(Y!==-1)qq.splice(qq,Y,1),o.push("Object")}if(qq.length>0){switch(qq.length){case 1:C+=`of type ${qq[0]}`;break;case 2:C+=`one of type ${qq[0]} or ${qq[1]}`;break;default:{const Y=qq.pop();C+=`one of type ${qq.join(", ")}, or ${Y}`}}if(o.length>0||$.length>0)C+=" or "}if(o.length>0){switch(o.length){case 1:C+=`an instance of ${o[0]}`;break;case 2:C+=`an instance of ${o[0]} or ${o[1]}`;break;default:{const Y=o.pop();C+=`an instance of ${o.join(", ")}, or ${Y}`}}if($.length>0)C+=" or "}switch($.length){case 0:break;case 1:if($[0].toLowerCase()!==$[0])C+="an ";C+=`${$[0]}`;break;case 2:C+=`one of ${$[0]} or ${$[1]}`;break;default:{const Y=$.pop();C+=`one of ${$.join(", ")}, or ${Y}`}}if(T==null)C+=`. Received ${T}`;else if(typeof T==="function"&&T.name)C+=`. Received function ${T.name}`;else if(typeof T==="object"){var s;if((s=T.constructor)!==null&&s!==void 0&&s.name)C+=`. Received an instance of ${T.constructor.name}`;else{const Y=F(T,{depth:-1});C+=`. Received ${Y}`}}else{let Y=F(T,{colors:!1});if(Y.length>25)Y=`${Y.slice(0,25)}...`;C+=`. Received type ${typeof T} (${Y})`}return C},TypeError),D("ERR_INVALID_ARG_VALUE",(K,U,T="is invalid")=>{let C=F(U);if(C.length>128)C=C.slice(0,128)+"...";return`The ${K.includes(".")?"property":"argument"} '${K}' ${T}. Received ${C}`},TypeError),D("ERR_INVALID_RETURN_VALUE",(K,U,T)=>{var C;const qq=T!==null&&T!==void 0&&(C=T.constructor)!==null&&C!==void 0&&C.name?`instance of ${T.constructor.name}`:`type ${typeof T}`;return`Expected ${K} to be returned from the "${U}" function but got ${qq}.`},TypeError),D("ERR_MISSING_ARGS",(...K)=>{c(K.length>0,"At least one arg needs to be specified");let U;const T=K.length;switch(K=(Array.isArray(K)?K:[K]).map((C)=>`"${C}"`).join(" or "),T){case 1:U+=`The ${K[0]} argument`;break;case 2:U+=`The ${K[0]} and ${K[1]} arguments`;break;default:{const C=K.pop();U+=`The ${K.join(", ")}, and ${C} arguments`}break}return`${U} must be specified`},TypeError),D("ERR_OUT_OF_RANGE",(K,U,T)=>{c(U,'Missing "range" argument');let C;if(Number.isInteger(T)&&Math.abs(T)>4294967296)C=_(String(T));else if(typeof T==="bigint"){if(C=String(T),T>2n**32n||T<-(2n**32n))C=_(C);C+="n"}else C=F(T);return`The value of "${K}" is out of range. It must be ${U}. Received ${C}`},RangeError),D("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),D("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),D("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),D("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),D("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),D("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),D("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),D("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),D("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),D("ERR_STREAM_WRITE_AFTER_END","write after end",Error),D("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),M.exports={AbortError:A,aggregateTwoErrors:p(P),hideStackFrames:p,codes:f}}}),Cq=$q({"node_modules/readable-stream/lib/internal/validators.js"(t,M){var{ArrayIsArray:B,ArrayPrototypeIncludes:F,ArrayPrototypeJoin:y,ArrayPrototypeMap:I,NumberIsInteger:j,NumberMAX_SAFE_INTEGER:R,NumberMIN_SAFE_INTEGER:x,NumberParseInt:g,RegExpPrototypeTest:f,String:c,StringPrototypeToUpperCase:_,StringPrototypeTrim:i}=Wq(),{hideStackFrames:D,codes:{ERR_SOCKET_BAD_PORT:p,ERR_INVALID_ARG_TYPE:P,ERR_INVALID_ARG_VALUE:A,ERR_OUT_OF_RANGE:K,ERR_UNKNOWN_SIGNAL:U}}=Mq(),{normalizeEncoding:T}=Eq(),{isAsyncFunction:C,isArrayBufferView:qq}=Eq().types,o={};function $(V){return V===(V|0)}function s(V){return V===V>>>0}var Y=/^[0-7]+$/,Z="must be a 32-bit unsigned integer or an octal string";function N(V,h,X){if(typeof V==="undefined")V=X;if(typeof V==="string"){if(!f(Y,V))throw new A(h,V,Z);V=g(V,8)}return u(V,h,0,4294967295),V}var m=D((V,h,X=x,H=R)=>{if(typeof V!=="number")throw new P(h,"number",V);if(!j(V))throw new K(h,"an integer",V);if(VH)throw new K(h,`>= ${X} && <= ${H}`,V)}),u=D((V,h,X=-2147483648,H=2147483647)=>{if(typeof V!=="number")throw new P(h,"number",V);if(!$(V)){if(!j(V))throw new K(h,"an integer",V);throw new K(h,`>= ${X} && <= ${H}`,V)}if(VH)throw new K(h,`>= ${X} && <= ${H}`,V)}),J=D((V,h,X)=>{if(typeof V!=="number")throw new P(h,"number",V);if(!s(V)){if(!j(V))throw new K(h,"an integer",V);throw new K(h,`>= ${X?1:0} && < 4294967296`,V)}if(X&&V===0)throw new K(h,">= 1 && < 4294967296",V)});function z(V,h){if(typeof V!=="string")throw new P(h,"string",V)}function w(V,h){if(typeof V!=="number")throw new P(h,"number",V)}var S=D((V,h,X)=>{if(!F(X,V)){const L="must be one of: "+y(I(X,(l)=>typeof l==="string"?`'${l}'`:c(l)),", ");throw new A(h,V,L)}});function E(V,h){if(typeof V!=="boolean")throw new P(h,"boolean",V)}var W=D((V,h,X)=>{const H=X==null,L=H?!1:X.allowArray,l=H?!1:X.allowFunction;if(!(H?!1:X.nullable)&&V===null||!L&&B(V)||typeof V!=="object"&&(!l||typeof V!=="function"))throw new P(h,"Object",V)}),b=D((V,h,X=0)=>{if(!B(V))throw new P(h,"Array",V);if(V.length{if(!qq(V))throw new P(h,["Buffer","TypedArray","DataView"],V)});function Qq(V,h){const X=T(h),H=V.length;if(X==="hex"&&H%2!==0)throw new A("encoding",h,`is invalid for data of length ${H}`)}function Zq(V,h="Port",X=!0){if(typeof V!=="number"&&typeof V!=="string"||typeof V==="string"&&i(V).length===0||+V!==+V>>>0||V>65535||V===0&&!X)throw new p(h,V,X);return V|0}var Vq=D((V,h)=>{if(V!==void 0&&(V===null||typeof V!=="object"||!("aborted"in V)))throw new P(h,"AbortSignal",V)}),Xq=D((V,h)=>{if(typeof V!=="function")throw new P(h,"Function",V)}),Bq=D((V,h)=>{if(typeof V!=="function"||C(V))throw new P(h,"Function",V)}),Jq=D((V,h)=>{if(V!==void 0)throw new P(h,"undefined",V)});M.exports={isInt32:$,isUint32:s,parseFileMode:N,validateArray:b,validateBoolean:E,validateBuffer:r,validateEncoding:Qq,validateFunction:Xq,validateInt32:u,validateInteger:m,validateNumber:w,validateObject:W,validateOneOf:S,validatePlainFunction:Bq,validatePort:Zq,validateSignalName:a,validateString:z,validateUint32:J,validateUndefined:Jq,validateAbortSignal:Vq}}}),Iq=$q({"node_modules/readable-stream/lib/internal/streams/utils.js"(t,M){var{Symbol:B,SymbolAsyncIterator:F,SymbolIterator:y}=Wq(),I=B("kDestroyed"),j=B("kIsErrored"),R=B("kIsReadable"),x=B("kIsDisturbed");function g(J,z=!1){var w;return!!(J&&typeof J.pipe==="function"&&typeof J.on==="function"&&(!z||typeof J.pause==="function"&&typeof J.resume==="function")&&(!J._writableState||((w=J._readableState)===null||w===void 0?void 0:w.readable)!==!1)&&(!J._writableState||J._readableState))}function f(J){var z;return!!(J&&typeof J.write==="function"&&typeof J.on==="function"&&(!J._readableState||((z=J._writableState)===null||z===void 0?void 0:z.writable)!==!1))}function c(J){return!!(J&&typeof J.pipe==="function"&&J._readableState&&typeof J.on==="function"&&typeof J.write==="function")}function _(J){return J&&(J._readableState||J._writableState||typeof J.write==="function"&&typeof J.on==="function"||typeof J.pipe==="function"&&typeof J.on==="function")}function i(J,z){if(J==null)return!1;if(z===!0)return typeof J[F]==="function";if(z===!1)return typeof J[y]==="function";return typeof J[F]==="function"||typeof J[y]==="function"}function D(J){if(!_(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!!(J.destroyed||J[I]||S!==null&&S!==void 0&&S.destroyed)}function p(J){if(!f(J))return null;if(J.writableEnded===!0)return!0;const z=J._writableState;if(z!==null&&z!==void 0&&z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function P(J,z){if(!f(J))return null;if(J.writableFinished===!0)return!0;const w=J._writableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.finished)!=="boolean")return null;return!!(w.finished||z===!1&&w.ended===!0&&w.length===0)}function A(J){if(!g(J))return null;if(J.readableEnded===!0)return!0;const z=J._readableState;if(!z||z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function K(J,z){if(!g(J))return null;const w=J._readableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.endEmitted)!=="boolean")return null;return!!(w.endEmitted||z===!1&&w.ended===!0&&w.length===0)}function U(J){if(J&&J[R]!=null)return J[R];if(typeof(J===null||J===void 0?void 0:J.readable)!=="boolean")return null;if(D(J))return!1;return g(J)&&J.readable&&!K(J)}function T(J){if(typeof(J===null||J===void 0?void 0:J.writable)!=="boolean")return null;if(D(J))return!1;return f(J)&&J.writable&&!p(J)}function C(J,z){if(!_(J))return null;if(D(J))return!0;if((z===null||z===void 0?void 0:z.readable)!==!1&&U(J))return!1;if((z===null||z===void 0?void 0:z.writable)!==!1&&T(J))return!1;return!0}function qq(J){var z,w;if(!_(J))return null;if(J.writableErrored)return J.writableErrored;return(z=(w=J._writableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function o(J){var z,w;if(!_(J))return null;if(J.readableErrored)return J.readableErrored;return(z=(w=J._readableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function $(J){if(!_(J))return null;if(typeof J.closed==="boolean")return J.closed;const{_writableState:z,_readableState:w}=J;if(typeof(z===null||z===void 0?void 0:z.closed)==="boolean"||typeof(w===null||w===void 0?void 0:w.closed)==="boolean")return(z===null||z===void 0?void 0:z.closed)||(w===null||w===void 0?void 0:w.closed);if(typeof J._closed==="boolean"&&s(J))return J._closed;return null}function s(J){return typeof J._closed==="boolean"&&typeof J._defaultKeepAlive==="boolean"&&typeof J._removedConnection==="boolean"&&typeof J._removedContLen==="boolean"}function Y(J){return typeof J._sent100==="boolean"&&s(J)}function Z(J){var z;return typeof J._consuming==="boolean"&&typeof J._dumped==="boolean"&&((z=J.req)===null||z===void 0?void 0:z.upgradeOrConnect)===void 0}function N(J){if(!_(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!S&&Y(J)||!!(S&&S.autoDestroy&&S.emitClose&&S.closed===!1)}function m(J){var z;return!!(J&&((z=J[x])!==null&&z!==void 0?z:J.readableDidRead||J.readableAborted))}function u(J){var z,w,S,E,W,b,a,r,Qq,Zq;return!!(J&&((z=(w=(S=(E=(W=(b=J[j])!==null&&b!==void 0?b:J.readableErrored)!==null&&W!==void 0?W:J.writableErrored)!==null&&E!==void 0?E:(a=J._readableState)===null||a===void 0?void 0:a.errorEmitted)!==null&&S!==void 0?S:(r=J._writableState)===null||r===void 0?void 0:r.errorEmitted)!==null&&w!==void 0?w:(Qq=J._readableState)===null||Qq===void 0?void 0:Qq.errored)!==null&&z!==void 0?z:(Zq=J._writableState)===null||Zq===void 0?void 0:Zq.errored))}M.exports={kDestroyed:I,isDisturbed:m,kIsDisturbed:x,isErrored:u,kIsErrored:j,isReadable:U,kIsReadable:R,isClosed:$,isDestroyed:D,isDuplexNodeStream:c,isFinished:C,isIterable:i,isReadableNodeStream:g,isReadableEnded:A,isReadableFinished:K,isReadableErrored:o,isNodeStream:_,isWritable:T,isWritableNodeStream:f,isWritableEnded:p,isWritableFinished:P,isWritableErrored:qq,isServerRequest:Z,isServerResponse:Y,willEmitClose:N}}}),jq=$q({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(t,M){var{AbortError:B,codes:F}=Mq(),{ERR_INVALID_ARG_TYPE:y,ERR_STREAM_PREMATURE_CLOSE:I}=F,{once:j}=Eq(),{validateAbortSignal:R,validateFunction:x,validateObject:g}=Cq(),{Promise:f}=Wq(),{isClosed:c,isReadable:_,isReadableNodeStream:i,isReadableFinished:D,isReadableErrored:p,isWritable:P,isWritableNodeStream:A,isWritableFinished:K,isWritableErrored:U,isNodeStream:T,willEmitClose:C}=Iq();function qq(Y){return Y.setHeader&&typeof Y.abort==="function"}var o=()=>{};function $(Y,Z,N){var m,u;if(arguments.length===2)N=Z,Z={};else if(Z==null)Z={};else g(Z,"options");x(N,"callback"),R(Z.signal,"options.signal"),N=j(N);const J=(m=Z.readable)!==null&&m!==void 0?m:i(Y),z=(u=Z.writable)!==null&&u!==void 0?u:A(Y);if(!T(Y))throw new y("stream","Stream",Y);const{_writableState:w,_readableState:S}=Y,E=()=>{if(!Y.writable)a()};let W=C(Y)&&i(Y)===J&&A(Y)===z,b=K(Y,!1);const a=()=>{if(b=!0,Y.destroyed)W=!1;if(W&&(!Y.readable||J))return;if(!J||r)N.call(Y)};let r=D(Y,!1);const Qq=()=>{if(r=!0,Y.destroyed)W=!1;if(W&&(!Y.writable||z))return;if(!z||b)N.call(Y)},Zq=(V)=>{N.call(Y,V)};let Vq=c(Y);const Xq=()=>{Vq=!0;const V=U(Y)||p(Y);if(V&&typeof V!=="boolean")return N.call(Y,V);if(J&&!r&&i(Y,!0)){if(!D(Y,!1))return N.call(Y,new I)}if(z&&!b){if(!K(Y,!1))return N.call(Y,new I)}N.call(Y)},Bq=()=>{Y.req.on("finish",a)};if(qq(Y)){if(Y.on("complete",a),!W)Y.on("abort",Xq);if(Y.req)Bq();else Y.on("request",Bq)}else if(z&&!w)Y.on("end",E),Y.on("close",E);if(!W&&typeof Y.aborted==="boolean")Y.on("aborted",Xq);if(Y.on("end",Qq),Y.on("finish",a),Z.error!==!1)Y.on("error",Zq);if(Y.on("close",Xq),Vq)Hq(Xq);else if(w!==null&&w!==void 0&&w.errorEmitted||S!==null&&S!==void 0&&S.errorEmitted){if(!W)Hq(Xq)}else if(!J&&(!W||_(Y))&&(b||P(Y)===!1))Hq(Xq);else if(!z&&(!W||P(Y))&&(r||_(Y)===!1))Hq(Xq);else if(S&&Y.req&&Y.aborted)Hq(Xq);const Jq=()=>{if(N=o,Y.removeListener("aborted",Xq),Y.removeListener("complete",a),Y.removeListener("abort",Xq),Y.removeListener("request",Bq),Y.req)Y.req.removeListener("finish",a);Y.removeListener("end",E),Y.removeListener("close",E),Y.removeListener("finish",a),Y.removeListener("end",Qq),Y.removeListener("error",Zq),Y.removeListener("close",Xq)};if(Z.signal&&!Vq){const V=()=>{const h=N;Jq(),h.call(Y,new B(void 0,{cause:Z.signal.reason}))};if(Z.signal.aborted)Hq(V);else{const h=N;N=j((...X)=>{Z.signal.removeEventListener("abort",V),h.apply(Y,X)}),Z.signal.addEventListener("abort",V)}}return Jq}function s(Y,Z){return new f((N,m)=>{$(Y,Z,(u)=>{if(u)m(u);else N()})})}M.exports=$,M.exports.finished=s}}),HQ=$q({"node_modules/readable-stream/lib/internal/streams/operators.js"(t,M){var{codes:{ERR_INVALID_ARG_TYPE:B,ERR_MISSING_ARGS:F,ERR_OUT_OF_RANGE:y},AbortError:I}=Mq(),{validateAbortSignal:j,validateInteger:R,validateObject:x}=Cq(),g=Wq().Symbol("kWeak"),{finished:f}=jq(),{ArrayPrototypePush:c,MathFloor:_,Number:i,NumberIsNaN:D,Promise:p,PromiseReject:P,PromisePrototypeCatch:A,Symbol:K}=Wq(),U=K("kEmpty"),T=K("kEof");function C(E,W){if(typeof E!=="function")throw new B("fn",["Function","AsyncFunction"],E);if(W!=null)x(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)j(W.signal,"options.signal");let b=1;if((W===null||W===void 0?void 0:W.concurrency)!=null)b=_(W.concurrency);return R(b,"concurrency",1),async function*a(){var r,Qq;const Zq=new AbortController,Vq=this,Xq=[],Bq=Zq.signal,Jq={signal:Bq},V=()=>Zq.abort();if(W!==null&&W!==void 0&&(r=W.signal)!==null&&r!==void 0&&r.aborted)V();W===null||W===void 0||(Qq=W.signal)===null||Qq===void 0||Qq.addEventListener("abort",V);let h,X,H=!1;function L(){H=!0}async function l(){try{for await(let q of Vq){var k;if(H)return;if(Bq.aborted)throw new I;try{q=E(q,Jq)}catch(Q){q=P(Q)}if(q===U)continue;if(typeof((k=q)===null||k===void 0?void 0:k.catch)==="function")q.catch(L);if(Xq.push(q),h)h(),h=null;if(!H&&Xq.length&&Xq.length>=b)await new p((Q)=>{X=Q})}Xq.push(T)}catch(q){const Q=P(q);A(Q,L),Xq.push(Q)}finally{var e;if(H=!0,h)h(),h=null;W===null||W===void 0||(e=W.signal)===null||e===void 0||e.removeEventListener("abort",V)}}l();try{while(!0){while(Xq.length>0){const k=await Xq[0];if(k===T)return;if(Bq.aborted)throw new I;if(k!==U)yield k;if(Xq.shift(),X)X(),X=null}await new p((k)=>{h=k})}}finally{if(Zq.abort(),H=!0,X)X(),X=null}}.call(this)}function qq(E=void 0){if(E!=null)x(E,"options");if((E===null||E===void 0?void 0:E.signal)!=null)j(E.signal,"options.signal");return async function*W(){let b=0;for await(let r of this){var a;if(E!==null&&E!==void 0&&(a=E.signal)!==null&&a!==void 0&&a.aborted)throw new I({cause:E.signal.reason});yield[b++,r]}}.call(this)}async function o(E,W=void 0){for await(let b of Z.call(this,E,W))return!0;return!1}async function $(E,W=void 0){if(typeof E!=="function")throw new B("fn",["Function","AsyncFunction"],E);return!await o.call(this,async(...b)=>{return!await E(...b)},W)}async function s(E,W){for await(let b of Z.call(this,E,W))return b;return}async function Y(E,W){if(typeof E!=="function")throw new B("fn",["Function","AsyncFunction"],E);async function b(a,r){return await E(a,r),U}for await(let a of C.call(this,b,W));}function Z(E,W){if(typeof E!=="function")throw new B("fn",["Function","AsyncFunction"],E);async function b(a,r){if(await E(a,r))return a;return U}return C.call(this,b,W)}var N=class extends F{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function m(E,W,b){var a;if(typeof E!=="function")throw new B("reducer",["Function","AsyncFunction"],E);if(b!=null)x(b,"options");if((b===null||b===void 0?void 0:b.signal)!=null)j(b.signal,"options.signal");let r=arguments.length>1;if(b!==null&&b!==void 0&&(a=b.signal)!==null&&a!==void 0&&a.aborted){const Bq=new I(void 0,{cause:b.signal.reason});throw this.once("error",()=>{}),await f(this.destroy(Bq)),Bq}const Qq=new AbortController,Zq=Qq.signal;if(b!==null&&b!==void 0&&b.signal){const Bq={once:!0,[g]:this};b.signal.addEventListener("abort",()=>Qq.abort(),Bq)}let Vq=!1;try{for await(let Bq of this){var Xq;if(Vq=!0,b!==null&&b!==void 0&&(Xq=b.signal)!==null&&Xq!==void 0&&Xq.aborted)throw new I;if(!r)W=Bq,r=!0;else W=await E(W,Bq,{signal:Zq})}if(!Vq&&!r)throw new N}finally{Qq.abort()}return W}async function u(E){if(E!=null)x(E,"options");if((E===null||E===void 0?void 0:E.signal)!=null)j(E.signal,"options.signal");const W=[];for await(let a of this){var b;if(E!==null&&E!==void 0&&(b=E.signal)!==null&&b!==void 0&&b.aborted)throw new I(void 0,{cause:E.signal.reason});c(W,a)}return W}function J(E,W){const b=C.call(this,E,W);return async function*a(){for await(let r of b)yield*r}.call(this)}function z(E){if(E=i(E),D(E))return 0;if(E<0)throw new y("number",">= 0",E);return E}function w(E,W=void 0){if(W!=null)x(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)j(W.signal,"options.signal");return E=z(E),async function*b(){var a;if(W!==null&&W!==void 0&&(a=W.signal)!==null&&a!==void 0&&a.aborted)throw new I;for await(let Qq of this){var r;if(W!==null&&W!==void 0&&(r=W.signal)!==null&&r!==void 0&&r.aborted)throw new I;if(E--<=0)yield Qq}}.call(this)}function S(E,W=void 0){if(W!=null)x(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)j(W.signal,"options.signal");return E=z(E),async function*b(){var a;if(W!==null&&W!==void 0&&(a=W.signal)!==null&&a!==void 0&&a.aborted)throw new I;for await(let Qq of this){var r;if(W!==null&&W!==void 0&&(r=W.signal)!==null&&r!==void 0&&r.aborted)throw new I;if(E-- >0)yield Qq;else return}}.call(this)}M.exports.streamReturningOperators={asIndexedPairs:qq,drop:w,filter:Z,flatMap:J,map:C,take:S},M.exports.promiseReturningOperators={every:$,forEach:Y,reduce:m,toArray:u,some:o,find:s}}}),Pq=$q({"node_modules/readable-stream/lib/internal/streams/destroy.js"(t,M){var{aggregateTwoErrors:B,codes:{ERR_MULTIPLE_CALLBACK:F},AbortError:y}=Mq(),{Symbol:I}=Wq(),{kDestroyed:j,isDestroyed:R,isFinished:x,isServerRequest:g}=Iq(),f="#kDestroy",c="#kConstruct";function _(Z,N,m){if(Z){if(Z.stack,N&&!N.errored)N.errored=Z;if(m&&!m.errored)m.errored=Z}}function i(Z,N){const m=this._readableState,u=this._writableState,J=u||m;if(u&&u.destroyed||m&&m.destroyed){if(typeof N==="function")N();return this}if(_(Z,u,m),u)u.destroyed=!0;if(m)m.destroyed=!0;if(!J.constructed)this.once(f,(z)=>{D(this,B(z,Z),N)});else D(this,Z,N);return this}function D(Z,N,m){let u=!1;function J(z){if(u)return;u=!0;const{_readableState:w,_writableState:S}=Z;if(_(z,S,w),S)S.closed=!0;if(w)w.closed=!0;if(typeof m==="function")m(z);if(z)Hq(p,Z,z);else Hq(P,Z)}try{Z._destroy(N||null,J)}catch(z){J(z)}}function p(Z,N){A(Z,N),P(Z)}function P(Z){const{_readableState:N,_writableState:m}=Z;if(m)m.closeEmitted=!0;if(N)N.closeEmitted=!0;if(m&&m.emitClose||N&&N.emitClose)Z.emit("close")}function A(Z,N){const m=Z?._readableState,u=Z?._writableState;if(u?.errorEmitted||m?.errorEmitted)return;if(u)u.errorEmitted=!0;if(m)m.errorEmitted=!0;Z?.emit?.("error",N)}function K(){const Z=this._readableState,N=this._writableState;if(Z)Z.constructed=!0,Z.closed=!1,Z.closeEmitted=!1,Z.destroyed=!1,Z.errored=null,Z.errorEmitted=!1,Z.reading=!1,Z.ended=Z.readable===!1,Z.endEmitted=Z.readable===!1;if(N)N.constructed=!0,N.destroyed=!1,N.closed=!1,N.closeEmitted=!1,N.errored=null,N.errorEmitted=!1,N.finalCalled=!1,N.prefinished=!1,N.ended=N.writable===!1,N.ending=N.writable===!1,N.finished=N.writable===!1}function U(Z,N,m){const u=Z?._readableState,J=Z?._writableState;if(J&&J.destroyed||u&&u.destroyed)return this;if(u&&u.autoDestroy||J&&J.autoDestroy)Z.destroy(N);else if(N){if(Error.captureStackTrace(N),J&&!J.errored)J.errored=N;if(u&&!u.errored)u.errored=N;if(m)Hq(A,Z,N);else A(Z,N)}}function T(Z,N){if(typeof Z._construct!=="function")return;const{_readableState:m,_writableState:u}=Z;if(m)m.constructed=!1;if(u)u.constructed=!1;if(Z.once(c,N),Z.listenerCount(c)>1)return;Hq(C,Z)}function C(Z){let N=!1;function m(u){if(N){U(Z,u!==null&&u!==void 0?u:new F);return}N=!0;const{_readableState:J,_writableState:z}=Z,w=z||J;if(J)J.constructed=!0;if(z)z.constructed=!0;if(w.destroyed)Z.emit(f,u);else if(u)U(Z,u,!0);else Hq(qq,Z)}try{Z._construct(m)}catch(u){m(u)}}function qq(Z){Z.emit(c)}function o(Z){return Z&&Z.setHeader&&typeof Z.abort==="function"}function $(Z){Z.emit("close")}function s(Z,N){Z.emit("error",N),Hq($,Z)}function Y(Z,N){if(!Z||R(Z))return;if(!N&&!x(Z))N=new y;if(g(Z))Z.socket=null,Z.destroy(N);else if(o(Z))Z.abort();else if(o(Z.req))Z.req.abort();else if(typeof Z.destroy==="function")Z.destroy(N);else if(typeof Z.close==="function")Z.close();else if(N)Hq(s,Z);else Hq($,Z);if(!Z.destroyed)Z[j]=!0}M.exports={construct:T,destroyer:Y,destroy:i,undestroy:K,errorOrDestroy:U}}}),Sq=$q({"node_modules/readable-stream/lib/internal/streams/legacy.js"(t,M){var{ArrayIsArray:B,ObjectSetPrototypeOf:F}=Wq();function y(j){if(!(this instanceof y))return new y(j);Tq.call(this,j)}F(y.prototype,Tq.prototype),F(y,Tq),y.prototype.pipe=function(j,R){const x=this;function g(P){if(j.writable&&j.write(P)===!1&&x.pause)x.pause()}x.on("data",g);function f(){if(x.readable&&x.resume)x.resume()}if(j.on("drain",f),!j._isStdio&&(!R||R.end!==!1))x.on("end",_),x.on("close",i);let c=!1;function _(){if(c)return;c=!0,j.end()}function i(){if(c)return;if(c=!0,typeof j.destroy==="function")j.destroy()}function D(P){if(p(),Tq.listenerCount(this,"error")===0)this.emit("error",P)}I(x,"error",D),I(j,"error",D);function p(){x.removeListener("data",g),j.removeListener("drain",f),x.removeListener("end",_),x.removeListener("close",i),x.removeListener("error",D),j.removeListener("error",D),x.removeListener("end",p),x.removeListener("close",p),j.removeListener("close",p)}return x.on("end",p),x.on("close",p),j.on("close",p),j.emit("pipe",x),j};function I(j,R,x){if(typeof j.prependListener==="function")return j.prependListener(R,x);if(!j._events||!j._events[R])j.on(R,x);else if(B(j._events[R]))j._events[R].unshift(x);else j._events[R]=[x,j._events[R]]}M.exports={Stream:y,prependListener:I}}}),gq=$q({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(t,M){var{AbortError:B,codes:F}=Mq(),y=jq(),{ERR_INVALID_ARG_TYPE:I}=F,j=(x,g)=>{if(typeof x!=="object"||!("aborted"in x))throw new I(g,"AbortSignal",x)};function R(x){return!!(x&&typeof x.pipe==="function")}M.exports.addAbortSignal=function x(g,f){if(j(g,"signal"),!R(f))throw new I("stream","stream.Stream",f);return M.exports.addAbortSignalNoValidate(g,f)},M.exports.addAbortSignalNoValidate=function(x,g){if(typeof x!=="object"||!("aborted"in x))return g;const f=()=>{g.destroy(new B(void 0,{cause:x.reason}))};if(x.aborted)f();else x.addEventListener("abort",f),y(g,()=>x.removeEventListener("abort",f));return g}}}),KQ=$q({"node_modules/readable-stream/lib/internal/streams/state.js"(t,M){var{MathFloor:B,NumberIsInteger:F}=Wq(),{ERR_INVALID_ARG_VALUE:y}=Mq().codes;function I(x,g,f){return x.highWaterMark!=null?x.highWaterMark:g?x[f]:null}function j(x){return x?16:16384}function R(x,g,f,c){const _=I(g,c,f);if(_!=null){if(!F(_)||_<0){const i=c?`options.${f}`:"options.highWaterMark";throw new y(i,_)}return B(_)}return j(x.objectMode)}M.exports={getHighWaterMark:R,getDefaultHighWaterMark:j}}}),pq=$q({"node_modules/readable-stream/lib/internal/streams/from.js"(t,M){var{PromisePrototypeThen:B,SymbolAsyncIterator:F,SymbolIterator:y}=Wq(),{ERR_INVALID_ARG_TYPE:I,ERR_STREAM_NULL_VALUES:j}=Mq().codes;function R(x,g,f){let c;if(typeof g==="string"||g instanceof Buffer)return new x({objectMode:!0,...f,read(){this.push(g),this.push(null)}});let _;if(g&&g[F])_=!0,c=g[F]();else if(g&&g[y])_=!1,c=g[y]();else throw new I("iterable",["Iterable"],g);const i=new x({objectMode:!0,highWaterMark:1,...f});let D=!1;i._read=function(){if(!D)D=!0,P()},i._destroy=function(A,K){B(p(A),()=>Hq(K,A),(U)=>Hq(K,U||A))};async function p(A){const K=A!==void 0&&A!==null,U=typeof c.throw==="function";if(K&&U){const{value:T,done:C}=await c.throw(A);if(await T,C)return}if(typeof c.return==="function"){const{value:T}=await c.return();await T}}async function P(){for(;;){try{const{value:A,done:K}=_?await c.next():c.next();if(K)i.push(null);else{const U=A&&typeof A.then==="function"?await A:A;if(U===null)throw D=!1,new j;else if(i.push(U))continue;else D=!1}}catch(A){i.destroy(A)}break}}return i}M.exports=R}}),uq,bq,Dq=$q({"node_modules/readable-stream/lib/internal/streams/readable.js"(t,M){var{ArrayPrototypeIndexOf:B,NumberIsInteger:F,NumberIsNaN:y,NumberParseInt:I,ObjectDefineProperties:j,ObjectKeys:R,ObjectSetPrototypeOf:x,Promise:g,SafeSet:f,SymbolAsyncIterator:c,Symbol:_}=Wq(),i=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{Stream:D,prependListener:p}=Sq();function P(q){if(!(this instanceof P))return new P(q);const Q=this instanceof Lq();if(this._readableState=new i(q,this,Q),q){const{read:O,destroy:G,construct:v,signal:Kq}=q;if(typeof O==="function")this._read=O;if(typeof G==="function")this._destroy=G;if(typeof v==="function")this._construct=v;if(Kq&&!Q)U(Kq,this)}D.call(this,q),Z.construct(this,()=>{if(this._readableState.needReadable)s(this,this._readableState)})}x(P.prototype,D.prototype),x(P,D),P.prototype.on=function(q,Q){const O=D.prototype.on.call(this,q,Q),G=this._readableState;if(q==="data")if(G.readableListening=this.listenerCount("readable")>0,G.flowing!==!1)n&&d("in flowing mode!",this.__id),this.resume();else n&&d("in readable mode!",this.__id);else if(q==="readable"){if(n&&d("readable listener added!",this.__id),!G.endEmitted&&!G.readableListening){if(G.readableListening=G.needReadable=!0,G.flowing=!1,G.emittedReadable=!1,n&&d("on readable - state.length, reading, emittedReadable",G.length,G.reading,G.emittedReadable,this.__id),G.length)Y(this,G);else if(!G.reading)Hq(Jq,this)}else if(G.endEmitted)n&&d("end already emitted...",this.__id)}return O};class A extends P{#q;#Q;#X;#H;constructor(q,Q){const{objectMode:O,highWaterMark:G,encoding:v,signal:Kq}=q;super({objectMode:O,highWaterMark:G,encoding:v,signal:Kq});this.#X=[],this.#q=void 0,this.#H=Q,this.#Q=!1}#J(){var q=this.#X,Q=0,O=q.length;for(;Q0)this.#X=[];return!1}#K(q){q.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){n&&d("ReadableFromWeb _read()",this.__id);var q=this.#H,Q=this.#q;if(q)Q=this.#q=q.getReader(),this.#H=void 0;else if(this.#J())return;var O;try{do{var G=!1,v;const Kq=Q.readMany();if(Oq(Kq)){if({done:G,value:v}=await Kq,this.#Q){this.#X.push(...v);return}}else({done:G,value:v}=Kq);if(G){this.#K(Q);return}if(!this.push(v[0])){this.#X=v.slice(1);return}for(let Yq=1,_q=v.length;Yq<_q;Yq++)if(!this.push(v[Yq])){this.#X=v.slice(Yq+1);return}}while(!this.#Q)}catch(Kq){O=Kq}finally{if(O)throw O}}_destroy(q,Q){if(!this.#Q){var O=this.#q;if(O)this.#q=void 0,O.cancel(q).finally(()=>{this.#Q=!0,Q(q)});return}try{Q(q)}catch(G){globalThis.reportError(G)}}}bq=A;function K(q,Q={}){if(!qQ(q))throw new m("readableStream","ReadableStream",q);S(Q,"options");const{highWaterMark:O,encoding:G,objectMode:v=!1,signal:Kq}=Q;if(G!==void 0&&!Buffer.isEncoding(G))throw new JQ(G,"options.encoding");return QQ(v,"options.objectMode"),UQ(P,q,Q)||new A({highWaterMark:O,encoding:G,objectMode:v,signal:Kq},q)}M.exports=P,uq=K;var{addAbortSignal:U}=gq(),T=jq();const{maybeReadMore:C,resume:qq,emitReadable:o,onEofChunk:$}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function s(q,Q){process.nextTick(C,q,Q)}function Y(q,Q){n&&d("NativeReadable - emitReadable",q.__id),o(q,Q)}var Z=Pq(),{aggregateTwoErrors:N,codes:{ERR_INVALID_ARG_TYPE:m,ERR_METHOD_NOT_IMPLEMENTED:u,ERR_OUT_OF_RANGE:J,ERR_STREAM_PUSH_AFTER_EOF:z,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:w}}=Mq(),{validateObject:S}=Cq(),E=pq(),W=()=>{},{errorOrDestroy:b}=Z;P.prototype.destroy=Z.destroy,P.prototype._undestroy=Z.undestroy,P.prototype._destroy=function(q,Q){Q(q)},P.prototype[Tq.captureRejectionSymbol]=function(q){this.destroy(q)},P.prototype.push=function(q,Q){return a(this,q,Q,!1)},P.prototype.unshift=function(q,Q){return a(this,q,Q,!0)};function a(q,Q,O,G){n&&d("readableAddChunk",Q,q.__id);const v=q._readableState;let Kq;if(!v.objectMode){if(typeof Q==="string"){if(O=O||v.defaultEncoding,v.encoding!==O)if(G&&v.encoding)Q=Buffer.from(Q,O).toString(v.encoding);else Q=Buffer.from(Q,O),O=""}else if(Q instanceof Buffer)O="";else if(D._isUint8Array(Q)){if(G||!v.decoder)Q=D._uint8ArrayToBuffer(Q);O=""}else if(Q!=null)Kq=new m("chunk",["string","Buffer","Uint8Array"],Q)}if(Kq)b(q,Kq);else if(Q===null)v.reading=!1,$(q,v);else if(v.objectMode||Q&&Q.length>0)if(G)if(v.endEmitted)b(q,new w);else if(v.destroyed||v.errored)return!1;else r(q,v,Q,!0);else if(v.ended)b(q,new z);else if(v.destroyed||v.errored)return!1;else if(v.reading=!1,v.decoder&&!O)if(Q=v.decoder.write(Q),v.objectMode||Q.length!==0)r(q,v,Q,!1);else s(q,v);else r(q,v,Q,!1);else if(!G)v.reading=!1,s(q,v);return!v.ended&&(v.length0){if(Q.multiAwaitDrain)Q.awaitDrainWriters.clear();else Q.awaitDrainWriters=null;Q.dataEmitted=!0,q.emit("data",O)}else{if(Q.length+=Q.objectMode?1:O.length,G)Q.buffer.unshift(O);else Q.buffer.push(O);if(n&&d("needReadable @ addChunk",Q.needReadable,q.__id),Q.needReadable)Y(q,Q)}s(q,Q)}P.prototype.isPaused=function(){const q=this._readableState;return q.paused===!0||q.flowing===!1},P.prototype.setEncoding=function(q){const Q=new rq(q);this._readableState.decoder=Q,this._readableState.encoding=this._readableState.decoder.encoding;const O=this._readableState.buffer;let G="";for(let v=O.length;v>0;v--)G+=Q.write(O.shift());if(G!=="")O.push(G);return this._readableState.length=G.length,this};var Qq=1073741824;function Zq(q){if(q>Qq)throw new J("size","<= 1GiB",q);else q--,q|=q>>>1,q|=q>>>2,q|=q>>>4,q|=q>>>8,q|=q>>>16,q++;return q}function Vq(q,Q){if(q<=0||Q.length===0&&Q.ended)return 0;if(Q.objectMode)return 1;if(y(q)){if(Q.flowing&&Q.length)return Q.buffer.first().length;return Q.length}if(q<=Q.length)return q;return Q.ended?Q.length:0}P.prototype.read=function(q){if(n&&d("read - n =",q,this.__id),!F(q))q=I(q,10);const Q=this._readableState,O=q;if(q>Q.highWaterMark)Q.highWaterMark=Zq(q);if(q!==0)Q.emittedReadable=!1;if(q===0&&Q.needReadable&&((Q.highWaterMark!==0?Q.length>=Q.highWaterMark:Q.length>0)||Q.ended)){if(n&&d("read: emitReadable or endReadable",Q.length,Q.ended,this.__id),Q.length===0&&Q.ended)H(this);else Y(this,Q);return null}if(q=Vq(q,Q),q===0&&Q.ended){if(n&&d("read: calling endReadable if length 0 -- length, state.ended",Q.length,Q.ended,this.__id),Q.length===0)H(this);return null}let G=Q.needReadable;if(n&&d("need readable",G,this.__id),Q.length===0||Q.length-q0)Kq=X(q,Q);else Kq=null;if(n&&d("ret @ read",Kq,this.__id),Kq===null)Q.needReadable=Q.length<=Q.highWaterMark,n&&d("state.length while ret = null",Q.length,this.__id),q=0;else if(Q.length-=q,Q.multiAwaitDrain)Q.awaitDrainWriters.clear();else Q.awaitDrainWriters=null;if(Q.length===0){if(!Q.ended)Q.needReadable=!0;if(O!==q&&Q.ended)H(this)}if(Kq!==null&&!Q.errorEmitted&&!Q.closeEmitted)Q.dataEmitted=!0,this.emit("data",Kq);return Kq},P.prototype._read=function(q){throw new u("_read()")},P.prototype.pipe=function(q,Q){const O=this,G=this._readableState;if(G.pipes.length===1){if(!G.multiAwaitDrain)G.multiAwaitDrain=!0,G.awaitDrainWriters=new f(G.awaitDrainWriters?[G.awaitDrainWriters]:[])}G.pipes.push(q),n&&d("pipe count=%d opts=%j",G.pipes.length,Q,O.__id);const Kq=(!Q||Q.end!==!1)&&q!==process.stdout&&q!==process.stderr?_q:xq;if(G.endEmitted)Hq(Kq);else O.once("end",Kq);q.on("unpipe",Yq);function Yq(Aq,Fq){if(n&&d("onunpipe",O.__id),Aq===O){if(Fq&&Fq.hasUnpiped===!1)Fq.hasUnpiped=!0,oq()}}function _q(){n&&d("onend",O.__id),q.end()}let Nq,kq=!1;function oq(){if(n&&d("cleanup",O.__id),q.removeListener("close",vq),q.removeListener("finish",Rq),Nq)q.removeListener("drain",Nq);if(q.removeListener("error",wq),q.removeListener("unpipe",Yq),O.removeListener("end",_q),O.removeListener("end",xq),O.removeListener("data",hq),kq=!0,Nq&&G.awaitDrainWriters&&(!q._writableState||q._writableState.needDrain))Nq()}function yq(){if(!kq){if(G.pipes.length===1&&G.pipes[0]===q)n&&d("false write response, pause",0,O.__id),G.awaitDrainWriters=q,G.multiAwaitDrain=!1;else if(G.pipes.length>1&&G.pipes.includes(q))n&&d("false write response, pause",G.awaitDrainWriters.size,O.__id),G.awaitDrainWriters.add(q);O.pause()}if(!Nq)Nq=Xq(O,q),q.on("drain",Nq)}O.on("data",hq);function hq(Aq){n&&d("ondata",O.__id);const Fq=q.write(Aq);if(n&&d("dest.write",Fq,O.__id),Fq===!1)yq()}function wq(Aq){if(d("onerror",Aq),xq(),q.removeListener("error",wq),q.listenerCount("error")===0){const Fq=q._writableState||q._readableState;if(Fq&&!Fq.errorEmitted)b(q,Aq);else q.emit("error",Aq)}}p(q,"error",wq);function vq(){q.removeListener("finish",Rq),xq()}q.once("close",vq);function Rq(){d("onfinish"),q.removeListener("close",vq),xq()}q.once("finish",Rq);function xq(){d("unpipe"),O.unpipe(q)}if(q.emit("pipe",O),q.writableNeedDrain===!0){if(G.flowing)yq()}else if(!G.flowing)d("pipe resume"),O.resume();return q};function Xq(q,Q){return function O(){const G=q._readableState;if(G.awaitDrainWriters===Q)d("pipeOnDrain",1),G.awaitDrainWriters=null;else if(G.multiAwaitDrain)d("pipeOnDrain",G.awaitDrainWriters.size),G.awaitDrainWriters.delete(Q);if((!G.awaitDrainWriters||G.awaitDrainWriters.size===0)&&q.listenerCount("data"))q.resume()}}P.prototype.unpipe=function(q){const Q=this._readableState,O={hasUnpiped:!1};if(Q.pipes.length===0)return this;if(!q){const v=Q.pipes;Q.pipes=[],this.pause();for(let Kq=0;Kq0,Q.resumeScheduled&&Q.paused===!1)Q.flowing=!0;else if(q.listenerCount("data")>0)q.resume();else if(!Q.readableListening)Q.flowing=null}function Jq(q){n&&d("on readable nextTick, calling read(0)",q.__id),q.read(0)}P.prototype.resume=function(){const q=this._readableState;if(!q.flowing)n&&d("resume",this.__id),q.flowing=!q.readableListening,qq(this,q);return q.paused=!1,this},P.prototype.pause=function(){if(n&&d("call pause flowing=%j",this._readableState.flowing,this.__id),this._readableState.flowing!==!1)n&&d("pause",this.__id),this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},P.prototype.wrap=function(q){let Q=!1;q.on("data",(G)=>{if(!this.push(G)&&q.pause)Q=!0,q.pause()}),q.on("end",()=>{this.push(null)}),q.on("error",(G)=>{b(this,G)}),q.on("close",()=>{this.destroy()}),q.on("destroy",()=>{this.destroy()}),this._read=()=>{if(Q&&q.resume)Q=!1,q.resume()};const O=R(q);for(let G=1;G{v=Yq?N(v,Yq):null,O(),O=W});try{while(!0){const Yq=q.destroyed?null:q.read();if(Yq!==null)yield Yq;else if(v)throw v;else if(v===null)return;else await new g(G)}}catch(Yq){throw v=N(v,Yq),v}finally{if((v||(Q===null||Q===void 0?void 0:Q.destroyOnReturn)!==!1)&&(v===void 0||q._readableState.autoDestroy))Z.destroyer(q,null);else q.off("readable",G),Kq()}}j(P.prototype,{readable:{get(){const q=this._readableState;return!!q&&q.readable!==!1&&!q.destroyed&&!q.errorEmitted&&!q.endEmitted},set(q){if(this._readableState)this._readableState.readable=!!q}},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(q){if(this._readableState)this._readableState.flowing=q}},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(q){if(!this._readableState)return;this._readableState.destroyed=q}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),P._fromList=X;function X(q,Q){if(Q.length===0)return null;let O;if(Q.objectMode)O=Q.buffer.shift();else if(!q||q>=Q.length){if(Q.decoder)O=Q.buffer.join("");else if(Q.buffer.length===1)O=Q.buffer.first();else O=Q.buffer.concat(Q.length);Q.buffer.clear()}else O=Q.buffer.consume(q,Q.decoder);return O}function H(q){const Q=q._readableState;if(n&&d("endEmitted @ endReadable",Q.endEmitted,q.__id),!Q.endEmitted)Q.ended=!0,Hq(L,Q,q)}function L(q,Q){if(n&&d("endReadableNT -- endEmitted, state.length",q.endEmitted,q.length,Q.__id),!q.errored&&!q.closeEmitted&&!q.endEmitted&&q.length===0){if(q.endEmitted=!0,Q.emit("end"),n&&d("end emitted @ endReadableNT",Q.__id),Q.writable&&Q.allowHalfOpen===!1)Hq(l,Q);else if(q.autoDestroy){const O=Q._writableState;if(!O||O.autoDestroy&&(O.finished||O.writable===!1))Q.destroy()}}}function l(q){if(q.writable&&!q.writableEnded&&!q.destroyed)q.end()}P.from=function(q,Q){return E(P,q,Q)};var k={newStreamReadableFromReadableStream:K};function e(){if(k===void 0)k={};return k}P.fromWeb=function(q,Q){return e().newStreamReadableFromReadableStream(q,Q)},P.toWeb=function(q){return e().newReadableStreamFromStreamReadable(q)},P.wrap=function(q,Q){var O,G;return new P({objectMode:(O=(G=q.readableObjectMode)!==null&&G!==void 0?G:q.objectMode)!==null&&O!==void 0?O:!0,...Q,destroy(v,Kq){Z.destroyer(q,v),Kq(v)}}).wrap(q)}}}),mq=$q({"node_modules/readable-stream/lib/internal/streams/writable.js"(t,M){var{ArrayPrototypeSlice:B,Error:F,FunctionPrototypeSymbolHasInstance:y,ObjectDefineProperty:I,ObjectDefineProperties:j,ObjectSetPrototypeOf:R,StringPrototypeToLowerCase:x,Symbol:g,SymbolHasInstance:f}=Wq(),c=Sq().Stream,_=Pq(),{addAbortSignal:i}=gq(),{getHighWaterMark:D,getDefaultHighWaterMark:p}=KQ(),{ERR_INVALID_ARG_TYPE:P,ERR_METHOD_NOT_IMPLEMENTED:A,ERR_MULTIPLE_CALLBACK:K,ERR_STREAM_CANNOT_PIPE:U,ERR_STREAM_DESTROYED:T,ERR_STREAM_ALREADY_FINISHED:C,ERR_STREAM_NULL_VALUES:qq,ERR_STREAM_WRITE_AFTER_END:o,ERR_UNKNOWN_ENCODING:$}=Mq().codes,{errorOrDestroy:s}=_;function Y(X={}){const H=this instanceof Lq();if(!H&&!y(Y,this))return new Y(X);if(this._writableState=new m(X,this,H),X){if(typeof X.write==="function")this._write=X.write;if(typeof X.writev==="function")this._writev=X.writev;if(typeof X.destroy==="function")this._destroy=X.destroy;if(typeof X.final==="function")this._final=X.final;if(typeof X.construct==="function")this._construct=X.construct;if(X.signal)i(X.signal,this)}c.call(this,X),_.construct(this,()=>{const L=this._writableState;if(!L.writing)r(this,L);Xq(this,L)})}R(Y.prototype,c.prototype),R(Y,c),M.exports=Y;function Z(){}var N=g("kOnFinished");function m(X,H,L){if(typeof L!=="boolean")L=H instanceof Lq();if(this.objectMode=!!(X&&X.objectMode),L)this.objectMode=this.objectMode||!!(X&&X.writableObjectMode);this.highWaterMark=X?D(this,X,"writableHighWaterMark",L):p(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const l=!!(X&&X.decodeStrings===!1);this.decodeStrings=!l,this.defaultEncoding=X&&X.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=E.bind(void 0,H),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,u(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!X||X.emitClose!==!1,this.autoDestroy=!X||X.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[N]=[]}function u(X){X.buffered=[],X.bufferedIndex=0,X.allBuffers=!0,X.allNoop=!0}m.prototype.getBuffer=function X(){return B(this.buffered,this.bufferedIndex)},I(m.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),I(Y,f,{value:function(X){if(y(this,X))return!0;if(this!==Y)return!1;return X&&X._writableState instanceof m}}),Y.prototype.pipe=function(){s(this,new U)};function J(X,H,L,l){const k=X._writableState;if(typeof L==="function")l=L,L=k.defaultEncoding;else{if(!L)L=k.defaultEncoding;else if(L!=="buffer"&&!Buffer.isEncoding(L))throw new $(L);if(typeof l!=="function")l=Z}if(H===null)throw new qq;else if(!k.objectMode)if(typeof H==="string"){if(k.decodeStrings!==!1)H=Buffer.from(H,L),L="buffer"}else if(H instanceof Buffer)L="buffer";else if(c._isUint8Array(H))H=c._uint8ArrayToBuffer(H),L="buffer";else throw new P("chunk",["string","Buffer","Uint8Array"],H);let e;if(k.ending)e=new o;else if(k.destroyed)e=new T("write");if(e)return Hq(l,e),s(X,e,!0),e;return k.pendingcb++,z(X,k,H,L,l)}Y.prototype.write=function(X,H,L){return J(this,X,H,L)===!0},Y.prototype.cork=function(){this._writableState.corked++},Y.prototype.uncork=function(){const X=this._writableState;if(X.corked){if(X.corked--,!X.writing)r(this,X)}},Y.prototype.setDefaultEncoding=function X(H){if(typeof H==="string")H=x(H);if(!Buffer.isEncoding(H))throw new $(H);return this._writableState.defaultEncoding=H,this};function z(X,H,L,l,k){const e=H.objectMode?1:L.length;H.length+=e;const q=H.lengthL.bufferedIndex)r(X,L);if(l)if(L.afterWriteTickInfo!==null&&L.afterWriteTickInfo.cb===k)L.afterWriteTickInfo.count++;else L.afterWriteTickInfo={count:1,cb:k,stream:X,state:L},Hq(W,L.afterWriteTickInfo);else b(X,L,1,k)}}function W({stream:X,state:H,count:L,cb:l}){return H.afterWriteTickInfo=null,b(X,H,L,l)}function b(X,H,L,l){if(!H.ending&&!X.destroyed&&H.length===0&&H.needDrain)H.needDrain=!1,X.emit("drain");while(L-- >0)H.pendingcb--,l();if(H.destroyed)a(H);Xq(X,H)}function a(X){if(X.writing)return;for(let k=X.bufferedIndex;k1&&X._writev){H.pendingcb-=e-1;const Q=H.allNoop?Z:(G)=>{for(let v=q;v256)L.splice(0,q),H.bufferedIndex=0;else H.bufferedIndex=q}H.bufferProcessing=!1}Y.prototype._write=function(X,H,L){if(this._writev)this._writev([{chunk:X,encoding:H}],L);else throw new A("_write()")},Y.prototype._writev=null,Y.prototype.end=function(X,H,L,l=!1){const k=this._writableState;if(n&&d("end",k,this.__id),typeof X==="function")L=X,X=null,H=null;else if(typeof H==="function")L=H,H=null;let e;if(X!==null&&X!==void 0){let q;if(!l)q=J(this,X,H);else q=this.write(X,H);if(q instanceof F)e=q}if(k.corked)k.corked=1,this.uncork();if(e)this.emit("error",e);else if(!k.errored&&!k.ending)k.ending=!0,Xq(this,k,!0),k.ended=!0;else if(k.finished)e=new C("end");else if(k.destroyed)e=new T("end");if(typeof L==="function")if(e||k.finished)Hq(L,e);else k[N].push(L);return this};function Qq(X,H){var L=X.ending&&!X.destroyed&&X.constructed&&X.length===0&&!X.errored&&X.buffered.length===0&&!X.finished&&!X.writing&&!X.errorEmitted&&!X.closeEmitted;return d("needFinish",L,H),L}function Zq(X,H){let L=!1;function l(k){if(L){s(X,k!==null&&k!==void 0?k:K());return}if(L=!0,H.pendingcb--,k){const e=H[N].splice(0);for(let q=0;q{if(Qq(k))Bq(l,k);else k.pendingcb--},X,H);else if(Qq(H))H.pendingcb++,Bq(X,H)}}function Bq(X,H){H.pendingcb--,H.finished=!0;const L=H[N].splice(0);for(let l=0;l{if(S!=null)throw new _("nully","body",S)},(S)=>{i(z,S)});return z=new T({objectMode:!0,readable:!1,write:N,final(S){m(async()=>{try{await w,Hq(S,null)}catch(E){Hq(S,E)}})},destroy:u})}throw new _("Iterable, AsyncIterable or AsyncFunction",s,Z)}if(K($))return o($.arrayBuffer());if(y($))return A(T,$,{objectMode:!0,writable:!1});if(typeof($===null||$===void 0?void 0:$.writable)==="object"||typeof($===null||$===void 0?void 0:$.readable)==="object"){const Z=$!==null&&$!==void 0&&$.readable?j($===null||$===void 0?void 0:$.readable)?$===null||$===void 0?void 0:$.readable:o($.readable):void 0,N=$!==null&&$!==void 0&&$.writable?R($===null||$===void 0?void 0:$.writable)?$===null||$===void 0?void 0:$.writable:o($.writable):void 0;return qq({readable:Z,writable:N})}const Y=$===null||$===void 0?void 0:$.then;if(typeof Y==="function"){let Z;return U(Y,$,(N)=>{if(N!=null)Z.push(N);Z.push(null)},(N)=>{i(Z,N)}),Z=new T({objectMode:!0,writable:!1,read(){}})}throw new c(s,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],$)};function C(o){let{promise:$,resolve:s}=P();const Y=new AbortController,Z=Y.signal;return{value:o(async function*(){while(!0){const m=$;$=null;const{chunk:u,done:J,cb:z}=await m;if(Hq(z),J)return;if(Z.aborted)throw new f(void 0,{cause:Z.reason});({promise:$,resolve:s}=P()),yield u}}(),{signal:Z}),write(m,u,J){const z=s;s=null,z({chunk:m,done:!1,cb:J})},final(m){const u=s;s=null,u({done:!0,cb:m})},destroy(m,u){Y.abort(),u(m)}}}function qq(o){const $=o.readable&&typeof o.readable.read!=="function"?p.wrap(o.readable):o.readable,s=o.writable;let Y=!!B($),Z=!!F(s),N,m,u,J,z;function w(S){const E=J;if(J=null,E)E(S);else if(S)z.destroy(S);else if(!Y&&!Z)z.destroy()}if(z=new T({readableObjectMode:!!($!==null&&$!==void 0&&$.readableObjectMode),writableObjectMode:!!(s!==null&&s!==void 0&&s.writableObjectMode),readable:Y,writable:Z}),Z)g(s,(S)=>{if(Z=!1,S)i($,S);w(S)}),z._write=function(S,E,W){if(s.write(S,E))W();else N=W},z._final=function(S){s.end(),m=S},s.on("drain",function(){if(N){const S=N;N=null,S()}}),s.on("finish",function(){if(m){const S=m;m=null,S()}});if(Y)g($,(S)=>{if(Y=!1,S)i($,S);w(S)}),$.on("readable",function(){if(u){const S=u;u=null,S()}}),$.on("end",function(){z.push(null)}),z._read=function(){while(!0){const S=$.read();if(S===null){u=z._read;return}if(!z.push(S))return}};return z._destroy=function(S,E){if(!S&&J!==null)S=new f;if(u=null,N=null,m=null,J===null)E(S);else J=E,i(s,S),i($,S)},z}}}),Lq=$q({"node_modules/readable-stream/lib/internal/streams/duplex.js"(t,M){var{ObjectDefineProperties:B,ObjectGetOwnPropertyDescriptor:F,ObjectKeys:y,ObjectSetPrototypeOf:I}=Wq(),j=Dq();function R(_){if(!(this instanceof R))return new R(_);if(j.call(this,_),Gq.call(this,_),_){if(this.allowHalfOpen=_.allowHalfOpen!==!1,_.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(_.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}M.exports=R,I(R.prototype,j.prototype),I(R,j);for(var x in Gq.prototype)if(!R.prototype[x])R.prototype[x]=Gq.prototype[x];B(R.prototype,{writable:F(Gq.prototype,"writable"),writableHighWaterMark:F(Gq.prototype,"writableHighWaterMark"),writableObjectMode:F(Gq.prototype,"writableObjectMode"),writableBuffer:F(Gq.prototype,"writableBuffer"),writableLength:F(Gq.prototype,"writableLength"),writableFinished:F(Gq.prototype,"writableFinished"),writableCorked:F(Gq.prototype,"writableCorked"),writableEnded:F(Gq.prototype,"writableEnded"),writableNeedDrain:F(Gq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(_){if(this._readableState&&this._writableState)this._readableState.destroyed=_,this._writableState.destroyed=_}}});var g;function f(){if(g===void 0)g={};return g}R.fromWeb=function(_,i){return f().newStreamDuplexFromReadableWritablePair(_,i)},R.toWeb=function(_){return f().newReadableWritablePairFromDuplex(_)};var c;R.from=function(_){if(!c)c=ZQ();return c(_,"body")}}}),cq=$q({"node_modules/readable-stream/lib/internal/streams/transform.js"(t,M){var{ObjectSetPrototypeOf:B,Symbol:F}=Wq(),{ERR_METHOD_NOT_IMPLEMENTED:y}=Mq().codes,I=Lq();function j(f){if(!(this instanceof j))return new j(f);if(I.call(this,f),this._readableState.sync=!1,this[R]=null,f){if(typeof f.transform==="function")this._transform=f.transform;if(typeof f.flush==="function")this._flush=f.flush}this.on("prefinish",g.bind(this))}B(j.prototype,I.prototype),B(j,I),M.exports=j;var R=F("kCallback");function x(f){if(typeof this._flush==="function"&&!this.destroyed)this._flush((c,_)=>{if(c){if(f)f(c);else this.destroy(c);return}if(_!=null)this.push(_);if(this.push(null),f)f()});else if(this.push(null),f)f()}function g(){if(this._final!==x)x.call(this)}j.prototype._final=x,j.prototype._transform=function(f,c,_){throw new y("_transform()")},j.prototype._write=function(f,c,_){const i=this._readableState,D=this._writableState,p=i.length;this._transform(f,c,(P,A)=>{if(P){_(P);return}if(A!=null)this.push(A);if(D.ended||p===i.length||i.length{S=!0});const E=I(J,{readable:z,writable:w},(W)=>{S=!W});return{destroy:(W)=>{if(S)return;S=!0,R.destroyer(J,W||new i("pipe"))},cleanup:E}}function $(J){return p(J[J.length-1],"streams[stream.length - 1]"),J.pop()}function s(J){if(A(J))return J;else if(U(J))return Y(J);throw new f("val",["Readable","Iterable","AsyncIterable"],J)}async function*Y(J){if(!qq)qq=Dq();yield*qq.prototype[y].call(J)}async function Z(J,z,w,{end:S}){let E,W=null;const b=(Qq)=>{if(Qq)E=Qq;if(W){const Zq=W;W=null,Zq()}},a=()=>new F((Qq,Zq)=>{if(E)Zq(E);else W=()=>{if(E)Zq(E);else Qq()}});z.on("drain",b);const r=I(z,{readable:!1},b);try{if(z.writableNeedDrain)await a();for await(let Qq of J)if(!z.write(Qq))await a();if(S)z.end();await a(),w()}catch(Qq){w(E!==Qq?g(E,Qq):Qq)}finally{r(),z.off("drain",b)}}function N(...J){return m(J,j($(J)))}function m(J,z,w){if(J.length===1&&B(J[0]))J=J[0];if(J.length<2)throw new _("streams");const S=new AbortController,E=S.signal,W=w===null||w===void 0?void 0:w.signal,b=[];P(W,"options.signal");function a(){Bq(new D)}W===null||W===void 0||W.addEventListener("abort",a);let r,Qq;const Zq=[];let Vq=0;function Xq(h){Bq(h,--Vq===0)}function Bq(h,X){if(h&&(!r||r.code==="ERR_STREAM_PREMATURE_CLOSE"))r=h;if(!r&&!X)return;while(Zq.length)Zq.shift()(r);if(W===null||W===void 0||W.removeEventListener("abort",a),S.abort(),X){if(!r)b.forEach((H)=>H());Hq(z,r,Qq)}}let Jq;for(let h=0;h0,l=H||(w===null||w===void 0?void 0:w.end)!==!1,k=h===J.length-1;if(T(X)){let e=function(q){if(q&&q.name!=="AbortError"&&q.code!=="ERR_STREAM_PREMATURE_CLOSE")Xq(q)};if(l){const{destroy:q,cleanup:Q}=o(X,H,L);if(Zq.push(q),K(X)&&k)b.push(Q)}if(X.on("error",e),K(X)&&k)b.push(()=>{X.removeListener("error",e)})}if(h===0)if(typeof X==="function"){if(Jq=X({signal:E}),!A(Jq))throw new c("Iterable, AsyncIterable or Stream","source",Jq)}else if(A(X)||U(X))Jq=X;else Jq=x.from(X);else if(typeof X==="function")if(Jq=s(Jq),Jq=X(Jq,{signal:E}),H){if(!A(Jq,!0))throw new c("AsyncIterable",`transform[${h-1}]`,Jq)}else{var V;if(!C)C=dq();const e=new C({objectMode:!0}),q=(V=Jq)===null||V===void 0?void 0:V.then;if(typeof q==="function")Vq++,q.call(Jq,(G)=>{if(Qq=G,G!=null)e.write(G);if(l)e.end();Hq(Xq)},(G)=>{e.destroy(G),Hq(Xq,G)});else if(A(Jq,!0))Vq++,Z(Jq,e,Xq,{end:l});else throw new c("AsyncIterable or Promise","destination",Jq);Jq=e;const{destroy:Q,cleanup:O}=o(Jq,!1,!0);if(Zq.push(Q),k)b.push(O)}else if(T(X)){if(U(Jq)){Vq+=2;const e=u(Jq,X,Xq,{end:l});if(K(X)&&k)b.push(e)}else if(A(Jq))Vq++,Z(Jq,X,Xq,{end:l});else throw new f("val",["Readable","Iterable","AsyncIterable"],Jq);Jq=X}else Jq=x.from(X)}if(E!==null&&E!==void 0&&E.aborted||W!==null&&W!==void 0&&W.aborted)Hq(a);return Jq}function u(J,z,w,{end:S}){if(J.pipe(z,{end:S}),S)J.once("end",()=>z.end());else w();return I(J,{readable:!0,writable:!1},(E)=>{const W=J._readableState;if(E&&E.code==="ERR_STREAM_PREMATURE_CLOSE"&&W&&W.ended&&!W.errored&&!W.errorEmitted)J.once("end",w).once("error",w);else w(E)}),I(z,{readable:!1,writable:!0},w)}M.exports={pipelineImpl:m,pipeline:N}}}),BQ=$q({"node_modules/readable-stream/lib/internal/streams/compose.js"(t,M){var{pipeline:B}=fq(),F=Lq(),{destroyer:y}=Pq(),{isNodeStream:I,isReadable:j,isWritable:R}=Iq(),{AbortError:x,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:f}}=Mq();M.exports=function c(..._){if(_.length===0)throw new f("streams");if(_.length===1)return F.from(_[0]);const i=[..._];if(typeof _[0]==="function")_[0]=F.from(_[0]);if(typeof _[_.length-1]==="function"){const $=_.length-1;_[$]=F.from(_[$])}for(let $=0;$<_.length;++$){if(!I(_[$]))continue;if($<_.length-1&&!j(_[$]))throw new g(`streams[${$}]`,i[$],"must be readable");if($>0&&!R(_[$]))throw new g(`streams[${$}]`,i[$],"must be writable")}let D,p,P,A,K;function U($){const s=A;if(A=null,s)s($);else if($)K.destroy($);else if(!o&&!qq)K.destroy()}const T=_[0],C=B(_,U),qq=!!R(T),o=!!j(C);if(K=new F({writableObjectMode:!!(T!==null&&T!==void 0&&T.writableObjectMode),readableObjectMode:!!(C!==null&&C!==void 0&&C.writableObjectMode),writable:qq,readable:o}),qq)K._write=function($,s,Y){if(T.write($,s))Y();else D=Y},K._final=function($){T.end(),p=$},T.on("drain",function(){if(D){const $=D;D=null,$()}}),C.on("finish",function(){if(p){const $=p;p=null,$()}});if(o)C.on("readable",function(){if(P){const $=P;P=null,$()}}),C.on("end",function(){K.push(null)}),K._read=function(){while(!0){const $=C.read();if($===null){P=K._read;return}if(!K.push($))return}};return K._destroy=function($,s){if(!$&&A!==null)$=new x;if(P=null,D=null,p=null,A===null)s($);else A=s,y(C,$)},K}}}),lq=$q({"node_modules/readable-stream/lib/stream/promises.js"(t,M){var{ArrayPrototypePop:B,Promise:F}=Wq(),{isIterable:y,isNodeStream:I}=Iq(),{pipelineImpl:j}=fq(),{finished:R}=jq();function x(...g){return new F((f,c)=>{let _,i;const D=g[g.length-1];if(D&&typeof D==="object"&&!I(D)&&!y(D)){const p=B(g);_=p.signal,i=p.end}j(g,(p,P)=>{if(p)c(p);else f(P)},{signal:_,end:i})})}M.exports={finished:R,pipeline:x}}}),YQ=$q({"node_modules/readable-stream/lib/stream.js"(t,M){var{ObjectDefineProperty:B,ObjectKeys:F,ReflectApply:y}=Wq(),{promisify:{custom:I}}=Eq(),{streamReturningOperators:j,promiseReturningOperators:R}=HQ(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:x}}=Mq(),g=BQ(),{pipeline:f}=fq(),{destroyer:c}=Pq(),_=jq(),i=lq(),D=Iq(),p=M.exports=Sq().Stream;p.isDisturbed=D.isDisturbed,p.isErrored=D.isErrored,p.isWritable=D.isWritable,p.isReadable=D.isReadable,p.Readable=Dq();for(let A of F(j)){let K=function(...T){if(new.target)throw x();return p.Readable.from(y(U,this,T))};const U=j[A];B(K,"name",{value:U.name}),B(K,"length",{value:U.length}),B(p.Readable.prototype,A,{value:K,enumerable:!1,configurable:!0,writable:!0})}for(let A of F(R)){let K=function(...T){if(new.target)throw x();return y(U,this,T)};const U=R[A];B(K,"name",{value:U.name}),B(K,"length",{value:U.length}),B(p.Readable.prototype,A,{value:K,enumerable:!1,configurable:!0,writable:!0})}p.Writable=mq(),p.Duplex=Lq(),p.Transform=cq(),p.PassThrough=dq(),p.pipeline=f;var{addAbortSignal:P}=gq();p.addAbortSignal=P,p.finished=_,p.destroy=c,p.compose=g,B(p,"promises",{configurable:!0,enumerable:!0,get(){return i}}),B(f,I,{enumerable:!0,get(){return i.pipeline}}),B(_,I,{enumerable:!0,get(){return i.finished}}),p.Stream=p,p._isUint8Array=function A(K){return K instanceof Uint8Array},p._uint8ArrayToBuffer=function A(K){return new Buffer(K.buffer,K.byteOffset,K.byteLength)}}}),$Q=$q({"node_modules/readable-stream/lib/ours/index.js"(t,M){const B=YQ(),F=lq(),y=B.Readable.destroy;M.exports=B,M.exports._uint8ArrayToBuffer=B._uint8ArrayToBuffer,M.exports._isUint8Array=B._isUint8Array,M.exports.isDisturbed=B.isDisturbed,M.exports.isErrored=B.isErrored,M.exports.isWritable=B.isWritable,M.exports.isReadable=B.isReadable,M.exports.Readable=B.Readable,M.exports.Writable=B.Writable,M.exports.Duplex=B.Duplex,M.exports.Transform=B.Transform,M.exports.PassThrough=B.PassThrough,M.exports.addAbortSignal=B.addAbortSignal,M.exports.finished=B.finished,M.exports.destroy=B.destroy,M.exports.destroy=y,M.exports.pipeline=B.pipeline,M.exports.compose=B.compose,M.exports._getNativeReadableStreamPrototype=iq,M.exports.NativeWritable=nq,Uq.defineProperty(B,"promises",{configurable:!0,enumerable:!0,get(){return F}}),M.exports.Stream=B.Stream,M.exports.default=M.exports}}),VQ={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Gq=mq(),nq=class t extends Gq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(M,B={}){super(B);this._construct=this.#H,this._destroy=this.#K,this._final=this.#Z,this.#q=M}#H(M){this._writableState.constructed=!0,this.constructed=!0,M()}#J(){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(M,B,F,y=this.#X){if(!y)return this.#X=!1,super.write(M,B,F);if(!this.#Q)this.#J();var I=this.#Q,j=I.write(M);if(Oq(j))return j.then(()=>{this.emit("drain"),I.flush(!0)}),!1;if(I.flush(!0),F)F(null,M.byteLength);return!0}end(M,B,F,y=this.#X){return super.end(M,B,F,y)}#K(M,B){if(this._writableState.destroyed=!0,B)B(M)}#Z(M){if(this.#Q)this.#Q.end();if(M)M()}ref(){if(!this.#Q)this.#J();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},zq=$Q();zq[Symbol.for("CommonJS")]=0;zq[Symbol.for("::bunternal::")]={_ReadableFromWeb:uq,_ReadableFromWebForUndici:bq};var lQ=zq,TQ=zq._uint8ArrayToBuffer,PQ=zq._isUint8Array,xQ=zq.isDisturbed,OQ=zq.isErrored,_Q=zq.isWritable,CQ=zq.isReadable,DQ=zq.Readable,Gq=zq.Writable,wQ=zq.Duplex,vQ=zq.Transform,RQ=zq.PassThrough,SQ=zq.addAbortSignal,gQ=zq.finished,fQ=zq.destroy,kQ=zq.pipeline,yQ=zq.compose,WQ=zq.Stream,hQ=zq.eos=jq,pQ=zq._getNativeReadableStreamPrototype,nq=zq.NativeWritable,uQ=WQ.promises;export{uQ as promises,kQ as pipeline,_Q as isWritable,CQ as isReadable,OQ as isErrored,xQ as isDisturbed,gQ as finished,hQ as eos,fQ as destroy,lQ as default,yQ as compose,SQ as addAbortSignal,TQ as _uint8ArrayToBuffer,PQ as _isUint8Array,pQ as _getNativeReadableStreamPrototype,Gq as Writable,vQ as Transform,WQ as Stream,DQ as Readable,RQ as PassThrough,nq as NativeWritable,wQ as Duplex}; +import{EventEmitter as Iq} from"bun:events_native";import{StringDecoder as aq} from"node:string_decoder";var tq=function(a){return typeof a==="object"&&a!==null&&a instanceof ReadableStream},eq=function(a,j){if(typeof a!=="boolean")throw new qQ(j,"boolean",a)};var qQ=function(a,j,B){return new Error(`The argument '${a}' is invalid. Received '${B}' for type '${j}'`)},QQ=function(a,j,B){return new Error(`The value '${j}' is invalid for argument '${a}'. Reason: ${B}`)},YQ=function(a,j){var[B,G,y,A,M,R,P]=globalThis[Symbol.for("Bun.lazy")](a),g=[!1],k=function(E,I,Z,U){if(I>0){const T=Z.subarray(0,I),_=Z.subarray(I);if(T.byteLength>0)E.push(T);if(U)E.push(null);return _.byteLength>0?_:void 0}if(U)E.push(null);return Z},c=function(E,I,Z,U){if(I.byteLength>0)E.push(I);if(U)E.push(null);return Z},O=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const l=new FinalizationRegistry((E)=>E&&M(E)),D=512;var p=class E extends j{#q;#Q=1;#X=!1;#H=void 0;#J;#K=!1;#Z=!O;#B;constructor(I,Z={}){super(Z);if(typeof Z.highWaterMark==="number")this.#J=Z.highWaterMark;else this.#J=262144;this.#q=I,this.#X=!1,this.#H=void 0,this.#K=!1,this.#B={},l.register(this,this.#q,this.#B)}_read(I){if(this.#K)return;var Z=this.#q;if(Z===0){this.push(null);return}if(!this.#X)this.#$(Z);return this.#V(this.#z(I),Z)}#$(I){this.#X=!0;const Z=G(I,this.#J);if(typeof Z==="number"&&Z>1)this.#Z=!0,this.#J=Math.min(this.#J,Z);if(P){const U=P(I);if((U?.byteLength??0)>0)this.push(U)}}#z(I=this.#J){var Z=this.#H;if(Z?.byteLength??0D?I:D;this.#H=Z=new Buffer(U)}return Z}push(I,Z){return super.push(...arguments)}#Y(I,Z,U){if(typeof I==="number"){if(I>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0;return k(this,I,Z,U)}else if(typeof I==="boolean")return this.push(null),Z?.byteLength??0>0?Z:void 0;else if(ArrayBuffer.isView(I)){if(I.byteLength>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0;return c(this,I,Z,U)}else throw new Error("Invalid result from pull")}#V(I,Z){g[0]=!1;var U=B(Z,I,g);if(xq(U))return this.#K=!0,U.then((T)=>{this.#K=!1,this.#H=this.#Y(T,I,g[0])},(T)=>{errorOrDestroy(this,T)});else this.#H=this.#Y(U,I,g[0])}_destroy(I,Z){var U=this.#q;if(U===0){Z(I);return}if(l.unregister(this.#B),this.#q=0,R)R(U,!1);y(U,I),Z(I)}ref(){var I=this.#q;if(I===0)return;if(this.#Q++===0)R(I,!0)}unref(){var I=this.#q;if(I===0)return;if(this.#Q--===1)R(I,!1)}};if(!R)p.prototype.ref=void 0,p.prototype.unref=void 0;return p},lq=function(a,j){return $Q[a]||=YQ(a,j)},zQ=function(a,j,B){if(!(j&&typeof j==="object"&&j instanceof ReadableStream))return;const G=sq(j);if(!G){Gq("no native readable stream");return}const{stream:y,data:A}=G;return new(lq(A,a))(y,B)};var Gq=()=>{},{isPromise:xq,isCallable:oq,direct:sq,Object:zq}=globalThis[Symbol.for("Bun.lazy")]("primordials"),GQ=zq.create,MQ=zq.defineProperty,FQ=zq.getOwnPropertyDescriptor,rq=zq.getOwnPropertyNames,LQ=zq.getPrototypeOf,jQ=zq.prototype.hasOwnProperty,NQ=zq.setPrototypeOf,Bq=(a,j)=>function B(){return j||(0,a[rq(a)[0]])((j={exports:{}}).exports,j),j.exports};var Xq=process.nextTick;var AQ=Array.isArray,Vq=Bq({"node_modules/readable-stream/lib/ours/primordials.js"(a,j){j.exports={ArrayIsArray(B){return Array.isArray(B)},ArrayPrototypeIncludes(B,G){return B.includes(G)},ArrayPrototypeIndexOf(B,G){return B.indexOf(G)},ArrayPrototypeJoin(B,G){return B.join(G)},ArrayPrototypeMap(B,G){return B.map(G)},ArrayPrototypePop(B,G){return B.pop(G)},ArrayPrototypePush(B,G){return B.push(G)},ArrayPrototypeSlice(B,G,y){return B.slice(G,y)},Error,FunctionPrototypeCall(B,G,...y){return B.call(G,...y)},FunctionPrototypeSymbolHasInstance(B,G){return Function.prototype[Symbol.hasInstance].call(B,G)},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(B,G){return zq.defineProperties(B,G)},ObjectDefineProperty(B,G,y){return zq.defineProperty(B,G,y)},ObjectGetOwnPropertyDescriptor(B,G){return zq.getOwnPropertyDescriptor(B,G)},ObjectKeys(B){return zq.keys(B)},ObjectSetPrototypeOf(B,G){return zq.setPrototypeOf(B,G)},Promise,PromisePrototypeCatch(B,G){return B.catch(G)},PromisePrototypeThen(B,G,y){return B.then(G,y)},PromiseReject(B){return Promise.reject(B)},ReflectApply:Reflect.apply,RegExpPrototypeTest(B,G){return B.test(G)},SafeSet:Set,String,StringPrototypeSlice(B,G,y){return B.slice(G,y)},StringPrototypeToLowerCase(B){return B.toLowerCase()},StringPrototypeToUpperCase(B){return B.toUpperCase()},StringPrototypeTrim(B){return B.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(B,G,y){return B.set(G,y)},Uint8Array}}}),Aq=Bq({"node_modules/readable-stream/lib/ours/util.js"(a,j){var B=zq.getPrototypeOf(async function(){}).constructor,G=typeof Blob!=="undefined"?function A(M){return M instanceof Blob}:function A(M){return!1},y=class extends Error{constructor(A){if(!Array.isArray(A))throw new TypeError(`Expected input to be an Array, got ${typeof A}`);let M="";for(let R=0;R{A=P,M=g}),resolve:A,reject:M}},promisify(A){return new Promise((M,R)=>{A((P,...g)=>{if(P)return R(P);return M(...g)})})},debuglog(){return function(){}},format(A,...M){return A.replace(/%([sdifj])/g,function(...[R,P]){const g=M.shift();if(P==="f")return g.toFixed(6);else if(P==="j")return JSON.stringify(g);else if(P==="s"&&typeof g==="object")return`${g.constructor!==zq?g.constructor.name:""} {}`.trim();else return g.toString()})},inspect(A){switch(typeof A){case"string":if(A.includes("'")){if(!A.includes('"'))return`"${A}"`;else if(!A.includes("`")&&!A.includes("${"))return`\`${A}\``}return`'${A}'`;case"number":if(isNaN(A))return"NaN";else if(zq.is(A,-0))return String(A);return A;case"bigint":return`${String(A)}n`;case"boolean":case"undefined":return String(A);case"object":return"{}"}},types:{isAsyncFunction(A){return A instanceof B},isArrayBufferView(A){return ArrayBuffer.isView(A)}},isBlob:G},j.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),Wq=Bq({"node_modules/readable-stream/lib/ours/errors.js"(a,j){var{format:B,inspect:G,AggregateError:y}=Aq(),A=globalThis.AggregateError||y,M=Symbol("kIsNodeError"),R=["string","function","number","object","Function","Object","boolean","bigint","symbol"],P=/^([A-Z][a-z0-9]*)+$/,g="__node_internal_",k={};function c(Z,U){if(!Z)throw new k.ERR_INTERNAL_ASSERTION(U)}function O(Z){let U="",T=Z.length;const _=Z[0]==="-"?1:0;for(;T>=_+4;T-=3)U=`_${Z.slice(T-3,T)}${U}`;return`${Z.slice(0,T)}${U}`}function l(Z,U,T){if(typeof U==="function")return c(U.length<=T.length,`Code: ${Z}; The provided arguments length (${T.length}) does not match the required ones (${U.length}).`),U(...T);const _=(U.match(/%[dfijoOs]/g)||[]).length;if(c(_===T.length,`Code: ${Z}; The provided arguments length (${T.length}) does not match the required ones (${_}).`),T.length===0)return U;return B(U,...T)}function D(Z,U,T){if(!T)T=Error;class _ extends T{constructor(...t){super(l(Z,U,t))}toString(){return`${this.name} [${Z}]: ${this.message}`}}zq.defineProperties(_.prototype,{name:{value:T.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${Z}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),_.prototype.code=Z,_.prototype[M]=!0,k[Z]=_}function p(Z){const U=g+Z.name;return zq.defineProperty(Z,"name",{value:U}),Z}function E(Z,U){if(Z&&U&&Z!==U){if(Array.isArray(U.errors))return U.errors.push(Z),U;const T=new A([U,Z],U.message);return T.code=U.code,T}return Z||U}var I=class extends Error{constructor(Z="The operation was aborted",U=void 0){if(U!==void 0&&typeof U!=="object")throw new k.ERR_INVALID_ARG_TYPE("options","Object",U);super(Z,U);this.code="ABORT_ERR",this.name="AbortError"}};D("ERR_ASSERTION","%s",Error),D("ERR_INVALID_ARG_TYPE",(Z,U,T)=>{if(c(typeof Z==="string","'name' must be a string"),!Array.isArray(U))U=[U];let _="The ";if(Z.endsWith(" argument"))_+=`${Z} `;else _+=`"${Z}" ${Z.includes(".")?"property":"argument"} `;_+="must be ";const t=[],i=[],$=[];for(let Y of U)if(c(typeof Y==="string","All expected entries have to be of type string"),R.includes(Y))t.push(Y.toLowerCase());else if(P.test(Y))i.push(Y);else c(Y!=="object",'The value "object" should be written as "Object"'),$.push(Y);if(i.length>0){const Y=t.indexOf("object");if(Y!==-1)t.splice(t,Y,1),i.push("Object")}if(t.length>0){switch(t.length){case 1:_+=`of type ${t[0]}`;break;case 2:_+=`one of type ${t[0]} or ${t[1]}`;break;default:{const Y=t.pop();_+=`one of type ${t.join(", ")}, or ${Y}`}}if(i.length>0||$.length>0)_+=" or "}if(i.length>0){switch(i.length){case 1:_+=`an instance of ${i[0]}`;break;case 2:_+=`an instance of ${i[0]} or ${i[1]}`;break;default:{const Y=i.pop();_+=`an instance of ${i.join(", ")}, or ${Y}`}}if($.length>0)_+=" or "}switch($.length){case 0:break;case 1:if($[0].toLowerCase()!==$[0])_+="an ";_+=`${$[0]}`;break;case 2:_+=`one of ${$[0]} or ${$[1]}`;break;default:{const Y=$.pop();_+=`one of ${$.join(", ")}, or ${Y}`}}if(T==null)_+=`. Received ${T}`;else if(typeof T==="function"&&T.name)_+=`. Received function ${T.name}`;else if(typeof T==="object"){var n;if((n=T.constructor)!==null&&n!==void 0&&n.name)_+=`. Received an instance of ${T.constructor.name}`;else{const Y=G(T,{depth:-1});_+=`. Received ${Y}`}}else{let Y=G(T,{colors:!1});if(Y.length>25)Y=`${Y.slice(0,25)}...`;_+=`. Received type ${typeof T} (${Y})`}return _},TypeError),D("ERR_INVALID_ARG_VALUE",(Z,U,T="is invalid")=>{let _=G(U);if(_.length>128)_=_.slice(0,128)+"...";return`The ${Z.includes(".")?"property":"argument"} '${Z}' ${T}. Received ${_}`},TypeError),D("ERR_INVALID_RETURN_VALUE",(Z,U,T)=>{var _;const t=T!==null&&T!==void 0&&(_=T.constructor)!==null&&_!==void 0&&_.name?`instance of ${T.constructor.name}`:`type ${typeof T}`;return`Expected ${Z} to be returned from the "${U}" function but got ${t}.`},TypeError),D("ERR_MISSING_ARGS",(...Z)=>{c(Z.length>0,"At least one arg needs to be specified");let U;const T=Z.length;switch(Z=(Array.isArray(Z)?Z:[Z]).map((_)=>`"${_}"`).join(" or "),T){case 1:U+=`The ${Z[0]} argument`;break;case 2:U+=`The ${Z[0]} and ${Z[1]} arguments`;break;default:{const _=Z.pop();U+=`The ${Z.join(", ")}, and ${_} arguments`}break}return`${U} must be specified`},TypeError),D("ERR_OUT_OF_RANGE",(Z,U,T)=>{c(U,'Missing "range" argument');let _;if(Number.isInteger(T)&&Math.abs(T)>4294967296)_=O(String(T));else if(typeof T==="bigint"){if(_=String(T),T>2n**32n||T<-(2n**32n))_=O(_);_+="n"}else _=G(T);return`The value of "${Z}" is out of range. It must be ${U}. Received ${_}`},RangeError),D("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),D("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),D("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),D("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),D("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),D("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),D("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),D("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),D("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),D("ERR_STREAM_WRITE_AFTER_END","write after end",Error),D("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),j.exports={AbortError:I,aggregateTwoErrors:p(E),hideStackFrames:p,codes:k}}}),Cq=Bq({"node_modules/readable-stream/lib/internal/validators.js"(a,j){var{ArrayIsArray:B,ArrayPrototypeIncludes:G,ArrayPrototypeJoin:y,ArrayPrototypeMap:A,NumberIsInteger:M,NumberMAX_SAFE_INTEGER:R,NumberMIN_SAFE_INTEGER:P,NumberParseInt:g,RegExpPrototypeTest:k,String:c,StringPrototypeToUpperCase:O,StringPrototypeTrim:l}=Vq(),{hideStackFrames:D,codes:{ERR_SOCKET_BAD_PORT:p,ERR_INVALID_ARG_TYPE:E,ERR_INVALID_ARG_VALUE:I,ERR_OUT_OF_RANGE:Z,ERR_UNKNOWN_SIGNAL:U}}=Wq(),{normalizeEncoding:T}=Aq(),{isAsyncFunction:_,isArrayBufferView:t}=Aq().types,i={};function $(V){return V===(V|0)}function n(V){return V===V>>>0}var Y=/^[0-7]+$/,K="must be a 32-bit unsigned integer or an octal string";function F(V,h,Q){if(typeof V==="undefined")V=Q;if(typeof V==="string"){if(!k(Y,V))throw new I(h,V,K);V=g(V,8)}return u(V,h,0,4294967295),V}var m=D((V,h,Q=P,H=R)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!M(V))throw new Z(h,"an integer",V);if(VH)throw new Z(h,`>= ${Q} && <= ${H}`,V)}),u=D((V,h,Q=-2147483648,H=2147483647)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!$(V)){if(!M(V))throw new Z(h,"an integer",V);throw new Z(h,`>= ${Q} && <= ${H}`,V)}if(VH)throw new Z(h,`>= ${Q} && <= ${H}`,V)}),J=D((V,h,Q)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!n(V)){if(!M(V))throw new Z(h,"an integer",V);throw new Z(h,`>= ${Q?1:0} && < 4294967296`,V)}if(Q&&V===0)throw new Z(h,">= 1 && < 4294967296",V)});function z(V,h){if(typeof V!=="string")throw new E(h,"string",V)}function w(V,h){if(typeof V!=="number")throw new E(h,"number",V)}var S=D((V,h,Q)=>{if(!G(Q,V)){const L="must be one of: "+y(A(Q,(d)=>typeof d==="string"?`'${d}'`:c(d)),", ");throw new I(h,V,L)}});function N(V,h){if(typeof V!=="boolean")throw new E(h,"boolean",V)}var W=D((V,h,Q)=>{const H=Q==null,L=H?!1:Q.allowArray,d=H?!1:Q.allowFunction;if(!(H?!1:Q.nullable)&&V===null||!L&&B(V)||typeof V!=="object"&&(!d||typeof V!=="function"))throw new E(h,"Object",V)}),b=D((V,h,Q=0)=>{if(!B(V))throw new E(h,"Array",V);if(V.length{if(!t(V))throw new E(h,["Buffer","TypedArray","DataView"],V)});function e(V,h){const Q=T(h),H=V.length;if(Q==="hex"&&H%2!==0)throw new I("encoding",h,`is invalid for data of length ${H}`)}function Hq(V,h="Port",Q=!0){if(typeof V!=="number"&&typeof V!=="string"||typeof V==="string"&&l(V).length===0||+V!==+V>>>0||V>65535||V===0&&!Q)throw new p(h,V,Q);return V|0}var $q=D((V,h)=>{if(V!==void 0&&(V===null||typeof V!=="object"||!("aborted"in V)))throw new E(h,"AbortSignal",V)}),qq=D((V,h)=>{if(typeof V!=="function")throw new E(h,"Function",V)}),Kq=D((V,h)=>{if(typeof V!=="function"||_(V))throw new E(h,"Function",V)}),Qq=D((V,h)=>{if(V!==void 0)throw new E(h,"undefined",V)});j.exports={isInt32:$,isUint32:n,parseFileMode:F,validateArray:b,validateBoolean:N,validateBuffer:s,validateEncoding:e,validateFunction:qq,validateInt32:u,validateInteger:m,validateNumber:w,validateObject:W,validateOneOf:S,validatePlainFunction:Kq,validatePort:Hq,validateSignalName:o,validateString:z,validateUint32:J,validateUndefined:Qq,validateAbortSignal:$q}}}),Eq=Bq({"node_modules/readable-stream/lib/internal/streams/utils.js"(a,j){var{Symbol:B,SymbolAsyncIterator:G,SymbolIterator:y}=Vq(),A=B("kDestroyed"),M=B("kIsErrored"),R=B("kIsReadable"),P=B("kIsDisturbed");function g(J,z=!1){var w;return!!(J&&typeof J.pipe==="function"&&typeof J.on==="function"&&(!z||typeof J.pause==="function"&&typeof J.resume==="function")&&(!J._writableState||((w=J._readableState)===null||w===void 0?void 0:w.readable)!==!1)&&(!J._writableState||J._readableState))}function k(J){var z;return!!(J&&typeof J.write==="function"&&typeof J.on==="function"&&(!J._readableState||((z=J._writableState)===null||z===void 0?void 0:z.writable)!==!1))}function c(J){return!!(J&&typeof J.pipe==="function"&&J._readableState&&typeof J.on==="function"&&typeof J.write==="function")}function O(J){return J&&(J._readableState||J._writableState||typeof J.write==="function"&&typeof J.on==="function"||typeof J.pipe==="function"&&typeof J.on==="function")}function l(J,z){if(J==null)return!1;if(z===!0)return typeof J[G]==="function";if(z===!1)return typeof J[y]==="function";return typeof J[G]==="function"||typeof J[y]==="function"}function D(J){if(!O(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!!(J.destroyed||J[A]||S!==null&&S!==void 0&&S.destroyed)}function p(J){if(!k(J))return null;if(J.writableEnded===!0)return!0;const z=J._writableState;if(z!==null&&z!==void 0&&z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function E(J,z){if(!k(J))return null;if(J.writableFinished===!0)return!0;const w=J._writableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.finished)!=="boolean")return null;return!!(w.finished||z===!1&&w.ended===!0&&w.length===0)}function I(J){if(!g(J))return null;if(J.readableEnded===!0)return!0;const z=J._readableState;if(!z||z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function Z(J,z){if(!g(J))return null;const w=J._readableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.endEmitted)!=="boolean")return null;return!!(w.endEmitted||z===!1&&w.ended===!0&&w.length===0)}function U(J){if(J&&J[R]!=null)return J[R];if(typeof(J===null||J===void 0?void 0:J.readable)!=="boolean")return null;if(D(J))return!1;return g(J)&&J.readable&&!Z(J)}function T(J){if(typeof(J===null||J===void 0?void 0:J.writable)!=="boolean")return null;if(D(J))return!1;return k(J)&&J.writable&&!p(J)}function _(J,z){if(!O(J))return null;if(D(J))return!0;if((z===null||z===void 0?void 0:z.readable)!==!1&&U(J))return!1;if((z===null||z===void 0?void 0:z.writable)!==!1&&T(J))return!1;return!0}function t(J){var z,w;if(!O(J))return null;if(J.writableErrored)return J.writableErrored;return(z=(w=J._writableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function i(J){var z,w;if(!O(J))return null;if(J.readableErrored)return J.readableErrored;return(z=(w=J._readableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function $(J){if(!O(J))return null;if(typeof J.closed==="boolean")return J.closed;const{_writableState:z,_readableState:w}=J;if(typeof(z===null||z===void 0?void 0:z.closed)==="boolean"||typeof(w===null||w===void 0?void 0:w.closed)==="boolean")return(z===null||z===void 0?void 0:z.closed)||(w===null||w===void 0?void 0:w.closed);if(typeof J._closed==="boolean"&&n(J))return J._closed;return null}function n(J){return typeof J._closed==="boolean"&&typeof J._defaultKeepAlive==="boolean"&&typeof J._removedConnection==="boolean"&&typeof J._removedContLen==="boolean"}function Y(J){return typeof J._sent100==="boolean"&&n(J)}function K(J){var z;return typeof J._consuming==="boolean"&&typeof J._dumped==="boolean"&&((z=J.req)===null||z===void 0?void 0:z.upgradeOrConnect)===void 0}function F(J){if(!O(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!S&&Y(J)||!!(S&&S.autoDestroy&&S.emitClose&&S.closed===!1)}function m(J){var z;return!!(J&&((z=J[P])!==null&&z!==void 0?z:J.readableDidRead||J.readableAborted))}function u(J){var z,w,S,N,W,b,o,s,e,Hq;return!!(J&&((z=(w=(S=(N=(W=(b=J[M])!==null&&b!==void 0?b:J.readableErrored)!==null&&W!==void 0?W:J.writableErrored)!==null&&N!==void 0?N:(o=J._readableState)===null||o===void 0?void 0:o.errorEmitted)!==null&&S!==void 0?S:(s=J._writableState)===null||s===void 0?void 0:s.errorEmitted)!==null&&w!==void 0?w:(e=J._readableState)===null||e===void 0?void 0:e.errored)!==null&&z!==void 0?z:(Hq=J._writableState)===null||Hq===void 0?void 0:Hq.errored))}j.exports={kDestroyed:A,isDisturbed:m,kIsDisturbed:P,isErrored:u,kIsErrored:M,isReadable:U,kIsReadable:R,isClosed:$,isDestroyed:D,isDuplexNodeStream:c,isFinished:_,isIterable:l,isReadableNodeStream:g,isReadableEnded:I,isReadableFinished:Z,isReadableErrored:i,isNodeStream:O,isWritable:T,isWritableNodeStream:k,isWritableEnded:p,isWritableFinished:E,isWritableErrored:t,isServerRequest:K,isServerResponse:Y,willEmitClose:F}}}),Fq=Bq({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(a,j){var{AbortError:B,codes:G}=Wq(),{ERR_INVALID_ARG_TYPE:y,ERR_STREAM_PREMATURE_CLOSE:A}=G,{once:M}=Aq(),{validateAbortSignal:R,validateFunction:P,validateObject:g}=Cq(),{Promise:k}=Vq(),{isClosed:c,isReadable:O,isReadableNodeStream:l,isReadableFinished:D,isReadableErrored:p,isWritable:E,isWritableNodeStream:I,isWritableFinished:Z,isWritableErrored:U,isNodeStream:T,willEmitClose:_}=Eq();function t(Y){return Y.setHeader&&typeof Y.abort==="function"}var i=()=>{};function $(Y,K,F){var m,u;if(arguments.length===2)F=K,K={};else if(K==null)K={};else g(K,"options");P(F,"callback"),R(K.signal,"options.signal"),F=M(F);const J=(m=K.readable)!==null&&m!==void 0?m:l(Y),z=(u=K.writable)!==null&&u!==void 0?u:I(Y);if(!T(Y))throw new y("stream","Stream",Y);const{_writableState:w,_readableState:S}=Y,N=()=>{if(!Y.writable)o()};let W=_(Y)&&l(Y)===J&&I(Y)===z,b=Z(Y,!1);const o=()=>{if(b=!0,Y.destroyed)W=!1;if(W&&(!Y.readable||J))return;if(!J||s)F.call(Y)};let s=D(Y,!1);const e=()=>{if(s=!0,Y.destroyed)W=!1;if(W&&(!Y.writable||z))return;if(!z||b)F.call(Y)},Hq=(V)=>{F.call(Y,V)};let $q=c(Y);const qq=()=>{$q=!0;const V=U(Y)||p(Y);if(V&&typeof V!=="boolean")return F.call(Y,V);if(J&&!s&&l(Y,!0)){if(!D(Y,!1))return F.call(Y,new A)}if(z&&!b){if(!Z(Y,!1))return F.call(Y,new A)}F.call(Y)},Kq=()=>{Y.req.on("finish",o)};if(t(Y)){if(Y.on("complete",o),!W)Y.on("abort",qq);if(Y.req)Kq();else Y.on("request",Kq)}else if(z&&!w)Y.on("end",N),Y.on("close",N);if(!W&&typeof Y.aborted==="boolean")Y.on("aborted",qq);if(Y.on("end",e),Y.on("finish",o),K.error!==!1)Y.on("error",Hq);if(Y.on("close",qq),$q)Xq(qq);else if(w!==null&&w!==void 0&&w.errorEmitted||S!==null&&S!==void 0&&S.errorEmitted){if(!W)Xq(qq)}else if(!J&&(!W||O(Y))&&(b||E(Y)===!1))Xq(qq);else if(!z&&(!W||E(Y))&&(s||O(Y)===!1))Xq(qq);else if(S&&Y.req&&Y.aborted)Xq(qq);const Qq=()=>{if(F=i,Y.removeListener("aborted",qq),Y.removeListener("complete",o),Y.removeListener("abort",qq),Y.removeListener("request",Kq),Y.req)Y.req.removeListener("finish",o);Y.removeListener("end",N),Y.removeListener("close",N),Y.removeListener("finish",o),Y.removeListener("end",e),Y.removeListener("error",Hq),Y.removeListener("close",qq)};if(K.signal&&!$q){const V=()=>{const h=F;Qq(),h.call(Y,new B(void 0,{cause:K.signal.reason}))};if(K.signal.aborted)Xq(V);else{const h=F;F=M((...Q)=>{K.signal.removeEventListener("abort",V),h.apply(Y,Q)}),K.signal.addEventListener("abort",V)}}return Qq}function n(Y,K){return new k((F,m)=>{$(Y,K,(u)=>{if(u)m(u);else F()})})}j.exports=$,j.exports.finished=n}}),XQ=Bq({"node_modules/readable-stream/lib/internal/streams/operators.js"(a,j){var{codes:{ERR_INVALID_ARG_TYPE:B,ERR_MISSING_ARGS:G,ERR_OUT_OF_RANGE:y},AbortError:A}=Wq(),{validateAbortSignal:M,validateInteger:R,validateObject:P}=Cq(),g=Vq().Symbol("kWeak"),{finished:k}=Fq(),{ArrayPrototypePush:c,MathFloor:O,Number:l,NumberIsNaN:D,Promise:p,PromiseReject:E,PromisePrototypeCatch:I,Symbol:Z}=Vq(),U=Z("kEmpty"),T=Z("kEof");function _(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);if(W!=null)P(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");let b=1;if((W===null||W===void 0?void 0:W.concurrency)!=null)b=O(W.concurrency);return R(b,"concurrency",1),async function*o(){var s,e;const Hq=new AbortController,$q=this,qq=[],Kq=Hq.signal,Qq={signal:Kq},V=()=>Hq.abort();if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)V();W===null||W===void 0||(e=W.signal)===null||e===void 0||e.addEventListener("abort",V);let h,Q,H=!1;function L(){H=!0}async function d(){try{for await(let q of $q){var f;if(H)return;if(Kq.aborted)throw new A;try{q=N(q,Qq)}catch(X){q=E(X)}if(q===U)continue;if(typeof((f=q)===null||f===void 0?void 0:f.catch)==="function")q.catch(L);if(qq.push(q),h)h(),h=null;if(!H&&qq.length&&qq.length>=b)await new p((X)=>{Q=X})}qq.push(T)}catch(q){const X=E(q);I(X,L),qq.push(X)}finally{var r;if(H=!0,h)h(),h=null;W===null||W===void 0||(r=W.signal)===null||r===void 0||r.removeEventListener("abort",V)}}d();try{while(!0){while(qq.length>0){const f=await qq[0];if(f===T)return;if(Kq.aborted)throw new A;if(f!==U)yield f;if(qq.shift(),Q)Q(),Q=null}await new p((f)=>{h=f})}}finally{if(Hq.abort(),H=!0,Q)Q(),Q=null}}.call(this)}function t(N=void 0){if(N!=null)P(N,"options");if((N===null||N===void 0?void 0:N.signal)!=null)M(N.signal,"options.signal");return async function*W(){let b=0;for await(let s of this){var o;if(N!==null&&N!==void 0&&(o=N.signal)!==null&&o!==void 0&&o.aborted)throw new A({cause:N.signal.reason});yield[b++,s]}}.call(this)}async function i(N,W=void 0){for await(let b of K.call(this,N,W))return!0;return!1}async function $(N,W=void 0){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);return!await i.call(this,async(...b)=>{return!await N(...b)},W)}async function n(N,W){for await(let b of K.call(this,N,W))return b;return}async function Y(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);async function b(o,s){return await N(o,s),U}for await(let o of _.call(this,b,W));}function K(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);async function b(o,s){if(await N(o,s))return o;return U}return _.call(this,b,W)}var F=class extends G{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function m(N,W,b){var o;if(typeof N!=="function")throw new B("reducer",["Function","AsyncFunction"],N);if(b!=null)P(b,"options");if((b===null||b===void 0?void 0:b.signal)!=null)M(b.signal,"options.signal");let s=arguments.length>1;if(b!==null&&b!==void 0&&(o=b.signal)!==null&&o!==void 0&&o.aborted){const Kq=new A(void 0,{cause:b.signal.reason});throw this.once("error",()=>{}),await k(this.destroy(Kq)),Kq}const e=new AbortController,Hq=e.signal;if(b!==null&&b!==void 0&&b.signal){const Kq={once:!0,[g]:this};b.signal.addEventListener("abort",()=>e.abort(),Kq)}let $q=!1;try{for await(let Kq of this){var qq;if($q=!0,b!==null&&b!==void 0&&(qq=b.signal)!==null&&qq!==void 0&&qq.aborted)throw new A;if(!s)W=Kq,s=!0;else W=await N(W,Kq,{signal:Hq})}if(!$q&&!s)throw new F}finally{e.abort()}return W}async function u(N){if(N!=null)P(N,"options");if((N===null||N===void 0?void 0:N.signal)!=null)M(N.signal,"options.signal");const W=[];for await(let o of this){var b;if(N!==null&&N!==void 0&&(b=N.signal)!==null&&b!==void 0&&b.aborted)throw new A(void 0,{cause:N.signal.reason});c(W,o)}return W}function J(N,W){const b=_.call(this,N,W);return async function*o(){for await(let s of b)yield*s}.call(this)}function z(N){if(N=l(N),D(N))return 0;if(N<0)throw new y("number",">= 0",N);return N}function w(N,W=void 0){if(W!=null)P(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");return N=z(N),async function*b(){var o;if(W!==null&&W!==void 0&&(o=W.signal)!==null&&o!==void 0&&o.aborted)throw new A;for await(let e of this){var s;if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)throw new A;if(N--<=0)yield e}}.call(this)}function S(N,W=void 0){if(W!=null)P(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");return N=z(N),async function*b(){var o;if(W!==null&&W!==void 0&&(o=W.signal)!==null&&o!==void 0&&o.aborted)throw new A;for await(let e of this){var s;if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)throw new A;if(N-- >0)yield e;else return}}.call(this)}j.exports.streamReturningOperators={asIndexedPairs:t,drop:w,filter:K,flatMap:J,map:_,take:S},j.exports.promiseReturningOperators={every:$,forEach:Y,reduce:m,toArray:u,some:i,find:n}}}),Tq=Bq({"node_modules/readable-stream/lib/internal/streams/destroy.js"(a,j){var{aggregateTwoErrors:B,codes:{ERR_MULTIPLE_CALLBACK:G},AbortError:y}=Wq(),{Symbol:A}=Vq(),{kDestroyed:M,isDestroyed:R,isFinished:P,isServerRequest:g}=Eq(),k="#kDestroy",c="#kConstruct";function O(K,F,m){if(K){if(K.stack,F&&!F.errored)F.errored=K;if(m&&!m.errored)m.errored=K}}function l(K,F){const m=this._readableState,u=this._writableState,J=u||m;if(u&&u.destroyed||m&&m.destroyed){if(typeof F==="function")F();return this}if(O(K,u,m),u)u.destroyed=!0;if(m)m.destroyed=!0;if(!J.constructed)this.once(k,(z)=>{D(this,B(z,K),F)});else D(this,K,F);return this}function D(K,F,m){let u=!1;function J(z){if(u)return;u=!0;const{_readableState:w,_writableState:S}=K;if(O(z,S,w),S)S.closed=!0;if(w)w.closed=!0;if(typeof m==="function")m(z);if(z)Xq(p,K,z);else Xq(E,K)}try{K._destroy(F||null,J)}catch(z){J(z)}}function p(K,F){I(K,F),E(K)}function E(K){const{_readableState:F,_writableState:m}=K;if(m)m.closeEmitted=!0;if(F)F.closeEmitted=!0;if(m&&m.emitClose||F&&F.emitClose)K.emit("close")}function I(K,F){const m=K?._readableState,u=K?._writableState;if(u?.errorEmitted||m?.errorEmitted)return;if(u)u.errorEmitted=!0;if(m)m.errorEmitted=!0;K?.emit?.("error",F)}function Z(){const K=this._readableState,F=this._writableState;if(K)K.constructed=!0,K.closed=!1,K.closeEmitted=!1,K.destroyed=!1,K.errored=null,K.errorEmitted=!1,K.reading=!1,K.ended=K.readable===!1,K.endEmitted=K.readable===!1;if(F)F.constructed=!0,F.destroyed=!1,F.closed=!1,F.closeEmitted=!1,F.errored=null,F.errorEmitted=!1,F.finalCalled=!1,F.prefinished=!1,F.ended=F.writable===!1,F.ending=F.writable===!1,F.finished=F.writable===!1}function U(K,F,m){const u=K?._readableState,J=K?._writableState;if(J&&J.destroyed||u&&u.destroyed)return this;if(u&&u.autoDestroy||J&&J.autoDestroy)K.destroy(F);else if(F){if(Error.captureStackTrace(F),J&&!J.errored)J.errored=F;if(u&&!u.errored)u.errored=F;if(m)Xq(I,K,F);else I(K,F)}}function T(K,F){if(typeof K._construct!=="function")return;const{_readableState:m,_writableState:u}=K;if(m)m.constructed=!1;if(u)u.constructed=!1;if(K.once(c,F),K.listenerCount(c)>1)return;Xq(_,K)}function _(K){let F=!1;function m(u){if(F){U(K,u!==null&&u!==void 0?u:new G);return}F=!0;const{_readableState:J,_writableState:z}=K,w=z||J;if(J)J.constructed=!0;if(z)z.constructed=!0;if(w.destroyed)K.emit(k,u);else if(u)U(K,u,!0);else Xq(t,K)}try{K._construct(m)}catch(u){m(u)}}function t(K){K.emit(c)}function i(K){return K&&K.setHeader&&typeof K.abort==="function"}function $(K){K.emit("close")}function n(K,F){K.emit("error",F),Xq($,K)}function Y(K,F){if(!K||R(K))return;if(!F&&!P(K))F=new y;if(g(K))K.socket=null,K.destroy(F);else if(i(K))K.abort();else if(i(K.req))K.req.abort();else if(typeof K.destroy==="function")K.destroy(F);else if(typeof K.close==="function")K.close();else if(F)Xq(n,K);else Xq($,K);if(!K.destroyed)K[M]=!0}j.exports={construct:T,destroyer:Y,destroy:l,undestroy:Z,errorOrDestroy:U}}}),Rq=Bq({"node_modules/readable-stream/lib/internal/streams/legacy.js"(a,j){var{ArrayIsArray:B,ObjectSetPrototypeOf:G}=Vq();function y(M){if(!(this instanceof y))return new y(M);Iq.call(this,M)}G(y.prototype,Iq.prototype),G(y,Iq),y.prototype.pipe=function(M,R){const P=this;function g(E){if(M.writable&&M.write(E)===!1&&P.pause)P.pause()}P.on("data",g);function k(){if(P.readable&&P.resume)P.resume()}if(M.on("drain",k),!M._isStdio&&(!R||R.end!==!1))P.on("end",O),P.on("close",l);let c=!1;function O(){if(c)return;c=!0,M.end()}function l(){if(c)return;if(c=!0,typeof M.destroy==="function")M.destroy()}function D(E){if(p(),Iq.listenerCount(this,"error")===0)this.emit("error",E)}A(P,"error",D),A(M,"error",D);function p(){P.removeListener("data",g),M.removeListener("drain",k),P.removeListener("end",O),P.removeListener("close",l),P.removeListener("error",D),M.removeListener("error",D),P.removeListener("end",p),P.removeListener("close",p),M.removeListener("close",p)}return P.on("end",p),P.on("close",p),M.on("close",p),M.emit("pipe",P),M};function A(M,R,P){if(typeof M.prependListener==="function")return M.prependListener(R,P);if(!M._events||!M._events[R])M.on(R,P);else if(B(M._events[R]))M._events[R].unshift(P);else M._events[R]=[P,M._events[R]]}j.exports={Stream:y,prependListener:A}}}),Sq=Bq({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(a,j){var{AbortError:B,codes:G}=Wq(),y=Fq(),{ERR_INVALID_ARG_TYPE:A}=G,M=(P,g)=>{if(typeof P!=="object"||!("aborted"in P))throw new A(g,"AbortSignal",P)};function R(P){return!!(P&&typeof P.pipe==="function")}j.exports.addAbortSignal=function P(g,k){if(M(g,"signal"),!R(k))throw new A("stream","stream.Stream",k);return j.exports.addAbortSignalNoValidate(g,k)},j.exports.addAbortSignalNoValidate=function(P,g){if(typeof P!=="object"||!("aborted"in P))return g;const k=()=>{g.destroy(new B(void 0,{cause:P.reason}))};if(P.aborted)k();else P.addEventListener("abort",k),y(g,()=>P.removeEventListener("abort",k));return g}}}),JQ=Bq({"node_modules/readable-stream/lib/internal/streams/state.js"(a,j){var{MathFloor:B,NumberIsInteger:G}=Vq(),{ERR_INVALID_ARG_VALUE:y}=Wq().codes;function A(P,g,k){return P.highWaterMark!=null?P.highWaterMark:g?P[k]:null}function M(P){return P?16:16384}function R(P,g,k,c){const O=A(g,c,k);if(O!=null){if(!G(O)||O<0){const l=c?`options.${k}`:"options.highWaterMark";throw new y(l,O)}return B(O)}return M(P.objectMode)}j.exports={getHighWaterMark:R,getDefaultHighWaterMark:M}}}),hq=Bq({"node_modules/readable-stream/lib/internal/streams/from.js"(a,j){var{PromisePrototypeThen:B,SymbolAsyncIterator:G,SymbolIterator:y}=Vq(),{ERR_INVALID_ARG_TYPE:A,ERR_STREAM_NULL_VALUES:M}=Wq().codes;function R(P,g,k){let c;if(typeof g==="string"||g instanceof Buffer)return new P({objectMode:!0,...k,read(){this.push(g),this.push(null)}});let O;if(g&&g[G])O=!0,c=g[G]();else if(g&&g[y])O=!1,c=g[y]();else throw new A("iterable",["Iterable"],g);const l=new P({objectMode:!0,highWaterMark:1,...k});let D=!1;l._read=function(){if(!D)D=!0,E()},l._destroy=function(I,Z){B(p(I),()=>Xq(Z,I),(U)=>Xq(Z,U||I))};async function p(I){const Z=I!==void 0&&I!==null,U=typeof c.throw==="function";if(Z&&U){const{value:T,done:_}=await c.throw(I);if(await T,_)return}if(typeof c.return==="function"){const{value:T}=await c.return();await T}}async function E(){for(;;){try{const{value:I,done:Z}=O?await c.next():c.next();if(Z)l.push(null);else{const U=I&&typeof I.then==="function"?await I:I;if(U===null)throw D=!1,new M;else if(l.push(U))continue;else D=!1}}catch(I){l.destroy(I)}break}}return l}j.exports=R}}),pq,uq,_q=Bq({"node_modules/readable-stream/lib/internal/streams/readable.js"(a,j){var{ArrayPrototypeIndexOf:B,NumberIsInteger:G,NumberIsNaN:y,NumberParseInt:A,ObjectDefineProperties:M,ObjectKeys:R,ObjectSetPrototypeOf:P,Promise:g,SafeSet:k,SymbolAsyncIterator:c,Symbol:O}=Vq(),l=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{Stream:D,prependListener:p}=Rq();function E(q){if(!(this instanceof E))return new E(q);const X=this instanceof Mq();if(this._readableState=new l(q,this,X),q){const{read:C,destroy:x,construct:v,signal:Jq}=q;if(typeof C==="function")this._read=C;if(typeof x==="function")this._destroy=x;if(typeof v==="function")this._construct=v;if(Jq&&!X)U(Jq,this)}D.call(this,q),K.construct(this,()=>{if(this._readableState.needReadable)n(this,this._readableState)})}P(E.prototype,D.prototype),P(E,D),E.prototype.on=function(q,X){const C=D.prototype.on.call(this,q,X),x=this._readableState;if(q==="data"){if(x.readableListening=this.listenerCount("readable")>0,x.flowing!==!1)this.resume()}else if(q==="readable"){if(!x.endEmitted&&!x.readableListening){if(x.readableListening=x.needReadable=!0,x.flowing=!1,x.emittedReadable=!1,x.length)Y(this,x);else if(!x.reading)Xq(Qq,this)}else if(x.endEmitted);}return C};class I extends E{#q;#Q;#X;#H;constructor(q,X){const{objectMode:C,highWaterMark:x,encoding:v,signal:Jq}=q;super({objectMode:C,highWaterMark:x,encoding:v,signal:Jq});this.#X=[],this.#q=void 0,this.#H=X,this.#Q=!1}#J(){var q=this.#X,X=0,C=q.length;for(;X0)this.#X=[];return!1}#K(q){q.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){var q=this.#H,X=this.#q;if(q)X=this.#q=q.getReader(),this.#H=void 0;else if(this.#J())return;var C;try{do{var x=!1,v;const Jq=X.readMany();if(xq(Jq)){if({done:x,value:v}=await Jq,this.#Q){this.#X.push(...v);return}}else({done:x,value:v}=Jq);if(x){this.#K(X);return}if(!this.push(v[0])){this.#X=v.slice(1);return}for(let Zq=1,Oq=v.length;Zq{this.#Q=!0,X(q)});return}try{X(q)}catch(x){globalThis.reportError(x)}}}uq=I;function Z(q,X={}){if(!tq(q))throw new m("readableStream","ReadableStream",q);S(X,"options");const{highWaterMark:C,encoding:x,objectMode:v=!1,signal:Jq}=X;if(x!==void 0&&!Buffer.isEncoding(x))throw new QQ(x,"options.encoding");return eq(v,"options.objectMode"),zQ(E,q,X)||new I({highWaterMark:C,encoding:x,objectMode:v,signal:Jq},q)}j.exports=E,pq=Z;var{addAbortSignal:U}=Sq(),T=Fq();const{maybeReadMore:_,resume:t,emitReadable:i,onEofChunk:$}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function n(q,X){process.nextTick(_,q,X)}function Y(q,X){i(q,X)}var K=Tq(),{aggregateTwoErrors:F,codes:{ERR_INVALID_ARG_TYPE:m,ERR_METHOD_NOT_IMPLEMENTED:u,ERR_OUT_OF_RANGE:J,ERR_STREAM_PUSH_AFTER_EOF:z,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:w}}=Wq(),{validateObject:S}=Cq(),N=hq(),W=()=>{},{errorOrDestroy:b}=K;E.prototype.destroy=K.destroy,E.prototype._undestroy=K.undestroy,E.prototype._destroy=function(q,X){X(q)},E.prototype[Iq.captureRejectionSymbol]=function(q){this.destroy(q)},E.prototype.push=function(q,X){return o(this,q,X,!1)},E.prototype.unshift=function(q,X){return o(this,q,X,!0)};function o(q,X,C,x){const v=q._readableState;let Jq;if(!v.objectMode){if(typeof X==="string"){if(C=C||v.defaultEncoding,v.encoding!==C)if(x&&v.encoding)X=Buffer.from(X,C).toString(v.encoding);else X=Buffer.from(X,C),C=""}else if(X instanceof Buffer)C="";else if(D._isUint8Array(X)){if(x||!v.decoder)X=D._uint8ArrayToBuffer(X);C=""}else if(X!=null)Jq=new m("chunk",["string","Buffer","Uint8Array"],X)}if(Jq)b(q,Jq);else if(X===null)v.reading=!1,$(q,v);else if(v.objectMode||X&&X.length>0)if(x)if(v.endEmitted)b(q,new w);else if(v.destroyed||v.errored)return!1;else s(q,v,X,!0);else if(v.ended)b(q,new z);else if(v.destroyed||v.errored)return!1;else if(v.reading=!1,v.decoder&&!C)if(X=v.decoder.write(X),v.objectMode||X.length!==0)s(q,v,X,!1);else n(q,v);else s(q,v,X,!1);else if(!x)v.reading=!1,n(q,v);return!v.ended&&(v.length0){if(X.multiAwaitDrain)X.awaitDrainWriters.clear();else X.awaitDrainWriters=null;X.dataEmitted=!0,q.emit("data",C)}else{if(X.length+=X.objectMode?1:C.length,x)X.buffer.unshift(C);else X.buffer.push(C);if(X.needReadable)Y(q,X)}n(q,X)}E.prototype.isPaused=function(){const q=this._readableState;return q.paused===!0||q.flowing===!1},E.prototype.setEncoding=function(q){const X=new aq(q);this._readableState.decoder=X,this._readableState.encoding=this._readableState.decoder.encoding;const C=this._readableState.buffer;let x="";for(let v=C.length;v>0;v--)x+=X.write(C.shift());if(x!=="")C.push(x);return this._readableState.length=x.length,this};var e=1073741824;function Hq(q){if(q>e)throw new J("size","<= 1GiB",q);else q--,q|=q>>>1,q|=q>>>2,q|=q>>>4,q|=q>>>8,q|=q>>>16,q++;return q}function $q(q,X){if(q<=0||X.length===0&&X.ended)return 0;if(X.objectMode)return 1;if(y(q)){if(X.flowing&&X.length)return X.buffer.first().length;return X.length}if(q<=X.length)return q;return X.ended?X.length:0}E.prototype.read=function(q){if(!G(q))q=A(q,10);const X=this._readableState,C=q;if(q>X.highWaterMark)X.highWaterMark=Hq(q);if(q!==0)X.emittedReadable=!1;if(q===0&&X.needReadable&&((X.highWaterMark!==0?X.length>=X.highWaterMark:X.length>0)||X.ended)){if(X.length===0&&X.ended)H(this);else Y(this,X);return null}if(q=$q(q,X),q===0&&X.ended){if(X.length===0)H(this);return null}let x=X.needReadable;if(X.length===0||X.length-q0)Jq=Q(q,X);else Jq=null;if(Jq===null)X.needReadable=X.length<=X.highWaterMark,q=0;else if(X.length-=q,X.multiAwaitDrain)X.awaitDrainWriters.clear();else X.awaitDrainWriters=null;if(X.length===0){if(!X.ended)X.needReadable=!0;if(C!==q&&X.ended)H(this)}if(Jq!==null&&!X.errorEmitted&&!X.closeEmitted)X.dataEmitted=!0,this.emit("data",Jq);return Jq},E.prototype._read=function(q){throw new u("_read()")},E.prototype.pipe=function(q,X){const C=this,x=this._readableState;if(x.pipes.length===1){if(!x.multiAwaitDrain)x.multiAwaitDrain=!0,x.awaitDrainWriters=new k(x.awaitDrainWriters?[x.awaitDrainWriters]:[])}x.pipes.push(q);const Jq=(!X||X.end!==!1)&&q!==process.stdout&&q!==process.stderr?Oq:Pq;if(x.endEmitted)Xq(Jq);else C.once("end",Jq);q.on("unpipe",Zq);function Zq(jq,Nq){if(jq===C){if(Nq&&Nq.hasUnpiped===!1)Nq.hasUnpiped=!0,nq()}}function Oq(){q.end()}let Lq,kq=!1;function nq(){if(q.removeListener("close",wq),q.removeListener("finish",vq),Lq)q.removeListener("drain",Lq);if(q.removeListener("error",Dq),q.removeListener("unpipe",Zq),C.removeListener("end",Oq),C.removeListener("end",Pq),C.removeListener("data",yq),kq=!0,Lq&&x.awaitDrainWriters&&(!q._writableState||q._writableState.needDrain))Lq()}function fq(){if(!kq){if(x.pipes.length===1&&x.pipes[0]===q)x.awaitDrainWriters=q,x.multiAwaitDrain=!1;else if(x.pipes.length>1&&x.pipes.includes(q))x.awaitDrainWriters.add(q);C.pause()}if(!Lq)Lq=qq(C,q),q.on("drain",Lq)}C.on("data",yq);function yq(jq){if(q.write(jq)===!1)fq()}function Dq(jq){if(Gq("onerror",jq),Pq(),q.removeListener("error",Dq),q.listenerCount("error")===0){const Nq=q._writableState||q._readableState;if(Nq&&!Nq.errorEmitted)b(q,jq);else q.emit("error",jq)}}p(q,"error",Dq);function wq(){q.removeListener("finish",vq),Pq()}q.once("close",wq);function vq(){Gq("onfinish"),q.removeListener("close",wq),Pq()}q.once("finish",vq);function Pq(){Gq("unpipe"),C.unpipe(q)}if(q.emit("pipe",C),q.writableNeedDrain===!0){if(x.flowing)fq()}else if(!x.flowing)Gq("pipe resume"),C.resume();return q};function qq(q,X){return function C(){const x=q._readableState;if(x.awaitDrainWriters===X)Gq("pipeOnDrain",1),x.awaitDrainWriters=null;else if(x.multiAwaitDrain)Gq("pipeOnDrain",x.awaitDrainWriters.size),x.awaitDrainWriters.delete(X);if((!x.awaitDrainWriters||x.awaitDrainWriters.size===0)&&q.listenerCount("data"))q.resume()}}E.prototype.unpipe=function(q){const X=this._readableState,C={hasUnpiped:!1};if(X.pipes.length===0)return this;if(!q){const v=X.pipes;X.pipes=[],this.pause();for(let Jq=0;Jq0,X.resumeScheduled&&X.paused===!1)X.flowing=!0;else if(q.listenerCount("data")>0)q.resume();else if(!X.readableListening)X.flowing=null}function Qq(q){q.read(0)}E.prototype.resume=function(){const q=this._readableState;if(!q.flowing)q.flowing=!q.readableListening,t(this,q);return q.paused=!1,this},E.prototype.pause=function(){if(this._readableState.flowing!==!1)this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},E.prototype.wrap=function(q){let X=!1;q.on("data",(x)=>{if(!this.push(x)&&q.pause)X=!0,q.pause()}),q.on("end",()=>{this.push(null)}),q.on("error",(x)=>{b(this,x)}),q.on("close",()=>{this.destroy()}),q.on("destroy",()=>{this.destroy()}),this._read=()=>{if(X&&q.resume)X=!1,q.resume()};const C=R(q);for(let x=1;x{v=Zq?F(v,Zq):null,C(),C=W});try{while(!0){const Zq=q.destroyed?null:q.read();if(Zq!==null)yield Zq;else if(v)throw v;else if(v===null)return;else await new g(x)}}catch(Zq){throw v=F(v,Zq),v}finally{if((v||(X===null||X===void 0?void 0:X.destroyOnReturn)!==!1)&&(v===void 0||q._readableState.autoDestroy))K.destroyer(q,null);else q.off("readable",x),Jq()}}M(E.prototype,{readable:{get(){const q=this._readableState;return!!q&&q.readable!==!1&&!q.destroyed&&!q.errorEmitted&&!q.endEmitted},set(q){if(this._readableState)this._readableState.readable=!!q}},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(q){if(this._readableState)this._readableState.flowing=q}},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(q){if(!this._readableState)return;this._readableState.destroyed=q}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),E._fromList=Q;function Q(q,X){if(X.length===0)return null;let C;if(X.objectMode)C=X.buffer.shift();else if(!q||q>=X.length){if(X.decoder)C=X.buffer.join("");else if(X.buffer.length===1)C=X.buffer.first();else C=X.buffer.concat(X.length);X.buffer.clear()}else C=X.buffer.consume(q,X.decoder);return C}function H(q){const X=q._readableState;if(!X.endEmitted)X.ended=!0,Xq(L,X,q)}function L(q,X){if(!q.errored&&!q.closeEmitted&&!q.endEmitted&&q.length===0){if(q.endEmitted=!0,X.emit("end"),X.writable&&X.allowHalfOpen===!1)Xq(d,X);else if(q.autoDestroy){const C=X._writableState;if(!C||C.autoDestroy&&(C.finished||C.writable===!1))X.destroy()}}}function d(q){if(q.writable&&!q.writableEnded&&!q.destroyed)q.end()}E.from=function(q,X){return N(E,q,X)};var f={newStreamReadableFromReadableStream:Z};function r(){if(f===void 0)f={};return f}E.fromWeb=function(q,X){return r().newStreamReadableFromReadableStream(q,X)},E.toWeb=function(q){return r().newReadableStreamFromStreamReadable(q)},E.wrap=function(q,X){var C,x;return new E({objectMode:(C=(x=q.readableObjectMode)!==null&&x!==void 0?x:q.objectMode)!==null&&C!==void 0?C:!0,...X,destroy(v,Jq){K.destroyer(q,v),Jq(v)}}).wrap(q)}}}),bq=Bq({"node_modules/readable-stream/lib/internal/streams/writable.js"(a,j){var{ArrayPrototypeSlice:B,Error:G,FunctionPrototypeSymbolHasInstance:y,ObjectDefineProperty:A,ObjectDefineProperties:M,ObjectSetPrototypeOf:R,StringPrototypeToLowerCase:P,Symbol:g,SymbolHasInstance:k}=Vq(),c=Rq().Stream,O=Tq(),{addAbortSignal:l}=Sq(),{getHighWaterMark:D,getDefaultHighWaterMark:p}=JQ(),{ERR_INVALID_ARG_TYPE:E,ERR_METHOD_NOT_IMPLEMENTED:I,ERR_MULTIPLE_CALLBACK:Z,ERR_STREAM_CANNOT_PIPE:U,ERR_STREAM_DESTROYED:T,ERR_STREAM_ALREADY_FINISHED:_,ERR_STREAM_NULL_VALUES:t,ERR_STREAM_WRITE_AFTER_END:i,ERR_UNKNOWN_ENCODING:$}=Wq().codes,{errorOrDestroy:n}=O;function Y(Q={}){const H=this instanceof Mq();if(!H&&!y(Y,this))return new Y(Q);if(this._writableState=new m(Q,this,H),Q){if(typeof Q.write==="function")this._write=Q.write;if(typeof Q.writev==="function")this._writev=Q.writev;if(typeof Q.destroy==="function")this._destroy=Q.destroy;if(typeof Q.final==="function")this._final=Q.final;if(typeof Q.construct==="function")this._construct=Q.construct;if(Q.signal)l(Q.signal,this)}c.call(this,Q),O.construct(this,()=>{const L=this._writableState;if(!L.writing)s(this,L);qq(this,L)})}R(Y.prototype,c.prototype),R(Y,c),j.exports=Y;function K(){}var F=g("kOnFinished");function m(Q,H,L){if(typeof L!=="boolean")L=H instanceof Mq();if(this.objectMode=!!(Q&&Q.objectMode),L)this.objectMode=this.objectMode||!!(Q&&Q.writableObjectMode);this.highWaterMark=Q?D(this,Q,"writableHighWaterMark",L):p(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const d=!!(Q&&Q.decodeStrings===!1);this.decodeStrings=!d,this.defaultEncoding=Q&&Q.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=N.bind(void 0,H),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,u(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!Q||Q.emitClose!==!1,this.autoDestroy=!Q||Q.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[F]=[]}function u(Q){Q.buffered=[],Q.bufferedIndex=0,Q.allBuffers=!0,Q.allNoop=!0}m.prototype.getBuffer=function Q(){return B(this.buffered,this.bufferedIndex)},A(m.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),A(Y,k,{value:function(Q){if(y(this,Q))return!0;if(this!==Y)return!1;return Q&&Q._writableState instanceof m}}),Y.prototype.pipe=function(){n(this,new U)};function J(Q,H,L,d){const f=Q._writableState;if(typeof L==="function")d=L,L=f.defaultEncoding;else{if(!L)L=f.defaultEncoding;else if(L!=="buffer"&&!Buffer.isEncoding(L))throw new $(L);if(typeof d!=="function")d=K}if(H===null)throw new t;else if(!f.objectMode)if(typeof H==="string"){if(f.decodeStrings!==!1)H=Buffer.from(H,L),L="buffer"}else if(H instanceof Buffer)L="buffer";else if(c._isUint8Array(H))H=c._uint8ArrayToBuffer(H),L="buffer";else throw new E("chunk",["string","Buffer","Uint8Array"],H);let r;if(f.ending)r=new i;else if(f.destroyed)r=new T("write");if(r)return Xq(d,r),n(Q,r,!0),r;return f.pendingcb++,z(Q,f,H,L,d)}Y.prototype.write=function(Q,H,L){return J(this,Q,H,L)===!0},Y.prototype.cork=function(){this._writableState.corked++},Y.prototype.uncork=function(){const Q=this._writableState;if(Q.corked){if(Q.corked--,!Q.writing)s(this,Q)}},Y.prototype.setDefaultEncoding=function Q(H){if(typeof H==="string")H=P(H);if(!Buffer.isEncoding(H))throw new $(H);return this._writableState.defaultEncoding=H,this};function z(Q,H,L,d,f){const r=H.objectMode?1:L.length;H.length+=r;const q=H.lengthL.bufferedIndex)s(Q,L);if(d)if(L.afterWriteTickInfo!==null&&L.afterWriteTickInfo.cb===f)L.afterWriteTickInfo.count++;else L.afterWriteTickInfo={count:1,cb:f,stream:Q,state:L},Xq(W,L.afterWriteTickInfo);else b(Q,L,1,f)}}function W({stream:Q,state:H,count:L,cb:d}){return H.afterWriteTickInfo=null,b(Q,H,L,d)}function b(Q,H,L,d){if(!H.ending&&!Q.destroyed&&H.length===0&&H.needDrain)H.needDrain=!1,Q.emit("drain");while(L-- >0)H.pendingcb--,d();if(H.destroyed)o(H);qq(Q,H)}function o(Q){if(Q.writing)return;for(let f=Q.bufferedIndex;f1&&Q._writev){H.pendingcb-=r-1;const X=H.allNoop?K:(x)=>{for(let v=q;v256)L.splice(0,q),H.bufferedIndex=0;else H.bufferedIndex=q}H.bufferProcessing=!1}Y.prototype._write=function(Q,H,L){if(this._writev)this._writev([{chunk:Q,encoding:H}],L);else throw new I("_write()")},Y.prototype._writev=null,Y.prototype.end=function(Q,H,L,d=!1){const f=this._writableState;if(typeof Q==="function")L=Q,Q=null,H=null;else if(typeof H==="function")L=H,H=null;let r;if(Q!==null&&Q!==void 0){let q;if(!d)q=J(this,Q,H);else q=this.write(Q,H);if(q instanceof G)r=q}if(f.corked)f.corked=1,this.uncork();if(r)this.emit("error",r);else if(!f.errored&&!f.ending)f.ending=!0,qq(this,f,!0),f.ended=!0;else if(f.finished)r=new _("end");else if(f.destroyed)r=new T("end");if(typeof L==="function")if(r||f.finished)Xq(L,r);else f[F].push(L);return this};function e(Q,H){var L=Q.ending&&!Q.destroyed&&Q.constructed&&Q.length===0&&!Q.errored&&Q.buffered.length===0&&!Q.finished&&!Q.writing&&!Q.errorEmitted&&!Q.closeEmitted;return Gq("needFinish",L,H),L}function Hq(Q,H){let L=!1;function d(f){if(L){n(Q,f!==null&&f!==void 0?f:Z());return}if(L=!0,H.pendingcb--,f){const r=H[F].splice(0);for(let q=0;q{if(e(f))Kq(d,f);else f.pendingcb--},Q,H);else if(e(H))H.pendingcb++,Kq(Q,H)}}function Kq(Q,H){H.pendingcb--,H.finished=!0;const L=H[F].splice(0);for(let d=0;d{if(S!=null)throw new O("nully","body",S)},(S)=>{l(z,S)});return z=new T({objectMode:!0,readable:!1,write:F,final(S){m(async()=>{try{await w,Xq(S,null)}catch(N){Xq(S,N)}})},destroy:u})}throw new O("Iterable, AsyncIterable or AsyncFunction",n,K)}if(Z($))return i($.arrayBuffer());if(y($))return I(T,$,{objectMode:!0,writable:!1});if(typeof($===null||$===void 0?void 0:$.writable)==="object"||typeof($===null||$===void 0?void 0:$.readable)==="object"){const K=$!==null&&$!==void 0&&$.readable?M($===null||$===void 0?void 0:$.readable)?$===null||$===void 0?void 0:$.readable:i($.readable):void 0,F=$!==null&&$!==void 0&&$.writable?R($===null||$===void 0?void 0:$.writable)?$===null||$===void 0?void 0:$.writable:i($.writable):void 0;return t({readable:K,writable:F})}const Y=$===null||$===void 0?void 0:$.then;if(typeof Y==="function"){let K;return U(Y,$,(F)=>{if(F!=null)K.push(F);K.push(null)},(F)=>{l(K,F)}),K=new T({objectMode:!0,writable:!1,read(){}})}throw new c(n,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],$)};function _(i){let{promise:$,resolve:n}=E();const Y=new AbortController,K=Y.signal;return{value:i(async function*(){while(!0){const m=$;$=null;const{chunk:u,done:J,cb:z}=await m;if(Xq(z),J)return;if(K.aborted)throw new k(void 0,{cause:K.reason});({promise:$,resolve:n}=E()),yield u}}(),{signal:K}),write(m,u,J){const z=n;n=null,z({chunk:m,done:!1,cb:J})},final(m){const u=n;n=null,u({done:!0,cb:m})},destroy(m,u){Y.abort(),u(m)}}}function t(i){const $=i.readable&&typeof i.readable.read!=="function"?p.wrap(i.readable):i.readable,n=i.writable;let Y=!!B($),K=!!G(n),F,m,u,J,z;function w(S){const N=J;if(J=null,N)N(S);else if(S)z.destroy(S);else if(!Y&&!K)z.destroy()}if(z=new T({readableObjectMode:!!($!==null&&$!==void 0&&$.readableObjectMode),writableObjectMode:!!(n!==null&&n!==void 0&&n.writableObjectMode),readable:Y,writable:K}),K)g(n,(S)=>{if(K=!1,S)l($,S);w(S)}),z._write=function(S,N,W){if(n.write(S,N))W();else F=W},z._final=function(S){n.end(),m=S},n.on("drain",function(){if(F){const S=F;F=null,S()}}),n.on("finish",function(){if(m){const S=m;m=null,S()}});if(Y)g($,(S)=>{if(Y=!1,S)l($,S);w(S)}),$.on("readable",function(){if(u){const S=u;u=null,S()}}),$.on("end",function(){z.push(null)}),z._read=function(){while(!0){const S=$.read();if(S===null){u=z._read;return}if(!z.push(S))return}};return z._destroy=function(S,N){if(!S&&J!==null)S=new k;if(u=null,F=null,m=null,J===null)N(S);else J=N,l(n,S),l($,S)},z}}}),Mq=Bq({"node_modules/readable-stream/lib/internal/streams/duplex.js"(a,j){var{ObjectDefineProperties:B,ObjectGetOwnPropertyDescriptor:G,ObjectKeys:y,ObjectSetPrototypeOf:A}=Vq(),M=_q();function R(O){if(!(this instanceof R))return new R(O);if(M.call(this,O),Uq.call(this,O),O){if(this.allowHalfOpen=O.allowHalfOpen!==!1,O.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(O.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}j.exports=R,A(R.prototype,M.prototype),A(R,M);for(var P in Uq.prototype)if(!R.prototype[P])R.prototype[P]=Uq.prototype[P];B(R.prototype,{writable:G(Uq.prototype,"writable"),writableHighWaterMark:G(Uq.prototype,"writableHighWaterMark"),writableObjectMode:G(Uq.prototype,"writableObjectMode"),writableBuffer:G(Uq.prototype,"writableBuffer"),writableLength:G(Uq.prototype,"writableLength"),writableFinished:G(Uq.prototype,"writableFinished"),writableCorked:G(Uq.prototype,"writableCorked"),writableEnded:G(Uq.prototype,"writableEnded"),writableNeedDrain:G(Uq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(O){if(this._readableState&&this._writableState)this._readableState.destroyed=O,this._writableState.destroyed=O}}});var g;function k(){if(g===void 0)g={};return g}R.fromWeb=function(O,l){return k().newStreamDuplexFromReadableWritablePair(O,l)},R.toWeb=function(O){return k().newReadableWritablePairFromDuplex(O)};var c;R.from=function(O){if(!c)c=HQ();return c(O,"body")}}}),mq=Bq({"node_modules/readable-stream/lib/internal/streams/transform.js"(a,j){var{ObjectSetPrototypeOf:B,Symbol:G}=Vq(),{ERR_METHOD_NOT_IMPLEMENTED:y}=Wq().codes,A=Mq();function M(k){if(!(this instanceof M))return new M(k);if(A.call(this,k),this._readableState.sync=!1,this[R]=null,k){if(typeof k.transform==="function")this._transform=k.transform;if(typeof k.flush==="function")this._flush=k.flush}this.on("prefinish",g.bind(this))}B(M.prototype,A.prototype),B(M,A),j.exports=M;var R=G("kCallback");function P(k){if(typeof this._flush==="function"&&!this.destroyed)this._flush((c,O)=>{if(c){if(k)k(c);else this.destroy(c);return}if(O!=null)this.push(O);if(this.push(null),k)k()});else if(this.push(null),k)k()}function g(){if(this._final!==P)P.call(this)}M.prototype._final=P,M.prototype._transform=function(k,c,O){throw new y("_transform()")},M.prototype._write=function(k,c,O){const l=this._readableState,D=this._writableState,p=l.length;this._transform(k,c,(E,I)=>{if(E){O(E);return}if(I!=null)this.push(I);if(D.ended||p===l.length||l.length{S=!0});const N=A(J,{readable:z,writable:w},(W)=>{S=!W});return{destroy:(W)=>{if(S)return;S=!0,R.destroyer(J,W||new l("pipe"))},cleanup:N}}function $(J){return p(J[J.length-1],"streams[stream.length - 1]"),J.pop()}function n(J){if(I(J))return J;else if(U(J))return Y(J);throw new k("val",["Readable","Iterable","AsyncIterable"],J)}async function*Y(J){if(!t)t=_q();yield*t.prototype[y].call(J)}async function K(J,z,w,{end:S}){let N,W=null;const b=(e)=>{if(e)N=e;if(W){const Hq=W;W=null,Hq()}},o=()=>new G((e,Hq)=>{if(N)Hq(N);else W=()=>{if(N)Hq(N);else e()}});z.on("drain",b);const s=A(z,{readable:!1},b);try{if(z.writableNeedDrain)await o();for await(let e of J)if(!z.write(e))await o();if(S)z.end();await o(),w()}catch(e){w(N!==e?g(N,e):e)}finally{s(),z.off("drain",b)}}function F(...J){return m(J,M($(J)))}function m(J,z,w){if(J.length===1&&B(J[0]))J=J[0];if(J.length<2)throw new O("streams");const S=new AbortController,N=S.signal,W=w===null||w===void 0?void 0:w.signal,b=[];E(W,"options.signal");function o(){Kq(new D)}W===null||W===void 0||W.addEventListener("abort",o);let s,e;const Hq=[];let $q=0;function qq(h){Kq(h,--$q===0)}function Kq(h,Q){if(h&&(!s||s.code==="ERR_STREAM_PREMATURE_CLOSE"))s=h;if(!s&&!Q)return;while(Hq.length)Hq.shift()(s);if(W===null||W===void 0||W.removeEventListener("abort",o),S.abort(),Q){if(!s)b.forEach((H)=>H());Xq(z,s,e)}}let Qq;for(let h=0;h0,d=H||(w===null||w===void 0?void 0:w.end)!==!1,f=h===J.length-1;if(T(Q)){let r=function(q){if(q&&q.name!=="AbortError"&&q.code!=="ERR_STREAM_PREMATURE_CLOSE")qq(q)};if(d){const{destroy:q,cleanup:X}=i(Q,H,L);if(Hq.push(q),Z(Q)&&f)b.push(X)}if(Q.on("error",r),Z(Q)&&f)b.push(()=>{Q.removeListener("error",r)})}if(h===0)if(typeof Q==="function"){if(Qq=Q({signal:N}),!I(Qq))throw new c("Iterable, AsyncIterable or Stream","source",Qq)}else if(I(Q)||U(Q))Qq=Q;else Qq=P.from(Q);else if(typeof Q==="function")if(Qq=n(Qq),Qq=Q(Qq,{signal:N}),H){if(!I(Qq,!0))throw new c("AsyncIterable",`transform[${h-1}]`,Qq)}else{var V;if(!_)_=cq();const r=new _({objectMode:!0}),q=(V=Qq)===null||V===void 0?void 0:V.then;if(typeof q==="function")$q++,q.call(Qq,(x)=>{if(e=x,x!=null)r.write(x);if(d)r.end();Xq(qq)},(x)=>{r.destroy(x),Xq(qq,x)});else if(I(Qq,!0))$q++,K(Qq,r,qq,{end:d});else throw new c("AsyncIterable or Promise","destination",Qq);Qq=r;const{destroy:X,cleanup:C}=i(Qq,!1,!0);if(Hq.push(X),f)b.push(C)}else if(T(Q)){if(U(Qq)){$q+=2;const r=u(Qq,Q,qq,{end:d});if(Z(Q)&&f)b.push(r)}else if(I(Qq))$q++,K(Qq,Q,qq,{end:d});else throw new k("val",["Readable","Iterable","AsyncIterable"],Qq);Qq=Q}else Qq=P.from(Q)}if(N!==null&&N!==void 0&&N.aborted||W!==null&&W!==void 0&&W.aborted)Xq(o);return Qq}function u(J,z,w,{end:S}){if(J.pipe(z,{end:S}),S)J.once("end",()=>z.end());else w();return A(J,{readable:!0,writable:!1},(N)=>{const W=J._readableState;if(N&&N.code==="ERR_STREAM_PREMATURE_CLOSE"&&W&&W.ended&&!W.errored&&!W.errorEmitted)J.once("end",w).once("error",w);else w(N)}),A(z,{readable:!1,writable:!0},w)}j.exports={pipelineImpl:m,pipeline:F}}}),KQ=Bq({"node_modules/readable-stream/lib/internal/streams/compose.js"(a,j){var{pipeline:B}=gq(),G=Mq(),{destroyer:y}=Tq(),{isNodeStream:A,isReadable:M,isWritable:R}=Eq(),{AbortError:P,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:k}}=Wq();j.exports=function c(...O){if(O.length===0)throw new k("streams");if(O.length===1)return G.from(O[0]);const l=[...O];if(typeof O[0]==="function")O[0]=G.from(O[0]);if(typeof O[O.length-1]==="function"){const $=O.length-1;O[$]=G.from(O[$])}for(let $=0;$0&&!R(O[$]))throw new g(`streams[${$}]`,l[$],"must be writable")}let D,p,E,I,Z;function U($){const n=I;if(I=null,n)n($);else if($)Z.destroy($);else if(!i&&!t)Z.destroy()}const T=O[0],_=B(O,U),t=!!R(T),i=!!M(_);if(Z=new G({writableObjectMode:!!(T!==null&&T!==void 0&&T.writableObjectMode),readableObjectMode:!!(_!==null&&_!==void 0&&_.writableObjectMode),writable:t,readable:i}),t)Z._write=function($,n,Y){if(T.write($,n))Y();else D=Y},Z._final=function($){T.end(),p=$},T.on("drain",function(){if(D){const $=D;D=null,$()}}),_.on("finish",function(){if(p){const $=p;p=null,$()}});if(i)_.on("readable",function(){if(E){const $=E;E=null,$()}}),_.on("end",function(){Z.push(null)}),Z._read=function(){while(!0){const $=_.read();if($===null){E=Z._read;return}if(!Z.push($))return}};return Z._destroy=function($,n){if(!$&&I!==null)$=new P;if(E=null,D=null,p=null,I===null)n($);else I=n,y(_,$)},Z}}}),dq=Bq({"node_modules/readable-stream/lib/stream/promises.js"(a,j){var{ArrayPrototypePop:B,Promise:G}=Vq(),{isIterable:y,isNodeStream:A}=Eq(),{pipelineImpl:M}=gq(),{finished:R}=Fq();function P(...g){return new G((k,c)=>{let O,l;const D=g[g.length-1];if(D&&typeof D==="object"&&!A(D)&&!y(D)){const p=B(g);O=p.signal,l=p.end}M(g,(p,E)=>{if(p)c(p);else k(E)},{signal:O,end:l})})}j.exports={finished:R,pipeline:P}}}),ZQ=Bq({"node_modules/readable-stream/lib/stream.js"(a,j){var{ObjectDefineProperty:B,ObjectKeys:G,ReflectApply:y}=Vq(),{promisify:{custom:A}}=Aq(),{streamReturningOperators:M,promiseReturningOperators:R}=XQ(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:P}}=Wq(),g=KQ(),{pipeline:k}=gq(),{destroyer:c}=Tq(),O=Fq(),l=dq(),D=Eq(),p=j.exports=Rq().Stream;p.isDisturbed=D.isDisturbed,p.isErrored=D.isErrored,p.isWritable=D.isWritable,p.isReadable=D.isReadable,p.Readable=_q();for(let I of G(M)){let Z=function(...T){if(new.target)throw P();return p.Readable.from(y(U,this,T))};const U=M[I];B(Z,"name",{value:U.name}),B(Z,"length",{value:U.length}),B(p.Readable.prototype,I,{value:Z,enumerable:!1,configurable:!0,writable:!0})}for(let I of G(R)){let Z=function(...T){if(new.target)throw P();return y(U,this,T)};const U=R[I];B(Z,"name",{value:U.name}),B(Z,"length",{value:U.length}),B(p.Readable.prototype,I,{value:Z,enumerable:!1,configurable:!0,writable:!0})}p.Writable=bq(),p.Duplex=Mq(),p.Transform=mq(),p.PassThrough=cq(),p.pipeline=k;var{addAbortSignal:E}=Sq();p.addAbortSignal=E,p.finished=O,p.destroy=c,p.compose=g,B(p,"promises",{configurable:!0,enumerable:!0,get(){return l}}),B(k,A,{enumerable:!0,get(){return l.pipeline}}),B(O,A,{enumerable:!0,get(){return l.finished}}),p.Stream=p,p._isUint8Array=function I(Z){return Z instanceof Uint8Array},p._uint8ArrayToBuffer=function I(Z){return new Buffer(Z.buffer,Z.byteOffset,Z.byteLength)}}}),BQ=Bq({"node_modules/readable-stream/lib/ours/index.js"(a,j){const B=ZQ(),G=dq(),y=B.Readable.destroy;j.exports=B,j.exports._uint8ArrayToBuffer=B._uint8ArrayToBuffer,j.exports._isUint8Array=B._isUint8Array,j.exports.isDisturbed=B.isDisturbed,j.exports.isErrored=B.isErrored,j.exports.isWritable=B.isWritable,j.exports.isReadable=B.isReadable,j.exports.Readable=B.Readable,j.exports.Writable=B.Writable,j.exports.Duplex=B.Duplex,j.exports.Transform=B.Transform,j.exports.PassThrough=B.PassThrough,j.exports.addAbortSignal=B.addAbortSignal,j.exports.finished=B.finished,j.exports.destroy=B.destroy,j.exports.destroy=y,j.exports.pipeline=B.pipeline,j.exports.compose=B.compose,j.exports._getNativeReadableStreamPrototype=lq,j.exports.NativeWritable=iq,zq.defineProperty(B,"promises",{configurable:!0,enumerable:!0,get(){return G}}),j.exports.Stream=B.Stream,j.exports.default=j.exports}}),$Q={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Uq=bq(),iq=class a extends Uq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(j,B={}){super(B);this._construct=this.#H,this._destroy=this.#K,this._final=this.#Z,this.#q=j}#H(j){this._writableState.constructed=!0,this.constructed=!0,j()}#J(){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(j,B,G,y=this.#X){if(!y)return this.#X=!1,super.write(j,B,G);if(!this.#Q)this.#J();var A=this.#Q,M=A.write(j);if(xq(M))return M.then(()=>{this.emit("drain"),A.flush(!0)}),!1;if(A.flush(!0),G)G(null,j.byteLength);return!0}end(j,B,G,y=this.#X){return super.end(j,B,G,y)}#K(j,B){if(this._writableState.destroyed=!0,B)B(j)}#Z(j){if(this.#Q)this.#Q.end();if(j)j()}ref(){if(!this.#Q)this.#J();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},Yq=BQ();Yq[Symbol.for("CommonJS")]=0;Yq[Symbol.for("::bunternal::")]={_ReadableFromWeb:pq,_ReadableFromWebForUndici:uq};var cQ=Yq,EQ=Yq._uint8ArrayToBuffer,IQ=Yq._isUint8Array,TQ=Yq.isDisturbed,PQ=Yq.isErrored,xQ=Yq.isWritable,OQ=Yq.isReadable,CQ=Yq.Readable,Uq=Yq.Writable,_Q=Yq.Duplex,DQ=Yq.Transform,wQ=Yq.PassThrough,vQ=Yq.addAbortSignal,RQ=Yq.finished,SQ=Yq.destroy,gQ=Yq.pipeline,kQ=Yq.compose,VQ=Yq.Stream,fQ=Yq.eos=Fq,yQ=Yq._getNativeReadableStreamPrototype,iq=Yq.NativeWritable,hQ=VQ.promises;export{hQ as promises,gQ as pipeline,xQ as isWritable,OQ as isReadable,PQ as isErrored,TQ as isDisturbed,RQ as finished,fQ as eos,SQ as destroy,cQ as default,kQ as compose,vQ as addAbortSignal,EQ as _uint8ArrayToBuffer,IQ as _isUint8Array,yQ as _getNativeReadableStreamPrototype,Uq as Writable,DQ as Transform,VQ as Stream,CQ as Readable,wQ as PassThrough,iq as NativeWritable,_Q as Duplex}; -- cgit v1.2.3 From 538bcef7317ce4b2dfd84097cda0281e1a948475 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 10 Jul 2023 01:33:46 -0700 Subject: Update globals.d.ts --- packages/bun-types/globals.d.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index da412b211..f3f941488 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -420,6 +420,32 @@ interface Process { emitWarning(warning: string | Error /*name?: string, ctor?: Function*/): void; readonly config: Object; + + memoryUsage: { + (delta?: MemoryUsageObject): MemoryUsageObject; + + rss(): number; + }; + + cpuUsage(previousValue?: CPUUsageObject): CPUUsageObject; + + /** + * Does nothing in Bun + */ + setSourceMapsEnabled(enabled: boolean): void; +} + +interface MemoryUsageObject { + rss: number; + heapTotal: number; + heapUsed: number; + external: number; + arrayBuffers: number; +} + +interface CPUUsageObject { + user: number; + system: number; } declare var process: Process; @@ -1437,8 +1463,8 @@ declare function queueMicrotask(callback: (...args: any[]) => void): void; declare function reportError(error: any): void; interface Timer { - ref(): void; - unref(): void; + ref(): Timer; + unref(): Timer; hasRef(): boolean; [Symbol.toPrimitive](): number; -- cgit v1.2.3 From ec1117031197dbce434473492c85bb2654a91248 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 10 Jul 2023 02:21:03 -0700 Subject: Fixes #3588 (#3590) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/js/node/http.ts | 132 +++++++++++++++++++++++++++++----------- src/js/out/modules/node/http.js | 80 ++++++++++++++++-------- 2 files changed, 149 insertions(+), 63 deletions(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 15b060d5f..a745f9b32 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -109,6 +109,28 @@ function isValidTLSArray(obj) { } } +class ERR_INVALID_ARG_TYPE extends TypeError { + constructor(name, expected, actual) { + super(`The ${name} argument must be of type ${expected}. Received type ${typeof actual}`); + this.code = "ERR_INVALID_ARG_TYPE"; + } +} + +function validateMsecs(numberlike: any, field: string) { + if (typeof numberlike !== "number" || numberlike < 0) { + throw new ERR_INVALID_ARG_TYPE(field, "number", numberlike); + } + + return numberlike; +} +function validateFunction(callable: any, field: string) { + if (typeof callable !== "function") { + throw new ERR_INVALID_ARG_TYPE(field, "Function", callable); + } + + return callable; +} + function getHeader(headers, name) { if (!headers) return; const result = headers.get(name); @@ -792,12 +814,13 @@ export class OutgoingMessage extends Writable { headersSent = false; sendDate = true; req; + timeout; #finished = false; [kEndCalled] = false; #fakeSocket; - #timeoutTimer: Timer | null = null; + #timeoutTimer?: Timer; [kAbortController]: AbortController | null = null; // Express "compress" package uses this @@ -894,21 +917,41 @@ export class OutgoingMessage extends Writable { [kClearTimeout]() { if (this.#timeoutTimer) { clearTimeout(this.#timeoutTimer); - this.#timeoutTimer = null; + this.removeAllListeners("timeout"); + this.#timeoutTimer = undefined; } } + #onTimeout() { + this.#timeoutTimer = undefined; + this[kAbortController]?.abort(); + this.emit("timeout"); + } + setTimeout(msecs, callback) { - if (this.#timeoutTimer) return this; - if (callback) { - this.on("timeout", callback); - } + if (this.destroyed) return this; + + this.timeout = msecs = validateMsecs(msecs, "msecs"); - this.#timeoutTimer = setTimeout(async () => { - this.#timeoutTimer = null; - this[kAbortController]?.abort(); - this.emit("timeout"); - }, msecs); + // Attempt to clear an existing timer in both cases - + // even if it will be rescheduled we don't want to leak an existing timer. + clearTimeout(this.#timeoutTimer!); + + if (msecs === 0) { + if (callback !== undefined) { + validateFunction(callback, "callback"); + this.removeListener("timeout", callback); + } + + this.#timeoutTimer = undefined; + } else { + this.#timeoutTimer = setTimeout(this.#onTimeout.bind(this), msecs).unref(); + + if (callback !== undefined) { + validateFunction(callback, "callback"); + this.once("timeout", callback); + } + } return this; } @@ -1155,7 +1198,7 @@ export class ClientRequest extends OutgoingMessage { #fetchRequest; #signal: AbortSignal | null = null; [kAbortController]: AbortController | null = null; - #timeoutTimer: Timer | null = null; + #timeoutTimer?: Timer = undefined; #options; #finished; @@ -1224,6 +1267,9 @@ export class ClientRequest extends OutgoingMessage { redirect: "manual", verbose: Boolean(__DEBUG__), signal: this[kAbortController].signal, + + // Timeouts are handled via this.setTimeout. + timeout: false, }, ) .then(response => { @@ -1348,8 +1394,6 @@ export class ClientRequest extends OutgoingMessage { this.#socketPath = options.socketPath; - if (options.timeout !== undefined) this.setTimeout(options.timeout, null); - const signal = options.signal; if (signal) { //We still want to control abort function and timeout so signal call our AbortController @@ -1427,7 +1471,12 @@ export class ClientRequest extends OutgoingMessage { this.#reusedSocket = false; this.#host = host; this.#protocol = protocol; - this.#timeoutTimer = null; + + var timeout = options.timeout; + if (timeout !== undefined && timeout !== 0) { + this.setTimeout(timeout, undefined); + } + const headersArray = ArrayIsArray(headers); if (!headersArray) { var headers = options.headers; @@ -1482,17 +1531,8 @@ export class ClientRequest extends OutgoingMessage { // this[kUniqueHeaders] = parseUniqueHeadersOption(options.uniqueHeaders); - var optsWithoutSignal = options; - if (optsWithoutSignal.signal) { - optsWithoutSignal = ObjectAssign({}, options); - delete optsWithoutSignal.signal; - } + var { signal: _signal, ...optsWithoutSignal } = options; this.#options = optsWithoutSignal; - - var timeout = options.timeout; - if (timeout) { - this.setTimeout(timeout); - } } setSocketKeepAlive(enable = true, initialDelay = 0) { @@ -1505,21 +1545,41 @@ export class ClientRequest extends OutgoingMessage { [kClearTimeout]() { if (this.#timeoutTimer) { clearTimeout(this.#timeoutTimer); - this.#timeoutTimer = null; + this.#timeoutTimer = undefined; + this.removeAllListeners("timeout"); } } - setTimeout(msecs, callback?) { - if (this.#timeoutTimer) return this; - if (callback) { - this.on("timeout", callback); - } + #onTimeout() { + this.#timeoutTimer = undefined; + this[kAbortController]?.abort(); + this.emit("timeout"); + } - this.#timeoutTimer = setTimeout(async () => { - this.#timeoutTimer = null; - this[kAbortController]?.abort(); - this.emit("timeout"); - }, msecs); + setTimeout(msecs, callback) { + if (this.destroyed) return this; + + this.timeout = msecs = validateMsecs(msecs, "msecs"); + + // Attempt to clear an existing timer in both cases - + // even if it will be rescheduled we don't want to leak an existing timer. + clearTimeout(this.#timeoutTimer!); + + if (msecs === 0) { + if (callback !== undefined) { + validateFunction(callback, "callback"); + this.removeListener("timeout", callback); + } + + this.#timeoutTimer = undefined; + } else { + this.#timeoutTimer = setTimeout(this.#onTimeout.bind(this), msecs).unref(); + + if (callback !== undefined) { + validateFunction(callback, "callback"); + this.once("timeout", callback); + } + } return this; } diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index f07dcc2e0..13ee7fded 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -14,6 +14,14 @@ var checkInvalidHeaderChar = function(val) { return !1; return !0; } +}, validateMsecs = function(numberlike, field) { + if (typeof numberlike !== "number" || numberlike < 0) + throw new ERR_INVALID_ARG_TYPE(field, "number", numberlike); + return numberlike; +}, validateFunction = function(callable, field) { + if (typeof callable !== "function") + throw new ERR_INVALID_ARG_TYPE(field, "Function", callable); + return callable; }, getHeader = function(headers, name) { if (!headers) return; @@ -108,7 +116,15 @@ var headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/, validateHeaderName = (name, lab if (checkInvalidHeaderChar(value)) throw new Error("ERR_INVALID_CHAR"); }, { 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.", _defaultHTTPSAgent, kInternalRequest = Symbol("kInternalRequest"), kInternalSocketData = Symbol.for("::bunternal::"), kEmptyBuffer = Buffer.alloc(0), FakeSocket = class Socket extends Duplex { +}, __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.", _defaultHTTPSAgent, kInternalRequest = Symbol("kInternalRequest"), kInternalSocketData = Symbol.for("::bunternal::"), kEmptyBuffer = Buffer.alloc(0); + +class ERR_INVALID_ARG_TYPE extends TypeError { + constructor(name, expected, actual) { + super(`The ${name} argument must be of type ${expected}. Received type ${typeof actual}`); + this.code = "ERR_INVALID_ARG_TYPE"; + } +} +var FakeSocket = class Socket extends Duplex { bytesRead = 0; bytesWritten = 0; connecting = !1; @@ -514,10 +530,11 @@ class OutgoingMessage extends Writable { headersSent = !1; sendDate = !0; req; + timeout; #finished = !1; [kEndCalled] = !1; #fakeSocket; - #timeoutTimer = null; + #timeoutTimer; [kAbortController] = null; _implicitHeader() { } @@ -592,16 +609,21 @@ class OutgoingMessage extends Writable { } [kClearTimeout]() { if (this.#timeoutTimer) - clearTimeout(this.#timeoutTimer), this.#timeoutTimer = null; + clearTimeout(this.#timeoutTimer), this.removeAllListeners("timeout"), this.#timeoutTimer = void 0; + } + #onTimeout() { + this.#timeoutTimer = void 0, this[kAbortController]?.abort(), this.emit("timeout"); } setTimeout(msecs, callback) { - if (this.#timeoutTimer) + if (this.destroyed) return this; - if (callback) - this.on("timeout", callback); - return this.#timeoutTimer = setTimeout(async () => { - this.#timeoutTimer = null, this[kAbortController]?.abort(), this.emit("timeout"); - }, msecs), this; + if (this.timeout = msecs = validateMsecs(msecs, "msecs"), clearTimeout(this.#timeoutTimer), msecs === 0) { + if (callback !== void 0) + validateFunction(callback, "callback"), this.removeListener("timeout", callback); + this.#timeoutTimer = void 0; + } else if (this.#timeoutTimer = setTimeout(this.#onTimeout.bind(this), msecs).unref(), callback !== void 0) + validateFunction(callback, "callback"), this.once("timeout", callback); + return this; } } @@ -780,7 +802,7 @@ class ClientRequest extends OutgoingMessage { #fetchRequest; #signal = null; [kAbortController] = null; - #timeoutTimer = null; + #timeoutTimer = void 0; #options; #finished; get path() { @@ -827,7 +849,8 @@ class ClientRequest extends OutgoingMessage { body: body && method !== "GET" && method !== "HEAD" && method !== "OPTIONS" ? body : void 0, redirect: "manual", verbose: Boolean(__DEBUG__), - signal: this[kAbortController].signal + signal: this[kAbortController].signal, + timeout: !1 }).then((response) => { var res = this.#res = new IncomingMessage(response, { type: "response", @@ -910,8 +933,7 @@ class ClientRequest extends OutgoingMessage { const defaultPort = protocol === "https:" ? 443 : 80; this.#port = options.port || options.defaultPort || this.#agent?.defaultPort || defaultPort, this.#useDefaultPort = this.#port === defaultPort; const host = this.#host = options.host = validateHost(options.hostname, "hostname") || validateHost(options.host, "host") || "localhost"; - if (this.#socketPath = options.socketPath, options.timeout !== void 0) - this.setTimeout(options.timeout, null); + this.#socketPath = options.socketPath; const signal = options.signal; if (signal) signal.addEventListener("abort", () => { @@ -932,7 +954,11 @@ class ClientRequest extends OutgoingMessage { var _joinDuplicateHeaders = options.joinDuplicateHeaders; if (this.#joinDuplicateHeaders = _joinDuplicateHeaders, this.#path = options.path || "/", cb) this.once("response", cb); - if (__DEBUG__ && debug(`new ClientRequest: ${this.#method} ${this.#protocol}//${this.#host}:${this.#port}${this.#path}`), this.#finished = !1, this.#res = null, this.#upgradeOrConnect = !1, this.#parser = null, this.#maxHeadersCount = null, this.#reusedSocket = !1, this.#host = host, this.#protocol = protocol, this.#timeoutTimer = null, !ArrayIsArray(headers)) { + __DEBUG__ && debug(`new ClientRequest: ${this.#method} ${this.#protocol}//${this.#host}:${this.#port}${this.#path}`), this.#finished = !1, this.#res = null, this.#upgradeOrConnect = !1, this.#parser = null, this.#maxHeadersCount = null, this.#reusedSocket = !1, this.#host = host, this.#protocol = protocol; + var timeout = options.timeout; + if (timeout !== void 0 && timeout !== 0) + this.setTimeout(timeout, void 0); + if (!ArrayIsArray(headers)) { var headers = options.headers; if (headers) for (let key in headers) @@ -941,13 +967,8 @@ class ClientRequest extends OutgoingMessage { if (auth && !this.getHeader("Authorization")) this.setHeader("Authorization", "Basic " + Buffer.from(auth).toString("base64")); } - var optsWithoutSignal = options; - if (optsWithoutSignal.signal) - optsWithoutSignal = ObjectAssign({}, options), delete optsWithoutSignal.signal; + var { signal: _signal, ...optsWithoutSignal } = options; this.#options = optsWithoutSignal; - var timeout = options.timeout; - if (timeout) - this.setTimeout(timeout); } setSocketKeepAlive(enable = !0, initialDelay = 0) { __DEBUG__ && debug(`${NODE_HTTP_WARNING}\n`, "WARN: ClientRequest.setSocketKeepAlive is a no-op"); @@ -957,16 +978,21 @@ class ClientRequest extends OutgoingMessage { } [kClearTimeout]() { if (this.#timeoutTimer) - clearTimeout(this.#timeoutTimer), this.#timeoutTimer = null; + clearTimeout(this.#timeoutTimer), this.#timeoutTimer = void 0, this.removeAllListeners("timeout"); + } + #onTimeout() { + this.#timeoutTimer = void 0, this[kAbortController]?.abort(), this.emit("timeout"); } setTimeout(msecs, callback) { - if (this.#timeoutTimer) + if (this.destroyed) return this; - if (callback) - this.on("timeout", callback); - return this.#timeoutTimer = setTimeout(async () => { - this.#timeoutTimer = null, this[kAbortController]?.abort(), this.emit("timeout"); - }, msecs), this; + if (this.timeout = msecs = validateMsecs(msecs, "msecs"), clearTimeout(this.#timeoutTimer), msecs === 0) { + if (callback !== void 0) + validateFunction(callback, "callback"), this.removeListener("timeout", callback); + this.#timeoutTimer = void 0; + } else if (this.#timeoutTimer = setTimeout(this.#onTimeout.bind(this), msecs).unref(), callback !== void 0) + validateFunction(callback, "callback"), this.once("timeout", callback); + return this; } } var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, METHODS = [ -- cgit v1.2.3 From c6e113554832d17a0736fea7491c0985705b7cd9 Mon Sep 17 00:00:00 2001 From: Hanaasagi Date: Mon, 10 Jul 2023 21:35:10 +0900 Subject: call `writeHead` before send headers Close: #3585 --- src/js/node/http.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 15b060d5f..0c42b247b 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -948,7 +948,10 @@ export class ServerResponse extends Writable { #finished = false; // Express "compress" package uses this - _implicitHeader() {} + _implicitHeader() { + const statusMessage = this.statusMessage ?? STATUS_CODES[this.statusCode]; + this.writeHead(this.statusCode, statusMessage, {}); + } _write(chunk, encoding, callback) { if (!this.#firstWrite && !this.headersSent) { @@ -1015,6 +1018,7 @@ export class ServerResponse extends Writable { var data = this.#firstWrite || ""; this.#firstWrite = undefined; this.#finished = true; + this._implicitHeader(); this._reply( new Response(data, { headers: this.#headers, -- cgit v1.2.3 From 438d54f1869a11a7219f6e93c3bb05f6c52ee27b Mon Sep 17 00:00:00 2001 From: Hanaasagi Date: Mon, 10 Jul 2023 22:04:39 +0900 Subject: add tests --- test/js/node/http/node-http.test.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts index 3e7da9d34..167cb9883 100644 --- a/test/js/node/http/node-http.test.ts +++ b/test/js/node/http/node-http.test.ts @@ -146,6 +146,29 @@ describe("node:http", () => { res.end("Path correct!\n"); return; } + if (reqUrl.pathname === "/customWriteHead") { + function createWriteHead(prevWriteHead, listener) { + let fired = false; + return function writeHead() { + if (!fired) { + fired = true; + listener.call(this); + } + return prevWriteHead.apply(this, arguments); + }; + } + + function addPoweredBy() { + if (!this.getHeader("X-Powered-By")) { + this.setHeader("X-Powered-By", "Bun"); + } + } + + res.writeHead = createWriteHead(res.writeHead, addPoweredBy); + res.setHeader("Content-Type", "text/plain"); + res.end("Hello World"); + return; + } } res.writeHead(200, { "Content-Type": "text/plain" }); @@ -507,6 +530,16 @@ describe("node:http", () => { req.end(); }); }); + it("re-implemented writeHead, issue#3585", done => { + runTest(done, (server, serverPort, done) => { + const req = request(`http://localhost:${serverPort}/customWriteHead`, res => { + expect(res.headers["content-type"]).toBe("text/plain"); + expect(res.headers["x-powered-by"]).toBe("Bun"); + done(); + }); + req.end(); + }); + }); }); describe("signal", () => { -- cgit v1.2.3 From 0c2df4ae012fdde46b2f61de17e640111cc9379b Mon Sep 17 00:00:00 2001 From: Hanaasagi Date: Mon, 10 Jul 2023 22:17:51 +0900 Subject: ignore check --- src/js/node/http.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index c8fbf20d6..253bcf4d8 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -992,8 +992,8 @@ export class ServerResponse extends Writable { // Express "compress" package uses this _implicitHeader() { - const statusMessage = this.statusMessage ?? STATUS_CODES[this.statusCode]; - this.writeHead(this.statusCode, statusMessage, {}); + // @ts-ignore + this.writeHead(this.statusCode); } _write(chunk, encoding, callback) { -- cgit v1.2.3 From 4af4b508a1027ee837f69d4fed5a246629714398 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Mon, 10 Jul 2023 21:14:37 -0300 Subject: feat(crypto) add getCurves (#3598) * add getCurves * add nodefallbacks * update docs * oops --- docs/runtime/nodejs-apis.md | 2 +- src/js/node/crypto.js | 36 +++++++++++++++++++++++++++++++++++- src/js/out/modules/node/crypto.js | 8 ++++---- src/node-fallbacks/crypto.js | 22 ++++++++++++++++++++++ test/js/node/crypto/crypto.test.ts | 9 ++++++++- 5 files changed, 70 insertions(+), 7 deletions(-) diff --git a/docs/runtime/nodejs-apis.md b/docs/runtime/nodejs-apis.md index 5f798fc39..3dfe76b97 100644 --- a/docs/runtime/nodejs-apis.md +++ b/docs/runtime/nodejs-apis.md @@ -51,7 +51,7 @@ This page is updated regularly to reflect compatibility status of the latest ver - {% anchor id="node_crypto" %} [`node:crypto`](https://nodejs.org/api/crypto.html) {% /anchor %} - 🟡 -- Missing `crypto.Certificate` `crypto.ECDH` `crypto.KeyObject` `crypto.X509Certificate` `crypto.checkPrime{Sync}` `crypto.createPrivateKey` `crypto.createPublicKey` `crypto.createSecretKey` `crypto.diffieHellman` `crypto.generateKey{Sync}` `crypto.generateKeyPair{Sync}` `crypto.generatePrime{Sync}` `crypto.getCipherInfo` `crypto.getCurves` `crypto.{get|set}Fips` `crypto.hkdf` `crypto.hkdfSync` `crypto.secureHeapUsed` `crypto.setEngine` `crypto.sign` `crypto.verify` +- Missing `crypto.Certificate` `crypto.ECDH` `crypto.KeyObject` `crypto.X509Certificate` `crypto.checkPrime{Sync}` `crypto.createPrivateKey` `crypto.createPublicKey` `crypto.createSecretKey` `crypto.diffieHellman` `crypto.generateKey{Sync}` `crypto.generateKeyPair{Sync}` `crypto.generatePrime{Sync}` `crypto.getCipherInfo` `crypto.{get|set}Fips` `crypto.hkdf` `crypto.hkdfSync` `crypto.secureHeapUsed` `crypto.setEngine` `crypto.sign` `crypto.verify` --- diff --git a/src/js/node/crypto.js b/src/js/node/crypto.js index e75182429..20e052e3e 100644 --- a/src/js/node/crypto.js +++ b/src/js/node/crypto.js @@ -23802,12 +23802,35 @@ timingSafeEqual && Object.defineProperty(scryptSync, "name", { value: "::bunternal::", })); + +const harcoded_curves = [ + "p192", + "p224", + "p256", + "p384", + "p521", + "curve25519", + "ed25519", + "secp256k1", + "secp224r1", + "prime256v1", + "prime192v1", + "ed25519", + "secp384r1", + "secp521r1", +]; + +function getCurves() { + return harcoded_curves; +} + var webcrypto = crypto; __export(crypto_exports, { DEFAULT_ENCODING: () => DEFAULT_ENCODING, getRandomValues: () => getRandomValues, randomUUID: () => randomUUID, randomInt: () => randomInt, + getCurves: () => getCurves, scrypt: () => scrypt, scryptSync: () => scryptSync, timingSafeEqual: () => timingSafeEqual, @@ -23856,6 +23879,17 @@ export const { createCredentials, constants, } = crypto_exports; -export { DEFAULT_ENCODING, getRandomValues, randomUUID, randomInt, scrypt, scryptSync, timingSafeEqual, webcrypto }; + +export { + DEFAULT_ENCODING, + getRandomValues, + getCurves, + randomUUID, + randomInt, + scrypt, + scryptSync, + timingSafeEqual, + webcrypto, +}; export default crypto_exports; /*! safe-buffer. MIT License. Feross Aboukhadijeh */ diff --git a/src/js/out/modules/node/crypto.js b/src/js/out/modules/node/crypto.js index eda9d4cc9..fe812ee61 100644 --- a/src/js/out/modules/node/crypto.js +++ b/src/js/out/modules/node/crypto.js @@ -1,4 +1,4 @@ -import{StringDecoder as bQ} from"node:string_decoder";import*as r$ from"node:buffer";import*as A$ from"node:stream";var hQ=Object.defineProperty;var dQ=Object.getOwnPropertyNames;var lQ=536870888,g0=globalThis.Buffer,H$=globalThis.crypto,i$=H$;var S0=(N,_)=>function(){return _||(0,N[dQ(N)[0]])((_={exports:{}}).exports,_),_.exports},oQ=(N,_)=>{for(var k in _)hQ(N,k,{get:_[k],enumerable:!0})};var N0=S0({"node_modules/safe-buffer/index.js"(N,_){var k=r$,j=k.Buffer;function F(X,C){for(var P in X)C[P]=X[P]}j.from&&j.alloc&&j.allocUnsafe&&j.allocUnsafeSlow?_.exports=k:(F(k,N),N.Buffer=z);function z(X,C,P){return j(X,C,P)}z.prototype=Object.create(j.prototype),F(j,z),z.from=function(X,C,P){if(typeof X=="number")throw new TypeError("Argument must not be a number");return j(X,C,P)},z.alloc=function(X,C,P){if(typeof X!="number")throw new TypeError("Argument must be a number");var T=j(X);return C!==void 0?typeof P=="string"?T.fill(C,P):T.fill(C):T.fill(0),T},z.allocUnsafe=function(X){if(typeof X!="number")throw new TypeError("Argument must be a number");return j(X)},z.allocUnsafeSlow=function(X){if(typeof X!="number")throw new TypeError("Argument must be a number");return k.SlowBuffer(X)}}}),L$=S0({"node_modules/randombytes/browser.js"(N,_){var k=65536,j=4294967295;function F(){throw new Error(`Secure random number generation is not supported by this browser. -Use Chrome, Firefox or Internet Explorer 11`)}var z=N0().Buffer,X=i$;X&&X.getRandomValues?_.exports=C:_.exports=F;function C(P,T){if(P>j)throw new RangeError("requested too many random bytes");var W=z.allocUnsafe(P);if(P>0)if(P>k)for(var J=0;J=this._blockSize;){for(var W=this._blockOffset;W0;++J)this._length[J]+=H,H=this._length[J]/4294967296|0,H>0&&(this._length[J]-=4294967296*H);return this},z.prototype._update=function(){throw new Error("_update is not implemented")},z.prototype.digest=function(X){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var C=this._digest();X!==void 0&&(C=C.toString(X)),this._block.fill(0),this._blockOffset=0;for(var P=0;P<4;++P)this._length[P]=0;return C},z.prototype._digest=function(){throw new Error("_digest is not implemented")},_.exports=z}}),QQ=S0({"node_modules/md5.js/index.js"(N,_){var k=B0(),j=$Q(),F=N0().Buffer,z=new Array(16);function X(){j.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}k(X,j),X.prototype._update=function(){for(var H=z,D=0;D<16;++D)H[D]=this._block.readInt32LE(D*4);var E=this._a,L=this._b,M=this._c,v=this._d;E=P(E,L,M,v,H[0],3614090360,7),v=P(v,E,L,M,H[1],3905402710,12),M=P(M,v,E,L,H[2],606105819,17),L=P(L,M,v,E,H[3],3250441966,22),E=P(E,L,M,v,H[4],4118548399,7),v=P(v,E,L,M,H[5],1200080426,12),M=P(M,v,E,L,H[6],2821735955,17),L=P(L,M,v,E,H[7],4249261313,22),E=P(E,L,M,v,H[8],1770035416,7),v=P(v,E,L,M,H[9],2336552879,12),M=P(M,v,E,L,H[10],4294925233,17),L=P(L,M,v,E,H[11],2304563134,22),E=P(E,L,M,v,H[12],1804603682,7),v=P(v,E,L,M,H[13],4254626195,12),M=P(M,v,E,L,H[14],2792965006,17),L=P(L,M,v,E,H[15],1236535329,22),E=T(E,L,M,v,H[1],4129170786,5),v=T(v,E,L,M,H[6],3225465664,9),M=T(M,v,E,L,H[11],643717713,14),L=T(L,M,v,E,H[0],3921069994,20),E=T(E,L,M,v,H[5],3593408605,5),v=T(v,E,L,M,H[10],38016083,9),M=T(M,v,E,L,H[15],3634488961,14),L=T(L,M,v,E,H[4],3889429448,20),E=T(E,L,M,v,H[9],568446438,5),v=T(v,E,L,M,H[14],3275163606,9),M=T(M,v,E,L,H[3],4107603335,14),L=T(L,M,v,E,H[8],1163531501,20),E=T(E,L,M,v,H[13],2850285829,5),v=T(v,E,L,M,H[2],4243563512,9),M=T(M,v,E,L,H[7],1735328473,14),L=T(L,M,v,E,H[12],2368359562,20),E=W(E,L,M,v,H[5],4294588738,4),v=W(v,E,L,M,H[8],2272392833,11),M=W(M,v,E,L,H[11],1839030562,16),L=W(L,M,v,E,H[14],4259657740,23),E=W(E,L,M,v,H[1],2763975236,4),v=W(v,E,L,M,H[4],1272893353,11),M=W(M,v,E,L,H[7],4139469664,16),L=W(L,M,v,E,H[10],3200236656,23),E=W(E,L,M,v,H[13],681279174,4),v=W(v,E,L,M,H[0],3936430074,11),M=W(M,v,E,L,H[3],3572445317,16),L=W(L,M,v,E,H[6],76029189,23),E=W(E,L,M,v,H[9],3654602809,4),v=W(v,E,L,M,H[12],3873151461,11),M=W(M,v,E,L,H[15],530742520,16),L=W(L,M,v,E,H[2],3299628645,23),E=J(E,L,M,v,H[0],4096336452,6),v=J(v,E,L,M,H[7],1126891415,10),M=J(M,v,E,L,H[14],2878612391,15),L=J(L,M,v,E,H[5],4237533241,21),E=J(E,L,M,v,H[12],1700485571,6),v=J(v,E,L,M,H[3],2399980690,10),M=J(M,v,E,L,H[10],4293915773,15),L=J(L,M,v,E,H[1],2240044497,21),E=J(E,L,M,v,H[8],1873313359,6),v=J(v,E,L,M,H[15],4264355552,10),M=J(M,v,E,L,H[6],2734768916,15),L=J(L,M,v,E,H[13],1309151649,21),E=J(E,L,M,v,H[4],4149444226,6),v=J(v,E,L,M,H[11],3174756917,10),M=J(M,v,E,L,H[2],718787259,15),L=J(L,M,v,E,H[9],3951481745,21),this._a=this._a+E|0,this._b=this._b+L|0,this._c=this._c+M|0,this._d=this._d+v|0},X.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 H=F.allocUnsafe(16);return H.writeInt32LE(this._a,0),H.writeInt32LE(this._b,4),H.writeInt32LE(this._c,8),H.writeInt32LE(this._d,12),H};function C(H,D){return H<>>32-D}function P(H,D,E,L,M,v,q){return C(H+(D&E|~D&L)+M+v|0,q)+D|0}function T(H,D,E,L,M,v,q){return C(H+(D&L|E&~L)+M+v|0,q)+D|0}function W(H,D,E,L,M,v,q){return C(H+(D^E^L)+M+v|0,q)+D|0}function J(H,D,E,L,M,v,q){return C(H+(E^(D|~L))+M+v|0,q)+D|0}_.exports=X}}),YQ=S0({"node_modules/ripemd160/index.js"(N,_){var k=g0,j=B0(),F=$Q(),z=new Array(16),X=[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],C=[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],P=[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],T=[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],W=[0,1518500249,1859775393,2400959708,2840853838],J=[1352829926,1548603684,1836072691,2053994217,0];function H(){F.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}j(H,F),H.prototype._update=function(){for(var g=z,y=0;y<16;++y)g[y]=this._block.readInt32LE(y*4);for(var w=this._a|0,f=this._b|0,b=this._c|0,u=this._d|0,Y0=this._e|0,p=this._a|0,v0=this._b|0,$=this._c|0,Y=this._d|0,G=this._e|0,Z=0;Z<80;Z+=1){var V,I;Z<16?(V=E(w,f,b,u,Y0,g[X[Z]],W[0],P[Z]),I=q(p,v0,$,Y,G,g[C[Z]],J[0],T[Z])):Z<32?(V=L(w,f,b,u,Y0,g[X[Z]],W[1],P[Z]),I=v(p,v0,$,Y,G,g[C[Z]],J[1],T[Z])):Z<48?(V=M(w,f,b,u,Y0,g[X[Z]],W[2],P[Z]),I=M(p,v0,$,Y,G,g[C[Z]],J[2],T[Z])):Z<64?(V=v(w,f,b,u,Y0,g[X[Z]],W[3],P[Z]),I=L(p,v0,$,Y,G,g[C[Z]],J[3],T[Z])):(V=q(w,f,b,u,Y0,g[X[Z]],W[4],P[Z]),I=E(p,v0,$,Y,G,g[C[Z]],J[4],T[Z])),w=Y0,Y0=u,u=D(b,10),b=f,f=V,p=G,G=Y,Y=D($,10),$=v0,v0=I}var O=this._b+b+Y|0;this._b=this._c+u+G|0,this._c=this._d+Y0+p|0,this._d=this._e+w+v0|0,this._e=this._a+f+$|0,this._a=O},H.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 g=k.alloc?k.alloc(20):new k(20);return g.writeInt32LE(this._a,0),g.writeInt32LE(this._b,4),g.writeInt32LE(this._c,8),g.writeInt32LE(this._d,12),g.writeInt32LE(this._e,16),g};function D(g,y){return g<>>32-y}function E(g,y,w,f,b,u,Y0,p){return D(g+(y^w^f)+u+Y0|0,p)+b|0}function L(g,y,w,f,b,u,Y0,p){return D(g+(y&w|~y&f)+u+Y0|0,p)+b|0}function M(g,y,w,f,b,u,Y0,p){return D(g+((y|~w)^f)+u+Y0|0,p)+b|0}function v(g,y,w,f,b,u,Y0,p){return D(g+(y&f|w&~f)+u+Y0|0,p)+b|0}function q(g,y,w,f,b,u,Y0,p){return D(g+(y^(w|~f))+u+Y0|0,p)+b|0}_.exports=H}}),R$=S0({"node_modules/sha.js/hash.js"(N,_){var k=N0().Buffer;function j(F,z){this._block=k.alloc(F),this._finalSize=z,this._blockSize=F,this._len=0}j.prototype.update=function(F,z){typeof F=="string"&&(z=z||"utf8",F=k.from(F,z));for(var X=this._block,C=this._blockSize,P=F.length,T=this._len,W=0;W=this._finalSize&&(this._update(this._block),this._block.fill(0));var X=this._len*8;if(X<=4294967295)this._block.writeUInt32BE(X,this._blockSize-4);else{var C=(X&4294967295)>>>0,P=(X-C)/4294967296;this._block.writeUInt32BE(P,this._blockSize-8),this._block.writeUInt32BE(C,this._blockSize-4)}this._update(this._block);var T=this._hash();return F?T.toString(F):T},j.prototype._update=function(){throw new Error("_update must be implemented by subclass")},_.exports=j}}),uQ=S0({"node_modules/sha.js/sha.js"(N,_){var k=B0(),j=R$(),F=N0().Buffer,z=[1518500249,1859775393,-1894007588,-899497514],X=new Array(80);function C(){this.init(),this._w=X,j.call(this,64,56)}k(C,j),C.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function P(J){return J<<5|J>>>27}function T(J){return J<<30|J>>>2}function W(J,H,D,E){return J===0?H&D|~H&E:J===2?H&D|H&E|D&E:H^D^E}C.prototype._update=function(J){for(var H=this._w,D=this._a|0,E=this._b|0,L=this._c|0,M=this._d|0,v=this._e|0,q=0;q<16;++q)H[q]=J.readInt32BE(q*4);for(;q<80;++q)H[q]=H[q-3]^H[q-8]^H[q-14]^H[q-16];for(var g=0;g<80;++g){var y=~~(g/20),w=P(D)+W(y,E,L,M)+v+H[g]+z[y]|0;v=M,M=L,L=T(E),E=D,D=w}this._a=D+this._a|0,this._b=E+this._b|0,this._c=L+this._c|0,this._d=M+this._d|0,this._e=v+this._e|0},C.prototype._hash=function(){var J=F.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=C}}),nQ=S0({"node_modules/sha.js/sha1.js"(N,_){var k=B0(),j=R$(),F=N0().Buffer,z=[1518500249,1859775393,-1894007588,-899497514],X=new Array(80);function C(){this.init(),this._w=X,j.call(this,64,56)}k(C,j),C.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function P(H){return H<<1|H>>>31}function T(H){return H<<5|H>>>27}function W(H){return H<<30|H>>>2}function J(H,D,E,L){return H===0?D&E|~D&L:H===2?D&E|D&L|E&L:D^E^L}C.prototype._update=function(H){for(var D=this._w,E=this._a|0,L=this._b|0,M=this._c|0,v=this._d|0,q=this._e|0,g=0;g<16;++g)D[g]=H.readInt32BE(g*4);for(;g<80;++g)D[g]=P(D[g-3]^D[g-8]^D[g-14]^D[g-16]);for(var y=0;y<80;++y){var w=~~(y/20),f=T(E)+J(w,L,M,v)+q+D[y]+z[w]|0;q=v,v=M,M=W(L),L=E,E=f}this._a=E+this._a|0,this._b=L+this._b|0,this._c=M+this._c|0,this._d=v+this._d|0,this._e=q+this._e|0},C.prototype._hash=function(){var H=F.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},_.exports=C}}),ZQ=S0({"node_modules/sha.js/sha256.js"(N,_){var k=B0(),j=R$(),F=N0().Buffer,z=[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],X=new Array(64);function C(){this.init(),this._w=X,j.call(this,64,56)}k(C,j),C.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 P(E,L,M){return M^E&(L^M)}function T(E,L,M){return E&L|M&(E|L)}function W(E){return(E>>>2|E<<30)^(E>>>13|E<<19)^(E>>>22|E<<10)}function J(E){return(E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7)}function H(E){return(E>>>7|E<<25)^(E>>>18|E<<14)^E>>>3}function D(E){return(E>>>17|E<<15)^(E>>>19|E<<13)^E>>>10}C.prototype._update=function(E){for(var L=this._w,M=this._a|0,v=this._b|0,q=this._c|0,g=this._d|0,y=this._e|0,w=this._f|0,f=this._g|0,b=this._h|0,u=0;u<16;++u)L[u]=E.readInt32BE(u*4);for(;u<64;++u)L[u]=D(L[u-2])+L[u-7]+H(L[u-15])+L[u-16]|0;for(var Y0=0;Y0<64;++Y0){var p=b+J(y)+P(y,w,f)+z[Y0]+L[Y0]|0,v0=W(M)+T(M,v,q)|0;b=f,f=w,w=y,y=g+p|0,g=q,q=v,v=M,M=p+v0|0}this._a=M+this._a|0,this._b=v+this._b|0,this._c=q+this._c|0,this._d=g+this._d|0,this._e=y+this._e|0,this._f=w+this._f|0,this._g=f+this._g|0,this._h=b+this._h|0},C.prototype._hash=function(){var E=F.allocUnsafe(32);return E.writeInt32BE(this._a,0),E.writeInt32BE(this._b,4),E.writeInt32BE(this._c,8),E.writeInt32BE(this._d,12),E.writeInt32BE(this._e,16),E.writeInt32BE(this._f,20),E.writeInt32BE(this._g,24),E.writeInt32BE(this._h,28),E},_.exports=C}}),sQ=S0({"node_modules/sha.js/sha224.js"(N,_){var k=B0(),j=ZQ(),F=R$(),z=N0().Buffer,X=new Array(64);function C(){this.init(),this._w=X,F.call(this,64,56)}k(C,j),C.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},C.prototype._hash=function(){var P=z.allocUnsafe(28);return P.writeInt32BE(this._a,0),P.writeInt32BE(this._b,4),P.writeInt32BE(this._c,8),P.writeInt32BE(this._d,12),P.writeInt32BE(this._e,16),P.writeInt32BE(this._f,20),P.writeInt32BE(this._g,24),P},_.exports=C}}),GQ=S0({"node_modules/sha.js/sha512.js"(N,_){var k=B0(),j=R$(),F=N0().Buffer,z=[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],X=new Array(160);function C(){this.init(),this._w=X,j.call(this,128,112)}k(C,j),C.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 P(v,q,g){return g^v&(q^g)}function T(v,q,g){return v&q|g&(v|q)}function W(v,q){return(v>>>28|q<<4)^(q>>>2|v<<30)^(q>>>7|v<<25)}function J(v,q){return(v>>>14|q<<18)^(v>>>18|q<<14)^(q>>>9|v<<23)}function H(v,q){return(v>>>1|q<<31)^(v>>>8|q<<24)^v>>>7}function D(v,q){return(v>>>1|q<<31)^(v>>>8|q<<24)^(v>>>7|q<<25)}function E(v,q){return(v>>>19|q<<13)^(q>>>29|v<<3)^v>>>6}function L(v,q){return(v>>>19|q<<13)^(q>>>29|v<<3)^(v>>>6|q<<26)}function M(v,q){return v>>>0>>0?1:0}C.prototype._update=function(v){for(var q=this._w,g=this._ah|0,y=this._bh|0,w=this._ch|0,f=this._dh|0,b=this._eh|0,u=this._fh|0,Y0=this._gh|0,p=this._hh|0,v0=this._al|0,$=this._bl|0,Y=this._cl|0,G=this._dl|0,Z=this._el|0,V=this._fl|0,I=this._gl|0,O=this._hl|0,U=0;U<32;U+=2)q[U]=v.readInt32BE(U*4),q[U+1]=v.readInt32BE(U*4+4);for(;U<160;U+=2){var Q=q[U-30],K=q[U-30+1],R=H(Q,K),A=D(K,Q);Q=q[U-4],K=q[U-4+1];var S=E(Q,K),x=L(K,Q),B=q[U-14],c=q[U-14+1],q0=q[U-32],h=q[U-32+1],d=A+c|0,_0=R+B+M(d,A)|0;d=d+x|0,_0=_0+S+M(d,x)|0,d=d+h|0,_0=_0+q0+M(d,h)|0,q[U]=_0,q[U+1]=d}for(var l=0;l<160;l+=2){_0=q[l],d=q[l+1];var n=T(g,y,w),y0=T(v0,$,Y),t=W(g,v0),s=W(v0,g),w0=J(b,Z),m=J(Z,b),r=z[l],$$=z[l+1],i=P(b,u,Y0),e=P(Z,V,I),x0=O+m|0,o=p+w0+M(x0,O)|0;x0=x0+e|0,o=o+i+M(x0,e)|0,x0=x0+$$|0,o=o+r+M(x0,$$)|0,x0=x0+d|0,o=o+_0+M(x0,d)|0;var a=s+y0|0,p0=t+n+M(a,s)|0;p=Y0,O=I,Y0=u,I=V,u=b,V=Z,Z=G+x0|0,b=f+o+M(Z,G)|0,f=w,G=Y,w=y,Y=$,y=g,$=v0,v0=x0+a|0,g=o+p0+M(v0,x0)|0}this._al=this._al+v0|0,this._bl=this._bl+$|0,this._cl=this._cl+Y|0,this._dl=this._dl+G|0,this._el=this._el+Z|0,this._fl=this._fl+V|0,this._gl=this._gl+I|0,this._hl=this._hl+O|0,this._ah=this._ah+g+M(this._al,v0)|0,this._bh=this._bh+y+M(this._bl,$)|0,this._ch=this._ch+w+M(this._cl,Y)|0,this._dh=this._dh+f+M(this._dl,G)|0,this._eh=this._eh+b+M(this._el,Z)|0,this._fh=this._fh+u+M(this._fl,V)|0,this._gh=this._gh+Y0+M(this._gl,I)|0,this._hh=this._hh+p+M(this._hl,O)|0},C.prototype._hash=function(){var v=F.allocUnsafe(64);function q(g,y,w){v.writeInt32BE(g,w),v.writeInt32BE(y,w+4)}return q(this._ah,this._al,0),q(this._bh,this._bl,8),q(this._ch,this._cl,16),q(this._dh,this._dl,24),q(this._eh,this._el,32),q(this._fh,this._fl,40),q(this._gh,this._gl,48),q(this._hh,this._hl,56),v},_.exports=C}}),tQ=S0({"node_modules/sha.js/sha384.js"(N,_){var k=B0(),j=GQ(),F=R$(),z=N0().Buffer,X=new Array(160);function C(){this.init(),this._w=X,F.call(this,128,112)}k(C,j),C.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},C.prototype._hash=function(){var P=z.allocUnsafe(48);function T(W,J,H){P.writeInt32BE(W,H),P.writeInt32BE(J,H+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),P},_.exports=C}}),VQ=S0({"node_modules/sha.js/index.js"(k,_){var k=_.exports=function(j){j=j.toLowerCase();var F=k[j];if(!F)throw new Error(j+" is not supported (we accept pull requests)");return new F};k.sha=uQ(),k.sha1=nQ(),k.sha224=sQ(),k.sha256=ZQ(),k.sha384=tQ(),k.sha512=GQ()}}),C$=S0({"node_modules/cipher-base/index.js"(N,_){var k=N0().Buffer,j=B0();function F(z){A$.Transform.call(this),this.hashMode=typeof z=="string",this.hashMode?this[z]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}j(F,A$.Transform),F.prototype.update=function(z,X,C){typeof z=="string"&&(z=k.from(z,X));var P=this._update(z);return this.hashMode?this:(C&&(P=this._toString(P,C)),P)},F.prototype.setAutoPadding=function(){},F.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},F.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},F.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},F.prototype._transform=function(z,X,C){var P;try{this.hashMode?this._update(z):this.push(this._update(z))}catch(T){P=T}finally{C(P)}},F.prototype._flush=function(z){var X;try{this.push(this.__final())}catch(C){X=C}z(X)},F.prototype._finalOrDigest=function(z){var X=this.__final()||k.alloc(0);return z&&(X=this._toString(X,z,!0)),X},F.prototype._toString=function(z,X,C){if(this._decoder||(this._decoder=new bQ(X),this._encoding=X),this._encoding!==X)throw new Error("can't switch encodings");var P=this._decoder.write(z);return C&&(P+=this._decoder.end()),P},_.exports=F}}),M$=S0({"node_modules/create-hash/browser.js"(N,_){const k=function z(X,C){this._options=C,this._hasher=new mY(X,C),this._finalized=!1};k.prototype=Object.create(A$.Transform.prototype),k.prototype.update=function z(X,C){return this._checkFinalized(),this._hasher.update(X,C),this},k.prototype.digest=function z(X,C){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(X,C)},k.prototype._checkFinalized=function z(){if(this._finalized){var X=new Error("Digest already called");throw X.code="ERR_CRYPTO_HASH_FINALIZED",X}},k.prototype.copy=function z(){const X=Object.create(k.prototype);return X._options=this._options,X._hasher=this._hasher.copy(),X._finalized=this._finalized,X};const j={__proto__:A$.Transform.prototype,...k.prototype,_transform(z,X,C){this.update(z,X),C&&C()},_flush(z){this.push(this.digest()),z()}},F=["_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 z of F)Object.defineProperty(k.prototype,z,{get(){return Object.setPrototypeOf(this,j),A$.Transform.call(this,this._options),this[z]},enumerable:!1,configurable:!0});_.exports=function z(X){return new k(X)},_.exports.createHash=_.exports,_.exports.Hash=k}}),mQ=S0({"node_modules/create-hmac/legacy.js"(N,_){var k=B0(),j=N0().Buffer,F=C$(),z=j.alloc(128),X=64;function C(P,T){F.call(this,"digest"),typeof T=="string"&&(T=j.from(T)),this._alg=P,this._key=T,T.length>X?T=P(T):T.lengthD){var E=J==="rmd160"?new C:P(J);H=E.update(H).digest()}else H.lengthk||F!==F)throw new TypeError("Bad key length")}}}),OQ=S0({"node_modules/pbkdf2/lib/default-encoding.js"(N,_){var k;global.process&&global.process.browser?k="utf-8":global.process&&global.process.version?(j=parseInt(process.version.split(".")[0].slice(1),10),k=j>=6?"utf-8":"binary"):k="utf-8";var j;_.exports=k}}),JQ=S0({"node_modules/pbkdf2/lib/to-buffer.js"(N,_){var k=N0().Buffer;_.exports=function(j,F,z){if(k.isBuffer(j))return j;if(typeof j=="string")return k.from(j,F);if(ArrayBuffer.isView(j))return k.from(j.buffer);throw new TypeError(z+" must be a string, a Buffer, a typed array or a DataView")}}}),FQ=S0({"node_modules/pbkdf2/lib/sync-browser.js"(N,_){var k=UQ(),j=YQ(),F=VQ(),z=N0().Buffer,X=IQ(),C=OQ(),P=JQ(),T=z.alloc(128),W={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function J(E,L,M){var v=H(E),q=E==="sha512"||E==="sha384"?128:64;L.length>q?L=v(L):L.length>>0},N.writeUInt32BE=function(F,z,X){F[0+X]=z>>>24,F[1+X]=z>>>16&255,F[2+X]=z>>>8&255,F[3+X]=z&255},N.ip=function(F,z,X,C){for(var P=0,T=0,W=6;W>=0;W-=2){for(var J=0;J<=24;J+=8)P<<=1,P|=z>>>J+W&1;for(var J=0;J<=24;J+=8)P<<=1,P|=F>>>J+W&1}for(var W=6;W>=0;W-=2){for(var J=1;J<=25;J+=8)T<<=1,T|=z>>>J+W&1;for(var J=1;J<=25;J+=8)T<<=1,T|=F>>>J+W&1}X[C+0]=P>>>0,X[C+1]=T>>>0},N.rip=function(F,z,X,C){for(var P=0,T=0,W=0;W<4;W++)for(var J=24;J>=0;J-=8)P<<=1,P|=z>>>J+W&1,P<<=1,P|=F>>>J+W&1;for(var W=4;W<8;W++)for(var J=24;J>=0;J-=8)T<<=1,T|=z>>>J+W&1,T<<=1,T|=F>>>J+W&1;X[C+0]=P>>>0,X[C+1]=T>>>0},N.pc1=function(F,z,X,C){for(var P=0,T=0,W=7;W>=5;W--){for(var J=0;J<=24;J+=8)P<<=1,P|=z>>J+W&1;for(var J=0;J<=24;J+=8)P<<=1,P|=F>>J+W&1}for(var J=0;J<=24;J+=8)P<<=1,P|=z>>J+W&1;for(var W=1;W<=3;W++){for(var J=0;J<=24;J+=8)T<<=1,T|=z>>J+W&1;for(var J=0;J<=24;J+=8)T<<=1,T|=F>>J+W&1}for(var J=0;J<=24;J+=8)T<<=1,T|=F>>J+W&1;X[C+0]=P>>>0,X[C+1]=T>>>0},N.r28shl=function(F,z){return F<>>28-z};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];N.pc2=function(F,z,X,C){for(var P=0,T=0,W=_.length>>>1,J=0;J>>_[J]&1;for(var J=W;J<_.length;J++)T<<=1,T|=z>>>_[J]&1;X[C+0]=P>>>0,X[C+1]=T>>>0},N.expand=function(F,z,X){var C=0,P=0;C=(F&1)<<5|F>>>27;for(var T=23;T>=15;T-=4)C<<=6,C|=F>>>T&63;for(var T=11;T>=3;T-=4)P|=F>>>T&63,P<<=6;P|=(F&31)<<1|F>>>31,z[X+0]=C>>>0,z[X+1]=P>>>0};var k=[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];N.substitute=function(F,z){for(var X=0,C=0;C<4;C++){var P=F>>>18-C*6&63,T=k[C*64+P];X<<=4,X|=T}for(var C=0;C<4;C++){var P=z>>>18-C*6&63,T=k[256+C*64+P];X<<=4,X|=T}return X>>>0};var j=[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];N.permute=function(F){for(var z=0,X=0;X>>j[X]&1;return z>>>0},N.padSplit=function(F,z,X){for(var C=F.toString(2);C.length0;C--)z+=this._buffer(F,z),X+=this._flushBuffer(P,X);return z+=this._buffer(F,z),P},j.prototype.final=function(F){var z;F&&(z=this.update(F));var X;return this.type==="encrypt"?X=this._finalEncrypt():X=this._finalDecrypt(),z?z.concat(X):X},j.prototype._pad=function(F,z){if(z===0)return!1;for(;z>>1];J=F.r28shl(J,E),H=F.r28shl(H,E),F.pc2(J,H,T.keys,D)}},C.prototype._update=function(T,W,J,H){var D=this._desState,E=F.readUInt32BE(T,W),L=F.readUInt32BE(T,W+4);F.ip(E,L,D.tmp,0),E=D.tmp[0],L=D.tmp[1],this.type==="encrypt"?this._encrypt(D,E,L,D.tmp,0):this._decrypt(D,E,L,D.tmp,0),E=D.tmp[0],L=D.tmp[1],F.writeUInt32BE(J,E,H),F.writeUInt32BE(J,L,H+4)},C.prototype._pad=function(T,W){for(var J=T.length-W,H=W;H>>0,E=w}F.rip(L,E,H,D)},C.prototype._decrypt=function(T,W,J,H,D){for(var E=J,L=W,M=T.keys.length-2;M>=0;M-=2){var v=T.keys[M],q=T.keys[M+1];F.expand(E,T.tmp,0),v^=T.tmp[0],q^=T.tmp[1];var g=F.substitute(v,q),y=F.permute(g),w=E;E=(L^y)>>>0,L=w}F.rip(E,L,H,D)}}}),rQ=S0({"node_modules/des.js/lib/des/cbc.js"(N){var _=W$(),k=B0(),j={};function F(X){_.equal(X.length,8,"Invalid IV length"),this.iv=new Array(8);for(var C=0;C>P%8,F._prev=j(F._prev,X?J:H);return W}function j(F,z){var X=F.length,C=-1,P=_.allocUnsafe(F.length);for(F=_.concat([F,_.from([z])]);++C>7;return P}N.encrypt=function(F,z,X){for(var C=z.length,P=_.allocUnsafe(C),T=-1;++T>>24]^L[g>>>16&255]^M[y>>>8&255]^v[w&255]^W[p++],b=E[g>>>24]^L[y>>>16&255]^M[w>>>8&255]^v[q&255]^W[p++],u=E[y>>>24]^L[w>>>16&255]^M[q>>>8&255]^v[g&255]^W[p++],Y0=E[w>>>24]^L[q>>>16&255]^M[g>>>8&255]^v[y&255]^W[p++],q=f,g=b,y=u,w=Y0;return f=(H[q>>>24]<<24|H[g>>>16&255]<<16|H[y>>>8&255]<<8|H[w&255])^W[p++],b=(H[g>>>24]<<24|H[y>>>16&255]<<16|H[w>>>8&255]<<8|H[q&255])^W[p++],u=(H[y>>>24]<<24|H[w>>>16&255]<<16|H[q>>>8&255]<<8|H[g&255])^W[p++],Y0=(H[w>>>24]<<24|H[q>>>16&255]<<16|H[g>>>8&255]<<8|H[y&255])^W[p++],f=f>>>0,b=b>>>0,u=u>>>0,Y0=Y0>>>0,[f,b,u,Y0]}var X=[0,1,2,4,8,16,32,64,128,27,54],C=function(){for(var T=new Array(256),W=0;W<256;W++)W<128?T[W]=W<<1:T[W]=W<<1^283;for(var J=[],H=[],D=[[],[],[],[]],E=[[],[],[],[]],L=0,M=0,v=0;v<256;++v){var q=M^M<<1^M<<2^M<<3^M<<4;q=q>>>8^q&255^99,J[L]=q,H[q]=L;var g=T[L],y=T[g],w=T[y],f=T[q]*257^q*16843008;D[0][L]=f<<24|f>>>8,D[1][L]=f<<16|f>>>16,D[2][L]=f<<8|f>>>24,D[3][L]=f,f=w*16843009^y*65537^g*257^L*16843008,E[0][q]=f<<24|f>>>8,E[1][q]=f<<16|f>>>16,E[2][q]=f<<8|f>>>24,E[3][q]=f,L===0?L=M=1:(L=g^T[T[T[w^g]]],M^=T[T[M]])}return{SBOX:J,INV_SBOX:H,SUB_MIX:D,INV_SUB_MIX:E}}();function P(T){this._key=j(T),this._reset()}P.blockSize=16,P.keySize=32,P.prototype.blockSize=P.blockSize,P.prototype.keySize=P.keySize,P.prototype._reset=function(){for(var T=this._key,W=T.length,J=W+6,H=(J+1)*4,D=[],E=0;E>>24,L=C.SBOX[L>>>24]<<24|C.SBOX[L>>>16&255]<<16|C.SBOX[L>>>8&255]<<8|C.SBOX[L&255],L^=X[E/W|0]<<24):W>6&&E%W===4&&(L=C.SBOX[L>>>24]<<24|C.SBOX[L>>>16&255]<<16|C.SBOX[L>>>8&255]<<8|C.SBOX[L&255]),D[E]=D[E-W]^L}for(var M=[],v=0;v>>24]]^C.INV_SUB_MIX[1][C.SBOX[g>>>16&255]]^C.INV_SUB_MIX[2][C.SBOX[g>>>8&255]]^C.INV_SUB_MIX[3][C.SBOX[g&255]]}this._nRounds=J,this._keySchedule=D,this._invKeySchedule=M},P.prototype.encryptBlockRaw=function(T){return T=j(T),z(T,this._keySchedule,C.SUB_MIX,C.SBOX,this._nRounds)},P.prototype.encryptBlock=function(T){var W=this.encryptBlockRaw(T),J=k.allocUnsafe(16);return J.writeUInt32BE(W[0],0),J.writeUInt32BE(W[1],4),J.writeUInt32BE(W[2],8),J.writeUInt32BE(W[3],12),J},P.prototype.decryptBlock=function(T){T=j(T);var W=T[1];T[1]=T[3],T[3]=W;var J=z(T,this._invKeySchedule,C.INV_SUB_MIX,C.INV_SBOX,this._nRounds),H=k.allocUnsafe(16);return H.writeUInt32BE(J[0],0),H.writeUInt32BE(J[3],4),H.writeUInt32BE(J[2],8),H.writeUInt32BE(J[1],12),H},P.prototype.scrub=function(){F(this._keySchedule),F(this._invKeySchedule),F(this._key)},_.exports.AES=P}}),KY=S0({"node_modules/browserify-aes/ghash.js"(N,_){var k=N0().Buffer,j=k.alloc(16,0);function F(C){return[C.readUInt32BE(0),C.readUInt32BE(4),C.readUInt32BE(8),C.readUInt32BE(12)]}function z(C){var P=k.allocUnsafe(16);return P.writeUInt32BE(C[0]>>>0,0),P.writeUInt32BE(C[1]>>>0,4),P.writeUInt32BE(C[2]>>>0,8),P.writeUInt32BE(C[3]>>>0,12),P}function X(C){this.h=C,this.state=k.alloc(16,0),this.cache=k.allocUnsafe(0)}X.prototype.ghash=function(C){for(var P=-1;++P0;T--)C[T]=C[T]>>>1|(C[T-1]&1)<<31;C[0]=C[0]>>>1,J&&(C[0]=C[0]^225<<24)}this.state=z(P)},X.prototype.update=function(C){this.cache=k.concat([this.cache,C]);for(var P;this.cache.length>=16;)P=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(P)},X.prototype.final=function(C,P){return this.cache.length&&this.ghash(k.concat([this.cache,j],16)),this.ghash(z([0,C,0,P])),this.state},_.exports=X}}),DQ=S0({"node_modules/browserify-aes/authCipher.js"(N,_){var k=q$(),j=N0().Buffer,F=C$(),z=B0(),X=KY(),C=S$(),P=EQ();function T(H,D){var E=0;H.length!==D.length&&E++;for(var L=Math.min(H.length,D.length),M=0;M0||P>0;){var D=new j;D.update(H),D.update(z),X&&D.update(X),H=D.digest();var E=0;if(T>0){var L=W.length-T;E=Math.min(T,H.length),H.copy(W,L,0,E),T-=E}if(E0){var M=J.length-P,v=Math.min(P,H.length-E);H.copy(J,M,E,E+v),P-=v}}return H.fill(0),{key:W,iv:J}}_.exports=F}}),IY=S0({"node_modules/browserify-aes/encrypter.js"(N){var _=w$(),k=DQ(),j=N0().Buffer,F=CQ(),z=C$(),X=q$(),C=j$(),P=B0();function T(E,L,M){z.call(this),this._cache=new J,this._cipher=new X.AES(L),this._prev=j.from(M),this._mode=E,this._autopadding=!0}P(T,z),T.prototype._update=function(E){this._cache.add(E);for(var L,M,v=[];L=this._cache.get();)M=this._mode.encrypt(this,L),v.push(M);return j.concat(v)};var W=j.alloc(16,16);T.prototype._final=function(){var E=this._cache.flush();if(this._autopadding)return E=this._mode.encrypt(this,E),this._cipher.scrub(),E;if(!E.equals(W))throw this._cipher.scrub(),new Error("data not multiple of block length")},T.prototype.setAutoPadding=function(E){return this._autopadding=!!E,this};function J(){this.cache=j.allocUnsafe(0)}J.prototype.add=function(E){this.cache=j.concat([this.cache,E])},J.prototype.get=function(){if(this.cache.length>15){var E=this.cache.slice(0,16);return this.cache=this.cache.slice(16),E}return null},J.prototype.flush=function(){for(var E=16-this.cache.length,L=j.allocUnsafe(E),M=-1;++M16)return L=this.cache.slice(0,16),this.cache=this.cache.slice(16),L}else if(this.cache.length>=16)return L=this.cache.slice(0,16),this.cache=this.cache.slice(16),L;return null},W.prototype.flush=function(){if(this.cache.length)return this.cache};function J(E){var L=E[15];if(L<1||L>16)throw new Error("unable to decrypt data");for(var M=-1;++M0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),AY=S0({"node_modules/miller-rabin/node_modules/bn.js/lib/bn.js"(N,_){(function(k,j){function F($,Y){if(!$)throw new Error(Y||"Assertion failed")}function z($,Y){$.super_=Y;var G=function(){};G.prototype=Y.prototype,$.prototype=new G,$.prototype.constructor=$}function X($,Y,G){if(X.isBN($))return $;this.negative=0,this.words=null,this.length=0,this.red=null,$!==null&&((Y==="le"||Y==="be")&&(G=Y,Y=10),this._init($||0,Y||10,G||"be"))}typeof k=="object"?k.exports=X:j.BN=X,X.BN=X,X.wordSize=26;var C=g0;X.isBN=function($){return $ instanceof X?!0:$!==null&&typeof $=="object"&&$.constructor.wordSize===X.wordSize&&Array.isArray($.words)},X.max=function($,Y){return $.cmp(Y)>0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),VZ=S0({"(disabled):node_modules/crypto-browserify/index.js"(){}}),f$=S0({"node_modules/brorand/index.js"(N,_){var k;_.exports=function(F){return k||(k=new j(null)),k.generate(F)};function j(F){this.rand=F}_.exports.Rand=j,j.prototype.generate=function(F){return this._rand(F)},j.prototype._rand=function(F){var z=new g0(F);return H$.getRandomValues(z),z}}}),RQ=S0({"node_modules/miller-rabin/lib/mr.js"(N,_){var k=AY(),j=f$();function F(z){this.rand=z||new j.Rand}_.exports=F,F.create=function(z){return new F(z)},F.prototype._randbelow=function(z){var X=z.bitLength(),C=Math.ceil(X/8);do var P=new k(this.rand.generate(C));while(P.cmp(z)>=0);return P},F.prototype._randrange=function(z,X){var C=X.sub(z);return z.add(this._randbelow(C))},F.prototype.test=function(z,X,C){var P=z.bitLength(),T=k.mont(z),W=new k(1).toRed(T);X||(X=Math.max(1,P/48|0));for(var J=z.subn(1),H=0;!J.testn(H);H++);for(var D=z.shrn(H),E=J.toRed(T),L=!0;X>0;X--){var M=this._randrange(new k(2),J);C&&C(M);var v=M.toRed(T).redPow(D);if(!(v.cmp(W)===0||v.cmp(E)===0)){for(var q=1;q0;X--){var E=this._randrange(new k(2),W),L=z.gcd(E);if(L.cmpn(1)!==0)return L;var M=E.toRed(P).redPow(H);if(!(M.cmp(T)===0||M.cmp(D)===0)){for(var v=1;vb;)Y0.ishrn(1);if(Y0.isEven()&&Y0.iadd(C),Y0.testn(1)||Y0.iadd(P),u.cmp(P)){if(!u.cmp(T))for(;Y0.mod(H).cmp(D);)Y0.iadd(M)}else for(;Y0.mod(F).cmp(L);)Y0.iadd(M);if(p=Y0.shrn(1),y(p)&&y(Y0)&&w(p)&&w(Y0)&&X.test(p)&&X.test(Y0))return Y0}}}}),HY=S0({"node_modules/diffie-hellman/lib/primes.json"(N,_){_.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"}}}}),WY=S0({"node_modules/diffie-hellman/lib/dh.js"(N,_){var k=LQ(),j=RQ(),F=new j,z=new k(24),X=new k(11),C=new k(10),P=new k(3),T=new k(7),W=PQ(),J=L$();_.exports=M;function H(q,g){return g=g||"utf8",g0.isBuffer(q)||(q=new g0(q,g)),this._pub=new k(q),this}function D(q,g){return g=g||"utf8",g0.isBuffer(q)||(q=new g0(q,g)),this._priv=new k(q),this}var E={};function L(q,g){var y=g.toString("hex"),w=[y,q.toString(16)].join("_");if(w in E)return E[w];var f=0;if(q.isEven()||!W.simpleSieve||!W.fermatTest(q)||!F.test(q))return f+=1,y==="02"||y==="05"?f+=8:f+=4,E[w]=f,f;F.test(q.shrn(1))||(f+=2);var b;switch(y){case"02":q.mod(z).cmp(X)&&(f+=8);break;case"05":b=q.mod(C),b.cmp(P)&&b.cmp(T)&&(f+=8);break;default:f+=4}return E[w]=f,f}function M(q,g,y){this.setGenerator(g),this.__prime=new k(q),this._prime=k.mont(this.__prime),this._primeLen=q.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,y?(this.setPublicKey=H,this.setPrivateKey=D):this._primeCode=8}Object.defineProperty(M.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=L(this.__prime,this.__gen)),this._primeCode}}),M.prototype.generateKeys=function(){return this._priv||(this._priv=new k(J(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},M.prototype.computeSecret=function(q){q=new k(q),q=q.toRed(this._prime);var g=q.redPow(this._priv).fromRed(),y=new g0(g.toArray()),w=this.getPrime();if(y.length0?Z:V},X.min=function(Z,V){return Z.cmp(V)<0?Z:V},X.prototype._init=function(Z,V,I){if(typeof Z=="number")return this._initNumber(Z,V,I);if(typeof Z=="object")return this._initArray(Z,V,I);V==="hex"&&(V=16),F(V===(V|0)&&V>=2&&V<=36),Z=Z.toString().replace(/\s+/g,"");var O=0;Z[0]==="-"&&(O++,this.negative=1),O=0;O-=3)Q=Z[O]|Z[O-1]<<8|Z[O-2]<<16,this.words[U]|=Q<>>26-K&67108863,K+=24,K>=26&&(K-=26,U++);else if(I==="le")for(O=0,U=0;O>>26-K&67108863,K+=24,K>=26&&(K-=26,U++);return this._strip()};function P(Z,V){var I=Z.charCodeAt(V);if(I>=48&&I<=57)return I-48;if(I>=65&&I<=70)return I-55;if(I>=97&&I<=102)return I-87;F(!1,"Invalid character in "+Z)}function T(Z,V,I){var O=P(Z,I);return I-1>=V&&(O|=P(Z,I-1)<<4),O}X.prototype._parseHex=function(Z,V,I){this.length=Math.ceil((Z.length-V)/6),this.words=new Array(this.length);for(var O=0;O=V;O-=2)K=T(Z,V,O)<=18?(U-=18,Q+=1,this.words[Q]|=K>>>26):U+=8;else{var R=Z.length-V;for(O=R%2===0?V+1:V;O=18?(U-=18,Q+=1,this.words[Q]|=K>>>26):U+=8}this._strip()};function W(Z,V,I,O){for(var U=0,Q=0,K=Math.min(Z.length,I),R=V;R=49?Q=A-49+10:A>=17?Q=A-17+10:Q=A,F(A>=0&&Q1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{X.prototype[Symbol.for("nodejs.util.inspect.custom")]=H}catch{X.prototype.inspect=H}else X.prototype.inspect=H;function H(){return(this.red?""}var D=["","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"],E=[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],L=[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];X.prototype.toString=function(Z,V){Z=Z||10,V=V|0||1;var I;if(Z===16||Z==="hex"){I="";for(var O=0,U=0,Q=0;Q>>24-O&16777215,O+=2,O>=26&&(O-=26,Q--),U!==0||Q!==this.length-1?I=D[6-R.length]+R+I:I=R+I}for(U!==0&&(I=U.toString(16)+I);I.length%V!==0;)I="0"+I;return this.negative!==0&&(I="-"+I),I}if(Z===(Z|0)&&Z>=2&&Z<=36){var A=E[Z],S=L[Z];I="";var x=this.clone();for(x.negative=0;!x.isZero();){var B=x.modrn(S).toString(Z);x=x.idivn(S),x.isZero()?I=B+I:I=D[A-B.length]+B+I}for(this.isZero()&&(I="0"+I);I.length%V!==0;)I="0"+I;return this.negative!==0&&(I="-"+I),I}F(!1,"Base should be between 2 and 36")},X.prototype.toNumber=function(){var Z=this.words[0];return this.length===2?Z+=this.words[1]*67108864:this.length===3&&this.words[2]===1?Z+=4503599627370496+this.words[1]*67108864:this.length>2&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-Z:Z},X.prototype.toJSON=function(){return this.toString(16,2)},C&&(X.prototype.toBuffer=function(Z,V){return this.toArrayLike(C,Z,V)}),X.prototype.toArray=function(Z,V){return this.toArrayLike(Array,Z,V)};var M=function(Z,V){return Z.allocUnsafe?Z.allocUnsafe(V):new Z(V)};X.prototype.toArrayLike=function(Z,V,I){this._strip();var O=this.byteLength(),U=I||Math.max(1,O);F(O<=U,"byte array longer than desired length"),F(U>0,"Requested array length <= 0");var Q=M(Z,U),K=V==="le"?"LE":"BE";return this["_toArrayLike"+K](Q,O),Q},X.prototype._toArrayLikeLE=function(Z,V){for(var I=0,O=0,U=0,Q=0;U>8&255),I>16&255),Q===6?(I>24&255),O=0,Q=0):(O=K>>>24,Q+=2)}if(I=0&&(Z[I--]=K>>8&255),I>=0&&(Z[I--]=K>>16&255),Q===6?(I>=0&&(Z[I--]=K>>24&255),O=0,Q=0):(O=K>>>24,Q+=2)}if(I>=0)for(Z[I--]=O;I>=0;)Z[I--]=0},Math.clz32?X.prototype._countBits=function(Z){return 32-Math.clz32(Z)}:X.prototype._countBits=function(Z){var V=Z,I=0;return V>=4096&&(I+=13,V>>>=13),V>=64&&(I+=7,V>>>=7),V>=8&&(I+=4,V>>>=4),V>=2&&(I+=2,V>>>=2),I+V},X.prototype._zeroBits=function(Z){if(Z===0)return 26;var V=Z,I=0;return(V&8191)===0&&(I+=13,V>>>=13),(V&127)===0&&(I+=7,V>>>=7),(V&15)===0&&(I+=4,V>>>=4),(V&3)===0&&(I+=2,V>>>=2),(V&1)===0&&I++,I},X.prototype.bitLength=function(){var Z=this.words[this.length-1],V=this._countBits(Z);return(this.length-1)*26+V};function v(Z){for(var V=new Array(Z.bitLength()),I=0;I>>U&1}return V}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var Z=0,V=0;VZ.length?this.clone().ior(Z):Z.clone().ior(this)},X.prototype.uor=function(Z){return this.length>Z.length?this.clone().iuor(Z):Z.clone().iuor(this)},X.prototype.iuand=function(Z){var V;this.length>Z.length?V=Z:V=this;for(var I=0;IZ.length?this.clone().iand(Z):Z.clone().iand(this)},X.prototype.uand=function(Z){return this.length>Z.length?this.clone().iuand(Z):Z.clone().iuand(this)},X.prototype.iuxor=function(Z){var V,I;this.length>Z.length?(V=this,I=Z):(V=Z,I=this);for(var O=0;OZ.length?this.clone().ixor(Z):Z.clone().ixor(this)},X.prototype.uxor=function(Z){return this.length>Z.length?this.clone().iuxor(Z):Z.clone().iuxor(this)},X.prototype.inotn=function(Z){F(typeof Z=="number"&&Z>=0);var V=Math.ceil(Z/26)|0,I=Z%26;this._expand(V),I>0&&V--;for(var O=0;O0&&(this.words[O]=~this.words[O]&67108863>>26-I),this._strip()},X.prototype.notn=function(Z){return this.clone().inotn(Z)},X.prototype.setn=function(Z,V){F(typeof Z=="number"&&Z>=0);var I=Z/26|0,O=Z%26;return this._expand(I+1),V?this.words[I]=this.words[I]|1<Z.length?(I=this,O=Z):(I=Z,O=this);for(var U=0,Q=0;Q>>26;for(;U!==0&&Q>>26;if(this.length=I.length,U!==0)this.words[this.length]=U,this.length++;else if(I!==this)for(;QZ.length?this.clone().iadd(Z):Z.clone().iadd(this)},X.prototype.isub=function(Z){if(Z.negative!==0){Z.negative=0;var V=this.iadd(Z);return Z.negative=1,V._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Z),this.negative=1,this._normSign();var I=this.cmp(Z);if(I===0)return this.negative=0,this.length=1,this.words[0]=0,this;var O,U;I>0?(O=this,U=Z):(O=Z,U=this);for(var Q=0,K=0;K>26,this.words[K]=V&67108863;for(;Q!==0&&K>26,this.words[K]=V&67108863;if(Q===0&&K>>26,B=A&67108863,c=Math.min(S,V.length-1),q0=Math.max(0,S-Z.length+1);q0<=c;q0++){var h=S-q0|0;U=Z.words[h]|0,Q=V.words[q0]|0,K=U*Q+B,x+=K/67108864|0,B=K&67108863}I.words[S]=B|0,A=x|0}return A!==0?I.words[S]=A|0:I.length--,I._strip()}var g=function(Z,V,I){var O=Z.words,U=V.words,Q=I.words,K=0,R,A,S,x=O[0]|0,B=x&8191,c=x>>>13,q0=O[1]|0,h=q0&8191,d=q0>>>13,_0=O[2]|0,l=_0&8191,n=_0>>>13,y0=O[3]|0,t=y0&8191,s=y0>>>13,w0=O[4]|0,m=w0&8191,r=w0>>>13,$$=O[5]|0,i=$$&8191,e=$$>>>13,x0=O[6]|0,o=x0&8191,a=x0>>>13,p0=O[7]|0,$0=p0&8191,Q0=p0>>>13,Y$=O[8]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=O[9]|0,V0=Z$&8191,U0=Z$>>>13,G$=U[0]|0,X0=G$&8191,K0=G$>>>13,V$=U[1]|0,I0=V$&8191,O0=V$>>>13,U$=U[2]|0,J0=U$&8191,F0=U$>>>13,X$=U[3]|0,A0=X$&8191,H0=X$>>>13,K$=U[4]|0,W0=K$&8191,E0=K$>>>13,I$=U[5]|0,T0=I$&8191,D0=I$>>>13,O$=U[6]|0,C0=O$&8191,L0=O$>>>13,J$=U[7]|0,R0=J$&8191,P0=J$>>>13,F$=U[8]|0,z0=F$&8191,M0=F$>>>13,Q$=U[9]|0,j0=Q$&8191,k0=Q$>>>13;I.negative=Z.negative^V.negative,I.length=19,R=Math.imul(B,X0),A=Math.imul(B,K0),A=A+Math.imul(c,X0)|0,S=Math.imul(c,K0);var f0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(f0>>>26)|0,f0&=67108863,R=Math.imul(h,X0),A=Math.imul(h,K0),A=A+Math.imul(d,X0)|0,S=Math.imul(d,K0),R=R+Math.imul(B,I0)|0,A=A+Math.imul(B,O0)|0,A=A+Math.imul(c,I0)|0,S=S+Math.imul(c,O0)|0;var c0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(c0>>>26)|0,c0&=67108863,R=Math.imul(l,X0),A=Math.imul(l,K0),A=A+Math.imul(n,X0)|0,S=Math.imul(n,K0),R=R+Math.imul(h,I0)|0,A=A+Math.imul(h,O0)|0,A=A+Math.imul(d,I0)|0,S=S+Math.imul(d,O0)|0,R=R+Math.imul(B,J0)|0,A=A+Math.imul(B,F0)|0,A=A+Math.imul(c,J0)|0,S=S+Math.imul(c,F0)|0;var h0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(h0>>>26)|0,h0&=67108863,R=Math.imul(t,X0),A=Math.imul(t,K0),A=A+Math.imul(s,X0)|0,S=Math.imul(s,K0),R=R+Math.imul(l,I0)|0,A=A+Math.imul(l,O0)|0,A=A+Math.imul(n,I0)|0,S=S+Math.imul(n,O0)|0,R=R+Math.imul(h,J0)|0,A=A+Math.imul(h,F0)|0,A=A+Math.imul(d,J0)|0,S=S+Math.imul(d,F0)|0,R=R+Math.imul(B,A0)|0,A=A+Math.imul(B,H0)|0,A=A+Math.imul(c,A0)|0,S=S+Math.imul(c,H0)|0;var d0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(d0>>>26)|0,d0&=67108863,R=Math.imul(m,X0),A=Math.imul(m,K0),A=A+Math.imul(r,X0)|0,S=Math.imul(r,K0),R=R+Math.imul(t,I0)|0,A=A+Math.imul(t,O0)|0,A=A+Math.imul(s,I0)|0,S=S+Math.imul(s,O0)|0,R=R+Math.imul(l,J0)|0,A=A+Math.imul(l,F0)|0,A=A+Math.imul(n,J0)|0,S=S+Math.imul(n,F0)|0,R=R+Math.imul(h,A0)|0,A=A+Math.imul(h,H0)|0,A=A+Math.imul(d,A0)|0,S=S+Math.imul(d,H0)|0,R=R+Math.imul(B,W0)|0,A=A+Math.imul(B,E0)|0,A=A+Math.imul(c,W0)|0,S=S+Math.imul(c,E0)|0;var b0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(b0>>>26)|0,b0&=67108863,R=Math.imul(i,X0),A=Math.imul(i,K0),A=A+Math.imul(e,X0)|0,S=Math.imul(e,K0),R=R+Math.imul(m,I0)|0,A=A+Math.imul(m,O0)|0,A=A+Math.imul(r,I0)|0,S=S+Math.imul(r,O0)|0,R=R+Math.imul(t,J0)|0,A=A+Math.imul(t,F0)|0,A=A+Math.imul(s,J0)|0,S=S+Math.imul(s,F0)|0,R=R+Math.imul(l,A0)|0,A=A+Math.imul(l,H0)|0,A=A+Math.imul(n,A0)|0,S=S+Math.imul(n,H0)|0,R=R+Math.imul(h,W0)|0,A=A+Math.imul(h,E0)|0,A=A+Math.imul(d,W0)|0,S=S+Math.imul(d,E0)|0,R=R+Math.imul(B,T0)|0,A=A+Math.imul(B,D0)|0,A=A+Math.imul(c,T0)|0,S=S+Math.imul(c,D0)|0;var l0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(l0>>>26)|0,l0&=67108863,R=Math.imul(o,X0),A=Math.imul(o,K0),A=A+Math.imul(a,X0)|0,S=Math.imul(a,K0),R=R+Math.imul(i,I0)|0,A=A+Math.imul(i,O0)|0,A=A+Math.imul(e,I0)|0,S=S+Math.imul(e,O0)|0,R=R+Math.imul(m,J0)|0,A=A+Math.imul(m,F0)|0,A=A+Math.imul(r,J0)|0,S=S+Math.imul(r,F0)|0,R=R+Math.imul(t,A0)|0,A=A+Math.imul(t,H0)|0,A=A+Math.imul(s,A0)|0,S=S+Math.imul(s,H0)|0,R=R+Math.imul(l,W0)|0,A=A+Math.imul(l,E0)|0,A=A+Math.imul(n,W0)|0,S=S+Math.imul(n,E0)|0,R=R+Math.imul(h,T0)|0,A=A+Math.imul(h,D0)|0,A=A+Math.imul(d,T0)|0,S=S+Math.imul(d,D0)|0,R=R+Math.imul(B,C0)|0,A=A+Math.imul(B,L0)|0,A=A+Math.imul(c,C0)|0,S=S+Math.imul(c,L0)|0;var o0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(o0>>>26)|0,o0&=67108863,R=Math.imul($0,X0),A=Math.imul($0,K0),A=A+Math.imul(Q0,X0)|0,S=Math.imul(Q0,K0),R=R+Math.imul(o,I0)|0,A=A+Math.imul(o,O0)|0,A=A+Math.imul(a,I0)|0,S=S+Math.imul(a,O0)|0,R=R+Math.imul(i,J0)|0,A=A+Math.imul(i,F0)|0,A=A+Math.imul(e,J0)|0,S=S+Math.imul(e,F0)|0,R=R+Math.imul(m,A0)|0,A=A+Math.imul(m,H0)|0,A=A+Math.imul(r,A0)|0,S=S+Math.imul(r,H0)|0,R=R+Math.imul(t,W0)|0,A=A+Math.imul(t,E0)|0,A=A+Math.imul(s,W0)|0,S=S+Math.imul(s,E0)|0,R=R+Math.imul(l,T0)|0,A=A+Math.imul(l,D0)|0,A=A+Math.imul(n,T0)|0,S=S+Math.imul(n,D0)|0,R=R+Math.imul(h,C0)|0,A=A+Math.imul(h,L0)|0,A=A+Math.imul(d,C0)|0,S=S+Math.imul(d,L0)|0,R=R+Math.imul(B,R0)|0,A=A+Math.imul(B,P0)|0,A=A+Math.imul(c,R0)|0,S=S+Math.imul(c,P0)|0;var u0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(u0>>>26)|0,u0&=67108863,R=Math.imul(Z0,X0),A=Math.imul(Z0,K0),A=A+Math.imul(G0,X0)|0,S=Math.imul(G0,K0),R=R+Math.imul($0,I0)|0,A=A+Math.imul($0,O0)|0,A=A+Math.imul(Q0,I0)|0,S=S+Math.imul(Q0,O0)|0,R=R+Math.imul(o,J0)|0,A=A+Math.imul(o,F0)|0,A=A+Math.imul(a,J0)|0,S=S+Math.imul(a,F0)|0,R=R+Math.imul(i,A0)|0,A=A+Math.imul(i,H0)|0,A=A+Math.imul(e,A0)|0,S=S+Math.imul(e,H0)|0,R=R+Math.imul(m,W0)|0,A=A+Math.imul(m,E0)|0,A=A+Math.imul(r,W0)|0,S=S+Math.imul(r,E0)|0,R=R+Math.imul(t,T0)|0,A=A+Math.imul(t,D0)|0,A=A+Math.imul(s,T0)|0,S=S+Math.imul(s,D0)|0,R=R+Math.imul(l,C0)|0,A=A+Math.imul(l,L0)|0,A=A+Math.imul(n,C0)|0,S=S+Math.imul(n,L0)|0,R=R+Math.imul(h,R0)|0,A=A+Math.imul(h,P0)|0,A=A+Math.imul(d,R0)|0,S=S+Math.imul(d,P0)|0,R=R+Math.imul(B,z0)|0,A=A+Math.imul(B,M0)|0,A=A+Math.imul(c,z0)|0,S=S+Math.imul(c,M0)|0;var n0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(n0>>>26)|0,n0&=67108863,R=Math.imul(V0,X0),A=Math.imul(V0,K0),A=A+Math.imul(U0,X0)|0,S=Math.imul(U0,K0),R=R+Math.imul(Z0,I0)|0,A=A+Math.imul(Z0,O0)|0,A=A+Math.imul(G0,I0)|0,S=S+Math.imul(G0,O0)|0,R=R+Math.imul($0,J0)|0,A=A+Math.imul($0,F0)|0,A=A+Math.imul(Q0,J0)|0,S=S+Math.imul(Q0,F0)|0,R=R+Math.imul(o,A0)|0,A=A+Math.imul(o,H0)|0,A=A+Math.imul(a,A0)|0,S=S+Math.imul(a,H0)|0,R=R+Math.imul(i,W0)|0,A=A+Math.imul(i,E0)|0,A=A+Math.imul(e,W0)|0,S=S+Math.imul(e,E0)|0,R=R+Math.imul(m,T0)|0,A=A+Math.imul(m,D0)|0,A=A+Math.imul(r,T0)|0,S=S+Math.imul(r,D0)|0,R=R+Math.imul(t,C0)|0,A=A+Math.imul(t,L0)|0,A=A+Math.imul(s,C0)|0,S=S+Math.imul(s,L0)|0,R=R+Math.imul(l,R0)|0,A=A+Math.imul(l,P0)|0,A=A+Math.imul(n,R0)|0,S=S+Math.imul(n,P0)|0,R=R+Math.imul(h,z0)|0,A=A+Math.imul(h,M0)|0,A=A+Math.imul(d,z0)|0,S=S+Math.imul(d,M0)|0,R=R+Math.imul(B,j0)|0,A=A+Math.imul(B,k0)|0,A=A+Math.imul(c,j0)|0,S=S+Math.imul(c,k0)|0;var s0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(s0>>>26)|0,s0&=67108863,R=Math.imul(V0,I0),A=Math.imul(V0,O0),A=A+Math.imul(U0,I0)|0,S=Math.imul(U0,O0),R=R+Math.imul(Z0,J0)|0,A=A+Math.imul(Z0,F0)|0,A=A+Math.imul(G0,J0)|0,S=S+Math.imul(G0,F0)|0,R=R+Math.imul($0,A0)|0,A=A+Math.imul($0,H0)|0,A=A+Math.imul(Q0,A0)|0,S=S+Math.imul(Q0,H0)|0,R=R+Math.imul(o,W0)|0,A=A+Math.imul(o,E0)|0,A=A+Math.imul(a,W0)|0,S=S+Math.imul(a,E0)|0,R=R+Math.imul(i,T0)|0,A=A+Math.imul(i,D0)|0,A=A+Math.imul(e,T0)|0,S=S+Math.imul(e,D0)|0,R=R+Math.imul(m,C0)|0,A=A+Math.imul(m,L0)|0,A=A+Math.imul(r,C0)|0,S=S+Math.imul(r,L0)|0,R=R+Math.imul(t,R0)|0,A=A+Math.imul(t,P0)|0,A=A+Math.imul(s,R0)|0,S=S+Math.imul(s,P0)|0,R=R+Math.imul(l,z0)|0,A=A+Math.imul(l,M0)|0,A=A+Math.imul(n,z0)|0,S=S+Math.imul(n,M0)|0,R=R+Math.imul(h,j0)|0,A=A+Math.imul(h,k0)|0,A=A+Math.imul(d,j0)|0,S=S+Math.imul(d,k0)|0;var t0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(t0>>>26)|0,t0&=67108863,R=Math.imul(V0,J0),A=Math.imul(V0,F0),A=A+Math.imul(U0,J0)|0,S=Math.imul(U0,F0),R=R+Math.imul(Z0,A0)|0,A=A+Math.imul(Z0,H0)|0,A=A+Math.imul(G0,A0)|0,S=S+Math.imul(G0,H0)|0,R=R+Math.imul($0,W0)|0,A=A+Math.imul($0,E0)|0,A=A+Math.imul(Q0,W0)|0,S=S+Math.imul(Q0,E0)|0,R=R+Math.imul(o,T0)|0,A=A+Math.imul(o,D0)|0,A=A+Math.imul(a,T0)|0,S=S+Math.imul(a,D0)|0,R=R+Math.imul(i,C0)|0,A=A+Math.imul(i,L0)|0,A=A+Math.imul(e,C0)|0,S=S+Math.imul(e,L0)|0,R=R+Math.imul(m,R0)|0,A=A+Math.imul(m,P0)|0,A=A+Math.imul(r,R0)|0,S=S+Math.imul(r,P0)|0,R=R+Math.imul(t,z0)|0,A=A+Math.imul(t,M0)|0,A=A+Math.imul(s,z0)|0,S=S+Math.imul(s,M0)|0,R=R+Math.imul(l,j0)|0,A=A+Math.imul(l,k0)|0,A=A+Math.imul(n,j0)|0,S=S+Math.imul(n,k0)|0;var m0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(m0>>>26)|0,m0&=67108863,R=Math.imul(V0,A0),A=Math.imul(V0,H0),A=A+Math.imul(U0,A0)|0,S=Math.imul(U0,H0),R=R+Math.imul(Z0,W0)|0,A=A+Math.imul(Z0,E0)|0,A=A+Math.imul(G0,W0)|0,S=S+Math.imul(G0,E0)|0,R=R+Math.imul($0,T0)|0,A=A+Math.imul($0,D0)|0,A=A+Math.imul(Q0,T0)|0,S=S+Math.imul(Q0,D0)|0,R=R+Math.imul(o,C0)|0,A=A+Math.imul(o,L0)|0,A=A+Math.imul(a,C0)|0,S=S+Math.imul(a,L0)|0,R=R+Math.imul(i,R0)|0,A=A+Math.imul(i,P0)|0,A=A+Math.imul(e,R0)|0,S=S+Math.imul(e,P0)|0,R=R+Math.imul(m,z0)|0,A=A+Math.imul(m,M0)|0,A=A+Math.imul(r,z0)|0,S=S+Math.imul(r,M0)|0,R=R+Math.imul(t,j0)|0,A=A+Math.imul(t,k0)|0,A=A+Math.imul(s,j0)|0,S=S+Math.imul(s,k0)|0;var a0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(a0>>>26)|0,a0&=67108863,R=Math.imul(V0,W0),A=Math.imul(V0,E0),A=A+Math.imul(U0,W0)|0,S=Math.imul(U0,E0),R=R+Math.imul(Z0,T0)|0,A=A+Math.imul(Z0,D0)|0,A=A+Math.imul(G0,T0)|0,S=S+Math.imul(G0,D0)|0,R=R+Math.imul($0,C0)|0,A=A+Math.imul($0,L0)|0,A=A+Math.imul(Q0,C0)|0,S=S+Math.imul(Q0,L0)|0,R=R+Math.imul(o,R0)|0,A=A+Math.imul(o,P0)|0,A=A+Math.imul(a,R0)|0,S=S+Math.imul(a,P0)|0,R=R+Math.imul(i,z0)|0,A=A+Math.imul(i,M0)|0,A=A+Math.imul(e,z0)|0,S=S+Math.imul(e,M0)|0,R=R+Math.imul(m,j0)|0,A=A+Math.imul(m,k0)|0,A=A+Math.imul(r,j0)|0,S=S+Math.imul(r,k0)|0;var e0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(e0>>>26)|0,e0&=67108863,R=Math.imul(V0,T0),A=Math.imul(V0,D0),A=A+Math.imul(U0,T0)|0,S=Math.imul(U0,D0),R=R+Math.imul(Z0,C0)|0,A=A+Math.imul(Z0,L0)|0,A=A+Math.imul(G0,C0)|0,S=S+Math.imul(G0,L0)|0,R=R+Math.imul($0,R0)|0,A=A+Math.imul($0,P0)|0,A=A+Math.imul(Q0,R0)|0,S=S+Math.imul(Q0,P0)|0,R=R+Math.imul(o,z0)|0,A=A+Math.imul(o,M0)|0,A=A+Math.imul(a,z0)|0,S=S+Math.imul(a,M0)|0,R=R+Math.imul(i,j0)|0,A=A+Math.imul(i,k0)|0,A=A+Math.imul(e,j0)|0,S=S+Math.imul(e,k0)|0;var r0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(r0>>>26)|0,r0&=67108863,R=Math.imul(V0,C0),A=Math.imul(V0,L0),A=A+Math.imul(U0,C0)|0,S=Math.imul(U0,L0),R=R+Math.imul(Z0,R0)|0,A=A+Math.imul(Z0,P0)|0,A=A+Math.imul(G0,R0)|0,S=S+Math.imul(G0,P0)|0,R=R+Math.imul($0,z0)|0,A=A+Math.imul($0,M0)|0,A=A+Math.imul(Q0,z0)|0,S=S+Math.imul(Q0,M0)|0,R=R+Math.imul(o,j0)|0,A=A+Math.imul(o,k0)|0,A=A+Math.imul(a,j0)|0,S=S+Math.imul(a,k0)|0;var i0=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(i0>>>26)|0,i0&=67108863,R=Math.imul(V0,R0),A=Math.imul(V0,P0),A=A+Math.imul(U0,R0)|0,S=Math.imul(U0,P0),R=R+Math.imul(Z0,z0)|0,A=A+Math.imul(Z0,M0)|0,A=A+Math.imul(G0,z0)|0,S=S+Math.imul(G0,M0)|0,R=R+Math.imul($0,j0)|0,A=A+Math.imul($0,k0)|0,A=A+Math.imul(Q0,j0)|0,S=S+Math.imul(Q0,k0)|0;var _$=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(_$>>>26)|0,_$&=67108863,R=Math.imul(V0,z0),A=Math.imul(V0,M0),A=A+Math.imul(U0,z0)|0,S=Math.imul(U0,M0),R=R+Math.imul(Z0,j0)|0,A=A+Math.imul(Z0,k0)|0,A=A+Math.imul(G0,j0)|0,S=S+Math.imul(G0,k0)|0;var N$=(K+R|0)+((A&8191)<<13)|0;K=(S+(A>>>13)|0)+(N$>>>26)|0,N$&=67108863,R=Math.imul(V0,j0),A=Math.imul(V0,k0),A=A+Math.imul(U0,j0)|0,S=Math.imul(U0,k0);var x$=(K+R|0)+((A&8191)<<13)|0;return K=(S+(A>>>13)|0)+(x$>>>26)|0,x$&=67108863,Q[0]=f0,Q[1]=c0,Q[2]=h0,Q[3]=d0,Q[4]=b0,Q[5]=l0,Q[6]=o0,Q[7]=u0,Q[8]=n0,Q[9]=s0,Q[10]=t0,Q[11]=m0,Q[12]=a0,Q[13]=e0,Q[14]=r0,Q[15]=i0,Q[16]=_$,Q[17]=N$,Q[18]=x$,K!==0&&(Q[19]=K,I.length++),I};Math.imul||(g=q);function y(Z,V,I){I.negative=V.negative^Z.negative,I.length=Z.length+V.length;for(var O=0,U=0,Q=0;Q>>26)|0,U+=K>>>26,K&=67108863}I.words[Q]=R,O=K,K=U}return O!==0?I.words[Q]=O:I.length--,I._strip()}function w(Z,V,I){return y(Z,V,I)}X.prototype.mulTo=function(Z,V){var I,O=this.length+Z.length;return this.length===10&&Z.length===10?I=g(this,Z,V):O<63?I=q(this,Z,V):O<1024?I=y(this,Z,V):I=w(this,Z,V),I};function f(Z,V){this.x=Z,this.y=V}f.prototype.makeRBT=function(Z){for(var V=new Array(Z),I=X.prototype._countBits(Z)-1,O=0;O>=1;return O},f.prototype.permute=function(Z,V,I,O,U,Q){for(var K=0;K>>1)U++;return 1<>>13,I[2*Q+1]=U&8191,U=U>>>13;for(Q=2*V;Q>=26,I+=U/67108864|0,I+=Q>>>26,this.words[O]=Q&67108863}return I!==0&&(this.words[O]=I,this.length++),V?this.ineg():this},X.prototype.muln=function(Z){return this.clone().imuln(Z)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function(Z){var V=v(Z);if(V.length===0)return new X(1);for(var I=this,O=0;O=0);var V=Z%26,I=(Z-V)/26,O=67108863>>>26-V<<26-V,U;if(V!==0){var Q=0;for(U=0;U>>26-V}Q&&(this.words[U]=Q,this.length++)}if(I!==0){for(U=this.length-1;U>=0;U--)this.words[U+I]=this.words[U];for(U=0;U=0);var O;V?O=(V-V%26)/26:O=0;var U=Z%26,Q=Math.min((Z-U)/26,this.length),K=67108863^67108863>>>U<Q)for(this.length-=Q,A=0;A=0&&(S!==0||A>=O);A--){var x=this.words[A]|0;this.words[A]=S<<26-U|x>>>U,S=x&K}return R&&S!==0&&(R.words[R.length++]=S),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},X.prototype.ishrn=function(Z,V,I){return F(this.negative===0),this.iushrn(Z,V,I)},X.prototype.shln=function(Z){return this.clone().ishln(Z)},X.prototype.ushln=function(Z){return this.clone().iushln(Z)},X.prototype.shrn=function(Z){return this.clone().ishrn(Z)},X.prototype.ushrn=function(Z){return this.clone().iushrn(Z)},X.prototype.testn=function(Z){F(typeof Z=="number"&&Z>=0);var V=Z%26,I=(Z-V)/26,O=1<=0);var V=Z%26,I=(Z-V)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=I)return this;if(V!==0&&I++,this.length=Math.min(I,this.length),V!==0){var O=67108863^67108863>>>V<=67108864;V++)this.words[V]-=67108864,V===this.length-1?this.words[V+1]=1:this.words[V+1]++;return this.length=Math.max(this.length,V+1),this},X.prototype.isubn=function(Z){if(F(typeof Z=="number"),F(Z<67108864),Z<0)return this.iaddn(-Z);if(this.negative!==0)return this.negative=0,this.iaddn(Z),this.negative=1,this;if(this.words[0]-=Z,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var V=0;V>26)-(R/67108864|0),this.words[U+I]=Q&67108863}for(;U>26,this.words[U+I]=Q&67108863;if(K===0)return this._strip();for(F(K===-1),K=0,U=0;U>26,this.words[U]=Q&67108863;return this.negative=1,this._strip()},X.prototype._wordDiv=function(Z,V){var I=this.length-Z.length,O=this.clone(),U=Z,Q=U.words[U.length-1]|0,K=this._countBits(Q);I=26-K,I!==0&&(U=U.ushln(I),O.iushln(I),Q=U.words[U.length-1]|0);var R=O.length-U.length,A;if(V!=="mod"){A=new X(null),A.length=R+1,A.words=new Array(A.length);for(var S=0;S=0;B--){var c=(O.words[U.length+B]|0)*67108864+(O.words[U.length+B-1]|0);for(c=Math.min(c/Q|0,67108863),O._ishlnsubmul(U,c,B);O.negative!==0;)c--,O.negative=0,O._ishlnsubmul(U,1,B),O.isZero()||(O.negative^=1);A&&(A.words[B]=c)}return A&&A._strip(),O._strip(),V!=="div"&&I!==0&&O.iushrn(I),{div:A||null,mod:O}},X.prototype.divmod=function(Z,V,I){if(F(!Z.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var O,U,Q;return this.negative!==0&&Z.negative===0?(Q=this.neg().divmod(Z,V),V!=="mod"&&(O=Q.div.neg()),V!=="div"&&(U=Q.mod.neg(),I&&U.negative!==0&&U.iadd(Z)),{div:O,mod:U}):this.negative===0&&Z.negative!==0?(Q=this.divmod(Z.neg(),V),V!=="mod"&&(O=Q.div.neg()),{div:O,mod:Q.mod}):(this.negative&Z.negative)!==0?(Q=this.neg().divmod(Z.neg(),V),V!=="div"&&(U=Q.mod.neg(),I&&U.negative!==0&&U.isub(Z)),{div:Q.div,mod:U}):Z.length>this.length||this.cmp(Z)<0?{div:new X(0),mod:this}:Z.length===1?V==="div"?{div:this.divn(Z.words[0]),mod:null}:V==="mod"?{div:null,mod:new X(this.modrn(Z.words[0]))}:{div:this.divn(Z.words[0]),mod:new X(this.modrn(Z.words[0]))}:this._wordDiv(Z,V)},X.prototype.div=function(Z){return this.divmod(Z,"div",!1).div},X.prototype.mod=function(Z){return this.divmod(Z,"mod",!1).mod},X.prototype.umod=function(Z){return this.divmod(Z,"mod",!0).mod},X.prototype.divRound=function(Z){var V=this.divmod(Z);if(V.mod.isZero())return V.div;var I=V.div.negative!==0?V.mod.isub(Z):V.mod,O=Z.ushrn(1),U=Z.andln(1),Q=I.cmp(O);return Q<0||U===1&&Q===0?V.div:V.div.negative!==0?V.div.isubn(1):V.div.iaddn(1)},X.prototype.modrn=function(Z){var V=Z<0;V&&(Z=-Z),F(Z<=67108863);for(var I=(1<<26)%Z,O=0,U=this.length-1;U>=0;U--)O=(I*O+(this.words[U]|0))%Z;return V?-O:O},X.prototype.modn=function(Z){return this.modrn(Z)},X.prototype.idivn=function(Z){var V=Z<0;V&&(Z=-Z),F(Z<=67108863);for(var I=0,O=this.length-1;O>=0;O--){var U=(this.words[O]|0)+I*67108864;this.words[O]=U/Z|0,I=U%Z}return this._strip(),V?this.ineg():this},X.prototype.divn=function(Z){return this.clone().idivn(Z)},X.prototype.egcd=function(Z){F(Z.negative===0),F(!Z.isZero());var V=this,I=Z.clone();V.negative!==0?V=V.umod(Z):V=V.clone();for(var O=new X(1),U=new X(0),Q=new X(0),K=new X(1),R=0;V.isEven()&&I.isEven();)V.iushrn(1),I.iushrn(1),++R;for(var A=I.clone(),S=V.clone();!V.isZero();){for(var x=0,B=1;(V.words[0]&B)===0&&x<26;++x,B<<=1);if(x>0)for(V.iushrn(x);x-- >0;)(O.isOdd()||U.isOdd())&&(O.iadd(A),U.isub(S)),O.iushrn(1),U.iushrn(1);for(var c=0,q0=1;(I.words[0]&q0)===0&&c<26;++c,q0<<=1);if(c>0)for(I.iushrn(c);c-- >0;)(Q.isOdd()||K.isOdd())&&(Q.iadd(A),K.isub(S)),Q.iushrn(1),K.iushrn(1);V.cmp(I)>=0?(V.isub(I),O.isub(Q),U.isub(K)):(I.isub(V),Q.isub(O),K.isub(U))}return{a:Q,b:K,gcd:I.iushln(R)}},X.prototype._invmp=function(Z){F(Z.negative===0),F(!Z.isZero());var V=this,I=Z.clone();V.negative!==0?V=V.umod(Z):V=V.clone();for(var O=new X(1),U=new X(0),Q=I.clone();V.cmpn(1)>0&&I.cmpn(1)>0;){for(var K=0,R=1;(V.words[0]&R)===0&&K<26;++K,R<<=1);if(K>0)for(V.iushrn(K);K-- >0;)O.isOdd()&&O.iadd(Q),O.iushrn(1);for(var A=0,S=1;(I.words[0]&S)===0&&A<26;++A,S<<=1);if(A>0)for(I.iushrn(A);A-- >0;)U.isOdd()&&U.iadd(Q),U.iushrn(1);V.cmp(I)>=0?(V.isub(I),O.isub(U)):(I.isub(V),U.isub(O))}var x;return V.cmpn(1)===0?x=O:x=U,x.cmpn(0)<0&&x.iadd(Z),x},X.prototype.gcd=function(Z){if(this.isZero())return Z.abs();if(Z.isZero())return this.abs();var V=this.clone(),I=Z.clone();V.negative=0,I.negative=0;for(var O=0;V.isEven()&&I.isEven();O++)V.iushrn(1),I.iushrn(1);do{for(;V.isEven();)V.iushrn(1);for(;I.isEven();)I.iushrn(1);var U=V.cmp(I);if(U<0){var Q=V;V=I,I=Q}else if(U===0||I.cmpn(1)===0)break;V.isub(I)}while(!0);return I.iushln(O)},X.prototype.invm=function(Z){return this.egcd(Z).a.umod(Z)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function(Z){return this.words[0]&Z},X.prototype.bincn=function(Z){F(typeof Z=="number");var V=Z%26,I=(Z-V)/26,O=1<>>26,K&=67108863,this.words[Q]=K}return U!==0&&(this.words[Q]=U,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function(Z){var V=Z<0;if(this.negative!==0&&!V)return-1;if(this.negative===0&&V)return 1;this._strip();var I;if(this.length>1)I=1;else{V&&(Z=-Z),F(Z<=67108863,"Number is too big");var O=this.words[0]|0;I=O===Z?0:OZ.length)return 1;if(this.length=0;I--){var O=this.words[I]|0,U=Z.words[I]|0;if(O!==U){OU&&(V=1);break}}return V},X.prototype.gtn=function(Z){return this.cmpn(Z)===1},X.prototype.gt=function(Z){return this.cmp(Z)===1},X.prototype.gten=function(Z){return this.cmpn(Z)>=0},X.prototype.gte=function(Z){return this.cmp(Z)>=0},X.prototype.ltn=function(Z){return this.cmpn(Z)===-1},X.prototype.lt=function(Z){return this.cmp(Z)===-1},X.prototype.lten=function(Z){return this.cmpn(Z)<=0},X.prototype.lte=function(Z){return this.cmp(Z)<=0},X.prototype.eqn=function(Z){return this.cmpn(Z)===0},X.prototype.eq=function(Z){return this.cmp(Z)===0},X.red=function(Z){return new Y(Z)},X.prototype.toRed=function(Z){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),Z.convertTo(this)._forceRed(Z)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function(Z){return this.red=Z,this},X.prototype.forceRed=function(Z){return F(!this.red,"Already a number in reduction context"),this._forceRed(Z)},X.prototype.redAdd=function(Z){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,Z)},X.prototype.redIAdd=function(Z){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Z)},X.prototype.redSub=function(Z){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,Z)},X.prototype.redISub=function(Z){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,Z)},X.prototype.redShl=function(Z){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,Z)},X.prototype.redMul=function(Z){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,Z),this.red.mul(this,Z)},X.prototype.redIMul=function(Z){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,Z),this.red.imul(this,Z)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function(Z){return F(this.red&&!Z.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Z)};var b={k256:null,p224:null,p192:null,p25519:null};function u(Z,V){this.name=Z,this.p=new X(V,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}u.prototype._tmp=function(){var Z=new X(null);return Z.words=new Array(Math.ceil(this.n/13)),Z},u.prototype.ireduce=function(Z){var V=Z,I;do this.split(V,this.tmp),V=this.imulK(V),V=V.iadd(this.tmp),I=V.bitLength();while(I>this.n);var O=I0?V.isub(this.p):V.strip!==void 0?V.strip():V._strip(),V},u.prototype.split=function(Z,V){Z.iushrn(this.n,0,V)},u.prototype.imulK=function(Z){return Z.imul(this.k)};function Y0(){u.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(Y0,u),Y0.prototype.split=function(Z,V){for(var I=4194303,O=Math.min(Z.length,9),U=0;U>>22,Q=K}Q>>>=22,Z.words[U-10]=Q,Q===0&&Z.length>10?Z.length-=10:Z.length-=9},Y0.prototype.imulK=function(Z){Z.words[Z.length]=0,Z.words[Z.length+1]=0,Z.length+=2;for(var V=0,I=0;I>>=26,Z.words[I]=U,V=O}return V!==0&&(Z.words[Z.length++]=V),Z},X._prime=function(Z){if(b[Z])return b[Z];var V;if(Z==="k256")V=new Y0;else if(Z==="p224")V=new p;else if(Z==="p192")V=new v0;else if(Z==="p25519")V=new $;else throw new Error("Unknown prime "+Z);return b[Z]=V,V};function Y(Z){if(typeof Z=="string"){var V=X._prime(Z);this.m=V.p,this.prime=V}else F(Z.gtn(1),"modulus must be greater than 1"),this.m=Z,this.prime=null}Y.prototype._verify1=function(Z){F(Z.negative===0,"red works only with positives"),F(Z.red,"red works only with red numbers")},Y.prototype._verify2=function(Z,V){F((Z.negative|V.negative)===0,"red works only with positives"),F(Z.red&&Z.red===V.red,"red works only with red numbers")},Y.prototype.imod=function(Z){return this.prime?this.prime.ireduce(Z)._forceRed(this):(J(Z,Z.umod(this.m)._forceRed(this)),Z)},Y.prototype.neg=function(Z){return Z.isZero()?Z.clone():this.m.sub(Z)._forceRed(this)},Y.prototype.add=function(Z,V){this._verify2(Z,V);var I=Z.add(V);return I.cmp(this.m)>=0&&I.isub(this.m),I._forceRed(this)},Y.prototype.iadd=function(Z,V){this._verify2(Z,V);var I=Z.iadd(V);return I.cmp(this.m)>=0&&I.isub(this.m),I},Y.prototype.sub=function(Z,V){this._verify2(Z,V);var I=Z.sub(V);return I.cmpn(0)<0&&I.iadd(this.m),I._forceRed(this)},Y.prototype.isub=function(Z,V){this._verify2(Z,V);var I=Z.isub(V);return I.cmpn(0)<0&&I.iadd(this.m),I},Y.prototype.shl=function(Z,V){return this._verify1(Z),this.imod(Z.ushln(V))},Y.prototype.imul=function(Z,V){return this._verify2(Z,V),this.imod(Z.imul(V))},Y.prototype.mul=function(Z,V){return this._verify2(Z,V),this.imod(Z.mul(V))},Y.prototype.isqr=function(Z){return this.imul(Z,Z.clone())},Y.prototype.sqr=function(Z){return this.mul(Z,Z)},Y.prototype.sqrt=function(Z){if(Z.isZero())return Z.clone();var V=this.m.andln(3);if(F(V%2===1),V===3){var I=this.m.add(new X(1)).iushrn(2);return this.pow(Z,I)}for(var O=this.m.subn(1),U=0;!O.isZero()&&O.andln(1)===0;)U++,O.iushrn(1);F(!O.isZero());var Q=new X(1).toRed(this),K=Q.redNeg(),R=this.m.subn(1).iushrn(1),A=this.m.bitLength();for(A=new X(2*A*A).toRed(this);this.pow(A,R).cmp(K)!==0;)A.redIAdd(K);for(var S=this.pow(A,O),x=this.pow(Z,O.addn(1).iushrn(1)),B=this.pow(Z,O),c=U;B.cmp(Q)!==0;){for(var q0=B,h=0;q0.cmp(Q)!==0;h++)q0=q0.redSqr();F(h=0;U--){for(var S=V.words[U],x=A-1;x>=0;x--){var B=S>>x&1;if(Q!==O[0]&&(Q=this.sqr(Q)),B===0&&K===0){R=0;continue}K<<=1,K|=B,R++,!(R!==I&&(U!==0||x!==0))&&(Q=this.mul(Q,O[K]),R=0,K=0)}A=26}return Q},Y.prototype.convertTo=function(Z){var V=Z.umod(this.m);return V===Z?V.clone():V},Y.prototype.convertFrom=function(Z){var V=Z.clone();return V.red=null,V},X.mont=function(Z){return new G(Z)};function G(Z){Y.call(this,Z),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(G,Y),G.prototype.convertTo=function(Z){return this.imod(Z.ushln(this.shift))},G.prototype.convertFrom=function(Z){var V=this.imod(Z.mul(this.rinv));return V.red=null,V},G.prototype.imul=function(Z,V){if(Z.isZero()||V.isZero())return Z.words[0]=0,Z.length=1,Z;var I=Z.imul(V),O=I.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),U=I.isub(O).iushrn(this.shift),Q=U;return U.cmp(this.m)>=0?Q=U.isub(this.m):U.cmpn(0)<0&&(Q=U.iadd(this.m)),Q._forceRed(this)},G.prototype.mul=function(Z,V){if(Z.isZero()||V.isZero())return new X(0)._forceRed(this);var I=Z.mul(V),O=I.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),U=I.isub(O).iushrn(this.shift),Q=U;return U.cmp(this.m)>=0?Q=U.isub(this.m):U.cmpn(0)<0&&(Q=U.iadd(this.m)),Q._forceRed(this)},G.prototype.invm=function(Z){var V=this.imod(Z._invmp(this.m).mul(this.r2));return V._forceRed(this)}})(typeof _>"u"||_,N)}}),h$=S0({"node_modules/browserify-rsa/index.js"(N,_){var k=c$(),j=L$();function F(C){var P=z(C),T=P.toRed(k.mont(C.modulus)).redPow(new k(C.publicExponent)).fromRed();return{blinder:T,unblinder:P.invm(C.modulus)}}function z(C){var P=C.modulus.byteLength(),T;do T=new k(j(P));while(T.cmp(C.modulus)>=0||!T.umod(C.prime1)||!T.umod(C.prime2));return T}function X(C,P){var T=F(P),W=P.modulus.byteLength(),J=new k(C).mul(T.blinder).umod(P.modulus),H=J.toRed(k.mont(P.prime1)),D=J.toRed(k.mont(P.prime2)),E=P.coefficient,L=P.prime1,M=P.prime2,v=H.redPow(P.exponent1).fromRed(),q=D.redPow(P.exponent2).fromRed(),g=v.isub(q).imul(E).umod(L).imul(M);return q.iadd(g).imul(T.unblinder).umod(P.modulus).toArrayLike(g0,"be",W)}X.getr=z,_.exports=X}}),TY=S0({"node_modules/elliptic/package.json"(N,_){_.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"}}}}),D$=S0({"node_modules/elliptic/node_modules/bn.js/lib/bn.js"(N,_){(function(k,j){function F($,Y){if(!$)throw new Error(Y||"Assertion failed")}function z($,Y){$.super_=Y;var G=function(){};G.prototype=Y.prototype,$.prototype=new G,$.prototype.constructor=$}function X($,Y,G){if(X.isBN($))return $;this.negative=0,this.words=null,this.length=0,this.red=null,$!==null&&((Y==="le"||Y==="be")&&(G=Y,Y=10),this._init($||0,Y||10,G||"be"))}typeof k=="object"?k.exports=X:j.BN=X,X.BN=X,X.wordSize=26;var C=g0;X.isBN=function($){return $ instanceof X?!0:$!==null&&typeof $=="object"&&$.constructor.wordSize===X.wordSize&&Array.isArray($.words)},X.max=function($,Y){return $.cmp(Y)>0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),zQ=S0({"node_modules/minimalistic-crypto-utils/lib/utils.js"(N){var _=N;function k(z,X){if(Array.isArray(z))return z.slice();if(!z)return[];var C=[];if(typeof z!="string"){for(var P=0;P>8,J=T&255;W?C.push(W,J):C.push(J)}return C}_.toArray=k;function j(z){return z.length===1?"0"+z:z}_.zero2=j;function F(z){for(var X="",C=0;C(E>>1)-1?v=(E>>1)-q:v=q,L.isubn(v)):v=0,D[M]=v,L.iushrn(1)}return D}_.getNAF=z;function X(W,J){var H=[[],[]];W=W.clone(),J=J.clone();for(var D=0,E=0,L;W.cmpn(-D)>0||J.cmpn(-E)>0;){var M=W.andln(3)+D&3,v=J.andln(3)+E&3;M===3&&(M=-1),v===3&&(v=-1);var q;(M&1)===0?q=0:(L=W.andln(7)+D&7,(L===3||L===5)&&v===2?q=-M:q=M),H[0].push(q);var g;(v&1)===0?g=0:(L=J.andln(7)+E&7,(L===3||L===5)&&M===2?g=-v:g=v),H[1].push(g),2*D===q+1&&(D=1-D),2*E===g+1&&(E=1-E),W.iushrn(1),J.iushrn(1)}return H}_.getJSF=X;function C(W,J,H){var D="_"+J;W.prototype[J]=function(){return this[D]!==void 0?this[D]:this[D]=H.call(this)}}_.cachedProperty=C;function P(W){return typeof W=="string"?_.toArray(W,"hex"):W}_.parseBytes=P;function T(W){return new k(W,"hex","le")}_.intFromLE=T}}),k$=S0({"node_modules/elliptic/lib/elliptic/curve/base.js"(N,_){var k=D$(),j=E$(),F=j.getNAF,z=j.getJSF,X=j.assert;function C(T,W){this.type=T,this.p=new k(W.p,16),this.red=W.prime?k.red(W.prime):k.mont(this.p),this.zero=new k(0).toRed(this.red),this.one=new k(1).toRed(this.red),this.two=new k(2).toRed(this.red),this.n=W.n&&new k(W.n,16),this.g=W.g&&this.pointFromJSON(W.g,W.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=C,C.prototype.point=function(){throw new Error("Not implemented")},C.prototype.validate=function(){throw new Error("Not implemented")},C.prototype._fixedNafMul=function(T,W){X(T.precomputed);var J=T._getDoubles(),H=F(W,1,this._bitLength),D=(1<=L;v--)M=(M<<1)+H[v];E.push(M)}for(var q=this.jpoint(null,null,null),g=this.jpoint(null,null,null),y=D;y>0;y--){for(L=0;L=0;M--){for(var v=0;M>=0&&E[M]===0;M--)v++;if(M>=0&&v++,L=L.dblp(v),M<0)break;var q=E[M];X(q!==0),T.type==="affine"?q>0?L=L.mixedAdd(D[q-1>>1]):L=L.mixedAdd(D[-q-1>>1].neg()):q>0?L=L.add(D[q-1>>1]):L=L.add(D[-q-1>>1].neg())}return T.type==="affine"?L.toP():L},C.prototype._wnafMulAdd=function(T,W,J,H,D){var E=this._wnafT1,L=this._wnafT2,M=this._wnafT3,v=0,q,g,y;for(q=0;q=1;q-=2){var f=q-1,b=q;if(E[f]!==1||E[b]!==1){M[f]=F(J[f],E[f],this._bitLength),M[b]=F(J[b],E[b],this._bitLength),v=Math.max(M[f].length,v),v=Math.max(M[b].length,v);continue}var u=[W[f],null,null,W[b]];W[f].y.cmp(W[b].y)===0?(u[1]=W[f].add(W[b]),u[2]=W[f].toJ().mixedAdd(W[b].neg())):W[f].y.cmp(W[b].y.redNeg())===0?(u[1]=W[f].toJ().mixedAdd(W[b]),u[2]=W[f].add(W[b].neg())):(u[1]=W[f].toJ().mixedAdd(W[b]),u[2]=W[f].toJ().mixedAdd(W[b].neg()));var Y0=[-3,-1,-5,-7,0,7,5,1,3],p=z(J[f],J[b]);for(v=Math.max(p[0].length,v),M[f]=new Array(v),M[b]=new Array(v),g=0;g=0;q--){for(var Z=0;q>=0;){var V=!0;for(g=0;g=0&&Z++,Y=Y.dblp(Z),q<0)break;for(g=0;g0?y=L[g][I-1>>1]:I<0&&(y=L[g][-I-1>>1].neg()),y.type==="affine"?Y=Y.mixedAdd(y):Y=Y.add(y))}}for(q=0;q=Math.ceil((T.bitLength()+1)/W.step):!1},P.prototype._getDoubles=function(T,W){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var J=[this],H=this,D=0;D=0&&(f=q,b=g),y.negative&&(y=y.neg(),w=w.neg()),f.negative&&(f=f.neg(),b=b.neg()),[{a:y,b:w},{a:f,b}]},C.prototype._endoSplit=function(W){var J=this.endo.basis,H=J[0],D=J[1],E=D.b.mul(W).divRound(this.n),L=H.b.neg().mul(W).divRound(this.n),M=E.mul(H.a),v=L.mul(D.a),q=E.mul(H.b),g=L.mul(D.b),y=W.sub(M).sub(v),w=q.add(g).neg();return{k1:y,k2:w}},C.prototype.pointFromX=function(W,J){W=new j(W,16),W.red||(W=W.toRed(this.red));var H=W.redSqr().redMul(W).redIAdd(W.redMul(this.a)).redIAdd(this.b),D=H.redSqrt();if(D.redSqr().redSub(H).cmp(this.zero)!==0)throw new Error("invalid point");var E=D.fromRed().isOdd();return(J&&!E||!J&&E)&&(D=D.redNeg()),this.point(W,D)},C.prototype.validate=function(W){if(W.inf)return!0;var{x:J,y:H}=W,D=this.a.redMul(J),E=J.redSqr().redMul(J).redIAdd(D).redIAdd(this.b);return H.redSqr().redISub(E).cmpn(0)===0},C.prototype._endoWnafMulAdd=function(W,J,H){for(var D=this._endoWnafT1,E=this._endoWnafT2,L=0;L":""},P.prototype.isInfinity=function(){return this.inf},P.prototype.add=function(W){if(this.inf)return W;if(W.inf)return this;if(this.eq(W))return this.dbl();if(this.neg().eq(W))return this.curve.point(null,null);if(this.x.cmp(W.x)===0)return this.curve.point(null,null);var J=this.y.redSub(W.y);J.cmpn(0)!==0&&(J=J.redMul(this.x.redSub(W.x).redInvm()));var H=J.redSqr().redISub(this.x).redISub(W.x),D=J.redMul(this.x.redSub(H)).redISub(this.y);return this.curve.point(H,D)},P.prototype.dbl=function(){if(this.inf)return this;var W=this.y.redAdd(this.y);if(W.cmpn(0)===0)return this.curve.point(null,null);var J=this.curve.a,H=this.x.redSqr(),D=W.redInvm(),E=H.redAdd(H).redIAdd(H).redIAdd(J).redMul(D),L=E.redSqr().redISub(this.x.redAdd(this.x)),M=E.redMul(this.x.redSub(L)).redISub(this.y);return this.curve.point(L,M)},P.prototype.getX=function(){return this.x.fromRed()},P.prototype.getY=function(){return this.y.fromRed()},P.prototype.mul=function(W){return W=new j(W,16),this.isInfinity()?this:this._hasDoubles(W)?this.curve._fixedNafMul(this,W):this.curve.endo?this.curve._endoWnafMulAdd([this],[W]):this.curve._wnafMul(this,W)},P.prototype.mulAdd=function(W,J,H){var D=[this,J],E=[W,H];return this.curve.endo?this.curve._endoWnafMulAdd(D,E):this.curve._wnafMulAdd(1,D,E,2)},P.prototype.jmulAdd=function(W,J,H){var D=[this,J],E=[W,H];return this.curve.endo?this.curve._endoWnafMulAdd(D,E,!0):this.curve._wnafMulAdd(1,D,E,2,!0)},P.prototype.eq=function(W){return this===W||this.inf===W.inf&&(this.inf||this.x.cmp(W.x)===0&&this.y.cmp(W.y)===0)},P.prototype.neg=function(W){if(this.inf)return this;var J=this.curve.point(this.x,this.y.redNeg());if(W&&this.precomputed){var H=this.precomputed,D=function(E){return E.neg()};J.precomputed={naf:H.naf&&{wnd:H.naf.wnd,points:H.naf.points.map(D)},doubles:H.doubles&&{step:H.doubles.step,points:H.doubles.points.map(D)}}}return J},P.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var W=this.curve.jpoint(this.x,this.y,this.curve.one);return W};function T(W,J,H,D){z.BasePoint.call(this,W,"jacobian"),J===null&&H===null&&D===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new j(0)):(this.x=new j(J,16),this.y=new j(H,16),this.z=new j(D,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}F(T,z.BasePoint),C.prototype.jpoint=function(W,J,H){return new T(this,W,J,H)},T.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var W=this.z.redInvm(),J=W.redSqr(),H=this.x.redMul(J),D=this.y.redMul(J).redMul(W);return this.curve.point(H,D)},T.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},T.prototype.add=function(W){if(this.isInfinity())return W;if(W.isInfinity())return this;var J=W.z.redSqr(),H=this.z.redSqr(),D=this.x.redMul(J),E=W.x.redMul(H),L=this.y.redMul(J.redMul(W.z)),M=W.y.redMul(H.redMul(this.z)),v=D.redSub(E),q=L.redSub(M);if(v.cmpn(0)===0)return q.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=v.redSqr(),y=g.redMul(v),w=D.redMul(g),f=q.redSqr().redIAdd(y).redISub(w).redISub(w),b=q.redMul(w.redISub(f)).redISub(L.redMul(y)),u=this.z.redMul(W.z).redMul(v);return this.curve.jpoint(f,b,u)},T.prototype.mixedAdd=function(W){if(this.isInfinity())return W.toJ();if(W.isInfinity())return this;var J=this.z.redSqr(),H=this.x,D=W.x.redMul(J),E=this.y,L=W.y.redMul(J).redMul(this.z),M=H.redSub(D),v=E.redSub(L);if(M.cmpn(0)===0)return v.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var q=M.redSqr(),g=q.redMul(M),y=H.redMul(q),w=v.redSqr().redIAdd(g).redISub(y).redISub(y),f=v.redMul(y.redISub(w)).redISub(E.redMul(g)),b=this.z.redMul(M);return this.curve.jpoint(w,f,b)},T.prototype.dblp=function(W){if(W===0)return this;if(this.isInfinity())return this;if(!W)return this.dbl();var J;if(this.curve.zeroA||this.curve.threeA){var H=this;for(J=0;J=0)return!1;if(H.redIAdd(E),this.x.cmp(H)===0)return!0}},T.prototype.inspect=function(){return this.isInfinity()?"":""},T.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),CY=S0({"node_modules/elliptic/lib/elliptic/curve/mont.js"(N,_){var k=D$(),j=B0(),F=k$(),z=E$();function X(P){F.call(this,"mont",P),this.a=new k(P.a,16).toRed(this.red),this.b=new k(P.b,16).toRed(this.red),this.i4=new k(4).toRed(this.red).redInvm(),this.two=new k(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}j(X,F),_.exports=X,X.prototype.validate=function(P){var T=P.normalize().x,W=T.redSqr(),J=W.redMul(T).redAdd(W.redMul(this.a)).redAdd(T),H=J.redSqrt();return H.redSqr().cmp(J)===0};function C(P,T,W){F.BasePoint.call(this,P,"projective"),T===null&&W===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new k(T,16),this.z=new k(W,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}j(C,F.BasePoint),X.prototype.decodePoint=function(P,T){return this.point(z.toArray(P,T),1)},X.prototype.point=function(P,T){return new C(this,P,T)},X.prototype.pointFromJSON=function(P){return C.fromJSON(this,P)},C.prototype.precompute=function(){},C.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},C.fromJSON=function(P,T){return new C(P,T[0],T[1]||P.one)},C.prototype.inspect=function(){return this.isInfinity()?"":""},C.prototype.isInfinity=function(){return this.z.cmpn(0)===0},C.prototype.dbl=function(){var P=this.x.redAdd(this.z),T=P.redSqr(),W=this.x.redSub(this.z),J=W.redSqr(),H=T.redSub(J),D=T.redMul(J),E=H.redMul(J.redAdd(this.curve.a24.redMul(H)));return this.curve.point(D,E)},C.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},C.prototype.diffAdd=function(P,T){var W=this.x.redAdd(this.z),J=this.x.redSub(this.z),H=P.x.redAdd(P.z),D=P.x.redSub(P.z),E=D.redMul(W),L=H.redMul(J),M=T.z.redMul(E.redAdd(L).redSqr()),v=T.x.redMul(E.redISub(L).redSqr());return this.curve.point(M,v)},C.prototype.mul=function(P){for(var T=P.clone(),W=this,J=this.curve.point(null,null),H=this,D=[];T.cmpn(0)!==0;T.iushrn(1))D.push(T.andln(1));for(var E=D.length-1;E>=0;E--)D[E]===0?(W=W.diffAdd(J,H),J=J.dbl()):(J=W.diffAdd(J,H),W=W.dbl());return J},C.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},C.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},C.prototype.eq=function(P){return this.getX().cmp(P.getX())===0},C.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},C.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),LY=S0({"node_modules/elliptic/lib/elliptic/curve/edwards.js"(N,_){var k=E$(),j=D$(),F=B0(),z=k$(),X=k.assert;function C(T){this.twisted=(T.a|0)!==1,this.mOneA=this.twisted&&(T.a|0)===-1,this.extended=this.mOneA,z.call(this,"edwards",T),this.a=new j(T.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new j(T.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new j(T.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),X(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(T.c|0)===1}F(C,z),_.exports=C,C.prototype._mulA=function(T){return this.mOneA?T.redNeg():this.a.redMul(T)},C.prototype._mulC=function(T){return this.oneC?T:this.c.redMul(T)},C.prototype.jpoint=function(T,W,J,H){return this.point(T,W,J,H)},C.prototype.pointFromX=function(T,W){T=new j(T,16),T.red||(T=T.toRed(this.red));var J=T.redSqr(),H=this.c2.redSub(this.a.redMul(J)),D=this.one.redSub(this.c2.redMul(this.d).redMul(J)),E=H.redMul(D.redInvm()),L=E.redSqrt();if(L.redSqr().redSub(E).cmp(this.zero)!==0)throw new Error("invalid point");var M=L.fromRed().isOdd();return(W&&!M||!W&&M)&&(L=L.redNeg()),this.point(T,L)},C.prototype.pointFromY=function(T,W){T=new j(T,16),T.red||(T=T.toRed(this.red));var J=T.redSqr(),H=J.redSub(this.c2),D=J.redMul(this.d).redMul(this.c2).redSub(this.a),E=H.redMul(D.redInvm());if(E.cmp(this.zero)===0){if(W)throw new Error("invalid point");return this.point(this.zero,T)}var L=E.redSqrt();if(L.redSqr().redSub(E).cmp(this.zero)!==0)throw new Error("invalid point");return L.fromRed().isOdd()!==W&&(L=L.redNeg()),this.point(L,T)},C.prototype.validate=function(T){if(T.isInfinity())return!0;T.normalize();var W=T.x.redSqr(),J=T.y.redSqr(),H=W.redMul(this.a).redAdd(J),D=this.c2.redMul(this.one.redAdd(this.d.redMul(W).redMul(J)));return H.cmp(D)===0};function P(T,W,J,H,D){z.BasePoint.call(this,T,"projective"),W===null&&J===null&&H===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 j(W,16),this.y=new j(J,16),this.z=H?new j(H,16):this.curve.one,this.t=D&&new j(D,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()))))}F(P,z.BasePoint),C.prototype.pointFromJSON=function(T){return P.fromJSON(this,T)},C.prototype.point=function(T,W,J,H){return new P(this,T,W,J,H)},P.fromJSON=function(T,W){return new P(T,W[0],W[1],W[2])},P.prototype.inspect=function(){return this.isInfinity()?"":""},P.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},P.prototype._extDbl=function(){var T=this.x.redSqr(),W=this.y.redSqr(),J=this.z.redSqr();J=J.redIAdd(J);var H=this.curve._mulA(T),D=this.x.redAdd(this.y).redSqr().redISub(T).redISub(W),E=H.redAdd(W),L=E.redSub(J),M=H.redSub(W),v=D.redMul(L),q=E.redMul(M),g=D.redMul(M),y=L.redMul(E);return this.curve.point(v,q,y,g)},P.prototype._projDbl=function(){var T=this.x.redAdd(this.y).redSqr(),W=this.x.redSqr(),J=this.y.redSqr(),H,D,E,L,M,v;if(this.curve.twisted){L=this.curve._mulA(W);var q=L.redAdd(J);this.zOne?(H=T.redSub(W).redSub(J).redMul(q.redSub(this.curve.two)),D=q.redMul(L.redSub(J)),E=q.redSqr().redSub(q).redSub(q)):(M=this.z.redSqr(),v=q.redSub(M).redISub(M),H=T.redSub(W).redISub(J).redMul(v),D=q.redMul(L.redSub(J)),E=q.redMul(v))}else L=W.redAdd(J),M=this.curve._mulC(this.z).redSqr(),v=L.redSub(M).redSub(M),H=this.curve._mulC(T.redISub(L)).redMul(v),D=this.curve._mulC(L).redMul(W.redISub(J)),E=L.redMul(v);return this.curve.point(H,D,E)},P.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},P.prototype._extAdd=function(T){var W=this.y.redSub(this.x).redMul(T.y.redSub(T.x)),J=this.y.redAdd(this.x).redMul(T.y.redAdd(T.x)),H=this.t.redMul(this.curve.dd).redMul(T.t),D=this.z.redMul(T.z.redAdd(T.z)),E=J.redSub(W),L=D.redSub(H),M=D.redAdd(H),v=J.redAdd(W),q=E.redMul(L),g=M.redMul(v),y=E.redMul(v),w=L.redMul(M);return this.curve.point(q,g,w,y)},P.prototype._projAdd=function(T){var W=this.z.redMul(T.z),J=W.redSqr(),H=this.x.redMul(T.x),D=this.y.redMul(T.y),E=this.curve.d.redMul(H).redMul(D),L=J.redSub(E),M=J.redAdd(E),v=this.x.redAdd(this.y).redMul(T.x.redAdd(T.y)).redISub(H).redISub(D),q=W.redMul(L).redMul(v),g,y;return this.curve.twisted?(g=W.redMul(M).redMul(D.redSub(this.curve._mulA(H))),y=L.redMul(M)):(g=W.redMul(M).redMul(D.redSub(H)),y=this.curve._mulC(L).redMul(M)),this.curve.point(q,g,y)},P.prototype.add=function(T){return this.isInfinity()?T:T.isInfinity()?this:this.curve.extended?this._extAdd(T):this._projAdd(T)},P.prototype.mul=function(T){return this._hasDoubles(T)?this.curve._fixedNafMul(this,T):this.curve._wnafMul(this,T)},P.prototype.mulAdd=function(T,W,J){return this.curve._wnafMulAdd(1,[this,W],[T,J],2,!1)},P.prototype.jmulAdd=function(T,W,J){return this.curve._wnafMulAdd(1,[this,W],[T,J],2,!0)},P.prototype.normalize=function(){if(this.zOne)return this;var T=this.z.redInvm();return this.x=this.x.redMul(T),this.y=this.y.redMul(T),this.t&&(this.t=this.t.redMul(T)),this.z=this.curve.one,this.zOne=!0,this},P.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},P.prototype.getX=function(){return this.normalize(),this.x.fromRed()},P.prototype.getY=function(){return this.normalize(),this.y.fromRed()},P.prototype.eq=function(T){return this===T||this.getX().cmp(T.getX())===0&&this.getY().cmp(T.getY())===0},P.prototype.eqXToP=function(T){var W=T.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(W)===0)return!0;for(var J=T.clone(),H=this.curve.redN.redMul(this.z);;){if(J.iadd(this.curve.n),J.cmp(this.curve.p)>=0)return!1;if(W.redIAdd(H),this.x.cmp(W)===0)return!0}},P.prototype.toP=P.prototype.normalize,P.prototype.mixedAdd=P.prototype.add}}),MQ=S0({"node_modules/elliptic/lib/elliptic/curve/index.js"(N){var _=N;_.base=k$(),_.short=DY(),_.mont=CY(),_.edwards=LY()}}),T$=S0({"node_modules/hash.js/lib/hash/utils.js"(N){var _=W$(),k=B0();N.inherits=k;function j(Y,G){return(Y.charCodeAt(G)&64512)!==55296||G<0||G+1>=Y.length?!1:(Y.charCodeAt(G+1)&64512)===56320}function F(Y,G){if(Array.isArray(Y))return Y.slice();if(!Y)return[];var Z=[];if(typeof Y=="string")if(G){if(G==="hex")for(Y=Y.replace(/[^a-z0-9]+/gi,""),Y.length%2!==0&&(Y="0"+Y),I=0;I>6|192,Z[V++]=O&63|128):j(Y,I)?(O=65536+((O&1023)<<10)+(Y.charCodeAt(++I)&1023),Z[V++]=O>>18|240,Z[V++]=O>>12&63|128,Z[V++]=O>>6&63|128,Z[V++]=O&63|128):(Z[V++]=O>>12|224,Z[V++]=O>>6&63|128,Z[V++]=O&63|128)}else for(I=0;I>>24|Y>>>8&65280|Y<<8&16711680|(Y&255)<<24;return G>>>0}N.htonl=X;function C(Y,G){for(var Z="",V=0;V>>0}return O}N.join32=W;function J(Y,G){for(var Z=new Array(Y.length*4),V=0,I=0;V>>24,Z[I+1]=O>>>16&255,Z[I+2]=O>>>8&255,Z[I+3]=O&255):(Z[I+3]=O>>>24,Z[I+2]=O>>>16&255,Z[I+1]=O>>>8&255,Z[I]=O&255)}return Z}N.split32=J;function H(Y,G){return Y>>>G|Y<<32-G}N.rotr32=H;function D(Y,G){return Y<>>32-G}N.rotl32=D;function E(Y,G){return Y+G>>>0}N.sum32=E;function L(Y,G,Z){return Y+G+Z>>>0}N.sum32_3=L;function M(Y,G,Z,V){return Y+G+Z+V>>>0}N.sum32_4=M;function v(Y,G,Z,V,I){return Y+G+Z+V+I>>>0}N.sum32_5=v;function q(Y,G,Z,V){var I=Y[G],O=Y[G+1],U=V+O>>>0,Q=(U>>0,Y[G+1]=U}N.sum64=q;function g(Y,G,Z,V){var I=G+V>>>0,O=(I>>0}N.sum64_hi=g;function y(Y,G,Z,V){var I=G+V;return I>>>0}N.sum64_lo=y;function w(Y,G,Z,V,I,O,U,Q){var K=0,R=G;R=R+V>>>0,K+=R>>0,K+=R>>0,K+=R>>0}N.sum64_4_hi=w;function f(Y,G,Z,V,I,O,U,Q){var K=G+V+O+Q;return K>>>0}N.sum64_4_lo=f;function b(Y,G,Z,V,I,O,U,Q,K,R){var A=0,S=G;S=S+V>>>0,A+=S>>0,A+=S>>0,A+=S>>0,A+=S>>0}N.sum64_5_hi=b;function u(Y,G,Z,V,I,O,U,Q,K,R){var A=G+V+O+Q+R;return A>>>0}N.sum64_5_lo=u;function Y0(Y,G,Z){var V=G<<32-Z|Y>>>Z;return V>>>0}N.rotr64_hi=Y0;function p(Y,G,Z){var V=Y<<32-Z|G>>>Z;return V>>>0}N.rotr64_lo=p;function v0(Y,G,Z){return Y>>>Z}N.shr64_hi=v0;function $(Y,G,Z){var V=Y<<32-Z|G>>>Z;return V>>>0}N.shr64_lo=$}}),v$=S0({"node_modules/hash.js/lib/hash/common.js"(N){var _=T$(),k=W$();function j(){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}N.BlockHash=j,j.prototype.update=function(F,z){if(F=_.toArray(F,z),this.pending?this.pending=this.pending.concat(F):this.pending=F,this.pendingTotal+=F.length,this.pending.length>=this._delta8){F=this.pending;var X=F.length%this._delta8;this.pending=F.slice(F.length-X,F.length),this.pending.length===0&&(this.pending=null),F=_.join32(F,0,F.length-X,this.endian);for(var C=0;C>>24&255,C[P++]=F>>>16&255,C[P++]=F>>>8&255,C[P++]=F&255}else for(C[P++]=F&255,C[P++]=F>>>8&255,C[P++]=F>>>16&255,C[P++]=F>>>24&255,C[P++]=0,C[P++]=0,C[P++]=0,C[P++]=0,T=8;T>>3}N.g0_256=T;function W(J){return k(J,17)^k(J,19)^J>>>10}N.g1_256=W}}),RY=S0({"node_modules/hash.js/lib/hash/sha/1.js"(N,_){var k=T$(),j=v$(),F=SQ(),z=k.rotl32,X=k.sum32,C=k.sum32_5,P=F.ft_1,T=j.BlockHash,W=[1518500249,1859775393,2400959708,3395469782];function J(){if(!(this instanceof J))return new J;T.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}k.inherits(J,T),_.exports=J,J.blockSize=512,J.outSize=160,J.hmacStrength=80,J.padLength=64,J.prototype._update=function(H,D){for(var E=this.W,L=0;L<16;L++)E[L]=H[D+L];for(;Lthis.blockSize&&(z=new this.Hash().update(z).digest()),j(z.length<=this.blockSize);for(var X=z.length;X=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(C,P,T)}_.exports=z,z.prototype._init=function(X,C,P){var T=X.concat(C).concat(P);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var W=0;W=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(X.concat(P||[])),this._reseed=1},z.prototype.generate=function(X,C,P,T){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof C!="string"&&(T=P,P=C,C=null),P&&(P=j.toArray(P,T||"hex"),this._update(P));for(var W=[];W.length"}}}),gY=S0({"node_modules/elliptic/lib/elliptic/ec/signature.js"(N,_){var k=D$(),j=E$(),F=j.assert;function z(W,J){if(W instanceof z)return W;this._importDER(W,J)||(F(W.r&&W.s,"Signature without r or s"),this.r=new k(W.r,16),this.s=new k(W.s,16),W.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=W.recoveryParam)}_.exports=z;function X(){this.place=0}function C(W,J){var H=W[J.place++];if(!(H&128))return H;var D=H&15;if(D===0||D>4)return!1;for(var E=0,L=0,M=J.place;L>>=0;return E<=127?!1:(J.place=M,E)}function P(W){for(var J=0,H=W.length-1;!W[J]&&!(W[J+1]&128)&&J>>3);for(W.push(H|128);--H;)W.push(J>>>(H<<3)&255);W.push(J)}z.prototype.toDER=function(W){var J=this.r.toArray(),H=this.s.toArray();for(J[0]&128&&(J=[0].concat(J)),H[0]&128&&(H=[0].concat(H)),J=P(J),H=P(H);!H[0]&&!(H[1]&128);)H=H.slice(1);var D=[2];T(D,J.length),D=D.concat(J),D.push(2),T(D,H.length);var E=D.concat(H),L=[48];return T(L,E.length),L=L.concat(E),j.encode(L,W)}}}),_Y=S0({"node_modules/elliptic/lib/elliptic/ec/index.js"(N,_){var k=D$(),j=jY(),F=E$(),z=b$(),X=f$(),C=F.assert,P=kY(),T=gY();function W(J){if(!(this instanceof W))return new W(J);typeof J=="string"&&(C(Object.prototype.hasOwnProperty.call(z,J),"Unknown curve "+J),J=z[J]),J instanceof z.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=W,W.prototype.keyPair=function(J){return new P(this,J)},W.prototype.keyFromPrivate=function(J,H){return P.fromPrivate(this,J,H)},W.prototype.keyFromPublic=function(J,H){return P.fromPublic(this,J,H)},W.prototype.genKeyPair=function(J){J||(J={});for(var H=new j({hash:this.hash,pers:J.pers,persEnc:J.persEnc||"utf8",entropy:J.entropy||X(this.hash.hmacStrength),entropyEnc:J.entropy&&J.entropyEnc||"utf8",nonce:this.n.toArray()}),D=this.n.byteLength(),E=this.n.sub(new k(2));;){var L=new k(H.generate(D));if(!(L.cmp(E)>0))return L.iaddn(1),this.keyFromPrivate(L)}},W.prototype._truncateToN=function(J,H){var D=J.byteLength()*8-this.n.bitLength();return D>0&&(J=J.ushrn(D)),!H&&J.cmp(this.n)>=0?J.sub(this.n):J},W.prototype.sign=function(J,H,D,E){typeof D=="object"&&(E=D,D=null),E||(E={}),H=this.keyFromPrivate(H,D),J=this._truncateToN(new k(J,16));for(var L=this.n.byteLength(),M=H.getPrivate().toArray("be",L),v=J.toArray("be",L),q=new j({hash:this.hash,entropy:M,nonce:v,pers:E.pers,persEnc:E.persEnc||"utf8"}),g=this.n.sub(new k(1)),y=0;;y++){var w=E.k?E.k(y):new k(q.generate(this.n.byteLength()));if(w=this._truncateToN(w,!0),!(w.cmpn(1)<=0||w.cmp(g)>=0)){var f=this.g.mul(w);if(!f.isInfinity()){var b=f.getX(),u=b.umod(this.n);if(u.cmpn(0)!==0){var Y0=w.invm(this.n).mul(u.mul(H.getPrivate()).iadd(J));if(Y0=Y0.umod(this.n),Y0.cmpn(0)!==0){var p=(f.getY().isOdd()?1:0)|(b.cmp(u)!==0?2:0);return E.canonical&&Y0.cmp(this.nh)>0&&(Y0=this.n.sub(Y0),p^=1),new T({r:u,s:Y0,recoveryParam:p})}}}}}},W.prototype.verify=function(J,H,D,E){J=this._truncateToN(new k(J,16)),D=this.keyFromPublic(D,E),H=new T(H,"hex");var{r:L,s:M}=H;if(L.cmpn(1)<0||L.cmp(this.n)>=0||M.cmpn(1)<0||M.cmp(this.n)>=0)return!1;var v=M.invm(this.n),q=v.mul(J).umod(this.n),g=v.mul(L).umod(this.n),y;return this.curve._maxwellTrick?(y=this.g.jmulAdd(q,D.getPublic(),g),y.isInfinity()?!1:y.eqXToP(L)):(y=this.g.mulAdd(q,D.getPublic(),g),y.isInfinity()?!1:y.getX().umod(this.n).cmp(L)===0)},W.prototype.recoverPubKey=function(J,H,D,E){C((3&D)===D,"The recovery param is more than two bits"),H=new T(H,E);var L=this.n,M=new k(J),v=H.r,q=H.s,g=D&1,y=D>>1;if(v.cmp(this.curve.p.umod(this.curve.n))>=0&&y)throw new Error("Unable to find sencond key candinate");y?v=this.curve.pointFromX(v.add(this.curve.n),g):v=this.curve.pointFromX(v,g);var w=H.r.invm(L),f=L.sub(M).mul(w).umod(L),b=q.mul(w).umod(L);return this.g.mulAdd(f,v,b)},W.prototype.getKeyRecoveryParam=function(J,H,D,E){if(H=new T(H,E),H.recoveryParam!==null)return H.recoveryParam;for(var L=0;L<4;L++){var M;try{M=this.recoverPubKey(J,H,L)}catch{continue}if(M.eq(D))return L}throw new Error("Unable to find valid recovery factor")}}}),NY=S0({"node_modules/elliptic/lib/elliptic/eddsa/key.js"(N,_){var k=E$(),j=k.assert,F=k.parseBytes,z=k.cachedProperty;function X(C,P){this.eddsa=C,this._secret=F(P.secret),C.isPoint(P.pub)?this._pub=P.pub:this._pubBytes=F(P.pub)}X.fromPublic=function(C,P){return P instanceof X?P:new X(C,{pub:P})},X.fromSecret=function(C,P){return P instanceof X?P:new X(C,{secret:P})},X.prototype.secret=function(){return this._secret},z(X,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),z(X,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),z(X,"privBytes",function(){var C=this.eddsa,P=this.hash(),T=C.encodingLength-1,W=P.slice(0,C.encodingLength);return W[0]&=248,W[T]&=127,W[T]|=64,W}),z(X,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),z(X,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),z(X,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),X.prototype.sign=function(C){return j(this._secret,"KeyPair can only verify"),this.eddsa.sign(C,this)},X.prototype.verify=function(C,P){return this.eddsa.verify(C,P,this)},X.prototype.getSecret=function(C){return j(this._secret,"KeyPair is public only"),k.encode(this.secret(),C)},X.prototype.getPublic=function(C){return k.encode(this.pubBytes(),C)},_.exports=X}}),xY=S0({"node_modules/elliptic/lib/elliptic/eddsa/signature.js"(N,_){var k=D$(),j=E$(),F=j.assert,z=j.cachedProperty,X=j.parseBytes;function C(P,T){this.eddsa=P,typeof T!="object"&&(T=X(T)),Array.isArray(T)&&(T={R:T.slice(0,P.encodingLength),S:T.slice(P.encodingLength)}),F(T.R&&T.S,"Signature without R or S"),P.isPoint(T.R)&&(this._R=T.R),T.S instanceof k&&(this._S=T.S),this._Rencoded=Array.isArray(T.R)?T.R:T.Rencoded,this._Sencoded=Array.isArray(T.S)?T.S:T.Sencoded}z(C,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),z(C,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),z(C,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),z(C,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),C.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},C.prototype.toHex=function(){return j.encode(this.toBytes(),"hex").toUpperCase()},_.exports=C}}),BY=S0({"node_modules/elliptic/lib/elliptic/eddsa/index.js"(N,_){var k=d$(),j=b$(),F=E$(),z=F.assert,X=F.parseBytes,C=NY(),P=xY();function T(W){if(z(W==="ed25519","only tested with ed25519 so far"),!(this instanceof T))return new T(W);W=j[W].curve,this.curve=W,this.g=W.g,this.g.precompute(W.n.bitLength()+1),this.pointClass=W.point().constructor,this.encodingLength=Math.ceil(W.n.bitLength()/8),this.hash=k.sha512}_.exports=T,T.prototype.sign=function(W,J){W=X(W);var H=this.keyFromSecret(J),D=this.hashInt(H.messagePrefix(),W),E=this.g.mul(D),L=this.encodePoint(E),M=this.hashInt(L,H.pubBytes(),W).mul(H.priv()),v=D.add(M).umod(this.curve.n);return this.makeSignature({R:E,S:v,Rencoded:L})},T.prototype.verify=function(W,J,H){W=X(W),J=this.makeSignature(J);var D=this.keyFromPublic(H),E=this.hashInt(J.Rencoded(),D.pubBytes(),W),L=this.g.mul(J.S()),M=J.R().add(D.pub().mul(E));return M.eq(L)},T.prototype.hashInt=function(){for(var W=this.hash(),J=0;J0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),o$=S0({"node_modules/safer-buffer/safer.js"(N,_){var k=r$,j=g0,F={},z;for(z in k)!k.hasOwnProperty(z)||z==="SlowBuffer"||z==="Buffer"||(F[z]=k[z]);var X=F.Buffer={};for(z in j)!j.hasOwnProperty(z)||z==="allocUnsafe"||z==="allocUnsafeSlow"||(X[z]=j[z]);if(F.Buffer.prototype=j.prototype,(!X.from||X.from===Uint8Array.from)&&(X.from=function(C,P,T){if(typeof C=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof C);if(C&&typeof C.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof C);return j(C,P,T)}),X.alloc||(X.alloc=function(C,P,T){if(typeof C!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof C);if(C<0||C>=2*(1<<30))throw new RangeError('The value "'+C+'" is invalid for option "size"');var W=j(C);return!P||P.length===0?W.fill(0):typeof T=="string"?W.fill(P,T):W.fill(P),W}),!F.kStringMaxLength)try{F.kStringMaxLength=lQ}catch{}F.constants||(F.constants={MAX_LENGTH:F.kMaxLength},F.kStringMaxLength&&(F.constants.MAX_STRING_LENGTH=F.kStringMaxLength)),_.exports=F}}),u$=S0({"node_modules/asn1.js/lib/asn1/base/reporter.js"(N){var _=B0();function k(F){this._reporterState={obj:null,path:[],options:F||{},errors:[]}}N.Reporter=k,k.prototype.isError=function(F){return F instanceof j},k.prototype.save=function(){let F=this._reporterState;return{obj:F.obj,pathLen:F.path.length}},k.prototype.restore=function(F){let z=this._reporterState;z.obj=F.obj,z.path=z.path.slice(0,F.pathLen)},k.prototype.enterKey=function(F){return this._reporterState.path.push(F)},k.prototype.exitKey=function(F){let z=this._reporterState;z.path=z.path.slice(0,F-1)},k.prototype.leaveKey=function(F,z,X){let C=this._reporterState;this.exitKey(F),C.obj!==null&&(C.obj[z]=X)},k.prototype.path=function(){return this._reporterState.path.join("/")},k.prototype.enterObject=function(){let F=this._reporterState,z=F.obj;return F.obj={},z},k.prototype.leaveObject=function(F){let z=this._reporterState,X=z.obj;return z.obj=F,X},k.prototype.error=function(F){let z,X=this._reporterState,C=F instanceof j;if(C?z=F:z=new j(X.path.map(function(P){return"["+JSON.stringify(P)+"]"}).join(""),F.message||F,F.stack),!X.options.partial)throw z;return C||X.errors.push(z),z},k.prototype.wrapResult=function(F){let z=this._reporterState;return z.options.partial?{result:this.isError(F)?null:F,errors:z.errors}:F};function j(F,z){this.path=F,this.rethrow(z)}_(j,Error),j.prototype.rethrow=function(F){if(this.message=F+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,j),!this.stack)try{throw new Error(this.message)}catch(z){this.stack=z.stack}return this}}}),P$=S0({"node_modules/asn1.js/lib/asn1/base/buffer.js"(N){var _=B0(),k=u$().Reporter,j=o$().Buffer;function F(X,C){if(k.call(this,C),!j.isBuffer(X)){this.error("Input not Buffer");return}this.base=X,this.offset=0,this.length=X.length}_(F,k),N.DecoderBuffer=F,F.isDecoderBuffer=function(X){return X instanceof F?!0:typeof X=="object"&&j.isBuffer(X.base)&&X.constructor.name==="DecoderBuffer"&&typeof X.offset=="number"&&typeof X.length=="number"&&typeof X.save=="function"&&typeof X.restore=="function"&&typeof X.isEmpty=="function"&&typeof X.readUInt8=="function"&&typeof X.skip=="function"&&typeof X.raw=="function"},F.prototype.save=function(){return{offset:this.offset,reporter:k.prototype.save.call(this)}},F.prototype.restore=function(X){let C=new F(this.base);return C.offset=X.offset,C.length=this.offset,this.offset=X.offset,k.prototype.restore.call(this,X.reporter),C},F.prototype.isEmpty=function(){return this.offset===this.length},F.prototype.readUInt8=function(X){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(X||"DecoderBuffer overrun")},F.prototype.skip=function(X,C){if(!(this.offset+X<=this.length))return this.error(C||"DecoderBuffer overrun");let P=new F(this.base);return P._reporterState=this._reporterState,P.offset=this.offset,P.length=this.offset+X,this.offset+=X,P},F.prototype.raw=function(X){return this.base.slice(X?X.offset:this.offset,this.length)};function z(X,C){if(Array.isArray(X))this.length=0,this.value=X.map(function(P){return z.isEncoderBuffer(P)||(P=new z(P,C)),this.length+=P.length,P},this);else if(typeof X=="number"){if(!(0<=X&&X<=255))return C.error("non-byte EncoderBuffer value");this.value=X,this.length=1}else if(typeof X=="string")this.value=X,this.length=j.byteLength(X);else if(j.isBuffer(X))this.value=X,this.length=X.length;else return C.error("Unsupported type: "+typeof X)}N.EncoderBuffer=z,z.isEncoderBuffer=function(X){return X instanceof z?!0:typeof X=="object"&&X.constructor.name==="EncoderBuffer"&&typeof X.length=="number"&&typeof X.join=="function"},z.prototype.join=function(X,C){return X||(X=j.alloc(this.length)),C||(C=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function(P){P.join(X,C),C+=P.length}):(typeof this.value=="number"?X[C]=this.value:typeof this.value=="string"?X.write(this.value,C):j.isBuffer(this.value)&&this.value.copy(X,C),C+=this.length)),X}}}),n$=S0({"node_modules/asn1.js/lib/asn1/base/node.js"(N,_){var k=u$().Reporter,j=P$().EncoderBuffer,F=P$().DecoderBuffer,z=W$(),X=["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"],C=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(X),P=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function T(J,H,D){let E={};this._baseState=E,E.name=D,E.enc=J,E.parent=H||null,E.children=null,E.tag=null,E.args=null,E.reverseArgs=null,E.choice=null,E.optional=!1,E.any=!1,E.obj=!1,E.use=null,E.useDecoder=null,E.key=null,E.default=null,E.explicit=null,E.implicit=null,E.contains=null,E.parent||(E.children=[],this._wrap())}_.exports=T;var W=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];T.prototype.clone=function(){let J=this._baseState,H={};W.forEach(function(E){H[E]=J[E]});let D=new this.constructor(H.parent);return D._baseState=H,D},T.prototype._wrap=function(){let J=this._baseState;C.forEach(function(H){this[H]=function(){let D=new this.constructor(this);return J.children.push(D),D[H].apply(D,arguments)}},this)},T.prototype._init=function(J){let H=this._baseState;z(H.parent===null),J.call(this),H.children=H.children.filter(function(D){return D._baseState.parent===this},this),z.equal(H.children.length,1,"Root node can have only one child")},T.prototype._useArgs=function(J){let H=this._baseState,D=J.filter(function(E){return E instanceof this.constructor},this);J=J.filter(function(E){return!(E instanceof this.constructor)},this),D.length!==0&&(z(H.children===null),H.children=D,D.forEach(function(E){E._baseState.parent=this},this)),J.length!==0&&(z(H.args===null),H.args=J,H.reverseArgs=J.map(function(E){if(typeof E!="object"||E.constructor!==Object)return E;let L={};return Object.keys(E).forEach(function(M){M==(M|0)&&(M|=0);let v=E[M];L[v]=M}),L}))},P.forEach(function(J){T.prototype[J]=function(){let H=this._baseState;throw new Error(J+" not implemented for encoding: "+H.enc)}}),X.forEach(function(J){T.prototype[J]=function(){let H=this._baseState,D=Array.prototype.slice.call(arguments);return z(H.tag===null),H.tag=J,this._useArgs(D),this}}),T.prototype.use=function(J){z(J);let H=this._baseState;return z(H.use===null),H.use=J,this},T.prototype.optional=function(){let J=this._baseState;return J.optional=!0,this},T.prototype.def=function(J){let H=this._baseState;return z(H.default===null),H.default=J,H.optional=!0,this},T.prototype.explicit=function(J){let H=this._baseState;return z(H.explicit===null&&H.implicit===null),H.explicit=J,this},T.prototype.implicit=function(J){let H=this._baseState;return z(H.explicit===null&&H.implicit===null),H.implicit=J,this},T.prototype.obj=function(){let J=this._baseState,H=Array.prototype.slice.call(arguments);return J.obj=!0,H.length!==0&&this._useArgs(H),this},T.prototype.key=function(J){let H=this._baseState;return z(H.key===null),H.key=J,this},T.prototype.any=function(){let J=this._baseState;return J.any=!0,this},T.prototype.choice=function(J){let H=this._baseState;return z(H.choice===null),H.choice=J,this._useArgs(Object.keys(J).map(function(D){return J[D]})),this},T.prototype.contains=function(J){let H=this._baseState;return z(H.use===null),H.contains=J,this},T.prototype._decode=function(J,H){let D=this._baseState;if(D.parent===null)return J.wrapResult(D.children[0]._decode(J,H));let E=D.default,L=!0,M=null;if(D.key!==null&&(M=J.enterKey(D.key)),D.optional){let q=null;if(D.explicit!==null?q=D.explicit:D.implicit!==null?q=D.implicit:D.tag!==null&&(q=D.tag),q===null&&!D.any){let g=J.save();try{D.choice===null?this._decodeGeneric(D.tag,J,H):this._decodeChoice(J,H),L=!0}catch{L=!1}J.restore(g)}else if(L=this._peekTag(J,q,D.any),J.isError(L))return L}let v;if(D.obj&&L&&(v=J.enterObject()),L){if(D.explicit!==null){let g=this._decodeTag(J,D.explicit);if(J.isError(g))return g;J=g}let q=J.offset;if(D.use===null&&D.choice===null){let g;D.any&&(g=J.save());let y=this._decodeTag(J,D.implicit!==null?D.implicit:D.tag,D.any);if(J.isError(y))return y;D.any?E=J.raw(g):J=y}if(H&&H.track&&D.tag!==null&&H.track(J.path(),q,J.length,"tagged"),H&&H.track&&D.tag!==null&&H.track(J.path(),J.offset,J.length,"content"),D.any||(D.choice===null?E=this._decodeGeneric(D.tag,J,H):E=this._decodeChoice(J,H)),J.isError(E))return E;if(!D.any&&D.choice===null&&D.children!==null&&D.children.forEach(function(g){g._decode(J,H)}),D.contains&&(D.tag==="octstr"||D.tag==="bitstr")){let g=new F(E);E=this._getUse(D.contains,J._reporterState.obj)._decode(g,H)}}return D.obj&&L&&(E=J.leaveObject(v)),D.key!==null&&(E!==null||L===!0)?J.leaveKey(M,D.key,E):M!==null&&J.exitKey(M),E},T.prototype._decodeGeneric=function(J,H,D){let E=this._baseState;return J==="seq"||J==="set"?null:J==="seqof"||J==="setof"?this._decodeList(H,J,E.args[0],D):/str$/.test(J)?this._decodeStr(H,J,D):J==="objid"&&E.args?this._decodeObjid(H,E.args[0],E.args[1],D):J==="objid"?this._decodeObjid(H,null,null,D):J==="gentime"||J==="utctime"?this._decodeTime(H,J,D):J==="null_"?this._decodeNull(H,D):J==="bool"?this._decodeBool(H,D):J==="objDesc"?this._decodeStr(H,J,D):J==="int"||J==="enum"?this._decodeInt(H,E.args&&E.args[0],D):E.use!==null?this._getUse(E.use,H._reporterState.obj)._decode(H,D):H.error("unknown tag: "+J)},T.prototype._getUse=function(J,H){let D=this._baseState;return D.useDecoder=this._use(J,H),z(D.useDecoder._baseState.parent===null),D.useDecoder=D.useDecoder._baseState.children[0],D.implicit!==D.useDecoder._baseState.implicit&&(D.useDecoder=D.useDecoder.clone(),D.useDecoder._baseState.implicit=D.implicit),D.useDecoder},T.prototype._decodeChoice=function(J,H){let D=this._baseState,E=null,L=!1;return Object.keys(D.choice).some(function(M){let v=J.save(),q=D.choice[M];try{let g=q._decode(J,H);if(J.isError(g))return!1;E={type:M,value:g},L=!0}catch{return J.restore(v),!1}return!0},this),L?E:J.error("Choice not matched")},T.prototype._createEncoderBuffer=function(J){return new j(J,this.reporter)},T.prototype._encode=function(J,H,D){let E=this._baseState;if(E.default!==null&&E.default===J)return;let L=this._encodeValue(J,H,D);if(L!==void 0&&!this._skipDefault(L,H,D))return L},T.prototype._encodeValue=function(J,H,D){let E=this._baseState;if(E.parent===null)return E.children[0]._encode(J,H||new k);let L=null;if(this.reporter=H,E.optional&&J===void 0)if(E.default!==null)J=E.default;else return;let M=null,v=!1;if(E.any)L=this._createEncoderBuffer(J);else if(E.choice)L=this._encodeChoice(J,H);else if(E.contains)M=this._getUse(E.contains,D)._encode(J,H),v=!0;else if(E.children)M=E.children.map(function(q){if(q._baseState.tag==="null_")return q._encode(null,H,J);if(q._baseState.key===null)return H.error("Child should have a key");let g=H.enterKey(q._baseState.key);if(typeof J!="object")return H.error("Child expected, but input is not object");let y=q._encode(J[q._baseState.key],H,J);return H.leaveKey(g),y},this).filter(function(q){return q}),M=this._createEncoderBuffer(M);else if(E.tag==="seqof"||E.tag==="setof"){if(!(E.args&&E.args.length===1))return H.error("Too many args for : "+E.tag);if(!Array.isArray(J))return H.error("seqof/setof, but data is not Array");let q=this.clone();q._baseState.implicit=null,M=this._createEncoderBuffer(J.map(function(g){let y=this._baseState;return this._getUse(y.args[0],J)._encode(g,H)},q))}else E.use!==null?L=this._getUse(E.use,D)._encode(J,H):(M=this._encodePrimitive(E.tag,J),v=!0);if(!E.any&&E.choice===null){let q=E.implicit!==null?E.implicit:E.tag,g=E.implicit===null?"universal":"context";q===null?E.use===null&&H.error("Tag could be omitted only for .use()"):E.use===null&&(L=this._encodeComposite(q,v,g,M))}return E.explicit!==null&&(L=this._encodeComposite(E.explicit,!1,"context",L)),L},T.prototype._encodeChoice=function(J,H){let D=this._baseState,E=D.choice[J.type];return E||z(!1,J.type+" not found in "+JSON.stringify(Object.keys(D.choice))),E._encode(J.value,H)},T.prototype._encodePrimitive=function(J,H){let D=this._baseState;if(/str$/.test(J))return this._encodeStr(H,J);if(J==="objid"&&D.args)return this._encodeObjid(H,D.reverseArgs[0],D.args[1]);if(J==="objid")return this._encodeObjid(H,null,null);if(J==="gentime"||J==="utctime")return this._encodeTime(H,J);if(J==="null_")return this._encodeNull();if(J==="int"||J==="enum")return this._encodeInt(H,D.args&&D.reverseArgs[0]);if(J==="bool")return this._encodeBool(H);if(J==="objDesc")return this._encodeStr(H,J);throw new Error("Unsupported tag: "+J)},T.prototype._isNumstr=function(J){return/^[0-9 ]*$/.test(J)},T.prototype._isPrintstr=function(J){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(J)}}}),s$=S0({"node_modules/asn1.js/lib/asn1/constants/der.js"(N){function _(k){let j={};return Object.keys(k).forEach(function(F){(F|0)==F&&(F=F|0);let z=k[F];j[z]=F}),j}N.tagClass={0:"universal",1:"application",2:"context",3:"private"},N.tagClassByName=_(N.tagClass),N.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"},N.tagByName=_(N.tag)}}),kQ=S0({"node_modules/asn1.js/lib/asn1/encoders/der.js"(N,_){var k=B0(),j=o$().Buffer,F=n$(),z=s$();function X(W){this.enc="der",this.name=W.name,this.entity=W,this.tree=new C,this.tree._init(W.body)}_.exports=X,X.prototype.encode=function(W,J){return this.tree._encode(W,J).join()};function C(W){F.call(this,"der",W)}k(C,F),C.prototype._encodeComposite=function(W,J,H,D){let E=T(W,J,H,this.reporter);if(D.length<128){let v=j.alloc(2);return v[0]=E,v[1]=D.length,this._createEncoderBuffer([v,D])}let L=1;for(let v=D.length;v>=256;v>>=8)L++;let M=j.alloc(2+L);M[0]=E,M[1]=128|L;for(let v=1+L,q=D.length;q>0;v--,q>>=8)M[v]=q&255;return this._createEncoderBuffer([M,D])},C.prototype._encodeStr=function(W,J){if(J==="bitstr")return this._createEncoderBuffer([W.unused|0,W.data]);if(J==="bmpstr"){let H=j.alloc(W.length*2);for(let D=0;D=40)return this.reporter.error("Second objid identifier OOB");W.splice(0,2,W[0]*40+W[1])}let D=0;for(let M=0;M=128;v>>=7)D++}let E=j.alloc(D),L=E.length-1;for(let M=W.length-1;M>=0;M--){let v=W[M];for(E[L--]=v&127;(v>>=7)>0;)E[L--]=128|v&127}return this._createEncoderBuffer(E)};function P(W){return W<10?"0"+W:W}C.prototype._encodeTime=function(W,J){let H,D=new Date(W);return J==="gentime"?H=[P(D.getUTCFullYear()),P(D.getUTCMonth()+1),P(D.getUTCDate()),P(D.getUTCHours()),P(D.getUTCMinutes()),P(D.getUTCSeconds()),"Z"].join(""):J==="utctime"?H=[P(D.getUTCFullYear()%100),P(D.getUTCMonth()+1),P(D.getUTCDate()),P(D.getUTCHours()),P(D.getUTCMinutes()),P(D.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+J+" time is not supported yet"),this._encodeStr(H,"octstr")},C.prototype._encodeNull=function(){return this._createEncoderBuffer("")},C.prototype._encodeInt=function(W,J){if(typeof W=="string"){if(!J)return this.reporter.error("String int or enum given, but no values map");if(!J.hasOwnProperty(W))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(W));W=J[W]}if(typeof W!="number"&&!j.isBuffer(W)){let E=W.toArray();!W.sign&&E[0]&128&&E.unshift(0),W=j.from(E)}if(j.isBuffer(W)){let E=W.length;W.length===0&&E++;let L=j.alloc(E);return W.copy(L),W.length===0&&(L[0]=0),this._createEncoderBuffer(L)}if(W<128)return this._createEncoderBuffer(W);if(W<256)return this._createEncoderBuffer([0,W]);let H=1;for(let E=W;E>=256;E>>=8)H++;let D=new Array(H);for(let E=D.length-1;E>=0;E--)D[E]=W&255,W>>=8;return D[0]&128&&D.unshift(0),this._createEncoderBuffer(j.from(D))},C.prototype._encodeBool=function(W){return this._createEncoderBuffer(W?255:0)},C.prototype._use=function(W,J){return typeof W=="function"&&(W=W(J)),W._getEncoder("der").tree},C.prototype._skipDefault=function(W,J,H){let D=this._baseState,E;if(D.default===null)return!1;let L=W.join();if(D.defaultBuffer===void 0&&(D.defaultBuffer=this._encodeValue(D.default,J,H).join()),L.length!==D.defaultBuffer.length)return!1;for(E=0;E=31?D.error("Multi-octet tag encoding unsupported"):(J||(E|=32),E|=z.tagClassByName[H||"universal"]<<6,E)}}}),yY=S0({"node_modules/asn1.js/lib/asn1/encoders/pem.js"(N,_){var k=B0(),j=kQ();function F(z){j.call(this,z),this.enc="pem"}k(F,j),_.exports=F,F.prototype.encode=function(z,X){let C=j.prototype.encode.call(this,z).toString("base64"),P=["-----BEGIN "+X.label+"-----"];for(let T=0;T>6],L=(D&32)===0;if((D&31)===31){let v=D;for(D=0;(v&128)===128;){if(v=J.readUInt8(H),J.isError(v))return v;D<<=7,D|=v&127}}else D&=31;let M=X.tag[D];return{cls:E,primitive:L,tag:D,tagStr:M}}function W(J,H,D){let E=J.readUInt8(D);if(J.isError(E))return E;if(!H&&E===128)return null;if((E&128)===0)return E;let L=E&127;if(L>4)return J.error("length octect is too long");E=0;for(let M=0;M0&&y.ishrn(w),y}function L(q,g){q=E(q,g),q=q.mod(g);var y=k.from(q.toArray());if(y.length=H)throw new Error("invalid sig")}_.exports=C}}),nY=S0({"node_modules/browserify-sign/browser/index.js"(N,_){var k=N0().Buffer,j=M$(),F=B0(),z=oY(),X=uY(),C=KQ();Object.keys(C).forEach(function(H){C[H].id=k.from(C[H].id,"hex"),C[H.toLowerCase()]=C[H]});function P(H){A$.Writable.call(this);var D=C[H];if(!D)throw new Error("Unknown message digest");this._hashType=D.hash,this._hash=j(D.hash),this._tag=D.id,this._signType=D.sign}F(P,A$.Writable),P.prototype._write=function(H,D,E){this._hash.update(H),E()},P.prototype.update=function(H,D){return typeof H=="string"&&(H=k.from(H,D)),this._hash.update(H),this},P.prototype.sign=function(H,D){this.end();var E=this._hash.digest(),L=z(E,H,this._hashType,this._signType,this._tag);return D?L.toString(D):L};function T(H){A$.Writable.call(this);var D=C[H];if(!D)throw new Error("Unknown message digest");this._hash=j(D.hash),this._tag=D.id,this._signType=D.sign}F(T,A$.Writable),T.prototype._write=function(H,D,E){this._hash.update(H),E()},T.prototype.update=function(H,D){return typeof H=="string"&&(H=k.from(H,D)),this._hash.update(H),this},T.prototype.verify=function(H,D,E){typeof D=="string"&&(D=k.from(D,E)),this.end();var L=this._hash.digest();return X(D,L,H,this._signType,this._tag)};function W(H){return new P(H)}function J(H){return new T(H)}_.exports={Sign:W,Verify:J,createSign:W,createVerify:J}}}),sY=S0({"node_modules/create-ecdh/node_modules/bn.js/lib/bn.js"(N,_){(function(k,j){function F($,Y){if(!$)throw new Error(Y||"Assertion failed")}function z($,Y){$.super_=Y;var G=function(){};G.prototype=Y.prototype,$.prototype=new G,$.prototype.constructor=$}function X($,Y,G){if(X.isBN($))return $;this.negative=0,this.words=null,this.length=0,this.red=null,$!==null&&((Y==="le"||Y==="be")&&(G=Y,Y=10),this._init($||0,Y||10,G||"be"))}typeof k=="object"?k.exports=X:j.BN=X,X.BN=X,X.wordSize=26;var C=g0;X.isBN=function($){return $ instanceof X?!0:$!==null&&typeof $=="object"&&$.constructor.wordSize===X.wordSize&&Array.isArray($.words)},X.max=function($,Y){return $.cmp(Y)>0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),tY=S0({"node_modules/create-ecdh/browser.js"(N,_){var k=l$(),j=sY();_.exports=function(C){return new z(C)};var F={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}};F.p224=F.secp224r1,F.p256=F.secp256r1=F.prime256v1,F.p192=F.secp192r1=F.prime192v1,F.p384=F.secp384r1,F.p521=F.secp521r1;function z(C){this.curveType=F[C],this.curveType||(this.curveType={name:C}),this.curve=new k.ec(this.curveType.name),this.keys=void 0}z.prototype.generateKeys=function(C,P){return this.keys=this.curve.genKeyPair(),this.getPublicKey(C,P)},z.prototype.computeSecret=function(C,P,T){P=P||"utf8",g0.isBuffer(C)||(C=new g0(C,P));var W=this.curve.keyFromPublic(C).getPublic(),J=W.mul(this.keys.getPrivate()).getX();return X(J,T,this.curveType.byteLength)},z.prototype.getPublicKey=function(C,P){var T=this.keys.getPublic(P==="compressed",!0);return P==="hybrid"&&(T[T.length-1]%2?T[0]=7:T[0]=6),X(T,C)},z.prototype.getPrivateKey=function(C){return X(this.keys.getPrivate(),C)},z.prototype.setPublicKey=function(C,P){return P=P||"utf8",g0.isBuffer(C)||(C=new g0(C,P)),this.keys._importPublic(C),this},z.prototype.setPrivateKey=function(C,P){P=P||"utf8",g0.isBuffer(C)||(C=new g0(C,P));var T=new j(C);return T=T.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(T),this};function X(C,P,T){Array.isArray(C)||(C=C.toArray());var W=new g0(C);if(T&&W.length0?$:Y},X.min=function($,Y){return $.cmp(Y)<0?$:Y},X.prototype._init=function($,Y,G){if(typeof $=="number")return this._initNumber($,Y,G);if(typeof $=="object")return this._initArray($,Y,G);Y==="hex"&&(Y=16),F(Y===(Y|0)&&Y>=2&&Y<=36),$=$.toString().replace(/\s+/g,"");var Z=0;$[0]==="-"&&(Z++,this.negative=1),Z<$.length&&(Y===16?this._parseHex($,Z,G):(this._parseBase($,Y,Z),G==="le"&&this._initArray(this.toArray(),Y,G)))},X.prototype._initNumber=function($,Y,G){$<0&&(this.negative=1,$=-$),$<67108864?(this.words=[$&67108863],this.length=1):$<4503599627370496?(this.words=[$&67108863,$/67108864&67108863],this.length=2):(F($<9007199254740992),this.words=[$&67108863,$/67108864&67108863,1],this.length=3),G==="le"&&this._initArray(this.toArray(),Y,G)},X.prototype._initArray=function($,Y,G){if(F(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 Z=0;Z=0;Z-=3)I=$[Z]|$[Z-1]<<8|$[Z-2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);else if(G==="le")for(Z=0,V=0;Z<$.length;Z+=3)I=$[Z]|$[Z+1]<<8|$[Z+2]<<16,this.words[V]|=I<>>26-O&67108863,O+=24,O>=26&&(O-=26,V++);return this.strip()};function P($,Y){var G=$.charCodeAt(Y);return G>=65&&G<=70?G-55:G>=97&&G<=102?G-87:G-48&15}function T($,Y,G){var Z=P($,G);return G-1>=Y&&(Z|=P($,G-1)<<4),Z}X.prototype._parseHex=function($,Y,G){this.length=Math.ceil(($.length-Y)/6),this.words=new Array(this.length);for(var Z=0;Z=Y;Z-=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8;else{var U=$.length-Y;for(Z=U%2===0?Y+1:Y;Z<$.length;Z+=2)O=T($,Y,Z)<=18?(V-=18,I+=1,this.words[I]|=O>>>26):V+=8}this.strip()};function W($,Y,G,Z){for(var V=0,I=Math.min($.length,G),O=Y;O=49?V+=U-49+10:U>=17?V+=U-17+10:V+=U}return V}X.prototype._parseBase=function($,Y,G){this.words=[0],this.length=1;for(var Z=0,V=1;V<=67108863;V*=Y)Z++;Z--,V=V/Y|0;for(var I=$.length-G,O=I%Z,U=Math.min(I,I-O)+G,Q=0,K=G;K1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},X.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},X.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"],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],D=[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];X.prototype.toString=function($,Y){$=$||10,Y=Y|0||1;var G;if($===16||$==="hex"){G="";for(var Z=0,V=0,I=0;I>>24-Z&16777215,V!==0||I!==this.length-1?G=J[6-U.length]+U+G:G=U+G,Z+=2,Z>=26&&(Z-=26,I--)}for(V!==0&&(G=V.toString(16)+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}if($===($|0)&&$>=2&&$<=36){var Q=H[$],K=D[$];G="";var R=this.clone();for(R.negative=0;!R.isZero();){var A=R.modn(K).toString($);R=R.idivn(K),R.isZero()?G=A+G:G=J[Q-A.length]+A+G}for(this.isZero()&&(G="0"+G);G.length%Y!==0;)G="0"+G;return this.negative!==0&&(G="-"+G),G}F(!1,"Base should be between 2 and 36")},X.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&&F(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-$:$},X.prototype.toJSON=function(){return this.toString(16)},X.prototype.toBuffer=function($,Y){return F(typeof C<"u"),this.toArrayLike(C,$,Y)},X.prototype.toArray=function($,Y){return this.toArrayLike(Array,$,Y)},X.prototype.toArrayLike=function($,Y,G){var Z=this.byteLength(),V=G||Math.max(1,Z);F(Z<=V,"byte array longer than desired length"),F(V>0,"Requested array length <= 0"),this.strip();var I=Y==="le",O=new $(V),U,Q,K=this.clone();if(I){for(Q=0;!K.isZero();Q++)U=K.andln(255),K.iushrn(8),O[Q]=U;for(;Q=4096&&(G+=13,Y>>>=13),Y>=64&&(G+=7,Y>>>=7),Y>=8&&(G+=4,Y>>>=4),Y>=2&&(G+=2,Y>>>=2),G+Y},X.prototype._zeroBits=function($){if($===0)return 26;var Y=$,G=0;return(Y&8191)===0&&(G+=13,Y>>>=13),(Y&127)===0&&(G+=7,Y>>>=7),(Y&15)===0&&(G+=4,Y>>>=4),(Y&3)===0&&(G+=2,Y>>>=2),(Y&1)===0&&G++,G},X.prototype.bitLength=function(){var $=this.words[this.length-1],Y=this._countBits($);return(this.length-1)*26+Y};function E($){for(var Y=new Array($.bitLength()),G=0;G>>V}return Y}X.prototype.zeroBits=function(){if(this.isZero())return 0;for(var $=0,Y=0;Y$.length?this.clone().ior($):$.clone().ior(this)},X.prototype.uor=function($){return this.length>$.length?this.clone().iuor($):$.clone().iuor(this)},X.prototype.iuand=function($){var Y;this.length>$.length?Y=$:Y=this;for(var G=0;G$.length?this.clone().iand($):$.clone().iand(this)},X.prototype.uand=function($){return this.length>$.length?this.clone().iuand($):$.clone().iuand(this)},X.prototype.iuxor=function($){var Y,G;this.length>$.length?(Y=this,G=$):(Y=$,G=this);for(var Z=0;Z$.length?this.clone().ixor($):$.clone().ixor(this)},X.prototype.uxor=function($){return this.length>$.length?this.clone().iuxor($):$.clone().iuxor(this)},X.prototype.inotn=function($){F(typeof $=="number"&&$>=0);var Y=Math.ceil($/26)|0,G=$%26;this._expand(Y),G>0&&Y--;for(var Z=0;Z0&&(this.words[Z]=~this.words[Z]&67108863>>26-G),this.strip()},X.prototype.notn=function($){return this.clone().inotn($)},X.prototype.setn=function($,Y){F(typeof $=="number"&&$>=0);var G=$/26|0,Z=$%26;return this._expand(G+1),Y?this.words[G]=this.words[G]|1<$.length?(G=this,Z=$):(G=$,Z=this);for(var V=0,I=0;I>>26;for(;V!==0&&I>>26;if(this.length=G.length,V!==0)this.words[this.length]=V,this.length++;else if(G!==this)for(;I$.length?this.clone().iadd($):$.clone().iadd(this)},X.prototype.isub=function($){if($.negative!==0){$.negative=0;var Y=this.iadd($);return $.negative=1,Y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd($),this.negative=1,this._normSign();var G=this.cmp($);if(G===0)return this.negative=0,this.length=1,this.words[0]=0,this;var Z,V;G>0?(Z=this,V=$):(Z=$,V=this);for(var I=0,O=0;O>26,this.words[O]=Y&67108863;for(;I!==0&&O>26,this.words[O]=Y&67108863;if(I===0&&O>>26,A=Q&67108863,S=Math.min(K,Y.length-1),x=Math.max(0,K-$.length+1);x<=S;x++){var B=K-x|0;V=$.words[B]|0,I=Y.words[x]|0,O=V*I+A,R+=O/67108864|0,A=O&67108863}G.words[K]=A|0,Q=R|0}return Q!==0?G.words[K]=Q|0:G.length--,G.strip()}var M=function($,Y,G){var Z=$.words,V=Y.words,I=G.words,O=0,U,Q,K,R=Z[0]|0,A=R&8191,S=R>>>13,x=Z[1]|0,B=x&8191,c=x>>>13,q0=Z[2]|0,h=q0&8191,d=q0>>>13,_0=Z[3]|0,l=_0&8191,n=_0>>>13,y0=Z[4]|0,t=y0&8191,s=y0>>>13,w0=Z[5]|0,m=w0&8191,r=w0>>>13,$$=Z[6]|0,i=$$&8191,e=$$>>>13,x0=Z[7]|0,o=x0&8191,a=x0>>>13,p0=Z[8]|0,$0=p0&8191,Q0=p0>>>13,Y$=Z[9]|0,Z0=Y$&8191,G0=Y$>>>13,Z$=V[0]|0,V0=Z$&8191,U0=Z$>>>13,G$=V[1]|0,X0=G$&8191,K0=G$>>>13,V$=V[2]|0,I0=V$&8191,O0=V$>>>13,U$=V[3]|0,J0=U$&8191,F0=U$>>>13,X$=V[4]|0,A0=X$&8191,H0=X$>>>13,K$=V[5]|0,W0=K$&8191,E0=K$>>>13,I$=V[6]|0,T0=I$&8191,D0=I$>>>13,O$=V[7]|0,C0=O$&8191,L0=O$>>>13,J$=V[8]|0,R0=J$&8191,P0=J$>>>13,F$=V[9]|0,z0=F$&8191,M0=F$>>>13;G.negative=$.negative^Y.negative,G.length=19,U=Math.imul(A,V0),Q=Math.imul(A,U0),Q=Q+Math.imul(S,V0)|0,K=Math.imul(S,U0);var Q$=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(Q$>>>26)|0,Q$&=67108863,U=Math.imul(B,V0),Q=Math.imul(B,U0),Q=Q+Math.imul(c,V0)|0,K=Math.imul(c,U0),U=U+Math.imul(A,X0)|0,Q=Q+Math.imul(A,K0)|0,Q=Q+Math.imul(S,X0)|0,K=K+Math.imul(S,K0)|0;var j0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(j0>>>26)|0,j0&=67108863,U=Math.imul(h,V0),Q=Math.imul(h,U0),Q=Q+Math.imul(d,V0)|0,K=Math.imul(d,U0),U=U+Math.imul(B,X0)|0,Q=Q+Math.imul(B,K0)|0,Q=Q+Math.imul(c,X0)|0,K=K+Math.imul(c,K0)|0,U=U+Math.imul(A,I0)|0,Q=Q+Math.imul(A,O0)|0,Q=Q+Math.imul(S,I0)|0,K=K+Math.imul(S,O0)|0;var k0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(k0>>>26)|0,k0&=67108863,U=Math.imul(l,V0),Q=Math.imul(l,U0),Q=Q+Math.imul(n,V0)|0,K=Math.imul(n,U0),U=U+Math.imul(h,X0)|0,Q=Q+Math.imul(h,K0)|0,Q=Q+Math.imul(d,X0)|0,K=K+Math.imul(d,K0)|0,U=U+Math.imul(B,I0)|0,Q=Q+Math.imul(B,O0)|0,Q=Q+Math.imul(c,I0)|0,K=K+Math.imul(c,O0)|0,U=U+Math.imul(A,J0)|0,Q=Q+Math.imul(A,F0)|0,Q=Q+Math.imul(S,J0)|0,K=K+Math.imul(S,F0)|0;var f0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(f0>>>26)|0,f0&=67108863,U=Math.imul(t,V0),Q=Math.imul(t,U0),Q=Q+Math.imul(s,V0)|0,K=Math.imul(s,U0),U=U+Math.imul(l,X0)|0,Q=Q+Math.imul(l,K0)|0,Q=Q+Math.imul(n,X0)|0,K=K+Math.imul(n,K0)|0,U=U+Math.imul(h,I0)|0,Q=Q+Math.imul(h,O0)|0,Q=Q+Math.imul(d,I0)|0,K=K+Math.imul(d,O0)|0,U=U+Math.imul(B,J0)|0,Q=Q+Math.imul(B,F0)|0,Q=Q+Math.imul(c,J0)|0,K=K+Math.imul(c,F0)|0,U=U+Math.imul(A,A0)|0,Q=Q+Math.imul(A,H0)|0,Q=Q+Math.imul(S,A0)|0,K=K+Math.imul(S,H0)|0;var c0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(c0>>>26)|0,c0&=67108863,U=Math.imul(m,V0),Q=Math.imul(m,U0),Q=Q+Math.imul(r,V0)|0,K=Math.imul(r,U0),U=U+Math.imul(t,X0)|0,Q=Q+Math.imul(t,K0)|0,Q=Q+Math.imul(s,X0)|0,K=K+Math.imul(s,K0)|0,U=U+Math.imul(l,I0)|0,Q=Q+Math.imul(l,O0)|0,Q=Q+Math.imul(n,I0)|0,K=K+Math.imul(n,O0)|0,U=U+Math.imul(h,J0)|0,Q=Q+Math.imul(h,F0)|0,Q=Q+Math.imul(d,J0)|0,K=K+Math.imul(d,F0)|0,U=U+Math.imul(B,A0)|0,Q=Q+Math.imul(B,H0)|0,Q=Q+Math.imul(c,A0)|0,K=K+Math.imul(c,H0)|0,U=U+Math.imul(A,W0)|0,Q=Q+Math.imul(A,E0)|0,Q=Q+Math.imul(S,W0)|0,K=K+Math.imul(S,E0)|0;var h0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(h0>>>26)|0,h0&=67108863,U=Math.imul(i,V0),Q=Math.imul(i,U0),Q=Q+Math.imul(e,V0)|0,K=Math.imul(e,U0),U=U+Math.imul(m,X0)|0,Q=Q+Math.imul(m,K0)|0,Q=Q+Math.imul(r,X0)|0,K=K+Math.imul(r,K0)|0,U=U+Math.imul(t,I0)|0,Q=Q+Math.imul(t,O0)|0,Q=Q+Math.imul(s,I0)|0,K=K+Math.imul(s,O0)|0,U=U+Math.imul(l,J0)|0,Q=Q+Math.imul(l,F0)|0,Q=Q+Math.imul(n,J0)|0,K=K+Math.imul(n,F0)|0,U=U+Math.imul(h,A0)|0,Q=Q+Math.imul(h,H0)|0,Q=Q+Math.imul(d,A0)|0,K=K+Math.imul(d,H0)|0,U=U+Math.imul(B,W0)|0,Q=Q+Math.imul(B,E0)|0,Q=Q+Math.imul(c,W0)|0,K=K+Math.imul(c,E0)|0,U=U+Math.imul(A,T0)|0,Q=Q+Math.imul(A,D0)|0,Q=Q+Math.imul(S,T0)|0,K=K+Math.imul(S,D0)|0;var d0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(d0>>>26)|0,d0&=67108863,U=Math.imul(o,V0),Q=Math.imul(o,U0),Q=Q+Math.imul(a,V0)|0,K=Math.imul(a,U0),U=U+Math.imul(i,X0)|0,Q=Q+Math.imul(i,K0)|0,Q=Q+Math.imul(e,X0)|0,K=K+Math.imul(e,K0)|0,U=U+Math.imul(m,I0)|0,Q=Q+Math.imul(m,O0)|0,Q=Q+Math.imul(r,I0)|0,K=K+Math.imul(r,O0)|0,U=U+Math.imul(t,J0)|0,Q=Q+Math.imul(t,F0)|0,Q=Q+Math.imul(s,J0)|0,K=K+Math.imul(s,F0)|0,U=U+Math.imul(l,A0)|0,Q=Q+Math.imul(l,H0)|0,Q=Q+Math.imul(n,A0)|0,K=K+Math.imul(n,H0)|0,U=U+Math.imul(h,W0)|0,Q=Q+Math.imul(h,E0)|0,Q=Q+Math.imul(d,W0)|0,K=K+Math.imul(d,E0)|0,U=U+Math.imul(B,T0)|0,Q=Q+Math.imul(B,D0)|0,Q=Q+Math.imul(c,T0)|0,K=K+Math.imul(c,D0)|0,U=U+Math.imul(A,C0)|0,Q=Q+Math.imul(A,L0)|0,Q=Q+Math.imul(S,C0)|0,K=K+Math.imul(S,L0)|0;var b0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(b0>>>26)|0,b0&=67108863,U=Math.imul($0,V0),Q=Math.imul($0,U0),Q=Q+Math.imul(Q0,V0)|0,K=Math.imul(Q0,U0),U=U+Math.imul(o,X0)|0,Q=Q+Math.imul(o,K0)|0,Q=Q+Math.imul(a,X0)|0,K=K+Math.imul(a,K0)|0,U=U+Math.imul(i,I0)|0,Q=Q+Math.imul(i,O0)|0,Q=Q+Math.imul(e,I0)|0,K=K+Math.imul(e,O0)|0,U=U+Math.imul(m,J0)|0,Q=Q+Math.imul(m,F0)|0,Q=Q+Math.imul(r,J0)|0,K=K+Math.imul(r,F0)|0,U=U+Math.imul(t,A0)|0,Q=Q+Math.imul(t,H0)|0,Q=Q+Math.imul(s,A0)|0,K=K+Math.imul(s,H0)|0,U=U+Math.imul(l,W0)|0,Q=Q+Math.imul(l,E0)|0,Q=Q+Math.imul(n,W0)|0,K=K+Math.imul(n,E0)|0,U=U+Math.imul(h,T0)|0,Q=Q+Math.imul(h,D0)|0,Q=Q+Math.imul(d,T0)|0,K=K+Math.imul(d,D0)|0,U=U+Math.imul(B,C0)|0,Q=Q+Math.imul(B,L0)|0,Q=Q+Math.imul(c,C0)|0,K=K+Math.imul(c,L0)|0,U=U+Math.imul(A,R0)|0,Q=Q+Math.imul(A,P0)|0,Q=Q+Math.imul(S,R0)|0,K=K+Math.imul(S,P0)|0;var l0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(l0>>>26)|0,l0&=67108863,U=Math.imul(Z0,V0),Q=Math.imul(Z0,U0),Q=Q+Math.imul(G0,V0)|0,K=Math.imul(G0,U0),U=U+Math.imul($0,X0)|0,Q=Q+Math.imul($0,K0)|0,Q=Q+Math.imul(Q0,X0)|0,K=K+Math.imul(Q0,K0)|0,U=U+Math.imul(o,I0)|0,Q=Q+Math.imul(o,O0)|0,Q=Q+Math.imul(a,I0)|0,K=K+Math.imul(a,O0)|0,U=U+Math.imul(i,J0)|0,Q=Q+Math.imul(i,F0)|0,Q=Q+Math.imul(e,J0)|0,K=K+Math.imul(e,F0)|0,U=U+Math.imul(m,A0)|0,Q=Q+Math.imul(m,H0)|0,Q=Q+Math.imul(r,A0)|0,K=K+Math.imul(r,H0)|0,U=U+Math.imul(t,W0)|0,Q=Q+Math.imul(t,E0)|0,Q=Q+Math.imul(s,W0)|0,K=K+Math.imul(s,E0)|0,U=U+Math.imul(l,T0)|0,Q=Q+Math.imul(l,D0)|0,Q=Q+Math.imul(n,T0)|0,K=K+Math.imul(n,D0)|0,U=U+Math.imul(h,C0)|0,Q=Q+Math.imul(h,L0)|0,Q=Q+Math.imul(d,C0)|0,K=K+Math.imul(d,L0)|0,U=U+Math.imul(B,R0)|0,Q=Q+Math.imul(B,P0)|0,Q=Q+Math.imul(c,R0)|0,K=K+Math.imul(c,P0)|0,U=U+Math.imul(A,z0)|0,Q=Q+Math.imul(A,M0)|0,Q=Q+Math.imul(S,z0)|0,K=K+Math.imul(S,M0)|0;var o0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(o0>>>26)|0,o0&=67108863,U=Math.imul(Z0,X0),Q=Math.imul(Z0,K0),Q=Q+Math.imul(G0,X0)|0,K=Math.imul(G0,K0),U=U+Math.imul($0,I0)|0,Q=Q+Math.imul($0,O0)|0,Q=Q+Math.imul(Q0,I0)|0,K=K+Math.imul(Q0,O0)|0,U=U+Math.imul(o,J0)|0,Q=Q+Math.imul(o,F0)|0,Q=Q+Math.imul(a,J0)|0,K=K+Math.imul(a,F0)|0,U=U+Math.imul(i,A0)|0,Q=Q+Math.imul(i,H0)|0,Q=Q+Math.imul(e,A0)|0,K=K+Math.imul(e,H0)|0,U=U+Math.imul(m,W0)|0,Q=Q+Math.imul(m,E0)|0,Q=Q+Math.imul(r,W0)|0,K=K+Math.imul(r,E0)|0,U=U+Math.imul(t,T0)|0,Q=Q+Math.imul(t,D0)|0,Q=Q+Math.imul(s,T0)|0,K=K+Math.imul(s,D0)|0,U=U+Math.imul(l,C0)|0,Q=Q+Math.imul(l,L0)|0,Q=Q+Math.imul(n,C0)|0,K=K+Math.imul(n,L0)|0,U=U+Math.imul(h,R0)|0,Q=Q+Math.imul(h,P0)|0,Q=Q+Math.imul(d,R0)|0,K=K+Math.imul(d,P0)|0,U=U+Math.imul(B,z0)|0,Q=Q+Math.imul(B,M0)|0,Q=Q+Math.imul(c,z0)|0,K=K+Math.imul(c,M0)|0;var u0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(u0>>>26)|0,u0&=67108863,U=Math.imul(Z0,I0),Q=Math.imul(Z0,O0),Q=Q+Math.imul(G0,I0)|0,K=Math.imul(G0,O0),U=U+Math.imul($0,J0)|0,Q=Q+Math.imul($0,F0)|0,Q=Q+Math.imul(Q0,J0)|0,K=K+Math.imul(Q0,F0)|0,U=U+Math.imul(o,A0)|0,Q=Q+Math.imul(o,H0)|0,Q=Q+Math.imul(a,A0)|0,K=K+Math.imul(a,H0)|0,U=U+Math.imul(i,W0)|0,Q=Q+Math.imul(i,E0)|0,Q=Q+Math.imul(e,W0)|0,K=K+Math.imul(e,E0)|0,U=U+Math.imul(m,T0)|0,Q=Q+Math.imul(m,D0)|0,Q=Q+Math.imul(r,T0)|0,K=K+Math.imul(r,D0)|0,U=U+Math.imul(t,C0)|0,Q=Q+Math.imul(t,L0)|0,Q=Q+Math.imul(s,C0)|0,K=K+Math.imul(s,L0)|0,U=U+Math.imul(l,R0)|0,Q=Q+Math.imul(l,P0)|0,Q=Q+Math.imul(n,R0)|0,K=K+Math.imul(n,P0)|0,U=U+Math.imul(h,z0)|0,Q=Q+Math.imul(h,M0)|0,Q=Q+Math.imul(d,z0)|0,K=K+Math.imul(d,M0)|0;var n0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(n0>>>26)|0,n0&=67108863,U=Math.imul(Z0,J0),Q=Math.imul(Z0,F0),Q=Q+Math.imul(G0,J0)|0,K=Math.imul(G0,F0),U=U+Math.imul($0,A0)|0,Q=Q+Math.imul($0,H0)|0,Q=Q+Math.imul(Q0,A0)|0,K=K+Math.imul(Q0,H0)|0,U=U+Math.imul(o,W0)|0,Q=Q+Math.imul(o,E0)|0,Q=Q+Math.imul(a,W0)|0,K=K+Math.imul(a,E0)|0,U=U+Math.imul(i,T0)|0,Q=Q+Math.imul(i,D0)|0,Q=Q+Math.imul(e,T0)|0,K=K+Math.imul(e,D0)|0,U=U+Math.imul(m,C0)|0,Q=Q+Math.imul(m,L0)|0,Q=Q+Math.imul(r,C0)|0,K=K+Math.imul(r,L0)|0,U=U+Math.imul(t,R0)|0,Q=Q+Math.imul(t,P0)|0,Q=Q+Math.imul(s,R0)|0,K=K+Math.imul(s,P0)|0,U=U+Math.imul(l,z0)|0,Q=Q+Math.imul(l,M0)|0,Q=Q+Math.imul(n,z0)|0,K=K+Math.imul(n,M0)|0;var s0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(s0>>>26)|0,s0&=67108863,U=Math.imul(Z0,A0),Q=Math.imul(Z0,H0),Q=Q+Math.imul(G0,A0)|0,K=Math.imul(G0,H0),U=U+Math.imul($0,W0)|0,Q=Q+Math.imul($0,E0)|0,Q=Q+Math.imul(Q0,W0)|0,K=K+Math.imul(Q0,E0)|0,U=U+Math.imul(o,T0)|0,Q=Q+Math.imul(o,D0)|0,Q=Q+Math.imul(a,T0)|0,K=K+Math.imul(a,D0)|0,U=U+Math.imul(i,C0)|0,Q=Q+Math.imul(i,L0)|0,Q=Q+Math.imul(e,C0)|0,K=K+Math.imul(e,L0)|0,U=U+Math.imul(m,R0)|0,Q=Q+Math.imul(m,P0)|0,Q=Q+Math.imul(r,R0)|0,K=K+Math.imul(r,P0)|0,U=U+Math.imul(t,z0)|0,Q=Q+Math.imul(t,M0)|0,Q=Q+Math.imul(s,z0)|0,K=K+Math.imul(s,M0)|0;var t0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(t0>>>26)|0,t0&=67108863,U=Math.imul(Z0,W0),Q=Math.imul(Z0,E0),Q=Q+Math.imul(G0,W0)|0,K=Math.imul(G0,E0),U=U+Math.imul($0,T0)|0,Q=Q+Math.imul($0,D0)|0,Q=Q+Math.imul(Q0,T0)|0,K=K+Math.imul(Q0,D0)|0,U=U+Math.imul(o,C0)|0,Q=Q+Math.imul(o,L0)|0,Q=Q+Math.imul(a,C0)|0,K=K+Math.imul(a,L0)|0,U=U+Math.imul(i,R0)|0,Q=Q+Math.imul(i,P0)|0,Q=Q+Math.imul(e,R0)|0,K=K+Math.imul(e,P0)|0,U=U+Math.imul(m,z0)|0,Q=Q+Math.imul(m,M0)|0,Q=Q+Math.imul(r,z0)|0,K=K+Math.imul(r,M0)|0;var m0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(m0>>>26)|0,m0&=67108863,U=Math.imul(Z0,T0),Q=Math.imul(Z0,D0),Q=Q+Math.imul(G0,T0)|0,K=Math.imul(G0,D0),U=U+Math.imul($0,C0)|0,Q=Q+Math.imul($0,L0)|0,Q=Q+Math.imul(Q0,C0)|0,K=K+Math.imul(Q0,L0)|0,U=U+Math.imul(o,R0)|0,Q=Q+Math.imul(o,P0)|0,Q=Q+Math.imul(a,R0)|0,K=K+Math.imul(a,P0)|0,U=U+Math.imul(i,z0)|0,Q=Q+Math.imul(i,M0)|0,Q=Q+Math.imul(e,z0)|0,K=K+Math.imul(e,M0)|0;var a0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(a0>>>26)|0,a0&=67108863,U=Math.imul(Z0,C0),Q=Math.imul(Z0,L0),Q=Q+Math.imul(G0,C0)|0,K=Math.imul(G0,L0),U=U+Math.imul($0,R0)|0,Q=Q+Math.imul($0,P0)|0,Q=Q+Math.imul(Q0,R0)|0,K=K+Math.imul(Q0,P0)|0,U=U+Math.imul(o,z0)|0,Q=Q+Math.imul(o,M0)|0,Q=Q+Math.imul(a,z0)|0,K=K+Math.imul(a,M0)|0;var e0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(e0>>>26)|0,e0&=67108863,U=Math.imul(Z0,R0),Q=Math.imul(Z0,P0),Q=Q+Math.imul(G0,R0)|0,K=Math.imul(G0,P0),U=U+Math.imul($0,z0)|0,Q=Q+Math.imul($0,M0)|0,Q=Q+Math.imul(Q0,z0)|0,K=K+Math.imul(Q0,M0)|0;var r0=(O+U|0)+((Q&8191)<<13)|0;O=(K+(Q>>>13)|0)+(r0>>>26)|0,r0&=67108863,U=Math.imul(Z0,z0),Q=Math.imul(Z0,M0),Q=Q+Math.imul(G0,z0)|0,K=Math.imul(G0,M0);var i0=(O+U|0)+((Q&8191)<<13)|0;return O=(K+(Q>>>13)|0)+(i0>>>26)|0,i0&=67108863,I[0]=Q$,I[1]=j0,I[2]=k0,I[3]=f0,I[4]=c0,I[5]=h0,I[6]=d0,I[7]=b0,I[8]=l0,I[9]=o0,I[10]=u0,I[11]=n0,I[12]=s0,I[13]=t0,I[14]=m0,I[15]=a0,I[16]=e0,I[17]=r0,I[18]=i0,O!==0&&(I[19]=O,G.length++),G};Math.imul||(M=L);function v($,Y,G){G.negative=Y.negative^$.negative,G.length=$.length+Y.length;for(var Z=0,V=0,I=0;I>>26)|0,V+=O>>>26,O&=67108863}G.words[I]=U,Z=O,O=V}return Z!==0?G.words[I]=Z:G.length--,G.strip()}function q($,Y,G){var Z=new g;return Z.mulp($,Y,G)}X.prototype.mulTo=function($,Y){var G,Z=this.length+$.length;return this.length===10&&$.length===10?G=M(this,$,Y):Z<63?G=L(this,$,Y):Z<1024?G=v(this,$,Y):G=q(this,$,Y),G};function g($,Y){this.x=$,this.y=Y}g.prototype.makeRBT=function($){for(var Y=new Array($),G=X.prototype._countBits($)-1,Z=0;Z<$;Z++)Y[Z]=this.revBin(Z,G,$);return Y},g.prototype.revBin=function($,Y,G){if($===0||$===G-1)return $;for(var Z=0,V=0;V>=1;return Z},g.prototype.permute=function($,Y,G,Z,V,I){for(var O=0;O>>1)V++;return 1<>>13,G[2*I+1]=V&8191,V=V>>>13;for(I=2*Y;I>=26,Y+=Z/67108864|0,Y+=V>>>26,this.words[G]=V&67108863}return Y!==0&&(this.words[G]=Y,this.length++),this},X.prototype.muln=function($){return this.clone().imuln($)},X.prototype.sqr=function(){return this.mul(this)},X.prototype.isqr=function(){return this.imul(this.clone())},X.prototype.pow=function($){var Y=E($);if(Y.length===0)return new X(1);for(var G=this,Z=0;Z=0);var Y=$%26,G=($-Y)/26,Z=67108863>>>26-Y<<26-Y,V;if(Y!==0){var I=0;for(V=0;V>>26-Y}I&&(this.words[V]=I,this.length++)}if(G!==0){for(V=this.length-1;V>=0;V--)this.words[V+G]=this.words[V];for(V=0;V=0);var Z;Y?Z=(Y-Y%26)/26:Z=0;var V=$%26,I=Math.min(($-V)/26,this.length),O=67108863^67108863>>>V<I)for(this.length-=I,Q=0;Q=0&&(K!==0||Q>=Z);Q--){var R=this.words[Q]|0;this.words[Q]=K<<26-V|R>>>V,K=R&O}return U&&K!==0&&(U.words[U.length++]=K),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},X.prototype.ishrn=function($,Y,G){return F(this.negative===0),this.iushrn($,Y,G)},X.prototype.shln=function($){return this.clone().ishln($)},X.prototype.ushln=function($){return this.clone().iushln($)},X.prototype.shrn=function($){return this.clone().ishrn($)},X.prototype.ushrn=function($){return this.clone().iushrn($)},X.prototype.testn=function($){F(typeof $=="number"&&$>=0);var Y=$%26,G=($-Y)/26,Z=1<=0);var Y=$%26,G=($-Y)/26;if(F(this.negative===0,"imaskn works only with positive numbers"),this.length<=G)return this;if(Y!==0&&G++,this.length=Math.min(G,this.length),Y!==0){var Z=67108863^67108863>>>Y<=67108864;Y++)this.words[Y]-=67108864,Y===this.length-1?this.words[Y+1]=1:this.words[Y+1]++;return this.length=Math.max(this.length,Y+1),this},X.prototype.isubn=function($){if(F(typeof $=="number"),F($<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 Y=0;Y>26)-(U/67108864|0),this.words[V+G]=I&67108863}for(;V>26,this.words[V+G]=I&67108863;if(O===0)return this.strip();for(F(O===-1),O=0,V=0;V>26,this.words[V]=I&67108863;return this.negative=1,this.strip()},X.prototype._wordDiv=function($,Y){var G=this.length-$.length,Z=this.clone(),V=$,I=V.words[V.length-1]|0,O=this._countBits(I);G=26-O,G!==0&&(V=V.ushln(G),Z.iushln(G),I=V.words[V.length-1]|0);var U=Z.length-V.length,Q;if(Y!=="mod"){Q=new X(null),Q.length=U+1,Q.words=new Array(Q.length);for(var K=0;K=0;A--){var S=(Z.words[V.length+A]|0)*67108864+(Z.words[V.length+A-1]|0);for(S=Math.min(S/I|0,67108863),Z._ishlnsubmul(V,S,A);Z.negative!==0;)S--,Z.negative=0,Z._ishlnsubmul(V,1,A),Z.isZero()||(Z.negative^=1);Q&&(Q.words[A]=S)}return Q&&Q.strip(),Z.strip(),Y!=="div"&&G!==0&&Z.iushrn(G),{div:Q||null,mod:Z}},X.prototype.divmod=function($,Y,G){if(F(!$.isZero()),this.isZero())return{div:new X(0),mod:new X(0)};var Z,V,I;return this.negative!==0&&$.negative===0?(I=this.neg().divmod($,Y),Y!=="mod"&&(Z=I.div.neg()),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.iadd($)),{div:Z,mod:V}):this.negative===0&&$.negative!==0?(I=this.divmod($.neg(),Y),Y!=="mod"&&(Z=I.div.neg()),{div:Z,mod:I.mod}):(this.negative&$.negative)!==0?(I=this.neg().divmod($.neg(),Y),Y!=="div"&&(V=I.mod.neg(),G&&V.negative!==0&&V.isub($)),{div:I.div,mod:V}):$.length>this.length||this.cmp($)<0?{div:new X(0),mod:this}:$.length===1?Y==="div"?{div:this.divn($.words[0]),mod:null}:Y==="mod"?{div:null,mod:new X(this.modn($.words[0]))}:{div:this.divn($.words[0]),mod:new X(this.modn($.words[0]))}:this._wordDiv($,Y)},X.prototype.div=function($){return this.divmod($,"div",!1).div},X.prototype.mod=function($){return this.divmod($,"mod",!1).mod},X.prototype.umod=function($){return this.divmod($,"mod",!0).mod},X.prototype.divRound=function($){var Y=this.divmod($);if(Y.mod.isZero())return Y.div;var G=Y.div.negative!==0?Y.mod.isub($):Y.mod,Z=$.ushrn(1),V=$.andln(1),I=G.cmp(Z);return I<0||V===1&&I===0?Y.div:Y.div.negative!==0?Y.div.isubn(1):Y.div.iaddn(1)},X.prototype.modn=function($){F($<=67108863);for(var Y=(1<<26)%$,G=0,Z=this.length-1;Z>=0;Z--)G=(Y*G+(this.words[Z]|0))%$;return G},X.prototype.idivn=function($){F($<=67108863);for(var Y=0,G=this.length-1;G>=0;G--){var Z=(this.words[G]|0)+Y*67108864;this.words[G]=Z/$|0,Y=Z%$}return this.strip()},X.prototype.divn=function($){return this.clone().idivn($)},X.prototype.egcd=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=new X(0),O=new X(1),U=0;Y.isEven()&&G.isEven();)Y.iushrn(1),G.iushrn(1),++U;for(var Q=G.clone(),K=Y.clone();!Y.isZero();){for(var R=0,A=1;(Y.words[0]&A)===0&&R<26;++R,A<<=1);if(R>0)for(Y.iushrn(R);R-- >0;)(Z.isOdd()||V.isOdd())&&(Z.iadd(Q),V.isub(K)),Z.iushrn(1),V.iushrn(1);for(var S=0,x=1;(G.words[0]&x)===0&&S<26;++S,x<<=1);if(S>0)for(G.iushrn(S);S-- >0;)(I.isOdd()||O.isOdd())&&(I.iadd(Q),O.isub(K)),I.iushrn(1),O.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(I),V.isub(O)):(G.isub(Y),I.isub(Z),O.isub(V))}return{a:I,b:O,gcd:G.iushln(U)}},X.prototype._invmp=function($){F($.negative===0),F(!$.isZero());var Y=this,G=$.clone();Y.negative!==0?Y=Y.umod($):Y=Y.clone();for(var Z=new X(1),V=new X(0),I=G.clone();Y.cmpn(1)>0&&G.cmpn(1)>0;){for(var O=0,U=1;(Y.words[0]&U)===0&&O<26;++O,U<<=1);if(O>0)for(Y.iushrn(O);O-- >0;)Z.isOdd()&&Z.iadd(I),Z.iushrn(1);for(var Q=0,K=1;(G.words[0]&K)===0&&Q<26;++Q,K<<=1);if(Q>0)for(G.iushrn(Q);Q-- >0;)V.isOdd()&&V.iadd(I),V.iushrn(1);Y.cmp(G)>=0?(Y.isub(G),Z.isub(V)):(G.isub(Y),V.isub(Z))}var R;return Y.cmpn(1)===0?R=Z:R=V,R.cmpn(0)<0&&R.iadd($),R},X.prototype.gcd=function($){if(this.isZero())return $.abs();if($.isZero())return this.abs();var Y=this.clone(),G=$.clone();Y.negative=0,G.negative=0;for(var Z=0;Y.isEven()&&G.isEven();Z++)Y.iushrn(1),G.iushrn(1);do{for(;Y.isEven();)Y.iushrn(1);for(;G.isEven();)G.iushrn(1);var V=Y.cmp(G);if(V<0){var I=Y;Y=G,G=I}else if(V===0||G.cmpn(1)===0)break;Y.isub(G)}while(!0);return G.iushln(Z)},X.prototype.invm=function($){return this.egcd($).a.umod($)},X.prototype.isEven=function(){return(this.words[0]&1)===0},X.prototype.isOdd=function(){return(this.words[0]&1)===1},X.prototype.andln=function($){return this.words[0]&$},X.prototype.bincn=function($){F(typeof $=="number");var Y=$%26,G=($-Y)/26,Z=1<>>26,O&=67108863,this.words[I]=O}return V!==0&&(this.words[I]=V,this.length++),this},X.prototype.isZero=function(){return this.length===1&&this.words[0]===0},X.prototype.cmpn=function($){var Y=$<0;if(this.negative!==0&&!Y)return-1;if(this.negative===0&&Y)return 1;this.strip();var G;if(this.length>1)G=1;else{Y&&($=-$),F($<=67108863,"Number is too big");var Z=this.words[0]|0;G=Z===$?0:Z<$?-1:1}return this.negative!==0?-G|0:G},X.prototype.cmp=function($){if(this.negative!==0&&$.negative===0)return-1;if(this.negative===0&&$.negative!==0)return 1;var Y=this.ucmp($);return this.negative!==0?-Y|0:Y},X.prototype.ucmp=function($){if(this.length>$.length)return 1;if(this.length<$.length)return-1;for(var Y=0,G=this.length-1;G>=0;G--){var Z=this.words[G]|0,V=$.words[G]|0;if(Z!==V){ZV&&(Y=1);break}}return Y},X.prototype.gtn=function($){return this.cmpn($)===1},X.prototype.gt=function($){return this.cmp($)===1},X.prototype.gten=function($){return this.cmpn($)>=0},X.prototype.gte=function($){return this.cmp($)>=0},X.prototype.ltn=function($){return this.cmpn($)===-1},X.prototype.lt=function($){return this.cmp($)===-1},X.prototype.lten=function($){return this.cmpn($)<=0},X.prototype.lte=function($){return this.cmp($)<=0},X.prototype.eqn=function($){return this.cmpn($)===0},X.prototype.eq=function($){return this.cmp($)===0},X.red=function($){return new p($)},X.prototype.toRed=function($){return F(!this.red,"Already a number in reduction context"),F(this.negative===0,"red works only with positives"),$.convertTo(this)._forceRed($)},X.prototype.fromRed=function(){return F(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},X.prototype._forceRed=function($){return this.red=$,this},X.prototype.forceRed=function($){return F(!this.red,"Already a number in reduction context"),this._forceRed($)},X.prototype.redAdd=function($){return F(this.red,"redAdd works only with red numbers"),this.red.add(this,$)},X.prototype.redIAdd=function($){return F(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,$)},X.prototype.redSub=function($){return F(this.red,"redSub works only with red numbers"),this.red.sub(this,$)},X.prototype.redISub=function($){return F(this.red,"redISub works only with red numbers"),this.red.isub(this,$)},X.prototype.redShl=function($){return F(this.red,"redShl works only with red numbers"),this.red.shl(this,$)},X.prototype.redMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.mul(this,$)},X.prototype.redIMul=function($){return F(this.red,"redMul works only with red numbers"),this.red._verify2(this,$),this.red.imul(this,$)},X.prototype.redSqr=function(){return F(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},X.prototype.redISqr=function(){return F(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},X.prototype.redSqrt=function(){return F(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},X.prototype.redInvm=function(){return F(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},X.prototype.redNeg=function(){return F(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},X.prototype.redPow=function($){return F(this.red&&!$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,$)};var y={k256:null,p224:null,p192:null,p25519:null};function w($,Y){this.name=$,this.p=new X(Y,16),this.n=this.p.bitLength(),this.k=new X(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}w.prototype._tmp=function(){var $=new X(null);return $.words=new Array(Math.ceil(this.n/13)),$},w.prototype.ireduce=function($){var Y=$,G;do this.split(Y,this.tmp),Y=this.imulK(Y),Y=Y.iadd(this.tmp),G=Y.bitLength();while(G>this.n);var Z=G0?Y.isub(this.p):Y.strip!==void 0?Y.strip():Y._strip(),Y},w.prototype.split=function($,Y){$.iushrn(this.n,0,Y)},w.prototype.imulK=function($){return $.imul(this.k)};function f(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}z(f,w),f.prototype.split=function($,Y){for(var G=4194303,Z=Math.min($.length,9),V=0;V>>22,I=O}I>>>=22,$.words[V-10]=I,I===0&&$.length>10?$.length-=10:$.length-=9},f.prototype.imulK=function($){$.words[$.length]=0,$.words[$.length+1]=0,$.length+=2;for(var Y=0,G=0;G<$.length;G++){var Z=$.words[G]|0;Y+=Z*977,$.words[G]=Y&67108863,Y=Z*64+(Y/67108864|0)}return $.words[$.length-1]===0&&($.length--,$.words[$.length-1]===0&&$.length--),$};function b(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}z(b,w);function u(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}z(u,w);function Y0(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}z(Y0,w),Y0.prototype.imulK=function($){for(var Y=0,G=0;G<$.length;G++){var Z=($.words[G]|0)*19+Y,V=Z&67108863;Z>>>=26,$.words[G]=V,Y=Z}return Y!==0&&($.words[$.length++]=Y),$},X._prime=function($){if(y[$])return y[$];var Y;if($==="k256")Y=new f;else if($==="p224")Y=new b;else if($==="p192")Y=new u;else if($==="p25519")Y=new Y0;else throw new Error("Unknown prime "+$);return y[$]=Y,Y};function p($){if(typeof $=="string"){var Y=X._prime($);this.m=Y.p,this.prime=Y}else F($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}p.prototype._verify1=function($){F($.negative===0,"red works only with positives"),F($.red,"red works only with red numbers")},p.prototype._verify2=function($,Y){F(($.negative|Y.negative)===0,"red works only with positives"),F($.red&&$.red===Y.red,"red works only with red numbers")},p.prototype.imod=function($){return this.prime?this.prime.ireduce($)._forceRed(this):$.umod(this.m)._forceRed(this)},p.prototype.neg=function($){return $.isZero()?$.clone():this.m.sub($)._forceRed(this)},p.prototype.add=function($,Y){this._verify2($,Y);var G=$.add(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G._forceRed(this)},p.prototype.iadd=function($,Y){this._verify2($,Y);var G=$.iadd(Y);return G.cmp(this.m)>=0&&G.isub(this.m),G},p.prototype.sub=function($,Y){this._verify2($,Y);var G=$.sub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G._forceRed(this)},p.prototype.isub=function($,Y){this._verify2($,Y);var G=$.isub(Y);return G.cmpn(0)<0&&G.iadd(this.m),G},p.prototype.shl=function($,Y){return this._verify1($),this.imod($.ushln(Y))},p.prototype.imul=function($,Y){return this._verify2($,Y),this.imod($.imul(Y))},p.prototype.mul=function($,Y){return this._verify2($,Y),this.imod($.mul(Y))},p.prototype.isqr=function($){return this.imul($,$.clone())},p.prototype.sqr=function($){return this.mul($,$)},p.prototype.sqrt=function($){if($.isZero())return $.clone();var Y=this.m.andln(3);if(F(Y%2===1),Y===3){var G=this.m.add(new X(1)).iushrn(2);return this.pow($,G)}for(var Z=this.m.subn(1),V=0;!Z.isZero()&&Z.andln(1)===0;)V++,Z.iushrn(1);F(!Z.isZero());var I=new X(1).toRed(this),O=I.redNeg(),U=this.m.subn(1).iushrn(1),Q=this.m.bitLength();for(Q=new X(2*Q*Q).toRed(this);this.pow(Q,U).cmp(O)!==0;)Q.redIAdd(O);for(var K=this.pow(Q,Z),R=this.pow($,Z.addn(1).iushrn(1)),A=this.pow($,Z),S=V;A.cmp(I)!==0;){for(var x=A,B=0;x.cmp(I)!==0;B++)x=x.redSqr();F(B=0;V--){for(var K=Y.words[V],R=Q-1;R>=0;R--){var A=K>>R&1;if(I!==Z[0]&&(I=this.sqr(I)),A===0&&O===0){U=0;continue}O<<=1,O|=A,U++,!(U!==G&&(V!==0||R!==0))&&(I=this.mul(I,Z[O]),U=0,O=0)}Q=26}return I},p.prototype.convertTo=function($){var Y=$.umod(this.m);return Y===$?Y.clone():Y},p.prototype.convertFrom=function($){var Y=$.clone();return Y.red=null,Y},X.mont=function($){return new v0($)};function v0($){p.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new X(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)}z(v0,p),v0.prototype.convertTo=function($){return this.imod($.ushln(this.shift))},v0.prototype.convertFrom=function($){var Y=this.imod($.mul(this.rinv));return Y.red=null,Y},v0.prototype.imul=function($,Y){if($.isZero()||Y.isZero())return $.words[0]=0,$.length=1,$;var G=$.imul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.mul=function($,Y){if($.isZero()||Y.isZero())return new X(0)._forceRed(this);var G=$.mul(Y),Z=G.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=G.isub(Z).iushrn(this.shift),I=V;return V.cmp(this.m)>=0?I=V.isub(this.m):V.cmpn(0)<0&&(I=V.iadd(this.m)),I._forceRed(this)},v0.prototype.invm=function($){var Y=this.imod($._invmp(this.m).mul(this.r2));return Y._forceRed(this)}})(typeof _>"u"||_,N)}}),{CryptoHasher:mY}=globalThis.Bun,pQ=S0({"node_modules/public-encrypt/withPublic.js"(N,_){var k=t$(),j=N0().Buffer;function F(z,X){return j.from(z.toRed(k.mont(X.modulus)).redPow(new k(X.publicExponent)).fromRed().toArray())}_.exports=F}}),aY=S0({"node_modules/public-encrypt/publicEncrypt.js"(N,_){var k=g$(),j=L$(),F=M$(),z=yQ(),X=wQ(),C=t$(),P=pQ(),T=h$(),W=N0().Buffer;_.exports=function(E,L,M){var v;E.padding?v=E.padding:M?v=1:v=4;var q=k(E),g;if(v===4)g=J(q,L);else if(v===1)g=H(q,L,M);else if(v===3){if(g=new C(L),g.cmp(q.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return M?T(g,q):P(g,q)};function J(E,L){var M=E.modulus.byteLength(),v=L.length,q=F("sha1").update(W.alloc(0)).digest(),g=q.length,y=2*g;if(v>M-y-2)throw new Error("message too long");var w=W.alloc(M-v-y-2),f=M-g-1,b=j(g),u=X(W.concat([q,w,W.alloc(1,1),L],f),z(b,f)),Y0=X(b,z(u,g));return new C(W.concat([W.alloc(1),Y0,u],M))}function H(E,L,M){var v=L.length,q=E.modulus.byteLength();if(v>q-11)throw new Error("message too long");var g;return M?g=W.alloc(q-v-3,255):g=D(q-v-3),new C(W.concat([W.from([0,M?1:2]),g,W.alloc(1),L],q))}function D(E){for(var L=W.allocUnsafe(E),M=0,v=j(E*2),q=0,g;Mq||new z(E).cmp(v.modulus)>=0)throw new Error("decryption error");var g;L?g=P(new z(E),v):g=X(E,v);var y=T.alloc(q-g.length);if(g=T.concat([y,g],q),M===4)return W(v,g);if(M===1)return J(v,g,L);if(M===3)return g;throw new Error("unknown padding")};function W(D,E){var L=D.modulus.byteLength(),M=C("sha1").update(T.alloc(0)).digest(),v=M.length;if(E[0]!==0)throw new Error("decryption error");var q=E.slice(1,v+1),g=E.slice(v+1),y=F(q,j(g,v)),w=F(g,j(y,L-v-1));if(H(M,w.slice(0,v)))throw new Error("decryption error");for(var f=v;w[f]===0;)f++;if(w[f++]!==1)throw new Error("decryption error");return w.slice(f)}function J(D,E,L){for(var M=E.slice(0,2),v=2,q=0;E[v++]!==0;)if(v>=E.length){q++;break}var g=E.slice(2,v-1);if((M.toString("hex")!=="0002"&&!L||M.toString("hex")!=="0001"&&L)&&q++,g.length<8&&q++,q)throw new Error("decryption error");return E.slice(v)}function H(D,E){D=T.from(D),E=T.from(E);var L=0,M=D.length;D.length!==E.length&&(L++,M=Math.min(D.length,E.length));for(var v=-1;++vz||J<0)throw new TypeError("offset must be a uint32");if(J>F||J>H)throw new RangeError("offset out of range")}function C(J,H,D){if(typeof J!="number"||J!==J)throw new TypeError("size must be a number");if(J>z||J<0)throw new TypeError("size must be a uint32");if(J+H>D||J>F)throw new RangeError("buffer too small")}N.randomFill=P,N.randomFillSync=W;function P(J,H,D,E){if(!j.isBuffer(J)&&!(J instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof H=="function")E=H,H=0,D=J.length;else if(typeof D=="function")E=D,D=J.length-H;else if(typeof E!="function")throw new TypeError('"cb" argument must be a function');return X(H,J.length),C(D,H,J.length),T(J,H,D,E)}function T(J,H,D,E){if(E){k(D,function(M,v){if(M)return E(M);v.copy(J,H),E(null,J)});return}var L=k(D);return L.copy(J,H),J}function W(J,H,D){if(typeof H>"u"&&(H=0),!j.isBuffer(J)&&!(J instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return X(H,J.length),D===void 0&&(D=J.length-H),C(D,H,J.length),T(J,H,D)}}}),$Z=S0({"node_modules/crypto-browserify/index.js"(N){N.randomBytes=N.rng=N.pseudoRandomBytes=N.prng=L$(),N.createHash=M$(),N.Hash=N.createHash.Hash,N.createHmac=N.Hmac=XQ();var _=aQ(),k=Object.keys(_),j=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(k);N.getHashes=function(){return j};var F=AQ();N.pbkdf2=F.pbkdf2,N.pbkdf2Sync=F.pbkdf2Sync;var z=FY();N.Cipher=z.Cipher,N.createCipher=z.createCipher,N.Cipheriv=z.Cipheriv,N.createCipheriv=z.createCipheriv,N.Decipher=z.Decipher,N.createDecipher=z.createDecipher,N.Decipheriv=z.Decipheriv,N.createDecipheriv=z.createDecipheriv,N.getCiphers=z.getCiphers,N.listCiphers=z.listCiphers;var X=EY();N.DiffieHellmanGroup=X.DiffieHellmanGroup,N.createDiffieHellmanGroup=X.createDiffieHellmanGroup,N.getDiffieHellman=X.getDiffieHellman,N.createDiffieHellman=X.createDiffieHellman,N.DiffieHellman=X.DiffieHellman;var C=nY();N.createSign=C.createSign,N.Sign=C.Sign,N.createVerify=C.createVerify,N.Verify=C.Verify,N.createECDH=tY();var P=rY();N.publicEncrypt=P.publicEncrypt,N.privateEncrypt=P.privateEncrypt,N.publicDecrypt=P.publicDecrypt,N.privateDecrypt=P.privateDecrypt,N.getRandomValues=(W)=>H$.getRandomValues(W);var T=iY();N.randomFill=T.randomFill,N.randomFillSync=T.randomFillSync,N.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` -`))},N.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}}}),m$={...$Z(),[Symbol.for("CommonJS")]:0},z$="buffer",QZ=(N)=>H$.getRandomValues(N),YZ=()=>H$.randomUUID(),ZZ=(...N)=>H$.randomInt(...N),B$="timingSafeEqual"in H$?(N,_)=>{let{byteLength:k}=N,{byteLength:j}=_;if(typeof k!="number"||typeof j!="number")throw new TypeError("Input must be an array buffer view");if(k!==j)throw new RangeError("Input buffers must have the same length");return H$.timingSafeEqual(N,_)}:void 0,fQ="scryptSync"in H$?(N,_,k,j)=>{let F=H$.scryptSync(N,_,k,j);return z$!=="buffer"?new g0(F).toString(z$):new g0(F)}:void 0,cQ="scryptSync"in H$?function(N,_,k,j,F){if(typeof j=="function"&&(F=j,j=void 0),typeof F!="function"){var z=new TypeError("callback must be a function");throw z.code="ERR_INVALID_CALLBACK",z}try{let X=H$.scryptSync(N,_,k,j);process.nextTick(F,null,z$!=="buffer"?new g0(X).toString(z$):new g0(X))}catch(X){throw X}}:void 0;B$&&(Object.defineProperty(B$,"name",{value:"::bunternal::"}),Object.defineProperty(cQ,"name",{value:"::bunternal::"}),Object.defineProperty(fQ,"name",{value:"::bunternal::"}));var e$=H$;oQ(m$,{DEFAULT_ENCODING:()=>z$,getRandomValues:()=>QZ,randomUUID:()=>YZ,randomInt:()=>ZZ,scrypt:()=>cQ,scryptSync:()=>fQ,timingSafeEqual:()=>B$,webcrypto:()=>e$,subtle:()=>e$.subtle});var{randomBytes:UZ,rng:XZ,pseudoRandomBytes:KZ,prng:IZ,Hash:OZ,createHash:JZ,createHmac:FZ,Hmac:AZ,getHashes:HZ,pbkdf2:WZ,pbkdf2Sync:EZ,Cipher:TZ,createCipher:DZ,Cipheriv:CZ,createCipheriv:LZ,Decipher:RZ,createDecipher:PZ,Decipheriv:zZ,createDecipheriv:MZ,getCiphers:SZ,listCiphers:vZ,DiffieHellmanGroup:qZ,createDiffieHellmanGroup:jZ,getDiffieHellman:kZ,createDiffieHellman:gZ,DiffieHellman:_Z,createSign:NZ,Sign:xZ,createVerify:BZ,Verify:yZ,createECDH:wZ,publicEncrypt:pZ,privateEncrypt:fZ,publicDecrypt:cZ,privateDecrypt:hZ,randomFill:dZ,randomFillSync:bZ,createCredentials:lZ,constants:oZ}=m$;var nZ=m$;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{e$ as webcrypto,B$ as timingSafeEqual,fQ as scryptSync,cQ as scrypt,XZ as rng,YZ as randomUUID,ZZ as randomInt,bZ as randomFillSync,dZ as randomFill,UZ as randomBytes,pZ as publicEncrypt,cZ as publicDecrypt,KZ as pseudoRandomBytes,IZ as prng,fZ as privateEncrypt,hZ as privateDecrypt,EZ as pbkdf2Sync,WZ as pbkdf2,vZ as listCiphers,QZ as getRandomValues,HZ as getHashes,kZ as getDiffieHellman,SZ as getCiphers,nZ as default,BZ as createVerify,NZ as createSign,FZ as createHmac,JZ as createHash,wZ as createECDH,jZ as createDiffieHellmanGroup,gZ as createDiffieHellman,MZ as createDecipheriv,PZ as createDecipher,lZ as createCredentials,LZ as createCipheriv,DZ as createCipher,oZ as constants,yZ as Verify,xZ as Sign,AZ as Hmac,OZ as Hash,qZ as DiffieHellmanGroup,_Z as DiffieHellman,zZ as Decipheriv,RZ as Decipher,z$ as DEFAULT_ENCODING,CZ as Cipheriv,TZ as Cipher}; +import{StringDecoder as BQ} from"node:string_decoder";import*as P0 from"node:buffer";import*as R0 from"node:stream";var PZ=function(){return RZ};var xQ=Object.defineProperty;var J=Object.getOwnPropertyNames;var yQ=536870888,G0=globalThis.Buffer,qQ=globalThis.crypto,wQ=qQ;var pQ=(t0,m0)=>function(){return m0||(0,t0[J(t0)[0]])((m0={exports:{}}).exports,m0),m0.exports},fQ=(t0,m0)=>{for(var a0 in m0)xQ(t0,a0,{get:m0[a0],enumerable:!0})};var cQ=pQ({"node_modules/safe-buffer/index.js"(t0,m0){var a0=P0,e0=a0.Buffer;function r0($$,Q$){for(var $ in $$)Q$[$]=$$[$]}e0.from&&e0.alloc&&e0.allocUnsafe&&e0.allocUnsafeSlow?m0.exports=a0:(r0(a0,t0),t0.Buffer=i0);function i0($$,Q$,$){return e0($$,Q$,$)}i0.prototype=Object.create(e0.prototype),r0(e0,i0),i0.from=function($$,Q$,$){if(typeof $$=="number")throw new TypeError("Argument must not be a number");return e0($$,Q$,$)},i0.alloc=function($$,Q$,$){if(typeof $$!="number")throw new TypeError("Argument must be a number");var N=e0($$);return Q$!==void 0?typeof $=="string"?N.fill(Q$,$):N.fill(Q$):N.fill(0),N},i0.allocUnsafe=function($$){if(typeof $$!="number")throw new TypeError("Argument must be a number");return e0($$)},i0.allocUnsafeSlow=function($$){if(typeof $$!="number")throw new TypeError("Argument must be a number");return a0.SlowBuffer($$)}}}),hQ=pQ({"node_modules/randombytes/browser.js"(t0,m0){var a0=65536,e0=4294967295;function r0(){throw new Error(`Secure random number generation is not supported by this browser. +Use Chrome, Firefox or Internet Explorer 11`)}var i0=cQ().Buffer,$$=wQ;$$&&$$.getRandomValues?m0.exports=Q$:m0.exports=r0;function Q$($,N){if($>e0)throw new RangeError("requested too many random bytes");var Y$=i0.allocUnsafe($);if($>0)if($>a0)for(var O0=0;O0<$;O0+=a0)$$.getRandomValues(Y$.slice(O0,O0+a0));else $$.getRandomValues(Y$);return typeof N=="function"?process.nextTick(function(){N(null,Y$)}):Y$}}}),dQ=pQ({"node_modules/inherits/inherits_browser.js"(t0,m0){typeof Object.create=="function"?m0.exports=function(a0,e0){e0&&(a0.super_=e0,a0.prototype=Object.create(e0.prototype,{constructor:{value:a0,enumerable:!1,writable:!0,configurable:!0}}))}:m0.exports=function(a0,e0){if(e0){a0.super_=e0;var r0=function(){};r0.prototype=e0.prototype,a0.prototype=new r0,a0.prototype.constructor=a0}}}}),F=pQ({"node_modules/hash-base/index.js"(t0,m0){var a0=cQ().Buffer,e0=dQ();function r0($$,Q$){if(!a0.isBuffer($$)&&typeof $$!="string")throw new TypeError(Q$+" must be a string or a buffer")}function i0($$){R0.Transform.call(this),this._block=a0.allocUnsafe($$),this._blockSize=$$,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e0(i0,R0.Transform),i0.prototype._transform=function($$,Q$,$){var N=null;try{this.update($$,Q$)}catch(Y$){N=Y$}$(N)},i0.prototype._flush=function($$){var Q$=null;try{this.push(this.digest())}catch($){Q$=$}$$(Q$)},i0.prototype.update=function($$,Q$){if(r0($$,"Data"),this._finalized)throw new Error("Digest already called");a0.isBuffer($$)||($$=a0.from($$,Q$));for(var $=this._block,N=0;this._blockOffset+$$.length-N>=this._blockSize;){for(var Y$=this._blockOffset;Y$0;++O0)this._length[O0]+=Z$,Z$=this._length[O0]/4294967296|0,Z$>0&&(this._length[O0]-=4294967296*Z$);return this},i0.prototype._update=function(){throw new Error("_update is not implemented")},i0.prototype.digest=function($$){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var Q$=this._digest();$$!==void 0&&(Q$=Q$.toString($$)),this._block.fill(0),this._blockOffset=0;for(var $=0;$<4;++$)this._length[$]=0;return Q$},i0.prototype._digest=function(){throw new Error("_digest is not implemented")},m0.exports=i0}}),_=pQ({"node_modules/md5.js/index.js"(t0,m0){var a0=dQ(),e0=F(),r0=cQ().Buffer,i0=new Array(16);function $$(){e0.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}a0($$,e0),$$.prototype._update=function(){for(var Z$=i0,G$=0;G$<16;++G$)Z$[G$]=this._block.readInt32LE(G$*4);var V$=this._a,U$=this._b,X$=this._c,K$=this._d;V$=$(V$,U$,X$,K$,Z$[0],3614090360,7),K$=$(K$,V$,U$,X$,Z$[1],3905402710,12),X$=$(X$,K$,V$,U$,Z$[2],606105819,17),U$=$(U$,X$,K$,V$,Z$[3],3250441966,22),V$=$(V$,U$,X$,K$,Z$[4],4118548399,7),K$=$(K$,V$,U$,X$,Z$[5],1200080426,12),X$=$(X$,K$,V$,U$,Z$[6],2821735955,17),U$=$(U$,X$,K$,V$,Z$[7],4249261313,22),V$=$(V$,U$,X$,K$,Z$[8],1770035416,7),K$=$(K$,V$,U$,X$,Z$[9],2336552879,12),X$=$(X$,K$,V$,U$,Z$[10],4294925233,17),U$=$(U$,X$,K$,V$,Z$[11],2304563134,22),V$=$(V$,U$,X$,K$,Z$[12],1804603682,7),K$=$(K$,V$,U$,X$,Z$[13],4254626195,12),X$=$(X$,K$,V$,U$,Z$[14],2792965006,17),U$=$(U$,X$,K$,V$,Z$[15],1236535329,22),V$=N(V$,U$,X$,K$,Z$[1],4129170786,5),K$=N(K$,V$,U$,X$,Z$[6],3225465664,9),X$=N(X$,K$,V$,U$,Z$[11],643717713,14),U$=N(U$,X$,K$,V$,Z$[0],3921069994,20),V$=N(V$,U$,X$,K$,Z$[5],3593408605,5),K$=N(K$,V$,U$,X$,Z$[10],38016083,9),X$=N(X$,K$,V$,U$,Z$[15],3634488961,14),U$=N(U$,X$,K$,V$,Z$[4],3889429448,20),V$=N(V$,U$,X$,K$,Z$[9],568446438,5),K$=N(K$,V$,U$,X$,Z$[14],3275163606,9),X$=N(X$,K$,V$,U$,Z$[3],4107603335,14),U$=N(U$,X$,K$,V$,Z$[8],1163531501,20),V$=N(V$,U$,X$,K$,Z$[13],2850285829,5),K$=N(K$,V$,U$,X$,Z$[2],4243563512,9),X$=N(X$,K$,V$,U$,Z$[7],1735328473,14),U$=N(U$,X$,K$,V$,Z$[12],2368359562,20),V$=Y$(V$,U$,X$,K$,Z$[5],4294588738,4),K$=Y$(K$,V$,U$,X$,Z$[8],2272392833,11),X$=Y$(X$,K$,V$,U$,Z$[11],1839030562,16),U$=Y$(U$,X$,K$,V$,Z$[14],4259657740,23),V$=Y$(V$,U$,X$,K$,Z$[1],2763975236,4),K$=Y$(K$,V$,U$,X$,Z$[4],1272893353,11),X$=Y$(X$,K$,V$,U$,Z$[7],4139469664,16),U$=Y$(U$,X$,K$,V$,Z$[10],3200236656,23),V$=Y$(V$,U$,X$,K$,Z$[13],681279174,4),K$=Y$(K$,V$,U$,X$,Z$[0],3936430074,11),X$=Y$(X$,K$,V$,U$,Z$[3],3572445317,16),U$=Y$(U$,X$,K$,V$,Z$[6],76029189,23),V$=Y$(V$,U$,X$,K$,Z$[9],3654602809,4),K$=Y$(K$,V$,U$,X$,Z$[12],3873151461,11),X$=Y$(X$,K$,V$,U$,Z$[15],530742520,16),U$=Y$(U$,X$,K$,V$,Z$[2],3299628645,23),V$=O0(V$,U$,X$,K$,Z$[0],4096336452,6),K$=O0(K$,V$,U$,X$,Z$[7],1126891415,10),X$=O0(X$,K$,V$,U$,Z$[14],2878612391,15),U$=O0(U$,X$,K$,V$,Z$[5],4237533241,21),V$=O0(V$,U$,X$,K$,Z$[12],1700485571,6),K$=O0(K$,V$,U$,X$,Z$[3],2399980690,10),X$=O0(X$,K$,V$,U$,Z$[10],4293915773,15),U$=O0(U$,X$,K$,V$,Z$[1],2240044497,21),V$=O0(V$,U$,X$,K$,Z$[8],1873313359,6),K$=O0(K$,V$,U$,X$,Z$[15],4264355552,10),X$=O0(X$,K$,V$,U$,Z$[6],2734768916,15),U$=O0(U$,X$,K$,V$,Z$[13],1309151649,21),V$=O0(V$,U$,X$,K$,Z$[4],4149444226,6),K$=O0(K$,V$,U$,X$,Z$[11],3174756917,10),X$=O0(X$,K$,V$,U$,Z$[2],718787259,15),U$=O0(U$,X$,K$,V$,Z$[9],3951481745,21),this._a=this._a+V$|0,this._b=this._b+U$|0,this._c=this._c+X$|0,this._d=this._d+K$|0},$$.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 Z$=r0.allocUnsafe(16);return Z$.writeInt32LE(this._a,0),Z$.writeInt32LE(this._b,4),Z$.writeInt32LE(this._c,8),Z$.writeInt32LE(this._d,12),Z$};function Q$(Z$,G$){return Z$<>>32-G$}function $(Z$,G$,V$,U$,X$,K$,I$){return Q$(Z$+(G$&V$|~G$&U$)+X$+K$|0,I$)+G$|0}function N(Z$,G$,V$,U$,X$,K$,I$){return Q$(Z$+(G$&U$|V$&~U$)+X$+K$|0,I$)+G$|0}function Y$(Z$,G$,V$,U$,X$,K$,I$){return Q$(Z$+(G$^V$^U$)+X$+K$|0,I$)+G$|0}function O0(Z$,G$,V$,U$,X$,K$,I$){return Q$(Z$+(V$^(G$|~U$))+X$+K$|0,I$)+G$|0}m0.exports=$$}}),V0=pQ({"node_modules/ripemd160/index.js"(t0,m0){var a0=G0,e0=dQ(),r0=F(),i0=new Array(16),$$=[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],Q$=[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],$=[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],N=[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],Y$=[0,1518500249,1859775393,2400959708,2840853838],O0=[1352829926,1548603684,1836072691,2053994217,0];function Z$(){r0.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}e0(Z$,r0),Z$.prototype._update=function(){for(var Q=i0,x=0;x<16;++x)Q[x]=this._block.readInt32LE(x*4);for(var O$=this._a|0,J0=this._b|0,J$=this._c|0,F$=this._d|0,A$=this._e|0,H$=this._a|0,W$=this._b|0,E$=this._c|0,T$=this._d|0,Y=this._e|0,f=0;f<80;f+=1){var D$,F0;f<16?(D$=V$(O$,J0,J$,F$,A$,Q[$$[f]],Y$[0],$[f]),F0=I$(H$,W$,E$,T$,Y,Q[Q$[f]],O0[0],N[f])):f<32?(D$=U$(O$,J0,J$,F$,A$,Q[$$[f]],Y$[1],$[f]),F0=K$(H$,W$,E$,T$,Y,Q[Q$[f]],O0[1],N[f])):f<48?(D$=X$(O$,J0,J$,F$,A$,Q[$$[f]],Y$[2],$[f]),F0=X$(H$,W$,E$,T$,Y,Q[Q$[f]],O0[2],N[f])):f<64?(D$=K$(O$,J0,J$,F$,A$,Q[$$[f]],Y$[3],$[f]),F0=U$(H$,W$,E$,T$,Y,Q[Q$[f]],O0[3],N[f])):(D$=I$(O$,J0,J$,F$,A$,Q[$$[f]],Y$[4],$[f]),F0=V$(H$,W$,E$,T$,Y,Q[Q$[f]],O0[4],N[f])),O$=A$,A$=F$,F$=G$(J$,10),J$=J0,J0=D$,H$=Y,Y=T$,T$=G$(E$,10),E$=W$,W$=F0}var C$=this._b+J$+T$|0;this._b=this._c+F$+Y|0,this._c=this._d+A$+H$|0,this._d=this._e+O$+W$|0,this._e=this._a+J0+E$|0,this._a=C$},Z$.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 Q=a0.alloc?a0.alloc(20):new a0(20);return Q.writeInt32LE(this._a,0),Q.writeInt32LE(this._b,4),Q.writeInt32LE(this._c,8),Q.writeInt32LE(this._d,12),Q.writeInt32LE(this._e,16),Q};function G$(Q,x){return Q<>>32-x}function V$(Q,x,O$,J0,J$,F$,A$,H$){return G$(Q+(x^O$^J0)+F$+A$|0,H$)+J$|0}function U$(Q,x,O$,J0,J$,F$,A$,H$){return G$(Q+(x&O$|~x&J0)+F$+A$|0,H$)+J$|0}function X$(Q,x,O$,J0,J$,F$,A$,H$){return G$(Q+((x|~O$)^J0)+F$+A$|0,H$)+J$|0}function K$(Q,x,O$,J0,J$,F$,A$,H$){return G$(Q+(x&J0|O$&~J0)+F$+A$|0,H$)+J$|0}function I$(Q,x,O$,J0,J$,F$,A$,H$){return G$(Q+(x^(O$|~J0))+F$+A$|0,H$)+J$|0}m0.exports=Z$}}),z0=pQ({"node_modules/sha.js/hash.js"(t0,m0){var a0=cQ().Buffer;function e0(r0,i0){this._block=a0.alloc(r0),this._finalSize=i0,this._blockSize=r0,this._len=0}e0.prototype.update=function(r0,i0){typeof r0=="string"&&(i0=i0||"utf8",r0=a0.from(r0,i0));for(var $$=this._block,Q$=this._blockSize,$=r0.length,N=this._len,Y$=0;Y$<$;){for(var O0=N%Q$,Z$=Math.min($-Y$,Q$-O0),G$=0;G$=this._finalSize&&(this._update(this._block),this._block.fill(0));var $$=this._len*8;if($$<=4294967295)this._block.writeUInt32BE($$,this._blockSize-4);else{var Q$=($$&4294967295)>>>0,$=($$-Q$)/4294967296;this._block.writeUInt32BE($,this._blockSize-8),this._block.writeUInt32BE(Q$,this._blockSize-4)}this._update(this._block);var N=this._hash();return r0?N.toString(r0):N},e0.prototype._update=function(){throw new Error("_update must be implemented by subclass")},m0.exports=e0}}),bQ=pQ({"node_modules/sha.js/sha.js"(t0,m0){var a0=dQ(),e0=z0(),r0=cQ().Buffer,i0=[1518500249,1859775393,-1894007588,-899497514],$$=new Array(80);function Q$(){this.init(),this._w=$$,e0.call(this,64,56)}a0(Q$,e0),Q$.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function $(O0){return O0<<5|O0>>>27}function N(O0){return O0<<30|O0>>>2}function Y$(O0,Z$,G$,V$){return O0===0?Z$&G$|~Z$&V$:O0===2?Z$&G$|Z$&V$|G$&V$:Z$^G$^V$}Q$.prototype._update=function(O0){for(var Z$=this._w,G$=this._a|0,V$=this._b|0,U$=this._c|0,X$=this._d|0,K$=this._e|0,I$=0;I$<16;++I$)Z$[I$]=O0.readInt32BE(I$*4);for(;I$<80;++I$)Z$[I$]=Z$[I$-3]^Z$[I$-8]^Z$[I$-14]^Z$[I$-16];for(var Q=0;Q<80;++Q){var x=~~(Q/20),O$=$(G$)+Y$(x,V$,U$,X$)+K$+Z$[Q]+i0[x]|0;K$=X$,X$=U$,U$=N(V$),V$=G$,G$=O$}this._a=G$+this._a|0,this._b=V$+this._b|0,this._c=U$+this._c|0,this._d=X$+this._d|0,this._e=K$+this._e|0},Q$.prototype._hash=function(){var O0=r0.allocUnsafe(20);return O0.writeInt32BE(this._a|0,0),O0.writeInt32BE(this._b|0,4),O0.writeInt32BE(this._c|0,8),O0.writeInt32BE(this._d|0,12),O0.writeInt32BE(this._e|0,16),O0},m0.exports=Q$}}),lQ=pQ({"node_modules/sha.js/sha1.js"(t0,m0){var a0=dQ(),e0=z0(),r0=cQ().Buffer,i0=[1518500249,1859775393,-1894007588,-899497514],$$=new Array(80);function Q$(){this.init(),this._w=$$,e0.call(this,64,56)}a0(Q$,e0),Q$.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function $(Z$){return Z$<<1|Z$>>>31}function N(Z$){return Z$<<5|Z$>>>27}function Y$(Z$){return Z$<<30|Z$>>>2}function O0(Z$,G$,V$,U$){return Z$===0?G$&V$|~G$&U$:Z$===2?G$&V$|G$&U$|V$&U$:G$^V$^U$}Q$.prototype._update=function(Z$){for(var G$=this._w,V$=this._a|0,U$=this._b|0,X$=this._c|0,K$=this._d|0,I$=this._e|0,Q=0;Q<16;++Q)G$[Q]=Z$.readInt32BE(Q*4);for(;Q<80;++Q)G$[Q]=$(G$[Q-3]^G$[Q-8]^G$[Q-14]^G$[Q-16]);for(var x=0;x<80;++x){var O$=~~(x/20),J0=N(V$)+O0(O$,U$,X$,K$)+I$+G$[x]+i0[O$]|0;I$=K$,K$=X$,X$=Y$(U$),U$=V$,V$=J0}this._a=V$+this._a|0,this._b=U$+this._b|0,this._c=X$+this._c|0,this._d=K$+this._d|0,this._e=I$+this._e|0},Q$.prototype._hash=function(){var Z$=r0.allocUnsafe(20);return Z$.writeInt32BE(this._a|0,0),Z$.writeInt32BE(this._b|0,4),Z$.writeInt32BE(this._c|0,8),Z$.writeInt32BE(this._d|0,12),Z$.writeInt32BE(this._e|0,16),Z$},m0.exports=Q$}}),oQ=pQ({"node_modules/sha.js/sha256.js"(t0,m0){var a0=dQ(),e0=z0(),r0=cQ().Buffer,i0=[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],$$=new Array(64);function Q$(){this.init(),this._w=$$,e0.call(this,64,56)}a0(Q$,e0),Q$.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 $(V$,U$,X$){return X$^V$&(U$^X$)}function N(V$,U$,X$){return V$&U$|X$&(V$|U$)}function Y$(V$){return(V$>>>2|V$<<30)^(V$>>>13|V$<<19)^(V$>>>22|V$<<10)}function O0(V$){return(V$>>>6|V$<<26)^(V$>>>11|V$<<21)^(V$>>>25|V$<<7)}function Z$(V$){return(V$>>>7|V$<<25)^(V$>>>18|V$<<14)^V$>>>3}function G$(V$){return(V$>>>17|V$<<15)^(V$>>>19|V$<<13)^V$>>>10}Q$.prototype._update=function(V$){for(var U$=this._w,X$=this._a|0,K$=this._b|0,I$=this._c|0,Q=this._d|0,x=this._e|0,O$=this._f|0,J0=this._g|0,J$=this._h|0,F$=0;F$<16;++F$)U$[F$]=V$.readInt32BE(F$*4);for(;F$<64;++F$)U$[F$]=G$(U$[F$-2])+U$[F$-7]+Z$(U$[F$-15])+U$[F$-16]|0;for(var A$=0;A$<64;++A$){var H$=J$+O0(x)+$(x,O$,J0)+i0[A$]+U$[A$]|0,W$=Y$(X$)+N(X$,K$,I$)|0;J$=J0,J0=O$,O$=x,x=Q+H$|0,Q=I$,I$=K$,K$=X$,X$=H$+W$|0}this._a=X$+this._a|0,this._b=K$+this._b|0,this._c=I$+this._c|0,this._d=Q+this._d|0,this._e=x+this._e|0,this._f=O$+this._f|0,this._g=J0+this._g|0,this._h=J$+this._h|0},Q$.prototype._hash=function(){var V$=r0.allocUnsafe(32);return V$.writeInt32BE(this._a,0),V$.writeInt32BE(this._b,4),V$.writeInt32BE(this._c,8),V$.writeInt32BE(this._d,12),V$.writeInt32BE(this._e,16),V$.writeInt32BE(this._f,20),V$.writeInt32BE(this._g,24),V$.writeInt32BE(this._h,28),V$},m0.exports=Q$}}),uQ=pQ({"node_modules/sha.js/sha224.js"(t0,m0){var a0=dQ(),e0=oQ(),r0=z0(),i0=cQ().Buffer,$$=new Array(64);function Q$(){this.init(),this._w=$$,r0.call(this,64,56)}a0(Q$,e0),Q$.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},Q$.prototype._hash=function(){var $=i0.allocUnsafe(28);return $.writeInt32BE(this._a,0),$.writeInt32BE(this._b,4),$.writeInt32BE(this._c,8),$.writeInt32BE(this._d,12),$.writeInt32BE(this._e,16),$.writeInt32BE(this._f,20),$.writeInt32BE(this._g,24),$},m0.exports=Q$}}),nQ=pQ({"node_modules/sha.js/sha512.js"(t0,m0){var a0=dQ(),e0=z0(),r0=cQ().Buffer,i0=[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],$$=new Array(160);function Q$(){this.init(),this._w=$$,e0.call(this,128,112)}a0(Q$,e0),Q$.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$,I$,Q){return Q^K$&(I$^Q)}function N(K$,I$,Q){return K$&I$|Q&(K$|I$)}function Y$(K$,I$){return(K$>>>28|I$<<4)^(I$>>>2|K$<<30)^(I$>>>7|K$<<25)}function O0(K$,I$){return(K$>>>14|I$<<18)^(K$>>>18|I$<<14)^(I$>>>9|K$<<23)}function Z$(K$,I$){return(K$>>>1|I$<<31)^(K$>>>8|I$<<24)^K$>>>7}function G$(K$,I$){return(K$>>>1|I$<<31)^(K$>>>8|I$<<24)^(K$>>>7|I$<<25)}function V$(K$,I$){return(K$>>>19|I$<<13)^(I$>>>29|K$<<3)^K$>>>6}function U$(K$,I$){return(K$>>>19|I$<<13)^(I$>>>29|K$<<3)^(K$>>>6|I$<<26)}function X$(K$,I$){return K$>>>0>>0?1:0}Q$.prototype._update=function(K$){for(var I$=this._w,Q=this._ah|0,x=this._bh|0,O$=this._ch|0,J0=this._dh|0,J$=this._eh|0,F$=this._fh|0,A$=this._gh|0,H$=this._hh|0,W$=this._al|0,E$=this._bl|0,T$=this._cl|0,Y=this._dl|0,f=this._el|0,D$=this._fl|0,F0=this._gl|0,C$=this._hl|0,L$=0;L$<32;L$+=2)I$[L$]=K$.readInt32BE(L$*4),I$[L$+1]=K$.readInt32BE(L$*4+4);for(;L$<160;L$+=2){var R$=I$[L$-30],P$=I$[L$-30+1],z$=Z$(R$,P$),M$=G$(P$,R$);R$=I$[L$-4],P$=I$[L$-4+1];var S$=V$(R$,P$),Z=U$(P$,R$),c=I$[L$-14],v$=I$[L$-14+1],A0=I$[L$-32],q$=I$[L$-32+1],j$=M$+v$|0,k$=z$+c+X$(j$,M$)|0;j$=j$+Z|0,k$=k$+S$+X$(j$,Z)|0,j$=j$+q$|0,k$=k$+A0+X$(j$,q$)|0,I$[L$]=k$,I$[L$+1]=j$}for(var g$=0;g$<160;g$+=2){k$=I$[g$],j$=I$[g$+1];var _$=N(Q,x,O$),N$=N(W$,E$,T$),x$=Y$(Q,W$),G=Y$(W$,Q),B=O0(J$,f),B$=O0(f,J$),H0=i0[g$],y$=i0[g$+1],w$=$(J$,F$,A$),p$=$(f,D$,F0),f$=C$+B$|0,c$=H$+B+X$(f$,C$)|0;f$=f$+p$|0,c$=c$+w$+X$(f$,p$)|0,f$=f$+y$|0,c$=c$+H0+X$(f$,y$)|0,f$=f$+j$|0,c$=c$+k$+X$(f$,j$)|0;var h$=G+N$|0,d$=x$+_$+X$(h$,G)|0;H$=A$,C$=F0,A$=F$,F0=D$,F$=J$,D$=f,f=Y+f$|0,J$=J0+c$+X$(f,Y)|0,J0=O$,Y=T$,O$=x,T$=E$,x=Q,E$=W$,W$=f$+h$|0,Q=c$+d$+X$(W$,f$)|0}this._al=this._al+W$|0,this._bl=this._bl+E$|0,this._cl=this._cl+T$|0,this._dl=this._dl+Y|0,this._el=this._el+f|0,this._fl=this._fl+D$|0,this._gl=this._gl+F0|0,this._hl=this._hl+C$|0,this._ah=this._ah+Q+X$(this._al,W$)|0,this._bh=this._bh+x+X$(this._bl,E$)|0,this._ch=this._ch+O$+X$(this._cl,T$)|0,this._dh=this._dh+J0+X$(this._dl,Y)|0,this._eh=this._eh+J$+X$(this._el,f)|0,this._fh=this._fh+F$+X$(this._fl,D$)|0,this._gh=this._gh+A$+X$(this._gl,F0)|0,this._hh=this._hh+H$+X$(this._hl,C$)|0},Q$.prototype._hash=function(){var K$=r0.allocUnsafe(64);function I$(Q,x,O$){K$.writeInt32BE(Q,O$),K$.writeInt32BE(x,O$+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),I$(this._gh,this._gl,48),I$(this._hh,this._hl,56),K$},m0.exports=Q$}}),sQ=pQ({"node_modules/sha.js/sha384.js"(t0,m0){var a0=dQ(),e0=nQ(),r0=z0(),i0=cQ().Buffer,$$=new Array(160);function Q$(){this.init(),this._w=$$,r0.call(this,128,112)}a0(Q$,e0),Q$.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},Q$.prototype._hash=function(){var $=i0.allocUnsafe(48);function N(Y$,O0,Z$){$.writeInt32BE(Y$,Z$),$.writeInt32BE(O0,Z$+4)}return N(this._ah,this._al,0),N(this._bh,this._bl,8),N(this._ch,this._cl,16),N(this._dh,this._dl,24),N(this._eh,this._el,32),N(this._fh,this._fl,40),$},m0.exports=Q$}}),tQ=pQ({"node_modules/sha.js/index.js"(a0,m0){var a0=m0.exports=function(e0){e0=e0.toLowerCase();var r0=a0[e0];if(!r0)throw new Error(e0+" is not supported (we accept pull requests)");return new r0};a0.sha=bQ(),a0.sha1=lQ(),a0.sha224=uQ(),a0.sha256=oQ(),a0.sha384=sQ(),a0.sha512=nQ()}}),A=pQ({"node_modules/cipher-base/index.js"(t0,m0){var a0=cQ().Buffer,e0=dQ();function r0(i0){R0.Transform.call(this),this.hashMode=typeof i0=="string",this.hashMode?this[i0]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e0(r0,R0.Transform),r0.prototype.update=function(i0,$$,Q$){typeof i0=="string"&&(i0=a0.from(i0,$$));var $=this._update(i0);return this.hashMode?this:(Q$&&($=this._toString($,Q$)),$)},r0.prototype.setAutoPadding=function(){},r0.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},r0.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},r0.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},r0.prototype._transform=function(i0,$$,Q$){var $;try{this.hashMode?this._update(i0):this.push(this._update(i0))}catch(N){$=N}finally{Q$($)}},r0.prototype._flush=function(i0){var $$;try{this.push(this.__final())}catch(Q$){$$=Q$}i0($$)},r0.prototype._finalOrDigest=function(i0){var $$=this.__final()||a0.alloc(0);return i0&&($$=this._toString($$,i0,!0)),$$},r0.prototype._toString=function(i0,$$,Q$){if(this._decoder||(this._decoder=new BQ($$),this._encoding=$$),this._encoding!==$$)throw new Error("can't switch encodings");var $=this._decoder.write(i0);return Q$&&($+=this._decoder.end()),$},m0.exports=r0}}),w=pQ({"node_modules/create-hash/browser.js"(t0,m0){const a0=function i0($$,Q$){this._options=Q$,this._hasher=new AZ($$,Q$),this._finalized=!1};a0.prototype=Object.create(R0.Transform.prototype),a0.prototype.update=function i0($$,Q$){return this._checkFinalized(),this._hasher.update($$,Q$),this},a0.prototype.digest=function i0($$,Q$){return this._checkFinalized(),this._finalized=!0,this._hasher.digest($$,Q$)},a0.prototype._checkFinalized=function i0(){if(this._finalized){var $$=new Error("Digest already called");throw $$.code="ERR_CRYPTO_HASH_FINALIZED",$$}},a0.prototype.copy=function i0(){const $$=Object.create(a0.prototype);return $$._options=this._options,$$._hasher=this._hasher.copy(),$$._finalized=this._finalized,$$};const e0={__proto__:R0.Transform.prototype,...a0.prototype,_transform(i0,$$,Q$){this.update(i0,$$),Q$&&Q$()},_flush(i0){this.push(this.digest()),i0()}},r0=["_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 i0 of r0)Object.defineProperty(a0.prototype,i0,{get(){return Object.setPrototypeOf(this,e0),R0.Transform.call(this,this._options),this[i0]},enumerable:!1,configurable:!0});m0.exports=function i0($$){return new a0($$)},m0.exports.createHash=m0.exports,m0.exports.Hash=a0}}),mQ=pQ({"node_modules/create-hmac/legacy.js"(t0,m0){var a0=dQ(),e0=cQ().Buffer,r0=A(),i0=e0.alloc(128),$$=64;function Q$($,N){r0.call(this,"digest"),typeof N=="string"&&(N=e0.from(N)),this._alg=$,this._key=N,N.length>$$?N=$(N):N.length<$$&&(N=e0.concat([N,i0],$$));for(var Y$=this._ipad=e0.allocUnsafe($$),O0=this._opad=e0.allocUnsafe($$),Z$=0;Z$<$$;Z$++)Y$[Z$]=N[Z$]^54,O0[Z$]=N[Z$]^92;this._hash=[Y$]}a0(Q$,r0),Q$.prototype._update=function($){this._hash.push($)},Q$.prototype._final=function(){var $=this._alg(e0.concat(this._hash));return this._alg(e0.concat([this._opad,$]))},m0.exports=Q$}}),M0=pQ({"node_modules/create-hash/md5.js"(t0,m0){var a0=_();m0.exports=function(e0){return new a0().update(e0).digest()}}}),aQ=pQ({"node_modules/create-hmac/browser.js"(t0,m0){var a0=dQ(),e0=mQ(),r0=A(),i0=cQ().Buffer,$$=M0(),Q$=V0(),$=tQ(),N=i0.alloc(128);function Y$(O0,Z$){r0.call(this,"digest"),typeof Z$=="string"&&(Z$=i0.from(Z$));var G$=O0==="sha512"||O0==="sha384"?128:64;if(this._alg=O0,this._key=Z$,Z$.length>G$){var V$=O0==="rmd160"?new Q$:$(O0);Z$=V$.update(Z$).digest()}else Z$.lengtha0||r0!==r0)throw new TypeError("Bad key length")}}}),$Y=pQ({"node_modules/pbkdf2/lib/default-encoding.js"(t0,m0){var a0;global.process&&global.process.browser?a0="utf-8":global.process&&global.process.version?(e0=parseInt(process.version.split(".")[0].slice(1),10),a0=e0>=6?"utf-8":"binary"):a0="utf-8";var e0;m0.exports=a0}}),QY=pQ({"node_modules/pbkdf2/lib/to-buffer.js"(t0,m0){var a0=cQ().Buffer;m0.exports=function(e0,r0,i0){if(a0.isBuffer(e0))return e0;if(typeof e0=="string")return a0.from(e0,r0);if(ArrayBuffer.isView(e0))return a0.from(e0.buffer);throw new TypeError(i0+" must be a string, a Buffer, a typed array or a DataView")}}}),YY=pQ({"node_modules/pbkdf2/lib/sync-browser.js"(t0,m0){var a0=M0(),e0=V0(),r0=tQ(),i0=cQ().Buffer,$$=iQ(),Q$=$Y(),$=QY(),N=i0.alloc(128),Y$={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function O0(V$,U$,X$){var K$=Z$(V$),I$=V$==="sha512"||V$==="sha384"?128:64;U$.length>I$?U$=K$(U$):U$.length>>0},t0.writeUInt32BE=function(r0,i0,$$){r0[0+$$]=i0>>>24,r0[1+$$]=i0>>>16&255,r0[2+$$]=i0>>>8&255,r0[3+$$]=i0&255},t0.ip=function(r0,i0,$$,Q$){for(var $=0,N=0,Y$=6;Y$>=0;Y$-=2){for(var O0=0;O0<=24;O0+=8)$<<=1,$|=i0>>>O0+Y$&1;for(var O0=0;O0<=24;O0+=8)$<<=1,$|=r0>>>O0+Y$&1}for(var Y$=6;Y$>=0;Y$-=2){for(var O0=1;O0<=25;O0+=8)N<<=1,N|=i0>>>O0+Y$&1;for(var O0=1;O0<=25;O0+=8)N<<=1,N|=r0>>>O0+Y$&1}$$[Q$+0]=$>>>0,$$[Q$+1]=N>>>0},t0.rip=function(r0,i0,$$,Q$){for(var $=0,N=0,Y$=0;Y$<4;Y$++)for(var O0=24;O0>=0;O0-=8)$<<=1,$|=i0>>>O0+Y$&1,$<<=1,$|=r0>>>O0+Y$&1;for(var Y$=4;Y$<8;Y$++)for(var O0=24;O0>=0;O0-=8)N<<=1,N|=i0>>>O0+Y$&1,N<<=1,N|=r0>>>O0+Y$&1;$$[Q$+0]=$>>>0,$$[Q$+1]=N>>>0},t0.pc1=function(r0,i0,$$,Q$){for(var $=0,N=0,Y$=7;Y$>=5;Y$--){for(var O0=0;O0<=24;O0+=8)$<<=1,$|=i0>>O0+Y$&1;for(var O0=0;O0<=24;O0+=8)$<<=1,$|=r0>>O0+Y$&1}for(var O0=0;O0<=24;O0+=8)$<<=1,$|=i0>>O0+Y$&1;for(var Y$=1;Y$<=3;Y$++){for(var O0=0;O0<=24;O0+=8)N<<=1,N|=i0>>O0+Y$&1;for(var O0=0;O0<=24;O0+=8)N<<=1,N|=r0>>O0+Y$&1}for(var O0=0;O0<=24;O0+=8)N<<=1,N|=r0>>O0+Y$&1;$$[Q$+0]=$>>>0,$$[Q$+1]=N>>>0},t0.r28shl=function(r0,i0){return r0<>>28-i0};var m0=[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];t0.pc2=function(r0,i0,$$,Q$){for(var $=0,N=0,Y$=m0.length>>>1,O0=0;O0>>m0[O0]&1;for(var O0=Y$;O0>>m0[O0]&1;$$[Q$+0]=$>>>0,$$[Q$+1]=N>>>0},t0.expand=function(r0,i0,$$){var Q$=0,$=0;Q$=(r0&1)<<5|r0>>>27;for(var N=23;N>=15;N-=4)Q$<<=6,Q$|=r0>>>N&63;for(var N=11;N>=3;N-=4)$|=r0>>>N&63,$<<=6;$|=(r0&31)<<1|r0>>>31,i0[$$+0]=Q$>>>0,i0[$$+1]=$>>>0};var a0=[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];t0.substitute=function(r0,i0){for(var $$=0,Q$=0;Q$<4;Q$++){var $=r0>>>18-Q$*6&63,N=a0[Q$*64+$];$$<<=4,$$|=N}for(var Q$=0;Q$<4;Q$++){var $=i0>>>18-Q$*6&63,N=a0[256+Q$*64+$];$$<<=4,$$|=N}return $$>>>0};var e0=[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];t0.permute=function(r0){for(var i0=0,$$=0;$$>>e0[$$]&1;return i0>>>0},t0.padSplit=function(r0,i0,$$){for(var Q$=r0.toString(2);Q$.length0;Q$--)i0+=this._buffer(r0,i0),$$+=this._flushBuffer($,$$);return i0+=this._buffer(r0,i0),$},e0.prototype.final=function(r0){var i0;r0&&(i0=this.update(r0));var $$;return this.type==="encrypt"?$$=this._finalEncrypt():$$=this._finalDecrypt(),i0?i0.concat($$):$$},e0.prototype._pad=function(r0,i0){if(i0===0)return!1;for(;i0>>1];O0=r0.r28shl(O0,V$),Z$=r0.r28shl(Z$,V$),r0.pc2(O0,Z$,N.keys,G$)}},Q$.prototype._update=function(N,Y$,O0,Z$){var G$=this._desState,V$=r0.readUInt32BE(N,Y$),U$=r0.readUInt32BE(N,Y$+4);r0.ip(V$,U$,G$.tmp,0),V$=G$.tmp[0],U$=G$.tmp[1],this.type==="encrypt"?this._encrypt(G$,V$,U$,G$.tmp,0):this._decrypt(G$,V$,U$,G$.tmp,0),V$=G$.tmp[0],U$=G$.tmp[1],r0.writeUInt32BE(O0,V$,Z$),r0.writeUInt32BE(O0,U$,Z$+4)},Q$.prototype._pad=function(N,Y$){for(var O0=N.length-Y$,Z$=Y$;Z$>>0,V$=O$}r0.rip(U$,V$,Z$,G$)},Q$.prototype._decrypt=function(N,Y$,O0,Z$,G$){for(var V$=O0,U$=Y$,X$=N.keys.length-2;X$>=0;X$-=2){var K$=N.keys[X$],I$=N.keys[X$+1];r0.expand(V$,N.tmp,0),K$^=N.tmp[0],I$^=N.tmp[1];var Q=r0.substitute(K$,I$),x=r0.permute(Q),O$=V$;V$=(U$^x)>>>0,U$=O$}r0.rip(V$,U$,Z$,G$)}}}),VY=pQ({"node_modules/des.js/lib/des/cbc.js"(t0){var m0=v0(),a0=dQ(),e0={};function r0($$){m0.equal($$.length,8,"Invalid IV length"),this.iv=new Array(8);for(var Q$=0;Q$>$%8,r0._prev=e0(r0._prev,$$?O0:Z$);return Y$}function e0(r0,i0){var $$=r0.length,Q$=-1,$=m0.allocUnsafe(r0.length);for(r0=m0.concat([r0,m0.from([i0])]);++Q$<$$;)$[Q$]=r0[Q$]<<1|r0[Q$+1]>>7;return $}t0.encrypt=function(r0,i0,$$){for(var Q$=i0.length,$=m0.allocUnsafe(Q$),N=-1;++N>>24]^U$[Q>>>16&255]^X$[x>>>8&255]^K$[O$&255]^Y$[H$++],J$=V$[Q>>>24]^U$[x>>>16&255]^X$[O$>>>8&255]^K$[I$&255]^Y$[H$++],F$=V$[x>>>24]^U$[O$>>>16&255]^X$[I$>>>8&255]^K$[Q&255]^Y$[H$++],A$=V$[O$>>>24]^U$[I$>>>16&255]^X$[Q>>>8&255]^K$[x&255]^Y$[H$++],I$=J0,Q=J$,x=F$,O$=A$;return J0=(Z$[I$>>>24]<<24|Z$[Q>>>16&255]<<16|Z$[x>>>8&255]<<8|Z$[O$&255])^Y$[H$++],J$=(Z$[Q>>>24]<<24|Z$[x>>>16&255]<<16|Z$[O$>>>8&255]<<8|Z$[I$&255])^Y$[H$++],F$=(Z$[x>>>24]<<24|Z$[O$>>>16&255]<<16|Z$[I$>>>8&255]<<8|Z$[Q&255])^Y$[H$++],A$=(Z$[O$>>>24]<<24|Z$[I$>>>16&255]<<16|Z$[Q>>>8&255]<<8|Z$[x&255])^Y$[H$++],J0=J0>>>0,J$=J$>>>0,F$=F$>>>0,A$=A$>>>0,[J0,J$,F$,A$]}var $$=[0,1,2,4,8,16,32,64,128,27,54],Q$=function(){for(var N=new Array(256),Y$=0;Y$<256;Y$++)Y$<128?N[Y$]=Y$<<1:N[Y$]=Y$<<1^283;for(var O0=[],Z$=[],G$=[[],[],[],[]],V$=[[],[],[],[]],U$=0,X$=0,K$=0;K$<256;++K$){var I$=X$^X$<<1^X$<<2^X$<<3^X$<<4;I$=I$>>>8^I$&255^99,O0[U$]=I$,Z$[I$]=U$;var Q=N[U$],x=N[Q],O$=N[x],J0=N[I$]*257^I$*16843008;G$[0][U$]=J0<<24|J0>>>8,G$[1][U$]=J0<<16|J0>>>16,G$[2][U$]=J0<<8|J0>>>24,G$[3][U$]=J0,J0=O$*16843009^x*65537^Q*257^U$*16843008,V$[0][I$]=J0<<24|J0>>>8,V$[1][I$]=J0<<16|J0>>>16,V$[2][I$]=J0<<8|J0>>>24,V$[3][I$]=J0,U$===0?U$=X$=1:(U$=Q^N[N[N[O$^Q]]],X$^=N[N[X$]])}return{SBOX:O0,INV_SBOX:Z$,SUB_MIX:G$,INV_SUB_MIX:V$}}();function $(N){this._key=e0(N),this._reset()}$.blockSize=16,$.keySize=32,$.prototype.blockSize=$.blockSize,$.prototype.keySize=$.keySize,$.prototype._reset=function(){for(var N=this._key,Y$=N.length,O0=Y$+6,Z$=(O0+1)*4,G$=[],V$=0;V$>>24,U$=Q$.SBOX[U$>>>24]<<24|Q$.SBOX[U$>>>16&255]<<16|Q$.SBOX[U$>>>8&255]<<8|Q$.SBOX[U$&255],U$^=$$[V$/Y$|0]<<24):Y$>6&&V$%Y$===4&&(U$=Q$.SBOX[U$>>>24]<<24|Q$.SBOX[U$>>>16&255]<<16|Q$.SBOX[U$>>>8&255]<<8|Q$.SBOX[U$&255]),G$[V$]=G$[V$-Y$]^U$}for(var X$=[],K$=0;K$>>24]]^Q$.INV_SUB_MIX[1][Q$.SBOX[Q>>>16&255]]^Q$.INV_SUB_MIX[2][Q$.SBOX[Q>>>8&255]]^Q$.INV_SUB_MIX[3][Q$.SBOX[Q&255]]}this._nRounds=O0,this._keySchedule=G$,this._invKeySchedule=X$},$.prototype.encryptBlockRaw=function(N){return N=e0(N),i0(N,this._keySchedule,Q$.SUB_MIX,Q$.SBOX,this._nRounds)},$.prototype.encryptBlock=function(N){var Y$=this.encryptBlockRaw(N),O0=a0.allocUnsafe(16);return O0.writeUInt32BE(Y$[0],0),O0.writeUInt32BE(Y$[1],4),O0.writeUInt32BE(Y$[2],8),O0.writeUInt32BE(Y$[3],12),O0},$.prototype.decryptBlock=function(N){N=e0(N);var Y$=N[1];N[1]=N[3],N[3]=Y$;var O0=i0(N,this._invKeySchedule,Q$.INV_SUB_MIX,Q$.INV_SBOX,this._nRounds),Z$=a0.allocUnsafe(16);return Z$.writeUInt32BE(O0[0],0),Z$.writeUInt32BE(O0[3],4),Z$.writeUInt32BE(O0[2],8),Z$.writeUInt32BE(O0[1],12),Z$},$.prototype.scrub=function(){r0(this._keySchedule),r0(this._invKeySchedule),r0(this._key)},m0.exports.AES=$}}),EY=pQ({"node_modules/browserify-aes/ghash.js"(t0,m0){var a0=cQ().Buffer,e0=a0.alloc(16,0);function r0(Q$){return[Q$.readUInt32BE(0),Q$.readUInt32BE(4),Q$.readUInt32BE(8),Q$.readUInt32BE(12)]}function i0(Q$){var $=a0.allocUnsafe(16);return $.writeUInt32BE(Q$[0]>>>0,0),$.writeUInt32BE(Q$[1]>>>0,4),$.writeUInt32BE(Q$[2]>>>0,8),$.writeUInt32BE(Q$[3]>>>0,12),$}function $$(Q$){this.h=Q$,this.state=a0.alloc(16,0),this.cache=a0.allocUnsafe(0)}$$.prototype.ghash=function(Q$){for(var $=-1;++$0;N--)Q$[N]=Q$[N]>>>1|(Q$[N-1]&1)<<31;Q$[0]=Q$[0]>>>1,O0&&(Q$[0]=Q$[0]^225<<24)}this.state=i0($)},$$.prototype.update=function(Q$){this.cache=a0.concat([this.cache,Q$]);for(var $;this.cache.length>=16;)$=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash($)},$$.prototype.final=function(Q$,$){return this.cache.length&&this.ghash(a0.concat([this.cache,e0],16)),this.ghash(i0([0,Q$,0,$])),this.state},m0.exports=$$}}),E=pQ({"node_modules/browserify-aes/authCipher.js"(t0,m0){var a0=WY(),e0=cQ().Buffer,r0=A(),i0=dQ(),$$=EY(),Q$=W(),$=FY();function N(Z$,G$){var V$=0;Z$.length!==G$.length&&V$++;for(var U$=Math.min(Z$.length,G$.length),X$=0;X$0||$>0;){var G$=new e0;G$.update(Z$),G$.update(i0),$$&&G$.update($$),Z$=G$.digest();var V$=0;if(N>0){var U$=Y$.length-N;V$=Math.min(N,Z$.length),Z$.copy(Y$,U$,0,V$),N-=V$}if(V$0){var X$=O0.length-$,K$=Math.min($,Z$.length-V$);Z$.copy(O0,X$,V$,V$+K$),$-=K$}}return Z$.fill(0),{key:Y$,iv:O0}}m0.exports=r0}}),g0=pQ({"node_modules/browserify-aes/encrypter.js"(t0){var m0=HY(),a0=E(),e0=cQ().Buffer,r0=s(),i0=A(),$$=WY(),Q$=k0(),$=dQ();function N(V$,U$,X$){i0.call(this),this._cache=new O0,this._cipher=new $$.AES(U$),this._prev=e0.from(X$),this._mode=V$,this._autopadding=!0}$(N,i0),N.prototype._update=function(V$){this._cache.add(V$);for(var U$,X$,K$=[];U$=this._cache.get();)X$=this._mode.encrypt(this,U$),K$.push(X$);return e0.concat(K$)};var Y$=e0.alloc(16,16);N.prototype._final=function(){var V$=this._cache.flush();if(this._autopadding)return V$=this._mode.encrypt(this,V$),this._cipher.scrub(),V$;if(!V$.equals(Y$))throw this._cipher.scrub(),new Error("data not multiple of block length")},N.prototype.setAutoPadding=function(V$){return this._autopadding=!!V$,this};function O0(){this.cache=e0.allocUnsafe(0)}O0.prototype.add=function(V$){this.cache=e0.concat([this.cache,V$])},O0.prototype.get=function(){if(this.cache.length>15){var V$=this.cache.slice(0,16);return this.cache=this.cache.slice(16),V$}return null},O0.prototype.flush=function(){for(var V$=16-this.cache.length,U$=e0.allocUnsafe(V$),X$=-1;++X$16)return U$=this.cache.slice(0,16),this.cache=this.cache.slice(16),U$}else if(this.cache.length>=16)return U$=this.cache.slice(0,16),this.cache=this.cache.slice(16),U$;return null},Y$.prototype.flush=function(){if(this.cache.length)return this.cache};function O0(V$){var U$=V$[15];if(U$<1||U$>16)throw new Error("unable to decrypt data");for(var X$=-1;++X$0?E$:T$},$$.min=function(E$,T$){return E$.cmp(T$)<0?E$:T$},$$.prototype._init=function(E$,T$,Y){if(typeof E$=="number")return this._initNumber(E$,T$,Y);if(typeof E$=="object")return this._initArray(E$,T$,Y);T$==="hex"&&(T$=16),r0(T$===(T$|0)&&T$>=2&&T$<=36),E$=E$.toString().replace(/\s+/g,"");var f=0;E$[0]==="-"&&(f++,this.negative=1),f=0;f-=3)F0=E$[f]|E$[f-1]<<8|E$[f-2]<<16,this.words[D$]|=F0<>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);else if(Y==="le")for(f=0,D$=0;f>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);return this.strip()};function $(E$,T$){var Y=E$.charCodeAt(T$);return Y>=65&&Y<=70?Y-55:Y>=97&&Y<=102?Y-87:Y-48&15}function N(E$,T$,Y){var f=$(E$,Y);return Y-1>=T$&&(f|=$(E$,Y-1)<<4),f}$$.prototype._parseHex=function(E$,T$,Y){this.length=Math.ceil((E$.length-T$)/6),this.words=new Array(this.length);for(var f=0;f=T$;f-=2)C$=N(E$,T$,f)<=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8;else{var L$=E$.length-T$;for(f=L$%2===0?T$+1:T$;f=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8}this.strip()};function Y$(E$,T$,Y,f){for(var D$=0,F0=Math.min(E$.length,Y),C$=T$;C$=49?D$+=L$-49+10:L$>=17?D$+=L$-17+10:D$+=L$}return D$}$$.prototype._parseBase=function(E$,T$,Y){this.words=[0],this.length=1;for(var f=0,D$=1;D$<=67108863;D$*=T$)f++;f--,D$=D$/T$|0;for(var F0=E$.length-Y,C$=F0%f,L$=Math.min(F0,F0-C$)+Y,R$=0,P$=Y;P$1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},$$.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},$$.prototype.inspect=function(){return(this.red?""};var O0=["","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"],Z$=[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],G$=[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];$$.prototype.toString=function(E$,T$){E$=E$||10,T$=T$|0||1;var Y;if(E$===16||E$==="hex"){Y="";for(var f=0,D$=0,F0=0;F0>>24-f&16777215,D$!==0||F0!==this.length-1?Y=O0[6-L$.length]+L$+Y:Y=L$+Y,f+=2,f>=26&&(f-=26,F0--)}for(D$!==0&&(Y=D$.toString(16)+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}if(E$===(E$|0)&&E$>=2&&E$<=36){var R$=Z$[E$],P$=G$[E$];Y="";var z$=this.clone();for(z$.negative=0;!z$.isZero();){var M$=z$.modn(P$).toString(E$);z$=z$.idivn(P$),z$.isZero()?Y=M$+Y:Y=O0[R$-M$.length]+M$+Y}for(this.isZero()&&(Y="0"+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}r0(!1,"Base should be between 2 and 36")},$$.prototype.toNumber=function(){var E$=this.words[0];return this.length===2?E$+=this.words[1]*67108864:this.length===3&&this.words[2]===1?E$+=4503599627370496+this.words[1]*67108864:this.length>2&&r0(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-E$:E$},$$.prototype.toJSON=function(){return this.toString(16)},$$.prototype.toBuffer=function(E$,T$){return r0(typeof Q$<"u"),this.toArrayLike(Q$,E$,T$)},$$.prototype.toArray=function(E$,T$){return this.toArrayLike(Array,E$,T$)},$$.prototype.toArrayLike=function(E$,T$,Y){var f=this.byteLength(),D$=Y||Math.max(1,f);r0(f<=D$,"byte array longer than desired length"),r0(D$>0,"Requested array length <= 0"),this.strip();var F0=T$==="le",C$=new E$(D$),L$,R$,P$=this.clone();if(F0){for(R$=0;!P$.isZero();R$++)L$=P$.andln(255),P$.iushrn(8),C$[R$]=L$;for(;R$=4096&&(Y+=13,T$>>>=13),T$>=64&&(Y+=7,T$>>>=7),T$>=8&&(Y+=4,T$>>>=4),T$>=2&&(Y+=2,T$>>>=2),Y+T$},$$.prototype._zeroBits=function(E$){if(E$===0)return 26;var T$=E$,Y=0;return(T$&8191)===0&&(Y+=13,T$>>>=13),(T$&127)===0&&(Y+=7,T$>>>=7),(T$&15)===0&&(Y+=4,T$>>>=4),(T$&3)===0&&(Y+=2,T$>>>=2),(T$&1)===0&&Y++,Y},$$.prototype.bitLength=function(){var E$=this.words[this.length-1],T$=this._countBits(E$);return(this.length-1)*26+T$};function V$(E$){for(var T$=new Array(E$.bitLength()),Y=0;Y>>D$}return T$}$$.prototype.zeroBits=function(){if(this.isZero())return 0;for(var E$=0,T$=0;T$E$.length?this.clone().ior(E$):E$.clone().ior(this)},$$.prototype.uor=function(E$){return this.length>E$.length?this.clone().iuor(E$):E$.clone().iuor(this)},$$.prototype.iuand=function(E$){var T$;this.length>E$.length?T$=E$:T$=this;for(var Y=0;YE$.length?this.clone().iand(E$):E$.clone().iand(this)},$$.prototype.uand=function(E$){return this.length>E$.length?this.clone().iuand(E$):E$.clone().iuand(this)},$$.prototype.iuxor=function(E$){var T$,Y;this.length>E$.length?(T$=this,Y=E$):(T$=E$,Y=this);for(var f=0;fE$.length?this.clone().ixor(E$):E$.clone().ixor(this)},$$.prototype.uxor=function(E$){return this.length>E$.length?this.clone().iuxor(E$):E$.clone().iuxor(this)},$$.prototype.inotn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=Math.ceil(E$/26)|0,Y=E$%26;this._expand(T$),Y>0&&T$--;for(var f=0;f0&&(this.words[f]=~this.words[f]&67108863>>26-Y),this.strip()},$$.prototype.notn=function(E$){return this.clone().inotn(E$)},$$.prototype.setn=function(E$,T$){r0(typeof E$=="number"&&E$>=0);var Y=E$/26|0,f=E$%26;return this._expand(Y+1),T$?this.words[Y]=this.words[Y]|1<E$.length?(Y=this,f=E$):(Y=E$,f=this);for(var D$=0,F0=0;F0>>26;for(;D$!==0&&F0>>26;if(this.length=Y.length,D$!==0)this.words[this.length]=D$,this.length++;else if(Y!==this)for(;F0E$.length?this.clone().iadd(E$):E$.clone().iadd(this)},$$.prototype.isub=function(E$){if(E$.negative!==0){E$.negative=0;var T$=this.iadd(E$);return E$.negative=1,T$._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(E$),this.negative=1,this._normSign();var Y=this.cmp(E$);if(Y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,D$;Y>0?(f=this,D$=E$):(f=E$,D$=this);for(var F0=0,C$=0;C$>26,this.words[C$]=T$&67108863;for(;F0!==0&&C$>26,this.words[C$]=T$&67108863;if(F0===0&&C$>>26,M$=R$&67108863,S$=Math.min(P$,T$.length-1),Z=Math.max(0,P$-E$.length+1);Z<=S$;Z++){var c=P$-Z|0;D$=E$.words[c]|0,F0=T$.words[Z]|0,C$=D$*F0+M$,z$+=C$/67108864|0,M$=C$&67108863}Y.words[P$]=M$|0,R$=z$|0}return R$!==0?Y.words[P$]=R$|0:Y.length--,Y.strip()}var X$=function(E$,T$,Y){var f=E$.words,D$=T$.words,F0=Y.words,C$=0,L$,R$,P$,z$=f[0]|0,M$=z$&8191,S$=z$>>>13,Z=f[1]|0,c=Z&8191,v$=Z>>>13,A0=f[2]|0,q$=A0&8191,j$=A0>>>13,k$=f[3]|0,g$=k$&8191,_$=k$>>>13,N$=f[4]|0,x$=N$&8191,G=N$>>>13,B=f[5]|0,B$=B&8191,H0=B>>>13,y$=f[6]|0,w$=y$&8191,p$=y$>>>13,f$=f[7]|0,c$=f$&8191,h$=f$>>>13,d$=f[8]|0,V=d$&8191,h=d$>>>13,W0=f[9]|0,E0=W0&8191,b$=W0>>>13,l$=D$[0]|0,o$=l$&8191,u$=l$>>>13,n$=D$[1]|0,s$=n$&8191,t$=n$>>>13,U=D$[2]|0,d=U&8191,m$=U>>>13,T0=D$[3]|0,a$=T0&8191,e$=T0>>>13,r$=D$[4]|0,i$=r$&8191,$Q=r$>>>13,QQ=D$[5]|0,YQ=QQ&8191,X=QQ>>>13,b=D$[6]|0,ZQ=b&8191,D0=b>>>13,GQ=D$[7]|0,VQ=GQ&8191,UQ=GQ>>>13,XQ=D$[8]|0,KQ=XQ&8191,IQ=XQ>>>13,OQ=D$[9]|0,K=OQ&8191,l=OQ>>>13;Y.negative=E$.negative^T$.negative,Y.length=19,L$=Math.imul(M$,o$),R$=Math.imul(M$,u$),R$=R$+Math.imul(S$,o$)|0,P$=Math.imul(S$,u$);var JQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(JQ>>>26)|0,JQ&=67108863,L$=Math.imul(c,o$),R$=Math.imul(c,u$),R$=R$+Math.imul(v$,o$)|0,P$=Math.imul(v$,u$),L$=L$+Math.imul(M$,s$)|0,R$=R$+Math.imul(M$,t$)|0,R$=R$+Math.imul(S$,s$)|0,P$=P$+Math.imul(S$,t$)|0;var C0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(C0>>>26)|0,C0&=67108863,L$=Math.imul(q$,o$),R$=Math.imul(q$,u$),R$=R$+Math.imul(j$,o$)|0,P$=Math.imul(j$,u$),L$=L$+Math.imul(c,s$)|0,R$=R$+Math.imul(c,t$)|0,R$=R$+Math.imul(v$,s$)|0,P$=P$+Math.imul(v$,t$)|0,L$=L$+Math.imul(M$,d)|0,R$=R$+Math.imul(M$,m$)|0,R$=R$+Math.imul(S$,d)|0,P$=P$+Math.imul(S$,m$)|0;var FQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(FQ>>>26)|0,FQ&=67108863,L$=Math.imul(g$,o$),R$=Math.imul(g$,u$),R$=R$+Math.imul(_$,o$)|0,P$=Math.imul(_$,u$),L$=L$+Math.imul(q$,s$)|0,R$=R$+Math.imul(q$,t$)|0,R$=R$+Math.imul(j$,s$)|0,P$=P$+Math.imul(j$,t$)|0,L$=L$+Math.imul(c,d)|0,R$=R$+Math.imul(c,m$)|0,R$=R$+Math.imul(v$,d)|0,P$=P$+Math.imul(v$,m$)|0,L$=L$+Math.imul(M$,a$)|0,R$=R$+Math.imul(M$,e$)|0,R$=R$+Math.imul(S$,a$)|0,P$=P$+Math.imul(S$,e$)|0;var AQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(AQ>>>26)|0,AQ&=67108863,L$=Math.imul(x$,o$),R$=Math.imul(x$,u$),R$=R$+Math.imul(G,o$)|0,P$=Math.imul(G,u$),L$=L$+Math.imul(g$,s$)|0,R$=R$+Math.imul(g$,t$)|0,R$=R$+Math.imul(_$,s$)|0,P$=P$+Math.imul(_$,t$)|0,L$=L$+Math.imul(q$,d)|0,R$=R$+Math.imul(q$,m$)|0,R$=R$+Math.imul(j$,d)|0,P$=P$+Math.imul(j$,m$)|0,L$=L$+Math.imul(c,a$)|0,R$=R$+Math.imul(c,e$)|0,R$=R$+Math.imul(v$,a$)|0,P$=P$+Math.imul(v$,e$)|0,L$=L$+Math.imul(M$,i$)|0,R$=R$+Math.imul(M$,$Q)|0,R$=R$+Math.imul(S$,i$)|0,P$=P$+Math.imul(S$,$Q)|0;var HQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(HQ>>>26)|0,HQ&=67108863,L$=Math.imul(B$,o$),R$=Math.imul(B$,u$),R$=R$+Math.imul(H0,o$)|0,P$=Math.imul(H0,u$),L$=L$+Math.imul(x$,s$)|0,R$=R$+Math.imul(x$,t$)|0,R$=R$+Math.imul(G,s$)|0,P$=P$+Math.imul(G,t$)|0,L$=L$+Math.imul(g$,d)|0,R$=R$+Math.imul(g$,m$)|0,R$=R$+Math.imul(_$,d)|0,P$=P$+Math.imul(_$,m$)|0,L$=L$+Math.imul(q$,a$)|0,R$=R$+Math.imul(q$,e$)|0,R$=R$+Math.imul(j$,a$)|0,P$=P$+Math.imul(j$,e$)|0,L$=L$+Math.imul(c,i$)|0,R$=R$+Math.imul(c,$Q)|0,R$=R$+Math.imul(v$,i$)|0,P$=P$+Math.imul(v$,$Q)|0,L$=L$+Math.imul(M$,YQ)|0,R$=R$+Math.imul(M$,X)|0,R$=R$+Math.imul(S$,YQ)|0,P$=P$+Math.imul(S$,X)|0;var WQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(WQ>>>26)|0,WQ&=67108863,L$=Math.imul(w$,o$),R$=Math.imul(w$,u$),R$=R$+Math.imul(p$,o$)|0,P$=Math.imul(p$,u$),L$=L$+Math.imul(B$,s$)|0,R$=R$+Math.imul(B$,t$)|0,R$=R$+Math.imul(H0,s$)|0,P$=P$+Math.imul(H0,t$)|0,L$=L$+Math.imul(x$,d)|0,R$=R$+Math.imul(x$,m$)|0,R$=R$+Math.imul(G,d)|0,P$=P$+Math.imul(G,m$)|0,L$=L$+Math.imul(g$,a$)|0,R$=R$+Math.imul(g$,e$)|0,R$=R$+Math.imul(_$,a$)|0,P$=P$+Math.imul(_$,e$)|0,L$=L$+Math.imul(q$,i$)|0,R$=R$+Math.imul(q$,$Q)|0,R$=R$+Math.imul(j$,i$)|0,P$=P$+Math.imul(j$,$Q)|0,L$=L$+Math.imul(c,YQ)|0,R$=R$+Math.imul(c,X)|0,R$=R$+Math.imul(v$,YQ)|0,P$=P$+Math.imul(v$,X)|0,L$=L$+Math.imul(M$,ZQ)|0,R$=R$+Math.imul(M$,D0)|0,R$=R$+Math.imul(S$,ZQ)|0,P$=P$+Math.imul(S$,D0)|0;var EQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(EQ>>>26)|0,EQ&=67108863,L$=Math.imul(c$,o$),R$=Math.imul(c$,u$),R$=R$+Math.imul(h$,o$)|0,P$=Math.imul(h$,u$),L$=L$+Math.imul(w$,s$)|0,R$=R$+Math.imul(w$,t$)|0,R$=R$+Math.imul(p$,s$)|0,P$=P$+Math.imul(p$,t$)|0,L$=L$+Math.imul(B$,d)|0,R$=R$+Math.imul(B$,m$)|0,R$=R$+Math.imul(H0,d)|0,P$=P$+Math.imul(H0,m$)|0,L$=L$+Math.imul(x$,a$)|0,R$=R$+Math.imul(x$,e$)|0,R$=R$+Math.imul(G,a$)|0,P$=P$+Math.imul(G,e$)|0,L$=L$+Math.imul(g$,i$)|0,R$=R$+Math.imul(g$,$Q)|0,R$=R$+Math.imul(_$,i$)|0,P$=P$+Math.imul(_$,$Q)|0,L$=L$+Math.imul(q$,YQ)|0,R$=R$+Math.imul(q$,X)|0,R$=R$+Math.imul(j$,YQ)|0,P$=P$+Math.imul(j$,X)|0,L$=L$+Math.imul(c,ZQ)|0,R$=R$+Math.imul(c,D0)|0,R$=R$+Math.imul(v$,ZQ)|0,P$=P$+Math.imul(v$,D0)|0,L$=L$+Math.imul(M$,VQ)|0,R$=R$+Math.imul(M$,UQ)|0,R$=R$+Math.imul(S$,VQ)|0,P$=P$+Math.imul(S$,UQ)|0;var TQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(TQ>>>26)|0,TQ&=67108863,L$=Math.imul(V,o$),R$=Math.imul(V,u$),R$=R$+Math.imul(h,o$)|0,P$=Math.imul(h,u$),L$=L$+Math.imul(c$,s$)|0,R$=R$+Math.imul(c$,t$)|0,R$=R$+Math.imul(h$,s$)|0,P$=P$+Math.imul(h$,t$)|0,L$=L$+Math.imul(w$,d)|0,R$=R$+Math.imul(w$,m$)|0,R$=R$+Math.imul(p$,d)|0,P$=P$+Math.imul(p$,m$)|0,L$=L$+Math.imul(B$,a$)|0,R$=R$+Math.imul(B$,e$)|0,R$=R$+Math.imul(H0,a$)|0,P$=P$+Math.imul(H0,e$)|0,L$=L$+Math.imul(x$,i$)|0,R$=R$+Math.imul(x$,$Q)|0,R$=R$+Math.imul(G,i$)|0,P$=P$+Math.imul(G,$Q)|0,L$=L$+Math.imul(g$,YQ)|0,R$=R$+Math.imul(g$,X)|0,R$=R$+Math.imul(_$,YQ)|0,P$=P$+Math.imul(_$,X)|0,L$=L$+Math.imul(q$,ZQ)|0,R$=R$+Math.imul(q$,D0)|0,R$=R$+Math.imul(j$,ZQ)|0,P$=P$+Math.imul(j$,D0)|0,L$=L$+Math.imul(c,VQ)|0,R$=R$+Math.imul(c,UQ)|0,R$=R$+Math.imul(v$,VQ)|0,P$=P$+Math.imul(v$,UQ)|0,L$=L$+Math.imul(M$,KQ)|0,R$=R$+Math.imul(M$,IQ)|0,R$=R$+Math.imul(S$,KQ)|0,P$=P$+Math.imul(S$,IQ)|0;var DQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(DQ>>>26)|0,DQ&=67108863,L$=Math.imul(E0,o$),R$=Math.imul(E0,u$),R$=R$+Math.imul(b$,o$)|0,P$=Math.imul(b$,u$),L$=L$+Math.imul(V,s$)|0,R$=R$+Math.imul(V,t$)|0,R$=R$+Math.imul(h,s$)|0,P$=P$+Math.imul(h,t$)|0,L$=L$+Math.imul(c$,d)|0,R$=R$+Math.imul(c$,m$)|0,R$=R$+Math.imul(h$,d)|0,P$=P$+Math.imul(h$,m$)|0,L$=L$+Math.imul(w$,a$)|0,R$=R$+Math.imul(w$,e$)|0,R$=R$+Math.imul(p$,a$)|0,P$=P$+Math.imul(p$,e$)|0,L$=L$+Math.imul(B$,i$)|0,R$=R$+Math.imul(B$,$Q)|0,R$=R$+Math.imul(H0,i$)|0,P$=P$+Math.imul(H0,$Q)|0,L$=L$+Math.imul(x$,YQ)|0,R$=R$+Math.imul(x$,X)|0,R$=R$+Math.imul(G,YQ)|0,P$=P$+Math.imul(G,X)|0,L$=L$+Math.imul(g$,ZQ)|0,R$=R$+Math.imul(g$,D0)|0,R$=R$+Math.imul(_$,ZQ)|0,P$=P$+Math.imul(_$,D0)|0,L$=L$+Math.imul(q$,VQ)|0,R$=R$+Math.imul(q$,UQ)|0,R$=R$+Math.imul(j$,VQ)|0,P$=P$+Math.imul(j$,UQ)|0,L$=L$+Math.imul(c,KQ)|0,R$=R$+Math.imul(c,IQ)|0,R$=R$+Math.imul(v$,KQ)|0,P$=P$+Math.imul(v$,IQ)|0,L$=L$+Math.imul(M$,K)|0,R$=R$+Math.imul(M$,l)|0,R$=R$+Math.imul(S$,K)|0,P$=P$+Math.imul(S$,l)|0;var I=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(I>>>26)|0,I&=67108863,L$=Math.imul(E0,s$),R$=Math.imul(E0,t$),R$=R$+Math.imul(b$,s$)|0,P$=Math.imul(b$,t$),L$=L$+Math.imul(V,d)|0,R$=R$+Math.imul(V,m$)|0,R$=R$+Math.imul(h,d)|0,P$=P$+Math.imul(h,m$)|0,L$=L$+Math.imul(c$,a$)|0,R$=R$+Math.imul(c$,e$)|0,R$=R$+Math.imul(h$,a$)|0,P$=P$+Math.imul(h$,e$)|0,L$=L$+Math.imul(w$,i$)|0,R$=R$+Math.imul(w$,$Q)|0,R$=R$+Math.imul(p$,i$)|0,P$=P$+Math.imul(p$,$Q)|0,L$=L$+Math.imul(B$,YQ)|0,R$=R$+Math.imul(B$,X)|0,R$=R$+Math.imul(H0,YQ)|0,P$=P$+Math.imul(H0,X)|0,L$=L$+Math.imul(x$,ZQ)|0,R$=R$+Math.imul(x$,D0)|0,R$=R$+Math.imul(G,ZQ)|0,P$=P$+Math.imul(G,D0)|0,L$=L$+Math.imul(g$,VQ)|0,R$=R$+Math.imul(g$,UQ)|0,R$=R$+Math.imul(_$,VQ)|0,P$=P$+Math.imul(_$,UQ)|0,L$=L$+Math.imul(q$,KQ)|0,R$=R$+Math.imul(q$,IQ)|0,R$=R$+Math.imul(j$,KQ)|0,P$=P$+Math.imul(j$,IQ)|0,L$=L$+Math.imul(c,K)|0,R$=R$+Math.imul(c,l)|0,R$=R$+Math.imul(v$,K)|0,P$=P$+Math.imul(v$,l)|0;var o=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(o>>>26)|0,o&=67108863,L$=Math.imul(E0,d),R$=Math.imul(E0,m$),R$=R$+Math.imul(b$,d)|0,P$=Math.imul(b$,m$),L$=L$+Math.imul(V,a$)|0,R$=R$+Math.imul(V,e$)|0,R$=R$+Math.imul(h,a$)|0,P$=P$+Math.imul(h,e$)|0,L$=L$+Math.imul(c$,i$)|0,R$=R$+Math.imul(c$,$Q)|0,R$=R$+Math.imul(h$,i$)|0,P$=P$+Math.imul(h$,$Q)|0,L$=L$+Math.imul(w$,YQ)|0,R$=R$+Math.imul(w$,X)|0,R$=R$+Math.imul(p$,YQ)|0,P$=P$+Math.imul(p$,X)|0,L$=L$+Math.imul(B$,ZQ)|0,R$=R$+Math.imul(B$,D0)|0,R$=R$+Math.imul(H0,ZQ)|0,P$=P$+Math.imul(H0,D0)|0,L$=L$+Math.imul(x$,VQ)|0,R$=R$+Math.imul(x$,UQ)|0,R$=R$+Math.imul(G,VQ)|0,P$=P$+Math.imul(G,UQ)|0,L$=L$+Math.imul(g$,KQ)|0,R$=R$+Math.imul(g$,IQ)|0,R$=R$+Math.imul(_$,KQ)|0,P$=P$+Math.imul(_$,IQ)|0,L$=L$+Math.imul(q$,K)|0,R$=R$+Math.imul(q$,l)|0,R$=R$+Math.imul(j$,K)|0,P$=P$+Math.imul(j$,l)|0;var CQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(CQ>>>26)|0,CQ&=67108863,L$=Math.imul(E0,a$),R$=Math.imul(E0,e$),R$=R$+Math.imul(b$,a$)|0,P$=Math.imul(b$,e$),L$=L$+Math.imul(V,i$)|0,R$=R$+Math.imul(V,$Q)|0,R$=R$+Math.imul(h,i$)|0,P$=P$+Math.imul(h,$Q)|0,L$=L$+Math.imul(c$,YQ)|0,R$=R$+Math.imul(c$,X)|0,R$=R$+Math.imul(h$,YQ)|0,P$=P$+Math.imul(h$,X)|0,L$=L$+Math.imul(w$,ZQ)|0,R$=R$+Math.imul(w$,D0)|0,R$=R$+Math.imul(p$,ZQ)|0,P$=P$+Math.imul(p$,D0)|0,L$=L$+Math.imul(B$,VQ)|0,R$=R$+Math.imul(B$,UQ)|0,R$=R$+Math.imul(H0,VQ)|0,P$=P$+Math.imul(H0,UQ)|0,L$=L$+Math.imul(x$,KQ)|0,R$=R$+Math.imul(x$,IQ)|0,R$=R$+Math.imul(G,KQ)|0,P$=P$+Math.imul(G,IQ)|0,L$=L$+Math.imul(g$,K)|0,R$=R$+Math.imul(g$,l)|0,R$=R$+Math.imul(_$,K)|0,P$=P$+Math.imul(_$,l)|0;var L0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(L0>>>26)|0,L0&=67108863,L$=Math.imul(E0,i$),R$=Math.imul(E0,$Q),R$=R$+Math.imul(b$,i$)|0,P$=Math.imul(b$,$Q),L$=L$+Math.imul(V,YQ)|0,R$=R$+Math.imul(V,X)|0,R$=R$+Math.imul(h,YQ)|0,P$=P$+Math.imul(h,X)|0,L$=L$+Math.imul(c$,ZQ)|0,R$=R$+Math.imul(c$,D0)|0,R$=R$+Math.imul(h$,ZQ)|0,P$=P$+Math.imul(h$,D0)|0,L$=L$+Math.imul(w$,VQ)|0,R$=R$+Math.imul(w$,UQ)|0,R$=R$+Math.imul(p$,VQ)|0,P$=P$+Math.imul(p$,UQ)|0,L$=L$+Math.imul(B$,KQ)|0,R$=R$+Math.imul(B$,IQ)|0,R$=R$+Math.imul(H0,KQ)|0,P$=P$+Math.imul(H0,IQ)|0,L$=L$+Math.imul(x$,K)|0,R$=R$+Math.imul(x$,l)|0,R$=R$+Math.imul(G,K)|0,P$=P$+Math.imul(G,l)|0;var LQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(LQ>>>26)|0,LQ&=67108863,L$=Math.imul(E0,YQ),R$=Math.imul(E0,X),R$=R$+Math.imul(b$,YQ)|0,P$=Math.imul(b$,X),L$=L$+Math.imul(V,ZQ)|0,R$=R$+Math.imul(V,D0)|0,R$=R$+Math.imul(h,ZQ)|0,P$=P$+Math.imul(h,D0)|0,L$=L$+Math.imul(c$,VQ)|0,R$=R$+Math.imul(c$,UQ)|0,R$=R$+Math.imul(h$,VQ)|0,P$=P$+Math.imul(h$,UQ)|0,L$=L$+Math.imul(w$,KQ)|0,R$=R$+Math.imul(w$,IQ)|0,R$=R$+Math.imul(p$,KQ)|0,P$=P$+Math.imul(p$,IQ)|0,L$=L$+Math.imul(B$,K)|0,R$=R$+Math.imul(B$,l)|0,R$=R$+Math.imul(H0,K)|0,P$=P$+Math.imul(H0,l)|0;var RQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(RQ>>>26)|0,RQ&=67108863,L$=Math.imul(E0,ZQ),R$=Math.imul(E0,D0),R$=R$+Math.imul(b$,ZQ)|0,P$=Math.imul(b$,D0),L$=L$+Math.imul(V,VQ)|0,R$=R$+Math.imul(V,UQ)|0,R$=R$+Math.imul(h,VQ)|0,P$=P$+Math.imul(h,UQ)|0,L$=L$+Math.imul(c$,KQ)|0,R$=R$+Math.imul(c$,IQ)|0,R$=R$+Math.imul(h$,KQ)|0,P$=P$+Math.imul(h$,IQ)|0,L$=L$+Math.imul(w$,K)|0,R$=R$+Math.imul(w$,l)|0,R$=R$+Math.imul(p$,K)|0,P$=P$+Math.imul(p$,l)|0;var PQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(PQ>>>26)|0,PQ&=67108863,L$=Math.imul(E0,VQ),R$=Math.imul(E0,UQ),R$=R$+Math.imul(b$,VQ)|0,P$=Math.imul(b$,UQ),L$=L$+Math.imul(V,KQ)|0,R$=R$+Math.imul(V,IQ)|0,R$=R$+Math.imul(h,KQ)|0,P$=P$+Math.imul(h,IQ)|0,L$=L$+Math.imul(c$,K)|0,R$=R$+Math.imul(c$,l)|0,R$=R$+Math.imul(h$,K)|0,P$=P$+Math.imul(h$,l)|0;var zQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(zQ>>>26)|0,zQ&=67108863,L$=Math.imul(E0,KQ),R$=Math.imul(E0,IQ),R$=R$+Math.imul(b$,KQ)|0,P$=Math.imul(b$,IQ),L$=L$+Math.imul(V,K)|0,R$=R$+Math.imul(V,l)|0,R$=R$+Math.imul(h,K)|0,P$=P$+Math.imul(h,l)|0;var MQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(MQ>>>26)|0,MQ&=67108863,L$=Math.imul(E0,K),R$=Math.imul(E0,l),R$=R$+Math.imul(b$,K)|0,P$=Math.imul(b$,l);var SQ=(C$+L$|0)+((R$&8191)<<13)|0;return C$=(P$+(R$>>>13)|0)+(SQ>>>26)|0,SQ&=67108863,F0[0]=JQ,F0[1]=C0,F0[2]=FQ,F0[3]=AQ,F0[4]=HQ,F0[5]=WQ,F0[6]=EQ,F0[7]=TQ,F0[8]=DQ,F0[9]=I,F0[10]=o,F0[11]=CQ,F0[12]=L0,F0[13]=LQ,F0[14]=RQ,F0[15]=PQ,F0[16]=zQ,F0[17]=MQ,F0[18]=SQ,C$!==0&&(F0[19]=C$,Y.length++),Y};Math.imul||(X$=U$);function K$(E$,T$,Y){Y.negative=T$.negative^E$.negative,Y.length=E$.length+T$.length;for(var f=0,D$=0,F0=0;F0>>26)|0,D$+=C$>>>26,C$&=67108863}Y.words[F0]=L$,f=C$,C$=D$}return f!==0?Y.words[F0]=f:Y.length--,Y.strip()}function I$(E$,T$,Y){var f=new Q;return f.mulp(E$,T$,Y)}$$.prototype.mulTo=function(E$,T$){var Y,f=this.length+E$.length;return this.length===10&&E$.length===10?Y=X$(this,E$,T$):f<63?Y=U$(this,E$,T$):f<1024?Y=K$(this,E$,T$):Y=I$(this,E$,T$),Y};function Q(E$,T$){this.x=E$,this.y=T$}Q.prototype.makeRBT=function(E$){for(var T$=new Array(E$),Y=$$.prototype._countBits(E$)-1,f=0;f>=1;return f},Q.prototype.permute=function(E$,T$,Y,f,D$,F0){for(var C$=0;C$>>1)D$++;return 1<>>13,Y[2*F0+1]=D$&8191,D$=D$>>>13;for(F0=2*T$;F0>=26,T$+=f/67108864|0,T$+=D$>>>26,this.words[Y]=D$&67108863}return T$!==0&&(this.words[Y]=T$,this.length++),this},$$.prototype.muln=function(E$){return this.clone().imuln(E$)},$$.prototype.sqr=function(){return this.mul(this)},$$.prototype.isqr=function(){return this.imul(this.clone())},$$.prototype.pow=function(E$){var T$=V$(E$);if(T$.length===0)return new $$(1);for(var Y=this,f=0;f=0);var T$=E$%26,Y=(E$-T$)/26,f=67108863>>>26-T$<<26-T$,D$;if(T$!==0){var F0=0;for(D$=0;D$>>26-T$}F0&&(this.words[D$]=F0,this.length++)}if(Y!==0){for(D$=this.length-1;D$>=0;D$--)this.words[D$+Y]=this.words[D$];for(D$=0;D$=0);var f;T$?f=(T$-T$%26)/26:f=0;var D$=E$%26,F0=Math.min((E$-D$)/26,this.length),C$=67108863^67108863>>>D$<F0)for(this.length-=F0,R$=0;R$=0&&(P$!==0||R$>=f);R$--){var z$=this.words[R$]|0;this.words[R$]=P$<<26-D$|z$>>>D$,P$=z$&C$}return L$&&P$!==0&&(L$.words[L$.length++]=P$),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},$$.prototype.ishrn=function(E$,T$,Y){return r0(this.negative===0),this.iushrn(E$,T$,Y)},$$.prototype.shln=function(E$){return this.clone().ishln(E$)},$$.prototype.ushln=function(E$){return this.clone().iushln(E$)},$$.prototype.shrn=function(E$){return this.clone().ishrn(E$)},$$.prototype.ushrn=function(E$){return this.clone().iushrn(E$)},$$.prototype.testn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=E$%26,Y=(E$-T$)/26,f=1<=0);var T$=E$%26,Y=(E$-T$)/26;if(r0(this.negative===0,"imaskn works only with positive numbers"),this.length<=Y)return this;if(T$!==0&&Y++,this.length=Math.min(Y,this.length),T$!==0){var f=67108863^67108863>>>T$<=67108864;T$++)this.words[T$]-=67108864,T$===this.length-1?this.words[T$+1]=1:this.words[T$+1]++;return this.length=Math.max(this.length,T$+1),this},$$.prototype.isubn=function(E$){if(r0(typeof E$=="number"),r0(E$<67108864),E$<0)return this.iaddn(-E$);if(this.negative!==0)return this.negative=0,this.iaddn(E$),this.negative=1,this;if(this.words[0]-=E$,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var T$=0;T$>26)-(L$/67108864|0),this.words[D$+Y]=F0&67108863}for(;D$>26,this.words[D$+Y]=F0&67108863;if(C$===0)return this.strip();for(r0(C$===-1),C$=0,D$=0;D$>26,this.words[D$]=F0&67108863;return this.negative=1,this.strip()},$$.prototype._wordDiv=function(E$,T$){var Y=this.length-E$.length,f=this.clone(),D$=E$,F0=D$.words[D$.length-1]|0,C$=this._countBits(F0);Y=26-C$,Y!==0&&(D$=D$.ushln(Y),f.iushln(Y),F0=D$.words[D$.length-1]|0);var L$=f.length-D$.length,R$;if(T$!=="mod"){R$=new $$(null),R$.length=L$+1,R$.words=new Array(R$.length);for(var P$=0;P$=0;M$--){var S$=(f.words[D$.length+M$]|0)*67108864+(f.words[D$.length+M$-1]|0);for(S$=Math.min(S$/F0|0,67108863),f._ishlnsubmul(D$,S$,M$);f.negative!==0;)S$--,f.negative=0,f._ishlnsubmul(D$,1,M$),f.isZero()||(f.negative^=1);R$&&(R$.words[M$]=S$)}return R$&&R$.strip(),f.strip(),T$!=="div"&&Y!==0&&f.iushrn(Y),{div:R$||null,mod:f}},$$.prototype.divmod=function(E$,T$,Y){if(r0(!E$.isZero()),this.isZero())return{div:new $$(0),mod:new $$(0)};var f,D$,F0;return this.negative!==0&&E$.negative===0?(F0=this.neg().divmod(E$,T$),T$!=="mod"&&(f=F0.div.neg()),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.iadd(E$)),{div:f,mod:D$}):this.negative===0&&E$.negative!==0?(F0=this.divmod(E$.neg(),T$),T$!=="mod"&&(f=F0.div.neg()),{div:f,mod:F0.mod}):(this.negative&E$.negative)!==0?(F0=this.neg().divmod(E$.neg(),T$),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.isub(E$)),{div:F0.div,mod:D$}):E$.length>this.length||this.cmp(E$)<0?{div:new $$(0),mod:this}:E$.length===1?T$==="div"?{div:this.divn(E$.words[0]),mod:null}:T$==="mod"?{div:null,mod:new $$(this.modn(E$.words[0]))}:{div:this.divn(E$.words[0]),mod:new $$(this.modn(E$.words[0]))}:this._wordDiv(E$,T$)},$$.prototype.div=function(E$){return this.divmod(E$,"div",!1).div},$$.prototype.mod=function(E$){return this.divmod(E$,"mod",!1).mod},$$.prototype.umod=function(E$){return this.divmod(E$,"mod",!0).mod},$$.prototype.divRound=function(E$){var T$=this.divmod(E$);if(T$.mod.isZero())return T$.div;var Y=T$.div.negative!==0?T$.mod.isub(E$):T$.mod,f=E$.ushrn(1),D$=E$.andln(1),F0=Y.cmp(f);return F0<0||D$===1&&F0===0?T$.div:T$.div.negative!==0?T$.div.isubn(1):T$.div.iaddn(1)},$$.prototype.modn=function(E$){r0(E$<=67108863);for(var T$=(1<<26)%E$,Y=0,f=this.length-1;f>=0;f--)Y=(T$*Y+(this.words[f]|0))%E$;return Y},$$.prototype.idivn=function(E$){r0(E$<=67108863);for(var T$=0,Y=this.length-1;Y>=0;Y--){var f=(this.words[Y]|0)+T$*67108864;this.words[Y]=f/E$|0,T$=f%E$}return this.strip()},$$.prototype.divn=function(E$){return this.clone().idivn(E$)},$$.prototype.egcd=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=new $$(0),C$=new $$(1),L$=0;T$.isEven()&&Y.isEven();)T$.iushrn(1),Y.iushrn(1),++L$;for(var R$=Y.clone(),P$=T$.clone();!T$.isZero();){for(var z$=0,M$=1;(T$.words[0]&M$)===0&&z$<26;++z$,M$<<=1);if(z$>0)for(T$.iushrn(z$);z$-- >0;)(f.isOdd()||D$.isOdd())&&(f.iadd(R$),D$.isub(P$)),f.iushrn(1),D$.iushrn(1);for(var S$=0,Z=1;(Y.words[0]&Z)===0&&S$<26;++S$,Z<<=1);if(S$>0)for(Y.iushrn(S$);S$-- >0;)(F0.isOdd()||C$.isOdd())&&(F0.iadd(R$),C$.isub(P$)),F0.iushrn(1),C$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(F0),D$.isub(C$)):(Y.isub(T$),F0.isub(f),C$.isub(D$))}return{a:F0,b:C$,gcd:Y.iushln(L$)}},$$.prototype._invmp=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=Y.clone();T$.cmpn(1)>0&&Y.cmpn(1)>0;){for(var C$=0,L$=1;(T$.words[0]&L$)===0&&C$<26;++C$,L$<<=1);if(C$>0)for(T$.iushrn(C$);C$-- >0;)f.isOdd()&&f.iadd(F0),f.iushrn(1);for(var R$=0,P$=1;(Y.words[0]&P$)===0&&R$<26;++R$,P$<<=1);if(R$>0)for(Y.iushrn(R$);R$-- >0;)D$.isOdd()&&D$.iadd(F0),D$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(D$)):(Y.isub(T$),D$.isub(f))}var z$;return T$.cmpn(1)===0?z$=f:z$=D$,z$.cmpn(0)<0&&z$.iadd(E$),z$},$$.prototype.gcd=function(E$){if(this.isZero())return E$.abs();if(E$.isZero())return this.abs();var T$=this.clone(),Y=E$.clone();T$.negative=0,Y.negative=0;for(var f=0;T$.isEven()&&Y.isEven();f++)T$.iushrn(1),Y.iushrn(1);do{for(;T$.isEven();)T$.iushrn(1);for(;Y.isEven();)Y.iushrn(1);var D$=T$.cmp(Y);if(D$<0){var F0=T$;T$=Y,Y=F0}else if(D$===0||Y.cmpn(1)===0)break;T$.isub(Y)}while(!0);return Y.iushln(f)},$$.prototype.invm=function(E$){return this.egcd(E$).a.umod(E$)},$$.prototype.isEven=function(){return(this.words[0]&1)===0},$$.prototype.isOdd=function(){return(this.words[0]&1)===1},$$.prototype.andln=function(E$){return this.words[0]&E$},$$.prototype.bincn=function(E$){r0(typeof E$=="number");var T$=E$%26,Y=(E$-T$)/26,f=1<>>26,C$&=67108863,this.words[F0]=C$}return D$!==0&&(this.words[F0]=D$,this.length++),this},$$.prototype.isZero=function(){return this.length===1&&this.words[0]===0},$$.prototype.cmpn=function(E$){var T$=E$<0;if(this.negative!==0&&!T$)return-1;if(this.negative===0&&T$)return 1;this.strip();var Y;if(this.length>1)Y=1;else{T$&&(E$=-E$),r0(E$<=67108863,"Number is too big");var f=this.words[0]|0;Y=f===E$?0:fE$.length)return 1;if(this.length=0;Y--){var f=this.words[Y]|0,D$=E$.words[Y]|0;if(f!==D$){fD$&&(T$=1);break}}return T$},$$.prototype.gtn=function(E$){return this.cmpn(E$)===1},$$.prototype.gt=function(E$){return this.cmp(E$)===1},$$.prototype.gten=function(E$){return this.cmpn(E$)>=0},$$.prototype.gte=function(E$){return this.cmp(E$)>=0},$$.prototype.ltn=function(E$){return this.cmpn(E$)===-1},$$.prototype.lt=function(E$){return this.cmp(E$)===-1},$$.prototype.lten=function(E$){return this.cmpn(E$)<=0},$$.prototype.lte=function(E$){return this.cmp(E$)<=0},$$.prototype.eqn=function(E$){return this.cmpn(E$)===0},$$.prototype.eq=function(E$){return this.cmp(E$)===0},$$.red=function(E$){return new H$(E$)},$$.prototype.toRed=function(E$){return r0(!this.red,"Already a number in reduction context"),r0(this.negative===0,"red works only with positives"),E$.convertTo(this)._forceRed(E$)},$$.prototype.fromRed=function(){return r0(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},$$.prototype._forceRed=function(E$){return this.red=E$,this},$$.prototype.forceRed=function(E$){return r0(!this.red,"Already a number in reduction context"),this._forceRed(E$)},$$.prototype.redAdd=function(E$){return r0(this.red,"redAdd works only with red numbers"),this.red.add(this,E$)},$$.prototype.redIAdd=function(E$){return r0(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,E$)},$$.prototype.redSub=function(E$){return r0(this.red,"redSub works only with red numbers"),this.red.sub(this,E$)},$$.prototype.redISub=function(E$){return r0(this.red,"redISub works only with red numbers"),this.red.isub(this,E$)},$$.prototype.redShl=function(E$){return r0(this.red,"redShl works only with red numbers"),this.red.shl(this,E$)},$$.prototype.redMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.mul(this,E$)},$$.prototype.redIMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.imul(this,E$)},$$.prototype.redSqr=function(){return r0(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},$$.prototype.redISqr=function(){return r0(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},$$.prototype.redSqrt=function(){return r0(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},$$.prototype.redInvm=function(){return r0(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},$$.prototype.redNeg=function(){return r0(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},$$.prototype.redPow=function(E$){return r0(this.red&&!E$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,E$)};var x={k256:null,p224:null,p192:null,p25519:null};function O$(E$,T$){this.name=E$,this.p=new $$(T$,16),this.n=this.p.bitLength(),this.k=new $$(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}O$.prototype._tmp=function(){var E$=new $$(null);return E$.words=new Array(Math.ceil(this.n/13)),E$},O$.prototype.ireduce=function(E$){var T$=E$,Y;do this.split(T$,this.tmp),T$=this.imulK(T$),T$=T$.iadd(this.tmp),Y=T$.bitLength();while(Y>this.n);var f=Y0?T$.isub(this.p):T$.strip!==void 0?T$.strip():T$._strip(),T$},O$.prototype.split=function(E$,T$){E$.iushrn(this.n,0,T$)},O$.prototype.imulK=function(E$){return E$.imul(this.k)};function J0(){O$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i0(J0,O$),J0.prototype.split=function(E$,T$){for(var Y=4194303,f=Math.min(E$.length,9),D$=0;D$>>22,F0=C$}F0>>>=22,E$.words[D$-10]=F0,F0===0&&E$.length>10?E$.length-=10:E$.length-=9},J0.prototype.imulK=function(E$){E$.words[E$.length]=0,E$.words[E$.length+1]=0,E$.length+=2;for(var T$=0,Y=0;Y>>=26,E$.words[Y]=D$,T$=f}return T$!==0&&(E$.words[E$.length++]=T$),E$},$$._prime=function(E$){if(x[E$])return x[E$];var T$;if(E$==="k256")T$=new J0;else if(E$==="p224")T$=new J$;else if(E$==="p192")T$=new F$;else if(E$==="p25519")T$=new A$;else throw new Error("Unknown prime "+E$);return x[E$]=T$,T$};function H$(E$){if(typeof E$=="string"){var T$=$$._prime(E$);this.m=T$.p,this.prime=T$}else r0(E$.gtn(1),"modulus must be greater than 1"),this.m=E$,this.prime=null}H$.prototype._verify1=function(E$){r0(E$.negative===0,"red works only with positives"),r0(E$.red,"red works only with red numbers")},H$.prototype._verify2=function(E$,T$){r0((E$.negative|T$.negative)===0,"red works only with positives"),r0(E$.red&&E$.red===T$.red,"red works only with red numbers")},H$.prototype.imod=function(E$){return this.prime?this.prime.ireduce(E$)._forceRed(this):E$.umod(this.m)._forceRed(this)},H$.prototype.neg=function(E$){return E$.isZero()?E$.clone():this.m.sub(E$)._forceRed(this)},H$.prototype.add=function(E$,T$){this._verify2(E$,T$);var Y=E$.add(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y._forceRed(this)},H$.prototype.iadd=function(E$,T$){this._verify2(E$,T$);var Y=E$.iadd(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y},H$.prototype.sub=function(E$,T$){this._verify2(E$,T$);var Y=E$.sub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y._forceRed(this)},H$.prototype.isub=function(E$,T$){this._verify2(E$,T$);var Y=E$.isub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y},H$.prototype.shl=function(E$,T$){return this._verify1(E$),this.imod(E$.ushln(T$))},H$.prototype.imul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.imul(T$))},H$.prototype.mul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.mul(T$))},H$.prototype.isqr=function(E$){return this.imul(E$,E$.clone())},H$.prototype.sqr=function(E$){return this.mul(E$,E$)},H$.prototype.sqrt=function(E$){if(E$.isZero())return E$.clone();var T$=this.m.andln(3);if(r0(T$%2===1),T$===3){var Y=this.m.add(new $$(1)).iushrn(2);return this.pow(E$,Y)}for(var f=this.m.subn(1),D$=0;!f.isZero()&&f.andln(1)===0;)D$++,f.iushrn(1);r0(!f.isZero());var F0=new $$(1).toRed(this),C$=F0.redNeg(),L$=this.m.subn(1).iushrn(1),R$=this.m.bitLength();for(R$=new $$(2*R$*R$).toRed(this);this.pow(R$,L$).cmp(C$)!==0;)R$.redIAdd(C$);for(var P$=this.pow(R$,f),z$=this.pow(E$,f.addn(1).iushrn(1)),M$=this.pow(E$,f),S$=D$;M$.cmp(F0)!==0;){for(var Z=M$,c=0;Z.cmp(F0)!==0;c++)Z=Z.redSqr();r0(c=0;D$--){for(var P$=T$.words[D$],z$=R$-1;z$>=0;z$--){var M$=P$>>z$&1;if(F0!==f[0]&&(F0=this.sqr(F0)),M$===0&&C$===0){L$=0;continue}C$<<=1,C$|=M$,L$++,!(L$!==Y&&(D$!==0||z$!==0))&&(F0=this.mul(F0,f[C$]),L$=0,C$=0)}R$=26}return F0},H$.prototype.convertTo=function(E$){var T$=E$.umod(this.m);return T$===E$?T$.clone():T$},H$.prototype.convertFrom=function(E$){var T$=E$.clone();return T$.red=null,T$},$$.mont=function(E$){return new W$(E$)};function W$(E$){H$.call(this,E$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new $$(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)}i0(W$,H$),W$.prototype.convertTo=function(E$){return this.imod(E$.ushln(this.shift))},W$.prototype.convertFrom=function(E$){var T$=this.imod(E$.mul(this.rinv));return T$.red=null,T$},W$.prototype.imul=function(E$,T$){if(E$.isZero()||T$.isZero())return E$.words[0]=0,E$.length=1,E$;var Y=E$.imul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.mul=function(E$,T$){if(E$.isZero()||T$.isZero())return new $$(0)._forceRed(this);var Y=E$.mul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.invm=function(E$){var T$=this.imod(E$._invmp(this.m).mul(this.r2));return T$._forceRed(this)}})(typeof m0>"u"||m0,t0)}}),PY=pQ({"node_modules/miller-rabin/node_modules/bn.js/lib/bn.js"(t0,m0){(function(a0,e0){function r0(E$,T$){if(!E$)throw new Error(T$||"Assertion failed")}function i0(E$,T$){E$.super_=T$;var Y=function(){};Y.prototype=T$.prototype,E$.prototype=new Y,E$.prototype.constructor=E$}function $$(E$,T$,Y){if($$.isBN(E$))return E$;this.negative=0,this.words=null,this.length=0,this.red=null,E$!==null&&((T$==="le"||T$==="be")&&(Y=T$,T$=10),this._init(E$||0,T$||10,Y||"be"))}typeof a0=="object"?a0.exports=$$:e0.BN=$$,$$.BN=$$,$$.wordSize=26;var Q$=G0;$$.isBN=function(E$){return E$ instanceof $$?!0:E$!==null&&typeof E$=="object"&&E$.constructor.wordSize===$$.wordSize&&Array.isArray(E$.words)},$$.max=function(E$,T$){return E$.cmp(T$)>0?E$:T$},$$.min=function(E$,T$){return E$.cmp(T$)<0?E$:T$},$$.prototype._init=function(E$,T$,Y){if(typeof E$=="number")return this._initNumber(E$,T$,Y);if(typeof E$=="object")return this._initArray(E$,T$,Y);T$==="hex"&&(T$=16),r0(T$===(T$|0)&&T$>=2&&T$<=36),E$=E$.toString().replace(/\s+/g,"");var f=0;E$[0]==="-"&&(f++,this.negative=1),f=0;f-=3)F0=E$[f]|E$[f-1]<<8|E$[f-2]<<16,this.words[D$]|=F0<>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);else if(Y==="le")for(f=0,D$=0;f>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);return this.strip()};function $(E$,T$){var Y=E$.charCodeAt(T$);return Y>=65&&Y<=70?Y-55:Y>=97&&Y<=102?Y-87:Y-48&15}function N(E$,T$,Y){var f=$(E$,Y);return Y-1>=T$&&(f|=$(E$,Y-1)<<4),f}$$.prototype._parseHex=function(E$,T$,Y){this.length=Math.ceil((E$.length-T$)/6),this.words=new Array(this.length);for(var f=0;f=T$;f-=2)C$=N(E$,T$,f)<=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8;else{var L$=E$.length-T$;for(f=L$%2===0?T$+1:T$;f=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8}this.strip()};function Y$(E$,T$,Y,f){for(var D$=0,F0=Math.min(E$.length,Y),C$=T$;C$=49?D$+=L$-49+10:L$>=17?D$+=L$-17+10:D$+=L$}return D$}$$.prototype._parseBase=function(E$,T$,Y){this.words=[0],this.length=1;for(var f=0,D$=1;D$<=67108863;D$*=T$)f++;f--,D$=D$/T$|0;for(var F0=E$.length-Y,C$=F0%f,L$=Math.min(F0,F0-C$)+Y,R$=0,P$=Y;P$1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},$$.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},$$.prototype.inspect=function(){return(this.red?""};var O0=["","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"],Z$=[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],G$=[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];$$.prototype.toString=function(E$,T$){E$=E$||10,T$=T$|0||1;var Y;if(E$===16||E$==="hex"){Y="";for(var f=0,D$=0,F0=0;F0>>24-f&16777215,D$!==0||F0!==this.length-1?Y=O0[6-L$.length]+L$+Y:Y=L$+Y,f+=2,f>=26&&(f-=26,F0--)}for(D$!==0&&(Y=D$.toString(16)+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}if(E$===(E$|0)&&E$>=2&&E$<=36){var R$=Z$[E$],P$=G$[E$];Y="";var z$=this.clone();for(z$.negative=0;!z$.isZero();){var M$=z$.modn(P$).toString(E$);z$=z$.idivn(P$),z$.isZero()?Y=M$+Y:Y=O0[R$-M$.length]+M$+Y}for(this.isZero()&&(Y="0"+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}r0(!1,"Base should be between 2 and 36")},$$.prototype.toNumber=function(){var E$=this.words[0];return this.length===2?E$+=this.words[1]*67108864:this.length===3&&this.words[2]===1?E$+=4503599627370496+this.words[1]*67108864:this.length>2&&r0(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-E$:E$},$$.prototype.toJSON=function(){return this.toString(16)},$$.prototype.toBuffer=function(E$,T$){return r0(typeof Q$<"u"),this.toArrayLike(Q$,E$,T$)},$$.prototype.toArray=function(E$,T$){return this.toArrayLike(Array,E$,T$)},$$.prototype.toArrayLike=function(E$,T$,Y){var f=this.byteLength(),D$=Y||Math.max(1,f);r0(f<=D$,"byte array longer than desired length"),r0(D$>0,"Requested array length <= 0"),this.strip();var F0=T$==="le",C$=new E$(D$),L$,R$,P$=this.clone();if(F0){for(R$=0;!P$.isZero();R$++)L$=P$.andln(255),P$.iushrn(8),C$[R$]=L$;for(;R$=4096&&(Y+=13,T$>>>=13),T$>=64&&(Y+=7,T$>>>=7),T$>=8&&(Y+=4,T$>>>=4),T$>=2&&(Y+=2,T$>>>=2),Y+T$},$$.prototype._zeroBits=function(E$){if(E$===0)return 26;var T$=E$,Y=0;return(T$&8191)===0&&(Y+=13,T$>>>=13),(T$&127)===0&&(Y+=7,T$>>>=7),(T$&15)===0&&(Y+=4,T$>>>=4),(T$&3)===0&&(Y+=2,T$>>>=2),(T$&1)===0&&Y++,Y},$$.prototype.bitLength=function(){var E$=this.words[this.length-1],T$=this._countBits(E$);return(this.length-1)*26+T$};function V$(E$){for(var T$=new Array(E$.bitLength()),Y=0;Y>>D$}return T$}$$.prototype.zeroBits=function(){if(this.isZero())return 0;for(var E$=0,T$=0;T$E$.length?this.clone().ior(E$):E$.clone().ior(this)},$$.prototype.uor=function(E$){return this.length>E$.length?this.clone().iuor(E$):E$.clone().iuor(this)},$$.prototype.iuand=function(E$){var T$;this.length>E$.length?T$=E$:T$=this;for(var Y=0;YE$.length?this.clone().iand(E$):E$.clone().iand(this)},$$.prototype.uand=function(E$){return this.length>E$.length?this.clone().iuand(E$):E$.clone().iuand(this)},$$.prototype.iuxor=function(E$){var T$,Y;this.length>E$.length?(T$=this,Y=E$):(T$=E$,Y=this);for(var f=0;fE$.length?this.clone().ixor(E$):E$.clone().ixor(this)},$$.prototype.uxor=function(E$){return this.length>E$.length?this.clone().iuxor(E$):E$.clone().iuxor(this)},$$.prototype.inotn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=Math.ceil(E$/26)|0,Y=E$%26;this._expand(T$),Y>0&&T$--;for(var f=0;f0&&(this.words[f]=~this.words[f]&67108863>>26-Y),this.strip()},$$.prototype.notn=function(E$){return this.clone().inotn(E$)},$$.prototype.setn=function(E$,T$){r0(typeof E$=="number"&&E$>=0);var Y=E$/26|0,f=E$%26;return this._expand(Y+1),T$?this.words[Y]=this.words[Y]|1<E$.length?(Y=this,f=E$):(Y=E$,f=this);for(var D$=0,F0=0;F0>>26;for(;D$!==0&&F0>>26;if(this.length=Y.length,D$!==0)this.words[this.length]=D$,this.length++;else if(Y!==this)for(;F0E$.length?this.clone().iadd(E$):E$.clone().iadd(this)},$$.prototype.isub=function(E$){if(E$.negative!==0){E$.negative=0;var T$=this.iadd(E$);return E$.negative=1,T$._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(E$),this.negative=1,this._normSign();var Y=this.cmp(E$);if(Y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,D$;Y>0?(f=this,D$=E$):(f=E$,D$=this);for(var F0=0,C$=0;C$>26,this.words[C$]=T$&67108863;for(;F0!==0&&C$>26,this.words[C$]=T$&67108863;if(F0===0&&C$>>26,M$=R$&67108863,S$=Math.min(P$,T$.length-1),Z=Math.max(0,P$-E$.length+1);Z<=S$;Z++){var c=P$-Z|0;D$=E$.words[c]|0,F0=T$.words[Z]|0,C$=D$*F0+M$,z$+=C$/67108864|0,M$=C$&67108863}Y.words[P$]=M$|0,R$=z$|0}return R$!==0?Y.words[P$]=R$|0:Y.length--,Y.strip()}var X$=function(E$,T$,Y){var f=E$.words,D$=T$.words,F0=Y.words,C$=0,L$,R$,P$,z$=f[0]|0,M$=z$&8191,S$=z$>>>13,Z=f[1]|0,c=Z&8191,v$=Z>>>13,A0=f[2]|0,q$=A0&8191,j$=A0>>>13,k$=f[3]|0,g$=k$&8191,_$=k$>>>13,N$=f[4]|0,x$=N$&8191,G=N$>>>13,B=f[5]|0,B$=B&8191,H0=B>>>13,y$=f[6]|0,w$=y$&8191,p$=y$>>>13,f$=f[7]|0,c$=f$&8191,h$=f$>>>13,d$=f[8]|0,V=d$&8191,h=d$>>>13,W0=f[9]|0,E0=W0&8191,b$=W0>>>13,l$=D$[0]|0,o$=l$&8191,u$=l$>>>13,n$=D$[1]|0,s$=n$&8191,t$=n$>>>13,U=D$[2]|0,d=U&8191,m$=U>>>13,T0=D$[3]|0,a$=T0&8191,e$=T0>>>13,r$=D$[4]|0,i$=r$&8191,$Q=r$>>>13,QQ=D$[5]|0,YQ=QQ&8191,X=QQ>>>13,b=D$[6]|0,ZQ=b&8191,D0=b>>>13,GQ=D$[7]|0,VQ=GQ&8191,UQ=GQ>>>13,XQ=D$[8]|0,KQ=XQ&8191,IQ=XQ>>>13,OQ=D$[9]|0,K=OQ&8191,l=OQ>>>13;Y.negative=E$.negative^T$.negative,Y.length=19,L$=Math.imul(M$,o$),R$=Math.imul(M$,u$),R$=R$+Math.imul(S$,o$)|0,P$=Math.imul(S$,u$);var JQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(JQ>>>26)|0,JQ&=67108863,L$=Math.imul(c,o$),R$=Math.imul(c,u$),R$=R$+Math.imul(v$,o$)|0,P$=Math.imul(v$,u$),L$=L$+Math.imul(M$,s$)|0,R$=R$+Math.imul(M$,t$)|0,R$=R$+Math.imul(S$,s$)|0,P$=P$+Math.imul(S$,t$)|0;var C0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(C0>>>26)|0,C0&=67108863,L$=Math.imul(q$,o$),R$=Math.imul(q$,u$),R$=R$+Math.imul(j$,o$)|0,P$=Math.imul(j$,u$),L$=L$+Math.imul(c,s$)|0,R$=R$+Math.imul(c,t$)|0,R$=R$+Math.imul(v$,s$)|0,P$=P$+Math.imul(v$,t$)|0,L$=L$+Math.imul(M$,d)|0,R$=R$+Math.imul(M$,m$)|0,R$=R$+Math.imul(S$,d)|0,P$=P$+Math.imul(S$,m$)|0;var FQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(FQ>>>26)|0,FQ&=67108863,L$=Math.imul(g$,o$),R$=Math.imul(g$,u$),R$=R$+Math.imul(_$,o$)|0,P$=Math.imul(_$,u$),L$=L$+Math.imul(q$,s$)|0,R$=R$+Math.imul(q$,t$)|0,R$=R$+Math.imul(j$,s$)|0,P$=P$+Math.imul(j$,t$)|0,L$=L$+Math.imul(c,d)|0,R$=R$+Math.imul(c,m$)|0,R$=R$+Math.imul(v$,d)|0,P$=P$+Math.imul(v$,m$)|0,L$=L$+Math.imul(M$,a$)|0,R$=R$+Math.imul(M$,e$)|0,R$=R$+Math.imul(S$,a$)|0,P$=P$+Math.imul(S$,e$)|0;var AQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(AQ>>>26)|0,AQ&=67108863,L$=Math.imul(x$,o$),R$=Math.imul(x$,u$),R$=R$+Math.imul(G,o$)|0,P$=Math.imul(G,u$),L$=L$+Math.imul(g$,s$)|0,R$=R$+Math.imul(g$,t$)|0,R$=R$+Math.imul(_$,s$)|0,P$=P$+Math.imul(_$,t$)|0,L$=L$+Math.imul(q$,d)|0,R$=R$+Math.imul(q$,m$)|0,R$=R$+Math.imul(j$,d)|0,P$=P$+Math.imul(j$,m$)|0,L$=L$+Math.imul(c,a$)|0,R$=R$+Math.imul(c,e$)|0,R$=R$+Math.imul(v$,a$)|0,P$=P$+Math.imul(v$,e$)|0,L$=L$+Math.imul(M$,i$)|0,R$=R$+Math.imul(M$,$Q)|0,R$=R$+Math.imul(S$,i$)|0,P$=P$+Math.imul(S$,$Q)|0;var HQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(HQ>>>26)|0,HQ&=67108863,L$=Math.imul(B$,o$),R$=Math.imul(B$,u$),R$=R$+Math.imul(H0,o$)|0,P$=Math.imul(H0,u$),L$=L$+Math.imul(x$,s$)|0,R$=R$+Math.imul(x$,t$)|0,R$=R$+Math.imul(G,s$)|0,P$=P$+Math.imul(G,t$)|0,L$=L$+Math.imul(g$,d)|0,R$=R$+Math.imul(g$,m$)|0,R$=R$+Math.imul(_$,d)|0,P$=P$+Math.imul(_$,m$)|0,L$=L$+Math.imul(q$,a$)|0,R$=R$+Math.imul(q$,e$)|0,R$=R$+Math.imul(j$,a$)|0,P$=P$+Math.imul(j$,e$)|0,L$=L$+Math.imul(c,i$)|0,R$=R$+Math.imul(c,$Q)|0,R$=R$+Math.imul(v$,i$)|0,P$=P$+Math.imul(v$,$Q)|0,L$=L$+Math.imul(M$,YQ)|0,R$=R$+Math.imul(M$,X)|0,R$=R$+Math.imul(S$,YQ)|0,P$=P$+Math.imul(S$,X)|0;var WQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(WQ>>>26)|0,WQ&=67108863,L$=Math.imul(w$,o$),R$=Math.imul(w$,u$),R$=R$+Math.imul(p$,o$)|0,P$=Math.imul(p$,u$),L$=L$+Math.imul(B$,s$)|0,R$=R$+Math.imul(B$,t$)|0,R$=R$+Math.imul(H0,s$)|0,P$=P$+Math.imul(H0,t$)|0,L$=L$+Math.imul(x$,d)|0,R$=R$+Math.imul(x$,m$)|0,R$=R$+Math.imul(G,d)|0,P$=P$+Math.imul(G,m$)|0,L$=L$+Math.imul(g$,a$)|0,R$=R$+Math.imul(g$,e$)|0,R$=R$+Math.imul(_$,a$)|0,P$=P$+Math.imul(_$,e$)|0,L$=L$+Math.imul(q$,i$)|0,R$=R$+Math.imul(q$,$Q)|0,R$=R$+Math.imul(j$,i$)|0,P$=P$+Math.imul(j$,$Q)|0,L$=L$+Math.imul(c,YQ)|0,R$=R$+Math.imul(c,X)|0,R$=R$+Math.imul(v$,YQ)|0,P$=P$+Math.imul(v$,X)|0,L$=L$+Math.imul(M$,ZQ)|0,R$=R$+Math.imul(M$,D0)|0,R$=R$+Math.imul(S$,ZQ)|0,P$=P$+Math.imul(S$,D0)|0;var EQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(EQ>>>26)|0,EQ&=67108863,L$=Math.imul(c$,o$),R$=Math.imul(c$,u$),R$=R$+Math.imul(h$,o$)|0,P$=Math.imul(h$,u$),L$=L$+Math.imul(w$,s$)|0,R$=R$+Math.imul(w$,t$)|0,R$=R$+Math.imul(p$,s$)|0,P$=P$+Math.imul(p$,t$)|0,L$=L$+Math.imul(B$,d)|0,R$=R$+Math.imul(B$,m$)|0,R$=R$+Math.imul(H0,d)|0,P$=P$+Math.imul(H0,m$)|0,L$=L$+Math.imul(x$,a$)|0,R$=R$+Math.imul(x$,e$)|0,R$=R$+Math.imul(G,a$)|0,P$=P$+Math.imul(G,e$)|0,L$=L$+Math.imul(g$,i$)|0,R$=R$+Math.imul(g$,$Q)|0,R$=R$+Math.imul(_$,i$)|0,P$=P$+Math.imul(_$,$Q)|0,L$=L$+Math.imul(q$,YQ)|0,R$=R$+Math.imul(q$,X)|0,R$=R$+Math.imul(j$,YQ)|0,P$=P$+Math.imul(j$,X)|0,L$=L$+Math.imul(c,ZQ)|0,R$=R$+Math.imul(c,D0)|0,R$=R$+Math.imul(v$,ZQ)|0,P$=P$+Math.imul(v$,D0)|0,L$=L$+Math.imul(M$,VQ)|0,R$=R$+Math.imul(M$,UQ)|0,R$=R$+Math.imul(S$,VQ)|0,P$=P$+Math.imul(S$,UQ)|0;var TQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(TQ>>>26)|0,TQ&=67108863,L$=Math.imul(V,o$),R$=Math.imul(V,u$),R$=R$+Math.imul(h,o$)|0,P$=Math.imul(h,u$),L$=L$+Math.imul(c$,s$)|0,R$=R$+Math.imul(c$,t$)|0,R$=R$+Math.imul(h$,s$)|0,P$=P$+Math.imul(h$,t$)|0,L$=L$+Math.imul(w$,d)|0,R$=R$+Math.imul(w$,m$)|0,R$=R$+Math.imul(p$,d)|0,P$=P$+Math.imul(p$,m$)|0,L$=L$+Math.imul(B$,a$)|0,R$=R$+Math.imul(B$,e$)|0,R$=R$+Math.imul(H0,a$)|0,P$=P$+Math.imul(H0,e$)|0,L$=L$+Math.imul(x$,i$)|0,R$=R$+Math.imul(x$,$Q)|0,R$=R$+Math.imul(G,i$)|0,P$=P$+Math.imul(G,$Q)|0,L$=L$+Math.imul(g$,YQ)|0,R$=R$+Math.imul(g$,X)|0,R$=R$+Math.imul(_$,YQ)|0,P$=P$+Math.imul(_$,X)|0,L$=L$+Math.imul(q$,ZQ)|0,R$=R$+Math.imul(q$,D0)|0,R$=R$+Math.imul(j$,ZQ)|0,P$=P$+Math.imul(j$,D0)|0,L$=L$+Math.imul(c,VQ)|0,R$=R$+Math.imul(c,UQ)|0,R$=R$+Math.imul(v$,VQ)|0,P$=P$+Math.imul(v$,UQ)|0,L$=L$+Math.imul(M$,KQ)|0,R$=R$+Math.imul(M$,IQ)|0,R$=R$+Math.imul(S$,KQ)|0,P$=P$+Math.imul(S$,IQ)|0;var DQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(DQ>>>26)|0,DQ&=67108863,L$=Math.imul(E0,o$),R$=Math.imul(E0,u$),R$=R$+Math.imul(b$,o$)|0,P$=Math.imul(b$,u$),L$=L$+Math.imul(V,s$)|0,R$=R$+Math.imul(V,t$)|0,R$=R$+Math.imul(h,s$)|0,P$=P$+Math.imul(h,t$)|0,L$=L$+Math.imul(c$,d)|0,R$=R$+Math.imul(c$,m$)|0,R$=R$+Math.imul(h$,d)|0,P$=P$+Math.imul(h$,m$)|0,L$=L$+Math.imul(w$,a$)|0,R$=R$+Math.imul(w$,e$)|0,R$=R$+Math.imul(p$,a$)|0,P$=P$+Math.imul(p$,e$)|0,L$=L$+Math.imul(B$,i$)|0,R$=R$+Math.imul(B$,$Q)|0,R$=R$+Math.imul(H0,i$)|0,P$=P$+Math.imul(H0,$Q)|0,L$=L$+Math.imul(x$,YQ)|0,R$=R$+Math.imul(x$,X)|0,R$=R$+Math.imul(G,YQ)|0,P$=P$+Math.imul(G,X)|0,L$=L$+Math.imul(g$,ZQ)|0,R$=R$+Math.imul(g$,D0)|0,R$=R$+Math.imul(_$,ZQ)|0,P$=P$+Math.imul(_$,D0)|0,L$=L$+Math.imul(q$,VQ)|0,R$=R$+Math.imul(q$,UQ)|0,R$=R$+Math.imul(j$,VQ)|0,P$=P$+Math.imul(j$,UQ)|0,L$=L$+Math.imul(c,KQ)|0,R$=R$+Math.imul(c,IQ)|0,R$=R$+Math.imul(v$,KQ)|0,P$=P$+Math.imul(v$,IQ)|0,L$=L$+Math.imul(M$,K)|0,R$=R$+Math.imul(M$,l)|0,R$=R$+Math.imul(S$,K)|0,P$=P$+Math.imul(S$,l)|0;var I=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(I>>>26)|0,I&=67108863,L$=Math.imul(E0,s$),R$=Math.imul(E0,t$),R$=R$+Math.imul(b$,s$)|0,P$=Math.imul(b$,t$),L$=L$+Math.imul(V,d)|0,R$=R$+Math.imul(V,m$)|0,R$=R$+Math.imul(h,d)|0,P$=P$+Math.imul(h,m$)|0,L$=L$+Math.imul(c$,a$)|0,R$=R$+Math.imul(c$,e$)|0,R$=R$+Math.imul(h$,a$)|0,P$=P$+Math.imul(h$,e$)|0,L$=L$+Math.imul(w$,i$)|0,R$=R$+Math.imul(w$,$Q)|0,R$=R$+Math.imul(p$,i$)|0,P$=P$+Math.imul(p$,$Q)|0,L$=L$+Math.imul(B$,YQ)|0,R$=R$+Math.imul(B$,X)|0,R$=R$+Math.imul(H0,YQ)|0,P$=P$+Math.imul(H0,X)|0,L$=L$+Math.imul(x$,ZQ)|0,R$=R$+Math.imul(x$,D0)|0,R$=R$+Math.imul(G,ZQ)|0,P$=P$+Math.imul(G,D0)|0,L$=L$+Math.imul(g$,VQ)|0,R$=R$+Math.imul(g$,UQ)|0,R$=R$+Math.imul(_$,VQ)|0,P$=P$+Math.imul(_$,UQ)|0,L$=L$+Math.imul(q$,KQ)|0,R$=R$+Math.imul(q$,IQ)|0,R$=R$+Math.imul(j$,KQ)|0,P$=P$+Math.imul(j$,IQ)|0,L$=L$+Math.imul(c,K)|0,R$=R$+Math.imul(c,l)|0,R$=R$+Math.imul(v$,K)|0,P$=P$+Math.imul(v$,l)|0;var o=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(o>>>26)|0,o&=67108863,L$=Math.imul(E0,d),R$=Math.imul(E0,m$),R$=R$+Math.imul(b$,d)|0,P$=Math.imul(b$,m$),L$=L$+Math.imul(V,a$)|0,R$=R$+Math.imul(V,e$)|0,R$=R$+Math.imul(h,a$)|0,P$=P$+Math.imul(h,e$)|0,L$=L$+Math.imul(c$,i$)|0,R$=R$+Math.imul(c$,$Q)|0,R$=R$+Math.imul(h$,i$)|0,P$=P$+Math.imul(h$,$Q)|0,L$=L$+Math.imul(w$,YQ)|0,R$=R$+Math.imul(w$,X)|0,R$=R$+Math.imul(p$,YQ)|0,P$=P$+Math.imul(p$,X)|0,L$=L$+Math.imul(B$,ZQ)|0,R$=R$+Math.imul(B$,D0)|0,R$=R$+Math.imul(H0,ZQ)|0,P$=P$+Math.imul(H0,D0)|0,L$=L$+Math.imul(x$,VQ)|0,R$=R$+Math.imul(x$,UQ)|0,R$=R$+Math.imul(G,VQ)|0,P$=P$+Math.imul(G,UQ)|0,L$=L$+Math.imul(g$,KQ)|0,R$=R$+Math.imul(g$,IQ)|0,R$=R$+Math.imul(_$,KQ)|0,P$=P$+Math.imul(_$,IQ)|0,L$=L$+Math.imul(q$,K)|0,R$=R$+Math.imul(q$,l)|0,R$=R$+Math.imul(j$,K)|0,P$=P$+Math.imul(j$,l)|0;var CQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(CQ>>>26)|0,CQ&=67108863,L$=Math.imul(E0,a$),R$=Math.imul(E0,e$),R$=R$+Math.imul(b$,a$)|0,P$=Math.imul(b$,e$),L$=L$+Math.imul(V,i$)|0,R$=R$+Math.imul(V,$Q)|0,R$=R$+Math.imul(h,i$)|0,P$=P$+Math.imul(h,$Q)|0,L$=L$+Math.imul(c$,YQ)|0,R$=R$+Math.imul(c$,X)|0,R$=R$+Math.imul(h$,YQ)|0,P$=P$+Math.imul(h$,X)|0,L$=L$+Math.imul(w$,ZQ)|0,R$=R$+Math.imul(w$,D0)|0,R$=R$+Math.imul(p$,ZQ)|0,P$=P$+Math.imul(p$,D0)|0,L$=L$+Math.imul(B$,VQ)|0,R$=R$+Math.imul(B$,UQ)|0,R$=R$+Math.imul(H0,VQ)|0,P$=P$+Math.imul(H0,UQ)|0,L$=L$+Math.imul(x$,KQ)|0,R$=R$+Math.imul(x$,IQ)|0,R$=R$+Math.imul(G,KQ)|0,P$=P$+Math.imul(G,IQ)|0,L$=L$+Math.imul(g$,K)|0,R$=R$+Math.imul(g$,l)|0,R$=R$+Math.imul(_$,K)|0,P$=P$+Math.imul(_$,l)|0;var L0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(L0>>>26)|0,L0&=67108863,L$=Math.imul(E0,i$),R$=Math.imul(E0,$Q),R$=R$+Math.imul(b$,i$)|0,P$=Math.imul(b$,$Q),L$=L$+Math.imul(V,YQ)|0,R$=R$+Math.imul(V,X)|0,R$=R$+Math.imul(h,YQ)|0,P$=P$+Math.imul(h,X)|0,L$=L$+Math.imul(c$,ZQ)|0,R$=R$+Math.imul(c$,D0)|0,R$=R$+Math.imul(h$,ZQ)|0,P$=P$+Math.imul(h$,D0)|0,L$=L$+Math.imul(w$,VQ)|0,R$=R$+Math.imul(w$,UQ)|0,R$=R$+Math.imul(p$,VQ)|0,P$=P$+Math.imul(p$,UQ)|0,L$=L$+Math.imul(B$,KQ)|0,R$=R$+Math.imul(B$,IQ)|0,R$=R$+Math.imul(H0,KQ)|0,P$=P$+Math.imul(H0,IQ)|0,L$=L$+Math.imul(x$,K)|0,R$=R$+Math.imul(x$,l)|0,R$=R$+Math.imul(G,K)|0,P$=P$+Math.imul(G,l)|0;var LQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(LQ>>>26)|0,LQ&=67108863,L$=Math.imul(E0,YQ),R$=Math.imul(E0,X),R$=R$+Math.imul(b$,YQ)|0,P$=Math.imul(b$,X),L$=L$+Math.imul(V,ZQ)|0,R$=R$+Math.imul(V,D0)|0,R$=R$+Math.imul(h,ZQ)|0,P$=P$+Math.imul(h,D0)|0,L$=L$+Math.imul(c$,VQ)|0,R$=R$+Math.imul(c$,UQ)|0,R$=R$+Math.imul(h$,VQ)|0,P$=P$+Math.imul(h$,UQ)|0,L$=L$+Math.imul(w$,KQ)|0,R$=R$+Math.imul(w$,IQ)|0,R$=R$+Math.imul(p$,KQ)|0,P$=P$+Math.imul(p$,IQ)|0,L$=L$+Math.imul(B$,K)|0,R$=R$+Math.imul(B$,l)|0,R$=R$+Math.imul(H0,K)|0,P$=P$+Math.imul(H0,l)|0;var RQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(RQ>>>26)|0,RQ&=67108863,L$=Math.imul(E0,ZQ),R$=Math.imul(E0,D0),R$=R$+Math.imul(b$,ZQ)|0,P$=Math.imul(b$,D0),L$=L$+Math.imul(V,VQ)|0,R$=R$+Math.imul(V,UQ)|0,R$=R$+Math.imul(h,VQ)|0,P$=P$+Math.imul(h,UQ)|0,L$=L$+Math.imul(c$,KQ)|0,R$=R$+Math.imul(c$,IQ)|0,R$=R$+Math.imul(h$,KQ)|0,P$=P$+Math.imul(h$,IQ)|0,L$=L$+Math.imul(w$,K)|0,R$=R$+Math.imul(w$,l)|0,R$=R$+Math.imul(p$,K)|0,P$=P$+Math.imul(p$,l)|0;var PQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(PQ>>>26)|0,PQ&=67108863,L$=Math.imul(E0,VQ),R$=Math.imul(E0,UQ),R$=R$+Math.imul(b$,VQ)|0,P$=Math.imul(b$,UQ),L$=L$+Math.imul(V,KQ)|0,R$=R$+Math.imul(V,IQ)|0,R$=R$+Math.imul(h,KQ)|0,P$=P$+Math.imul(h,IQ)|0,L$=L$+Math.imul(c$,K)|0,R$=R$+Math.imul(c$,l)|0,R$=R$+Math.imul(h$,K)|0,P$=P$+Math.imul(h$,l)|0;var zQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(zQ>>>26)|0,zQ&=67108863,L$=Math.imul(E0,KQ),R$=Math.imul(E0,IQ),R$=R$+Math.imul(b$,KQ)|0,P$=Math.imul(b$,IQ),L$=L$+Math.imul(V,K)|0,R$=R$+Math.imul(V,l)|0,R$=R$+Math.imul(h,K)|0,P$=P$+Math.imul(h,l)|0;var MQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(MQ>>>26)|0,MQ&=67108863,L$=Math.imul(E0,K),R$=Math.imul(E0,l),R$=R$+Math.imul(b$,K)|0,P$=Math.imul(b$,l);var SQ=(C$+L$|0)+((R$&8191)<<13)|0;return C$=(P$+(R$>>>13)|0)+(SQ>>>26)|0,SQ&=67108863,F0[0]=JQ,F0[1]=C0,F0[2]=FQ,F0[3]=AQ,F0[4]=HQ,F0[5]=WQ,F0[6]=EQ,F0[7]=TQ,F0[8]=DQ,F0[9]=I,F0[10]=o,F0[11]=CQ,F0[12]=L0,F0[13]=LQ,F0[14]=RQ,F0[15]=PQ,F0[16]=zQ,F0[17]=MQ,F0[18]=SQ,C$!==0&&(F0[19]=C$,Y.length++),Y};Math.imul||(X$=U$);function K$(E$,T$,Y){Y.negative=T$.negative^E$.negative,Y.length=E$.length+T$.length;for(var f=0,D$=0,F0=0;F0>>26)|0,D$+=C$>>>26,C$&=67108863}Y.words[F0]=L$,f=C$,C$=D$}return f!==0?Y.words[F0]=f:Y.length--,Y.strip()}function I$(E$,T$,Y){var f=new Q;return f.mulp(E$,T$,Y)}$$.prototype.mulTo=function(E$,T$){var Y,f=this.length+E$.length;return this.length===10&&E$.length===10?Y=X$(this,E$,T$):f<63?Y=U$(this,E$,T$):f<1024?Y=K$(this,E$,T$):Y=I$(this,E$,T$),Y};function Q(E$,T$){this.x=E$,this.y=T$}Q.prototype.makeRBT=function(E$){for(var T$=new Array(E$),Y=$$.prototype._countBits(E$)-1,f=0;f>=1;return f},Q.prototype.permute=function(E$,T$,Y,f,D$,F0){for(var C$=0;C$>>1)D$++;return 1<>>13,Y[2*F0+1]=D$&8191,D$=D$>>>13;for(F0=2*T$;F0>=26,T$+=f/67108864|0,T$+=D$>>>26,this.words[Y]=D$&67108863}return T$!==0&&(this.words[Y]=T$,this.length++),this},$$.prototype.muln=function(E$){return this.clone().imuln(E$)},$$.prototype.sqr=function(){return this.mul(this)},$$.prototype.isqr=function(){return this.imul(this.clone())},$$.prototype.pow=function(E$){var T$=V$(E$);if(T$.length===0)return new $$(1);for(var Y=this,f=0;f=0);var T$=E$%26,Y=(E$-T$)/26,f=67108863>>>26-T$<<26-T$,D$;if(T$!==0){var F0=0;for(D$=0;D$>>26-T$}F0&&(this.words[D$]=F0,this.length++)}if(Y!==0){for(D$=this.length-1;D$>=0;D$--)this.words[D$+Y]=this.words[D$];for(D$=0;D$=0);var f;T$?f=(T$-T$%26)/26:f=0;var D$=E$%26,F0=Math.min((E$-D$)/26,this.length),C$=67108863^67108863>>>D$<F0)for(this.length-=F0,R$=0;R$=0&&(P$!==0||R$>=f);R$--){var z$=this.words[R$]|0;this.words[R$]=P$<<26-D$|z$>>>D$,P$=z$&C$}return L$&&P$!==0&&(L$.words[L$.length++]=P$),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},$$.prototype.ishrn=function(E$,T$,Y){return r0(this.negative===0),this.iushrn(E$,T$,Y)},$$.prototype.shln=function(E$){return this.clone().ishln(E$)},$$.prototype.ushln=function(E$){return this.clone().iushln(E$)},$$.prototype.shrn=function(E$){return this.clone().ishrn(E$)},$$.prototype.ushrn=function(E$){return this.clone().iushrn(E$)},$$.prototype.testn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=E$%26,Y=(E$-T$)/26,f=1<=0);var T$=E$%26,Y=(E$-T$)/26;if(r0(this.negative===0,"imaskn works only with positive numbers"),this.length<=Y)return this;if(T$!==0&&Y++,this.length=Math.min(Y,this.length),T$!==0){var f=67108863^67108863>>>T$<=67108864;T$++)this.words[T$]-=67108864,T$===this.length-1?this.words[T$+1]=1:this.words[T$+1]++;return this.length=Math.max(this.length,T$+1),this},$$.prototype.isubn=function(E$){if(r0(typeof E$=="number"),r0(E$<67108864),E$<0)return this.iaddn(-E$);if(this.negative!==0)return this.negative=0,this.iaddn(E$),this.negative=1,this;if(this.words[0]-=E$,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var T$=0;T$>26)-(L$/67108864|0),this.words[D$+Y]=F0&67108863}for(;D$>26,this.words[D$+Y]=F0&67108863;if(C$===0)return this.strip();for(r0(C$===-1),C$=0,D$=0;D$>26,this.words[D$]=F0&67108863;return this.negative=1,this.strip()},$$.prototype._wordDiv=function(E$,T$){var Y=this.length-E$.length,f=this.clone(),D$=E$,F0=D$.words[D$.length-1]|0,C$=this._countBits(F0);Y=26-C$,Y!==0&&(D$=D$.ushln(Y),f.iushln(Y),F0=D$.words[D$.length-1]|0);var L$=f.length-D$.length,R$;if(T$!=="mod"){R$=new $$(null),R$.length=L$+1,R$.words=new Array(R$.length);for(var P$=0;P$=0;M$--){var S$=(f.words[D$.length+M$]|0)*67108864+(f.words[D$.length+M$-1]|0);for(S$=Math.min(S$/F0|0,67108863),f._ishlnsubmul(D$,S$,M$);f.negative!==0;)S$--,f.negative=0,f._ishlnsubmul(D$,1,M$),f.isZero()||(f.negative^=1);R$&&(R$.words[M$]=S$)}return R$&&R$.strip(),f.strip(),T$!=="div"&&Y!==0&&f.iushrn(Y),{div:R$||null,mod:f}},$$.prototype.divmod=function(E$,T$,Y){if(r0(!E$.isZero()),this.isZero())return{div:new $$(0),mod:new $$(0)};var f,D$,F0;return this.negative!==0&&E$.negative===0?(F0=this.neg().divmod(E$,T$),T$!=="mod"&&(f=F0.div.neg()),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.iadd(E$)),{div:f,mod:D$}):this.negative===0&&E$.negative!==0?(F0=this.divmod(E$.neg(),T$),T$!=="mod"&&(f=F0.div.neg()),{div:f,mod:F0.mod}):(this.negative&E$.negative)!==0?(F0=this.neg().divmod(E$.neg(),T$),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.isub(E$)),{div:F0.div,mod:D$}):E$.length>this.length||this.cmp(E$)<0?{div:new $$(0),mod:this}:E$.length===1?T$==="div"?{div:this.divn(E$.words[0]),mod:null}:T$==="mod"?{div:null,mod:new $$(this.modn(E$.words[0]))}:{div:this.divn(E$.words[0]),mod:new $$(this.modn(E$.words[0]))}:this._wordDiv(E$,T$)},$$.prototype.div=function(E$){return this.divmod(E$,"div",!1).div},$$.prototype.mod=function(E$){return this.divmod(E$,"mod",!1).mod},$$.prototype.umod=function(E$){return this.divmod(E$,"mod",!0).mod},$$.prototype.divRound=function(E$){var T$=this.divmod(E$);if(T$.mod.isZero())return T$.div;var Y=T$.div.negative!==0?T$.mod.isub(E$):T$.mod,f=E$.ushrn(1),D$=E$.andln(1),F0=Y.cmp(f);return F0<0||D$===1&&F0===0?T$.div:T$.div.negative!==0?T$.div.isubn(1):T$.div.iaddn(1)},$$.prototype.modn=function(E$){r0(E$<=67108863);for(var T$=(1<<26)%E$,Y=0,f=this.length-1;f>=0;f--)Y=(T$*Y+(this.words[f]|0))%E$;return Y},$$.prototype.idivn=function(E$){r0(E$<=67108863);for(var T$=0,Y=this.length-1;Y>=0;Y--){var f=(this.words[Y]|0)+T$*67108864;this.words[Y]=f/E$|0,T$=f%E$}return this.strip()},$$.prototype.divn=function(E$){return this.clone().idivn(E$)},$$.prototype.egcd=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=new $$(0),C$=new $$(1),L$=0;T$.isEven()&&Y.isEven();)T$.iushrn(1),Y.iushrn(1),++L$;for(var R$=Y.clone(),P$=T$.clone();!T$.isZero();){for(var z$=0,M$=1;(T$.words[0]&M$)===0&&z$<26;++z$,M$<<=1);if(z$>0)for(T$.iushrn(z$);z$-- >0;)(f.isOdd()||D$.isOdd())&&(f.iadd(R$),D$.isub(P$)),f.iushrn(1),D$.iushrn(1);for(var S$=0,Z=1;(Y.words[0]&Z)===0&&S$<26;++S$,Z<<=1);if(S$>0)for(Y.iushrn(S$);S$-- >0;)(F0.isOdd()||C$.isOdd())&&(F0.iadd(R$),C$.isub(P$)),F0.iushrn(1),C$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(F0),D$.isub(C$)):(Y.isub(T$),F0.isub(f),C$.isub(D$))}return{a:F0,b:C$,gcd:Y.iushln(L$)}},$$.prototype._invmp=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=Y.clone();T$.cmpn(1)>0&&Y.cmpn(1)>0;){for(var C$=0,L$=1;(T$.words[0]&L$)===0&&C$<26;++C$,L$<<=1);if(C$>0)for(T$.iushrn(C$);C$-- >0;)f.isOdd()&&f.iadd(F0),f.iushrn(1);for(var R$=0,P$=1;(Y.words[0]&P$)===0&&R$<26;++R$,P$<<=1);if(R$>0)for(Y.iushrn(R$);R$-- >0;)D$.isOdd()&&D$.iadd(F0),D$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(D$)):(Y.isub(T$),D$.isub(f))}var z$;return T$.cmpn(1)===0?z$=f:z$=D$,z$.cmpn(0)<0&&z$.iadd(E$),z$},$$.prototype.gcd=function(E$){if(this.isZero())return E$.abs();if(E$.isZero())return this.abs();var T$=this.clone(),Y=E$.clone();T$.negative=0,Y.negative=0;for(var f=0;T$.isEven()&&Y.isEven();f++)T$.iushrn(1),Y.iushrn(1);do{for(;T$.isEven();)T$.iushrn(1);for(;Y.isEven();)Y.iushrn(1);var D$=T$.cmp(Y);if(D$<0){var F0=T$;T$=Y,Y=F0}else if(D$===0||Y.cmpn(1)===0)break;T$.isub(Y)}while(!0);return Y.iushln(f)},$$.prototype.invm=function(E$){return this.egcd(E$).a.umod(E$)},$$.prototype.isEven=function(){return(this.words[0]&1)===0},$$.prototype.isOdd=function(){return(this.words[0]&1)===1},$$.prototype.andln=function(E$){return this.words[0]&E$},$$.prototype.bincn=function(E$){r0(typeof E$=="number");var T$=E$%26,Y=(E$-T$)/26,f=1<>>26,C$&=67108863,this.words[F0]=C$}return D$!==0&&(this.words[F0]=D$,this.length++),this},$$.prototype.isZero=function(){return this.length===1&&this.words[0]===0},$$.prototype.cmpn=function(E$){var T$=E$<0;if(this.negative!==0&&!T$)return-1;if(this.negative===0&&T$)return 1;this.strip();var Y;if(this.length>1)Y=1;else{T$&&(E$=-E$),r0(E$<=67108863,"Number is too big");var f=this.words[0]|0;Y=f===E$?0:fE$.length)return 1;if(this.length=0;Y--){var f=this.words[Y]|0,D$=E$.words[Y]|0;if(f!==D$){fD$&&(T$=1);break}}return T$},$$.prototype.gtn=function(E$){return this.cmpn(E$)===1},$$.prototype.gt=function(E$){return this.cmp(E$)===1},$$.prototype.gten=function(E$){return this.cmpn(E$)>=0},$$.prototype.gte=function(E$){return this.cmp(E$)>=0},$$.prototype.ltn=function(E$){return this.cmpn(E$)===-1},$$.prototype.lt=function(E$){return this.cmp(E$)===-1},$$.prototype.lten=function(E$){return this.cmpn(E$)<=0},$$.prototype.lte=function(E$){return this.cmp(E$)<=0},$$.prototype.eqn=function(E$){return this.cmpn(E$)===0},$$.prototype.eq=function(E$){return this.cmp(E$)===0},$$.red=function(E$){return new H$(E$)},$$.prototype.toRed=function(E$){return r0(!this.red,"Already a number in reduction context"),r0(this.negative===0,"red works only with positives"),E$.convertTo(this)._forceRed(E$)},$$.prototype.fromRed=function(){return r0(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},$$.prototype._forceRed=function(E$){return this.red=E$,this},$$.prototype.forceRed=function(E$){return r0(!this.red,"Already a number in reduction context"),this._forceRed(E$)},$$.prototype.redAdd=function(E$){return r0(this.red,"redAdd works only with red numbers"),this.red.add(this,E$)},$$.prototype.redIAdd=function(E$){return r0(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,E$)},$$.prototype.redSub=function(E$){return r0(this.red,"redSub works only with red numbers"),this.red.sub(this,E$)},$$.prototype.redISub=function(E$){return r0(this.red,"redISub works only with red numbers"),this.red.isub(this,E$)},$$.prototype.redShl=function(E$){return r0(this.red,"redShl works only with red numbers"),this.red.shl(this,E$)},$$.prototype.redMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.mul(this,E$)},$$.prototype.redIMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.imul(this,E$)},$$.prototype.redSqr=function(){return r0(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},$$.prototype.redISqr=function(){return r0(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},$$.prototype.redSqrt=function(){return r0(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},$$.prototype.redInvm=function(){return r0(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},$$.prototype.redNeg=function(){return r0(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},$$.prototype.redPow=function(E$){return r0(this.red&&!E$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,E$)};var x={k256:null,p224:null,p192:null,p25519:null};function O$(E$,T$){this.name=E$,this.p=new $$(T$,16),this.n=this.p.bitLength(),this.k=new $$(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}O$.prototype._tmp=function(){var E$=new $$(null);return E$.words=new Array(Math.ceil(this.n/13)),E$},O$.prototype.ireduce=function(E$){var T$=E$,Y;do this.split(T$,this.tmp),T$=this.imulK(T$),T$=T$.iadd(this.tmp),Y=T$.bitLength();while(Y>this.n);var f=Y0?T$.isub(this.p):T$.strip!==void 0?T$.strip():T$._strip(),T$},O$.prototype.split=function(E$,T$){E$.iushrn(this.n,0,T$)},O$.prototype.imulK=function(E$){return E$.imul(this.k)};function J0(){O$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i0(J0,O$),J0.prototype.split=function(E$,T$){for(var Y=4194303,f=Math.min(E$.length,9),D$=0;D$>>22,F0=C$}F0>>>=22,E$.words[D$-10]=F0,F0===0&&E$.length>10?E$.length-=10:E$.length-=9},J0.prototype.imulK=function(E$){E$.words[E$.length]=0,E$.words[E$.length+1]=0,E$.length+=2;for(var T$=0,Y=0;Y>>=26,E$.words[Y]=D$,T$=f}return T$!==0&&(E$.words[E$.length++]=T$),E$},$$._prime=function(E$){if(x[E$])return x[E$];var T$;if(E$==="k256")T$=new J0;else if(E$==="p224")T$=new J$;else if(E$==="p192")T$=new F$;else if(E$==="p25519")T$=new A$;else throw new Error("Unknown prime "+E$);return x[E$]=T$,T$};function H$(E$){if(typeof E$=="string"){var T$=$$._prime(E$);this.m=T$.p,this.prime=T$}else r0(E$.gtn(1),"modulus must be greater than 1"),this.m=E$,this.prime=null}H$.prototype._verify1=function(E$){r0(E$.negative===0,"red works only with positives"),r0(E$.red,"red works only with red numbers")},H$.prototype._verify2=function(E$,T$){r0((E$.negative|T$.negative)===0,"red works only with positives"),r0(E$.red&&E$.red===T$.red,"red works only with red numbers")},H$.prototype.imod=function(E$){return this.prime?this.prime.ireduce(E$)._forceRed(this):E$.umod(this.m)._forceRed(this)},H$.prototype.neg=function(E$){return E$.isZero()?E$.clone():this.m.sub(E$)._forceRed(this)},H$.prototype.add=function(E$,T$){this._verify2(E$,T$);var Y=E$.add(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y._forceRed(this)},H$.prototype.iadd=function(E$,T$){this._verify2(E$,T$);var Y=E$.iadd(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y},H$.prototype.sub=function(E$,T$){this._verify2(E$,T$);var Y=E$.sub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y._forceRed(this)},H$.prototype.isub=function(E$,T$){this._verify2(E$,T$);var Y=E$.isub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y},H$.prototype.shl=function(E$,T$){return this._verify1(E$),this.imod(E$.ushln(T$))},H$.prototype.imul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.imul(T$))},H$.prototype.mul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.mul(T$))},H$.prototype.isqr=function(E$){return this.imul(E$,E$.clone())},H$.prototype.sqr=function(E$){return this.mul(E$,E$)},H$.prototype.sqrt=function(E$){if(E$.isZero())return E$.clone();var T$=this.m.andln(3);if(r0(T$%2===1),T$===3){var Y=this.m.add(new $$(1)).iushrn(2);return this.pow(E$,Y)}for(var f=this.m.subn(1),D$=0;!f.isZero()&&f.andln(1)===0;)D$++,f.iushrn(1);r0(!f.isZero());var F0=new $$(1).toRed(this),C$=F0.redNeg(),L$=this.m.subn(1).iushrn(1),R$=this.m.bitLength();for(R$=new $$(2*R$*R$).toRed(this);this.pow(R$,L$).cmp(C$)!==0;)R$.redIAdd(C$);for(var P$=this.pow(R$,f),z$=this.pow(E$,f.addn(1).iushrn(1)),M$=this.pow(E$,f),S$=D$;M$.cmp(F0)!==0;){for(var Z=M$,c=0;Z.cmp(F0)!==0;c++)Z=Z.redSqr();r0(c=0;D$--){for(var P$=T$.words[D$],z$=R$-1;z$>=0;z$--){var M$=P$>>z$&1;if(F0!==f[0]&&(F0=this.sqr(F0)),M$===0&&C$===0){L$=0;continue}C$<<=1,C$|=M$,L$++,!(L$!==Y&&(D$!==0||z$!==0))&&(F0=this.mul(F0,f[C$]),L$=0,C$=0)}R$=26}return F0},H$.prototype.convertTo=function(E$){var T$=E$.umod(this.m);return T$===E$?T$.clone():T$},H$.prototype.convertFrom=function(E$){var T$=E$.clone();return T$.red=null,T$},$$.mont=function(E$){return new W$(E$)};function W$(E$){H$.call(this,E$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new $$(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)}i0(W$,H$),W$.prototype.convertTo=function(E$){return this.imod(E$.ushln(this.shift))},W$.prototype.convertFrom=function(E$){var T$=this.imod(E$.mul(this.rinv));return T$.red=null,T$},W$.prototype.imul=function(E$,T$){if(E$.isZero()||T$.isZero())return E$.words[0]=0,E$.length=1,E$;var Y=E$.imul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.mul=function(E$,T$){if(E$.isZero()||T$.isZero())return new $$(0)._forceRed(this);var Y=E$.mul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.invm=function(E$){var T$=this.imod(E$._invmp(this.m).mul(this.r2));return T$._forceRed(this)}})(typeof m0>"u"||m0,t0)}}),zY=pQ({"(disabled):node_modules/crypto-browserify/index.js"(){}}),T=pQ({"node_modules/brorand/index.js"(t0,m0){var a0;m0.exports=function(r0){return a0||(a0=new e0(null)),a0.generate(r0)};function e0(r0){this.rand=r0}m0.exports.Rand=e0,e0.prototype.generate=function(r0){return this._rand(r0)},e0.prototype._rand=function(r0){var i0=new G0(r0);return qQ.getRandomValues(i0),i0}}}),t=pQ({"node_modules/miller-rabin/lib/mr.js"(t0,m0){var a0=PY(),e0=T();function r0(i0){this.rand=i0||new e0.Rand}m0.exports=r0,r0.create=function(i0){return new r0(i0)},r0.prototype._randbelow=function(i0){var $$=i0.bitLength(),Q$=Math.ceil($$/8);do var $=new a0(this.rand.generate(Q$));while($.cmp(i0)>=0);return $},r0.prototype._randrange=function(i0,$$){var Q$=$$.sub(i0);return i0.add(this._randbelow(Q$))},r0.prototype.test=function(i0,$$,Q$){var $=i0.bitLength(),N=a0.mont(i0),Y$=new a0(1).toRed(N);$$||($$=Math.max(1,$/48|0));for(var O0=i0.subn(1),Z$=0;!O0.testn(Z$);Z$++);for(var G$=i0.shrn(Z$),V$=O0.toRed(N),U$=!0;$$>0;$$--){var X$=this._randrange(new a0(2),O0);Q$&&Q$(X$);var K$=X$.toRed(N).redPow(G$);if(!(K$.cmp(Y$)===0||K$.cmp(V$)===0)){for(var I$=1;I$0;$$--){var V$=this._randrange(new a0(2),Y$),U$=i0.gcd(V$);if(U$.cmpn(1)!==0)return U$;var X$=V$.toRed($).redPow(Z$);if(!(X$.cmp(N)===0||X$.cmp(G$)===0)){for(var K$=1;K$J$;)A$.ishrn(1);if(A$.isEven()&&A$.iadd(Q$),A$.testn(1)||A$.iadd($),F$.cmp($)){if(!F$.cmp(N))for(;A$.mod(Z$).cmp(G$);)A$.iadd(X$)}else for(;A$.mod(r0).cmp(U$);)A$.iadd(X$);if(H$=A$.shrn(1),x(H$)&&x(A$)&&O$(H$)&&O$(A$)&&$$.test(H$)&&$$.test(A$))return A$}}}}),N0=pQ({"node_modules/diffie-hellman/lib/primes.json"(t0,m0){m0.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"}}}}),MY=pQ({"node_modules/diffie-hellman/lib/dh.js"(t0,m0){var a0=RY(),e0=t(),r0=new e0,i0=new a0(24),$$=new a0(11),Q$=new a0(10),$=new a0(3),N=new a0(7),Y$=_0(),O0=hQ();m0.exports=X$;function Z$(I$,Q){return Q=Q||"utf8",G0.isBuffer(I$)||(I$=new G0(I$,Q)),this._pub=new a0(I$),this}function G$(I$,Q){return Q=Q||"utf8",G0.isBuffer(I$)||(I$=new G0(I$,Q)),this._priv=new a0(I$),this}var V$={};function U$(I$,Q){var x=Q.toString("hex"),O$=[x,I$.toString(16)].join("_");if(O$ in V$)return V$[O$];var J0=0;if(I$.isEven()||!Y$.simpleSieve||!Y$.fermatTest(I$)||!r0.test(I$))return J0+=1,x==="02"||x==="05"?J0+=8:J0+=4,V$[O$]=J0,J0;r0.test(I$.shrn(1))||(J0+=2);var J$;switch(x){case"02":I$.mod(i0).cmp($$)&&(J0+=8);break;case"05":J$=I$.mod(Q$),J$.cmp($)&&J$.cmp(N)&&(J0+=8);break;default:J0+=4}return V$[O$]=J0,J0}function X$(I$,Q,x){this.setGenerator(Q),this.__prime=new a0(I$),this._prime=a0.mont(this.__prime),this._primeLen=I$.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,x?(this.setPublicKey=Z$,this.setPrivateKey=G$):this._primeCode=8}Object.defineProperty(X$.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=U$(this.__prime,this.__gen)),this._primeCode}}),X$.prototype.generateKeys=function(){return this._priv||(this._priv=new a0(O0(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},X$.prototype.computeSecret=function(I$){I$=new a0(I$),I$=I$.toRed(this._prime);var Q=I$.redPow(this._priv).fromRed(),x=new G0(Q.toArray()),O$=this.getPrime();if(x.length0?f:D$},$$.min=function(f,D$){return f.cmp(D$)<0?f:D$},$$.prototype._init=function(f,D$,F0){if(typeof f=="number")return this._initNumber(f,D$,F0);if(typeof f=="object")return this._initArray(f,D$,F0);D$==="hex"&&(D$=16),r0(D$===(D$|0)&&D$>=2&&D$<=36),f=f.toString().replace(/\s+/g,"");var C$=0;f[0]==="-"&&(C$++,this.negative=1),C$=0;C$-=3)R$=f[C$]|f[C$-1]<<8|f[C$-2]<<16,this.words[L$]|=R$<>>26-P$&67108863,P$+=24,P$>=26&&(P$-=26,L$++);else if(F0==="le")for(C$=0,L$=0;C$>>26-P$&67108863,P$+=24,P$>=26&&(P$-=26,L$++);return this._strip()};function $(f,D$){var F0=f.charCodeAt(D$);if(F0>=48&&F0<=57)return F0-48;if(F0>=65&&F0<=70)return F0-55;if(F0>=97&&F0<=102)return F0-87;r0(!1,"Invalid character in "+f)}function N(f,D$,F0){var C$=$(f,F0);return F0-1>=D$&&(C$|=$(f,F0-1)<<4),C$}$$.prototype._parseHex=function(f,D$,F0){this.length=Math.ceil((f.length-D$)/6),this.words=new Array(this.length);for(var C$=0;C$=D$;C$-=2)P$=N(f,D$,C$)<=18?(L$-=18,R$+=1,this.words[R$]|=P$>>>26):L$+=8;else{var z$=f.length-D$;for(C$=z$%2===0?D$+1:D$;C$=18?(L$-=18,R$+=1,this.words[R$]|=P$>>>26):L$+=8}this._strip()};function Y$(f,D$,F0,C$){for(var L$=0,R$=0,P$=Math.min(f.length,F0),z$=D$;z$=49?R$=M$-49+10:M$>=17?R$=M$-17+10:R$=M$,r0(M$>=0&&R$1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},$$.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{$$.prototype[Symbol.for("nodejs.util.inspect.custom")]=Z$}catch{$$.prototype.inspect=Z$}else $$.prototype.inspect=Z$;function Z$(){return(this.red?""}var G$=["","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"],V$=[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],U$=[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];$$.prototype.toString=function(f,D$){f=f||10,D$=D$|0||1;var F0;if(f===16||f==="hex"){F0="";for(var C$=0,L$=0,R$=0;R$>>24-C$&16777215,C$+=2,C$>=26&&(C$-=26,R$--),L$!==0||R$!==this.length-1?F0=G$[6-z$.length]+z$+F0:F0=z$+F0}for(L$!==0&&(F0=L$.toString(16)+F0);F0.length%D$!==0;)F0="0"+F0;return this.negative!==0&&(F0="-"+F0),F0}if(f===(f|0)&&f>=2&&f<=36){var M$=V$[f],S$=U$[f];F0="";var Z=this.clone();for(Z.negative=0;!Z.isZero();){var c=Z.modrn(S$).toString(f);Z=Z.idivn(S$),Z.isZero()?F0=c+F0:F0=G$[M$-c.length]+c+F0}for(this.isZero()&&(F0="0"+F0);F0.length%D$!==0;)F0="0"+F0;return this.negative!==0&&(F0="-"+F0),F0}r0(!1,"Base should be between 2 and 36")},$$.prototype.toNumber=function(){var f=this.words[0];return this.length===2?f+=this.words[1]*67108864:this.length===3&&this.words[2]===1?f+=4503599627370496+this.words[1]*67108864:this.length>2&&r0(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-f:f},$$.prototype.toJSON=function(){return this.toString(16,2)},Q$&&($$.prototype.toBuffer=function(f,D$){return this.toArrayLike(Q$,f,D$)}),$$.prototype.toArray=function(f,D$){return this.toArrayLike(Array,f,D$)};var X$=function(f,D$){return f.allocUnsafe?f.allocUnsafe(D$):new f(D$)};$$.prototype.toArrayLike=function(f,D$,F0){this._strip();var C$=this.byteLength(),L$=F0||Math.max(1,C$);r0(C$<=L$,"byte array longer than desired length"),r0(L$>0,"Requested array length <= 0");var R$=X$(f,L$),P$=D$==="le"?"LE":"BE";return this["_toArrayLike"+P$](R$,C$),R$},$$.prototype._toArrayLikeLE=function(f,D$){for(var F0=0,C$=0,L$=0,R$=0;L$>8&255),F0>16&255),R$===6?(F0>24&255),C$=0,R$=0):(C$=P$>>>24,R$+=2)}if(F0=0&&(f[F0--]=P$>>8&255),F0>=0&&(f[F0--]=P$>>16&255),R$===6?(F0>=0&&(f[F0--]=P$>>24&255),C$=0,R$=0):(C$=P$>>>24,R$+=2)}if(F0>=0)for(f[F0--]=C$;F0>=0;)f[F0--]=0},Math.clz32?$$.prototype._countBits=function(f){return 32-Math.clz32(f)}:$$.prototype._countBits=function(f){var D$=f,F0=0;return D$>=4096&&(F0+=13,D$>>>=13),D$>=64&&(F0+=7,D$>>>=7),D$>=8&&(F0+=4,D$>>>=4),D$>=2&&(F0+=2,D$>>>=2),F0+D$},$$.prototype._zeroBits=function(f){if(f===0)return 26;var D$=f,F0=0;return(D$&8191)===0&&(F0+=13,D$>>>=13),(D$&127)===0&&(F0+=7,D$>>>=7),(D$&15)===0&&(F0+=4,D$>>>=4),(D$&3)===0&&(F0+=2,D$>>>=2),(D$&1)===0&&F0++,F0},$$.prototype.bitLength=function(){var f=this.words[this.length-1],D$=this._countBits(f);return(this.length-1)*26+D$};function K$(f){for(var D$=new Array(f.bitLength()),F0=0;F0>>L$&1}return D$}$$.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,D$=0;D$f.length?this.clone().ior(f):f.clone().ior(this)},$$.prototype.uor=function(f){return this.length>f.length?this.clone().iuor(f):f.clone().iuor(this)},$$.prototype.iuand=function(f){var D$;this.length>f.length?D$=f:D$=this;for(var F0=0;F0f.length?this.clone().iand(f):f.clone().iand(this)},$$.prototype.uand=function(f){return this.length>f.length?this.clone().iuand(f):f.clone().iuand(this)},$$.prototype.iuxor=function(f){var D$,F0;this.length>f.length?(D$=this,F0=f):(D$=f,F0=this);for(var C$=0;C$f.length?this.clone().ixor(f):f.clone().ixor(this)},$$.prototype.uxor=function(f){return this.length>f.length?this.clone().iuxor(f):f.clone().iuxor(this)},$$.prototype.inotn=function(f){r0(typeof f=="number"&&f>=0);var D$=Math.ceil(f/26)|0,F0=f%26;this._expand(D$),F0>0&&D$--;for(var C$=0;C$0&&(this.words[C$]=~this.words[C$]&67108863>>26-F0),this._strip()},$$.prototype.notn=function(f){return this.clone().inotn(f)},$$.prototype.setn=function(f,D$){r0(typeof f=="number"&&f>=0);var F0=f/26|0,C$=f%26;return this._expand(F0+1),D$?this.words[F0]=this.words[F0]|1<f.length?(F0=this,C$=f):(F0=f,C$=this);for(var L$=0,R$=0;R$>>26;for(;L$!==0&&R$>>26;if(this.length=F0.length,L$!==0)this.words[this.length]=L$,this.length++;else if(F0!==this)for(;R$f.length?this.clone().iadd(f):f.clone().iadd(this)},$$.prototype.isub=function(f){if(f.negative!==0){f.negative=0;var D$=this.iadd(f);return f.negative=1,D$._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(f),this.negative=1,this._normSign();var F0=this.cmp(f);if(F0===0)return this.negative=0,this.length=1,this.words[0]=0,this;var C$,L$;F0>0?(C$=this,L$=f):(C$=f,L$=this);for(var R$=0,P$=0;P$>26,this.words[P$]=D$&67108863;for(;R$!==0&&P$>26,this.words[P$]=D$&67108863;if(R$===0&&P$>>26,c=M$&67108863,v$=Math.min(S$,D$.length-1),A0=Math.max(0,S$-f.length+1);A0<=v$;A0++){var q$=S$-A0|0;L$=f.words[q$]|0,R$=D$.words[A0]|0,P$=L$*R$+c,Z+=P$/67108864|0,c=P$&67108863}F0.words[S$]=c|0,M$=Z|0}return M$!==0?F0.words[S$]=M$|0:F0.length--,F0._strip()}var Q=function(f,D$,F0){var C$=f.words,L$=D$.words,R$=F0.words,P$=0,z$,M$,S$,Z=C$[0]|0,c=Z&8191,v$=Z>>>13,A0=C$[1]|0,q$=A0&8191,j$=A0>>>13,k$=C$[2]|0,g$=k$&8191,_$=k$>>>13,N$=C$[3]|0,x$=N$&8191,G=N$>>>13,B=C$[4]|0,B$=B&8191,H0=B>>>13,y$=C$[5]|0,w$=y$&8191,p$=y$>>>13,f$=C$[6]|0,c$=f$&8191,h$=f$>>>13,d$=C$[7]|0,V=d$&8191,h=d$>>>13,W0=C$[8]|0,E0=W0&8191,b$=W0>>>13,l$=C$[9]|0,o$=l$&8191,u$=l$>>>13,n$=L$[0]|0,s$=n$&8191,t$=n$>>>13,U=L$[1]|0,d=U&8191,m$=U>>>13,T0=L$[2]|0,a$=T0&8191,e$=T0>>>13,r$=L$[3]|0,i$=r$&8191,$Q=r$>>>13,QQ=L$[4]|0,YQ=QQ&8191,X=QQ>>>13,b=L$[5]|0,ZQ=b&8191,D0=b>>>13,GQ=L$[6]|0,VQ=GQ&8191,UQ=GQ>>>13,XQ=L$[7]|0,KQ=XQ&8191,IQ=XQ>>>13,OQ=L$[8]|0,K=OQ&8191,l=OQ>>>13,JQ=L$[9]|0,C0=JQ&8191,FQ=JQ>>>13;F0.negative=f.negative^D$.negative,F0.length=19,z$=Math.imul(c,s$),M$=Math.imul(c,t$),M$=M$+Math.imul(v$,s$)|0,S$=Math.imul(v$,t$);var AQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(AQ>>>26)|0,AQ&=67108863,z$=Math.imul(q$,s$),M$=Math.imul(q$,t$),M$=M$+Math.imul(j$,s$)|0,S$=Math.imul(j$,t$),z$=z$+Math.imul(c,d)|0,M$=M$+Math.imul(c,m$)|0,M$=M$+Math.imul(v$,d)|0,S$=S$+Math.imul(v$,m$)|0;var HQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(HQ>>>26)|0,HQ&=67108863,z$=Math.imul(g$,s$),M$=Math.imul(g$,t$),M$=M$+Math.imul(_$,s$)|0,S$=Math.imul(_$,t$),z$=z$+Math.imul(q$,d)|0,M$=M$+Math.imul(q$,m$)|0,M$=M$+Math.imul(j$,d)|0,S$=S$+Math.imul(j$,m$)|0,z$=z$+Math.imul(c,a$)|0,M$=M$+Math.imul(c,e$)|0,M$=M$+Math.imul(v$,a$)|0,S$=S$+Math.imul(v$,e$)|0;var WQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(WQ>>>26)|0,WQ&=67108863,z$=Math.imul(x$,s$),M$=Math.imul(x$,t$),M$=M$+Math.imul(G,s$)|0,S$=Math.imul(G,t$),z$=z$+Math.imul(g$,d)|0,M$=M$+Math.imul(g$,m$)|0,M$=M$+Math.imul(_$,d)|0,S$=S$+Math.imul(_$,m$)|0,z$=z$+Math.imul(q$,a$)|0,M$=M$+Math.imul(q$,e$)|0,M$=M$+Math.imul(j$,a$)|0,S$=S$+Math.imul(j$,e$)|0,z$=z$+Math.imul(c,i$)|0,M$=M$+Math.imul(c,$Q)|0,M$=M$+Math.imul(v$,i$)|0,S$=S$+Math.imul(v$,$Q)|0;var EQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(EQ>>>26)|0,EQ&=67108863,z$=Math.imul(B$,s$),M$=Math.imul(B$,t$),M$=M$+Math.imul(H0,s$)|0,S$=Math.imul(H0,t$),z$=z$+Math.imul(x$,d)|0,M$=M$+Math.imul(x$,m$)|0,M$=M$+Math.imul(G,d)|0,S$=S$+Math.imul(G,m$)|0,z$=z$+Math.imul(g$,a$)|0,M$=M$+Math.imul(g$,e$)|0,M$=M$+Math.imul(_$,a$)|0,S$=S$+Math.imul(_$,e$)|0,z$=z$+Math.imul(q$,i$)|0,M$=M$+Math.imul(q$,$Q)|0,M$=M$+Math.imul(j$,i$)|0,S$=S$+Math.imul(j$,$Q)|0,z$=z$+Math.imul(c,YQ)|0,M$=M$+Math.imul(c,X)|0,M$=M$+Math.imul(v$,YQ)|0,S$=S$+Math.imul(v$,X)|0;var TQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(TQ>>>26)|0,TQ&=67108863,z$=Math.imul(w$,s$),M$=Math.imul(w$,t$),M$=M$+Math.imul(p$,s$)|0,S$=Math.imul(p$,t$),z$=z$+Math.imul(B$,d)|0,M$=M$+Math.imul(B$,m$)|0,M$=M$+Math.imul(H0,d)|0,S$=S$+Math.imul(H0,m$)|0,z$=z$+Math.imul(x$,a$)|0,M$=M$+Math.imul(x$,e$)|0,M$=M$+Math.imul(G,a$)|0,S$=S$+Math.imul(G,e$)|0,z$=z$+Math.imul(g$,i$)|0,M$=M$+Math.imul(g$,$Q)|0,M$=M$+Math.imul(_$,i$)|0,S$=S$+Math.imul(_$,$Q)|0,z$=z$+Math.imul(q$,YQ)|0,M$=M$+Math.imul(q$,X)|0,M$=M$+Math.imul(j$,YQ)|0,S$=S$+Math.imul(j$,X)|0,z$=z$+Math.imul(c,ZQ)|0,M$=M$+Math.imul(c,D0)|0,M$=M$+Math.imul(v$,ZQ)|0,S$=S$+Math.imul(v$,D0)|0;var DQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(DQ>>>26)|0,DQ&=67108863,z$=Math.imul(c$,s$),M$=Math.imul(c$,t$),M$=M$+Math.imul(h$,s$)|0,S$=Math.imul(h$,t$),z$=z$+Math.imul(w$,d)|0,M$=M$+Math.imul(w$,m$)|0,M$=M$+Math.imul(p$,d)|0,S$=S$+Math.imul(p$,m$)|0,z$=z$+Math.imul(B$,a$)|0,M$=M$+Math.imul(B$,e$)|0,M$=M$+Math.imul(H0,a$)|0,S$=S$+Math.imul(H0,e$)|0,z$=z$+Math.imul(x$,i$)|0,M$=M$+Math.imul(x$,$Q)|0,M$=M$+Math.imul(G,i$)|0,S$=S$+Math.imul(G,$Q)|0,z$=z$+Math.imul(g$,YQ)|0,M$=M$+Math.imul(g$,X)|0,M$=M$+Math.imul(_$,YQ)|0,S$=S$+Math.imul(_$,X)|0,z$=z$+Math.imul(q$,ZQ)|0,M$=M$+Math.imul(q$,D0)|0,M$=M$+Math.imul(j$,ZQ)|0,S$=S$+Math.imul(j$,D0)|0,z$=z$+Math.imul(c,VQ)|0,M$=M$+Math.imul(c,UQ)|0,M$=M$+Math.imul(v$,VQ)|0,S$=S$+Math.imul(v$,UQ)|0;var I=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(I>>>26)|0,I&=67108863,z$=Math.imul(V,s$),M$=Math.imul(V,t$),M$=M$+Math.imul(h,s$)|0,S$=Math.imul(h,t$),z$=z$+Math.imul(c$,d)|0,M$=M$+Math.imul(c$,m$)|0,M$=M$+Math.imul(h$,d)|0,S$=S$+Math.imul(h$,m$)|0,z$=z$+Math.imul(w$,a$)|0,M$=M$+Math.imul(w$,e$)|0,M$=M$+Math.imul(p$,a$)|0,S$=S$+Math.imul(p$,e$)|0,z$=z$+Math.imul(B$,i$)|0,M$=M$+Math.imul(B$,$Q)|0,M$=M$+Math.imul(H0,i$)|0,S$=S$+Math.imul(H0,$Q)|0,z$=z$+Math.imul(x$,YQ)|0,M$=M$+Math.imul(x$,X)|0,M$=M$+Math.imul(G,YQ)|0,S$=S$+Math.imul(G,X)|0,z$=z$+Math.imul(g$,ZQ)|0,M$=M$+Math.imul(g$,D0)|0,M$=M$+Math.imul(_$,ZQ)|0,S$=S$+Math.imul(_$,D0)|0,z$=z$+Math.imul(q$,VQ)|0,M$=M$+Math.imul(q$,UQ)|0,M$=M$+Math.imul(j$,VQ)|0,S$=S$+Math.imul(j$,UQ)|0,z$=z$+Math.imul(c,KQ)|0,M$=M$+Math.imul(c,IQ)|0,M$=M$+Math.imul(v$,KQ)|0,S$=S$+Math.imul(v$,IQ)|0;var o=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(o>>>26)|0,o&=67108863,z$=Math.imul(E0,s$),M$=Math.imul(E0,t$),M$=M$+Math.imul(b$,s$)|0,S$=Math.imul(b$,t$),z$=z$+Math.imul(V,d)|0,M$=M$+Math.imul(V,m$)|0,M$=M$+Math.imul(h,d)|0,S$=S$+Math.imul(h,m$)|0,z$=z$+Math.imul(c$,a$)|0,M$=M$+Math.imul(c$,e$)|0,M$=M$+Math.imul(h$,a$)|0,S$=S$+Math.imul(h$,e$)|0,z$=z$+Math.imul(w$,i$)|0,M$=M$+Math.imul(w$,$Q)|0,M$=M$+Math.imul(p$,i$)|0,S$=S$+Math.imul(p$,$Q)|0,z$=z$+Math.imul(B$,YQ)|0,M$=M$+Math.imul(B$,X)|0,M$=M$+Math.imul(H0,YQ)|0,S$=S$+Math.imul(H0,X)|0,z$=z$+Math.imul(x$,ZQ)|0,M$=M$+Math.imul(x$,D0)|0,M$=M$+Math.imul(G,ZQ)|0,S$=S$+Math.imul(G,D0)|0,z$=z$+Math.imul(g$,VQ)|0,M$=M$+Math.imul(g$,UQ)|0,M$=M$+Math.imul(_$,VQ)|0,S$=S$+Math.imul(_$,UQ)|0,z$=z$+Math.imul(q$,KQ)|0,M$=M$+Math.imul(q$,IQ)|0,M$=M$+Math.imul(j$,KQ)|0,S$=S$+Math.imul(j$,IQ)|0,z$=z$+Math.imul(c,K)|0,M$=M$+Math.imul(c,l)|0,M$=M$+Math.imul(v$,K)|0,S$=S$+Math.imul(v$,l)|0;var CQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(CQ>>>26)|0,CQ&=67108863,z$=Math.imul(o$,s$),M$=Math.imul(o$,t$),M$=M$+Math.imul(u$,s$)|0,S$=Math.imul(u$,t$),z$=z$+Math.imul(E0,d)|0,M$=M$+Math.imul(E0,m$)|0,M$=M$+Math.imul(b$,d)|0,S$=S$+Math.imul(b$,m$)|0,z$=z$+Math.imul(V,a$)|0,M$=M$+Math.imul(V,e$)|0,M$=M$+Math.imul(h,a$)|0,S$=S$+Math.imul(h,e$)|0,z$=z$+Math.imul(c$,i$)|0,M$=M$+Math.imul(c$,$Q)|0,M$=M$+Math.imul(h$,i$)|0,S$=S$+Math.imul(h$,$Q)|0,z$=z$+Math.imul(w$,YQ)|0,M$=M$+Math.imul(w$,X)|0,M$=M$+Math.imul(p$,YQ)|0,S$=S$+Math.imul(p$,X)|0,z$=z$+Math.imul(B$,ZQ)|0,M$=M$+Math.imul(B$,D0)|0,M$=M$+Math.imul(H0,ZQ)|0,S$=S$+Math.imul(H0,D0)|0,z$=z$+Math.imul(x$,VQ)|0,M$=M$+Math.imul(x$,UQ)|0,M$=M$+Math.imul(G,VQ)|0,S$=S$+Math.imul(G,UQ)|0,z$=z$+Math.imul(g$,KQ)|0,M$=M$+Math.imul(g$,IQ)|0,M$=M$+Math.imul(_$,KQ)|0,S$=S$+Math.imul(_$,IQ)|0,z$=z$+Math.imul(q$,K)|0,M$=M$+Math.imul(q$,l)|0,M$=M$+Math.imul(j$,K)|0,S$=S$+Math.imul(j$,l)|0,z$=z$+Math.imul(c,C0)|0,M$=M$+Math.imul(c,FQ)|0,M$=M$+Math.imul(v$,C0)|0,S$=S$+Math.imul(v$,FQ)|0;var L0=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(L0>>>26)|0,L0&=67108863,z$=Math.imul(o$,d),M$=Math.imul(o$,m$),M$=M$+Math.imul(u$,d)|0,S$=Math.imul(u$,m$),z$=z$+Math.imul(E0,a$)|0,M$=M$+Math.imul(E0,e$)|0,M$=M$+Math.imul(b$,a$)|0,S$=S$+Math.imul(b$,e$)|0,z$=z$+Math.imul(V,i$)|0,M$=M$+Math.imul(V,$Q)|0,M$=M$+Math.imul(h,i$)|0,S$=S$+Math.imul(h,$Q)|0,z$=z$+Math.imul(c$,YQ)|0,M$=M$+Math.imul(c$,X)|0,M$=M$+Math.imul(h$,YQ)|0,S$=S$+Math.imul(h$,X)|0,z$=z$+Math.imul(w$,ZQ)|0,M$=M$+Math.imul(w$,D0)|0,M$=M$+Math.imul(p$,ZQ)|0,S$=S$+Math.imul(p$,D0)|0,z$=z$+Math.imul(B$,VQ)|0,M$=M$+Math.imul(B$,UQ)|0,M$=M$+Math.imul(H0,VQ)|0,S$=S$+Math.imul(H0,UQ)|0,z$=z$+Math.imul(x$,KQ)|0,M$=M$+Math.imul(x$,IQ)|0,M$=M$+Math.imul(G,KQ)|0,S$=S$+Math.imul(G,IQ)|0,z$=z$+Math.imul(g$,K)|0,M$=M$+Math.imul(g$,l)|0,M$=M$+Math.imul(_$,K)|0,S$=S$+Math.imul(_$,l)|0,z$=z$+Math.imul(q$,C0)|0,M$=M$+Math.imul(q$,FQ)|0,M$=M$+Math.imul(j$,C0)|0,S$=S$+Math.imul(j$,FQ)|0;var LQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(LQ>>>26)|0,LQ&=67108863,z$=Math.imul(o$,a$),M$=Math.imul(o$,e$),M$=M$+Math.imul(u$,a$)|0,S$=Math.imul(u$,e$),z$=z$+Math.imul(E0,i$)|0,M$=M$+Math.imul(E0,$Q)|0,M$=M$+Math.imul(b$,i$)|0,S$=S$+Math.imul(b$,$Q)|0,z$=z$+Math.imul(V,YQ)|0,M$=M$+Math.imul(V,X)|0,M$=M$+Math.imul(h,YQ)|0,S$=S$+Math.imul(h,X)|0,z$=z$+Math.imul(c$,ZQ)|0,M$=M$+Math.imul(c$,D0)|0,M$=M$+Math.imul(h$,ZQ)|0,S$=S$+Math.imul(h$,D0)|0,z$=z$+Math.imul(w$,VQ)|0,M$=M$+Math.imul(w$,UQ)|0,M$=M$+Math.imul(p$,VQ)|0,S$=S$+Math.imul(p$,UQ)|0,z$=z$+Math.imul(B$,KQ)|0,M$=M$+Math.imul(B$,IQ)|0,M$=M$+Math.imul(H0,KQ)|0,S$=S$+Math.imul(H0,IQ)|0,z$=z$+Math.imul(x$,K)|0,M$=M$+Math.imul(x$,l)|0,M$=M$+Math.imul(G,K)|0,S$=S$+Math.imul(G,l)|0,z$=z$+Math.imul(g$,C0)|0,M$=M$+Math.imul(g$,FQ)|0,M$=M$+Math.imul(_$,C0)|0,S$=S$+Math.imul(_$,FQ)|0;var RQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(RQ>>>26)|0,RQ&=67108863,z$=Math.imul(o$,i$),M$=Math.imul(o$,$Q),M$=M$+Math.imul(u$,i$)|0,S$=Math.imul(u$,$Q),z$=z$+Math.imul(E0,YQ)|0,M$=M$+Math.imul(E0,X)|0,M$=M$+Math.imul(b$,YQ)|0,S$=S$+Math.imul(b$,X)|0,z$=z$+Math.imul(V,ZQ)|0,M$=M$+Math.imul(V,D0)|0,M$=M$+Math.imul(h,ZQ)|0,S$=S$+Math.imul(h,D0)|0,z$=z$+Math.imul(c$,VQ)|0,M$=M$+Math.imul(c$,UQ)|0,M$=M$+Math.imul(h$,VQ)|0,S$=S$+Math.imul(h$,UQ)|0,z$=z$+Math.imul(w$,KQ)|0,M$=M$+Math.imul(w$,IQ)|0,M$=M$+Math.imul(p$,KQ)|0,S$=S$+Math.imul(p$,IQ)|0,z$=z$+Math.imul(B$,K)|0,M$=M$+Math.imul(B$,l)|0,M$=M$+Math.imul(H0,K)|0,S$=S$+Math.imul(H0,l)|0,z$=z$+Math.imul(x$,C0)|0,M$=M$+Math.imul(x$,FQ)|0,M$=M$+Math.imul(G,C0)|0,S$=S$+Math.imul(G,FQ)|0;var PQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(PQ>>>26)|0,PQ&=67108863,z$=Math.imul(o$,YQ),M$=Math.imul(o$,X),M$=M$+Math.imul(u$,YQ)|0,S$=Math.imul(u$,X),z$=z$+Math.imul(E0,ZQ)|0,M$=M$+Math.imul(E0,D0)|0,M$=M$+Math.imul(b$,ZQ)|0,S$=S$+Math.imul(b$,D0)|0,z$=z$+Math.imul(V,VQ)|0,M$=M$+Math.imul(V,UQ)|0,M$=M$+Math.imul(h,VQ)|0,S$=S$+Math.imul(h,UQ)|0,z$=z$+Math.imul(c$,KQ)|0,M$=M$+Math.imul(c$,IQ)|0,M$=M$+Math.imul(h$,KQ)|0,S$=S$+Math.imul(h$,IQ)|0,z$=z$+Math.imul(w$,K)|0,M$=M$+Math.imul(w$,l)|0,M$=M$+Math.imul(p$,K)|0,S$=S$+Math.imul(p$,l)|0,z$=z$+Math.imul(B$,C0)|0,M$=M$+Math.imul(B$,FQ)|0,M$=M$+Math.imul(H0,C0)|0,S$=S$+Math.imul(H0,FQ)|0;var zQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(zQ>>>26)|0,zQ&=67108863,z$=Math.imul(o$,ZQ),M$=Math.imul(o$,D0),M$=M$+Math.imul(u$,ZQ)|0,S$=Math.imul(u$,D0),z$=z$+Math.imul(E0,VQ)|0,M$=M$+Math.imul(E0,UQ)|0,M$=M$+Math.imul(b$,VQ)|0,S$=S$+Math.imul(b$,UQ)|0,z$=z$+Math.imul(V,KQ)|0,M$=M$+Math.imul(V,IQ)|0,M$=M$+Math.imul(h,KQ)|0,S$=S$+Math.imul(h,IQ)|0,z$=z$+Math.imul(c$,K)|0,M$=M$+Math.imul(c$,l)|0,M$=M$+Math.imul(h$,K)|0,S$=S$+Math.imul(h$,l)|0,z$=z$+Math.imul(w$,C0)|0,M$=M$+Math.imul(w$,FQ)|0,M$=M$+Math.imul(p$,C0)|0,S$=S$+Math.imul(p$,FQ)|0;var MQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(MQ>>>26)|0,MQ&=67108863,z$=Math.imul(o$,VQ),M$=Math.imul(o$,UQ),M$=M$+Math.imul(u$,VQ)|0,S$=Math.imul(u$,UQ),z$=z$+Math.imul(E0,KQ)|0,M$=M$+Math.imul(E0,IQ)|0,M$=M$+Math.imul(b$,KQ)|0,S$=S$+Math.imul(b$,IQ)|0,z$=z$+Math.imul(V,K)|0,M$=M$+Math.imul(V,l)|0,M$=M$+Math.imul(h,K)|0,S$=S$+Math.imul(h,l)|0,z$=z$+Math.imul(c$,C0)|0,M$=M$+Math.imul(c$,FQ)|0,M$=M$+Math.imul(h$,C0)|0,S$=S$+Math.imul(h$,FQ)|0;var SQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(SQ>>>26)|0,SQ&=67108863,z$=Math.imul(o$,KQ),M$=Math.imul(o$,IQ),M$=M$+Math.imul(u$,KQ)|0,S$=Math.imul(u$,IQ),z$=z$+Math.imul(E0,K)|0,M$=M$+Math.imul(E0,l)|0,M$=M$+Math.imul(b$,K)|0,S$=S$+Math.imul(b$,l)|0,z$=z$+Math.imul(V,C0)|0,M$=M$+Math.imul(V,FQ)|0,M$=M$+Math.imul(h,C0)|0,S$=S$+Math.imul(h,FQ)|0;var vQ=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(vQ>>>26)|0,vQ&=67108863,z$=Math.imul(o$,K),M$=Math.imul(o$,l),M$=M$+Math.imul(u$,K)|0,S$=Math.imul(u$,l),z$=z$+Math.imul(E0,C0)|0,M$=M$+Math.imul(E0,FQ)|0,M$=M$+Math.imul(b$,C0)|0,S$=S$+Math.imul(b$,FQ)|0;var O=(P$+z$|0)+((M$&8191)<<13)|0;P$=(S$+(M$>>>13)|0)+(O>>>26)|0,O&=67108863,z$=Math.imul(o$,C0),M$=Math.imul(o$,FQ),M$=M$+Math.imul(u$,C0)|0,S$=Math.imul(u$,FQ);var g=(P$+z$|0)+((M$&8191)<<13)|0;return P$=(S$+(M$>>>13)|0)+(g>>>26)|0,g&=67108863,R$[0]=AQ,R$[1]=HQ,R$[2]=WQ,R$[3]=EQ,R$[4]=TQ,R$[5]=DQ,R$[6]=I,R$[7]=o,R$[8]=CQ,R$[9]=L0,R$[10]=LQ,R$[11]=RQ,R$[12]=PQ,R$[13]=zQ,R$[14]=MQ,R$[15]=SQ,R$[16]=vQ,R$[17]=O,R$[18]=g,P$!==0&&(R$[19]=P$,F0.length++),F0};Math.imul||(Q=I$);function x(f,D$,F0){F0.negative=D$.negative^f.negative,F0.length=f.length+D$.length;for(var C$=0,L$=0,R$=0;R$>>26)|0,L$+=P$>>>26,P$&=67108863}F0.words[R$]=z$,C$=P$,P$=L$}return C$!==0?F0.words[R$]=C$:F0.length--,F0._strip()}function O$(f,D$,F0){return x(f,D$,F0)}$$.prototype.mulTo=function(f,D$){var F0,C$=this.length+f.length;return this.length===10&&f.length===10?F0=Q(this,f,D$):C$<63?F0=I$(this,f,D$):C$<1024?F0=x(this,f,D$):F0=O$(this,f,D$),F0};function J0(f,D$){this.x=f,this.y=D$}J0.prototype.makeRBT=function(f){for(var D$=new Array(f),F0=$$.prototype._countBits(f)-1,C$=0;C$>=1;return C$},J0.prototype.permute=function(f,D$,F0,C$,L$,R$){for(var P$=0;P$>>1)L$++;return 1<>>13,F0[2*R$+1]=L$&8191,L$=L$>>>13;for(R$=2*D$;R$>=26,F0+=L$/67108864|0,F0+=R$>>>26,this.words[C$]=R$&67108863}return F0!==0&&(this.words[C$]=F0,this.length++),D$?this.ineg():this},$$.prototype.muln=function(f){return this.clone().imuln(f)},$$.prototype.sqr=function(){return this.mul(this)},$$.prototype.isqr=function(){return this.imul(this.clone())},$$.prototype.pow=function(f){var D$=K$(f);if(D$.length===0)return new $$(1);for(var F0=this,C$=0;C$=0);var D$=f%26,F0=(f-D$)/26,C$=67108863>>>26-D$<<26-D$,L$;if(D$!==0){var R$=0;for(L$=0;L$>>26-D$}R$&&(this.words[L$]=R$,this.length++)}if(F0!==0){for(L$=this.length-1;L$>=0;L$--)this.words[L$+F0]=this.words[L$];for(L$=0;L$=0);var C$;D$?C$=(D$-D$%26)/26:C$=0;var L$=f%26,R$=Math.min((f-L$)/26,this.length),P$=67108863^67108863>>>L$<R$)for(this.length-=R$,M$=0;M$=0&&(S$!==0||M$>=C$);M$--){var Z=this.words[M$]|0;this.words[M$]=S$<<26-L$|Z>>>L$,S$=Z&P$}return z$&&S$!==0&&(z$.words[z$.length++]=S$),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},$$.prototype.ishrn=function(f,D$,F0){return r0(this.negative===0),this.iushrn(f,D$,F0)},$$.prototype.shln=function(f){return this.clone().ishln(f)},$$.prototype.ushln=function(f){return this.clone().iushln(f)},$$.prototype.shrn=function(f){return this.clone().ishrn(f)},$$.prototype.ushrn=function(f){return this.clone().iushrn(f)},$$.prototype.testn=function(f){r0(typeof f=="number"&&f>=0);var D$=f%26,F0=(f-D$)/26,C$=1<=0);var D$=f%26,F0=(f-D$)/26;if(r0(this.negative===0,"imaskn works only with positive numbers"),this.length<=F0)return this;if(D$!==0&&F0++,this.length=Math.min(F0,this.length),D$!==0){var C$=67108863^67108863>>>D$<=67108864;D$++)this.words[D$]-=67108864,D$===this.length-1?this.words[D$+1]=1:this.words[D$+1]++;return this.length=Math.max(this.length,D$+1),this},$$.prototype.isubn=function(f){if(r0(typeof f=="number"),r0(f<67108864),f<0)return this.iaddn(-f);if(this.negative!==0)return this.negative=0,this.iaddn(f),this.negative=1,this;if(this.words[0]-=f,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var D$=0;D$>26)-(z$/67108864|0),this.words[L$+F0]=R$&67108863}for(;L$>26,this.words[L$+F0]=R$&67108863;if(P$===0)return this._strip();for(r0(P$===-1),P$=0,L$=0;L$>26,this.words[L$]=R$&67108863;return this.negative=1,this._strip()},$$.prototype._wordDiv=function(f,D$){var F0=this.length-f.length,C$=this.clone(),L$=f,R$=L$.words[L$.length-1]|0,P$=this._countBits(R$);F0=26-P$,F0!==0&&(L$=L$.ushln(F0),C$.iushln(F0),R$=L$.words[L$.length-1]|0);var z$=C$.length-L$.length,M$;if(D$!=="mod"){M$=new $$(null),M$.length=z$+1,M$.words=new Array(M$.length);for(var S$=0;S$=0;c--){var v$=(C$.words[L$.length+c]|0)*67108864+(C$.words[L$.length+c-1]|0);for(v$=Math.min(v$/R$|0,67108863),C$._ishlnsubmul(L$,v$,c);C$.negative!==0;)v$--,C$.negative=0,C$._ishlnsubmul(L$,1,c),C$.isZero()||(C$.negative^=1);M$&&(M$.words[c]=v$)}return M$&&M$._strip(),C$._strip(),D$!=="div"&&F0!==0&&C$.iushrn(F0),{div:M$||null,mod:C$}},$$.prototype.divmod=function(f,D$,F0){if(r0(!f.isZero()),this.isZero())return{div:new $$(0),mod:new $$(0)};var C$,L$,R$;return this.negative!==0&&f.negative===0?(R$=this.neg().divmod(f,D$),D$!=="mod"&&(C$=R$.div.neg()),D$!=="div"&&(L$=R$.mod.neg(),F0&&L$.negative!==0&&L$.iadd(f)),{div:C$,mod:L$}):this.negative===0&&f.negative!==0?(R$=this.divmod(f.neg(),D$),D$!=="mod"&&(C$=R$.div.neg()),{div:C$,mod:R$.mod}):(this.negative&f.negative)!==0?(R$=this.neg().divmod(f.neg(),D$),D$!=="div"&&(L$=R$.mod.neg(),F0&&L$.negative!==0&&L$.isub(f)),{div:R$.div,mod:L$}):f.length>this.length||this.cmp(f)<0?{div:new $$(0),mod:this}:f.length===1?D$==="div"?{div:this.divn(f.words[0]),mod:null}:D$==="mod"?{div:null,mod:new $$(this.modrn(f.words[0]))}:{div:this.divn(f.words[0]),mod:new $$(this.modrn(f.words[0]))}:this._wordDiv(f,D$)},$$.prototype.div=function(f){return this.divmod(f,"div",!1).div},$$.prototype.mod=function(f){return this.divmod(f,"mod",!1).mod},$$.prototype.umod=function(f){return this.divmod(f,"mod",!0).mod},$$.prototype.divRound=function(f){var D$=this.divmod(f);if(D$.mod.isZero())return D$.div;var F0=D$.div.negative!==0?D$.mod.isub(f):D$.mod,C$=f.ushrn(1),L$=f.andln(1),R$=F0.cmp(C$);return R$<0||L$===1&&R$===0?D$.div:D$.div.negative!==0?D$.div.isubn(1):D$.div.iaddn(1)},$$.prototype.modrn=function(f){var D$=f<0;D$&&(f=-f),r0(f<=67108863);for(var F0=(1<<26)%f,C$=0,L$=this.length-1;L$>=0;L$--)C$=(F0*C$+(this.words[L$]|0))%f;return D$?-C$:C$},$$.prototype.modn=function(f){return this.modrn(f)},$$.prototype.idivn=function(f){var D$=f<0;D$&&(f=-f),r0(f<=67108863);for(var F0=0,C$=this.length-1;C$>=0;C$--){var L$=(this.words[C$]|0)+F0*67108864;this.words[C$]=L$/f|0,F0=L$%f}return this._strip(),D$?this.ineg():this},$$.prototype.divn=function(f){return this.clone().idivn(f)},$$.prototype.egcd=function(f){r0(f.negative===0),r0(!f.isZero());var D$=this,F0=f.clone();D$.negative!==0?D$=D$.umod(f):D$=D$.clone();for(var C$=new $$(1),L$=new $$(0),R$=new $$(0),P$=new $$(1),z$=0;D$.isEven()&&F0.isEven();)D$.iushrn(1),F0.iushrn(1),++z$;for(var M$=F0.clone(),S$=D$.clone();!D$.isZero();){for(var Z=0,c=1;(D$.words[0]&c)===0&&Z<26;++Z,c<<=1);if(Z>0)for(D$.iushrn(Z);Z-- >0;)(C$.isOdd()||L$.isOdd())&&(C$.iadd(M$),L$.isub(S$)),C$.iushrn(1),L$.iushrn(1);for(var v$=0,A0=1;(F0.words[0]&A0)===0&&v$<26;++v$,A0<<=1);if(v$>0)for(F0.iushrn(v$);v$-- >0;)(R$.isOdd()||P$.isOdd())&&(R$.iadd(M$),P$.isub(S$)),R$.iushrn(1),P$.iushrn(1);D$.cmp(F0)>=0?(D$.isub(F0),C$.isub(R$),L$.isub(P$)):(F0.isub(D$),R$.isub(C$),P$.isub(L$))}return{a:R$,b:P$,gcd:F0.iushln(z$)}},$$.prototype._invmp=function(f){r0(f.negative===0),r0(!f.isZero());var D$=this,F0=f.clone();D$.negative!==0?D$=D$.umod(f):D$=D$.clone();for(var C$=new $$(1),L$=new $$(0),R$=F0.clone();D$.cmpn(1)>0&&F0.cmpn(1)>0;){for(var P$=0,z$=1;(D$.words[0]&z$)===0&&P$<26;++P$,z$<<=1);if(P$>0)for(D$.iushrn(P$);P$-- >0;)C$.isOdd()&&C$.iadd(R$),C$.iushrn(1);for(var M$=0,S$=1;(F0.words[0]&S$)===0&&M$<26;++M$,S$<<=1);if(M$>0)for(F0.iushrn(M$);M$-- >0;)L$.isOdd()&&L$.iadd(R$),L$.iushrn(1);D$.cmp(F0)>=0?(D$.isub(F0),C$.isub(L$)):(F0.isub(D$),L$.isub(C$))}var Z;return D$.cmpn(1)===0?Z=C$:Z=L$,Z.cmpn(0)<0&&Z.iadd(f),Z},$$.prototype.gcd=function(f){if(this.isZero())return f.abs();if(f.isZero())return this.abs();var D$=this.clone(),F0=f.clone();D$.negative=0,F0.negative=0;for(var C$=0;D$.isEven()&&F0.isEven();C$++)D$.iushrn(1),F0.iushrn(1);do{for(;D$.isEven();)D$.iushrn(1);for(;F0.isEven();)F0.iushrn(1);var L$=D$.cmp(F0);if(L$<0){var R$=D$;D$=F0,F0=R$}else if(L$===0||F0.cmpn(1)===0)break;D$.isub(F0)}while(!0);return F0.iushln(C$)},$$.prototype.invm=function(f){return this.egcd(f).a.umod(f)},$$.prototype.isEven=function(){return(this.words[0]&1)===0},$$.prototype.isOdd=function(){return(this.words[0]&1)===1},$$.prototype.andln=function(f){return this.words[0]&f},$$.prototype.bincn=function(f){r0(typeof f=="number");var D$=f%26,F0=(f-D$)/26,C$=1<>>26,P$&=67108863,this.words[R$]=P$}return L$!==0&&(this.words[R$]=L$,this.length++),this},$$.prototype.isZero=function(){return this.length===1&&this.words[0]===0},$$.prototype.cmpn=function(f){var D$=f<0;if(this.negative!==0&&!D$)return-1;if(this.negative===0&&D$)return 1;this._strip();var F0;if(this.length>1)F0=1;else{D$&&(f=-f),r0(f<=67108863,"Number is too big");var C$=this.words[0]|0;F0=C$===f?0:C$f.length)return 1;if(this.length=0;F0--){var C$=this.words[F0]|0,L$=f.words[F0]|0;if(C$!==L$){C$L$&&(D$=1);break}}return D$},$$.prototype.gtn=function(f){return this.cmpn(f)===1},$$.prototype.gt=function(f){return this.cmp(f)===1},$$.prototype.gten=function(f){return this.cmpn(f)>=0},$$.prototype.gte=function(f){return this.cmp(f)>=0},$$.prototype.ltn=function(f){return this.cmpn(f)===-1},$$.prototype.lt=function(f){return this.cmp(f)===-1},$$.prototype.lten=function(f){return this.cmpn(f)<=0},$$.prototype.lte=function(f){return this.cmp(f)<=0},$$.prototype.eqn=function(f){return this.cmpn(f)===0},$$.prototype.eq=function(f){return this.cmp(f)===0},$$.red=function(f){return new T$(f)},$$.prototype.toRed=function(f){return r0(!this.red,"Already a number in reduction context"),r0(this.negative===0,"red works only with positives"),f.convertTo(this)._forceRed(f)},$$.prototype.fromRed=function(){return r0(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},$$.prototype._forceRed=function(f){return this.red=f,this},$$.prototype.forceRed=function(f){return r0(!this.red,"Already a number in reduction context"),this._forceRed(f)},$$.prototype.redAdd=function(f){return r0(this.red,"redAdd works only with red numbers"),this.red.add(this,f)},$$.prototype.redIAdd=function(f){return r0(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,f)},$$.prototype.redSub=function(f){return r0(this.red,"redSub works only with red numbers"),this.red.sub(this,f)},$$.prototype.redISub=function(f){return r0(this.red,"redISub works only with red numbers"),this.red.isub(this,f)},$$.prototype.redShl=function(f){return r0(this.red,"redShl works only with red numbers"),this.red.shl(this,f)},$$.prototype.redMul=function(f){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.mul(this,f)},$$.prototype.redIMul=function(f){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.imul(this,f)},$$.prototype.redSqr=function(){return r0(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},$$.prototype.redISqr=function(){return r0(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},$$.prototype.redSqrt=function(){return r0(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},$$.prototype.redInvm=function(){return r0(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},$$.prototype.redNeg=function(){return r0(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},$$.prototype.redPow=function(f){return r0(this.red&&!f.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,f)};var J$={k256:null,p224:null,p192:null,p25519:null};function F$(f,D$){this.name=f,this.p=new $$(D$,16),this.n=this.p.bitLength(),this.k=new $$(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F$.prototype._tmp=function(){var f=new $$(null);return f.words=new Array(Math.ceil(this.n/13)),f},F$.prototype.ireduce=function(f){var D$=f,F0;do this.split(D$,this.tmp),D$=this.imulK(D$),D$=D$.iadd(this.tmp),F0=D$.bitLength();while(F0>this.n);var C$=F00?D$.isub(this.p):D$.strip!==void 0?D$.strip():D$._strip(),D$},F$.prototype.split=function(f,D$){f.iushrn(this.n,0,D$)},F$.prototype.imulK=function(f){return f.imul(this.k)};function A$(){F$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i0(A$,F$),A$.prototype.split=function(f,D$){for(var F0=4194303,C$=Math.min(f.length,9),L$=0;L$>>22,R$=P$}R$>>>=22,f.words[L$-10]=R$,R$===0&&f.length>10?f.length-=10:f.length-=9},A$.prototype.imulK=function(f){f.words[f.length]=0,f.words[f.length+1]=0,f.length+=2;for(var D$=0,F0=0;F0>>=26,f.words[F0]=L$,D$=C$}return D$!==0&&(f.words[f.length++]=D$),f},$$._prime=function(f){if(J$[f])return J$[f];var D$;if(f==="k256")D$=new A$;else if(f==="p224")D$=new H$;else if(f==="p192")D$=new W$;else if(f==="p25519")D$=new E$;else throw new Error("Unknown prime "+f);return J$[f]=D$,D$};function T$(f){if(typeof f=="string"){var D$=$$._prime(f);this.m=D$.p,this.prime=D$}else r0(f.gtn(1),"modulus must be greater than 1"),this.m=f,this.prime=null}T$.prototype._verify1=function(f){r0(f.negative===0,"red works only with positives"),r0(f.red,"red works only with red numbers")},T$.prototype._verify2=function(f,D$){r0((f.negative|D$.negative)===0,"red works only with positives"),r0(f.red&&f.red===D$.red,"red works only with red numbers")},T$.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(O0(f,f.umod(this.m)._forceRed(this)),f)},T$.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},T$.prototype.add=function(f,D$){this._verify2(f,D$);var F0=f.add(D$);return F0.cmp(this.m)>=0&&F0.isub(this.m),F0._forceRed(this)},T$.prototype.iadd=function(f,D$){this._verify2(f,D$);var F0=f.iadd(D$);return F0.cmp(this.m)>=0&&F0.isub(this.m),F0},T$.prototype.sub=function(f,D$){this._verify2(f,D$);var F0=f.sub(D$);return F0.cmpn(0)<0&&F0.iadd(this.m),F0._forceRed(this)},T$.prototype.isub=function(f,D$){this._verify2(f,D$);var F0=f.isub(D$);return F0.cmpn(0)<0&&F0.iadd(this.m),F0},T$.prototype.shl=function(f,D$){return this._verify1(f),this.imod(f.ushln(D$))},T$.prototype.imul=function(f,D$){return this._verify2(f,D$),this.imod(f.imul(D$))},T$.prototype.mul=function(f,D$){return this._verify2(f,D$),this.imod(f.mul(D$))},T$.prototype.isqr=function(f){return this.imul(f,f.clone())},T$.prototype.sqr=function(f){return this.mul(f,f)},T$.prototype.sqrt=function(f){if(f.isZero())return f.clone();var D$=this.m.andln(3);if(r0(D$%2===1),D$===3){var F0=this.m.add(new $$(1)).iushrn(2);return this.pow(f,F0)}for(var C$=this.m.subn(1),L$=0;!C$.isZero()&&C$.andln(1)===0;)L$++,C$.iushrn(1);r0(!C$.isZero());var R$=new $$(1).toRed(this),P$=R$.redNeg(),z$=this.m.subn(1).iushrn(1),M$=this.m.bitLength();for(M$=new $$(2*M$*M$).toRed(this);this.pow(M$,z$).cmp(P$)!==0;)M$.redIAdd(P$);for(var S$=this.pow(M$,C$),Z=this.pow(f,C$.addn(1).iushrn(1)),c=this.pow(f,C$),v$=L$;c.cmp(R$)!==0;){for(var A0=c,q$=0;A0.cmp(R$)!==0;q$++)A0=A0.redSqr();r0(q$=0;L$--){for(var S$=D$.words[L$],Z=M$-1;Z>=0;Z--){var c=S$>>Z&1;if(R$!==C$[0]&&(R$=this.sqr(R$)),c===0&&P$===0){z$=0;continue}P$<<=1,P$|=c,z$++,!(z$!==F0&&(L$!==0||Z!==0))&&(R$=this.mul(R$,C$[P$]),z$=0,P$=0)}M$=26}return R$},T$.prototype.convertTo=function(f){var D$=f.umod(this.m);return D$===f?D$.clone():D$},T$.prototype.convertFrom=function(f){var D$=f.clone();return D$.red=null,D$},$$.mont=function(f){return new Y(f)};function Y(f){T$.call(this,f),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new $$(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)}i0(Y,T$),Y.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},Y.prototype.convertFrom=function(f){var D$=this.imod(f.mul(this.rinv));return D$.red=null,D$},Y.prototype.imul=function(f,D$){if(f.isZero()||D$.isZero())return f.words[0]=0,f.length=1,f;var F0=f.imul(D$),C$=F0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),L$=F0.isub(C$).iushrn(this.shift),R$=L$;return L$.cmp(this.m)>=0?R$=L$.isub(this.m):L$.cmpn(0)<0&&(R$=L$.iadd(this.m)),R$._forceRed(this)},Y.prototype.mul=function(f,D$){if(f.isZero()||D$.isZero())return new $$(0)._forceRed(this);var F0=f.mul(D$),C$=F0.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),L$=F0.isub(C$).iushrn(this.shift),R$=L$;return L$.cmp(this.m)>=0?R$=L$.isub(this.m):L$.cmpn(0)<0&&(R$=L$.iadd(this.m)),R$._forceRed(this)},Y.prototype.invm=function(f){var D$=this.imod(f._invmp(this.m).mul(this.r2));return D$._forceRed(this)}})(typeof m0>"u"||m0,t0)}}),qY=pQ({"node_modules/browserify-rsa/index.js"(t0,m0){var a0=vY(),e0=hQ();function r0(Q$){var $=i0(Q$),N=$.toRed(a0.mont(Q$.modulus)).redPow(new a0(Q$.publicExponent)).fromRed();return{blinder:N,unblinder:$.invm(Q$.modulus)}}function i0(Q$){var $=Q$.modulus.byteLength(),N;do N=new a0(e0($));while(N.cmp(Q$.modulus)>=0||!N.umod(Q$.prime1)||!N.umod(Q$.prime2));return N}function $$(Q$,$){var N=r0($),Y$=$.modulus.byteLength(),O0=new a0(Q$).mul(N.blinder).umod($.modulus),Z$=O0.toRed(a0.mont($.prime1)),G$=O0.toRed(a0.mont($.prime2)),V$=$.coefficient,U$=$.prime1,X$=$.prime2,K$=Z$.redPow($.exponent1).fromRed(),I$=G$.redPow($.exponent2).fromRed(),Q=K$.isub(I$).imul(V$).umod(U$).imul(X$);return I$.iadd(Q).imul(N.unblinder).umod($.modulus).toArrayLike(G0,"be",Y$)}$$.getr=i0,m0.exports=$$}}),jY=pQ({"node_modules/elliptic/package.json"(t0,m0){m0.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"}}}}),kY=pQ({"node_modules/elliptic/node_modules/bn.js/lib/bn.js"(t0,m0){(function(a0,e0){function r0(E$,T$){if(!E$)throw new Error(T$||"Assertion failed")}function i0(E$,T$){E$.super_=T$;var Y=function(){};Y.prototype=T$.prototype,E$.prototype=new Y,E$.prototype.constructor=E$}function $$(E$,T$,Y){if($$.isBN(E$))return E$;this.negative=0,this.words=null,this.length=0,this.red=null,E$!==null&&((T$==="le"||T$==="be")&&(Y=T$,T$=10),this._init(E$||0,T$||10,Y||"be"))}typeof a0=="object"?a0.exports=$$:e0.BN=$$,$$.BN=$$,$$.wordSize=26;var Q$=G0;$$.isBN=function(E$){return E$ instanceof $$?!0:E$!==null&&typeof E$=="object"&&E$.constructor.wordSize===$$.wordSize&&Array.isArray(E$.words)},$$.max=function(E$,T$){return E$.cmp(T$)>0?E$:T$},$$.min=function(E$,T$){return E$.cmp(T$)<0?E$:T$},$$.prototype._init=function(E$,T$,Y){if(typeof E$=="number")return this._initNumber(E$,T$,Y);if(typeof E$=="object")return this._initArray(E$,T$,Y);T$==="hex"&&(T$=16),r0(T$===(T$|0)&&T$>=2&&T$<=36),E$=E$.toString().replace(/\s+/g,"");var f=0;E$[0]==="-"&&(f++,this.negative=1),f=0;f-=3)F0=E$[f]|E$[f-1]<<8|E$[f-2]<<16,this.words[D$]|=F0<>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);else if(Y==="le")for(f=0,D$=0;f>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);return this.strip()};function $(E$,T$){var Y=E$.charCodeAt(T$);return Y>=65&&Y<=70?Y-55:Y>=97&&Y<=102?Y-87:Y-48&15}function N(E$,T$,Y){var f=$(E$,Y);return Y-1>=T$&&(f|=$(E$,Y-1)<<4),f}$$.prototype._parseHex=function(E$,T$,Y){this.length=Math.ceil((E$.length-T$)/6),this.words=new Array(this.length);for(var f=0;f=T$;f-=2)C$=N(E$,T$,f)<=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8;else{var L$=E$.length-T$;for(f=L$%2===0?T$+1:T$;f=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8}this.strip()};function Y$(E$,T$,Y,f){for(var D$=0,F0=Math.min(E$.length,Y),C$=T$;C$=49?D$+=L$-49+10:L$>=17?D$+=L$-17+10:D$+=L$}return D$}$$.prototype._parseBase=function(E$,T$,Y){this.words=[0],this.length=1;for(var f=0,D$=1;D$<=67108863;D$*=T$)f++;f--,D$=D$/T$|0;for(var F0=E$.length-Y,C$=F0%f,L$=Math.min(F0,F0-C$)+Y,R$=0,P$=Y;P$1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},$$.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},$$.prototype.inspect=function(){return(this.red?""};var O0=["","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"],Z$=[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],G$=[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];$$.prototype.toString=function(E$,T$){E$=E$||10,T$=T$|0||1;var Y;if(E$===16||E$==="hex"){Y="";for(var f=0,D$=0,F0=0;F0>>24-f&16777215,D$!==0||F0!==this.length-1?Y=O0[6-L$.length]+L$+Y:Y=L$+Y,f+=2,f>=26&&(f-=26,F0--)}for(D$!==0&&(Y=D$.toString(16)+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}if(E$===(E$|0)&&E$>=2&&E$<=36){var R$=Z$[E$],P$=G$[E$];Y="";var z$=this.clone();for(z$.negative=0;!z$.isZero();){var M$=z$.modn(P$).toString(E$);z$=z$.idivn(P$),z$.isZero()?Y=M$+Y:Y=O0[R$-M$.length]+M$+Y}for(this.isZero()&&(Y="0"+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}r0(!1,"Base should be between 2 and 36")},$$.prototype.toNumber=function(){var E$=this.words[0];return this.length===2?E$+=this.words[1]*67108864:this.length===3&&this.words[2]===1?E$+=4503599627370496+this.words[1]*67108864:this.length>2&&r0(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-E$:E$},$$.prototype.toJSON=function(){return this.toString(16)},$$.prototype.toBuffer=function(E$,T$){return r0(typeof Q$<"u"),this.toArrayLike(Q$,E$,T$)},$$.prototype.toArray=function(E$,T$){return this.toArrayLike(Array,E$,T$)},$$.prototype.toArrayLike=function(E$,T$,Y){var f=this.byteLength(),D$=Y||Math.max(1,f);r0(f<=D$,"byte array longer than desired length"),r0(D$>0,"Requested array length <= 0"),this.strip();var F0=T$==="le",C$=new E$(D$),L$,R$,P$=this.clone();if(F0){for(R$=0;!P$.isZero();R$++)L$=P$.andln(255),P$.iushrn(8),C$[R$]=L$;for(;R$=4096&&(Y+=13,T$>>>=13),T$>=64&&(Y+=7,T$>>>=7),T$>=8&&(Y+=4,T$>>>=4),T$>=2&&(Y+=2,T$>>>=2),Y+T$},$$.prototype._zeroBits=function(E$){if(E$===0)return 26;var T$=E$,Y=0;return(T$&8191)===0&&(Y+=13,T$>>>=13),(T$&127)===0&&(Y+=7,T$>>>=7),(T$&15)===0&&(Y+=4,T$>>>=4),(T$&3)===0&&(Y+=2,T$>>>=2),(T$&1)===0&&Y++,Y},$$.prototype.bitLength=function(){var E$=this.words[this.length-1],T$=this._countBits(E$);return(this.length-1)*26+T$};function V$(E$){for(var T$=new Array(E$.bitLength()),Y=0;Y>>D$}return T$}$$.prototype.zeroBits=function(){if(this.isZero())return 0;for(var E$=0,T$=0;T$E$.length?this.clone().ior(E$):E$.clone().ior(this)},$$.prototype.uor=function(E$){return this.length>E$.length?this.clone().iuor(E$):E$.clone().iuor(this)},$$.prototype.iuand=function(E$){var T$;this.length>E$.length?T$=E$:T$=this;for(var Y=0;YE$.length?this.clone().iand(E$):E$.clone().iand(this)},$$.prototype.uand=function(E$){return this.length>E$.length?this.clone().iuand(E$):E$.clone().iuand(this)},$$.prototype.iuxor=function(E$){var T$,Y;this.length>E$.length?(T$=this,Y=E$):(T$=E$,Y=this);for(var f=0;fE$.length?this.clone().ixor(E$):E$.clone().ixor(this)},$$.prototype.uxor=function(E$){return this.length>E$.length?this.clone().iuxor(E$):E$.clone().iuxor(this)},$$.prototype.inotn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=Math.ceil(E$/26)|0,Y=E$%26;this._expand(T$),Y>0&&T$--;for(var f=0;f0&&(this.words[f]=~this.words[f]&67108863>>26-Y),this.strip()},$$.prototype.notn=function(E$){return this.clone().inotn(E$)},$$.prototype.setn=function(E$,T$){r0(typeof E$=="number"&&E$>=0);var Y=E$/26|0,f=E$%26;return this._expand(Y+1),T$?this.words[Y]=this.words[Y]|1<E$.length?(Y=this,f=E$):(Y=E$,f=this);for(var D$=0,F0=0;F0>>26;for(;D$!==0&&F0>>26;if(this.length=Y.length,D$!==0)this.words[this.length]=D$,this.length++;else if(Y!==this)for(;F0E$.length?this.clone().iadd(E$):E$.clone().iadd(this)},$$.prototype.isub=function(E$){if(E$.negative!==0){E$.negative=0;var T$=this.iadd(E$);return E$.negative=1,T$._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(E$),this.negative=1,this._normSign();var Y=this.cmp(E$);if(Y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,D$;Y>0?(f=this,D$=E$):(f=E$,D$=this);for(var F0=0,C$=0;C$>26,this.words[C$]=T$&67108863;for(;F0!==0&&C$>26,this.words[C$]=T$&67108863;if(F0===0&&C$>>26,M$=R$&67108863,S$=Math.min(P$,T$.length-1),Z=Math.max(0,P$-E$.length+1);Z<=S$;Z++){var c=P$-Z|0;D$=E$.words[c]|0,F0=T$.words[Z]|0,C$=D$*F0+M$,z$+=C$/67108864|0,M$=C$&67108863}Y.words[P$]=M$|0,R$=z$|0}return R$!==0?Y.words[P$]=R$|0:Y.length--,Y.strip()}var X$=function(E$,T$,Y){var f=E$.words,D$=T$.words,F0=Y.words,C$=0,L$,R$,P$,z$=f[0]|0,M$=z$&8191,S$=z$>>>13,Z=f[1]|0,c=Z&8191,v$=Z>>>13,A0=f[2]|0,q$=A0&8191,j$=A0>>>13,k$=f[3]|0,g$=k$&8191,_$=k$>>>13,N$=f[4]|0,x$=N$&8191,G=N$>>>13,B=f[5]|0,B$=B&8191,H0=B>>>13,y$=f[6]|0,w$=y$&8191,p$=y$>>>13,f$=f[7]|0,c$=f$&8191,h$=f$>>>13,d$=f[8]|0,V=d$&8191,h=d$>>>13,W0=f[9]|0,E0=W0&8191,b$=W0>>>13,l$=D$[0]|0,o$=l$&8191,u$=l$>>>13,n$=D$[1]|0,s$=n$&8191,t$=n$>>>13,U=D$[2]|0,d=U&8191,m$=U>>>13,T0=D$[3]|0,a$=T0&8191,e$=T0>>>13,r$=D$[4]|0,i$=r$&8191,$Q=r$>>>13,QQ=D$[5]|0,YQ=QQ&8191,X=QQ>>>13,b=D$[6]|0,ZQ=b&8191,D0=b>>>13,GQ=D$[7]|0,VQ=GQ&8191,UQ=GQ>>>13,XQ=D$[8]|0,KQ=XQ&8191,IQ=XQ>>>13,OQ=D$[9]|0,K=OQ&8191,l=OQ>>>13;Y.negative=E$.negative^T$.negative,Y.length=19,L$=Math.imul(M$,o$),R$=Math.imul(M$,u$),R$=R$+Math.imul(S$,o$)|0,P$=Math.imul(S$,u$);var JQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(JQ>>>26)|0,JQ&=67108863,L$=Math.imul(c,o$),R$=Math.imul(c,u$),R$=R$+Math.imul(v$,o$)|0,P$=Math.imul(v$,u$),L$=L$+Math.imul(M$,s$)|0,R$=R$+Math.imul(M$,t$)|0,R$=R$+Math.imul(S$,s$)|0,P$=P$+Math.imul(S$,t$)|0;var C0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(C0>>>26)|0,C0&=67108863,L$=Math.imul(q$,o$),R$=Math.imul(q$,u$),R$=R$+Math.imul(j$,o$)|0,P$=Math.imul(j$,u$),L$=L$+Math.imul(c,s$)|0,R$=R$+Math.imul(c,t$)|0,R$=R$+Math.imul(v$,s$)|0,P$=P$+Math.imul(v$,t$)|0,L$=L$+Math.imul(M$,d)|0,R$=R$+Math.imul(M$,m$)|0,R$=R$+Math.imul(S$,d)|0,P$=P$+Math.imul(S$,m$)|0;var FQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(FQ>>>26)|0,FQ&=67108863,L$=Math.imul(g$,o$),R$=Math.imul(g$,u$),R$=R$+Math.imul(_$,o$)|0,P$=Math.imul(_$,u$),L$=L$+Math.imul(q$,s$)|0,R$=R$+Math.imul(q$,t$)|0,R$=R$+Math.imul(j$,s$)|0,P$=P$+Math.imul(j$,t$)|0,L$=L$+Math.imul(c,d)|0,R$=R$+Math.imul(c,m$)|0,R$=R$+Math.imul(v$,d)|0,P$=P$+Math.imul(v$,m$)|0,L$=L$+Math.imul(M$,a$)|0,R$=R$+Math.imul(M$,e$)|0,R$=R$+Math.imul(S$,a$)|0,P$=P$+Math.imul(S$,e$)|0;var AQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(AQ>>>26)|0,AQ&=67108863,L$=Math.imul(x$,o$),R$=Math.imul(x$,u$),R$=R$+Math.imul(G,o$)|0,P$=Math.imul(G,u$),L$=L$+Math.imul(g$,s$)|0,R$=R$+Math.imul(g$,t$)|0,R$=R$+Math.imul(_$,s$)|0,P$=P$+Math.imul(_$,t$)|0,L$=L$+Math.imul(q$,d)|0,R$=R$+Math.imul(q$,m$)|0,R$=R$+Math.imul(j$,d)|0,P$=P$+Math.imul(j$,m$)|0,L$=L$+Math.imul(c,a$)|0,R$=R$+Math.imul(c,e$)|0,R$=R$+Math.imul(v$,a$)|0,P$=P$+Math.imul(v$,e$)|0,L$=L$+Math.imul(M$,i$)|0,R$=R$+Math.imul(M$,$Q)|0,R$=R$+Math.imul(S$,i$)|0,P$=P$+Math.imul(S$,$Q)|0;var HQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(HQ>>>26)|0,HQ&=67108863,L$=Math.imul(B$,o$),R$=Math.imul(B$,u$),R$=R$+Math.imul(H0,o$)|0,P$=Math.imul(H0,u$),L$=L$+Math.imul(x$,s$)|0,R$=R$+Math.imul(x$,t$)|0,R$=R$+Math.imul(G,s$)|0,P$=P$+Math.imul(G,t$)|0,L$=L$+Math.imul(g$,d)|0,R$=R$+Math.imul(g$,m$)|0,R$=R$+Math.imul(_$,d)|0,P$=P$+Math.imul(_$,m$)|0,L$=L$+Math.imul(q$,a$)|0,R$=R$+Math.imul(q$,e$)|0,R$=R$+Math.imul(j$,a$)|0,P$=P$+Math.imul(j$,e$)|0,L$=L$+Math.imul(c,i$)|0,R$=R$+Math.imul(c,$Q)|0,R$=R$+Math.imul(v$,i$)|0,P$=P$+Math.imul(v$,$Q)|0,L$=L$+Math.imul(M$,YQ)|0,R$=R$+Math.imul(M$,X)|0,R$=R$+Math.imul(S$,YQ)|0,P$=P$+Math.imul(S$,X)|0;var WQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(WQ>>>26)|0,WQ&=67108863,L$=Math.imul(w$,o$),R$=Math.imul(w$,u$),R$=R$+Math.imul(p$,o$)|0,P$=Math.imul(p$,u$),L$=L$+Math.imul(B$,s$)|0,R$=R$+Math.imul(B$,t$)|0,R$=R$+Math.imul(H0,s$)|0,P$=P$+Math.imul(H0,t$)|0,L$=L$+Math.imul(x$,d)|0,R$=R$+Math.imul(x$,m$)|0,R$=R$+Math.imul(G,d)|0,P$=P$+Math.imul(G,m$)|0,L$=L$+Math.imul(g$,a$)|0,R$=R$+Math.imul(g$,e$)|0,R$=R$+Math.imul(_$,a$)|0,P$=P$+Math.imul(_$,e$)|0,L$=L$+Math.imul(q$,i$)|0,R$=R$+Math.imul(q$,$Q)|0,R$=R$+Math.imul(j$,i$)|0,P$=P$+Math.imul(j$,$Q)|0,L$=L$+Math.imul(c,YQ)|0,R$=R$+Math.imul(c,X)|0,R$=R$+Math.imul(v$,YQ)|0,P$=P$+Math.imul(v$,X)|0,L$=L$+Math.imul(M$,ZQ)|0,R$=R$+Math.imul(M$,D0)|0,R$=R$+Math.imul(S$,ZQ)|0,P$=P$+Math.imul(S$,D0)|0;var EQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(EQ>>>26)|0,EQ&=67108863,L$=Math.imul(c$,o$),R$=Math.imul(c$,u$),R$=R$+Math.imul(h$,o$)|0,P$=Math.imul(h$,u$),L$=L$+Math.imul(w$,s$)|0,R$=R$+Math.imul(w$,t$)|0,R$=R$+Math.imul(p$,s$)|0,P$=P$+Math.imul(p$,t$)|0,L$=L$+Math.imul(B$,d)|0,R$=R$+Math.imul(B$,m$)|0,R$=R$+Math.imul(H0,d)|0,P$=P$+Math.imul(H0,m$)|0,L$=L$+Math.imul(x$,a$)|0,R$=R$+Math.imul(x$,e$)|0,R$=R$+Math.imul(G,a$)|0,P$=P$+Math.imul(G,e$)|0,L$=L$+Math.imul(g$,i$)|0,R$=R$+Math.imul(g$,$Q)|0,R$=R$+Math.imul(_$,i$)|0,P$=P$+Math.imul(_$,$Q)|0,L$=L$+Math.imul(q$,YQ)|0,R$=R$+Math.imul(q$,X)|0,R$=R$+Math.imul(j$,YQ)|0,P$=P$+Math.imul(j$,X)|0,L$=L$+Math.imul(c,ZQ)|0,R$=R$+Math.imul(c,D0)|0,R$=R$+Math.imul(v$,ZQ)|0,P$=P$+Math.imul(v$,D0)|0,L$=L$+Math.imul(M$,VQ)|0,R$=R$+Math.imul(M$,UQ)|0,R$=R$+Math.imul(S$,VQ)|0,P$=P$+Math.imul(S$,UQ)|0;var TQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(TQ>>>26)|0,TQ&=67108863,L$=Math.imul(V,o$),R$=Math.imul(V,u$),R$=R$+Math.imul(h,o$)|0,P$=Math.imul(h,u$),L$=L$+Math.imul(c$,s$)|0,R$=R$+Math.imul(c$,t$)|0,R$=R$+Math.imul(h$,s$)|0,P$=P$+Math.imul(h$,t$)|0,L$=L$+Math.imul(w$,d)|0,R$=R$+Math.imul(w$,m$)|0,R$=R$+Math.imul(p$,d)|0,P$=P$+Math.imul(p$,m$)|0,L$=L$+Math.imul(B$,a$)|0,R$=R$+Math.imul(B$,e$)|0,R$=R$+Math.imul(H0,a$)|0,P$=P$+Math.imul(H0,e$)|0,L$=L$+Math.imul(x$,i$)|0,R$=R$+Math.imul(x$,$Q)|0,R$=R$+Math.imul(G,i$)|0,P$=P$+Math.imul(G,$Q)|0,L$=L$+Math.imul(g$,YQ)|0,R$=R$+Math.imul(g$,X)|0,R$=R$+Math.imul(_$,YQ)|0,P$=P$+Math.imul(_$,X)|0,L$=L$+Math.imul(q$,ZQ)|0,R$=R$+Math.imul(q$,D0)|0,R$=R$+Math.imul(j$,ZQ)|0,P$=P$+Math.imul(j$,D0)|0,L$=L$+Math.imul(c,VQ)|0,R$=R$+Math.imul(c,UQ)|0,R$=R$+Math.imul(v$,VQ)|0,P$=P$+Math.imul(v$,UQ)|0,L$=L$+Math.imul(M$,KQ)|0,R$=R$+Math.imul(M$,IQ)|0,R$=R$+Math.imul(S$,KQ)|0,P$=P$+Math.imul(S$,IQ)|0;var DQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(DQ>>>26)|0,DQ&=67108863,L$=Math.imul(E0,o$),R$=Math.imul(E0,u$),R$=R$+Math.imul(b$,o$)|0,P$=Math.imul(b$,u$),L$=L$+Math.imul(V,s$)|0,R$=R$+Math.imul(V,t$)|0,R$=R$+Math.imul(h,s$)|0,P$=P$+Math.imul(h,t$)|0,L$=L$+Math.imul(c$,d)|0,R$=R$+Math.imul(c$,m$)|0,R$=R$+Math.imul(h$,d)|0,P$=P$+Math.imul(h$,m$)|0,L$=L$+Math.imul(w$,a$)|0,R$=R$+Math.imul(w$,e$)|0,R$=R$+Math.imul(p$,a$)|0,P$=P$+Math.imul(p$,e$)|0,L$=L$+Math.imul(B$,i$)|0,R$=R$+Math.imul(B$,$Q)|0,R$=R$+Math.imul(H0,i$)|0,P$=P$+Math.imul(H0,$Q)|0,L$=L$+Math.imul(x$,YQ)|0,R$=R$+Math.imul(x$,X)|0,R$=R$+Math.imul(G,YQ)|0,P$=P$+Math.imul(G,X)|0,L$=L$+Math.imul(g$,ZQ)|0,R$=R$+Math.imul(g$,D0)|0,R$=R$+Math.imul(_$,ZQ)|0,P$=P$+Math.imul(_$,D0)|0,L$=L$+Math.imul(q$,VQ)|0,R$=R$+Math.imul(q$,UQ)|0,R$=R$+Math.imul(j$,VQ)|0,P$=P$+Math.imul(j$,UQ)|0,L$=L$+Math.imul(c,KQ)|0,R$=R$+Math.imul(c,IQ)|0,R$=R$+Math.imul(v$,KQ)|0,P$=P$+Math.imul(v$,IQ)|0,L$=L$+Math.imul(M$,K)|0,R$=R$+Math.imul(M$,l)|0,R$=R$+Math.imul(S$,K)|0,P$=P$+Math.imul(S$,l)|0;var I=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(I>>>26)|0,I&=67108863,L$=Math.imul(E0,s$),R$=Math.imul(E0,t$),R$=R$+Math.imul(b$,s$)|0,P$=Math.imul(b$,t$),L$=L$+Math.imul(V,d)|0,R$=R$+Math.imul(V,m$)|0,R$=R$+Math.imul(h,d)|0,P$=P$+Math.imul(h,m$)|0,L$=L$+Math.imul(c$,a$)|0,R$=R$+Math.imul(c$,e$)|0,R$=R$+Math.imul(h$,a$)|0,P$=P$+Math.imul(h$,e$)|0,L$=L$+Math.imul(w$,i$)|0,R$=R$+Math.imul(w$,$Q)|0,R$=R$+Math.imul(p$,i$)|0,P$=P$+Math.imul(p$,$Q)|0,L$=L$+Math.imul(B$,YQ)|0,R$=R$+Math.imul(B$,X)|0,R$=R$+Math.imul(H0,YQ)|0,P$=P$+Math.imul(H0,X)|0,L$=L$+Math.imul(x$,ZQ)|0,R$=R$+Math.imul(x$,D0)|0,R$=R$+Math.imul(G,ZQ)|0,P$=P$+Math.imul(G,D0)|0,L$=L$+Math.imul(g$,VQ)|0,R$=R$+Math.imul(g$,UQ)|0,R$=R$+Math.imul(_$,VQ)|0,P$=P$+Math.imul(_$,UQ)|0,L$=L$+Math.imul(q$,KQ)|0,R$=R$+Math.imul(q$,IQ)|0,R$=R$+Math.imul(j$,KQ)|0,P$=P$+Math.imul(j$,IQ)|0,L$=L$+Math.imul(c,K)|0,R$=R$+Math.imul(c,l)|0,R$=R$+Math.imul(v$,K)|0,P$=P$+Math.imul(v$,l)|0;var o=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(o>>>26)|0,o&=67108863,L$=Math.imul(E0,d),R$=Math.imul(E0,m$),R$=R$+Math.imul(b$,d)|0,P$=Math.imul(b$,m$),L$=L$+Math.imul(V,a$)|0,R$=R$+Math.imul(V,e$)|0,R$=R$+Math.imul(h,a$)|0,P$=P$+Math.imul(h,e$)|0,L$=L$+Math.imul(c$,i$)|0,R$=R$+Math.imul(c$,$Q)|0,R$=R$+Math.imul(h$,i$)|0,P$=P$+Math.imul(h$,$Q)|0,L$=L$+Math.imul(w$,YQ)|0,R$=R$+Math.imul(w$,X)|0,R$=R$+Math.imul(p$,YQ)|0,P$=P$+Math.imul(p$,X)|0,L$=L$+Math.imul(B$,ZQ)|0,R$=R$+Math.imul(B$,D0)|0,R$=R$+Math.imul(H0,ZQ)|0,P$=P$+Math.imul(H0,D0)|0,L$=L$+Math.imul(x$,VQ)|0,R$=R$+Math.imul(x$,UQ)|0,R$=R$+Math.imul(G,VQ)|0,P$=P$+Math.imul(G,UQ)|0,L$=L$+Math.imul(g$,KQ)|0,R$=R$+Math.imul(g$,IQ)|0,R$=R$+Math.imul(_$,KQ)|0,P$=P$+Math.imul(_$,IQ)|0,L$=L$+Math.imul(q$,K)|0,R$=R$+Math.imul(q$,l)|0,R$=R$+Math.imul(j$,K)|0,P$=P$+Math.imul(j$,l)|0;var CQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(CQ>>>26)|0,CQ&=67108863,L$=Math.imul(E0,a$),R$=Math.imul(E0,e$),R$=R$+Math.imul(b$,a$)|0,P$=Math.imul(b$,e$),L$=L$+Math.imul(V,i$)|0,R$=R$+Math.imul(V,$Q)|0,R$=R$+Math.imul(h,i$)|0,P$=P$+Math.imul(h,$Q)|0,L$=L$+Math.imul(c$,YQ)|0,R$=R$+Math.imul(c$,X)|0,R$=R$+Math.imul(h$,YQ)|0,P$=P$+Math.imul(h$,X)|0,L$=L$+Math.imul(w$,ZQ)|0,R$=R$+Math.imul(w$,D0)|0,R$=R$+Math.imul(p$,ZQ)|0,P$=P$+Math.imul(p$,D0)|0,L$=L$+Math.imul(B$,VQ)|0,R$=R$+Math.imul(B$,UQ)|0,R$=R$+Math.imul(H0,VQ)|0,P$=P$+Math.imul(H0,UQ)|0,L$=L$+Math.imul(x$,KQ)|0,R$=R$+Math.imul(x$,IQ)|0,R$=R$+Math.imul(G,KQ)|0,P$=P$+Math.imul(G,IQ)|0,L$=L$+Math.imul(g$,K)|0,R$=R$+Math.imul(g$,l)|0,R$=R$+Math.imul(_$,K)|0,P$=P$+Math.imul(_$,l)|0;var L0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(L0>>>26)|0,L0&=67108863,L$=Math.imul(E0,i$),R$=Math.imul(E0,$Q),R$=R$+Math.imul(b$,i$)|0,P$=Math.imul(b$,$Q),L$=L$+Math.imul(V,YQ)|0,R$=R$+Math.imul(V,X)|0,R$=R$+Math.imul(h,YQ)|0,P$=P$+Math.imul(h,X)|0,L$=L$+Math.imul(c$,ZQ)|0,R$=R$+Math.imul(c$,D0)|0,R$=R$+Math.imul(h$,ZQ)|0,P$=P$+Math.imul(h$,D0)|0,L$=L$+Math.imul(w$,VQ)|0,R$=R$+Math.imul(w$,UQ)|0,R$=R$+Math.imul(p$,VQ)|0,P$=P$+Math.imul(p$,UQ)|0,L$=L$+Math.imul(B$,KQ)|0,R$=R$+Math.imul(B$,IQ)|0,R$=R$+Math.imul(H0,KQ)|0,P$=P$+Math.imul(H0,IQ)|0,L$=L$+Math.imul(x$,K)|0,R$=R$+Math.imul(x$,l)|0,R$=R$+Math.imul(G,K)|0,P$=P$+Math.imul(G,l)|0;var LQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(LQ>>>26)|0,LQ&=67108863,L$=Math.imul(E0,YQ),R$=Math.imul(E0,X),R$=R$+Math.imul(b$,YQ)|0,P$=Math.imul(b$,X),L$=L$+Math.imul(V,ZQ)|0,R$=R$+Math.imul(V,D0)|0,R$=R$+Math.imul(h,ZQ)|0,P$=P$+Math.imul(h,D0)|0,L$=L$+Math.imul(c$,VQ)|0,R$=R$+Math.imul(c$,UQ)|0,R$=R$+Math.imul(h$,VQ)|0,P$=P$+Math.imul(h$,UQ)|0,L$=L$+Math.imul(w$,KQ)|0,R$=R$+Math.imul(w$,IQ)|0,R$=R$+Math.imul(p$,KQ)|0,P$=P$+Math.imul(p$,IQ)|0,L$=L$+Math.imul(B$,K)|0,R$=R$+Math.imul(B$,l)|0,R$=R$+Math.imul(H0,K)|0,P$=P$+Math.imul(H0,l)|0;var RQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(RQ>>>26)|0,RQ&=67108863,L$=Math.imul(E0,ZQ),R$=Math.imul(E0,D0),R$=R$+Math.imul(b$,ZQ)|0,P$=Math.imul(b$,D0),L$=L$+Math.imul(V,VQ)|0,R$=R$+Math.imul(V,UQ)|0,R$=R$+Math.imul(h,VQ)|0,P$=P$+Math.imul(h,UQ)|0,L$=L$+Math.imul(c$,KQ)|0,R$=R$+Math.imul(c$,IQ)|0,R$=R$+Math.imul(h$,KQ)|0,P$=P$+Math.imul(h$,IQ)|0,L$=L$+Math.imul(w$,K)|0,R$=R$+Math.imul(w$,l)|0,R$=R$+Math.imul(p$,K)|0,P$=P$+Math.imul(p$,l)|0;var PQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(PQ>>>26)|0,PQ&=67108863,L$=Math.imul(E0,VQ),R$=Math.imul(E0,UQ),R$=R$+Math.imul(b$,VQ)|0,P$=Math.imul(b$,UQ),L$=L$+Math.imul(V,KQ)|0,R$=R$+Math.imul(V,IQ)|0,R$=R$+Math.imul(h,KQ)|0,P$=P$+Math.imul(h,IQ)|0,L$=L$+Math.imul(c$,K)|0,R$=R$+Math.imul(c$,l)|0,R$=R$+Math.imul(h$,K)|0,P$=P$+Math.imul(h$,l)|0;var zQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(zQ>>>26)|0,zQ&=67108863,L$=Math.imul(E0,KQ),R$=Math.imul(E0,IQ),R$=R$+Math.imul(b$,KQ)|0,P$=Math.imul(b$,IQ),L$=L$+Math.imul(V,K)|0,R$=R$+Math.imul(V,l)|0,R$=R$+Math.imul(h,K)|0,P$=P$+Math.imul(h,l)|0;var MQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(MQ>>>26)|0,MQ&=67108863,L$=Math.imul(E0,K),R$=Math.imul(E0,l),R$=R$+Math.imul(b$,K)|0,P$=Math.imul(b$,l);var SQ=(C$+L$|0)+((R$&8191)<<13)|0;return C$=(P$+(R$>>>13)|0)+(SQ>>>26)|0,SQ&=67108863,F0[0]=JQ,F0[1]=C0,F0[2]=FQ,F0[3]=AQ,F0[4]=HQ,F0[5]=WQ,F0[6]=EQ,F0[7]=TQ,F0[8]=DQ,F0[9]=I,F0[10]=o,F0[11]=CQ,F0[12]=L0,F0[13]=LQ,F0[14]=RQ,F0[15]=PQ,F0[16]=zQ,F0[17]=MQ,F0[18]=SQ,C$!==0&&(F0[19]=C$,Y.length++),Y};Math.imul||(X$=U$);function K$(E$,T$,Y){Y.negative=T$.negative^E$.negative,Y.length=E$.length+T$.length;for(var f=0,D$=0,F0=0;F0>>26)|0,D$+=C$>>>26,C$&=67108863}Y.words[F0]=L$,f=C$,C$=D$}return f!==0?Y.words[F0]=f:Y.length--,Y.strip()}function I$(E$,T$,Y){var f=new Q;return f.mulp(E$,T$,Y)}$$.prototype.mulTo=function(E$,T$){var Y,f=this.length+E$.length;return this.length===10&&E$.length===10?Y=X$(this,E$,T$):f<63?Y=U$(this,E$,T$):f<1024?Y=K$(this,E$,T$):Y=I$(this,E$,T$),Y};function Q(E$,T$){this.x=E$,this.y=T$}Q.prototype.makeRBT=function(E$){for(var T$=new Array(E$),Y=$$.prototype._countBits(E$)-1,f=0;f>=1;return f},Q.prototype.permute=function(E$,T$,Y,f,D$,F0){for(var C$=0;C$>>1)D$++;return 1<>>13,Y[2*F0+1]=D$&8191,D$=D$>>>13;for(F0=2*T$;F0>=26,T$+=f/67108864|0,T$+=D$>>>26,this.words[Y]=D$&67108863}return T$!==0&&(this.words[Y]=T$,this.length++),this},$$.prototype.muln=function(E$){return this.clone().imuln(E$)},$$.prototype.sqr=function(){return this.mul(this)},$$.prototype.isqr=function(){return this.imul(this.clone())},$$.prototype.pow=function(E$){var T$=V$(E$);if(T$.length===0)return new $$(1);for(var Y=this,f=0;f=0);var T$=E$%26,Y=(E$-T$)/26,f=67108863>>>26-T$<<26-T$,D$;if(T$!==0){var F0=0;for(D$=0;D$>>26-T$}F0&&(this.words[D$]=F0,this.length++)}if(Y!==0){for(D$=this.length-1;D$>=0;D$--)this.words[D$+Y]=this.words[D$];for(D$=0;D$=0);var f;T$?f=(T$-T$%26)/26:f=0;var D$=E$%26,F0=Math.min((E$-D$)/26,this.length),C$=67108863^67108863>>>D$<F0)for(this.length-=F0,R$=0;R$=0&&(P$!==0||R$>=f);R$--){var z$=this.words[R$]|0;this.words[R$]=P$<<26-D$|z$>>>D$,P$=z$&C$}return L$&&P$!==0&&(L$.words[L$.length++]=P$),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},$$.prototype.ishrn=function(E$,T$,Y){return r0(this.negative===0),this.iushrn(E$,T$,Y)},$$.prototype.shln=function(E$){return this.clone().ishln(E$)},$$.prototype.ushln=function(E$){return this.clone().iushln(E$)},$$.prototype.shrn=function(E$){return this.clone().ishrn(E$)},$$.prototype.ushrn=function(E$){return this.clone().iushrn(E$)},$$.prototype.testn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=E$%26,Y=(E$-T$)/26,f=1<=0);var T$=E$%26,Y=(E$-T$)/26;if(r0(this.negative===0,"imaskn works only with positive numbers"),this.length<=Y)return this;if(T$!==0&&Y++,this.length=Math.min(Y,this.length),T$!==0){var f=67108863^67108863>>>T$<=67108864;T$++)this.words[T$]-=67108864,T$===this.length-1?this.words[T$+1]=1:this.words[T$+1]++;return this.length=Math.max(this.length,T$+1),this},$$.prototype.isubn=function(E$){if(r0(typeof E$=="number"),r0(E$<67108864),E$<0)return this.iaddn(-E$);if(this.negative!==0)return this.negative=0,this.iaddn(E$),this.negative=1,this;if(this.words[0]-=E$,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var T$=0;T$>26)-(L$/67108864|0),this.words[D$+Y]=F0&67108863}for(;D$>26,this.words[D$+Y]=F0&67108863;if(C$===0)return this.strip();for(r0(C$===-1),C$=0,D$=0;D$>26,this.words[D$]=F0&67108863;return this.negative=1,this.strip()},$$.prototype._wordDiv=function(E$,T$){var Y=this.length-E$.length,f=this.clone(),D$=E$,F0=D$.words[D$.length-1]|0,C$=this._countBits(F0);Y=26-C$,Y!==0&&(D$=D$.ushln(Y),f.iushln(Y),F0=D$.words[D$.length-1]|0);var L$=f.length-D$.length,R$;if(T$!=="mod"){R$=new $$(null),R$.length=L$+1,R$.words=new Array(R$.length);for(var P$=0;P$=0;M$--){var S$=(f.words[D$.length+M$]|0)*67108864+(f.words[D$.length+M$-1]|0);for(S$=Math.min(S$/F0|0,67108863),f._ishlnsubmul(D$,S$,M$);f.negative!==0;)S$--,f.negative=0,f._ishlnsubmul(D$,1,M$),f.isZero()||(f.negative^=1);R$&&(R$.words[M$]=S$)}return R$&&R$.strip(),f.strip(),T$!=="div"&&Y!==0&&f.iushrn(Y),{div:R$||null,mod:f}},$$.prototype.divmod=function(E$,T$,Y){if(r0(!E$.isZero()),this.isZero())return{div:new $$(0),mod:new $$(0)};var f,D$,F0;return this.negative!==0&&E$.negative===0?(F0=this.neg().divmod(E$,T$),T$!=="mod"&&(f=F0.div.neg()),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.iadd(E$)),{div:f,mod:D$}):this.negative===0&&E$.negative!==0?(F0=this.divmod(E$.neg(),T$),T$!=="mod"&&(f=F0.div.neg()),{div:f,mod:F0.mod}):(this.negative&E$.negative)!==0?(F0=this.neg().divmod(E$.neg(),T$),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.isub(E$)),{div:F0.div,mod:D$}):E$.length>this.length||this.cmp(E$)<0?{div:new $$(0),mod:this}:E$.length===1?T$==="div"?{div:this.divn(E$.words[0]),mod:null}:T$==="mod"?{div:null,mod:new $$(this.modn(E$.words[0]))}:{div:this.divn(E$.words[0]),mod:new $$(this.modn(E$.words[0]))}:this._wordDiv(E$,T$)},$$.prototype.div=function(E$){return this.divmod(E$,"div",!1).div},$$.prototype.mod=function(E$){return this.divmod(E$,"mod",!1).mod},$$.prototype.umod=function(E$){return this.divmod(E$,"mod",!0).mod},$$.prototype.divRound=function(E$){var T$=this.divmod(E$);if(T$.mod.isZero())return T$.div;var Y=T$.div.negative!==0?T$.mod.isub(E$):T$.mod,f=E$.ushrn(1),D$=E$.andln(1),F0=Y.cmp(f);return F0<0||D$===1&&F0===0?T$.div:T$.div.negative!==0?T$.div.isubn(1):T$.div.iaddn(1)},$$.prototype.modn=function(E$){r0(E$<=67108863);for(var T$=(1<<26)%E$,Y=0,f=this.length-1;f>=0;f--)Y=(T$*Y+(this.words[f]|0))%E$;return Y},$$.prototype.idivn=function(E$){r0(E$<=67108863);for(var T$=0,Y=this.length-1;Y>=0;Y--){var f=(this.words[Y]|0)+T$*67108864;this.words[Y]=f/E$|0,T$=f%E$}return this.strip()},$$.prototype.divn=function(E$){return this.clone().idivn(E$)},$$.prototype.egcd=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=new $$(0),C$=new $$(1),L$=0;T$.isEven()&&Y.isEven();)T$.iushrn(1),Y.iushrn(1),++L$;for(var R$=Y.clone(),P$=T$.clone();!T$.isZero();){for(var z$=0,M$=1;(T$.words[0]&M$)===0&&z$<26;++z$,M$<<=1);if(z$>0)for(T$.iushrn(z$);z$-- >0;)(f.isOdd()||D$.isOdd())&&(f.iadd(R$),D$.isub(P$)),f.iushrn(1),D$.iushrn(1);for(var S$=0,Z=1;(Y.words[0]&Z)===0&&S$<26;++S$,Z<<=1);if(S$>0)for(Y.iushrn(S$);S$-- >0;)(F0.isOdd()||C$.isOdd())&&(F0.iadd(R$),C$.isub(P$)),F0.iushrn(1),C$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(F0),D$.isub(C$)):(Y.isub(T$),F0.isub(f),C$.isub(D$))}return{a:F0,b:C$,gcd:Y.iushln(L$)}},$$.prototype._invmp=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=Y.clone();T$.cmpn(1)>0&&Y.cmpn(1)>0;){for(var C$=0,L$=1;(T$.words[0]&L$)===0&&C$<26;++C$,L$<<=1);if(C$>0)for(T$.iushrn(C$);C$-- >0;)f.isOdd()&&f.iadd(F0),f.iushrn(1);for(var R$=0,P$=1;(Y.words[0]&P$)===0&&R$<26;++R$,P$<<=1);if(R$>0)for(Y.iushrn(R$);R$-- >0;)D$.isOdd()&&D$.iadd(F0),D$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(D$)):(Y.isub(T$),D$.isub(f))}var z$;return T$.cmpn(1)===0?z$=f:z$=D$,z$.cmpn(0)<0&&z$.iadd(E$),z$},$$.prototype.gcd=function(E$){if(this.isZero())return E$.abs();if(E$.isZero())return this.abs();var T$=this.clone(),Y=E$.clone();T$.negative=0,Y.negative=0;for(var f=0;T$.isEven()&&Y.isEven();f++)T$.iushrn(1),Y.iushrn(1);do{for(;T$.isEven();)T$.iushrn(1);for(;Y.isEven();)Y.iushrn(1);var D$=T$.cmp(Y);if(D$<0){var F0=T$;T$=Y,Y=F0}else if(D$===0||Y.cmpn(1)===0)break;T$.isub(Y)}while(!0);return Y.iushln(f)},$$.prototype.invm=function(E$){return this.egcd(E$).a.umod(E$)},$$.prototype.isEven=function(){return(this.words[0]&1)===0},$$.prototype.isOdd=function(){return(this.words[0]&1)===1},$$.prototype.andln=function(E$){return this.words[0]&E$},$$.prototype.bincn=function(E$){r0(typeof E$=="number");var T$=E$%26,Y=(E$-T$)/26,f=1<>>26,C$&=67108863,this.words[F0]=C$}return D$!==0&&(this.words[F0]=D$,this.length++),this},$$.prototype.isZero=function(){return this.length===1&&this.words[0]===0},$$.prototype.cmpn=function(E$){var T$=E$<0;if(this.negative!==0&&!T$)return-1;if(this.negative===0&&T$)return 1;this.strip();var Y;if(this.length>1)Y=1;else{T$&&(E$=-E$),r0(E$<=67108863,"Number is too big");var f=this.words[0]|0;Y=f===E$?0:fE$.length)return 1;if(this.length=0;Y--){var f=this.words[Y]|0,D$=E$.words[Y]|0;if(f!==D$){fD$&&(T$=1);break}}return T$},$$.prototype.gtn=function(E$){return this.cmpn(E$)===1},$$.prototype.gt=function(E$){return this.cmp(E$)===1},$$.prototype.gten=function(E$){return this.cmpn(E$)>=0},$$.prototype.gte=function(E$){return this.cmp(E$)>=0},$$.prototype.ltn=function(E$){return this.cmpn(E$)===-1},$$.prototype.lt=function(E$){return this.cmp(E$)===-1},$$.prototype.lten=function(E$){return this.cmpn(E$)<=0},$$.prototype.lte=function(E$){return this.cmp(E$)<=0},$$.prototype.eqn=function(E$){return this.cmpn(E$)===0},$$.prototype.eq=function(E$){return this.cmp(E$)===0},$$.red=function(E$){return new H$(E$)},$$.prototype.toRed=function(E$){return r0(!this.red,"Already a number in reduction context"),r0(this.negative===0,"red works only with positives"),E$.convertTo(this)._forceRed(E$)},$$.prototype.fromRed=function(){return r0(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},$$.prototype._forceRed=function(E$){return this.red=E$,this},$$.prototype.forceRed=function(E$){return r0(!this.red,"Already a number in reduction context"),this._forceRed(E$)},$$.prototype.redAdd=function(E$){return r0(this.red,"redAdd works only with red numbers"),this.red.add(this,E$)},$$.prototype.redIAdd=function(E$){return r0(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,E$)},$$.prototype.redSub=function(E$){return r0(this.red,"redSub works only with red numbers"),this.red.sub(this,E$)},$$.prototype.redISub=function(E$){return r0(this.red,"redISub works only with red numbers"),this.red.isub(this,E$)},$$.prototype.redShl=function(E$){return r0(this.red,"redShl works only with red numbers"),this.red.shl(this,E$)},$$.prototype.redMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.mul(this,E$)},$$.prototype.redIMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.imul(this,E$)},$$.prototype.redSqr=function(){return r0(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},$$.prototype.redISqr=function(){return r0(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},$$.prototype.redSqrt=function(){return r0(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},$$.prototype.redInvm=function(){return r0(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},$$.prototype.redNeg=function(){return r0(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},$$.prototype.redPow=function(E$){return r0(this.red&&!E$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,E$)};var x={k256:null,p224:null,p192:null,p25519:null};function O$(E$,T$){this.name=E$,this.p=new $$(T$,16),this.n=this.p.bitLength(),this.k=new $$(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}O$.prototype._tmp=function(){var E$=new $$(null);return E$.words=new Array(Math.ceil(this.n/13)),E$},O$.prototype.ireduce=function(E$){var T$=E$,Y;do this.split(T$,this.tmp),T$=this.imulK(T$),T$=T$.iadd(this.tmp),Y=T$.bitLength();while(Y>this.n);var f=Y0?T$.isub(this.p):T$.strip!==void 0?T$.strip():T$._strip(),T$},O$.prototype.split=function(E$,T$){E$.iushrn(this.n,0,T$)},O$.prototype.imulK=function(E$){return E$.imul(this.k)};function J0(){O$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i0(J0,O$),J0.prototype.split=function(E$,T$){for(var Y=4194303,f=Math.min(E$.length,9),D$=0;D$>>22,F0=C$}F0>>>=22,E$.words[D$-10]=F0,F0===0&&E$.length>10?E$.length-=10:E$.length-=9},J0.prototype.imulK=function(E$){E$.words[E$.length]=0,E$.words[E$.length+1]=0,E$.length+=2;for(var T$=0,Y=0;Y>>=26,E$.words[Y]=D$,T$=f}return T$!==0&&(E$.words[E$.length++]=T$),E$},$$._prime=function(E$){if(x[E$])return x[E$];var T$;if(E$==="k256")T$=new J0;else if(E$==="p224")T$=new J$;else if(E$==="p192")T$=new F$;else if(E$==="p25519")T$=new A$;else throw new Error("Unknown prime "+E$);return x[E$]=T$,T$};function H$(E$){if(typeof E$=="string"){var T$=$$._prime(E$);this.m=T$.p,this.prime=T$}else r0(E$.gtn(1),"modulus must be greater than 1"),this.m=E$,this.prime=null}H$.prototype._verify1=function(E$){r0(E$.negative===0,"red works only with positives"),r0(E$.red,"red works only with red numbers")},H$.prototype._verify2=function(E$,T$){r0((E$.negative|T$.negative)===0,"red works only with positives"),r0(E$.red&&E$.red===T$.red,"red works only with red numbers")},H$.prototype.imod=function(E$){return this.prime?this.prime.ireduce(E$)._forceRed(this):E$.umod(this.m)._forceRed(this)},H$.prototype.neg=function(E$){return E$.isZero()?E$.clone():this.m.sub(E$)._forceRed(this)},H$.prototype.add=function(E$,T$){this._verify2(E$,T$);var Y=E$.add(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y._forceRed(this)},H$.prototype.iadd=function(E$,T$){this._verify2(E$,T$);var Y=E$.iadd(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y},H$.prototype.sub=function(E$,T$){this._verify2(E$,T$);var Y=E$.sub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y._forceRed(this)},H$.prototype.isub=function(E$,T$){this._verify2(E$,T$);var Y=E$.isub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y},H$.prototype.shl=function(E$,T$){return this._verify1(E$),this.imod(E$.ushln(T$))},H$.prototype.imul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.imul(T$))},H$.prototype.mul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.mul(T$))},H$.prototype.isqr=function(E$){return this.imul(E$,E$.clone())},H$.prototype.sqr=function(E$){return this.mul(E$,E$)},H$.prototype.sqrt=function(E$){if(E$.isZero())return E$.clone();var T$=this.m.andln(3);if(r0(T$%2===1),T$===3){var Y=this.m.add(new $$(1)).iushrn(2);return this.pow(E$,Y)}for(var f=this.m.subn(1),D$=0;!f.isZero()&&f.andln(1)===0;)D$++,f.iushrn(1);r0(!f.isZero());var F0=new $$(1).toRed(this),C$=F0.redNeg(),L$=this.m.subn(1).iushrn(1),R$=this.m.bitLength();for(R$=new $$(2*R$*R$).toRed(this);this.pow(R$,L$).cmp(C$)!==0;)R$.redIAdd(C$);for(var P$=this.pow(R$,f),z$=this.pow(E$,f.addn(1).iushrn(1)),M$=this.pow(E$,f),S$=D$;M$.cmp(F0)!==0;){for(var Z=M$,c=0;Z.cmp(F0)!==0;c++)Z=Z.redSqr();r0(c=0;D$--){for(var P$=T$.words[D$],z$=R$-1;z$>=0;z$--){var M$=P$>>z$&1;if(F0!==f[0]&&(F0=this.sqr(F0)),M$===0&&C$===0){L$=0;continue}C$<<=1,C$|=M$,L$++,!(L$!==Y&&(D$!==0||z$!==0))&&(F0=this.mul(F0,f[C$]),L$=0,C$=0)}R$=26}return F0},H$.prototype.convertTo=function(E$){var T$=E$.umod(this.m);return T$===E$?T$.clone():T$},H$.prototype.convertFrom=function(E$){var T$=E$.clone();return T$.red=null,T$},$$.mont=function(E$){return new W$(E$)};function W$(E$){H$.call(this,E$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new $$(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)}i0(W$,H$),W$.prototype.convertTo=function(E$){return this.imod(E$.ushln(this.shift))},W$.prototype.convertFrom=function(E$){var T$=this.imod(E$.mul(this.rinv));return T$.red=null,T$},W$.prototype.imul=function(E$,T$){if(E$.isZero()||T$.isZero())return E$.words[0]=0,E$.length=1,E$;var Y=E$.imul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.mul=function(E$,T$){if(E$.isZero()||T$.isZero())return new $$(0)._forceRed(this);var Y=E$.mul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.invm=function(E$){var T$=this.imod(E$._invmp(this.m).mul(this.r2));return T$._forceRed(this)}})(typeof m0>"u"||m0,t0)}}),gY=pQ({"node_modules/minimalistic-crypto-utils/lib/utils.js"(t0){var m0=t0;function a0(i0,$$){if(Array.isArray(i0))return i0.slice();if(!i0)return[];var Q$=[];if(typeof i0!="string"){for(var $=0;$>8,O0=N&255;Y$?Q$.push(Y$,O0):Q$.push(O0)}return Q$}m0.toArray=a0;function e0(i0){return i0.length===1?"0"+i0:i0}m0.zero2=e0;function r0(i0){for(var $$="",Q$=0;Q$(V$>>1)-1?K$=(V$>>1)-I$:K$=I$,U$.isubn(K$)):K$=0,G$[X$]=K$,U$.iushrn(1)}return G$}m0.getNAF=i0;function $$(Y$,O0){var Z$=[[],[]];Y$=Y$.clone(),O0=O0.clone();for(var G$=0,V$=0,U$;Y$.cmpn(-G$)>0||O0.cmpn(-V$)>0;){var X$=Y$.andln(3)+G$&3,K$=O0.andln(3)+V$&3;X$===3&&(X$=-1),K$===3&&(K$=-1);var I$;(X$&1)===0?I$=0:(U$=Y$.andln(7)+G$&7,(U$===3||U$===5)&&K$===2?I$=-X$:I$=X$),Z$[0].push(I$);var Q;(K$&1)===0?Q=0:(U$=O0.andln(7)+V$&7,(U$===3||U$===5)&&X$===2?Q=-K$:Q=K$),Z$[1].push(Q),2*G$===I$+1&&(G$=1-G$),2*V$===Q+1&&(V$=1-V$),Y$.iushrn(1),O0.iushrn(1)}return Z$}m0.getJSF=$$;function Q$(Y$,O0,Z$){var G$="_"+O0;Y$.prototype[O0]=function(){return this[G$]!==void 0?this[G$]:this[G$]=Z$.call(this)}}m0.cachedProperty=Q$;function $(Y$){return typeof Y$=="string"?m0.toArray(Y$,"hex"):Y$}m0.parseBytes=$;function N(Y$){return new a0(Y$,"hex","le")}m0.intFromLE=N}}),m=pQ({"node_modules/elliptic/lib/elliptic/curve/base.js"(t0,m0){var a0=kY(),e0=D(),r0=e0.getNAF,i0=e0.getJSF,$$=e0.assert;function Q$(N,Y$){this.type=N,this.p=new a0(Y$.p,16),this.red=Y$.prime?a0.red(Y$.prime):a0.mont(this.p),this.zero=new a0(0).toRed(this.red),this.one=new a0(1).toRed(this.red),this.two=new a0(2).toRed(this.red),this.n=Y$.n&&new a0(Y$.n,16),this.g=Y$.g&&this.pointFromJSON(Y$.g,Y$.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 O0=this.n&&this.p.div(this.n);!O0||O0.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}m0.exports=Q$,Q$.prototype.point=function(){throw new Error("Not implemented")},Q$.prototype.validate=function(){throw new Error("Not implemented")},Q$.prototype._fixedNafMul=function(N,Y$){$$(N.precomputed);var O0=N._getDoubles(),Z$=r0(Y$,1,this._bitLength),G$=(1<=U$;K$--)X$=(X$<<1)+Z$[K$];V$.push(X$)}for(var I$=this.jpoint(null,null,null),Q=this.jpoint(null,null,null),x=G$;x>0;x--){for(U$=0;U$=0;X$--){for(var K$=0;X$>=0&&V$[X$]===0;X$--)K$++;if(X$>=0&&K$++,U$=U$.dblp(K$),X$<0)break;var I$=V$[X$];$$(I$!==0),N.type==="affine"?I$>0?U$=U$.mixedAdd(G$[I$-1>>1]):U$=U$.mixedAdd(G$[-I$-1>>1].neg()):I$>0?U$=U$.add(G$[I$-1>>1]):U$=U$.add(G$[-I$-1>>1].neg())}return N.type==="affine"?U$.toP():U$},Q$.prototype._wnafMulAdd=function(N,Y$,O0,Z$,G$){var V$=this._wnafT1,U$=this._wnafT2,X$=this._wnafT3,K$=0,I$,Q,x;for(I$=0;I$=1;I$-=2){var J0=I$-1,J$=I$;if(V$[J0]!==1||V$[J$]!==1){X$[J0]=r0(O0[J0],V$[J0],this._bitLength),X$[J$]=r0(O0[J$],V$[J$],this._bitLength),K$=Math.max(X$[J0].length,K$),K$=Math.max(X$[J$].length,K$);continue}var F$=[Y$[J0],null,null,Y$[J$]];Y$[J0].y.cmp(Y$[J$].y)===0?(F$[1]=Y$[J0].add(Y$[J$]),F$[2]=Y$[J0].toJ().mixedAdd(Y$[J$].neg())):Y$[J0].y.cmp(Y$[J$].y.redNeg())===0?(F$[1]=Y$[J0].toJ().mixedAdd(Y$[J$]),F$[2]=Y$[J0].add(Y$[J$].neg())):(F$[1]=Y$[J0].toJ().mixedAdd(Y$[J$]),F$[2]=Y$[J0].toJ().mixedAdd(Y$[J$].neg()));var A$=[-3,-1,-5,-7,0,7,5,1,3],H$=i0(O0[J0],O0[J$]);for(K$=Math.max(H$[0].length,K$),X$[J0]=new Array(K$),X$[J$]=new Array(K$),Q=0;Q=0;I$--){for(var f=0;I$>=0;){var D$=!0;for(Q=0;Q=0&&f++,T$=T$.dblp(f),I$<0)break;for(Q=0;Q0?x=U$[Q][F0-1>>1]:F0<0&&(x=U$[Q][-F0-1>>1].neg()),x.type==="affine"?T$=T$.mixedAdd(x):T$=T$.add(x))}}for(I$=0;I$=Math.ceil((N.bitLength()+1)/Y$.step):!1},$.prototype._getDoubles=function(N,Y$){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var O0=[this],Z$=this,G$=0;G$=0&&(J0=I$,J$=Q),x.negative&&(x=x.neg(),O$=O$.neg()),J0.negative&&(J0=J0.neg(),J$=J$.neg()),[{a:x,b:O$},{a:J0,b:J$}]},Q$.prototype._endoSplit=function(Y$){var O0=this.endo.basis,Z$=O0[0],G$=O0[1],V$=G$.b.mul(Y$).divRound(this.n),U$=Z$.b.neg().mul(Y$).divRound(this.n),X$=V$.mul(Z$.a),K$=U$.mul(G$.a),I$=V$.mul(Z$.b),Q=U$.mul(G$.b),x=Y$.sub(X$).sub(K$),O$=I$.add(Q).neg();return{k1:x,k2:O$}},Q$.prototype.pointFromX=function(Y$,O0){Y$=new e0(Y$,16),Y$.red||(Y$=Y$.toRed(this.red));var Z$=Y$.redSqr().redMul(Y$).redIAdd(Y$.redMul(this.a)).redIAdd(this.b),G$=Z$.redSqrt();if(G$.redSqr().redSub(Z$).cmp(this.zero)!==0)throw new Error("invalid point");var V$=G$.fromRed().isOdd();return(O0&&!V$||!O0&&V$)&&(G$=G$.redNeg()),this.point(Y$,G$)},Q$.prototype.validate=function(Y$){if(Y$.inf)return!0;var{x:O0,y:Z$}=Y$,G$=this.a.redMul(O0),V$=O0.redSqr().redMul(O0).redIAdd(G$).redIAdd(this.b);return Z$.redSqr().redISub(V$).cmpn(0)===0},Q$.prototype._endoWnafMulAdd=function(Y$,O0,Z$){for(var G$=this._endoWnafT1,V$=this._endoWnafT2,U$=0;U$":""},$.prototype.isInfinity=function(){return this.inf},$.prototype.add=function(Y$){if(this.inf)return Y$;if(Y$.inf)return this;if(this.eq(Y$))return this.dbl();if(this.neg().eq(Y$))return this.curve.point(null,null);if(this.x.cmp(Y$.x)===0)return this.curve.point(null,null);var O0=this.y.redSub(Y$.y);O0.cmpn(0)!==0&&(O0=O0.redMul(this.x.redSub(Y$.x).redInvm()));var Z$=O0.redSqr().redISub(this.x).redISub(Y$.x),G$=O0.redMul(this.x.redSub(Z$)).redISub(this.y);return this.curve.point(Z$,G$)},$.prototype.dbl=function(){if(this.inf)return this;var Y$=this.y.redAdd(this.y);if(Y$.cmpn(0)===0)return this.curve.point(null,null);var O0=this.curve.a,Z$=this.x.redSqr(),G$=Y$.redInvm(),V$=Z$.redAdd(Z$).redIAdd(Z$).redIAdd(O0).redMul(G$),U$=V$.redSqr().redISub(this.x.redAdd(this.x)),X$=V$.redMul(this.x.redSub(U$)).redISub(this.y);return this.curve.point(U$,X$)},$.prototype.getX=function(){return this.x.fromRed()},$.prototype.getY=function(){return this.y.fromRed()},$.prototype.mul=function(Y$){return Y$=new e0(Y$,16),this.isInfinity()?this:this._hasDoubles(Y$)?this.curve._fixedNafMul(this,Y$):this.curve.endo?this.curve._endoWnafMulAdd([this],[Y$]):this.curve._wnafMul(this,Y$)},$.prototype.mulAdd=function(Y$,O0,Z$){var G$=[this,O0],V$=[Y$,Z$];return this.curve.endo?this.curve._endoWnafMulAdd(G$,V$):this.curve._wnafMulAdd(1,G$,V$,2)},$.prototype.jmulAdd=function(Y$,O0,Z$){var G$=[this,O0],V$=[Y$,Z$];return this.curve.endo?this.curve._endoWnafMulAdd(G$,V$,!0):this.curve._wnafMulAdd(1,G$,V$,2,!0)},$.prototype.eq=function(Y$){return this===Y$||this.inf===Y$.inf&&(this.inf||this.x.cmp(Y$.x)===0&&this.y.cmp(Y$.y)===0)},$.prototype.neg=function(Y$){if(this.inf)return this;var O0=this.curve.point(this.x,this.y.redNeg());if(Y$&&this.precomputed){var Z$=this.precomputed,G$=function(V$){return V$.neg()};O0.precomputed={naf:Z$.naf&&{wnd:Z$.naf.wnd,points:Z$.naf.points.map(G$)},doubles:Z$.doubles&&{step:Z$.doubles.step,points:Z$.doubles.points.map(G$)}}}return O0},$.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var Y$=this.curve.jpoint(this.x,this.y,this.curve.one);return Y$};function N(Y$,O0,Z$,G$){i0.BasePoint.call(this,Y$,"jacobian"),O0===null&&Z$===null&&G$===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new e0(0)):(this.x=new e0(O0,16),this.y=new e0(Z$,16),this.z=new e0(G$,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}r0(N,i0.BasePoint),Q$.prototype.jpoint=function(Y$,O0,Z$){return new N(this,Y$,O0,Z$)},N.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var Y$=this.z.redInvm(),O0=Y$.redSqr(),Z$=this.x.redMul(O0),G$=this.y.redMul(O0).redMul(Y$);return this.curve.point(Z$,G$)},N.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},N.prototype.add=function(Y$){if(this.isInfinity())return Y$;if(Y$.isInfinity())return this;var O0=Y$.z.redSqr(),Z$=this.z.redSqr(),G$=this.x.redMul(O0),V$=Y$.x.redMul(Z$),U$=this.y.redMul(O0.redMul(Y$.z)),X$=Y$.y.redMul(Z$.redMul(this.z)),K$=G$.redSub(V$),I$=U$.redSub(X$);if(K$.cmpn(0)===0)return I$.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var Q=K$.redSqr(),x=Q.redMul(K$),O$=G$.redMul(Q),J0=I$.redSqr().redIAdd(x).redISub(O$).redISub(O$),J$=I$.redMul(O$.redISub(J0)).redISub(U$.redMul(x)),F$=this.z.redMul(Y$.z).redMul(K$);return this.curve.jpoint(J0,J$,F$)},N.prototype.mixedAdd=function(Y$){if(this.isInfinity())return Y$.toJ();if(Y$.isInfinity())return this;var O0=this.z.redSqr(),Z$=this.x,G$=Y$.x.redMul(O0),V$=this.y,U$=Y$.y.redMul(O0).redMul(this.z),X$=Z$.redSub(G$),K$=V$.redSub(U$);if(X$.cmpn(0)===0)return K$.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var I$=X$.redSqr(),Q=I$.redMul(X$),x=Z$.redMul(I$),O$=K$.redSqr().redIAdd(Q).redISub(x).redISub(x),J0=K$.redMul(x.redISub(O$)).redISub(V$.redMul(Q)),J$=this.z.redMul(X$);return this.curve.jpoint(O$,J0,J$)},N.prototype.dblp=function(Y$){if(Y$===0)return this;if(this.isInfinity())return this;if(!Y$)return this.dbl();var O0;if(this.curve.zeroA||this.curve.threeA){var Z$=this;for(O0=0;O0=0)return!1;if(Z$.redIAdd(V$),this.x.cmp(Z$)===0)return!0}},N.prototype.inspect=function(){return this.isInfinity()?"":""},N.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),B0=pQ({"node_modules/elliptic/lib/elliptic/curve/mont.js"(t0,m0){var a0=kY(),e0=dQ(),r0=m(),i0=D();function $$($){r0.call(this,"mont",$),this.a=new a0($.a,16).toRed(this.red),this.b=new a0($.b,16).toRed(this.red),this.i4=new a0(4).toRed(this.red).redInvm(),this.two=new a0(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}e0($$,r0),m0.exports=$$,$$.prototype.validate=function($){var N=$.normalize().x,Y$=N.redSqr(),O0=Y$.redMul(N).redAdd(Y$.redMul(this.a)).redAdd(N),Z$=O0.redSqrt();return Z$.redSqr().cmp(O0)===0};function Q$($,N,Y$){r0.BasePoint.call(this,$,"projective"),N===null&&Y$===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new a0(N,16),this.z=new a0(Y$,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}e0(Q$,r0.BasePoint),$$.prototype.decodePoint=function($,N){return this.point(i0.toArray($,N),1)},$$.prototype.point=function($,N){return new Q$(this,$,N)},$$.prototype.pointFromJSON=function($){return Q$.fromJSON(this,$)},Q$.prototype.precompute=function(){},Q$.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Q$.fromJSON=function($,N){return new Q$($,N[0],N[1]||$.one)},Q$.prototype.inspect=function(){return this.isInfinity()?"":""},Q$.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Q$.prototype.dbl=function(){var $=this.x.redAdd(this.z),N=$.redSqr(),Y$=this.x.redSub(this.z),O0=Y$.redSqr(),Z$=N.redSub(O0),G$=N.redMul(O0),V$=Z$.redMul(O0.redAdd(this.curve.a24.redMul(Z$)));return this.curve.point(G$,V$)},Q$.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Q$.prototype.diffAdd=function($,N){var Y$=this.x.redAdd(this.z),O0=this.x.redSub(this.z),Z$=$.x.redAdd($.z),G$=$.x.redSub($.z),V$=G$.redMul(Y$),U$=Z$.redMul(O0),X$=N.z.redMul(V$.redAdd(U$).redSqr()),K$=N.x.redMul(V$.redISub(U$).redSqr());return this.curve.point(X$,K$)},Q$.prototype.mul=function($){for(var N=$.clone(),Y$=this,O0=this.curve.point(null,null),Z$=this,G$=[];N.cmpn(0)!==0;N.iushrn(1))G$.push(N.andln(1));for(var V$=G$.length-1;V$>=0;V$--)G$[V$]===0?(Y$=Y$.diffAdd(O0,Z$),O0=O0.dbl()):(O0=Y$.diffAdd(O0,Z$),Y$=Y$.dbl());return O0},Q$.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Q$.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Q$.prototype.eq=function($){return this.getX().cmp($.getX())===0},Q$.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Q$.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),_Y=pQ({"node_modules/elliptic/lib/elliptic/curve/edwards.js"(t0,m0){var a0=D(),e0=kY(),r0=dQ(),i0=m(),$$=a0.assert;function Q$(N){this.twisted=(N.a|0)!==1,this.mOneA=this.twisted&&(N.a|0)===-1,this.extended=this.mOneA,i0.call(this,"edwards",N),this.a=new e0(N.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new e0(N.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new e0(N.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),$$(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(N.c|0)===1}r0(Q$,i0),m0.exports=Q$,Q$.prototype._mulA=function(N){return this.mOneA?N.redNeg():this.a.redMul(N)},Q$.prototype._mulC=function(N){return this.oneC?N:this.c.redMul(N)},Q$.prototype.jpoint=function(N,Y$,O0,Z$){return this.point(N,Y$,O0,Z$)},Q$.prototype.pointFromX=function(N,Y$){N=new e0(N,16),N.red||(N=N.toRed(this.red));var O0=N.redSqr(),Z$=this.c2.redSub(this.a.redMul(O0)),G$=this.one.redSub(this.c2.redMul(this.d).redMul(O0)),V$=Z$.redMul(G$.redInvm()),U$=V$.redSqrt();if(U$.redSqr().redSub(V$).cmp(this.zero)!==0)throw new Error("invalid point");var X$=U$.fromRed().isOdd();return(Y$&&!X$||!Y$&&X$)&&(U$=U$.redNeg()),this.point(N,U$)},Q$.prototype.pointFromY=function(N,Y$){N=new e0(N,16),N.red||(N=N.toRed(this.red));var O0=N.redSqr(),Z$=O0.redSub(this.c2),G$=O0.redMul(this.d).redMul(this.c2).redSub(this.a),V$=Z$.redMul(G$.redInvm());if(V$.cmp(this.zero)===0){if(Y$)throw new Error("invalid point");return this.point(this.zero,N)}var U$=V$.redSqrt();if(U$.redSqr().redSub(V$).cmp(this.zero)!==0)throw new Error("invalid point");return U$.fromRed().isOdd()!==Y$&&(U$=U$.redNeg()),this.point(U$,N)},Q$.prototype.validate=function(N){if(N.isInfinity())return!0;N.normalize();var Y$=N.x.redSqr(),O0=N.y.redSqr(),Z$=Y$.redMul(this.a).redAdd(O0),G$=this.c2.redMul(this.one.redAdd(this.d.redMul(Y$).redMul(O0)));return Z$.cmp(G$)===0};function $(N,Y$,O0,Z$,G$){i0.BasePoint.call(this,N,"projective"),Y$===null&&O0===null&&Z$===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 e0(Y$,16),this.y=new e0(O0,16),this.z=Z$?new e0(Z$,16):this.curve.one,this.t=G$&&new e0(G$,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()))))}r0($,i0.BasePoint),Q$.prototype.pointFromJSON=function(N){return $.fromJSON(this,N)},Q$.prototype.point=function(N,Y$,O0,Z$){return new $(this,N,Y$,O0,Z$)},$.fromJSON=function(N,Y$){return new $(N,Y$[0],Y$[1],Y$[2])},$.prototype.inspect=function(){return this.isInfinity()?"":""},$.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},$.prototype._extDbl=function(){var N=this.x.redSqr(),Y$=this.y.redSqr(),O0=this.z.redSqr();O0=O0.redIAdd(O0);var Z$=this.curve._mulA(N),G$=this.x.redAdd(this.y).redSqr().redISub(N).redISub(Y$),V$=Z$.redAdd(Y$),U$=V$.redSub(O0),X$=Z$.redSub(Y$),K$=G$.redMul(U$),I$=V$.redMul(X$),Q=G$.redMul(X$),x=U$.redMul(V$);return this.curve.point(K$,I$,x,Q)},$.prototype._projDbl=function(){var N=this.x.redAdd(this.y).redSqr(),Y$=this.x.redSqr(),O0=this.y.redSqr(),Z$,G$,V$,U$,X$,K$;if(this.curve.twisted){U$=this.curve._mulA(Y$);var I$=U$.redAdd(O0);this.zOne?(Z$=N.redSub(Y$).redSub(O0).redMul(I$.redSub(this.curve.two)),G$=I$.redMul(U$.redSub(O0)),V$=I$.redSqr().redSub(I$).redSub(I$)):(X$=this.z.redSqr(),K$=I$.redSub(X$).redISub(X$),Z$=N.redSub(Y$).redISub(O0).redMul(K$),G$=I$.redMul(U$.redSub(O0)),V$=I$.redMul(K$))}else U$=Y$.redAdd(O0),X$=this.curve._mulC(this.z).redSqr(),K$=U$.redSub(X$).redSub(X$),Z$=this.curve._mulC(N.redISub(U$)).redMul(K$),G$=this.curve._mulC(U$).redMul(Y$.redISub(O0)),V$=U$.redMul(K$);return this.curve.point(Z$,G$,V$)},$.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},$.prototype._extAdd=function(N){var Y$=this.y.redSub(this.x).redMul(N.y.redSub(N.x)),O0=this.y.redAdd(this.x).redMul(N.y.redAdd(N.x)),Z$=this.t.redMul(this.curve.dd).redMul(N.t),G$=this.z.redMul(N.z.redAdd(N.z)),V$=O0.redSub(Y$),U$=G$.redSub(Z$),X$=G$.redAdd(Z$),K$=O0.redAdd(Y$),I$=V$.redMul(U$),Q=X$.redMul(K$),x=V$.redMul(K$),O$=U$.redMul(X$);return this.curve.point(I$,Q,O$,x)},$.prototype._projAdd=function(N){var Y$=this.z.redMul(N.z),O0=Y$.redSqr(),Z$=this.x.redMul(N.x),G$=this.y.redMul(N.y),V$=this.curve.d.redMul(Z$).redMul(G$),U$=O0.redSub(V$),X$=O0.redAdd(V$),K$=this.x.redAdd(this.y).redMul(N.x.redAdd(N.y)).redISub(Z$).redISub(G$),I$=Y$.redMul(U$).redMul(K$),Q,x;return this.curve.twisted?(Q=Y$.redMul(X$).redMul(G$.redSub(this.curve._mulA(Z$))),x=U$.redMul(X$)):(Q=Y$.redMul(X$).redMul(G$.redSub(Z$)),x=this.curve._mulC(U$).redMul(X$)),this.curve.point(I$,Q,x)},$.prototype.add=function(N){return this.isInfinity()?N:N.isInfinity()?this:this.curve.extended?this._extAdd(N):this._projAdd(N)},$.prototype.mul=function(N){return this._hasDoubles(N)?this.curve._fixedNafMul(this,N):this.curve._wnafMul(this,N)},$.prototype.mulAdd=function(N,Y$,O0){return this.curve._wnafMulAdd(1,[this,Y$],[N,O0],2,!1)},$.prototype.jmulAdd=function(N,Y$,O0){return this.curve._wnafMulAdd(1,[this,Y$],[N,O0],2,!0)},$.prototype.normalize=function(){if(this.zOne)return this;var N=this.z.redInvm();return this.x=this.x.redMul(N),this.y=this.y.redMul(N),this.t&&(this.t=this.t.redMul(N)),this.z=this.curve.one,this.zOne=!0,this},$.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},$.prototype.getX=function(){return this.normalize(),this.x.fromRed()},$.prototype.getY=function(){return this.normalize(),this.y.fromRed()},$.prototype.eq=function(N){return this===N||this.getX().cmp(N.getX())===0&&this.getY().cmp(N.getY())===0},$.prototype.eqXToP=function(N){var Y$=N.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(Y$)===0)return!0;for(var O0=N.clone(),Z$=this.curve.redN.redMul(this.z);;){if(O0.iadd(this.curve.n),O0.cmp(this.curve.p)>=0)return!1;if(Y$.redIAdd(Z$),this.x.cmp(Y$)===0)return!0}},$.prototype.toP=$.prototype.normalize,$.prototype.mixedAdd=$.prototype.add}}),NY=pQ({"node_modules/elliptic/lib/elliptic/curve/index.js"(t0){var m0=t0;m0.base=m(),m0.short=x0(),m0.mont=B0(),m0.edwards=_Y()}}),xY=pQ({"node_modules/hash.js/lib/hash/utils.js"(t0){var m0=v0(),a0=dQ();t0.inherits=a0;function e0(T$,Y){return(T$.charCodeAt(Y)&64512)!==55296||Y<0||Y+1>=T$.length?!1:(T$.charCodeAt(Y+1)&64512)===56320}function r0(T$,Y){if(Array.isArray(T$))return T$.slice();if(!T$)return[];var f=[];if(typeof T$=="string")if(Y){if(Y==="hex")for(T$=T$.replace(/[^a-z0-9]+/gi,""),T$.length%2!==0&&(T$="0"+T$),F0=0;F0>6|192,f[D$++]=C$&63|128):e0(T$,F0)?(C$=65536+((C$&1023)<<10)+(T$.charCodeAt(++F0)&1023),f[D$++]=C$>>18|240,f[D$++]=C$>>12&63|128,f[D$++]=C$>>6&63|128,f[D$++]=C$&63|128):(f[D$++]=C$>>12|224,f[D$++]=C$>>6&63|128,f[D$++]=C$&63|128)}else for(F0=0;F0>>24|T$>>>8&65280|T$<<8&16711680|(T$&255)<<24;return Y>>>0}t0.htonl=$$;function Q$(T$,Y){for(var f="",D$=0;D$>>0}return C$}t0.join32=Y$;function O0(T$,Y){for(var f=new Array(T$.length*4),D$=0,F0=0;D$>>24,f[F0+1]=C$>>>16&255,f[F0+2]=C$>>>8&255,f[F0+3]=C$&255):(f[F0+3]=C$>>>24,f[F0+2]=C$>>>16&255,f[F0+1]=C$>>>8&255,f[F0]=C$&255)}return f}t0.split32=O0;function Z$(T$,Y){return T$>>>Y|T$<<32-Y}t0.rotr32=Z$;function G$(T$,Y){return T$<>>32-Y}t0.rotl32=G$;function V$(T$,Y){return T$+Y>>>0}t0.sum32=V$;function U$(T$,Y,f){return T$+Y+f>>>0}t0.sum32_3=U$;function X$(T$,Y,f,D$){return T$+Y+f+D$>>>0}t0.sum32_4=X$;function K$(T$,Y,f,D$,F0){return T$+Y+f+D$+F0>>>0}t0.sum32_5=K$;function I$(T$,Y,f,D$){var F0=T$[Y],C$=T$[Y+1],L$=D$+C$>>>0,R$=(L$>>0,T$[Y+1]=L$}t0.sum64=I$;function Q(T$,Y,f,D$){var F0=Y+D$>>>0,C$=(F0>>0}t0.sum64_hi=Q;function x(T$,Y,f,D$){var F0=Y+D$;return F0>>>0}t0.sum64_lo=x;function O$(T$,Y,f,D$,F0,C$,L$,R$){var P$=0,z$=Y;z$=z$+D$>>>0,P$+=z$>>0,P$+=z$>>0,P$+=z$>>0}t0.sum64_4_hi=O$;function J0(T$,Y,f,D$,F0,C$,L$,R$){var P$=Y+D$+C$+R$;return P$>>>0}t0.sum64_4_lo=J0;function J$(T$,Y,f,D$,F0,C$,L$,R$,P$,z$){var M$=0,S$=Y;S$=S$+D$>>>0,M$+=S$>>0,M$+=S$>>0,M$+=S$>>0,M$+=S$>>0}t0.sum64_5_hi=J$;function F$(T$,Y,f,D$,F0,C$,L$,R$,P$,z$){var M$=Y+D$+C$+R$+z$;return M$>>>0}t0.sum64_5_lo=F$;function A$(T$,Y,f){var D$=Y<<32-f|T$>>>f;return D$>>>0}t0.rotr64_hi=A$;function H$(T$,Y,f){var D$=T$<<32-f|Y>>>f;return D$>>>0}t0.rotr64_lo=H$;function W$(T$,Y,f){return T$>>>f}t0.shr64_hi=W$;function E$(T$,Y,f){var D$=T$<<32-f|Y>>>f;return D$>>>0}t0.shr64_lo=E$}}),BY=pQ({"node_modules/hash.js/lib/hash/common.js"(t0){var m0=xY(),a0=v0();function e0(){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}t0.BlockHash=e0,e0.prototype.update=function(r0,i0){if(r0=m0.toArray(r0,i0),this.pending?this.pending=this.pending.concat(r0):this.pending=r0,this.pendingTotal+=r0.length,this.pending.length>=this._delta8){r0=this.pending;var $$=r0.length%this._delta8;this.pending=r0.slice(r0.length-$$,r0.length),this.pending.length===0&&(this.pending=null),r0=m0.join32(r0,0,r0.length-$$,this.endian);for(var Q$=0;Q$>>24&255,Q$[$++]=r0>>>16&255,Q$[$++]=r0>>>8&255,Q$[$++]=r0&255}else for(Q$[$++]=r0&255,Q$[$++]=r0>>>8&255,Q$[$++]=r0>>>16&255,Q$[$++]=r0>>>24&255,Q$[$++]=0,Q$[$++]=0,Q$[$++]=0,Q$[$++]=0,N=8;N>>3}t0.g0_256=N;function Y$(O0){return a0(O0,17)^a0(O0,19)^O0>>>10}t0.g1_256=Y$}}),wY=pQ({"node_modules/hash.js/lib/hash/sha/1.js"(t0,m0){var a0=xY(),e0=BY(),r0=yY(),i0=a0.rotl32,$$=a0.sum32,Q$=a0.sum32_5,$=r0.ft_1,N=e0.BlockHash,Y$=[1518500249,1859775393,2400959708,3395469782];function O0(){if(!(this instanceof O0))return new O0;N.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}a0.inherits(O0,N),m0.exports=O0,O0.blockSize=512,O0.outSize=160,O0.hmacStrength=80,O0.padLength=64,O0.prototype._update=function(Z$,G$){for(var V$=this.W,U$=0;U$<16;U$++)V$[U$]=Z$[G$+U$];for(;U$this.blockSize&&(i0=new this.Hash().update(i0).digest()),e0(i0.length<=this.blockSize);for(var $$=i0.length;$$=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(Q$,$,N)}m0.exports=i0,i0.prototype._init=function($$,Q$,$){var N=$$.concat(Q$).concat($);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var Y$=0;Y$=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update($$.concat($||[])),this._reseed=1},i0.prototype.generate=function($$,Q$,$,N){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof Q$!="string"&&(N=$,$=Q$,Q$=null),$&&($=e0.toArray($,N||"hex"),this._update($));for(var Y$=[];Y$.length<$$;)this.V=this._hmac().update(this.V).digest(),Y$=Y$.concat(this.V);var O0=Y$.slice(0,$$);return this._update($),this._reseed++,e0.encode(O0,Q$)}}}),oY=pQ({"node_modules/elliptic/lib/elliptic/ec/key.js"(t0,m0){var a0=kY(),e0=D(),r0=e0.assert;function i0($$,Q$){this.ec=$$,this.priv=null,this.pub=null,Q$.priv&&this._importPrivate(Q$.priv,Q$.privEnc),Q$.pub&&this._importPublic(Q$.pub,Q$.pubEnc)}m0.exports=i0,i0.fromPublic=function($$,Q$,$){return Q$ instanceof i0?Q$:new i0($$,{pub:Q$,pubEnc:$})},i0.fromPrivate=function($$,Q$,$){return Q$ instanceof i0?Q$:new i0($$,{priv:Q$,privEnc:$})},i0.prototype.validate=function(){var $$=this.getPublic();return $$.isInfinity()?{result:!1,reason:"Invalid public key"}:$$.validate()?$$.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i0.prototype.getPublic=function($$,Q$){return typeof $$=="string"&&(Q$=$$,$$=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),Q$?this.pub.encode(Q$,$$):this.pub},i0.prototype.getPrivate=function($$){return $$==="hex"?this.priv.toString(16,2):this.priv},i0.prototype._importPrivate=function($$,Q$){this.priv=new a0($$,Q$||16),this.priv=this.priv.umod(this.ec.curve.n)},i0.prototype._importPublic=function($$,Q$){if($$.x||$$.y){this.ec.curve.type==="mont"?r0($$.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&r0($$.x&&$$.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point($$.x,$$.y);return}this.pub=this.ec.curve.decodePoint($$,Q$)},i0.prototype.derive=function($$){return $$.validate()||r0($$.validate(),"public point not validated"),$$.mul(this.priv).getX()},i0.prototype.sign=function($$,Q$,$){return this.ec.sign($$,this,Q$,$)},i0.prototype.verify=function($$,Q$){return this.ec.verify($$,Q$,this)},i0.prototype.inspect=function(){return""}}}),L=pQ({"node_modules/elliptic/lib/elliptic/ec/signature.js"(t0,m0){var a0=kY(),e0=D(),r0=e0.assert;function i0(Y$,O0){if(Y$ instanceof i0)return Y$;this._importDER(Y$,O0)||(r0(Y$.r&&Y$.s,"Signature without r or s"),this.r=new a0(Y$.r,16),this.s=new a0(Y$.s,16),Y$.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=Y$.recoveryParam)}m0.exports=i0;function $$(){this.place=0}function Q$(Y$,O0){var Z$=Y$[O0.place++];if(!(Z$&128))return Z$;var G$=Z$&15;if(G$===0||G$>4)return!1;for(var V$=0,U$=0,X$=O0.place;U$>>=0;return V$<=127?!1:(O0.place=X$,V$)}function $(Y$){for(var O0=0,Z$=Y$.length-1;!Y$[O0]&&!(Y$[O0+1]&128)&&O0>>3);for(Y$.push(Z$|128);--Z$;)Y$.push(O0>>>(Z$<<3)&255);Y$.push(O0)}i0.prototype.toDER=function(Y$){var O0=this.r.toArray(),Z$=this.s.toArray();for(O0[0]&128&&(O0=[0].concat(O0)),Z$[0]&128&&(Z$=[0].concat(Z$)),O0=$(O0),Z$=$(Z$);!Z$[0]&&!(Z$[1]&128);)Z$=Z$.slice(1);var G$=[2];N(G$,O0.length),G$=G$.concat(O0),G$.push(2),N(G$,Z$.length);var V$=G$.concat(Z$),U$=[48];return N(U$,V$.length),U$=U$.concat(V$),e0.encode(U$,Y$)}}}),e=pQ({"node_modules/elliptic/lib/elliptic/ec/index.js"(t0,m0){var a0=kY(),e0=lY(),r0=D(),i0=bY(),$$=T(),Q$=r0.assert,$=oY(),N=L();function Y$(O0){if(!(this instanceof Y$))return new Y$(O0);typeof O0=="string"&&(Q$(Object.prototype.hasOwnProperty.call(i0,O0),"Unknown curve "+O0),O0=i0[O0]),O0 instanceof i0.PresetCurve&&(O0={curve:O0}),this.curve=O0.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=O0.curve.g,this.g.precompute(O0.curve.n.bitLength()+1),this.hash=O0.hash||O0.curve.hash}m0.exports=Y$,Y$.prototype.keyPair=function(O0){return new $(this,O0)},Y$.prototype.keyFromPrivate=function(O0,Z$){return $.fromPrivate(this,O0,Z$)},Y$.prototype.keyFromPublic=function(O0,Z$){return $.fromPublic(this,O0,Z$)},Y$.prototype.genKeyPair=function(O0){O0||(O0={});for(var Z$=new e0({hash:this.hash,pers:O0.pers,persEnc:O0.persEnc||"utf8",entropy:O0.entropy||$$(this.hash.hmacStrength),entropyEnc:O0.entropy&&O0.entropyEnc||"utf8",nonce:this.n.toArray()}),G$=this.n.byteLength(),V$=this.n.sub(new a0(2));;){var U$=new a0(Z$.generate(G$));if(!(U$.cmp(V$)>0))return U$.iaddn(1),this.keyFromPrivate(U$)}},Y$.prototype._truncateToN=function(O0,Z$){var G$=O0.byteLength()*8-this.n.bitLength();return G$>0&&(O0=O0.ushrn(G$)),!Z$&&O0.cmp(this.n)>=0?O0.sub(this.n):O0},Y$.prototype.sign=function(O0,Z$,G$,V$){typeof G$=="object"&&(V$=G$,G$=null),V$||(V$={}),Z$=this.keyFromPrivate(Z$,G$),O0=this._truncateToN(new a0(O0,16));for(var U$=this.n.byteLength(),X$=Z$.getPrivate().toArray("be",U$),K$=O0.toArray("be",U$),I$=new e0({hash:this.hash,entropy:X$,nonce:K$,pers:V$.pers,persEnc:V$.persEnc||"utf8"}),Q=this.n.sub(new a0(1)),x=0;;x++){var O$=V$.k?V$.k(x):new a0(I$.generate(this.n.byteLength()));if(O$=this._truncateToN(O$,!0),!(O$.cmpn(1)<=0||O$.cmp(Q)>=0)){var J0=this.g.mul(O$);if(!J0.isInfinity()){var J$=J0.getX(),F$=J$.umod(this.n);if(F$.cmpn(0)!==0){var A$=O$.invm(this.n).mul(F$.mul(Z$.getPrivate()).iadd(O0));if(A$=A$.umod(this.n),A$.cmpn(0)!==0){var H$=(J0.getY().isOdd()?1:0)|(J$.cmp(F$)!==0?2:0);return V$.canonical&&A$.cmp(this.nh)>0&&(A$=this.n.sub(A$),H$^=1),new N({r:F$,s:A$,recoveryParam:H$})}}}}}},Y$.prototype.verify=function(O0,Z$,G$,V$){O0=this._truncateToN(new a0(O0,16)),G$=this.keyFromPublic(G$,V$),Z$=new N(Z$,"hex");var{r:U$,s:X$}=Z$;if(U$.cmpn(1)<0||U$.cmp(this.n)>=0||X$.cmpn(1)<0||X$.cmp(this.n)>=0)return!1;var K$=X$.invm(this.n),I$=K$.mul(O0).umod(this.n),Q=K$.mul(U$).umod(this.n),x;return this.curve._maxwellTrick?(x=this.g.jmulAdd(I$,G$.getPublic(),Q),x.isInfinity()?!1:x.eqXToP(U$)):(x=this.g.mulAdd(I$,G$.getPublic(),Q),x.isInfinity()?!1:x.getX().umod(this.n).cmp(U$)===0)},Y$.prototype.recoverPubKey=function(O0,Z$,G$,V$){Q$((3&G$)===G$,"The recovery param is more than two bits"),Z$=new N(Z$,V$);var U$=this.n,X$=new a0(O0),K$=Z$.r,I$=Z$.s,Q=G$&1,x=G$>>1;if(K$.cmp(this.curve.p.umod(this.curve.n))>=0&&x)throw new Error("Unable to find sencond key candinate");x?K$=this.curve.pointFromX(K$.add(this.curve.n),Q):K$=this.curve.pointFromX(K$,Q);var O$=Z$.r.invm(U$),J0=U$.sub(X$).mul(O$).umod(U$),J$=I$.mul(O$).umod(U$);return this.g.mulAdd(J0,K$,J$)},Y$.prototype.getKeyRecoveryParam=function(O0,Z$,G$,V$){if(Z$=new N(Z$,V$),Z$.recoveryParam!==null)return Z$.recoveryParam;for(var U$=0;U$<4;U$++){var X$;try{X$=this.recoverPubKey(O0,Z$,U$)}catch{continue}if(X$.eq(G$))return U$}throw new Error("Unable to find valid recovery factor")}}}),p0=pQ({"node_modules/elliptic/lib/elliptic/eddsa/key.js"(t0,m0){var a0=D(),e0=a0.assert,r0=a0.parseBytes,i0=a0.cachedProperty;function $$(Q$,$){this.eddsa=Q$,this._secret=r0($.secret),Q$.isPoint($.pub)?this._pub=$.pub:this._pubBytes=r0($.pub)}$$.fromPublic=function(Q$,$){return $ instanceof $$?$:new $$(Q$,{pub:$})},$$.fromSecret=function(Q$,$){return $ instanceof $$?$:new $$(Q$,{secret:$})},$$.prototype.secret=function(){return this._secret},i0($$,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),i0($$,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),i0($$,"privBytes",function(){var Q$=this.eddsa,$=this.hash(),N=Q$.encodingLength-1,Y$=$.slice(0,Q$.encodingLength);return Y$[0]&=248,Y$[N]&=127,Y$[N]|=64,Y$}),i0($$,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),i0($$,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),i0($$,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),$$.prototype.sign=function(Q$){return e0(this._secret,"KeyPair can only verify"),this.eddsa.sign(Q$,this)},$$.prototype.verify=function(Q$,$){return this.eddsa.verify(Q$,$,this)},$$.prototype.getSecret=function(Q$){return e0(this._secret,"KeyPair is public only"),a0.encode(this.secret(),Q$)},$$.prototype.getPublic=function(Q$){return a0.encode(this.pubBytes(),Q$)},m0.exports=$$}}),f0=pQ({"node_modules/elliptic/lib/elliptic/eddsa/signature.js"(t0,m0){var a0=kY(),e0=D(),r0=e0.assert,i0=e0.cachedProperty,$$=e0.parseBytes;function Q$($,N){this.eddsa=$,typeof N!="object"&&(N=$$(N)),Array.isArray(N)&&(N={R:N.slice(0,$.encodingLength),S:N.slice($.encodingLength)}),r0(N.R&&N.S,"Signature without R or S"),$.isPoint(N.R)&&(this._R=N.R),N.S instanceof a0&&(this._S=N.S),this._Rencoded=Array.isArray(N.R)?N.R:N.Rencoded,this._Sencoded=Array.isArray(N.S)?N.S:N.Sencoded}i0(Q$,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),i0(Q$,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),i0(Q$,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),i0(Q$,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Q$.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Q$.prototype.toHex=function(){return e0.encode(this.toBytes(),"hex").toUpperCase()},m0.exports=Q$}}),uY=pQ({"node_modules/elliptic/lib/elliptic/eddsa/index.js"(t0,m0){var a0=hY(),e0=bY(),r0=D(),i0=r0.assert,$$=r0.parseBytes,Q$=p0(),$=f0();function N(Y$){if(i0(Y$==="ed25519","only tested with ed25519 so far"),!(this instanceof N))return new N(Y$);Y$=e0[Y$].curve,this.curve=Y$,this.g=Y$.g,this.g.precompute(Y$.n.bitLength()+1),this.pointClass=Y$.point().constructor,this.encodingLength=Math.ceil(Y$.n.bitLength()/8),this.hash=a0.sha512}m0.exports=N,N.prototype.sign=function(Y$,O0){Y$=$$(Y$);var Z$=this.keyFromSecret(O0),G$=this.hashInt(Z$.messagePrefix(),Y$),V$=this.g.mul(G$),U$=this.encodePoint(V$),X$=this.hashInt(U$,Z$.pubBytes(),Y$).mul(Z$.priv()),K$=G$.add(X$).umod(this.curve.n);return this.makeSignature({R:V$,S:K$,Rencoded:U$})},N.prototype.verify=function(Y$,O0,Z$){Y$=$$(Y$),O0=this.makeSignature(O0);var G$=this.keyFromPublic(Z$),V$=this.hashInt(O0.Rencoded(),G$.pubBytes(),Y$),U$=this.g.mul(O0.S()),X$=O0.R().add(G$.pub().mul(V$));return X$.eq(U$)},N.prototype.hashInt=function(){for(var Y$=this.hash(),O0=0;O00?E$:T$},$$.min=function(E$,T$){return E$.cmp(T$)<0?E$:T$},$$.prototype._init=function(E$,T$,Y){if(typeof E$=="number")return this._initNumber(E$,T$,Y);if(typeof E$=="object")return this._initArray(E$,T$,Y);T$==="hex"&&(T$=16),r0(T$===(T$|0)&&T$>=2&&T$<=36),E$=E$.toString().replace(/\s+/g,"");var f=0;E$[0]==="-"&&(f++,this.negative=1),f=0;f-=3)F0=E$[f]|E$[f-1]<<8|E$[f-2]<<16,this.words[D$]|=F0<>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);else if(Y==="le")for(f=0,D$=0;f>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);return this.strip()};function $(E$,T$){var Y=E$.charCodeAt(T$);return Y>=65&&Y<=70?Y-55:Y>=97&&Y<=102?Y-87:Y-48&15}function N(E$,T$,Y){var f=$(E$,Y);return Y-1>=T$&&(f|=$(E$,Y-1)<<4),f}$$.prototype._parseHex=function(E$,T$,Y){this.length=Math.ceil((E$.length-T$)/6),this.words=new Array(this.length);for(var f=0;f=T$;f-=2)C$=N(E$,T$,f)<=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8;else{var L$=E$.length-T$;for(f=L$%2===0?T$+1:T$;f=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8}this.strip()};function Y$(E$,T$,Y,f){for(var D$=0,F0=Math.min(E$.length,Y),C$=T$;C$=49?D$+=L$-49+10:L$>=17?D$+=L$-17+10:D$+=L$}return D$}$$.prototype._parseBase=function(E$,T$,Y){this.words=[0],this.length=1;for(var f=0,D$=1;D$<=67108863;D$*=T$)f++;f--,D$=D$/T$|0;for(var F0=E$.length-Y,C$=F0%f,L$=Math.min(F0,F0-C$)+Y,R$=0,P$=Y;P$1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},$$.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},$$.prototype.inspect=function(){return(this.red?""};var O0=["","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"],Z$=[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],G$=[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];$$.prototype.toString=function(E$,T$){E$=E$||10,T$=T$|0||1;var Y;if(E$===16||E$==="hex"){Y="";for(var f=0,D$=0,F0=0;F0>>24-f&16777215,D$!==0||F0!==this.length-1?Y=O0[6-L$.length]+L$+Y:Y=L$+Y,f+=2,f>=26&&(f-=26,F0--)}for(D$!==0&&(Y=D$.toString(16)+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}if(E$===(E$|0)&&E$>=2&&E$<=36){var R$=Z$[E$],P$=G$[E$];Y="";var z$=this.clone();for(z$.negative=0;!z$.isZero();){var M$=z$.modn(P$).toString(E$);z$=z$.idivn(P$),z$.isZero()?Y=M$+Y:Y=O0[R$-M$.length]+M$+Y}for(this.isZero()&&(Y="0"+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}r0(!1,"Base should be between 2 and 36")},$$.prototype.toNumber=function(){var E$=this.words[0];return this.length===2?E$+=this.words[1]*67108864:this.length===3&&this.words[2]===1?E$+=4503599627370496+this.words[1]*67108864:this.length>2&&r0(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-E$:E$},$$.prototype.toJSON=function(){return this.toString(16)},$$.prototype.toBuffer=function(E$,T$){return r0(typeof Q$<"u"),this.toArrayLike(Q$,E$,T$)},$$.prototype.toArray=function(E$,T$){return this.toArrayLike(Array,E$,T$)},$$.prototype.toArrayLike=function(E$,T$,Y){var f=this.byteLength(),D$=Y||Math.max(1,f);r0(f<=D$,"byte array longer than desired length"),r0(D$>0,"Requested array length <= 0"),this.strip();var F0=T$==="le",C$=new E$(D$),L$,R$,P$=this.clone();if(F0){for(R$=0;!P$.isZero();R$++)L$=P$.andln(255),P$.iushrn(8),C$[R$]=L$;for(;R$=4096&&(Y+=13,T$>>>=13),T$>=64&&(Y+=7,T$>>>=7),T$>=8&&(Y+=4,T$>>>=4),T$>=2&&(Y+=2,T$>>>=2),Y+T$},$$.prototype._zeroBits=function(E$){if(E$===0)return 26;var T$=E$,Y=0;return(T$&8191)===0&&(Y+=13,T$>>>=13),(T$&127)===0&&(Y+=7,T$>>>=7),(T$&15)===0&&(Y+=4,T$>>>=4),(T$&3)===0&&(Y+=2,T$>>>=2),(T$&1)===0&&Y++,Y},$$.prototype.bitLength=function(){var E$=this.words[this.length-1],T$=this._countBits(E$);return(this.length-1)*26+T$};function V$(E$){for(var T$=new Array(E$.bitLength()),Y=0;Y>>D$}return T$}$$.prototype.zeroBits=function(){if(this.isZero())return 0;for(var E$=0,T$=0;T$E$.length?this.clone().ior(E$):E$.clone().ior(this)},$$.prototype.uor=function(E$){return this.length>E$.length?this.clone().iuor(E$):E$.clone().iuor(this)},$$.prototype.iuand=function(E$){var T$;this.length>E$.length?T$=E$:T$=this;for(var Y=0;YE$.length?this.clone().iand(E$):E$.clone().iand(this)},$$.prototype.uand=function(E$){return this.length>E$.length?this.clone().iuand(E$):E$.clone().iuand(this)},$$.prototype.iuxor=function(E$){var T$,Y;this.length>E$.length?(T$=this,Y=E$):(T$=E$,Y=this);for(var f=0;fE$.length?this.clone().ixor(E$):E$.clone().ixor(this)},$$.prototype.uxor=function(E$){return this.length>E$.length?this.clone().iuxor(E$):E$.clone().iuxor(this)},$$.prototype.inotn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=Math.ceil(E$/26)|0,Y=E$%26;this._expand(T$),Y>0&&T$--;for(var f=0;f0&&(this.words[f]=~this.words[f]&67108863>>26-Y),this.strip()},$$.prototype.notn=function(E$){return this.clone().inotn(E$)},$$.prototype.setn=function(E$,T$){r0(typeof E$=="number"&&E$>=0);var Y=E$/26|0,f=E$%26;return this._expand(Y+1),T$?this.words[Y]=this.words[Y]|1<E$.length?(Y=this,f=E$):(Y=E$,f=this);for(var D$=0,F0=0;F0>>26;for(;D$!==0&&F0>>26;if(this.length=Y.length,D$!==0)this.words[this.length]=D$,this.length++;else if(Y!==this)for(;F0E$.length?this.clone().iadd(E$):E$.clone().iadd(this)},$$.prototype.isub=function(E$){if(E$.negative!==0){E$.negative=0;var T$=this.iadd(E$);return E$.negative=1,T$._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(E$),this.negative=1,this._normSign();var Y=this.cmp(E$);if(Y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,D$;Y>0?(f=this,D$=E$):(f=E$,D$=this);for(var F0=0,C$=0;C$>26,this.words[C$]=T$&67108863;for(;F0!==0&&C$>26,this.words[C$]=T$&67108863;if(F0===0&&C$>>26,M$=R$&67108863,S$=Math.min(P$,T$.length-1),Z=Math.max(0,P$-E$.length+1);Z<=S$;Z++){var c=P$-Z|0;D$=E$.words[c]|0,F0=T$.words[Z]|0,C$=D$*F0+M$,z$+=C$/67108864|0,M$=C$&67108863}Y.words[P$]=M$|0,R$=z$|0}return R$!==0?Y.words[P$]=R$|0:Y.length--,Y.strip()}var X$=function(E$,T$,Y){var f=E$.words,D$=T$.words,F0=Y.words,C$=0,L$,R$,P$,z$=f[0]|0,M$=z$&8191,S$=z$>>>13,Z=f[1]|0,c=Z&8191,v$=Z>>>13,A0=f[2]|0,q$=A0&8191,j$=A0>>>13,k$=f[3]|0,g$=k$&8191,_$=k$>>>13,N$=f[4]|0,x$=N$&8191,G=N$>>>13,B=f[5]|0,B$=B&8191,H0=B>>>13,y$=f[6]|0,w$=y$&8191,p$=y$>>>13,f$=f[7]|0,c$=f$&8191,h$=f$>>>13,d$=f[8]|0,V=d$&8191,h=d$>>>13,W0=f[9]|0,E0=W0&8191,b$=W0>>>13,l$=D$[0]|0,o$=l$&8191,u$=l$>>>13,n$=D$[1]|0,s$=n$&8191,t$=n$>>>13,U=D$[2]|0,d=U&8191,m$=U>>>13,T0=D$[3]|0,a$=T0&8191,e$=T0>>>13,r$=D$[4]|0,i$=r$&8191,$Q=r$>>>13,QQ=D$[5]|0,YQ=QQ&8191,X=QQ>>>13,b=D$[6]|0,ZQ=b&8191,D0=b>>>13,GQ=D$[7]|0,VQ=GQ&8191,UQ=GQ>>>13,XQ=D$[8]|0,KQ=XQ&8191,IQ=XQ>>>13,OQ=D$[9]|0,K=OQ&8191,l=OQ>>>13;Y.negative=E$.negative^T$.negative,Y.length=19,L$=Math.imul(M$,o$),R$=Math.imul(M$,u$),R$=R$+Math.imul(S$,o$)|0,P$=Math.imul(S$,u$);var JQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(JQ>>>26)|0,JQ&=67108863,L$=Math.imul(c,o$),R$=Math.imul(c,u$),R$=R$+Math.imul(v$,o$)|0,P$=Math.imul(v$,u$),L$=L$+Math.imul(M$,s$)|0,R$=R$+Math.imul(M$,t$)|0,R$=R$+Math.imul(S$,s$)|0,P$=P$+Math.imul(S$,t$)|0;var C0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(C0>>>26)|0,C0&=67108863,L$=Math.imul(q$,o$),R$=Math.imul(q$,u$),R$=R$+Math.imul(j$,o$)|0,P$=Math.imul(j$,u$),L$=L$+Math.imul(c,s$)|0,R$=R$+Math.imul(c,t$)|0,R$=R$+Math.imul(v$,s$)|0,P$=P$+Math.imul(v$,t$)|0,L$=L$+Math.imul(M$,d)|0,R$=R$+Math.imul(M$,m$)|0,R$=R$+Math.imul(S$,d)|0,P$=P$+Math.imul(S$,m$)|0;var FQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(FQ>>>26)|0,FQ&=67108863,L$=Math.imul(g$,o$),R$=Math.imul(g$,u$),R$=R$+Math.imul(_$,o$)|0,P$=Math.imul(_$,u$),L$=L$+Math.imul(q$,s$)|0,R$=R$+Math.imul(q$,t$)|0,R$=R$+Math.imul(j$,s$)|0,P$=P$+Math.imul(j$,t$)|0,L$=L$+Math.imul(c,d)|0,R$=R$+Math.imul(c,m$)|0,R$=R$+Math.imul(v$,d)|0,P$=P$+Math.imul(v$,m$)|0,L$=L$+Math.imul(M$,a$)|0,R$=R$+Math.imul(M$,e$)|0,R$=R$+Math.imul(S$,a$)|0,P$=P$+Math.imul(S$,e$)|0;var AQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(AQ>>>26)|0,AQ&=67108863,L$=Math.imul(x$,o$),R$=Math.imul(x$,u$),R$=R$+Math.imul(G,o$)|0,P$=Math.imul(G,u$),L$=L$+Math.imul(g$,s$)|0,R$=R$+Math.imul(g$,t$)|0,R$=R$+Math.imul(_$,s$)|0,P$=P$+Math.imul(_$,t$)|0,L$=L$+Math.imul(q$,d)|0,R$=R$+Math.imul(q$,m$)|0,R$=R$+Math.imul(j$,d)|0,P$=P$+Math.imul(j$,m$)|0,L$=L$+Math.imul(c,a$)|0,R$=R$+Math.imul(c,e$)|0,R$=R$+Math.imul(v$,a$)|0,P$=P$+Math.imul(v$,e$)|0,L$=L$+Math.imul(M$,i$)|0,R$=R$+Math.imul(M$,$Q)|0,R$=R$+Math.imul(S$,i$)|0,P$=P$+Math.imul(S$,$Q)|0;var HQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(HQ>>>26)|0,HQ&=67108863,L$=Math.imul(B$,o$),R$=Math.imul(B$,u$),R$=R$+Math.imul(H0,o$)|0,P$=Math.imul(H0,u$),L$=L$+Math.imul(x$,s$)|0,R$=R$+Math.imul(x$,t$)|0,R$=R$+Math.imul(G,s$)|0,P$=P$+Math.imul(G,t$)|0,L$=L$+Math.imul(g$,d)|0,R$=R$+Math.imul(g$,m$)|0,R$=R$+Math.imul(_$,d)|0,P$=P$+Math.imul(_$,m$)|0,L$=L$+Math.imul(q$,a$)|0,R$=R$+Math.imul(q$,e$)|0,R$=R$+Math.imul(j$,a$)|0,P$=P$+Math.imul(j$,e$)|0,L$=L$+Math.imul(c,i$)|0,R$=R$+Math.imul(c,$Q)|0,R$=R$+Math.imul(v$,i$)|0,P$=P$+Math.imul(v$,$Q)|0,L$=L$+Math.imul(M$,YQ)|0,R$=R$+Math.imul(M$,X)|0,R$=R$+Math.imul(S$,YQ)|0,P$=P$+Math.imul(S$,X)|0;var WQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(WQ>>>26)|0,WQ&=67108863,L$=Math.imul(w$,o$),R$=Math.imul(w$,u$),R$=R$+Math.imul(p$,o$)|0,P$=Math.imul(p$,u$),L$=L$+Math.imul(B$,s$)|0,R$=R$+Math.imul(B$,t$)|0,R$=R$+Math.imul(H0,s$)|0,P$=P$+Math.imul(H0,t$)|0,L$=L$+Math.imul(x$,d)|0,R$=R$+Math.imul(x$,m$)|0,R$=R$+Math.imul(G,d)|0,P$=P$+Math.imul(G,m$)|0,L$=L$+Math.imul(g$,a$)|0,R$=R$+Math.imul(g$,e$)|0,R$=R$+Math.imul(_$,a$)|0,P$=P$+Math.imul(_$,e$)|0,L$=L$+Math.imul(q$,i$)|0,R$=R$+Math.imul(q$,$Q)|0,R$=R$+Math.imul(j$,i$)|0,P$=P$+Math.imul(j$,$Q)|0,L$=L$+Math.imul(c,YQ)|0,R$=R$+Math.imul(c,X)|0,R$=R$+Math.imul(v$,YQ)|0,P$=P$+Math.imul(v$,X)|0,L$=L$+Math.imul(M$,ZQ)|0,R$=R$+Math.imul(M$,D0)|0,R$=R$+Math.imul(S$,ZQ)|0,P$=P$+Math.imul(S$,D0)|0;var EQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(EQ>>>26)|0,EQ&=67108863,L$=Math.imul(c$,o$),R$=Math.imul(c$,u$),R$=R$+Math.imul(h$,o$)|0,P$=Math.imul(h$,u$),L$=L$+Math.imul(w$,s$)|0,R$=R$+Math.imul(w$,t$)|0,R$=R$+Math.imul(p$,s$)|0,P$=P$+Math.imul(p$,t$)|0,L$=L$+Math.imul(B$,d)|0,R$=R$+Math.imul(B$,m$)|0,R$=R$+Math.imul(H0,d)|0,P$=P$+Math.imul(H0,m$)|0,L$=L$+Math.imul(x$,a$)|0,R$=R$+Math.imul(x$,e$)|0,R$=R$+Math.imul(G,a$)|0,P$=P$+Math.imul(G,e$)|0,L$=L$+Math.imul(g$,i$)|0,R$=R$+Math.imul(g$,$Q)|0,R$=R$+Math.imul(_$,i$)|0,P$=P$+Math.imul(_$,$Q)|0,L$=L$+Math.imul(q$,YQ)|0,R$=R$+Math.imul(q$,X)|0,R$=R$+Math.imul(j$,YQ)|0,P$=P$+Math.imul(j$,X)|0,L$=L$+Math.imul(c,ZQ)|0,R$=R$+Math.imul(c,D0)|0,R$=R$+Math.imul(v$,ZQ)|0,P$=P$+Math.imul(v$,D0)|0,L$=L$+Math.imul(M$,VQ)|0,R$=R$+Math.imul(M$,UQ)|0,R$=R$+Math.imul(S$,VQ)|0,P$=P$+Math.imul(S$,UQ)|0;var TQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(TQ>>>26)|0,TQ&=67108863,L$=Math.imul(V,o$),R$=Math.imul(V,u$),R$=R$+Math.imul(h,o$)|0,P$=Math.imul(h,u$),L$=L$+Math.imul(c$,s$)|0,R$=R$+Math.imul(c$,t$)|0,R$=R$+Math.imul(h$,s$)|0,P$=P$+Math.imul(h$,t$)|0,L$=L$+Math.imul(w$,d)|0,R$=R$+Math.imul(w$,m$)|0,R$=R$+Math.imul(p$,d)|0,P$=P$+Math.imul(p$,m$)|0,L$=L$+Math.imul(B$,a$)|0,R$=R$+Math.imul(B$,e$)|0,R$=R$+Math.imul(H0,a$)|0,P$=P$+Math.imul(H0,e$)|0,L$=L$+Math.imul(x$,i$)|0,R$=R$+Math.imul(x$,$Q)|0,R$=R$+Math.imul(G,i$)|0,P$=P$+Math.imul(G,$Q)|0,L$=L$+Math.imul(g$,YQ)|0,R$=R$+Math.imul(g$,X)|0,R$=R$+Math.imul(_$,YQ)|0,P$=P$+Math.imul(_$,X)|0,L$=L$+Math.imul(q$,ZQ)|0,R$=R$+Math.imul(q$,D0)|0,R$=R$+Math.imul(j$,ZQ)|0,P$=P$+Math.imul(j$,D0)|0,L$=L$+Math.imul(c,VQ)|0,R$=R$+Math.imul(c,UQ)|0,R$=R$+Math.imul(v$,VQ)|0,P$=P$+Math.imul(v$,UQ)|0,L$=L$+Math.imul(M$,KQ)|0,R$=R$+Math.imul(M$,IQ)|0,R$=R$+Math.imul(S$,KQ)|0,P$=P$+Math.imul(S$,IQ)|0;var DQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(DQ>>>26)|0,DQ&=67108863,L$=Math.imul(E0,o$),R$=Math.imul(E0,u$),R$=R$+Math.imul(b$,o$)|0,P$=Math.imul(b$,u$),L$=L$+Math.imul(V,s$)|0,R$=R$+Math.imul(V,t$)|0,R$=R$+Math.imul(h,s$)|0,P$=P$+Math.imul(h,t$)|0,L$=L$+Math.imul(c$,d)|0,R$=R$+Math.imul(c$,m$)|0,R$=R$+Math.imul(h$,d)|0,P$=P$+Math.imul(h$,m$)|0,L$=L$+Math.imul(w$,a$)|0,R$=R$+Math.imul(w$,e$)|0,R$=R$+Math.imul(p$,a$)|0,P$=P$+Math.imul(p$,e$)|0,L$=L$+Math.imul(B$,i$)|0,R$=R$+Math.imul(B$,$Q)|0,R$=R$+Math.imul(H0,i$)|0,P$=P$+Math.imul(H0,$Q)|0,L$=L$+Math.imul(x$,YQ)|0,R$=R$+Math.imul(x$,X)|0,R$=R$+Math.imul(G,YQ)|0,P$=P$+Math.imul(G,X)|0,L$=L$+Math.imul(g$,ZQ)|0,R$=R$+Math.imul(g$,D0)|0,R$=R$+Math.imul(_$,ZQ)|0,P$=P$+Math.imul(_$,D0)|0,L$=L$+Math.imul(q$,VQ)|0,R$=R$+Math.imul(q$,UQ)|0,R$=R$+Math.imul(j$,VQ)|0,P$=P$+Math.imul(j$,UQ)|0,L$=L$+Math.imul(c,KQ)|0,R$=R$+Math.imul(c,IQ)|0,R$=R$+Math.imul(v$,KQ)|0,P$=P$+Math.imul(v$,IQ)|0,L$=L$+Math.imul(M$,K)|0,R$=R$+Math.imul(M$,l)|0,R$=R$+Math.imul(S$,K)|0,P$=P$+Math.imul(S$,l)|0;var I=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(I>>>26)|0,I&=67108863,L$=Math.imul(E0,s$),R$=Math.imul(E0,t$),R$=R$+Math.imul(b$,s$)|0,P$=Math.imul(b$,t$),L$=L$+Math.imul(V,d)|0,R$=R$+Math.imul(V,m$)|0,R$=R$+Math.imul(h,d)|0,P$=P$+Math.imul(h,m$)|0,L$=L$+Math.imul(c$,a$)|0,R$=R$+Math.imul(c$,e$)|0,R$=R$+Math.imul(h$,a$)|0,P$=P$+Math.imul(h$,e$)|0,L$=L$+Math.imul(w$,i$)|0,R$=R$+Math.imul(w$,$Q)|0,R$=R$+Math.imul(p$,i$)|0,P$=P$+Math.imul(p$,$Q)|0,L$=L$+Math.imul(B$,YQ)|0,R$=R$+Math.imul(B$,X)|0,R$=R$+Math.imul(H0,YQ)|0,P$=P$+Math.imul(H0,X)|0,L$=L$+Math.imul(x$,ZQ)|0,R$=R$+Math.imul(x$,D0)|0,R$=R$+Math.imul(G,ZQ)|0,P$=P$+Math.imul(G,D0)|0,L$=L$+Math.imul(g$,VQ)|0,R$=R$+Math.imul(g$,UQ)|0,R$=R$+Math.imul(_$,VQ)|0,P$=P$+Math.imul(_$,UQ)|0,L$=L$+Math.imul(q$,KQ)|0,R$=R$+Math.imul(q$,IQ)|0,R$=R$+Math.imul(j$,KQ)|0,P$=P$+Math.imul(j$,IQ)|0,L$=L$+Math.imul(c,K)|0,R$=R$+Math.imul(c,l)|0,R$=R$+Math.imul(v$,K)|0,P$=P$+Math.imul(v$,l)|0;var o=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(o>>>26)|0,o&=67108863,L$=Math.imul(E0,d),R$=Math.imul(E0,m$),R$=R$+Math.imul(b$,d)|0,P$=Math.imul(b$,m$),L$=L$+Math.imul(V,a$)|0,R$=R$+Math.imul(V,e$)|0,R$=R$+Math.imul(h,a$)|0,P$=P$+Math.imul(h,e$)|0,L$=L$+Math.imul(c$,i$)|0,R$=R$+Math.imul(c$,$Q)|0,R$=R$+Math.imul(h$,i$)|0,P$=P$+Math.imul(h$,$Q)|0,L$=L$+Math.imul(w$,YQ)|0,R$=R$+Math.imul(w$,X)|0,R$=R$+Math.imul(p$,YQ)|0,P$=P$+Math.imul(p$,X)|0,L$=L$+Math.imul(B$,ZQ)|0,R$=R$+Math.imul(B$,D0)|0,R$=R$+Math.imul(H0,ZQ)|0,P$=P$+Math.imul(H0,D0)|0,L$=L$+Math.imul(x$,VQ)|0,R$=R$+Math.imul(x$,UQ)|0,R$=R$+Math.imul(G,VQ)|0,P$=P$+Math.imul(G,UQ)|0,L$=L$+Math.imul(g$,KQ)|0,R$=R$+Math.imul(g$,IQ)|0,R$=R$+Math.imul(_$,KQ)|0,P$=P$+Math.imul(_$,IQ)|0,L$=L$+Math.imul(q$,K)|0,R$=R$+Math.imul(q$,l)|0,R$=R$+Math.imul(j$,K)|0,P$=P$+Math.imul(j$,l)|0;var CQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(CQ>>>26)|0,CQ&=67108863,L$=Math.imul(E0,a$),R$=Math.imul(E0,e$),R$=R$+Math.imul(b$,a$)|0,P$=Math.imul(b$,e$),L$=L$+Math.imul(V,i$)|0,R$=R$+Math.imul(V,$Q)|0,R$=R$+Math.imul(h,i$)|0,P$=P$+Math.imul(h,$Q)|0,L$=L$+Math.imul(c$,YQ)|0,R$=R$+Math.imul(c$,X)|0,R$=R$+Math.imul(h$,YQ)|0,P$=P$+Math.imul(h$,X)|0,L$=L$+Math.imul(w$,ZQ)|0,R$=R$+Math.imul(w$,D0)|0,R$=R$+Math.imul(p$,ZQ)|0,P$=P$+Math.imul(p$,D0)|0,L$=L$+Math.imul(B$,VQ)|0,R$=R$+Math.imul(B$,UQ)|0,R$=R$+Math.imul(H0,VQ)|0,P$=P$+Math.imul(H0,UQ)|0,L$=L$+Math.imul(x$,KQ)|0,R$=R$+Math.imul(x$,IQ)|0,R$=R$+Math.imul(G,KQ)|0,P$=P$+Math.imul(G,IQ)|0,L$=L$+Math.imul(g$,K)|0,R$=R$+Math.imul(g$,l)|0,R$=R$+Math.imul(_$,K)|0,P$=P$+Math.imul(_$,l)|0;var L0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(L0>>>26)|0,L0&=67108863,L$=Math.imul(E0,i$),R$=Math.imul(E0,$Q),R$=R$+Math.imul(b$,i$)|0,P$=Math.imul(b$,$Q),L$=L$+Math.imul(V,YQ)|0,R$=R$+Math.imul(V,X)|0,R$=R$+Math.imul(h,YQ)|0,P$=P$+Math.imul(h,X)|0,L$=L$+Math.imul(c$,ZQ)|0,R$=R$+Math.imul(c$,D0)|0,R$=R$+Math.imul(h$,ZQ)|0,P$=P$+Math.imul(h$,D0)|0,L$=L$+Math.imul(w$,VQ)|0,R$=R$+Math.imul(w$,UQ)|0,R$=R$+Math.imul(p$,VQ)|0,P$=P$+Math.imul(p$,UQ)|0,L$=L$+Math.imul(B$,KQ)|0,R$=R$+Math.imul(B$,IQ)|0,R$=R$+Math.imul(H0,KQ)|0,P$=P$+Math.imul(H0,IQ)|0,L$=L$+Math.imul(x$,K)|0,R$=R$+Math.imul(x$,l)|0,R$=R$+Math.imul(G,K)|0,P$=P$+Math.imul(G,l)|0;var LQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(LQ>>>26)|0,LQ&=67108863,L$=Math.imul(E0,YQ),R$=Math.imul(E0,X),R$=R$+Math.imul(b$,YQ)|0,P$=Math.imul(b$,X),L$=L$+Math.imul(V,ZQ)|0,R$=R$+Math.imul(V,D0)|0,R$=R$+Math.imul(h,ZQ)|0,P$=P$+Math.imul(h,D0)|0,L$=L$+Math.imul(c$,VQ)|0,R$=R$+Math.imul(c$,UQ)|0,R$=R$+Math.imul(h$,VQ)|0,P$=P$+Math.imul(h$,UQ)|0,L$=L$+Math.imul(w$,KQ)|0,R$=R$+Math.imul(w$,IQ)|0,R$=R$+Math.imul(p$,KQ)|0,P$=P$+Math.imul(p$,IQ)|0,L$=L$+Math.imul(B$,K)|0,R$=R$+Math.imul(B$,l)|0,R$=R$+Math.imul(H0,K)|0,P$=P$+Math.imul(H0,l)|0;var RQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(RQ>>>26)|0,RQ&=67108863,L$=Math.imul(E0,ZQ),R$=Math.imul(E0,D0),R$=R$+Math.imul(b$,ZQ)|0,P$=Math.imul(b$,D0),L$=L$+Math.imul(V,VQ)|0,R$=R$+Math.imul(V,UQ)|0,R$=R$+Math.imul(h,VQ)|0,P$=P$+Math.imul(h,UQ)|0,L$=L$+Math.imul(c$,KQ)|0,R$=R$+Math.imul(c$,IQ)|0,R$=R$+Math.imul(h$,KQ)|0,P$=P$+Math.imul(h$,IQ)|0,L$=L$+Math.imul(w$,K)|0,R$=R$+Math.imul(w$,l)|0,R$=R$+Math.imul(p$,K)|0,P$=P$+Math.imul(p$,l)|0;var PQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(PQ>>>26)|0,PQ&=67108863,L$=Math.imul(E0,VQ),R$=Math.imul(E0,UQ),R$=R$+Math.imul(b$,VQ)|0,P$=Math.imul(b$,UQ),L$=L$+Math.imul(V,KQ)|0,R$=R$+Math.imul(V,IQ)|0,R$=R$+Math.imul(h,KQ)|0,P$=P$+Math.imul(h,IQ)|0,L$=L$+Math.imul(c$,K)|0,R$=R$+Math.imul(c$,l)|0,R$=R$+Math.imul(h$,K)|0,P$=P$+Math.imul(h$,l)|0;var zQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(zQ>>>26)|0,zQ&=67108863,L$=Math.imul(E0,KQ),R$=Math.imul(E0,IQ),R$=R$+Math.imul(b$,KQ)|0,P$=Math.imul(b$,IQ),L$=L$+Math.imul(V,K)|0,R$=R$+Math.imul(V,l)|0,R$=R$+Math.imul(h,K)|0,P$=P$+Math.imul(h,l)|0;var MQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(MQ>>>26)|0,MQ&=67108863,L$=Math.imul(E0,K),R$=Math.imul(E0,l),R$=R$+Math.imul(b$,K)|0,P$=Math.imul(b$,l);var SQ=(C$+L$|0)+((R$&8191)<<13)|0;return C$=(P$+(R$>>>13)|0)+(SQ>>>26)|0,SQ&=67108863,F0[0]=JQ,F0[1]=C0,F0[2]=FQ,F0[3]=AQ,F0[4]=HQ,F0[5]=WQ,F0[6]=EQ,F0[7]=TQ,F0[8]=DQ,F0[9]=I,F0[10]=o,F0[11]=CQ,F0[12]=L0,F0[13]=LQ,F0[14]=RQ,F0[15]=PQ,F0[16]=zQ,F0[17]=MQ,F0[18]=SQ,C$!==0&&(F0[19]=C$,Y.length++),Y};Math.imul||(X$=U$);function K$(E$,T$,Y){Y.negative=T$.negative^E$.negative,Y.length=E$.length+T$.length;for(var f=0,D$=0,F0=0;F0>>26)|0,D$+=C$>>>26,C$&=67108863}Y.words[F0]=L$,f=C$,C$=D$}return f!==0?Y.words[F0]=f:Y.length--,Y.strip()}function I$(E$,T$,Y){var f=new Q;return f.mulp(E$,T$,Y)}$$.prototype.mulTo=function(E$,T$){var Y,f=this.length+E$.length;return this.length===10&&E$.length===10?Y=X$(this,E$,T$):f<63?Y=U$(this,E$,T$):f<1024?Y=K$(this,E$,T$):Y=I$(this,E$,T$),Y};function Q(E$,T$){this.x=E$,this.y=T$}Q.prototype.makeRBT=function(E$){for(var T$=new Array(E$),Y=$$.prototype._countBits(E$)-1,f=0;f>=1;return f},Q.prototype.permute=function(E$,T$,Y,f,D$,F0){for(var C$=0;C$>>1)D$++;return 1<>>13,Y[2*F0+1]=D$&8191,D$=D$>>>13;for(F0=2*T$;F0>=26,T$+=f/67108864|0,T$+=D$>>>26,this.words[Y]=D$&67108863}return T$!==0&&(this.words[Y]=T$,this.length++),this},$$.prototype.muln=function(E$){return this.clone().imuln(E$)},$$.prototype.sqr=function(){return this.mul(this)},$$.prototype.isqr=function(){return this.imul(this.clone())},$$.prototype.pow=function(E$){var T$=V$(E$);if(T$.length===0)return new $$(1);for(var Y=this,f=0;f=0);var T$=E$%26,Y=(E$-T$)/26,f=67108863>>>26-T$<<26-T$,D$;if(T$!==0){var F0=0;for(D$=0;D$>>26-T$}F0&&(this.words[D$]=F0,this.length++)}if(Y!==0){for(D$=this.length-1;D$>=0;D$--)this.words[D$+Y]=this.words[D$];for(D$=0;D$=0);var f;T$?f=(T$-T$%26)/26:f=0;var D$=E$%26,F0=Math.min((E$-D$)/26,this.length),C$=67108863^67108863>>>D$<F0)for(this.length-=F0,R$=0;R$=0&&(P$!==0||R$>=f);R$--){var z$=this.words[R$]|0;this.words[R$]=P$<<26-D$|z$>>>D$,P$=z$&C$}return L$&&P$!==0&&(L$.words[L$.length++]=P$),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},$$.prototype.ishrn=function(E$,T$,Y){return r0(this.negative===0),this.iushrn(E$,T$,Y)},$$.prototype.shln=function(E$){return this.clone().ishln(E$)},$$.prototype.ushln=function(E$){return this.clone().iushln(E$)},$$.prototype.shrn=function(E$){return this.clone().ishrn(E$)},$$.prototype.ushrn=function(E$){return this.clone().iushrn(E$)},$$.prototype.testn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=E$%26,Y=(E$-T$)/26,f=1<=0);var T$=E$%26,Y=(E$-T$)/26;if(r0(this.negative===0,"imaskn works only with positive numbers"),this.length<=Y)return this;if(T$!==0&&Y++,this.length=Math.min(Y,this.length),T$!==0){var f=67108863^67108863>>>T$<=67108864;T$++)this.words[T$]-=67108864,T$===this.length-1?this.words[T$+1]=1:this.words[T$+1]++;return this.length=Math.max(this.length,T$+1),this},$$.prototype.isubn=function(E$){if(r0(typeof E$=="number"),r0(E$<67108864),E$<0)return this.iaddn(-E$);if(this.negative!==0)return this.negative=0,this.iaddn(E$),this.negative=1,this;if(this.words[0]-=E$,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var T$=0;T$>26)-(L$/67108864|0),this.words[D$+Y]=F0&67108863}for(;D$>26,this.words[D$+Y]=F0&67108863;if(C$===0)return this.strip();for(r0(C$===-1),C$=0,D$=0;D$>26,this.words[D$]=F0&67108863;return this.negative=1,this.strip()},$$.prototype._wordDiv=function(E$,T$){var Y=this.length-E$.length,f=this.clone(),D$=E$,F0=D$.words[D$.length-1]|0,C$=this._countBits(F0);Y=26-C$,Y!==0&&(D$=D$.ushln(Y),f.iushln(Y),F0=D$.words[D$.length-1]|0);var L$=f.length-D$.length,R$;if(T$!=="mod"){R$=new $$(null),R$.length=L$+1,R$.words=new Array(R$.length);for(var P$=0;P$=0;M$--){var S$=(f.words[D$.length+M$]|0)*67108864+(f.words[D$.length+M$-1]|0);for(S$=Math.min(S$/F0|0,67108863),f._ishlnsubmul(D$,S$,M$);f.negative!==0;)S$--,f.negative=0,f._ishlnsubmul(D$,1,M$),f.isZero()||(f.negative^=1);R$&&(R$.words[M$]=S$)}return R$&&R$.strip(),f.strip(),T$!=="div"&&Y!==0&&f.iushrn(Y),{div:R$||null,mod:f}},$$.prototype.divmod=function(E$,T$,Y){if(r0(!E$.isZero()),this.isZero())return{div:new $$(0),mod:new $$(0)};var f,D$,F0;return this.negative!==0&&E$.negative===0?(F0=this.neg().divmod(E$,T$),T$!=="mod"&&(f=F0.div.neg()),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.iadd(E$)),{div:f,mod:D$}):this.negative===0&&E$.negative!==0?(F0=this.divmod(E$.neg(),T$),T$!=="mod"&&(f=F0.div.neg()),{div:f,mod:F0.mod}):(this.negative&E$.negative)!==0?(F0=this.neg().divmod(E$.neg(),T$),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.isub(E$)),{div:F0.div,mod:D$}):E$.length>this.length||this.cmp(E$)<0?{div:new $$(0),mod:this}:E$.length===1?T$==="div"?{div:this.divn(E$.words[0]),mod:null}:T$==="mod"?{div:null,mod:new $$(this.modn(E$.words[0]))}:{div:this.divn(E$.words[0]),mod:new $$(this.modn(E$.words[0]))}:this._wordDiv(E$,T$)},$$.prototype.div=function(E$){return this.divmod(E$,"div",!1).div},$$.prototype.mod=function(E$){return this.divmod(E$,"mod",!1).mod},$$.prototype.umod=function(E$){return this.divmod(E$,"mod",!0).mod},$$.prototype.divRound=function(E$){var T$=this.divmod(E$);if(T$.mod.isZero())return T$.div;var Y=T$.div.negative!==0?T$.mod.isub(E$):T$.mod,f=E$.ushrn(1),D$=E$.andln(1),F0=Y.cmp(f);return F0<0||D$===1&&F0===0?T$.div:T$.div.negative!==0?T$.div.isubn(1):T$.div.iaddn(1)},$$.prototype.modn=function(E$){r0(E$<=67108863);for(var T$=(1<<26)%E$,Y=0,f=this.length-1;f>=0;f--)Y=(T$*Y+(this.words[f]|0))%E$;return Y},$$.prototype.idivn=function(E$){r0(E$<=67108863);for(var T$=0,Y=this.length-1;Y>=0;Y--){var f=(this.words[Y]|0)+T$*67108864;this.words[Y]=f/E$|0,T$=f%E$}return this.strip()},$$.prototype.divn=function(E$){return this.clone().idivn(E$)},$$.prototype.egcd=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=new $$(0),C$=new $$(1),L$=0;T$.isEven()&&Y.isEven();)T$.iushrn(1),Y.iushrn(1),++L$;for(var R$=Y.clone(),P$=T$.clone();!T$.isZero();){for(var z$=0,M$=1;(T$.words[0]&M$)===0&&z$<26;++z$,M$<<=1);if(z$>0)for(T$.iushrn(z$);z$-- >0;)(f.isOdd()||D$.isOdd())&&(f.iadd(R$),D$.isub(P$)),f.iushrn(1),D$.iushrn(1);for(var S$=0,Z=1;(Y.words[0]&Z)===0&&S$<26;++S$,Z<<=1);if(S$>0)for(Y.iushrn(S$);S$-- >0;)(F0.isOdd()||C$.isOdd())&&(F0.iadd(R$),C$.isub(P$)),F0.iushrn(1),C$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(F0),D$.isub(C$)):(Y.isub(T$),F0.isub(f),C$.isub(D$))}return{a:F0,b:C$,gcd:Y.iushln(L$)}},$$.prototype._invmp=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=Y.clone();T$.cmpn(1)>0&&Y.cmpn(1)>0;){for(var C$=0,L$=1;(T$.words[0]&L$)===0&&C$<26;++C$,L$<<=1);if(C$>0)for(T$.iushrn(C$);C$-- >0;)f.isOdd()&&f.iadd(F0),f.iushrn(1);for(var R$=0,P$=1;(Y.words[0]&P$)===0&&R$<26;++R$,P$<<=1);if(R$>0)for(Y.iushrn(R$);R$-- >0;)D$.isOdd()&&D$.iadd(F0),D$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(D$)):(Y.isub(T$),D$.isub(f))}var z$;return T$.cmpn(1)===0?z$=f:z$=D$,z$.cmpn(0)<0&&z$.iadd(E$),z$},$$.prototype.gcd=function(E$){if(this.isZero())return E$.abs();if(E$.isZero())return this.abs();var T$=this.clone(),Y=E$.clone();T$.negative=0,Y.negative=0;for(var f=0;T$.isEven()&&Y.isEven();f++)T$.iushrn(1),Y.iushrn(1);do{for(;T$.isEven();)T$.iushrn(1);for(;Y.isEven();)Y.iushrn(1);var D$=T$.cmp(Y);if(D$<0){var F0=T$;T$=Y,Y=F0}else if(D$===0||Y.cmpn(1)===0)break;T$.isub(Y)}while(!0);return Y.iushln(f)},$$.prototype.invm=function(E$){return this.egcd(E$).a.umod(E$)},$$.prototype.isEven=function(){return(this.words[0]&1)===0},$$.prototype.isOdd=function(){return(this.words[0]&1)===1},$$.prototype.andln=function(E$){return this.words[0]&E$},$$.prototype.bincn=function(E$){r0(typeof E$=="number");var T$=E$%26,Y=(E$-T$)/26,f=1<>>26,C$&=67108863,this.words[F0]=C$}return D$!==0&&(this.words[F0]=D$,this.length++),this},$$.prototype.isZero=function(){return this.length===1&&this.words[0]===0},$$.prototype.cmpn=function(E$){var T$=E$<0;if(this.negative!==0&&!T$)return-1;if(this.negative===0&&T$)return 1;this.strip();var Y;if(this.length>1)Y=1;else{T$&&(E$=-E$),r0(E$<=67108863,"Number is too big");var f=this.words[0]|0;Y=f===E$?0:fE$.length)return 1;if(this.length=0;Y--){var f=this.words[Y]|0,D$=E$.words[Y]|0;if(f!==D$){fD$&&(T$=1);break}}return T$},$$.prototype.gtn=function(E$){return this.cmpn(E$)===1},$$.prototype.gt=function(E$){return this.cmp(E$)===1},$$.prototype.gten=function(E$){return this.cmpn(E$)>=0},$$.prototype.gte=function(E$){return this.cmp(E$)>=0},$$.prototype.ltn=function(E$){return this.cmpn(E$)===-1},$$.prototype.lt=function(E$){return this.cmp(E$)===-1},$$.prototype.lten=function(E$){return this.cmpn(E$)<=0},$$.prototype.lte=function(E$){return this.cmp(E$)<=0},$$.prototype.eqn=function(E$){return this.cmpn(E$)===0},$$.prototype.eq=function(E$){return this.cmp(E$)===0},$$.red=function(E$){return new H$(E$)},$$.prototype.toRed=function(E$){return r0(!this.red,"Already a number in reduction context"),r0(this.negative===0,"red works only with positives"),E$.convertTo(this)._forceRed(E$)},$$.prototype.fromRed=function(){return r0(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},$$.prototype._forceRed=function(E$){return this.red=E$,this},$$.prototype.forceRed=function(E$){return r0(!this.red,"Already a number in reduction context"),this._forceRed(E$)},$$.prototype.redAdd=function(E$){return r0(this.red,"redAdd works only with red numbers"),this.red.add(this,E$)},$$.prototype.redIAdd=function(E$){return r0(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,E$)},$$.prototype.redSub=function(E$){return r0(this.red,"redSub works only with red numbers"),this.red.sub(this,E$)},$$.prototype.redISub=function(E$){return r0(this.red,"redISub works only with red numbers"),this.red.isub(this,E$)},$$.prototype.redShl=function(E$){return r0(this.red,"redShl works only with red numbers"),this.red.shl(this,E$)},$$.prototype.redMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.mul(this,E$)},$$.prototype.redIMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.imul(this,E$)},$$.prototype.redSqr=function(){return r0(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},$$.prototype.redISqr=function(){return r0(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},$$.prototype.redSqrt=function(){return r0(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},$$.prototype.redInvm=function(){return r0(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},$$.prototype.redNeg=function(){return r0(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},$$.prototype.redPow=function(E$){return r0(this.red&&!E$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,E$)};var x={k256:null,p224:null,p192:null,p25519:null};function O$(E$,T$){this.name=E$,this.p=new $$(T$,16),this.n=this.p.bitLength(),this.k=new $$(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}O$.prototype._tmp=function(){var E$=new $$(null);return E$.words=new Array(Math.ceil(this.n/13)),E$},O$.prototype.ireduce=function(E$){var T$=E$,Y;do this.split(T$,this.tmp),T$=this.imulK(T$),T$=T$.iadd(this.tmp),Y=T$.bitLength();while(Y>this.n);var f=Y0?T$.isub(this.p):T$.strip!==void 0?T$.strip():T$._strip(),T$},O$.prototype.split=function(E$,T$){E$.iushrn(this.n,0,T$)},O$.prototype.imulK=function(E$){return E$.imul(this.k)};function J0(){O$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i0(J0,O$),J0.prototype.split=function(E$,T$){for(var Y=4194303,f=Math.min(E$.length,9),D$=0;D$>>22,F0=C$}F0>>>=22,E$.words[D$-10]=F0,F0===0&&E$.length>10?E$.length-=10:E$.length-=9},J0.prototype.imulK=function(E$){E$.words[E$.length]=0,E$.words[E$.length+1]=0,E$.length+=2;for(var T$=0,Y=0;Y>>=26,E$.words[Y]=D$,T$=f}return T$!==0&&(E$.words[E$.length++]=T$),E$},$$._prime=function(E$){if(x[E$])return x[E$];var T$;if(E$==="k256")T$=new J0;else if(E$==="p224")T$=new J$;else if(E$==="p192")T$=new F$;else if(E$==="p25519")T$=new A$;else throw new Error("Unknown prime "+E$);return x[E$]=T$,T$};function H$(E$){if(typeof E$=="string"){var T$=$$._prime(E$);this.m=T$.p,this.prime=T$}else r0(E$.gtn(1),"modulus must be greater than 1"),this.m=E$,this.prime=null}H$.prototype._verify1=function(E$){r0(E$.negative===0,"red works only with positives"),r0(E$.red,"red works only with red numbers")},H$.prototype._verify2=function(E$,T$){r0((E$.negative|T$.negative)===0,"red works only with positives"),r0(E$.red&&E$.red===T$.red,"red works only with red numbers")},H$.prototype.imod=function(E$){return this.prime?this.prime.ireduce(E$)._forceRed(this):E$.umod(this.m)._forceRed(this)},H$.prototype.neg=function(E$){return E$.isZero()?E$.clone():this.m.sub(E$)._forceRed(this)},H$.prototype.add=function(E$,T$){this._verify2(E$,T$);var Y=E$.add(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y._forceRed(this)},H$.prototype.iadd=function(E$,T$){this._verify2(E$,T$);var Y=E$.iadd(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y},H$.prototype.sub=function(E$,T$){this._verify2(E$,T$);var Y=E$.sub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y._forceRed(this)},H$.prototype.isub=function(E$,T$){this._verify2(E$,T$);var Y=E$.isub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y},H$.prototype.shl=function(E$,T$){return this._verify1(E$),this.imod(E$.ushln(T$))},H$.prototype.imul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.imul(T$))},H$.prototype.mul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.mul(T$))},H$.prototype.isqr=function(E$){return this.imul(E$,E$.clone())},H$.prototype.sqr=function(E$){return this.mul(E$,E$)},H$.prototype.sqrt=function(E$){if(E$.isZero())return E$.clone();var T$=this.m.andln(3);if(r0(T$%2===1),T$===3){var Y=this.m.add(new $$(1)).iushrn(2);return this.pow(E$,Y)}for(var f=this.m.subn(1),D$=0;!f.isZero()&&f.andln(1)===0;)D$++,f.iushrn(1);r0(!f.isZero());var F0=new $$(1).toRed(this),C$=F0.redNeg(),L$=this.m.subn(1).iushrn(1),R$=this.m.bitLength();for(R$=new $$(2*R$*R$).toRed(this);this.pow(R$,L$).cmp(C$)!==0;)R$.redIAdd(C$);for(var P$=this.pow(R$,f),z$=this.pow(E$,f.addn(1).iushrn(1)),M$=this.pow(E$,f),S$=D$;M$.cmp(F0)!==0;){for(var Z=M$,c=0;Z.cmp(F0)!==0;c++)Z=Z.redSqr();r0(c=0;D$--){for(var P$=T$.words[D$],z$=R$-1;z$>=0;z$--){var M$=P$>>z$&1;if(F0!==f[0]&&(F0=this.sqr(F0)),M$===0&&C$===0){L$=0;continue}C$<<=1,C$|=M$,L$++,!(L$!==Y&&(D$!==0||z$!==0))&&(F0=this.mul(F0,f[C$]),L$=0,C$=0)}R$=26}return F0},H$.prototype.convertTo=function(E$){var T$=E$.umod(this.m);return T$===E$?T$.clone():T$},H$.prototype.convertFrom=function(E$){var T$=E$.clone();return T$.red=null,T$},$$.mont=function(E$){return new W$(E$)};function W$(E$){H$.call(this,E$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new $$(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)}i0(W$,H$),W$.prototype.convertTo=function(E$){return this.imod(E$.ushln(this.shift))},W$.prototype.convertFrom=function(E$){var T$=this.imod(E$.mul(this.rinv));return T$.red=null,T$},W$.prototype.imul=function(E$,T$){if(E$.isZero()||T$.isZero())return E$.words[0]=0,E$.length=1,E$;var Y=E$.imul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.mul=function(E$,T$){if(E$.isZero()||T$.isZero())return new $$(0)._forceRed(this);var Y=E$.mul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.invm=function(E$){var T$=this.imod(E$._invmp(this.m).mul(this.r2));return T$._forceRed(this)}})(typeof m0>"u"||m0,t0)}}),tY=pQ({"node_modules/safer-buffer/safer.js"(t0,m0){var a0=P0,e0=G0,r0={},i0;for(i0 in a0)!a0.hasOwnProperty(i0)||i0==="SlowBuffer"||i0==="Buffer"||(r0[i0]=a0[i0]);var $$=r0.Buffer={};for(i0 in e0)!e0.hasOwnProperty(i0)||i0==="allocUnsafe"||i0==="allocUnsafeSlow"||($$[i0]=e0[i0]);if(r0.Buffer.prototype=e0.prototype,(!$$.from||$$.from===Uint8Array.from)&&($$.from=function(Q$,$,N){if(typeof Q$=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof Q$);if(Q$&&typeof Q$.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Q$);return e0(Q$,$,N)}),$$.alloc||($$.alloc=function(Q$,$,N){if(typeof Q$!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof Q$);if(Q$<0||Q$>=2*(1<<30))throw new RangeError('The value "'+Q$+'" is invalid for option "size"');var Y$=e0(Q$);return!$||$.length===0?Y$.fill(0):typeof N=="string"?Y$.fill($,N):Y$.fill($),Y$}),!r0.kStringMaxLength)try{r0.kStringMaxLength=yQ}catch{}r0.constants||(r0.constants={MAX_LENGTH:r0.kMaxLength},r0.kStringMaxLength&&(r0.constants.MAX_STRING_LENGTH=r0.kStringMaxLength)),m0.exports=r0}}),mY=pQ({"node_modules/asn1.js/lib/asn1/base/reporter.js"(t0){var m0=dQ();function a0(r0){this._reporterState={obj:null,path:[],options:r0||{},errors:[]}}t0.Reporter=a0,a0.prototype.isError=function(r0){return r0 instanceof e0},a0.prototype.save=function(){let r0=this._reporterState;return{obj:r0.obj,pathLen:r0.path.length}},a0.prototype.restore=function(r0){let i0=this._reporterState;i0.obj=r0.obj,i0.path=i0.path.slice(0,r0.pathLen)},a0.prototype.enterKey=function(r0){return this._reporterState.path.push(r0)},a0.prototype.exitKey=function(r0){let i0=this._reporterState;i0.path=i0.path.slice(0,r0-1)},a0.prototype.leaveKey=function(r0,i0,$$){let Q$=this._reporterState;this.exitKey(r0),Q$.obj!==null&&(Q$.obj[i0]=$$)},a0.prototype.path=function(){return this._reporterState.path.join("/")},a0.prototype.enterObject=function(){let r0=this._reporterState,i0=r0.obj;return r0.obj={},i0},a0.prototype.leaveObject=function(r0){let i0=this._reporterState,$$=i0.obj;return i0.obj=r0,$$},a0.prototype.error=function(r0){let i0,$$=this._reporterState,Q$=r0 instanceof e0;if(Q$?i0=r0:i0=new e0($$.path.map(function($){return"["+JSON.stringify($)+"]"}).join(""),r0.message||r0,r0.stack),!$$.options.partial)throw i0;return Q$||$$.errors.push(i0),i0},a0.prototype.wrapResult=function(r0){let i0=this._reporterState;return i0.options.partial?{result:this.isError(r0)?null:r0,errors:i0.errors}:r0};function e0(r0,i0){this.path=r0,this.rethrow(i0)}m0(e0,Error),e0.prototype.rethrow=function(r0){if(this.message=r0+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,e0),!this.stack)try{throw new Error(this.message)}catch(i0){this.stack=i0.stack}return this}}}),kQ=pQ({"node_modules/asn1.js/lib/asn1/base/buffer.js"(t0){var m0=dQ(),a0=mY().Reporter,e0=tY().Buffer;function r0($$,Q$){if(a0.call(this,Q$),!e0.isBuffer($$)){this.error("Input not Buffer");return}this.base=$$,this.offset=0,this.length=$$.length}m0(r0,a0),t0.DecoderBuffer=r0,r0.isDecoderBuffer=function($$){return $$ instanceof r0?!0:typeof $$=="object"&&e0.isBuffer($$.base)&&$$.constructor.name==="DecoderBuffer"&&typeof $$.offset=="number"&&typeof $$.length=="number"&&typeof $$.save=="function"&&typeof $$.restore=="function"&&typeof $$.isEmpty=="function"&&typeof $$.readUInt8=="function"&&typeof $$.skip=="function"&&typeof $$.raw=="function"},r0.prototype.save=function(){return{offset:this.offset,reporter:a0.prototype.save.call(this)}},r0.prototype.restore=function($$){let Q$=new r0(this.base);return Q$.offset=$$.offset,Q$.length=this.offset,this.offset=$$.offset,a0.prototype.restore.call(this,$$.reporter),Q$},r0.prototype.isEmpty=function(){return this.offset===this.length},r0.prototype.readUInt8=function($$){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error($$||"DecoderBuffer overrun")},r0.prototype.skip=function($$,Q$){if(!(this.offset+$$<=this.length))return this.error(Q$||"DecoderBuffer overrun");let $=new r0(this.base);return $._reporterState=this._reporterState,$.offset=this.offset,$.length=this.offset+$$,this.offset+=$$,$},r0.prototype.raw=function($$){return this.base.slice($$?$$.offset:this.offset,this.length)};function i0($$,Q$){if(Array.isArray($$))this.length=0,this.value=$$.map(function($){return i0.isEncoderBuffer($)||($=new i0($,Q$)),this.length+=$.length,$},this);else if(typeof $$=="number"){if(!(0<=$$&&$$<=255))return Q$.error("non-byte EncoderBuffer value");this.value=$$,this.length=1}else if(typeof $$=="string")this.value=$$,this.length=e0.byteLength($$);else if(e0.isBuffer($$))this.value=$$,this.length=$$.length;else return Q$.error("Unsupported type: "+typeof $$)}t0.EncoderBuffer=i0,i0.isEncoderBuffer=function($$){return $$ instanceof i0?!0:typeof $$=="object"&&$$.constructor.name==="EncoderBuffer"&&typeof $$.length=="number"&&typeof $$.join=="function"},i0.prototype.join=function($$,Q$){return $$||($$=e0.alloc(this.length)),Q$||(Q$=0),this.length===0||(Array.isArray(this.value)?this.value.forEach(function($){$.join($$,Q$),Q$+=$.length}):(typeof this.value=="number"?$$[Q$]=this.value:typeof this.value=="string"?$$.write(this.value,Q$):e0.isBuffer(this.value)&&this.value.copy($$,Q$),Q$+=this.length)),$$}}}),aY=pQ({"node_modules/asn1.js/lib/asn1/base/node.js"(t0,m0){var a0=mY().Reporter,e0=kQ().EncoderBuffer,r0=kQ().DecoderBuffer,i0=v0(),$$=["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"],Q$=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat($$),$=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function N(O0,Z$,G$){let V$={};this._baseState=V$,V$.name=G$,V$.enc=O0,V$.parent=Z$||null,V$.children=null,V$.tag=null,V$.args=null,V$.reverseArgs=null,V$.choice=null,V$.optional=!1,V$.any=!1,V$.obj=!1,V$.use=null,V$.useDecoder=null,V$.key=null,V$.default=null,V$.explicit=null,V$.implicit=null,V$.contains=null,V$.parent||(V$.children=[],this._wrap())}m0.exports=N;var Y$=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];N.prototype.clone=function(){let O0=this._baseState,Z$={};Y$.forEach(function(V$){Z$[V$]=O0[V$]});let G$=new this.constructor(Z$.parent);return G$._baseState=Z$,G$},N.prototype._wrap=function(){let O0=this._baseState;Q$.forEach(function(Z$){this[Z$]=function(){let G$=new this.constructor(this);return O0.children.push(G$),G$[Z$].apply(G$,arguments)}},this)},N.prototype._init=function(O0){let Z$=this._baseState;i0(Z$.parent===null),O0.call(this),Z$.children=Z$.children.filter(function(G$){return G$._baseState.parent===this},this),i0.equal(Z$.children.length,1,"Root node can have only one child")},N.prototype._useArgs=function(O0){let Z$=this._baseState,G$=O0.filter(function(V$){return V$ instanceof this.constructor},this);O0=O0.filter(function(V$){return!(V$ instanceof this.constructor)},this),G$.length!==0&&(i0(Z$.children===null),Z$.children=G$,G$.forEach(function(V$){V$._baseState.parent=this},this)),O0.length!==0&&(i0(Z$.args===null),Z$.args=O0,Z$.reverseArgs=O0.map(function(V$){if(typeof V$!="object"||V$.constructor!==Object)return V$;let U$={};return Object.keys(V$).forEach(function(X$){X$==(X$|0)&&(X$|=0);let K$=V$[X$];U$[K$]=X$}),U$}))},$.forEach(function(O0){N.prototype[O0]=function(){let Z$=this._baseState;throw new Error(O0+" not implemented for encoding: "+Z$.enc)}}),$$.forEach(function(O0){N.prototype[O0]=function(){let Z$=this._baseState,G$=Array.prototype.slice.call(arguments);return i0(Z$.tag===null),Z$.tag=O0,this._useArgs(G$),this}}),N.prototype.use=function(O0){i0(O0);let Z$=this._baseState;return i0(Z$.use===null),Z$.use=O0,this},N.prototype.optional=function(){let O0=this._baseState;return O0.optional=!0,this},N.prototype.def=function(O0){let Z$=this._baseState;return i0(Z$.default===null),Z$.default=O0,Z$.optional=!0,this},N.prototype.explicit=function(O0){let Z$=this._baseState;return i0(Z$.explicit===null&&Z$.implicit===null),Z$.explicit=O0,this},N.prototype.implicit=function(O0){let Z$=this._baseState;return i0(Z$.explicit===null&&Z$.implicit===null),Z$.implicit=O0,this},N.prototype.obj=function(){let O0=this._baseState,Z$=Array.prototype.slice.call(arguments);return O0.obj=!0,Z$.length!==0&&this._useArgs(Z$),this},N.prototype.key=function(O0){let Z$=this._baseState;return i0(Z$.key===null),Z$.key=O0,this},N.prototype.any=function(){let O0=this._baseState;return O0.any=!0,this},N.prototype.choice=function(O0){let Z$=this._baseState;return i0(Z$.choice===null),Z$.choice=O0,this._useArgs(Object.keys(O0).map(function(G$){return O0[G$]})),this},N.prototype.contains=function(O0){let Z$=this._baseState;return i0(Z$.use===null),Z$.contains=O0,this},N.prototype._decode=function(O0,Z$){let G$=this._baseState;if(G$.parent===null)return O0.wrapResult(G$.children[0]._decode(O0,Z$));let V$=G$.default,U$=!0,X$=null;if(G$.key!==null&&(X$=O0.enterKey(G$.key)),G$.optional){let I$=null;if(G$.explicit!==null?I$=G$.explicit:G$.implicit!==null?I$=G$.implicit:G$.tag!==null&&(I$=G$.tag),I$===null&&!G$.any){let Q=O0.save();try{G$.choice===null?this._decodeGeneric(G$.tag,O0,Z$):this._decodeChoice(O0,Z$),U$=!0}catch{U$=!1}O0.restore(Q)}else if(U$=this._peekTag(O0,I$,G$.any),O0.isError(U$))return U$}let K$;if(G$.obj&&U$&&(K$=O0.enterObject()),U$){if(G$.explicit!==null){let Q=this._decodeTag(O0,G$.explicit);if(O0.isError(Q))return Q;O0=Q}let I$=O0.offset;if(G$.use===null&&G$.choice===null){let Q;G$.any&&(Q=O0.save());let x=this._decodeTag(O0,G$.implicit!==null?G$.implicit:G$.tag,G$.any);if(O0.isError(x))return x;G$.any?V$=O0.raw(Q):O0=x}if(Z$&&Z$.track&&G$.tag!==null&&Z$.track(O0.path(),I$,O0.length,"tagged"),Z$&&Z$.track&&G$.tag!==null&&Z$.track(O0.path(),O0.offset,O0.length,"content"),G$.any||(G$.choice===null?V$=this._decodeGeneric(G$.tag,O0,Z$):V$=this._decodeChoice(O0,Z$)),O0.isError(V$))return V$;if(!G$.any&&G$.choice===null&&G$.children!==null&&G$.children.forEach(function(Q){Q._decode(O0,Z$)}),G$.contains&&(G$.tag==="octstr"||G$.tag==="bitstr")){let Q=new r0(V$);V$=this._getUse(G$.contains,O0._reporterState.obj)._decode(Q,Z$)}}return G$.obj&&U$&&(V$=O0.leaveObject(K$)),G$.key!==null&&(V$!==null||U$===!0)?O0.leaveKey(X$,G$.key,V$):X$!==null&&O0.exitKey(X$),V$},N.prototype._decodeGeneric=function(O0,Z$,G$){let V$=this._baseState;return O0==="seq"||O0==="set"?null:O0==="seqof"||O0==="setof"?this._decodeList(Z$,O0,V$.args[0],G$):/str$/.test(O0)?this._decodeStr(Z$,O0,G$):O0==="objid"&&V$.args?this._decodeObjid(Z$,V$.args[0],V$.args[1],G$):O0==="objid"?this._decodeObjid(Z$,null,null,G$):O0==="gentime"||O0==="utctime"?this._decodeTime(Z$,O0,G$):O0==="null_"?this._decodeNull(Z$,G$):O0==="bool"?this._decodeBool(Z$,G$):O0==="objDesc"?this._decodeStr(Z$,O0,G$):O0==="int"||O0==="enum"?this._decodeInt(Z$,V$.args&&V$.args[0],G$):V$.use!==null?this._getUse(V$.use,Z$._reporterState.obj)._decode(Z$,G$):Z$.error("unknown tag: "+O0)},N.prototype._getUse=function(O0,Z$){let G$=this._baseState;return G$.useDecoder=this._use(O0,Z$),i0(G$.useDecoder._baseState.parent===null),G$.useDecoder=G$.useDecoder._baseState.children[0],G$.implicit!==G$.useDecoder._baseState.implicit&&(G$.useDecoder=G$.useDecoder.clone(),G$.useDecoder._baseState.implicit=G$.implicit),G$.useDecoder},N.prototype._decodeChoice=function(O0,Z$){let G$=this._baseState,V$=null,U$=!1;return Object.keys(G$.choice).some(function(X$){let K$=O0.save(),I$=G$.choice[X$];try{let Q=I$._decode(O0,Z$);if(O0.isError(Q))return!1;V$={type:X$,value:Q},U$=!0}catch{return O0.restore(K$),!1}return!0},this),U$?V$:O0.error("Choice not matched")},N.prototype._createEncoderBuffer=function(O0){return new e0(O0,this.reporter)},N.prototype._encode=function(O0,Z$,G$){let V$=this._baseState;if(V$.default!==null&&V$.default===O0)return;let U$=this._encodeValue(O0,Z$,G$);if(U$!==void 0&&!this._skipDefault(U$,Z$,G$))return U$},N.prototype._encodeValue=function(O0,Z$,G$){let V$=this._baseState;if(V$.parent===null)return V$.children[0]._encode(O0,Z$||new a0);let U$=null;if(this.reporter=Z$,V$.optional&&O0===void 0)if(V$.default!==null)O0=V$.default;else return;let X$=null,K$=!1;if(V$.any)U$=this._createEncoderBuffer(O0);else if(V$.choice)U$=this._encodeChoice(O0,Z$);else if(V$.contains)X$=this._getUse(V$.contains,G$)._encode(O0,Z$),K$=!0;else if(V$.children)X$=V$.children.map(function(I$){if(I$._baseState.tag==="null_")return I$._encode(null,Z$,O0);if(I$._baseState.key===null)return Z$.error("Child should have a key");let Q=Z$.enterKey(I$._baseState.key);if(typeof O0!="object")return Z$.error("Child expected, but input is not object");let x=I$._encode(O0[I$._baseState.key],Z$,O0);return Z$.leaveKey(Q),x},this).filter(function(I$){return I$}),X$=this._createEncoderBuffer(X$);else if(V$.tag==="seqof"||V$.tag==="setof"){if(!(V$.args&&V$.args.length===1))return Z$.error("Too many args for : "+V$.tag);if(!Array.isArray(O0))return Z$.error("seqof/setof, but data is not Array");let I$=this.clone();I$._baseState.implicit=null,X$=this._createEncoderBuffer(O0.map(function(Q){let x=this._baseState;return this._getUse(x.args[0],O0)._encode(Q,Z$)},I$))}else V$.use!==null?U$=this._getUse(V$.use,G$)._encode(O0,Z$):(X$=this._encodePrimitive(V$.tag,O0),K$=!0);if(!V$.any&&V$.choice===null){let I$=V$.implicit!==null?V$.implicit:V$.tag,Q=V$.implicit===null?"universal":"context";I$===null?V$.use===null&&Z$.error("Tag could be omitted only for .use()"):V$.use===null&&(U$=this._encodeComposite(I$,K$,Q,X$))}return V$.explicit!==null&&(U$=this._encodeComposite(V$.explicit,!1,"context",U$)),U$},N.prototype._encodeChoice=function(O0,Z$){let G$=this._baseState,V$=G$.choice[O0.type];return V$||i0(!1,O0.type+" not found in "+JSON.stringify(Object.keys(G$.choice))),V$._encode(O0.value,Z$)},N.prototype._encodePrimitive=function(O0,Z$){let G$=this._baseState;if(/str$/.test(O0))return this._encodeStr(Z$,O0);if(O0==="objid"&&G$.args)return this._encodeObjid(Z$,G$.reverseArgs[0],G$.args[1]);if(O0==="objid")return this._encodeObjid(Z$,null,null);if(O0==="gentime"||O0==="utctime")return this._encodeTime(Z$,O0);if(O0==="null_")return this._encodeNull();if(O0==="int"||O0==="enum")return this._encodeInt(Z$,G$.args&&G$.reverseArgs[0]);if(O0==="bool")return this._encodeBool(Z$);if(O0==="objDesc")return this._encodeStr(Z$,O0);throw new Error("Unsupported tag: "+O0)},N.prototype._isNumstr=function(O0){return/^[0-9 ]*$/.test(O0)},N.prototype._isPrintstr=function(O0){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(O0)}}}),eY=pQ({"node_modules/asn1.js/lib/asn1/constants/der.js"(t0){function m0(a0){let e0={};return Object.keys(a0).forEach(function(r0){(r0|0)==r0&&(r0=r0|0);let i0=a0[r0];e0[i0]=r0}),e0}t0.tagClass={0:"universal",1:"application",2:"context",3:"private"},t0.tagClassByName=m0(t0.tagClass),t0.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"},t0.tagByName=m0(t0.tag)}}),R=pQ({"node_modules/asn1.js/lib/asn1/encoders/der.js"(t0,m0){var a0=dQ(),e0=tY().Buffer,r0=aY(),i0=eY();function $$(Y$){this.enc="der",this.name=Y$.name,this.entity=Y$,this.tree=new Q$,this.tree._init(Y$.body)}m0.exports=$$,$$.prototype.encode=function(Y$,O0){return this.tree._encode(Y$,O0).join()};function Q$(Y$){r0.call(this,"der",Y$)}a0(Q$,r0),Q$.prototype._encodeComposite=function(Y$,O0,Z$,G$){let V$=N(Y$,O0,Z$,this.reporter);if(G$.length<128){let K$=e0.alloc(2);return K$[0]=V$,K$[1]=G$.length,this._createEncoderBuffer([K$,G$])}let U$=1;for(let K$=G$.length;K$>=256;K$>>=8)U$++;let X$=e0.alloc(2+U$);X$[0]=V$,X$[1]=128|U$;for(let K$=1+U$,I$=G$.length;I$>0;K$--,I$>>=8)X$[K$]=I$&255;return this._createEncoderBuffer([X$,G$])},Q$.prototype._encodeStr=function(Y$,O0){if(O0==="bitstr")return this._createEncoderBuffer([Y$.unused|0,Y$.data]);if(O0==="bmpstr"){let Z$=e0.alloc(Y$.length*2);for(let G$=0;G$=40)return this.reporter.error("Second objid identifier OOB");Y$.splice(0,2,Y$[0]*40+Y$[1])}let G$=0;for(let X$=0;X$=128;K$>>=7)G$++}let V$=e0.alloc(G$),U$=V$.length-1;for(let X$=Y$.length-1;X$>=0;X$--){let K$=Y$[X$];for(V$[U$--]=K$&127;(K$>>=7)>0;)V$[U$--]=128|K$&127}return this._createEncoderBuffer(V$)};function $(Y$){return Y$<10?"0"+Y$:Y$}Q$.prototype._encodeTime=function(Y$,O0){let Z$,G$=new Date(Y$);return O0==="gentime"?Z$=[$(G$.getUTCFullYear()),$(G$.getUTCMonth()+1),$(G$.getUTCDate()),$(G$.getUTCHours()),$(G$.getUTCMinutes()),$(G$.getUTCSeconds()),"Z"].join(""):O0==="utctime"?Z$=[$(G$.getUTCFullYear()%100),$(G$.getUTCMonth()+1),$(G$.getUTCDate()),$(G$.getUTCHours()),$(G$.getUTCMinutes()),$(G$.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+O0+" time is not supported yet"),this._encodeStr(Z$,"octstr")},Q$.prototype._encodeNull=function(){return this._createEncoderBuffer("")},Q$.prototype._encodeInt=function(Y$,O0){if(typeof Y$=="string"){if(!O0)return this.reporter.error("String int or enum given, but no values map");if(!O0.hasOwnProperty(Y$))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(Y$));Y$=O0[Y$]}if(typeof Y$!="number"&&!e0.isBuffer(Y$)){let V$=Y$.toArray();!Y$.sign&&V$[0]&128&&V$.unshift(0),Y$=e0.from(V$)}if(e0.isBuffer(Y$)){let V$=Y$.length;Y$.length===0&&V$++;let U$=e0.alloc(V$);return Y$.copy(U$),Y$.length===0&&(U$[0]=0),this._createEncoderBuffer(U$)}if(Y$<128)return this._createEncoderBuffer(Y$);if(Y$<256)return this._createEncoderBuffer([0,Y$]);let Z$=1;for(let V$=Y$;V$>=256;V$>>=8)Z$++;let G$=new Array(Z$);for(let V$=G$.length-1;V$>=0;V$--)G$[V$]=Y$&255,Y$>>=8;return G$[0]&128&&G$.unshift(0),this._createEncoderBuffer(e0.from(G$))},Q$.prototype._encodeBool=function(Y$){return this._createEncoderBuffer(Y$?255:0)},Q$.prototype._use=function(Y$,O0){return typeof Y$=="function"&&(Y$=Y$(O0)),Y$._getEncoder("der").tree},Q$.prototype._skipDefault=function(Y$,O0,Z$){let G$=this._baseState,V$;if(G$.default===null)return!1;let U$=Y$.join();if(G$.defaultBuffer===void 0&&(G$.defaultBuffer=this._encodeValue(G$.default,O0,Z$).join()),U$.length!==G$.defaultBuffer.length)return!1;for(V$=0;V$=31?G$.error("Multi-octet tag encoding unsupported"):(O0||(V$|=32),V$|=i0.tagClassByName[Z$||"universal"]<<6,V$)}}}),r=pQ({"node_modules/asn1.js/lib/asn1/encoders/pem.js"(t0,m0){var a0=dQ(),e0=R();function r0(i0){e0.call(this,i0),this.enc="pem"}a0(r0,e0),m0.exports=r0,r0.prototype.encode=function(i0,$$){let Q$=e0.prototype.encode.call(this,i0).toString("base64"),$=["-----BEGIN "+$$.label+"-----"];for(let N=0;N>6],U$=(G$&32)===0;if((G$&31)===31){let K$=G$;for(G$=0;(K$&128)===128;){if(K$=O0.readUInt8(Z$),O0.isError(K$))return K$;G$<<=7,G$|=K$&127}}else G$&=31;let X$=$$.tag[G$];return{cls:V$,primitive:U$,tag:G$,tagStr:X$}}function Y$(O0,Z$,G$){let V$=O0.readUInt8(G$);if(O0.isError(V$))return V$;if(!Z$&&V$===128)return null;if((V$&128)===0)return V$;let U$=V$&127;if(U$>4)return O0.error("length octect is too long");V$=0;for(let X$=0;X$0&&x.ishrn(O$),x}function U$(I$,Q){I$=V$(I$,Q),I$=I$.mod(Q);var x=a0.from(I$.toArray());if(x.length=Z$)throw new Error("invalid sig")}m0.exports=Q$}}),IZ=pQ({"node_modules/browserify-sign/browser/index.js"(t0,m0){var a0=cQ().Buffer,e0=w(),r0=dQ(),i0=XZ(),$$=KZ(),Q$=eQ();Object.keys(Q$).forEach(function(Z$){Q$[Z$].id=a0.from(Q$[Z$].id,"hex"),Q$[Z$.toLowerCase()]=Q$[Z$]});function $(Z$){R0.Writable.call(this);var G$=Q$[Z$];if(!G$)throw new Error("Unknown message digest");this._hashType=G$.hash,this._hash=e0(G$.hash),this._tag=G$.id,this._signType=G$.sign}r0($,R0.Writable),$.prototype._write=function(Z$,G$,V$){this._hash.update(Z$),V$()},$.prototype.update=function(Z$,G$){return typeof Z$=="string"&&(Z$=a0.from(Z$,G$)),this._hash.update(Z$),this},$.prototype.sign=function(Z$,G$){this.end();var V$=this._hash.digest(),U$=i0(V$,Z$,this._hashType,this._signType,this._tag);return G$?U$.toString(G$):U$};function N(Z$){R0.Writable.call(this);var G$=Q$[Z$];if(!G$)throw new Error("Unknown message digest");this._hash=e0(G$.hash),this._tag=G$.id,this._signType=G$.sign}r0(N,R0.Writable),N.prototype._write=function(Z$,G$,V$){this._hash.update(Z$),V$()},N.prototype.update=function(Z$,G$){return typeof Z$=="string"&&(Z$=a0.from(Z$,G$)),this._hash.update(Z$),this},N.prototype.verify=function(Z$,G$,V$){typeof G$=="string"&&(G$=a0.from(G$,V$)),this.end();var U$=this._hash.digest();return $$(G$,U$,Z$,this._signType,this._tag)};function Y$(Z$){return new $(Z$)}function O0(Z$){return new N(Z$)}m0.exports={Sign:Y$,Verify:O0,createSign:Y$,createVerify:O0}}}),OZ=pQ({"node_modules/create-ecdh/node_modules/bn.js/lib/bn.js"(t0,m0){(function(a0,e0){function r0(E$,T$){if(!E$)throw new Error(T$||"Assertion failed")}function i0(E$,T$){E$.super_=T$;var Y=function(){};Y.prototype=T$.prototype,E$.prototype=new Y,E$.prototype.constructor=E$}function $$(E$,T$,Y){if($$.isBN(E$))return E$;this.negative=0,this.words=null,this.length=0,this.red=null,E$!==null&&((T$==="le"||T$==="be")&&(Y=T$,T$=10),this._init(E$||0,T$||10,Y||"be"))}typeof a0=="object"?a0.exports=$$:e0.BN=$$,$$.BN=$$,$$.wordSize=26;var Q$=G0;$$.isBN=function(E$){return E$ instanceof $$?!0:E$!==null&&typeof E$=="object"&&E$.constructor.wordSize===$$.wordSize&&Array.isArray(E$.words)},$$.max=function(E$,T$){return E$.cmp(T$)>0?E$:T$},$$.min=function(E$,T$){return E$.cmp(T$)<0?E$:T$},$$.prototype._init=function(E$,T$,Y){if(typeof E$=="number")return this._initNumber(E$,T$,Y);if(typeof E$=="object")return this._initArray(E$,T$,Y);T$==="hex"&&(T$=16),r0(T$===(T$|0)&&T$>=2&&T$<=36),E$=E$.toString().replace(/\s+/g,"");var f=0;E$[0]==="-"&&(f++,this.negative=1),f=0;f-=3)F0=E$[f]|E$[f-1]<<8|E$[f-2]<<16,this.words[D$]|=F0<>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);else if(Y==="le")for(f=0,D$=0;f>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);return this.strip()};function $(E$,T$){var Y=E$.charCodeAt(T$);return Y>=65&&Y<=70?Y-55:Y>=97&&Y<=102?Y-87:Y-48&15}function N(E$,T$,Y){var f=$(E$,Y);return Y-1>=T$&&(f|=$(E$,Y-1)<<4),f}$$.prototype._parseHex=function(E$,T$,Y){this.length=Math.ceil((E$.length-T$)/6),this.words=new Array(this.length);for(var f=0;f=T$;f-=2)C$=N(E$,T$,f)<=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8;else{var L$=E$.length-T$;for(f=L$%2===0?T$+1:T$;f=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8}this.strip()};function Y$(E$,T$,Y,f){for(var D$=0,F0=Math.min(E$.length,Y),C$=T$;C$=49?D$+=L$-49+10:L$>=17?D$+=L$-17+10:D$+=L$}return D$}$$.prototype._parseBase=function(E$,T$,Y){this.words=[0],this.length=1;for(var f=0,D$=1;D$<=67108863;D$*=T$)f++;f--,D$=D$/T$|0;for(var F0=E$.length-Y,C$=F0%f,L$=Math.min(F0,F0-C$)+Y,R$=0,P$=Y;P$1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},$$.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},$$.prototype.inspect=function(){return(this.red?""};var O0=["","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"],Z$=[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],G$=[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];$$.prototype.toString=function(E$,T$){E$=E$||10,T$=T$|0||1;var Y;if(E$===16||E$==="hex"){Y="";for(var f=0,D$=0,F0=0;F0>>24-f&16777215,D$!==0||F0!==this.length-1?Y=O0[6-L$.length]+L$+Y:Y=L$+Y,f+=2,f>=26&&(f-=26,F0--)}for(D$!==0&&(Y=D$.toString(16)+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}if(E$===(E$|0)&&E$>=2&&E$<=36){var R$=Z$[E$],P$=G$[E$];Y="";var z$=this.clone();for(z$.negative=0;!z$.isZero();){var M$=z$.modn(P$).toString(E$);z$=z$.idivn(P$),z$.isZero()?Y=M$+Y:Y=O0[R$-M$.length]+M$+Y}for(this.isZero()&&(Y="0"+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}r0(!1,"Base should be between 2 and 36")},$$.prototype.toNumber=function(){var E$=this.words[0];return this.length===2?E$+=this.words[1]*67108864:this.length===3&&this.words[2]===1?E$+=4503599627370496+this.words[1]*67108864:this.length>2&&r0(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-E$:E$},$$.prototype.toJSON=function(){return this.toString(16)},$$.prototype.toBuffer=function(E$,T$){return r0(typeof Q$<"u"),this.toArrayLike(Q$,E$,T$)},$$.prototype.toArray=function(E$,T$){return this.toArrayLike(Array,E$,T$)},$$.prototype.toArrayLike=function(E$,T$,Y){var f=this.byteLength(),D$=Y||Math.max(1,f);r0(f<=D$,"byte array longer than desired length"),r0(D$>0,"Requested array length <= 0"),this.strip();var F0=T$==="le",C$=new E$(D$),L$,R$,P$=this.clone();if(F0){for(R$=0;!P$.isZero();R$++)L$=P$.andln(255),P$.iushrn(8),C$[R$]=L$;for(;R$=4096&&(Y+=13,T$>>>=13),T$>=64&&(Y+=7,T$>>>=7),T$>=8&&(Y+=4,T$>>>=4),T$>=2&&(Y+=2,T$>>>=2),Y+T$},$$.prototype._zeroBits=function(E$){if(E$===0)return 26;var T$=E$,Y=0;return(T$&8191)===0&&(Y+=13,T$>>>=13),(T$&127)===0&&(Y+=7,T$>>>=7),(T$&15)===0&&(Y+=4,T$>>>=4),(T$&3)===0&&(Y+=2,T$>>>=2),(T$&1)===0&&Y++,Y},$$.prototype.bitLength=function(){var E$=this.words[this.length-1],T$=this._countBits(E$);return(this.length-1)*26+T$};function V$(E$){for(var T$=new Array(E$.bitLength()),Y=0;Y>>D$}return T$}$$.prototype.zeroBits=function(){if(this.isZero())return 0;for(var E$=0,T$=0;T$E$.length?this.clone().ior(E$):E$.clone().ior(this)},$$.prototype.uor=function(E$){return this.length>E$.length?this.clone().iuor(E$):E$.clone().iuor(this)},$$.prototype.iuand=function(E$){var T$;this.length>E$.length?T$=E$:T$=this;for(var Y=0;YE$.length?this.clone().iand(E$):E$.clone().iand(this)},$$.prototype.uand=function(E$){return this.length>E$.length?this.clone().iuand(E$):E$.clone().iuand(this)},$$.prototype.iuxor=function(E$){var T$,Y;this.length>E$.length?(T$=this,Y=E$):(T$=E$,Y=this);for(var f=0;fE$.length?this.clone().ixor(E$):E$.clone().ixor(this)},$$.prototype.uxor=function(E$){return this.length>E$.length?this.clone().iuxor(E$):E$.clone().iuxor(this)},$$.prototype.inotn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=Math.ceil(E$/26)|0,Y=E$%26;this._expand(T$),Y>0&&T$--;for(var f=0;f0&&(this.words[f]=~this.words[f]&67108863>>26-Y),this.strip()},$$.prototype.notn=function(E$){return this.clone().inotn(E$)},$$.prototype.setn=function(E$,T$){r0(typeof E$=="number"&&E$>=0);var Y=E$/26|0,f=E$%26;return this._expand(Y+1),T$?this.words[Y]=this.words[Y]|1<E$.length?(Y=this,f=E$):(Y=E$,f=this);for(var D$=0,F0=0;F0>>26;for(;D$!==0&&F0>>26;if(this.length=Y.length,D$!==0)this.words[this.length]=D$,this.length++;else if(Y!==this)for(;F0E$.length?this.clone().iadd(E$):E$.clone().iadd(this)},$$.prototype.isub=function(E$){if(E$.negative!==0){E$.negative=0;var T$=this.iadd(E$);return E$.negative=1,T$._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(E$),this.negative=1,this._normSign();var Y=this.cmp(E$);if(Y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,D$;Y>0?(f=this,D$=E$):(f=E$,D$=this);for(var F0=0,C$=0;C$>26,this.words[C$]=T$&67108863;for(;F0!==0&&C$>26,this.words[C$]=T$&67108863;if(F0===0&&C$>>26,M$=R$&67108863,S$=Math.min(P$,T$.length-1),Z=Math.max(0,P$-E$.length+1);Z<=S$;Z++){var c=P$-Z|0;D$=E$.words[c]|0,F0=T$.words[Z]|0,C$=D$*F0+M$,z$+=C$/67108864|0,M$=C$&67108863}Y.words[P$]=M$|0,R$=z$|0}return R$!==0?Y.words[P$]=R$|0:Y.length--,Y.strip()}var X$=function(E$,T$,Y){var f=E$.words,D$=T$.words,F0=Y.words,C$=0,L$,R$,P$,z$=f[0]|0,M$=z$&8191,S$=z$>>>13,Z=f[1]|0,c=Z&8191,v$=Z>>>13,A0=f[2]|0,q$=A0&8191,j$=A0>>>13,k$=f[3]|0,g$=k$&8191,_$=k$>>>13,N$=f[4]|0,x$=N$&8191,G=N$>>>13,B=f[5]|0,B$=B&8191,H0=B>>>13,y$=f[6]|0,w$=y$&8191,p$=y$>>>13,f$=f[7]|0,c$=f$&8191,h$=f$>>>13,d$=f[8]|0,V=d$&8191,h=d$>>>13,W0=f[9]|0,E0=W0&8191,b$=W0>>>13,l$=D$[0]|0,o$=l$&8191,u$=l$>>>13,n$=D$[1]|0,s$=n$&8191,t$=n$>>>13,U=D$[2]|0,d=U&8191,m$=U>>>13,T0=D$[3]|0,a$=T0&8191,e$=T0>>>13,r$=D$[4]|0,i$=r$&8191,$Q=r$>>>13,QQ=D$[5]|0,YQ=QQ&8191,X=QQ>>>13,b=D$[6]|0,ZQ=b&8191,D0=b>>>13,GQ=D$[7]|0,VQ=GQ&8191,UQ=GQ>>>13,XQ=D$[8]|0,KQ=XQ&8191,IQ=XQ>>>13,OQ=D$[9]|0,K=OQ&8191,l=OQ>>>13;Y.negative=E$.negative^T$.negative,Y.length=19,L$=Math.imul(M$,o$),R$=Math.imul(M$,u$),R$=R$+Math.imul(S$,o$)|0,P$=Math.imul(S$,u$);var JQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(JQ>>>26)|0,JQ&=67108863,L$=Math.imul(c,o$),R$=Math.imul(c,u$),R$=R$+Math.imul(v$,o$)|0,P$=Math.imul(v$,u$),L$=L$+Math.imul(M$,s$)|0,R$=R$+Math.imul(M$,t$)|0,R$=R$+Math.imul(S$,s$)|0,P$=P$+Math.imul(S$,t$)|0;var C0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(C0>>>26)|0,C0&=67108863,L$=Math.imul(q$,o$),R$=Math.imul(q$,u$),R$=R$+Math.imul(j$,o$)|0,P$=Math.imul(j$,u$),L$=L$+Math.imul(c,s$)|0,R$=R$+Math.imul(c,t$)|0,R$=R$+Math.imul(v$,s$)|0,P$=P$+Math.imul(v$,t$)|0,L$=L$+Math.imul(M$,d)|0,R$=R$+Math.imul(M$,m$)|0,R$=R$+Math.imul(S$,d)|0,P$=P$+Math.imul(S$,m$)|0;var FQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(FQ>>>26)|0,FQ&=67108863,L$=Math.imul(g$,o$),R$=Math.imul(g$,u$),R$=R$+Math.imul(_$,o$)|0,P$=Math.imul(_$,u$),L$=L$+Math.imul(q$,s$)|0,R$=R$+Math.imul(q$,t$)|0,R$=R$+Math.imul(j$,s$)|0,P$=P$+Math.imul(j$,t$)|0,L$=L$+Math.imul(c,d)|0,R$=R$+Math.imul(c,m$)|0,R$=R$+Math.imul(v$,d)|0,P$=P$+Math.imul(v$,m$)|0,L$=L$+Math.imul(M$,a$)|0,R$=R$+Math.imul(M$,e$)|0,R$=R$+Math.imul(S$,a$)|0,P$=P$+Math.imul(S$,e$)|0;var AQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(AQ>>>26)|0,AQ&=67108863,L$=Math.imul(x$,o$),R$=Math.imul(x$,u$),R$=R$+Math.imul(G,o$)|0,P$=Math.imul(G,u$),L$=L$+Math.imul(g$,s$)|0,R$=R$+Math.imul(g$,t$)|0,R$=R$+Math.imul(_$,s$)|0,P$=P$+Math.imul(_$,t$)|0,L$=L$+Math.imul(q$,d)|0,R$=R$+Math.imul(q$,m$)|0,R$=R$+Math.imul(j$,d)|0,P$=P$+Math.imul(j$,m$)|0,L$=L$+Math.imul(c,a$)|0,R$=R$+Math.imul(c,e$)|0,R$=R$+Math.imul(v$,a$)|0,P$=P$+Math.imul(v$,e$)|0,L$=L$+Math.imul(M$,i$)|0,R$=R$+Math.imul(M$,$Q)|0,R$=R$+Math.imul(S$,i$)|0,P$=P$+Math.imul(S$,$Q)|0;var HQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(HQ>>>26)|0,HQ&=67108863,L$=Math.imul(B$,o$),R$=Math.imul(B$,u$),R$=R$+Math.imul(H0,o$)|0,P$=Math.imul(H0,u$),L$=L$+Math.imul(x$,s$)|0,R$=R$+Math.imul(x$,t$)|0,R$=R$+Math.imul(G,s$)|0,P$=P$+Math.imul(G,t$)|0,L$=L$+Math.imul(g$,d)|0,R$=R$+Math.imul(g$,m$)|0,R$=R$+Math.imul(_$,d)|0,P$=P$+Math.imul(_$,m$)|0,L$=L$+Math.imul(q$,a$)|0,R$=R$+Math.imul(q$,e$)|0,R$=R$+Math.imul(j$,a$)|0,P$=P$+Math.imul(j$,e$)|0,L$=L$+Math.imul(c,i$)|0,R$=R$+Math.imul(c,$Q)|0,R$=R$+Math.imul(v$,i$)|0,P$=P$+Math.imul(v$,$Q)|0,L$=L$+Math.imul(M$,YQ)|0,R$=R$+Math.imul(M$,X)|0,R$=R$+Math.imul(S$,YQ)|0,P$=P$+Math.imul(S$,X)|0;var WQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(WQ>>>26)|0,WQ&=67108863,L$=Math.imul(w$,o$),R$=Math.imul(w$,u$),R$=R$+Math.imul(p$,o$)|0,P$=Math.imul(p$,u$),L$=L$+Math.imul(B$,s$)|0,R$=R$+Math.imul(B$,t$)|0,R$=R$+Math.imul(H0,s$)|0,P$=P$+Math.imul(H0,t$)|0,L$=L$+Math.imul(x$,d)|0,R$=R$+Math.imul(x$,m$)|0,R$=R$+Math.imul(G,d)|0,P$=P$+Math.imul(G,m$)|0,L$=L$+Math.imul(g$,a$)|0,R$=R$+Math.imul(g$,e$)|0,R$=R$+Math.imul(_$,a$)|0,P$=P$+Math.imul(_$,e$)|0,L$=L$+Math.imul(q$,i$)|0,R$=R$+Math.imul(q$,$Q)|0,R$=R$+Math.imul(j$,i$)|0,P$=P$+Math.imul(j$,$Q)|0,L$=L$+Math.imul(c,YQ)|0,R$=R$+Math.imul(c,X)|0,R$=R$+Math.imul(v$,YQ)|0,P$=P$+Math.imul(v$,X)|0,L$=L$+Math.imul(M$,ZQ)|0,R$=R$+Math.imul(M$,D0)|0,R$=R$+Math.imul(S$,ZQ)|0,P$=P$+Math.imul(S$,D0)|0;var EQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(EQ>>>26)|0,EQ&=67108863,L$=Math.imul(c$,o$),R$=Math.imul(c$,u$),R$=R$+Math.imul(h$,o$)|0,P$=Math.imul(h$,u$),L$=L$+Math.imul(w$,s$)|0,R$=R$+Math.imul(w$,t$)|0,R$=R$+Math.imul(p$,s$)|0,P$=P$+Math.imul(p$,t$)|0,L$=L$+Math.imul(B$,d)|0,R$=R$+Math.imul(B$,m$)|0,R$=R$+Math.imul(H0,d)|0,P$=P$+Math.imul(H0,m$)|0,L$=L$+Math.imul(x$,a$)|0,R$=R$+Math.imul(x$,e$)|0,R$=R$+Math.imul(G,a$)|0,P$=P$+Math.imul(G,e$)|0,L$=L$+Math.imul(g$,i$)|0,R$=R$+Math.imul(g$,$Q)|0,R$=R$+Math.imul(_$,i$)|0,P$=P$+Math.imul(_$,$Q)|0,L$=L$+Math.imul(q$,YQ)|0,R$=R$+Math.imul(q$,X)|0,R$=R$+Math.imul(j$,YQ)|0,P$=P$+Math.imul(j$,X)|0,L$=L$+Math.imul(c,ZQ)|0,R$=R$+Math.imul(c,D0)|0,R$=R$+Math.imul(v$,ZQ)|0,P$=P$+Math.imul(v$,D0)|0,L$=L$+Math.imul(M$,VQ)|0,R$=R$+Math.imul(M$,UQ)|0,R$=R$+Math.imul(S$,VQ)|0,P$=P$+Math.imul(S$,UQ)|0;var TQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(TQ>>>26)|0,TQ&=67108863,L$=Math.imul(V,o$),R$=Math.imul(V,u$),R$=R$+Math.imul(h,o$)|0,P$=Math.imul(h,u$),L$=L$+Math.imul(c$,s$)|0,R$=R$+Math.imul(c$,t$)|0,R$=R$+Math.imul(h$,s$)|0,P$=P$+Math.imul(h$,t$)|0,L$=L$+Math.imul(w$,d)|0,R$=R$+Math.imul(w$,m$)|0,R$=R$+Math.imul(p$,d)|0,P$=P$+Math.imul(p$,m$)|0,L$=L$+Math.imul(B$,a$)|0,R$=R$+Math.imul(B$,e$)|0,R$=R$+Math.imul(H0,a$)|0,P$=P$+Math.imul(H0,e$)|0,L$=L$+Math.imul(x$,i$)|0,R$=R$+Math.imul(x$,$Q)|0,R$=R$+Math.imul(G,i$)|0,P$=P$+Math.imul(G,$Q)|0,L$=L$+Math.imul(g$,YQ)|0,R$=R$+Math.imul(g$,X)|0,R$=R$+Math.imul(_$,YQ)|0,P$=P$+Math.imul(_$,X)|0,L$=L$+Math.imul(q$,ZQ)|0,R$=R$+Math.imul(q$,D0)|0,R$=R$+Math.imul(j$,ZQ)|0,P$=P$+Math.imul(j$,D0)|0,L$=L$+Math.imul(c,VQ)|0,R$=R$+Math.imul(c,UQ)|0,R$=R$+Math.imul(v$,VQ)|0,P$=P$+Math.imul(v$,UQ)|0,L$=L$+Math.imul(M$,KQ)|0,R$=R$+Math.imul(M$,IQ)|0,R$=R$+Math.imul(S$,KQ)|0,P$=P$+Math.imul(S$,IQ)|0;var DQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(DQ>>>26)|0,DQ&=67108863,L$=Math.imul(E0,o$),R$=Math.imul(E0,u$),R$=R$+Math.imul(b$,o$)|0,P$=Math.imul(b$,u$),L$=L$+Math.imul(V,s$)|0,R$=R$+Math.imul(V,t$)|0,R$=R$+Math.imul(h,s$)|0,P$=P$+Math.imul(h,t$)|0,L$=L$+Math.imul(c$,d)|0,R$=R$+Math.imul(c$,m$)|0,R$=R$+Math.imul(h$,d)|0,P$=P$+Math.imul(h$,m$)|0,L$=L$+Math.imul(w$,a$)|0,R$=R$+Math.imul(w$,e$)|0,R$=R$+Math.imul(p$,a$)|0,P$=P$+Math.imul(p$,e$)|0,L$=L$+Math.imul(B$,i$)|0,R$=R$+Math.imul(B$,$Q)|0,R$=R$+Math.imul(H0,i$)|0,P$=P$+Math.imul(H0,$Q)|0,L$=L$+Math.imul(x$,YQ)|0,R$=R$+Math.imul(x$,X)|0,R$=R$+Math.imul(G,YQ)|0,P$=P$+Math.imul(G,X)|0,L$=L$+Math.imul(g$,ZQ)|0,R$=R$+Math.imul(g$,D0)|0,R$=R$+Math.imul(_$,ZQ)|0,P$=P$+Math.imul(_$,D0)|0,L$=L$+Math.imul(q$,VQ)|0,R$=R$+Math.imul(q$,UQ)|0,R$=R$+Math.imul(j$,VQ)|0,P$=P$+Math.imul(j$,UQ)|0,L$=L$+Math.imul(c,KQ)|0,R$=R$+Math.imul(c,IQ)|0,R$=R$+Math.imul(v$,KQ)|0,P$=P$+Math.imul(v$,IQ)|0,L$=L$+Math.imul(M$,K)|0,R$=R$+Math.imul(M$,l)|0,R$=R$+Math.imul(S$,K)|0,P$=P$+Math.imul(S$,l)|0;var I=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(I>>>26)|0,I&=67108863,L$=Math.imul(E0,s$),R$=Math.imul(E0,t$),R$=R$+Math.imul(b$,s$)|0,P$=Math.imul(b$,t$),L$=L$+Math.imul(V,d)|0,R$=R$+Math.imul(V,m$)|0,R$=R$+Math.imul(h,d)|0,P$=P$+Math.imul(h,m$)|0,L$=L$+Math.imul(c$,a$)|0,R$=R$+Math.imul(c$,e$)|0,R$=R$+Math.imul(h$,a$)|0,P$=P$+Math.imul(h$,e$)|0,L$=L$+Math.imul(w$,i$)|0,R$=R$+Math.imul(w$,$Q)|0,R$=R$+Math.imul(p$,i$)|0,P$=P$+Math.imul(p$,$Q)|0,L$=L$+Math.imul(B$,YQ)|0,R$=R$+Math.imul(B$,X)|0,R$=R$+Math.imul(H0,YQ)|0,P$=P$+Math.imul(H0,X)|0,L$=L$+Math.imul(x$,ZQ)|0,R$=R$+Math.imul(x$,D0)|0,R$=R$+Math.imul(G,ZQ)|0,P$=P$+Math.imul(G,D0)|0,L$=L$+Math.imul(g$,VQ)|0,R$=R$+Math.imul(g$,UQ)|0,R$=R$+Math.imul(_$,VQ)|0,P$=P$+Math.imul(_$,UQ)|0,L$=L$+Math.imul(q$,KQ)|0,R$=R$+Math.imul(q$,IQ)|0,R$=R$+Math.imul(j$,KQ)|0,P$=P$+Math.imul(j$,IQ)|0,L$=L$+Math.imul(c,K)|0,R$=R$+Math.imul(c,l)|0,R$=R$+Math.imul(v$,K)|0,P$=P$+Math.imul(v$,l)|0;var o=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(o>>>26)|0,o&=67108863,L$=Math.imul(E0,d),R$=Math.imul(E0,m$),R$=R$+Math.imul(b$,d)|0,P$=Math.imul(b$,m$),L$=L$+Math.imul(V,a$)|0,R$=R$+Math.imul(V,e$)|0,R$=R$+Math.imul(h,a$)|0,P$=P$+Math.imul(h,e$)|0,L$=L$+Math.imul(c$,i$)|0,R$=R$+Math.imul(c$,$Q)|0,R$=R$+Math.imul(h$,i$)|0,P$=P$+Math.imul(h$,$Q)|0,L$=L$+Math.imul(w$,YQ)|0,R$=R$+Math.imul(w$,X)|0,R$=R$+Math.imul(p$,YQ)|0,P$=P$+Math.imul(p$,X)|0,L$=L$+Math.imul(B$,ZQ)|0,R$=R$+Math.imul(B$,D0)|0,R$=R$+Math.imul(H0,ZQ)|0,P$=P$+Math.imul(H0,D0)|0,L$=L$+Math.imul(x$,VQ)|0,R$=R$+Math.imul(x$,UQ)|0,R$=R$+Math.imul(G,VQ)|0,P$=P$+Math.imul(G,UQ)|0,L$=L$+Math.imul(g$,KQ)|0,R$=R$+Math.imul(g$,IQ)|0,R$=R$+Math.imul(_$,KQ)|0,P$=P$+Math.imul(_$,IQ)|0,L$=L$+Math.imul(q$,K)|0,R$=R$+Math.imul(q$,l)|0,R$=R$+Math.imul(j$,K)|0,P$=P$+Math.imul(j$,l)|0;var CQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(CQ>>>26)|0,CQ&=67108863,L$=Math.imul(E0,a$),R$=Math.imul(E0,e$),R$=R$+Math.imul(b$,a$)|0,P$=Math.imul(b$,e$),L$=L$+Math.imul(V,i$)|0,R$=R$+Math.imul(V,$Q)|0,R$=R$+Math.imul(h,i$)|0,P$=P$+Math.imul(h,$Q)|0,L$=L$+Math.imul(c$,YQ)|0,R$=R$+Math.imul(c$,X)|0,R$=R$+Math.imul(h$,YQ)|0,P$=P$+Math.imul(h$,X)|0,L$=L$+Math.imul(w$,ZQ)|0,R$=R$+Math.imul(w$,D0)|0,R$=R$+Math.imul(p$,ZQ)|0,P$=P$+Math.imul(p$,D0)|0,L$=L$+Math.imul(B$,VQ)|0,R$=R$+Math.imul(B$,UQ)|0,R$=R$+Math.imul(H0,VQ)|0,P$=P$+Math.imul(H0,UQ)|0,L$=L$+Math.imul(x$,KQ)|0,R$=R$+Math.imul(x$,IQ)|0,R$=R$+Math.imul(G,KQ)|0,P$=P$+Math.imul(G,IQ)|0,L$=L$+Math.imul(g$,K)|0,R$=R$+Math.imul(g$,l)|0,R$=R$+Math.imul(_$,K)|0,P$=P$+Math.imul(_$,l)|0;var L0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(L0>>>26)|0,L0&=67108863,L$=Math.imul(E0,i$),R$=Math.imul(E0,$Q),R$=R$+Math.imul(b$,i$)|0,P$=Math.imul(b$,$Q),L$=L$+Math.imul(V,YQ)|0,R$=R$+Math.imul(V,X)|0,R$=R$+Math.imul(h,YQ)|0,P$=P$+Math.imul(h,X)|0,L$=L$+Math.imul(c$,ZQ)|0,R$=R$+Math.imul(c$,D0)|0,R$=R$+Math.imul(h$,ZQ)|0,P$=P$+Math.imul(h$,D0)|0,L$=L$+Math.imul(w$,VQ)|0,R$=R$+Math.imul(w$,UQ)|0,R$=R$+Math.imul(p$,VQ)|0,P$=P$+Math.imul(p$,UQ)|0,L$=L$+Math.imul(B$,KQ)|0,R$=R$+Math.imul(B$,IQ)|0,R$=R$+Math.imul(H0,KQ)|0,P$=P$+Math.imul(H0,IQ)|0,L$=L$+Math.imul(x$,K)|0,R$=R$+Math.imul(x$,l)|0,R$=R$+Math.imul(G,K)|0,P$=P$+Math.imul(G,l)|0;var LQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(LQ>>>26)|0,LQ&=67108863,L$=Math.imul(E0,YQ),R$=Math.imul(E0,X),R$=R$+Math.imul(b$,YQ)|0,P$=Math.imul(b$,X),L$=L$+Math.imul(V,ZQ)|0,R$=R$+Math.imul(V,D0)|0,R$=R$+Math.imul(h,ZQ)|0,P$=P$+Math.imul(h,D0)|0,L$=L$+Math.imul(c$,VQ)|0,R$=R$+Math.imul(c$,UQ)|0,R$=R$+Math.imul(h$,VQ)|0,P$=P$+Math.imul(h$,UQ)|0,L$=L$+Math.imul(w$,KQ)|0,R$=R$+Math.imul(w$,IQ)|0,R$=R$+Math.imul(p$,KQ)|0,P$=P$+Math.imul(p$,IQ)|0,L$=L$+Math.imul(B$,K)|0,R$=R$+Math.imul(B$,l)|0,R$=R$+Math.imul(H0,K)|0,P$=P$+Math.imul(H0,l)|0;var RQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(RQ>>>26)|0,RQ&=67108863,L$=Math.imul(E0,ZQ),R$=Math.imul(E0,D0),R$=R$+Math.imul(b$,ZQ)|0,P$=Math.imul(b$,D0),L$=L$+Math.imul(V,VQ)|0,R$=R$+Math.imul(V,UQ)|0,R$=R$+Math.imul(h,VQ)|0,P$=P$+Math.imul(h,UQ)|0,L$=L$+Math.imul(c$,KQ)|0,R$=R$+Math.imul(c$,IQ)|0,R$=R$+Math.imul(h$,KQ)|0,P$=P$+Math.imul(h$,IQ)|0,L$=L$+Math.imul(w$,K)|0,R$=R$+Math.imul(w$,l)|0,R$=R$+Math.imul(p$,K)|0,P$=P$+Math.imul(p$,l)|0;var PQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(PQ>>>26)|0,PQ&=67108863,L$=Math.imul(E0,VQ),R$=Math.imul(E0,UQ),R$=R$+Math.imul(b$,VQ)|0,P$=Math.imul(b$,UQ),L$=L$+Math.imul(V,KQ)|0,R$=R$+Math.imul(V,IQ)|0,R$=R$+Math.imul(h,KQ)|0,P$=P$+Math.imul(h,IQ)|0,L$=L$+Math.imul(c$,K)|0,R$=R$+Math.imul(c$,l)|0,R$=R$+Math.imul(h$,K)|0,P$=P$+Math.imul(h$,l)|0;var zQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(zQ>>>26)|0,zQ&=67108863,L$=Math.imul(E0,KQ),R$=Math.imul(E0,IQ),R$=R$+Math.imul(b$,KQ)|0,P$=Math.imul(b$,IQ),L$=L$+Math.imul(V,K)|0,R$=R$+Math.imul(V,l)|0,R$=R$+Math.imul(h,K)|0,P$=P$+Math.imul(h,l)|0;var MQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(MQ>>>26)|0,MQ&=67108863,L$=Math.imul(E0,K),R$=Math.imul(E0,l),R$=R$+Math.imul(b$,K)|0,P$=Math.imul(b$,l);var SQ=(C$+L$|0)+((R$&8191)<<13)|0;return C$=(P$+(R$>>>13)|0)+(SQ>>>26)|0,SQ&=67108863,F0[0]=JQ,F0[1]=C0,F0[2]=FQ,F0[3]=AQ,F0[4]=HQ,F0[5]=WQ,F0[6]=EQ,F0[7]=TQ,F0[8]=DQ,F0[9]=I,F0[10]=o,F0[11]=CQ,F0[12]=L0,F0[13]=LQ,F0[14]=RQ,F0[15]=PQ,F0[16]=zQ,F0[17]=MQ,F0[18]=SQ,C$!==0&&(F0[19]=C$,Y.length++),Y};Math.imul||(X$=U$);function K$(E$,T$,Y){Y.negative=T$.negative^E$.negative,Y.length=E$.length+T$.length;for(var f=0,D$=0,F0=0;F0>>26)|0,D$+=C$>>>26,C$&=67108863}Y.words[F0]=L$,f=C$,C$=D$}return f!==0?Y.words[F0]=f:Y.length--,Y.strip()}function I$(E$,T$,Y){var f=new Q;return f.mulp(E$,T$,Y)}$$.prototype.mulTo=function(E$,T$){var Y,f=this.length+E$.length;return this.length===10&&E$.length===10?Y=X$(this,E$,T$):f<63?Y=U$(this,E$,T$):f<1024?Y=K$(this,E$,T$):Y=I$(this,E$,T$),Y};function Q(E$,T$){this.x=E$,this.y=T$}Q.prototype.makeRBT=function(E$){for(var T$=new Array(E$),Y=$$.prototype._countBits(E$)-1,f=0;f>=1;return f},Q.prototype.permute=function(E$,T$,Y,f,D$,F0){for(var C$=0;C$>>1)D$++;return 1<>>13,Y[2*F0+1]=D$&8191,D$=D$>>>13;for(F0=2*T$;F0>=26,T$+=f/67108864|0,T$+=D$>>>26,this.words[Y]=D$&67108863}return T$!==0&&(this.words[Y]=T$,this.length++),this},$$.prototype.muln=function(E$){return this.clone().imuln(E$)},$$.prototype.sqr=function(){return this.mul(this)},$$.prototype.isqr=function(){return this.imul(this.clone())},$$.prototype.pow=function(E$){var T$=V$(E$);if(T$.length===0)return new $$(1);for(var Y=this,f=0;f=0);var T$=E$%26,Y=(E$-T$)/26,f=67108863>>>26-T$<<26-T$,D$;if(T$!==0){var F0=0;for(D$=0;D$>>26-T$}F0&&(this.words[D$]=F0,this.length++)}if(Y!==0){for(D$=this.length-1;D$>=0;D$--)this.words[D$+Y]=this.words[D$];for(D$=0;D$=0);var f;T$?f=(T$-T$%26)/26:f=0;var D$=E$%26,F0=Math.min((E$-D$)/26,this.length),C$=67108863^67108863>>>D$<F0)for(this.length-=F0,R$=0;R$=0&&(P$!==0||R$>=f);R$--){var z$=this.words[R$]|0;this.words[R$]=P$<<26-D$|z$>>>D$,P$=z$&C$}return L$&&P$!==0&&(L$.words[L$.length++]=P$),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},$$.prototype.ishrn=function(E$,T$,Y){return r0(this.negative===0),this.iushrn(E$,T$,Y)},$$.prototype.shln=function(E$){return this.clone().ishln(E$)},$$.prototype.ushln=function(E$){return this.clone().iushln(E$)},$$.prototype.shrn=function(E$){return this.clone().ishrn(E$)},$$.prototype.ushrn=function(E$){return this.clone().iushrn(E$)},$$.prototype.testn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=E$%26,Y=(E$-T$)/26,f=1<=0);var T$=E$%26,Y=(E$-T$)/26;if(r0(this.negative===0,"imaskn works only with positive numbers"),this.length<=Y)return this;if(T$!==0&&Y++,this.length=Math.min(Y,this.length),T$!==0){var f=67108863^67108863>>>T$<=67108864;T$++)this.words[T$]-=67108864,T$===this.length-1?this.words[T$+1]=1:this.words[T$+1]++;return this.length=Math.max(this.length,T$+1),this},$$.prototype.isubn=function(E$){if(r0(typeof E$=="number"),r0(E$<67108864),E$<0)return this.iaddn(-E$);if(this.negative!==0)return this.negative=0,this.iaddn(E$),this.negative=1,this;if(this.words[0]-=E$,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var T$=0;T$>26)-(L$/67108864|0),this.words[D$+Y]=F0&67108863}for(;D$>26,this.words[D$+Y]=F0&67108863;if(C$===0)return this.strip();for(r0(C$===-1),C$=0,D$=0;D$>26,this.words[D$]=F0&67108863;return this.negative=1,this.strip()},$$.prototype._wordDiv=function(E$,T$){var Y=this.length-E$.length,f=this.clone(),D$=E$,F0=D$.words[D$.length-1]|0,C$=this._countBits(F0);Y=26-C$,Y!==0&&(D$=D$.ushln(Y),f.iushln(Y),F0=D$.words[D$.length-1]|0);var L$=f.length-D$.length,R$;if(T$!=="mod"){R$=new $$(null),R$.length=L$+1,R$.words=new Array(R$.length);for(var P$=0;P$=0;M$--){var S$=(f.words[D$.length+M$]|0)*67108864+(f.words[D$.length+M$-1]|0);for(S$=Math.min(S$/F0|0,67108863),f._ishlnsubmul(D$,S$,M$);f.negative!==0;)S$--,f.negative=0,f._ishlnsubmul(D$,1,M$),f.isZero()||(f.negative^=1);R$&&(R$.words[M$]=S$)}return R$&&R$.strip(),f.strip(),T$!=="div"&&Y!==0&&f.iushrn(Y),{div:R$||null,mod:f}},$$.prototype.divmod=function(E$,T$,Y){if(r0(!E$.isZero()),this.isZero())return{div:new $$(0),mod:new $$(0)};var f,D$,F0;return this.negative!==0&&E$.negative===0?(F0=this.neg().divmod(E$,T$),T$!=="mod"&&(f=F0.div.neg()),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.iadd(E$)),{div:f,mod:D$}):this.negative===0&&E$.negative!==0?(F0=this.divmod(E$.neg(),T$),T$!=="mod"&&(f=F0.div.neg()),{div:f,mod:F0.mod}):(this.negative&E$.negative)!==0?(F0=this.neg().divmod(E$.neg(),T$),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.isub(E$)),{div:F0.div,mod:D$}):E$.length>this.length||this.cmp(E$)<0?{div:new $$(0),mod:this}:E$.length===1?T$==="div"?{div:this.divn(E$.words[0]),mod:null}:T$==="mod"?{div:null,mod:new $$(this.modn(E$.words[0]))}:{div:this.divn(E$.words[0]),mod:new $$(this.modn(E$.words[0]))}:this._wordDiv(E$,T$)},$$.prototype.div=function(E$){return this.divmod(E$,"div",!1).div},$$.prototype.mod=function(E$){return this.divmod(E$,"mod",!1).mod},$$.prototype.umod=function(E$){return this.divmod(E$,"mod",!0).mod},$$.prototype.divRound=function(E$){var T$=this.divmod(E$);if(T$.mod.isZero())return T$.div;var Y=T$.div.negative!==0?T$.mod.isub(E$):T$.mod,f=E$.ushrn(1),D$=E$.andln(1),F0=Y.cmp(f);return F0<0||D$===1&&F0===0?T$.div:T$.div.negative!==0?T$.div.isubn(1):T$.div.iaddn(1)},$$.prototype.modn=function(E$){r0(E$<=67108863);for(var T$=(1<<26)%E$,Y=0,f=this.length-1;f>=0;f--)Y=(T$*Y+(this.words[f]|0))%E$;return Y},$$.prototype.idivn=function(E$){r0(E$<=67108863);for(var T$=0,Y=this.length-1;Y>=0;Y--){var f=(this.words[Y]|0)+T$*67108864;this.words[Y]=f/E$|0,T$=f%E$}return this.strip()},$$.prototype.divn=function(E$){return this.clone().idivn(E$)},$$.prototype.egcd=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=new $$(0),C$=new $$(1),L$=0;T$.isEven()&&Y.isEven();)T$.iushrn(1),Y.iushrn(1),++L$;for(var R$=Y.clone(),P$=T$.clone();!T$.isZero();){for(var z$=0,M$=1;(T$.words[0]&M$)===0&&z$<26;++z$,M$<<=1);if(z$>0)for(T$.iushrn(z$);z$-- >0;)(f.isOdd()||D$.isOdd())&&(f.iadd(R$),D$.isub(P$)),f.iushrn(1),D$.iushrn(1);for(var S$=0,Z=1;(Y.words[0]&Z)===0&&S$<26;++S$,Z<<=1);if(S$>0)for(Y.iushrn(S$);S$-- >0;)(F0.isOdd()||C$.isOdd())&&(F0.iadd(R$),C$.isub(P$)),F0.iushrn(1),C$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(F0),D$.isub(C$)):(Y.isub(T$),F0.isub(f),C$.isub(D$))}return{a:F0,b:C$,gcd:Y.iushln(L$)}},$$.prototype._invmp=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=Y.clone();T$.cmpn(1)>0&&Y.cmpn(1)>0;){for(var C$=0,L$=1;(T$.words[0]&L$)===0&&C$<26;++C$,L$<<=1);if(C$>0)for(T$.iushrn(C$);C$-- >0;)f.isOdd()&&f.iadd(F0),f.iushrn(1);for(var R$=0,P$=1;(Y.words[0]&P$)===0&&R$<26;++R$,P$<<=1);if(R$>0)for(Y.iushrn(R$);R$-- >0;)D$.isOdd()&&D$.iadd(F0),D$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(D$)):(Y.isub(T$),D$.isub(f))}var z$;return T$.cmpn(1)===0?z$=f:z$=D$,z$.cmpn(0)<0&&z$.iadd(E$),z$},$$.prototype.gcd=function(E$){if(this.isZero())return E$.abs();if(E$.isZero())return this.abs();var T$=this.clone(),Y=E$.clone();T$.negative=0,Y.negative=0;for(var f=0;T$.isEven()&&Y.isEven();f++)T$.iushrn(1),Y.iushrn(1);do{for(;T$.isEven();)T$.iushrn(1);for(;Y.isEven();)Y.iushrn(1);var D$=T$.cmp(Y);if(D$<0){var F0=T$;T$=Y,Y=F0}else if(D$===0||Y.cmpn(1)===0)break;T$.isub(Y)}while(!0);return Y.iushln(f)},$$.prototype.invm=function(E$){return this.egcd(E$).a.umod(E$)},$$.prototype.isEven=function(){return(this.words[0]&1)===0},$$.prototype.isOdd=function(){return(this.words[0]&1)===1},$$.prototype.andln=function(E$){return this.words[0]&E$},$$.prototype.bincn=function(E$){r0(typeof E$=="number");var T$=E$%26,Y=(E$-T$)/26,f=1<>>26,C$&=67108863,this.words[F0]=C$}return D$!==0&&(this.words[F0]=D$,this.length++),this},$$.prototype.isZero=function(){return this.length===1&&this.words[0]===0},$$.prototype.cmpn=function(E$){var T$=E$<0;if(this.negative!==0&&!T$)return-1;if(this.negative===0&&T$)return 1;this.strip();var Y;if(this.length>1)Y=1;else{T$&&(E$=-E$),r0(E$<=67108863,"Number is too big");var f=this.words[0]|0;Y=f===E$?0:fE$.length)return 1;if(this.length=0;Y--){var f=this.words[Y]|0,D$=E$.words[Y]|0;if(f!==D$){fD$&&(T$=1);break}}return T$},$$.prototype.gtn=function(E$){return this.cmpn(E$)===1},$$.prototype.gt=function(E$){return this.cmp(E$)===1},$$.prototype.gten=function(E$){return this.cmpn(E$)>=0},$$.prototype.gte=function(E$){return this.cmp(E$)>=0},$$.prototype.ltn=function(E$){return this.cmpn(E$)===-1},$$.prototype.lt=function(E$){return this.cmp(E$)===-1},$$.prototype.lten=function(E$){return this.cmpn(E$)<=0},$$.prototype.lte=function(E$){return this.cmp(E$)<=0},$$.prototype.eqn=function(E$){return this.cmpn(E$)===0},$$.prototype.eq=function(E$){return this.cmp(E$)===0},$$.red=function(E$){return new H$(E$)},$$.prototype.toRed=function(E$){return r0(!this.red,"Already a number in reduction context"),r0(this.negative===0,"red works only with positives"),E$.convertTo(this)._forceRed(E$)},$$.prototype.fromRed=function(){return r0(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},$$.prototype._forceRed=function(E$){return this.red=E$,this},$$.prototype.forceRed=function(E$){return r0(!this.red,"Already a number in reduction context"),this._forceRed(E$)},$$.prototype.redAdd=function(E$){return r0(this.red,"redAdd works only with red numbers"),this.red.add(this,E$)},$$.prototype.redIAdd=function(E$){return r0(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,E$)},$$.prototype.redSub=function(E$){return r0(this.red,"redSub works only with red numbers"),this.red.sub(this,E$)},$$.prototype.redISub=function(E$){return r0(this.red,"redISub works only with red numbers"),this.red.isub(this,E$)},$$.prototype.redShl=function(E$){return r0(this.red,"redShl works only with red numbers"),this.red.shl(this,E$)},$$.prototype.redMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.mul(this,E$)},$$.prototype.redIMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.imul(this,E$)},$$.prototype.redSqr=function(){return r0(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},$$.prototype.redISqr=function(){return r0(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},$$.prototype.redSqrt=function(){return r0(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},$$.prototype.redInvm=function(){return r0(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},$$.prototype.redNeg=function(){return r0(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},$$.prototype.redPow=function(E$){return r0(this.red&&!E$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,E$)};var x={k256:null,p224:null,p192:null,p25519:null};function O$(E$,T$){this.name=E$,this.p=new $$(T$,16),this.n=this.p.bitLength(),this.k=new $$(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}O$.prototype._tmp=function(){var E$=new $$(null);return E$.words=new Array(Math.ceil(this.n/13)),E$},O$.prototype.ireduce=function(E$){var T$=E$,Y;do this.split(T$,this.tmp),T$=this.imulK(T$),T$=T$.iadd(this.tmp),Y=T$.bitLength();while(Y>this.n);var f=Y0?T$.isub(this.p):T$.strip!==void 0?T$.strip():T$._strip(),T$},O$.prototype.split=function(E$,T$){E$.iushrn(this.n,0,T$)},O$.prototype.imulK=function(E$){return E$.imul(this.k)};function J0(){O$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i0(J0,O$),J0.prototype.split=function(E$,T$){for(var Y=4194303,f=Math.min(E$.length,9),D$=0;D$>>22,F0=C$}F0>>>=22,E$.words[D$-10]=F0,F0===0&&E$.length>10?E$.length-=10:E$.length-=9},J0.prototype.imulK=function(E$){E$.words[E$.length]=0,E$.words[E$.length+1]=0,E$.length+=2;for(var T$=0,Y=0;Y>>=26,E$.words[Y]=D$,T$=f}return T$!==0&&(E$.words[E$.length++]=T$),E$},$$._prime=function(E$){if(x[E$])return x[E$];var T$;if(E$==="k256")T$=new J0;else if(E$==="p224")T$=new J$;else if(E$==="p192")T$=new F$;else if(E$==="p25519")T$=new A$;else throw new Error("Unknown prime "+E$);return x[E$]=T$,T$};function H$(E$){if(typeof E$=="string"){var T$=$$._prime(E$);this.m=T$.p,this.prime=T$}else r0(E$.gtn(1),"modulus must be greater than 1"),this.m=E$,this.prime=null}H$.prototype._verify1=function(E$){r0(E$.negative===0,"red works only with positives"),r0(E$.red,"red works only with red numbers")},H$.prototype._verify2=function(E$,T$){r0((E$.negative|T$.negative)===0,"red works only with positives"),r0(E$.red&&E$.red===T$.red,"red works only with red numbers")},H$.prototype.imod=function(E$){return this.prime?this.prime.ireduce(E$)._forceRed(this):E$.umod(this.m)._forceRed(this)},H$.prototype.neg=function(E$){return E$.isZero()?E$.clone():this.m.sub(E$)._forceRed(this)},H$.prototype.add=function(E$,T$){this._verify2(E$,T$);var Y=E$.add(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y._forceRed(this)},H$.prototype.iadd=function(E$,T$){this._verify2(E$,T$);var Y=E$.iadd(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y},H$.prototype.sub=function(E$,T$){this._verify2(E$,T$);var Y=E$.sub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y._forceRed(this)},H$.prototype.isub=function(E$,T$){this._verify2(E$,T$);var Y=E$.isub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y},H$.prototype.shl=function(E$,T$){return this._verify1(E$),this.imod(E$.ushln(T$))},H$.prototype.imul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.imul(T$))},H$.prototype.mul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.mul(T$))},H$.prototype.isqr=function(E$){return this.imul(E$,E$.clone())},H$.prototype.sqr=function(E$){return this.mul(E$,E$)},H$.prototype.sqrt=function(E$){if(E$.isZero())return E$.clone();var T$=this.m.andln(3);if(r0(T$%2===1),T$===3){var Y=this.m.add(new $$(1)).iushrn(2);return this.pow(E$,Y)}for(var f=this.m.subn(1),D$=0;!f.isZero()&&f.andln(1)===0;)D$++,f.iushrn(1);r0(!f.isZero());var F0=new $$(1).toRed(this),C$=F0.redNeg(),L$=this.m.subn(1).iushrn(1),R$=this.m.bitLength();for(R$=new $$(2*R$*R$).toRed(this);this.pow(R$,L$).cmp(C$)!==0;)R$.redIAdd(C$);for(var P$=this.pow(R$,f),z$=this.pow(E$,f.addn(1).iushrn(1)),M$=this.pow(E$,f),S$=D$;M$.cmp(F0)!==0;){for(var Z=M$,c=0;Z.cmp(F0)!==0;c++)Z=Z.redSqr();r0(c=0;D$--){for(var P$=T$.words[D$],z$=R$-1;z$>=0;z$--){var M$=P$>>z$&1;if(F0!==f[0]&&(F0=this.sqr(F0)),M$===0&&C$===0){L$=0;continue}C$<<=1,C$|=M$,L$++,!(L$!==Y&&(D$!==0||z$!==0))&&(F0=this.mul(F0,f[C$]),L$=0,C$=0)}R$=26}return F0},H$.prototype.convertTo=function(E$){var T$=E$.umod(this.m);return T$===E$?T$.clone():T$},H$.prototype.convertFrom=function(E$){var T$=E$.clone();return T$.red=null,T$},$$.mont=function(E$){return new W$(E$)};function W$(E$){H$.call(this,E$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new $$(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)}i0(W$,H$),W$.prototype.convertTo=function(E$){return this.imod(E$.ushln(this.shift))},W$.prototype.convertFrom=function(E$){var T$=this.imod(E$.mul(this.rinv));return T$.red=null,T$},W$.prototype.imul=function(E$,T$){if(E$.isZero()||T$.isZero())return E$.words[0]=0,E$.length=1,E$;var Y=E$.imul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.mul=function(E$,T$){if(E$.isZero()||T$.isZero())return new $$(0)._forceRed(this);var Y=E$.mul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.invm=function(E$){var T$=this.imod(E$._invmp(this.m).mul(this.r2));return T$._forceRed(this)}})(typeof m0>"u"||m0,t0)}}),JZ=pQ({"node_modules/create-ecdh/browser.js"(t0,m0){var a0=nY(),e0=OZ();m0.exports=function(Q$){return new i0(Q$)};var r0={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}};r0.p224=r0.secp224r1,r0.p256=r0.secp256r1=r0.prime256v1,r0.p192=r0.secp192r1=r0.prime192v1,r0.p384=r0.secp384r1,r0.p521=r0.secp521r1;function i0(Q$){this.curveType=r0[Q$],this.curveType||(this.curveType={name:Q$}),this.curve=new a0.ec(this.curveType.name),this.keys=void 0}i0.prototype.generateKeys=function(Q$,$){return this.keys=this.curve.genKeyPair(),this.getPublicKey(Q$,$)},i0.prototype.computeSecret=function(Q$,$,N){$=$||"utf8",G0.isBuffer(Q$)||(Q$=new G0(Q$,$));var Y$=this.curve.keyFromPublic(Q$).getPublic(),O0=Y$.mul(this.keys.getPrivate()).getX();return $$(O0,N,this.curveType.byteLength)},i0.prototype.getPublicKey=function(Q$,$){var N=this.keys.getPublic($==="compressed",!0);return $==="hybrid"&&(N[N.length-1]%2?N[0]=7:N[0]=6),$$(N,Q$)},i0.prototype.getPrivateKey=function(Q$){return $$(this.keys.getPrivate(),Q$)},i0.prototype.setPublicKey=function(Q$,$){return $=$||"utf8",G0.isBuffer(Q$)||(Q$=new G0(Q$,$)),this.keys._importPublic(Q$),this},i0.prototype.setPrivateKey=function(Q$,$){$=$||"utf8",G0.isBuffer(Q$)||(Q$=new G0(Q$,$));var N=new e0(Q$);return N=N.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(N),this};function $$(Q$,$,N){Array.isArray(Q$)||(Q$=Q$.toArray());var Y$=new G0(Q$);if(N&&Y$.length0?E$:T$},$$.min=function(E$,T$){return E$.cmp(T$)<0?E$:T$},$$.prototype._init=function(E$,T$,Y){if(typeof E$=="number")return this._initNumber(E$,T$,Y);if(typeof E$=="object")return this._initArray(E$,T$,Y);T$==="hex"&&(T$=16),r0(T$===(T$|0)&&T$>=2&&T$<=36),E$=E$.toString().replace(/\s+/g,"");var f=0;E$[0]==="-"&&(f++,this.negative=1),f=0;f-=3)F0=E$[f]|E$[f-1]<<8|E$[f-2]<<16,this.words[D$]|=F0<>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);else if(Y==="le")for(f=0,D$=0;f>>26-C$&67108863,C$+=24,C$>=26&&(C$-=26,D$++);return this.strip()};function $(E$,T$){var Y=E$.charCodeAt(T$);return Y>=65&&Y<=70?Y-55:Y>=97&&Y<=102?Y-87:Y-48&15}function N(E$,T$,Y){var f=$(E$,Y);return Y-1>=T$&&(f|=$(E$,Y-1)<<4),f}$$.prototype._parseHex=function(E$,T$,Y){this.length=Math.ceil((E$.length-T$)/6),this.words=new Array(this.length);for(var f=0;f=T$;f-=2)C$=N(E$,T$,f)<=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8;else{var L$=E$.length-T$;for(f=L$%2===0?T$+1:T$;f=18?(D$-=18,F0+=1,this.words[F0]|=C$>>>26):D$+=8}this.strip()};function Y$(E$,T$,Y,f){for(var D$=0,F0=Math.min(E$.length,Y),C$=T$;C$=49?D$+=L$-49+10:L$>=17?D$+=L$-17+10:D$+=L$}return D$}$$.prototype._parseBase=function(E$,T$,Y){this.words=[0],this.length=1;for(var f=0,D$=1;D$<=67108863;D$*=T$)f++;f--,D$=D$/T$|0;for(var F0=E$.length-Y,C$=F0%f,L$=Math.min(F0,F0-C$)+Y,R$=0,P$=Y;P$1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},$$.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},$$.prototype.inspect=function(){return(this.red?""};var O0=["","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"],Z$=[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],G$=[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];$$.prototype.toString=function(E$,T$){E$=E$||10,T$=T$|0||1;var Y;if(E$===16||E$==="hex"){Y="";for(var f=0,D$=0,F0=0;F0>>24-f&16777215,D$!==0||F0!==this.length-1?Y=O0[6-L$.length]+L$+Y:Y=L$+Y,f+=2,f>=26&&(f-=26,F0--)}for(D$!==0&&(Y=D$.toString(16)+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}if(E$===(E$|0)&&E$>=2&&E$<=36){var R$=Z$[E$],P$=G$[E$];Y="";var z$=this.clone();for(z$.negative=0;!z$.isZero();){var M$=z$.modn(P$).toString(E$);z$=z$.idivn(P$),z$.isZero()?Y=M$+Y:Y=O0[R$-M$.length]+M$+Y}for(this.isZero()&&(Y="0"+Y);Y.length%T$!==0;)Y="0"+Y;return this.negative!==0&&(Y="-"+Y),Y}r0(!1,"Base should be between 2 and 36")},$$.prototype.toNumber=function(){var E$=this.words[0];return this.length===2?E$+=this.words[1]*67108864:this.length===3&&this.words[2]===1?E$+=4503599627370496+this.words[1]*67108864:this.length>2&&r0(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-E$:E$},$$.prototype.toJSON=function(){return this.toString(16)},$$.prototype.toBuffer=function(E$,T$){return r0(typeof Q$<"u"),this.toArrayLike(Q$,E$,T$)},$$.prototype.toArray=function(E$,T$){return this.toArrayLike(Array,E$,T$)},$$.prototype.toArrayLike=function(E$,T$,Y){var f=this.byteLength(),D$=Y||Math.max(1,f);r0(f<=D$,"byte array longer than desired length"),r0(D$>0,"Requested array length <= 0"),this.strip();var F0=T$==="le",C$=new E$(D$),L$,R$,P$=this.clone();if(F0){for(R$=0;!P$.isZero();R$++)L$=P$.andln(255),P$.iushrn(8),C$[R$]=L$;for(;R$=4096&&(Y+=13,T$>>>=13),T$>=64&&(Y+=7,T$>>>=7),T$>=8&&(Y+=4,T$>>>=4),T$>=2&&(Y+=2,T$>>>=2),Y+T$},$$.prototype._zeroBits=function(E$){if(E$===0)return 26;var T$=E$,Y=0;return(T$&8191)===0&&(Y+=13,T$>>>=13),(T$&127)===0&&(Y+=7,T$>>>=7),(T$&15)===0&&(Y+=4,T$>>>=4),(T$&3)===0&&(Y+=2,T$>>>=2),(T$&1)===0&&Y++,Y},$$.prototype.bitLength=function(){var E$=this.words[this.length-1],T$=this._countBits(E$);return(this.length-1)*26+T$};function V$(E$){for(var T$=new Array(E$.bitLength()),Y=0;Y>>D$}return T$}$$.prototype.zeroBits=function(){if(this.isZero())return 0;for(var E$=0,T$=0;T$E$.length?this.clone().ior(E$):E$.clone().ior(this)},$$.prototype.uor=function(E$){return this.length>E$.length?this.clone().iuor(E$):E$.clone().iuor(this)},$$.prototype.iuand=function(E$){var T$;this.length>E$.length?T$=E$:T$=this;for(var Y=0;YE$.length?this.clone().iand(E$):E$.clone().iand(this)},$$.prototype.uand=function(E$){return this.length>E$.length?this.clone().iuand(E$):E$.clone().iuand(this)},$$.prototype.iuxor=function(E$){var T$,Y;this.length>E$.length?(T$=this,Y=E$):(T$=E$,Y=this);for(var f=0;fE$.length?this.clone().ixor(E$):E$.clone().ixor(this)},$$.prototype.uxor=function(E$){return this.length>E$.length?this.clone().iuxor(E$):E$.clone().iuxor(this)},$$.prototype.inotn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=Math.ceil(E$/26)|0,Y=E$%26;this._expand(T$),Y>0&&T$--;for(var f=0;f0&&(this.words[f]=~this.words[f]&67108863>>26-Y),this.strip()},$$.prototype.notn=function(E$){return this.clone().inotn(E$)},$$.prototype.setn=function(E$,T$){r0(typeof E$=="number"&&E$>=0);var Y=E$/26|0,f=E$%26;return this._expand(Y+1),T$?this.words[Y]=this.words[Y]|1<E$.length?(Y=this,f=E$):(Y=E$,f=this);for(var D$=0,F0=0;F0>>26;for(;D$!==0&&F0>>26;if(this.length=Y.length,D$!==0)this.words[this.length]=D$,this.length++;else if(Y!==this)for(;F0E$.length?this.clone().iadd(E$):E$.clone().iadd(this)},$$.prototype.isub=function(E$){if(E$.negative!==0){E$.negative=0;var T$=this.iadd(E$);return E$.negative=1,T$._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(E$),this.negative=1,this._normSign();var Y=this.cmp(E$);if(Y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,D$;Y>0?(f=this,D$=E$):(f=E$,D$=this);for(var F0=0,C$=0;C$>26,this.words[C$]=T$&67108863;for(;F0!==0&&C$>26,this.words[C$]=T$&67108863;if(F0===0&&C$>>26,M$=R$&67108863,S$=Math.min(P$,T$.length-1),Z=Math.max(0,P$-E$.length+1);Z<=S$;Z++){var c=P$-Z|0;D$=E$.words[c]|0,F0=T$.words[Z]|0,C$=D$*F0+M$,z$+=C$/67108864|0,M$=C$&67108863}Y.words[P$]=M$|0,R$=z$|0}return R$!==0?Y.words[P$]=R$|0:Y.length--,Y.strip()}var X$=function(E$,T$,Y){var f=E$.words,D$=T$.words,F0=Y.words,C$=0,L$,R$,P$,z$=f[0]|0,M$=z$&8191,S$=z$>>>13,Z=f[1]|0,c=Z&8191,v$=Z>>>13,A0=f[2]|0,q$=A0&8191,j$=A0>>>13,k$=f[3]|0,g$=k$&8191,_$=k$>>>13,N$=f[4]|0,x$=N$&8191,G=N$>>>13,B=f[5]|0,B$=B&8191,H0=B>>>13,y$=f[6]|0,w$=y$&8191,p$=y$>>>13,f$=f[7]|0,c$=f$&8191,h$=f$>>>13,d$=f[8]|0,V=d$&8191,h=d$>>>13,W0=f[9]|0,E0=W0&8191,b$=W0>>>13,l$=D$[0]|0,o$=l$&8191,u$=l$>>>13,n$=D$[1]|0,s$=n$&8191,t$=n$>>>13,U=D$[2]|0,d=U&8191,m$=U>>>13,T0=D$[3]|0,a$=T0&8191,e$=T0>>>13,r$=D$[4]|0,i$=r$&8191,$Q=r$>>>13,QQ=D$[5]|0,YQ=QQ&8191,X=QQ>>>13,b=D$[6]|0,ZQ=b&8191,D0=b>>>13,GQ=D$[7]|0,VQ=GQ&8191,UQ=GQ>>>13,XQ=D$[8]|0,KQ=XQ&8191,IQ=XQ>>>13,OQ=D$[9]|0,K=OQ&8191,l=OQ>>>13;Y.negative=E$.negative^T$.negative,Y.length=19,L$=Math.imul(M$,o$),R$=Math.imul(M$,u$),R$=R$+Math.imul(S$,o$)|0,P$=Math.imul(S$,u$);var JQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(JQ>>>26)|0,JQ&=67108863,L$=Math.imul(c,o$),R$=Math.imul(c,u$),R$=R$+Math.imul(v$,o$)|0,P$=Math.imul(v$,u$),L$=L$+Math.imul(M$,s$)|0,R$=R$+Math.imul(M$,t$)|0,R$=R$+Math.imul(S$,s$)|0,P$=P$+Math.imul(S$,t$)|0;var C0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(C0>>>26)|0,C0&=67108863,L$=Math.imul(q$,o$),R$=Math.imul(q$,u$),R$=R$+Math.imul(j$,o$)|0,P$=Math.imul(j$,u$),L$=L$+Math.imul(c,s$)|0,R$=R$+Math.imul(c,t$)|0,R$=R$+Math.imul(v$,s$)|0,P$=P$+Math.imul(v$,t$)|0,L$=L$+Math.imul(M$,d)|0,R$=R$+Math.imul(M$,m$)|0,R$=R$+Math.imul(S$,d)|0,P$=P$+Math.imul(S$,m$)|0;var FQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(FQ>>>26)|0,FQ&=67108863,L$=Math.imul(g$,o$),R$=Math.imul(g$,u$),R$=R$+Math.imul(_$,o$)|0,P$=Math.imul(_$,u$),L$=L$+Math.imul(q$,s$)|0,R$=R$+Math.imul(q$,t$)|0,R$=R$+Math.imul(j$,s$)|0,P$=P$+Math.imul(j$,t$)|0,L$=L$+Math.imul(c,d)|0,R$=R$+Math.imul(c,m$)|0,R$=R$+Math.imul(v$,d)|0,P$=P$+Math.imul(v$,m$)|0,L$=L$+Math.imul(M$,a$)|0,R$=R$+Math.imul(M$,e$)|0,R$=R$+Math.imul(S$,a$)|0,P$=P$+Math.imul(S$,e$)|0;var AQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(AQ>>>26)|0,AQ&=67108863,L$=Math.imul(x$,o$),R$=Math.imul(x$,u$),R$=R$+Math.imul(G,o$)|0,P$=Math.imul(G,u$),L$=L$+Math.imul(g$,s$)|0,R$=R$+Math.imul(g$,t$)|0,R$=R$+Math.imul(_$,s$)|0,P$=P$+Math.imul(_$,t$)|0,L$=L$+Math.imul(q$,d)|0,R$=R$+Math.imul(q$,m$)|0,R$=R$+Math.imul(j$,d)|0,P$=P$+Math.imul(j$,m$)|0,L$=L$+Math.imul(c,a$)|0,R$=R$+Math.imul(c,e$)|0,R$=R$+Math.imul(v$,a$)|0,P$=P$+Math.imul(v$,e$)|0,L$=L$+Math.imul(M$,i$)|0,R$=R$+Math.imul(M$,$Q)|0,R$=R$+Math.imul(S$,i$)|0,P$=P$+Math.imul(S$,$Q)|0;var HQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(HQ>>>26)|0,HQ&=67108863,L$=Math.imul(B$,o$),R$=Math.imul(B$,u$),R$=R$+Math.imul(H0,o$)|0,P$=Math.imul(H0,u$),L$=L$+Math.imul(x$,s$)|0,R$=R$+Math.imul(x$,t$)|0,R$=R$+Math.imul(G,s$)|0,P$=P$+Math.imul(G,t$)|0,L$=L$+Math.imul(g$,d)|0,R$=R$+Math.imul(g$,m$)|0,R$=R$+Math.imul(_$,d)|0,P$=P$+Math.imul(_$,m$)|0,L$=L$+Math.imul(q$,a$)|0,R$=R$+Math.imul(q$,e$)|0,R$=R$+Math.imul(j$,a$)|0,P$=P$+Math.imul(j$,e$)|0,L$=L$+Math.imul(c,i$)|0,R$=R$+Math.imul(c,$Q)|0,R$=R$+Math.imul(v$,i$)|0,P$=P$+Math.imul(v$,$Q)|0,L$=L$+Math.imul(M$,YQ)|0,R$=R$+Math.imul(M$,X)|0,R$=R$+Math.imul(S$,YQ)|0,P$=P$+Math.imul(S$,X)|0;var WQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(WQ>>>26)|0,WQ&=67108863,L$=Math.imul(w$,o$),R$=Math.imul(w$,u$),R$=R$+Math.imul(p$,o$)|0,P$=Math.imul(p$,u$),L$=L$+Math.imul(B$,s$)|0,R$=R$+Math.imul(B$,t$)|0,R$=R$+Math.imul(H0,s$)|0,P$=P$+Math.imul(H0,t$)|0,L$=L$+Math.imul(x$,d)|0,R$=R$+Math.imul(x$,m$)|0,R$=R$+Math.imul(G,d)|0,P$=P$+Math.imul(G,m$)|0,L$=L$+Math.imul(g$,a$)|0,R$=R$+Math.imul(g$,e$)|0,R$=R$+Math.imul(_$,a$)|0,P$=P$+Math.imul(_$,e$)|0,L$=L$+Math.imul(q$,i$)|0,R$=R$+Math.imul(q$,$Q)|0,R$=R$+Math.imul(j$,i$)|0,P$=P$+Math.imul(j$,$Q)|0,L$=L$+Math.imul(c,YQ)|0,R$=R$+Math.imul(c,X)|0,R$=R$+Math.imul(v$,YQ)|0,P$=P$+Math.imul(v$,X)|0,L$=L$+Math.imul(M$,ZQ)|0,R$=R$+Math.imul(M$,D0)|0,R$=R$+Math.imul(S$,ZQ)|0,P$=P$+Math.imul(S$,D0)|0;var EQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(EQ>>>26)|0,EQ&=67108863,L$=Math.imul(c$,o$),R$=Math.imul(c$,u$),R$=R$+Math.imul(h$,o$)|0,P$=Math.imul(h$,u$),L$=L$+Math.imul(w$,s$)|0,R$=R$+Math.imul(w$,t$)|0,R$=R$+Math.imul(p$,s$)|0,P$=P$+Math.imul(p$,t$)|0,L$=L$+Math.imul(B$,d)|0,R$=R$+Math.imul(B$,m$)|0,R$=R$+Math.imul(H0,d)|0,P$=P$+Math.imul(H0,m$)|0,L$=L$+Math.imul(x$,a$)|0,R$=R$+Math.imul(x$,e$)|0,R$=R$+Math.imul(G,a$)|0,P$=P$+Math.imul(G,e$)|0,L$=L$+Math.imul(g$,i$)|0,R$=R$+Math.imul(g$,$Q)|0,R$=R$+Math.imul(_$,i$)|0,P$=P$+Math.imul(_$,$Q)|0,L$=L$+Math.imul(q$,YQ)|0,R$=R$+Math.imul(q$,X)|0,R$=R$+Math.imul(j$,YQ)|0,P$=P$+Math.imul(j$,X)|0,L$=L$+Math.imul(c,ZQ)|0,R$=R$+Math.imul(c,D0)|0,R$=R$+Math.imul(v$,ZQ)|0,P$=P$+Math.imul(v$,D0)|0,L$=L$+Math.imul(M$,VQ)|0,R$=R$+Math.imul(M$,UQ)|0,R$=R$+Math.imul(S$,VQ)|0,P$=P$+Math.imul(S$,UQ)|0;var TQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(TQ>>>26)|0,TQ&=67108863,L$=Math.imul(V,o$),R$=Math.imul(V,u$),R$=R$+Math.imul(h,o$)|0,P$=Math.imul(h,u$),L$=L$+Math.imul(c$,s$)|0,R$=R$+Math.imul(c$,t$)|0,R$=R$+Math.imul(h$,s$)|0,P$=P$+Math.imul(h$,t$)|0,L$=L$+Math.imul(w$,d)|0,R$=R$+Math.imul(w$,m$)|0,R$=R$+Math.imul(p$,d)|0,P$=P$+Math.imul(p$,m$)|0,L$=L$+Math.imul(B$,a$)|0,R$=R$+Math.imul(B$,e$)|0,R$=R$+Math.imul(H0,a$)|0,P$=P$+Math.imul(H0,e$)|0,L$=L$+Math.imul(x$,i$)|0,R$=R$+Math.imul(x$,$Q)|0,R$=R$+Math.imul(G,i$)|0,P$=P$+Math.imul(G,$Q)|0,L$=L$+Math.imul(g$,YQ)|0,R$=R$+Math.imul(g$,X)|0,R$=R$+Math.imul(_$,YQ)|0,P$=P$+Math.imul(_$,X)|0,L$=L$+Math.imul(q$,ZQ)|0,R$=R$+Math.imul(q$,D0)|0,R$=R$+Math.imul(j$,ZQ)|0,P$=P$+Math.imul(j$,D0)|0,L$=L$+Math.imul(c,VQ)|0,R$=R$+Math.imul(c,UQ)|0,R$=R$+Math.imul(v$,VQ)|0,P$=P$+Math.imul(v$,UQ)|0,L$=L$+Math.imul(M$,KQ)|0,R$=R$+Math.imul(M$,IQ)|0,R$=R$+Math.imul(S$,KQ)|0,P$=P$+Math.imul(S$,IQ)|0;var DQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(DQ>>>26)|0,DQ&=67108863,L$=Math.imul(E0,o$),R$=Math.imul(E0,u$),R$=R$+Math.imul(b$,o$)|0,P$=Math.imul(b$,u$),L$=L$+Math.imul(V,s$)|0,R$=R$+Math.imul(V,t$)|0,R$=R$+Math.imul(h,s$)|0,P$=P$+Math.imul(h,t$)|0,L$=L$+Math.imul(c$,d)|0,R$=R$+Math.imul(c$,m$)|0,R$=R$+Math.imul(h$,d)|0,P$=P$+Math.imul(h$,m$)|0,L$=L$+Math.imul(w$,a$)|0,R$=R$+Math.imul(w$,e$)|0,R$=R$+Math.imul(p$,a$)|0,P$=P$+Math.imul(p$,e$)|0,L$=L$+Math.imul(B$,i$)|0,R$=R$+Math.imul(B$,$Q)|0,R$=R$+Math.imul(H0,i$)|0,P$=P$+Math.imul(H0,$Q)|0,L$=L$+Math.imul(x$,YQ)|0,R$=R$+Math.imul(x$,X)|0,R$=R$+Math.imul(G,YQ)|0,P$=P$+Math.imul(G,X)|0,L$=L$+Math.imul(g$,ZQ)|0,R$=R$+Math.imul(g$,D0)|0,R$=R$+Math.imul(_$,ZQ)|0,P$=P$+Math.imul(_$,D0)|0,L$=L$+Math.imul(q$,VQ)|0,R$=R$+Math.imul(q$,UQ)|0,R$=R$+Math.imul(j$,VQ)|0,P$=P$+Math.imul(j$,UQ)|0,L$=L$+Math.imul(c,KQ)|0,R$=R$+Math.imul(c,IQ)|0,R$=R$+Math.imul(v$,KQ)|0,P$=P$+Math.imul(v$,IQ)|0,L$=L$+Math.imul(M$,K)|0,R$=R$+Math.imul(M$,l)|0,R$=R$+Math.imul(S$,K)|0,P$=P$+Math.imul(S$,l)|0;var I=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(I>>>26)|0,I&=67108863,L$=Math.imul(E0,s$),R$=Math.imul(E0,t$),R$=R$+Math.imul(b$,s$)|0,P$=Math.imul(b$,t$),L$=L$+Math.imul(V,d)|0,R$=R$+Math.imul(V,m$)|0,R$=R$+Math.imul(h,d)|0,P$=P$+Math.imul(h,m$)|0,L$=L$+Math.imul(c$,a$)|0,R$=R$+Math.imul(c$,e$)|0,R$=R$+Math.imul(h$,a$)|0,P$=P$+Math.imul(h$,e$)|0,L$=L$+Math.imul(w$,i$)|0,R$=R$+Math.imul(w$,$Q)|0,R$=R$+Math.imul(p$,i$)|0,P$=P$+Math.imul(p$,$Q)|0,L$=L$+Math.imul(B$,YQ)|0,R$=R$+Math.imul(B$,X)|0,R$=R$+Math.imul(H0,YQ)|0,P$=P$+Math.imul(H0,X)|0,L$=L$+Math.imul(x$,ZQ)|0,R$=R$+Math.imul(x$,D0)|0,R$=R$+Math.imul(G,ZQ)|0,P$=P$+Math.imul(G,D0)|0,L$=L$+Math.imul(g$,VQ)|0,R$=R$+Math.imul(g$,UQ)|0,R$=R$+Math.imul(_$,VQ)|0,P$=P$+Math.imul(_$,UQ)|0,L$=L$+Math.imul(q$,KQ)|0,R$=R$+Math.imul(q$,IQ)|0,R$=R$+Math.imul(j$,KQ)|0,P$=P$+Math.imul(j$,IQ)|0,L$=L$+Math.imul(c,K)|0,R$=R$+Math.imul(c,l)|0,R$=R$+Math.imul(v$,K)|0,P$=P$+Math.imul(v$,l)|0;var o=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(o>>>26)|0,o&=67108863,L$=Math.imul(E0,d),R$=Math.imul(E0,m$),R$=R$+Math.imul(b$,d)|0,P$=Math.imul(b$,m$),L$=L$+Math.imul(V,a$)|0,R$=R$+Math.imul(V,e$)|0,R$=R$+Math.imul(h,a$)|0,P$=P$+Math.imul(h,e$)|0,L$=L$+Math.imul(c$,i$)|0,R$=R$+Math.imul(c$,$Q)|0,R$=R$+Math.imul(h$,i$)|0,P$=P$+Math.imul(h$,$Q)|0,L$=L$+Math.imul(w$,YQ)|0,R$=R$+Math.imul(w$,X)|0,R$=R$+Math.imul(p$,YQ)|0,P$=P$+Math.imul(p$,X)|0,L$=L$+Math.imul(B$,ZQ)|0,R$=R$+Math.imul(B$,D0)|0,R$=R$+Math.imul(H0,ZQ)|0,P$=P$+Math.imul(H0,D0)|0,L$=L$+Math.imul(x$,VQ)|0,R$=R$+Math.imul(x$,UQ)|0,R$=R$+Math.imul(G,VQ)|0,P$=P$+Math.imul(G,UQ)|0,L$=L$+Math.imul(g$,KQ)|0,R$=R$+Math.imul(g$,IQ)|0,R$=R$+Math.imul(_$,KQ)|0,P$=P$+Math.imul(_$,IQ)|0,L$=L$+Math.imul(q$,K)|0,R$=R$+Math.imul(q$,l)|0,R$=R$+Math.imul(j$,K)|0,P$=P$+Math.imul(j$,l)|0;var CQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(CQ>>>26)|0,CQ&=67108863,L$=Math.imul(E0,a$),R$=Math.imul(E0,e$),R$=R$+Math.imul(b$,a$)|0,P$=Math.imul(b$,e$),L$=L$+Math.imul(V,i$)|0,R$=R$+Math.imul(V,$Q)|0,R$=R$+Math.imul(h,i$)|0,P$=P$+Math.imul(h,$Q)|0,L$=L$+Math.imul(c$,YQ)|0,R$=R$+Math.imul(c$,X)|0,R$=R$+Math.imul(h$,YQ)|0,P$=P$+Math.imul(h$,X)|0,L$=L$+Math.imul(w$,ZQ)|0,R$=R$+Math.imul(w$,D0)|0,R$=R$+Math.imul(p$,ZQ)|0,P$=P$+Math.imul(p$,D0)|0,L$=L$+Math.imul(B$,VQ)|0,R$=R$+Math.imul(B$,UQ)|0,R$=R$+Math.imul(H0,VQ)|0,P$=P$+Math.imul(H0,UQ)|0,L$=L$+Math.imul(x$,KQ)|0,R$=R$+Math.imul(x$,IQ)|0,R$=R$+Math.imul(G,KQ)|0,P$=P$+Math.imul(G,IQ)|0,L$=L$+Math.imul(g$,K)|0,R$=R$+Math.imul(g$,l)|0,R$=R$+Math.imul(_$,K)|0,P$=P$+Math.imul(_$,l)|0;var L0=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(L0>>>26)|0,L0&=67108863,L$=Math.imul(E0,i$),R$=Math.imul(E0,$Q),R$=R$+Math.imul(b$,i$)|0,P$=Math.imul(b$,$Q),L$=L$+Math.imul(V,YQ)|0,R$=R$+Math.imul(V,X)|0,R$=R$+Math.imul(h,YQ)|0,P$=P$+Math.imul(h,X)|0,L$=L$+Math.imul(c$,ZQ)|0,R$=R$+Math.imul(c$,D0)|0,R$=R$+Math.imul(h$,ZQ)|0,P$=P$+Math.imul(h$,D0)|0,L$=L$+Math.imul(w$,VQ)|0,R$=R$+Math.imul(w$,UQ)|0,R$=R$+Math.imul(p$,VQ)|0,P$=P$+Math.imul(p$,UQ)|0,L$=L$+Math.imul(B$,KQ)|0,R$=R$+Math.imul(B$,IQ)|0,R$=R$+Math.imul(H0,KQ)|0,P$=P$+Math.imul(H0,IQ)|0,L$=L$+Math.imul(x$,K)|0,R$=R$+Math.imul(x$,l)|0,R$=R$+Math.imul(G,K)|0,P$=P$+Math.imul(G,l)|0;var LQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(LQ>>>26)|0,LQ&=67108863,L$=Math.imul(E0,YQ),R$=Math.imul(E0,X),R$=R$+Math.imul(b$,YQ)|0,P$=Math.imul(b$,X),L$=L$+Math.imul(V,ZQ)|0,R$=R$+Math.imul(V,D0)|0,R$=R$+Math.imul(h,ZQ)|0,P$=P$+Math.imul(h,D0)|0,L$=L$+Math.imul(c$,VQ)|0,R$=R$+Math.imul(c$,UQ)|0,R$=R$+Math.imul(h$,VQ)|0,P$=P$+Math.imul(h$,UQ)|0,L$=L$+Math.imul(w$,KQ)|0,R$=R$+Math.imul(w$,IQ)|0,R$=R$+Math.imul(p$,KQ)|0,P$=P$+Math.imul(p$,IQ)|0,L$=L$+Math.imul(B$,K)|0,R$=R$+Math.imul(B$,l)|0,R$=R$+Math.imul(H0,K)|0,P$=P$+Math.imul(H0,l)|0;var RQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(RQ>>>26)|0,RQ&=67108863,L$=Math.imul(E0,ZQ),R$=Math.imul(E0,D0),R$=R$+Math.imul(b$,ZQ)|0,P$=Math.imul(b$,D0),L$=L$+Math.imul(V,VQ)|0,R$=R$+Math.imul(V,UQ)|0,R$=R$+Math.imul(h,VQ)|0,P$=P$+Math.imul(h,UQ)|0,L$=L$+Math.imul(c$,KQ)|0,R$=R$+Math.imul(c$,IQ)|0,R$=R$+Math.imul(h$,KQ)|0,P$=P$+Math.imul(h$,IQ)|0,L$=L$+Math.imul(w$,K)|0,R$=R$+Math.imul(w$,l)|0,R$=R$+Math.imul(p$,K)|0,P$=P$+Math.imul(p$,l)|0;var PQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(PQ>>>26)|0,PQ&=67108863,L$=Math.imul(E0,VQ),R$=Math.imul(E0,UQ),R$=R$+Math.imul(b$,VQ)|0,P$=Math.imul(b$,UQ),L$=L$+Math.imul(V,KQ)|0,R$=R$+Math.imul(V,IQ)|0,R$=R$+Math.imul(h,KQ)|0,P$=P$+Math.imul(h,IQ)|0,L$=L$+Math.imul(c$,K)|0,R$=R$+Math.imul(c$,l)|0,R$=R$+Math.imul(h$,K)|0,P$=P$+Math.imul(h$,l)|0;var zQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(zQ>>>26)|0,zQ&=67108863,L$=Math.imul(E0,KQ),R$=Math.imul(E0,IQ),R$=R$+Math.imul(b$,KQ)|0,P$=Math.imul(b$,IQ),L$=L$+Math.imul(V,K)|0,R$=R$+Math.imul(V,l)|0,R$=R$+Math.imul(h,K)|0,P$=P$+Math.imul(h,l)|0;var MQ=(C$+L$|0)+((R$&8191)<<13)|0;C$=(P$+(R$>>>13)|0)+(MQ>>>26)|0,MQ&=67108863,L$=Math.imul(E0,K),R$=Math.imul(E0,l),R$=R$+Math.imul(b$,K)|0,P$=Math.imul(b$,l);var SQ=(C$+L$|0)+((R$&8191)<<13)|0;return C$=(P$+(R$>>>13)|0)+(SQ>>>26)|0,SQ&=67108863,F0[0]=JQ,F0[1]=C0,F0[2]=FQ,F0[3]=AQ,F0[4]=HQ,F0[5]=WQ,F0[6]=EQ,F0[7]=TQ,F0[8]=DQ,F0[9]=I,F0[10]=o,F0[11]=CQ,F0[12]=L0,F0[13]=LQ,F0[14]=RQ,F0[15]=PQ,F0[16]=zQ,F0[17]=MQ,F0[18]=SQ,C$!==0&&(F0[19]=C$,Y.length++),Y};Math.imul||(X$=U$);function K$(E$,T$,Y){Y.negative=T$.negative^E$.negative,Y.length=E$.length+T$.length;for(var f=0,D$=0,F0=0;F0>>26)|0,D$+=C$>>>26,C$&=67108863}Y.words[F0]=L$,f=C$,C$=D$}return f!==0?Y.words[F0]=f:Y.length--,Y.strip()}function I$(E$,T$,Y){var f=new Q;return f.mulp(E$,T$,Y)}$$.prototype.mulTo=function(E$,T$){var Y,f=this.length+E$.length;return this.length===10&&E$.length===10?Y=X$(this,E$,T$):f<63?Y=U$(this,E$,T$):f<1024?Y=K$(this,E$,T$):Y=I$(this,E$,T$),Y};function Q(E$,T$){this.x=E$,this.y=T$}Q.prototype.makeRBT=function(E$){for(var T$=new Array(E$),Y=$$.prototype._countBits(E$)-1,f=0;f>=1;return f},Q.prototype.permute=function(E$,T$,Y,f,D$,F0){for(var C$=0;C$>>1)D$++;return 1<>>13,Y[2*F0+1]=D$&8191,D$=D$>>>13;for(F0=2*T$;F0>=26,T$+=f/67108864|0,T$+=D$>>>26,this.words[Y]=D$&67108863}return T$!==0&&(this.words[Y]=T$,this.length++),this},$$.prototype.muln=function(E$){return this.clone().imuln(E$)},$$.prototype.sqr=function(){return this.mul(this)},$$.prototype.isqr=function(){return this.imul(this.clone())},$$.prototype.pow=function(E$){var T$=V$(E$);if(T$.length===0)return new $$(1);for(var Y=this,f=0;f=0);var T$=E$%26,Y=(E$-T$)/26,f=67108863>>>26-T$<<26-T$,D$;if(T$!==0){var F0=0;for(D$=0;D$>>26-T$}F0&&(this.words[D$]=F0,this.length++)}if(Y!==0){for(D$=this.length-1;D$>=0;D$--)this.words[D$+Y]=this.words[D$];for(D$=0;D$=0);var f;T$?f=(T$-T$%26)/26:f=0;var D$=E$%26,F0=Math.min((E$-D$)/26,this.length),C$=67108863^67108863>>>D$<F0)for(this.length-=F0,R$=0;R$=0&&(P$!==0||R$>=f);R$--){var z$=this.words[R$]|0;this.words[R$]=P$<<26-D$|z$>>>D$,P$=z$&C$}return L$&&P$!==0&&(L$.words[L$.length++]=P$),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},$$.prototype.ishrn=function(E$,T$,Y){return r0(this.negative===0),this.iushrn(E$,T$,Y)},$$.prototype.shln=function(E$){return this.clone().ishln(E$)},$$.prototype.ushln=function(E$){return this.clone().iushln(E$)},$$.prototype.shrn=function(E$){return this.clone().ishrn(E$)},$$.prototype.ushrn=function(E$){return this.clone().iushrn(E$)},$$.prototype.testn=function(E$){r0(typeof E$=="number"&&E$>=0);var T$=E$%26,Y=(E$-T$)/26,f=1<=0);var T$=E$%26,Y=(E$-T$)/26;if(r0(this.negative===0,"imaskn works only with positive numbers"),this.length<=Y)return this;if(T$!==0&&Y++,this.length=Math.min(Y,this.length),T$!==0){var f=67108863^67108863>>>T$<=67108864;T$++)this.words[T$]-=67108864,T$===this.length-1?this.words[T$+1]=1:this.words[T$+1]++;return this.length=Math.max(this.length,T$+1),this},$$.prototype.isubn=function(E$){if(r0(typeof E$=="number"),r0(E$<67108864),E$<0)return this.iaddn(-E$);if(this.negative!==0)return this.negative=0,this.iaddn(E$),this.negative=1,this;if(this.words[0]-=E$,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var T$=0;T$>26)-(L$/67108864|0),this.words[D$+Y]=F0&67108863}for(;D$>26,this.words[D$+Y]=F0&67108863;if(C$===0)return this.strip();for(r0(C$===-1),C$=0,D$=0;D$>26,this.words[D$]=F0&67108863;return this.negative=1,this.strip()},$$.prototype._wordDiv=function(E$,T$){var Y=this.length-E$.length,f=this.clone(),D$=E$,F0=D$.words[D$.length-1]|0,C$=this._countBits(F0);Y=26-C$,Y!==0&&(D$=D$.ushln(Y),f.iushln(Y),F0=D$.words[D$.length-1]|0);var L$=f.length-D$.length,R$;if(T$!=="mod"){R$=new $$(null),R$.length=L$+1,R$.words=new Array(R$.length);for(var P$=0;P$=0;M$--){var S$=(f.words[D$.length+M$]|0)*67108864+(f.words[D$.length+M$-1]|0);for(S$=Math.min(S$/F0|0,67108863),f._ishlnsubmul(D$,S$,M$);f.negative!==0;)S$--,f.negative=0,f._ishlnsubmul(D$,1,M$),f.isZero()||(f.negative^=1);R$&&(R$.words[M$]=S$)}return R$&&R$.strip(),f.strip(),T$!=="div"&&Y!==0&&f.iushrn(Y),{div:R$||null,mod:f}},$$.prototype.divmod=function(E$,T$,Y){if(r0(!E$.isZero()),this.isZero())return{div:new $$(0),mod:new $$(0)};var f,D$,F0;return this.negative!==0&&E$.negative===0?(F0=this.neg().divmod(E$,T$),T$!=="mod"&&(f=F0.div.neg()),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.iadd(E$)),{div:f,mod:D$}):this.negative===0&&E$.negative!==0?(F0=this.divmod(E$.neg(),T$),T$!=="mod"&&(f=F0.div.neg()),{div:f,mod:F0.mod}):(this.negative&E$.negative)!==0?(F0=this.neg().divmod(E$.neg(),T$),T$!=="div"&&(D$=F0.mod.neg(),Y&&D$.negative!==0&&D$.isub(E$)),{div:F0.div,mod:D$}):E$.length>this.length||this.cmp(E$)<0?{div:new $$(0),mod:this}:E$.length===1?T$==="div"?{div:this.divn(E$.words[0]),mod:null}:T$==="mod"?{div:null,mod:new $$(this.modn(E$.words[0]))}:{div:this.divn(E$.words[0]),mod:new $$(this.modn(E$.words[0]))}:this._wordDiv(E$,T$)},$$.prototype.div=function(E$){return this.divmod(E$,"div",!1).div},$$.prototype.mod=function(E$){return this.divmod(E$,"mod",!1).mod},$$.prototype.umod=function(E$){return this.divmod(E$,"mod",!0).mod},$$.prototype.divRound=function(E$){var T$=this.divmod(E$);if(T$.mod.isZero())return T$.div;var Y=T$.div.negative!==0?T$.mod.isub(E$):T$.mod,f=E$.ushrn(1),D$=E$.andln(1),F0=Y.cmp(f);return F0<0||D$===1&&F0===0?T$.div:T$.div.negative!==0?T$.div.isubn(1):T$.div.iaddn(1)},$$.prototype.modn=function(E$){r0(E$<=67108863);for(var T$=(1<<26)%E$,Y=0,f=this.length-1;f>=0;f--)Y=(T$*Y+(this.words[f]|0))%E$;return Y},$$.prototype.idivn=function(E$){r0(E$<=67108863);for(var T$=0,Y=this.length-1;Y>=0;Y--){var f=(this.words[Y]|0)+T$*67108864;this.words[Y]=f/E$|0,T$=f%E$}return this.strip()},$$.prototype.divn=function(E$){return this.clone().idivn(E$)},$$.prototype.egcd=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=new $$(0),C$=new $$(1),L$=0;T$.isEven()&&Y.isEven();)T$.iushrn(1),Y.iushrn(1),++L$;for(var R$=Y.clone(),P$=T$.clone();!T$.isZero();){for(var z$=0,M$=1;(T$.words[0]&M$)===0&&z$<26;++z$,M$<<=1);if(z$>0)for(T$.iushrn(z$);z$-- >0;)(f.isOdd()||D$.isOdd())&&(f.iadd(R$),D$.isub(P$)),f.iushrn(1),D$.iushrn(1);for(var S$=0,Z=1;(Y.words[0]&Z)===0&&S$<26;++S$,Z<<=1);if(S$>0)for(Y.iushrn(S$);S$-- >0;)(F0.isOdd()||C$.isOdd())&&(F0.iadd(R$),C$.isub(P$)),F0.iushrn(1),C$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(F0),D$.isub(C$)):(Y.isub(T$),F0.isub(f),C$.isub(D$))}return{a:F0,b:C$,gcd:Y.iushln(L$)}},$$.prototype._invmp=function(E$){r0(E$.negative===0),r0(!E$.isZero());var T$=this,Y=E$.clone();T$.negative!==0?T$=T$.umod(E$):T$=T$.clone();for(var f=new $$(1),D$=new $$(0),F0=Y.clone();T$.cmpn(1)>0&&Y.cmpn(1)>0;){for(var C$=0,L$=1;(T$.words[0]&L$)===0&&C$<26;++C$,L$<<=1);if(C$>0)for(T$.iushrn(C$);C$-- >0;)f.isOdd()&&f.iadd(F0),f.iushrn(1);for(var R$=0,P$=1;(Y.words[0]&P$)===0&&R$<26;++R$,P$<<=1);if(R$>0)for(Y.iushrn(R$);R$-- >0;)D$.isOdd()&&D$.iadd(F0),D$.iushrn(1);T$.cmp(Y)>=0?(T$.isub(Y),f.isub(D$)):(Y.isub(T$),D$.isub(f))}var z$;return T$.cmpn(1)===0?z$=f:z$=D$,z$.cmpn(0)<0&&z$.iadd(E$),z$},$$.prototype.gcd=function(E$){if(this.isZero())return E$.abs();if(E$.isZero())return this.abs();var T$=this.clone(),Y=E$.clone();T$.negative=0,Y.negative=0;for(var f=0;T$.isEven()&&Y.isEven();f++)T$.iushrn(1),Y.iushrn(1);do{for(;T$.isEven();)T$.iushrn(1);for(;Y.isEven();)Y.iushrn(1);var D$=T$.cmp(Y);if(D$<0){var F0=T$;T$=Y,Y=F0}else if(D$===0||Y.cmpn(1)===0)break;T$.isub(Y)}while(!0);return Y.iushln(f)},$$.prototype.invm=function(E$){return this.egcd(E$).a.umod(E$)},$$.prototype.isEven=function(){return(this.words[0]&1)===0},$$.prototype.isOdd=function(){return(this.words[0]&1)===1},$$.prototype.andln=function(E$){return this.words[0]&E$},$$.prototype.bincn=function(E$){r0(typeof E$=="number");var T$=E$%26,Y=(E$-T$)/26,f=1<>>26,C$&=67108863,this.words[F0]=C$}return D$!==0&&(this.words[F0]=D$,this.length++),this},$$.prototype.isZero=function(){return this.length===1&&this.words[0]===0},$$.prototype.cmpn=function(E$){var T$=E$<0;if(this.negative!==0&&!T$)return-1;if(this.negative===0&&T$)return 1;this.strip();var Y;if(this.length>1)Y=1;else{T$&&(E$=-E$),r0(E$<=67108863,"Number is too big");var f=this.words[0]|0;Y=f===E$?0:fE$.length)return 1;if(this.length=0;Y--){var f=this.words[Y]|0,D$=E$.words[Y]|0;if(f!==D$){fD$&&(T$=1);break}}return T$},$$.prototype.gtn=function(E$){return this.cmpn(E$)===1},$$.prototype.gt=function(E$){return this.cmp(E$)===1},$$.prototype.gten=function(E$){return this.cmpn(E$)>=0},$$.prototype.gte=function(E$){return this.cmp(E$)>=0},$$.prototype.ltn=function(E$){return this.cmpn(E$)===-1},$$.prototype.lt=function(E$){return this.cmp(E$)===-1},$$.prototype.lten=function(E$){return this.cmpn(E$)<=0},$$.prototype.lte=function(E$){return this.cmp(E$)<=0},$$.prototype.eqn=function(E$){return this.cmpn(E$)===0},$$.prototype.eq=function(E$){return this.cmp(E$)===0},$$.red=function(E$){return new H$(E$)},$$.prototype.toRed=function(E$){return r0(!this.red,"Already a number in reduction context"),r0(this.negative===0,"red works only with positives"),E$.convertTo(this)._forceRed(E$)},$$.prototype.fromRed=function(){return r0(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},$$.prototype._forceRed=function(E$){return this.red=E$,this},$$.prototype.forceRed=function(E$){return r0(!this.red,"Already a number in reduction context"),this._forceRed(E$)},$$.prototype.redAdd=function(E$){return r0(this.red,"redAdd works only with red numbers"),this.red.add(this,E$)},$$.prototype.redIAdd=function(E$){return r0(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,E$)},$$.prototype.redSub=function(E$){return r0(this.red,"redSub works only with red numbers"),this.red.sub(this,E$)},$$.prototype.redISub=function(E$){return r0(this.red,"redISub works only with red numbers"),this.red.isub(this,E$)},$$.prototype.redShl=function(E$){return r0(this.red,"redShl works only with red numbers"),this.red.shl(this,E$)},$$.prototype.redMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.mul(this,E$)},$$.prototype.redIMul=function(E$){return r0(this.red,"redMul works only with red numbers"),this.red._verify2(this,E$),this.red.imul(this,E$)},$$.prototype.redSqr=function(){return r0(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},$$.prototype.redISqr=function(){return r0(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},$$.prototype.redSqrt=function(){return r0(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},$$.prototype.redInvm=function(){return r0(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},$$.prototype.redNeg=function(){return r0(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},$$.prototype.redPow=function(E$){return r0(this.red&&!E$.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,E$)};var x={k256:null,p224:null,p192:null,p25519:null};function O$(E$,T$){this.name=E$,this.p=new $$(T$,16),this.n=this.p.bitLength(),this.k=new $$(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}O$.prototype._tmp=function(){var E$=new $$(null);return E$.words=new Array(Math.ceil(this.n/13)),E$},O$.prototype.ireduce=function(E$){var T$=E$,Y;do this.split(T$,this.tmp),T$=this.imulK(T$),T$=T$.iadd(this.tmp),Y=T$.bitLength();while(Y>this.n);var f=Y0?T$.isub(this.p):T$.strip!==void 0?T$.strip():T$._strip(),T$},O$.prototype.split=function(E$,T$){E$.iushrn(this.n,0,T$)},O$.prototype.imulK=function(E$){return E$.imul(this.k)};function J0(){O$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i0(J0,O$),J0.prototype.split=function(E$,T$){for(var Y=4194303,f=Math.min(E$.length,9),D$=0;D$>>22,F0=C$}F0>>>=22,E$.words[D$-10]=F0,F0===0&&E$.length>10?E$.length-=10:E$.length-=9},J0.prototype.imulK=function(E$){E$.words[E$.length]=0,E$.words[E$.length+1]=0,E$.length+=2;for(var T$=0,Y=0;Y>>=26,E$.words[Y]=D$,T$=f}return T$!==0&&(E$.words[E$.length++]=T$),E$},$$._prime=function(E$){if(x[E$])return x[E$];var T$;if(E$==="k256")T$=new J0;else if(E$==="p224")T$=new J$;else if(E$==="p192")T$=new F$;else if(E$==="p25519")T$=new A$;else throw new Error("Unknown prime "+E$);return x[E$]=T$,T$};function H$(E$){if(typeof E$=="string"){var T$=$$._prime(E$);this.m=T$.p,this.prime=T$}else r0(E$.gtn(1),"modulus must be greater than 1"),this.m=E$,this.prime=null}H$.prototype._verify1=function(E$){r0(E$.negative===0,"red works only with positives"),r0(E$.red,"red works only with red numbers")},H$.prototype._verify2=function(E$,T$){r0((E$.negative|T$.negative)===0,"red works only with positives"),r0(E$.red&&E$.red===T$.red,"red works only with red numbers")},H$.prototype.imod=function(E$){return this.prime?this.prime.ireduce(E$)._forceRed(this):E$.umod(this.m)._forceRed(this)},H$.prototype.neg=function(E$){return E$.isZero()?E$.clone():this.m.sub(E$)._forceRed(this)},H$.prototype.add=function(E$,T$){this._verify2(E$,T$);var Y=E$.add(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y._forceRed(this)},H$.prototype.iadd=function(E$,T$){this._verify2(E$,T$);var Y=E$.iadd(T$);return Y.cmp(this.m)>=0&&Y.isub(this.m),Y},H$.prototype.sub=function(E$,T$){this._verify2(E$,T$);var Y=E$.sub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y._forceRed(this)},H$.prototype.isub=function(E$,T$){this._verify2(E$,T$);var Y=E$.isub(T$);return Y.cmpn(0)<0&&Y.iadd(this.m),Y},H$.prototype.shl=function(E$,T$){return this._verify1(E$),this.imod(E$.ushln(T$))},H$.prototype.imul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.imul(T$))},H$.prototype.mul=function(E$,T$){return this._verify2(E$,T$),this.imod(E$.mul(T$))},H$.prototype.isqr=function(E$){return this.imul(E$,E$.clone())},H$.prototype.sqr=function(E$){return this.mul(E$,E$)},H$.prototype.sqrt=function(E$){if(E$.isZero())return E$.clone();var T$=this.m.andln(3);if(r0(T$%2===1),T$===3){var Y=this.m.add(new $$(1)).iushrn(2);return this.pow(E$,Y)}for(var f=this.m.subn(1),D$=0;!f.isZero()&&f.andln(1)===0;)D$++,f.iushrn(1);r0(!f.isZero());var F0=new $$(1).toRed(this),C$=F0.redNeg(),L$=this.m.subn(1).iushrn(1),R$=this.m.bitLength();for(R$=new $$(2*R$*R$).toRed(this);this.pow(R$,L$).cmp(C$)!==0;)R$.redIAdd(C$);for(var P$=this.pow(R$,f),z$=this.pow(E$,f.addn(1).iushrn(1)),M$=this.pow(E$,f),S$=D$;M$.cmp(F0)!==0;){for(var Z=M$,c=0;Z.cmp(F0)!==0;c++)Z=Z.redSqr();r0(c=0;D$--){for(var P$=T$.words[D$],z$=R$-1;z$>=0;z$--){var M$=P$>>z$&1;if(F0!==f[0]&&(F0=this.sqr(F0)),M$===0&&C$===0){L$=0;continue}C$<<=1,C$|=M$,L$++,!(L$!==Y&&(D$!==0||z$!==0))&&(F0=this.mul(F0,f[C$]),L$=0,C$=0)}R$=26}return F0},H$.prototype.convertTo=function(E$){var T$=E$.umod(this.m);return T$===E$?T$.clone():T$},H$.prototype.convertFrom=function(E$){var T$=E$.clone();return T$.red=null,T$},$$.mont=function(E$){return new W$(E$)};function W$(E$){H$.call(this,E$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new $$(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)}i0(W$,H$),W$.prototype.convertTo=function(E$){return this.imod(E$.ushln(this.shift))},W$.prototype.convertFrom=function(E$){var T$=this.imod(E$.mul(this.rinv));return T$.red=null,T$},W$.prototype.imul=function(E$,T$){if(E$.isZero()||T$.isZero())return E$.words[0]=0,E$.length=1,E$;var Y=E$.imul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.mul=function(E$,T$){if(E$.isZero()||T$.isZero())return new $$(0)._forceRed(this);var Y=E$.mul(T$),f=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),D$=Y.isub(f).iushrn(this.shift),F0=D$;return D$.cmp(this.m)>=0?F0=D$.isub(this.m):D$.cmpn(0)<0&&(F0=D$.iadd(this.m)),F0._forceRed(this)},W$.prototype.invm=function(E$){var T$=this.imod(E$._invmp(this.m).mul(this.r2));return T$._forceRed(this)}})(typeof m0>"u"||m0,t0)}}),{CryptoHasher:AZ}=globalThis.Bun,b0=pQ({"node_modules/public-encrypt/withPublic.js"(t0,m0){var a0=$0(),e0=cQ().Buffer;function r0(i0,$$){return e0.from(i0.toRed(a0.mont($$.modulus)).redPow(new a0($$.publicExponent)).fromRed().toArray())}m0.exports=r0}}),HZ=pQ({"node_modules/public-encrypt/publicEncrypt.js"(t0,m0){var a0=d0(),e0=hQ(),r0=w(),i0=FZ(),$$=z(),Q$=$0(),$=b0(),N=qY(),Y$=cQ().Buffer;m0.exports=function(V$,U$,X$){var K$;V$.padding?K$=V$.padding:X$?K$=1:K$=4;var I$=a0(V$),Q;if(K$===4)Q=O0(I$,U$);else if(K$===1)Q=Z$(I$,U$,X$);else if(K$===3){if(Q=new Q$(U$),Q.cmp(I$.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return X$?N(Q,I$):$(Q,I$)};function O0(V$,U$){var X$=V$.modulus.byteLength(),K$=U$.length,I$=r0("sha1").update(Y$.alloc(0)).digest(),Q=I$.length,x=2*Q;if(K$>X$-x-2)throw new Error("message too long");var O$=Y$.alloc(X$-K$-x-2),J0=X$-Q-1,J$=e0(Q),F$=$$(Y$.concat([I$,O$,Y$.alloc(1,1),U$],J0),i0(J$,J0)),A$=$$(J$,i0(F$,Q));return new Q$(Y$.concat([Y$.alloc(1),A$,F$],X$))}function Z$(V$,U$,X$){var K$=U$.length,I$=V$.modulus.byteLength();if(K$>I$-11)throw new Error("message too long");var Q;return X$?Q=Y$.alloc(I$-K$-3,255):Q=G$(I$-K$-3),new Q$(Y$.concat([Y$.from([0,X$?1:2]),Q,Y$.alloc(1),U$],I$))}function G$(V$){for(var U$=Y$.allocUnsafe(V$),X$=0,K$=e0(V$*2),I$=0,Q;X$I$||new i0(V$).cmp(K$.modulus)>=0)throw new Error("decryption error");var Q;U$?Q=$(new i0(V$),K$):Q=$$(V$,K$);var x=N.alloc(I$-Q.length);if(Q=N.concat([x,Q],I$),X$===4)return Y$(K$,Q);if(X$===1)return O0(K$,Q,U$);if(X$===3)return Q;throw new Error("unknown padding")};function Y$(G$,V$){var U$=G$.modulus.byteLength(),X$=Q$("sha1").update(N.alloc(0)).digest(),K$=X$.length;if(V$[0]!==0)throw new Error("decryption error");var I$=V$.slice(1,K$+1),Q=V$.slice(K$+1),x=r0(I$,e0(Q,K$)),O$=r0(Q,e0(x,U$-K$-1));if(Z$(X$,O$.slice(0,K$)))throw new Error("decryption error");for(var J0=K$;O$[J0]===0;)J0++;if(O$[J0++]!==1)throw new Error("decryption error");return O$.slice(J0)}function O0(G$,V$,U$){for(var X$=V$.slice(0,2),K$=2,I$=0;V$[K$++]!==0;)if(K$>=V$.length){I$++;break}var Q=V$.slice(2,K$-1);if((X$.toString("hex")!=="0002"&&!U$||X$.toString("hex")!=="0001"&&U$)&&I$++,Q.length<8&&I$++,I$)throw new Error("decryption error");return V$.slice(K$)}function Z$(G$,V$){G$=N.from(G$),V$=N.from(V$);var U$=0,X$=G$.length;G$.length!==V$.length&&(U$++,X$=Math.min(G$.length,V$.length));for(var K$=-1;++K$i0||O0<0)throw new TypeError("offset must be a uint32");if(O0>r0||O0>Z$)throw new RangeError("offset out of range")}function Q$(O0,Z$,G$){if(typeof O0!="number"||O0!==O0)throw new TypeError("size must be a number");if(O0>i0||O0<0)throw new TypeError("size must be a uint32");if(O0+Z$>G$||O0>r0)throw new RangeError("buffer too small")}t0.randomFill=$,t0.randomFillSync=Y$;function $(O0,Z$,G$,V$){if(!e0.isBuffer(O0)&&!(O0 instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof Z$=="function")V$=Z$,Z$=0,G$=O0.length;else if(typeof G$=="function")V$=G$,G$=O0.length-Z$;else if(typeof V$!="function")throw new TypeError('"cb" argument must be a function');return $$(Z$,O0.length),Q$(G$,Z$,O0.length),N(O0,Z$,G$,V$)}function N(O0,Z$,G$,V$){if(V$){a0(G$,function(X$,K$){if(X$)return V$(X$);K$.copy(O0,Z$),V$(null,O0)});return}var U$=a0(G$);return U$.copy(O0,Z$),O0}function Y$(O0,Z$,G$){if(typeof Z$>"u"&&(Z$=0),!e0.isBuffer(O0)&&!(O0 instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return $$(Z$,O0.length),G$===void 0&&(G$=O0.length-Z$),Q$(G$,Z$,O0.length),N(O0,Z$,G$)}}}),DZ=pQ({"node_modules/crypto-browserify/index.js"(t0){t0.randomBytes=t0.rng=t0.pseudoRandomBytes=t0.prng=hQ(),t0.createHash=w(),t0.Hash=t0.createHash.Hash,t0.createHmac=t0.Hmac=aQ();var m0=rQ(),a0=Object.keys(m0),e0=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(a0);t0.getHashes=function(){return e0};var r0=u();t0.pbkdf2=r0.pbkdf2,t0.pbkdf2Sync=r0.pbkdf2Sync;var i0=LY();t0.Cipher=i0.Cipher,t0.createCipher=i0.createCipher,t0.Cipheriv=i0.Cipheriv,t0.createCipheriv=i0.createCipheriv,t0.Decipher=i0.Decipher,t0.createDecipher=i0.createDecipher,t0.Decipheriv=i0.Decipheriv,t0.createDecipheriv=i0.createDecipheriv,t0.getCiphers=i0.getCiphers,t0.listCiphers=i0.listCiphers;var $$=SY();t0.DiffieHellmanGroup=$$.DiffieHellmanGroup,t0.createDiffieHellmanGroup=$$.createDiffieHellmanGroup,t0.getDiffieHellman=$$.getDiffieHellman,t0.createDiffieHellman=$$.createDiffieHellman,t0.DiffieHellman=$$.DiffieHellman;var Q$=IZ();t0.createSign=Q$.createSign,t0.Sign=Q$.Sign,t0.createVerify=Q$.createVerify,t0.Verify=Q$.Verify,t0.createECDH=JZ();var $=EZ();t0.publicEncrypt=$.publicEncrypt,t0.privateEncrypt=$.privateEncrypt,t0.publicDecrypt=$.publicDecrypt,t0.privateDecrypt=$.privateDecrypt,t0.getRandomValues=(Y$)=>qQ.getRandomValues(Y$);var N=TZ();t0.randomFill=N.randomFill,t0.randomFillSync=N.randomFillSync,t0.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(` +`))},t0.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}}}),CZ={...DZ(),[Symbol.for("CommonJS")]:0},gQ="buffer",LZ=(t0)=>qQ.getRandomValues(t0),M=()=>qQ.randomUUID(),p=(...t0)=>qQ.randomInt(...t0),_Q="timingSafeEqual"in qQ?(t0,m0)=>{let{byteLength:a0}=t0,{byteLength:e0}=m0;if(typeof a0!="number"||typeof e0!="number")throw new TypeError("Input must be an array buffer view");if(a0!==e0)throw new RangeError("Input buffers must have the same length");return qQ.timingSafeEqual(t0,m0)}:void 0,U0="scryptSync"in qQ?(t0,m0,a0,e0)=>{let r0=qQ.scryptSync(t0,m0,a0,e0);return gQ!=="buffer"?new G0(r0).toString(gQ):new G0(r0)}:void 0,X0="scryptSync"in qQ?function(t0,m0,a0,e0,r0){if(typeof e0=="function"&&(r0=e0,e0=void 0),typeof r0!="function"){var i0=new TypeError("callback must be a function");throw i0.code="ERR_INVALID_CALLBACK",i0}try{let $$=qQ.scryptSync(t0,m0,a0,e0);process.nextTick(r0,null,gQ!=="buffer"?new G0($$).toString(gQ):new G0($$))}catch($$){throw $$}}:void 0;_Q&&(Object.defineProperty(_Q,"name",{value:"::bunternal::"}),Object.defineProperty(X0,"name",{value:"::bunternal::"}),Object.defineProperty(U0,"name",{value:"::bunternal::"}));var RZ=["p192","p224","p256","p384","p521","curve25519","ed25519","secp256k1","secp224r1","prime256v1","prime192v1","ed25519","secp384r1","secp521r1"],NQ=qQ;fQ(CZ,{DEFAULT_ENCODING:()=>gQ,getRandomValues:()=>LZ,randomUUID:()=>M,randomInt:()=>p,getCurves:()=>PZ,scrypt:()=>X0,scryptSync:()=>U0,timingSafeEqual:()=>_Q,webcrypto:()=>NQ,subtle:()=>NQ.subtle});var{randomBytes:zZ,rng:MZ,pseudoRandomBytes:SZ,prng:vZ,Hash:qZ,createHash:S,createHmac:k,Hmac:s0,getHashes:l0,pbkdf2:jZ,pbkdf2Sync:kZ,Cipher:gZ,createCipher:_Z,Cipheriv:NZ,createCipheriv:xZ,Decipher:BZ,createDecipher:v,Decipheriv:Q0,createDecipheriv:o0,getCiphers:u0,listCiphers:yZ,DiffieHellmanGroup:wZ,createDiffieHellmanGroup:pZ,getDiffieHellman:fZ,createDiffieHellman:cZ,DiffieHellman:hZ,createSign:dZ,Sign:q,createVerify:Y0,Verify:K0,createECDH:n0,publicEncrypt:bZ,privateEncrypt:lZ,publicDecrypt:oZ,privateDecrypt:uZ,randomFill:nZ,randomFillSync:sZ,createCredentials:tZ,constants:j}=CZ;var I0=CZ;/*! safe-buffer. MIT License. Feross Aboukhadijeh */export{NQ as webcrypto,_Q as timingSafeEqual,U0 as scryptSync,X0 as scrypt,MZ as rng,M as randomUUID,p as randomInt,sZ as randomFillSync,nZ as randomFill,zZ as randomBytes,bZ as publicEncrypt,oZ as publicDecrypt,SZ as pseudoRandomBytes,vZ as prng,lZ as privateEncrypt,uZ as privateDecrypt,kZ as pbkdf2Sync,jZ as pbkdf2,yZ as listCiphers,LZ as getRandomValues,l0 as getHashes,fZ as getDiffieHellman,PZ as getCurves,u0 as getCiphers,I0 as default,Y0 as createVerify,dZ as createSign,k as createHmac,S as createHash,n0 as createECDH,pZ as createDiffieHellmanGroup,cZ as createDiffieHellman,o0 as createDecipheriv,v as createDecipher,tZ as createCredentials,xZ as createCipheriv,_Z as createCipher,j as constants,K0 as Verify,q as Sign,s0 as Hmac,qZ as Hash,wZ as DiffieHellmanGroup,hZ as DiffieHellman,Q0 as Decipheriv,BZ as Decipher,gQ as DEFAULT_ENCODING,NZ as Cipheriv,gZ as Cipher}; diff --git a/src/node-fallbacks/crypto.js b/src/node-fallbacks/crypto.js index 7745530da..65ae2f5b3 100644 --- a/src/node-fallbacks/crypto.js +++ b/src/node-fallbacks/crypto.js @@ -12,6 +12,27 @@ export const randomUUID = () => { return crypto.randomUUID(); }; +const harcoded_curves = [ + "p192", + "p224", + "p256", + "p384", + "p521", + "curve25519", + "ed25519", + "secp256k1", + "secp224r1", + "prime256v1", + "prime192v1", + "ed25519", + "secp384r1", + "secp521r1", +]; + +export function getCurves() { + return harcoded_curves; +} + export const timingSafeEqual = "timingSafeEqual" in crypto ? (a, b) => { @@ -89,4 +110,5 @@ export default { scryptSync, scrypt, webcrypto, + getCurves, }; diff --git a/test/js/node/crypto/crypto.test.ts b/test/js/node/crypto/crypto.test.ts index d8bfe5353..b1b8646f3 100644 --- a/test/js/node/crypto/crypto.test.ts +++ b/test/js/node/crypto/crypto.test.ts @@ -1,6 +1,6 @@ import { sha, MD5, MD4, SHA1, SHA224, SHA256, SHA384, SHA512, SHA512_256, gc, CryptoHasher } from "bun"; import { it, expect, describe } from "bun:test"; - +import crypto from "crypto"; const HashClasses = [MD5, MD4, SHA1, SHA224, SHA256, SHA384, SHA512, SHA512_256]; describe("CryptoHasher", () => { @@ -109,6 +109,13 @@ describe("CryptoHasher", () => { } }); +describe("crypto.getCurves", () => { + it("should return an array of strings", () => { + expect(Array.isArray(crypto.getCurves())).toBe(true); + expect(typeof crypto.getCurves()[0]).toBe("string"); + }); +}); + describe("crypto", () => { for (let Hash of HashClasses) { for (let [input, label] of [ -- cgit v1.2.3 From b2c576bba2c3274eac32cd0a70318339c3683425 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Mon, 10 Jul 2023 18:25:20 -0700 Subject: fix "readable" event being emitted incorrectly (#3475) * fix "readable" event being emitted incorrectly * fix impl and add test * changes * asdfghj * esm --- src/bun.js/bindings/JSReadableHelper.h | 1 - src/js/node/stream.js | 12 +- src/js/out/WebCoreJSBuiltins.cpp | 300 ++++++++++++++++----------------- src/js/out/modules/node/stream.js | 4 +- test/js/node/fs/fs.test.ts | 23 +++ 5 files changed, 182 insertions(+), 158 deletions(-) diff --git a/src/bun.js/bindings/JSReadableHelper.h b/src/bun.js/bindings/JSReadableHelper.h index 6746bcbec..3e2554c2b 100644 --- a/src/bun.js/bindings/JSReadableHelper.h +++ b/src/bun.js/bindings/JSReadableHelper.h @@ -8,7 +8,6 @@ JSC_DECLARE_HOST_FUNCTION(jsReadable_maybeReadMore); JSC_DECLARE_HOST_FUNCTION(jsReadable_resume); JSC_DECLARE_HOST_FUNCTION(jsReadable_emitReadable); JSC_DECLARE_HOST_FUNCTION(jsReadable_onEofChunk); -JSC_DECLARE_HOST_FUNCTION(jsReadable_resume_); JSC_DECLARE_HOST_FUNCTION(jsReadable_emitReadable_); } // namespace WebCore diff --git a/src/js/node/stream.js b/src/js/node/stream.js index 741b2f65c..30c76d797 100644 --- a/src/js/node/stream.js +++ b/src/js/node/stream.js @@ -5356,10 +5356,10 @@ function createNativeStreamReadable(nativeType, Readable) { return chunk; } - push(result, encoding) { - __DEBUG__ && debug("NativeReadable push -- result, encoding", result, encoding, this.__id); - return super.push(...arguments); - } + // push(result, encoding) { + // __DEBUG__ && debug("NativeReadable push -- result, encoding", result, encoding, this.__id); + // return super.push(...arguments); + // } #handleResult(result, view, isClosed) { __DEBUG__ && debug("result, isClosed @ #handleResult", result, isClosed, this.__id); @@ -5372,7 +5372,9 @@ function createNativeStreamReadable(nativeType, Readable) { return handleNumberResult(this, result, view, isClosed); } else if (typeof result === "boolean") { - this.push(null); + process.nextTick(() => { + this.push(null); + }); return view?.byteLength ?? 0 > 0 ? view : undefined; } else if (ArrayBuffer.isView(result)) { if (result.byteLength >= this.#highWaterMark && !this.#hasResized && !isClosed) { diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index f20f626d4..fb3100762 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -16,7 +16,7 @@ const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunSetupFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunSetupFunctionCodeLength = 2165; static const JSC::Intrinsic s_bundlerPluginRunSetupFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunSetupFunctionCode = "(function (J,_){\"use strict\";var D=new Map,F=new Map;function H(q,h,E){if(!q||!@isObject(q))@throwTypeError('Expected an object with \"filter\" RegExp');if(!h||!@isCallable(h))@throwTypeError(\"callback must be a function\");var{filter:w,namespace:z=\"file\"}=q;if(!w)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(w))@throwTypeError(\"filter must be a RegExp\");if(z&&typeof z!==\"string\")@throwTypeError(\"namespace must be a string\");if((z\?.length\?\?0)===0)z=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(z))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var A=E.@get(z);if(!A)E.@set(z,[[w,h]]);else @arrayPush(A,[w,h])}function K(q,h){H(q,h,D)}function M(q,h){H(q,h,F)}const I=()=>{var q=!1,h=!1;for(var[E,w]of D.entries())for(var[z]of w)this.addFilter(z,E,1),q=!0;for(var[E,w]of F.entries())for(var[z]of w)this.addFilter(z,E,0),h=!0;if(h){var A=this.onResolve;if(!A)this.onResolve=F;else for(var[E,w]of F.entries()){var C=A.@get(E);if(!C)A.@set(E,w);else A.@set(E,C.concat(w))}}if(q){var G=this.onLoad;if(!G)this.onLoad=D;else for(var[E,w]of D.entries()){var C=G.@get(E);if(!C)G.@set(E,w);else G.@set(E,C.concat(w))}}return q||h};var B=J({config:_,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:K,onResolve:M,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{..._,bundle:!0,entryPoints:_.entrypoints\?\?_.entryPoints\?\?[],minify:typeof _.minify===\"boolean\"\?_.minify:!1,minifyIdentifiers:_.minify===!0||_.minify\?.identifiers,minifyWhitespace:_.minify===!0||_.minify\?.whitespace,minifySyntax:_.minify===!0||_.minify\?.syntax,outbase:_.root,platform:_.target===\"bun\"\?\"node\":_.target},esbuild:{}});if(B&&@isPromise(B))if(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);else return B.@then(I);return I()})\n"; +const char* const s_bundlerPluginRunSetupFunctionCode = "(function (_,E){\"use strict\";var w=new Map,h=new Map;function q(D,F,G){if(!D||!@isObject(D))@throwTypeError('Expected an object with \"filter\" RegExp');if(!F||!@isCallable(F))@throwTypeError(\"callback must be a function\");var{filter:H,namespace:I=\"file\"}=D;if(!H)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(H))@throwTypeError(\"filter must be a RegExp\");if(I&&typeof I!==\"string\")@throwTypeError(\"namespace must be a string\");if((I\?.length\?\?0)===0)I=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(I))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var J=G.@get(I);if(!J)G.@set(I,[[H,F]]);else @arrayPush(J,[H,F])}function z(D,F){q(D,F,w)}function A(D,F){q(D,F,h)}const B=()=>{var D=!1,F=!1;for(var[G,H]of w.entries())for(var[I]of H)this.addFilter(I,G,1),D=!0;for(var[G,H]of h.entries())for(var[I]of H)this.addFilter(I,G,0),F=!0;if(F){var J=this.onResolve;if(!J)this.onResolve=h;else for(var[G,H]of h.entries()){var K=J.@get(G);if(!K)J.@set(G,H);else J.@set(G,K.concat(H))}}if(D){var M=this.onLoad;if(!M)this.onLoad=w;else for(var[G,H]of w.entries()){var K=M.@get(G);if(!K)M.@set(G,H);else M.@set(G,K.concat(H))}}return D||F};var C=_({config:E,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:z,onResolve:A,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{...E,bundle:!0,entryPoints:E.entrypoints\?\?E.entryPoints\?\?[],minify:typeof E.minify===\"boolean\"\?E.minify:!1,minifyIdentifiers:E.minify===!0||E.minify\?.identifiers,minifyWhitespace:E.minify===!0||E.minify\?.whitespace,minifySyntax:E.minify===!0||E.minify\?.syntax,outbase:E.root,platform:E.target===\"bun\"\?\"node\":E.target},esbuild:{}});if(C&&@isPromise(C))if(@getPromiseInternalField(C,@promiseFieldFlags)&@promiseStateFulfilled)C=@getPromiseInternalField(C,@promiseFieldReactionsOrResult);else return C.@then(B);return B()})\n"; // runOnResolvePlugins const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -24,7 +24,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnResolvePluginsCodeLength = 1711; static const JSC::Intrinsic s_bundlerPluginRunOnResolvePluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (C,E,F,b,G){\"use strict\";const H=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][G];var g=(async(j,q,J,K)=>{var{onResolve:M,onLoad:A}=this,B=M.@get(q);if(!B)return this.onResolveAsync(b,null,null,null),null;for(let[O,Q]of B)if(O.test(j)){var _=Q({path:j,importer:J,namespace:q,kind:K});while(_&&@isPromise(_)&&(@getPromiseInternalField(_,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)_=@getPromiseInternalField(_,@promiseFieldReactionsOrResult);if(_&&@isPromise(_))_=await _;if(!_||!@isObject(_))continue;var{path:y,namespace:w=q,external:z}=_;if(typeof y!==\"string\"||typeof w!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!y)continue;if(!w)w=q;if(typeof z!==\"boolean\"&&!@isUndefinedOrNull(z))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!z){if(w===\"file\"){if(darwin!==\"win32\"){if(y[0]!==\"/\"||y.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(w===\"dataurl\"){if(!y.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(w&&w!==\"file\"&&(!A||!A.@has(w)))@throwTypeError(`Expected onLoad plugin for namespace ${w} to exist`)}return this.onResolveAsync(b,y,w,z),null}return this.onResolveAsync(b,null,null,null),null})(C,E,F,H);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(b,j,0)})})\n"; +const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (_,w,g,y,b){\"use strict\";const j=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][b];var q=(async(z,A,B,C)=>{var{onResolve:E,onLoad:F}=this,G=E.@get(A);if(!G)return this.onResolveAsync(y,null,null,null),null;for(let[O,Q]of G)if(O.test(z)){var H=Q({path:z,importer:B,namespace:A,kind:C});while(H&&@isPromise(H)&&(@getPromiseInternalField(H,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)H=@getPromiseInternalField(H,@promiseFieldReactionsOrResult);if(H&&@isPromise(H))H=await H;if(!H||!@isObject(H))continue;var{path:J,namespace:K=A,external:M}=H;if(typeof J!==\"string\"||typeof K!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!J)continue;if(!K)K=A;if(typeof M!==\"boolean\"&&!@isUndefinedOrNull(M))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!M){if(K===\"file\"){if(darwin!==\"win32\"){if(J[0]!==\"/\"||J.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(K===\"dataurl\"){if(!J.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(K&&K!==\"file\"&&(!F||!F.@has(K)))@throwTypeError(`Expected onLoad plugin for namespace ${K} to exist`)}return this.onResolveAsync(y,J,K,M),null}return this.onResolveAsync(y,null,null,null),null})(_,w,g,j);while(q&&@isPromise(q)&&(@getPromiseInternalField(q,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)q=@getPromiseInternalField(q,@promiseFieldReactionsOrResult);if(q&&@isPromise(q))q.then(()=>{},(z)=>{this.addError(y,z,0)})})\n"; // runOnLoadPlugins const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (w,F,G,H){\"use strict\";const J={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},K=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][H];var g=(async(j,x,y,z)=>{var B=this.onLoad.@get(y);if(!B)return this.onLoadAsync(j,null,null),null;for(let[Q,T]of B)if(Q.test(x)){var b=T({path:x,namespace:y,loader:z});while(b&&@isPromise(b)&&(@getPromiseInternalField(b,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)b=@getPromiseInternalField(b,@promiseFieldReactionsOrResult);if(b&&@isPromise(b))b=await b;if(!b||!@isObject(b))continue;var{contents:q,loader:v=z}=b;if(typeof q!==\"string\"&&!@isTypedArrayView(q))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof v!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const C=J[v];if(C===@undefined)@throwTypeError(`Loader ${v} is not supported.`);return this.onLoadAsync(j,q,C),null}return this.onLoadAsync(j,null,null),null})(w,F,G,K);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(w,j,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,g,j,q){\"use strict\";const v={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},w=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][q];var x=(async(y,z,B,C)=>{var F=this.onLoad.@get(B);if(!F)return this.onLoadAsync(y,null,null),null;for(let[K,Q]of F)if(K.test(z)){var G=Q({path:z,namespace:B,loader:C});while(G&&@isPromise(G)&&(@getPromiseInternalField(G,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)G=@getPromiseInternalField(G,@promiseFieldReactionsOrResult);if(G&&@isPromise(G))G=await G;if(!G||!@isObject(G))continue;var{contents:H,loader:J=C}=G;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=v[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(y,H,T),null}return this.onLoadAsync(y,null,null),null})(b,g,j,w);while(x&&@isPromise(x)&&(@getPromiseInternalField(x,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)x=@getPromiseInternalField(x,@promiseFieldReactionsOrResult);if(x&&@isPromise(x))x.then(()=>{},(y)=>{this.addError(b,y,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -108,7 +108,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeCons const JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateWritableStreamCodeLength = 278; static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (p,N,_,f,u,j){\"use strict\";@assert(typeof u===\"number\"&&!@isNaN(u)&&u>=0);const d={};@initializeWritableStreamSlots(d,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(d,q,p,N,_,f,u,j),@createWritableStreamFromInternal(d)})\n"; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (u,N,d,f,p,_){\"use strict\";@assert(typeof p===\"number\"&&!@isNaN(p)&&p>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,N,d,f,p,_),@createWritableStreamFromInternal(j)})\n"; // createInternalWritableStreamFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -116,7 +116,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStream const JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 920; static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,w){\"use strict\";const C={};if(f===@undefined)f={};if(w===@undefined)w={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const E=@extractSizeAlgorithm(w),_=@extractHighWaterMark(w,1),o={};if(\"start\"in f){if(o.start=f.start,typeof o.start!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in f){if(o.write=f.write,typeof o.write!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in f){if(o.close=f.close,typeof o.close!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in f){if(o.abort=f.abort,typeof o.abort!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(C,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(C,f,o,_,E),C})\n"; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,o){\"use strict\";const w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\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 (g,n){\"use strict\";if(@isWritableStreamLocked(n))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(g,\"stream\",n),@putByIdDirectPrivate(n,\"writer\",g);const v=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(g,\"readyPromise\",v),@putByIdDirectPrivate(g,\"closedPromise\",h);const B=@getByIdDirectPrivate(n,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(n)||!@getByIdDirectPrivate(n,\"backpressure\"))v.@resolve.@call()}else if(B===\"erroring\")v.@reject.@call(@undefined,@getByIdDirectPrivate(n,\"storedError\")),@markPromiseAsHandled(v.@promise);else if(B===\"closed\")v.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(n,\"storedError\");v.@reject.@call(@undefined,_),@markPromiseAsHandled(v.@promise),h.@reject.@call(@undefined,_),@markPromiseAsHandled(h.@promise)}})\n"; +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"; // 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 (h,B){\"use strict\";const c=@getByIdDirectPrivate(h,\"state\");if(c===\"closed\"||c===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(h,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(c===\"writable\"||c===\"erroring\");let _=!1;if(c===\"erroring\")_=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(h,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:_}),!_)@writableStreamStartErroring(h,B);return j.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (c,h){\"use strict\";const B=@getByIdDirectPrivate(c,\"state\");if(B===\"closed\"||B===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(B===\"writable\"||B===\"erroring\");let _=!1;if(B===\"erroring\")_=!0,h=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:j,reason:h,wasAlreadyErroring:_}),!_)@writableStreamStartErroring(c,h);return j.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -196,7 +196,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithReject const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDealWithRejectionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength = 189; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDealWithRejectionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,c){\"use strict\";const n=@getByIdDirectPrivate(i,\"state\");if(n===\"writable\"){@writableStreamStartErroring(i,c);return}@assert(n===\"erroring\"),@writableStreamFinishErroring(i)})\n"; +const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,n){\"use strict\";const c=@getByIdDirectPrivate(i,\"state\");if(c===\"writable\"){@writableStreamStartErroring(i,n);return}@assert(c===\"erroring\"),@writableStreamFinishErroring(i)})\n"; // writableStreamFinishErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility = 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 (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const h=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(h,\"errorSteps\").@call();const A=@getByIdDirectPrivate(i,\"storedError\"),B=@getByIdDirectPrivate(i,\"writeRequests\");for(var p=B.shift();p;p=B.shift())p.@reject.@call(@undefined,A);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const _=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(_===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),_.wasAlreadyErroring){_.promise.@reject.@call(@undefined,A),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(h,\"abortSteps\").@call(@undefined,_.reason).@then(()=>{_.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(I)=>{_.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\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; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const i=@getByIdDirectPrivate(d,\"state\");if(@assert(i===\"writable\"||i===\"erroring\"),i===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const n=@getByIdDirectPrivate(d,\"writer\");if(n!==@undefined)@getByIdDirectPrivate(n,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -292,7 +292,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterA const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength = 130; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (d,f){\"use strict\";const c=@getByIdDirectPrivate(d,\"stream\");return @assert(c!==@undefined),@writableStreamAbort(c,f)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (c,d){\"use strict\";const f=@getByIdDirectPrivate(c,\"stream\");return @assert(f!==@undefined),@writableStreamAbort(f,d)})\n"; // writableStreamDefaultWriterClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -300,7 +300,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength = 126; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (c){\"use strict\";const _=@getByIdDirectPrivate(c,\"stream\");return @assert(_!==@undefined),@writableStreamClose(_)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");return @assert(c!==@undefined),@writableStreamClose(c)})\n"; // writableStreamDefaultWriterCloseWithErrorPropagation const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -308,7 +308,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength = 385; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (u){\"use strict\";const c=@getByIdDirectPrivate(u,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(@writableStreamCloseQueuedOrInFlight(c)||l===\"closed\")return @Promise.@resolve();if(l===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(c,\"storedError\"));return @assert(l===\"writable\"||l===\"erroring\"),@writableStreamDefaultWriterClose(u)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (c){\"use strict\";const l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const u=@getByIdDirectPrivate(l,\"state\");if(@writableStreamCloseQueuedOrInFlight(l)||u===\"closed\")return @Promise.@resolve();if(u===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(l,\"storedError\"));return @assert(u===\"writable\"||u===\"erroring\"),@writableStreamDefaultWriterClose(c)})\n"; // writableStreamDefaultWriterEnsureClosedPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -316,7 +316,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength = 329; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (h,u){\"use strict\";let _=@getByIdDirectPrivate(h,\"closedPromise\"),n=_.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)_=@newPromiseCapability(@Promise),n=_.@promise,@putByIdDirectPrivate(h,\"closedPromise\",_);_.@reject.@call(@undefined,u),@markPromiseAsHandled(n)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (_,n){\"use strict\";let h=@getByIdDirectPrivate(_,\"closedPromise\"),u=h.@promise;if((@getPromiseInternalField(u,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),u=h.@promise,@putByIdDirectPrivate(_,\"closedPromise\",h);h.@reject.@call(@undefined,n),@markPromiseAsHandled(u)})\n"; // writableStreamDefaultWriterEnsureReadyPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -324,7 +324,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 327; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (h,n){\"use strict\";let c=@getByIdDirectPrivate(h,\"readyPromise\"),g=c.@promise;if((@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)c=@newPromiseCapability(@Promise),g=c.@promise,@putByIdDirectPrivate(h,\"readyPromise\",c);c.@reject.@call(@undefined,n),@markPromiseAsHandled(g)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (c,g){\"use strict\";let h=@getByIdDirectPrivate(c,\"readyPromise\"),n=h.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),n=h.@promise,@putByIdDirectPrivate(c,\"readyPromise\",h);h.@reject.@call(@undefined,g),@markPromiseAsHandled(n)})\n"; // writableStreamDefaultWriterGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -332,7 +332,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterG const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength = 299; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(l===\"errored\"||l===\"erroring\")return null;if(l===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(c,\"controller\"))})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (c){\"use strict\";const l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const _=@getByIdDirectPrivate(l,\"state\");if(_===\"errored\"||_===\"erroring\")return null;if(_===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(l,\"controller\"))})\n"; // writableStreamDefaultWriterRelease const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -340,7 +340,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterR const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength = 414; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");@assert(c!==@undefined),@assert(@getByIdDirectPrivate(c,\"writer\")===_);const h=@makeTypeError(\"writableStreamDefaultWriterRelease\");@writableStreamDefaultWriterEnsureReadyPromiseRejected(_,h),@writableStreamDefaultWriterEnsureClosedPromiseRejected(_,h),@putByIdDirectPrivate(c,\"writer\",@undefined),@putByIdDirectPrivate(_,\"stream\",@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode = "(function (_){\"use strict\";const h=@getByIdDirectPrivate(_,\"stream\");@assert(h!==@undefined),@assert(@getByIdDirectPrivate(h,\"writer\")===_);const c=@makeTypeError(\"writableStreamDefaultWriterRelease\");@writableStreamDefaultWriterEnsureReadyPromiseRejected(_,c),@writableStreamDefaultWriterEnsureClosedPromiseRejected(_,c),@putByIdDirectPrivate(h,\"writer\",@undefined),@putByIdDirectPrivate(_,\"stream\",@undefined)})\n"; // writableStreamDefaultWriterWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructAbility = 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 (W,_){\"use strict\";const d=@getByIdDirectPrivate(W,\"stream\");@assert(d!==@undefined);const P=@getByIdDirectPrivate(d,\"controller\");@assert(P!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(P,_);if(d!==@getByIdDirectPrivate(W,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const g=@getByIdDirectPrivate(d,\"state\");if(g===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(g===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));@assert(g===\"writable\");const f=@writableStreamAddWriteRequest(d);return @writableStreamDefaultControllerWrite(P,_,b),f})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (d,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const W=@getByIdDirectPrivate(P,\"controller\");@assert(W!==@undefined);const _=@writableStreamDefaultControllerGetChunkSize(W,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const b=@getByIdDirectPrivate(P,\"state\");if(b===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(b===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(b===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(W,g,_),f})\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(B)),@assert(@getByIdDirectPrivate(B,\"controller\")===@undefined),@putByIdDirectPrivate(_,\"stream\",B),@putByIdDirectPrivate(B,\"controller\",_),@resetQueue(@getByIdDirectPrivate(_,\"queue\")),@putByIdDirectPrivate(_,\"started\",-1),@putByIdDirectPrivate(_,\"startAlgorithm\",v),@putByIdDirectPrivate(_,\"strategySizeAlgorithm\",j),@putByIdDirectPrivate(_,\"strategyHWM\",f),@putByIdDirectPrivate(_,\"writeAlgorithm\",P),@putByIdDirectPrivate(_,\"closeAlgorithm\",U),@putByIdDirectPrivate(_,\"abortAlgorithm\",d);const q=@writableStreamDefaultControllerGetBackpressure(_);@writableStreamUpdateBackpressure(B,q),@writableStreamDefaultControllerStart(_)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (_,B,d,v,f,P,j,U){\"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\",d),@putByIdDirectPrivate(B,\"strategySizeAlgorithm\",U),@putByIdDirectPrivate(B,\"strategyHWM\",j),@putByIdDirectPrivate(B,\"writeAlgorithm\",v),@putByIdDirectPrivate(B,\"closeAlgorithm\",f),@putByIdDirectPrivate(B,\"abortAlgorithm\",P);const q=@writableStreamDefaultControllerGetBackpressure(B);@writableStreamUpdateBackpressure(_,q),@writableStreamDefaultControllerStart(B)})\n"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -364,7 +364,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 647; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const p=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(p.@call()).@then(()=>{const _=@getByIdDirectPrivate(d,\"state\");@assert(_===\"writable\"||_===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(_)=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,_)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const _=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(_.@call()).@then(()=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(d,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,u)})})\n"; // setUpWritableStreamDefaultControllerFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,O,_,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let q=()=>{},v=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in _){const p=_.start;q=()=>@promiseInvokeOrNoopMethodNoCatch(O,p,[f])}if(\"write\"in _){const p=_.write;v=(j)=>@promiseInvokeOrNoopMethod(O,p,[j,f])}if(\"close\"in _){const p=_.close;x=()=>@promiseInvokeOrNoopMethod(O,p,[])}if(\"abort\"in _){const p=_.abort;B=(j)=>@promiseInvokeOrNoopMethod(O,p,[j])}@setUpWritableStreamDefaultController(C,f,q,v,x,B,E,F)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (_,j,v,p,f){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},O=()=>{return @Promise.@resolve()};if(\"start\"in v){const E=v.start;x=()=>@promiseInvokeOrNoopMethodNoCatch(j,E,[q])}if(\"write\"in v){const E=v.write;B=(F)=>@promiseInvokeOrNoopMethod(j,E,[F,q])}if(\"close\"in v){const E=v.close;C=()=>@promiseInvokeOrNoopMethod(j,E,[])}if(\"abort\"in v){const E=v.abort;O=(F)=>@promiseInvokeOrNoopMethod(j,E,[F])}@setUpWritableStreamDefaultController(_,q,x,B,C,O,p,f)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -412,7 +412,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength = 237; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (h,b){\"use strict\";const i=@getByIdDirectPrivate(h,\"stream\");@assert(i!==@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(h),@writableStreamStartErroring(i,b)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (i,h){\"use strict\";const b=@getByIdDirectPrivate(i,\"stream\");@assert(b!==@undefined),@assert(@getByIdDirectPrivate(b,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(i),@writableStreamStartErroring(b,h)})\n"; // writableStreamDefaultControllerErrorIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility = 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 (d,v){\"use strict\";const i=@getByIdDirectPrivate(d,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(i),@getByIdDirectPrivate(d,\"writeAlgorithm\").@call(@undefined,v).@then(()=>{@writableStreamFinishInFlightWrite(i);const _=@getByIdDirectPrivate(i,\"state\");if(@assert(_===\"writable\"||_===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(d,\"queue\")),!@writableStreamCloseQueuedOrInFlight(i)&&_===\"writable\"){const q=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(i,q)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)},(_)=>{if(@getByIdDirectPrivate(i,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(d);@writableStreamFinishInFlightWriteWithError(i,_)})})\n"; +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"; // 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 (d,B,D){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),B,D);const y=@getByIdDirectPrivate(d,\"stream\"),I=@getByIdDirectPrivate(y,\"state\");if(!@writableStreamCloseQueuedOrInFlight(y)&&I===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(y,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)}catch(y){@writableStreamDefaultControllerErrorIfNeeded(d,y)}})\n"; +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"; #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 (D,E,F,_,j,c,q){\"use strict\";if(_===@undefined)_=1;if(j===@undefined)j=()=>1;if(c===@undefined)c=0;if(q===@undefined)q=()=>1;@assert(_>=0),@assert(c>=0);const B={};@putByIdDirectPrivate(B,\"TransformStream\",!0);const v=new @TransformStream(B),x=@newPromiseCapability(@Promise);@initializeTransformStream(v,x.@promise,_,j,c,q);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(v,G,E,F),D().@then(()=>{x.@resolve.@call()},(I)=>{x.@reject.@call(@undefined,I)}),v})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (j,q,v,x,B,D,E){\"use strict\";if(x===@undefined)x=1;if(B===@undefined)B=()=>1;if(D===@undefined)D=0;if(E===@undefined)E=()=>1;@assert(x>=0),@assert(D>=0);const F={};@putByIdDirectPrivate(F,\"TransformStream\",!0);const G=new @TransformStream(F),I=@newPromiseCapability(@Promise);@initializeTransformStream(G,I.@promise,x,B,D,E);const _=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(G,_,q,v),j().@then(()=>{I.@resolve.@call()},(c)=>{I.@reject.@call(@undefined,c)}),G})\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 (f,x,C,D,E,F){\"use strict\";const q=()=>{return x},G=(B)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,B)},I=(B)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,B)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},v=@createWritableStream(q,G,J,I,C,D),K=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},L=(B)=>{return @transformStreamErrorWritableAndUnblockWrite(f,B),@Promise.@resolve()},T={};@putByIdDirectPrivate(T,\"start\",q),@putByIdDirectPrivate(T,\"pull\",K),@putByIdDirectPrivate(T,\"cancel\",L);const j={};@putByIdDirectPrivate(j,\"size\",F),@putByIdDirectPrivate(j,\"highWaterMark\",E);const N=new @ReadableStream(T,j);@putByIdDirectPrivate(f,\"writable\",v),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(v)),@putByIdDirectPrivate(f,\"readable\",N),@putByIdDirectPrivate(f,\"backpressure\",@undefined),@putByIdDirectPrivate(f,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(f,!0),@putByIdDirectPrivate(f,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (f,G,B,T,C,F){\"use strict\";const I=()=>{return G},J=(x)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,x)},K=(x)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,x)},j=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},L=@createWritableStream(I,J,j,K,B,T),N=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},q=(x)=>{return @transformStreamErrorWritableAndUnblockWrite(f,x),@Promise.@resolve()},D={};@putByIdDirectPrivate(D,\"start\",I),@putByIdDirectPrivate(D,\"pull\",N),@putByIdDirectPrivate(D,\"cancel\",q);const E={};@putByIdDirectPrivate(E,\"size\",F),@putByIdDirectPrivate(E,\"highWaterMark\",C);const v=new @ReadableStream(D,E);@putByIdDirectPrivate(f,\"writable\",L),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(L)),@putByIdDirectPrivate(f,\"readable\",v),@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; @@ -526,7 +526,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritabl const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength = 339; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (_,n){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(_,\"controller\"));const o=@getByIdDirectPrivate(_,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(o,\"controller\"),n),@getByIdDirectPrivate(_,\"backpressure\"))@transformStreamSetBackpressure(_,!1)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (_,o){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(_,\"controller\"));const n=@getByIdDirectPrivate(_,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(n,\"controller\"),o),@getByIdDirectPrivate(_,\"backpressure\"))@transformStreamSetBackpressure(_,!1)})\n"; // transformStreamSetBackpressure const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 443; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (q,v,_){\"use strict\";const d=new @TransformStreamDefaultController;let b=(p)=>{try{@transformStreamDefaultControllerEnqueue(d,p)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in _)b=(p)=>{return @promiseInvokeOrNoopMethod(v,_.transform,[p,d])};if(\"flush\"in _)j=()=>{return @promiseInvokeOrNoopMethod(v,_.flush,[d])};@setUpTransformStreamDefaultController(q,d,b,j)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,d,p){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in p)b=(q)=>{return @promiseInvokeOrNoopMethod(d,p.transform,[q,v])};if(\"flush\"in p)j=()=>{return @promiseInvokeOrNoopMethod(d,p.flush,[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = 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 (g,i){\"use strict\";const _=@getByIdDirectPrivate(g,\"stream\"),W=@getByIdDirectPrivate(_,\"readable\"),S=@getByIdDirectPrivate(W,\"readableStreamController\");if(@assert(S!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(S))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(S,i)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(_,j),@getByIdDirectPrivate(W,\"storedError\")}const f=!@readableStreamDefaultControllerShouldCallPull(S);if(f!==@getByIdDirectPrivate(_,\"backpressure\"))@assert(f),@transformStreamSetBackpressure(_,!0)})\n"; +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"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (d,g){\"use strict\";const _=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(d,\"transformAlgorithm\").@call(@undefined,g).@then(()=>{_.@resolve()},(f)=>{@transformStreamError(@getByIdDirectPrivate(d,\"stream\"),f),_.@reject.@call(@undefined,f)}),_.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -590,7 +590,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 367; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (f){\"use strict\";const i=@getByIdDirectPrivate(f,\"stream\"),k=@getByIdDirectPrivate(i,\"readable\"),_=@getByIdDirectPrivate(k,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(_))@readableStreamDefaultControllerClose(_);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(i,u)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\"),f=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(f,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(_,u)})\n"; // transformStreamDefaultSinkWriteAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = 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,j){\"use strict\";const f=@getByIdDirectPrivate(d,\"internalWritable\");@assert(@getByIdDirectPrivate(f,\"state\")===\"writable\");const q=@getByIdDirectPrivate(d,\"controller\");if(@getByIdDirectPrivate(d,\"backpressure\")){const _=@newPromiseCapability(@Promise),x=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(x!==@undefined),x.@promise.@then(()=>{const v=@getByIdDirectPrivate(f,\"state\");if(v===\"erroring\"){_.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(v===\"writable\"),@transformStreamDefaultControllerPerformTransform(q,j).@then(()=>{_.@resolve()},(z)=>{_.@reject.@call(@undefined,z)})},(v)=>{_.@reject.@call(@undefined,v)}),_.@promise}return @transformStreamDefaultControllerPerformTransform(q,j)})\n"; +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 q=@newPromiseCapability(@Promise),_=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(_!==@undefined),_.@promise.@then(()=>{const x=@getByIdDirectPrivate(f,\"state\");if(x===\"erroring\"){q.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(x===\"writable\"),@transformStreamDefaultControllerPerformTransform(j,v).@then(()=>{q.@resolve()},(z)=>{q.@reject.@call(@undefined,z)})},(x)=>{q.@reject.@call(@undefined,x)}),q.@promise}return @transformStreamDefaultControllerPerformTransform(j,v)})\n"; // transformStreamDefaultSinkAbortAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -606,7 +606,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkA const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength = 85; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode = "(function (d,t){\"use strict\";return @transformStreamError(d,t),@Promise.@resolve()})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode = "(function (t,d){\"use strict\";return @transformStreamError(t,d),@Promise.@resolve()})\n"; // transformStreamDefaultSinkCloseAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructAbility = 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 (f){\"use strict\";const _=@getByIdDirectPrivate(f,\"readable\"),q=@getByIdDirectPrivate(f,\"controller\"),j=@getByIdDirectPrivate(_,\"readableStreamController\"),k=@getByIdDirectPrivate(q,\"flushAlgorithm\");@assert(k!==@undefined);const u=@getByIdDirectPrivate(q,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(q);const I=@newPromiseCapability(@Promise);return u.@then(()=>{if(@getByIdDirectPrivate(_,\"state\")===@streamErrored){I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(j))@readableStreamDefaultControllerClose(j);I.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(q,\"stream\"),v),I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"))}),I.@promise})\n"; +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"; // transformStreamDefaultSourcePullAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -640,7 +640,7 @@ const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsBindingCodeLength = 473; static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsBindingCode = "(function (I){\"use strict\";if(I!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var r=globalThis.Symbol.for(\"process.bindings.constants\"),l=globalThis[r];if(!l){const{constants:d}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");l={fs:d,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[r]=l}return l})\n"; +const char* const s_processObjectInternalsBindingCode = "(function (d){\"use strict\";if(d!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var l=globalThis.Symbol.for(\"process.bindings.constants\"),I=globalThis[l];if(!I){const{constants:r}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");I={fs:r,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[l]=I}return I})\n"; // getStdioWriteStream const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4311; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (Z){\"use strict\";var L=(M)=>{var G=@requireMap.get(M);if(G)return G.exports;return @internalRequire(M)},D={path:\"node:process\",require:L};function Y(M){var{Duplex:G,eos:j,destroy:z}=L(\"node:stream\"),J=class O extends G{#j;#$;#M=!0;#N=!0;#J;#z;#G;#B;#H;#K;get isTTY(){return this.#K\?\?=L(\"node:tty\").isatty(M)}get fd(){return M}constructor(B){super({readable:!0,writable:!0});this.#J=`/dev/fd/${B}`}#L(B){const H=this.#z;if(this.#z=null,H)H(B);else if(B)this.destroy(B);else if(!this.#M&&!this.#N)this.destroy()}_destroy(B,H){if(!B&&this.#z!==null){var N=class X extends Error{code;name;constructor(Q=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(Q,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};B=new N}if(this.#G=null,this.#B=null,this.#z===null)H(B);else{if(this.#z=H,this.#j)z(this.#j,B);if(this.#$)z(this.#$,B)}}_write(B,H,N){if(!this.#j){var{createWriteStream:X}=L(\"node:fs\"),Q=this.#j=X(this.#J);Q.on(\"finish\",()=>{if(this.#B){const K=this.#B;this.#B=null,K()}}),Q.on(\"drain\",()=>{if(this.#G){const K=this.#G;this.#G=null,K()}}),j(Q,(K)=>{if(this.#N=!1,K)z(Q,K);this.#L(K)})}if(Q.write(B,H))N();else this.#G=N}_final(B){this.#j&&this.#j.end(),this.#B=B}#O(){var{createReadStream:B}=L(\"node:fs\"),H=this.#$=B(this.#J);return H.on(\"readable\",()=>{if(this.#H){const N=this.#H;this.#H=null,N()}else this.read()}),H.on(\"end\",()=>{this.push(null)}),j(H,(N)=>{if(this.#M=!1,N)z(H,N);this.#L(N)}),H}_read(){var B=this.#$;if(!B)B=this.#O();while(!0){const H=B.read();if(H===null||!this.push(H))return}}};return new J(M)}var{EventEmitter:P}=L(\"node:events\");function V(M){if(!M)return!0;var G=M.toLowerCase();return G===\"utf8\"||G===\"utf-8\"||G===\"buffer\"||G===\"binary\"}var U,A=class M extends P{#j;#$;#M;#N;bytesWritten=0;setDefaultEncoding(G){if(this.#$||!V(G))return this.#G(),this.#$.setDefaultEncoding(G)}#J(){switch(this.#j){case 1:{var G=@Bun.stdout.writer({highWaterMark:0});return G.unref(),G}case 2:{var G=@Bun.stderr.writer({highWaterMark:0});return G.unref(),G}default:throw new Error(\"Unsupported writer\")}}#z(){return this.#M\?\?=this.#J()}constructor(G){super();this.#j=G}get fd(){return this.#j}get isTTY(){return this.#N\?\?=L(\"node:tty\").isatty(this.#j)}cursorTo(G,j,z){return(U\?\?=L(\"readline\")).cursorTo(this,G,j,z)}moveCursor(G,j,z){return(U\?\?=L(\"readline\")).moveCursor(this,G,j,z)}clearLine(G,j){return(U\?\?=L(\"readline\")).clearLine(this,G,j)}clearScreenDown(G){return(U\?\?=L(\"readline\")).clearScreenDown(this,G)}ref(){this.#z().ref()}unref(){this.#z().unref()}on(G,j){if(G===\"close\"||G===\"finish\")return this.#G(),this.#$.on(G,j);if(G===\"drain\")return super.on(\"drain\",j);if(G===\"error\")return super.on(\"error\",j);return super.on(G,j)}get _writableState(){return this.#G(),this.#$._writableState}get _readableState(){return this.#G(),this.#$._readableState}pipe(G){return this.#G(),this.#$.pipe(G)}unpipe(G){return this.#G(),this.#$.unpipe(G)}#G(){if(this.#$)return;this.#$=Y(this.#j);const G=this.eventNames();for(let j of G)this.#$.on(j,(...z)=>{this.emit(j,...z)})}#B(G){var j=this.#z();const z=j.write(G);this.bytesWritten+=z;const J=j.flush(!1);return!!(z||J)}#H(G,j){if(!V(j))return this.#G(),this.#$.write(G,j);return this.#B(G)}#K(G,j){if(j)this.emit(\"error\",j);try{G(j\?j:null)}catch(z){this.emit(\"error\",z)}}#L(G,j,z){if(!V(j))return this.#G(),this.#$.write(G,j,z);var J=this.#z();const O=J.write(G),B=J.flush(!0);if(B\?.then)return B.then(()=>{this.#K(z),this.emit(\"drain\")},(H)=>this.#K(z,H)),!1;return queueMicrotask(()=>{this.#K(z)}),!!(O||B)}write(G,j,z){const J=this._write(G,j,z);if(J)this.emit(\"drain\");return J}get hasColors(){return @Bun.tty[this.#j].hasColors}_write(G,j,z){var J=this.#$;if(J)return J.write(G,j,z);switch(arguments.length){case 0:{var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}case 1:return this.#B(G);case 2:if(typeof j===\"function\")return this.#L(G,\"\",j);else if(typeof j===\"string\")return this.#H(G,j);default:{if(typeof j!==\"undefined\"&&typeof j!==\"string\"||typeof z!==\"undefined\"&&typeof z!==\"function\"){var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}if(typeof z===\"undefined\")return this.#H(G,j);return this.#L(G,j,z)}}}destroy(){return this}end(){return this}};return new A(Z)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (z){\"use strict\";var G=(U)=>{var V=@requireMap.get(U);if(V)return V.exports;return @internalRequire(U)},J={path:\"node:process\",require:G};function K(U){var{Duplex:V,eos:X,destroy:j}=G(\"node:stream\"),B=class Z extends V{#$;#G;#j=!0;#z=!0;#B;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(U)}get fd(){return U}constructor(Y){super({readable:!0,writable:!0});this.#B=`/dev/fd/${Y}`}#N(Y){const P=this.#H;if(this.#H=null,P)P(Y);else if(Y)this.destroy(Y);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Y,P){if(!Y&&this.#H!==null){var A=class D extends Error{code;name;constructor(H=\"The operation was aborted\",N=void 0){if(N!==void 0&&typeof N!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(N,null,2)}`);super(H,N);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Y=new A}if(this.#J=null,this.#K=null,this.#H===null)P(Y);else{if(this.#H=P,this.#$)j(this.#$,Y);if(this.#G)j(this.#G,Y)}}_write(Y,P,A){if(!this.#$){var{createWriteStream:D}=G(\"node:fs\"),H=this.#$=D(this.#B);H.on(\"finish\",()=>{if(this.#K){const N=this.#K;this.#K=null,N()}}),H.on(\"drain\",()=>{if(this.#J){const N=this.#J;this.#J=null,N()}}),X(H,(N)=>{if(this.#z=!1,N)j(H,N);this.#N(N)})}if(H.write(Y,P))A();else this.#J=A}_final(Y){this.#$&&this.#$.end(),this.#K=Y}#O(){var{createReadStream:Y}=G(\"node:fs\"),P=this.#G=Y(this.#B);return P.on(\"readable\",()=>{if(this.#L){const A=this.#L;this.#L=null,A()}else this.read()}),P.on(\"end\",()=>{this.push(null)}),X(P,(A)=>{if(this.#j=!1,A)j(P,A);this.#N(A)}),P}_read(){var Y=this.#G;if(!Y)Y=this.#O();while(!0){const P=Y.read();if(P===null||!this.push(P))return}}};return new B(U)}var{EventEmitter:L}=G(\"node:events\");function O(U){if(!U)return!0;var V=U.toLowerCase();return V===\"utf8\"||V===\"utf-8\"||V===\"buffer\"||V===\"binary\"}var M,Q=class U extends L{#$;#G;#j;#z;bytesWritten=0;setDefaultEncoding(V){if(this.#G||!O(V))return this.#J(),this.#G.setDefaultEncoding(V)}#B(){switch(this.#$){case 1:{var V=@Bun.stdout.writer({highWaterMark:0});return V.unref(),V}case 2:{var V=@Bun.stderr.writer({highWaterMark:0});return V.unref(),V}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#B()}constructor(V){super();this.#$=V}get fd(){return this.#$}get isTTY(){return this.#z\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(V,X,j){return(M\?\?=G(\"readline\")).cursorTo(this,V,X,j)}moveCursor(V,X,j){return(M\?\?=G(\"readline\")).moveCursor(this,V,X,j)}clearLine(V,X){return(M\?\?=G(\"readline\")).clearLine(this,V,X)}clearScreenDown(V){return(M\?\?=G(\"readline\")).clearScreenDown(this,V)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(V,X){if(V===\"close\"||V===\"finish\")return this.#J(),this.#G.on(V,X);if(V===\"drain\")return super.on(\"drain\",X);if(V===\"error\")return super.on(\"error\",X);return super.on(V,X)}get _writableState(){return this.#J(),this.#G._writableState}get _readableState(){return this.#J(),this.#G._readableState}pipe(V){return this.#J(),this.#G.pipe(V)}unpipe(V){return this.#J(),this.#G.unpipe(V)}#J(){if(this.#G)return;this.#G=K(this.#$);const V=this.eventNames();for(let X of V)this.#G.on(X,(...j)=>{this.emit(X,...j)})}#K(V){var X=this.#H();const j=X.write(V);this.bytesWritten+=j;const B=X.flush(!1);return!!(j||B)}#L(V,X){if(!O(X))return this.#J(),this.#G.write(V,X);return this.#K(V)}#M(V,X){if(X)this.emit(\"error\",X);try{V(X\?X:null)}catch(j){this.emit(\"error\",j)}}#N(V,X,j){if(!O(X))return this.#J(),this.#G.write(V,X,j);var B=this.#H();const Z=B.write(V),Y=B.flush(!0);if(Y\?.then)return Y.then(()=>{this.#M(j),this.emit(\"drain\")},(P)=>this.#M(j,P)),!1;return queueMicrotask(()=>{this.#M(j)}),!!(Z||Y)}write(V,X,j){const B=this._write(V,X,j);if(B)this.emit(\"drain\");return B}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(V,X,j){var B=this.#G;if(B)return B.write(V,X,j);switch(arguments.length){case 0:{var Z=new Error(\"Invalid arguments\");throw Z.code=\"ERR_INVALID_ARG_TYPE\",Z}case 1:return this.#K(V);case 2:if(typeof X===\"function\")return this.#N(V,\"\",X);else if(typeof X===\"string\")return this.#L(V,X);default:{if(typeof X!==\"undefined\"&&typeof X!==\"string\"||typeof j!==\"undefined\"&&typeof j!==\"function\"){var Z=new Error(\"Invalid arguments\");throw Z.code=\"ERR_INVALID_ARG_TYPE\",Z}if(typeof j===\"undefined\")return this.#L(V,X);return this.#N(V,X,j)}}}destroy(){return this}end(){return this}};return new Q(z)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -656,7 +656,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructor const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdinStreamCodeLength = 1861; static const JSC::Intrinsic s_processObjectInternalsGetStdinStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdinStreamCode = "(function (K){\"use strict\";var H=(I)=>{var N=@requireMap.get(I);if(N)return N.exports;return @internalRequire(I)},T={path:\"node:process\",require:H},{Duplex:M,eos:P,destroy:L}=H(\"node:stream\"),Q=class I extends M{#J;#j;#$;#G=!0;#H=!1;#K=!0;#z;#N;#B;get isTTY(){return H(\"tty\").isatty(K)}get fd(){return K}constructor(){super({readable:!0,writable:!0})}#I(N){const j=this.#N;if(this.#N=null,j)j(N);else if(N)this.destroy(N);else if(!this.#G&&!this.#K)this.destroy()}_destroy(N,j){if(!N&&this.#N!==null){var z=class B extends Error{constructor(G=\"The operation was aborted\",J=void 0){if(J!==void 0&&typeof J!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(J,null,2)}`);super(G,J);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new z}if(this.#N===null)j(N);else if(this.#N=j,this.#$)L(this.#$,N)}setRawMode(N){}on(N,j){if(N===\"readable\")this.ref(),this.#H=!0;return super.on(N,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#J\?\?=@Bun.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#L(){try{var N,j;const z=this.#J.readMany();if(!z\?.then)({done:N,value:j}=z);else({done:N,value:j}=await z);if(!N){this.push(j[0]);const B=j.length;for(let G=1;G{if(this.#z){const z=this.#z;this.#z=null,z()}}),j.on(\"drain\",()=>{if(this.#B){const z=this.#B;this.#B=null,z()}}),P(j,(z)=>{if(this.#K=!1,z)L(j,z);this.#I(z)}),j}_write(N,j,z){var B=this.#$;if(!B)B=this.#M();if(B.write(N,j))z();else this.#B=z}_final(N){this.#$.end(),this.#z=(...j)=>N(...j)}};return new Q})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (N){\"use strict\";var j=(J)=>{var K=@requireMap.get(J);if(K)return K.exports;return @internalRequire(J)},z={path:\"node:process\",require:j},{Duplex:B,eos:G,destroy:H}=j(\"node:stream\"),I=class J extends B{#$;#N;#j;#z=!0;#B=!1;#G=!0;#H;#I;#J;get isTTY(){return j(\"tty\").isatty(N)}get fd(){return N}constructor(){super({readable:!0,writable:!0})}#K(K){const L=this.#I;if(this.#I=null,L)L(K);else if(K)this.destroy(K);else if(!this.#z&&!this.#G)this.destroy()}_destroy(K,L){if(!K&&this.#I!==null){var M=class P extends Error{constructor(Q=\"The operation was aborted\",T=void 0){if(T!==void 0&&typeof T!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(T,null,2)}`);super(Q,T);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};K=new M}if(this.#I===null)L(K);else if(this.#I=L,this.#j)H(this.#j,K)}setRawMode(K){}on(K,L){if(K===\"readable\")this.ref(),this.#B=!0;return super.on(K,L)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#$\?\?=@Bun.stdin.stream().getReader(),this.#N\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#N)clearInterval(this.#N),this.#N=null}async#L(){try{var K,L;const M=this.#$.readMany();if(!M\?.then)({done:K,value:L}=M);else({done:K,value:L}=await M);if(!K){this.push(L[0]);const P=L.length;for(let Q=1;Q{if(this.#H){const M=this.#H;this.#H=null,M()}}),L.on(\"drain\",()=>{if(this.#J){const M=this.#J;this.#J=null,M()}}),G(L,(M)=>{if(this.#G=!1,M)H(L,M);this.#K(M)}),L}_write(K,L,M){var P=this.#j;if(!P)P=this.#M();if(P.write(K,L))M();else this.#J=M}_final(K){this.#j.end(),this.#H=(...L)=>K(...L)}};return new I})\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 = 1304; static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let j=arguments[1],q=arguments[2];if(_===@undefined)_=null;if(q===@undefined)q={};if(j===@undefined)j={};let u={};if(_!==null){if(\"start\"in _){if(u.start=_.start,typeof u.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(u.transform=_.transform,typeof u.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(u.flush=_.flush,typeof u.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const x=@extractHighWaterMark(q,0),B=@extractSizeAlgorithm(q),E=@extractHighWaterMark(j,1),F=@extractSizeAlgorithm(j),v=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,v.@promise,E,F,x,B),@setUpTransformStreamDefaultControllerFromTransformer(this,_,u),(\"start\"in u)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,u.start,[G]))().@then(()=>{v.@resolve.@call()},(I)=>{v.@reject.@call(@undefined,I)})}else v.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let j=arguments[0];if(@isObject(j)&&@getByIdDirectPrivate(j,\"TransformStream\"))return this;let q=arguments[1],v=arguments[2];if(j===@undefined)j=null;if(v===@undefined)v={};if(q===@undefined)q={};let x={};if(j!==null){if(\"start\"in j){if(x.start=j.start,typeof x.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in j){if(x.transform=j.transform,typeof x.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in j){if(x.flush=j.flush,typeof x.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in j)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in j)@throwRangeError(\"TransformStream transformer has a writableType\")}const B=@extractHighWaterMark(v,0),E=@extractSizeAlgorithm(v),F=@extractHighWaterMark(q,1),G=@extractSizeAlgorithm(q),I=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,I.@promise,F,G,B,E),@setUpTransformStreamDefaultControllerFromTransformer(this,j,x),(\"start\"in x)){const J=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(j,x.start,[J]))().@then(()=>{I.@resolve.@call()},(u)=>{I.@reject.@call(@undefined,u)})}else I.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (_){\"use strict\";const b=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(b)return @evaluateCommonJSModule(b),b.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=S.module,f=@Loader.getModuleNamespaceObject(M),r=f\?.[@commonJSSymbol]===0||f\?.default\?.[@commonJSSymbol]===0\?f.default:f.__esModule\?f:Object.create(f,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const L=@createCommonJSModule(_,{},!1);@requireMap.@set(_,L);var h=this.@require(_,L);if(h===-1){try{h=@requireESM(_)}catch(M){throw @requireMap.@delete(_),M}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=@Loader.getModuleNamespaceObject(S.module);return L.exports=M\?.[@commonJSSymbol]===0||M\?.default\?.[@commonJSSymbol]===0\?M.default:M.__esModule\?M:Object.create(M,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const M=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(M)return @evaluateCommonJSModule(M),M.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=S.module,h=@Loader.getModuleNamespaceObject(b),r=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const f=@createCommonJSModule(_,{},!1);@requireMap.@set(_,f);var L=this.@require(_,f);if(L===-1){try{L=@requireESM(_)}catch(b){throw @requireMap.@delete(_),b}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=@Loader.getModuleNamespaceObject(S.module);return f.exports=b\?.[@commonJSSymbol]===0||b\?.default\?.[@commonJSSymbol]===0\?b.default:b.__esModule\?b:Object.create(b,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(f),f.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,u){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(u){case 1:return r.getInt8(d);case 2:return r.getInt16(d,!0);case 3:{const _=r.getUint16(d,!0)+r.getUint8(d+2)*65536;return _|(_&8388608)*510}case 4:return r.getInt32(d,!0);case 5:{const _=r.getUint8(d+4);return(_|(_&128)*33554430)*4294967296+r.getUint32(d,!0)}case 6:{const _=r.getUint16(d+4,!0);return(_|(_&32768)*131070)*4294967296+r.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -838,7 +838,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntBECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:return d.getInt8(r);case 2:return d.getInt16(r,!1);case 3:{const u=d.getUint16(r+1,!1)+d.getUint8(r)*65536;return u|(u&8388608)*510}case 4:return d.getInt32(r,!1);case 5:{const u=d.getUint8(r);return(u|(u&128)*33554430)*4294967296+d.getUint32(r+1,!1)}case 6:{const u=d.getUint16(r,!1);return(u|(u&32768)*131070)*4294967296+d.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,d){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return u.getInt8(r);case 2:return u.getInt16(r,!1);case 3:{const c=u.getUint16(r+1,!1)+u.getUint8(r)*65536;return c|(c&8388608)*510}case 4:return u.getInt32(r,!1);case 5:{const c=u.getUint8(r);return(c|(c&128)*33554430)*4294967296+u.getUint32(r+1,!1)}case 6:{const c=u.getUint16(r,!1);return(c|(c&32768)*131070)*4294967296+u.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntLE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -846,7 +846,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntLECodeLength = 445; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,r){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return d.getUint8(a);case 2:return d.getUint16(a,!0);case 3:return d.getUint16(a,!0)+d.getUint8(a+2)*65536;case 4:return d.getUint32(a,!0);case 5:return d.getUint8(a+4)*4294967296+d.getUint32(a,!0);case 6:return d.getUint16(a+4,!0)*4294967296+d.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,d){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return r.getUint8(a);case 2:return r.getUint16(a,!0);case 3:return r.getUint16(a,!0)+r.getUint8(a+2)*65536;case 4:return r.getUint32(a,!0);case 5:return r.getUint8(a+4)*4294967296+r.getUint32(a,!0);case 6:return r.getUint16(a+4,!0)*4294967296+r.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -854,7 +854,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntBECodeLength = 504; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,p){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:return r.getUint8(d);case 2:return r.getUint16(d,!1);case 3:return r.getUint16(d+1,!1)+r.getUint8(d)*65536;case 4:return r.getUint32(d,!1);case 5:{const c=r.getUint8(d);return(c|(c&128)*33554430)*4294967296+r.getUint32(d+1,!1)}case 6:{const c=r.getUint16(d,!1);return(c|(c&32768)*131070)*4294967296+r.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,r){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return c.getUint8(d);case 2:return c.getUint16(d,!1);case 3:return c.getUint16(d+1,!1)+c.getUint8(d)*65536;case 4:return c.getUint32(d,!1);case 5:{const p=c.getUint8(d);return(p|(p&128)*33554430)*4294967296+c.getUint32(d+1,!1)}case 6:{const p=c.getUint16(d,!1);return(p|(p&32768)*131070)*4294967296+c.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readFloatLE const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -926,7 +926,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt8CodeLength = 131; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt8Code = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(d,r),d+1})\n"; +const char* const s_jsBufferPrototypeWriteInt8Code = "(function (d,r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(r,d),r+1})\n"; // writeUInt8 const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -934,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; @@ -942,7 +942,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt16LECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!0),c+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!0),d+2})\n"; // writeInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -950,7 +950,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt16BECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!1),c+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!1),d+2})\n"; // writeUInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -958,7 +958,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt16LECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!0),c+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!0),d+2})\n"; // writeUInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -966,7 +966,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt16BECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!1),c+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!1),d+2})\n"; // writeInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -974,7 +974,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt32LECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!0),c+4})\n"; +const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,c,!0),d+4})\n"; // writeInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -982,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 (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!1),c+4})\n"; +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"; // writeUInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -990,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; @@ -998,7 +998,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt32BECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(c,d,!1),c+4})\n"; +const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!1),d+4})\n"; // writeIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1006,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 (r,d,j){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(j){case 1:{c.setInt8(d,r);break}case 2:{c.setInt16(d,r,!0);break}case 3:{c.setUint16(d,r&65535,!0),c.setInt8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{c.setInt32(d,r,!0);break}case 5:{c.setUint32(d,r|0,!0),c.setInt8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{c.setUint32(d,r|0,!0),c.setInt16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+j})\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; @@ -1014,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,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setInt8(d,r);break}case 2:{E.setInt16(d,r,!1);break}case 3:{E.setUint16(d+1,r&65535,!1),E.setInt8(d,Math.floor(r*0.0000152587890625));break}case 4:{E.setInt32(d,r,!1);break}case 5:{E.setUint32(d+1,r|0,!1),E.setInt8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d+2,r|0,!1),E.setInt16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+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; @@ -1022,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 (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setUint8(d,r);break}case 2:{E.setUint16(d,r,!0);break}case 3:{E.setUint16(d,r&65535,!0),E.setUint8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{E.setUint32(d,r,!0);break}case 5:{E.setUint32(d,r|0,!0),E.setUint8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d,r|0,!0),E.setUint16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\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; @@ -1030,7 +1030,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntBECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (r,d,_){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{p.setUint8(d,r);break}case 2:{p.setUint16(d,r,!1);break}case 3:{p.setUint16(d+1,r&65535,!1),p.setUint8(d,Math.floor(r*0.0000152587890625));break}case 4:{p.setUint32(d,r,!1);break}case 5:{p.setUint32(d+1,r|0,!1),p.setUint8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{p.setUint32(d+2,r|0,!1),p.setUint16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+_})\n"; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (d,r,p){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:{_.setUint8(r,d);break}case 2:{_.setUint16(r,d,!1);break}case 3:{_.setUint16(r+1,d&65535,!1),_.setUint8(r,Math.floor(d*0.0000152587890625));break}case 4:{_.setUint32(r,d,!1);break}case 5:{_.setUint32(r+1,d|0,!1),_.setUint8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{_.setUint32(r+2,d|0,!1),_.setUint16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+p})\n"; // writeFloatLE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1038,7 +1038,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!0),c+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!0),d+4})\n"; // writeFloatBE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1046,7 +1046,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!1),c+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!1),d+4})\n"; // writeDoubleLE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1054,7 +1054,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteDoubleLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!0),c+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!0),d+8})\n"; // writeDoubleBE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1062,7 +1062,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteDoubleBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!1),c+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!1),d+8})\n"; // writeBigInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1070,7 +1070,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigInt64LECodeLength = 138; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,d,!0),c+8})\n"; +const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!0),d+8})\n"; // writeBigInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1078,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; @@ -1086,7 +1086,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKin const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigUInt64LECodeLength = 139; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!0),c+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!0),d+8})\n"; // writeBigUInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1094,7 +1094,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKin const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigUInt64BECodeLength = 139; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!1),c+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!1),d+8})\n"; // utf8Write const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1118,7 +1118,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf16leWriteCodeLength = 68; static const JSC::Intrinsic s_jsBufferPrototypeUtf16leWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (d,r,a){\"use strict\";return this.write(d,r,a,\"utf16le\")})\n"; +const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (r,d,a){\"use strict\";return this.write(r,d,a,\"utf16le\")})\n"; // latin1Write const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (w,m){\"use strict\";var{buffer:x,byteOffset:z,byteLength:p}=this;function q(c,k){if(c=@trunc(c),c===0||@isNaN(c))return 0;else if(c<0)return c+=k,c>0\?c:0;else return ci\?v-i:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (i,q){\"use strict\";var{buffer:c,byteOffset:v,byteLength:p}=this;function w(z,m){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=m,z>0\?z:0;else return zk\?x-k:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,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 a=@getByIdDirectPrivate(this,\"byobRequest\");if(a===@undefined){var l=@getByIdDirectPrivate(this,\"pendingPullIntos\");const _=l.peek();if(_){const m=new @Uint8Array(_.buffer,_.byteOffset+_.bytesFilled,_.byteLength-_.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 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"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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 D=async function*L(){var F=@Bun.stdin.stream().getReader(),G=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),z,H=@Bun.indexOfLine;try{while(!0){var A,B,w;const m=F.readMany();if(@isPromise(m))({done:A,value:B}=await m);else({done:A,value:B}=m);if(A){if(w)yield G.decode(w);return}var _;for(let J of B){if(_=J,w)_=@Buffer.concat([w,J]),w=null;var j=0,q=H(_,j);while(q!==-1)yield G.decode(_.subarray(j,q)),j=q+1,q=H(_,j);w=_.subarray(j)}}}catch(m){z=m}finally{if(F.releaseLock(),z)throw z}},K=globalThis.Symbol.asyncIterator;return this[K]=D,D()})\n"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const w=async function*_(){var G=@Bun.stdin.stream().getReader(),B=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),H,J=@Bun.indexOfLine;try{while(!0){var j,D,K;const q=G.readMany();if(@isPromise(q))({done:j,value:D}=await q);else({done:j,value:D}=q);if(j){if(K)yield B.decode(K);return}var m;for(let M of D){if(m=M,K)m=@Buffer.concat([K,M]),K=null;var L=0,F=J(m,L);while(F!==-1)yield B.decode(m.subarray(L,F)),L=F+1,F=J(m,L);K=m.subarray(L)}}}catch(q){H=q}finally{if(G.releaseLock(),H)throw H}},z=globalThis.Symbol.asyncIterator;return this[z]=w,w()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (_){\"use strict\";var a=@getByIdDirectPrivate(this,\"writer\");if(!a){var b=@toLength(_\?.length\?\?0);a=@Bun.stdout.writer({highWaterMark:b>65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",a)}var c=a.write(_);const f=@argumentCount();for(var d=1;d65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a{},(_)=>{c.error(_)});function y(){@readableStreamDefaultReaderRead(h).@then(function(_){if(_.done){c.close();return}try{c.enqueue(_.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(_){c.error(_)})}y()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (_,h){\"use strict\";@assert(@isReadableStream(_));const y=new @ReadableStreamDefaultReader(_);@getByIdDirectPrivate(y,\"closedPromiseCapability\").@promise.@then(()=>{},(c)=>{h.error(c)});function S(){@readableStreamDefaultReaderRead(y).@then(function(c){if(c.done){h.close();return}try{h.enqueue(c.value)}catch(g){h.error(\"ReadableStream chunk enqueueing in the sink failed\");return}S()},function(c){h.error(c)})}S()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1404,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 (b,f,j,q,D,v,w){\"use strict\";const _=new @ReadableStreamDefaultController(b,f,j,q,@isReadableStream),x=()=>@promiseInvokeOrNoopMethod(f,v,[_]),B=(C)=>@promiseInvokeOrNoopMethod(f,w,[C]);@putByIdDirectPrivate(_,\"pullAlgorithm\",x),@putByIdDirectPrivate(_,\"cancelAlgorithm\",B),@putByIdDirectPrivate(_,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(_,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",_),@readableStreamDefaultControllerStart(_)})\n"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (b,v,_,w,f,x,j){\"use strict\";const B=new @ReadableStreamDefaultController(b,v,_,w,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(v,x,[B]),q=(D)=>@promiseInvokeOrNoopMethod(v,j,[D]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",q),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (w,v,f){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(f.highWaterMark===@undefined)f.highWaterMark=0;if(f.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(w,\"readableStreamController\",new @ReadableByteStreamController(w,v,f.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=f\?.highWaterMark;@initializeArrayBufferStream.@call(w,v,b)}else if(A===@undefined){if(f.highWaterMark===@undefined)f.highWaterMark=1;@setupReadableStreamDefaultController(w,v,f.size,f.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,b)}else if(A===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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,E,z,B,F,D){\"use strict\";if(@assert(@isReadableStream(f)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(f)),@assert(!@isWritableStreamLocked(E)),@assert(D===@undefined||@isAbortSignal(D)),@getByIdDirectPrivate(f,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:f,destination:E,preventAbort:B,preventCancel:F,preventClose:z,signal:D};if(_.reader=@acquireReadableStreamDefaultReader(f),_.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(f,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),D!==@undefined){const G=(T)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const H=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,T):@Promise.@resolve(),I=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,T):@Promise.@resolve();let k=@newPromiseCapability(@Promise),q=!0,w=()=>{if(q){q=!1;return}k.@resolve.@call()},x=(J)=>{k.@reject.@call(@undefined,J)};return H.@then(w,x),I.@then(w,x),k.@promise},T)};if(@whenSignalAborted(D,G))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (_,f,D,E,T,k){\"use strict\";if(@assert(@isReadableStream(_)),@assert(@isWritableStream(f)),@assert(!@isReadableStreamLocked(_)),@assert(!@isWritableStreamLocked(f)),@assert(k===@undefined||@isAbortSignal(k)),@getByIdDirectPrivate(_,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let q={source:_,destination:f,preventAbort:E,preventCancel:T,preventClose:D,signal:k};if(q.reader=@acquireReadableStreamDefaultReader(_),q.writer=@acquireWritableStreamDefaultWriter(f),@putByIdDirectPrivate(_,\"disturbed\",!0),q.finalized=!1,q.shuttingDown=!1,q.promiseCapability=@newPromiseCapability(@Promise),q.pendingReadPromiseCapability=@newPromiseCapability(@Promise),q.pendingReadPromiseCapability.@resolve.@call(),q.pendingWritePromise=@Promise.@resolve(),k!==@undefined){const w=(x)=>{if(q.finalized)return;@pipeToShutdownWithAction(q,()=>{const B=!q.preventAbort&&@getByIdDirectPrivate(q.destination,\"state\")===\"writable\"\?@writableStreamAbort(q.destination,x):@Promise.@resolve(),G=!q.preventCancel&&@getByIdDirectPrivate(q.source,\"state\")===@streamReadable\?@readableStreamCancel(q.source,x):@Promise.@resolve();let H=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}H.@resolve.@call()},K=(L)=>{H.@reject.@call(@undefined,L)};return B.@then(J,K),G.@then(J,K),H.@promise},x)};if(@whenSignalAborted(k,w))return q.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(q),@pipeToErrorsMustBePropagatedBackward(q),@pipeToClosingMustBePropagatedForward(q),@pipeToClosingMustBePropagatedBackward(q),@pipeToLoop(q),q.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1452,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 d=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,b),b);return}@pipeToShutdown(_,b)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){d();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,d)})\n"; +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"; // pipeToErrorsMustBePropagatedBackward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1460,7 +1460,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagated const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength = 369; static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const y=()=>{const h=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,h),h);return}@pipeToShutdown(m,h)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){y();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,y)})\n"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const h=()=>{const y=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,y),y);return}@pipeToShutdown(m,y)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){h();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,h)})\n"; // pipeToClosingMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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 (_,d){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const g=arguments.length>2,h=arguments[2],m=()=>{d().@then(()=>{if(g)@pipeToFinalize(_,h);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(m,m)},(b)=>@pipeToFinalize(_,b));return}m()})\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; @@ -1492,7 +1492,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownCodeLength = 411; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,u=arguments[1],d=()=>{if(m)@pipeToFinalize(_,u);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(d,d)},(I)=>@pipeToFinalize(_,I));return}d()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const d=arguments.length>1,m=arguments[1],u=()=>{if(d)@pipeToFinalize(_,m);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(I)=>@pipeToFinalize(_,I));return}u()})\n"; // pipeToFinalize const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,q){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof q===\"boolean\");var v=@getByIdDirectPrivate(_,\"start\");if(v)@putByIdDirectPrivate(_,\"start\",@undefined),v();const w=new @ReadableStreamDefaultReader(_),i={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};i.cancelPromiseCapability=@newPromiseCapability(@Promise);const x=@readableStreamTeePullFunction(i,w,q),f={};@putByIdDirectPrivate(f,\"pull\",x),@putByIdDirectPrivate(f,\"cancel\",@readableStreamTeeBranch1CancelFunction(i,_));const g={};@putByIdDirectPrivate(g,\"pull\",x),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch2CancelFunction(i,_));const j=new @ReadableStream(f),k=new @ReadableStream(g);return @getByIdDirectPrivate(w,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(i.closedOrErrored)return;if(@readableStreamDefaultControllerError(j.@readableStreamController,y),@readableStreamDefaultControllerError(k.@readableStreamController,y),i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}),i.branch1=j,i.branch2=k,[j,k]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,f){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof f===\"boolean\");var g=@getByIdDirectPrivate(_,\"start\");if(g)@putByIdDirectPrivate(_,\"start\",@undefined),g();const j=new @ReadableStreamDefaultReader(_),k={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};k.cancelPromiseCapability=@newPromiseCapability(@Promise);const q=@readableStreamTeePullFunction(k,j,f),v={};@putByIdDirectPrivate(v,\"pull\",q),@putByIdDirectPrivate(v,\"cancel\",@readableStreamTeeBranch1CancelFunction(k,_));const w={};@putByIdDirectPrivate(w,\"pull\",q),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(k,_));const x=new @ReadableStream(v),y=new @ReadableStream(w);return @getByIdDirectPrivate(j,\"closedPromiseCapability\").@promise.@then(@undefined,function(i){if(k.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,i),@readableStreamDefaultControllerError(y.@readableStreamController,i),k.closedOrErrored=!0,!k.canceled1||!k.canceled2)k.cancelPromiseCapability.@resolve.@call()}),k.branch1=x,k.branch2=y,[x,y]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,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,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"; +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"; // readableStreamTeeBranch1CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,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,q,_){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function w(f,v){if(v&&_\?.cancel){try{var A=_.cancel(v);@markPromiseAsHandled(A)}catch(B){}_=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),v)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",v);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!_.pull){w();return}if(!@isCallable(_.pull)){w(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",q);const x=@getByIdDirectPrivate(j,\"highWaterMark\");q.start({highWaterMark:!x||x<64\?64:x}),@startDirectStream.@call(q,j,_.pull,w),@putByIdDirectPrivate(j,\"reader\",{});var z=_.pull(q);if(q=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (_,x,f){\"use strict\";@putByIdDirectPrivate(_,\"underlyingSource\",@undefined),@putByIdDirectPrivate(_,\"start\",@undefined);function j(v,A){if(A&&f\?.cancel){try{var w=f.cancel(A);@markPromiseAsHandled(w)}catch(B){}f=@undefined}if(v){if(@putByIdDirectPrivate(v,\"readableStreamController\",@undefined),@putByIdDirectPrivate(v,\"reader\",@undefined),A)@putByIdDirectPrivate(v,\"state\",@streamErrored),@putByIdDirectPrivate(v,\"storedError\",A);else @putByIdDirectPrivate(v,\"state\",@streamClosed);v=@undefined}}if(!f.pull){j();return}if(!@isCallable(f.pull)){j(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(_,\"readableStreamController\",x);const q=@getByIdDirectPrivate(_,\"highWaterMark\");x.start({highWaterMark:!q||q<64\?64:q}),@startDirectStream.@call(x,_,f.pull,j),@putByIdDirectPrivate(_,\"reader\",{});var z=f.pull(x);if(x=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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,E){\"use strict\";var x=!1,B=!1;try{var I=_.getReader(),f=I.readMany();if(f&&@isPromise(f))f=await f;if(f.done)return x=!0,c.end();var K=f.value.length;const q=@getByIdDirectPrivate(_,\"highWaterMark\");if(E)@startDirectStream.@call(c,_,@undefined,()=>!B&&@markPromiseAsHandled(_.cancel()));c.start({highWaterMark:q||0});for(var D=0,F=f.value,G=f.value.length;D!D&&@markPromiseAsHandled(c.cancel()));F.start({highWaterMark:x||0});for(var J=0,P=G.value,z=G.value.length;J{var b=@createFulfilledPromise({value:v,done:!1});return v=@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 b=this.@controlledReadableStream;if(!b||@getByIdDirectPrivate(b,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=c;return}if(@putByIdDirectPrivate(b,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,c)}catch(j){}var v;try{v=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(j){if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(y,j)}@readableStreamError(b,j);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var B=@getByIdDirectPrivate(b,\"reader\");if(B&&@isReadableStreamDefaultReader(B)){var C=this._pendingRead;if(C&&@isPromise(C)&&v\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(C,{value:v,done:!1}),@readableStreamClose(b);return}}if(v\?.byteLength){var S=@getByIdDirectPrivate(B,\"readRequests\");if(S\?.isNotEmpty()){@readableStreamFulfillReadRequest(b,v,!1),@readableStreamClose(b);return}@putByIdDirectPrivate(b,\"state\",@streamReadable),this.@pull=()=>{var j=@createFulfilledPromise({value:v,done:!1});return v=@undefined,@readableStreamClose(b),b=@undefined,j}}else if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(y,{value:@undefined,done:!0})}@readableStreamClose(b)})\n"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var B=this.@controlledReadableStream,i=@getByIdDirectPrivate(B,\"reader\");if(!i||!@isReadableStreamDefaultReader(i))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var c=this.@sink.flush();if(c\?.byteLength)this._pendingRead=@getByIdDirectPrivate(B,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:c,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(B,\"readRequests\")\?.isNotEmpty()){var c=this.@sink.flush();if(c\?.byteLength)@readableStreamFulfillReadRequest(B,c,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var i=this.@sink.flush();if(i\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:i,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var i=this.@sink.flush();if(i\?.byteLength)@readableStreamFulfillReadRequest(c,i,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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 (G){\"use strict\";var q,v=[],x=!1,z=!1,j=\"\",C=@toLength(0),F=@newPromiseCapability(@Promise),A=!1;return q={start(){},write(_){if(typeof _===\"string\"){var w=@toLength(_.length);if(w>0)j+=_,x=!0,C+=w;return w}if(!_||!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const E=@toLength(_.byteLength);if(E>0)if(z=!0,j.length>0)@arrayPush(v,j,_),j=\"\";else @arrayPush(v,_);return C+=E,E},flush(){return 0},end(){if(A)return\"\";return q.fulfill()},fulfill(){A=!0;const _=q.finishInternal();return @fulfillPromise(F.@promise,_),_},finishInternal(){if(!x&&!z)return\"\";if(x&&!z)return j;if(z&&!x)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(v));var _=new @Bun.ArrayBufferSink;_.start({highWaterMark:C,asUint8Array:!0});for(let w of v)_.write(w);if(v.length=0,j.length>0)_.write(j),j=\"\";return new globalThis.TextDecoder().decode(_.end())},close(){try{if(!A)A=!0,q.fulfill()}catch(_){}}},[q,F]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (v){\"use strict\";var _,w=[],A=!1,C=!1,j=\"\",x=@toLength(0),E=@newPromiseCapability(@Promise),F=!1;return _={start(){},write(q){if(typeof q===\"string\"){var z=@toLength(q.length);if(z>0)j+=q,A=!0,x+=z;return z}if(!q||!(@ArrayBuffer.@isView(q)||q instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const G=@toLength(q.byteLength);if(G>0)if(C=!0,j.length>0)@arrayPush(w,j,q),j=\"\";else @arrayPush(w,q);return x+=G,G},flush(){return 0},end(){if(F)return\"\";return _.fulfill()},fulfill(){F=!0;const q=_.finishInternal();return @fulfillPromise(E.@promise,q),q},finishInternal(){if(!A&&!C)return\"\";if(A&&!C)return j;if(C&&!A)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(w));var q=new @Bun.ArrayBufferSink;q.start({highWaterMark:x,asUint8Array:!0});for(let z of w)q.write(z);if(w.length=0,j.length>0)q.write(j),j=\"\";return new globalThis.TextDecoder().decode(q.end())},close(){try{if(!F)F=!0,_.fulfill()}catch(q){}}},[_,E]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (m,p){\"use strict\";var[_,b]=@createTextStream(p),f={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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 (m,v){\"use strict\";var _=[],b=@newPromiseCapability(@Promise),t=!1;function d(){return t=!0,b.@resolve.@call(@undefined,_),_}var j={start(){},write(p){return @arrayPush(_,p),p.byteLength||p.length},flush(){return 0},end(){if(t)return[];return d()},close(){if(!t)d()}},q={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:j,close:@onCloseDirectStream,write:j.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 m(){return d=!0,b.@resolve.@call(@undefined,p),p}var j={start(){},write(v){return @arrayPush(p,v),v.byteLength||v.length},flush(){return 0},end(){if(d)return[];return m()},close(){if(!d)m()}},q={@underlyingSource:t,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:j,close:@onCloseDirectStream,write:j.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; @@ -1668,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 (w,m){\"use strict\";var D=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},_=new @Bun.ArrayBufferSink;_.start(D);var b={@underlyingSource:w,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write.bind(_),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; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (c,f){\"use strict\";@assert(@isReadableStream(c)),@assert(@getByIdDirectPrivate(c,\"state\")===@streamReadable),@putByIdDirectPrivate(c,\"state\",@streamErrored),@putByIdDirectPrivate(c,\"storedError\",f);const _=@getByIdDirectPrivate(c,\"reader\");if(!_)return;if(@isReadableStreamDefaultReader(_)){const n=@getByIdDirectPrivate(_,\"readRequests\");@putByIdDirectPrivate(_,\"readRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}else{@assert(@isReadableStreamBYOBReader(_));const n=@getByIdDirectPrivate(_,\"readIntoRequests\");@putByIdDirectPrivate(_,\"readIntoRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}@getByIdDirectPrivate(_,\"closedPromiseCapability\").@reject.@call(@undefined,f);const h=@getByIdDirectPrivate(_,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const h=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1708,7 +1708,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 283; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const g=@getByIdDirectPrivate(i,\"controlledReadableStream\"),d=@getByIdDirectPrivate(g,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\"),g=@getByIdDirectPrivate(d,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; // readableStreamReaderGenericCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1716,7 +1716,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 133; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (h,i){\"use strict\";const c=@getByIdDirectPrivate(h,\"ownerReadableStream\");return @assert(!!c),@readableStreamCancel(c,i)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,h){\"use strict\";const i=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,h)})\n"; // readableStreamCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,d){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const h=@getByIdDirectPrivate(i,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var _=@getByIdDirectPrivate(i,\"readableStreamController\"),p=_.@cancel;if(p)return p(_,d).@then(function(){});var u=_.close;if(u)return @Promise.@resolve(_.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (_,d){\"use strict\";@putByIdDirectPrivate(_,\"disturbed\",!0);const h=@getByIdDirectPrivate(_,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));@readableStreamClose(_);var p=@getByIdDirectPrivate(_,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,d).@then(function(){});var i=p.close;if(i)return @Promise.@resolve(p.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1740,7 +1740,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 519; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const f=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:f,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),d})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var d=@getByIdDirectPrivate(a,\"queue\");if(d.content.isNotEmpty()){const _=@dequeueValue(d);if(@getByIdDirectPrivate(a,\"closeRequested\")&&d.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:_,done:!1})}const f=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),f})\n"; // readableStreamDefaultControllerClose const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var i=d.shift();i;i=d.shift())@fulfillPromise(i,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1764,7 +1764,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadReq const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 157; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,p,y){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:p,done:y})})\n"; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (p,y,_){\"use strict\";const i=@getByIdDirectPrivate(@getByIdDirectPrivate(p,\"reader\"),\"readRequests\").shift();@fulfillPromise(i,{value:y,done:_})})\n"; // readableStreamDefaultControllerEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,D){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,D,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let d=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)d=@getByIdDirectPrivate(_,\"strategy\").size(D);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),D,d)}catch(d){throw @readableStreamDefaultControllerError(_,d),d}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (y){\"use strict\";const i=@getByIdDirectPrivate(y,\"ownerReadableStream\");@assert(!!i);const n=@getByIdDirectPrivate(i,\"state\");if(@putByIdDirectPrivate(i,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(i,\"readableStreamController\").@pull(@getByIdDirectPrivate(i,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,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 (J,P){\"use strict\";var G=@getByIdDirectPrivate(J,\"bunNativeType\"),B=@getByIdDirectPrivate(J,\"bunNativePtr\"),x=@lazyStreamPrototypeMap.@get(G);if(x===@undefined){let q=function(m){var{c:b,v:f}=this;this.c=@undefined,this.v=@undefined,I(m,b,f)},N=function(m){try{m.close()}catch(b){globalThis.reportError(b)}},O=function(m,b,f,j){j[0]=!1;var y;try{y=Q(m,f,j)}catch(Y){return b.error(Y)}return I(y,b,f)};var z=q,A=N,p=O,[Q,U,W,Z,D,K,X]=@lazyLoad(G),H=[!1],I;I=function m(b,f,j){if(b&&@isPromise(b))return b.then(q.bind({c:f,v:j}),(y)=>f.error(y));else if(typeof b===\"number\")if(j&&j.byteLength===b&&j.buffer===f.byobRequest\?.view\?.buffer)f.byobRequest.respondWithNewView(j);else f.byobRequest.respond(b);else if(b.constructor===@Uint8Array)f.enqueue(b);if(H[0]||b===!1)@enqueueJob(N,f),H[0]=!1};const F=D\?new FinalizationRegistry(D):null;x=class m{constructor(b,f,j){if(this.#f=b,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=f,j!==@undefined)this.start=(y)=>{y.enqueue(j)};if(F)F.register(this,b,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=U;#j(b){var f=this.#f;if(!f){b.close();return}O(f,b,b.byobRequest.view,H)}#m(b){var f=this.#f;F&&F.unregister(this.#b),K&&K(f,!1),W(f,b)}static deinit=D;static drain=X},@lazyStreamPrototypeMap.@set(G,x)}const L=x.startSync(B,P);var E;const{drain:M,deinit:_}=x;if(M)E=M(B);if(L===0){if(D&&B&&@enqueueJob(D,B),(E\?.byteLength\?\?0)>0)return{start(q){q.enqueue(E),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new x(B,L,E)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (P,F){\"use strict\";var L=@getByIdDirectPrivate(P,\"bunNativeType\"),G=@getByIdDirectPrivate(P,\"bunNativePtr\"),H=@lazyStreamPrototypeMap.@get(L);if(H===@undefined){let j=function(B){var{c:p,v:z}=this;this.c=@undefined,this.v=@undefined,W(B,p,z)},Z=function(B){try{B.close()}catch(p){globalThis.reportError(p)}},_=function(B,p,z,A){A[0]=!1;var D;try{D=b(B,z,A)}catch(E){return p.error(E)}return W(D,p,z)};var f=j,O=Z,m=_,[b,I,M,q,J,N,Q]=@lazyLoad(L),U=[!1],W;W=function B(p,z,A){if(p&&@isPromise(p))return p.then(j.bind({c:z,v:A}),(D)=>z.error(D));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(U[0]||p===!1)@enqueueJob(Z,z),U[0]=!1};const y=J\?new FinalizationRegistry(J):null;H=class B{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=(D)=>{D.enqueue(A)};if(y)y.register(this,p,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=I;#j(p){var z=this.#f;if(!z){p.close();return}_(z,p,p.byobRequest.view,U)}#m(p){var z=this.#f;y&&y.unregister(this.#b),N&&N(z,!1),M(z,p)}static deinit=J;static drain=Q},@lazyStreamPrototypeMap.@set(L,H)}const X=H.startSync(G,F);var Y;const{drain:x,deinit:K}=H;if(x)Y=x(G);if(X===0){if(J&&G&&@enqueueJob(J,G),(Y\?.byteLength\?\?0)>0)return{start(j){j.enqueue(Y),j.close()},type:\"bytes\"};return{start(j){j.close()},type:\"bytes\"}}return new H(G,X,Y)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (q){\"use strict\";var b=q.getReader(),f=b.readMany();async function g(j){if(j.done)return[];var _=j.value||[];while(!0){var p=await b.read();if(p.done)break;_=_.concat(p.value)}return _}if(f&&@isPromise(f))return f.@then(g);return g(f)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var b=_.getReader(),g=b.readMany();async function j(p){if(p.done)return[];var f=p.value||[];while(!0){var q=await b.read();if(q.done)break;f=f.concat(q.value)}return f}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1836,7 +1836,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 214; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (_){\"use strict\";const[h,d]=@createTextStream(@getByIdDirectPrivate(_,\"highWaterMark\")),i=@readStreamIntoSink(_,h,!1);if(i&&@isPromise(i))return @Promise.@resolve(i).@then(d.@promise);return d.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (i){\"use strict\";const[_,d]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),h=@readStreamIntoSink(i,_,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; // readableStreamToArrayBufferDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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 (O,A){\"use strict\";var j=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var B=@getByIdDirectPrivate(O,\"highWaterMark\");j.start(B\?{highWaterMark:B}:{});var w=@newPromiseCapability(@Promise),q=!1,x=A.pull,v=A.close,z={start(){},close(_){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},end(){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},flush(){return 0},write:j.write.bind(j)},C=!1;try{const _=x(z);if(_&&@isObject(_)&&@isPromise(_))return async function(D,F,G){while(!q)await G(D);return await F}(z,promise,x);return w.@promise}catch(_){return C=!0,@readableStreamError(O,_),@Promise.@reject(_)}finally{if(!C&&O)@readableStreamClose(O);z=v=j=x=O=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,_){\"use strict\";var q=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var v=@getByIdDirectPrivate(O,\"highWaterMark\");q.start(v\?{highWaterMark:v}:{});var w=@newPromiseCapability(@Promise),A=!1,z=_.pull,B=_.close,C={start(){},close(F){if(!A){if(A=!0,B)B();@fulfillPromise(w.@promise,q.end())}},end(){if(!A){if(A=!0,B)B();@fulfillPromise(w.@promise,q.end())}},flush(){return 0},write:q.write.bind(q)},D=!1;try{const F=z(C);if(F&&@isObject(F)&&@isPromise(F))return async function(G,j,x){while(!A)await x(G);return await j}(C,promise,z);return w.@promise}catch(F){return D=!0,@readableStreamError(O,F),@Promise.@reject(F)}finally{if(!D&&O)@readableStreamClose(O);C=B=q=z=O=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,h){\"use strict\";const j=@initializeTextStream.@call(_,h,@undefined);var f=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await f.read();if(k.done)break}try{f.releaseLock()}catch(p){}return f=@undefined,_=@undefined,j.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var k=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(_){}return k=@undefined,f=@undefined,j.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,j){\"use strict\";const p=@initializeArrayStream.@call(f,j,@undefined);j=@undefined;var _=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var q=await _.read();if(q.done)break}try{_.releaseLock()}catch(k){}return _=@undefined,@Promise.@resolve(p.@promise)}catch(k){throw k}finally{f=@undefined,_=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,j){\"use strict\";const k=@initializeArrayStream.@call(_,j,@undefined);j=@undefined;var p=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var q=await p.read();if(q.done)break}try{p.releaseLock()}catch(f){}return p=@undefined,@Promise.@resolve(k.@promise)}catch(f){throw f}finally{_=@undefined,p=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (i){\"use strict\";var B=globalThis.Symbol.asyncIterator,w=async function*x(k,G){var z=k.getReader(),g;try{while(!0){var j,q;const h=z.readMany();if(@isPromise(h))({done:j,value:q}=await h);else({done:j,value:q}=h);if(j)return;yield*q}}catch(h){g=h}finally{if(z.releaseLock(),!G)k.cancel(g);if(g)throw g}},D=function x(){return w(this,!1)},F=function x({preventCancel:k=!1}={preventCancel:!1}){return w(this,k)};return @Object.@defineProperty(i,B,{value:D}),@Object.@defineProperty(i,\"values\",{value:F}),i})\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) \ @@ -1894,7 +1894,7 @@ const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeCons const JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 339; static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),u=@getByIdDirectPrivate(_,\"readable\"),i=@getByIdDirectPrivate(u,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(i)})\n"; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),i=@getByIdDirectPrivate(_,\"readable\"),u=@getByIdDirectPrivate(i,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(u)})\n"; // enqueue const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1986,7 +1986,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const u=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(u){const f=u.@call(n,\"string\");if(typeof f===\"string\")switch(@argumentCount()){case 1:return new @Buffer(f);case 2:return new @Buffer(f,@argument(1));default:return new @Buffer(f,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; // isBuffer const JSC::ConstructAbility s_jsBufferConstructorIsBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2028,7 +2028,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 j=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!j)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const I=@getByIdDirectPrivate(j,\"state\");if(@putByIdDirectPrivate(j,\"disturbed\",!0),I===@streamClosed)return{value:[],size:0,done:!0};else if(I===@streamErrored)throw @getByIdDirectPrivate(j,\"storedError\");var B=@getByIdDirectPrivate(j,\"readableStreamController\"),F=@getByIdDirectPrivate(B,\"queue\");if(!F)return B.@pull(B).@then(function({done:_,value:w}){return _\?{done:!0,value:[],size:0}:{value:[w],size:1,done:!1}});const N=F.content;var Q=F.size,x=N.toArray(!1),C=x.length;if(C>0){var D=@newArrayWithSize(C);if(@isReadableByteStreamController(B)){{const _=x[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(D,0,_)}for(var d=1;d{if(_.done)return{value:[],size:0,done:!0};var w=@getByIdDirectPrivate(j,\"readableStreamController\"),G=@getByIdDirectPrivate(w,\"queue\"),k=[_.value].concat(G.content.toArray(!1)),K=k.length;if(@isReadableByteStreamController(w))for(var A=0;A0){var D=@newArrayWithSize(I);if(@isReadableByteStreamController(G)){{const K=E[0];if(!(@ArrayBuffer.@isView(K)||K instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(K.buffer,K.byteOffset,K.byteLength));else @putByValDirect(D,0,K)}for(var J=1;J{if(K.done)return{value:[],size:0,done:!0};var B=@getByIdDirectPrivate(S,\"readableStreamController\"),F=@getByIdDirectPrivate(B,\"queue\"),N=[K.value].concat(F.content.toArray(!1)),j=N.length;if(@isReadableByteStreamController(B))for(var H=0;H0}shift(){var{_head:g,_tail:b,_list:x,_capacityMask:M}=this;if(g===b)return @undefined;var w=x[g];if(@putByValDirect(x,g,@undefined),g=this._head=g+1&M,g<2&&b>1e4&&b<=x.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(g){var b=this._tail;if(@putByValDirect(this._list,b,g),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(g){var b=this._list,x=@toLength(b.length);if(g||this._head>this._tail){var M=@toLength(this._head),w=@toLength(this._tail),F=@toLength(x-M+w),z=@newArrayWithSize(F),B=0;for(var v=M;v>>=1,this._capacityMask>>>=1}}return new A})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var b=@Array.prototype.slice;class w{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:x,_tail:g,_list:M,_capacityMask:z}=this;if(x===g)return @undefined;var A=M[x];if(@putByValDirect(M,x,@undefined),x=this._head=x+1&z,x<2&&g>1e4&&g<=M.length>>>2)this._shrinkArray();return A}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(x){var g=this._tail;if(@putByValDirect(this._list,g,x),this._tail=g+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(x){var g=this._list,M=@toLength(g.length);if(x||this._head>this._tail){var z=@toLength(this._head),A=@toLength(this._tail),B=@toLength(M-z+A),E=@newArrayWithSize(B),v=0;for(var F=z;F>>=1,this._capacityMask>>>=1}}return new w})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2158,7 +2158,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 (d,o,n){\"use strict\";if(n=@toNumber(n),!@isFinite(n)||n<0)@throwRangeError(\"size has an incorrect value\");d.content.push({value:o,size:n}),d.size+=n})\n"; +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"; // peekQueueValue const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2182,7 +2182,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 (p){\"use strict\";const d=p.size;if(d===@undefined)return()=>1;if(typeof d!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(w)=>{return d(w)}})\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; @@ -2190,7 +2190,7 @@ const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorK const JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsExtractHighWaterMarkCodeLength = 188; static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (b,c){\"use strict\";const o=b.highWaterMark;if(o===@undefined)return c;if(@isNaN(o)||o<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(o)})\n"; +const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (o,b){\"use strict\";const c=o.highWaterMark;if(c===@undefined)return b;if(@isNaN(c)||c<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(c)})\n"; // extractHighWaterMarkFromQueuingStrategyInit const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2206,7 +2206,7 @@ const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructo const JSC::ImplementationVisibility s_streamInternalsCreateFulfilledPromiseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsCreateFulfilledPromiseCodeLength = 81; static const JSC::Intrinsic s_streamInternalsCreateFulfilledPromiseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (n){\"use strict\";const d=@newPromise();return @fulfillPromise(d,n),d})\n"; +const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (d){\"use strict\";const n=@newPromise();return @fulfillPromise(n,d),n})\n"; // toDictionary const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (B){\"use strict\";var D=@Loader,H=@createFIFO(),_=B;while(_){var w=D.registry.@get(_);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(_),w=D.registry.@get(_);var W=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),x=D.parseModule(_,W),z=w.module;if(x&&@isPromise(x)){var J=@getPromiseInternalField(x,@promiseFieldReactionsOrResult),X=@getPromiseInternalField(x,@promiseFieldFlags),Q=X&@promiseStateMask;if(Q===@promiseStatePending||J&&@isPromise(J))@throwTypeError(`require() async module \"${_}\" is unsupported. use \"await import()\" instead.`);else if(Q===@promiseStateRejected){if(!J\?.message)@throwTypeError(`${J+\"\"\?J:\"An error occurred\"} occurred while parsing module \\\"${_}\\\"`);throw J}w.module=z=J}else if(x&&!z)w.module=z=x;@setStateToMax(w,@ModuleLink);var Y=z.dependenciesMap,I=D.requestedModules(z),T=@newArrayWithSize(I.length);for(var F=0,Z=I.length;F=@ModuleLink)_=H.shift()}var V=D.linkAndEvaluateModule(B,@undefined);if(V&&@isPromise(V))@throwTypeError(`require() async module \\\"${B}\\\" is unsupported. use \"await import()\" instead.`);return D.registry.@get(B)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (D){\"use strict\";var H=@Loader,_=@createFIFO(),I=D;while(I){var w=H.registry.@get(I);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(I),w=H.registry.@get(I);var L=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),J=H.parseModule(I,L),Q=w.module;if(J&&@isPromise(J)){var T=@getPromiseInternalField(J,@promiseFieldReactionsOrResult),x=@getPromiseInternalField(J,@promiseFieldFlags),U=x&@promiseStateMask;if(U===@promiseStatePending||T&&@isPromise(T))@throwTypeError(`require() async module \"${I}\" is unsupported. use \"await import()\" instead.`);else if(U===@promiseStateRejected){if(!T\?.message)@throwTypeError(`${T+\"\"\?T:\"An error occurred\"} occurred while parsing module \\\"${I}\\\"`);throw T}w.module=Q=T}else if(J&&!Q)w.module=Q=J;@setStateToMax(w,@ModuleLink);var V=Q.dependenciesMap,W=H.requestedModules(Q),X=@newArrayWithSize(W.length);for(var Y=0,Z=W.length;Y=@ModuleLink)I=_.shift()}var G=H.linkAndEvaluateModule(D,@undefined);if(G&&@isPromise(G))@throwTypeError(`require() async module \\\"${D}\\\" is unsupported. use \"await import()\" instead.`);return H.registry.@get(D)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (c){\"use strict\";var a=@Loader.registry.@get(c);if(!a||!a.evaluated)a=@loadCJS2ESM(c);if(!a||!a.evaluated||!a.module)@throwTypeError(`require() failed to evaluate module \"${c}\". This is an internal consistentency error.`);var _=@Loader.getModuleNamespaceObject(a.module);if(_[@commonJSSymbol]===0)return;return _})\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; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var n=@requireMap.@get(_);const g=_.substring(_.length-5);if(n)return n.exports;if(g===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else if(g===\".node\"){const k=@createCommonJSModule(_,{},!0);return process.dlopen(k,_),@requireMap.@set(_,k),k.exports}else if(g===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else{var b=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var q=b\?.default;if(q\?.[@commonJSSymbol]===0)b=q;return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}})\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(),n=JSON.parse(k.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}else if(j===\".node\"){const q=@createCommonJSModule(b,{},!0);return process.dlopen(q,b),@requireMap.@set(b,q),q.exports}else if(j===\".toml\"){var k=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),n=@Bun.TOML.parse(k.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}else{var n=@requireESM(b);const v=@requireMap.@get(b);if(v)return v.exports;var _=n\?.default;if(_\?.[@commonJSSymbol]===0)n=_;return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2256,7 +2256,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var c=new Map,L={};return new Proxy(L,{get(f,_){const h=@requireMap.@get(_);if(h)return h;const t=@Loader.registry.@get(_);if(t\?.evaluated){const u=@Loader.getModuleNamespaceObject(t.module),g=u[@commonJSSymbol]===0||u.default\?.[@commonJSSymbol]\?u.default:u,b=@createCommonJSModule(_,g,!0);return @requireMap.@set(_,b),b}return L[_]},set(f,_,h){return @requireMap.@set(_,h),!0},has(f,_){return @requireMap.@has(_)||@Loader.registry.@has(_)},deleteProperty(f,_){return c.@delete(_),@requireMap.@delete(_),@Loader.registry.@delete(_),!0},ownKeys(f){var _=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let t of h)if(!_.includes(t))@arrayPush(_,t);return _},getPrototypeOf(f){return null},getOwnPropertyDescriptor(f,_){if(@requireMap.@has(_)||@Loader.registry.@has(_))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,f={};return new Proxy(f,{get(h,t){const u=@requireMap.@get(t);if(u)return u;const L=@Loader.registry.@get(t);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(t,c,!0);return @requireMap.@set(t,g),g}return f[t]},set(h,t,u){return @requireMap.@set(t,u),!0},has(h,t){return @requireMap.@has(t)||@Loader.registry.@has(t)},deleteProperty(h,t){return _.@delete(t),@requireMap.@delete(t),@Loader.registry.@delete(t),!0},ownKeys(h){var t=[...@requireMap.@keys()];const u=[...@Loader.registry.@keys()];for(let L of u)if(!t.includes(L))@arrayPush(t,L);return t},getPrototypeOf(h){return null},getOwnPropertyDescriptor(h,t){if(@requireMap.@has(t)||@Loader.registry.@has(t))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2440,7 +2440,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const B=_.type===\"direct\",b=!!_.@lazy,I=B||b;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!I){const v=@getByIdDirectPrivate(f,\"size\"),m=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",m),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,v,m!==@undefined\?m:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(B)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(I){const v=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",v||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const m=@lazyLoadStream(this,v);if(m)@createReadableStreamController(this,m,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,I=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!I){const _=@getByIdDirectPrivate(m,\"size\"),b=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,b!==@undefined\?b:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(I){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,_);if(b)@createReadableStreamController(this,b,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2448,7 +2448,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorK const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayCodeLength = 173; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayDirect(_,b);return @readableStreamIntoArray(_)})\n"; +const char* const s_readableStreamReadableStreamToArrayCode = "(function (b){\"use strict\";var _=@getByIdDirectPrivate(b,\"underlyingSource\");if(_!==@undefined)return @readableStreamToArrayDirect(b,_);return @readableStreamIntoArray(b)})\n"; // readableStreamToText const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2464,7 +2464,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2488,7 +2488,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 (G,k,x){\"use strict\";const A=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var j=globalThis[A];if(!j)j=globalThis[A]=[];var q=j[k];if(q===@undefined){var[L,H,I,J,N,B]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](k);q=class K{handleError;handleClosed;processResult;constructor(_,F){this.#_=F,this.#F=_,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),_.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var _=this.#_;this.#_=0,J(_),B(_)}_handleError(_){if(this.#$)return;this.#$=!0;var F=this.#_;this.#_=0,H(F,_),B(F)}#_;#$=!1;#F;_handleReadMany({value:_,done:F,size:w}){if(F){this.handleClosed();return}if(this.#$)return;I(this.#_,_,F,w)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(_){if(_&&@isPromise(_)){if(@getPromiseInternalField(_,@promiseFieldFlags)&@promiseStateFulfilled){const w=@getPromiseInternalField(_,@promiseFieldReactionsOrResult);if(w)_=w}}if(_&&@isPromise(_))return _.then(this.processResult,this.handleError),null;if(_.done)return this.handleClosed(),0;else if(_.value)return _.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const D=k+1;if(j.length{@putByIdDirectPrivate(v,\"started\",1),@assert(!@getByIdDirectPrivate(v,\"pulling\")),@assert(!@getByIdDirectPrivate(v,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(v)},(d)=>{if(@getByIdDirectPrivate(b,\"state\")===@streamReadable)@readableByteStreamControllerError(v,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (_,v,b){\"use strict\";if(!@isReadableStream(_))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(_,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",_),@putByIdDirectPrivate(this,\"underlyingByteSource\",v),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let p=@toNumber(b);if(@isNaN(p)||p<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",p);let R=v.autoAllocateChunkSize;if(R!==@undefined){if(R=@toNumber(R),R<=0||R===@Infinity||R===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",R),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const d=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(d,\"underlyingByteSource\"),\"start\",[d]).@then(()=>{@putByIdDirectPrivate(d,\"started\",1),@assert(!@getByIdDirectPrivate(d,\"pulling\")),@assert(!@getByIdDirectPrivate(d,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(d)},(f)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(d,f)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2684,7 +2684,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var _=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=_.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2716,7 +2716,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 272; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const _=@getByIdDirectPrivate(u,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const d=@getByIdDirectPrivate(u,\"controlledReadableStream\"),_=@getByIdDirectPrivate(d,\"state\");if(_===@streamErrored)return null;if(_===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; // readableStreamHasBYOBReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2724,7 +2724,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBRea const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 125; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (u){\"use strict\";const n=@getByIdDirectPrivate(u,\"reader\");return n!==@undefined&&@isReadableStreamBYOBReader(n)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (n){\"use strict\";const u=@getByIdDirectPrivate(n,\"reader\");return u!==@undefined&&@isReadableStreamBYOBReader(u)})\n"; // readableStreamHasDefaultReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2732,7 +2732,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefault const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength = 128; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (n){\"use strict\";const l=@getByIdDirectPrivate(n,\"reader\");return l!==@undefined&&@isReadableStreamDefaultReader(l)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (l){\"use strict\";const n=@getByIdDirectPrivate(l,\"reader\");return n!==@undefined&&@isReadableStreamDefaultReader(n)})\n"; // readableByteStreamControllerHandleQueueDrain const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const P=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(P)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const d=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=d.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let h;try{h=new @Uint8Array(d.buffer,d.byteOffset,d.byteLength)}catch(F){return @Promise.@reject(F)}return @createFulfilledPromise({value:h,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let d;try{d=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(F){return @Promise.@reject(F)}const h={buffer:d,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(h)}const R=@readableStreamAddReadRequest(P);return @readableByteStreamControllerCallPullIfNeeded(_),R})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const h=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(h)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const F=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=F.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let P;try{P=new @Uint8Array(F.buffer,F.byteOffset,F.byteLength)}catch(R){return @Promise.@reject(R)}return @createFulfilledPromise({value:P,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let F;try{F=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(R){return @Promise.@reject(R)}const P={buffer:F,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(P)}const d=@readableStreamAddReadRequest(h);return @readableByteStreamControllerCallPullIfNeeded(_),d})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2788,7 +2788,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1076; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (d,i){\"use strict\";const _=@getByIdDirectPrivate(d,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(d,\"closeRequested\")),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@getByIdDirectPrivate(_,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(_,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);else{@assert(!@getByIdDirectPrivate(d,\"queue\").content.size());const f=i.constructor===@Uint8Array\?i:new @Uint8Array(i.buffer,i.byteOffset,i.byteLength);@readableStreamFulfillReadRequest(_,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength),@readableByteStreamControllerProcessPullDescriptors(d);break}case 3:break;default:{@assert(!@isReadableStreamLocked(_)),@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);break}}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,_){\"use strict\";const f=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(f,\"state\")===@streamReadable),@getByIdDirectPrivate(f,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(f,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(f,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const d=_.constructor===@Uint8Array\?_:new @Uint8Array(_.buffer,_.byteOffset,_.byteLength);@readableStreamFulfillReadRequest(f,d,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(f)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength);break}}})\n"; // readableByteStreamControllerEnqueueChunk const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2796,7 +2796,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,d,p,a){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:d,byteOffset:p,byteLength:a}),@getByIdDirectPrivate(_,\"queue\").size+=a})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,d,p){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:d,byteLength:p}),@getByIdDirectPrivate(_,\"queue\").size+=p})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2804,7 +2804,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 417; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (d,u){\"use strict\";@assert(@getByIdDirectPrivate(d,\"pendingPullIntos\").isNotEmpty());let a=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek();if(a.byteOffset+a.bytesFilled!==u.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(a.byteLength!==u.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");a.buffer=u.buffer,@readableByteStreamControllerRespondInternal(d,u.byteLength)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (u,a){\"use strict\";@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty());let d=@getByIdDirectPrivate(u,\"pendingPullIntos\").peek();if(d.byteOffset+d.bytesFilled!==a.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(d.byteLength!==a.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");d.buffer=a.buffer,@readableByteStreamControllerRespondInternal(u,a.byteLength)})\n"; // readableByteStreamControllerRespond const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2812,7 +2812,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength = 251; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (I,u){\"use strict\";if(u=@toNumber(u),@isNaN(u)||u===@Infinity||u<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(I,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(I,u)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (u,I){\"use strict\";if(I=@toNumber(I),@isNaN(I)||I===@Infinity||I<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(u,I)})\n"; // readableByteStreamControllerRespondInternal const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2828,7 +2828,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,_,f){\"use strict\";if(f.bytesFilled+_>f.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===f),@readableByteStreamControllerInvalidateBYOBRequest(w),f.bytesFilled+=_,f.bytesFilled0){const h=f.byteOffset+f.bytesFilled,g=@cloneArrayBuffer(f.buffer,h-R,R);@readableByteStreamControllerEnqueueChunk(w,g,0,g.byteLength)}f.buffer=@transferBufferToCurrentRealm(f.buffer),f.bytesFilled-=R,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),f),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (f,R,w){\"use strict\";if(w.bytesFilled+R>w.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(f,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(f,\"pendingPullIntos\").peek()===w),@readableByteStreamControllerInvalidateBYOBRequest(f),w.bytesFilled+=R,w.bytesFilled0){const g=w.byteOffset+w.bytesFilled,h=@cloneArrayBuffer(w.buffer,g-_,_);@readableByteStreamControllerEnqueueChunk(f,h,0,h.byteLength)}w.buffer=@transferBufferToCurrentRealm(w.buffer),w.bytesFilled-=_,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(f,\"controlledReadableStream\"),w),@readableByteStreamControllerProcessPullDescriptors(f)})\n"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2852,7 +2852,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 (q,_){\"use strict\";const H=_.bytesFilled-_.bytesFilled%_.elementSize,z=@getByIdDirectPrivate(q,\"queue\").size<_.byteLength-_.bytesFilled\?@getByIdDirectPrivate(q,\"queue\").size:_.byteLength-_.bytesFilled,E=_.bytesFilled+z,G=E-E%_.elementSize;let v=z,w=!1;if(G>H)v=G-_.bytesFilled,w=!0;while(v>0){let j=@getByIdDirectPrivate(q,\"queue\").content.peek();const k=v0),@assert(_.bytesFilled<_.elementSize);return w})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode = "(function (_,q){\"use strict\";const z=q.bytesFilled-q.bytesFilled%q.elementSize,j=@getByIdDirectPrivate(_,\"queue\").sizez)G=k-q.bytesFilled,v=!0;while(G>0){let H=@getByIdDirectPrivate(_,\"queue\").content.peek();const w=G0),@assert(q.bytesFilled0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,_)){const k=@readableByteStreamControllerConvertDescriptor(_);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}_.buffer=@transferBufferToCurrentRealm(_.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(_);const R=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(b),R})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (_,E){\"use strict\";const b=@getByIdDirectPrivate(_,\"controlledReadableStream\");let d=1;if(E.BYTES_PER_ELEMENT!==@undefined)d=E.BYTES_PER_ELEMENT;const k=E.constructor,A={buffer:E.buffer,byteOffset:E.byteOffset,byteLength:E.byteLength,bytesFilled:0,elementSize:d,ctor:k,readerType:\"byob\"};var L=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(L\?.isNotEmpty())return A.buffer=@transferBufferToCurrentRealm(A.buffer),L.push(A),@readableStreamAddReadIntoRequest(b);if(@getByIdDirectPrivate(b,\"state\")===@streamClosed){const R=new k(A.buffer,A.byteOffset,0);return @createFulfilledPromise({value:R,done:!0})}if(@getByIdDirectPrivate(_,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(_,A)){const R=@readableByteStreamControllerConvertDescriptor(A);return @readableByteStreamControllerHandleQueueDrain(_),@createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(_,\"closeRequested\")){const R=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(_,R),@Promise.@reject(R)}}A.buffer=@transferBufferToCurrentRealm(A.buffer),@getByIdDirectPrivate(_,\"pendingPullIntos\").push(A);const N=@readableStreamAddReadIntoRequest(b);return @readableByteStreamControllerCallPullIfNeeded(_),N})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2942,7 +2942,7 @@ const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructor const JSC::ImplementationVisibility s_writableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamDefaultControllerErrorCodeLength = 301; static const JSC::Intrinsic s_writableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamDefaultControllerErrorCode = "(function (r){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const t=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(t,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(this,r)})\n"; +const char* const s_writableStreamDefaultControllerErrorCode = "(function (t){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const r=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(r,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(this,t)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2960,7 +2960,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 F extends EventTarget{#B;#$;#J;#K;#L;#M=!1;#A=null;#j=\"\";#O=\"\";#Q=\"\";#U=!0;#F=0;#G=0;#X=0;#w=null;static#V(j){j.#H()}static#Y(j,A){const w=j.data,B=w.#Q\?`Last-Event-ID: ${w.#Q}\\r\\n`:\"\",K=`GET ${A.pathname}${A.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${B}\\r\\n`,G=j.write(K);if(G!==K.length)w.#O=K.substring(G)}static#Z(j,A,w){for(;;){if(w>=A.length)return;let B=-1,K=A.indexOf(\"\\r\\n\",w);const G=K+2;if(K>0)if(j.#F===0){const J=parseInt(A.substring(w,K),16);if(J===0){j.#$=2,j.#A\?.end();return}B=G+J}else B=A.length;else{if(j.#j.length===0){j.#j+=A.substring(w);return}B=A.length}let M=A.substring(G,B);w=B+2;let Z=0,L=M.indexOf(\"\\n\\n\");if(L==-1){j.#j+=A.substring(G);return}if(j.#j.length)j.#j+=M,M=j.#j,j.#j=\"\";let X=!0;while(X){const J=M.substring(Z,L);let Y,O=\"\",Q,W=0,V=-1;for(;;){let z=J.indexOf(\"\\n\",W);if(z===-1){if(W>=J.length)break;z=J.length}const U=J.substring(W,z);if(U.startsWith(\"data:\"))if(O.length)O+=`\\n${U.substring(5).trim()}`;else O=U.substring(5).trim();else if(U.startsWith(\"event:\"))Y=U.substring(6).trim();else if(U.startsWith(\"id:\"))Q=U.substring(3).trim();else if(U.startsWith(\"retry:\")){if(V=parseInt(U.substring(6).trim(),10),@isNaN(V))V=-1}W=z+1}if(j.#Q=Q||\"\",V>=0)j.#X=V;if(O||Q||Y)j.dispatchEvent(new MessageEvent(Y||\"message\",{data:O||\"\",origin:j.#B.origin,source:j,lastEventId:Q}));if(M.length===L+2){X=!1;break}const H=M.indexOf(\"\\n\\n\",L+1);if(H===-1)break;Z=L,L=H}}}static#z={open(j){const A=j.data;if(A.#A=j,!A.#M)F.#Y(j,A.#B)},handshake(j,A,w){const B=j.data;if(A)F.#Y(j,B.#B);else B.#$=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:w})),j.end()},data(j,A){const w=j.data;switch(w.#$){case 0:{let B=A.toString();const K=B.indexOf(\"\\r\\n\\r\\n\");if(K===-1){w.#j+=B;return}if(w.#j.length)w.#j+=B,B=w.#j,w.#j=\"\";const G=B.substring(0,K),M=G.indexOf(\"\\r\\n\");if(M===-1){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),j.end();return}const Z=G.substring(0,M);if(Z!==\"HTTP/1.1 200 OK\"){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Z)})),j.end();return}let L=M+1,X=!1,J=-1;for(;;){let O=G.indexOf(\"\\r\\n\",L);if(O===-1){if(L>=G.length){if(!X)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.`)})),j.end();return}O=G.length}const Q=G.substring(L+1,O),W=Q.indexOf(\":\"),V=Q.substring(0,W),H=V.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(L=O+1,H)if(Q.endsWith(\" text/event-stream\"))X=!0;else{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.`)})),j.end();return}else if(V.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(J=parseInt(Q.substring(W+1).trim(),10),@isNaN(J)||J<=0){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),j.end();return}if(X)break}else if(V.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(Q.substring(W+1).trim()!==\"chunked\"){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),j.end();return}if(J=0,X)break}}w.#F=J,w.#$=1,w.dispatchEvent(new Event(\"open\"));const Y=B.substring(K+4);if(F.#Z(w,Y,0),w.#F>0){if(w.#G+=Y.length,w.#G>=w.#F)w.#$=2,j.end()}return}case 1:if(F.#Z(w,A.toString(),2),w.#F>0){if(w.#G+=A.byteLength,w.#G>=w.#F)w.#$=2,j.end()}return;default:break}},drain(j){const A=j.data;if(A.#$===0){const w=A.#j;if(w.length){const B=j.write(w);if(B!==w.length)j.data.#O=w.substring(B);else j.data.#O=\"\"}}},close:F.#W,end(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#W(j){const A=j.data;if(A.#A=null,A.#G=0,A.#$=2,A.#U){if(A.#w)clearTimeout(A.#w);A.#w=setTimeout(F.#V,A.#X,A)}return A}constructor(j,A=@undefined){super();const w=new URL(j);this.#M=w.protocol===\"https:\",this.#B=w,this.#$=2,process.nextTick(F.#V,this)}ref(){this.#w\?.ref(),this.#A\?.ref()}unref(){this.#w\?.unref(),this.#A\?.unref()}#H(){if(this.#$!==2)return;const j=this.#B,A=this.#M;this.#$=0,@Bun.connect({data:this,socket:F.#z,hostname:j.hostname,port:parseInt(j.port||(A\?\"443\":\"80\"),10),tls:A\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((w)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:w})),this.#U){if(this.#w)this.#w.unref\?.();this.#w=setTimeout(F.#V,1000,this)}})}get url(){return this.#B.href}get readyState(){return this.#$}close(){this.#U=!1,this.#$=2,this.#A\?.unref(),this.#A\?.end()}get onopen(){return this.#L}get onerror(){return this.#J}get onmessage(){return this.#K}set onopen(j){if(this.#L)super.removeEventListener(\"close\",this.#L);super.addEventListener(\"open\",j),this.#L=j}set onerror(j){if(this.#J)super.removeEventListener(\"error\",this.#J);super.addEventListener(\"error\",j),this.#J=j}set onmessage(j){if(this.#K)super.removeEventListener(\"message\",this.#K);super.addEventListener(\"message\",j),this.#K=j}}return Object.defineProperty(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class F 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,Y){const O=W.data,Z=O.#L\?`Last-Event-ID: ${O.#L}\\r\\n`:\"\",j=`GET ${Y.pathname}${Y.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${Z}\\r\\n`,G=W.write(j);if(G!==j.length)O.#K=j.substring(G)}static#Y(W,Y,O){for(;;){if(O>=Y.length)return;let Z=-1,j=Y.indexOf(\"\\r\\n\",O);const G=j+2;if(j>0)if(W.#O===0){const w=parseInt(Y.substring(O,j),16);if(w===0){W.#j=2,W.#G\?.end();return}Z=G+w}else Z=Y.length;else{if(W.#J.length===0){W.#J+=Y.substring(O);return}Z=Y.length}let z=Y.substring(G,Z);O=Z+2;let B=0,J=z.indexOf(\"\\n\\n\");if(J==-1){W.#J+=Y.substring(G);return}if(W.#J.length)W.#J+=z,z=W.#J,W.#J=\"\";let K=!0;while(K){const w=z.substring(B,J);let Q,L=\"\",X,A=0,U=-1;for(;;){let V=w.indexOf(\"\\n\",A);if(V===-1){if(A>=w.length)break;V=w.length}const H=w.substring(A,V);if(H.startsWith(\"data:\"))if(L.length)L+=`\\n${H.substring(5).trim()}`;else L=H.substring(5).trim();else if(H.startsWith(\"event:\"))Q=H.substring(6).trim();else if(H.startsWith(\"id:\"))X=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(U=parseInt(H.substring(6).trim(),10),@isNaN(U))U=-1}A=V+1}if(W.#L=X||\"\",U>=0)W.#U=U;if(L||X||Q)W.dispatchEvent(new MessageEvent(Q||\"message\",{data:L||\"\",origin:W.#$.origin,source:W,lastEventId:X}));if(z.length===J+2){K=!1;break}const M=z.indexOf(\"\\n\\n\",J+1);if(M===-1)break;B=J,J=M}}}static#Z={open(W){const Y=W.data;if(Y.#G=W,!Y.#F)F.#X(W,Y.#$)},handshake(W,Y,O){const Z=W.data;if(Y)F.#X(W,Z.#$);else Z.#j=2,Z.dispatchEvent(new ErrorEvent(\"error\",{error:O})),W.end()},data(W,Y){const O=W.data;switch(O.#j){case 0:{let Z=Y.toString();const j=Z.indexOf(\"\\r\\n\\r\\n\");if(j===-1){O.#J+=Z;return}if(O.#J.length)O.#J+=Z,Z=O.#J,O.#J=\"\";const G=Z.substring(0,j),z=G.indexOf(\"\\r\\n\");if(z===-1){O.#j=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),W.end();return}const B=G.substring(0,z);if(B!==\"HTTP/1.1 200 OK\"){O.#j=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(B)})),W.end();return}let J=z+1,K=!1,w=-1;for(;;){let L=G.indexOf(\"\\r\\n\",J);if(L===-1){if(J>=G.length){if(!K)O.#j=2,O.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}L=G.length}const X=G.substring(J+1,L),A=X.indexOf(\":\"),U=X.substring(0,A),M=U.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(J=L+1,M)if(X.endsWith(\" text/event-stream\"))K=!0;else{O.#j=2,O.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(U.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(w=parseInt(X.substring(A+1).trim(),10),@isNaN(w)||w<=0){O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),W.end();return}if(K)break}else if(U.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(X.substring(A+1).trim()!==\"chunked\"){O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),W.end();return}if(w=0,K)break}}O.#O=w,O.#j=1,O.dispatchEvent(new Event(\"open\"));const Q=Z.substring(j+4);if(F.#Y(O,Q,0),O.#O>0){if(O.#Q+=Q.length,O.#Q>=O.#O)O.#j=2,W.end()}return}case 1:if(F.#Y(O,Y.toString(),2),O.#O>0){if(O.#Q+=Y.byteLength,O.#Q>=O.#O)O.#j=2,W.end()}return;default:break}},drain(W){const Y=W.data;if(Y.#j===0){const O=Y.#J;if(O.length){const Z=W.write(O);if(Z!==O.length)W.data.#K=O.substring(Z);else W.data.#K=\"\"}}},close:F.#z,end(W){F.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(W){F.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(W){const Y=W.data;if(Y.#G=null,Y.#Q=0,Y.#j=2,Y.#M){if(Y.#V)clearTimeout(Y.#V);Y.#V=setTimeout(F.#W,Y.#U,Y)}return Y}constructor(W,Y=@undefined){super();const O=new URL(W);this.#F=O.protocol===\"https:\",this.#$=O,this.#j=2,process.nextTick(F.#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.#$,Y=this.#F;this.#j=0,@Bun.connect({data:this,socket:F.#Z,hostname:W.hostname,port:parseInt(W.port||(Y\?\"443\":\"80\"),10),tls:Y\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((O)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:O})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(F.#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(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/src/js/out/modules/node/stream.js b/src/js/out/modules/node/stream.js index 0497ffd82..06727e66e 100644 --- a/src/js/out/modules/node/stream.js +++ b/src/js/out/modules/node/stream.js @@ -1,2 +1,2 @@ -import{EventEmitter as Iq} from"bun:events_native";import{StringDecoder as aq} from"node:string_decoder";var tq=function(a){return typeof a==="object"&&a!==null&&a instanceof ReadableStream},eq=function(a,j){if(typeof a!=="boolean")throw new qQ(j,"boolean",a)};var qQ=function(a,j,B){return new Error(`The argument '${a}' is invalid. Received '${B}' for type '${j}'`)},QQ=function(a,j,B){return new Error(`The value '${j}' is invalid for argument '${a}'. Reason: ${B}`)},YQ=function(a,j){var[B,G,y,A,M,R,P]=globalThis[Symbol.for("Bun.lazy")](a),g=[!1],k=function(E,I,Z,U){if(I>0){const T=Z.subarray(0,I),_=Z.subarray(I);if(T.byteLength>0)E.push(T);if(U)E.push(null);return _.byteLength>0?_:void 0}if(U)E.push(null);return Z},c=function(E,I,Z,U){if(I.byteLength>0)E.push(I);if(U)E.push(null);return Z},O=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const l=new FinalizationRegistry((E)=>E&&M(E)),D=512;var p=class E extends j{#q;#Q=1;#X=!1;#H=void 0;#J;#K=!1;#Z=!O;#B;constructor(I,Z={}){super(Z);if(typeof Z.highWaterMark==="number")this.#J=Z.highWaterMark;else this.#J=262144;this.#q=I,this.#X=!1,this.#H=void 0,this.#K=!1,this.#B={},l.register(this,this.#q,this.#B)}_read(I){if(this.#K)return;var Z=this.#q;if(Z===0){this.push(null);return}if(!this.#X)this.#$(Z);return this.#V(this.#z(I),Z)}#$(I){this.#X=!0;const Z=G(I,this.#J);if(typeof Z==="number"&&Z>1)this.#Z=!0,this.#J=Math.min(this.#J,Z);if(P){const U=P(I);if((U?.byteLength??0)>0)this.push(U)}}#z(I=this.#J){var Z=this.#H;if(Z?.byteLength??0D?I:D;this.#H=Z=new Buffer(U)}return Z}push(I,Z){return super.push(...arguments)}#Y(I,Z,U){if(typeof I==="number"){if(I>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0;return k(this,I,Z,U)}else if(typeof I==="boolean")return this.push(null),Z?.byteLength??0>0?Z:void 0;else if(ArrayBuffer.isView(I)){if(I.byteLength>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0;return c(this,I,Z,U)}else throw new Error("Invalid result from pull")}#V(I,Z){g[0]=!1;var U=B(Z,I,g);if(xq(U))return this.#K=!0,U.then((T)=>{this.#K=!1,this.#H=this.#Y(T,I,g[0])},(T)=>{errorOrDestroy(this,T)});else this.#H=this.#Y(U,I,g[0])}_destroy(I,Z){var U=this.#q;if(U===0){Z(I);return}if(l.unregister(this.#B),this.#q=0,R)R(U,!1);y(U,I),Z(I)}ref(){var I=this.#q;if(I===0)return;if(this.#Q++===0)R(I,!0)}unref(){var I=this.#q;if(I===0)return;if(this.#Q--===1)R(I,!1)}};if(!R)p.prototype.ref=void 0,p.prototype.unref=void 0;return p},lq=function(a,j){return $Q[a]||=YQ(a,j)},zQ=function(a,j,B){if(!(j&&typeof j==="object"&&j instanceof ReadableStream))return;const G=sq(j);if(!G){Gq("no native readable stream");return}const{stream:y,data:A}=G;return new(lq(A,a))(y,B)};var Gq=()=>{},{isPromise:xq,isCallable:oq,direct:sq,Object:zq}=globalThis[Symbol.for("Bun.lazy")]("primordials"),GQ=zq.create,MQ=zq.defineProperty,FQ=zq.getOwnPropertyDescriptor,rq=zq.getOwnPropertyNames,LQ=zq.getPrototypeOf,jQ=zq.prototype.hasOwnProperty,NQ=zq.setPrototypeOf,Bq=(a,j)=>function B(){return j||(0,a[rq(a)[0]])((j={exports:{}}).exports,j),j.exports};var Xq=process.nextTick;var AQ=Array.isArray,Vq=Bq({"node_modules/readable-stream/lib/ours/primordials.js"(a,j){j.exports={ArrayIsArray(B){return Array.isArray(B)},ArrayPrototypeIncludes(B,G){return B.includes(G)},ArrayPrototypeIndexOf(B,G){return B.indexOf(G)},ArrayPrototypeJoin(B,G){return B.join(G)},ArrayPrototypeMap(B,G){return B.map(G)},ArrayPrototypePop(B,G){return B.pop(G)},ArrayPrototypePush(B,G){return B.push(G)},ArrayPrototypeSlice(B,G,y){return B.slice(G,y)},Error,FunctionPrototypeCall(B,G,...y){return B.call(G,...y)},FunctionPrototypeSymbolHasInstance(B,G){return Function.prototype[Symbol.hasInstance].call(B,G)},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(B,G){return zq.defineProperties(B,G)},ObjectDefineProperty(B,G,y){return zq.defineProperty(B,G,y)},ObjectGetOwnPropertyDescriptor(B,G){return zq.getOwnPropertyDescriptor(B,G)},ObjectKeys(B){return zq.keys(B)},ObjectSetPrototypeOf(B,G){return zq.setPrototypeOf(B,G)},Promise,PromisePrototypeCatch(B,G){return B.catch(G)},PromisePrototypeThen(B,G,y){return B.then(G,y)},PromiseReject(B){return Promise.reject(B)},ReflectApply:Reflect.apply,RegExpPrototypeTest(B,G){return B.test(G)},SafeSet:Set,String,StringPrototypeSlice(B,G,y){return B.slice(G,y)},StringPrototypeToLowerCase(B){return B.toLowerCase()},StringPrototypeToUpperCase(B){return B.toUpperCase()},StringPrototypeTrim(B){return B.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(B,G,y){return B.set(G,y)},Uint8Array}}}),Aq=Bq({"node_modules/readable-stream/lib/ours/util.js"(a,j){var B=zq.getPrototypeOf(async function(){}).constructor,G=typeof Blob!=="undefined"?function A(M){return M instanceof Blob}:function A(M){return!1},y=class extends Error{constructor(A){if(!Array.isArray(A))throw new TypeError(`Expected input to be an Array, got ${typeof A}`);let M="";for(let R=0;R{A=P,M=g}),resolve:A,reject:M}},promisify(A){return new Promise((M,R)=>{A((P,...g)=>{if(P)return R(P);return M(...g)})})},debuglog(){return function(){}},format(A,...M){return A.replace(/%([sdifj])/g,function(...[R,P]){const g=M.shift();if(P==="f")return g.toFixed(6);else if(P==="j")return JSON.stringify(g);else if(P==="s"&&typeof g==="object")return`${g.constructor!==zq?g.constructor.name:""} {}`.trim();else return g.toString()})},inspect(A){switch(typeof A){case"string":if(A.includes("'")){if(!A.includes('"'))return`"${A}"`;else if(!A.includes("`")&&!A.includes("${"))return`\`${A}\``}return`'${A}'`;case"number":if(isNaN(A))return"NaN";else if(zq.is(A,-0))return String(A);return A;case"bigint":return`${String(A)}n`;case"boolean":case"undefined":return String(A);case"object":return"{}"}},types:{isAsyncFunction(A){return A instanceof B},isArrayBufferView(A){return ArrayBuffer.isView(A)}},isBlob:G},j.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),Wq=Bq({"node_modules/readable-stream/lib/ours/errors.js"(a,j){var{format:B,inspect:G,AggregateError:y}=Aq(),A=globalThis.AggregateError||y,M=Symbol("kIsNodeError"),R=["string","function","number","object","Function","Object","boolean","bigint","symbol"],P=/^([A-Z][a-z0-9]*)+$/,g="__node_internal_",k={};function c(Z,U){if(!Z)throw new k.ERR_INTERNAL_ASSERTION(U)}function O(Z){let U="",T=Z.length;const _=Z[0]==="-"?1:0;for(;T>=_+4;T-=3)U=`_${Z.slice(T-3,T)}${U}`;return`${Z.slice(0,T)}${U}`}function l(Z,U,T){if(typeof U==="function")return c(U.length<=T.length,`Code: ${Z}; The provided arguments length (${T.length}) does not match the required ones (${U.length}).`),U(...T);const _=(U.match(/%[dfijoOs]/g)||[]).length;if(c(_===T.length,`Code: ${Z}; The provided arguments length (${T.length}) does not match the required ones (${_}).`),T.length===0)return U;return B(U,...T)}function D(Z,U,T){if(!T)T=Error;class _ extends T{constructor(...t){super(l(Z,U,t))}toString(){return`${this.name} [${Z}]: ${this.message}`}}zq.defineProperties(_.prototype,{name:{value:T.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${Z}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),_.prototype.code=Z,_.prototype[M]=!0,k[Z]=_}function p(Z){const U=g+Z.name;return zq.defineProperty(Z,"name",{value:U}),Z}function E(Z,U){if(Z&&U&&Z!==U){if(Array.isArray(U.errors))return U.errors.push(Z),U;const T=new A([U,Z],U.message);return T.code=U.code,T}return Z||U}var I=class extends Error{constructor(Z="The operation was aborted",U=void 0){if(U!==void 0&&typeof U!=="object")throw new k.ERR_INVALID_ARG_TYPE("options","Object",U);super(Z,U);this.code="ABORT_ERR",this.name="AbortError"}};D("ERR_ASSERTION","%s",Error),D("ERR_INVALID_ARG_TYPE",(Z,U,T)=>{if(c(typeof Z==="string","'name' must be a string"),!Array.isArray(U))U=[U];let _="The ";if(Z.endsWith(" argument"))_+=`${Z} `;else _+=`"${Z}" ${Z.includes(".")?"property":"argument"} `;_+="must be ";const t=[],i=[],$=[];for(let Y of U)if(c(typeof Y==="string","All expected entries have to be of type string"),R.includes(Y))t.push(Y.toLowerCase());else if(P.test(Y))i.push(Y);else c(Y!=="object",'The value "object" should be written as "Object"'),$.push(Y);if(i.length>0){const Y=t.indexOf("object");if(Y!==-1)t.splice(t,Y,1),i.push("Object")}if(t.length>0){switch(t.length){case 1:_+=`of type ${t[0]}`;break;case 2:_+=`one of type ${t[0]} or ${t[1]}`;break;default:{const Y=t.pop();_+=`one of type ${t.join(", ")}, or ${Y}`}}if(i.length>0||$.length>0)_+=" or "}if(i.length>0){switch(i.length){case 1:_+=`an instance of ${i[0]}`;break;case 2:_+=`an instance of ${i[0]} or ${i[1]}`;break;default:{const Y=i.pop();_+=`an instance of ${i.join(", ")}, or ${Y}`}}if($.length>0)_+=" or "}switch($.length){case 0:break;case 1:if($[0].toLowerCase()!==$[0])_+="an ";_+=`${$[0]}`;break;case 2:_+=`one of ${$[0]} or ${$[1]}`;break;default:{const Y=$.pop();_+=`one of ${$.join(", ")}, or ${Y}`}}if(T==null)_+=`. Received ${T}`;else if(typeof T==="function"&&T.name)_+=`. Received function ${T.name}`;else if(typeof T==="object"){var n;if((n=T.constructor)!==null&&n!==void 0&&n.name)_+=`. Received an instance of ${T.constructor.name}`;else{const Y=G(T,{depth:-1});_+=`. Received ${Y}`}}else{let Y=G(T,{colors:!1});if(Y.length>25)Y=`${Y.slice(0,25)}...`;_+=`. Received type ${typeof T} (${Y})`}return _},TypeError),D("ERR_INVALID_ARG_VALUE",(Z,U,T="is invalid")=>{let _=G(U);if(_.length>128)_=_.slice(0,128)+"...";return`The ${Z.includes(".")?"property":"argument"} '${Z}' ${T}. Received ${_}`},TypeError),D("ERR_INVALID_RETURN_VALUE",(Z,U,T)=>{var _;const t=T!==null&&T!==void 0&&(_=T.constructor)!==null&&_!==void 0&&_.name?`instance of ${T.constructor.name}`:`type ${typeof T}`;return`Expected ${Z} to be returned from the "${U}" function but got ${t}.`},TypeError),D("ERR_MISSING_ARGS",(...Z)=>{c(Z.length>0,"At least one arg needs to be specified");let U;const T=Z.length;switch(Z=(Array.isArray(Z)?Z:[Z]).map((_)=>`"${_}"`).join(" or "),T){case 1:U+=`The ${Z[0]} argument`;break;case 2:U+=`The ${Z[0]} and ${Z[1]} arguments`;break;default:{const _=Z.pop();U+=`The ${Z.join(", ")}, and ${_} arguments`}break}return`${U} must be specified`},TypeError),D("ERR_OUT_OF_RANGE",(Z,U,T)=>{c(U,'Missing "range" argument');let _;if(Number.isInteger(T)&&Math.abs(T)>4294967296)_=O(String(T));else if(typeof T==="bigint"){if(_=String(T),T>2n**32n||T<-(2n**32n))_=O(_);_+="n"}else _=G(T);return`The value of "${Z}" is out of range. It must be ${U}. Received ${_}`},RangeError),D("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),D("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),D("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),D("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),D("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),D("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),D("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),D("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),D("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),D("ERR_STREAM_WRITE_AFTER_END","write after end",Error),D("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),j.exports={AbortError:I,aggregateTwoErrors:p(E),hideStackFrames:p,codes:k}}}),Cq=Bq({"node_modules/readable-stream/lib/internal/validators.js"(a,j){var{ArrayIsArray:B,ArrayPrototypeIncludes:G,ArrayPrototypeJoin:y,ArrayPrototypeMap:A,NumberIsInteger:M,NumberMAX_SAFE_INTEGER:R,NumberMIN_SAFE_INTEGER:P,NumberParseInt:g,RegExpPrototypeTest:k,String:c,StringPrototypeToUpperCase:O,StringPrototypeTrim:l}=Vq(),{hideStackFrames:D,codes:{ERR_SOCKET_BAD_PORT:p,ERR_INVALID_ARG_TYPE:E,ERR_INVALID_ARG_VALUE:I,ERR_OUT_OF_RANGE:Z,ERR_UNKNOWN_SIGNAL:U}}=Wq(),{normalizeEncoding:T}=Aq(),{isAsyncFunction:_,isArrayBufferView:t}=Aq().types,i={};function $(V){return V===(V|0)}function n(V){return V===V>>>0}var Y=/^[0-7]+$/,K="must be a 32-bit unsigned integer or an octal string";function F(V,h,Q){if(typeof V==="undefined")V=Q;if(typeof V==="string"){if(!k(Y,V))throw new I(h,V,K);V=g(V,8)}return u(V,h,0,4294967295),V}var m=D((V,h,Q=P,H=R)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!M(V))throw new Z(h,"an integer",V);if(VH)throw new Z(h,`>= ${Q} && <= ${H}`,V)}),u=D((V,h,Q=-2147483648,H=2147483647)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!$(V)){if(!M(V))throw new Z(h,"an integer",V);throw new Z(h,`>= ${Q} && <= ${H}`,V)}if(VH)throw new Z(h,`>= ${Q} && <= ${H}`,V)}),J=D((V,h,Q)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!n(V)){if(!M(V))throw new Z(h,"an integer",V);throw new Z(h,`>= ${Q?1:0} && < 4294967296`,V)}if(Q&&V===0)throw new Z(h,">= 1 && < 4294967296",V)});function z(V,h){if(typeof V!=="string")throw new E(h,"string",V)}function w(V,h){if(typeof V!=="number")throw new E(h,"number",V)}var S=D((V,h,Q)=>{if(!G(Q,V)){const L="must be one of: "+y(A(Q,(d)=>typeof d==="string"?`'${d}'`:c(d)),", ");throw new I(h,V,L)}});function N(V,h){if(typeof V!=="boolean")throw new E(h,"boolean",V)}var W=D((V,h,Q)=>{const H=Q==null,L=H?!1:Q.allowArray,d=H?!1:Q.allowFunction;if(!(H?!1:Q.nullable)&&V===null||!L&&B(V)||typeof V!=="object"&&(!d||typeof V!=="function"))throw new E(h,"Object",V)}),b=D((V,h,Q=0)=>{if(!B(V))throw new E(h,"Array",V);if(V.length{if(!t(V))throw new E(h,["Buffer","TypedArray","DataView"],V)});function e(V,h){const Q=T(h),H=V.length;if(Q==="hex"&&H%2!==0)throw new I("encoding",h,`is invalid for data of length ${H}`)}function Hq(V,h="Port",Q=!0){if(typeof V!=="number"&&typeof V!=="string"||typeof V==="string"&&l(V).length===0||+V!==+V>>>0||V>65535||V===0&&!Q)throw new p(h,V,Q);return V|0}var $q=D((V,h)=>{if(V!==void 0&&(V===null||typeof V!=="object"||!("aborted"in V)))throw new E(h,"AbortSignal",V)}),qq=D((V,h)=>{if(typeof V!=="function")throw new E(h,"Function",V)}),Kq=D((V,h)=>{if(typeof V!=="function"||_(V))throw new E(h,"Function",V)}),Qq=D((V,h)=>{if(V!==void 0)throw new E(h,"undefined",V)});j.exports={isInt32:$,isUint32:n,parseFileMode:F,validateArray:b,validateBoolean:N,validateBuffer:s,validateEncoding:e,validateFunction:qq,validateInt32:u,validateInteger:m,validateNumber:w,validateObject:W,validateOneOf:S,validatePlainFunction:Kq,validatePort:Hq,validateSignalName:o,validateString:z,validateUint32:J,validateUndefined:Qq,validateAbortSignal:$q}}}),Eq=Bq({"node_modules/readable-stream/lib/internal/streams/utils.js"(a,j){var{Symbol:B,SymbolAsyncIterator:G,SymbolIterator:y}=Vq(),A=B("kDestroyed"),M=B("kIsErrored"),R=B("kIsReadable"),P=B("kIsDisturbed");function g(J,z=!1){var w;return!!(J&&typeof J.pipe==="function"&&typeof J.on==="function"&&(!z||typeof J.pause==="function"&&typeof J.resume==="function")&&(!J._writableState||((w=J._readableState)===null||w===void 0?void 0:w.readable)!==!1)&&(!J._writableState||J._readableState))}function k(J){var z;return!!(J&&typeof J.write==="function"&&typeof J.on==="function"&&(!J._readableState||((z=J._writableState)===null||z===void 0?void 0:z.writable)!==!1))}function c(J){return!!(J&&typeof J.pipe==="function"&&J._readableState&&typeof J.on==="function"&&typeof J.write==="function")}function O(J){return J&&(J._readableState||J._writableState||typeof J.write==="function"&&typeof J.on==="function"||typeof J.pipe==="function"&&typeof J.on==="function")}function l(J,z){if(J==null)return!1;if(z===!0)return typeof J[G]==="function";if(z===!1)return typeof J[y]==="function";return typeof J[G]==="function"||typeof J[y]==="function"}function D(J){if(!O(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!!(J.destroyed||J[A]||S!==null&&S!==void 0&&S.destroyed)}function p(J){if(!k(J))return null;if(J.writableEnded===!0)return!0;const z=J._writableState;if(z!==null&&z!==void 0&&z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function E(J,z){if(!k(J))return null;if(J.writableFinished===!0)return!0;const w=J._writableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.finished)!=="boolean")return null;return!!(w.finished||z===!1&&w.ended===!0&&w.length===0)}function I(J){if(!g(J))return null;if(J.readableEnded===!0)return!0;const z=J._readableState;if(!z||z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function Z(J,z){if(!g(J))return null;const w=J._readableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.endEmitted)!=="boolean")return null;return!!(w.endEmitted||z===!1&&w.ended===!0&&w.length===0)}function U(J){if(J&&J[R]!=null)return J[R];if(typeof(J===null||J===void 0?void 0:J.readable)!=="boolean")return null;if(D(J))return!1;return g(J)&&J.readable&&!Z(J)}function T(J){if(typeof(J===null||J===void 0?void 0:J.writable)!=="boolean")return null;if(D(J))return!1;return k(J)&&J.writable&&!p(J)}function _(J,z){if(!O(J))return null;if(D(J))return!0;if((z===null||z===void 0?void 0:z.readable)!==!1&&U(J))return!1;if((z===null||z===void 0?void 0:z.writable)!==!1&&T(J))return!1;return!0}function t(J){var z,w;if(!O(J))return null;if(J.writableErrored)return J.writableErrored;return(z=(w=J._writableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function i(J){var z,w;if(!O(J))return null;if(J.readableErrored)return J.readableErrored;return(z=(w=J._readableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function $(J){if(!O(J))return null;if(typeof J.closed==="boolean")return J.closed;const{_writableState:z,_readableState:w}=J;if(typeof(z===null||z===void 0?void 0:z.closed)==="boolean"||typeof(w===null||w===void 0?void 0:w.closed)==="boolean")return(z===null||z===void 0?void 0:z.closed)||(w===null||w===void 0?void 0:w.closed);if(typeof J._closed==="boolean"&&n(J))return J._closed;return null}function n(J){return typeof J._closed==="boolean"&&typeof J._defaultKeepAlive==="boolean"&&typeof J._removedConnection==="boolean"&&typeof J._removedContLen==="boolean"}function Y(J){return typeof J._sent100==="boolean"&&n(J)}function K(J){var z;return typeof J._consuming==="boolean"&&typeof J._dumped==="boolean"&&((z=J.req)===null||z===void 0?void 0:z.upgradeOrConnect)===void 0}function F(J){if(!O(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!S&&Y(J)||!!(S&&S.autoDestroy&&S.emitClose&&S.closed===!1)}function m(J){var z;return!!(J&&((z=J[P])!==null&&z!==void 0?z:J.readableDidRead||J.readableAborted))}function u(J){var z,w,S,N,W,b,o,s,e,Hq;return!!(J&&((z=(w=(S=(N=(W=(b=J[M])!==null&&b!==void 0?b:J.readableErrored)!==null&&W!==void 0?W:J.writableErrored)!==null&&N!==void 0?N:(o=J._readableState)===null||o===void 0?void 0:o.errorEmitted)!==null&&S!==void 0?S:(s=J._writableState)===null||s===void 0?void 0:s.errorEmitted)!==null&&w!==void 0?w:(e=J._readableState)===null||e===void 0?void 0:e.errored)!==null&&z!==void 0?z:(Hq=J._writableState)===null||Hq===void 0?void 0:Hq.errored))}j.exports={kDestroyed:A,isDisturbed:m,kIsDisturbed:P,isErrored:u,kIsErrored:M,isReadable:U,kIsReadable:R,isClosed:$,isDestroyed:D,isDuplexNodeStream:c,isFinished:_,isIterable:l,isReadableNodeStream:g,isReadableEnded:I,isReadableFinished:Z,isReadableErrored:i,isNodeStream:O,isWritable:T,isWritableNodeStream:k,isWritableEnded:p,isWritableFinished:E,isWritableErrored:t,isServerRequest:K,isServerResponse:Y,willEmitClose:F}}}),Fq=Bq({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(a,j){var{AbortError:B,codes:G}=Wq(),{ERR_INVALID_ARG_TYPE:y,ERR_STREAM_PREMATURE_CLOSE:A}=G,{once:M}=Aq(),{validateAbortSignal:R,validateFunction:P,validateObject:g}=Cq(),{Promise:k}=Vq(),{isClosed:c,isReadable:O,isReadableNodeStream:l,isReadableFinished:D,isReadableErrored:p,isWritable:E,isWritableNodeStream:I,isWritableFinished:Z,isWritableErrored:U,isNodeStream:T,willEmitClose:_}=Eq();function t(Y){return Y.setHeader&&typeof Y.abort==="function"}var i=()=>{};function $(Y,K,F){var m,u;if(arguments.length===2)F=K,K={};else if(K==null)K={};else g(K,"options");P(F,"callback"),R(K.signal,"options.signal"),F=M(F);const J=(m=K.readable)!==null&&m!==void 0?m:l(Y),z=(u=K.writable)!==null&&u!==void 0?u:I(Y);if(!T(Y))throw new y("stream","Stream",Y);const{_writableState:w,_readableState:S}=Y,N=()=>{if(!Y.writable)o()};let W=_(Y)&&l(Y)===J&&I(Y)===z,b=Z(Y,!1);const o=()=>{if(b=!0,Y.destroyed)W=!1;if(W&&(!Y.readable||J))return;if(!J||s)F.call(Y)};let s=D(Y,!1);const e=()=>{if(s=!0,Y.destroyed)W=!1;if(W&&(!Y.writable||z))return;if(!z||b)F.call(Y)},Hq=(V)=>{F.call(Y,V)};let $q=c(Y);const qq=()=>{$q=!0;const V=U(Y)||p(Y);if(V&&typeof V!=="boolean")return F.call(Y,V);if(J&&!s&&l(Y,!0)){if(!D(Y,!1))return F.call(Y,new A)}if(z&&!b){if(!Z(Y,!1))return F.call(Y,new A)}F.call(Y)},Kq=()=>{Y.req.on("finish",o)};if(t(Y)){if(Y.on("complete",o),!W)Y.on("abort",qq);if(Y.req)Kq();else Y.on("request",Kq)}else if(z&&!w)Y.on("end",N),Y.on("close",N);if(!W&&typeof Y.aborted==="boolean")Y.on("aborted",qq);if(Y.on("end",e),Y.on("finish",o),K.error!==!1)Y.on("error",Hq);if(Y.on("close",qq),$q)Xq(qq);else if(w!==null&&w!==void 0&&w.errorEmitted||S!==null&&S!==void 0&&S.errorEmitted){if(!W)Xq(qq)}else if(!J&&(!W||O(Y))&&(b||E(Y)===!1))Xq(qq);else if(!z&&(!W||E(Y))&&(s||O(Y)===!1))Xq(qq);else if(S&&Y.req&&Y.aborted)Xq(qq);const Qq=()=>{if(F=i,Y.removeListener("aborted",qq),Y.removeListener("complete",o),Y.removeListener("abort",qq),Y.removeListener("request",Kq),Y.req)Y.req.removeListener("finish",o);Y.removeListener("end",N),Y.removeListener("close",N),Y.removeListener("finish",o),Y.removeListener("end",e),Y.removeListener("error",Hq),Y.removeListener("close",qq)};if(K.signal&&!$q){const V=()=>{const h=F;Qq(),h.call(Y,new B(void 0,{cause:K.signal.reason}))};if(K.signal.aborted)Xq(V);else{const h=F;F=M((...Q)=>{K.signal.removeEventListener("abort",V),h.apply(Y,Q)}),K.signal.addEventListener("abort",V)}}return Qq}function n(Y,K){return new k((F,m)=>{$(Y,K,(u)=>{if(u)m(u);else F()})})}j.exports=$,j.exports.finished=n}}),XQ=Bq({"node_modules/readable-stream/lib/internal/streams/operators.js"(a,j){var{codes:{ERR_INVALID_ARG_TYPE:B,ERR_MISSING_ARGS:G,ERR_OUT_OF_RANGE:y},AbortError:A}=Wq(),{validateAbortSignal:M,validateInteger:R,validateObject:P}=Cq(),g=Vq().Symbol("kWeak"),{finished:k}=Fq(),{ArrayPrototypePush:c,MathFloor:O,Number:l,NumberIsNaN:D,Promise:p,PromiseReject:E,PromisePrototypeCatch:I,Symbol:Z}=Vq(),U=Z("kEmpty"),T=Z("kEof");function _(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);if(W!=null)P(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");let b=1;if((W===null||W===void 0?void 0:W.concurrency)!=null)b=O(W.concurrency);return R(b,"concurrency",1),async function*o(){var s,e;const Hq=new AbortController,$q=this,qq=[],Kq=Hq.signal,Qq={signal:Kq},V=()=>Hq.abort();if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)V();W===null||W===void 0||(e=W.signal)===null||e===void 0||e.addEventListener("abort",V);let h,Q,H=!1;function L(){H=!0}async function d(){try{for await(let q of $q){var f;if(H)return;if(Kq.aborted)throw new A;try{q=N(q,Qq)}catch(X){q=E(X)}if(q===U)continue;if(typeof((f=q)===null||f===void 0?void 0:f.catch)==="function")q.catch(L);if(qq.push(q),h)h(),h=null;if(!H&&qq.length&&qq.length>=b)await new p((X)=>{Q=X})}qq.push(T)}catch(q){const X=E(q);I(X,L),qq.push(X)}finally{var r;if(H=!0,h)h(),h=null;W===null||W===void 0||(r=W.signal)===null||r===void 0||r.removeEventListener("abort",V)}}d();try{while(!0){while(qq.length>0){const f=await qq[0];if(f===T)return;if(Kq.aborted)throw new A;if(f!==U)yield f;if(qq.shift(),Q)Q(),Q=null}await new p((f)=>{h=f})}}finally{if(Hq.abort(),H=!0,Q)Q(),Q=null}}.call(this)}function t(N=void 0){if(N!=null)P(N,"options");if((N===null||N===void 0?void 0:N.signal)!=null)M(N.signal,"options.signal");return async function*W(){let b=0;for await(let s of this){var o;if(N!==null&&N!==void 0&&(o=N.signal)!==null&&o!==void 0&&o.aborted)throw new A({cause:N.signal.reason});yield[b++,s]}}.call(this)}async function i(N,W=void 0){for await(let b of K.call(this,N,W))return!0;return!1}async function $(N,W=void 0){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);return!await i.call(this,async(...b)=>{return!await N(...b)},W)}async function n(N,W){for await(let b of K.call(this,N,W))return b;return}async function Y(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);async function b(o,s){return await N(o,s),U}for await(let o of _.call(this,b,W));}function K(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);async function b(o,s){if(await N(o,s))return o;return U}return _.call(this,b,W)}var F=class extends G{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function m(N,W,b){var o;if(typeof N!=="function")throw new B("reducer",["Function","AsyncFunction"],N);if(b!=null)P(b,"options");if((b===null||b===void 0?void 0:b.signal)!=null)M(b.signal,"options.signal");let s=arguments.length>1;if(b!==null&&b!==void 0&&(o=b.signal)!==null&&o!==void 0&&o.aborted){const Kq=new A(void 0,{cause:b.signal.reason});throw this.once("error",()=>{}),await k(this.destroy(Kq)),Kq}const e=new AbortController,Hq=e.signal;if(b!==null&&b!==void 0&&b.signal){const Kq={once:!0,[g]:this};b.signal.addEventListener("abort",()=>e.abort(),Kq)}let $q=!1;try{for await(let Kq of this){var qq;if($q=!0,b!==null&&b!==void 0&&(qq=b.signal)!==null&&qq!==void 0&&qq.aborted)throw new A;if(!s)W=Kq,s=!0;else W=await N(W,Kq,{signal:Hq})}if(!$q&&!s)throw new F}finally{e.abort()}return W}async function u(N){if(N!=null)P(N,"options");if((N===null||N===void 0?void 0:N.signal)!=null)M(N.signal,"options.signal");const W=[];for await(let o of this){var b;if(N!==null&&N!==void 0&&(b=N.signal)!==null&&b!==void 0&&b.aborted)throw new A(void 0,{cause:N.signal.reason});c(W,o)}return W}function J(N,W){const b=_.call(this,N,W);return async function*o(){for await(let s of b)yield*s}.call(this)}function z(N){if(N=l(N),D(N))return 0;if(N<0)throw new y("number",">= 0",N);return N}function w(N,W=void 0){if(W!=null)P(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");return N=z(N),async function*b(){var o;if(W!==null&&W!==void 0&&(o=W.signal)!==null&&o!==void 0&&o.aborted)throw new A;for await(let e of this){var s;if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)throw new A;if(N--<=0)yield e}}.call(this)}function S(N,W=void 0){if(W!=null)P(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");return N=z(N),async function*b(){var o;if(W!==null&&W!==void 0&&(o=W.signal)!==null&&o!==void 0&&o.aborted)throw new A;for await(let e of this){var s;if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)throw new A;if(N-- >0)yield e;else return}}.call(this)}j.exports.streamReturningOperators={asIndexedPairs:t,drop:w,filter:K,flatMap:J,map:_,take:S},j.exports.promiseReturningOperators={every:$,forEach:Y,reduce:m,toArray:u,some:i,find:n}}}),Tq=Bq({"node_modules/readable-stream/lib/internal/streams/destroy.js"(a,j){var{aggregateTwoErrors:B,codes:{ERR_MULTIPLE_CALLBACK:G},AbortError:y}=Wq(),{Symbol:A}=Vq(),{kDestroyed:M,isDestroyed:R,isFinished:P,isServerRequest:g}=Eq(),k="#kDestroy",c="#kConstruct";function O(K,F,m){if(K){if(K.stack,F&&!F.errored)F.errored=K;if(m&&!m.errored)m.errored=K}}function l(K,F){const m=this._readableState,u=this._writableState,J=u||m;if(u&&u.destroyed||m&&m.destroyed){if(typeof F==="function")F();return this}if(O(K,u,m),u)u.destroyed=!0;if(m)m.destroyed=!0;if(!J.constructed)this.once(k,(z)=>{D(this,B(z,K),F)});else D(this,K,F);return this}function D(K,F,m){let u=!1;function J(z){if(u)return;u=!0;const{_readableState:w,_writableState:S}=K;if(O(z,S,w),S)S.closed=!0;if(w)w.closed=!0;if(typeof m==="function")m(z);if(z)Xq(p,K,z);else Xq(E,K)}try{K._destroy(F||null,J)}catch(z){J(z)}}function p(K,F){I(K,F),E(K)}function E(K){const{_readableState:F,_writableState:m}=K;if(m)m.closeEmitted=!0;if(F)F.closeEmitted=!0;if(m&&m.emitClose||F&&F.emitClose)K.emit("close")}function I(K,F){const m=K?._readableState,u=K?._writableState;if(u?.errorEmitted||m?.errorEmitted)return;if(u)u.errorEmitted=!0;if(m)m.errorEmitted=!0;K?.emit?.("error",F)}function Z(){const K=this._readableState,F=this._writableState;if(K)K.constructed=!0,K.closed=!1,K.closeEmitted=!1,K.destroyed=!1,K.errored=null,K.errorEmitted=!1,K.reading=!1,K.ended=K.readable===!1,K.endEmitted=K.readable===!1;if(F)F.constructed=!0,F.destroyed=!1,F.closed=!1,F.closeEmitted=!1,F.errored=null,F.errorEmitted=!1,F.finalCalled=!1,F.prefinished=!1,F.ended=F.writable===!1,F.ending=F.writable===!1,F.finished=F.writable===!1}function U(K,F,m){const u=K?._readableState,J=K?._writableState;if(J&&J.destroyed||u&&u.destroyed)return this;if(u&&u.autoDestroy||J&&J.autoDestroy)K.destroy(F);else if(F){if(Error.captureStackTrace(F),J&&!J.errored)J.errored=F;if(u&&!u.errored)u.errored=F;if(m)Xq(I,K,F);else I(K,F)}}function T(K,F){if(typeof K._construct!=="function")return;const{_readableState:m,_writableState:u}=K;if(m)m.constructed=!1;if(u)u.constructed=!1;if(K.once(c,F),K.listenerCount(c)>1)return;Xq(_,K)}function _(K){let F=!1;function m(u){if(F){U(K,u!==null&&u!==void 0?u:new G);return}F=!0;const{_readableState:J,_writableState:z}=K,w=z||J;if(J)J.constructed=!0;if(z)z.constructed=!0;if(w.destroyed)K.emit(k,u);else if(u)U(K,u,!0);else Xq(t,K)}try{K._construct(m)}catch(u){m(u)}}function t(K){K.emit(c)}function i(K){return K&&K.setHeader&&typeof K.abort==="function"}function $(K){K.emit("close")}function n(K,F){K.emit("error",F),Xq($,K)}function Y(K,F){if(!K||R(K))return;if(!F&&!P(K))F=new y;if(g(K))K.socket=null,K.destroy(F);else if(i(K))K.abort();else if(i(K.req))K.req.abort();else if(typeof K.destroy==="function")K.destroy(F);else if(typeof K.close==="function")K.close();else if(F)Xq(n,K);else Xq($,K);if(!K.destroyed)K[M]=!0}j.exports={construct:T,destroyer:Y,destroy:l,undestroy:Z,errorOrDestroy:U}}}),Rq=Bq({"node_modules/readable-stream/lib/internal/streams/legacy.js"(a,j){var{ArrayIsArray:B,ObjectSetPrototypeOf:G}=Vq();function y(M){if(!(this instanceof y))return new y(M);Iq.call(this,M)}G(y.prototype,Iq.prototype),G(y,Iq),y.prototype.pipe=function(M,R){const P=this;function g(E){if(M.writable&&M.write(E)===!1&&P.pause)P.pause()}P.on("data",g);function k(){if(P.readable&&P.resume)P.resume()}if(M.on("drain",k),!M._isStdio&&(!R||R.end!==!1))P.on("end",O),P.on("close",l);let c=!1;function O(){if(c)return;c=!0,M.end()}function l(){if(c)return;if(c=!0,typeof M.destroy==="function")M.destroy()}function D(E){if(p(),Iq.listenerCount(this,"error")===0)this.emit("error",E)}A(P,"error",D),A(M,"error",D);function p(){P.removeListener("data",g),M.removeListener("drain",k),P.removeListener("end",O),P.removeListener("close",l),P.removeListener("error",D),M.removeListener("error",D),P.removeListener("end",p),P.removeListener("close",p),M.removeListener("close",p)}return P.on("end",p),P.on("close",p),M.on("close",p),M.emit("pipe",P),M};function A(M,R,P){if(typeof M.prependListener==="function")return M.prependListener(R,P);if(!M._events||!M._events[R])M.on(R,P);else if(B(M._events[R]))M._events[R].unshift(P);else M._events[R]=[P,M._events[R]]}j.exports={Stream:y,prependListener:A}}}),Sq=Bq({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(a,j){var{AbortError:B,codes:G}=Wq(),y=Fq(),{ERR_INVALID_ARG_TYPE:A}=G,M=(P,g)=>{if(typeof P!=="object"||!("aborted"in P))throw new A(g,"AbortSignal",P)};function R(P){return!!(P&&typeof P.pipe==="function")}j.exports.addAbortSignal=function P(g,k){if(M(g,"signal"),!R(k))throw new A("stream","stream.Stream",k);return j.exports.addAbortSignalNoValidate(g,k)},j.exports.addAbortSignalNoValidate=function(P,g){if(typeof P!=="object"||!("aborted"in P))return g;const k=()=>{g.destroy(new B(void 0,{cause:P.reason}))};if(P.aborted)k();else P.addEventListener("abort",k),y(g,()=>P.removeEventListener("abort",k));return g}}}),JQ=Bq({"node_modules/readable-stream/lib/internal/streams/state.js"(a,j){var{MathFloor:B,NumberIsInteger:G}=Vq(),{ERR_INVALID_ARG_VALUE:y}=Wq().codes;function A(P,g,k){return P.highWaterMark!=null?P.highWaterMark:g?P[k]:null}function M(P){return P?16:16384}function R(P,g,k,c){const O=A(g,c,k);if(O!=null){if(!G(O)||O<0){const l=c?`options.${k}`:"options.highWaterMark";throw new y(l,O)}return B(O)}return M(P.objectMode)}j.exports={getHighWaterMark:R,getDefaultHighWaterMark:M}}}),hq=Bq({"node_modules/readable-stream/lib/internal/streams/from.js"(a,j){var{PromisePrototypeThen:B,SymbolAsyncIterator:G,SymbolIterator:y}=Vq(),{ERR_INVALID_ARG_TYPE:A,ERR_STREAM_NULL_VALUES:M}=Wq().codes;function R(P,g,k){let c;if(typeof g==="string"||g instanceof Buffer)return new P({objectMode:!0,...k,read(){this.push(g),this.push(null)}});let O;if(g&&g[G])O=!0,c=g[G]();else if(g&&g[y])O=!1,c=g[y]();else throw new A("iterable",["Iterable"],g);const l=new P({objectMode:!0,highWaterMark:1,...k});let D=!1;l._read=function(){if(!D)D=!0,E()},l._destroy=function(I,Z){B(p(I),()=>Xq(Z,I),(U)=>Xq(Z,U||I))};async function p(I){const Z=I!==void 0&&I!==null,U=typeof c.throw==="function";if(Z&&U){const{value:T,done:_}=await c.throw(I);if(await T,_)return}if(typeof c.return==="function"){const{value:T}=await c.return();await T}}async function E(){for(;;){try{const{value:I,done:Z}=O?await c.next():c.next();if(Z)l.push(null);else{const U=I&&typeof I.then==="function"?await I:I;if(U===null)throw D=!1,new M;else if(l.push(U))continue;else D=!1}}catch(I){l.destroy(I)}break}}return l}j.exports=R}}),pq,uq,_q=Bq({"node_modules/readable-stream/lib/internal/streams/readable.js"(a,j){var{ArrayPrototypeIndexOf:B,NumberIsInteger:G,NumberIsNaN:y,NumberParseInt:A,ObjectDefineProperties:M,ObjectKeys:R,ObjectSetPrototypeOf:P,Promise:g,SafeSet:k,SymbolAsyncIterator:c,Symbol:O}=Vq(),l=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{Stream:D,prependListener:p}=Rq();function E(q){if(!(this instanceof E))return new E(q);const X=this instanceof Mq();if(this._readableState=new l(q,this,X),q){const{read:C,destroy:x,construct:v,signal:Jq}=q;if(typeof C==="function")this._read=C;if(typeof x==="function")this._destroy=x;if(typeof v==="function")this._construct=v;if(Jq&&!X)U(Jq,this)}D.call(this,q),K.construct(this,()=>{if(this._readableState.needReadable)n(this,this._readableState)})}P(E.prototype,D.prototype),P(E,D),E.prototype.on=function(q,X){const C=D.prototype.on.call(this,q,X),x=this._readableState;if(q==="data"){if(x.readableListening=this.listenerCount("readable")>0,x.flowing!==!1)this.resume()}else if(q==="readable"){if(!x.endEmitted&&!x.readableListening){if(x.readableListening=x.needReadable=!0,x.flowing=!1,x.emittedReadable=!1,x.length)Y(this,x);else if(!x.reading)Xq(Qq,this)}else if(x.endEmitted);}return C};class I extends E{#q;#Q;#X;#H;constructor(q,X){const{objectMode:C,highWaterMark:x,encoding:v,signal:Jq}=q;super({objectMode:C,highWaterMark:x,encoding:v,signal:Jq});this.#X=[],this.#q=void 0,this.#H=X,this.#Q=!1}#J(){var q=this.#X,X=0,C=q.length;for(;X0)this.#X=[];return!1}#K(q){q.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){var q=this.#H,X=this.#q;if(q)X=this.#q=q.getReader(),this.#H=void 0;else if(this.#J())return;var C;try{do{var x=!1,v;const Jq=X.readMany();if(xq(Jq)){if({done:x,value:v}=await Jq,this.#Q){this.#X.push(...v);return}}else({done:x,value:v}=Jq);if(x){this.#K(X);return}if(!this.push(v[0])){this.#X=v.slice(1);return}for(let Zq=1,Oq=v.length;Zq{this.#Q=!0,X(q)});return}try{X(q)}catch(x){globalThis.reportError(x)}}}uq=I;function Z(q,X={}){if(!tq(q))throw new m("readableStream","ReadableStream",q);S(X,"options");const{highWaterMark:C,encoding:x,objectMode:v=!1,signal:Jq}=X;if(x!==void 0&&!Buffer.isEncoding(x))throw new QQ(x,"options.encoding");return eq(v,"options.objectMode"),zQ(E,q,X)||new I({highWaterMark:C,encoding:x,objectMode:v,signal:Jq},q)}j.exports=E,pq=Z;var{addAbortSignal:U}=Sq(),T=Fq();const{maybeReadMore:_,resume:t,emitReadable:i,onEofChunk:$}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function n(q,X){process.nextTick(_,q,X)}function Y(q,X){i(q,X)}var K=Tq(),{aggregateTwoErrors:F,codes:{ERR_INVALID_ARG_TYPE:m,ERR_METHOD_NOT_IMPLEMENTED:u,ERR_OUT_OF_RANGE:J,ERR_STREAM_PUSH_AFTER_EOF:z,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:w}}=Wq(),{validateObject:S}=Cq(),N=hq(),W=()=>{},{errorOrDestroy:b}=K;E.prototype.destroy=K.destroy,E.prototype._undestroy=K.undestroy,E.prototype._destroy=function(q,X){X(q)},E.prototype[Iq.captureRejectionSymbol]=function(q){this.destroy(q)},E.prototype.push=function(q,X){return o(this,q,X,!1)},E.prototype.unshift=function(q,X){return o(this,q,X,!0)};function o(q,X,C,x){const v=q._readableState;let Jq;if(!v.objectMode){if(typeof X==="string"){if(C=C||v.defaultEncoding,v.encoding!==C)if(x&&v.encoding)X=Buffer.from(X,C).toString(v.encoding);else X=Buffer.from(X,C),C=""}else if(X instanceof Buffer)C="";else if(D._isUint8Array(X)){if(x||!v.decoder)X=D._uint8ArrayToBuffer(X);C=""}else if(X!=null)Jq=new m("chunk",["string","Buffer","Uint8Array"],X)}if(Jq)b(q,Jq);else if(X===null)v.reading=!1,$(q,v);else if(v.objectMode||X&&X.length>0)if(x)if(v.endEmitted)b(q,new w);else if(v.destroyed||v.errored)return!1;else s(q,v,X,!0);else if(v.ended)b(q,new z);else if(v.destroyed||v.errored)return!1;else if(v.reading=!1,v.decoder&&!C)if(X=v.decoder.write(X),v.objectMode||X.length!==0)s(q,v,X,!1);else n(q,v);else s(q,v,X,!1);else if(!x)v.reading=!1,n(q,v);return!v.ended&&(v.length0){if(X.multiAwaitDrain)X.awaitDrainWriters.clear();else X.awaitDrainWriters=null;X.dataEmitted=!0,q.emit("data",C)}else{if(X.length+=X.objectMode?1:C.length,x)X.buffer.unshift(C);else X.buffer.push(C);if(X.needReadable)Y(q,X)}n(q,X)}E.prototype.isPaused=function(){const q=this._readableState;return q.paused===!0||q.flowing===!1},E.prototype.setEncoding=function(q){const X=new aq(q);this._readableState.decoder=X,this._readableState.encoding=this._readableState.decoder.encoding;const C=this._readableState.buffer;let x="";for(let v=C.length;v>0;v--)x+=X.write(C.shift());if(x!=="")C.push(x);return this._readableState.length=x.length,this};var e=1073741824;function Hq(q){if(q>e)throw new J("size","<= 1GiB",q);else q--,q|=q>>>1,q|=q>>>2,q|=q>>>4,q|=q>>>8,q|=q>>>16,q++;return q}function $q(q,X){if(q<=0||X.length===0&&X.ended)return 0;if(X.objectMode)return 1;if(y(q)){if(X.flowing&&X.length)return X.buffer.first().length;return X.length}if(q<=X.length)return q;return X.ended?X.length:0}E.prototype.read=function(q){if(!G(q))q=A(q,10);const X=this._readableState,C=q;if(q>X.highWaterMark)X.highWaterMark=Hq(q);if(q!==0)X.emittedReadable=!1;if(q===0&&X.needReadable&&((X.highWaterMark!==0?X.length>=X.highWaterMark:X.length>0)||X.ended)){if(X.length===0&&X.ended)H(this);else Y(this,X);return null}if(q=$q(q,X),q===0&&X.ended){if(X.length===0)H(this);return null}let x=X.needReadable;if(X.length===0||X.length-q0)Jq=Q(q,X);else Jq=null;if(Jq===null)X.needReadable=X.length<=X.highWaterMark,q=0;else if(X.length-=q,X.multiAwaitDrain)X.awaitDrainWriters.clear();else X.awaitDrainWriters=null;if(X.length===0){if(!X.ended)X.needReadable=!0;if(C!==q&&X.ended)H(this)}if(Jq!==null&&!X.errorEmitted&&!X.closeEmitted)X.dataEmitted=!0,this.emit("data",Jq);return Jq},E.prototype._read=function(q){throw new u("_read()")},E.prototype.pipe=function(q,X){const C=this,x=this._readableState;if(x.pipes.length===1){if(!x.multiAwaitDrain)x.multiAwaitDrain=!0,x.awaitDrainWriters=new k(x.awaitDrainWriters?[x.awaitDrainWriters]:[])}x.pipes.push(q);const Jq=(!X||X.end!==!1)&&q!==process.stdout&&q!==process.stderr?Oq:Pq;if(x.endEmitted)Xq(Jq);else C.once("end",Jq);q.on("unpipe",Zq);function Zq(jq,Nq){if(jq===C){if(Nq&&Nq.hasUnpiped===!1)Nq.hasUnpiped=!0,nq()}}function Oq(){q.end()}let Lq,kq=!1;function nq(){if(q.removeListener("close",wq),q.removeListener("finish",vq),Lq)q.removeListener("drain",Lq);if(q.removeListener("error",Dq),q.removeListener("unpipe",Zq),C.removeListener("end",Oq),C.removeListener("end",Pq),C.removeListener("data",yq),kq=!0,Lq&&x.awaitDrainWriters&&(!q._writableState||q._writableState.needDrain))Lq()}function fq(){if(!kq){if(x.pipes.length===1&&x.pipes[0]===q)x.awaitDrainWriters=q,x.multiAwaitDrain=!1;else if(x.pipes.length>1&&x.pipes.includes(q))x.awaitDrainWriters.add(q);C.pause()}if(!Lq)Lq=qq(C,q),q.on("drain",Lq)}C.on("data",yq);function yq(jq){if(q.write(jq)===!1)fq()}function Dq(jq){if(Gq("onerror",jq),Pq(),q.removeListener("error",Dq),q.listenerCount("error")===0){const Nq=q._writableState||q._readableState;if(Nq&&!Nq.errorEmitted)b(q,jq);else q.emit("error",jq)}}p(q,"error",Dq);function wq(){q.removeListener("finish",vq),Pq()}q.once("close",wq);function vq(){Gq("onfinish"),q.removeListener("close",wq),Pq()}q.once("finish",vq);function Pq(){Gq("unpipe"),C.unpipe(q)}if(q.emit("pipe",C),q.writableNeedDrain===!0){if(x.flowing)fq()}else if(!x.flowing)Gq("pipe resume"),C.resume();return q};function qq(q,X){return function C(){const x=q._readableState;if(x.awaitDrainWriters===X)Gq("pipeOnDrain",1),x.awaitDrainWriters=null;else if(x.multiAwaitDrain)Gq("pipeOnDrain",x.awaitDrainWriters.size),x.awaitDrainWriters.delete(X);if((!x.awaitDrainWriters||x.awaitDrainWriters.size===0)&&q.listenerCount("data"))q.resume()}}E.prototype.unpipe=function(q){const X=this._readableState,C={hasUnpiped:!1};if(X.pipes.length===0)return this;if(!q){const v=X.pipes;X.pipes=[],this.pause();for(let Jq=0;Jq0,X.resumeScheduled&&X.paused===!1)X.flowing=!0;else if(q.listenerCount("data")>0)q.resume();else if(!X.readableListening)X.flowing=null}function Qq(q){q.read(0)}E.prototype.resume=function(){const q=this._readableState;if(!q.flowing)q.flowing=!q.readableListening,t(this,q);return q.paused=!1,this},E.prototype.pause=function(){if(this._readableState.flowing!==!1)this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},E.prototype.wrap=function(q){let X=!1;q.on("data",(x)=>{if(!this.push(x)&&q.pause)X=!0,q.pause()}),q.on("end",()=>{this.push(null)}),q.on("error",(x)=>{b(this,x)}),q.on("close",()=>{this.destroy()}),q.on("destroy",()=>{this.destroy()}),this._read=()=>{if(X&&q.resume)X=!1,q.resume()};const C=R(q);for(let x=1;x{v=Zq?F(v,Zq):null,C(),C=W});try{while(!0){const Zq=q.destroyed?null:q.read();if(Zq!==null)yield Zq;else if(v)throw v;else if(v===null)return;else await new g(x)}}catch(Zq){throw v=F(v,Zq),v}finally{if((v||(X===null||X===void 0?void 0:X.destroyOnReturn)!==!1)&&(v===void 0||q._readableState.autoDestroy))K.destroyer(q,null);else q.off("readable",x),Jq()}}M(E.prototype,{readable:{get(){const q=this._readableState;return!!q&&q.readable!==!1&&!q.destroyed&&!q.errorEmitted&&!q.endEmitted},set(q){if(this._readableState)this._readableState.readable=!!q}},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(q){if(this._readableState)this._readableState.flowing=q}},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(q){if(!this._readableState)return;this._readableState.destroyed=q}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),E._fromList=Q;function Q(q,X){if(X.length===0)return null;let C;if(X.objectMode)C=X.buffer.shift();else if(!q||q>=X.length){if(X.decoder)C=X.buffer.join("");else if(X.buffer.length===1)C=X.buffer.first();else C=X.buffer.concat(X.length);X.buffer.clear()}else C=X.buffer.consume(q,X.decoder);return C}function H(q){const X=q._readableState;if(!X.endEmitted)X.ended=!0,Xq(L,X,q)}function L(q,X){if(!q.errored&&!q.closeEmitted&&!q.endEmitted&&q.length===0){if(q.endEmitted=!0,X.emit("end"),X.writable&&X.allowHalfOpen===!1)Xq(d,X);else if(q.autoDestroy){const C=X._writableState;if(!C||C.autoDestroy&&(C.finished||C.writable===!1))X.destroy()}}}function d(q){if(q.writable&&!q.writableEnded&&!q.destroyed)q.end()}E.from=function(q,X){return N(E,q,X)};var f={newStreamReadableFromReadableStream:Z};function r(){if(f===void 0)f={};return f}E.fromWeb=function(q,X){return r().newStreamReadableFromReadableStream(q,X)},E.toWeb=function(q){return r().newReadableStreamFromStreamReadable(q)},E.wrap=function(q,X){var C,x;return new E({objectMode:(C=(x=q.readableObjectMode)!==null&&x!==void 0?x:q.objectMode)!==null&&C!==void 0?C:!0,...X,destroy(v,Jq){K.destroyer(q,v),Jq(v)}}).wrap(q)}}}),bq=Bq({"node_modules/readable-stream/lib/internal/streams/writable.js"(a,j){var{ArrayPrototypeSlice:B,Error:G,FunctionPrototypeSymbolHasInstance:y,ObjectDefineProperty:A,ObjectDefineProperties:M,ObjectSetPrototypeOf:R,StringPrototypeToLowerCase:P,Symbol:g,SymbolHasInstance:k}=Vq(),c=Rq().Stream,O=Tq(),{addAbortSignal:l}=Sq(),{getHighWaterMark:D,getDefaultHighWaterMark:p}=JQ(),{ERR_INVALID_ARG_TYPE:E,ERR_METHOD_NOT_IMPLEMENTED:I,ERR_MULTIPLE_CALLBACK:Z,ERR_STREAM_CANNOT_PIPE:U,ERR_STREAM_DESTROYED:T,ERR_STREAM_ALREADY_FINISHED:_,ERR_STREAM_NULL_VALUES:t,ERR_STREAM_WRITE_AFTER_END:i,ERR_UNKNOWN_ENCODING:$}=Wq().codes,{errorOrDestroy:n}=O;function Y(Q={}){const H=this instanceof Mq();if(!H&&!y(Y,this))return new Y(Q);if(this._writableState=new m(Q,this,H),Q){if(typeof Q.write==="function")this._write=Q.write;if(typeof Q.writev==="function")this._writev=Q.writev;if(typeof Q.destroy==="function")this._destroy=Q.destroy;if(typeof Q.final==="function")this._final=Q.final;if(typeof Q.construct==="function")this._construct=Q.construct;if(Q.signal)l(Q.signal,this)}c.call(this,Q),O.construct(this,()=>{const L=this._writableState;if(!L.writing)s(this,L);qq(this,L)})}R(Y.prototype,c.prototype),R(Y,c),j.exports=Y;function K(){}var F=g("kOnFinished");function m(Q,H,L){if(typeof L!=="boolean")L=H instanceof Mq();if(this.objectMode=!!(Q&&Q.objectMode),L)this.objectMode=this.objectMode||!!(Q&&Q.writableObjectMode);this.highWaterMark=Q?D(this,Q,"writableHighWaterMark",L):p(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const d=!!(Q&&Q.decodeStrings===!1);this.decodeStrings=!d,this.defaultEncoding=Q&&Q.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=N.bind(void 0,H),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,u(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!Q||Q.emitClose!==!1,this.autoDestroy=!Q||Q.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[F]=[]}function u(Q){Q.buffered=[],Q.bufferedIndex=0,Q.allBuffers=!0,Q.allNoop=!0}m.prototype.getBuffer=function Q(){return B(this.buffered,this.bufferedIndex)},A(m.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),A(Y,k,{value:function(Q){if(y(this,Q))return!0;if(this!==Y)return!1;return Q&&Q._writableState instanceof m}}),Y.prototype.pipe=function(){n(this,new U)};function J(Q,H,L,d){const f=Q._writableState;if(typeof L==="function")d=L,L=f.defaultEncoding;else{if(!L)L=f.defaultEncoding;else if(L!=="buffer"&&!Buffer.isEncoding(L))throw new $(L);if(typeof d!=="function")d=K}if(H===null)throw new t;else if(!f.objectMode)if(typeof H==="string"){if(f.decodeStrings!==!1)H=Buffer.from(H,L),L="buffer"}else if(H instanceof Buffer)L="buffer";else if(c._isUint8Array(H))H=c._uint8ArrayToBuffer(H),L="buffer";else throw new E("chunk",["string","Buffer","Uint8Array"],H);let r;if(f.ending)r=new i;else if(f.destroyed)r=new T("write");if(r)return Xq(d,r),n(Q,r,!0),r;return f.pendingcb++,z(Q,f,H,L,d)}Y.prototype.write=function(Q,H,L){return J(this,Q,H,L)===!0},Y.prototype.cork=function(){this._writableState.corked++},Y.prototype.uncork=function(){const Q=this._writableState;if(Q.corked){if(Q.corked--,!Q.writing)s(this,Q)}},Y.prototype.setDefaultEncoding=function Q(H){if(typeof H==="string")H=P(H);if(!Buffer.isEncoding(H))throw new $(H);return this._writableState.defaultEncoding=H,this};function z(Q,H,L,d,f){const r=H.objectMode?1:L.length;H.length+=r;const q=H.lengthL.bufferedIndex)s(Q,L);if(d)if(L.afterWriteTickInfo!==null&&L.afterWriteTickInfo.cb===f)L.afterWriteTickInfo.count++;else L.afterWriteTickInfo={count:1,cb:f,stream:Q,state:L},Xq(W,L.afterWriteTickInfo);else b(Q,L,1,f)}}function W({stream:Q,state:H,count:L,cb:d}){return H.afterWriteTickInfo=null,b(Q,H,L,d)}function b(Q,H,L,d){if(!H.ending&&!Q.destroyed&&H.length===0&&H.needDrain)H.needDrain=!1,Q.emit("drain");while(L-- >0)H.pendingcb--,d();if(H.destroyed)o(H);qq(Q,H)}function o(Q){if(Q.writing)return;for(let f=Q.bufferedIndex;f1&&Q._writev){H.pendingcb-=r-1;const X=H.allNoop?K:(x)=>{for(let v=q;v256)L.splice(0,q),H.bufferedIndex=0;else H.bufferedIndex=q}H.bufferProcessing=!1}Y.prototype._write=function(Q,H,L){if(this._writev)this._writev([{chunk:Q,encoding:H}],L);else throw new I("_write()")},Y.prototype._writev=null,Y.prototype.end=function(Q,H,L,d=!1){const f=this._writableState;if(typeof Q==="function")L=Q,Q=null,H=null;else if(typeof H==="function")L=H,H=null;let r;if(Q!==null&&Q!==void 0){let q;if(!d)q=J(this,Q,H);else q=this.write(Q,H);if(q instanceof G)r=q}if(f.corked)f.corked=1,this.uncork();if(r)this.emit("error",r);else if(!f.errored&&!f.ending)f.ending=!0,qq(this,f,!0),f.ended=!0;else if(f.finished)r=new _("end");else if(f.destroyed)r=new T("end");if(typeof L==="function")if(r||f.finished)Xq(L,r);else f[F].push(L);return this};function e(Q,H){var L=Q.ending&&!Q.destroyed&&Q.constructed&&Q.length===0&&!Q.errored&&Q.buffered.length===0&&!Q.finished&&!Q.writing&&!Q.errorEmitted&&!Q.closeEmitted;return Gq("needFinish",L,H),L}function Hq(Q,H){let L=!1;function d(f){if(L){n(Q,f!==null&&f!==void 0?f:Z());return}if(L=!0,H.pendingcb--,f){const r=H[F].splice(0);for(let q=0;q{if(e(f))Kq(d,f);else f.pendingcb--},Q,H);else if(e(H))H.pendingcb++,Kq(Q,H)}}function Kq(Q,H){H.pendingcb--,H.finished=!0;const L=H[F].splice(0);for(let d=0;d{if(S!=null)throw new O("nully","body",S)},(S)=>{l(z,S)});return z=new T({objectMode:!0,readable:!1,write:F,final(S){m(async()=>{try{await w,Xq(S,null)}catch(N){Xq(S,N)}})},destroy:u})}throw new O("Iterable, AsyncIterable or AsyncFunction",n,K)}if(Z($))return i($.arrayBuffer());if(y($))return I(T,$,{objectMode:!0,writable:!1});if(typeof($===null||$===void 0?void 0:$.writable)==="object"||typeof($===null||$===void 0?void 0:$.readable)==="object"){const K=$!==null&&$!==void 0&&$.readable?M($===null||$===void 0?void 0:$.readable)?$===null||$===void 0?void 0:$.readable:i($.readable):void 0,F=$!==null&&$!==void 0&&$.writable?R($===null||$===void 0?void 0:$.writable)?$===null||$===void 0?void 0:$.writable:i($.writable):void 0;return t({readable:K,writable:F})}const Y=$===null||$===void 0?void 0:$.then;if(typeof Y==="function"){let K;return U(Y,$,(F)=>{if(F!=null)K.push(F);K.push(null)},(F)=>{l(K,F)}),K=new T({objectMode:!0,writable:!1,read(){}})}throw new c(n,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],$)};function _(i){let{promise:$,resolve:n}=E();const Y=new AbortController,K=Y.signal;return{value:i(async function*(){while(!0){const m=$;$=null;const{chunk:u,done:J,cb:z}=await m;if(Xq(z),J)return;if(K.aborted)throw new k(void 0,{cause:K.reason});({promise:$,resolve:n}=E()),yield u}}(),{signal:K}),write(m,u,J){const z=n;n=null,z({chunk:m,done:!1,cb:J})},final(m){const u=n;n=null,u({done:!0,cb:m})},destroy(m,u){Y.abort(),u(m)}}}function t(i){const $=i.readable&&typeof i.readable.read!=="function"?p.wrap(i.readable):i.readable,n=i.writable;let Y=!!B($),K=!!G(n),F,m,u,J,z;function w(S){const N=J;if(J=null,N)N(S);else if(S)z.destroy(S);else if(!Y&&!K)z.destroy()}if(z=new T({readableObjectMode:!!($!==null&&$!==void 0&&$.readableObjectMode),writableObjectMode:!!(n!==null&&n!==void 0&&n.writableObjectMode),readable:Y,writable:K}),K)g(n,(S)=>{if(K=!1,S)l($,S);w(S)}),z._write=function(S,N,W){if(n.write(S,N))W();else F=W},z._final=function(S){n.end(),m=S},n.on("drain",function(){if(F){const S=F;F=null,S()}}),n.on("finish",function(){if(m){const S=m;m=null,S()}});if(Y)g($,(S)=>{if(Y=!1,S)l($,S);w(S)}),$.on("readable",function(){if(u){const S=u;u=null,S()}}),$.on("end",function(){z.push(null)}),z._read=function(){while(!0){const S=$.read();if(S===null){u=z._read;return}if(!z.push(S))return}};return z._destroy=function(S,N){if(!S&&J!==null)S=new k;if(u=null,F=null,m=null,J===null)N(S);else J=N,l(n,S),l($,S)},z}}}),Mq=Bq({"node_modules/readable-stream/lib/internal/streams/duplex.js"(a,j){var{ObjectDefineProperties:B,ObjectGetOwnPropertyDescriptor:G,ObjectKeys:y,ObjectSetPrototypeOf:A}=Vq(),M=_q();function R(O){if(!(this instanceof R))return new R(O);if(M.call(this,O),Uq.call(this,O),O){if(this.allowHalfOpen=O.allowHalfOpen!==!1,O.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(O.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}j.exports=R,A(R.prototype,M.prototype),A(R,M);for(var P in Uq.prototype)if(!R.prototype[P])R.prototype[P]=Uq.prototype[P];B(R.prototype,{writable:G(Uq.prototype,"writable"),writableHighWaterMark:G(Uq.prototype,"writableHighWaterMark"),writableObjectMode:G(Uq.prototype,"writableObjectMode"),writableBuffer:G(Uq.prototype,"writableBuffer"),writableLength:G(Uq.prototype,"writableLength"),writableFinished:G(Uq.prototype,"writableFinished"),writableCorked:G(Uq.prototype,"writableCorked"),writableEnded:G(Uq.prototype,"writableEnded"),writableNeedDrain:G(Uq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(O){if(this._readableState&&this._writableState)this._readableState.destroyed=O,this._writableState.destroyed=O}}});var g;function k(){if(g===void 0)g={};return g}R.fromWeb=function(O,l){return k().newStreamDuplexFromReadableWritablePair(O,l)},R.toWeb=function(O){return k().newReadableWritablePairFromDuplex(O)};var c;R.from=function(O){if(!c)c=HQ();return c(O,"body")}}}),mq=Bq({"node_modules/readable-stream/lib/internal/streams/transform.js"(a,j){var{ObjectSetPrototypeOf:B,Symbol:G}=Vq(),{ERR_METHOD_NOT_IMPLEMENTED:y}=Wq().codes,A=Mq();function M(k){if(!(this instanceof M))return new M(k);if(A.call(this,k),this._readableState.sync=!1,this[R]=null,k){if(typeof k.transform==="function")this._transform=k.transform;if(typeof k.flush==="function")this._flush=k.flush}this.on("prefinish",g.bind(this))}B(M.prototype,A.prototype),B(M,A),j.exports=M;var R=G("kCallback");function P(k){if(typeof this._flush==="function"&&!this.destroyed)this._flush((c,O)=>{if(c){if(k)k(c);else this.destroy(c);return}if(O!=null)this.push(O);if(this.push(null),k)k()});else if(this.push(null),k)k()}function g(){if(this._final!==P)P.call(this)}M.prototype._final=P,M.prototype._transform=function(k,c,O){throw new y("_transform()")},M.prototype._write=function(k,c,O){const l=this._readableState,D=this._writableState,p=l.length;this._transform(k,c,(E,I)=>{if(E){O(E);return}if(I!=null)this.push(I);if(D.ended||p===l.length||l.length{S=!0});const N=A(J,{readable:z,writable:w},(W)=>{S=!W});return{destroy:(W)=>{if(S)return;S=!0,R.destroyer(J,W||new l("pipe"))},cleanup:N}}function $(J){return p(J[J.length-1],"streams[stream.length - 1]"),J.pop()}function n(J){if(I(J))return J;else if(U(J))return Y(J);throw new k("val",["Readable","Iterable","AsyncIterable"],J)}async function*Y(J){if(!t)t=_q();yield*t.prototype[y].call(J)}async function K(J,z,w,{end:S}){let N,W=null;const b=(e)=>{if(e)N=e;if(W){const Hq=W;W=null,Hq()}},o=()=>new G((e,Hq)=>{if(N)Hq(N);else W=()=>{if(N)Hq(N);else e()}});z.on("drain",b);const s=A(z,{readable:!1},b);try{if(z.writableNeedDrain)await o();for await(let e of J)if(!z.write(e))await o();if(S)z.end();await o(),w()}catch(e){w(N!==e?g(N,e):e)}finally{s(),z.off("drain",b)}}function F(...J){return m(J,M($(J)))}function m(J,z,w){if(J.length===1&&B(J[0]))J=J[0];if(J.length<2)throw new O("streams");const S=new AbortController,N=S.signal,W=w===null||w===void 0?void 0:w.signal,b=[];E(W,"options.signal");function o(){Kq(new D)}W===null||W===void 0||W.addEventListener("abort",o);let s,e;const Hq=[];let $q=0;function qq(h){Kq(h,--$q===0)}function Kq(h,Q){if(h&&(!s||s.code==="ERR_STREAM_PREMATURE_CLOSE"))s=h;if(!s&&!Q)return;while(Hq.length)Hq.shift()(s);if(W===null||W===void 0||W.removeEventListener("abort",o),S.abort(),Q){if(!s)b.forEach((H)=>H());Xq(z,s,e)}}let Qq;for(let h=0;h0,d=H||(w===null||w===void 0?void 0:w.end)!==!1,f=h===J.length-1;if(T(Q)){let r=function(q){if(q&&q.name!=="AbortError"&&q.code!=="ERR_STREAM_PREMATURE_CLOSE")qq(q)};if(d){const{destroy:q,cleanup:X}=i(Q,H,L);if(Hq.push(q),Z(Q)&&f)b.push(X)}if(Q.on("error",r),Z(Q)&&f)b.push(()=>{Q.removeListener("error",r)})}if(h===0)if(typeof Q==="function"){if(Qq=Q({signal:N}),!I(Qq))throw new c("Iterable, AsyncIterable or Stream","source",Qq)}else if(I(Q)||U(Q))Qq=Q;else Qq=P.from(Q);else if(typeof Q==="function")if(Qq=n(Qq),Qq=Q(Qq,{signal:N}),H){if(!I(Qq,!0))throw new c("AsyncIterable",`transform[${h-1}]`,Qq)}else{var V;if(!_)_=cq();const r=new _({objectMode:!0}),q=(V=Qq)===null||V===void 0?void 0:V.then;if(typeof q==="function")$q++,q.call(Qq,(x)=>{if(e=x,x!=null)r.write(x);if(d)r.end();Xq(qq)},(x)=>{r.destroy(x),Xq(qq,x)});else if(I(Qq,!0))$q++,K(Qq,r,qq,{end:d});else throw new c("AsyncIterable or Promise","destination",Qq);Qq=r;const{destroy:X,cleanup:C}=i(Qq,!1,!0);if(Hq.push(X),f)b.push(C)}else if(T(Q)){if(U(Qq)){$q+=2;const r=u(Qq,Q,qq,{end:d});if(Z(Q)&&f)b.push(r)}else if(I(Qq))$q++,K(Qq,Q,qq,{end:d});else throw new k("val",["Readable","Iterable","AsyncIterable"],Qq);Qq=Q}else Qq=P.from(Q)}if(N!==null&&N!==void 0&&N.aborted||W!==null&&W!==void 0&&W.aborted)Xq(o);return Qq}function u(J,z,w,{end:S}){if(J.pipe(z,{end:S}),S)J.once("end",()=>z.end());else w();return A(J,{readable:!0,writable:!1},(N)=>{const W=J._readableState;if(N&&N.code==="ERR_STREAM_PREMATURE_CLOSE"&&W&&W.ended&&!W.errored&&!W.errorEmitted)J.once("end",w).once("error",w);else w(N)}),A(z,{readable:!1,writable:!0},w)}j.exports={pipelineImpl:m,pipeline:F}}}),KQ=Bq({"node_modules/readable-stream/lib/internal/streams/compose.js"(a,j){var{pipeline:B}=gq(),G=Mq(),{destroyer:y}=Tq(),{isNodeStream:A,isReadable:M,isWritable:R}=Eq(),{AbortError:P,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:k}}=Wq();j.exports=function c(...O){if(O.length===0)throw new k("streams");if(O.length===1)return G.from(O[0]);const l=[...O];if(typeof O[0]==="function")O[0]=G.from(O[0]);if(typeof O[O.length-1]==="function"){const $=O.length-1;O[$]=G.from(O[$])}for(let $=0;$0&&!R(O[$]))throw new g(`streams[${$}]`,l[$],"must be writable")}let D,p,E,I,Z;function U($){const n=I;if(I=null,n)n($);else if($)Z.destroy($);else if(!i&&!t)Z.destroy()}const T=O[0],_=B(O,U),t=!!R(T),i=!!M(_);if(Z=new G({writableObjectMode:!!(T!==null&&T!==void 0&&T.writableObjectMode),readableObjectMode:!!(_!==null&&_!==void 0&&_.writableObjectMode),writable:t,readable:i}),t)Z._write=function($,n,Y){if(T.write($,n))Y();else D=Y},Z._final=function($){T.end(),p=$},T.on("drain",function(){if(D){const $=D;D=null,$()}}),_.on("finish",function(){if(p){const $=p;p=null,$()}});if(i)_.on("readable",function(){if(E){const $=E;E=null,$()}}),_.on("end",function(){Z.push(null)}),Z._read=function(){while(!0){const $=_.read();if($===null){E=Z._read;return}if(!Z.push($))return}};return Z._destroy=function($,n){if(!$&&I!==null)$=new P;if(E=null,D=null,p=null,I===null)n($);else I=n,y(_,$)},Z}}}),dq=Bq({"node_modules/readable-stream/lib/stream/promises.js"(a,j){var{ArrayPrototypePop:B,Promise:G}=Vq(),{isIterable:y,isNodeStream:A}=Eq(),{pipelineImpl:M}=gq(),{finished:R}=Fq();function P(...g){return new G((k,c)=>{let O,l;const D=g[g.length-1];if(D&&typeof D==="object"&&!A(D)&&!y(D)){const p=B(g);O=p.signal,l=p.end}M(g,(p,E)=>{if(p)c(p);else k(E)},{signal:O,end:l})})}j.exports={finished:R,pipeline:P}}}),ZQ=Bq({"node_modules/readable-stream/lib/stream.js"(a,j){var{ObjectDefineProperty:B,ObjectKeys:G,ReflectApply:y}=Vq(),{promisify:{custom:A}}=Aq(),{streamReturningOperators:M,promiseReturningOperators:R}=XQ(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:P}}=Wq(),g=KQ(),{pipeline:k}=gq(),{destroyer:c}=Tq(),O=Fq(),l=dq(),D=Eq(),p=j.exports=Rq().Stream;p.isDisturbed=D.isDisturbed,p.isErrored=D.isErrored,p.isWritable=D.isWritable,p.isReadable=D.isReadable,p.Readable=_q();for(let I of G(M)){let Z=function(...T){if(new.target)throw P();return p.Readable.from(y(U,this,T))};const U=M[I];B(Z,"name",{value:U.name}),B(Z,"length",{value:U.length}),B(p.Readable.prototype,I,{value:Z,enumerable:!1,configurable:!0,writable:!0})}for(let I of G(R)){let Z=function(...T){if(new.target)throw P();return y(U,this,T)};const U=R[I];B(Z,"name",{value:U.name}),B(Z,"length",{value:U.length}),B(p.Readable.prototype,I,{value:Z,enumerable:!1,configurable:!0,writable:!0})}p.Writable=bq(),p.Duplex=Mq(),p.Transform=mq(),p.PassThrough=cq(),p.pipeline=k;var{addAbortSignal:E}=Sq();p.addAbortSignal=E,p.finished=O,p.destroy=c,p.compose=g,B(p,"promises",{configurable:!0,enumerable:!0,get(){return l}}),B(k,A,{enumerable:!0,get(){return l.pipeline}}),B(O,A,{enumerable:!0,get(){return l.finished}}),p.Stream=p,p._isUint8Array=function I(Z){return Z instanceof Uint8Array},p._uint8ArrayToBuffer=function I(Z){return new Buffer(Z.buffer,Z.byteOffset,Z.byteLength)}}}),BQ=Bq({"node_modules/readable-stream/lib/ours/index.js"(a,j){const B=ZQ(),G=dq(),y=B.Readable.destroy;j.exports=B,j.exports._uint8ArrayToBuffer=B._uint8ArrayToBuffer,j.exports._isUint8Array=B._isUint8Array,j.exports.isDisturbed=B.isDisturbed,j.exports.isErrored=B.isErrored,j.exports.isWritable=B.isWritable,j.exports.isReadable=B.isReadable,j.exports.Readable=B.Readable,j.exports.Writable=B.Writable,j.exports.Duplex=B.Duplex,j.exports.Transform=B.Transform,j.exports.PassThrough=B.PassThrough,j.exports.addAbortSignal=B.addAbortSignal,j.exports.finished=B.finished,j.exports.destroy=B.destroy,j.exports.destroy=y,j.exports.pipeline=B.pipeline,j.exports.compose=B.compose,j.exports._getNativeReadableStreamPrototype=lq,j.exports.NativeWritable=iq,zq.defineProperty(B,"promises",{configurable:!0,enumerable:!0,get(){return G}}),j.exports.Stream=B.Stream,j.exports.default=j.exports}}),$Q={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Uq=bq(),iq=class a extends Uq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(j,B={}){super(B);this._construct=this.#H,this._destroy=this.#K,this._final=this.#Z,this.#q=j}#H(j){this._writableState.constructed=!0,this.constructed=!0,j()}#J(){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(j,B,G,y=this.#X){if(!y)return this.#X=!1,super.write(j,B,G);if(!this.#Q)this.#J();var A=this.#Q,M=A.write(j);if(xq(M))return M.then(()=>{this.emit("drain"),A.flush(!0)}),!1;if(A.flush(!0),G)G(null,j.byteLength);return!0}end(j,B,G,y=this.#X){return super.end(j,B,G,y)}#K(j,B){if(this._writableState.destroyed=!0,B)B(j)}#Z(j){if(this.#Q)this.#Q.end();if(j)j()}ref(){if(!this.#Q)this.#J();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},Yq=BQ();Yq[Symbol.for("CommonJS")]=0;Yq[Symbol.for("::bunternal::")]={_ReadableFromWeb:pq,_ReadableFromWebForUndici:uq};var cQ=Yq,EQ=Yq._uint8ArrayToBuffer,IQ=Yq._isUint8Array,TQ=Yq.isDisturbed,PQ=Yq.isErrored,xQ=Yq.isWritable,OQ=Yq.isReadable,CQ=Yq.Readable,Uq=Yq.Writable,_Q=Yq.Duplex,DQ=Yq.Transform,wQ=Yq.PassThrough,vQ=Yq.addAbortSignal,RQ=Yq.finished,SQ=Yq.destroy,gQ=Yq.pipeline,kQ=Yq.compose,VQ=Yq.Stream,fQ=Yq.eos=Fq,yQ=Yq._getNativeReadableStreamPrototype,iq=Yq.NativeWritable,hQ=VQ.promises;export{hQ as promises,gQ as pipeline,xQ as isWritable,OQ as isReadable,PQ as isErrored,TQ as isDisturbed,RQ as finished,fQ as eos,SQ as destroy,cQ as default,kQ as compose,vQ as addAbortSignal,EQ as _uint8ArrayToBuffer,IQ as _isUint8Array,yQ as _getNativeReadableStreamPrototype,Uq as Writable,DQ as Transform,VQ as Stream,CQ as Readable,wQ as PassThrough,iq as NativeWritable,_Q as Duplex}; +import{EventEmitter as Iq} from"bun:events_native";import{StringDecoder as aq} from"node:string_decoder";var tq=function(a){return typeof a==="object"&&a!==null&&a instanceof ReadableStream},eq=function(a,j){if(typeof a!=="boolean")throw new qQ(j,"boolean",a)};var qQ=function(a,j,B){return new Error(`The argument '${a}' is invalid. Received '${B}' for type '${j}'`)},QQ=function(a,j,B){return new Error(`The value '${j}' is invalid for argument '${a}'. Reason: ${B}`)},YQ=function(a,j){var[B,G,y,A,M,R,T]=globalThis[Symbol.for("Bun.lazy")](a),g=[!1],k=function(E,P,Z,U){if(P>0){const I=Z.subarray(0,P),_=Z.subarray(P);if(I.byteLength>0)E.push(I);if(U)E.push(null);return _.byteLength>0?_:void 0}if(U)E.push(null);return Z},c=function(E,P,Z,U){if(P.byteLength>0)E.push(P);if(U)E.push(null);return Z},O=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!=="1";const l=new FinalizationRegistry((E)=>E&&M(E)),D=512;var p=class E extends j{#q;#Q=1;#X=!1;#H=void 0;#J;#K=!1;#Z=!O;#B;constructor(P,Z={}){super(Z);if(typeof Z.highWaterMark==="number")this.#J=Z.highWaterMark;else this.#J=262144;this.#q=P,this.#X=!1,this.#H=void 0,this.#K=!1,this.#B={},l.register(this,this.#q,this.#B)}_read(P){if(this.#K)return;var Z=this.#q;if(Z===0){this.push(null);return}if(!this.#X)this.#$(Z);return this.#V(this.#z(P),Z)}#$(P){this.#X=!0;const Z=G(P,this.#J);if(typeof Z==="number"&&Z>1)this.#Z=!0,this.#J=Math.min(this.#J,Z);if(T){const U=T(P);if((U?.byteLength??0)>0)this.push(U)}}#z(P=this.#J){var Z=this.#H;if(Z?.byteLength??0D?P:D;this.#H=Z=new Buffer(U)}return Z}#Y(P,Z,U){if(typeof P==="number"){if(P>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0;return k(this,P,Z,U)}else if(typeof P==="boolean")return process.nextTick(()=>{this.push(null)}),Z?.byteLength??0>0?Z:void 0;else if(ArrayBuffer.isView(P)){if(P.byteLength>=this.#J&&!this.#Z&&!U)this.#J*=2,this.#Z=!0;return c(this,P,Z,U)}else throw new Error("Invalid result from pull")}#V(P,Z){g[0]=!1;var U=B(Z,P,g);if(xq(U))return this.#K=!0,U.then((I)=>{this.#K=!1,this.#H=this.#Y(I,P,g[0])},(I)=>{errorOrDestroy(this,I)});else this.#H=this.#Y(U,P,g[0])}_destroy(P,Z){var U=this.#q;if(U===0){Z(P);return}if(l.unregister(this.#B),this.#q=0,R)R(U,!1);y(U,P),Z(P)}ref(){var P=this.#q;if(P===0)return;if(this.#Q++===0)R(P,!0)}unref(){var P=this.#q;if(P===0)return;if(this.#Q--===1)R(P,!1)}};if(!R)p.prototype.ref=void 0,p.prototype.unref=void 0;return p},lq=function(a,j){return $Q[a]||=YQ(a,j)},zQ=function(a,j,B){if(!(j&&typeof j==="object"&&j instanceof ReadableStream))return;const G=sq(j);if(!G){Gq("no native readable stream");return}const{stream:y,data:A}=G;return new(lq(A,a))(y,B)};var Gq=()=>{},{isPromise:xq,isCallable:oq,direct:sq,Object:zq}=globalThis[Symbol.for("Bun.lazy")]("primordials"),GQ=zq.create,MQ=zq.defineProperty,FQ=zq.getOwnPropertyDescriptor,rq=zq.getOwnPropertyNames,LQ=zq.getPrototypeOf,jQ=zq.prototype.hasOwnProperty,NQ=zq.setPrototypeOf,Bq=(a,j)=>function B(){return j||(0,a[rq(a)[0]])((j={exports:{}}).exports,j),j.exports};var Xq=process.nextTick;var AQ=Array.isArray,Vq=Bq({"node_modules/readable-stream/lib/ours/primordials.js"(a,j){j.exports={ArrayIsArray(B){return Array.isArray(B)},ArrayPrototypeIncludes(B,G){return B.includes(G)},ArrayPrototypeIndexOf(B,G){return B.indexOf(G)},ArrayPrototypeJoin(B,G){return B.join(G)},ArrayPrototypeMap(B,G){return B.map(G)},ArrayPrototypePop(B,G){return B.pop(G)},ArrayPrototypePush(B,G){return B.push(G)},ArrayPrototypeSlice(B,G,y){return B.slice(G,y)},Error,FunctionPrototypeCall(B,G,...y){return B.call(G,...y)},FunctionPrototypeSymbolHasInstance(B,G){return Function.prototype[Symbol.hasInstance].call(B,G)},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(B,G){return zq.defineProperties(B,G)},ObjectDefineProperty(B,G,y){return zq.defineProperty(B,G,y)},ObjectGetOwnPropertyDescriptor(B,G){return zq.getOwnPropertyDescriptor(B,G)},ObjectKeys(B){return zq.keys(B)},ObjectSetPrototypeOf(B,G){return zq.setPrototypeOf(B,G)},Promise,PromisePrototypeCatch(B,G){return B.catch(G)},PromisePrototypeThen(B,G,y){return B.then(G,y)},PromiseReject(B){return Promise.reject(B)},ReflectApply:Reflect.apply,RegExpPrototypeTest(B,G){return B.test(G)},SafeSet:Set,String,StringPrototypeSlice(B,G,y){return B.slice(G,y)},StringPrototypeToLowerCase(B){return B.toLowerCase()},StringPrototypeToUpperCase(B){return B.toUpperCase()},StringPrototypeTrim(B){return B.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(B,G,y){return B.set(G,y)},Uint8Array}}}),Aq=Bq({"node_modules/readable-stream/lib/ours/util.js"(a,j){var B=zq.getPrototypeOf(async function(){}).constructor,G=typeof Blob!=="undefined"?function A(M){return M instanceof Blob}:function A(M){return!1},y=class extends Error{constructor(A){if(!Array.isArray(A))throw new TypeError(`Expected input to be an Array, got ${typeof A}`);let M="";for(let R=0;R{A=T,M=g}),resolve:A,reject:M}},promisify(A){return new Promise((M,R)=>{A((T,...g)=>{if(T)return R(T);return M(...g)})})},debuglog(){return function(){}},format(A,...M){return A.replace(/%([sdifj])/g,function(...[R,T]){const g=M.shift();if(T==="f")return g.toFixed(6);else if(T==="j")return JSON.stringify(g);else if(T==="s"&&typeof g==="object")return`${g.constructor!==zq?g.constructor.name:""} {}`.trim();else return g.toString()})},inspect(A){switch(typeof A){case"string":if(A.includes("'")){if(!A.includes('"'))return`"${A}"`;else if(!A.includes("`")&&!A.includes("${"))return`\`${A}\``}return`'${A}'`;case"number":if(isNaN(A))return"NaN";else if(zq.is(A,-0))return String(A);return A;case"bigint":return`${String(A)}n`;case"boolean":case"undefined":return String(A);case"object":return"{}"}},types:{isAsyncFunction(A){return A instanceof B},isArrayBufferView(A){return ArrayBuffer.isView(A)}},isBlob:G},j.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}}),Wq=Bq({"node_modules/readable-stream/lib/ours/errors.js"(a,j){var{format:B,inspect:G,AggregateError:y}=Aq(),A=globalThis.AggregateError||y,M=Symbol("kIsNodeError"),R=["string","function","number","object","Function","Object","boolean","bigint","symbol"],T=/^([A-Z][a-z0-9]*)+$/,g="__node_internal_",k={};function c(Z,U){if(!Z)throw new k.ERR_INTERNAL_ASSERTION(U)}function O(Z){let U="",I=Z.length;const _=Z[0]==="-"?1:0;for(;I>=_+4;I-=3)U=`_${Z.slice(I-3,I)}${U}`;return`${Z.slice(0,I)}${U}`}function l(Z,U,I){if(typeof U==="function")return c(U.length<=I.length,`Code: ${Z}; The provided arguments length (${I.length}) does not match the required ones (${U.length}).`),U(...I);const _=(U.match(/%[dfijoOs]/g)||[]).length;if(c(_===I.length,`Code: ${Z}; The provided arguments length (${I.length}) does not match the required ones (${_}).`),I.length===0)return U;return B(U,...I)}function D(Z,U,I){if(!I)I=Error;class _ extends I{constructor(...t){super(l(Z,U,t))}toString(){return`${this.name} [${Z}]: ${this.message}`}}zq.defineProperties(_.prototype,{name:{value:I.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${Z}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),_.prototype.code=Z,_.prototype[M]=!0,k[Z]=_}function p(Z){const U=g+Z.name;return zq.defineProperty(Z,"name",{value:U}),Z}function E(Z,U){if(Z&&U&&Z!==U){if(Array.isArray(U.errors))return U.errors.push(Z),U;const I=new A([U,Z],U.message);return I.code=U.code,I}return Z||U}var P=class extends Error{constructor(Z="The operation was aborted",U=void 0){if(U!==void 0&&typeof U!=="object")throw new k.ERR_INVALID_ARG_TYPE("options","Object",U);super(Z,U);this.code="ABORT_ERR",this.name="AbortError"}};D("ERR_ASSERTION","%s",Error),D("ERR_INVALID_ARG_TYPE",(Z,U,I)=>{if(c(typeof Z==="string","'name' must be a string"),!Array.isArray(U))U=[U];let _="The ";if(Z.endsWith(" argument"))_+=`${Z} `;else _+=`"${Z}" ${Z.includes(".")?"property":"argument"} `;_+="must be ";const t=[],i=[],$=[];for(let Y of U)if(c(typeof Y==="string","All expected entries have to be of type string"),R.includes(Y))t.push(Y.toLowerCase());else if(T.test(Y))i.push(Y);else c(Y!=="object",'The value "object" should be written as "Object"'),$.push(Y);if(i.length>0){const Y=t.indexOf("object");if(Y!==-1)t.splice(t,Y,1),i.push("Object")}if(t.length>0){switch(t.length){case 1:_+=`of type ${t[0]}`;break;case 2:_+=`one of type ${t[0]} or ${t[1]}`;break;default:{const Y=t.pop();_+=`one of type ${t.join(", ")}, or ${Y}`}}if(i.length>0||$.length>0)_+=" or "}if(i.length>0){switch(i.length){case 1:_+=`an instance of ${i[0]}`;break;case 2:_+=`an instance of ${i[0]} or ${i[1]}`;break;default:{const Y=i.pop();_+=`an instance of ${i.join(", ")}, or ${Y}`}}if($.length>0)_+=" or "}switch($.length){case 0:break;case 1:if($[0].toLowerCase()!==$[0])_+="an ";_+=`${$[0]}`;break;case 2:_+=`one of ${$[0]} or ${$[1]}`;break;default:{const Y=$.pop();_+=`one of ${$.join(", ")}, or ${Y}`}}if(I==null)_+=`. Received ${I}`;else if(typeof I==="function"&&I.name)_+=`. Received function ${I.name}`;else if(typeof I==="object"){var n;if((n=I.constructor)!==null&&n!==void 0&&n.name)_+=`. Received an instance of ${I.constructor.name}`;else{const Y=G(I,{depth:-1});_+=`. Received ${Y}`}}else{let Y=G(I,{colors:!1});if(Y.length>25)Y=`${Y.slice(0,25)}...`;_+=`. Received type ${typeof I} (${Y})`}return _},TypeError),D("ERR_INVALID_ARG_VALUE",(Z,U,I="is invalid")=>{let _=G(U);if(_.length>128)_=_.slice(0,128)+"...";return`The ${Z.includes(".")?"property":"argument"} '${Z}' ${I}. Received ${_}`},TypeError),D("ERR_INVALID_RETURN_VALUE",(Z,U,I)=>{var _;const t=I!==null&&I!==void 0&&(_=I.constructor)!==null&&_!==void 0&&_.name?`instance of ${I.constructor.name}`:`type ${typeof I}`;return`Expected ${Z} to be returned from the "${U}" function but got ${t}.`},TypeError),D("ERR_MISSING_ARGS",(...Z)=>{c(Z.length>0,"At least one arg needs to be specified");let U;const I=Z.length;switch(Z=(Array.isArray(Z)?Z:[Z]).map((_)=>`"${_}"`).join(" or "),I){case 1:U+=`The ${Z[0]} argument`;break;case 2:U+=`The ${Z[0]} and ${Z[1]} arguments`;break;default:{const _=Z.pop();U+=`The ${Z.join(", ")}, and ${_} arguments`}break}return`${U} must be specified`},TypeError),D("ERR_OUT_OF_RANGE",(Z,U,I)=>{c(U,'Missing "range" argument');let _;if(Number.isInteger(I)&&Math.abs(I)>4294967296)_=O(String(I));else if(typeof I==="bigint"){if(_=String(I),I>2n**32n||I<-(2n**32n))_=O(_);_+="n"}else _=G(I);return`The value of "${Z}" is out of range. It must be ${U}. Received ${_}`},RangeError),D("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),D("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),D("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),D("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),D("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),D("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),D("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),D("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),D("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),D("ERR_STREAM_WRITE_AFTER_END","write after end",Error),D("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),j.exports={AbortError:P,aggregateTwoErrors:p(E),hideStackFrames:p,codes:k}}}),Cq=Bq({"node_modules/readable-stream/lib/internal/validators.js"(a,j){var{ArrayIsArray:B,ArrayPrototypeIncludes:G,ArrayPrototypeJoin:y,ArrayPrototypeMap:A,NumberIsInteger:M,NumberMAX_SAFE_INTEGER:R,NumberMIN_SAFE_INTEGER:T,NumberParseInt:g,RegExpPrototypeTest:k,String:c,StringPrototypeToUpperCase:O,StringPrototypeTrim:l}=Vq(),{hideStackFrames:D,codes:{ERR_SOCKET_BAD_PORT:p,ERR_INVALID_ARG_TYPE:E,ERR_INVALID_ARG_VALUE:P,ERR_OUT_OF_RANGE:Z,ERR_UNKNOWN_SIGNAL:U}}=Wq(),{normalizeEncoding:I}=Aq(),{isAsyncFunction:_,isArrayBufferView:t}=Aq().types,i={};function $(V){return V===(V|0)}function n(V){return V===V>>>0}var Y=/^[0-7]+$/,K="must be a 32-bit unsigned integer or an octal string";function F(V,h,Q){if(typeof V==="undefined")V=Q;if(typeof V==="string"){if(!k(Y,V))throw new P(h,V,K);V=g(V,8)}return u(V,h,0,4294967295),V}var m=D((V,h,Q=T,H=R)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!M(V))throw new Z(h,"an integer",V);if(VH)throw new Z(h,`>= ${Q} && <= ${H}`,V)}),u=D((V,h,Q=-2147483648,H=2147483647)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!$(V)){if(!M(V))throw new Z(h,"an integer",V);throw new Z(h,`>= ${Q} && <= ${H}`,V)}if(VH)throw new Z(h,`>= ${Q} && <= ${H}`,V)}),J=D((V,h,Q)=>{if(typeof V!=="number")throw new E(h,"number",V);if(!n(V)){if(!M(V))throw new Z(h,"an integer",V);throw new Z(h,`>= ${Q?1:0} && < 4294967296`,V)}if(Q&&V===0)throw new Z(h,">= 1 && < 4294967296",V)});function z(V,h){if(typeof V!=="string")throw new E(h,"string",V)}function w(V,h){if(typeof V!=="number")throw new E(h,"number",V)}var S=D((V,h,Q)=>{if(!G(Q,V)){const L="must be one of: "+y(A(Q,(d)=>typeof d==="string"?`'${d}'`:c(d)),", ");throw new P(h,V,L)}});function N(V,h){if(typeof V!=="boolean")throw new E(h,"boolean",V)}var W=D((V,h,Q)=>{const H=Q==null,L=H?!1:Q.allowArray,d=H?!1:Q.allowFunction;if(!(H?!1:Q.nullable)&&V===null||!L&&B(V)||typeof V!=="object"&&(!d||typeof V!=="function"))throw new E(h,"Object",V)}),b=D((V,h,Q=0)=>{if(!B(V))throw new E(h,"Array",V);if(V.length{if(!t(V))throw new E(h,["Buffer","TypedArray","DataView"],V)});function e(V,h){const Q=I(h),H=V.length;if(Q==="hex"&&H%2!==0)throw new P("encoding",h,`is invalid for data of length ${H}`)}function Hq(V,h="Port",Q=!0){if(typeof V!=="number"&&typeof V!=="string"||typeof V==="string"&&l(V).length===0||+V!==+V>>>0||V>65535||V===0&&!Q)throw new p(h,V,Q);return V|0}var $q=D((V,h)=>{if(V!==void 0&&(V===null||typeof V!=="object"||!("aborted"in V)))throw new E(h,"AbortSignal",V)}),qq=D((V,h)=>{if(typeof V!=="function")throw new E(h,"Function",V)}),Kq=D((V,h)=>{if(typeof V!=="function"||_(V))throw new E(h,"Function",V)}),Qq=D((V,h)=>{if(V!==void 0)throw new E(h,"undefined",V)});j.exports={isInt32:$,isUint32:n,parseFileMode:F,validateArray:b,validateBoolean:N,validateBuffer:s,validateEncoding:e,validateFunction:qq,validateInt32:u,validateInteger:m,validateNumber:w,validateObject:W,validateOneOf:S,validatePlainFunction:Kq,validatePort:Hq,validateSignalName:o,validateString:z,validateUint32:J,validateUndefined:Qq,validateAbortSignal:$q}}}),Eq=Bq({"node_modules/readable-stream/lib/internal/streams/utils.js"(a,j){var{Symbol:B,SymbolAsyncIterator:G,SymbolIterator:y}=Vq(),A=B("kDestroyed"),M=B("kIsErrored"),R=B("kIsReadable"),T=B("kIsDisturbed");function g(J,z=!1){var w;return!!(J&&typeof J.pipe==="function"&&typeof J.on==="function"&&(!z||typeof J.pause==="function"&&typeof J.resume==="function")&&(!J._writableState||((w=J._readableState)===null||w===void 0?void 0:w.readable)!==!1)&&(!J._writableState||J._readableState))}function k(J){var z;return!!(J&&typeof J.write==="function"&&typeof J.on==="function"&&(!J._readableState||((z=J._writableState)===null||z===void 0?void 0:z.writable)!==!1))}function c(J){return!!(J&&typeof J.pipe==="function"&&J._readableState&&typeof J.on==="function"&&typeof J.write==="function")}function O(J){return J&&(J._readableState||J._writableState||typeof J.write==="function"&&typeof J.on==="function"||typeof J.pipe==="function"&&typeof J.on==="function")}function l(J,z){if(J==null)return!1;if(z===!0)return typeof J[G]==="function";if(z===!1)return typeof J[y]==="function";return typeof J[G]==="function"||typeof J[y]==="function"}function D(J){if(!O(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!!(J.destroyed||J[A]||S!==null&&S!==void 0&&S.destroyed)}function p(J){if(!k(J))return null;if(J.writableEnded===!0)return!0;const z=J._writableState;if(z!==null&&z!==void 0&&z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function E(J,z){if(!k(J))return null;if(J.writableFinished===!0)return!0;const w=J._writableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.finished)!=="boolean")return null;return!!(w.finished||z===!1&&w.ended===!0&&w.length===0)}function P(J){if(!g(J))return null;if(J.readableEnded===!0)return!0;const z=J._readableState;if(!z||z.errored)return!1;if(typeof(z===null||z===void 0?void 0:z.ended)!=="boolean")return null;return z.ended}function Z(J,z){if(!g(J))return null;const w=J._readableState;if(w!==null&&w!==void 0&&w.errored)return!1;if(typeof(w===null||w===void 0?void 0:w.endEmitted)!=="boolean")return null;return!!(w.endEmitted||z===!1&&w.ended===!0&&w.length===0)}function U(J){if(J&&J[R]!=null)return J[R];if(typeof(J===null||J===void 0?void 0:J.readable)!=="boolean")return null;if(D(J))return!1;return g(J)&&J.readable&&!Z(J)}function I(J){if(typeof(J===null||J===void 0?void 0:J.writable)!=="boolean")return null;if(D(J))return!1;return k(J)&&J.writable&&!p(J)}function _(J,z){if(!O(J))return null;if(D(J))return!0;if((z===null||z===void 0?void 0:z.readable)!==!1&&U(J))return!1;if((z===null||z===void 0?void 0:z.writable)!==!1&&I(J))return!1;return!0}function t(J){var z,w;if(!O(J))return null;if(J.writableErrored)return J.writableErrored;return(z=(w=J._writableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function i(J){var z,w;if(!O(J))return null;if(J.readableErrored)return J.readableErrored;return(z=(w=J._readableState)===null||w===void 0?void 0:w.errored)!==null&&z!==void 0?z:null}function $(J){if(!O(J))return null;if(typeof J.closed==="boolean")return J.closed;const{_writableState:z,_readableState:w}=J;if(typeof(z===null||z===void 0?void 0:z.closed)==="boolean"||typeof(w===null||w===void 0?void 0:w.closed)==="boolean")return(z===null||z===void 0?void 0:z.closed)||(w===null||w===void 0?void 0:w.closed);if(typeof J._closed==="boolean"&&n(J))return J._closed;return null}function n(J){return typeof J._closed==="boolean"&&typeof J._defaultKeepAlive==="boolean"&&typeof J._removedConnection==="boolean"&&typeof J._removedContLen==="boolean"}function Y(J){return typeof J._sent100==="boolean"&&n(J)}function K(J){var z;return typeof J._consuming==="boolean"&&typeof J._dumped==="boolean"&&((z=J.req)===null||z===void 0?void 0:z.upgradeOrConnect)===void 0}function F(J){if(!O(J))return null;const{_writableState:z,_readableState:w}=J,S=z||w;return!S&&Y(J)||!!(S&&S.autoDestroy&&S.emitClose&&S.closed===!1)}function m(J){var z;return!!(J&&((z=J[T])!==null&&z!==void 0?z:J.readableDidRead||J.readableAborted))}function u(J){var z,w,S,N,W,b,o,s,e,Hq;return!!(J&&((z=(w=(S=(N=(W=(b=J[M])!==null&&b!==void 0?b:J.readableErrored)!==null&&W!==void 0?W:J.writableErrored)!==null&&N!==void 0?N:(o=J._readableState)===null||o===void 0?void 0:o.errorEmitted)!==null&&S!==void 0?S:(s=J._writableState)===null||s===void 0?void 0:s.errorEmitted)!==null&&w!==void 0?w:(e=J._readableState)===null||e===void 0?void 0:e.errored)!==null&&z!==void 0?z:(Hq=J._writableState)===null||Hq===void 0?void 0:Hq.errored))}j.exports={kDestroyed:A,isDisturbed:m,kIsDisturbed:T,isErrored:u,kIsErrored:M,isReadable:U,kIsReadable:R,isClosed:$,isDestroyed:D,isDuplexNodeStream:c,isFinished:_,isIterable:l,isReadableNodeStream:g,isReadableEnded:P,isReadableFinished:Z,isReadableErrored:i,isNodeStream:O,isWritable:I,isWritableNodeStream:k,isWritableEnded:p,isWritableFinished:E,isWritableErrored:t,isServerRequest:K,isServerResponse:Y,willEmitClose:F}}}),Fq=Bq({"node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(a,j){var{AbortError:B,codes:G}=Wq(),{ERR_INVALID_ARG_TYPE:y,ERR_STREAM_PREMATURE_CLOSE:A}=G,{once:M}=Aq(),{validateAbortSignal:R,validateFunction:T,validateObject:g}=Cq(),{Promise:k}=Vq(),{isClosed:c,isReadable:O,isReadableNodeStream:l,isReadableFinished:D,isReadableErrored:p,isWritable:E,isWritableNodeStream:P,isWritableFinished:Z,isWritableErrored:U,isNodeStream:I,willEmitClose:_}=Eq();function t(Y){return Y.setHeader&&typeof Y.abort==="function"}var i=()=>{};function $(Y,K,F){var m,u;if(arguments.length===2)F=K,K={};else if(K==null)K={};else g(K,"options");T(F,"callback"),R(K.signal,"options.signal"),F=M(F);const J=(m=K.readable)!==null&&m!==void 0?m:l(Y),z=(u=K.writable)!==null&&u!==void 0?u:P(Y);if(!I(Y))throw new y("stream","Stream",Y);const{_writableState:w,_readableState:S}=Y,N=()=>{if(!Y.writable)o()};let W=_(Y)&&l(Y)===J&&P(Y)===z,b=Z(Y,!1);const o=()=>{if(b=!0,Y.destroyed)W=!1;if(W&&(!Y.readable||J))return;if(!J||s)F.call(Y)};let s=D(Y,!1);const e=()=>{if(s=!0,Y.destroyed)W=!1;if(W&&(!Y.writable||z))return;if(!z||b)F.call(Y)},Hq=(V)=>{F.call(Y,V)};let $q=c(Y);const qq=()=>{$q=!0;const V=U(Y)||p(Y);if(V&&typeof V!=="boolean")return F.call(Y,V);if(J&&!s&&l(Y,!0)){if(!D(Y,!1))return F.call(Y,new A)}if(z&&!b){if(!Z(Y,!1))return F.call(Y,new A)}F.call(Y)},Kq=()=>{Y.req.on("finish",o)};if(t(Y)){if(Y.on("complete",o),!W)Y.on("abort",qq);if(Y.req)Kq();else Y.on("request",Kq)}else if(z&&!w)Y.on("end",N),Y.on("close",N);if(!W&&typeof Y.aborted==="boolean")Y.on("aborted",qq);if(Y.on("end",e),Y.on("finish",o),K.error!==!1)Y.on("error",Hq);if(Y.on("close",qq),$q)Xq(qq);else if(w!==null&&w!==void 0&&w.errorEmitted||S!==null&&S!==void 0&&S.errorEmitted){if(!W)Xq(qq)}else if(!J&&(!W||O(Y))&&(b||E(Y)===!1))Xq(qq);else if(!z&&(!W||E(Y))&&(s||O(Y)===!1))Xq(qq);else if(S&&Y.req&&Y.aborted)Xq(qq);const Qq=()=>{if(F=i,Y.removeListener("aborted",qq),Y.removeListener("complete",o),Y.removeListener("abort",qq),Y.removeListener("request",Kq),Y.req)Y.req.removeListener("finish",o);Y.removeListener("end",N),Y.removeListener("close",N),Y.removeListener("finish",o),Y.removeListener("end",e),Y.removeListener("error",Hq),Y.removeListener("close",qq)};if(K.signal&&!$q){const V=()=>{const h=F;Qq(),h.call(Y,new B(void 0,{cause:K.signal.reason}))};if(K.signal.aborted)Xq(V);else{const h=F;F=M((...Q)=>{K.signal.removeEventListener("abort",V),h.apply(Y,Q)}),K.signal.addEventListener("abort",V)}}return Qq}function n(Y,K){return new k((F,m)=>{$(Y,K,(u)=>{if(u)m(u);else F()})})}j.exports=$,j.exports.finished=n}}),XQ=Bq({"node_modules/readable-stream/lib/internal/streams/operators.js"(a,j){var{codes:{ERR_INVALID_ARG_TYPE:B,ERR_MISSING_ARGS:G,ERR_OUT_OF_RANGE:y},AbortError:A}=Wq(),{validateAbortSignal:M,validateInteger:R,validateObject:T}=Cq(),g=Vq().Symbol("kWeak"),{finished:k}=Fq(),{ArrayPrototypePush:c,MathFloor:O,Number:l,NumberIsNaN:D,Promise:p,PromiseReject:E,PromisePrototypeCatch:P,Symbol:Z}=Vq(),U=Z("kEmpty"),I=Z("kEof");function _(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);if(W!=null)T(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");let b=1;if((W===null||W===void 0?void 0:W.concurrency)!=null)b=O(W.concurrency);return R(b,"concurrency",1),async function*o(){var s,e;const Hq=new AbortController,$q=this,qq=[],Kq=Hq.signal,Qq={signal:Kq},V=()=>Hq.abort();if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)V();W===null||W===void 0||(e=W.signal)===null||e===void 0||e.addEventListener("abort",V);let h,Q,H=!1;function L(){H=!0}async function d(){try{for await(let q of $q){var f;if(H)return;if(Kq.aborted)throw new A;try{q=N(q,Qq)}catch(X){q=E(X)}if(q===U)continue;if(typeof((f=q)===null||f===void 0?void 0:f.catch)==="function")q.catch(L);if(qq.push(q),h)h(),h=null;if(!H&&qq.length&&qq.length>=b)await new p((X)=>{Q=X})}qq.push(I)}catch(q){const X=E(q);P(X,L),qq.push(X)}finally{var r;if(H=!0,h)h(),h=null;W===null||W===void 0||(r=W.signal)===null||r===void 0||r.removeEventListener("abort",V)}}d();try{while(!0){while(qq.length>0){const f=await qq[0];if(f===I)return;if(Kq.aborted)throw new A;if(f!==U)yield f;if(qq.shift(),Q)Q(),Q=null}await new p((f)=>{h=f})}}finally{if(Hq.abort(),H=!0,Q)Q(),Q=null}}.call(this)}function t(N=void 0){if(N!=null)T(N,"options");if((N===null||N===void 0?void 0:N.signal)!=null)M(N.signal,"options.signal");return async function*W(){let b=0;for await(let s of this){var o;if(N!==null&&N!==void 0&&(o=N.signal)!==null&&o!==void 0&&o.aborted)throw new A({cause:N.signal.reason});yield[b++,s]}}.call(this)}async function i(N,W=void 0){for await(let b of K.call(this,N,W))return!0;return!1}async function $(N,W=void 0){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);return!await i.call(this,async(...b)=>{return!await N(...b)},W)}async function n(N,W){for await(let b of K.call(this,N,W))return b;return}async function Y(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);async function b(o,s){return await N(o,s),U}for await(let o of _.call(this,b,W));}function K(N,W){if(typeof N!=="function")throw new B("fn",["Function","AsyncFunction"],N);async function b(o,s){if(await N(o,s))return o;return U}return _.call(this,b,W)}var F=class extends G{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}};async function m(N,W,b){var o;if(typeof N!=="function")throw new B("reducer",["Function","AsyncFunction"],N);if(b!=null)T(b,"options");if((b===null||b===void 0?void 0:b.signal)!=null)M(b.signal,"options.signal");let s=arguments.length>1;if(b!==null&&b!==void 0&&(o=b.signal)!==null&&o!==void 0&&o.aborted){const Kq=new A(void 0,{cause:b.signal.reason});throw this.once("error",()=>{}),await k(this.destroy(Kq)),Kq}const e=new AbortController,Hq=e.signal;if(b!==null&&b!==void 0&&b.signal){const Kq={once:!0,[g]:this};b.signal.addEventListener("abort",()=>e.abort(),Kq)}let $q=!1;try{for await(let Kq of this){var qq;if($q=!0,b!==null&&b!==void 0&&(qq=b.signal)!==null&&qq!==void 0&&qq.aborted)throw new A;if(!s)W=Kq,s=!0;else W=await N(W,Kq,{signal:Hq})}if(!$q&&!s)throw new F}finally{e.abort()}return W}async function u(N){if(N!=null)T(N,"options");if((N===null||N===void 0?void 0:N.signal)!=null)M(N.signal,"options.signal");const W=[];for await(let o of this){var b;if(N!==null&&N!==void 0&&(b=N.signal)!==null&&b!==void 0&&b.aborted)throw new A(void 0,{cause:N.signal.reason});c(W,o)}return W}function J(N,W){const b=_.call(this,N,W);return async function*o(){for await(let s of b)yield*s}.call(this)}function z(N){if(N=l(N),D(N))return 0;if(N<0)throw new y("number",">= 0",N);return N}function w(N,W=void 0){if(W!=null)T(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");return N=z(N),async function*b(){var o;if(W!==null&&W!==void 0&&(o=W.signal)!==null&&o!==void 0&&o.aborted)throw new A;for await(let e of this){var s;if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)throw new A;if(N--<=0)yield e}}.call(this)}function S(N,W=void 0){if(W!=null)T(W,"options");if((W===null||W===void 0?void 0:W.signal)!=null)M(W.signal,"options.signal");return N=z(N),async function*b(){var o;if(W!==null&&W!==void 0&&(o=W.signal)!==null&&o!==void 0&&o.aborted)throw new A;for await(let e of this){var s;if(W!==null&&W!==void 0&&(s=W.signal)!==null&&s!==void 0&&s.aborted)throw new A;if(N-- >0)yield e;else return}}.call(this)}j.exports.streamReturningOperators={asIndexedPairs:t,drop:w,filter:K,flatMap:J,map:_,take:S},j.exports.promiseReturningOperators={every:$,forEach:Y,reduce:m,toArray:u,some:i,find:n}}}),Tq=Bq({"node_modules/readable-stream/lib/internal/streams/destroy.js"(a,j){var{aggregateTwoErrors:B,codes:{ERR_MULTIPLE_CALLBACK:G},AbortError:y}=Wq(),{Symbol:A}=Vq(),{kDestroyed:M,isDestroyed:R,isFinished:T,isServerRequest:g}=Eq(),k="#kDestroy",c="#kConstruct";function O(K,F,m){if(K){if(K.stack,F&&!F.errored)F.errored=K;if(m&&!m.errored)m.errored=K}}function l(K,F){const m=this._readableState,u=this._writableState,J=u||m;if(u&&u.destroyed||m&&m.destroyed){if(typeof F==="function")F();return this}if(O(K,u,m),u)u.destroyed=!0;if(m)m.destroyed=!0;if(!J.constructed)this.once(k,(z)=>{D(this,B(z,K),F)});else D(this,K,F);return this}function D(K,F,m){let u=!1;function J(z){if(u)return;u=!0;const{_readableState:w,_writableState:S}=K;if(O(z,S,w),S)S.closed=!0;if(w)w.closed=!0;if(typeof m==="function")m(z);if(z)Xq(p,K,z);else Xq(E,K)}try{K._destroy(F||null,J)}catch(z){J(z)}}function p(K,F){P(K,F),E(K)}function E(K){const{_readableState:F,_writableState:m}=K;if(m)m.closeEmitted=!0;if(F)F.closeEmitted=!0;if(m&&m.emitClose||F&&F.emitClose)K.emit("close")}function P(K,F){const m=K?._readableState,u=K?._writableState;if(u?.errorEmitted||m?.errorEmitted)return;if(u)u.errorEmitted=!0;if(m)m.errorEmitted=!0;K?.emit?.("error",F)}function Z(){const K=this._readableState,F=this._writableState;if(K)K.constructed=!0,K.closed=!1,K.closeEmitted=!1,K.destroyed=!1,K.errored=null,K.errorEmitted=!1,K.reading=!1,K.ended=K.readable===!1,K.endEmitted=K.readable===!1;if(F)F.constructed=!0,F.destroyed=!1,F.closed=!1,F.closeEmitted=!1,F.errored=null,F.errorEmitted=!1,F.finalCalled=!1,F.prefinished=!1,F.ended=F.writable===!1,F.ending=F.writable===!1,F.finished=F.writable===!1}function U(K,F,m){const u=K?._readableState,J=K?._writableState;if(J&&J.destroyed||u&&u.destroyed)return this;if(u&&u.autoDestroy||J&&J.autoDestroy)K.destroy(F);else if(F){if(Error.captureStackTrace(F),J&&!J.errored)J.errored=F;if(u&&!u.errored)u.errored=F;if(m)Xq(P,K,F);else P(K,F)}}function I(K,F){if(typeof K._construct!=="function")return;const{_readableState:m,_writableState:u}=K;if(m)m.constructed=!1;if(u)u.constructed=!1;if(K.once(c,F),K.listenerCount(c)>1)return;Xq(_,K)}function _(K){let F=!1;function m(u){if(F){U(K,u!==null&&u!==void 0?u:new G);return}F=!0;const{_readableState:J,_writableState:z}=K,w=z||J;if(J)J.constructed=!0;if(z)z.constructed=!0;if(w.destroyed)K.emit(k,u);else if(u)U(K,u,!0);else Xq(t,K)}try{K._construct(m)}catch(u){m(u)}}function t(K){K.emit(c)}function i(K){return K&&K.setHeader&&typeof K.abort==="function"}function $(K){K.emit("close")}function n(K,F){K.emit("error",F),Xq($,K)}function Y(K,F){if(!K||R(K))return;if(!F&&!T(K))F=new y;if(g(K))K.socket=null,K.destroy(F);else if(i(K))K.abort();else if(i(K.req))K.req.abort();else if(typeof K.destroy==="function")K.destroy(F);else if(typeof K.close==="function")K.close();else if(F)Xq(n,K);else Xq($,K);if(!K.destroyed)K[M]=!0}j.exports={construct:I,destroyer:Y,destroy:l,undestroy:Z,errorOrDestroy:U}}}),Rq=Bq({"node_modules/readable-stream/lib/internal/streams/legacy.js"(a,j){var{ArrayIsArray:B,ObjectSetPrototypeOf:G}=Vq();function y(M){if(!(this instanceof y))return new y(M);Iq.call(this,M)}G(y.prototype,Iq.prototype),G(y,Iq),y.prototype.pipe=function(M,R){const T=this;function g(E){if(M.writable&&M.write(E)===!1&&T.pause)T.pause()}T.on("data",g);function k(){if(T.readable&&T.resume)T.resume()}if(M.on("drain",k),!M._isStdio&&(!R||R.end!==!1))T.on("end",O),T.on("close",l);let c=!1;function O(){if(c)return;c=!0,M.end()}function l(){if(c)return;if(c=!0,typeof M.destroy==="function")M.destroy()}function D(E){if(p(),Iq.listenerCount(this,"error")===0)this.emit("error",E)}A(T,"error",D),A(M,"error",D);function p(){T.removeListener("data",g),M.removeListener("drain",k),T.removeListener("end",O),T.removeListener("close",l),T.removeListener("error",D),M.removeListener("error",D),T.removeListener("end",p),T.removeListener("close",p),M.removeListener("close",p)}return T.on("end",p),T.on("close",p),M.on("close",p),M.emit("pipe",T),M};function A(M,R,T){if(typeof M.prependListener==="function")return M.prependListener(R,T);if(!M._events||!M._events[R])M.on(R,T);else if(B(M._events[R]))M._events[R].unshift(T);else M._events[R]=[T,M._events[R]]}j.exports={Stream:y,prependListener:A}}}),Sq=Bq({"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js"(a,j){var{AbortError:B,codes:G}=Wq(),y=Fq(),{ERR_INVALID_ARG_TYPE:A}=G,M=(T,g)=>{if(typeof T!=="object"||!("aborted"in T))throw new A(g,"AbortSignal",T)};function R(T){return!!(T&&typeof T.pipe==="function")}j.exports.addAbortSignal=function T(g,k){if(M(g,"signal"),!R(k))throw new A("stream","stream.Stream",k);return j.exports.addAbortSignalNoValidate(g,k)},j.exports.addAbortSignalNoValidate=function(T,g){if(typeof T!=="object"||!("aborted"in T))return g;const k=()=>{g.destroy(new B(void 0,{cause:T.reason}))};if(T.aborted)k();else T.addEventListener("abort",k),y(g,()=>T.removeEventListener("abort",k));return g}}}),JQ=Bq({"node_modules/readable-stream/lib/internal/streams/state.js"(a,j){var{MathFloor:B,NumberIsInteger:G}=Vq(),{ERR_INVALID_ARG_VALUE:y}=Wq().codes;function A(T,g,k){return T.highWaterMark!=null?T.highWaterMark:g?T[k]:null}function M(T){return T?16:16384}function R(T,g,k,c){const O=A(g,c,k);if(O!=null){if(!G(O)||O<0){const l=c?`options.${k}`:"options.highWaterMark";throw new y(l,O)}return B(O)}return M(T.objectMode)}j.exports={getHighWaterMark:R,getDefaultHighWaterMark:M}}}),hq=Bq({"node_modules/readable-stream/lib/internal/streams/from.js"(a,j){var{PromisePrototypeThen:B,SymbolAsyncIterator:G,SymbolIterator:y}=Vq(),{ERR_INVALID_ARG_TYPE:A,ERR_STREAM_NULL_VALUES:M}=Wq().codes;function R(T,g,k){let c;if(typeof g==="string"||g instanceof Buffer)return new T({objectMode:!0,...k,read(){this.push(g),this.push(null)}});let O;if(g&&g[G])O=!0,c=g[G]();else if(g&&g[y])O=!1,c=g[y]();else throw new A("iterable",["Iterable"],g);const l=new T({objectMode:!0,highWaterMark:1,...k});let D=!1;l._read=function(){if(!D)D=!0,E()},l._destroy=function(P,Z){B(p(P),()=>Xq(Z,P),(U)=>Xq(Z,U||P))};async function p(P){const Z=P!==void 0&&P!==null,U=typeof c.throw==="function";if(Z&&U){const{value:I,done:_}=await c.throw(P);if(await I,_)return}if(typeof c.return==="function"){const{value:I}=await c.return();await I}}async function E(){for(;;){try{const{value:P,done:Z}=O?await c.next():c.next();if(Z)l.push(null);else{const U=P&&typeof P.then==="function"?await P:P;if(U===null)throw D=!1,new M;else if(l.push(U))continue;else D=!1}}catch(P){l.destroy(P)}break}}return l}j.exports=R}}),pq,uq,_q=Bq({"node_modules/readable-stream/lib/internal/streams/readable.js"(a,j){var{ArrayPrototypeIndexOf:B,NumberIsInteger:G,NumberIsNaN:y,NumberParseInt:A,ObjectDefineProperties:M,ObjectKeys:R,ObjectSetPrototypeOf:T,Promise:g,SafeSet:k,SymbolAsyncIterator:c,Symbol:O}=Vq(),l=globalThis[Symbol.for("Bun.lazy")]("bun:stream").ReadableState,{Stream:D,prependListener:p}=Rq();function E(q){if(!(this instanceof E))return new E(q);const X=this instanceof Mq();if(this._readableState=new l(q,this,X),q){const{read:C,destroy:x,construct:v,signal:Jq}=q;if(typeof C==="function")this._read=C;if(typeof x==="function")this._destroy=x;if(typeof v==="function")this._construct=v;if(Jq&&!X)U(Jq,this)}D.call(this,q),K.construct(this,()=>{if(this._readableState.needReadable)n(this,this._readableState)})}T(E.prototype,D.prototype),T(E,D),E.prototype.on=function(q,X){const C=D.prototype.on.call(this,q,X),x=this._readableState;if(q==="data"){if(x.readableListening=this.listenerCount("readable")>0,x.flowing!==!1)this.resume()}else if(q==="readable"){if(!x.endEmitted&&!x.readableListening){if(x.readableListening=x.needReadable=!0,x.flowing=!1,x.emittedReadable=!1,x.length)Y(this,x);else if(!x.reading)Xq(Qq,this)}else if(x.endEmitted);}return C};class P extends E{#q;#Q;#X;#H;constructor(q,X){const{objectMode:C,highWaterMark:x,encoding:v,signal:Jq}=q;super({objectMode:C,highWaterMark:x,encoding:v,signal:Jq});this.#X=[],this.#q=void 0,this.#H=X,this.#Q=!1}#J(){var q=this.#X,X=0,C=q.length;for(;X0)this.#X=[];return!1}#K(q){q.releaseLock(),this.#q=void 0,this.#Q=!0,this.push(null);return}async _read(){var q=this.#H,X=this.#q;if(q)X=this.#q=q.getReader(),this.#H=void 0;else if(this.#J())return;var C;try{do{var x=!1,v;const Jq=X.readMany();if(xq(Jq)){if({done:x,value:v}=await Jq,this.#Q){this.#X.push(...v);return}}else({done:x,value:v}=Jq);if(x){this.#K(X);return}if(!this.push(v[0])){this.#X=v.slice(1);return}for(let Zq=1,Oq=v.length;Zq{this.#Q=!0,X(q)});return}try{X(q)}catch(x){globalThis.reportError(x)}}}uq=P;function Z(q,X={}){if(!tq(q))throw new m("readableStream","ReadableStream",q);S(X,"options");const{highWaterMark:C,encoding:x,objectMode:v=!1,signal:Jq}=X;if(x!==void 0&&!Buffer.isEncoding(x))throw new QQ(x,"options.encoding");return eq(v,"options.objectMode"),zQ(E,q,X)||new P({highWaterMark:C,encoding:x,objectMode:v,signal:Jq},q)}j.exports=E,pq=Z;var{addAbortSignal:U}=Sq(),I=Fq();const{maybeReadMore:_,resume:t,emitReadable:i,onEofChunk:$}=globalThis[Symbol.for("Bun.lazy")]("bun:stream");function n(q,X){process.nextTick(_,q,X)}function Y(q,X){i(q,X)}var K=Tq(),{aggregateTwoErrors:F,codes:{ERR_INVALID_ARG_TYPE:m,ERR_METHOD_NOT_IMPLEMENTED:u,ERR_OUT_OF_RANGE:J,ERR_STREAM_PUSH_AFTER_EOF:z,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:w}}=Wq(),{validateObject:S}=Cq(),N=hq(),W=()=>{},{errorOrDestroy:b}=K;E.prototype.destroy=K.destroy,E.prototype._undestroy=K.undestroy,E.prototype._destroy=function(q,X){X(q)},E.prototype[Iq.captureRejectionSymbol]=function(q){this.destroy(q)},E.prototype.push=function(q,X){return o(this,q,X,!1)},E.prototype.unshift=function(q,X){return o(this,q,X,!0)};function o(q,X,C,x){const v=q._readableState;let Jq;if(!v.objectMode){if(typeof X==="string"){if(C=C||v.defaultEncoding,v.encoding!==C)if(x&&v.encoding)X=Buffer.from(X,C).toString(v.encoding);else X=Buffer.from(X,C),C=""}else if(X instanceof Buffer)C="";else if(D._isUint8Array(X)){if(x||!v.decoder)X=D._uint8ArrayToBuffer(X);C=""}else if(X!=null)Jq=new m("chunk",["string","Buffer","Uint8Array"],X)}if(Jq)b(q,Jq);else if(X===null)v.reading=!1,$(q,v);else if(v.objectMode||X&&X.length>0)if(x)if(v.endEmitted)b(q,new w);else if(v.destroyed||v.errored)return!1;else s(q,v,X,!0);else if(v.ended)b(q,new z);else if(v.destroyed||v.errored)return!1;else if(v.reading=!1,v.decoder&&!C)if(X=v.decoder.write(X),v.objectMode||X.length!==0)s(q,v,X,!1);else n(q,v);else s(q,v,X,!1);else if(!x)v.reading=!1,n(q,v);return!v.ended&&(v.length0){if(X.multiAwaitDrain)X.awaitDrainWriters.clear();else X.awaitDrainWriters=null;X.dataEmitted=!0,q.emit("data",C)}else{if(X.length+=X.objectMode?1:C.length,x)X.buffer.unshift(C);else X.buffer.push(C);if(X.needReadable)Y(q,X)}n(q,X)}E.prototype.isPaused=function(){const q=this._readableState;return q.paused===!0||q.flowing===!1},E.prototype.setEncoding=function(q){const X=new aq(q);this._readableState.decoder=X,this._readableState.encoding=this._readableState.decoder.encoding;const C=this._readableState.buffer;let x="";for(let v=C.length;v>0;v--)x+=X.write(C.shift());if(x!=="")C.push(x);return this._readableState.length=x.length,this};var e=1073741824;function Hq(q){if(q>e)throw new J("size","<= 1GiB",q);else q--,q|=q>>>1,q|=q>>>2,q|=q>>>4,q|=q>>>8,q|=q>>>16,q++;return q}function $q(q,X){if(q<=0||X.length===0&&X.ended)return 0;if(X.objectMode)return 1;if(y(q)){if(X.flowing&&X.length)return X.buffer.first().length;return X.length}if(q<=X.length)return q;return X.ended?X.length:0}E.prototype.read=function(q){if(!G(q))q=A(q,10);const X=this._readableState,C=q;if(q>X.highWaterMark)X.highWaterMark=Hq(q);if(q!==0)X.emittedReadable=!1;if(q===0&&X.needReadable&&((X.highWaterMark!==0?X.length>=X.highWaterMark:X.length>0)||X.ended)){if(X.length===0&&X.ended)H(this);else Y(this,X);return null}if(q=$q(q,X),q===0&&X.ended){if(X.length===0)H(this);return null}let x=X.needReadable;if(X.length===0||X.length-q0)Jq=Q(q,X);else Jq=null;if(Jq===null)X.needReadable=X.length<=X.highWaterMark,q=0;else if(X.length-=q,X.multiAwaitDrain)X.awaitDrainWriters.clear();else X.awaitDrainWriters=null;if(X.length===0){if(!X.ended)X.needReadable=!0;if(C!==q&&X.ended)H(this)}if(Jq!==null&&!X.errorEmitted&&!X.closeEmitted)X.dataEmitted=!0,this.emit("data",Jq);return Jq},E.prototype._read=function(q){throw new u("_read()")},E.prototype.pipe=function(q,X){const C=this,x=this._readableState;if(x.pipes.length===1){if(!x.multiAwaitDrain)x.multiAwaitDrain=!0,x.awaitDrainWriters=new k(x.awaitDrainWriters?[x.awaitDrainWriters]:[])}x.pipes.push(q);const Jq=(!X||X.end!==!1)&&q!==process.stdout&&q!==process.stderr?Oq:Pq;if(x.endEmitted)Xq(Jq);else C.once("end",Jq);q.on("unpipe",Zq);function Zq(jq,Nq){if(jq===C){if(Nq&&Nq.hasUnpiped===!1)Nq.hasUnpiped=!0,nq()}}function Oq(){q.end()}let Lq,kq=!1;function nq(){if(q.removeListener("close",wq),q.removeListener("finish",vq),Lq)q.removeListener("drain",Lq);if(q.removeListener("error",Dq),q.removeListener("unpipe",Zq),C.removeListener("end",Oq),C.removeListener("end",Pq),C.removeListener("data",yq),kq=!0,Lq&&x.awaitDrainWriters&&(!q._writableState||q._writableState.needDrain))Lq()}function fq(){if(!kq){if(x.pipes.length===1&&x.pipes[0]===q)x.awaitDrainWriters=q,x.multiAwaitDrain=!1;else if(x.pipes.length>1&&x.pipes.includes(q))x.awaitDrainWriters.add(q);C.pause()}if(!Lq)Lq=qq(C,q),q.on("drain",Lq)}C.on("data",yq);function yq(jq){if(q.write(jq)===!1)fq()}function Dq(jq){if(Gq("onerror",jq),Pq(),q.removeListener("error",Dq),q.listenerCount("error")===0){const Nq=q._writableState||q._readableState;if(Nq&&!Nq.errorEmitted)b(q,jq);else q.emit("error",jq)}}p(q,"error",Dq);function wq(){q.removeListener("finish",vq),Pq()}q.once("close",wq);function vq(){Gq("onfinish"),q.removeListener("close",wq),Pq()}q.once("finish",vq);function Pq(){Gq("unpipe"),C.unpipe(q)}if(q.emit("pipe",C),q.writableNeedDrain===!0){if(x.flowing)fq()}else if(!x.flowing)Gq("pipe resume"),C.resume();return q};function qq(q,X){return function C(){const x=q._readableState;if(x.awaitDrainWriters===X)Gq("pipeOnDrain",1),x.awaitDrainWriters=null;else if(x.multiAwaitDrain)Gq("pipeOnDrain",x.awaitDrainWriters.size),x.awaitDrainWriters.delete(X);if((!x.awaitDrainWriters||x.awaitDrainWriters.size===0)&&q.listenerCount("data"))q.resume()}}E.prototype.unpipe=function(q){const X=this._readableState,C={hasUnpiped:!1};if(X.pipes.length===0)return this;if(!q){const v=X.pipes;X.pipes=[],this.pause();for(let Jq=0;Jq0,X.resumeScheduled&&X.paused===!1)X.flowing=!0;else if(q.listenerCount("data")>0)q.resume();else if(!X.readableListening)X.flowing=null}function Qq(q){q.read(0)}E.prototype.resume=function(){const q=this._readableState;if(!q.flowing)q.flowing=!q.readableListening,t(this,q);return q.paused=!1,this},E.prototype.pause=function(){if(this._readableState.flowing!==!1)this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this},E.prototype.wrap=function(q){let X=!1;q.on("data",(x)=>{if(!this.push(x)&&q.pause)X=!0,q.pause()}),q.on("end",()=>{this.push(null)}),q.on("error",(x)=>{b(this,x)}),q.on("close",()=>{this.destroy()}),q.on("destroy",()=>{this.destroy()}),this._read=()=>{if(X&&q.resume)X=!1,q.resume()};const C=R(q);for(let x=1;x{v=Zq?F(v,Zq):null,C(),C=W});try{while(!0){const Zq=q.destroyed?null:q.read();if(Zq!==null)yield Zq;else if(v)throw v;else if(v===null)return;else await new g(x)}}catch(Zq){throw v=F(v,Zq),v}finally{if((v||(X===null||X===void 0?void 0:X.destroyOnReturn)!==!1)&&(v===void 0||q._readableState.autoDestroy))K.destroyer(q,null);else q.off("readable",x),Jq()}}M(E.prototype,{readable:{get(){const q=this._readableState;return!!q&&q.readable!==!1&&!q.destroyed&&!q.errorEmitted&&!q.endEmitted},set(q){if(this._readableState)this._readableState.readable=!!q}},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(q){if(this._readableState)this._readableState.flowing=q}},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(q){if(!this._readableState)return;this._readableState.destroyed=q}},readableEnded:{enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),E._fromList=Q;function Q(q,X){if(X.length===0)return null;let C;if(X.objectMode)C=X.buffer.shift();else if(!q||q>=X.length){if(X.decoder)C=X.buffer.join("");else if(X.buffer.length===1)C=X.buffer.first();else C=X.buffer.concat(X.length);X.buffer.clear()}else C=X.buffer.consume(q,X.decoder);return C}function H(q){const X=q._readableState;if(!X.endEmitted)X.ended=!0,Xq(L,X,q)}function L(q,X){if(!q.errored&&!q.closeEmitted&&!q.endEmitted&&q.length===0){if(q.endEmitted=!0,X.emit("end"),X.writable&&X.allowHalfOpen===!1)Xq(d,X);else if(q.autoDestroy){const C=X._writableState;if(!C||C.autoDestroy&&(C.finished||C.writable===!1))X.destroy()}}}function d(q){if(q.writable&&!q.writableEnded&&!q.destroyed)q.end()}E.from=function(q,X){return N(E,q,X)};var f={newStreamReadableFromReadableStream:Z};function r(){if(f===void 0)f={};return f}E.fromWeb=function(q,X){return r().newStreamReadableFromReadableStream(q,X)},E.toWeb=function(q){return r().newReadableStreamFromStreamReadable(q)},E.wrap=function(q,X){var C,x;return new E({objectMode:(C=(x=q.readableObjectMode)!==null&&x!==void 0?x:q.objectMode)!==null&&C!==void 0?C:!0,...X,destroy(v,Jq){K.destroyer(q,v),Jq(v)}}).wrap(q)}}}),bq=Bq({"node_modules/readable-stream/lib/internal/streams/writable.js"(a,j){var{ArrayPrototypeSlice:B,Error:G,FunctionPrototypeSymbolHasInstance:y,ObjectDefineProperty:A,ObjectDefineProperties:M,ObjectSetPrototypeOf:R,StringPrototypeToLowerCase:T,Symbol:g,SymbolHasInstance:k}=Vq(),c=Rq().Stream,O=Tq(),{addAbortSignal:l}=Sq(),{getHighWaterMark:D,getDefaultHighWaterMark:p}=JQ(),{ERR_INVALID_ARG_TYPE:E,ERR_METHOD_NOT_IMPLEMENTED:P,ERR_MULTIPLE_CALLBACK:Z,ERR_STREAM_CANNOT_PIPE:U,ERR_STREAM_DESTROYED:I,ERR_STREAM_ALREADY_FINISHED:_,ERR_STREAM_NULL_VALUES:t,ERR_STREAM_WRITE_AFTER_END:i,ERR_UNKNOWN_ENCODING:$}=Wq().codes,{errorOrDestroy:n}=O;function Y(Q={}){const H=this instanceof Mq();if(!H&&!y(Y,this))return new Y(Q);if(this._writableState=new m(Q,this,H),Q){if(typeof Q.write==="function")this._write=Q.write;if(typeof Q.writev==="function")this._writev=Q.writev;if(typeof Q.destroy==="function")this._destroy=Q.destroy;if(typeof Q.final==="function")this._final=Q.final;if(typeof Q.construct==="function")this._construct=Q.construct;if(Q.signal)l(Q.signal,this)}c.call(this,Q),O.construct(this,()=>{const L=this._writableState;if(!L.writing)s(this,L);qq(this,L)})}R(Y.prototype,c.prototype),R(Y,c),j.exports=Y;function K(){}var F=g("kOnFinished");function m(Q,H,L){if(typeof L!=="boolean")L=H instanceof Mq();if(this.objectMode=!!(Q&&Q.objectMode),L)this.objectMode=this.objectMode||!!(Q&&Q.writableObjectMode);this.highWaterMark=Q?D(this,Q,"writableHighWaterMark",L):p(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const d=!!(Q&&Q.decodeStrings===!1);this.decodeStrings=!d,this.defaultEncoding=Q&&Q.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=N.bind(void 0,H),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,u(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!Q||Q.emitClose!==!1,this.autoDestroy=!Q||Q.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[F]=[]}function u(Q){Q.buffered=[],Q.bufferedIndex=0,Q.allBuffers=!0,Q.allNoop=!0}m.prototype.getBuffer=function Q(){return B(this.buffered,this.bufferedIndex)},A(m.prototype,"bufferedRequestCount",{get(){return this.buffered.length-this.bufferedIndex}}),A(Y,k,{value:function(Q){if(y(this,Q))return!0;if(this!==Y)return!1;return Q&&Q._writableState instanceof m}}),Y.prototype.pipe=function(){n(this,new U)};function J(Q,H,L,d){const f=Q._writableState;if(typeof L==="function")d=L,L=f.defaultEncoding;else{if(!L)L=f.defaultEncoding;else if(L!=="buffer"&&!Buffer.isEncoding(L))throw new $(L);if(typeof d!=="function")d=K}if(H===null)throw new t;else if(!f.objectMode)if(typeof H==="string"){if(f.decodeStrings!==!1)H=Buffer.from(H,L),L="buffer"}else if(H instanceof Buffer)L="buffer";else if(c._isUint8Array(H))H=c._uint8ArrayToBuffer(H),L="buffer";else throw new E("chunk",["string","Buffer","Uint8Array"],H);let r;if(f.ending)r=new i;else if(f.destroyed)r=new I("write");if(r)return Xq(d,r),n(Q,r,!0),r;return f.pendingcb++,z(Q,f,H,L,d)}Y.prototype.write=function(Q,H,L){return J(this,Q,H,L)===!0},Y.prototype.cork=function(){this._writableState.corked++},Y.prototype.uncork=function(){const Q=this._writableState;if(Q.corked){if(Q.corked--,!Q.writing)s(this,Q)}},Y.prototype.setDefaultEncoding=function Q(H){if(typeof H==="string")H=T(H);if(!Buffer.isEncoding(H))throw new $(H);return this._writableState.defaultEncoding=H,this};function z(Q,H,L,d,f){const r=H.objectMode?1:L.length;H.length+=r;const q=H.lengthL.bufferedIndex)s(Q,L);if(d)if(L.afterWriteTickInfo!==null&&L.afterWriteTickInfo.cb===f)L.afterWriteTickInfo.count++;else L.afterWriteTickInfo={count:1,cb:f,stream:Q,state:L},Xq(W,L.afterWriteTickInfo);else b(Q,L,1,f)}}function W({stream:Q,state:H,count:L,cb:d}){return H.afterWriteTickInfo=null,b(Q,H,L,d)}function b(Q,H,L,d){if(!H.ending&&!Q.destroyed&&H.length===0&&H.needDrain)H.needDrain=!1,Q.emit("drain");while(L-- >0)H.pendingcb--,d();if(H.destroyed)o(H);qq(Q,H)}function o(Q){if(Q.writing)return;for(let f=Q.bufferedIndex;f1&&Q._writev){H.pendingcb-=r-1;const X=H.allNoop?K:(x)=>{for(let v=q;v256)L.splice(0,q),H.bufferedIndex=0;else H.bufferedIndex=q}H.bufferProcessing=!1}Y.prototype._write=function(Q,H,L){if(this._writev)this._writev([{chunk:Q,encoding:H}],L);else throw new P("_write()")},Y.prototype._writev=null,Y.prototype.end=function(Q,H,L,d=!1){const f=this._writableState;if(typeof Q==="function")L=Q,Q=null,H=null;else if(typeof H==="function")L=H,H=null;let r;if(Q!==null&&Q!==void 0){let q;if(!d)q=J(this,Q,H);else q=this.write(Q,H);if(q instanceof G)r=q}if(f.corked)f.corked=1,this.uncork();if(r)this.emit("error",r);else if(!f.errored&&!f.ending)f.ending=!0,qq(this,f,!0),f.ended=!0;else if(f.finished)r=new _("end");else if(f.destroyed)r=new I("end");if(typeof L==="function")if(r||f.finished)Xq(L,r);else f[F].push(L);return this};function e(Q,H){var L=Q.ending&&!Q.destroyed&&Q.constructed&&Q.length===0&&!Q.errored&&Q.buffered.length===0&&!Q.finished&&!Q.writing&&!Q.errorEmitted&&!Q.closeEmitted;return Gq("needFinish",L,H),L}function Hq(Q,H){let L=!1;function d(f){if(L){n(Q,f!==null&&f!==void 0?f:Z());return}if(L=!0,H.pendingcb--,f){const r=H[F].splice(0);for(let q=0;q{if(e(f))Kq(d,f);else f.pendingcb--},Q,H);else if(e(H))H.pendingcb++,Kq(Q,H)}}function Kq(Q,H){H.pendingcb--,H.finished=!0;const L=H[F].splice(0);for(let d=0;d{if(S!=null)throw new O("nully","body",S)},(S)=>{l(z,S)});return z=new I({objectMode:!0,readable:!1,write:F,final(S){m(async()=>{try{await w,Xq(S,null)}catch(N){Xq(S,N)}})},destroy:u})}throw new O("Iterable, AsyncIterable or AsyncFunction",n,K)}if(Z($))return i($.arrayBuffer());if(y($))return P(I,$,{objectMode:!0,writable:!1});if(typeof($===null||$===void 0?void 0:$.writable)==="object"||typeof($===null||$===void 0?void 0:$.readable)==="object"){const K=$!==null&&$!==void 0&&$.readable?M($===null||$===void 0?void 0:$.readable)?$===null||$===void 0?void 0:$.readable:i($.readable):void 0,F=$!==null&&$!==void 0&&$.writable?R($===null||$===void 0?void 0:$.writable)?$===null||$===void 0?void 0:$.writable:i($.writable):void 0;return t({readable:K,writable:F})}const Y=$===null||$===void 0?void 0:$.then;if(typeof Y==="function"){let K;return U(Y,$,(F)=>{if(F!=null)K.push(F);K.push(null)},(F)=>{l(K,F)}),K=new I({objectMode:!0,writable:!1,read(){}})}throw new c(n,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],$)};function _(i){let{promise:$,resolve:n}=E();const Y=new AbortController,K=Y.signal;return{value:i(async function*(){while(!0){const m=$;$=null;const{chunk:u,done:J,cb:z}=await m;if(Xq(z),J)return;if(K.aborted)throw new k(void 0,{cause:K.reason});({promise:$,resolve:n}=E()),yield u}}(),{signal:K}),write(m,u,J){const z=n;n=null,z({chunk:m,done:!1,cb:J})},final(m){const u=n;n=null,u({done:!0,cb:m})},destroy(m,u){Y.abort(),u(m)}}}function t(i){const $=i.readable&&typeof i.readable.read!=="function"?p.wrap(i.readable):i.readable,n=i.writable;let Y=!!B($),K=!!G(n),F,m,u,J,z;function w(S){const N=J;if(J=null,N)N(S);else if(S)z.destroy(S);else if(!Y&&!K)z.destroy()}if(z=new I({readableObjectMode:!!($!==null&&$!==void 0&&$.readableObjectMode),writableObjectMode:!!(n!==null&&n!==void 0&&n.writableObjectMode),readable:Y,writable:K}),K)g(n,(S)=>{if(K=!1,S)l($,S);w(S)}),z._write=function(S,N,W){if(n.write(S,N))W();else F=W},z._final=function(S){n.end(),m=S},n.on("drain",function(){if(F){const S=F;F=null,S()}}),n.on("finish",function(){if(m){const S=m;m=null,S()}});if(Y)g($,(S)=>{if(Y=!1,S)l($,S);w(S)}),$.on("readable",function(){if(u){const S=u;u=null,S()}}),$.on("end",function(){z.push(null)}),z._read=function(){while(!0){const S=$.read();if(S===null){u=z._read;return}if(!z.push(S))return}};return z._destroy=function(S,N){if(!S&&J!==null)S=new k;if(u=null,F=null,m=null,J===null)N(S);else J=N,l(n,S),l($,S)},z}}}),Mq=Bq({"node_modules/readable-stream/lib/internal/streams/duplex.js"(a,j){var{ObjectDefineProperties:B,ObjectGetOwnPropertyDescriptor:G,ObjectKeys:y,ObjectSetPrototypeOf:A}=Vq(),M=_q();function R(O){if(!(this instanceof R))return new R(O);if(M.call(this,O),Uq.call(this,O),O){if(this.allowHalfOpen=O.allowHalfOpen!==!1,O.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(O.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}j.exports=R,A(R.prototype,M.prototype),A(R,M);for(var T in Uq.prototype)if(!R.prototype[T])R.prototype[T]=Uq.prototype[T];B(R.prototype,{writable:G(Uq.prototype,"writable"),writableHighWaterMark:G(Uq.prototype,"writableHighWaterMark"),writableObjectMode:G(Uq.prototype,"writableObjectMode"),writableBuffer:G(Uq.prototype,"writableBuffer"),writableLength:G(Uq.prototype,"writableLength"),writableFinished:G(Uq.prototype,"writableFinished"),writableCorked:G(Uq.prototype,"writableCorked"),writableEnded:G(Uq.prototype,"writableEnded"),writableNeedDrain:G(Uq.prototype,"writableNeedDrain"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(O){if(this._readableState&&this._writableState)this._readableState.destroyed=O,this._writableState.destroyed=O}}});var g;function k(){if(g===void 0)g={};return g}R.fromWeb=function(O,l){return k().newStreamDuplexFromReadableWritablePair(O,l)},R.toWeb=function(O){return k().newReadableWritablePairFromDuplex(O)};var c;R.from=function(O){if(!c)c=HQ();return c(O,"body")}}}),mq=Bq({"node_modules/readable-stream/lib/internal/streams/transform.js"(a,j){var{ObjectSetPrototypeOf:B,Symbol:G}=Vq(),{ERR_METHOD_NOT_IMPLEMENTED:y}=Wq().codes,A=Mq();function M(k){if(!(this instanceof M))return new M(k);if(A.call(this,k),this._readableState.sync=!1,this[R]=null,k){if(typeof k.transform==="function")this._transform=k.transform;if(typeof k.flush==="function")this._flush=k.flush}this.on("prefinish",g.bind(this))}B(M.prototype,A.prototype),B(M,A),j.exports=M;var R=G("kCallback");function T(k){if(typeof this._flush==="function"&&!this.destroyed)this._flush((c,O)=>{if(c){if(k)k(c);else this.destroy(c);return}if(O!=null)this.push(O);if(this.push(null),k)k()});else if(this.push(null),k)k()}function g(){if(this._final!==T)T.call(this)}M.prototype._final=T,M.prototype._transform=function(k,c,O){throw new y("_transform()")},M.prototype._write=function(k,c,O){const l=this._readableState,D=this._writableState,p=l.length;this._transform(k,c,(E,P)=>{if(E){O(E);return}if(P!=null)this.push(P);if(D.ended||p===l.length||l.length{S=!0});const N=A(J,{readable:z,writable:w},(W)=>{S=!W});return{destroy:(W)=>{if(S)return;S=!0,R.destroyer(J,W||new l("pipe"))},cleanup:N}}function $(J){return p(J[J.length-1],"streams[stream.length - 1]"),J.pop()}function n(J){if(P(J))return J;else if(U(J))return Y(J);throw new k("val",["Readable","Iterable","AsyncIterable"],J)}async function*Y(J){if(!t)t=_q();yield*t.prototype[y].call(J)}async function K(J,z,w,{end:S}){let N,W=null;const b=(e)=>{if(e)N=e;if(W){const Hq=W;W=null,Hq()}},o=()=>new G((e,Hq)=>{if(N)Hq(N);else W=()=>{if(N)Hq(N);else e()}});z.on("drain",b);const s=A(z,{readable:!1},b);try{if(z.writableNeedDrain)await o();for await(let e of J)if(!z.write(e))await o();if(S)z.end();await o(),w()}catch(e){w(N!==e?g(N,e):e)}finally{s(),z.off("drain",b)}}function F(...J){return m(J,M($(J)))}function m(J,z,w){if(J.length===1&&B(J[0]))J=J[0];if(J.length<2)throw new O("streams");const S=new AbortController,N=S.signal,W=w===null||w===void 0?void 0:w.signal,b=[];E(W,"options.signal");function o(){Kq(new D)}W===null||W===void 0||W.addEventListener("abort",o);let s,e;const Hq=[];let $q=0;function qq(h){Kq(h,--$q===0)}function Kq(h,Q){if(h&&(!s||s.code==="ERR_STREAM_PREMATURE_CLOSE"))s=h;if(!s&&!Q)return;while(Hq.length)Hq.shift()(s);if(W===null||W===void 0||W.removeEventListener("abort",o),S.abort(),Q){if(!s)b.forEach((H)=>H());Xq(z,s,e)}}let Qq;for(let h=0;h0,d=H||(w===null||w===void 0?void 0:w.end)!==!1,f=h===J.length-1;if(I(Q)){let r=function(q){if(q&&q.name!=="AbortError"&&q.code!=="ERR_STREAM_PREMATURE_CLOSE")qq(q)};if(d){const{destroy:q,cleanup:X}=i(Q,H,L);if(Hq.push(q),Z(Q)&&f)b.push(X)}if(Q.on("error",r),Z(Q)&&f)b.push(()=>{Q.removeListener("error",r)})}if(h===0)if(typeof Q==="function"){if(Qq=Q({signal:N}),!P(Qq))throw new c("Iterable, AsyncIterable or Stream","source",Qq)}else if(P(Q)||U(Q))Qq=Q;else Qq=T.from(Q);else if(typeof Q==="function")if(Qq=n(Qq),Qq=Q(Qq,{signal:N}),H){if(!P(Qq,!0))throw new c("AsyncIterable",`transform[${h-1}]`,Qq)}else{var V;if(!_)_=cq();const r=new _({objectMode:!0}),q=(V=Qq)===null||V===void 0?void 0:V.then;if(typeof q==="function")$q++,q.call(Qq,(x)=>{if(e=x,x!=null)r.write(x);if(d)r.end();Xq(qq)},(x)=>{r.destroy(x),Xq(qq,x)});else if(P(Qq,!0))$q++,K(Qq,r,qq,{end:d});else throw new c("AsyncIterable or Promise","destination",Qq);Qq=r;const{destroy:X,cleanup:C}=i(Qq,!1,!0);if(Hq.push(X),f)b.push(C)}else if(I(Q)){if(U(Qq)){$q+=2;const r=u(Qq,Q,qq,{end:d});if(Z(Q)&&f)b.push(r)}else if(P(Qq))$q++,K(Qq,Q,qq,{end:d});else throw new k("val",["Readable","Iterable","AsyncIterable"],Qq);Qq=Q}else Qq=T.from(Q)}if(N!==null&&N!==void 0&&N.aborted||W!==null&&W!==void 0&&W.aborted)Xq(o);return Qq}function u(J,z,w,{end:S}){if(J.pipe(z,{end:S}),S)J.once("end",()=>z.end());else w();return A(J,{readable:!0,writable:!1},(N)=>{const W=J._readableState;if(N&&N.code==="ERR_STREAM_PREMATURE_CLOSE"&&W&&W.ended&&!W.errored&&!W.errorEmitted)J.once("end",w).once("error",w);else w(N)}),A(z,{readable:!1,writable:!0},w)}j.exports={pipelineImpl:m,pipeline:F}}}),KQ=Bq({"node_modules/readable-stream/lib/internal/streams/compose.js"(a,j){var{pipeline:B}=gq(),G=Mq(),{destroyer:y}=Tq(),{isNodeStream:A,isReadable:M,isWritable:R}=Eq(),{AbortError:T,codes:{ERR_INVALID_ARG_VALUE:g,ERR_MISSING_ARGS:k}}=Wq();j.exports=function c(...O){if(O.length===0)throw new k("streams");if(O.length===1)return G.from(O[0]);const l=[...O];if(typeof O[0]==="function")O[0]=G.from(O[0]);if(typeof O[O.length-1]==="function"){const $=O.length-1;O[$]=G.from(O[$])}for(let $=0;$0&&!R(O[$]))throw new g(`streams[${$}]`,l[$],"must be writable")}let D,p,E,P,Z;function U($){const n=P;if(P=null,n)n($);else if($)Z.destroy($);else if(!i&&!t)Z.destroy()}const I=O[0],_=B(O,U),t=!!R(I),i=!!M(_);if(Z=new G({writableObjectMode:!!(I!==null&&I!==void 0&&I.writableObjectMode),readableObjectMode:!!(_!==null&&_!==void 0&&_.writableObjectMode),writable:t,readable:i}),t)Z._write=function($,n,Y){if(I.write($,n))Y();else D=Y},Z._final=function($){I.end(),p=$},I.on("drain",function(){if(D){const $=D;D=null,$()}}),_.on("finish",function(){if(p){const $=p;p=null,$()}});if(i)_.on("readable",function(){if(E){const $=E;E=null,$()}}),_.on("end",function(){Z.push(null)}),Z._read=function(){while(!0){const $=_.read();if($===null){E=Z._read;return}if(!Z.push($))return}};return Z._destroy=function($,n){if(!$&&P!==null)$=new T;if(E=null,D=null,p=null,P===null)n($);else P=n,y(_,$)},Z}}}),dq=Bq({"node_modules/readable-stream/lib/stream/promises.js"(a,j){var{ArrayPrototypePop:B,Promise:G}=Vq(),{isIterable:y,isNodeStream:A}=Eq(),{pipelineImpl:M}=gq(),{finished:R}=Fq();function T(...g){return new G((k,c)=>{let O,l;const D=g[g.length-1];if(D&&typeof D==="object"&&!A(D)&&!y(D)){const p=B(g);O=p.signal,l=p.end}M(g,(p,E)=>{if(p)c(p);else k(E)},{signal:O,end:l})})}j.exports={finished:R,pipeline:T}}}),ZQ=Bq({"node_modules/readable-stream/lib/stream.js"(a,j){var{ObjectDefineProperty:B,ObjectKeys:G,ReflectApply:y}=Vq(),{promisify:{custom:A}}=Aq(),{streamReturningOperators:M,promiseReturningOperators:R}=XQ(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:T}}=Wq(),g=KQ(),{pipeline:k}=gq(),{destroyer:c}=Tq(),O=Fq(),l=dq(),D=Eq(),p=j.exports=Rq().Stream;p.isDisturbed=D.isDisturbed,p.isErrored=D.isErrored,p.isWritable=D.isWritable,p.isReadable=D.isReadable,p.Readable=_q();for(let P of G(M)){let Z=function(...I){if(new.target)throw T();return p.Readable.from(y(U,this,I))};const U=M[P];B(Z,"name",{value:U.name}),B(Z,"length",{value:U.length}),B(p.Readable.prototype,P,{value:Z,enumerable:!1,configurable:!0,writable:!0})}for(let P of G(R)){let Z=function(...I){if(new.target)throw T();return y(U,this,I)};const U=R[P];B(Z,"name",{value:U.name}),B(Z,"length",{value:U.length}),B(p.Readable.prototype,P,{value:Z,enumerable:!1,configurable:!0,writable:!0})}p.Writable=bq(),p.Duplex=Mq(),p.Transform=mq(),p.PassThrough=cq(),p.pipeline=k;var{addAbortSignal:E}=Sq();p.addAbortSignal=E,p.finished=O,p.destroy=c,p.compose=g,B(p,"promises",{configurable:!0,enumerable:!0,get(){return l}}),B(k,A,{enumerable:!0,get(){return l.pipeline}}),B(O,A,{enumerable:!0,get(){return l.finished}}),p.Stream=p,p._isUint8Array=function P(Z){return Z instanceof Uint8Array},p._uint8ArrayToBuffer=function P(Z){return new Buffer(Z.buffer,Z.byteOffset,Z.byteLength)}}}),BQ=Bq({"node_modules/readable-stream/lib/ours/index.js"(a,j){const B=ZQ(),G=dq(),y=B.Readable.destroy;j.exports=B,j.exports._uint8ArrayToBuffer=B._uint8ArrayToBuffer,j.exports._isUint8Array=B._isUint8Array,j.exports.isDisturbed=B.isDisturbed,j.exports.isErrored=B.isErrored,j.exports.isWritable=B.isWritable,j.exports.isReadable=B.isReadable,j.exports.Readable=B.Readable,j.exports.Writable=B.Writable,j.exports.Duplex=B.Duplex,j.exports.Transform=B.Transform,j.exports.PassThrough=B.PassThrough,j.exports.addAbortSignal=B.addAbortSignal,j.exports.finished=B.finished,j.exports.destroy=B.destroy,j.exports.destroy=y,j.exports.pipeline=B.pipeline,j.exports.compose=B.compose,j.exports._getNativeReadableStreamPrototype=lq,j.exports.NativeWritable=iq,zq.defineProperty(B,"promises",{configurable:!0,enumerable:!0,get(){return G}}),j.exports.Stream=B.Stream,j.exports.default=j.exports}}),$Q={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0},Uq=bq(),iq=class a extends Uq{#q;#Q;#X=!0;_construct;_destroy;_final;constructor(j,B={}){super(B);this._construct=this.#H,this._destroy=this.#K,this._final=this.#Z,this.#q=j}#H(j){this._writableState.constructed=!0,this.constructed=!0,j()}#J(){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(j,B,G,y=this.#X){if(!y)return this.#X=!1,super.write(j,B,G);if(!this.#Q)this.#J();var A=this.#Q,M=A.write(j);if(xq(M))return M.then(()=>{this.emit("drain"),A.flush(!0)}),!1;if(A.flush(!0),G)G(null,j.byteLength);return!0}end(j,B,G,y=this.#X){return super.end(j,B,G,y)}#K(j,B){if(this._writableState.destroyed=!0,B)B(j)}#Z(j){if(this.#Q)this.#Q.end();if(j)j()}ref(){if(!this.#Q)this.#J();this.#Q.ref()}unref(){if(!this.#Q)return;this.#Q.unref()}},Yq=BQ();Yq[Symbol.for("CommonJS")]=0;Yq[Symbol.for("::bunternal::")]={_ReadableFromWeb:pq,_ReadableFromWebForUndici:uq};var cQ=Yq,EQ=Yq._uint8ArrayToBuffer,IQ=Yq._isUint8Array,TQ=Yq.isDisturbed,PQ=Yq.isErrored,xQ=Yq.isWritable,OQ=Yq.isReadable,CQ=Yq.Readable,Uq=Yq.Writable,_Q=Yq.Duplex,DQ=Yq.Transform,wQ=Yq.PassThrough,vQ=Yq.addAbortSignal,RQ=Yq.finished,SQ=Yq.destroy,gQ=Yq.pipeline,kQ=Yq.compose,VQ=Yq.Stream,fQ=Yq.eos=Fq,yQ=Yq._getNativeReadableStreamPrototype,iq=Yq.NativeWritable,hQ=VQ.promises;export{hQ as promises,gQ as pipeline,xQ as isWritable,OQ as isReadable,PQ as isErrored,TQ as isDisturbed,RQ as finished,fQ as eos,SQ as destroy,cQ as default,kQ as compose,vQ as addAbortSignal,EQ as _uint8ArrayToBuffer,IQ as _isUint8Array,yQ as _getNativeReadableStreamPrototype,Uq as Writable,DQ as Transform,VQ as Stream,CQ as Readable,wQ as PassThrough,iq as NativeWritable,_Q as Duplex}; diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index 3b1688c15..0236010be 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -1448,3 +1448,26 @@ describe("utimesSync", () => { expect(finalStats.atime).toEqual(prevAccessTime); }); }); + +it("createReadStream on a large file emits readable event correctly", () => { + return new Promise((resolve, reject) => { + const tmp = mkdtempSync(`${tmpdir()}/readable`); + // write a 10mb file + writeFileSync(`${tmp}/large.txt`, "a".repeat(10 * 1024 * 1024)); + var stream = createReadStream(`${tmp}/large.txt`); + var ended = false; + var timer: Timer; + stream.on("readable", () => { + const v = stream.read(); + if (ended) { + clearTimeout(timer); + reject(new Error("readable emitted after end")); + } else if (v == null) { + ended = true; + timer = setTimeout(() => { + resolve(); + }, 20); + } + }); + }); +}); -- cgit v1.2.3 From 17031936c852c2973eacf0929e762972a76ec7bf Mon Sep 17 00:00:00 2001 From: Hanaasagi Date: Tue, 11 Jul 2023 20:10:25 +0900 Subject: small fix, check if the method has been reassigned. --- src/js/node/http.ts | 7 +++++-- src/js/out/modules/node/http.js | 8 ++++++-- test/js/node/http/node-http.test.ts | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 253bcf4d8..3a283912e 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -972,6 +972,7 @@ export class ServerResponse extends Writable { this.#firstWrite = undefined; this._writableState.decodeStrings = false; this.#deferred = undefined; + this.#originalWriteHead = this.writeHead; } req; @@ -989,7 +990,7 @@ export class ServerResponse extends Writable { _removedContLen = false; #deferred: (() => void) | undefined = undefined; #finished = false; - + #originalWriteHead: (statusCode, statusMessage, headers) => ServerResponse; // Express "compress" package uses this _implicitHeader() { // @ts-ignore @@ -1061,7 +1062,9 @@ export class ServerResponse extends Writable { var data = this.#firstWrite || ""; this.#firstWrite = undefined; this.#finished = true; - this._implicitHeader(); + if (this.writeHead !== this.#originalWriteHead) { + this._implicitHeader(); + } this._reply( new Response(data, { headers: this.#headers, diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index 13ee7fded..9cfaccd04 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -630,7 +630,7 @@ class OutgoingMessage extends Writable { class ServerResponse extends Writable { constructor({ req, reply }) { super(); - this.req = req, this._reply = reply, this.sendDate = !0, this.statusCode = 200, this.headersSent = !1, this.statusMessage = void 0, this.#controller = void 0, this.#firstWrite = void 0, this._writableState.decodeStrings = !1, this.#deferred = void 0; + this.req = req, this._reply = reply, this.sendDate = !0, this.statusCode = 200, this.headersSent = !1, this.statusMessage = void 0, this.#controller = void 0, this.#firstWrite = void 0, this._writableState.decodeStrings = !1, this.#deferred = void 0, this.#originalWriteHead = this.writeHead; } req; _reply; @@ -647,7 +647,9 @@ class ServerResponse extends Writable { _removedContLen = !1; #deferred = void 0; #finished = !1; + #originalWriteHead; _implicitHeader() { + this.writeHead(this.statusCode); } _write(chunk, encoding, callback) { if (!this.#firstWrite && !this.headersSent) { @@ -694,7 +696,9 @@ class ServerResponse extends Writable { _final(callback) { if (!this.headersSent) { var data = this.#firstWrite || ""; - this.#firstWrite = void 0, this.#finished = !0, this._reply(new Response(data, { + if (this.#firstWrite = void 0, this.#finished = !0, this.writeHead !== this.#originalWriteHead) + this._implicitHeader(); + this._reply(new Response(data, { headers: this.#headers, status: this.statusCode, statusText: this.statusMessage ?? STATUS_CODES[this.statusCode] diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts index 167cb9883..0e7b3ca13 100644 --- a/test/js/node/http/node-http.test.ts +++ b/test/js/node/http/node-http.test.ts @@ -530,7 +530,7 @@ describe("node:http", () => { req.end(); }); }); - it("re-implemented writeHead, issue#3585", done => { + it("reassign writeHead method, issue#3585", done => { runTest(done, (server, serverPort, done) => { const req = request(`http://localhost:${serverPort}/customWriteHead`, res => { expect(res.headers["content-type"]).toBe("text/plain"); -- cgit v1.2.3 From c4c5eb2d3257fdddf47b843cfb621098dca816ee Mon Sep 17 00:00:00 2001 From: Hanaasagi Date: Tue, 11 Jul 2023 21:30:24 +0900 Subject: use `Object.getPrototypeOf` --- src/js/node/http.ts | 4 +--- src/js/out/modules/node/http.js | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 3a283912e..563cb8c46 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -972,7 +972,6 @@ export class ServerResponse extends Writable { this.#firstWrite = undefined; this._writableState.decodeStrings = false; this.#deferred = undefined; - this.#originalWriteHead = this.writeHead; } req; @@ -990,7 +989,6 @@ export class ServerResponse extends Writable { _removedContLen = false; #deferred: (() => void) | undefined = undefined; #finished = false; - #originalWriteHead: (statusCode, statusMessage, headers) => ServerResponse; // Express "compress" package uses this _implicitHeader() { // @ts-ignore @@ -1062,7 +1060,7 @@ export class ServerResponse extends Writable { var data = this.#firstWrite || ""; this.#firstWrite = undefined; this.#finished = true; - if (this.writeHead !== this.#originalWriteHead) { + if (this.writeHead !== Object.getPrototypeOf(this).writeHead) { this._implicitHeader(); } this._reply( diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index 9cfaccd04..7a9b87604 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -630,7 +630,7 @@ class OutgoingMessage extends Writable { class ServerResponse extends Writable { constructor({ req, reply }) { super(); - this.req = req, this._reply = reply, this.sendDate = !0, this.statusCode = 200, this.headersSent = !1, this.statusMessage = void 0, this.#controller = void 0, this.#firstWrite = void 0, this._writableState.decodeStrings = !1, this.#deferred = void 0, this.#originalWriteHead = this.writeHead; + this.req = req, this._reply = reply, this.sendDate = !0, this.statusCode = 200, this.headersSent = !1, this.statusMessage = void 0, this.#controller = void 0, this.#firstWrite = void 0, this._writableState.decodeStrings = !1, this.#deferred = void 0; } req; _reply; @@ -647,7 +647,6 @@ class ServerResponse extends Writable { _removedContLen = !1; #deferred = void 0; #finished = !1; - #originalWriteHead; _implicitHeader() { this.writeHead(this.statusCode); } @@ -696,7 +695,7 @@ class ServerResponse extends Writable { _final(callback) { if (!this.headersSent) { var data = this.#firstWrite || ""; - if (this.#firstWrite = void 0, this.#finished = !0, this.writeHead !== this.#originalWriteHead) + if (this.#firstWrite = void 0, this.#finished = !0, this.writeHead !== Object.getPrototypeOf(this).writeHead) this._implicitHeader(); this._reply(new Response(data, { headers: this.#headers, -- cgit v1.2.3 From 4b333b2d3571a106e8a028ce62bf5149954d38f0 Mon Sep 17 00:00:00 2001 From: simylein <67859356+simylein@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:09:06 +0200 Subject: docs(sqlite): database prepare types reflect runtime (#3599) * docs(sqlite): database prepare types reflect runtime * Update sqlite.d.ts --------- Co-authored-by: Ashcon Partovi --- packages/bun-types/sqlite.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/bun-types/sqlite.d.ts b/packages/bun-types/sqlite.d.ts index e1b8adcd0..c5b1af1c8 100644 --- a/packages/bun-types/sqlite.d.ts +++ b/packages/bun-types/sqlite.d.ts @@ -235,6 +235,7 @@ declare module "bun:sqlite" { ParamsType extends SQLQueryBindings | SQLQueryBindings[], >( sqlQuery: string, + params?: ParamsType ): Statement< ReturnType, ParamsType extends Array ? ParamsType : [ParamsType] -- cgit v1.2.3 From 31ab56d36238528c6f44c52a6cbf600744a91f0a Mon Sep 17 00:00:00 2001 From: dave caruso Date: Tue, 11 Jul 2023 12:48:19 -0700 Subject: Fix: console.log with class constructors (#3602) * Fix console.log with class constructors * oops * fix it * lol * fix test --- src/bun.js/bindings/bindings.cpp | 14 ++++++++-- src/bun.js/bindings/exports.zig | 37 +++++++++++------------- src/bun.js/test/pretty_format.zig | 42 +++++++++++++++------------- test/js/web/console/console-log.expected.txt | 8 +++++- test/js/web/console/console-log.js | 6 ++++ 5 files changed, 65 insertions(+), 42 deletions(-) diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 9f9b20c1e..d311072e4 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -2775,8 +2775,18 @@ void JSC__JSValue__put(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, const Z bool JSC__JSValue__isClass(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { - JSC::JSValue value = JSC::JSValue::decode(JSValue0); - return value.isConstructor(); + JSValue value = JSValue::decode(JSValue0); + auto callData = getCallData(value); + + switch (callData.type) { + case CallData::Type::JS: + return callData.js.functionExecutable->isClassConstructorFunction(); + case CallData::Type::Native: + if (callData.native.isBoundFunction) + return false; + return value.isConstructor(); + } + return false; } bool JSC__JSValue__isCell(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isCell(); } bool JSC__JSValue__isCustomGetterSetter(JSC__JSValue JSValue0) diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index 73a26e4be..db6de2ef3 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -1417,23 +1417,20 @@ pub const ZigConsoleClient = struct { // If we check an Object has a method table and it does not // it will crash - const callable = js_type != .Object and value.isCallable(globalThis.vm()); - - if (value.isClass(globalThis) and !callable) { - return .{ - .tag = .Object, - .cell = js_type, - }; - } + if (js_type != .Object and value.isCallable(globalThis.vm())) { + if (value.isClass(globalThis)) { + return .{ + .tag = .Class, + .cell = js_type, + }; + } - if (callable and js_type == .JSFunction) { - return .{ - .tag = .Function, - .cell = js_type, - }; - } else if (callable and js_type == .InternalFunction) { return .{ - .tag = .Object, + // TODO: we print InternalFunction as Object because we have a lot of + // callable namespaces and printing the contents of it is better than [Function: namespace] + // ideally, we would print [Function: namespace] { ... } on all functions, internal and js. + // what we'll do later is rid of .Function and .Class and handle the prefix in the .Object formatter + .tag = if (js_type == .InternalFunction) .Object else .Function, .cell = js_type, }; } @@ -1756,7 +1753,7 @@ pub const ZigConsoleClient = struct { parent: JSValue, const enable_ansi_colors = enable_ansi_colors_; pub fn handleFirstProperty(this: *@This(), globalThis: *JSC.JSGlobalObject, value: JSValue) void { - if (!value.jsType().isFunction() and !value.isClass(globalThis)) { + if (!value.jsType().isFunction()) { var writer = WrappedWriter(Writer){ .ctx = this.writer, .failed = false, @@ -2094,9 +2091,9 @@ pub const ZigConsoleClient = struct { this.addForNewLine(printable.len); if (printable.len == 0) { - writer.print(comptime Output.prettyFmt("[class]", enable_ansi_colors), .{}); + writer.print(comptime Output.prettyFmt("[class]", enable_ansi_colors), .{}); } else { - writer.print(comptime Output.prettyFmt("[class {}]", enable_ansi_colors), .{printable}); + writer.print(comptime Output.prettyFmt("[class {}]", enable_ansi_colors), .{printable}); } }, .Function => { @@ -2106,7 +2103,7 @@ pub const ZigConsoleClient = struct { if (printable.len == 0) { writer.print(comptime Output.prettyFmt("[Function]", enable_ansi_colors), .{}); } else { - writer.print(comptime Output.prettyFmt("[Function: {}]", enable_ansi_colors), .{printable}); + writer.print(comptime Output.prettyFmt("[Function: {}]", enable_ansi_colors), .{printable}); } }, .Getter => { @@ -2802,7 +2799,7 @@ pub const ZigConsoleClient = struct { } if (iter.i == 0) { - if (value.isClass(this.globalThis) and !value.isCallable(this.globalThis.vm())) + if (value.isClass(this.globalThis)) this.printAs(.Class, Writer, writer_, value, jsType, enable_ansi_colors) else if (value.isCallable(this.globalThis.vm())) this.printAs(.Function, Writer, writer_, value, jsType, enable_ansi_colors) diff --git a/src/bun.js/test/pretty_format.zig b/src/bun.js/test/pretty_format.zig index 4a245c3bb..a6c6aa631 100644 --- a/src/bun.js/test/pretty_format.zig +++ b/src/bun.js/test/pretty_format.zig @@ -423,23 +423,20 @@ pub const JestPrettyFormat = struct { // If we check an Object has a method table and it does not // it will crash - const callable = js_type != .Object and value.isCallable(globalThis.vm()); + if (js_type != .Object and value.isCallable(globalThis.vm())) { + if (value.isClass(globalThis)) { + return .{ + .tag = .Class, + .cell = js_type, + }; + } - if (value.isClass(globalThis) and !callable) { return .{ - .tag = .Object, - .cell = js_type, - }; - } - - if (callable and js_type == .JSFunction) { - return .{ - .tag = .Function, - .cell = js_type, - }; - } else if (callable and js_type == .InternalFunction) { - return .{ - .tag = .Object, + // TODO: we print InternalFunction as Object because we have a lot of + // callable namespaces and printing the contents of it is better than [Function: namespace] + // ideally, we would print [Function: namespace] { ... } on all functions, internal and js. + // what we'll do later is rid of .Function and .Class and handle the prefix in the .Object formatter + .tag = if (js_type == .InternalFunction) .Object else .Function, .cell = js_type, }; } @@ -750,7 +747,7 @@ pub const JestPrettyFormat = struct { parent: JSValue, const enable_ansi_colors = enable_ansi_colors_; pub fn handleFirstProperty(this: *@This(), globalThis: *JSC.JSGlobalObject, value: JSValue) void { - if (!value.jsType().isFunction() and !value.isClass(globalThis)) { + if (!value.jsType().isFunction()) { var writer = WrappedWriter(Writer){ .ctx = this.writer, .failed = false, @@ -1126,13 +1123,20 @@ pub const JestPrettyFormat = struct { this.addForNewLine(printable.len); if (printable.len == 0) { - writer.print(comptime Output.prettyFmt("[class]", enable_ansi_colors), .{}); + writer.print(comptime Output.prettyFmt("[class]", enable_ansi_colors), .{}); } else { - writer.print(comptime Output.prettyFmt("[class {}]", enable_ansi_colors), .{printable}); + writer.print(comptime Output.prettyFmt("[class {}]", enable_ansi_colors), .{printable}); } }, .Function => { - writer.writeAll("[Function]"); + var printable = ZigString.init(&name_buf); + value.getNameProperty(this.globalThis, &printable); + + if (printable.len == 0) { + writer.print(comptime Output.prettyFmt("[Function]", enable_ansi_colors), .{}); + } else { + writer.print(comptime Output.prettyFmt("[Function: {}]", enable_ansi_colors), .{printable}); + } }, .Array => { const len = @truncate(u32, value.getLength(this.globalThis)); diff --git a/test/js/web/console/console-log.expected.txt b/test/js/web/console/console-log.expected.txt index 97191c8be..332322665 100644 --- a/test/js/web/console/console-log.expected.txt +++ b/test/js/web/console/console-log.expected.txt @@ -1,4 +1,6 @@ Hello World! +0 +-0 123 -123 123.567 @@ -7,6 +9,8 @@ true false null undefined +Infinity +-Infinity Symbol(Symbol Description) 2000-06-27T02:24:34.304Z [ 123, 456, 789 ] @@ -29,7 +33,9 @@ Symbol(Symbol Description) } Promise { } [Function] -[Function: Foo] +[Function] +[class Foo] +[class] {} [Function: foooo] /FooRegex/ diff --git a/test/js/web/console/console-log.js b/test/js/web/console/console-log.js index e23a3e9cb..4db40aaac 100644 --- a/test/js/web/console/console-log.js +++ b/test/js/web/console/console-log.js @@ -1,4 +1,6 @@ console.log("Hello World!"); +console.log(0); +console.log(-0); console.log(123); console.log(-123); console.log(123.567); @@ -7,6 +9,8 @@ console.log(true); console.log(false); console.log(null); console.log(undefined); +console.log(Infinity); +console.log(-Infinity); console.log(Symbol("Symbol Description")); console.log(new Date(Math.pow(2, 34) * 56)); console.log([123, 456, 789]); @@ -27,7 +31,9 @@ console.log(new Promise(() => {})); class Foo {} console.log(() => {}); +console.log(function () {}); console.log(Foo); +console.log(class {}); console.log(new Foo()); console.log(function foooo() {}); -- cgit v1.2.3 From ae7bc37e94185726196a9cf77850379390904d4a Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:48:32 -0700 Subject: fix iterating stack trace (#3600) * `i + 1` and remove `defer` * a test * fix test --- src/bun.js/bindings/exports.zig | 6 +++--- test/js/bun/http/error-response.js | 8 ++++++++ test/js/bun/http/serve.test.ts | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/js/bun/http/error-response.js diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index db6de2ef3..e9e9d3a8d 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -460,7 +460,7 @@ pub const ZigStackTrace = extern struct { var source_line_len = source_lines_iter.getLength(); if (source_line_len > 0) { - var source_lines = try allocator.alloc(Api.SourceLine, @intCast(usize, @max(source_lines_iter.i, 0))); + var source_lines = try allocator.alloc(Api.SourceLine, @intCast(usize, @max(source_lines_iter.i + 1, 0))); var source_line_buf = try allocator.alloc(u8, source_line_len); source_lines_iter = this.sourceLineIterator(); var remain_buf = source_line_buf[0..]; @@ -468,7 +468,7 @@ pub const ZigStackTrace = extern struct { while (source_lines_iter.next()) |source| { const text = source.text.slice(); defer source.text.deinit(); - defer bun.copy( + bun.copy( u8, remain_buf, text, @@ -515,7 +515,7 @@ pub const ZigStackTrace = extern struct { pub fn getLength(this: *SourceLineIterator) usize { var count: usize = 0; - for (this.trace.source_lines_ptr[0..@intCast(usize, this.i)]) |*line| { + for (this.trace.source_lines_ptr[0..@intCast(usize, this.i + 1)]) |*line| { count += line.length(); } diff --git a/test/js/bun/http/error-response.js b/test/js/bun/http/error-response.js new file mode 100644 index 000000000..3284c146b --- /dev/null +++ b/test/js/bun/http/error-response.js @@ -0,0 +1,8 @@ +const s = Bun.serve({ + fetch(req, res) { + s.stop(true); + throw new Error("1"); + }, + port: 0, +}); +fetch(`http://${s.hostname}:${s.port}`).then(res => console.log(res.status)); diff --git a/test/js/bun/http/serve.test.ts b/test/js/bun/http/serve.test.ts index 7182ba68d..bba35c085 100644 --- a/test/js/bun/http/serve.test.ts +++ b/test/js/bun/http/serve.test.ts @@ -2,8 +2,10 @@ import { file, gc, Serve, serve, Server } from "bun"; import { afterEach, describe, it, expect, afterAll } from "bun:test"; import { readFileSync, writeFileSync } from "fs"; import { resolve } from "path"; +import { bunExe, bunEnv } from "harness"; import { renderToReadableStream } from "react-dom/server"; import app_jsx from "./app.jsx"; +import { spawn } from "child_process"; type Handler = (req: Request) => Response; afterEach(() => gc(true)); @@ -980,6 +982,19 @@ describe("should support Content-Range with Bun.file()", () => { } }); +it("formats error responses correctly", async () => { + const c = spawn(bunExe(), ["./error-response.js"], { cwd: import.meta.dir, env: bunEnv }); + + var output = ""; + c.stderr.on("data", chunk => { + output += chunk.toString(); + }); + c.stderr.on("end", () => { + expect(output).toContain('throw new Error("1");'); + c.kill(); + }); +}); + it("request body and signal life cycle", async () => { { const headers = { -- cgit v1.2.3 From 5c8726d602fe73e49d027194fef65b9432872c8b Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:48:46 -0700 Subject: process signal events (#3569) * signal events * simple tests * ignore SIGSTOP * better tests * use `EventEmitter` * use `Bun__getDefaultGlobal` * progress * don't use 'Bun__getDefaultGlobal` * fix tests * remove signals from map * update tests * don't overwrite event emitter methods * avoid two lookups * use `std::once` * releaseEarly() * Remove signal handler after use * Update call-raise.js * Create process-signal-handler.fixture.js * Don't register duplicates * Add missing lock * another test * update test * revert some changes --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/JSBundlerPlugin.cpp | 3 +- src/bun.js/bindings/Process.cpp | 290 +++++++++++++++------ src/bun.js/bindings/Process.h | 2 + src/bun.js/bindings/ScriptExecutionContext.cpp | 6 + src/bun.js/bindings/ScriptExecutionContext.h | 8 +- src/bun.js/bindings/webcore/EventEmitter.cpp | 7 + src/bun.js/bindings/webcore/EventEmitter.h | 6 +- src/bun.js/bindings/webcore/JSEventEmitter.cpp | 15 +- src/bun.js/bindings/webcore/JSEventEmitter.h | 3 + test/js/node/process/call-raise.js | 15 ++ .../node/process/process-signal-handler.fixture.js | 63 +++++ test/js/node/process/process.test.js | 26 +- 12 files changed, 352 insertions(+), 92 deletions(-) create mode 100644 test/js/node/process/call-raise.js create mode 100644 test/js/node/process/process-signal-handler.fixture.js diff --git a/src/bun.js/bindings/JSBundlerPlugin.cpp b/src/bun.js/bindings/JSBundlerPlugin.cpp index d55c5fc2e..ec3933574 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.cpp +++ b/src/bun.js/bindings/JSBundlerPlugin.cpp @@ -157,7 +157,8 @@ public: JSC::LazyProperty setupFunction; private: - JSBundlerPlugin(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure, void* config, BunPluginTarget target, JSBundlerPluginAddErrorCallback addError, JSBundlerPluginOnLoadAsyncCallback onLoadAsync, JSBundlerPluginOnResolveAsyncCallback onResolveAsync) + JSBundlerPlugin(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure, void* config, BunPluginTarget target, + JSBundlerPluginAddErrorCallback addError, JSBundlerPluginOnLoadAsyncCallback onLoadAsync, JSBundlerPluginOnResolveAsyncCallback onResolveAsync) : JSC::JSNonFinalObject(vm, structure) , plugin(BundlerPlugin(config, target, addError, onLoadAsync, onResolveAsync)) { diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 7d7bdd982..f9fb85b95 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -437,91 +437,215 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, return JSC::JSValue::encode(result); } -// static const NeverDestroyed signalNames[] = { -// MAKE_STATIC_STRING_IMPL("SIGHUP"), -// MAKE_STATIC_STRING_IMPL("SIGINT"), -// MAKE_STATIC_STRING_IMPL("SIGQUIT"), -// MAKE_STATIC_STRING_IMPL("SIGILL"), -// MAKE_STATIC_STRING_IMPL("SIGTRAP"), -// MAKE_STATIC_STRING_IMPL("SIGABRT"), -// MAKE_STATIC_STRING_IMPL("SIGIOT"), -// MAKE_STATIC_STRING_IMPL("SIGBUS"), -// MAKE_STATIC_STRING_IMPL("SIGFPE"), -// MAKE_STATIC_STRING_IMPL("SIGKILL"), -// MAKE_STATIC_STRING_IMPL("SIGUSR1"), -// MAKE_STATIC_STRING_IMPL("SIGSEGV"), -// MAKE_STATIC_STRING_IMPL("SIGUSR2"), -// MAKE_STATIC_STRING_IMPL("SIGPIPE"), -// MAKE_STATIC_STRING_IMPL("SIGALRM"), -// MAKE_STATIC_STRING_IMPL("SIGTERM"), -// MAKE_STATIC_STRING_IMPL("SIGCHLD"), -// MAKE_STATIC_STRING_IMPL("SIGCONT"), -// MAKE_STATIC_STRING_IMPL("SIGSTOP"), -// MAKE_STATIC_STRING_IMPL("SIGTSTP"), -// MAKE_STATIC_STRING_IMPL("SIGTTIN"), -// MAKE_STATIC_STRING_IMPL("SIGTTOU"), -// MAKE_STATIC_STRING_IMPL("SIGURG"), -// MAKE_STATIC_STRING_IMPL("SIGXCPU"), -// MAKE_STATIC_STRING_IMPL("SIGXFSZ"), -// MAKE_STATIC_STRING_IMPL("SIGVTALRM"), -// MAKE_STATIC_STRING_IMPL("SIGPROF"), -// MAKE_STATIC_STRING_IMPL("SIGWINCH"), -// MAKE_STATIC_STRING_IMPL("SIGIO"), -// MAKE_STATIC_STRING_IMPL("SIGINFO"), -// MAKE_STATIC_STRING_IMPL("SIGSYS"), -// }; -// static const int signalNumbers[] = { -// SIGHUP, -// SIGINT, -// SIGQUIT, -// SIGILL, -// SIGTRAP, -// SIGABRT, -// SIGIOT, -// SIGBUS, -// SIGFPE, -// SIGKILL, -// SIGUSR1, -// SIGSEGV, -// SIGUSR2, -// SIGPIPE, -// SIGALRM, -// SIGTERM, -// SIGCHLD, -// SIGCONT, -// SIGSTOP, -// SIGTSTP, -// SIGTTIN, -// SIGTTOU, -// SIGURG, -// SIGXCPU, -// SIGXFSZ, -// SIGVTALRM, -// SIGPROF, -// SIGWINCH, -// SIGIO, -// SIGINFO, -// SIGSYS, -// }; - -// JSC_DEFINE_HOST_FUNCTION(jsFunctionProcessOn, (JSGlobalObject * globalObject, CallFrame* callFrame)) -// { -// VM& vm = globalObject->vm(); -// auto scope = DECLARE_THROW_SCOPE(vm); - -// if (callFrame->argumentCount() < 2) { -// throwVMError(globalObject, scope, "Not enough arguments"_s); -// return JSValue::encode(jsUndefined()); -// } - -// String eventName = callFrame->uncheckedArgument(0).toWTFString(globalObject); -// RETURN_IF_EXCEPTION(scope, encodedJSValue()); -// } +static HashMap* signalNameToNumberMap = nullptr; +static HashMap* signalNumberToNameMap = nullptr; + +// signal number to array of script execution context ids that care about the signal +static HashMap>* signalToContextIdsMap = nullptr; +static Lock signalToContextIdsMapLock; + +static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& eventName, bool isAdded) +{ + + static const NeverDestroyed signalNames[] = { + MAKE_STATIC_STRING_IMPL("SIGHUP"), + MAKE_STATIC_STRING_IMPL("SIGINT"), + MAKE_STATIC_STRING_IMPL("SIGQUIT"), + MAKE_STATIC_STRING_IMPL("SIGILL"), + MAKE_STATIC_STRING_IMPL("SIGTRAP"), + MAKE_STATIC_STRING_IMPL("SIGABRT"), + MAKE_STATIC_STRING_IMPL("SIGIOT"), + MAKE_STATIC_STRING_IMPL("SIGBUS"), + MAKE_STATIC_STRING_IMPL("SIGFPE"), + MAKE_STATIC_STRING_IMPL("SIGKILL"), + MAKE_STATIC_STRING_IMPL("SIGUSR1"), + MAKE_STATIC_STRING_IMPL("SIGSEGV"), + MAKE_STATIC_STRING_IMPL("SIGUSR2"), + MAKE_STATIC_STRING_IMPL("SIGPIPE"), + MAKE_STATIC_STRING_IMPL("SIGALRM"), + MAKE_STATIC_STRING_IMPL("SIGTERM"), + MAKE_STATIC_STRING_IMPL("SIGCHLD"), + MAKE_STATIC_STRING_IMPL("SIGCONT"), + MAKE_STATIC_STRING_IMPL("SIGSTOP"), + MAKE_STATIC_STRING_IMPL("SIGTSTP"), + MAKE_STATIC_STRING_IMPL("SIGTTIN"), + MAKE_STATIC_STRING_IMPL("SIGTTOU"), + MAKE_STATIC_STRING_IMPL("SIGURG"), + MAKE_STATIC_STRING_IMPL("SIGXCPU"), + MAKE_STATIC_STRING_IMPL("SIGXFSZ"), + MAKE_STATIC_STRING_IMPL("SIGVTALRM"), + MAKE_STATIC_STRING_IMPL("SIGPROF"), + MAKE_STATIC_STRING_IMPL("SIGWINCH"), + MAKE_STATIC_STRING_IMPL("SIGIO"), + MAKE_STATIC_STRING_IMPL("SIGINFO"), + MAKE_STATIC_STRING_IMPL("SIGSYS"), + }; + + static std::once_flag signalNameToNumberMapOnceFlag; + std::call_once(signalNameToNumberMapOnceFlag, [] { + signalNameToNumberMap = new HashMap(); + signalNameToNumberMap->reserveInitialCapacity(31); + signalNameToNumberMap->add(signalNames[0], SIGHUP); + signalNameToNumberMap->add(signalNames[1], SIGINT); + signalNameToNumberMap->add(signalNames[2], SIGQUIT); + signalNameToNumberMap->add(signalNames[3], SIGILL); + signalNameToNumberMap->add(signalNames[4], SIGTRAP); + signalNameToNumberMap->add(signalNames[5], SIGABRT); + signalNameToNumberMap->add(signalNames[6], SIGIOT); + signalNameToNumberMap->add(signalNames[7], SIGBUS); + signalNameToNumberMap->add(signalNames[8], SIGFPE); + // signalNameToNumberMap->add(signalNames[9], SIGKILL); + signalNameToNumberMap->add(signalNames[10], SIGUSR1); + signalNameToNumberMap->add(signalNames[11], SIGSEGV); + signalNameToNumberMap->add(signalNames[12], SIGUSR2); + signalNameToNumberMap->add(signalNames[13], SIGPIPE); + signalNameToNumberMap->add(signalNames[14], SIGALRM); + signalNameToNumberMap->add(signalNames[15], SIGTERM); + signalNameToNumberMap->add(signalNames[16], SIGCHLD); + signalNameToNumberMap->add(signalNames[17], SIGCONT); + // signalNameToNumberMap->add(signalNames[18], SIGSTOP); + signalNameToNumberMap->add(signalNames[19], SIGTSTP); + signalNameToNumberMap->add(signalNames[20], SIGTTIN); + signalNameToNumberMap->add(signalNames[21], SIGTTOU); + signalNameToNumberMap->add(signalNames[22], SIGURG); + signalNameToNumberMap->add(signalNames[23], SIGXCPU); + signalNameToNumberMap->add(signalNames[24], SIGXFSZ); + signalNameToNumberMap->add(signalNames[25], SIGVTALRM); + signalNameToNumberMap->add(signalNames[26], SIGPROF); + signalNameToNumberMap->add(signalNames[27], SIGWINCH); + signalNameToNumberMap->add(signalNames[28], SIGIO); +#ifdef SIGINFO + signalNameToNumberMap->add(signalNames[29], SIGINFO); +#endif + +#ifndef SIGINFO + signalNameToNumberMap->add(signalNames[29], 255); +#endif + signalNameToNumberMap->add(signalNames[30], SIGSYS); + }); + + static std::once_flag signalNumberToNameMapOnceFlag; + std::call_once(signalNumberToNameMapOnceFlag, [] { + signalNumberToNameMap = new HashMap(); + signalNumberToNameMap->reserveInitialCapacity(31); + signalNumberToNameMap->add(SIGHUP, signalNames[0]); + signalNumberToNameMap->add(SIGINT, signalNames[1]); + signalNumberToNameMap->add(SIGQUIT, signalNames[2]); + signalNumberToNameMap->add(SIGILL, signalNames[3]); + signalNumberToNameMap->add(SIGTRAP, signalNames[4]); + signalNumberToNameMap->add(SIGABRT, signalNames[5]); + signalNumberToNameMap->add(SIGIOT, signalNames[6]); + signalNumberToNameMap->add(SIGBUS, signalNames[7]); + signalNumberToNameMap->add(SIGFPE, signalNames[8]); + // signalNumberToNameMap->add(SIGKILL, signalNames[9]); + signalNumberToNameMap->add(SIGUSR1, signalNames[10]); + signalNumberToNameMap->add(SIGSEGV, signalNames[11]); + signalNumberToNameMap->add(SIGUSR2, signalNames[12]); + signalNumberToNameMap->add(SIGPIPE, signalNames[13]); + signalNumberToNameMap->add(SIGALRM, signalNames[14]); + signalNumberToNameMap->add(SIGTERM, signalNames[15]); + signalNumberToNameMap->add(SIGCHLD, signalNames[16]); + signalNumberToNameMap->add(SIGCONT, signalNames[17]); + // signalNumberToNameMap->add(SIGSTOP, signalNames[18]); + signalNumberToNameMap->add(SIGTSTP, signalNames[19]); + signalNumberToNameMap->add(SIGTTIN, signalNames[20]); + signalNumberToNameMap->add(SIGTTOU, signalNames[21]); + signalNumberToNameMap->add(SIGURG, signalNames[22]); + signalNumberToNameMap->add(SIGXCPU, signalNames[23]); + signalNumberToNameMap->add(SIGXFSZ, signalNames[24]); + signalNumberToNameMap->add(SIGVTALRM, signalNames[25]); + signalNumberToNameMap->add(SIGPROF, signalNames[26]); + signalNumberToNameMap->add(SIGWINCH, signalNames[27]); + signalNumberToNameMap->add(SIGIO, signalNames[28]); +#ifdef SIGINFO + signalNameToNumberMap->add(signalNames[29], SIGINFO); +#endif + signalNumberToNameMap->add(SIGSYS, signalNames[30]); + }); + + if (!signalToContextIdsMap) { + signalToContextIdsMap = new HashMap>(); + } + + if (isAdded) { + if (auto signalNumber = signalNameToNumberMap->get(eventName.string())) { + uint32_t contextId = eventEmitter.scriptExecutionContext()->identifier(); + Locker lock { signalToContextIdsMapLock }; + if (!signalToContextIdsMap->contains(signalNumber)) { + HashSet contextIds; + contextIds.add(contextId); + signalToContextIdsMap->set(signalNumber, contextIds); + + lock.unlockEarly(); + + struct sigaction action; + memset(&action, 0, sizeof(struct sigaction)); + + // Set the handler in the action struct + action.sa_handler = [](int signalNumber) { + if (UNLIKELY(signalNumberToNameMap->find(signalNumber) == signalNumberToNameMap->end())) + return; + + Locker lock { signalToContextIdsMapLock }; + if (UNLIKELY(signalToContextIdsMap->find(signalNumber) == signalToContextIdsMap->end())) + return; + auto contextIds = signalToContextIdsMap->get(signalNumber); + + for (int contextId : contextIds) { + auto* context = ScriptExecutionContext::getScriptExecutionContext(contextId); + if (UNLIKELY(!context)) + continue; + + JSGlobalObject* lexicalGlobalObject = context->jsGlobalObject(); + Zig::GlobalObject* globalObject = static_cast(lexicalGlobalObject); + + Process* process = jsCast(globalObject->processObject()); + + context->postCrossThreadTask(*process, &Process::emitSignalEvent, signalNumber); + } + }; + + // Clear the sa_mask + sigemptyset(&action.sa_mask); + sigaddset(&action.sa_mask, signalNumber); + action.sa_flags = SA_RESTART; + + sigaction(signalNumber, &action, nullptr); + } else { + auto contextIds = signalToContextIdsMap->get(signalNumber); + contextIds.add(contextId); + signalToContextIdsMap->set(signalNumber, contextIds); + } + } + } else { + if (auto signalNumber = signalNameToNumberMap->get(eventName.string())) { + uint32_t contextId = eventEmitter.scriptExecutionContext()->identifier(); + Locker lock { signalToContextIdsMapLock }; + if (signalToContextIdsMap->find(signalNumber) != signalToContextIdsMap->end()) { + HashSet contextIds = signalToContextIdsMap->get(signalNumber); + contextIds.remove(contextId); + if (contextIds.isEmpty()) { + signal(signalNumber, SIG_DFL); + signalToContextIdsMap->remove(signalNumber); + } else { + signalToContextIdsMap->set(signalNumber, contextIds); + } + } + } + } +} + +void Process::emitSignalEvent(int signalNumber) +{ + String signalName = signalNumberToNameMap->get(signalNumber); + Identifier signalNameIdentifier = Identifier::fromString(vm(), signalName); + MarkedArgumentBuffer args; + args.append(jsNumber(signalNumber)); + wrapped().emitForBindings(signalNameIdentifier, args); +} Process::~Process() { - for (auto& listener : this->wrapped().eventListenerMap().entries()) { - } } JSC_DEFINE_HOST_FUNCTION(Process_functionAbort, (JSGlobalObject * globalObject, CallFrame*)) @@ -1550,6 +1674,8 @@ void Process::finishCreation(JSC::VM& vm) { Base::finishCreation(vm); + this->wrapped().onDidChangeListener = &onDidChangeListeners; + this->cpuUsageStructure.initLater([](const JSC::LazyProperty::Initializer& init) { init.set(constructCPUUsageStructure(init.vm, init.owner->globalObject())); }); diff --git a/src/bun.js/bindings/Process.h b/src/bun.js/bindings/Process.h index fbad9b1ff..0ee6f4243 100644 --- a/src/bun.js/bindings/Process.h +++ b/src/bun.js/bindings/Process.h @@ -19,6 +19,8 @@ public: { } + void emitSignalEvent(int signalNumber); + DECLARE_EXPORT_INFO; static void destroy(JSC::JSCell* cell) diff --git a/src/bun.js/bindings/ScriptExecutionContext.cpp b/src/bun.js/bindings/ScriptExecutionContext.cpp index e8cae5e33..3262bdb5d 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.cpp +++ b/src/bun.js/bindings/ScriptExecutionContext.cpp @@ -20,6 +20,12 @@ static HashMap& allSc return contexts; } +ScriptExecutionContext* ScriptExecutionContext::getScriptExecutionContext(ScriptExecutionContextIdentifier identifier) +{ + Locker locker { allScriptExecutionContextsMapLock }; + return allScriptExecutionContextsMap().get(identifier); +} + template static void registerHTTPContextForWebSocket(ScriptExecutionContext* script, us_socket_context_t* ctx, us_loop_t* loop) { diff --git a/src/bun.js/bindings/ScriptExecutionContext.h b/src/bun.js/bindings/ScriptExecutionContext.h index 5f6c56a90..aed7977a5 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.h +++ b/src/bun.js/bindings/ScriptExecutionContext.h @@ -96,7 +96,12 @@ public: } } - const WTF::URL& url() const { return m_url; } + static ScriptExecutionContext* getScriptExecutionContext(ScriptExecutionContextIdentifier identifier); + + const WTF::URL& url() const + { + return m_url; + } bool activeDOMObjectsAreSuspended() { return false; } bool activeDOMObjectsAreStopped() { return false; } bool isContextThread() { return true; } @@ -141,6 +146,7 @@ public: auto* task = new EventLoopTask(WTFMove(lambda)); postTaskOnTimeout(task, timeout); } + template void postCrossThreadTask(Arguments&&... arguments) { diff --git a/src/bun.js/bindings/webcore/EventEmitter.cpp b/src/bun.js/bindings/webcore/EventEmitter.cpp index 0650d624c..0e273042b 100644 --- a/src/bun.js/bindings/webcore/EventEmitter.cpp +++ b/src/bun.js/bindings/webcore/EventEmitter.cpp @@ -35,6 +35,8 @@ bool EventEmitter::addListener(const Identifier& eventType, Ref&& } eventListenersDidChange(); + if (this->onDidChangeListener) + this->onDidChangeListener(*this, eventType, true); return true; } @@ -62,6 +64,9 @@ bool EventEmitter::removeListener(const Identifier& eventType, EventListener& li if (data->eventListenerMap.remove(eventType, listener)) { eventListenersDidChange(); + + if (this->onDidChangeListener) + this->onDidChangeListener(*this, eventType, false); return true; } return false; @@ -93,6 +98,8 @@ bool EventEmitter::removeAllListeners(const Identifier& eventType) if (data->eventListenerMap.removeAll(eventType)) { eventListenersDidChange(); + if (this->onDidChangeListener) + this->onDidChangeListener(*this, eventType, false); return true; } return false; diff --git a/src/bun.js/bindings/webcore/EventEmitter.h b/src/bun.js/bindings/webcore/EventEmitter.h index b46bcff5d..8db59c188 100644 --- a/src/bun.js/bindings/webcore/EventEmitter.h +++ b/src/bun.js/bindings/webcore/EventEmitter.h @@ -67,6 +67,8 @@ public: bool hasActiveEventListeners(const Identifier& eventType) const; bool hasEventListeners(JSC::VM& vm, ASCIILiteral eventType) const; + WTF::Function onDidChangeListener = WTF::Function(nullptr); + unsigned getMaxListeners() const { return m_maxListeners; }; void setMaxListeners(unsigned count); @@ -101,7 +103,9 @@ private: EventEmitterData* eventTargetData() { return &m_eventTargetData; } EventEmitterData* eventTargetDataConcurrently() { return &m_eventTargetData; } EventEmitterData& ensureEventEmitterData() { return m_eventTargetData; } - void eventListenersDidChange() {} + void eventListenersDidChange() + { + } void innerInvokeEventListeners(const Identifier&, SimpleEventListenerVector, const MarkedArgumentBuffer& arguments); void invalidateEventListenerRegions(); diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.cpp b/src/bun.js/bindings/webcore/JSEventEmitter.cpp index 231ae0db4..959cbd8d7 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitter.cpp +++ b/src/bun.js/bindings/webcore/JSEventEmitter.cpp @@ -219,7 +219,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsEventEmitterConstructor, (JSGlobalObject * lexicalGlo return JSValue::encode(JSEventEmitter::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject())); } -static inline JSC::EncodedJSValue addListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis, bool once, bool prepend) +inline JSC::EncodedJSValue JSEventEmitter::addListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSEventEmitter* castedThis, bool once, bool prepend) { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -251,7 +251,7 @@ static inline JSC::EncodedJSValue addListener(JSC::JSGlobalObject* lexicalGlobal static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_addListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { - return addListener(lexicalGlobalObject, callFrame, castedThis, false, false); + return JSEventEmitter::addListener(lexicalGlobalObject, callFrame, castedThis, false, false); } static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_setMaxListenersBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) @@ -280,17 +280,17 @@ static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_getMaxListener static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_addOnceListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { - return addListener(lexicalGlobalObject, callFrame, castedThis, true, false); + return JSEventEmitter::addListener(lexicalGlobalObject, callFrame, castedThis, true, false); } static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_prependListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { - return addListener(lexicalGlobalObject, callFrame, castedThis, false, true); + return JSEventEmitter::addListener(lexicalGlobalObject, callFrame, castedThis, false, true); } static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_prependOnceListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { - return addListener(lexicalGlobalObject, callFrame, castedThis, true, true); + return JSEventEmitter::addListener(lexicalGlobalObject, callFrame, castedThis, true, true); } JSC_DEFINE_HOST_FUNCTION(jsEventEmitterPrototypeFunction_addListener, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) @@ -324,6 +324,11 @@ JSC_DEFINE_HOST_FUNCTION(jsEventEmitterPrototypeFunction_prependOnceListener, (J } static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_removeListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) +{ + return JSEventEmitter::removeListener(lexicalGlobalObject, callFrame, castedThis); +} + +inline JSC::EncodedJSValue JSEventEmitter::removeListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSEventEmitter* castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.h b/src/bun.js/bindings/webcore/JSEventEmitter.h index 855241011..30d62d792 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitter.h +++ b/src/bun.js/bindings/webcore/JSEventEmitter.h @@ -27,6 +27,9 @@ public: static EventEmitter* toWrapped(JSC::VM&, JSC::JSValue); static void destroy(JSC::JSCell*); + static inline JSC::EncodedJSValue addListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSEventEmitter* castedThis, bool once, bool prepend); + static inline JSC::EncodedJSValue removeListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSEventEmitter* castedThis); + DECLARE_INFO; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/test/js/node/process/call-raise.js b/test/js/node/process/call-raise.js new file mode 100644 index 000000000..898906759 --- /dev/null +++ b/test/js/node/process/call-raise.js @@ -0,0 +1,15 @@ +import { dlopen } from "bun:ffi"; + +var lazyRaise; +export function raise(signal) { + if (!lazyRaise) { + const suffix = process.platform === "darwin" ? "dylib" : "so.6"; + lazyRaise = dlopen(`libc.${suffix}`, { + raise: { + args: ["int"], + returns: "int", + }, + }).symbols.raise; + } + lazyRaise(signal); +} diff --git a/test/js/node/process/process-signal-handler.fixture.js b/test/js/node/process/process-signal-handler.fixture.js new file mode 100644 index 000000000..de5a78bda --- /dev/null +++ b/test/js/node/process/process-signal-handler.fixture.js @@ -0,0 +1,63 @@ +import os from "os"; +import { raise } from "./call-raise"; + +var counter = 0; +function done() { + counter++; + if (counter === 2) { + setTimeout(() => { + if (counter !== 2) { + console.log(counter); + console.log("FAIL"); + process.exit(1); + } + + console.log("PASS"); + process.exit(0); + }, 1); + } +} + +var counter2 = 0; +function done2() { + counter2++; + if (counter2 === 2) { + setTimeout(() => { + if (counter2 !== 2) { + console.log(counter2); + console.log("FAIL"); + process.exit(1); + } + + console.log("PASS"); + process.exit(0); + }, 1); + } +} + +const SIGUSR1 = os.constants.signals.SIGUSR1; +const SIGUSR2 = os.constants.signals.SIGUSR2; + +switch (process.argv.at(-1)) { + case "SIGUSR1": { + process.on("SIGUSR1", () => { + done(); + }); + process.on("SIGUSR1", () => { + done(); + }); + raise(SIGUSR1); + break; + } + case "SIGUSR2": { + process.on("SIGUSR2", () => { + done2(); + }); + process.emit("SIGUSR2"); + raise(SIGUSR2); + break; + } + default: { + throw new Error("Unknown argument: " + process.argv.at(-1)); + } +} diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index e038383de..51825b2b4 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -1,6 +1,6 @@ -import { resolveSync, spawnSync, which } from "bun"; +import { spawnSync, which } from "bun"; import { describe, expect, it } from "bun:test"; -import { existsSync, readFileSync, realpathSync } from "fs"; +import { existsSync, readFileSync } from "fs"; import { bunEnv, bunExe } from "harness"; import { basename, join, resolve } from "path"; @@ -381,6 +381,28 @@ it("process.getuid", () => { expect(typeof process.getuid()).toBe("number"); }); +describe("signal", () => { + const fixture = join(import.meta.dir, "./process-signal-handler.fixture.js"); + it("simple case works", async () => { + const child = Bun.spawn({ + cmd: [bunExe(), fixture, "SIGUSR1"], + env: bunEnv, + }); + + expect(await child.exited).toBe(0); + expect(await new Response(child.stdout).text()).toBe("PASS\n"); + }); + it("process.emit will call signal events", async () => { + const child = Bun.spawn({ + cmd: [bunExe(), fixture, "SIGUSR2"], + env: bunEnv, + }); + + expect(await child.exited).toBe(0); + expect(await new Response(child.stdout).text()).toBe("PASS\n"); + }); +}); + const undefinedStubs = [ "_debugEnd", "_debugProcess", -- cgit v1.2.3 From bab58b754156cdd749faa6e5ee41bd4758346da6 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 11 Jul 2023 13:07:03 -0700 Subject: Avoid Object.getPrototypeOf --- src/js/node/http.ts | 16 +++++++++++++--- src/js/out/modules/node/http.js | 12 +++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 563cb8c46..42388b32e 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -957,6 +957,7 @@ export class OutgoingMessage extends Writable { } } +let OriginalWriteHeadFn, OriginalImplicitHeadFn; export class ServerResponse extends Writable { declare _writableState: any; @@ -1055,14 +1056,20 @@ export class ServerResponse extends Writable { ); } + #drainHeadersIfObservable() { + if (this._implicitHeader === OriginalImplicitHeadFn && this.writeHead === OriginalWriteHeadFn) { + return; + } + + this._implicitHeader(); + } + _final(callback) { if (!this.headersSent) { var data = this.#firstWrite || ""; this.#firstWrite = undefined; this.#finished = true; - if (this.writeHead !== Object.getPrototypeOf(this).writeHead) { - this._implicitHeader(); - } + this.#drainHeadersIfObservable(); this._reply( new Response(data, { headers: this.#headers, @@ -1181,6 +1188,9 @@ export class ServerResponse extends Writable { } } +OriginalWriteHeadFn = ServerResponse.prototype.writeHead; +OriginalImplicitHeadFn = ServerResponse.prototype._implicitHeader; + export class ClientRequest extends OutgoingMessage { #timeout; #res: IncomingMessage | null = null; diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index 7a9b87604..d0937a945 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -626,6 +626,7 @@ class OutgoingMessage extends Writable { return this; } } +var OriginalWriteHeadFn, OriginalImplicitHeadFn; class ServerResponse extends Writable { constructor({ req, reply }) { @@ -692,12 +693,15 @@ class ServerResponse extends Writable { statusText: this.statusMessage ?? STATUS_CODES[this.statusCode] })); } + #drainHeadersIfObservable() { + if (this._implicitHeader === OriginalImplicitHeadFn && this.writeHead === OriginalWriteHeadFn) + return; + this._implicitHeader(); + } _final(callback) { if (!this.headersSent) { var data = this.#firstWrite || ""; - if (this.#firstWrite = void 0, this.#finished = !0, this.writeHead !== Object.getPrototypeOf(this).writeHead) - this._implicitHeader(); - this._reply(new Response(data, { + this.#firstWrite = void 0, this.#finished = !0, this.#drainHeadersIfObservable(), this._reply(new Response(data, { headers: this.#headers, status: this.statusCode, statusText: this.statusMessage ?? STATUS_CODES[this.statusCode] @@ -783,6 +787,8 @@ class ServerResponse extends Writable { return _writeHead(statusCode, statusMessage, headers, this), this; } } +OriginalWriteHeadFn = ServerResponse.prototype.writeHead; +OriginalImplicitHeadFn = ServerResponse.prototype._implicitHeader; class ClientRequest extends OutgoingMessage { #timeout; -- cgit v1.2.3 From 609f81a74614b20a1d49ce1197e1ddfe5aa2736f Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Tue, 11 Jul 2023 15:32:41 -0700 Subject: Add npmrc note --- docs/api/file-io.md | 12 ++++++++++-- docs/install/registries.md | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/api/file-io.md b/docs/api/file-io.md index effc57580..be9cf0991 100644 --- a/docs/api/file-io.md +++ b/docs/api/file-io.md @@ -285,7 +285,13 @@ interface Bun { write( destination: string | number | BunFile | URL, - input: string | Blob | ArrayBuffer | SharedArrayBuffer | TypedArray | Response, + input: + | string + | Blob + | ArrayBuffer + | SharedArrayBuffer + | TypedArray + | Response, ): Promise; } @@ -301,7 +307,9 @@ interface BunFile { } export interface FileSink { - write(chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer): number; + write( + chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer, + ): number; flush(): number | Promise; end(error?: Error): number | Promise; start(options?: { highWaterMark?: number }): void; diff --git a/docs/install/registries.md b/docs/install/registries.md index e4090e3c9..86657ca26 100644 --- a/docs/install/registries.md +++ b/docs/install/registries.md @@ -24,3 +24,7 @@ To configure a private registry scoped to a particular organization: # registry with token "@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" } ``` + +### `.npmrc` + +Bun does not currently read `.npmrc` files. For private registries, migrate your registry configuration to `bunfig.toml` as documented above. -- cgit v1.2.3 From 854ddaa909a97c0317ec29682f6c6635818d7b9e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:44:29 -0700 Subject: Implement throwIfNoEntry --- src/bun.js/node/node_fs.zig | 51 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 74a41c5bd..3f298c5c7 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -652,6 +652,7 @@ pub const Arguments = struct { pub const Stat = struct { path: PathLike, big_int: bool = false, + throw_if_no_entry: bool = true, pub fn deinit(this: Stat) void { this.path.deinit(); @@ -672,13 +673,25 @@ pub const Arguments = struct { if (exception.* != null) return null; + var throw_if_no_entry = true; + const big_int = brk: { if (arguments.next()) |next_val| { if (next_val.isObject()) { if (next_val.isCallable(ctx.ptr().vm())) break :brk false; arguments.eat(); - if (next_val.getOptional(ctx.ptr(), "bigint", bool) catch false) |big_int| { + if (next_val.getOptional(ctx.ptr(), "throwIfNoEntry", bool) catch { + path.deinit(); + return null; + }) |throw_if_no_entry_val| { + throw_if_no_entry = throw_if_no_entry_val; + } + + if (next_val.getOptional(ctx.ptr(), "bigint", bool) catch { + path.deinit(); + return null; + }) |big_int| { break :brk big_int; } } @@ -688,7 +701,7 @@ pub const Arguments = struct { if (exception.* != null) return null; - return Stat{ .path = path, .big_int = big_int }; + return Stat{ .path = path, .big_int = big_int, .throw_if_no_entry = throw_if_no_entry }; } }; @@ -2497,6 +2510,18 @@ pub const Arguments = struct { }; }; +pub const StatOrNotFound = union(enum) { + stats: Stats, + not_found: void, + + pub fn toJS(this: *StatOrNotFound, globalObject: *JSC.JSGlobalObject) JSC.JSValue { + return switch (this.*) { + .stats => this.stats.toJS(globalObject), + .not_found => JSC.JSValue.undefined, + }; + } +}; + const Return = struct { pub const Access = void; pub const AppendFile = void; @@ -2515,7 +2540,7 @@ const Return = struct { pub const Lchmod = void; pub const Lchown = void; pub const Link = void; - pub const Lstat = Stats; + pub const Lstat = StatOrNotFound; pub const Mkdir = bun.String; pub const Mkdtemp = JSC.ZigString; pub const Open = FileDescriptor; @@ -2617,7 +2642,7 @@ const Return = struct { pub const RealpathNative = Realpath; pub const Rename = void; pub const Rmdir = void; - pub const Stat = Stats; + pub const Stat = StatOrNotFound; pub const Symlink = void; pub const Truncate = void; @@ -3129,8 +3154,13 @@ pub const NodeFS = struct { &this.sync_error_buf, ), )) { - .result => |result| Maybe(Return.Lstat){ .result = Return.Lstat.init(result, false) }, - .err => |err| Maybe(Return.Lstat){ .err = err }, + .result => |result| Maybe(Return.Lstat){ .result = .{ .stats = Stats.init(result, args.big_int) } }, + .err => |err| brk: { + if (!args.throw_if_no_entry and err.getErrno() == .NOENT) { + return Maybe(Return.Lstat){ .result = .{ .not_found = {} } }; + } + break :brk Maybe(Return.Lstat){ .err = err }; + }, }; }, else => {}, @@ -4333,8 +4363,13 @@ pub const NodeFS = struct { &this.sync_error_buf, ), )) { - .result => |result| Maybe(Return.Stat){ .result = Return.Stat.init(result, false) }, - .err => |err| Maybe(Return.Stat){ .err = err }, + .result => |result| Maybe(Return.Stat){ .result = .{ .stats = Stats.init(result, args.big_int) } }, + .err => |err| brk: { + if (!args.throw_if_no_entry and err.getErrno() == .NOENT) { + return Maybe(Return.Stat){ .result = .{ .not_found = {} } }; + } + break :brk Maybe(Return.Stat){ .err = err }; + }, }); }, else => {}, -- cgit v1.2.3 From 2106e1d7f657a2f5fcad2c329532773bc5ce31e2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:48:13 -0700 Subject: Tests --- test/js/node/fs/fs.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index 0236010be..48aa9d3b9 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -159,6 +159,18 @@ it("readdirSync on import.meta.dir", () => { expect(match).toBe(true); }); +it("statSync throwIfNoEntry", () => { + expect(statSync("/tmp/404/not-found/ok", { throwIfNoEntry: false })).toBeUndefined(); + expect(lstatSync("/tmp/404/not-found/ok", { throwIfNoEntry: false })).toBeUndefined(); +}); + +it("statSync throwIfNoEntry: true", () => { + expect(() => statSync("/tmp/404/not-found/ok", { throwIfNoEntry: true })).toThrow("No such file or directory"); + expect(() => statSync("/tmp/404/not-found/ok")).toThrow("No such file or directory"); + expect(() => lstatSync("/tmp/404/not-found/ok", { throwIfNoEntry: true })).toThrow("No such file or directory"); + expect(() => lstatSync("/tmp/404/not-found/ok")).toThrow("No such file or directory"); +}); + // https://github.com/oven-sh/bun/issues/1887 it("mkdtempSync, readdirSync, rmdirSync and unlinkSync with non-ascii", () => { const tempdir = mkdtempSync(`${tmpdir()}/emoji-fruit-🍇 🍈 🍉 🍊 🍋`); -- cgit v1.2.3 From 8ca2194a371ac5b69af11a71748db16e7cf3262a Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:49:35 -0700 Subject: fix #3597 (#3609) * fix #3597 * Update http.ts * initialize to true --- src/js/node/http.ts | 19 +++++++++++++++++++ src/js/out/modules/node/http.js | 6 +++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 42388b32e..fe075c832 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -973,6 +973,10 @@ export class ServerResponse extends Writable { this.#firstWrite = undefined; this._writableState.decodeStrings = false; this.#deferred = undefined; + + // this is matching node's behaviour + // https://github.com/nodejs/node/blob/cf8c6994e0f764af02da4fa70bc5962142181bf3/lib/_http_server.js#L192 + if (req.method === "HEAD") this._hasBody = false; } req; @@ -988,6 +992,7 @@ export class ServerResponse extends Writable { _defaultKeepAlive = false; _removedConnection = false; _removedContLen = false; + _hasBody = true; #deferred: (() => void) | undefined = undefined; #finished = false; // Express "compress" package uses this @@ -1835,6 +1840,20 @@ function _writeHead(statusCode, reason, obj, response) { } } } + + if (statusCode === 204 || statusCode === 304 || (statusCode >= 100 && statusCode <= 199)) { + // RFC 2616, 10.2.5: + // The 204 response MUST NOT include a message-body, and thus is always + // terminated by the first empty line after the header fields. + // RFC 2616, 10.3.5: + // The 304 response MUST NOT contain a message-body, and thus is always + // terminated by the first empty line after the header fields. + // RFC 2616, 10.1 Informational 1xx: + // This class of status code indicates a provisional response, + // consisting only of the Status-Line and optional headers, and is + // terminated by an empty line. + response._hasBody = false; + } } /** diff --git a/src/js/out/modules/node/http.js b/src/js/out/modules/node/http.js index d0937a945..cc9092518 100644 --- a/src/js/out/modules/node/http.js +++ b/src/js/out/modules/node/http.js @@ -99,6 +99,8 @@ var _writeHead = function(statusCode, reason, obj, response) { response.setHeader(k, obj[k]); } } + if (statusCode === 204 || statusCode === 304 || statusCode >= 100 && statusCode <= 199) + response._hasBody = !1; }; function request(url, options, cb) { return new ClientRequest(url, options, cb); @@ -631,7 +633,8 @@ var OriginalWriteHeadFn, OriginalImplicitHeadFn; class ServerResponse extends Writable { constructor({ req, reply }) { super(); - this.req = req, this._reply = reply, this.sendDate = !0, this.statusCode = 200, this.headersSent = !1, this.statusMessage = void 0, this.#controller = void 0, this.#firstWrite = void 0, this._writableState.decodeStrings = !1, this.#deferred = void 0; + if (this.req = req, this._reply = reply, this.sendDate = !0, this.statusCode = 200, this.headersSent = !1, this.statusMessage = void 0, this.#controller = void 0, this.#firstWrite = void 0, this._writableState.decodeStrings = !1, this.#deferred = void 0, req.method === "HEAD") + this._hasBody = !1; } req; _reply; @@ -646,6 +649,7 @@ class ServerResponse extends Writable { _defaultKeepAlive = !1; _removedConnection = !1; _removedContLen = !1; + _hasBody = !0; #deferred = void 0; #finished = !1; _implicitHeader() { -- cgit v1.2.3 From a1fb289c96ca41fc3fc50ccb76f6e63e70b6a772 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Tue, 11 Jul 2023 18:50:34 -0700 Subject: typo (#3610) --- src/install/install.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/install/install.zig b/src/install/install.zig index f6133afce..65f4a35e9 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -5554,7 +5554,7 @@ pub const PackageManager = struct { // Done if (manager.options.log_level != .silent) Output.prettyln( - \\Success! Registered \"{[name]s}\" + \\Success! Registered "{[name]s}" \\ \\To use {[name]s} in a project, run: \\ bun link {[name]s} -- cgit v1.2.3 From a686b3bfc13a53bc324c09d7bae37f1249330481 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:00:24 -0700 Subject: Fixes #3595 --- src/bun.js/bindings/ZigGlobalObject.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 3291b204e..af0dad4da 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -336,12 +336,22 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c extern "C" void* Bun__getVM(); extern "C" JSGlobalObject* Bun__getDefaultGlobal(); +// Error.captureStackTrace may cause computeErrorInfo to be called twice +// Rather than figure out the plumbing in JSC, we just skip the next call +// TODO: thread_local for workers +static bool skipNextComputeErrorInfo = false; + +// error.stack calls this function static String computeErrorInfoWithoutPrepareStackTrace(JSC::VM& vm, Vector& stackTrace, unsigned& line, unsigned& column, String& sourceURL, JSObject* errorInstance) { if (!errorInstance) { return String(); } + if (skipNextComputeErrorInfo) { + return String(); + } + Zig::GlobalObject* globalObject = jsDynamicCast(errorInstance->globalObject()); if (!globalObject) { // Happens in node:vm @@ -414,6 +424,9 @@ static String computeErrorInfoWithoutPrepareStackTrace(JSC::VM& vm, VectorformatStackTrace(vm, lexicalGlobalObject, errorObject, callSites); RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode({})); + bool orignialSkipNextComputeErrorInfo = skipNextComputeErrorInfo; + skipNextComputeErrorInfo = true; if (errorObject->hasProperty(lexicalGlobalObject, vm.propertyNames->stack)) { + skipNextComputeErrorInfo = true; errorObject->deleteProperty(lexicalGlobalObject, vm.propertyNames->stack); } + skipNextComputeErrorInfo = orignialSkipNextComputeErrorInfo; + if (formattedStackTrace.isUndefinedOrNull()) { formattedStackTrace = JSC::jsUndefined(); } -- cgit v1.2.3 From c5f228048936b266ac5c2dd840e59222c2e893c3 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:06:01 -0700 Subject: Implement `process.kill` and `process._kill` --- packages/bun-types/globals.d.ts | 2 + src/bun.js/bindings/Process.cpp | 147 +++++++++++++---- src/bun.js/bindings/Process.lut.h | 77 ++++----- src/js/out/WebCoreJSBuiltins.cpp | 300 +++++++++++++++++------------------ test/js/node/process/process.test.js | 27 ++++ 5 files changed, 331 insertions(+), 222 deletions(-) diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index f3f941488..9e9b5138d 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -433,6 +433,8 @@ interface Process { * Does nothing in Bun */ setSourceMapsEnabled(enabled: boolean): void; + + kill(pid: number, signal?: string | number): void; } interface MemoryUsageObject { diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index f9fb85b95..745be0e47 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -444,43 +444,43 @@ static HashMap* signalNumberToNameMap = nullptr; static HashMap>* signalToContextIdsMap = nullptr; static Lock signalToContextIdsMapLock; -static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& eventName, bool isAdded) +static const NeverDestroyed signalNames[] = { + MAKE_STATIC_STRING_IMPL("SIGHUP"), + MAKE_STATIC_STRING_IMPL("SIGINT"), + MAKE_STATIC_STRING_IMPL("SIGQUIT"), + MAKE_STATIC_STRING_IMPL("SIGILL"), + MAKE_STATIC_STRING_IMPL("SIGTRAP"), + MAKE_STATIC_STRING_IMPL("SIGABRT"), + MAKE_STATIC_STRING_IMPL("SIGIOT"), + MAKE_STATIC_STRING_IMPL("SIGBUS"), + MAKE_STATIC_STRING_IMPL("SIGFPE"), + MAKE_STATIC_STRING_IMPL("SIGKILL"), + MAKE_STATIC_STRING_IMPL("SIGUSR1"), + MAKE_STATIC_STRING_IMPL("SIGSEGV"), + MAKE_STATIC_STRING_IMPL("SIGUSR2"), + MAKE_STATIC_STRING_IMPL("SIGPIPE"), + MAKE_STATIC_STRING_IMPL("SIGALRM"), + MAKE_STATIC_STRING_IMPL("SIGTERM"), + MAKE_STATIC_STRING_IMPL("SIGCHLD"), + MAKE_STATIC_STRING_IMPL("SIGCONT"), + MAKE_STATIC_STRING_IMPL("SIGSTOP"), + MAKE_STATIC_STRING_IMPL("SIGTSTP"), + MAKE_STATIC_STRING_IMPL("SIGTTIN"), + MAKE_STATIC_STRING_IMPL("SIGTTOU"), + MAKE_STATIC_STRING_IMPL("SIGURG"), + MAKE_STATIC_STRING_IMPL("SIGXCPU"), + MAKE_STATIC_STRING_IMPL("SIGXFSZ"), + MAKE_STATIC_STRING_IMPL("SIGVTALRM"), + MAKE_STATIC_STRING_IMPL("SIGPROF"), + MAKE_STATIC_STRING_IMPL("SIGWINCH"), + MAKE_STATIC_STRING_IMPL("SIGIO"), + MAKE_STATIC_STRING_IMPL("SIGINFO"), + MAKE_STATIC_STRING_IMPL("SIGSYS"), +}; + +static void loadSignalNumberMap() { - static const NeverDestroyed signalNames[] = { - MAKE_STATIC_STRING_IMPL("SIGHUP"), - MAKE_STATIC_STRING_IMPL("SIGINT"), - MAKE_STATIC_STRING_IMPL("SIGQUIT"), - MAKE_STATIC_STRING_IMPL("SIGILL"), - MAKE_STATIC_STRING_IMPL("SIGTRAP"), - MAKE_STATIC_STRING_IMPL("SIGABRT"), - MAKE_STATIC_STRING_IMPL("SIGIOT"), - MAKE_STATIC_STRING_IMPL("SIGBUS"), - MAKE_STATIC_STRING_IMPL("SIGFPE"), - MAKE_STATIC_STRING_IMPL("SIGKILL"), - MAKE_STATIC_STRING_IMPL("SIGUSR1"), - MAKE_STATIC_STRING_IMPL("SIGSEGV"), - MAKE_STATIC_STRING_IMPL("SIGUSR2"), - MAKE_STATIC_STRING_IMPL("SIGPIPE"), - MAKE_STATIC_STRING_IMPL("SIGALRM"), - MAKE_STATIC_STRING_IMPL("SIGTERM"), - MAKE_STATIC_STRING_IMPL("SIGCHLD"), - MAKE_STATIC_STRING_IMPL("SIGCONT"), - MAKE_STATIC_STRING_IMPL("SIGSTOP"), - MAKE_STATIC_STRING_IMPL("SIGTSTP"), - MAKE_STATIC_STRING_IMPL("SIGTTIN"), - MAKE_STATIC_STRING_IMPL("SIGTTOU"), - MAKE_STATIC_STRING_IMPL("SIGURG"), - MAKE_STATIC_STRING_IMPL("SIGXCPU"), - MAKE_STATIC_STRING_IMPL("SIGXFSZ"), - MAKE_STATIC_STRING_IMPL("SIGVTALRM"), - MAKE_STATIC_STRING_IMPL("SIGPROF"), - MAKE_STATIC_STRING_IMPL("SIGWINCH"), - MAKE_STATIC_STRING_IMPL("SIGIO"), - MAKE_STATIC_STRING_IMPL("SIGINFO"), - MAKE_STATIC_STRING_IMPL("SIGSYS"), - }; - static std::once_flag signalNameToNumberMapOnceFlag; std::call_once(signalNameToNumberMapOnceFlag, [] { signalNameToNumberMap = new HashMap(); @@ -523,6 +523,11 @@ static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& e #endif signalNameToNumberMap->add(signalNames[30], SIGSYS); }); +} + +static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& eventName, bool isAdded) +{ + loadSignalNumberMap(); static std::once_flag signalNumberToNameMapOnceFlag; std::call_once(signalNumberToNameMapOnceFlag, [] { @@ -1601,6 +1606,76 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, return JSC::JSValue::encode(result); } +JSC_DEFINE_HOST_FUNCTION(Process_functionReallyKill, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + + int pid = callFrame->argument(0).toInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + + int signal = callFrame->argument(1).toInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + + int result = kill(pid, signal); + if (result == -1) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("kill"_s); + throwException(globalObject, scope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSValue::encode(jsUndefined()); + } + + return JSValue::encode(jsUndefined()); +} +JSC_DEFINE_HOST_FUNCTION(Process_functionKill, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + + int pid = callFrame->argument(0).toInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + if (pid < 0) { + throwRangeError(globalObject, scope, "pid must be a positive integer"_s); + return JSValue::encode(jsUndefined()); + } + + JSC::JSValue signalValue = callFrame->argument(1); + + int signal = SIGTERM; + + if (signalValue.isNumber()) { + signal = signalValue.toInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + } else if (signalValue.isString()) { + loadSignalNumberMap(); + if (auto num = signalNameToNumberMap->get(signalValue.toWTFString(globalObject))) { + signal = num; + RETURN_IF_EXCEPTION(scope, {}); + } else { + throwRangeError(globalObject, scope, "Unknown signal name"_s); + return JSValue::encode(jsUndefined()); + } + + RETURN_IF_EXCEPTION(scope, {}); + } else if (!signalValue.isUndefinedOrNull()) { + throwTypeError(globalObject, scope, "signal must be a string or number"_s); + return JSValue::encode(jsUndefined()); + } + + int result = kill(pid, signal); + + if (result == -1) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("kill"_s); + throwException(globalObject, scope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSValue::encode(jsUndefined()); + } + + return JSValue::encode(jsUndefined()); +} + /* Source for Process.lut.h @begin processObjectTable abort Process_functionAbort Function 1 @@ -1632,6 +1707,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, getuid Process_functiongetuid Function 0 hrtime constructProcessHrtimeObject PropertyCallback isBun constructIsBun PropertyCallback + kill Process_functionKill Function 2 mainModule JSBuiltin ReadOnly|Builtin|Accessor|Function 0 memoryUsage constructMemoryUsage PropertyCallback moduleLoadList Process_stubEmptyArray PropertyCallback @@ -1663,6 +1739,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, _startProfilerIdleNotifier Process_stubEmptyFunction Function 0 _stopProfilerIdleNotifier Process_stubEmptyFunction Function 0 _tickCallback Process_stubEmptyFunction Function 0 + _kill Process_functionReallyKill Function 2 @end */ diff --git a/src/bun.js/bindings/Process.lut.h b/src/bun.js/bindings/Process.lut.h index 81eb1b7b9..81cf98c7d 100644 --- a/src/bun.js/bindings/Process.lut.h +++ b/src/bun.js/bindings/Process.lut.h @@ -1,6 +1,6 @@ // File generated via `make generate-builtins` -static const struct CompactHashIndex processObjectTableIndex[142] = { - { 43, -1 }, +static const struct CompactHashIndex processObjectTableIndex[143] = { + { 44, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -14,9 +14,9 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { 15, 129 }, { -1, -1 }, { -1, -1 }, - { 18, 138 }, + { 18, 139 }, { -1, -1 }, - { 45, -1 }, + { 46, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -33,37 +33,37 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 3, 141 }, + { 3, 142 }, { 1, 128 }, { -1, -1 }, - { 59, -1 }, + { 60, -1 }, { -1, -1 }, { 10, -1 }, { -1, -1 }, { -1, -1 }, - { 31, -1 }, + { 32, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 52, -1 }, + { 53, -1 }, { 27, -1 }, { 12, -1 }, { -1, -1 }, { 19, -1 }, { -1, -1 }, - { 14, 137 }, + { 14, 138 }, { -1, -1 }, - { 36, -1 }, + { 37, -1 }, { -1, -1 }, - { 38, -1 }, - { 55, -1 }, - { 35, -1 }, - { 6, 139 }, + { 39, -1 }, + { 56, -1 }, + { 36, -1 }, + { 6, 140 }, { -1, -1 }, - { 51, -1 }, + { 52, -1 }, { 4, -1 }, - { 47, -1 }, + { 48, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -75,25 +75,25 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 40, -1 }, + { 41, -1 }, { -1, -1 }, - { 37, -1 }, + { 29, 133 }, { -1, -1 }, { 0, -1 }, - { 26, 135 }, + { 26, 136 }, { 16, 130 }, - { 39, -1 }, + { 40, -1 }, { -1, -1 }, { 23, -1 }, { 11, -1 }, { -1, -1 }, { -1, -1 }, - { 58, -1 }, + { 59, -1 }, { -1, -1 }, { -1, -1 }, - { 30, 136 }, + { 31, 137 }, { -1, -1 }, - { 29, -1 }, + { 30, -1 }, { 22, -1 }, { -1, -1 }, { -1, -1 }, @@ -104,8 +104,8 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { -1, -1 }, { 5, -1 }, { -1, -1 }, - { -1, -1 }, - { 48, -1 }, + { 61, -1 }, + { 49, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -115,36 +115,37 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { -1, -1 }, { -1, -1 }, { 9, -1 }, - { 25, 133 }, + { 25, 134 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 21, 134 }, + { 21, 135 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 46, 140 }, + { 47, 141 }, { -1, -1 }, { 17, -1 }, { 8, -1 }, { 28, -1 }, - { 32, 132 }, - { 33, -1 }, + { 33, 132 }, { 34, -1 }, - { 41, -1 }, + { 35, -1 }, + { 38, -1 }, { 42, -1 }, - { 44, -1 }, - { 49, -1 }, + { 43, -1 }, + { 45, -1 }, { 50, -1 }, - { 53, -1 }, + { 51, -1 }, { 54, -1 }, - { 56, -1 }, + { 55, -1 }, { 57, -1 }, + { 58, -1 }, }; -static const struct HashTableValue processObjectTableValues[60] = { +static const struct HashTableValue processObjectTableValues[62] = { { "abort"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionAbort, 1 } }, { "allowedNodeEnvironmentFlags"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptySet } }, { "arch"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArch } }, @@ -174,6 +175,7 @@ static const struct HashTableValue processObjectTableValues[60] = { { "getuid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetuid, 0 } }, { "hrtime"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessHrtimeObject } }, { "isBun"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructIsBun } }, + { "kill"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionKill, 2 } }, { "mainModule"_s, ((static_cast(PropertyAttribute::ReadOnly|PropertyAttribute::Builtin|PropertyAttribute::Accessor|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, processObjectMainModuleCodeGenerator, 0 } }, { "memoryUsage"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructMemoryUsage } }, { "moduleLoadList"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptyArray } }, @@ -205,7 +207,8 @@ static const struct HashTableValue processObjectTableValues[60] = { { "_startProfilerIdleNotifier"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, { "_stopProfilerIdleNotifier"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, { "_tickCallback"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_kill"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionReallyKill, 2 } }, }; static const struct HashTable processObjectTable = - { 60, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; + { 62, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index fb3100762..f20f626d4 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -16,7 +16,7 @@ const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunSetupFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunSetupFunctionCodeLength = 2165; static const JSC::Intrinsic s_bundlerPluginRunSetupFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunSetupFunctionCode = "(function (_,E){\"use strict\";var w=new Map,h=new Map;function q(D,F,G){if(!D||!@isObject(D))@throwTypeError('Expected an object with \"filter\" RegExp');if(!F||!@isCallable(F))@throwTypeError(\"callback must be a function\");var{filter:H,namespace:I=\"file\"}=D;if(!H)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(H))@throwTypeError(\"filter must be a RegExp\");if(I&&typeof I!==\"string\")@throwTypeError(\"namespace must be a string\");if((I\?.length\?\?0)===0)I=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(I))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var J=G.@get(I);if(!J)G.@set(I,[[H,F]]);else @arrayPush(J,[H,F])}function z(D,F){q(D,F,w)}function A(D,F){q(D,F,h)}const B=()=>{var D=!1,F=!1;for(var[G,H]of w.entries())for(var[I]of H)this.addFilter(I,G,1),D=!0;for(var[G,H]of h.entries())for(var[I]of H)this.addFilter(I,G,0),F=!0;if(F){var J=this.onResolve;if(!J)this.onResolve=h;else for(var[G,H]of h.entries()){var K=J.@get(G);if(!K)J.@set(G,H);else J.@set(G,K.concat(H))}}if(D){var M=this.onLoad;if(!M)this.onLoad=w;else for(var[G,H]of w.entries()){var K=M.@get(G);if(!K)M.@set(G,H);else M.@set(G,K.concat(H))}}return D||F};var C=_({config:E,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:z,onResolve:A,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{...E,bundle:!0,entryPoints:E.entrypoints\?\?E.entryPoints\?\?[],minify:typeof E.minify===\"boolean\"\?E.minify:!1,minifyIdentifiers:E.minify===!0||E.minify\?.identifiers,minifyWhitespace:E.minify===!0||E.minify\?.whitespace,minifySyntax:E.minify===!0||E.minify\?.syntax,outbase:E.root,platform:E.target===\"bun\"\?\"node\":E.target},esbuild:{}});if(C&&@isPromise(C))if(@getPromiseInternalField(C,@promiseFieldFlags)&@promiseStateFulfilled)C=@getPromiseInternalField(C,@promiseFieldReactionsOrResult);else return C.@then(B);return B()})\n"; +const char* const s_bundlerPluginRunSetupFunctionCode = "(function (J,_){\"use strict\";var D=new Map,F=new Map;function H(q,h,E){if(!q||!@isObject(q))@throwTypeError('Expected an object with \"filter\" RegExp');if(!h||!@isCallable(h))@throwTypeError(\"callback must be a function\");var{filter:w,namespace:z=\"file\"}=q;if(!w)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(w))@throwTypeError(\"filter must be a RegExp\");if(z&&typeof z!==\"string\")@throwTypeError(\"namespace must be a string\");if((z\?.length\?\?0)===0)z=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(z))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var A=E.@get(z);if(!A)E.@set(z,[[w,h]]);else @arrayPush(A,[w,h])}function K(q,h){H(q,h,D)}function M(q,h){H(q,h,F)}const I=()=>{var q=!1,h=!1;for(var[E,w]of D.entries())for(var[z]of w)this.addFilter(z,E,1),q=!0;for(var[E,w]of F.entries())for(var[z]of w)this.addFilter(z,E,0),h=!0;if(h){var A=this.onResolve;if(!A)this.onResolve=F;else for(var[E,w]of F.entries()){var C=A.@get(E);if(!C)A.@set(E,w);else A.@set(E,C.concat(w))}}if(q){var G=this.onLoad;if(!G)this.onLoad=D;else for(var[E,w]of D.entries()){var C=G.@get(E);if(!C)G.@set(E,w);else G.@set(E,C.concat(w))}}return q||h};var B=J({config:_,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:K,onResolve:M,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{..._,bundle:!0,entryPoints:_.entrypoints\?\?_.entryPoints\?\?[],minify:typeof _.minify===\"boolean\"\?_.minify:!1,minifyIdentifiers:_.minify===!0||_.minify\?.identifiers,minifyWhitespace:_.minify===!0||_.minify\?.whitespace,minifySyntax:_.minify===!0||_.minify\?.syntax,outbase:_.root,platform:_.target===\"bun\"\?\"node\":_.target},esbuild:{}});if(B&&@isPromise(B))if(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);else return B.@then(I);return I()})\n"; // runOnResolvePlugins const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -24,7 +24,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnResolvePluginsCodeLength = 1711; static const JSC::Intrinsic s_bundlerPluginRunOnResolvePluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (_,w,g,y,b){\"use strict\";const j=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][b];var q=(async(z,A,B,C)=>{var{onResolve:E,onLoad:F}=this,G=E.@get(A);if(!G)return this.onResolveAsync(y,null,null,null),null;for(let[O,Q]of G)if(O.test(z)){var H=Q({path:z,importer:B,namespace:A,kind:C});while(H&&@isPromise(H)&&(@getPromiseInternalField(H,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)H=@getPromiseInternalField(H,@promiseFieldReactionsOrResult);if(H&&@isPromise(H))H=await H;if(!H||!@isObject(H))continue;var{path:J,namespace:K=A,external:M}=H;if(typeof J!==\"string\"||typeof K!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!J)continue;if(!K)K=A;if(typeof M!==\"boolean\"&&!@isUndefinedOrNull(M))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!M){if(K===\"file\"){if(darwin!==\"win32\"){if(J[0]!==\"/\"||J.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(K===\"dataurl\"){if(!J.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(K&&K!==\"file\"&&(!F||!F.@has(K)))@throwTypeError(`Expected onLoad plugin for namespace ${K} to exist`)}return this.onResolveAsync(y,J,K,M),null}return this.onResolveAsync(y,null,null,null),null})(_,w,g,j);while(q&&@isPromise(q)&&(@getPromiseInternalField(q,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)q=@getPromiseInternalField(q,@promiseFieldReactionsOrResult);if(q&&@isPromise(q))q.then(()=>{},(z)=>{this.addError(y,z,0)})})\n"; +const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (C,E,F,b,G){\"use strict\";const H=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][G];var g=(async(j,q,J,K)=>{var{onResolve:M,onLoad:A}=this,B=M.@get(q);if(!B)return this.onResolveAsync(b,null,null,null),null;for(let[O,Q]of B)if(O.test(j)){var _=Q({path:j,importer:J,namespace:q,kind:K});while(_&&@isPromise(_)&&(@getPromiseInternalField(_,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)_=@getPromiseInternalField(_,@promiseFieldReactionsOrResult);if(_&&@isPromise(_))_=await _;if(!_||!@isObject(_))continue;var{path:y,namespace:w=q,external:z}=_;if(typeof y!==\"string\"||typeof w!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!y)continue;if(!w)w=q;if(typeof z!==\"boolean\"&&!@isUndefinedOrNull(z))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!z){if(w===\"file\"){if(darwin!==\"win32\"){if(y[0]!==\"/\"||y.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(w===\"dataurl\"){if(!y.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(w&&w!==\"file\"&&(!A||!A.@has(w)))@throwTypeError(`Expected onLoad plugin for namespace ${w} to exist`)}return this.onResolveAsync(b,y,w,z),null}return this.onResolveAsync(b,null,null,null),null})(C,E,F,H);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(b,j,0)})})\n"; // runOnLoadPlugins const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,g,j,q){\"use strict\";const v={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},w=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][q];var x=(async(y,z,B,C)=>{var F=this.onLoad.@get(B);if(!F)return this.onLoadAsync(y,null,null),null;for(let[K,Q]of F)if(K.test(z)){var G=Q({path:z,namespace:B,loader:C});while(G&&@isPromise(G)&&(@getPromiseInternalField(G,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)G=@getPromiseInternalField(G,@promiseFieldReactionsOrResult);if(G&&@isPromise(G))G=await G;if(!G||!@isObject(G))continue;var{contents:H,loader:J=C}=G;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=v[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(y,H,T),null}return this.onLoadAsync(y,null,null),null})(b,g,j,w);while(x&&@isPromise(x)&&(@getPromiseInternalField(x,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)x=@getPromiseInternalField(x,@promiseFieldReactionsOrResult);if(x&&@isPromise(x))x.then(()=>{},(y)=>{this.addError(b,y,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (w,F,G,H){\"use strict\";const J={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},K=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][H];var g=(async(j,x,y,z)=>{var B=this.onLoad.@get(y);if(!B)return this.onLoadAsync(j,null,null),null;for(let[Q,T]of B)if(Q.test(x)){var b=T({path:x,namespace:y,loader:z});while(b&&@isPromise(b)&&(@getPromiseInternalField(b,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)b=@getPromiseInternalField(b,@promiseFieldReactionsOrResult);if(b&&@isPromise(b))b=await b;if(!b||!@isObject(b))continue;var{contents:q,loader:v=z}=b;if(typeof q!==\"string\"&&!@isTypedArrayView(q))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof v!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const C=J[v];if(C===@undefined)@throwTypeError(`Loader ${v} is not supported.`);return this.onLoadAsync(j,q,C),null}return this.onLoadAsync(j,null,null),null})(w,F,G,K);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(w,j,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -108,7 +108,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeCons const JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateWritableStreamCodeLength = 278; static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (u,N,d,f,p,_){\"use strict\";@assert(typeof p===\"number\"&&!@isNaN(p)&&p>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,N,d,f,p,_),@createWritableStreamFromInternal(j)})\n"; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (p,N,_,f,u,j){\"use strict\";@assert(typeof u===\"number\"&&!@isNaN(u)&&u>=0);const d={};@initializeWritableStreamSlots(d,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(d,q,p,N,_,f,u,j),@createWritableStreamFromInternal(d)})\n"; // createInternalWritableStreamFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -116,7 +116,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStream const JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 920; static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,o){\"use strict\";const w={};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 C=@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(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,w){\"use strict\";const C={};if(f===@undefined)f={};if(w===@undefined)w={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const E=@extractSizeAlgorithm(w),_=@extractHighWaterMark(w,1),o={};if(\"start\"in f){if(o.start=f.start,typeof o.start!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in f){if(o.write=f.write,typeof o.write!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in f){if(o.close=f.close,typeof o.close!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in f){if(o.abort=f.abort,typeof o.abort!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(C,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(C,f,o,_,E),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 (g,n){\"use strict\";if(@isWritableStreamLocked(n))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(g,\"stream\",n),@putByIdDirectPrivate(n,\"writer\",g);const v=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(g,\"readyPromise\",v),@putByIdDirectPrivate(g,\"closedPromise\",h);const B=@getByIdDirectPrivate(n,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(n)||!@getByIdDirectPrivate(n,\"backpressure\"))v.@resolve.@call()}else if(B===\"erroring\")v.@reject.@call(@undefined,@getByIdDirectPrivate(n,\"storedError\")),@markPromiseAsHandled(v.@promise);else if(B===\"closed\")v.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(n,\"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 f=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(B===\"writable\"||B===\"erroring\");let _=!1;if(B===\"erroring\")_=!0,h=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:j,reason:h,wasAlreadyErroring:_}),!_)@writableStreamStartErroring(c,h);return j.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (h,B){\"use strict\";const c=@getByIdDirectPrivate(h,\"state\");if(c===\"closed\"||c===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(h,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(c===\"writable\"||c===\"erroring\");let _=!1;if(c===\"erroring\")_=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(h,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:_}),!_)@writableStreamStartErroring(h,B);return j.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -196,7 +196,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithReject const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDealWithRejectionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength = 189; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDealWithRejectionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,n){\"use strict\";const c=@getByIdDirectPrivate(i,\"state\");if(c===\"writable\"){@writableStreamStartErroring(i,n);return}@assert(c===\"erroring\"),@writableStreamFinishErroring(i)})\n"; +const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,c){\"use strict\";const n=@getByIdDirectPrivate(i,\"state\");if(n===\"writable\"){@writableStreamStartErroring(i,c);return}@assert(n===\"erroring\"),@writableStreamFinishErroring(i)})\n"; // writableStreamFinishErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility = 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 (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"; +const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const h=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(h,\"errorSteps\").@call();const A=@getByIdDirectPrivate(i,\"storedError\"),B=@getByIdDirectPrivate(i,\"writeRequests\");for(var p=B.shift();p;p=B.shift())p.@reject.@call(@undefined,A);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const _=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(_===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),_.wasAlreadyErroring){_.promise.@reject.@call(@undefined,A),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(h,\"abortSteps\").@call(@undefined,_.reason).@then(()=>{_.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(I)=>{_.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const i=@getByIdDirectPrivate(d,\"state\");if(@assert(i===\"writable\"||i===\"erroring\"),i===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const n=@getByIdDirectPrivate(d,\"writer\");if(n!==@undefined)@getByIdDirectPrivate(n,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -292,7 +292,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterA const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength = 130; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (c,d){\"use strict\";const f=@getByIdDirectPrivate(c,\"stream\");return @assert(f!==@undefined),@writableStreamAbort(f,d)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (d,f){\"use strict\";const c=@getByIdDirectPrivate(d,\"stream\");return @assert(c!==@undefined),@writableStreamAbort(c,f)})\n"; // writableStreamDefaultWriterClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -300,7 +300,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength = 126; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");return @assert(c!==@undefined),@writableStreamClose(c)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (c){\"use strict\";const _=@getByIdDirectPrivate(c,\"stream\");return @assert(_!==@undefined),@writableStreamClose(_)})\n"; // writableStreamDefaultWriterCloseWithErrorPropagation const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -308,7 +308,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength = 385; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (c){\"use strict\";const l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const u=@getByIdDirectPrivate(l,\"state\");if(@writableStreamCloseQueuedOrInFlight(l)||u===\"closed\")return @Promise.@resolve();if(u===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(l,\"storedError\"));return @assert(u===\"writable\"||u===\"erroring\"),@writableStreamDefaultWriterClose(c)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (u){\"use strict\";const c=@getByIdDirectPrivate(u,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(@writableStreamCloseQueuedOrInFlight(c)||l===\"closed\")return @Promise.@resolve();if(l===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(c,\"storedError\"));return @assert(l===\"writable\"||l===\"erroring\"),@writableStreamDefaultWriterClose(u)})\n"; // writableStreamDefaultWriterEnsureClosedPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -316,7 +316,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength = 329; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (_,n){\"use strict\";let h=@getByIdDirectPrivate(_,\"closedPromise\"),u=h.@promise;if((@getPromiseInternalField(u,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),u=h.@promise,@putByIdDirectPrivate(_,\"closedPromise\",h);h.@reject.@call(@undefined,n),@markPromiseAsHandled(u)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (h,u){\"use strict\";let _=@getByIdDirectPrivate(h,\"closedPromise\"),n=_.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)_=@newPromiseCapability(@Promise),n=_.@promise,@putByIdDirectPrivate(h,\"closedPromise\",_);_.@reject.@call(@undefined,u),@markPromiseAsHandled(n)})\n"; // writableStreamDefaultWriterEnsureReadyPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -324,7 +324,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 327; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (c,g){\"use strict\";let h=@getByIdDirectPrivate(c,\"readyPromise\"),n=h.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),n=h.@promise,@putByIdDirectPrivate(c,\"readyPromise\",h);h.@reject.@call(@undefined,g),@markPromiseAsHandled(n)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (h,n){\"use strict\";let c=@getByIdDirectPrivate(h,\"readyPromise\"),g=c.@promise;if((@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)c=@newPromiseCapability(@Promise),g=c.@promise,@putByIdDirectPrivate(h,\"readyPromise\",c);c.@reject.@call(@undefined,n),@markPromiseAsHandled(g)})\n"; // writableStreamDefaultWriterGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -332,7 +332,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterG const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength = 299; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (c){\"use strict\";const l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const _=@getByIdDirectPrivate(l,\"state\");if(_===\"errored\"||_===\"erroring\")return null;if(_===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(l,\"controller\"))})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(l===\"errored\"||l===\"erroring\")return null;if(l===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(c,\"controller\"))})\n"; // writableStreamDefaultWriterRelease const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -340,7 +340,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterR const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength = 414; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode = "(function (_){\"use strict\";const h=@getByIdDirectPrivate(_,\"stream\");@assert(h!==@undefined),@assert(@getByIdDirectPrivate(h,\"writer\")===_);const c=@makeTypeError(\"writableStreamDefaultWriterRelease\");@writableStreamDefaultWriterEnsureReadyPromiseRejected(_,c),@writableStreamDefaultWriterEnsureClosedPromiseRejected(_,c),@putByIdDirectPrivate(h,\"writer\",@undefined),@putByIdDirectPrivate(_,\"stream\",@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");@assert(c!==@undefined),@assert(@getByIdDirectPrivate(c,\"writer\")===_);const h=@makeTypeError(\"writableStreamDefaultWriterRelease\");@writableStreamDefaultWriterEnsureReadyPromiseRejected(_,h),@writableStreamDefaultWriterEnsureClosedPromiseRejected(_,h),@putByIdDirectPrivate(c,\"writer\",@undefined),@putByIdDirectPrivate(_,\"stream\",@undefined)})\n"; // writableStreamDefaultWriterWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructAbility = 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 (d,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const W=@getByIdDirectPrivate(P,\"controller\");@assert(W!==@undefined);const _=@writableStreamDefaultControllerGetChunkSize(W,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const b=@getByIdDirectPrivate(P,\"state\");if(b===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(b===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(b===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(W,g,_),f})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (W,_){\"use strict\";const d=@getByIdDirectPrivate(W,\"stream\");@assert(d!==@undefined);const P=@getByIdDirectPrivate(d,\"controller\");@assert(P!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(P,_);if(d!==@getByIdDirectPrivate(W,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const g=@getByIdDirectPrivate(d,\"state\");if(g===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(g===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));@assert(g===\"writable\");const f=@writableStreamAddWriteRequest(d);return @writableStreamDefaultControllerWrite(P,_,b),f})\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,d,v,f,P,j,U){\"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\",d),@putByIdDirectPrivate(B,\"strategySizeAlgorithm\",U),@putByIdDirectPrivate(B,\"strategyHWM\",j),@putByIdDirectPrivate(B,\"writeAlgorithm\",v),@putByIdDirectPrivate(B,\"closeAlgorithm\",f),@putByIdDirectPrivate(B,\"abortAlgorithm\",P);const q=@writableStreamDefaultControllerGetBackpressure(B);@writableStreamUpdateBackpressure(_,q),@writableStreamDefaultControllerStart(B)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (B,_,v,P,U,d,f,j){\"use strict\";@assert(@isWritableStream(B)),@assert(@getByIdDirectPrivate(B,\"controller\")===@undefined),@putByIdDirectPrivate(_,\"stream\",B),@putByIdDirectPrivate(B,\"controller\",_),@resetQueue(@getByIdDirectPrivate(_,\"queue\")),@putByIdDirectPrivate(_,\"started\",-1),@putByIdDirectPrivate(_,\"startAlgorithm\",v),@putByIdDirectPrivate(_,\"strategySizeAlgorithm\",j),@putByIdDirectPrivate(_,\"strategyHWM\",f),@putByIdDirectPrivate(_,\"writeAlgorithm\",P),@putByIdDirectPrivate(_,\"closeAlgorithm\",U),@putByIdDirectPrivate(_,\"abortAlgorithm\",d);const q=@writableStreamDefaultControllerGetBackpressure(_);@writableStreamUpdateBackpressure(B,q),@writableStreamDefaultControllerStart(_)})\n"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -364,7 +364,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 647; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const _=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(_.@call()).@then(()=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(d,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,u)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const p=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(p.@call()).@then(()=>{const _=@getByIdDirectPrivate(d,\"state\");@assert(_===\"writable\"||_===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(_)=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,_)})})\n"; // setUpWritableStreamDefaultControllerFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (_,j,v,p,f){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},O=()=>{return @Promise.@resolve()};if(\"start\"in v){const E=v.start;x=()=>@promiseInvokeOrNoopMethodNoCatch(j,E,[q])}if(\"write\"in v){const E=v.write;B=(F)=>@promiseInvokeOrNoopMethod(j,E,[F,q])}if(\"close\"in v){const E=v.close;C=()=>@promiseInvokeOrNoopMethod(j,E,[])}if(\"abort\"in v){const E=v.abort;O=(F)=>@promiseInvokeOrNoopMethod(j,E,[F])}@setUpWritableStreamDefaultController(_,q,x,B,C,O,p,f)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,O,_,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let q=()=>{},v=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in _){const p=_.start;q=()=>@promiseInvokeOrNoopMethodNoCatch(O,p,[f])}if(\"write\"in _){const p=_.write;v=(j)=>@promiseInvokeOrNoopMethod(O,p,[j,f])}if(\"close\"in _){const p=_.close;x=()=>@promiseInvokeOrNoopMethod(O,p,[])}if(\"abort\"in _){const p=_.abort;B=(j)=>@promiseInvokeOrNoopMethod(O,p,[j])}@setUpWritableStreamDefaultController(C,f,q,v,x,B,E,F)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -412,7 +412,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength = 237; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (i,h){\"use strict\";const b=@getByIdDirectPrivate(i,\"stream\");@assert(b!==@undefined),@assert(@getByIdDirectPrivate(b,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(i),@writableStreamStartErroring(b,h)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (h,b){\"use strict\";const i=@getByIdDirectPrivate(h,\"stream\");@assert(i!==@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(h),@writableStreamStartErroring(i,b)})\n"; // writableStreamDefaultControllerErrorIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility = 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,v){\"use strict\";const i=@getByIdDirectPrivate(d,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(i),@getByIdDirectPrivate(d,\"writeAlgorithm\").@call(@undefined,v).@then(()=>{@writableStreamFinishInFlightWrite(i);const _=@getByIdDirectPrivate(i,\"state\");if(@assert(_===\"writable\"||_===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(d,\"queue\")),!@writableStreamCloseQueuedOrInFlight(i)&&_===\"writable\"){const q=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(i,q)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)},(_)=>{if(@getByIdDirectPrivate(i,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(d);@writableStreamFinishInFlightWriteWithError(i,_)})})\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,B,D){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),B,D);const y=@getByIdDirectPrivate(d,\"stream\"),I=@getByIdDirectPrivate(y,\"state\");if(!@writableStreamCloseQueuedOrInFlight(y)&&I===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(y,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)}catch(y){@writableStreamDefaultControllerErrorIfNeeded(d,y)}})\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 (j,q,v,x,B,D,E){\"use strict\";if(x===@undefined)x=1;if(B===@undefined)B=()=>1;if(D===@undefined)D=0;if(E===@undefined)E=()=>1;@assert(x>=0),@assert(D>=0);const F={};@putByIdDirectPrivate(F,\"TransformStream\",!0);const G=new @TransformStream(F),I=@newPromiseCapability(@Promise);@initializeTransformStream(G,I.@promise,x,B,D,E);const _=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(G,_,q,v),j().@then(()=>{I.@resolve.@call()},(c)=>{I.@reject.@call(@undefined,c)}),G})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (D,E,F,_,j,c,q){\"use strict\";if(_===@undefined)_=1;if(j===@undefined)j=()=>1;if(c===@undefined)c=0;if(q===@undefined)q=()=>1;@assert(_>=0),@assert(c>=0);const B={};@putByIdDirectPrivate(B,\"TransformStream\",!0);const v=new @TransformStream(B),x=@newPromiseCapability(@Promise);@initializeTransformStream(v,x.@promise,_,j,c,q);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(v,G,E,F),D().@then(()=>{x.@resolve.@call()},(I)=>{x.@reject.@call(@undefined,I)}),v})\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 (f,G,B,T,C,F){\"use strict\";const I=()=>{return G},J=(x)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,x)},K=(x)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,x)},j=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},L=@createWritableStream(I,J,j,K,B,T),N=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},q=(x)=>{return @transformStreamErrorWritableAndUnblockWrite(f,x),@Promise.@resolve()},D={};@putByIdDirectPrivate(D,\"start\",I),@putByIdDirectPrivate(D,\"pull\",N),@putByIdDirectPrivate(D,\"cancel\",q);const E={};@putByIdDirectPrivate(E,\"size\",F),@putByIdDirectPrivate(E,\"highWaterMark\",C);const v=new @ReadableStream(D,E);@putByIdDirectPrivate(f,\"writable\",L),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(L)),@putByIdDirectPrivate(f,\"readable\",v),@putByIdDirectPrivate(f,\"backpressure\",@undefined),@putByIdDirectPrivate(f,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(f,!0),@putByIdDirectPrivate(f,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (f,x,C,D,E,F){\"use strict\";const q=()=>{return x},G=(B)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,B)},I=(B)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,B)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},v=@createWritableStream(q,G,J,I,C,D),K=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},L=(B)=>{return @transformStreamErrorWritableAndUnblockWrite(f,B),@Promise.@resolve()},T={};@putByIdDirectPrivate(T,\"start\",q),@putByIdDirectPrivate(T,\"pull\",K),@putByIdDirectPrivate(T,\"cancel\",L);const j={};@putByIdDirectPrivate(j,\"size\",F),@putByIdDirectPrivate(j,\"highWaterMark\",E);const N=new @ReadableStream(T,j);@putByIdDirectPrivate(f,\"writable\",v),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(v)),@putByIdDirectPrivate(f,\"readable\",N),@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; @@ -526,7 +526,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritabl const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength = 339; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (_,o){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(_,\"controller\"));const n=@getByIdDirectPrivate(_,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(n,\"controller\"),o),@getByIdDirectPrivate(_,\"backpressure\"))@transformStreamSetBackpressure(_,!1)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (_,n){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(_,\"controller\"));const o=@getByIdDirectPrivate(_,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(o,\"controller\"),n),@getByIdDirectPrivate(_,\"backpressure\"))@transformStreamSetBackpressure(_,!1)})\n"; // transformStreamSetBackpressure const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 443; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,d,p){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in p)b=(q)=>{return @promiseInvokeOrNoopMethod(d,p.transform,[q,v])};if(\"flush\"in p)j=()=>{return @promiseInvokeOrNoopMethod(d,p.flush,[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (q,v,_){\"use strict\";const d=new @TransformStreamDefaultController;let b=(p)=>{try{@transformStreamDefaultControllerEnqueue(d,p)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in _)b=(p)=>{return @promiseInvokeOrNoopMethod(v,_.transform,[p,d])};if(\"flush\"in _)j=()=>{return @promiseInvokeOrNoopMethod(v,_.flush,[d])};@setUpTransformStreamDefaultController(q,d,b,j)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = 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 (g,i){\"use strict\";const _=@getByIdDirectPrivate(g,\"stream\"),W=@getByIdDirectPrivate(_,\"readable\"),S=@getByIdDirectPrivate(W,\"readableStreamController\");if(@assert(S!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(S))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(S,i)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(_,j),@getByIdDirectPrivate(W,\"storedError\")}const f=!@readableStreamDefaultControllerShouldCallPull(S);if(f!==@getByIdDirectPrivate(_,\"backpressure\"))@assert(f),@transformStreamSetBackpressure(_,!0)})\n"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (d,g){\"use strict\";const _=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(d,\"transformAlgorithm\").@call(@undefined,g).@then(()=>{_.@resolve()},(f)=>{@transformStreamError(@getByIdDirectPrivate(d,\"stream\"),f),_.@reject.@call(@undefined,f)}),_.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -590,7 +590,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 367; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\"),f=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(f,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(_,u)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (f){\"use strict\";const i=@getByIdDirectPrivate(f,\"stream\"),k=@getByIdDirectPrivate(i,\"readable\"),_=@getByIdDirectPrivate(k,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(_))@readableStreamDefaultControllerClose(_);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(i,u)})\n"; // transformStreamDefaultSinkWriteAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = 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 q=@newPromiseCapability(@Promise),_=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(_!==@undefined),_.@promise.@then(()=>{const x=@getByIdDirectPrivate(f,\"state\");if(x===\"erroring\"){q.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(x===\"writable\"),@transformStreamDefaultControllerPerformTransform(j,v).@then(()=>{q.@resolve()},(z)=>{q.@reject.@call(@undefined,z)})},(x)=>{q.@reject.@call(@undefined,x)}),q.@promise}return @transformStreamDefaultControllerPerformTransform(j,v)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (d,j){\"use strict\";const f=@getByIdDirectPrivate(d,\"internalWritable\");@assert(@getByIdDirectPrivate(f,\"state\")===\"writable\");const q=@getByIdDirectPrivate(d,\"controller\");if(@getByIdDirectPrivate(d,\"backpressure\")){const _=@newPromiseCapability(@Promise),x=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(x!==@undefined),x.@promise.@then(()=>{const v=@getByIdDirectPrivate(f,\"state\");if(v===\"erroring\"){_.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(v===\"writable\"),@transformStreamDefaultControllerPerformTransform(q,j).@then(()=>{_.@resolve()},(z)=>{_.@reject.@call(@undefined,z)})},(v)=>{_.@reject.@call(@undefined,v)}),_.@promise}return @transformStreamDefaultControllerPerformTransform(q,j)})\n"; // transformStreamDefaultSinkAbortAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -606,7 +606,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkA const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength = 85; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode = "(function (t,d){\"use strict\";return @transformStreamError(t,d),@Promise.@resolve()})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode = "(function (d,t){\"use strict\";return @transformStreamError(d,t),@Promise.@resolve()})\n"; // transformStreamDefaultSinkCloseAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructAbility = 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 (f){\"use strict\";const _=@getByIdDirectPrivate(f,\"readable\"),q=@getByIdDirectPrivate(f,\"controller\"),j=@getByIdDirectPrivate(_,\"readableStreamController\"),k=@getByIdDirectPrivate(q,\"flushAlgorithm\");@assert(k!==@undefined);const u=@getByIdDirectPrivate(q,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(q);const I=@newPromiseCapability(@Promise);return u.@then(()=>{if(@getByIdDirectPrivate(_,\"state\")===@streamErrored){I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(j))@readableStreamDefaultControllerClose(j);I.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(q,\"stream\"),v),I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"))}),I.@promise})\n"; // transformStreamDefaultSourcePullAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -640,7 +640,7 @@ const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsBindingCodeLength = 473; static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsBindingCode = "(function (d){\"use strict\";if(d!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var l=globalThis.Symbol.for(\"process.bindings.constants\"),I=globalThis[l];if(!I){const{constants:r}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");I={fs:r,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[l]=I}return I})\n"; +const char* const s_processObjectInternalsBindingCode = "(function (I){\"use strict\";if(I!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var r=globalThis.Symbol.for(\"process.bindings.constants\"),l=globalThis[r];if(!l){const{constants:d}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");l={fs:d,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[r]=l}return l})\n"; // getStdioWriteStream const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4311; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (z){\"use strict\";var G=(U)=>{var V=@requireMap.get(U);if(V)return V.exports;return @internalRequire(U)},J={path:\"node:process\",require:G};function K(U){var{Duplex:V,eos:X,destroy:j}=G(\"node:stream\"),B=class Z extends V{#$;#G;#j=!0;#z=!0;#B;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(U)}get fd(){return U}constructor(Y){super({readable:!0,writable:!0});this.#B=`/dev/fd/${Y}`}#N(Y){const P=this.#H;if(this.#H=null,P)P(Y);else if(Y)this.destroy(Y);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Y,P){if(!Y&&this.#H!==null){var A=class D extends Error{code;name;constructor(H=\"The operation was aborted\",N=void 0){if(N!==void 0&&typeof N!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(N,null,2)}`);super(H,N);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Y=new A}if(this.#J=null,this.#K=null,this.#H===null)P(Y);else{if(this.#H=P,this.#$)j(this.#$,Y);if(this.#G)j(this.#G,Y)}}_write(Y,P,A){if(!this.#$){var{createWriteStream:D}=G(\"node:fs\"),H=this.#$=D(this.#B);H.on(\"finish\",()=>{if(this.#K){const N=this.#K;this.#K=null,N()}}),H.on(\"drain\",()=>{if(this.#J){const N=this.#J;this.#J=null,N()}}),X(H,(N)=>{if(this.#z=!1,N)j(H,N);this.#N(N)})}if(H.write(Y,P))A();else this.#J=A}_final(Y){this.#$&&this.#$.end(),this.#K=Y}#O(){var{createReadStream:Y}=G(\"node:fs\"),P=this.#G=Y(this.#B);return P.on(\"readable\",()=>{if(this.#L){const A=this.#L;this.#L=null,A()}else this.read()}),P.on(\"end\",()=>{this.push(null)}),X(P,(A)=>{if(this.#j=!1,A)j(P,A);this.#N(A)}),P}_read(){var Y=this.#G;if(!Y)Y=this.#O();while(!0){const P=Y.read();if(P===null||!this.push(P))return}}};return new B(U)}var{EventEmitter:L}=G(\"node:events\");function O(U){if(!U)return!0;var V=U.toLowerCase();return V===\"utf8\"||V===\"utf-8\"||V===\"buffer\"||V===\"binary\"}var M,Q=class U extends L{#$;#G;#j;#z;bytesWritten=0;setDefaultEncoding(V){if(this.#G||!O(V))return this.#J(),this.#G.setDefaultEncoding(V)}#B(){switch(this.#$){case 1:{var V=@Bun.stdout.writer({highWaterMark:0});return V.unref(),V}case 2:{var V=@Bun.stderr.writer({highWaterMark:0});return V.unref(),V}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#B()}constructor(V){super();this.#$=V}get fd(){return this.#$}get isTTY(){return this.#z\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(V,X,j){return(M\?\?=G(\"readline\")).cursorTo(this,V,X,j)}moveCursor(V,X,j){return(M\?\?=G(\"readline\")).moveCursor(this,V,X,j)}clearLine(V,X){return(M\?\?=G(\"readline\")).clearLine(this,V,X)}clearScreenDown(V){return(M\?\?=G(\"readline\")).clearScreenDown(this,V)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(V,X){if(V===\"close\"||V===\"finish\")return this.#J(),this.#G.on(V,X);if(V===\"drain\")return super.on(\"drain\",X);if(V===\"error\")return super.on(\"error\",X);return super.on(V,X)}get _writableState(){return this.#J(),this.#G._writableState}get _readableState(){return this.#J(),this.#G._readableState}pipe(V){return this.#J(),this.#G.pipe(V)}unpipe(V){return this.#J(),this.#G.unpipe(V)}#J(){if(this.#G)return;this.#G=K(this.#$);const V=this.eventNames();for(let X of V)this.#G.on(X,(...j)=>{this.emit(X,...j)})}#K(V){var X=this.#H();const j=X.write(V);this.bytesWritten+=j;const B=X.flush(!1);return!!(j||B)}#L(V,X){if(!O(X))return this.#J(),this.#G.write(V,X);return this.#K(V)}#M(V,X){if(X)this.emit(\"error\",X);try{V(X\?X:null)}catch(j){this.emit(\"error\",j)}}#N(V,X,j){if(!O(X))return this.#J(),this.#G.write(V,X,j);var B=this.#H();const Z=B.write(V),Y=B.flush(!0);if(Y\?.then)return Y.then(()=>{this.#M(j),this.emit(\"drain\")},(P)=>this.#M(j,P)),!1;return queueMicrotask(()=>{this.#M(j)}),!!(Z||Y)}write(V,X,j){const B=this._write(V,X,j);if(B)this.emit(\"drain\");return B}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(V,X,j){var B=this.#G;if(B)return B.write(V,X,j);switch(arguments.length){case 0:{var Z=new Error(\"Invalid arguments\");throw Z.code=\"ERR_INVALID_ARG_TYPE\",Z}case 1:return this.#K(V);case 2:if(typeof X===\"function\")return this.#N(V,\"\",X);else if(typeof X===\"string\")return this.#L(V,X);default:{if(typeof X!==\"undefined\"&&typeof X!==\"string\"||typeof j!==\"undefined\"&&typeof j!==\"function\"){var Z=new Error(\"Invalid arguments\");throw Z.code=\"ERR_INVALID_ARG_TYPE\",Z}if(typeof j===\"undefined\")return this.#L(V,X);return this.#N(V,X,j)}}}destroy(){return this}end(){return this}};return new Q(z)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (Z){\"use strict\";var L=(M)=>{var G=@requireMap.get(M);if(G)return G.exports;return @internalRequire(M)},D={path:\"node:process\",require:L};function Y(M){var{Duplex:G,eos:j,destroy:z}=L(\"node:stream\"),J=class O extends G{#j;#$;#M=!0;#N=!0;#J;#z;#G;#B;#H;#K;get isTTY(){return this.#K\?\?=L(\"node:tty\").isatty(M)}get fd(){return M}constructor(B){super({readable:!0,writable:!0});this.#J=`/dev/fd/${B}`}#L(B){const H=this.#z;if(this.#z=null,H)H(B);else if(B)this.destroy(B);else if(!this.#M&&!this.#N)this.destroy()}_destroy(B,H){if(!B&&this.#z!==null){var N=class X extends Error{code;name;constructor(Q=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(Q,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};B=new N}if(this.#G=null,this.#B=null,this.#z===null)H(B);else{if(this.#z=H,this.#j)z(this.#j,B);if(this.#$)z(this.#$,B)}}_write(B,H,N){if(!this.#j){var{createWriteStream:X}=L(\"node:fs\"),Q=this.#j=X(this.#J);Q.on(\"finish\",()=>{if(this.#B){const K=this.#B;this.#B=null,K()}}),Q.on(\"drain\",()=>{if(this.#G){const K=this.#G;this.#G=null,K()}}),j(Q,(K)=>{if(this.#N=!1,K)z(Q,K);this.#L(K)})}if(Q.write(B,H))N();else this.#G=N}_final(B){this.#j&&this.#j.end(),this.#B=B}#O(){var{createReadStream:B}=L(\"node:fs\"),H=this.#$=B(this.#J);return H.on(\"readable\",()=>{if(this.#H){const N=this.#H;this.#H=null,N()}else this.read()}),H.on(\"end\",()=>{this.push(null)}),j(H,(N)=>{if(this.#M=!1,N)z(H,N);this.#L(N)}),H}_read(){var B=this.#$;if(!B)B=this.#O();while(!0){const H=B.read();if(H===null||!this.push(H))return}}};return new J(M)}var{EventEmitter:P}=L(\"node:events\");function V(M){if(!M)return!0;var G=M.toLowerCase();return G===\"utf8\"||G===\"utf-8\"||G===\"buffer\"||G===\"binary\"}var U,A=class M extends P{#j;#$;#M;#N;bytesWritten=0;setDefaultEncoding(G){if(this.#$||!V(G))return this.#G(),this.#$.setDefaultEncoding(G)}#J(){switch(this.#j){case 1:{var G=@Bun.stdout.writer({highWaterMark:0});return G.unref(),G}case 2:{var G=@Bun.stderr.writer({highWaterMark:0});return G.unref(),G}default:throw new Error(\"Unsupported writer\")}}#z(){return this.#M\?\?=this.#J()}constructor(G){super();this.#j=G}get fd(){return this.#j}get isTTY(){return this.#N\?\?=L(\"node:tty\").isatty(this.#j)}cursorTo(G,j,z){return(U\?\?=L(\"readline\")).cursorTo(this,G,j,z)}moveCursor(G,j,z){return(U\?\?=L(\"readline\")).moveCursor(this,G,j,z)}clearLine(G,j){return(U\?\?=L(\"readline\")).clearLine(this,G,j)}clearScreenDown(G){return(U\?\?=L(\"readline\")).clearScreenDown(this,G)}ref(){this.#z().ref()}unref(){this.#z().unref()}on(G,j){if(G===\"close\"||G===\"finish\")return this.#G(),this.#$.on(G,j);if(G===\"drain\")return super.on(\"drain\",j);if(G===\"error\")return super.on(\"error\",j);return super.on(G,j)}get _writableState(){return this.#G(),this.#$._writableState}get _readableState(){return this.#G(),this.#$._readableState}pipe(G){return this.#G(),this.#$.pipe(G)}unpipe(G){return this.#G(),this.#$.unpipe(G)}#G(){if(this.#$)return;this.#$=Y(this.#j);const G=this.eventNames();for(let j of G)this.#$.on(j,(...z)=>{this.emit(j,...z)})}#B(G){var j=this.#z();const z=j.write(G);this.bytesWritten+=z;const J=j.flush(!1);return!!(z||J)}#H(G,j){if(!V(j))return this.#G(),this.#$.write(G,j);return this.#B(G)}#K(G,j){if(j)this.emit(\"error\",j);try{G(j\?j:null)}catch(z){this.emit(\"error\",z)}}#L(G,j,z){if(!V(j))return this.#G(),this.#$.write(G,j,z);var J=this.#z();const O=J.write(G),B=J.flush(!0);if(B\?.then)return B.then(()=>{this.#K(z),this.emit(\"drain\")},(H)=>this.#K(z,H)),!1;return queueMicrotask(()=>{this.#K(z)}),!!(O||B)}write(G,j,z){const J=this._write(G,j,z);if(J)this.emit(\"drain\");return J}get hasColors(){return @Bun.tty[this.#j].hasColors}_write(G,j,z){var J=this.#$;if(J)return J.write(G,j,z);switch(arguments.length){case 0:{var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}case 1:return this.#B(G);case 2:if(typeof j===\"function\")return this.#L(G,\"\",j);else if(typeof j===\"string\")return this.#H(G,j);default:{if(typeof j!==\"undefined\"&&typeof j!==\"string\"||typeof z!==\"undefined\"&&typeof z!==\"function\"){var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}if(typeof z===\"undefined\")return this.#H(G,j);return this.#L(G,j,z)}}}destroy(){return this}end(){return this}};return new A(Z)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -656,7 +656,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructor const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdinStreamCodeLength = 1861; static const JSC::Intrinsic s_processObjectInternalsGetStdinStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdinStreamCode = "(function (N){\"use strict\";var j=(J)=>{var K=@requireMap.get(J);if(K)return K.exports;return @internalRequire(J)},z={path:\"node:process\",require:j},{Duplex:B,eos:G,destroy:H}=j(\"node:stream\"),I=class J extends B{#$;#N;#j;#z=!0;#B=!1;#G=!0;#H;#I;#J;get isTTY(){return j(\"tty\").isatty(N)}get fd(){return N}constructor(){super({readable:!0,writable:!0})}#K(K){const L=this.#I;if(this.#I=null,L)L(K);else if(K)this.destroy(K);else if(!this.#z&&!this.#G)this.destroy()}_destroy(K,L){if(!K&&this.#I!==null){var M=class P extends Error{constructor(Q=\"The operation was aborted\",T=void 0){if(T!==void 0&&typeof T!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(T,null,2)}`);super(Q,T);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};K=new M}if(this.#I===null)L(K);else if(this.#I=L,this.#j)H(this.#j,K)}setRawMode(K){}on(K,L){if(K===\"readable\")this.ref(),this.#B=!0;return super.on(K,L)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#$\?\?=@Bun.stdin.stream().getReader(),this.#N\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#N)clearInterval(this.#N),this.#N=null}async#L(){try{var K,L;const M=this.#$.readMany();if(!M\?.then)({done:K,value:L}=M);else({done:K,value:L}=await M);if(!K){this.push(L[0]);const P=L.length;for(let Q=1;Q{if(this.#H){const M=this.#H;this.#H=null,M()}}),L.on(\"drain\",()=>{if(this.#J){const M=this.#J;this.#J=null,M()}}),G(L,(M)=>{if(this.#G=!1,M)H(L,M);this.#K(M)}),L}_write(K,L,M){var P=this.#j;if(!P)P=this.#M();if(P.write(K,L))M();else this.#J=M}_final(K){this.#j.end(),this.#H=(...L)=>K(...L)}};return new I})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (K){\"use strict\";var H=(I)=>{var N=@requireMap.get(I);if(N)return N.exports;return @internalRequire(I)},T={path:\"node:process\",require:H},{Duplex:M,eos:P,destroy:L}=H(\"node:stream\"),Q=class I extends M{#J;#j;#$;#G=!0;#H=!1;#K=!0;#z;#N;#B;get isTTY(){return H(\"tty\").isatty(K)}get fd(){return K}constructor(){super({readable:!0,writable:!0})}#I(N){const j=this.#N;if(this.#N=null,j)j(N);else if(N)this.destroy(N);else if(!this.#G&&!this.#K)this.destroy()}_destroy(N,j){if(!N&&this.#N!==null){var z=class B extends Error{constructor(G=\"The operation was aborted\",J=void 0){if(J!==void 0&&typeof J!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(J,null,2)}`);super(G,J);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new z}if(this.#N===null)j(N);else if(this.#N=j,this.#$)L(this.#$,N)}setRawMode(N){}on(N,j){if(N===\"readable\")this.ref(),this.#H=!0;return super.on(N,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#J\?\?=@Bun.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#L(){try{var N,j;const z=this.#J.readMany();if(!z\?.then)({done:N,value:j}=z);else({done:N,value:j}=await z);if(!N){this.push(j[0]);const B=j.length;for(let G=1;G{if(this.#z){const z=this.#z;this.#z=null,z()}}),j.on(\"drain\",()=>{if(this.#B){const z=this.#B;this.#B=null,z()}}),P(j,(z)=>{if(this.#K=!1,z)L(j,z);this.#I(z)}),j}_write(N,j,z){var B=this.#$;if(!B)B=this.#M();if(B.write(N,j))z();else this.#B=z}_final(N){this.#$.end(),this.#z=(...j)=>N(...j)}};return new Q})\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 = 1304; static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let j=arguments[0];if(@isObject(j)&&@getByIdDirectPrivate(j,\"TransformStream\"))return this;let q=arguments[1],v=arguments[2];if(j===@undefined)j=null;if(v===@undefined)v={};if(q===@undefined)q={};let x={};if(j!==null){if(\"start\"in j){if(x.start=j.start,typeof x.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in j){if(x.transform=j.transform,typeof x.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in j){if(x.flush=j.flush,typeof x.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in j)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in j)@throwRangeError(\"TransformStream transformer has a writableType\")}const B=@extractHighWaterMark(v,0),E=@extractSizeAlgorithm(v),F=@extractHighWaterMark(q,1),G=@extractSizeAlgorithm(q),I=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,I.@promise,F,G,B,E),@setUpTransformStreamDefaultControllerFromTransformer(this,j,x),(\"start\"in x)){const J=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(j,x.start,[J]))().@then(()=>{I.@resolve.@call()},(u)=>{I.@reject.@call(@undefined,u)})}else I.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let j=arguments[1],q=arguments[2];if(_===@undefined)_=null;if(q===@undefined)q={};if(j===@undefined)j={};let u={};if(_!==null){if(\"start\"in _){if(u.start=_.start,typeof u.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(u.transform=_.transform,typeof u.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(u.flush=_.flush,typeof u.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const x=@extractHighWaterMark(q,0),B=@extractSizeAlgorithm(q),E=@extractHighWaterMark(j,1),F=@extractSizeAlgorithm(j),v=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,v.@promise,E,F,x,B),@setUpTransformStreamDefaultControllerFromTransformer(this,_,u),(\"start\"in u)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,u.start,[G]))().@then(()=>{v.@resolve.@call()},(I)=>{v.@reject.@call(@undefined,I)})}else v.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (_){\"use strict\";const M=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(M)return @evaluateCommonJSModule(M),M.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=S.module,h=@Loader.getModuleNamespaceObject(b),r=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const f=@createCommonJSModule(_,{},!1);@requireMap.@set(_,f);var L=this.@require(_,f);if(L===-1){try{L=@requireESM(_)}catch(b){throw @requireMap.@delete(_),b}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=@Loader.getModuleNamespaceObject(S.module);return f.exports=b\?.[@commonJSSymbol]===0||b\?.default\?.[@commonJSSymbol]===0\?b.default:b.__esModule\?b:Object.create(b,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(f),f.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const b=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(b)return @evaluateCommonJSModule(b),b.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=S.module,f=@Loader.getModuleNamespaceObject(M),r=f\?.[@commonJSSymbol]===0||f\?.default\?.[@commonJSSymbol]===0\?f.default:f.__esModule\?f:Object.create(f,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const L=@createCommonJSModule(_,{},!1);@requireMap.@set(_,L);var h=this.@require(_,L);if(h===-1){try{h=@requireESM(_)}catch(M){throw @requireMap.@delete(_),M}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=@Loader.getModuleNamespaceObject(S.module);return L.exports=M\?.[@commonJSSymbol]===0||M\?.default\?.[@commonJSSymbol]===0\?M.default:M.__esModule\?M:Object.create(M,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,u){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(u){case 1:return r.getInt8(d);case 2:return r.getInt16(d,!0);case 3:{const _=r.getUint16(d,!0)+r.getUint8(d+2)*65536;return _|(_&8388608)*510}case 4:return r.getInt32(d,!0);case 5:{const _=r.getUint8(d+4);return(_|(_&128)*33554430)*4294967296+r.getUint32(d,!0)}case 6:{const _=r.getUint16(d+4,!0);return(_|(_&32768)*131070)*4294967296+r.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -838,7 +838,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntBECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,d){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return u.getInt8(r);case 2:return u.getInt16(r,!1);case 3:{const c=u.getUint16(r+1,!1)+u.getUint8(r)*65536;return c|(c&8388608)*510}case 4:return u.getInt32(r,!1);case 5:{const c=u.getUint8(r);return(c|(c&128)*33554430)*4294967296+u.getUint32(r+1,!1)}case 6:{const c=u.getUint16(r,!1);return(c|(c&32768)*131070)*4294967296+u.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:return d.getInt8(r);case 2:return d.getInt16(r,!1);case 3:{const u=d.getUint16(r+1,!1)+d.getUint8(r)*65536;return u|(u&8388608)*510}case 4:return d.getInt32(r,!1);case 5:{const u=d.getUint8(r);return(u|(u&128)*33554430)*4294967296+d.getUint32(r+1,!1)}case 6:{const u=d.getUint16(r,!1);return(u|(u&32768)*131070)*4294967296+d.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntLE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -846,7 +846,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntLECodeLength = 445; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,d){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return r.getUint8(a);case 2:return r.getUint16(a,!0);case 3:return r.getUint16(a,!0)+r.getUint8(a+2)*65536;case 4:return r.getUint32(a,!0);case 5:return r.getUint8(a+4)*4294967296+r.getUint32(a,!0);case 6:return r.getUint16(a+4,!0)*4294967296+r.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,r){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return d.getUint8(a);case 2:return d.getUint16(a,!0);case 3:return d.getUint16(a,!0)+d.getUint8(a+2)*65536;case 4:return d.getUint32(a,!0);case 5:return d.getUint8(a+4)*4294967296+d.getUint32(a,!0);case 6:return d.getUint16(a+4,!0)*4294967296+d.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -854,7 +854,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntBECodeLength = 504; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,r){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return c.getUint8(d);case 2:return c.getUint16(d,!1);case 3:return c.getUint16(d+1,!1)+c.getUint8(d)*65536;case 4:return c.getUint32(d,!1);case 5:{const p=c.getUint8(d);return(p|(p&128)*33554430)*4294967296+c.getUint32(d+1,!1)}case 6:{const p=c.getUint16(d,!1);return(p|(p&32768)*131070)*4294967296+c.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,p){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:return r.getUint8(d);case 2:return r.getUint16(d,!1);case 3:return r.getUint16(d+1,!1)+r.getUint8(d)*65536;case 4:return r.getUint32(d,!1);case 5:{const c=r.getUint8(d);return(c|(c&128)*33554430)*4294967296+r.getUint32(d+1,!1)}case 6:{const c=r.getUint16(d,!1);return(c|(c&32768)*131070)*4294967296+r.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readFloatLE const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -926,7 +926,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt8CodeLength = 131; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt8Code = "(function (d,r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(r,d),r+1})\n"; +const char* const s_jsBufferPrototypeWriteInt8Code = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(d,r),d+1})\n"; // writeUInt8 const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -934,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(d,c),d+1})\n"; +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"; // writeInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -942,7 +942,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt16LECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!0),d+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!0),c+2})\n"; // writeInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -950,7 +950,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt16BECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!1),d+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!1),c+2})\n"; // writeUInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -958,7 +958,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt16LECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!0),d+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!0),c+2})\n"; // writeUInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -966,7 +966,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt16BECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!1),d+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!1),c+2})\n"; // writeInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -974,7 +974,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt32LECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!0),c+4})\n"; // writeInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -982,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; @@ -990,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!0),d+4})\n"; +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"; // writeUInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -998,7 +998,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt32BECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(c,d,!1),c+4})\n"; // writeIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1006,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 (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"; +const char* const s_jsBufferPrototypeWriteIntLECode = "(function (r,d,j){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(j){case 1:{c.setInt8(d,r);break}case 2:{c.setInt16(d,r,!0);break}case 3:{c.setUint16(d,r&65535,!0),c.setInt8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{c.setInt32(d,r,!0);break}case 5:{c.setUint32(d,r|0,!0),c.setInt8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{c.setUint32(d,r|0,!0),c.setInt16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+j})\n"; // writeIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1014,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 (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"; +const char* const s_jsBufferPrototypeWriteIntBECode = "(function (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setInt8(d,r);break}case 2:{E.setInt16(d,r,!1);break}case 3:{E.setUint16(d+1,r&65535,!1),E.setInt8(d,Math.floor(r*0.0000152587890625));break}case 4:{E.setInt32(d,r,!1);break}case 5:{E.setUint32(d+1,r|0,!1),E.setInt8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d+2,r|0,!1),E.setInt16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\n"; // writeUIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1022,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,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"; +const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setUint8(d,r);break}case 2:{E.setUint16(d,r,!0);break}case 3:{E.setUint16(d,r&65535,!0),E.setUint8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{E.setUint32(d,r,!0);break}case 5:{E.setUint32(d,r|0,!0),E.setUint8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d,r|0,!0),E.setUint16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\n"; // writeUIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1030,7 +1030,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntBECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (d,r,p){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:{_.setUint8(r,d);break}case 2:{_.setUint16(r,d,!1);break}case 3:{_.setUint16(r+1,d&65535,!1),_.setUint8(r,Math.floor(d*0.0000152587890625));break}case 4:{_.setUint32(r,d,!1);break}case 5:{_.setUint32(r+1,d|0,!1),_.setUint8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{_.setUint32(r+2,d|0,!1),_.setUint16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+p})\n"; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (r,d,_){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{p.setUint8(d,r);break}case 2:{p.setUint16(d,r,!1);break}case 3:{p.setUint16(d+1,r&65535,!1),p.setUint8(d,Math.floor(r*0.0000152587890625));break}case 4:{p.setUint32(d,r,!1);break}case 5:{p.setUint32(d+1,r|0,!1),p.setUint8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{p.setUint32(d+2,r|0,!1),p.setUint16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+_})\n"; // writeFloatLE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1038,7 +1038,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!0),c+4})\n"; // writeFloatBE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1046,7 +1046,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!1),c+4})\n"; // writeDoubleLE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1054,7 +1054,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteDoubleLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!0),c+8})\n"; // writeDoubleBE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1062,7 +1062,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteDoubleBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!1),c+8})\n"; // writeBigInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1070,7 +1070,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigInt64LECodeLength = 138; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,d,!0),c+8})\n"; // writeBigInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1078,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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!1),d+8})\n"; +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"; // writeBigUInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1086,7 +1086,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKin const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigUInt64LECodeLength = 139; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!0),c+8})\n"; // writeBigUInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1094,7 +1094,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKin const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigUInt64BECodeLength = 139; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!1),c+8})\n"; // utf8Write const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1118,7 +1118,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf16leWriteCodeLength = 68; static const JSC::Intrinsic s_jsBufferPrototypeUtf16leWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (r,d,a){\"use strict\";return this.write(r,d,a,\"utf16le\")})\n"; +const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (d,r,a){\"use strict\";return this.write(d,r,a,\"utf16le\")})\n"; // latin1Write const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (i,q){\"use strict\";var{buffer:c,byteOffset:v,byteLength:p}=this;function w(z,m){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=m,z>0\?z:0;else return zk\?x-k:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (w,m){\"use strict\";var{buffer:x,byteOffset:z,byteLength:p}=this;function q(c,k){if(c=@trunc(c),c===0||@isNaN(c))return 0;else if(c<0)return c+=k,c>0\?c:0;else return ci\?v-i:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,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 a=@getByIdDirectPrivate(this,\"byobRequest\");if(a===@undefined){var l=@getByIdDirectPrivate(this,\"pendingPullIntos\");const _=l.peek();if(_){const m=new @Uint8Array(_.buffer,_.byteOffset+_.bytesFilled,_.byteLength-_.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,m,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,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 w=async function*_(){var G=@Bun.stdin.stream().getReader(),B=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),H,J=@Bun.indexOfLine;try{while(!0){var j,D,K;const q=G.readMany();if(@isPromise(q))({done:j,value:D}=await q);else({done:j,value:D}=q);if(j){if(K)yield B.decode(K);return}var m;for(let M of D){if(m=M,K)m=@Buffer.concat([K,M]),K=null;var L=0,F=J(m,L);while(F!==-1)yield B.decode(m.subarray(L,F)),L=F+1,F=J(m,L);K=m.subarray(L)}}}catch(q){H=q}finally{if(G.releaseLock(),H)throw H}},z=globalThis.Symbol.asyncIterator;return this[z]=w,w()})\n"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const D=async function*L(){var F=@Bun.stdin.stream().getReader(),G=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),z,H=@Bun.indexOfLine;try{while(!0){var A,B,w;const m=F.readMany();if(@isPromise(m))({done:A,value:B}=await m);else({done:A,value:B}=m);if(A){if(w)yield G.decode(w);return}var _;for(let J of B){if(_=J,w)_=@Buffer.concat([w,J]),w=null;var j=0,q=H(_,j);while(q!==-1)yield G.decode(_.subarray(j,q)),j=q+1,q=H(_,j);w=_.subarray(j)}}}catch(m){z=m}finally{if(F.releaseLock(),z)throw z}},K=globalThis.Symbol.asyncIterator;return this[K]=D,D()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (d){\"use strict\";var _=@getByIdDirectPrivate(this,\"writer\");if(!_){var b=@toLength(d\?.length\?\?0);_=@Bun.stdout.writer({highWaterMark:b>65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",a)}var c=a.write(_);const f=@argumentCount();for(var d=1;d{},(c)=>{h.error(c)});function S(){@readableStreamDefaultReaderRead(y).@then(function(c){if(c.done){h.close();return}try{h.enqueue(c.value)}catch(g){h.error(\"ReadableStream chunk enqueueing in the sink failed\");return}S()},function(c){h.error(c)})}S()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (g,c){\"use strict\";@assert(@isReadableStream(g));const h=new @ReadableStreamDefaultReader(g);@getByIdDirectPrivate(h,\"closedPromiseCapability\").@promise.@then(()=>{},(_)=>{c.error(_)});function y(){@readableStreamDefaultReaderRead(h).@then(function(_){if(_.done){c.close();return}try{c.enqueue(_.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(_){c.error(_)})}y()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1404,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 (b,v,_,w,f,x,j){\"use strict\";const B=new @ReadableStreamDefaultController(b,v,_,w,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(v,x,[B]),q=(D)=>@promiseInvokeOrNoopMethod(v,j,[D]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",q),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (b,f,j,q,D,v,w){\"use strict\";const _=new @ReadableStreamDefaultController(b,f,j,q,@isReadableStream),x=()=>@promiseInvokeOrNoopMethod(f,v,[_]),B=(C)=>@promiseInvokeOrNoopMethod(f,w,[C]);@putByIdDirectPrivate(_,\"pullAlgorithm\",x),@putByIdDirectPrivate(_,\"cancelAlgorithm\",B),@putByIdDirectPrivate(_,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(_,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",_),@readableStreamDefaultControllerStart(_)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,b)}else if(A===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (w,v,f){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(f.highWaterMark===@undefined)f.highWaterMark=0;if(f.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(w,\"readableStreamController\",new @ReadableByteStreamController(w,v,f.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=f\?.highWaterMark;@initializeArrayBufferStream.@call(w,v,b)}else if(A===@undefined){if(f.highWaterMark===@undefined)f.highWaterMark=1;@setupReadableStreamDefaultController(w,v,f.size,f.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,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,D,E,T,k){\"use strict\";if(@assert(@isReadableStream(_)),@assert(@isWritableStream(f)),@assert(!@isReadableStreamLocked(_)),@assert(!@isWritableStreamLocked(f)),@assert(k===@undefined||@isAbortSignal(k)),@getByIdDirectPrivate(_,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let q={source:_,destination:f,preventAbort:E,preventCancel:T,preventClose:D,signal:k};if(q.reader=@acquireReadableStreamDefaultReader(_),q.writer=@acquireWritableStreamDefaultWriter(f),@putByIdDirectPrivate(_,\"disturbed\",!0),q.finalized=!1,q.shuttingDown=!1,q.promiseCapability=@newPromiseCapability(@Promise),q.pendingReadPromiseCapability=@newPromiseCapability(@Promise),q.pendingReadPromiseCapability.@resolve.@call(),q.pendingWritePromise=@Promise.@resolve(),k!==@undefined){const w=(x)=>{if(q.finalized)return;@pipeToShutdownWithAction(q,()=>{const B=!q.preventAbort&&@getByIdDirectPrivate(q.destination,\"state\")===\"writable\"\?@writableStreamAbort(q.destination,x):@Promise.@resolve(),G=!q.preventCancel&&@getByIdDirectPrivate(q.source,\"state\")===@streamReadable\?@readableStreamCancel(q.source,x):@Promise.@resolve();let H=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}H.@resolve.@call()},K=(L)=>{H.@reject.@call(@undefined,L)};return B.@then(J,K),G.@then(J,K),H.@promise},x)};if(@whenSignalAborted(k,w))return q.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(q),@pipeToErrorsMustBePropagatedBackward(q),@pipeToClosingMustBePropagatedForward(q),@pipeToClosingMustBePropagatedBackward(q),@pipeToLoop(q),q.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (f,E,z,B,F,D){\"use strict\";if(@assert(@isReadableStream(f)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(f)),@assert(!@isWritableStreamLocked(E)),@assert(D===@undefined||@isAbortSignal(D)),@getByIdDirectPrivate(f,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:f,destination:E,preventAbort:B,preventCancel:F,preventClose:z,signal:D};if(_.reader=@acquireReadableStreamDefaultReader(f),_.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(f,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),D!==@undefined){const G=(T)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const H=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,T):@Promise.@resolve(),I=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,T):@Promise.@resolve();let k=@newPromiseCapability(@Promise),q=!0,w=()=>{if(q){q=!1;return}k.@resolve.@call()},x=(J)=>{k.@reject.@call(@undefined,J)};return H.@then(w,x),I.@then(w,x),k.@promise},T)};if(@whenSignalAborted(D,G))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1452,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 (_){\"use strict\";const d=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,b),b);return}@pipeToShutdown(_,b)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){d();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,d)})\n"; // pipeToErrorsMustBePropagatedBackward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1460,7 +1460,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagated const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength = 369; static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const h=()=>{const y=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,y),y);return}@pipeToShutdown(m,y)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){h();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,h)})\n"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const y=()=>{const h=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,h),h);return}@pipeToShutdown(m,h)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){y();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,y)})\n"; // pipeToClosingMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,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){\"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"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (_,d){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const g=arguments.length>2,h=arguments[2],m=()=>{d().@then(()=>{if(g)@pipeToFinalize(_,h);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(m,m)},(b)=>@pipeToFinalize(_,b));return}m()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1492,7 +1492,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownCodeLength = 411; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const d=arguments.length>1,m=arguments[1],u=()=>{if(d)@pipeToFinalize(_,m);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(I)=>@pipeToFinalize(_,I));return}u()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,u=arguments[1],d=()=>{if(m)@pipeToFinalize(_,u);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(d,d)},(I)=>@pipeToFinalize(_,I));return}d()})\n"; // pipeToFinalize const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,f){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof f===\"boolean\");var g=@getByIdDirectPrivate(_,\"start\");if(g)@putByIdDirectPrivate(_,\"start\",@undefined),g();const j=new @ReadableStreamDefaultReader(_),k={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};k.cancelPromiseCapability=@newPromiseCapability(@Promise);const q=@readableStreamTeePullFunction(k,j,f),v={};@putByIdDirectPrivate(v,\"pull\",q),@putByIdDirectPrivate(v,\"cancel\",@readableStreamTeeBranch1CancelFunction(k,_));const w={};@putByIdDirectPrivate(w,\"pull\",q),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(k,_));const x=new @ReadableStream(v),y=new @ReadableStream(w);return @getByIdDirectPrivate(j,\"closedPromiseCapability\").@promise.@then(@undefined,function(i){if(k.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,i),@readableStreamDefaultControllerError(y.@readableStreamController,i),k.closedOrErrored=!0,!k.canceled1||!k.canceled2)k.cancelPromiseCapability.@resolve.@call()}),k.branch1=x,k.branch2=y,[x,y]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,q){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof q===\"boolean\");var v=@getByIdDirectPrivate(_,\"start\");if(v)@putByIdDirectPrivate(_,\"start\",@undefined),v();const w=new @ReadableStreamDefaultReader(_),i={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};i.cancelPromiseCapability=@newPromiseCapability(@Promise);const x=@readableStreamTeePullFunction(i,w,q),f={};@putByIdDirectPrivate(f,\"pull\",x),@putByIdDirectPrivate(f,\"cancel\",@readableStreamTeeBranch1CancelFunction(i,_));const g={};@putByIdDirectPrivate(g,\"pull\",x),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch2CancelFunction(i,_));const j=new @ReadableStream(f),k=new @ReadableStream(g);return @getByIdDirectPrivate(w,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(i.closedOrErrored)return;if(@readableStreamDefaultControllerError(j.@readableStreamController,y),@readableStreamDefaultControllerError(k.@readableStreamController,y),i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}),i.branch1=j,i.branch2=k,[j,k]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,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; @@ -1564,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 (_,x,f){\"use strict\";@putByIdDirectPrivate(_,\"underlyingSource\",@undefined),@putByIdDirectPrivate(_,\"start\",@undefined);function j(v,A){if(A&&f\?.cancel){try{var w=f.cancel(A);@markPromiseAsHandled(w)}catch(B){}f=@undefined}if(v){if(@putByIdDirectPrivate(v,\"readableStreamController\",@undefined),@putByIdDirectPrivate(v,\"reader\",@undefined),A)@putByIdDirectPrivate(v,\"state\",@streamErrored),@putByIdDirectPrivate(v,\"storedError\",A);else @putByIdDirectPrivate(v,\"state\",@streamClosed);v=@undefined}}if(!f.pull){j();return}if(!@isCallable(f.pull)){j(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(_,\"readableStreamController\",x);const q=@getByIdDirectPrivate(_,\"highWaterMark\");x.start({highWaterMark:!q||q<64\?64:q}),@startDirectStream.@call(x,_,f.pull,j),@putByIdDirectPrivate(_,\"reader\",{});var z=f.pull(x);if(x=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (j,q,_){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function w(f,v){if(v&&_\?.cancel){try{var A=_.cancel(v);@markPromiseAsHandled(A)}catch(B){}_=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),v)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",v);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!_.pull){w();return}if(!@isCallable(_.pull)){w(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",q);const x=@getByIdDirectPrivate(j,\"highWaterMark\");q.start({highWaterMark:!x||x<64\?64:x}),@startDirectStream.@call(q,j,_.pull,w),@putByIdDirectPrivate(j,\"reader\",{});var z=_.pull(q);if(q=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,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,F,f){\"use strict\";var I=!1,D=!1;try{var E=c.getReader(),G=E.readMany();if(G&&@isPromise(G))G=await G;if(G.done)return I=!0,F.end();var H=G.value.length;const x=@getByIdDirectPrivate(c,\"highWaterMark\");if(f)@startDirectStream.@call(F,c,@undefined,()=>!D&&@markPromiseAsHandled(c.cancel()));F.start({highWaterMark:x||0});for(var J=0,P=G.value,z=G.value.length;J!B&&@markPromiseAsHandled(_.cancel()));c.start({highWaterMark:q||0});for(var D=0,F=f.value,G=f.value.length;D{var j=@createFulfilledPromise({value:v,done:!1});return v=@undefined,@readableStreamClose(b),b=@undefined,j}}else if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(y,{value:@undefined,done:!0})}@readableStreamClose(b)})\n"; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (S){\"use strict\";var c=this.@controlledReadableStream;if(!c||@getByIdDirectPrivate(c,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=S;return}if(@putByIdDirectPrivate(c,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,S)}catch(b){}var v;try{v=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(b){if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(y,b)}@readableStreamError(c,b);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var B=@getByIdDirectPrivate(c,\"reader\");if(B&&@isReadableStreamDefaultReader(B)){var C=this._pendingRead;if(C&&@isPromise(C)&&v\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(C,{value:v,done:!1}),@readableStreamClose(c);return}}if(v\?.byteLength){var j=@getByIdDirectPrivate(B,\"readRequests\");if(j\?.isNotEmpty()){@readableStreamFulfillReadRequest(c,v,!1),@readableStreamClose(c);return}@putByIdDirectPrivate(c,\"state\",@streamReadable),this.@pull=()=>{var b=@createFulfilledPromise({value:v,done:!1});return v=@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"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var i=this.@sink.flush();if(i\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:i,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var i=this.@sink.flush();if(i\?.byteLength)@readableStreamFulfillReadRequest(c,i,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var B=this.@controlledReadableStream,i=@getByIdDirectPrivate(B,\"reader\");if(!i||!@isReadableStreamDefaultReader(i))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var c=this.@sink.flush();if(c\?.byteLength)this._pendingRead=@getByIdDirectPrivate(B,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:c,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(B,\"readRequests\")\?.isNotEmpty()){var c=this.@sink.flush();if(c\?.byteLength)@readableStreamFulfillReadRequest(B,c,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,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 _,w=[],A=!1,C=!1,j=\"\",x=@toLength(0),E=@newPromiseCapability(@Promise),F=!1;return _={start(){},write(q){if(typeof q===\"string\"){var z=@toLength(q.length);if(z>0)j+=q,A=!0,x+=z;return z}if(!q||!(@ArrayBuffer.@isView(q)||q instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const G=@toLength(q.byteLength);if(G>0)if(C=!0,j.length>0)@arrayPush(w,j,q),j=\"\";else @arrayPush(w,q);return x+=G,G},flush(){return 0},end(){if(F)return\"\";return _.fulfill()},fulfill(){F=!0;const q=_.finishInternal();return @fulfillPromise(E.@promise,q),q},finishInternal(){if(!A&&!C)return\"\";if(A&&!C)return j;if(C&&!A)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(w));var q=new @Bun.ArrayBufferSink;q.start({highWaterMark:x,asUint8Array:!0});for(let z of w)q.write(z);if(w.length=0,j.length>0)q.write(j),j=\"\";return new globalThis.TextDecoder().decode(q.end())},close(){try{if(!F)F=!0,_.fulfill()}catch(q){}}},[_,E]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (G){\"use strict\";var q,v=[],x=!1,z=!1,j=\"\",C=@toLength(0),F=@newPromiseCapability(@Promise),A=!1;return q={start(){},write(_){if(typeof _===\"string\"){var w=@toLength(_.length);if(w>0)j+=_,x=!0,C+=w;return w}if(!_||!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const E=@toLength(_.byteLength);if(E>0)if(z=!0,j.length>0)@arrayPush(v,j,_),j=\"\";else @arrayPush(v,_);return C+=E,E},flush(){return 0},end(){if(A)return\"\";return q.fulfill()},fulfill(){A=!0;const _=q.finishInternal();return @fulfillPromise(F.@promise,_),_},finishInternal(){if(!x&&!z)return\"\";if(x&&!z)return j;if(z&&!x)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(v));var _=new @Bun.ArrayBufferSink;_.start({highWaterMark:C,asUint8Array:!0});for(let w of v)_.write(w);if(v.length=0,j.length>0)_.write(j),j=\"\";return new globalThis.TextDecoder().decode(_.end())},close(){try{if(!A)A=!0,q.fulfill()}catch(_){}}},[q,F]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (m,p){\"use strict\";var[_,b]=@createTextStream(p),f={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,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,_){\"use strict\";var p=[],b=@newPromiseCapability(@Promise),d=!1;function m(){return d=!0,b.@resolve.@call(@undefined,p),p}var j={start(){},write(v){return @arrayPush(p,v),v.byteLength||v.length},flush(){return 0},end(){if(d)return[];return m()},close(){if(!d)m()}},q={@underlyingSource:t,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:j,close:@onCloseDirectStream,write:j.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 (m,v){\"use strict\";var _=[],b=@newPromiseCapability(@Promise),t=!1;function d(){return t=!0,b.@resolve.@call(@undefined,_),_}var j={start(){},write(p){return @arrayPush(_,p),p.byteLength||p.length},flush(){return 0},end(){if(t)return[];return d()},close(){if(!t)d()}},q={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:j,close:@onCloseDirectStream,write:j.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; @@ -1668,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 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"; +const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (w,m){\"use strict\";var D=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},_=new @Bun.ArrayBufferSink;_.start(D);var b={@underlyingSource:w,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write.bind(_),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; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const h=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (c,f){\"use strict\";@assert(@isReadableStream(c)),@assert(@getByIdDirectPrivate(c,\"state\")===@streamReadable),@putByIdDirectPrivate(c,\"state\",@streamErrored),@putByIdDirectPrivate(c,\"storedError\",f);const _=@getByIdDirectPrivate(c,\"reader\");if(!_)return;if(@isReadableStreamDefaultReader(_)){const n=@getByIdDirectPrivate(_,\"readRequests\");@putByIdDirectPrivate(_,\"readRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}else{@assert(@isReadableStreamBYOBReader(_));const n=@getByIdDirectPrivate(_,\"readIntoRequests\");@putByIdDirectPrivate(_,\"readIntoRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}@getByIdDirectPrivate(_,\"closedPromiseCapability\").@reject.@call(@undefined,f);const h=@getByIdDirectPrivate(_,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1708,7 +1708,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 283; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\"),g=@getByIdDirectPrivate(d,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const g=@getByIdDirectPrivate(i,\"controlledReadableStream\"),d=@getByIdDirectPrivate(g,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; // readableStreamReaderGenericCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1716,7 +1716,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 133; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,h){\"use strict\";const i=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,h)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (h,i){\"use strict\";const c=@getByIdDirectPrivate(h,\"ownerReadableStream\");return @assert(!!c),@readableStreamCancel(c,i)})\n"; // readableStreamCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (_,d){\"use strict\";@putByIdDirectPrivate(_,\"disturbed\",!0);const h=@getByIdDirectPrivate(_,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));@readableStreamClose(_);var p=@getByIdDirectPrivate(_,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,d).@then(function(){});var i=p.close;if(i)return @Promise.@resolve(p.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,d){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const h=@getByIdDirectPrivate(i,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var _=@getByIdDirectPrivate(i,\"readableStreamController\"),p=_.@cancel;if(p)return p(_,d).@then(function(){});var u=_.close;if(u)return @Promise.@resolve(_.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1740,7 +1740,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 519; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var d=@getByIdDirectPrivate(a,\"queue\");if(d.content.isNotEmpty()){const _=@dequeueValue(d);if(@getByIdDirectPrivate(a,\"closeRequested\")&&d.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:_,done:!1})}const f=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),f})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const f=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:f,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),d})\n"; // readableStreamDefaultControllerClose const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var i=d.shift();i;i=d.shift())@fulfillPromise(i,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1764,7 +1764,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadReq const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 157; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (p,y,_){\"use strict\";const i=@getByIdDirectPrivate(@getByIdDirectPrivate(p,\"reader\"),\"readRequests\").shift();@fulfillPromise(i,{value:y,done:_})})\n"; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,p,y){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:p,done:y})})\n"; // readableStreamDefaultControllerEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,D){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,D,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let d=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)d=@getByIdDirectPrivate(_,\"strategy\").size(D);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),D,d)}catch(d){throw @readableStreamDefaultControllerError(_,d),d}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (y){\"use strict\";const i=@getByIdDirectPrivate(y,\"ownerReadableStream\");@assert(!!i);const n=@getByIdDirectPrivate(i,\"state\");if(@putByIdDirectPrivate(i,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(i,\"readableStreamController\").@pull(@getByIdDirectPrivate(i,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,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 (P,F){\"use strict\";var L=@getByIdDirectPrivate(P,\"bunNativeType\"),G=@getByIdDirectPrivate(P,\"bunNativePtr\"),H=@lazyStreamPrototypeMap.@get(L);if(H===@undefined){let j=function(B){var{c:p,v:z}=this;this.c=@undefined,this.v=@undefined,W(B,p,z)},Z=function(B){try{B.close()}catch(p){globalThis.reportError(p)}},_=function(B,p,z,A){A[0]=!1;var D;try{D=b(B,z,A)}catch(E){return p.error(E)}return W(D,p,z)};var f=j,O=Z,m=_,[b,I,M,q,J,N,Q]=@lazyLoad(L),U=[!1],W;W=function B(p,z,A){if(p&&@isPromise(p))return p.then(j.bind({c:z,v:A}),(D)=>z.error(D));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(U[0]||p===!1)@enqueueJob(Z,z),U[0]=!1};const y=J\?new FinalizationRegistry(J):null;H=class B{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=(D)=>{D.enqueue(A)};if(y)y.register(this,p,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=I;#j(p){var z=this.#f;if(!z){p.close();return}_(z,p,p.byobRequest.view,U)}#m(p){var z=this.#f;y&&y.unregister(this.#b),N&&N(z,!1),M(z,p)}static deinit=J;static drain=Q},@lazyStreamPrototypeMap.@set(L,H)}const X=H.startSync(G,F);var Y;const{drain:x,deinit:K}=H;if(x)Y=x(G);if(X===0){if(J&&G&&@enqueueJob(J,G),(Y\?.byteLength\?\?0)>0)return{start(j){j.enqueue(Y),j.close()},type:\"bytes\"};return{start(j){j.close()},type:\"bytes\"}}return new H(G,X,Y)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (J,P){\"use strict\";var G=@getByIdDirectPrivate(J,\"bunNativeType\"),B=@getByIdDirectPrivate(J,\"bunNativePtr\"),x=@lazyStreamPrototypeMap.@get(G);if(x===@undefined){let q=function(m){var{c:b,v:f}=this;this.c=@undefined,this.v=@undefined,I(m,b,f)},N=function(m){try{m.close()}catch(b){globalThis.reportError(b)}},O=function(m,b,f,j){j[0]=!1;var y;try{y=Q(m,f,j)}catch(Y){return b.error(Y)}return I(y,b,f)};var z=q,A=N,p=O,[Q,U,W,Z,D,K,X]=@lazyLoad(G),H=[!1],I;I=function m(b,f,j){if(b&&@isPromise(b))return b.then(q.bind({c:f,v:j}),(y)=>f.error(y));else if(typeof b===\"number\")if(j&&j.byteLength===b&&j.buffer===f.byobRequest\?.view\?.buffer)f.byobRequest.respondWithNewView(j);else f.byobRequest.respond(b);else if(b.constructor===@Uint8Array)f.enqueue(b);if(H[0]||b===!1)@enqueueJob(N,f),H[0]=!1};const F=D\?new FinalizationRegistry(D):null;x=class m{constructor(b,f,j){if(this.#f=b,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=f,j!==@undefined)this.start=(y)=>{y.enqueue(j)};if(F)F.register(this,b,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=U;#j(b){var f=this.#f;if(!f){b.close();return}O(f,b,b.byobRequest.view,H)}#m(b){var f=this.#f;F&&F.unregister(this.#b),K&&K(f,!1),W(f,b)}static deinit=D;static drain=X},@lazyStreamPrototypeMap.@set(G,x)}const L=x.startSync(B,P);var E;const{drain:M,deinit:_}=x;if(M)E=M(B);if(L===0){if(D&&B&&@enqueueJob(D,B),(E\?.byteLength\?\?0)>0)return{start(q){q.enqueue(E),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new x(B,L,E)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var b=_.getReader(),g=b.readMany();async function j(p){if(p.done)return[];var f=p.value||[];while(!0){var q=await b.read();if(q.done)break;f=f.concat(q.value)}return f}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (q){\"use strict\";var b=q.getReader(),f=b.readMany();async function g(j){if(j.done)return[];var _=j.value||[];while(!0){var p=await b.read();if(p.done)break;_=_.concat(p.value)}return _}if(f&&@isPromise(f))return f.@then(g);return g(f)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1836,7 +1836,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 214; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (i){\"use strict\";const[_,d]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),h=@readStreamIntoSink(i,_,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (_){\"use strict\";const[h,d]=@createTextStream(@getByIdDirectPrivate(_,\"highWaterMark\")),i=@readStreamIntoSink(_,h,!1);if(i&&@isPromise(i))return @Promise.@resolve(i).@then(d.@promise);return d.@promise})\n"; // readableStreamToArrayBufferDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,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 (O,_){\"use strict\";var q=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var v=@getByIdDirectPrivate(O,\"highWaterMark\");q.start(v\?{highWaterMark:v}:{});var w=@newPromiseCapability(@Promise),A=!1,z=_.pull,B=_.close,C={start(){},close(F){if(!A){if(A=!0,B)B();@fulfillPromise(w.@promise,q.end())}},end(){if(!A){if(A=!0,B)B();@fulfillPromise(w.@promise,q.end())}},flush(){return 0},write:q.write.bind(q)},D=!1;try{const F=z(C);if(F&&@isObject(F)&&@isPromise(F))return async function(G,j,x){while(!A)await x(G);return await j}(C,promise,z);return w.@promise}catch(F){return D=!0,@readableStreamError(O,F),@Promise.@reject(F)}finally{if(!D&&O)@readableStreamClose(O);C=B=q=z=O=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,A){\"use strict\";var j=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var B=@getByIdDirectPrivate(O,\"highWaterMark\");j.start(B\?{highWaterMark:B}:{});var w=@newPromiseCapability(@Promise),q=!1,x=A.pull,v=A.close,z={start(){},close(_){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},end(){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},flush(){return 0},write:j.write.bind(j)},C=!1;try{const _=x(z);if(_&&@isObject(_)&&@isPromise(_))return async function(D,F,G){while(!q)await G(D);return await F}(z,promise,x);return w.@promise}catch(_){return C=!0,@readableStreamError(O,_),@Promise.@reject(_)}finally{if(!C&&O)@readableStreamClose(O);z=v=j=x=O=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var k=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(_){}return k=@undefined,f=@undefined,j.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,h){\"use strict\";const j=@initializeTextStream.@call(_,h,@undefined);var f=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await f.read();if(k.done)break}try{f.releaseLock()}catch(p){}return f=@undefined,_=@undefined,j.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,j){\"use strict\";const k=@initializeArrayStream.@call(_,j,@undefined);j=@undefined;var p=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var q=await p.read();if(q.done)break}try{p.releaseLock()}catch(f){}return p=@undefined,@Promise.@resolve(k.@promise)}catch(f){throw f}finally{_=@undefined,p=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,j){\"use strict\";const p=@initializeArrayStream.@call(f,j,@undefined);j=@undefined;var _=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var q=await _.read();if(q.done)break}try{_.releaseLock()}catch(k){}return _=@undefined,@Promise.@resolve(p.@promise)}catch(k){throw k}finally{f=@undefined,_=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,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 (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"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (i){\"use strict\";var B=globalThis.Symbol.asyncIterator,w=async function*x(k,G){var z=k.getReader(),g;try{while(!0){var j,q;const h=z.readMany();if(@isPromise(h))({done:j,value:q}=await h);else({done:j,value:q}=h);if(j)return;yield*q}}catch(h){g=h}finally{if(z.releaseLock(),!G)k.cancel(g);if(g)throw g}},D=function x(){return w(this,!1)},F=function x({preventCancel:k=!1}={preventCancel:!1}){return w(this,k)};return @Object.@defineProperty(i,B,{value:D}),@Object.@defineProperty(i,\"values\",{value:F}),i})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1894,7 +1894,7 @@ const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeCons const JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 339; static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),i=@getByIdDirectPrivate(_,\"readable\"),u=@getByIdDirectPrivate(i,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(u)})\n"; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),u=@getByIdDirectPrivate(_,\"readable\"),i=@getByIdDirectPrivate(u,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(i)})\n"; // enqueue const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1986,7 +1986,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const u=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(u){const f=u.@call(n,\"string\");if(typeof f===\"string\")switch(@argumentCount()){case 1:return new @Buffer(f);case 2:return new @Buffer(f,@argument(1));default:return new @Buffer(f,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; // isBuffer const JSC::ConstructAbility s_jsBufferConstructorIsBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2028,7 +2028,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 S=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!S)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const k=@getByIdDirectPrivate(S,\"state\");if(@putByIdDirectPrivate(S,\"disturbed\",!0),k===@streamClosed)return{value:[],size:0,done:!0};else if(k===@streamErrored)throw @getByIdDirectPrivate(S,\"storedError\");var G=@getByIdDirectPrivate(S,\"readableStreamController\"),x=@getByIdDirectPrivate(G,\"queue\");if(!x)return G.@pull(G).@then(function({done:K,value:B}){return K\?{done:!0,value:[],size:0}:{value:[B],size:1,done:!1}});const C=x.content;var _=x.size,E=C.toArray(!1),I=E.length;if(I>0){var D=@newArrayWithSize(I);if(@isReadableByteStreamController(G)){{const K=E[0];if(!(@ArrayBuffer.@isView(K)||K instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(K.buffer,K.byteOffset,K.byteLength));else @putByValDirect(D,0,K)}for(var J=1;J{if(K.done)return{value:[],size:0,done:!0};var B=@getByIdDirectPrivate(S,\"readableStreamController\"),F=@getByIdDirectPrivate(B,\"queue\"),N=[K.value].concat(F.content.toArray(!1)),j=N.length;if(@isReadableByteStreamController(B))for(var H=0;H0){var D=@newArrayWithSize(C);if(@isReadableByteStreamController(B)){{const _=x[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(D,0,_)}for(var d=1;d{if(_.done)return{value:[],size:0,done:!0};var w=@getByIdDirectPrivate(j,\"readableStreamController\"),G=@getByIdDirectPrivate(w,\"queue\"),k=[_.value].concat(G.content.toArray(!1)),K=k.length;if(@isReadableByteStreamController(w))for(var A=0;A0}shift(){var{_head:x,_tail:g,_list:M,_capacityMask:z}=this;if(x===g)return @undefined;var A=M[x];if(@putByValDirect(M,x,@undefined),x=this._head=x+1&z,x<2&&g>1e4&&g<=M.length>>>2)this._shrinkArray();return A}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(x){var g=this._tail;if(@putByValDirect(this._list,g,x),this._tail=g+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(x){var g=this._list,M=@toLength(g.length);if(x||this._head>this._tail){var z=@toLength(this._head),A=@toLength(this._tail),B=@toLength(M-z+A),E=@newArrayWithSize(B),v=0;for(var F=z;F>>=1,this._capacityMask>>>=1}}return new w})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var E=@Array.prototype.slice;class A{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:g,_tail:b,_list:x,_capacityMask:M}=this;if(g===b)return @undefined;var w=x[g];if(@putByValDirect(x,g,@undefined),g=this._head=g+1&M,g<2&&b>1e4&&b<=x.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(g){var b=this._tail;if(@putByValDirect(this._list,b,g),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(g){var b=this._list,x=@toLength(b.length);if(g||this._head>this._tail){var M=@toLength(this._head),w=@toLength(this._tail),F=@toLength(x-M+w),z=@newArrayWithSize(F),B=0;for(var v=M;v>>=1,this._capacityMask>>>=1}}return new A})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2158,7 +2158,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 (d,o,n){\"use strict\";if(n=@toNumber(n),!@isFinite(n)||n<0)@throwRangeError(\"size has an incorrect value\");d.content.push({value:o,size:n}),d.size+=n})\n"; // peekQueueValue const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2182,7 +2182,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 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"; +const char* const s_streamInternalsExtractSizeAlgorithmCode = "(function (p){\"use strict\";const d=p.size;if(d===@undefined)return()=>1;if(typeof d!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(w)=>{return d(w)}})\n"; // extractHighWaterMark const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2190,7 +2190,7 @@ const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorK const JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsExtractHighWaterMarkCodeLength = 188; static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (o,b){\"use strict\";const c=o.highWaterMark;if(c===@undefined)return b;if(@isNaN(c)||c<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(c)})\n"; +const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (b,c){\"use strict\";const o=b.highWaterMark;if(o===@undefined)return c;if(@isNaN(o)||o<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(o)})\n"; // extractHighWaterMarkFromQueuingStrategyInit const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2206,7 +2206,7 @@ const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructo const JSC::ImplementationVisibility s_streamInternalsCreateFulfilledPromiseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsCreateFulfilledPromiseCodeLength = 81; static const JSC::Intrinsic s_streamInternalsCreateFulfilledPromiseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (d){\"use strict\";const n=@newPromise();return @fulfillPromise(n,d),n})\n"; +const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (n){\"use strict\";const d=@newPromise();return @fulfillPromise(d,n),d})\n"; // toDictionary const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (D){\"use strict\";var H=@Loader,_=@createFIFO(),I=D;while(I){var w=H.registry.@get(I);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(I),w=H.registry.@get(I);var L=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),J=H.parseModule(I,L),Q=w.module;if(J&&@isPromise(J)){var T=@getPromiseInternalField(J,@promiseFieldReactionsOrResult),x=@getPromiseInternalField(J,@promiseFieldFlags),U=x&@promiseStateMask;if(U===@promiseStatePending||T&&@isPromise(T))@throwTypeError(`require() async module \"${I}\" is unsupported. use \"await import()\" instead.`);else if(U===@promiseStateRejected){if(!T\?.message)@throwTypeError(`${T+\"\"\?T:\"An error occurred\"} occurred while parsing module \\\"${I}\\\"`);throw T}w.module=Q=T}else if(J&&!Q)w.module=Q=J;@setStateToMax(w,@ModuleLink);var V=Q.dependenciesMap,W=H.requestedModules(Q),X=@newArrayWithSize(W.length);for(var Y=0,Z=W.length;Y=@ModuleLink)I=_.shift()}var G=H.linkAndEvaluateModule(D,@undefined);if(G&&@isPromise(G))@throwTypeError(`require() async module \\\"${D}\\\" is unsupported. use \"await import()\" instead.`);return H.registry.@get(D)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (B){\"use strict\";var D=@Loader,H=@createFIFO(),_=B;while(_){var w=D.registry.@get(_);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(_),w=D.registry.@get(_);var W=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),x=D.parseModule(_,W),z=w.module;if(x&&@isPromise(x)){var J=@getPromiseInternalField(x,@promiseFieldReactionsOrResult),X=@getPromiseInternalField(x,@promiseFieldFlags),Q=X&@promiseStateMask;if(Q===@promiseStatePending||J&&@isPromise(J))@throwTypeError(`require() async module \"${_}\" is unsupported. use \"await import()\" instead.`);else if(Q===@promiseStateRejected){if(!J\?.message)@throwTypeError(`${J+\"\"\?J:\"An error occurred\"} occurred while parsing module \\\"${_}\\\"`);throw J}w.module=z=J}else if(x&&!z)w.module=z=x;@setStateToMax(w,@ModuleLink);var Y=z.dependenciesMap,I=D.requestedModules(z),T=@newArrayWithSize(I.length);for(var F=0,Z=I.length;F=@ModuleLink)_=H.shift()}var V=D.linkAndEvaluateModule(B,@undefined);if(V&&@isPromise(V))@throwTypeError(`require() async module \\\"${B}\\\" is unsupported. use \"await import()\" instead.`);return D.registry.@get(B)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -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"; +const char* const s_importMetaObjectRequireESMCode = "(function (c){\"use strict\";var a=@Loader.registry.@get(c);if(!a||!a.evaluated)a=@loadCJS2ESM(c);if(!a||!a.evaluated||!a.module)@throwTypeError(`require() failed to evaluate module \"${c}\". This is an internal consistentency error.`);var _=@Loader.getModuleNamespaceObject(a.module);if(_[@commonJSSymbol]===0)return;return _})\n"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -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(),n=JSON.parse(k.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}else if(j===\".node\"){const q=@createCommonJSModule(b,{},!0);return process.dlopen(q,b),@requireMap.@set(b,q),q.exports}else if(j===\".toml\"){var k=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),n=@Bun.TOML.parse(k.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}else{var n=@requireESM(b);const v=@requireMap.@get(b);if(v)return v.exports;var _=n\?.default;if(_\?.[@commonJSSymbol]===0)n=_;return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}})\n"; +const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var n=@requireMap.@get(_);const g=_.substring(_.length-5);if(n)return n.exports;if(g===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else if(g===\".node\"){const k=@createCommonJSModule(_,{},!0);return process.dlopen(k,_),@requireMap.@set(_,k),k.exports}else if(g===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else{var b=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var q=b\?.default;if(q\?.[@commonJSSymbol]===0)b=q;return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2256,7 +2256,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,f={};return new Proxy(f,{get(h,t){const u=@requireMap.@get(t);if(u)return u;const L=@Loader.registry.@get(t);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(t,c,!0);return @requireMap.@set(t,g),g}return f[t]},set(h,t,u){return @requireMap.@set(t,u),!0},has(h,t){return @requireMap.@has(t)||@Loader.registry.@has(t)},deleteProperty(h,t){return _.@delete(t),@requireMap.@delete(t),@Loader.registry.@delete(t),!0},ownKeys(h){var t=[...@requireMap.@keys()];const u=[...@Loader.registry.@keys()];for(let L of u)if(!t.includes(L))@arrayPush(t,L);return t},getPrototypeOf(h){return null},getOwnPropertyDescriptor(h,t){if(@requireMap.@has(t)||@Loader.registry.@has(t))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var c=new Map,L={};return new Proxy(L,{get(f,_){const h=@requireMap.@get(_);if(h)return h;const t=@Loader.registry.@get(_);if(t\?.evaluated){const u=@Loader.getModuleNamespaceObject(t.module),g=u[@commonJSSymbol]===0||u.default\?.[@commonJSSymbol]\?u.default:u,b=@createCommonJSModule(_,g,!0);return @requireMap.@set(_,b),b}return L[_]},set(f,_,h){return @requireMap.@set(_,h),!0},has(f,_){return @requireMap.@has(_)||@Loader.registry.@has(_)},deleteProperty(f,_){return c.@delete(_),@requireMap.@delete(_),@Loader.registry.@delete(_),!0},ownKeys(f){var _=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let t of h)if(!_.includes(t))@arrayPush(_,t);return _},getPrototypeOf(f){return null},getOwnPropertyDescriptor(f,_){if(@requireMap.@has(_)||@Loader.registry.@has(_))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2440,7 +2440,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,I=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!I){const _=@getByIdDirectPrivate(m,\"size\"),b=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,b!==@undefined\?b:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(I){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,_);if(b)@createReadableStreamController(this,b,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const B=_.type===\"direct\",b=!!_.@lazy,I=B||b;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!I){const v=@getByIdDirectPrivate(f,\"size\"),m=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",m),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,v,m!==@undefined\?m:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(B)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(I){const v=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",v||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const m=@lazyLoadStream(this,v);if(m)@createReadableStreamController(this,m,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2448,7 +2448,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorK const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayCodeLength = 173; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayCode = "(function (b){\"use strict\";var _=@getByIdDirectPrivate(b,\"underlyingSource\");if(_!==@undefined)return @readableStreamToArrayDirect(b,_);return @readableStreamIntoArray(b)})\n"; +const char* const s_readableStreamReadableStreamToArrayCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayDirect(_,b);return @readableStreamIntoArray(_)})\n"; // readableStreamToText const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2464,7 +2464,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2488,7 +2488,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 (w,x,A){\"use strict\";const B=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var j=globalThis[B];if(!j)j=globalThis[B]=[];var I=j[x];if(I===@undefined){var[k,J,K,L,G,_]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](x);I=class H{handleError;handleClosed;processResult;constructor(D,N){this.#_=N,this.#F=D,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),D.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var D=this.#_;this.#_=0,L(D),_(D)}_handleError(D){if(this.#$)return;this.#$=!0;var N=this.#_;this.#_=0,J(N,D),_(N)}#_;#$=!1;#F;_handleReadMany({value:D,done:N,size:q}){if(N){this.handleClosed();return}if(this.#$)return;K(this.#_,D,N,q)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(D){if(D&&@isPromise(D)){if(@getPromiseInternalField(D,@promiseFieldFlags)&@promiseStateFulfilled){const q=@getPromiseInternalField(D,@promiseFieldReactionsOrResult);if(q)D=q}}if(D&&@isPromise(D))return D.then(this.processResult,this.handleError),null;if(D.done)return this.handleClosed(),0;else if(D.value)return D.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const F=x+1;if(j.length{@putByIdDirectPrivate(d,\"started\",1),@assert(!@getByIdDirectPrivate(d,\"pulling\")),@assert(!@getByIdDirectPrivate(d,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(d)},(f)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(d,f)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (b,p,R){\"use strict\";if(!@isReadableStream(b))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(b,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",b),@putByIdDirectPrivate(this,\"underlyingByteSource\",p),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let f=@toNumber(R);if(@isNaN(f)||f<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",f);let _=p.autoAllocateChunkSize;if(_!==@undefined){if(_=@toNumber(_),_<=0||_===@Infinity||_===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",_),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const v=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(v,\"underlyingByteSource\"),\"start\",[v]).@then(()=>{@putByIdDirectPrivate(v,\"started\",1),@assert(!@getByIdDirectPrivate(v,\"pulling\")),@assert(!@getByIdDirectPrivate(v,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(v)},(d)=>{if(@getByIdDirectPrivate(b,\"state\")===@streamReadable)@readableByteStreamControllerError(v,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2684,7 +2684,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var _=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=_.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2716,7 +2716,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 272; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const d=@getByIdDirectPrivate(u,\"controlledReadableStream\"),_=@getByIdDirectPrivate(d,\"state\");if(_===@streamErrored)return null;if(_===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const _=@getByIdDirectPrivate(u,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; // readableStreamHasBYOBReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2724,7 +2724,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBRea const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 125; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (n){\"use strict\";const u=@getByIdDirectPrivate(n,\"reader\");return u!==@undefined&&@isReadableStreamBYOBReader(u)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (u){\"use strict\";const n=@getByIdDirectPrivate(u,\"reader\");return n!==@undefined&&@isReadableStreamBYOBReader(n)})\n"; // readableStreamHasDefaultReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2732,7 +2732,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefault const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength = 128; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (l){\"use strict\";const n=@getByIdDirectPrivate(l,\"reader\");return n!==@undefined&&@isReadableStreamDefaultReader(n)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (n){\"use strict\";const l=@getByIdDirectPrivate(n,\"reader\");return l!==@undefined&&@isReadableStreamDefaultReader(l)})\n"; // readableByteStreamControllerHandleQueueDrain const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const h=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(h)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const F=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=F.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let P;try{P=new @Uint8Array(F.buffer,F.byteOffset,F.byteLength)}catch(R){return @Promise.@reject(R)}return @createFulfilledPromise({value:P,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let F;try{F=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(R){return @Promise.@reject(R)}const P={buffer:F,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(P)}const d=@readableStreamAddReadRequest(h);return @readableByteStreamControllerCallPullIfNeeded(_),d})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const P=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(P)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const d=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=d.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let h;try{h=new @Uint8Array(d.buffer,d.byteOffset,d.byteLength)}catch(F){return @Promise.@reject(F)}return @createFulfilledPromise({value:h,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let d;try{d=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(F){return @Promise.@reject(F)}const h={buffer:d,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(h)}const R=@readableStreamAddReadRequest(P);return @readableByteStreamControllerCallPullIfNeeded(_),R})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2788,7 +2788,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1076; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,_){\"use strict\";const f=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(f,\"state\")===@streamReadable),@getByIdDirectPrivate(f,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(f,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(f,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const d=_.constructor===@Uint8Array\?_:new @Uint8Array(_.buffer,_.byteOffset,_.byteLength);@readableStreamFulfillReadRequest(f,d,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(f)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength);break}}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (d,i){\"use strict\";const _=@getByIdDirectPrivate(d,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(d,\"closeRequested\")),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@getByIdDirectPrivate(_,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(_,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);else{@assert(!@getByIdDirectPrivate(d,\"queue\").content.size());const f=i.constructor===@Uint8Array\?i:new @Uint8Array(i.buffer,i.byteOffset,i.byteLength);@readableStreamFulfillReadRequest(_,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength),@readableByteStreamControllerProcessPullDescriptors(d);break}case 3:break;default:{@assert(!@isReadableStreamLocked(_)),@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);break}}})\n"; // readableByteStreamControllerEnqueueChunk const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2796,7 +2796,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,d,p){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:d,byteLength:p}),@getByIdDirectPrivate(_,\"queue\").size+=p})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,d,p,a){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:d,byteOffset:p,byteLength:a}),@getByIdDirectPrivate(_,\"queue\").size+=a})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2804,7 +2804,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 417; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (u,a){\"use strict\";@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty());let d=@getByIdDirectPrivate(u,\"pendingPullIntos\").peek();if(d.byteOffset+d.bytesFilled!==a.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(d.byteLength!==a.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");d.buffer=a.buffer,@readableByteStreamControllerRespondInternal(u,a.byteLength)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (d,u){\"use strict\";@assert(@getByIdDirectPrivate(d,\"pendingPullIntos\").isNotEmpty());let a=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek();if(a.byteOffset+a.bytesFilled!==u.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(a.byteLength!==u.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");a.buffer=u.buffer,@readableByteStreamControllerRespondInternal(d,u.byteLength)})\n"; // readableByteStreamControllerRespond const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2812,7 +2812,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength = 251; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (u,I){\"use strict\";if(I=@toNumber(I),@isNaN(I)||I===@Infinity||I<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(u,I)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (I,u){\"use strict\";if(u=@toNumber(u),@isNaN(u)||u===@Infinity||u<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(I,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(I,u)})\n"; // readableByteStreamControllerRespondInternal const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2828,7 +2828,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (f,R,w){\"use strict\";if(w.bytesFilled+R>w.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(f,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(f,\"pendingPullIntos\").peek()===w),@readableByteStreamControllerInvalidateBYOBRequest(f),w.bytesFilled+=R,w.bytesFilled0){const g=w.byteOffset+w.bytesFilled,h=@cloneArrayBuffer(w.buffer,g-_,_);@readableByteStreamControllerEnqueueChunk(f,h,0,h.byteLength)}w.buffer=@transferBufferToCurrentRealm(w.buffer),w.bytesFilled-=_,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(f,\"controlledReadableStream\"),w),@readableByteStreamControllerProcessPullDescriptors(f)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,_,f){\"use strict\";if(f.bytesFilled+_>f.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===f),@readableByteStreamControllerInvalidateBYOBRequest(w),f.bytesFilled+=_,f.bytesFilled0){const h=f.byteOffset+f.bytesFilled,g=@cloneArrayBuffer(f.buffer,h-R,R);@readableByteStreamControllerEnqueueChunk(w,g,0,g.byteLength)}f.buffer=@transferBufferToCurrentRealm(f.buffer),f.bytesFilled-=R,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),f),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2852,7 +2852,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 (_,q){\"use strict\";const z=q.bytesFilled-q.bytesFilled%q.elementSize,j=@getByIdDirectPrivate(_,\"queue\").sizez)G=k-q.bytesFilled,v=!0;while(G>0){let H=@getByIdDirectPrivate(_,\"queue\").content.peek();const w=G0),@assert(q.bytesFilledH)v=G-_.bytesFilled,w=!0;while(v>0){let j=@getByIdDirectPrivate(q,\"queue\").content.peek();const k=v0),@assert(_.bytesFilled<_.elementSize);return w})\n"; // readableByteStreamControllerShiftPendingDescriptor const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2892,7 +2892,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamFulfillRea const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength = 161; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode = "(function (l,p,_){\"use strict\";const i=@getByIdDirectPrivate(@getByIdDirectPrivate(l,\"reader\"),\"readIntoRequests\").shift();@fulfillPromise(i,{value:p,done:_})})\n"; +const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode = "(function (l,i,p){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(l,\"reader\"),\"readIntoRequests\").shift();@fulfillPromise(_,{value:i,done:p})})\n"; // readableStreamBYOBReaderRead const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2900,7 +2900,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReader const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength = 356; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = "(function (o,c){\"use strict\";const l=@getByIdDirectPrivate(o,\"ownerReadableStream\");if(@assert(!!l),@putByIdDirectPrivate(l,\"disturbed\",!0),@getByIdDirectPrivate(l,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(l,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(l,\"readableStreamController\"),c)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = "(function (c,l){\"use strict\";const o=@getByIdDirectPrivate(c,\"ownerReadableStream\");if(@assert(!!o),@putByIdDirectPrivate(o,\"disturbed\",!0),@getByIdDirectPrivate(o,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(o,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(o,\"readableStreamController\"),l)})\n"; // readableByteStreamControllerPullInto const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2908,7 +2908,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength = 1255; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (_,E){\"use strict\";const b=@getByIdDirectPrivate(_,\"controlledReadableStream\");let d=1;if(E.BYTES_PER_ELEMENT!==@undefined)d=E.BYTES_PER_ELEMENT;const k=E.constructor,A={buffer:E.buffer,byteOffset:E.byteOffset,byteLength:E.byteLength,bytesFilled:0,elementSize:d,ctor:k,readerType:\"byob\"};var L=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(L\?.isNotEmpty())return A.buffer=@transferBufferToCurrentRealm(A.buffer),L.push(A),@readableStreamAddReadIntoRequest(b);if(@getByIdDirectPrivate(b,\"state\")===@streamClosed){const R=new k(A.buffer,A.byteOffset,0);return @createFulfilledPromise({value:R,done:!0})}if(@getByIdDirectPrivate(_,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(_,A)){const R=@readableByteStreamControllerConvertDescriptor(A);return @readableByteStreamControllerHandleQueueDrain(_),@createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(_,\"closeRequested\")){const R=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(_,R),@Promise.@reject(R)}}A.buffer=@transferBufferToCurrentRealm(A.buffer),@getByIdDirectPrivate(_,\"pendingPullIntos\").push(A);const N=@readableStreamAddReadIntoRequest(b);return @readableByteStreamControllerCallPullIfNeeded(_),N})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (b,d){\"use strict\";const A=@getByIdDirectPrivate(b,\"controlledReadableStream\");let E=1;if(d.BYTES_PER_ELEMENT!==@undefined)E=d.BYTES_PER_ELEMENT;const L=d.constructor,_={buffer:d.buffer,byteOffset:d.byteOffset,byteLength:d.byteLength,bytesFilled:0,elementSize:E,ctor:L,readerType:\"byob\"};var N=@getByIdDirectPrivate(b,\"pendingPullIntos\");if(N\?.isNotEmpty())return _.buffer=@transferBufferToCurrentRealm(_.buffer),N.push(_),@readableStreamAddReadIntoRequest(A);if(@getByIdDirectPrivate(A,\"state\")===@streamClosed){const k=new L(_.buffer,_.byteOffset,0);return @createFulfilledPromise({value:k,done:!0})}if(@getByIdDirectPrivate(b,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,_)){const k=@readableByteStreamControllerConvertDescriptor(_);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}_.buffer=@transferBufferToCurrentRealm(_.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(_);const R=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(b),R})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2942,7 +2942,7 @@ const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructor const JSC::ImplementationVisibility s_writableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamDefaultControllerErrorCodeLength = 301; static const JSC::Intrinsic s_writableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamDefaultControllerErrorCode = "(function (t){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const r=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(r,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(this,t)})\n"; +const char* const s_writableStreamDefaultControllerErrorCode = "(function (r){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const t=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(t,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(this,r)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2960,7 +2960,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 F 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,Y){const O=W.data,Z=O.#L\?`Last-Event-ID: ${O.#L}\\r\\n`:\"\",j=`GET ${Y.pathname}${Y.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${Z}\\r\\n`,G=W.write(j);if(G!==j.length)O.#K=j.substring(G)}static#Y(W,Y,O){for(;;){if(O>=Y.length)return;let Z=-1,j=Y.indexOf(\"\\r\\n\",O);const G=j+2;if(j>0)if(W.#O===0){const w=parseInt(Y.substring(O,j),16);if(w===0){W.#j=2,W.#G\?.end();return}Z=G+w}else Z=Y.length;else{if(W.#J.length===0){W.#J+=Y.substring(O);return}Z=Y.length}let z=Y.substring(G,Z);O=Z+2;let B=0,J=z.indexOf(\"\\n\\n\");if(J==-1){W.#J+=Y.substring(G);return}if(W.#J.length)W.#J+=z,z=W.#J,W.#J=\"\";let K=!0;while(K){const w=z.substring(B,J);let Q,L=\"\",X,A=0,U=-1;for(;;){let V=w.indexOf(\"\\n\",A);if(V===-1){if(A>=w.length)break;V=w.length}const H=w.substring(A,V);if(H.startsWith(\"data:\"))if(L.length)L+=`\\n${H.substring(5).trim()}`;else L=H.substring(5).trim();else if(H.startsWith(\"event:\"))Q=H.substring(6).trim();else if(H.startsWith(\"id:\"))X=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(U=parseInt(H.substring(6).trim(),10),@isNaN(U))U=-1}A=V+1}if(W.#L=X||\"\",U>=0)W.#U=U;if(L||X||Q)W.dispatchEvent(new MessageEvent(Q||\"message\",{data:L||\"\",origin:W.#$.origin,source:W,lastEventId:X}));if(z.length===J+2){K=!1;break}const M=z.indexOf(\"\\n\\n\",J+1);if(M===-1)break;B=J,J=M}}}static#Z={open(W){const Y=W.data;if(Y.#G=W,!Y.#F)F.#X(W,Y.#$)},handshake(W,Y,O){const Z=W.data;if(Y)F.#X(W,Z.#$);else Z.#j=2,Z.dispatchEvent(new ErrorEvent(\"error\",{error:O})),W.end()},data(W,Y){const O=W.data;switch(O.#j){case 0:{let Z=Y.toString();const j=Z.indexOf(\"\\r\\n\\r\\n\");if(j===-1){O.#J+=Z;return}if(O.#J.length)O.#J+=Z,Z=O.#J,O.#J=\"\";const G=Z.substring(0,j),z=G.indexOf(\"\\r\\n\");if(z===-1){O.#j=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),W.end();return}const B=G.substring(0,z);if(B!==\"HTTP/1.1 200 OK\"){O.#j=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(B)})),W.end();return}let J=z+1,K=!1,w=-1;for(;;){let L=G.indexOf(\"\\r\\n\",J);if(L===-1){if(J>=G.length){if(!K)O.#j=2,O.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}L=G.length}const X=G.substring(J+1,L),A=X.indexOf(\":\"),U=X.substring(0,A),M=U.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(J=L+1,M)if(X.endsWith(\" text/event-stream\"))K=!0;else{O.#j=2,O.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(U.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(w=parseInt(X.substring(A+1).trim(),10),@isNaN(w)||w<=0){O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),W.end();return}if(K)break}else if(U.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(X.substring(A+1).trim()!==\"chunked\"){O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),W.end();return}if(w=0,K)break}}O.#O=w,O.#j=1,O.dispatchEvent(new Event(\"open\"));const Q=Z.substring(j+4);if(F.#Y(O,Q,0),O.#O>0){if(O.#Q+=Q.length,O.#Q>=O.#O)O.#j=2,W.end()}return}case 1:if(F.#Y(O,Y.toString(),2),O.#O>0){if(O.#Q+=Y.byteLength,O.#Q>=O.#O)O.#j=2,W.end()}return;default:break}},drain(W){const Y=W.data;if(Y.#j===0){const O=Y.#J;if(O.length){const Z=W.write(O);if(Z!==O.length)W.data.#K=O.substring(Z);else W.data.#K=\"\"}}},close:F.#z,end(W){F.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(W){F.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(W){const Y=W.data;if(Y.#G=null,Y.#Q=0,Y.#j=2,Y.#M){if(Y.#V)clearTimeout(Y.#V);Y.#V=setTimeout(F.#W,Y.#U,Y)}return Y}constructor(W,Y=@undefined){super();const O=new URL(W);this.#F=O.protocol===\"https:\",this.#$=O,this.#j=2,process.nextTick(F.#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.#$,Y=this.#F;this.#j=0,@Bun.connect({data:this,socket:F.#Z,hostname:W.hostname,port:parseInt(W.port||(Y\?\"443\":\"80\"),10),tls:Y\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((O)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:O})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(F.#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(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class F extends EventTarget{#B;#$;#J;#K;#L;#M=!1;#A=null;#j=\"\";#O=\"\";#Q=\"\";#U=!0;#F=0;#G=0;#X=0;#w=null;static#V(j){j.#H()}static#Y(j,A){const w=j.data,B=w.#Q\?`Last-Event-ID: ${w.#Q}\\r\\n`:\"\",K=`GET ${A.pathname}${A.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${B}\\r\\n`,G=j.write(K);if(G!==K.length)w.#O=K.substring(G)}static#Z(j,A,w){for(;;){if(w>=A.length)return;let B=-1,K=A.indexOf(\"\\r\\n\",w);const G=K+2;if(K>0)if(j.#F===0){const J=parseInt(A.substring(w,K),16);if(J===0){j.#$=2,j.#A\?.end();return}B=G+J}else B=A.length;else{if(j.#j.length===0){j.#j+=A.substring(w);return}B=A.length}let M=A.substring(G,B);w=B+2;let Z=0,L=M.indexOf(\"\\n\\n\");if(L==-1){j.#j+=A.substring(G);return}if(j.#j.length)j.#j+=M,M=j.#j,j.#j=\"\";let X=!0;while(X){const J=M.substring(Z,L);let Y,O=\"\",Q,W=0,V=-1;for(;;){let z=J.indexOf(\"\\n\",W);if(z===-1){if(W>=J.length)break;z=J.length}const U=J.substring(W,z);if(U.startsWith(\"data:\"))if(O.length)O+=`\\n${U.substring(5).trim()}`;else O=U.substring(5).trim();else if(U.startsWith(\"event:\"))Y=U.substring(6).trim();else if(U.startsWith(\"id:\"))Q=U.substring(3).trim();else if(U.startsWith(\"retry:\")){if(V=parseInt(U.substring(6).trim(),10),@isNaN(V))V=-1}W=z+1}if(j.#Q=Q||\"\",V>=0)j.#X=V;if(O||Q||Y)j.dispatchEvent(new MessageEvent(Y||\"message\",{data:O||\"\",origin:j.#B.origin,source:j,lastEventId:Q}));if(M.length===L+2){X=!1;break}const H=M.indexOf(\"\\n\\n\",L+1);if(H===-1)break;Z=L,L=H}}}static#z={open(j){const A=j.data;if(A.#A=j,!A.#M)F.#Y(j,A.#B)},handshake(j,A,w){const B=j.data;if(A)F.#Y(j,B.#B);else B.#$=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:w})),j.end()},data(j,A){const w=j.data;switch(w.#$){case 0:{let B=A.toString();const K=B.indexOf(\"\\r\\n\\r\\n\");if(K===-1){w.#j+=B;return}if(w.#j.length)w.#j+=B,B=w.#j,w.#j=\"\";const G=B.substring(0,K),M=G.indexOf(\"\\r\\n\");if(M===-1){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),j.end();return}const Z=G.substring(0,M);if(Z!==\"HTTP/1.1 200 OK\"){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Z)})),j.end();return}let L=M+1,X=!1,J=-1;for(;;){let O=G.indexOf(\"\\r\\n\",L);if(O===-1){if(L>=G.length){if(!X)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.`)})),j.end();return}O=G.length}const Q=G.substring(L+1,O),W=Q.indexOf(\":\"),V=Q.substring(0,W),H=V.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(L=O+1,H)if(Q.endsWith(\" text/event-stream\"))X=!0;else{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.`)})),j.end();return}else if(V.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(J=parseInt(Q.substring(W+1).trim(),10),@isNaN(J)||J<=0){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),j.end();return}if(X)break}else if(V.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(Q.substring(W+1).trim()!==\"chunked\"){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),j.end();return}if(J=0,X)break}}w.#F=J,w.#$=1,w.dispatchEvent(new Event(\"open\"));const Y=B.substring(K+4);if(F.#Z(w,Y,0),w.#F>0){if(w.#G+=Y.length,w.#G>=w.#F)w.#$=2,j.end()}return}case 1:if(F.#Z(w,A.toString(),2),w.#F>0){if(w.#G+=A.byteLength,w.#G>=w.#F)w.#$=2,j.end()}return;default:break}},drain(j){const A=j.data;if(A.#$===0){const w=A.#j;if(w.length){const B=j.write(w);if(B!==w.length)j.data.#O=w.substring(B);else j.data.#O=\"\"}}},close:F.#W,end(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#W(j){const A=j.data;if(A.#A=null,A.#G=0,A.#$=2,A.#U){if(A.#w)clearTimeout(A.#w);A.#w=setTimeout(F.#V,A.#X,A)}return A}constructor(j,A=@undefined){super();const w=new URL(j);this.#M=w.protocol===\"https:\",this.#B=w,this.#$=2,process.nextTick(F.#V,this)}ref(){this.#w\?.ref(),this.#A\?.ref()}unref(){this.#w\?.unref(),this.#A\?.unref()}#H(){if(this.#$!==2)return;const j=this.#B,A=this.#M;this.#$=0,@Bun.connect({data:this,socket:F.#z,hostname:j.hostname,port:parseInt(j.port||(A\?\"443\":\"80\"),10),tls:A\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((w)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:w})),this.#U){if(this.#w)this.#w.unref\?.();this.#w=setTimeout(F.#V,1000,this)}})}get url(){return this.#B.href}get readyState(){return this.#$}close(){this.#U=!1,this.#$=2,this.#A\?.unref(),this.#A\?.end()}get onopen(){return this.#L}get onerror(){return this.#J}get onmessage(){return this.#K}set onopen(j){if(this.#L)super.removeEventListener(\"close\",this.#L);super.addEventListener(\"open\",j),this.#L=j}set onerror(j){if(this.#J)super.removeEventListener(\"error\",this.#J);super.addEventListener(\"error\",j),this.#J=j}set onmessage(j){if(this.#K)super.removeEventListener(\"message\",this.#K);super.addEventListener(\"message\",j),this.#K=j}}return Object.defineProperty(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index 51825b2b4..890f5032e 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -401,6 +401,33 @@ describe("signal", () => { expect(await child.exited).toBe(0); expect(await new Response(child.stdout).text()).toBe("PASS\n"); }); + + it("process.kill(2) works", async () => { + const child = Bun.spawn({ + cmd: ["bash", "-c", "sleep 1000000"], + stdout: "pipe", + }); + const prom = child.exited; + process.kill(child.pid, "SIGTERM"); + await prom; + expect(child.signalCode).toBe("SIGTERM"); + }); + + it("process._kill(2) works", async () => { + const child = Bun.spawn({ + cmd: ["bash", "-c", "sleep 1000000"], + stdout: "pipe", + }); + const prom = child.exited; + process.kill(child.pid, 9); + await prom; + expect(child.signalCode).toBe("SIGKILL"); + }); + + it("process.kill(2) throws on invalid input", async () => { + expect(() => process.kill(0, "SIGPOOP")).toThrow(); + expect(() => process.kill(0, 456)).toThrow(); + }); }); const undefinedStubs = [ -- cgit v1.2.3 From 34b0e7a2bbd8bf8097341cdb0075d0908283e834 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:06:49 -0700 Subject: Update ZigGlobalObject.cpp --- src/bun.js/bindings/ZigGlobalObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index af0dad4da..91d365af6 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -436,7 +436,7 @@ static String computeErrorInfoWithoutPrepareStackTrace(JSC::VM& vm, Vector